From 7e7c74e71cf4133beed3648f8a05b151e5c9852f Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sat, 20 Apr 2024 19:31:08 +0200 Subject: [PATCH] gnulib-tool-tests: Add test-diffutils-1. --- .../diffutils-20230801/.gitignore | 117 + .../diffutils-20230801/Makefile.am | 58 + .../diffutils-20230801/build-aux/.gitignore | 11 + .../diffutils-20230801/configure.ac | 182 + .../diffutils-20230801/doc/.gitignore | 2 + .../gnulib-tests/.gitignore | 448 ++ .../gnulib-tests/glthread/.gitignore | 2 + .../diffutils-20230801/gnulib-tests/nan.h | 85 + .../gnulib-tests/test-raise.c | 51 + .../gnulib-tests/unicase/.gitignore | 3 + .../gnulib-tests/unictype/.gitignore | 14 + .../gnulib-tests/unistr/.gitignore | 13 + .../gnulib-tests/uniwidth/.gitignore | 3 + .../diffutils-20230801/lib/.gitignore | 344 + .../lib/glthread/.gitignore | 3 + .../diffutils-20230801/lib/malloc/.gitignore | 7 + .../diffutils-20230801/lib/unicase/.gitignore | 3 + .../lib/unictype/.gitignore | 25 + .../diffutils-20230801/lib/unistr/.gitignore | 9 + .../lib/uniwidth/.gitignore | 4 + .../diffutils-20230801/m4/.gitignore | 271 + .../diffutils-20230801/m4/gnulib-cache.m4 | 245 + .../diffutils-20230801/m4/gnulib-comp.m4 | 2831 +++++++ gnulib-tool-tests/import-tests/test-all.sh | 1 + .../import-tests/test-diffutils-1.err | 0 .../import-tests/test-diffutils-1.out | 3066 ++++++++ .../test-diffutils-1.result/.gitignore | 117 + .../test-diffutils-1.result/GNUmakefile | 127 + .../test-diffutils-1.result/Makefile.am | 58 + .../test-diffutils-1.result/README-release | 101 + .../build-aux/.gitignore | 11 + .../build-aux/announce-gen | 704 ++ .../build-aux/config.rpath | 684 ++ .../build-aux/do-release-commit-and-tag | 179 + .../build-aux/gendocs.sh | 524 ++ .../build-aux/git-version-gen | 227 + .../build-aux/gitlog-to-changelog | 516 ++ .../build-aux/gnu-web-doc-update | 216 + .../build-aux/gnupload | 480 ++ .../build-aux/update-copyright | 307 + .../build-aux/useless-if-before-free | 240 + .../build-aux/vc-list-files | 113 + .../test-diffutils-1.result/configure.ac | 182 + .../test-diffutils-1.result/doc/.gitignore | 2 + .../doc/gendocs_template | 103 + .../doc/gendocs_template_min | 108 + .../gnulib-tests/.gitignore | 495 ++ .../gnulib-tests/.gitignore~ | 448 ++ .../gnulib-tests/_Noreturn.h | 50 + .../gnulib-tests/accept.c | 52 + .../gnulib-tests/alloca.c | 167 + .../gnulib-tests/altstack-util.h | 66 + .../gnulib-tests/anytostr.c | 50 + .../gnulib-tests/arg-nonnull.h | 26 + .../gnulib-tests/arpa_inet.in.h | 155 + .../gnulib-tests/asnprintf.c | 34 + .../gnulib-tests/at-func.c | 146 + .../gnulib-tests/atoll.c | 34 + .../gnulib-tests/bind.c | 49 + .../gnulib-tests/c++defs.h | 337 + .../gnulib-tests/c-strcasestr.c | 76 + .../gnulib-tests/c-strcasestr.h | 36 + .../gnulib-tests/c32rtomb.c | 132 + .../gnulib-tests/c32tob.c | 70 + .../gnulib-tests/connect.c | 56 + .../gnulib-tests/dtotimespec.c | 53 + .../gnulib-tests/fdopen.c | 73 + .../gnulib-tests/float+.h | 147 + .../gnulib-tests/float.c | 33 + .../gnulib-tests/float.in.h | 194 + .../gnulib-tests/fpucw.h | 108 + .../gnulib-tests/ftruncate.c | 195 + .../gnulib-tests/glthread/.gitignore | 2 + .../gnulib-tests/glthread/thread.c | 218 + .../gnulib-tests/glthread/thread.h | 346 + .../gnulib-tests/gnulib.mk | 3518 +++++++++ .../gnulib-tests/hash-pjw.c | 40 + .../gnulib-tests/hash-pjw.h | 28 + .../gnulib-tests/imaxtostr.c | 20 + .../gnulib-tests/inet_pton.c | 268 + .../gnulib-tests/infinity.h | 66 + .../gnulib-tests/init.sh | 706 ++ .../gnulib-tests/inttostr.c | 20 + .../gnulib-tests/inttostr.h | 34 + .../gnulib-tests/ioctl.c | 92 + .../gnulib-tests/isnan.c | 190 + .../gnulib-tests/isnand-nolibm.h | 38 + .../gnulib-tests/isnand.c | 19 + .../gnulib-tests/isnanf-nolibm.h | 46 + .../gnulib-tests/isnanf.c | 20 + .../gnulib-tests/isnanl-nolibm.h | 39 + .../gnulib-tests/isnanl.c | 20 + .../gnulib-tests/itold.c | 28 + .../gnulib-tests/listen.c | 49 + .../gnulib-tests/locale.c | 85 + .../gnulib-tests/macros.h | 109 + .../gnulib-tests/math.c | 22 + .../gnulib-tests/math.in.h | 2857 +++++++ .../gnulib-tests/minus-zero.h | 74 + .../gnulib-tests/mmap-anon-util.h | 99 + .../gnulib-tests/nan.h | 97 + .../gnulib-tests/nan.h~ | 85 + .../gnulib-tests/nanosleep.c | 192 + .../gnulib-tests/nap.h | 161 + .../gnulib-tests/netinet_in.in.h | 47 + .../gnulib-tests/offtostr.c | 20 + .../gnulib-tests/perror.c | 49 + .../gnulib-tests/printf-args.c | 306 + .../gnulib-tests/printf-args.h | 205 + .../gnulib-tests/printf-parse.c | 714 ++ .../gnulib-tests/printf-parse.h | 193 + .../gnulib-tests/priv-set.c | 144 + .../gnulib-tests/priv-set.h | 67 + .../gnulib-tests/pselect.c | 118 + .../gnulib-tests/pthread-thread.c | 178 + .../gnulib-tests/pthread.in.h | 2022 +++++ .../gnulib-tests/pthread_sigmask.c | 92 + .../gnulib-tests/putenv.c | 196 + .../gnulib-tests/rmdir.c | 56 + .../gnulib-tests/root-uid.h | 30 + .../gnulib-tests/sched.in.h | 111 + .../gnulib-tests/select.c | 601 ++ .../gnulib-tests/setsockopt.c | 65 + .../gnulib-tests/signature.h | 48 + .../gnulib-tests/signbitd.c | 64 + .../gnulib-tests/signbitf.c | 64 + .../gnulib-tests/signbitl.c | 64 + .../gnulib-tests/signed-nan.h | 88 + .../gnulib-tests/signed-snan.h | 142 + .../gnulib-tests/size_max.h | 35 + .../gnulib-tests/sleep.c | 74 + .../gnulib-tests/snan.h | 276 + .../gnulib-tests/snprintf.c | 71 + .../gnulib-tests/socket.c | 53 + .../gnulib-tests/sockets.c | 161 + .../gnulib-tests/sockets.h | 71 + .../gnulib-tests/str-two-way.h | 452 ++ .../gnulib-tests/strerror_r.c | 454 ++ .../gnulib-tests/symlink.c | 57 + .../gnulib-tests/symlinkat.c | 101 + .../gnulib-tests/sys_ioctl.in.h | 86 + .../gnulib-tests/sys_select.in.h | 346 + .../gnulib-tests/sys_socket.c | 22 + .../gnulib-tests/sys_socket.in.h | 744 ++ .../gnulib-tests/sys_uio.in.h | 63 + .../gnulib-tests/test-accept.c | 56 + .../gnulib-tests/test-alignasof.c | 100 + .../gnulib-tests/test-alloca-opt.c | 62 + .../gnulib-tests/test-argmatch.c | 189 + .../gnulib-tests/test-arpa_inet.c | 27 + .../gnulib-tests/test-assert.c | 72 + .../gnulib-tests/test-binary-io.c | 63 + .../gnulib-tests/test-binary-io.sh | 12 + .../gnulib-tests/test-bind.c | 58 + .../gnulib-tests/test-bitrotate.c | 279 + .../gnulib-tests/test-btoc32-1.sh | 9 + .../gnulib-tests/test-btoc32-2.sh | 15 + .../gnulib-tests/test-btoc32-3.sh | 15 + .../gnulib-tests/test-btoc32.c | 94 + .../gnulib-tests/test-btowc-1.sh | 9 + .../gnulib-tests/test-btowc-2.sh | 15 + .../gnulib-tests/test-btowc-3.sh | 15 + .../gnulib-tests/test-btowc.c | 91 + .../gnulib-tests/test-c-ctype.c | 228 + .../gnulib-tests/test-c-stack.c | 73 + .../gnulib-tests/test-c-stack.sh | 21 + .../gnulib-tests/test-c-stack2.sh | 43 + .../gnulib-tests/test-c-strcase.sh | 21 + .../gnulib-tests/test-c-strcasecmp.c | 68 + .../gnulib-tests/test-c-strcasestr.c | 272 + .../gnulib-tests/test-c-strncasecmp.c | 82 + .../gnulib-tests/test-c32_apply_type_test.c | 170 + .../gnulib-tests/test-c32_get_type_test.c | 73 + .../gnulib-tests/test-c32isalnum.c | 261 + .../gnulib-tests/test-c32isalnum.sh | 42 + .../gnulib-tests/test-c32isalpha.c | 259 + .../gnulib-tests/test-c32isalpha.sh | 42 + .../gnulib-tests/test-c32isblank.c | 205 + .../gnulib-tests/test-c32isblank.sh | 42 + .../gnulib-tests/test-c32iscntrl.c | 212 + .../gnulib-tests/test-c32iscntrl.sh | 42 + .../gnulib-tests/test-c32isdigit.c | 236 + .../gnulib-tests/test-c32isdigit.sh | 42 + .../gnulib-tests/test-c32isgraph.c | 247 + .../gnulib-tests/test-c32isgraph.sh | 42 + .../gnulib-tests/test-c32islower.c | 354 + .../gnulib-tests/test-c32islower.sh | 42 + .../gnulib-tests/test-c32isprint.c | 250 + .../gnulib-tests/test-c32isprint.sh | 42 + .../gnulib-tests/test-c32ispunct.c | 330 + .../gnulib-tests/test-c32ispunct.sh | 42 + .../gnulib-tests/test-c32isspace.c | 198 + .../gnulib-tests/test-c32isspace.sh | 42 + .../gnulib-tests/test-c32isupper.c | 340 + .../gnulib-tests/test-c32isupper.sh | 42 + .../gnulib-tests/test-c32isxdigit.c | 262 + .../gnulib-tests/test-c32isxdigit.sh | 42 + .../gnulib-tests/test-c32rtomb-w32-2.sh | 4 + .../gnulib-tests/test-c32rtomb-w32-3.sh | 4 + .../gnulib-tests/test-c32rtomb-w32-4.sh | 4 + .../gnulib-tests/test-c32rtomb-w32-5.sh | 4 + .../gnulib-tests/test-c32rtomb-w32-6.sh | 4 + .../gnulib-tests/test-c32rtomb-w32-7.sh | 4 + .../gnulib-tests/test-c32rtomb-w32-8.sh | 4 + .../gnulib-tests/test-c32rtomb-w32.c | 349 + .../gnulib-tests/test-c32rtomb.c | 174 + .../gnulib-tests/test-c32rtomb.sh | 42 + .../gnulib-tests/test-c32tolower.c | 440 ++ .../gnulib-tests/test-c32tolower.sh | 45 + .../gnulib-tests/test-c32width.c | 104 + .../gnulib-tests/test-calloc-gnu.c | 73 + .../gnulib-tests/test-chdir.c | 33 + .../gnulib-tests/test-cloexec.c | 152 + .../gnulib-tests/test-close.c | 45 + .../gnulib-tests/test-connect.c | 60 + .../gnulib-tests/test-count-leading-zeros.c | 75 + .../gnulib-tests/test-ctype.c | 27 + .../gnulib-tests/test-dirent.c | 32 + .../gnulib-tests/test-dirfd.c | 47 + .../gnulib-tests/test-dirname.c | 192 + .../gnulib-tests/test-dup-safer.c | 183 + .../gnulib-tests/test-dup.c | 45 + .../gnulib-tests/test-dup2.c | 232 + .../gnulib-tests/test-dynarray.c | 53 + .../gnulib-tests/test-environ.c | 44 + .../gnulib-tests/test-errno.c | 119 + .../gnulib-tests/test-error.c | 89 + .../gnulib-tests/test-error.sh | 36 + .../gnulib-tests/test-exclude.c | 127 + .../gnulib-tests/test-exclude1.sh | 50 + .../gnulib-tests/test-exclude2.sh | 50 + .../gnulib-tests/test-exclude3.sh | 50 + .../gnulib-tests/test-exclude4.sh | 45 + .../gnulib-tests/test-exclude5.sh | 48 + .../gnulib-tests/test-exclude6.sh | 46 + .../gnulib-tests/test-exclude7.sh | 47 + .../gnulib-tests/test-exclude8.sh | 46 + .../gnulib-tests/test-fchdir.c | 110 + .../gnulib-tests/test-fcntl-h.c | 130 + .../gnulib-tests/test-fcntl.c | 444 ++ .../gnulib-tests/test-fdopen.c | 54 + .../gnulib-tests/test-fdopendir.c | 80 + .../gnulib-tests/test-fgetc.c | 101 + .../gnulib-tests/test-filenamecat.c | 86 + .../gnulib-tests/test-float.c | 392 + .../gnulib-tests/test-fnmatch-1.sh | 9 + .../gnulib-tests/test-fnmatch-2.sh | 15 + .../gnulib-tests/test-fnmatch-3.sh | 15 + .../gnulib-tests/test-fnmatch-4.sh | 15 + .../gnulib-tests/test-fnmatch-5.sh | 15 + .../gnulib-tests/test-fnmatch-h.c | 31 + .../gnulib-tests/test-fnmatch-w32-2.sh | 4 + .../gnulib-tests/test-fnmatch-w32-3.sh | 4 + .../gnulib-tests/test-fnmatch-w32-4.sh | 4 + .../gnulib-tests/test-fnmatch-w32-5.sh | 4 + .../gnulib-tests/test-fnmatch-w32-6.sh | 4 + .../gnulib-tests/test-fnmatch-w32-7.sh | 4 + .../gnulib-tests/test-fnmatch-w32-8.sh | 4 + .../gnulib-tests/test-fnmatch-w32.c | 411 + .../gnulib-tests/test-fnmatch.c | 963 +++ .../gnulib-tests/test-fopen-gnu.c | 88 + .../gnulib-tests/test-fopen.c | 34 + .../gnulib-tests/test-fopen.h | 94 + .../gnulib-tests/test-fputc.c | 95 + .../gnulib-tests/test-fread.c | 104 + .../gnulib-tests/test-free.c | 175 + .../gnulib-tests/test-freopen.c | 86 + .../gnulib-tests/test-fstat.c | 50 + .../gnulib-tests/test-fstatat.c | 107 + .../gnulib-tests/test-ftruncate.c | 60 + .../gnulib-tests/test-ftruncate.sh | 3 + .../gnulib-tests/test-fwrite.c | 98 + .../gnulib-tests/test-getcwd-lgpl.c | 102 + .../gnulib-tests/test-getdtablesize.c | 41 + .../gnulib-tests/test-getopt-gnu.c | 45 + .../gnulib-tests/test-getopt-main.h | 76 + .../gnulib-tests/test-getopt-posix.c | 34 + .../gnulib-tests/test-getopt.h | 1390 ++++ .../gnulib-tests/test-getopt_long.h | 2144 +++++ .../gnulib-tests/test-getprogname.c | 59 + .../gnulib-tests/test-getrandom.c | 92 + .../gnulib-tests/test-gettimeofday.c | 88 + .../gnulib-tests/test-hard-locale.c | 116 + .../gnulib-tests/test-hash.c | 262 + .../gnulib-tests/test-ignore-value.c | 78 + .../gnulib-tests/test-inet_pton.c | 58 + .../gnulib-tests/test-init.sh | 74 + .../gnulib-tests/test-intprops.c | 448 ++ .../gnulib-tests/test-inttostr.c | 94 + .../gnulib-tests/test-inttypes.c | 116 + .../gnulib-tests/test-ioctl.c | 51 + .../gnulib-tests/test-isblank.c | 50 + .../gnulib-tests/test-isnand-nolibm.c | 21 + .../gnulib-tests/test-isnand.h | 49 + .../gnulib-tests/test-isnanf-nolibm.c | 21 + .../gnulib-tests/test-isnanf.h | 49 + .../gnulib-tests/test-isnanl-nolibm.c | 23 + .../gnulib-tests/test-isnanl.h | 104 + .../gnulib-tests/test-iswblank.c | 40 + .../gnulib-tests/test-iswctype.c | 198 + .../gnulib-tests/test-iswdigit.c | 233 + .../gnulib-tests/test-iswdigit.sh | 39 + .../gnulib-tests/test-iswpunct.c | 153 + .../gnulib-tests/test-iswpunct.sh | 7 + .../gnulib-tests/test-iswxdigit.c | 259 + .../gnulib-tests/test-iswxdigit.sh | 39 + .../gnulib-tests/test-langinfo.c | 92 + .../gnulib-tests/test-largefile.c | 51 + .../gnulib-tests/test-limits-h.c | 133 + .../gnulib-tests/test-listen.c | 54 + .../gnulib-tests/test-localcharset.c | 39 + .../gnulib-tests/test-locale.c | 78 + .../gnulib-tests/test-localeconv.c | 72 + .../gnulib-tests/test-lstat.c | 59 + .../gnulib-tests/test-lstat.h | 122 + .../gnulib-tests/test-malloc-gnu.c | 45 + .../gnulib-tests/test-malloca.c | 62 + .../gnulib-tests/test-math.c | 104 + .../gnulib-tests/test-mbrtoc32-1.sh | 9 + .../gnulib-tests/test-mbrtoc32-2.sh | 15 + .../gnulib-tests/test-mbrtoc32-3.sh | 15 + .../gnulib-tests/test-mbrtoc32-4.sh | 15 + .../gnulib-tests/test-mbrtoc32-5.sh | 15 + .../gnulib-tests/test-mbrtoc32-w32-2.sh | 4 + .../gnulib-tests/test-mbrtoc32-w32-3.sh | 4 + .../gnulib-tests/test-mbrtoc32-w32-4.sh | 4 + .../gnulib-tests/test-mbrtoc32-w32-5.sh | 4 + .../gnulib-tests/test-mbrtoc32-w32-6.sh | 4 + .../gnulib-tests/test-mbrtoc32-w32-7.sh | 4 + .../gnulib-tests/test-mbrtoc32-w32-8.sh | 4 + .../gnulib-tests/test-mbrtoc32-w32.c | 750 ++ .../gnulib-tests/test-mbrtoc32.c | 441 ++ .../gnulib-tests/test-mbrtowc-1.sh | 9 + .../gnulib-tests/test-mbrtowc-2.sh | 15 + .../gnulib-tests/test-mbrtowc-3.sh | 15 + .../gnulib-tests/test-mbrtowc-4.sh | 15 + .../gnulib-tests/test-mbrtowc-5.sh | 15 + .../gnulib-tests/test-mbrtowc-w32-2.sh | 4 + .../gnulib-tests/test-mbrtowc-w32-3.sh | 4 + .../gnulib-tests/test-mbrtowc-w32-4.sh | 4 + .../gnulib-tests/test-mbrtowc-w32-5.sh | 4 + .../gnulib-tests/test-mbrtowc-w32-6.sh | 4 + .../gnulib-tests/test-mbrtowc-w32-7.sh | 4 + .../gnulib-tests/test-mbrtowc-w32-8.sh | 4 + .../gnulib-tests/test-mbrtowc-w32.c | 734 ++ .../gnulib-tests/test-mbrtowc.c | 391 + .../gnulib-tests/test-mbscasecmp.c | 55 + .../gnulib-tests/test-mbscasecmp.sh | 15 + .../gnulib-tests/test-mbsinit.c | 55 + .../gnulib-tests/test-mbsinit.sh | 15 + .../gnulib-tests/test-mbsrtoc32s-1.sh | 9 + .../gnulib-tests/test-mbsrtoc32s-2.sh | 15 + .../gnulib-tests/test-mbsrtoc32s-3.sh | 15 + .../gnulib-tests/test-mbsrtoc32s-4.sh | 15 + .../gnulib-tests/test-mbsrtoc32s-5.sh | 15 + .../gnulib-tests/test-mbsrtoc32s.c | 375 + .../gnulib-tests/test-mbsrtowcs-1.sh | 9 + .../gnulib-tests/test-mbsrtowcs-2.sh | 15 + .../gnulib-tests/test-mbsrtowcs-3.sh | 15 + .../gnulib-tests/test-mbsrtowcs-4.sh | 15 + .../gnulib-tests/test-mbsrtowcs-5.sh | 15 + .../gnulib-tests/test-mbsrtowcs.c | 368 + .../gnulib-tests/test-memchr.c | 137 + .../gnulib-tests/test-memrchr.c | 98 + .../gnulib-tests/test-mkdir.c | 46 + .../gnulib-tests/test-mkdir.h | 98 + .../gnulib-tests/test-nanosleep.c | 94 + .../gnulib-tests/test-netinet_in.c | 27 + .../gnulib-tests/test-nl_langinfo-mt.c | 253 + .../gnulib-tests/test-nl_langinfo1.c | 152 + .../gnulib-tests/test-nl_langinfo1.sh | 17 + .../gnulib-tests/test-nl_langinfo2.c | 146 + .../gnulib-tests/test-nl_langinfo2.sh | 12 + .../gnulib-tests/test-nstrftime.c | 349 + .../gnulib-tests/test-nullptr.c | 69 + .../gnulib-tests/test-open.c | 40 + .../gnulib-tests/test-open.h | 138 + .../gnulib-tests/test-openat.c | 98 + .../gnulib-tests/test-pathmax.c | 32 + .../gnulib-tests/test-perror.c | 36 + .../gnulib-tests/test-perror.sh | 26 + .../gnulib-tests/test-perror2.c | 138 + .../gnulib-tests/test-pipe.c | 107 + .../gnulib-tests/test-popen.c | 28 + .../gnulib-tests/test-popen.h | 93 + .../gnulib-tests/test-priv-set.c | 88 + .../gnulib-tests/test-pselect.c | 49 + .../gnulib-tests/test-pthread-thread.c | 73 + .../gnulib-tests/test-pthread.c | 88 + .../gnulib-tests/test-pthread_sigmask1.c | 96 + .../gnulib-tests/test-pthread_sigmask2.c | 105 + .../gnulib-tests/test-quotearg-simple.c | 365 + .../gnulib-tests/test-quotearg.h | 128 + .../gnulib-tests/test-raise.c | 51 + .../gnulib-tests/test-raise.c~ | 51 + .../gnulib-tests/test-rawmemchr.c | 105 + .../gnulib-tests/test-readlink.c | 47 + .../gnulib-tests/test-readlink.h | 119 + .../gnulib-tests/test-readlinkat.c | 120 + .../gnulib-tests/test-realloc-gnu.c | 49 + .../gnulib-tests/test-reallocarray.c | 58 + .../gnulib-tests/test-regex.c | 488 ++ .../gnulib-tests/test-rmdir.c | 46 + .../gnulib-tests/test-rmdir.h | 102 + .../gnulib-tests/test-sched.c | 41 + .../gnulib-tests/test-select-fd.c | 72 + .../gnulib-tests/test-select-in.sh | 38 + .../gnulib-tests/test-select-out.sh | 35 + .../gnulib-tests/test-select-stdin.c | 83 + .../gnulib-tests/test-select.c | 35 + .../gnulib-tests/test-select.h | 467 ++ .../gnulib-tests/test-setenv.c | 56 + .../gnulib-tests/test-setlocale_null-mt-all.c | 172 + .../gnulib-tests/test-setlocale_null-mt-one.c | 172 + .../gnulib-tests/test-setlocale_null.c | 32 + .../gnulib-tests/test-setsockopt.c | 55 + .../gnulib-tests/test-sh-quote.c | 203 + .../gnulib-tests/test-sigaction.c | 122 + .../gnulib-tests/test-signal-h.c | 129 + .../gnulib-tests/test-signbit.c | 135 + .../gnulib-tests/test-sigprocmask.c | 97 + .../gnulib-tests/test-sigsegv-catch-segv1.c | 130 + .../gnulib-tests/test-sigsegv-catch-segv2.c | 153 + .../test-sigsegv-catch-stackoverflow1.c | 149 + .../test-sigsegv-catch-stackoverflow2.c | 211 + .../gnulib-tests/test-sleep.c | 58 + .../gnulib-tests/test-snprintf.c | 72 + .../gnulib-tests/test-sockets.c | 46 + .../gnulib-tests/test-stat-time.c | 248 + .../gnulib-tests/test-stat.c | 55 + .../gnulib-tests/test-stat.h | 107 + .../gnulib-tests/test-stdbool.c | 119 + .../gnulib-tests/test-stdckdint.c | 30 + .../gnulib-tests/test-stddef.c | 100 + .../gnulib-tests/test-stdint.c | 437 ++ .../gnulib-tests/test-stdio.c | 93 + .../gnulib-tests/test-stdlib.c | 63 + .../gnulib-tests/test-strerror.c | 75 + .../gnulib-tests/test-strerror_r.c | 178 + .../gnulib-tests/test-string.c | 31 + .../gnulib-tests/test-strings.c | 27 + .../gnulib-tests/test-strnlen.c | 68 + .../gnulib-tests/test-strtoimax.c | 181 + .../gnulib-tests/test-strtoll.c | 305 + .../gnulib-tests/test-symlink.c | 46 + .../gnulib-tests/test-symlink.h | 96 + .../gnulib-tests/test-symlinkat.c | 88 + .../gnulib-tests/test-sys_ioctl.c | 27 + .../gnulib-tests/test-sys_random.c | 32 + .../gnulib-tests/test-sys_select.c | 59 + .../gnulib-tests/test-sys_socket.c | 68 + .../gnulib-tests/test-sys_stat.c | 338 + .../gnulib-tests/test-sys_time.c | 34 + .../gnulib-tests/test-sys_types.c | 34 + .../gnulib-tests/test-sys_uio.c | 32 + .../gnulib-tests/test-sys_wait.c | 47 + .../gnulib-tests/test-sys_wait.h | 53 + .../gnulib-tests/test-thread_create.c | 78 + .../gnulib-tests/test-thread_self.c | 39 + .../gnulib-tests/test-time-h.c | 43 + .../gnulib-tests/test-time.c | 49 + .../gnulib-tests/test-timespec.c | 166 + .../gnulib-tests/test-timespec_get.c | 57 + .../gnulib-tests/test-uchar.c | 57 + .../gnulib-tests/test-unistd.c | 54 + .../gnulib-tests/test-unlink.c | 48 + .../gnulib-tests/test-unlink.h | 86 + .../gnulib-tests/test-unlinkat.c | 94 + .../gnulib-tests/test-unsetenv.c | 62 + .../gnulib-tests/test-update-copyright.sh | 611 ++ .../gnulib-tests/test-vasnprintf.c | 121 + .../gnulib-tests/test-vc-list-files-cvs.sh | 53 + .../gnulib-tests/test-vc-list-files-git.sh | 49 + .../gnulib-tests/test-verify-try.c | 21 + .../gnulib-tests/test-verify.c | 119 + .../gnulib-tests/test-verify.sh | 25 + .../gnulib-tests/test-version-etc.c | 31 + .../gnulib-tests/test-version-etc.sh | 45 + .../gnulib-tests/test-wchar.c | 35 + .../gnulib-tests/test-wcrtomb-w32-2.sh | 4 + .../gnulib-tests/test-wcrtomb-w32-3.sh | 4 + .../gnulib-tests/test-wcrtomb-w32-4.sh | 4 + .../gnulib-tests/test-wcrtomb-w32-5.sh | 4 + .../gnulib-tests/test-wcrtomb-w32-6.sh | 4 + .../gnulib-tests/test-wcrtomb-w32-7.sh | 4 + .../gnulib-tests/test-wcrtomb-w32-8.sh | 4 + .../gnulib-tests/test-wcrtomb-w32.c | 337 + .../gnulib-tests/test-wcrtomb.c | 166 + .../gnulib-tests/test-wcrtomb.sh | 39 + .../gnulib-tests/test-wctype-h.c | 111 + .../gnulib-tests/test-wctype.c | 73 + .../gnulib-tests/test-wcwidth.c | 106 + .../gnulib-tests/test-xalloc-die.c | 28 + .../gnulib-tests/test-xalloc-die.sh | 36 + .../gnulib-tests/test-xstdopen.c | 32 + .../gnulib-tests/test-xstdopen.sh | 20 + .../gnulib-tests/test-xstrtoimax.c | 4 + .../gnulib-tests/test-xstrtoimax.sh | 46 + .../gnulib-tests/test-xstrtol.c | 62 + .../gnulib-tests/test-xstrtol.sh | 71 + .../gnulib-tests/test-xstrtoul.c | 4 + .../gnulib-tests/test-year2038.c | 39 + .../gnulib-tests/time.c | 41 + .../gnulib-tests/timespec-add.c | 66 + .../gnulib-tests/timespec-sub.c | 66 + .../gnulib-tests/uinttostr.c | 20 + .../gnulib-tests/umaxtostr.c | 20 + .../gnulib-tests/unicase/.gitignore | 3 + .../gnulib-tests/unicase/test-mapping-part1.h | 31 + .../gnulib-tests/unicase/test-mapping-part2.h | 37 + .../gnulib-tests/unicase/test-uc_tolower.c | 1457 ++++ .../gnulib-tests/unictype/.gitignore | 14 + .../gnulib-tests/unictype/test-ctype_alnum.c | 738 ++ .../gnulib-tests/unictype/test-ctype_alpha.c | 737 ++ .../gnulib-tests/unictype/test-ctype_blank.c | 29 + .../gnulib-tests/unictype/test-ctype_cntrl.c | 25 + .../gnulib-tests/unictype/test-ctype_digit.c | 23 + .../gnulib-tests/unictype/test-ctype_graph.c | 734 ++ .../gnulib-tests/unictype/test-ctype_lower.c | 649 ++ .../gnulib-tests/unictype/test-ctype_print.c | 731 ++ .../gnulib-tests/unictype/test-ctype_punct.c | 588 ++ .../gnulib-tests/unictype/test-ctype_space.c | 30 + .../gnulib-tests/unictype/test-ctype_upper.c | 631 ++ .../gnulib-tests/unictype/test-ctype_xdigit.c | 25 + .../unictype/test-predicate-part1.h | 31 + .../unictype/test-predicate-part2.h | 37 + .../gnulib-tests/unistr/.gitignore | 13 + .../gnulib-tests/unistr/test-chr.h | 142 + .../gnulib-tests/unistr/test-cpy.h | 44 + .../gnulib-tests/unistr/test-pcpy.h | 44 + .../gnulib-tests/unistr/test-set.h | 44 + .../gnulib-tests/unistr/test-strcat.h | 56 + .../gnulib-tests/unistr/test-u32-chr.c | 34 + .../gnulib-tests/unistr/test-u32-cpy.c | 28 + .../gnulib-tests/unistr/test-u32-pcpy.c | 28 + .../gnulib-tests/unistr/test-u32-set.c | 29 + .../gnulib-tests/unistr/test-u32-strcat.c | 28 + .../gnulib-tests/unistr/test-u32-strlen.c | 57 + .../gnulib-tests/unistr/u-set.h | 47 + .../gnulib-tests/unistr/u32-set.c | 34 + .../gnulib-tests/uniwidth/.gitignore | 3 + .../gnulib-tests/uniwidth/test-uc_width.c | 56 + .../gnulib-tests/uniwidth/test-uc_width2.c | 86 + .../gnulib-tests/uniwidth/test-uc_width2.sh | 939 +++ .../gnulib-tests/unlink.c | 98 + .../gnulib-tests/unlinkat.c | 124 + .../gnulib-tests/unlinkdir.c | 55 + .../gnulib-tests/unlinkdir.h | 24 + .../gnulib-tests/vasnprintf.c | 6979 +++++++++++++++++ .../gnulib-tests/vasnprintf.h | 77 + .../gnulib-tests/w32sock.h | 140 + .../gnulib-tests/warn-on-use.h | 149 + .../gnulib-tests/wctob.c | 38 + .../gnulib-tests/wctomb-impl.h | 34 + .../gnulib-tests/wctomb.c | 25 + .../gnulib-tests/windows-thread.c | 243 + .../gnulib-tests/windows-thread.h | 60 + .../gnulib-tests/windows-tls.c | 339 + .../gnulib-tests/windows-tls.h | 42 + .../gnulib-tests/xsize.c | 21 + .../gnulib-tests/xsize.h | 110 + .../gnulib-tests/xstrtol-error.c | 98 + .../gnulib-tests/xstrtol-error.h | 51 + .../gnulib-tests/zerosize-ptr.h | 82 + .../test-diffutils-1.result/lib/.gitignore | 351 + .../test-diffutils-1.result/lib/.gitignore~ | 344 + .../test-diffutils-1.result/lib/_Noreturn.h | 50 + .../test-diffutils-1.result/lib/alloca.in.h | 72 + .../test-diffutils-1.result/lib/allocator.c | 22 + .../test-diffutils-1.result/lib/allocator.h | 58 + .../test-diffutils-1.result/lib/arg-nonnull.h | 26 + .../test-diffutils-1.result/lib/argmatch.c | 293 + .../test-diffutils-1.result/lib/argmatch.h | 350 + .../test-diffutils-1.result/lib/assert.in.h | 27 + .../test-diffutils-1.result/lib/assure.h | 57 + .../test-diffutils-1.result/lib/at-func.c | 146 + .../test-diffutils-1.result/lib/attribute.h | 243 + .../lib/basename-lgpl.c | 70 + .../lib/basename-lgpl.h | 83 + .../test-diffutils-1.result/lib/basename.c | 64 + .../test-diffutils-1.result/lib/binary-io.c | 39 + .../test-diffutils-1.result/lib/binary-io.h | 79 + .../test-diffutils-1.result/lib/bitrotate.c | 21 + .../test-diffutils-1.result/lib/bitrotate.h | 140 + .../test-diffutils-1.result/lib/btoc32.c | 68 + .../test-diffutils-1.result/lib/btowc.c | 47 + .../test-diffutils-1.result/lib/c++defs.h | 337 + .../test-diffutils-1.result/lib/c-ctype.c | 21 + .../test-diffutils-1.result/lib/c-ctype.h | 366 + .../test-diffutils-1.result/lib/c-file-type.c | 111 + .../test-diffutils-1.result/lib/c-stack.c | 213 + .../test-diffutils-1.result/lib/c-stack.h | 62 + .../test-diffutils-1.result/lib/c-strcase.h | 61 + .../lib/c-strcasecmp.c | 56 + .../test-diffutils-1.result/lib/c-strcaseeq.h | 181 + .../lib/c-strncasecmp.c | 56 + .../lib/c32_apply_type_test.c | 39 + .../lib/c32_get_type_test.c | 113 + .../test-diffutils-1.result/lib/c32is-impl.h | 105 + .../test-diffutils-1.result/lib/c32isalnum.c | 26 + .../test-diffutils-1.result/lib/c32isalpha.c | 26 + .../test-diffutils-1.result/lib/c32isblank.c | 26 + .../test-diffutils-1.result/lib/c32iscntrl.c | 26 + .../test-diffutils-1.result/lib/c32isdigit.c | 26 + .../test-diffutils-1.result/lib/c32isgraph.c | 26 + .../test-diffutils-1.result/lib/c32islower.c | 26 + .../test-diffutils-1.result/lib/c32isprint.c | 26 + .../test-diffutils-1.result/lib/c32ispunct.c | 26 + .../test-diffutils-1.result/lib/c32isspace.c | 26 + .../test-diffutils-1.result/lib/c32isupper.c | 26 + .../test-diffutils-1.result/lib/c32isxdigit.c | 26 + .../test-diffutils-1.result/lib/c32to-impl.h | 92 + .../test-diffutils-1.result/lib/c32tolower.c | 26 + .../test-diffutils-1.result/lib/c32width.c | 102 + .../test-diffutils-1.result/lib/calloc.c | 55 + .../lib/careadlinkat.c | 182 + .../lib/careadlinkat.h | 72 + .../test-diffutils-1.result/lib/cdefs.h | 715 ++ .../test-diffutils-1.result/lib/chdir-long.c | 263 + .../test-diffutils-1.result/lib/chdir-long.h | 30 + .../test-diffutils-1.result/lib/cloexec.c | 83 + .../test-diffutils-1.result/lib/cloexec.h | 34 + .../test-diffutils-1.result/lib/close.c | 75 + .../test-diffutils-1.result/lib/closedir.c | 77 + .../lib/count-leading-zeros.c | 21 + .../lib/count-leading-zeros.h | 138 + .../test-diffutils-1.result/lib/ctype.in.h | 62 + .../test-diffutils-1.result/lib/diffseq.h | 570 ++ .../lib/dirent-private.h | 67 + .../test-diffutils-1.result/lib/dirent.in.h | 352 + .../test-diffutils-1.result/lib/dirfd.c | 44 + .../lib/dirname-lgpl.c | 86 + .../test-diffutils-1.result/lib/dirname.c | 38 + .../test-diffutils-1.result/lib/dirname.h | 59 + .../lib/dup-safer-flag.c | 38 + .../test-diffutils-1.result/lib/dup-safer.c | 34 + .../test-diffutils-1.result/lib/dup.c | 92 + .../test-diffutils-1.result/lib/dup2.c | 189 + .../test-diffutils-1.result/lib/dynarray.h | 284 + .../test-diffutils-1.result/lib/errno.in.h | 279 + .../test-diffutils-1.result/lib/error.c | 410 + .../test-diffutils-1.result/lib/error.in.h | 216 + .../test-diffutils-1.result/lib/exclude.c | 673 ++ .../test-diffutils-1.result/lib/exclude.h | 70 + .../test-diffutils-1.result/lib/exitfail.c | 24 + .../test-diffutils-1.result/lib/exitfail.h | 18 + .../test-diffutils-1.result/lib/fchdir.c | 204 + .../test-diffutils-1.result/lib/fcntl.c | 629 ++ .../test-diffutils-1.result/lib/fcntl.in.h | 450 ++ .../test-diffutils-1.result/lib/fd-hook.c | 116 + .../test-diffutils-1.result/lib/fd-hook.h | 119 + .../lib/fd-safer-flag.c | 52 + .../test-diffutils-1.result/lib/fd-safer.c | 49 + .../test-diffutils-1.result/lib/fdopendir.c | 238 + .../test-diffutils-1.result/lib/file-type.c | 31 + .../test-diffutils-1.result/lib/file-type.h | 35 + .../test-diffutils-1.result/lib/filename.h | 112 + .../lib/filenamecat-lgpl.c | 90 + .../test-diffutils-1.result/lib/filenamecat.c | 41 + .../test-diffutils-1.result/lib/filenamecat.h | 37 + .../test-diffutils-1.result/lib/flexmember.h | 76 + .../test-diffutils-1.result/lib/fnmatch.c | 391 + .../test-diffutils-1.result/lib/fnmatch.in.h | 117 + .../lib/fnmatch_loop.c | 1211 +++ .../test-diffutils-1.result/lib/fopen.c | 237 + .../test-diffutils-1.result/lib/free.c | 53 + .../test-diffutils-1.result/lib/freopen.c | 96 + .../test-diffutils-1.result/lib/fstat.c | 94 + .../test-diffutils-1.result/lib/fstatat.c | 148 + .../test-diffutils-1.result/lib/getcwd-lgpl.c | 127 + .../lib/getdtablesize.c | 124 + .../lib/getopt-cdefs.in.h | 70 + .../test-diffutils-1.result/lib/getopt-core.h | 96 + .../test-diffutils-1.result/lib/getopt-ext.h | 77 + .../lib/getopt-pfx-core.h | 66 + .../lib/getopt-pfx-ext.h | 70 + .../test-diffutils-1.result/lib/getopt.c | 814 ++ .../test-diffutils-1.result/lib/getopt.in.h | 61 + .../test-diffutils-1.result/lib/getopt1.c | 159 + .../test-diffutils-1.result/lib/getopt_int.h | 118 + .../test-diffutils-1.result/lib/getpagesize.c | 39 + .../test-diffutils-1.result/lib/getprogname.c | 312 + .../test-diffutils-1.result/lib/getprogname.h | 26 + .../test-diffutils-1.result/lib/getrandom.c | 190 + .../test-diffutils-1.result/lib/gettext.h | 300 + .../test-diffutils-1.result/lib/gettime.c | 51 + .../lib/gettimeofday.c | 151 + .../lib/glthread/.gitignore | 3 + .../lib/glthread/lock.c | 749 ++ .../lib/glthread/lock.h | 799 ++ .../lib/glthread/threadlib.c | 108 + .../test-diffutils-1.result/lib/gnulib.mk | 4189 ++++++++++ .../test-diffutils-1.result/lib/hard-locale.c | 47 + .../test-diffutils-1.result/lib/hard-locale.h | 28 + .../test-diffutils-1.result/lib/hash.c | 1120 +++ .../test-diffutils-1.result/lib/hash.h | 273 + .../test-diffutils-1.result/lib/ialloc.c | 21 + .../test-diffutils-1.result/lib/ialloc.h | 140 + .../test-diffutils-1.result/lib/idx.h | 134 + .../lib/ignore-value.h | 51 + .../lib/intprops-internal.h | 397 + .../test-diffutils-1.result/lib/intprops.h | 335 + .../test-diffutils-1.result/lib/inttypes.in.h | 1033 +++ .../test-diffutils-1.result/lib/isblank.c | 33 + .../test-diffutils-1.result/lib/iswblank.c | 26 + .../lib/iswctype-impl.h | 22 + .../test-diffutils-1.result/lib/iswctype.c | 36 + .../test-diffutils-1.result/lib/iswdigit.c | 26 + .../test-diffutils-1.result/lib/iswpunct.c | 33 + .../test-diffutils-1.result/lib/iswxdigit.c | 33 + .../test-diffutils-1.result/lib/langinfo.in.h | 229 + .../lib/lc-charset-dispatch.c | 82 + .../lib/lc-charset-dispatch.h | 40 + .../test-diffutils-1.result/lib/libc-config.h | 204 + .../test-diffutils-1.result/lib/limits.in.h | 151 + .../lib/localcharset.c | 1159 +++ .../lib/localcharset.h | 135 + .../test-diffutils-1.result/lib/locale.in.h | 310 + .../test-diffutils-1.result/lib/localeconv.c | 114 + .../test-diffutils-1.result/lib/lstat.c | 104 + .../test-diffutils-1.result/lib/malloc.c | 51 + .../lib/malloc/.gitignore | 7 + .../lib/malloc/dynarray-skeleton.c | 528 ++ .../lib/malloc/dynarray.h | 177 + .../lib/malloc/dynarray_at_failure.c | 40 + .../lib/malloc/dynarray_emplace_enlarge.c | 77 + .../lib/malloc/dynarray_finalize.c | 66 + .../lib/malloc/dynarray_resize.c | 68 + .../lib/malloc/dynarray_resize_clear.c | 39 + .../test-diffutils-1.result/lib/malloca.c | 135 + .../test-diffutils-1.result/lib/malloca.h | 147 + .../test-diffutils-1.result/lib/mbchar.c | 23 + .../test-diffutils-1.result/lib/mbchar.h | 373 + .../test-diffutils-1.result/lib/mbrtoc32.c | 288 + .../lib/mbrtowc-impl-utf8.h | 138 + .../lib/mbrtowc-impl.h | 262 + .../test-diffutils-1.result/lib/mbrtowc.c | 161 + .../test-diffutils-1.result/lib/mbscasecmp.c | 114 + .../test-diffutils-1.result/lib/mbsinit.c | 69 + .../lib/mbsrtoc32s-state.c | 37 + .../test-diffutils-1.result/lib/mbsrtoc32s.c | 65 + .../lib/mbsrtowcs-impl.h | 123 + .../lib/mbsrtowcs-state.c | 37 + .../test-diffutils-1.result/lib/mbsrtowcs.c | 37 + .../test-diffutils-1.result/lib/mbszero.c | 23 + .../test-diffutils-1.result/lib/mbtowc-impl.h | 44 + .../test-diffutils-1.result/lib/mbtowc-lock.c | 151 + .../test-diffutils-1.result/lib/mbtowc-lock.h | 125 + .../test-diffutils-1.result/lib/mbtowc.c | 26 + .../test-diffutils-1.result/lib/mbuiter.c | 20 + .../test-diffutils-1.result/lib/mbuiter.h | 267 + .../test-diffutils-1.result/lib/mbuiterf.c | 20 + .../test-diffutils-1.result/lib/mbuiterf.h | 213 + .../test-diffutils-1.result/lib/memchr.c | 172 + .../lib/memchr.valgrind | 30 + .../test-diffutils-1.result/lib/mempcpy.c | 33 + .../test-diffutils-1.result/lib/memrchr.c | 161 + .../test-diffutils-1.result/lib/minmax.h | 65 + .../test-diffutils-1.result/lib/mkdir.c | 93 + .../test-diffutils-1.result/lib/mkstemp.c | 50 + .../lib/mktime-internal.h | 79 + .../test-diffutils-1.result/lib/mktime.c | 579 ++ .../test-diffutils-1.result/lib/msvc-inval.c | 129 + .../test-diffutils-1.result/lib/msvc-inval.h | 227 + .../lib/msvc-nothrow.c | 51 + .../lib/msvc-nothrow.h | 48 + .../lib/nl_langinfo-lock.c | 151 + .../test-diffutils-1.result/lib/nl_langinfo.c | 585 ++ .../test-diffutils-1.result/lib/nstrftime.c | 1510 ++++ .../test-diffutils-1.result/lib/open.c | 213 + .../test-diffutils-1.result/lib/openat-die.c | 62 + .../test-diffutils-1.result/lib/openat-priv.h | 64 + .../test-diffutils-1.result/lib/openat-proc.c | 154 + .../test-diffutils-1.result/lib/openat.c | 315 + .../test-diffutils-1.result/lib/openat.h | 127 + .../test-diffutils-1.result/lib/opendir.c | 186 + .../test-diffutils-1.result/lib/pathmax.h | 88 + .../test-diffutils-1.result/lib/pclose.c | 28 + .../test-diffutils-1.result/lib/pipe-safer.c | 52 + .../test-diffutils-1.result/lib/pipe.c | 50 + .../test-diffutils-1.result/lib/popen.c | 103 + .../test-diffutils-1.result/lib/progname.c | 92 + .../test-diffutils-1.result/lib/progname.h | 62 + .../lib/propername-lite.c | 36 + .../test-diffutils-1.result/lib/propername.h | 134 + .../test-diffutils-1.result/lib/quote.h | 46 + .../test-diffutils-1.result/lib/quotearg.c | 1084 +++ .../test-diffutils-1.result/lib/quotearg.h | 436 + .../test-diffutils-1.result/lib/raise.c | 83 + .../test-diffutils-1.result/lib/rawmemchr.c | 135 + .../lib/rawmemchr.valgrind | 28 + .../test-diffutils-1.result/lib/readdir.c | 109 + .../test-diffutils-1.result/lib/readlink.c | 104 + .../test-diffutils-1.result/lib/readlinkat.c | 113 + .../test-diffutils-1.result/lib/realloc.c | 63 + .../lib/reallocarray.c | 38 + .../test-diffutils-1.result/lib/regcomp.c | 3788 +++++++++ .../test-diffutils-1.result/lib/regex.c | 84 + .../test-diffutils-1.result/lib/regex.h | 699 ++ .../lib/regex_internal.c | 1711 ++++ .../lib/regex_internal.h | 832 ++ .../test-diffutils-1.result/lib/regexec.c | 4221 ++++++++++ .../test-diffutils-1.result/lib/same-inode.c | 3 + .../test-diffutils-1.result/lib/same-inode.h | 85 + .../test-diffutils-1.result/lib/save-cwd.c | 96 + .../test-diffutils-1.result/lib/save-cwd.h | 34 + .../test-diffutils-1.result/lib/setenv.c | 396 + .../lib/setlocale-lock.c | 151 + .../lib/setlocale_null.c | 422 + .../lib/setlocale_null.h | 82 + .../test-diffutils-1.result/lib/sh-quote.c | 107 + .../test-diffutils-1.result/lib/sh-quote.h | 58 + .../test-diffutils-1.result/lib/sig-handler.c | 21 + .../test-diffutils-1.result/lib/sig-handler.h | 53 + .../test-diffutils-1.result/lib/sigaction.c | 204 + .../test-diffutils-1.result/lib/signal.in.h | 500 ++ .../test-diffutils-1.result/lib/sigprocmask.c | 349 + .../test-diffutils-1.result/lib/sigsegv.c | 1482 ++++ .../test-diffutils-1.result/lib/sigsegv.in.h | 244 + .../test-diffutils-1.result/lib/stackvma.c | 2381 ++++++ .../test-diffutils-1.result/lib/stackvma.h | 62 + .../test-diffutils-1.result/lib/stat-macros.h | 20 + .../test-diffutils-1.result/lib/stat-time.c | 21 + .../test-diffutils-1.result/lib/stat-time.h | 245 + .../test-diffutils-1.result/lib/stat-w32.c | 460 ++ .../test-diffutils-1.result/lib/stat-w32.h | 37 + .../test-diffutils-1.result/lib/stat.c | 438 ++ .../test-diffutils-1.result/lib/stdarg.in.h | 40 + .../lib/stdckdint.in.h | 35 + .../test-diffutils-1.result/lib/stddef.in.h | 213 + .../test-diffutils-1.result/lib/stdint.in.h | 742 ++ .../test-diffutils-1.result/lib/stdio-read.c | 168 + .../test-diffutils-1.result/lib/stdio-write.c | 206 + .../test-diffutils-1.result/lib/stdio.in.h | 1843 +++++ .../test-diffutils-1.result/lib/stdlib.in.h | 1853 +++++ .../test-diffutils-1.result/lib/stdopen.c | 66 + .../test-diffutils-1.result/lib/stdopen.h | 32 + .../test-diffutils-1.result/lib/stpcpy.c | 49 + .../test-diffutils-1.result/lib/strcasecmp.c | 60 + .../test-diffutils-1.result/lib/strdup.c | 54 + .../test-diffutils-1.result/lib/streq.h | 176 + .../lib/strerror-override.c | 306 + .../lib/strerror-override.h | 62 + .../test-diffutils-1.result/lib/strerror.c | 70 + .../test-diffutils-1.result/lib/strftime.h | 38 + .../test-diffutils-1.result/lib/string.in.h | 1460 ++++ .../test-diffutils-1.result/lib/strings.in.h | 127 + .../test-diffutils-1.result/lib/stripslash.c | 45 + .../test-diffutils-1.result/lib/strncasecmp.c | 60 + .../test-diffutils-1.result/lib/strnlen.c | 30 + .../test-diffutils-1.result/lib/strnlen1.c | 35 + .../test-diffutils-1.result/lib/strnlen1.h | 45 + .../test-diffutils-1.result/lib/strptime.c | 1163 +++ .../test-diffutils-1.result/lib/strtoimax.c | 70 + .../test-diffutils-1.result/lib/strtol.c | 416 + .../test-diffutils-1.result/lib/strtoll.c | 33 + .../lib/sys_random.in.h | 105 + .../test-diffutils-1.result/lib/sys_stat.in.h | 998 +++ .../test-diffutils-1.result/lib/sys_time.in.h | 236 + .../lib/sys_types.in.h | 113 + .../test-diffutils-1.result/lib/sys_wait.in.h | 136 + .../lib/system-quote.c | 310 + .../lib/system-quote.h | 108 + .../test-diffutils-1.result/lib/tempname.c | 286 + .../test-diffutils-1.result/lib/tempname.h | 72 + .../lib/time-internal.h | 49 + .../test-diffutils-1.result/lib/time.in.h | 589 ++ .../test-diffutils-1.result/lib/time_r.c | 44 + .../test-diffutils-1.result/lib/time_rz.c | 316 + .../test-diffutils-1.result/lib/timegm.c | 58 + .../test-diffutils-1.result/lib/timespec.c | 21 + .../test-diffutils-1.result/lib/timespec.h | 102 + .../lib/timespec_get.c | 33 + .../test-diffutils-1.result/lib/tzset.c | 66 + .../test-diffutils-1.result/lib/uchar.in.h | 910 +++ .../test-diffutils-1.result/lib/unicase.in.h | 471 ++ .../lib/unicase/.gitignore | 3 + .../lib/unicase/simple-mapping.h | 39 + .../lib/unicase/tolower.c | 27 + .../lib/unicase/tolower.h | 727 ++ .../test-diffutils-1.result/lib/unictype.in.h | 1096 +++ .../lib/unictype/.gitignore | 25 + .../lib/unictype/bitmap.h | 48 + .../lib/unictype/ctype_alnum.c | 32 + .../lib/unictype/ctype_alnum.h | 877 +++ .../lib/unictype/ctype_alpha.c | 32 + .../lib/unictype/ctype_alpha.h | 877 +++ .../lib/unictype/ctype_blank.c | 32 + .../lib/unictype/ctype_blank.h | 184 + .../lib/unictype/ctype_cntrl.c | 32 + .../lib/unictype/ctype_cntrl.h | 176 + .../lib/unictype/ctype_digit.c | 32 + .../lib/unictype/ctype_digit.h | 172 + .../lib/unictype/ctype_graph.c | 32 + .../lib/unictype/ctype_graph.h | 1182 +++ .../lib/unictype/ctype_lower.c | 32 + .../lib/unictype/ctype_lower.h | 371 + .../lib/unictype/ctype_print.c | 32 + .../lib/unictype/ctype_print.h | 1182 +++ .../lib/unictype/ctype_punct.c | 32 + .../lib/unictype/ctype_punct.h | 858 ++ .../lib/unictype/ctype_space.c | 32 + .../lib/unictype/ctype_space.h | 184 + .../lib/unictype/ctype_upper.c | 32 + .../lib/unictype/ctype_upper.h | 367 + .../lib/unictype/ctype_xdigit.c | 32 + .../lib/unictype/ctype_xdigit.h | 172 + .../test-diffutils-1.result/lib/uninorm.in.h | 255 + .../test-diffutils-1.result/lib/unistd--.h | 32 + .../lib/unistd-safer.h | 31 + .../test-diffutils-1.result/lib/unistd.c | 22 + .../test-diffutils-1.result/lib/unistd.in.h | 2419 ++++++ .../test-diffutils-1.result/lib/unistr.in.h | 762 ++ .../lib/unistr/.gitignore | 9 + .../lib/unistr/u-cpy.h | 33 + .../lib/unistr/u-pcpy.h | 22 + .../lib/unistr/u-strcat.h | 26 + .../lib/unistr/u-strlen.h | 26 + .../lib/unistr/u32-chr.c | 32 + .../lib/unistr/u32-cpy.c | 25 + .../lib/unistr/u32-pcpy.c | 26 + .../lib/unistr/u32-strcat.c | 26 + .../lib/unistr/u32-strlen.c | 25 + .../test-diffutils-1.result/lib/unitypes.in.h | 61 + .../test-diffutils-1.result/lib/uniwidth.in.h | 72 + .../lib/uniwidth/.gitignore | 4 + .../lib/uniwidth/cjk.h | 37 + .../lib/uniwidth/width.c | 95 + .../lib/uniwidth/width0.h | 486 ++ .../lib/uniwidth/width2.h | 541 ++ .../test-diffutils-1.result/lib/unlocked-io.h | 141 + .../test-diffutils-1.result/lib/unsetenv.c | 127 + .../test-diffutils-1.result/lib/verify.h | 375 + .../lib/version-etc-fsf.c | 30 + .../test-diffutils-1.result/lib/version-etc.c | 262 + .../test-diffutils-1.result/lib/version-etc.h | 83 + .../test-diffutils-1.result/lib/warn-on-use.h | 149 + .../test-diffutils-1.result/lib/wchar.in.h | 1707 ++++ .../test-diffutils-1.result/lib/wcrtomb.c | 80 + .../test-diffutils-1.result/lib/wctype-h.c | 23 + .../test-diffutils-1.result/lib/wctype-impl.h | 96 + .../test-diffutils-1.result/lib/wctype.c | 25 + .../test-diffutils-1.result/lib/wctype.in.h | 797 ++ .../test-diffutils-1.result/lib/wcwidth.c | 73 + .../lib/windows-initguard.h | 35 + .../lib/windows-mutex.c | 95 + .../lib/windows-mutex.h | 51 + .../lib/windows-once.c | 62 + .../lib/windows-once.h | 47 + .../lib/windows-recmutex.c | 127 + .../lib/windows-recmutex.h | 57 + .../lib/windows-rwlock.c | 377 + .../lib/windows-rwlock.h | 68 + .../lib/wmemchr-impl.h | 27 + .../test-diffutils-1.result/lib/wmemchr.c | 23 + .../test-diffutils-1.result/lib/wmempcpy.c | 28 + .../test-diffutils-1.result/lib/xalloc-die.c | 41 + .../lib/xalloc-oversized.h | 65 + .../test-diffutils-1.result/lib/xalloc.h | 215 + .../test-diffutils-1.result/lib/xfreopen.c | 41 + .../test-diffutils-1.result/lib/xfreopen.h | 29 + .../test-diffutils-1.result/lib/xmalloc.c | 340 + .../test-diffutils-1.result/lib/xmalloca.c | 38 + .../test-diffutils-1.result/lib/xmalloca.h | 77 + .../test-diffutils-1.result/lib/xstdopen.c | 35 + .../test-diffutils-1.result/lib/xstdopen.h | 28 + .../test-diffutils-1.result/lib/xstrtoimax.c | 24 + .../test-diffutils-1.result/lib/xstrtol.c | 247 + .../test-diffutils-1.result/lib/xstrtol.h | 51 + .../test-diffutils-1.result/lib/xstrtoul.c | 23 + .../test-diffutils-1.result/m4/.gitignore | 282 + .../test-diffutils-1.result/m4/.gitignore~ | 271 + .../test-diffutils-1.result/m4/00gnulib.m4 | 85 + .../test-diffutils-1.result/m4/__inline.m4 | 22 + .../m4/absolute-header.m4 | 100 + .../test-diffutils-1.result/m4/alloca.m4 | 106 + .../test-diffutils-1.result/m4/arpa_inet_h.m4 | 74 + .../m4/asm-underscore.m4 | 83 + .../test-diffutils-1.result/m4/assert_h.m4 | 73 + .../test-diffutils-1.result/m4/atoll.m4 | 19 + .../test-diffutils-1.result/m4/btowc.m4 | 161 + .../m4/builtin-expect.m4 | 49 + .../test-diffutils-1.result/m4/c-bool.m4 | 51 + .../test-diffutils-1.result/m4/c-stack.m4 | 20 + .../test-diffutils-1.result/m4/c32rtomb.m4 | 88 + .../test-diffutils-1.result/m4/calloc.m4 | 83 + .../test-diffutils-1.result/m4/chdir-long.m4 | 30 + .../test-diffutils-1.result/m4/clock_time.m4 | 53 + .../test-diffutils-1.result/m4/close.m4 | 35 + .../test-diffutils-1.result/m4/closedir.m4 | 31 + .../test-diffutils-1.result/m4/codeset.m4 | 24 + .../test-diffutils-1.result/m4/config-h.m4 | 13 + .../test-diffutils-1.result/m4/ctype_h.m4 | 47 + .../test-diffutils-1.result/m4/dirent_h.m4 | 97 + .../test-diffutils-1.result/m4/dirfd.m4 | 88 + .../m4/double-slash-root.m4 | 38 + .../test-diffutils-1.result/m4/dup.m4 | 54 + .../test-diffutils-1.result/m4/dup2.m4 | 105 + .../test-diffutils-1.result/m4/eealloc.m4 | 31 + .../test-diffutils-1.result/m4/environ.m4 | 46 + .../test-diffutils-1.result/m4/errno_h.m4 | 131 + .../test-diffutils-1.result/m4/error.m4 | 22 + .../test-diffutils-1.result/m4/error_h.m4 | 124 + .../test-diffutils-1.result/m4/exponentd.m4 | 116 + .../test-diffutils-1.result/m4/exponentf.m4 | 92 + .../test-diffutils-1.result/m4/exponentl.m4 | 113 + .../test-diffutils-1.result/m4/extensions.m4 | 232 + .../m4/extern-inline.m4 | 132 + .../test-diffutils-1.result/m4/fchdir.m4 | 76 + .../test-diffutils-1.result/m4/fclose.m4 | 98 + .../test-diffutils-1.result/m4/fcntl-o.m4 | 140 + .../test-diffutils-1.result/m4/fcntl.m4 | 151 + .../test-diffutils-1.result/m4/fcntl_h.m4 | 70 + .../test-diffutils-1.result/m4/fdopen.m4 | 51 + .../test-diffutils-1.result/m4/fdopendir.m4 | 67 + .../test-diffutils-1.result/m4/fflush.m4 | 100 + .../test-diffutils-1.result/m4/filenamecat.m4 | 16 + .../test-diffutils-1.result/m4/flexmember.m4 | 44 + .../test-diffutils-1.result/m4/float_h.m4 | 108 + .../test-diffutils-1.result/m4/fnmatch.m4 | 209 + .../test-diffutils-1.result/m4/fnmatch_h.m4 | 87 + .../test-diffutils-1.result/m4/fopen.m4 | 158 + .../test-diffutils-1.result/m4/fpieee.m4 | 54 + .../test-diffutils-1.result/m4/free.m4 | 52 + .../test-diffutils-1.result/m4/freopen.m4 | 40 + .../test-diffutils-1.result/m4/fstat.m4 | 40 + .../test-diffutils-1.result/m4/fstatat.m4 | 65 + .../test-diffutils-1.result/m4/ftruncate.m4 | 43 + .../test-diffutils-1.result/m4/getcwd.m4 | 168 + .../m4/getdtablesize.m4 | 63 + .../test-diffutils-1.result/m4/getopt.m4 | 381 + .../test-diffutils-1.result/m4/getpagesize.m4 | 49 + .../test-diffutils-1.result/m4/getprogname.m4 | 60 + .../test-diffutils-1.result/m4/getrandom.m4 | 82 + .../test-diffutils-1.result/m4/gettime.m4 | 68 + .../m4/gettimeofday.m4 | 69 + .../test-diffutils-1.result/m4/gnu-make.m4 | 17 + .../m4/gnulib-cache.m4 | 260 + .../m4/gnulib-cache.m4~ | 245 + .../m4/gnulib-common.m4 | 1462 ++++ .../test-diffutils-1.result/m4/gnulib-comp.m4 | 3391 ++++++++ .../m4/gnulib-comp.m4~ | 2831 +++++++ .../test-diffutils-1.result/m4/gnulib-tool.m4 | 63 + .../m4/host-cpu-c-abi.m4 | 527 ++ .../m4/include_next.m4 | 224 + .../test-diffutils-1.result/m4/inet_pton.m4 | 70 + .../test-diffutils-1.result/m4/inline.m4 | 40 + .../m4/intl-thread-locale.m4 | 219 + .../test-diffutils-1.result/m4/intmax_t.m4 | 59 + .../test-diffutils-1.result/m4/inttostr.m4 | 32 + .../test-diffutils-1.result/m4/inttypes.m4 | 184 + .../test-diffutils-1.result/m4/inttypes_h.m4 | 29 + .../test-diffutils-1.result/m4/ioctl.m4 | 44 + .../test-diffutils-1.result/m4/isblank.m4 | 17 + .../test-diffutils-1.result/m4/isnand.m4 | 95 + .../test-diffutils-1.result/m4/isnanf.m4 | 196 + .../test-diffutils-1.result/m4/isnanl.m4 | 247 + .../test-diffutils-1.result/m4/iswblank.m4 | 38 + .../test-diffutils-1.result/m4/iswctype.m4 | 13 + .../test-diffutils-1.result/m4/iswdigit.m4 | 120 + .../test-diffutils-1.result/m4/iswpunct.m4 | 48 + .../test-diffutils-1.result/m4/iswxdigit.m4 | 110 + .../test-diffutils-1.result/m4/langinfo_h.m4 | 137 + .../test-diffutils-1.result/m4/largefile.m4 | 358 + .../test-diffutils-1.result/m4/lib-ld.m4 | 168 + .../test-diffutils-1.result/m4/lib-link.m4 | 813 ++ .../test-diffutils-1.result/m4/lib-prefix.m4 | 323 + .../test-diffutils-1.result/m4/libsigsegv.m4 | 16 + .../m4/libunistring-base.m4 | 196 + .../test-diffutils-1.result/m4/limits-h.m4 | 54 + .../m4/localcharset.m4 | 11 + .../test-diffutils-1.result/m4/locale-fr.m4 | 300 + .../test-diffutils-1.result/m4/locale-ja.m4 | 149 + .../test-diffutils-1.result/m4/locale-tr.m4 | 132 + .../test-diffutils-1.result/m4/locale-zh.m4 | 143 + .../test-diffutils-1.result/m4/locale_h.m4 | 176 + .../test-diffutils-1.result/m4/localeconv.m4 | 59 + .../test-diffutils-1.result/m4/lock.m4 | 47 + .../test-diffutils-1.result/m4/lstat.m4 | 82 + .../test-diffutils-1.result/m4/malloc.m4 | 176 + .../test-diffutils-1.result/m4/malloca.m4 | 14 + .../m4/manywarnings-c++.m4 | 243 + .../m4/manywarnings.m4 | 206 + .../test-diffutils-1.result/m4/math_h.m4 | 402 + .../test-diffutils-1.result/m4/mbchar.m4 | 13 + .../test-diffutils-1.result/m4/mbiter.m4 | 14 + .../test-diffutils-1.result/m4/mbrtoc32.m4 | 266 + .../test-diffutils-1.result/m4/mbrtowc.m4 | 796 ++ .../test-diffutils-1.result/m4/mbsinit.m4 | 44 + .../test-diffutils-1.result/m4/mbsrtowcs.m4 | 154 + .../test-diffutils-1.result/m4/mbstate_t.m4 | 34 + .../test-diffutils-1.result/m4/mbtowc.m4 | 27 + .../test-diffutils-1.result/m4/memchr.m4 | 106 + .../test-diffutils-1.result/m4/mempcpy.m4 | 29 + .../test-diffutils-1.result/m4/memrchr.m4 | 23 + .../test-diffutils-1.result/m4/minmax.m4 | 44 + .../test-diffutils-1.result/m4/mkdir.m4 | 92 + .../test-diffutils-1.result/m4/mkstemp.m4 | 87 + .../test-diffutils-1.result/m4/mktime.m4 | 318 + .../test-diffutils-1.result/m4/mmap-anon.m4 | 55 + .../test-diffutils-1.result/m4/mode_t.m4 | 26 + .../test-diffutils-1.result/m4/msvc-inval.m4 | 19 + .../m4/msvc-nothrow.m4 | 10 + .../test-diffutils-1.result/m4/multiarch.m4 | 65 + .../test-diffutils-1.result/m4/musl.m4 | 20 + .../test-diffutils-1.result/m4/nan-mips.m4 | 89 + .../test-diffutils-1.result/m4/nanosleep.m4 | 151 + .../m4/netinet_in_h.m4 | 29 + .../test-diffutils-1.result/m4/nl_langinfo.m4 | 80 + .../test-diffutils-1.result/m4/nocrash.m4 | 131 + .../test-diffutils-1.result/m4/nstrftime.m4 | 22 + .../test-diffutils-1.result/m4/nullptr.m4 | 62 + .../test-diffutils-1.result/m4/off_t.m4 | 18 + .../m4/open-cloexec.m4 | 21 + .../test-diffutils-1.result/m4/open-slash.m4 | 60 + .../test-diffutils-1.result/m4/open.m4 | 56 + .../test-diffutils-1.result/m4/openat.m4 | 38 + .../test-diffutils-1.result/m4/opendir.m4 | 31 + .../test-diffutils-1.result/m4/pathmax.m4 | 42 + .../test-diffutils-1.result/m4/pclose.m4 | 20 + .../test-diffutils-1.result/m4/perl.m4 | 53 + .../test-diffutils-1.result/m4/perror.m4 | 76 + .../test-diffutils-1.result/m4/pid_t.m4 | 38 + .../test-diffutils-1.result/m4/pipe.m4 | 15 + .../test-diffutils-1.result/m4/popen.m4 | 54 + .../test-diffutils-1.result/m4/printf.m4 | 2214 ++++++ .../test-diffutils-1.result/m4/priv-set.m4 | 15 + .../test-diffutils-1.result/m4/pselect.m4 | 75 + .../m4/pthread-thread.m4 | 69 + .../test-diffutils-1.result/m4/pthread_h.m4 | 283 + .../m4/pthread_rwlock_rdlock.m4 | 185 + .../m4/pthread_sigmask.m4 | 280 + .../test-diffutils-1.result/m4/putenv.m4 | 64 + .../test-diffutils-1.result/m4/quote.m4 | 13 + .../test-diffutils-1.result/m4/quotearg.m4 | 11 + .../test-diffutils-1.result/m4/raise.m4 | 36 + .../test-diffutils-1.result/m4/rawmemchr.m4 | 20 + .../test-diffutils-1.result/m4/readdir.m4 | 22 + .../test-diffutils-1.result/m4/readlink.m4 | 120 + .../test-diffutils-1.result/m4/readlinkat.m4 | 42 + .../test-diffutils-1.result/m4/realloc.m4 | 64 + .../m4/reallocarray.m4 | 26 + .../test-diffutils-1.result/m4/regex.m4 | 396 + .../test-diffutils-1.result/m4/rmdir.m4 | 56 + .../test-diffutils-1.result/m4/save-cwd.m4 | 11 + .../test-diffutils-1.result/m4/sched_h.m4 | 106 + .../test-diffutils-1.result/m4/select.m4 | 122 + .../test-diffutils-1.result/m4/setenv.m4 | 165 + .../m4/setlocale_null.m4 | 117 + .../test-diffutils-1.result/m4/sigaction.m4 | 40 + .../test-diffutils-1.result/m4/sigaltstack.m4 | 197 + .../test-diffutils-1.result/m4/signal_h.m4 | 100 + .../m4/signalblocking.m4 | 23 + .../test-diffutils-1.result/m4/signbit.m4 | 393 + .../test-diffutils-1.result/m4/sigsegv.m4 | 20 + .../test-diffutils-1.result/m4/size_max.m4 | 75 + .../test-diffutils-1.result/m4/sleep.m4 | 68 + .../test-diffutils-1.result/m4/snan.m4 | 14 + .../test-diffutils-1.result/m4/snprintf.m4 | 62 + .../test-diffutils-1.result/m4/socketlib.m4 | 96 + .../test-diffutils-1.result/m4/sockets.m4 | 17 + .../test-diffutils-1.result/m4/socklen.m4 | 76 + .../test-diffutils-1.result/m4/sockpfaf.m4 | 84 + .../test-diffutils-1.result/m4/ssize_t.m4 | 37 + .../m4/stack-direction.m4 | 125 + .../test-diffutils-1.result/m4/stat-time.m4 | 83 + .../test-diffutils-1.result/m4/stat.m4 | 87 + .../test-diffutils-1.result/m4/std-gnu11.m4 | 829 ++ .../test-diffutils-1.result/m4/stdalign.m4 | 206 + .../test-diffutils-1.result/m4/stdarg.m4 | 76 + .../test-diffutils-1.result/m4/stddef_h.m4 | 119 + .../test-diffutils-1.result/m4/stdint.m4 | 534 ++ .../test-diffutils-1.result/m4/stdint_h.m4 | 27 + .../test-diffutils-1.result/m4/stdio_h.m4 | 255 + .../test-diffutils-1.result/m4/stdlib_h.m4 | 258 + .../test-diffutils-1.result/m4/stpcpy.m4 | 28 + .../test-diffutils-1.result/m4/strcase.m4 | 45 + .../test-diffutils-1.result/m4/strdup.m4 | 32 + .../test-diffutils-1.result/m4/strerror.m4 | 102 + .../test-diffutils-1.result/m4/strerror_r.m4 | 180 + .../test-diffutils-1.result/m4/string_h.m4 | 152 + .../test-diffutils-1.result/m4/strings_h.m4 | 62 + .../test-diffutils-1.result/m4/strnlen.m4 | 30 + .../test-diffutils-1.result/m4/strptime.m4 | 22 + .../test-diffutils-1.result/m4/strtoimax.m4 | 88 + .../test-diffutils-1.result/m4/strtoll.m4 | 68 + .../test-diffutils-1.result/m4/symlink.m4 | 57 + .../test-diffutils-1.result/m4/symlinkat.m4 | 61 + .../test-diffutils-1.result/m4/sys_ioctl_h.m4 | 79 + .../m4/sys_random_h.m4 | 68 + .../m4/sys_select_h.m4 | 110 + .../m4/sys_socket_h.m4 | 206 + .../test-diffutils-1.result/m4/sys_stat_h.m4 | 129 + .../test-diffutils-1.result/m4/sys_time_h.m4 | 120 + .../test-diffutils-1.result/m4/sys_types_h.m4 | 70 + .../test-diffutils-1.result/m4/sys_uio_h.m4 | 46 + .../test-diffutils-1.result/m4/sys_wait_h.m4 | 51 + .../test-diffutils-1.result/m4/tempname.m4 | 19 + .../test-diffutils-1.result/m4/thread.m4 | 17 + .../test-diffutils-1.result/m4/threadlib.m4 | 686 ++ .../test-diffutils-1.result/m4/time.m4 | 55 + .../test-diffutils-1.result/m4/time_h.m4 | 180 + .../test-diffutils-1.result/m4/time_r.m4 | 97 + .../test-diffutils-1.result/m4/time_rz.m4 | 53 + .../test-diffutils-1.result/m4/timegm.m4 | 28 + .../test-diffutils-1.result/m4/timespec.m4 | 11 + .../m4/timespec_get.m4 | 21 + .../test-diffutils-1.result/m4/tm_gmtoff.m4 | 14 + .../test-diffutils-1.result/m4/tzset.m4 | 17 + .../test-diffutils-1.result/m4/uchar_h.m4 | 249 + .../test-diffutils-1.result/m4/unicase_h.m4 | 43 + .../test-diffutils-1.result/m4/unictype_h.m4 | 172 + .../test-diffutils-1.result/m4/uninorm_h.m4 | 45 + .../m4/unistd-safer.m4 | 10 + .../test-diffutils-1.result/m4/unistd_h.m4 | 276 + .../test-diffutils-1.result/m4/unlink.m4 | 137 + .../test-diffutils-1.result/m4/unlinkat.m4 | 34 + .../test-diffutils-1.result/m4/unlinkdir.m4 | 32 + .../test-diffutils-1.result/m4/unlocked-io.m4 | 36 + .../test-diffutils-1.result/m4/vararrays.m4 | 72 + .../test-diffutils-1.result/m4/vasnprintf.m4 | 480 ++ .../test-diffutils-1.result/m4/version-etc.m4 | 33 + .../test-diffutils-1.result/m4/visibility.m4 | 82 + .../test-diffutils-1.result/m4/warn-on-use.m4 | 62 + .../test-diffutils-1.result/m4/warnings.m4 | 176 + .../test-diffutils-1.result/m4/wchar_h.m4 | 264 + .../test-diffutils-1.result/m4/wchar_t.m4 | 24 + .../test-diffutils-1.result/m4/wcrtomb.m4 | 152 + .../test-diffutils-1.result/m4/wctob.m4 | 109 + .../test-diffutils-1.result/m4/wctomb.m4 | 19 + .../test-diffutils-1.result/m4/wctype.m4 | 51 + .../test-diffutils-1.result/m4/wctype_h.m4 | 204 + .../test-diffutils-1.result/m4/wcwidth.m4 | 115 + .../test-diffutils-1.result/m4/wint_t.m4 | 57 + .../test-diffutils-1.result/m4/wmemchr.m4 | 25 + .../test-diffutils-1.result/m4/wmempcpy.m4 | 24 + .../test-diffutils-1.result/m4/xalloc.m4 | 7 + .../test-diffutils-1.result/m4/xsize.m4 | 12 + .../test-diffutils-1.result/m4/xstrtol.m4 | 10 + .../test-diffutils-1.result/m4/zzgnulib.m4 | 23 + .../test-diffutils-1.result/maint.mk | 1805 +++++ .../import-tests/test-diffutils-1.sh | 124 + 1242 files changed, 225409 insertions(+) create mode 100644 gnulib-tool-tests/import-tests/diffutils-20230801/.gitignore create mode 100644 gnulib-tool-tests/import-tests/diffutils-20230801/Makefile.am create mode 100644 gnulib-tool-tests/import-tests/diffutils-20230801/build-aux/.gitignore create mode 100644 gnulib-tool-tests/import-tests/diffutils-20230801/configure.ac create mode 100644 gnulib-tool-tests/import-tests/diffutils-20230801/doc/.gitignore create mode 100644 gnulib-tool-tests/import-tests/diffutils-20230801/gnulib-tests/.gitignore create mode 100644 gnulib-tool-tests/import-tests/diffutils-20230801/gnulib-tests/glthread/.gitignore create mode 100644 gnulib-tool-tests/import-tests/diffutils-20230801/gnulib-tests/nan.h create mode 100644 gnulib-tool-tests/import-tests/diffutils-20230801/gnulib-tests/test-raise.c create mode 100644 gnulib-tool-tests/import-tests/diffutils-20230801/gnulib-tests/unicase/.gitignore create mode 100644 gnulib-tool-tests/import-tests/diffutils-20230801/gnulib-tests/unictype/.gitignore create mode 100644 gnulib-tool-tests/import-tests/diffutils-20230801/gnulib-tests/unistr/.gitignore create mode 100644 gnulib-tool-tests/import-tests/diffutils-20230801/gnulib-tests/uniwidth/.gitignore create mode 100644 gnulib-tool-tests/import-tests/diffutils-20230801/lib/.gitignore create mode 100644 gnulib-tool-tests/import-tests/diffutils-20230801/lib/glthread/.gitignore create mode 100644 gnulib-tool-tests/import-tests/diffutils-20230801/lib/malloc/.gitignore create mode 100644 gnulib-tool-tests/import-tests/diffutils-20230801/lib/unicase/.gitignore create mode 100644 gnulib-tool-tests/import-tests/diffutils-20230801/lib/unictype/.gitignore create mode 100644 gnulib-tool-tests/import-tests/diffutils-20230801/lib/unistr/.gitignore create mode 100644 gnulib-tool-tests/import-tests/diffutils-20230801/lib/uniwidth/.gitignore create mode 100644 gnulib-tool-tests/import-tests/diffutils-20230801/m4/.gitignore create mode 100644 gnulib-tool-tests/import-tests/diffutils-20230801/m4/gnulib-cache.m4 create mode 100644 gnulib-tool-tests/import-tests/diffutils-20230801/m4/gnulib-comp.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.err create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.out create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/.gitignore create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/GNUmakefile create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/Makefile.am create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/README-release create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/build-aux/.gitignore create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/build-aux/announce-gen create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/build-aux/config.rpath create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/build-aux/do-release-commit-and-tag create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/build-aux/gendocs.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/build-aux/git-version-gen create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/build-aux/gitlog-to-changelog create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/build-aux/gnu-web-doc-update create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/build-aux/gnupload create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/build-aux/update-copyright create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/build-aux/useless-if-before-free create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/build-aux/vc-list-files create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/configure.ac create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/doc/.gitignore create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/doc/gendocs_template create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/doc/gendocs_template_min create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/.gitignore create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/.gitignore~ create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/_Noreturn.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/accept.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/alloca.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/altstack-util.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/anytostr.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/arg-nonnull.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/arpa_inet.in.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/asnprintf.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/at-func.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/atoll.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/bind.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/c++defs.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/c-strcasestr.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/c-strcasestr.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/c32rtomb.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/c32tob.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/connect.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/dtotimespec.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/fdopen.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/float+.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/float.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/float.in.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/fpucw.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/ftruncate.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/glthread/.gitignore create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/glthread/thread.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/glthread/thread.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/gnulib.mk create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/hash-pjw.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/hash-pjw.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/imaxtostr.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/inet_pton.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/infinity.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/init.sh create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/inttostr.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/inttostr.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/ioctl.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/isnan.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/isnand-nolibm.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/isnand.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/isnanf-nolibm.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/isnanf.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/isnanl-nolibm.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/isnanl.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/itold.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/listen.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/locale.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/macros.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/math.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/math.in.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/minus-zero.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/mmap-anon-util.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/nan.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/nan.h~ create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/nanosleep.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/nap.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/netinet_in.in.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/offtostr.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/perror.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/printf-args.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/printf-args.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/printf-parse.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/printf-parse.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/priv-set.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/priv-set.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/pselect.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/pthread-thread.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/pthread.in.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/pthread_sigmask.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/putenv.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/rmdir.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/root-uid.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/sched.in.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/select.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/setsockopt.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/signature.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/signbitd.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/signbitf.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/signbitl.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/signed-nan.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/signed-snan.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/size_max.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/sleep.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/snan.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/snprintf.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/socket.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/sockets.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/sockets.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/str-two-way.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/strerror_r.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/symlink.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/symlinkat.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/sys_ioctl.in.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/sys_select.in.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/sys_socket.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/sys_socket.in.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/sys_uio.in.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-accept.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-alignasof.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-alloca-opt.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-argmatch.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-arpa_inet.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-assert.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-binary-io.c create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-binary-io.sh create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-bind.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-bitrotate.c create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-btoc32-1.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-btoc32-2.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-btoc32-3.sh create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-btoc32.c create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-btowc-1.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-btowc-2.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-btowc-3.sh create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-btowc.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c-ctype.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c-stack.c create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c-stack.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c-stack2.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c-strcase.sh create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c-strcasecmp.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c-strcasestr.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c-strncasecmp.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32_apply_type_test.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32_get_type_test.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isalnum.c create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isalnum.sh create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isalpha.c create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isalpha.sh create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isblank.c create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isblank.sh create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32iscntrl.c create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32iscntrl.sh create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isdigit.c create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isdigit.sh create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isgraph.c create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isgraph.sh create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32islower.c create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32islower.sh create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isprint.c create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isprint.sh create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32ispunct.c create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32ispunct.sh create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isspace.c create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isspace.sh create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isupper.c create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isupper.sh create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isxdigit.c create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isxdigit.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32rtomb-w32-2.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32rtomb-w32-3.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32rtomb-w32-4.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32rtomb-w32-5.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32rtomb-w32-6.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32rtomb-w32-7.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32rtomb-w32-8.sh create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32rtomb-w32.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32rtomb.c create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32rtomb.sh create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32tolower.c create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32tolower.sh create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32width.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-calloc-gnu.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-chdir.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-cloexec.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-close.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-connect.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-count-leading-zeros.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-ctype.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-dirent.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-dirfd.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-dirname.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-dup-safer.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-dup.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-dup2.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-dynarray.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-environ.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-errno.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-error.c create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-error.sh create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-exclude.c create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-exclude1.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-exclude2.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-exclude3.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-exclude4.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-exclude5.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-exclude6.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-exclude7.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-exclude8.sh create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fchdir.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fcntl-h.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fcntl.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fdopen.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fdopendir.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fgetc.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-filenamecat.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-float.c create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch-1.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch-2.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch-3.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch-4.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch-5.sh create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch-h.c create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch-w32-2.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch-w32-3.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch-w32-4.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch-w32-5.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch-w32-6.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch-w32-7.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch-w32-8.sh create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch-w32.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fopen-gnu.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fopen.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fopen.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fputc.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fread.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-free.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-freopen.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fstat.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fstatat.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-ftruncate.c create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-ftruncate.sh create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fwrite.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-getcwd-lgpl.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-getdtablesize.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-getopt-gnu.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-getopt-main.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-getopt-posix.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-getopt.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-getopt_long.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-getprogname.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-getrandom.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-gettimeofday.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-hard-locale.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-hash.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-ignore-value.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-inet_pton.c create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-init.sh create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-intprops.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-inttostr.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-inttypes.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-ioctl.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-isblank.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-isnand-nolibm.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-isnand.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-isnanf-nolibm.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-isnanf.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-isnanl-nolibm.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-isnanl.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-iswblank.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-iswctype.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-iswdigit.c create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-iswdigit.sh create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-iswpunct.c create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-iswpunct.sh create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-iswxdigit.c create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-iswxdigit.sh create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-langinfo.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-largefile.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-limits-h.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-listen.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-localcharset.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-locale.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-localeconv.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-lstat.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-lstat.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-malloc-gnu.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-malloca.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-math.c create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtoc32-1.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtoc32-2.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtoc32-3.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtoc32-4.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtoc32-5.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtoc32-w32-2.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtoc32-w32-3.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtoc32-w32-4.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtoc32-w32-5.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtoc32-w32-6.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtoc32-w32-7.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtoc32-w32-8.sh create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtoc32-w32.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtoc32.c create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtowc-1.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtowc-2.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtowc-3.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtowc-4.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtowc-5.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtowc-w32-2.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtowc-w32-3.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtowc-w32-4.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtowc-w32-5.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtowc-w32-6.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtowc-w32-7.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtowc-w32-8.sh create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtowc-w32.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtowc.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbscasecmp.c create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbscasecmp.sh create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbsinit.c create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbsinit.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbsrtoc32s-1.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbsrtoc32s-2.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbsrtoc32s-3.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbsrtoc32s-4.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbsrtoc32s-5.sh create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbsrtoc32s.c create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbsrtowcs-1.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbsrtowcs-2.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbsrtowcs-3.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbsrtowcs-4.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbsrtowcs-5.sh create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbsrtowcs.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-memchr.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-memrchr.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mkdir.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mkdir.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-nanosleep.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-netinet_in.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-nl_langinfo-mt.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-nl_langinfo1.c create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-nl_langinfo1.sh create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-nl_langinfo2.c create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-nl_langinfo2.sh create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-nstrftime.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-nullptr.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-open.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-open.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-openat.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-pathmax.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-perror.c create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-perror.sh create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-perror2.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-pipe.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-popen.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-popen.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-priv-set.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-pselect.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-pthread-thread.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-pthread.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-pthread_sigmask1.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-pthread_sigmask2.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-quotearg-simple.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-quotearg.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-raise.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-raise.c~ create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-rawmemchr.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-readlink.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-readlink.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-readlinkat.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-realloc-gnu.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-reallocarray.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-regex.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-rmdir.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-rmdir.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sched.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-select-fd.c create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-select-in.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-select-out.sh create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-select-stdin.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-select.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-select.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-setenv.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-setlocale_null-mt-all.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-setlocale_null-mt-one.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-setlocale_null.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-setsockopt.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sh-quote.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sigaction.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-signal-h.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-signbit.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sigprocmask.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sigsegv-catch-segv1.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sigsegv-catch-segv2.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sigsegv-catch-stackoverflow1.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sigsegv-catch-stackoverflow2.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sleep.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-snprintf.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sockets.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-stat-time.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-stat.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-stat.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-stdbool.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-stdckdint.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-stddef.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-stdint.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-stdio.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-stdlib.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-strerror.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-strerror_r.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-string.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-strings.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-strnlen.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-strtoimax.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-strtoll.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-symlink.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-symlink.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-symlinkat.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sys_ioctl.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sys_random.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sys_select.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sys_socket.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sys_stat.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sys_time.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sys_types.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sys_uio.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sys_wait.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sys_wait.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-thread_create.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-thread_self.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-time-h.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-time.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-timespec.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-timespec_get.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-uchar.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-unistd.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-unlink.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-unlink.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-unlinkat.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-unsetenv.c create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-update-copyright.sh create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-vasnprintf.c create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-vc-list-files-cvs.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-vc-list-files-git.sh create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-verify-try.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-verify.c create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-verify.sh create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-version-etc.c create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-version-etc.sh create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-wchar.c create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-wcrtomb-w32-2.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-wcrtomb-w32-3.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-wcrtomb-w32-4.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-wcrtomb-w32-5.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-wcrtomb-w32-6.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-wcrtomb-w32-7.sh create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-wcrtomb-w32-8.sh create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-wcrtomb-w32.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-wcrtomb.c create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-wcrtomb.sh create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-wctype-h.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-wctype.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-wcwidth.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-xalloc-die.c create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-xalloc-die.sh create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-xstdopen.c create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-xstdopen.sh create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-xstrtoimax.c create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-xstrtoimax.sh create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-xstrtol.c create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-xstrtol.sh create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-xstrtoul.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-year2038.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/time.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/timespec-add.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/timespec-sub.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/uinttostr.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/umaxtostr.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unicase/.gitignore create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unicase/test-mapping-part1.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unicase/test-mapping-part2.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unicase/test-uc_tolower.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/.gitignore create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/test-ctype_alnum.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/test-ctype_alpha.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/test-ctype_blank.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/test-ctype_cntrl.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/test-ctype_digit.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/test-ctype_graph.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/test-ctype_lower.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/test-ctype_print.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/test-ctype_punct.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/test-ctype_space.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/test-ctype_upper.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/test-ctype_xdigit.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/test-predicate-part1.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/test-predicate-part2.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unistr/.gitignore create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unistr/test-chr.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unistr/test-cpy.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unistr/test-pcpy.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unistr/test-set.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unistr/test-strcat.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unistr/test-u32-chr.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unistr/test-u32-cpy.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unistr/test-u32-pcpy.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unistr/test-u32-set.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unistr/test-u32-strcat.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unistr/test-u32-strlen.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unistr/u-set.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unistr/u32-set.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/uniwidth/.gitignore create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/uniwidth/test-uc_width.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/uniwidth/test-uc_width2.c create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/uniwidth/test-uc_width2.sh create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unlink.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unlinkat.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unlinkdir.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unlinkdir.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/vasnprintf.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/vasnprintf.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/w32sock.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/warn-on-use.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/wctob.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/wctomb-impl.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/wctomb.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/windows-thread.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/windows-thread.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/windows-tls.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/windows-tls.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/xsize.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/xsize.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/xstrtol-error.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/xstrtol-error.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/zerosize-ptr.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/.gitignore create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/.gitignore~ create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/_Noreturn.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/alloca.in.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/allocator.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/allocator.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/arg-nonnull.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/argmatch.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/argmatch.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/assert.in.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/assure.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/at-func.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/attribute.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/basename-lgpl.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/basename-lgpl.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/basename.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/binary-io.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/binary-io.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/bitrotate.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/bitrotate.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/btoc32.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/btowc.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c++defs.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c-ctype.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c-ctype.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c-file-type.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c-stack.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c-stack.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c-strcase.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c-strcasecmp.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c-strcaseeq.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c-strncasecmp.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32_apply_type_test.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32_get_type_test.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32is-impl.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32isalnum.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32isalpha.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32isblank.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32iscntrl.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32isdigit.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32isgraph.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32islower.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32isprint.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32ispunct.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32isspace.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32isupper.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32isxdigit.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32to-impl.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32tolower.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32width.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/calloc.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/careadlinkat.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/careadlinkat.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/cdefs.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/chdir-long.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/chdir-long.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/cloexec.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/cloexec.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/close.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/closedir.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/count-leading-zeros.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/count-leading-zeros.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/ctype.in.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/diffseq.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/dirent-private.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/dirent.in.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/dirfd.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/dirname-lgpl.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/dirname.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/dirname.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/dup-safer-flag.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/dup-safer.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/dup.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/dup2.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/dynarray.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/errno.in.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/error.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/error.in.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/exclude.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/exclude.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/exitfail.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/exitfail.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/fchdir.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/fcntl.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/fcntl.in.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/fd-hook.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/fd-hook.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/fd-safer-flag.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/fd-safer.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/fdopendir.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/file-type.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/file-type.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/filename.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/filenamecat-lgpl.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/filenamecat.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/filenamecat.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/flexmember.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/fnmatch.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/fnmatch.in.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/fnmatch_loop.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/fopen.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/free.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/freopen.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/fstat.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/fstatat.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getcwd-lgpl.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getdtablesize.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getopt-cdefs.in.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getopt-core.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getopt-ext.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getopt-pfx-core.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getopt-pfx-ext.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getopt.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getopt.in.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getopt1.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getopt_int.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getpagesize.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getprogname.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getprogname.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getrandom.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/gettext.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/gettime.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/gettimeofday.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/glthread/.gitignore create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/glthread/lock.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/glthread/lock.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/glthread/threadlib.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/gnulib.mk create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/hard-locale.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/hard-locale.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/hash.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/hash.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/ialloc.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/ialloc.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/idx.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/ignore-value.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/intprops-internal.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/intprops.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/inttypes.in.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/isblank.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/iswblank.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/iswctype-impl.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/iswctype.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/iswdigit.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/iswpunct.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/iswxdigit.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/langinfo.in.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/lc-charset-dispatch.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/lc-charset-dispatch.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/libc-config.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/limits.in.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/localcharset.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/localcharset.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/locale.in.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/localeconv.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/lstat.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/malloc.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/malloc/.gitignore create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/malloc/dynarray-skeleton.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/malloc/dynarray.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/malloc/dynarray_at_failure.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/malloc/dynarray_emplace_enlarge.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/malloc/dynarray_finalize.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/malloc/dynarray_resize.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/malloc/dynarray_resize_clear.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/malloca.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/malloca.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbchar.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbchar.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbrtoc32.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbrtowc-impl-utf8.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbrtowc-impl.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbrtowc.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbscasecmp.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbsinit.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbsrtoc32s-state.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbsrtoc32s.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbsrtowcs-impl.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbsrtowcs-state.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbsrtowcs.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbszero.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbtowc-impl.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbtowc-lock.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbtowc-lock.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbtowc.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbuiter.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbuiter.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbuiterf.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbuiterf.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/memchr.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/memchr.valgrind create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mempcpy.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/memrchr.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/minmax.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mkdir.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mkstemp.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mktime-internal.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mktime.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/msvc-inval.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/msvc-inval.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/msvc-nothrow.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/msvc-nothrow.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/nl_langinfo-lock.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/nl_langinfo.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/nstrftime.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/open.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/openat-die.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/openat-priv.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/openat-proc.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/openat.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/openat.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/opendir.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/pathmax.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/pclose.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/pipe-safer.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/pipe.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/popen.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/progname.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/progname.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/propername-lite.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/propername.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/quote.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/quotearg.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/quotearg.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/raise.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/rawmemchr.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/rawmemchr.valgrind create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/readdir.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/readlink.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/readlinkat.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/realloc.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/reallocarray.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/regcomp.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/regex.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/regex.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/regex_internal.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/regex_internal.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/regexec.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/same-inode.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/same-inode.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/save-cwd.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/save-cwd.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/setenv.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/setlocale-lock.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/setlocale_null.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/setlocale_null.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/sh-quote.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/sh-quote.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/sig-handler.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/sig-handler.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/sigaction.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/signal.in.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/sigprocmask.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/sigsegv.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/sigsegv.in.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stackvma.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stackvma.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stat-macros.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stat-time.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stat-time.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stat-w32.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stat-w32.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stat.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stdarg.in.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stdckdint.in.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stddef.in.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stdint.in.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stdio-read.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stdio-write.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stdio.in.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stdlib.in.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stdopen.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stdopen.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stpcpy.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strcasecmp.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strdup.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/streq.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strerror-override.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strerror-override.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strerror.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strftime.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/string.in.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strings.in.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stripslash.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strncasecmp.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strnlen.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strnlen1.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strnlen1.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strptime.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strtoimax.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strtol.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strtoll.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/sys_random.in.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/sys_stat.in.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/sys_time.in.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/sys_types.in.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/sys_wait.in.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/system-quote.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/system-quote.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/tempname.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/tempname.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/time-internal.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/time.in.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/time_r.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/time_rz.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/timegm.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/timespec.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/timespec.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/timespec_get.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/tzset.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/uchar.in.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unicase.in.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unicase/.gitignore create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unicase/simple-mapping.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unicase/tolower.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unicase/tolower.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype.in.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/.gitignore create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/bitmap.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_alnum.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_alnum.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_alpha.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_alpha.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_blank.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_blank.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_cntrl.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_cntrl.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_digit.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_digit.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_graph.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_graph.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_lower.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_lower.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_print.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_print.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_punct.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_punct.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_space.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_space.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_upper.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_upper.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_xdigit.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_xdigit.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/uninorm.in.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistd--.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistd-safer.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistd.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistd.in.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistr.in.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistr/.gitignore create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistr/u-cpy.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistr/u-pcpy.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistr/u-strcat.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistr/u-strlen.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistr/u32-chr.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistr/u32-cpy.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistr/u32-pcpy.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistr/u32-strcat.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistr/u32-strlen.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unitypes.in.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/uniwidth.in.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/uniwidth/.gitignore create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/uniwidth/cjk.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/uniwidth/width.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/uniwidth/width0.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/uniwidth/width2.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unlocked-io.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unsetenv.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/verify.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/version-etc-fsf.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/version-etc.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/version-etc.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/warn-on-use.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/wchar.in.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/wcrtomb.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/wctype-h.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/wctype-impl.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/wctype.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/wctype.in.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/wcwidth.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/windows-initguard.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/windows-mutex.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/windows-mutex.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/windows-once.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/windows-once.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/windows-recmutex.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/windows-recmutex.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/windows-rwlock.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/windows-rwlock.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/wmemchr-impl.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/wmemchr.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/wmempcpy.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/xalloc-die.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/xalloc-oversized.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/xalloc.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/xfreopen.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/xfreopen.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/xmalloc.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/xmalloca.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/xmalloca.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/xstdopen.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/xstdopen.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/xstrtoimax.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/xstrtol.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/xstrtol.h create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/xstrtoul.c create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/.gitignore create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/.gitignore~ create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/00gnulib.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/__inline.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/absolute-header.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/alloca.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/arpa_inet_h.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/asm-underscore.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/assert_h.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/atoll.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/btowc.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/builtin-expect.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/c-bool.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/c-stack.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/c32rtomb.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/calloc.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/chdir-long.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/clock_time.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/close.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/closedir.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/codeset.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/config-h.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/ctype_h.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/dirent_h.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/dirfd.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/double-slash-root.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/dup.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/dup2.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/eealloc.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/environ.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/errno_h.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/error.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/error_h.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/exponentd.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/exponentf.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/exponentl.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/extensions.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/extern-inline.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/fchdir.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/fclose.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/fcntl-o.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/fcntl.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/fcntl_h.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/fdopen.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/fdopendir.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/fflush.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/filenamecat.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/flexmember.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/float_h.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/fnmatch.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/fnmatch_h.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/fopen.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/fpieee.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/free.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/freopen.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/fstat.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/fstatat.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/ftruncate.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/getcwd.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/getdtablesize.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/getopt.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/getpagesize.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/getprogname.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/getrandom.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/gettime.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/gettimeofday.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/gnu-make.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/gnulib-cache.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/gnulib-cache.m4~ create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/gnulib-common.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/gnulib-comp.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/gnulib-comp.m4~ create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/gnulib-tool.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/host-cpu-c-abi.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/include_next.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/inet_pton.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/inline.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/intl-thread-locale.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/intmax_t.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/inttostr.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/inttypes.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/inttypes_h.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/ioctl.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/isblank.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/isnand.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/isnanf.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/isnanl.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/iswblank.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/iswctype.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/iswdigit.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/iswpunct.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/iswxdigit.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/langinfo_h.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/largefile.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/lib-ld.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/lib-link.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/lib-prefix.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/libsigsegv.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/libunistring-base.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/limits-h.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/localcharset.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/locale-fr.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/locale-ja.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/locale-tr.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/locale-zh.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/locale_h.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/localeconv.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/lock.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/lstat.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/malloc.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/malloca.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/manywarnings-c++.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/manywarnings.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/math_h.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/mbchar.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/mbiter.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/mbrtoc32.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/mbrtowc.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/mbsinit.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/mbsrtowcs.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/mbstate_t.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/mbtowc.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/memchr.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/mempcpy.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/memrchr.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/minmax.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/mkdir.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/mkstemp.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/mktime.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/mmap-anon.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/mode_t.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/msvc-inval.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/msvc-nothrow.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/multiarch.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/musl.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/nan-mips.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/nanosleep.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/netinet_in_h.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/nl_langinfo.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/nocrash.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/nstrftime.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/nullptr.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/off_t.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/open-cloexec.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/open-slash.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/open.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/openat.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/opendir.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/pathmax.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/pclose.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/perl.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/perror.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/pid_t.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/pipe.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/popen.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/printf.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/priv-set.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/pselect.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/pthread-thread.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/pthread_h.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/pthread_rwlock_rdlock.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/pthread_sigmask.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/putenv.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/quote.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/quotearg.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/raise.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/rawmemchr.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/readdir.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/readlink.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/readlinkat.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/realloc.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/reallocarray.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/regex.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/rmdir.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/save-cwd.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sched_h.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/select.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/setenv.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/setlocale_null.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sigaction.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sigaltstack.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/signal_h.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/signalblocking.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/signbit.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sigsegv.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/size_max.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sleep.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/snan.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/snprintf.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/socketlib.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sockets.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/socklen.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sockpfaf.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/ssize_t.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/stack-direction.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/stat-time.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/stat.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/std-gnu11.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/stdalign.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/stdarg.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/stddef_h.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/stdint.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/stdint_h.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/stdio_h.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/stdlib_h.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/stpcpy.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/strcase.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/strdup.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/strerror.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/strerror_r.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/string_h.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/strings_h.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/strnlen.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/strptime.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/strtoimax.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/strtoll.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/symlink.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/symlinkat.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sys_ioctl_h.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sys_random_h.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sys_select_h.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sys_socket_h.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sys_stat_h.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sys_time_h.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sys_types_h.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sys_uio_h.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sys_wait_h.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/tempname.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/thread.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/threadlib.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/time.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/time_h.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/time_r.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/time_rz.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/timegm.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/timespec.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/timespec_get.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/tm_gmtoff.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/tzset.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/uchar_h.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/unicase_h.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/unictype_h.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/uninorm_h.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/unistd-safer.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/unistd_h.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/unlink.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/unlinkat.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/unlinkdir.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/unlocked-io.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/vararrays.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/vasnprintf.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/version-etc.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/visibility.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/warn-on-use.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/warnings.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/wchar_h.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/wchar_t.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/wcrtomb.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/wctob.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/wctomb.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/wctype.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/wctype_h.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/wcwidth.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/wint_t.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/wmemchr.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/wmempcpy.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/xalloc.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/xsize.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/xstrtol.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/zzgnulib.m4 create mode 100644 gnulib-tool-tests/import-tests/test-diffutils-1.result/maint.mk create mode 100755 gnulib-tool-tests/import-tests/test-diffutils-1.sh diff --git a/gnulib-tool-tests/import-tests/diffutils-20230801/.gitignore b/gnulib-tool-tests/import-tests/diffutils-20230801/.gitignore new file mode 100644 index 00000000..0e163f80 --- /dev/null +++ b/gnulib-tool-tests/import-tests/diffutils-20230801/.gitignore @@ -0,0 +1,117 @@ +*.a +*.exe +*.o +*.orig +*.patch +*.rej +*~ +.Tpo +.deps/ +.dirstamp +.gdb-history +/*.diff +/ABOUT-NLS +/GNUmakefile +/INSTALL +/README-release +/aclocal.m4 +/autom4te.cache/ +/build-aux/ +/confdefs* +/config.cache +/config.log +/config.status +/configure +/conftest* +/diffutils-*.tar.xz +/gnulib-tests/ +/m4/ +/maint.mk +ChangeLog +ID +Makefile +Makefile.in +TAGS +doc/.gitignore +doc/diffutils.aux +doc/diffutils.cp +doc/diffutils.cps +doc/diffutils.info +doc/diffutils.log +doc/diffutils.toc +doc/stamp-vti +doc/version.texi +lib/*/ +lib/.gitignore +lib/alloca.h +lib/arg-nonnull.h +lib/c++defs.h +lib/charset.alias +lib/config.h +lib/config.hin +lib/configmake.h +lib/ctype.h +lib/dirent.h +lib/error.h +lib/errno.h +lib/fcntl.h +lib/fnmatch.h +lib/getopt-cdefs.h +lib/getopt.h +lib/iconv*.h +lib/inttypes.h +lib/langinfo.h +lib/limits.h +lib/locale.h +lib/ref-add.sed +lib/ref-del.sed +lib/signal.h +lib/sigsegv.h +lib/stamp-h1 +lib/stdarg.h +lib/stdckdint.h +lib/stddef.h +lib/stdint.h +lib/stdio.h +lib/stdlib.h +# For some reason 'bootstrap' doesn't add /stdopen.[ch] to lib/.gitignore. +lib/stdopen.[ch] +lib/string.h +lib/strings.h +lib/time.h +lib/unicase.h +lib/unictype.h +lib/uninorm.h +lib/unistd.h +lib/unistr/ +lib/unistr.h +lib/unitypes.h +lib/uniwidth/ +lib/uniwidth.h +lib/warn-on-use.h +lib/wchar.h +lib/wctype.h +lib/uchar.h +man/*.1 +po/*.gmo +po/*.po +po/*.pot +po/*.sed +po/.gitignore +po/.reference +po/LINGUAS +po/Makefile.in.in +po/Makevars +po/Makevars.template +po/POTFILES +po/Rules-quot +po/stamp-po +src/cmp +src/diff +src/diff3 +src/paths.h +src/sdiff +src/version.[ch] +tests/*.log +tests/*.trs +vc-dwim-log-* diff --git a/gnulib-tool-tests/import-tests/diffutils-20230801/Makefile.am b/gnulib-tool-tests/import-tests/diffutils-20230801/Makefile.am new file mode 100644 index 00000000..c47bc830 --- /dev/null +++ b/gnulib-tool-tests/import-tests/diffutils-20230801/Makefile.am @@ -0,0 +1,58 @@ +# Main Automakefile for GNU diffutils. + +# Copyright (C) 2001-2002, 2004, 2006, 2009-2013, 2015-2023 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 . + +ALL_RECURSIVE_TARGETS = + +EXTRA_DIST = bootstrap exgettext ChangeLog-2008 cfg.mk dist-check.mk +SUBDIRS = lib src tests doc man po gnulib-tests + +ACLOCAL_AMFLAGS = -I m4 +AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS) + +# Arrange so that .tarball-version appears only in the distribution +# tarball, and never in a checked-out repository. +dist-hook: gen-ChangeLog + $(AM_V_GEN)echo $(VERSION) > $(distdir)/.tarball-version + +gen_start_date = '2009-11-11 15:00' +.PHONY: gen-ChangeLog +gen-ChangeLog: + $(AM_V_GEN)if test -d .git; then \ + $(top_srcdir)/build-aux/gitlog-to-changelog \ + --since=$(gen_start_date) > $(distdir)/cl-t && \ + { rm -f $(distdir)/ChangeLog && \ + mv $(distdir)/cl-t $(distdir)/ChangeLog; } \ + fi + +ALL_RECURSIVE_TARGETS += distcheck-hook +distcheck-hook: + $(MAKE) my-distcheck + +# Some of our git hook scripts are supposed to be identical to git's samples. +# See if they are still in sync. +.PHONY: check-git-hook-script-sync +check-git-hook-script-sync: + @fail=0; \ + t=$$(mktemp -d) \ + && cd $$t && git init -q && cd .git/hooks \ + && for i in pre-commit pre-applypatch applypatch-msg; do \ + diff -u $(abs_top_srcdir)/scripts/git-hooks/$$i $$i.sample \ + || fail=1; \ + done; \ + rm -rf $$t; \ + test $$fail = 0 diff --git a/gnulib-tool-tests/import-tests/diffutils-20230801/build-aux/.gitignore b/gnulib-tool-tests/import-tests/diffutils-20230801/build-aux/.gitignore new file mode 100644 index 00000000..dbc68bb5 --- /dev/null +++ b/gnulib-tool-tests/import-tests/diffutils-20230801/build-aux/.gitignore @@ -0,0 +1,11 @@ +/config.rpath +/announce-gen +/do-release-commit-and-tag +/gendocs.sh +/git-version-gen +/gitlog-to-changelog +/gnu-web-doc-update +/gnupload +/update-copyright +/useless-if-before-free +/vc-list-files diff --git a/gnulib-tool-tests/import-tests/diffutils-20230801/configure.ac b/gnulib-tool-tests/import-tests/diffutils-20230801/configure.ac new file mode 100644 index 00000000..1779fcda --- /dev/null +++ b/gnulib-tool-tests/import-tests/diffutils-20230801/configure.ac @@ -0,0 +1,182 @@ +# Configure template for GNU Diffutils. + +# Copyright (C) 1994-1995, 1998, 2001-2002, 2004, 2006, 2009-2013, 2015-2023 +# 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 . + +AC_PREREQ([2.64]) + +AC_INIT([GNU diffutils], + m4_esyscmd([build-aux/git-version-gen .tarball-version]), + [bug-diffutils@gnu.org], + [diffutils], + [https://www.gnu.org/software/diffutils/]) + +AC_CONFIG_SRCDIR([src/diff.c]) +AC_CONFIG_AUX_DIR([build-aux]) +AC_CONFIG_MACRO_DIR([m4]) + +AM_INIT_AUTOMAKE([1.11 dist-xz no-dist-gzip subdir-objects + color-tests parallel-tests]) +AM_SILENT_RULES([yes]) # make --enable-silent-rules the default. + +AC_CONFIG_HEADERS([lib/config.h:lib/config.hin]) + +AC_PROG_AWK +AC_PROG_CC +AM_MISSING_PROG([HELP2MAN], [help2man]) +AC_PROG_RANLIB +gl_EARLY +gl_USE_SYSTEM_EXTENSIONS +gl_INIT + +# Ensure VLAs are not used. +# Note -Wvla is implicitly added by gl_MANYWARN_ALL_GCC +AC_DEFINE([GNULIB_NO_VLA], [1], [Define to 1 to disable use of VLAs]) + +# diffutils is single-threaded; optimize for this. +AC_DEFINE([GNULIB_EXCLUDE_SINGLE_THREAD], [1], + ['exclude' code is called only from 1 thread.]) +AC_DEFINE([GNULIB_MBRTOWC_SINGLE_THREAD], [1], + ['mbrtowc', 'mbrtoc32', 'regex' code is called only from 1 thread.]) +AC_DEFINE([GNULIB_REGEX_SINGLE_THREAD], [1], + ['regex' code is called only from 1 thread.]) +AC_DEFINE([GNULIB_WCHAR_SINGLE_LOCALE], [1], + [Locale-sensitive functions are called only after locale is set.]) + +# gl_GCC_VERSION_IFELSE([major], [minor], [run-if-found], [run-if-not-found]) +# ------------------------------------------------ +# If $CPP is gcc-MAJOR.MINOR or newer, then run RUN-IF-FOUND. +# Otherwise, run RUN-IF-NOT-FOUND. +AC_DEFUN([gl_GCC_VERSION_IFELSE], + [AC_PREPROC_IFELSE( + [AC_LANG_PROGRAM( + [[ +#if ($1) < __GNUC__ || (($1) == __GNUC__ && ($2) <= __GNUC_MINOR__) +/* ok */ +#else +# error "your version of gcc is older than $1.$2" +#endif + ]]), + ], [$3], [$4]) + ] +) + +AC_ARG_ENABLE([gcc-warnings], + [AS_HELP_STRING([[--enable-gcc-warnings[=TYPE]]], + [control generation of GCC warnings. The TYPE 'no' disables + warnings (default for non-developer builds); 'yes' generates + cheap warnings if available (default for developer builds); + 'expensive' in addition generates expensive-to-compute warnings + if available.])], + [case $enableval in + no|yes|expensive) ;; + *) AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;; + esac + gl_gcc_warnings=$enableval], + [ + # GCC provides fine-grained control over diagnostics which + # is used in gnulib for example to suppress warnings from + # certain sections of code. So if this is available and + # we're running from a git repo, then auto enable the warnings. + gl_gcc_warnings=no + gl_GCC_VERSION_IFELSE([4], [6], + [test -d "$srcdir"/.git \ + && ! test -f "$srcdir"/.tarball-version \ + && gl_gcc_warnings=yes])] +) + +if test $gl_gcc_warnings != no; then + gl_WARN_ADD([-Werror], [WERROR_CFLAGS]) + AC_SUBST([WERROR_CFLAGS]) + + ew= + AS_IF([test $gl_gcc_warnings != expensive], + [# -fanalyzer and related options slow GCC considerably. + ew="$ew -fanalyzer -Wno-analyzer-malloc-leak"]) + + # This, $nw, is the list of warnings we disable. + nw=$ew + nw="$nw -Winline" # not a correctness warning + nw="$nw -Wstack-protector" # not a correctness warning + + gl_MANYWARN_ALL_GCC([ws]) + gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw]) + for w in $ws; do + gl_WARN_ADD([$w]) + done + gl_WARN_ADD([-Wno-sign-compare]) # Too many false positives + gl_WARN_ADD([-Wno-format-nonliteral]) + + AC_SUBST([WARN_CFLAGS]) + + AH_VERBATIM([FORTIFY_SOURCE], + [/* Enable compile-time and run-time bounds-checking, and some warnings, + without upsetting glibc 2.15+. */ + #if !defined _FORTIFY_SOURCE && defined __OPTIMIZE__ && __OPTIMIZE__ \ + && !defined __MINGW32__ + # define _FORTIFY_SOURCE 2 + #endif + ]) + AC_DEFINE([GNULIB_PORTCHECK], [1], [enable some gnulib portability checks]) +fi + +AC_C_INLINE + +AC_DEFINE([DEFAULT_EDITOR_PROGRAM], ["ed"], + [Name of editor program, unless overridden.]) + +AC_PATH_PROG([PR_PROGRAM], [pr], [""]) +AC_DEFINE_UNQUOTED([PR_PROGRAM], ["$PR_PROGRAM"], [Name of "pr" program.]) + +AC_CHECK_MEMBERS([struct stat.st_blksize]) +AC_CHECK_MEMBERS([struct stat.st_rdev]) +AC_HEADER_DIRENT +AC_HEADER_SYS_WAIT +AC_TYPE_PID_T + +AC_CHECK_FUNCS_ONCE([sigaction sigprocmask]) +if test $ac_cv_func_sigprocmask = no; then + AC_CHECK_FUNCS([sigblock]) +fi +AC_FUNC_FORK + +# When .tarball-version exists, we're building from a tarball +# and must not make man/*.1 files depend on the generated src/version.c, +# because that would induce a requirement to run the help2man perl script. +# We are not yet prepared to make perl a build-from-tarball requirement. +# Hence, here we detect .tarball-version existence. When not present, +# we define a variable to be used in man/Makefile.am to induce the +# proper dependency (so that man/*.1 will be rebuilt upon any version change), +# but not when built from a tarball. +AC_SUBST([SRC_VERSION_C]) +test -f $srcdir/.tarball-version \ + && SRC_VERSION_C= \ + || SRC_VERSION_C=../src/version.c + +AM_GNU_GETTEXT([external], [need-ngettext]) +AM_GNU_GETTEXT_VERSION([0.19.2]) +XGETTEXT="AWK='$AWK' \$(SHELL) \$(top_srcdir)/exgettext $XGETTEXT" + +AC_CONFIG_FILES([ + Makefile doc/Makefile + lib/Makefile + src/Makefile + tests/Makefile + gnulib-tests/Makefile + man/Makefile + po/Makefile.in +]) +AC_OUTPUT diff --git a/gnulib-tool-tests/import-tests/diffutils-20230801/doc/.gitignore b/gnulib-tool-tests/import-tests/diffutils-20230801/doc/.gitignore new file mode 100644 index 00000000..847f66f4 --- /dev/null +++ b/gnulib-tool-tests/import-tests/diffutils-20230801/doc/.gitignore @@ -0,0 +1,2 @@ +/gendocs_template +/gendocs_template_min diff --git a/gnulib-tool-tests/import-tests/diffutils-20230801/gnulib-tests/.gitignore b/gnulib-tool-tests/import-tests/diffutils-20230801/gnulib-tests/.gitignore new file mode 100644 index 00000000..daa3020b --- /dev/null +++ b/gnulib-tool-tests/import-tests/diffutils-20230801/gnulib-tests/.gitignore @@ -0,0 +1,448 @@ +/_Noreturn.h +/accept.c +/alloca.c +/altstack-util.h +/arg-nonnull.h +/arpa_inet.in.h +/asnprintf.c +/atoll.c +/bind.c +/c++defs.h +/c-strcasestr.c +/c-strcasestr.h +/connect.c +/dtotimespec.c +/fdopen.c +/float+.h +/float.c +/float.in.h +/fpucw.h +/ftruncate.c +/gnulib.mk +/hash-pjw.c +/hash-pjw.h +/inet_pton.c +/init.sh +/ioctl.c +/itold.c +/listen.c +/locale.c +/macros.h +/mmap-anon-util.h +/nan.h +/nanosleep.c +/nap.h +/netinet_in.in.h +/perror.c +/printf-args.c +/printf-args.h +/printf-parse.c +/printf-parse.h +/pselect.c +/pthread-thread.c +/pthread.in.h +/pthread_sigmask.c +/putenv.c +/sched.in.h +/select.c +/setsockopt.c +/signature.h +/size_max.h +/sleep.c +/snprintf.c +/socket.c +/sockets.c +/sockets.h +/str-two-way.h +/strerror_r.c +/symlink.c +/sys_ioctl.in.h +/sys_select.in.h +/sys_socket.c +/sys_socket.in.h +/sys_uio.in.h +/test-accept.c +/test-alignasof.c +/test-alloca-opt.c +/test-argmatch.c +/test-arpa_inet.c +/test-assert.c +/test-binary-io.c +/test-binary-io.sh +/test-bind.c +/test-bitrotate.c +/test-btowc.c +/test-btowc1.sh +/test-btowc2.sh +/test-btowc3.sh +/test-c-ctype.c +/test-c-stack.c +/test-c-stack.sh +/test-c-stack2.sh +/test-c-strcase.sh +/test-c-strcasecmp.c +/test-c-strcasestr.c +/test-c-strncasecmp.c +/test-calloc-gnu.c +/test-cloexec.c +/test-close.c +/test-connect.c +/test-ctype.c +/test-dirname.c +/test-dup2.c +/test-dynarray.c +/test-environ.c +/test-errno.c +/test-error.c +/test-error.sh +/test-exclude.c +/test-exclude1.sh +/test-exclude2.sh +/test-exclude3.sh +/test-exclude4.sh +/test-exclude5.sh +/test-exclude6.sh +/test-exclude7.sh +/test-exclude8.sh +/test-fcntl-h.c +/test-fcntl.c +/test-fdopen.c +/test-fgetc.c +/test-filenamecat.c +/test-float.c +/test-fnmatch-h.c +/test-fnmatch.c +/test-fopen-gnu.c +/test-fopen.c +/test-fopen.h +/test-fputc.c +/test-fread.c +/test-free.c +/test-freopen.c +/test-fstat.c +/test-ftruncate.c +/test-ftruncate.sh +/test-fwrite.c +/test-getcwd-lgpl.c +/test-getdtablesize.c +/test-getopt-gnu.c +/test-getopt-main.h +/test-getopt-posix.c +/test-getopt.h +/test-getopt_long.h +/test-getprogname.c +/test-getrandom.c +/test-gettimeofday.c +/test-hard-locale.c +/test-hash.c +/test-ignore-value.c +/test-inet_pton.c +/test-init.sh +/test-intprops.c +/test-inttostr.c +/test-inttypes.c +/test-ioctl.c +/test-isblank.c +/test-iswblank.c +/test-iswdigit.c +/test-iswdigit.sh +/test-iswxdigit.c +/test-iswxdigit.sh +/test-langinfo.c +/test-largefile.c +/test-limits-h.c +/test-listen.c +/test-localcharset.c +/test-locale.c +/test-localeconv.c +/test-lstat.c +/test-lstat.h +/test-malloc-gnu.c +/test-malloca.c +/test-mbrtowc-w32-1.sh +/test-mbrtowc-w32-2.sh +/test-mbrtowc-w32-3.sh +/test-mbrtowc-w32-4.sh +/test-mbrtowc-w32-5.sh +/test-mbrtowc-w32-6.sh +/test-mbrtowc-w32-7.sh +/test-mbrtowc-w32.c +/test-mbrtowc.c +/test-mbrtowc1.sh +/test-mbrtowc2.sh +/test-mbrtowc3.sh +/test-mbrtowc4.sh +/test-mbrtowc5.sh +/test-mbscasecmp.c +/test-mbscasecmp.sh +/test-mbsinit.c +/test-mbsinit.sh +/test-mbsrtowcs.c +/test-mbsrtowcs1.sh +/test-mbsrtowcs2.sh +/test-mbsrtowcs3.sh +/test-mbsrtowcs4.sh +/test-mbsrtowcs5.sh +/test-memchr.c +/test-mkdir.c +/test-mkdir.h +/test-nanosleep.c +/test-netinet_in.c +/test-nl_langinfo-mt.c +/test-nl_langinfo1.c +/test-nl_langinfo1.sh +/test-nl_langinfo2.c +/test-nl_langinfo2.sh +/test-nstrftime.c +/test-nullptr.c +/test-open.c +/test-open.h +/test-pathmax.c +/test-perror.c +/test-perror.sh +/test-perror2.c +/test-pipe.c +/test-pselect.c +/test-pthread-thread.c +/test-pthread.c +/test-pthread_sigmask1.c +/test-pthread_sigmask2.c +/test-quotearg-simple.c +/test-quotearg.h +/test-raise.c +/test-rawmemchr.c +/test-realloc-gnu.c +/test-reallocarray.c +/test-regex.c +/test-sched.c +/test-select-fd.c +/test-select-in.sh +/test-select-out.sh +/test-select-stdin.c +/test-select.c +/test-select.h +/test-setenv.c +/test-setlocale_null-mt-all.c +/test-setlocale_null-mt-one.c +/test-setlocale_null.c +/test-setsockopt.c +/test-sh-quote.c +/test-signal-h.c +/test-sigprocmask.c +/test-sigsegv-catch-segv1.c +/test-sigsegv-catch-segv2.c +/test-sigsegv-catch-stackoverflow1.c +/test-sigsegv-catch-stackoverflow2.c +/test-sleep.c +/test-snprintf.c +/test-sockets.c +/test-stat-time.c +/test-stat.c +/test-stat.h +/test-stdbool.c +/test-stdckdint.c +/test-stddef.c +/test-stdint.c +/test-stdio.c +/test-stdlib.c +/test-strerror.c +/test-strerror_r.c +/test-string.c +/test-strings.c +/test-strnlen.c +/test-strtoimax.c +/test-strtoll.c +/test-symlink.c +/test-symlink.h +/test-sys_ioctl.c +/test-sys_random.c +/test-sys_select.c +/test-sys_socket.c +/test-sys_stat.c +/test-sys_time.c +/test-sys_types.c +/test-sys_uio.c +/test-sys_wait.c +/test-sys_wait.h +/test-thread_create.c +/test-thread_self.c +/test-time-h.c +/test-time.c +/test-timespec.c +/test-unistd.c +/test-unsetenv.c +/test-update-copyright.sh +/test-vasnprintf.c +/test-vc-list-files-cvs.sh +/test-vc-list-files-git.sh +/test-verify-try.c +/test-verify.c +/test-verify.sh +/test-version-etc.c +/test-version-etc.sh +/test-wchar.c +/test-wcrtomb-w32-1.sh +/test-wcrtomb-w32-2.sh +/test-wcrtomb-w32-3.sh +/test-wcrtomb-w32-4.sh +/test-wcrtomb-w32-5.sh +/test-wcrtomb-w32-6.sh +/test-wcrtomb-w32-7.sh +/test-wcrtomb-w32.c +/test-wcrtomb.c +/test-wcrtomb.sh +/test-wctype-h.c +/test-wcwidth.c +/test-xalloc-die.c +/test-xalloc-die.sh +/test-xstdopen.c +/test-xstdopen.sh +/test-xstrtoimax.c +/test-xstrtoimax.sh +/test-xstrtol.c +/test-xstrtol.sh +/test-xstrtoul.c +/test-year2038.c +/time.c +/timespec-add.c +/timespec-sub.c +/vasnprintf.c +/vasnprintf.h +/w32sock.h +/warn-on-use.h +/wctob.c +/wctomb-impl.h +/wctomb.c +/windows-thread.c +/windows-thread.h +/windows-tls.c +/windows-tls.h +/xsize.c +/xsize.h +/xstrtol-error.c +/xstrtol-error.h +/zerosize-ptr.h +/c32rtomb.c +/c32tob.c +/test-btoc32-1.sh +/test-btoc32-2.sh +/test-btoc32-3.sh +/test-btoc32.c +/test-c32rtomb-w32-1.sh +/test-c32rtomb-w32-2.sh +/test-c32rtomb-w32-3.sh +/test-c32rtomb-w32-4.sh +/test-c32rtomb-w32-5.sh +/test-c32rtomb-w32-6.sh +/test-c32rtomb-w32-7.sh +/test-c32rtomb-w32.c +/test-c32rtomb.c +/test-c32rtomb.sh +/test-c32width.c +/test-count-leading-zeros.c +/test-mbrtoc32-1.sh +/test-mbrtoc32-2.sh +/test-mbrtoc32-3.sh +/test-mbrtoc32-4.sh +/test-mbrtoc32-5.sh +/test-mbrtoc32-w32-1.sh +/test-mbrtoc32-w32-2.sh +/test-mbrtoc32-w32-3.sh +/test-mbrtoc32-w32-4.sh +/test-mbrtoc32-w32-5.sh +/test-mbrtoc32-w32-6.sh +/test-mbrtoc32-w32-7.sh +/test-mbrtoc32-w32.c +/test-mbrtoc32.c +/test-uchar.c +/anytostr.c +/imaxtostr.c +/inttostr.c +/inttostr.h +/offtostr.c +/test-c32_apply_type_test.c +/test-c32_get_type_test.c +/test-c32isalnum.c +/test-c32isalnum.sh +/test-c32isalpha.c +/test-c32isalpha.sh +/test-c32isblank.c +/test-c32isblank.sh +/test-c32iscntrl.c +/test-c32iscntrl.sh +/test-c32isdigit.c +/test-c32isdigit.sh +/test-c32isgraph.c +/test-c32isgraph.sh +/test-c32islower.c +/test-c32islower.sh +/test-c32isprint.c +/test-c32isprint.sh +/test-c32ispunct.c +/test-c32ispunct.sh +/test-c32isspace.c +/test-c32isspace.sh +/test-c32isupper.c +/test-c32isupper.sh +/test-c32isxdigit.c +/test-c32isxdigit.sh +/test-c32tolower.c +/test-c32tolower.sh +/test-chdir.c +/test-dirent.c +/test-dirfd.c +/test-dup-safer.c +/test-dup.c +/test-fchdir.c +/test-fdopendir.c +/test-fnmatch-1.sh +/test-fnmatch-2.sh +/test-fnmatch-3.sh +/test-fnmatch-4.sh +/test-fnmatch-5.sh +/test-fnmatch-w32-1.sh +/test-fnmatch-w32-2.sh +/test-fnmatch-w32-3.sh +/test-fnmatch-w32-4.sh +/test-fnmatch-w32-5.sh +/test-fnmatch-w32-6.sh +/test-fnmatch-w32-7.sh +/test-fnmatch-w32.c +/test-fstatat.c +/test-mbsrtoc32s-1.sh +/test-mbsrtoc32s-2.sh +/test-mbsrtoc32s-3.sh +/test-mbsrtoc32s-4.sh +/test-mbsrtoc32s-5.sh +/test-mbsrtoc32s.c +/test-memrchr.c +/test-openat.c +/test-timespec_get.c +/uinttostr.c +/umaxtostr.c +/at-func.c +/priv-set.c +/priv-set.h +/rmdir.c +/root-uid.h +/symlinkat.c +/test-priv-set.c +/test-readlink.c +/test-readlink.h +/test-readlinkat.c +/test-rmdir.c +/test-rmdir.h +/test-sigaction.c +/test-symlinkat.c +/test-unlink.c +/test-unlink.h +/test-unlinkat.c +/unlink.c +/unlinkat.c +/unlinkdir.c +/unlinkdir.h +/test-popen.c +/test-popen.h +/btoc32.c +/test-areadlink.c +/test-areadlink.h diff --git a/gnulib-tool-tests/import-tests/diffutils-20230801/gnulib-tests/glthread/.gitignore b/gnulib-tool-tests/import-tests/diffutils-20230801/gnulib-tests/glthread/.gitignore new file mode 100644 index 00000000..55a7d140 --- /dev/null +++ b/gnulib-tool-tests/import-tests/diffutils-20230801/gnulib-tests/glthread/.gitignore @@ -0,0 +1,2 @@ +/thread.c +/thread.h diff --git a/gnulib-tool-tests/import-tests/diffutils-20230801/gnulib-tests/nan.h b/gnulib-tool-tests/import-tests/diffutils-20230801/gnulib-tests/nan.h new file mode 100644 index 00000000..05f141d2 --- /dev/null +++ b/gnulib-tool-tests/import-tests/diffutils-20230801/gnulib-tests/nan.h @@ -0,0 +1,85 @@ +/* Macros for not-a-number. + Copyright (C) 2007-2023 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 . */ + + +/* IBM z/OS supports both hexadecimal and IEEE floating-point formats. The + former does not support NaN and its isnan() implementation returns zero + for all values. */ +#if defined __MVS__ && defined __IBMC__ && !defined __BFP__ +# error "NaN is not supported with IBM's hexadecimal floating-point format; please re-compile with -qfloat=ieee" +#endif + +/* NaNf () returns a 'float' not-a-number. */ + +/* The Compaq (ex-DEC) C 6.4 compiler and the Microsoft MSVC 9 compiler choke + on the expression 0.0 / 0.0. The IBM XL C compiler on z/OS complains. + PGI 16.10 complains. */ +#if (defined __DECC || defined _MSC_VER \ + || (defined __MVS__ && defined __IBMC__) \ + || defined __PGI) +static float +NaNf () +{ + static float zero = 0.0f; + return zero / zero; +} +#else +# define NaNf() (0.0f / 0.0f) +#endif + + +/* NaNd () returns a 'double' not-a-number. */ + +/* The Compaq (ex-DEC) C 6.4 compiler and the Microsoft MSVC 9 compiler choke + on the expression 0.0 / 0.0. The IBM XL C compiler on z/OS complains. + PGI 16.10 complains. */ +#if (defined __DECC || defined _MSC_VER \ + || (defined __MVS__ && defined __IBMC__) \ + || defined __PGI) +static double +NaNd () +{ + static double zero = 0.0; + return zero / zero; +} +#else +# define NaNd() (0.0 / 0.0) +#endif + + +/* NaNl () returns a 'long double' not-a-number. */ + +/* On Irix 6.5, gcc 3.4.3 can't compute compile-time NaN, and needs the + runtime type conversion. + The Microsoft MSVC 9 compiler chokes on the expression 0.0L / 0.0L. + The IBM XL C compiler on z/OS complains. + PGI 16.10 complains. */ +#ifdef __sgi +static long double NaNl () +{ + double zero = 0.0; + return zero / zero; +} +#elif defined _MSC_VER || (defined __MVS__ && defined __IBMC__) || defined __PGI +static long double +NaNl () +{ + static long double zero = 0.0L; + return zero / zero; +} +#else +# define NaNl() (0.0L / 0.0L) +#endif diff --git a/gnulib-tool-tests/import-tests/diffutils-20230801/gnulib-tests/test-raise.c b/gnulib-tool-tests/import-tests/diffutils-20230801/gnulib-tests/test-raise.c new file mode 100644 index 00000000..7574b2b4 --- /dev/null +++ b/gnulib-tool-tests/import-tests/diffutils-20230801/gnulib-tests/test-raise.c @@ -0,0 +1,51 @@ +/* Test raising a signal. + Copyright (C) 2011-2023 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 . */ + +#include + +#include +#include + +#include "signature.h" +SIGNATURE_CHECK (raise, int, (int)); + +#include + +#include "macros.h" + +/* It is safe to use _Noreturn here: exit() never returns, and GCC knows that + exit() is a non-returning function, even on platforms where its declaration + in does not have the 'noreturn' attribute. */ +static _Noreturn void +handler (int sig) +{ + _exit (0); +} + +int +main (void) +{ + /* Test behaviour for invalid argument. */ + ASSERT (raise (-1) != 0); + + /* Test behaviour for SIGINT. */ + ASSERT (signal (SIGINT, handler) != SIG_ERR); + + raise (SIGINT); + + /* We should not get here, because the handler takes away the control. */ + exit (1); +} diff --git a/gnulib-tool-tests/import-tests/diffutils-20230801/gnulib-tests/unicase/.gitignore b/gnulib-tool-tests/import-tests/diffutils-20230801/gnulib-tests/unicase/.gitignore new file mode 100644 index 00000000..19cfffea --- /dev/null +++ b/gnulib-tool-tests/import-tests/diffutils-20230801/gnulib-tests/unicase/.gitignore @@ -0,0 +1,3 @@ +/test-mapping-part1.h +/test-mapping-part2.h +/test-uc_tolower.c diff --git a/gnulib-tool-tests/import-tests/diffutils-20230801/gnulib-tests/unictype/.gitignore b/gnulib-tool-tests/import-tests/diffutils-20230801/gnulib-tests/unictype/.gitignore new file mode 100644 index 00000000..e77e0507 --- /dev/null +++ b/gnulib-tool-tests/import-tests/diffutils-20230801/gnulib-tests/unictype/.gitignore @@ -0,0 +1,14 @@ +/test-ctype_alnum.c +/test-ctype_alpha.c +/test-ctype_blank.c +/test-ctype_cntrl.c +/test-ctype_digit.c +/test-ctype_graph.c +/test-ctype_lower.c +/test-ctype_print.c +/test-ctype_punct.c +/test-ctype_space.c +/test-ctype_upper.c +/test-ctype_xdigit.c +/test-predicate-part1.h +/test-predicate-part2.h diff --git a/gnulib-tool-tests/import-tests/diffutils-20230801/gnulib-tests/unistr/.gitignore b/gnulib-tool-tests/import-tests/diffutils-20230801/gnulib-tests/unistr/.gitignore new file mode 100644 index 00000000..57f6b56e --- /dev/null +++ b/gnulib-tool-tests/import-tests/diffutils-20230801/gnulib-tests/unistr/.gitignore @@ -0,0 +1,13 @@ +/test-chr.h +/test-cpy.h +/test-pcpy.h +/test-set.h +/test-strcat.h +/test-u32-chr.c +/test-u32-cpy.c +/test-u32-pcpy.c +/test-u32-set.c +/test-u32-strcat.c +/test-u32-strlen.c +/u-set.h +/u32-set.c diff --git a/gnulib-tool-tests/import-tests/diffutils-20230801/gnulib-tests/uniwidth/.gitignore b/gnulib-tool-tests/import-tests/diffutils-20230801/gnulib-tests/uniwidth/.gitignore new file mode 100644 index 00000000..2cd813bd --- /dev/null +++ b/gnulib-tool-tests/import-tests/diffutils-20230801/gnulib-tests/uniwidth/.gitignore @@ -0,0 +1,3 @@ +/test-uc_width.c +/test-uc_width2.c +/test-uc_width2.sh diff --git a/gnulib-tool-tests/import-tests/diffutils-20230801/lib/.gitignore b/gnulib-tool-tests/import-tests/diffutils-20230801/lib/.gitignore new file mode 100644 index 00000000..ab3d6f6f --- /dev/null +++ b/gnulib-tool-tests/import-tests/diffutils-20230801/lib/.gitignore @@ -0,0 +1,344 @@ +/_Noreturn.h +/alloca.in.h +/allocator.c +/allocator.h +/arg-nonnull.h +/argmatch.c +/argmatch.h +/assert.in.h +/assure.h +/attribute.h +/basename-lgpl.c +/basename-lgpl.h +/basename.c +/binary-io.c +/binary-io.h +/bitrotate.c +/bitrotate.h +/btowc.c +/c++defs.h +/c-ctype.c +/c-ctype.h +/c-stack.c +/c-stack.h +/c-strcase.h +/c-strcasecmp.c +/c-strcaseeq.h +/c-strncasecmp.c +/calloc.c +/careadlinkat.c +/careadlinkat.h +/cdefs.h +/cloexec.c +/cloexec.h +/close.c +/ctype.in.h +/diffseq.h +/dirname-lgpl.c +/dirname.c +/dirname.h +/dup2.c +/dynarray.h +/errno.in.h +/error.c +/error.in.h +/exclude.c +/exclude.h +/exitfail.c +/exitfail.h +/fcntl.c +/fcntl.in.h +/fd-hook.c +/fd-hook.h +/file-type.c +/file-type.h +/filename.h +/filenamecat-lgpl.c +/filenamecat.c +/filenamecat.h +/flexmember.h +/fnmatch.c +/fnmatch.in.h +/fnmatch_loop.c +/fopen.c +/free.c +/freopen.c +/fstat.c +/getdtablesize.c +/getopt-cdefs.in.h +/getopt-core.h +/getopt-ext.h +/getopt-pfx-core.h +/getopt-pfx-ext.h +/getopt.c +/getopt.in.h +/getopt1.c +/getopt_int.h +/getpagesize.c +/getprogname.c +/getprogname.h +/getrandom.c +/gettext.h +/gettime.c +/gettimeofday.c +/gnulib.mk +/hard-locale.c +/hard-locale.h +/hash.c +/hash.h +/ialloc.c +/ialloc.h +/idx.h +/ignore-value.h +/intprops-internal.h +/intprops.h +/inttypes.in.h +/isblank.c +/iswblank.c +/iswdigit.c +/iswxdigit.c +/langinfo.in.h +/lc-charset-dispatch.c +/lc-charset-dispatch.h +/libc-config.h +/limits.in.h +/localcharset.c +/localcharset.h +/locale.in.h +/localeconv.c +/lstat.c +/malloc.c +/malloca.c +/malloca.h +/mbchar.c +/mbchar.h +/mbrtowc-impl-utf8.h +/mbrtowc-impl.h +/mbrtowc.c +/mbscasecmp.c +/mbsinit.c +/mbsrtowcs-impl.h +/mbsrtowcs-state.c +/mbsrtowcs.c +/mbtowc-impl.h +/mbtowc-lock.c +/mbtowc-lock.h +/mbtowc.c +/mbuiter.c +/mbuiter.h +/memchr.c +/memchr.valgrind +/mempcpy.c +/minmax.h +/mkdir.c +/mkstemp.c +/mktime-internal.h +/mktime.c +/msvc-inval.c +/msvc-inval.h +/msvc-nothrow.c +/msvc-nothrow.h +/nl_langinfo-lock.c +/nl_langinfo.c +/nstrftime.c +/open.c +/pathmax.h +/progname.c +/progname.h +/propername.h +/quote.h +/quotearg.c +/quotearg.h +/raise.c +/rawmemchr.c +/rawmemchr.valgrind +/realloc.c +/reallocarray.c +/regcomp.c +/regex.c +/regex.h +/regex_internal.c +/regex_internal.h +/regexec.c +/setenv.c +/setlocale-lock.c +/setlocale_null.c +/setlocale_null.h +/sh-quote.c +/sh-quote.h +/signal.in.h +/sigprocmask.c +/sigsegv.c +/sigsegv.in.h +/stackvma.c +/stackvma.h +/stat-macros.h +/stat-time.c +/stat-time.h +/stat-w32.c +/stat-w32.h +/stat.c +/stdarg.in.h +/stdckdint.in.h +/stddef.in.h +/stdint.in.h +/stdio-read.c +/stdio-write.c +/stdio.in.h +/stdlib.in.h +/stdopen.c +/stdopen.h +/stpcpy.c +/strcasecmp.c +/streq.h +/strerror-override.c +/strerror-override.h +/strerror.c +/strftime.h +/string.in.h +/strings.in.h +/stripslash.c +/strncasecmp.c +/strnlen.c +/strnlen1.c +/strnlen1.h +/strptime.c +/strtoimax.c +/strtol.c +/strtoll.c +/sys_random.in.h +/sys_stat.in.h +/sys_time.in.h +/sys_types.in.h +/sys_wait.in.h +/system-quote.c +/system-quote.h +/tempname.c +/tempname.h +/time-internal.h +/time.in.h +/time_r.c +/time_rz.c +/timegm.c +/timespec.c +/timespec.h +/tzset.c +/unistd.c +/unistd.in.h +/unitypes.in.h +/uniwidth.in.h +/unlocked-io.h +/unsetenv.c +/verify.h +/version-etc-fsf.c +/version-etc.c +/version-etc.h +/warn-on-use.h +/wchar.in.h +/wcrtomb.c +/wctype-h.c +/wctype.in.h +/wcwidth.c +/windows-initguard.h +/windows-mutex.c +/windows-mutex.h +/windows-once.c +/windows-once.h +/windows-recmutex.c +/windows-recmutex.h +/windows-rwlock.c +/windows-rwlock.h +/wmemchr-impl.h +/wmemchr.c +/wmempcpy.c +/xalloc-die.c +/xalloc-oversized.h +/xalloc.h +/xfreopen.c +/xfreopen.h +/xmalloc.c +/xmalloca.c +/xmalloca.h +/xstdopen.c +/xstdopen.h +/xstrtoimax.c +/xstrtol.c +/xstrtol.h +/xstrtoul.c +/c32width.c +/count-leading-zeros.c +/count-leading-zeros.h +/mbrtoc32.c +/propername-lite.c +/same-inode.h +/uchar.in.h +/at-func.c +/btoc32.c +/c32_apply_type_test.c +/c32_get_type_test.c +/c32is-impl.h +/c32isalnum.c +/c32isalpha.c +/c32isblank.c +/c32iscntrl.c +/c32isdigit.c +/c32isgraph.c +/c32islower.c +/c32isprint.c +/c32ispunct.c +/c32isspace.c +/c32isupper.c +/c32isxdigit.c +/c32to-impl.h +/c32tolower.c +/chdir-long.c +/chdir-long.h +/closedir.c +/dirent-private.h +/dirent.in.h +/dirfd.c +/dup-safer-flag.c +/dup-safer.c +/dup.c +/fchdir.c +/fd-safer-flag.c +/fd-safer.c +/fdopendir.c +/fstatat.c +/getcwd-lgpl.c +/mbsrtoc32s-state.c +/mbsrtoc32s.c +/mbszero.c +/mbuiterf.c +/mbuiterf.h +/memrchr.c +/openat-die.c +/openat-priv.h +/openat-proc.c +/openat.c +/openat.h +/opendir.c +/pipe-safer.c +/pipe.c +/save-cwd.c +/save-cwd.h +/strdup.c +/timespec_get.c +/unicase.in.h +/unictype.in.h +/uninorm.in.h +/unistd--.h +/unistd-safer.h +/unistr.in.h +/readlink.c +/readlinkat.c +/sig-handler.c +/sig-handler.h +/sigaction.c +/popen.c +/pclose.c +/readdir.c +/areadlink.c +/areadlink.h +/xreadlink.c +/xreadlink.h diff --git a/gnulib-tool-tests/import-tests/diffutils-20230801/lib/glthread/.gitignore b/gnulib-tool-tests/import-tests/diffutils-20230801/lib/glthread/.gitignore new file mode 100644 index 00000000..e0605e15 --- /dev/null +++ b/gnulib-tool-tests/import-tests/diffutils-20230801/lib/glthread/.gitignore @@ -0,0 +1,3 @@ +/lock.c +/lock.h +/threadlib.c diff --git a/gnulib-tool-tests/import-tests/diffutils-20230801/lib/malloc/.gitignore b/gnulib-tool-tests/import-tests/diffutils-20230801/lib/malloc/.gitignore new file mode 100644 index 00000000..0c6fbbe9 --- /dev/null +++ b/gnulib-tool-tests/import-tests/diffutils-20230801/lib/malloc/.gitignore @@ -0,0 +1,7 @@ +/dynarray-skeleton.c +/dynarray.h +/dynarray_at_failure.c +/dynarray_emplace_enlarge.c +/dynarray_finalize.c +/dynarray_resize.c +/dynarray_resize_clear.c diff --git a/gnulib-tool-tests/import-tests/diffutils-20230801/lib/unicase/.gitignore b/gnulib-tool-tests/import-tests/diffutils-20230801/lib/unicase/.gitignore new file mode 100644 index 00000000..ec75a5ef --- /dev/null +++ b/gnulib-tool-tests/import-tests/diffutils-20230801/lib/unicase/.gitignore @@ -0,0 +1,3 @@ +/simple-mapping.h +/tolower.c +/tolower.h diff --git a/gnulib-tool-tests/import-tests/diffutils-20230801/lib/unictype/.gitignore b/gnulib-tool-tests/import-tests/diffutils-20230801/lib/unictype/.gitignore new file mode 100644 index 00000000..0ac94567 --- /dev/null +++ b/gnulib-tool-tests/import-tests/diffutils-20230801/lib/unictype/.gitignore @@ -0,0 +1,25 @@ +/bitmap.h +/ctype_alnum.c +/ctype_alnum.h +/ctype_alpha.c +/ctype_alpha.h +/ctype_blank.c +/ctype_blank.h +/ctype_cntrl.c +/ctype_cntrl.h +/ctype_digit.c +/ctype_digit.h +/ctype_graph.c +/ctype_graph.h +/ctype_lower.c +/ctype_lower.h +/ctype_print.c +/ctype_print.h +/ctype_punct.c +/ctype_punct.h +/ctype_space.c +/ctype_space.h +/ctype_upper.c +/ctype_upper.h +/ctype_xdigit.c +/ctype_xdigit.h diff --git a/gnulib-tool-tests/import-tests/diffutils-20230801/lib/unistr/.gitignore b/gnulib-tool-tests/import-tests/diffutils-20230801/lib/unistr/.gitignore new file mode 100644 index 00000000..ccbc8da0 --- /dev/null +++ b/gnulib-tool-tests/import-tests/diffutils-20230801/lib/unistr/.gitignore @@ -0,0 +1,9 @@ +/u-cpy.h +/u-pcpy.h +/u-strcat.h +/u-strlen.h +/u32-chr.c +/u32-cpy.c +/u32-pcpy.c +/u32-strcat.c +/u32-strlen.c diff --git a/gnulib-tool-tests/import-tests/diffutils-20230801/lib/uniwidth/.gitignore b/gnulib-tool-tests/import-tests/diffutils-20230801/lib/uniwidth/.gitignore new file mode 100644 index 00000000..ba2320c6 --- /dev/null +++ b/gnulib-tool-tests/import-tests/diffutils-20230801/lib/uniwidth/.gitignore @@ -0,0 +1,4 @@ +/cjk.h +/width.c +/width0.h +/width2.h diff --git a/gnulib-tool-tests/import-tests/diffutils-20230801/m4/.gitignore b/gnulib-tool-tests/import-tests/diffutils-20230801/m4/.gitignore new file mode 100644 index 00000000..04ff0db2 --- /dev/null +++ b/gnulib-tool-tests/import-tests/diffutils-20230801/m4/.gitignore @@ -0,0 +1,271 @@ +/iconv.m4 +/xsize.m4 +/wint_t.m4 +/wchar_t.m4 +/visibility.m4 +/uintmax_t.m4 +/threadlib.m4 +/stdint_h.m4 +/size_max.m4 +/progtest.m4 +/printf-posix.m4 +/po.m4 +/nls.m4 +/longlong.m4 +/lock.m4 +/lib-prefix.m4 +/lib-link.m4 +/lib-ld.m4 +/lcmessage.m4 +/inttypes_h.m4 +/inttypes-pri.m4 +/intmax.m4 +/intlmacosx.m4 +/intldir.m4 +/intl.m4 +/intdiv0.m4 +/glibc21.m4 +/glibc2.m4 +/gettext.m4 +/fcntl-o.m4 +/extern-inline.m4 +/codeset.m4 +/00gnulib.m4 +/__inline.m4 +/absolute-header.m4 +/alloca.m4 +/arpa_inet_h.m4 +/asm-underscore.m4 +/assert_h.m4 +/atoll.m4 +/btowc.m4 +/builtin-expect.m4 +/c-bool.m4 +/c-stack.m4 +/calloc.m4 +/clock_time.m4 +/close.m4 +/config-h.m4 +/ctype_h.m4 +/double-slash-root.m4 +/dup2.m4 +/eealloc.m4 +/environ.m4 +/errno_h.m4 +/error.m4 +/error_h.m4 +/exponentd.m4 +/extensions.m4 +/fclose.m4 +/fcntl.m4 +/fcntl_h.m4 +/fdopen.m4 +/fflush.m4 +/filenamecat.m4 +/flexmember.m4 +/float_h.m4 +/fnmatch.m4 +/fnmatch_h.m4 +/fopen.m4 +/fpieee.m4 +/free.m4 +/freopen.m4 +/fstat.m4 +/ftruncate.m4 +/getcwd.m4 +/getdtablesize.m4 +/getopt.m4 +/getpagesize.m4 +/getprogname.m4 +/getrandom.m4 +/gettime.m4 +/gettimeofday.m4 +/gnu-make.m4 +/gnulib-common.m4 +/gnulib-comp.m4 +/gnulib-tool.m4 +/host-cpu-c-abi.m4 +/include_next.m4 +/inet_pton.m4 +/intl-thread-locale.m4 +/intmax_t.m4 +/inttostr.m4 +/inttypes.m4 +/ioctl.m4 +/isblank.m4 +/iswblank.m4 +/iswdigit.m4 +/iswxdigit.m4 +/langinfo_h.m4 +/largefile.m4 +/libsigsegv.m4 +/libunistring-base.m4 +/limits-h.m4 +/localcharset.m4 +/locale-fr.m4 +/locale-ja.m4 +/locale-tr.m4 +/locale-zh.m4 +/locale_h.m4 +/localeconv.m4 +/lstat.m4 +/malloc.m4 +/malloca.m4 +/manywarnings-c++.m4 +/manywarnings.m4 +/math_h.m4 +/mbchar.m4 +/mbiter.m4 +/mbrtowc.m4 +/mbsinit.m4 +/mbsrtowcs.m4 +/mbstate_t.m4 +/mbtowc.m4 +/memchr.m4 +/mempcpy.m4 +/minmax.m4 +/mkdir.m4 +/mkstemp.m4 +/mktime.m4 +/mmap-anon.m4 +/mode_t.m4 +/msvc-inval.m4 +/msvc-nothrow.m4 +/multiarch.m4 +/musl.m4 +/nanosleep.m4 +/netinet_in_h.m4 +/nl_langinfo.m4 +/nocrash.m4 +/nstrftime.m4 +/nullptr.m4 +/off_t.m4 +/open-cloexec.m4 +/open-slash.m4 +/open.m4 +/pathmax.m4 +/perl.m4 +/perror.m4 +/pid_t.m4 +/pipe.m4 +/printf.m4 +/pselect.m4 +/pthread-thread.m4 +/pthread_h.m4 +/pthread_rwlock_rdlock.m4 +/pthread_sigmask.m4 +/putenv.m4 +/quote.m4 +/quotearg.m4 +/raise.m4 +/rawmemchr.m4 +/realloc.m4 +/reallocarray.m4 +/regex.m4 +/sched_h.m4 +/select.m4 +/setenv.m4 +/setlocale_null.m4 +/sigaltstack.m4 +/signal_h.m4 +/signalblocking.m4 +/sigsegv.m4 +/sleep.m4 +/snprintf.m4 +/socketlib.m4 +/sockets.m4 +/socklen.m4 +/sockpfaf.m4 +/ssize_t.m4 +/stack-direction.m4 +/stat-time.m4 +/stat.m4 +/std-gnu11.m4 +/stdalign.m4 +/stdarg.m4 +/stddef_h.m4 +/stdint.m4 +/stdio_h.m4 +/stdlib_h.m4 +/stpcpy.m4 +/strcase.m4 +/strerror.m4 +/strerror_r.m4 +/string_h.m4 +/strings_h.m4 +/strnlen.m4 +/strptime.m4 +/strtoimax.m4 +/strtoll.m4 +/symlink.m4 +/sys_ioctl_h.m4 +/sys_random_h.m4 +/sys_select_h.m4 +/sys_socket_h.m4 +/sys_stat_h.m4 +/sys_time_h.m4 +/sys_types_h.m4 +/sys_uio_h.m4 +/sys_wait_h.m4 +/tempname.m4 +/thread.m4 +/time.m4 +/time_h.m4 +/time_r.m4 +/time_rz.m4 +/timegm.m4 +/timespec.m4 +/tm_gmtoff.m4 +/tzset.m4 +/unistd_h.m4 +/unlocked-io.m4 +/vararrays.m4 +/vasnprintf.m4 +/version-etc.m4 +/warn-on-use.m4 +/warnings.m4 +/wchar_h.m4 +/wcrtomb.m4 +/wctob.m4 +/wctomb.m4 +/wctype_h.m4 +/wcwidth.m4 +/wmemchr.m4 +/wmempcpy.m4 +/xalloc.m4 +/xstrtol.m4 +/zzgnulib.m4 +/c32rtomb.m4 +/mbrtoc32.m4 +/uchar_h.m4 +/chdir-long.m4 +/closedir.m4 +/dirent_h.m4 +/dirfd.m4 +/dup.m4 +/fchdir.m4 +/fdopendir.m4 +/fstatat.m4 +/inline.m4 +/memrchr.m4 +/openat.m4 +/opendir.m4 +/save-cwd.m4 +/strdup.m4 +/timespec_get.m4 +/unicase_h.m4 +/unictype_h.m4 +/uninorm_h.m4 +/unistd-safer.m4 +/priv-set.m4 +/readlink.m4 +/readlinkat.m4 +/rmdir.m4 +/sigaction.m4 +/symlinkat.m4 +/unlink.m4 +/unlinkat.m4 +/unlinkdir.m4 +/pclose.m4 +/popen.m4 +/readdir.m4 diff --git a/gnulib-tool-tests/import-tests/diffutils-20230801/m4/gnulib-cache.m4 b/gnulib-tool-tests/import-tests/diffutils-20230801/m4/gnulib-cache.m4 new file mode 100644 index 00000000..de176c13 --- /dev/null +++ b/gnulib-tool-tests/import-tests/diffutils-20230801/m4/gnulib-cache.m4 @@ -0,0 +1,245 @@ +# Copyright (C) 2002-2023 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 +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This file 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 file. If not, see . +# +# As a special exception to the GNU General Public License, +# this file may be distributed as part of a program that +# contains a configuration script generated by Autoconf, under +# the same distribution terms as the rest of that program. +# +# Generated by gnulib-tool. +# +# This file represents the specification of how gnulib-tool is used. +# It acts as a cache: It is written and read by gnulib-tool. +# In projects that use version control, this file is meant to be put under +# version control, like the configure.ac and various Makefile.am files. + + +# Specification in the form of a command-line invocation: +# gnulib-tool --import --local-dir=gl \ +# --lib=libdiffutils \ +# --source-base=lib \ +# --m4-base=m4 \ +# --doc-base=doc \ +# --tests-base=gnulib-tests \ +# --aux-dir=build-aux \ +# --with-tests \ +# --makefile-name=gnulib.mk \ +# --no-conditional-dependencies \ +# --no-libtool \ +# --macro-prefix=gl \ +# --avoid=localename \ +# --avoid=lock-tests \ +# --avoid=setlocale \ +# announce-gen \ +# argmatch \ +# assert-h \ +# attribute \ +# binary-io \ +# builtin-expect \ +# c-ctype \ +# c-stack \ +# c32isspace \ +# c32tolower \ +# c32width \ +# config-h \ +# count-leading-zeros \ +# diffseq \ +# dirname \ +# do-release-commit-and-tag \ +# dup2 \ +# error \ +# exclude \ +# exitfail \ +# extensions \ +# extern-inline \ +# fcntl \ +# fdopendir \ +# file-type \ +# filenamecat \ +# flexmember \ +# fnmatch-gnu \ +# getopt-gnu \ +# gettext-h \ +# git-version-gen \ +# gitlog-to-changelog \ +# gnu-make \ +# gnu-web-doc-update \ +# gnumakefile \ +# gnupload \ +# hard-locale \ +# ialloc \ +# idx \ +# intprops \ +# inttypes \ +# isblank \ +# largefile \ +# lstat \ +# maintainer-makefile \ +# manywarnings \ +# mbrtoc32 \ +# mempcpy \ +# minmax \ +# mkstemp \ +# mktime \ +# nstrftime \ +# nullptr \ +# perl \ +# progname \ +# propername-lite \ +# raise \ +# rawmemchr \ +# readme-release \ +# regex \ +# same-inode \ +# sh-quote \ +# signal \ +# sigprocmask \ +# stat \ +# stat-macros \ +# stat-time \ +# stdbool \ +# stdckdint \ +# stdint \ +# stpcpy \ +# strcase \ +# strptime \ +# strtoimax \ +# sys_wait \ +# system-quote \ +# time_rz \ +# timespec \ +# timespec_get \ +# unistd \ +# unlocked-io \ +# update-copyright \ +# verify \ +# version-etc \ +# version-etc-fsf \ +# xalloc \ +# xfreopen \ +# xmalloca \ +# xreadlink \ +# xstdopen \ +# xstrtoimax \ +# year2038 + +# Specification in the form of a few gnulib-tool.m4 macro invocations: +gl_LOCAL_DIR([gl]) +gl_MODULES([ + announce-gen + argmatch + assert-h + attribute + binary-io + builtin-expect + c-ctype + c-stack + c32isspace + c32tolower + c32width + config-h + count-leading-zeros + diffseq + dirname + do-release-commit-and-tag + dup2 + error + exclude + exitfail + extensions + extern-inline + fcntl + fdopendir + file-type + filenamecat + flexmember + fnmatch-gnu + getopt-gnu + gettext-h + git-version-gen + gitlog-to-changelog + gnu-make + gnu-web-doc-update + gnumakefile + gnupload + hard-locale + ialloc + idx + intprops + inttypes + isblank + largefile + lstat + maintainer-makefile + manywarnings + mbrtoc32 + mempcpy + minmax + mkstemp + mktime + nstrftime + nullptr + perl + progname + propername-lite + raise + rawmemchr + readme-release + regex + same-inode + sh-quote + signal + sigprocmask + stat + stat-macros + stat-time + stdbool + stdckdint + stdint + stpcpy + strcase + strptime + strtoimax + sys_wait + system-quote + time_rz + timespec + timespec_get + unistd + unlocked-io + update-copyright + verify + version-etc + version-etc-fsf + xalloc + xfreopen + xmalloca + xreadlink + xstdopen + xstrtoimax + year2038 +]) +gl_AVOID([ localename lock-tests setlocale]) +gl_SOURCE_BASE([lib]) +gl_M4_BASE([m4]) +gl_PO_BASE([]) +gl_DOC_BASE([doc]) +gl_TESTS_BASE([gnulib-tests]) +gl_WITH_TESTS +gl_LIB([libdiffutils]) +gl_MAKEFILE_NAME([gnulib.mk]) +gl_MACRO_PREFIX([gl]) +gl_PO_DOMAIN([]) +gl_WITNESS_C_MACRO([]) diff --git a/gnulib-tool-tests/import-tests/diffutils-20230801/m4/gnulib-comp.m4 b/gnulib-tool-tests/import-tests/diffutils-20230801/m4/gnulib-comp.m4 new file mode 100644 index 00000000..b7e7819c --- /dev/null +++ b/gnulib-tool-tests/import-tests/diffutils-20230801/m4/gnulib-comp.m4 @@ -0,0 +1,2831 @@ +# DO NOT EDIT! GENERATED AUTOMATICALLY! +# Copyright (C) 2002-2023 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 +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This file 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 file. If not, see . +# +# As a special exception to the GNU General Public License, +# this file may be distributed as part of a program that +# contains a configuration script generated by Autoconf, under +# the same distribution terms as the rest of that program. +# +# Generated by gnulib-tool. +# +# This file represents the compiled summary of the specification in +# gnulib-cache.m4. It lists the computed macro invocations that need +# to be invoked from configure.ac. +# In projects that use version control, this file can be treated like +# other built files. + + +# This macro should be invoked from ./configure.ac, in the section +# "Checks for programs", right after AC_PROG_CC, and certainly before +# any checks for libraries, header files, types and library functions. +AC_DEFUN([gl_EARLY], +[ + m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace + m4_pattern_allow([^gl_ES$])dnl a valid locale name + m4_pattern_allow([^gl_LIBOBJS$])dnl a variable + m4_pattern_allow([^gl_LTLIBOBJS$])dnl a variable + + # Pre-early section. + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + AC_REQUIRE([gl_PROG_AR_RANLIB]) + + # Code from module absolute-header: + # Code from module accept: + # Code from module accept-tests: + # Code from module alignasof: + # Code from module alignasof-tests: + # Code from module alloca: + # Code from module alloca-opt: + # Code from module alloca-opt-tests: + # Code from module allocator: + # Code from module announce-gen: + # Code from module areadlink: + # Code from module areadlink-tests: + # Code from module argmatch: + # Code from module argmatch-tests: + # Code from module arpa_inet: + # Code from module arpa_inet-tests: + # Code from module assert-h: + # Code from module assert-h-tests: + # Code from module assure: + # Code from module at-internal: + # Code from module atoll: + # Code from module attribute: + # Code from module basename-lgpl: + # Code from module binary-io: + # Code from module binary-io-tests: + # Code from module bind: + # Code from module bind-tests: + # Code from module bitrotate: + # Code from module bitrotate-tests: + # Code from module btoc32: + # Code from module btoc32-tests: + # Code from module btowc: + # Code from module btowc-tests: + # Code from module builtin-expect: + # Code from module c-ctype: + # Code from module c-ctype-tests: + # Code from module c-stack: + # Code from module c-stack-tests: + # Code from module c-strcase: + # Code from module c-strcase-tests: + # Code from module c-strcaseeq: + # Code from module c-strcasestr: + # Code from module c-strcasestr-tests: + # Code from module c32isspace: + # Code from module c32isspace-tests: + # Code from module c32rtomb: + # Code from module c32rtomb-tests: + # Code from module c32tob: + # Code from module c32tolower: + # Code from module c32tolower-tests: + # Code from module c32width: + # Code from module c32width-tests: + # Code from module c99: + # Code from module calloc-gnu: + # Code from module calloc-gnu-tests: + # Code from module calloc-posix: + # Code from module careadlinkat: + # Code from module chdir: + # Code from module chdir-long: + # Code from module chdir-tests: + # Code from module clock-time: + # Code from module cloexec: + # Code from module cloexec-tests: + # Code from module close: + # Code from module close-tests: + # Code from module closedir: + # Code from module config-h: + # Code from module connect: + # Code from module connect-tests: + # Code from module count-leading-zeros: + # Code from module count-leading-zeros-tests: + # Code from module ctype: + # Code from module ctype-tests: + # Code from module diffseq: + # Code from module dirent: + # Code from module dirent-tests: + # Code from module dirfd: + # Code from module dirfd-tests: + # Code from module dirname: + # Code from module dirname-lgpl: + # Code from module dirname-tests: + # Code from module do-release-commit-and-tag: + # Code from module double-slash-root: + # Code from module dtotimespec: + # Code from module dup: + # Code from module dup-tests: + # Code from module dup2: + # Code from module dup2-tests: + # Code from module environ: + # Code from module environ-tests: + # Code from module errno: + # Code from module errno-tests: + # Code from module error: + # Code from module error-h: + # Code from module error-tests: + # Code from module exclude: + # Code from module exclude-tests: + # Code from module exitfail: + # Code from module extensions: + # Code from module extern-inline: + # Code from module fchdir: + # Code from module fchdir-tests: + # Code from module fcntl: + # Code from module fcntl-h: + # Code from module fcntl-h-tests: + # Code from module fcntl-tests: + # Code from module fd-hook: + # Code from module fd-safer-flag: + # Code from module fdopen: + # Code from module fdopen-tests: + # Code from module fdopendir: + # Code from module fdopendir-tests: + # Code from module fgetc-tests: + # Code from module file-type: + # Code from module filename: + # Code from module filenamecat: + # Code from module filenamecat-lgpl: + # Code from module filenamecat-tests: + # Code from module flexmember: + # Code from module float: + # Code from module float-tests: + # Code from module fnmatch: + # Code from module fnmatch-gnu: + # Code from module fnmatch-h: + # Code from module fnmatch-h-tests: + # Code from module fnmatch-tests: + # Code from module fopen: + # Code from module fopen-gnu: + # Code from module fopen-gnu-tests: + # Code from module fopen-tests: + # Code from module fpieee: + AC_REQUIRE([gl_FP_IEEE]) + # Code from module fpucw: + # Code from module fputc-tests: + # Code from module fread-tests: + # Code from module free-posix: + # Code from module free-posix-tests: + # Code from module freopen: + # Code from module freopen-tests: + # Code from module fstat: + # Code from module fstat-tests: + # Code from module ftruncate: + # Code from module ftruncate-tests: + # Code from module fwrite-tests: + # Code from module gen-header: + # Code from module gendocs: + # Code from module getcwd-lgpl: + # Code from module getcwd-lgpl-tests: + # Code from module getdtablesize: + # Code from module getdtablesize-tests: + # Code from module getopt-gnu: + # Code from module getopt-gnu-tests: + # Code from module getopt-posix: + # Code from module getopt-posix-tests: + # Code from module getpagesize: + # Code from module getprogname: + # Code from module getprogname-tests: + # Code from module getrandom: + # Code from module getrandom-tests: + # Code from module gettext-h: + # Code from module gettime: + # Code from module gettimeofday: + # Code from module gettimeofday-tests: + # Code from module git-version-gen: + # Code from module gitlog-to-changelog: + # Code from module glibc-internal/dynarray: + # Code from module glibc-internal/dynarray-tests: + # Code from module gnu-make: + # Code from module gnu-web-doc-update: + # Code from module gnumakefile: + # Code from module gnupload: + # Code from module hard-locale: + # Code from module hard-locale-tests: + # Code from module hash: + # Code from module hash-pjw: + # Code from module hash-tests: + # Code from module havelib: + # Code from module host-cpu-c-abi: + # Code from module ialloc: + # Code from module idx: + # Code from module ignore-value: + # Code from module ignore-value-tests: + # Code from module include_next: + # Code from module inet_pton: + # Code from module inet_pton-tests: + # Code from module intprops: + # Code from module intprops-tests: + # Code from module inttostr: + # Code from module inttostr-tests: + # Code from module inttypes: + # Code from module inttypes-incomplete: + # Code from module inttypes-tests: + # Code from module ioctl: + # Code from module ioctl-tests: + # Code from module isblank: + # Code from module isblank-tests: + # Code from module iswblank: + # Code from module iswblank-tests: + # Code from module iswdigit: + # Code from module iswdigit-tests: + # Code from module iswxdigit: + # Code from module iswxdigit-tests: + # Code from module langinfo: + # Code from module langinfo-tests: + # Code from module largefile: + AC_REQUIRE([AC_SYS_LARGEFILE]) + # Code from module largefile-tests: + # Code from module libc-config: + # Code from module limits-h: + # Code from module limits-h-tests: + # Code from module listen: + # Code from module listen-tests: + # Code from module localcharset: + # Code from module localcharset-tests: + # Code from module locale: + # Code from module locale-tests: + # Code from module localeconv: + # Code from module localeconv-tests: + # Code from module lock: + # Code from module lstat: + # Code from module lstat-tests: + # Code from module maintainer-makefile: + # Code from module malloc-gnu: + # Code from module malloc-gnu-tests: + # Code from module malloc-posix: + # Code from module malloca: + # Code from module malloca-tests: + # Code from module manywarnings: + # Code from module mbchar: + # Code from module mbrtoc32: + # Code from module mbrtoc32-tests: + # Code from module mbrtowc: + # Code from module mbrtowc-tests: + # Code from module mbscasecmp: + # Code from module mbscasecmp-tests: + # Code from module mbsinit: + # Code from module mbsinit-tests: + # Code from module mbsrtowcs: + # Code from module mbsrtowcs-tests: + # Code from module mbtowc: + # Code from module mbuiter: + # Code from module memchr: + # Code from module memchr-tests: + # Code from module mempcpy: + # Code from module memrchr: + # Code from module memrchr-tests: + # Code from module minmax: + # Code from module mkdir: + # Code from module mkdir-tests: + # Code from module mkstemp: + # Code from module mktime: + # Code from module mktime-internal: + # Code from module msvc-inval: + # Code from module msvc-nothrow: + # Code from module multiarch: + # Code from module nanosleep: + # Code from module nanosleep-tests: + # Code from module netinet_in: + # Code from module netinet_in-tests: + # Code from module nl_langinfo: + # Code from module nl_langinfo-tests: + # Code from module nocrash: + # Code from module nstrftime: + # Code from module nstrftime-tests: + # Code from module nullptr: + # Code from module nullptr-tests: + # Code from module open: + # Code from module open-tests: + # Code from module openat: + # Code from module openat-die: + # Code from module openat-h: + # Code from module openat-tests: + # Code from module opendir: + # Code from module pathmax: + # Code from module pathmax-tests: + # Code from module perl: + # Code from module perror: + # Code from module perror-tests: + # Code from module pipe-posix: + # Code from module pipe-posix-tests: + # Code from module progname: + # Code from module propername-lite: + # Code from module pselect: + # Code from module pselect-tests: + # Code from module pthread-h: + gl_ANYTHREADLIB_EARLY + # Code from module pthread-h-tests: + # Code from module pthread-thread: + # Code from module pthread-thread-tests: + # Code from module pthread_sigmask: + # Code from module pthread_sigmask-tests: + # Code from module putenv: + # Code from module quote: + # Code from module quotearg: + # Code from module quotearg-simple: + # Code from module quotearg-simple-tests: + # Code from module raise: + # Code from module raise-tests: + # Code from module rawmemchr: + # Code from module rawmemchr-tests: + # Code from module readlink: + # Code from module readlink-tests: + # Code from module readme-release: + # Code from module realloc-gnu: + # Code from module realloc-gnu-tests: + # Code from module realloc-posix: + # Code from module reallocarray: + # Code from module reallocarray-tests: + # Code from module regex: + # Code from module regex-tests: + # Code from module same-inode: + # Code from module save-cwd: + # Code from module sched: + # Code from module sched-tests: + # Code from module select: + # Code from module select-tests: + # Code from module setenv: + # Code from module setenv-tests: + # Code from module setlocale-null: + # Code from module setlocale-null-tests: + # Code from module setsockopt: + # Code from module setsockopt-tests: + # Code from module sh-quote: + # Code from module sh-quote-tests: + # Code from module signal: + # Code from module signal-h: + # Code from module signal-h-tests: + # Code from module sigprocmask: + # Code from module sigprocmask-tests: + # Code from module sigsegv: + # Code from module sigsegv-tests: + # Code from module size_max: + # Code from module sleep: + # Code from module sleep-tests: + # Code from module snippet/_Noreturn: + # Code from module snippet/arg-nonnull: + # Code from module snippet/c++defs: + # Code from module snippet/warn-on-use: + # Code from module snprintf: + # Code from module snprintf-tests: + # Code from module socket: + # Code from module socketlib: + # Code from module sockets: + # Code from module sockets-tests: + # Code from module socklen: + # Code from module ssize_t: + # Code from module stat: + # Code from module stat-macros: + # Code from module stat-tests: + # Code from module stat-time: + # Code from module stat-time-tests: + # Code from module std-gnu11: + # Code from module stdarg: + dnl Some compilers (e.g., AIX 5.3 cc) need to be in c99 mode + dnl for the builtin va_copy to work. gl_PROG_CC_C99 arranges for this. + gl_PROG_CC_C99 + # Code from module stdarg-tests: + # Code from module stdbool: + # Code from module stdbool-tests: + # Code from module stdckdint: + # Code from module stdckdint-tests: + # Code from module stddef: + # Code from module stddef-tests: + # Code from module stdint: + # Code from module stdint-tests: + # Code from module stdio: + gl_STDIO_H_EARLY + # Code from module stdio-tests: + # Code from module stdlib: + # Code from module stdlib-tests: + # Code from module stdopen: + # Code from module stpcpy: + # Code from module strcase: + # Code from module strdup-posix: + # Code from module streq: + # Code from module strerror: + # Code from module strerror-override: + # Code from module strerror-tests: + # Code from module strerror_r-posix: + # Code from module strerror_r-posix-tests: + # Code from module string: + # Code from module string-tests: + # Code from module strings: + # Code from module strings-tests: + # Code from module strnlen: + # Code from module strnlen-tests: + # Code from module strnlen1: + # Code from module strptime: + # Code from module strtoimax: + # Code from module strtoimax-tests: + # Code from module strtoll: + # Code from module strtoll-tests: + # Code from module symlink: + # Code from module symlink-tests: + # Code from module sys_ioctl: + # Code from module sys_ioctl-tests: + # Code from module sys_random: + # Code from module sys_random-tests: + # Code from module sys_select: + # Code from module sys_select-tests: + # Code from module sys_socket: + # Code from module sys_socket-tests: + # Code from module sys_stat: + # Code from module sys_stat-tests: + # Code from module sys_time: + # Code from module sys_time-tests: + # Code from module sys_types: + # Code from module sys_types-tests: + # Code from module sys_uio: + # Code from module sys_uio-tests: + # Code from module sys_wait: + # Code from module sys_wait-tests: + # Code from module system-quote: + # Code from module tempname: + # Code from module test-framework-sh: + # Code from module test-framework-sh-tests: + # Code from module thread: + # Code from module thread-tests: + # Code from module threadlib: + gl_THREADLIB_EARLY + # Code from module time: + # Code from module time-h: + # Code from module time-h-tests: + # Code from module time-tests: + # Code from module time_r: + # Code from module time_rz: + # Code from module timegm: + # Code from module timespec: + # Code from module timespec-add: + # Code from module timespec-sub: + # Code from module timespec-tests: + # Code from module timespec_get: + # Code from module timespec_get-tests: + # Code from module tzset: + # Code from module uchar: + # Code from module uchar-tests: + # Code from module unicase/base: + # Code from module unicase/tolower: + # Code from module unicase/tolower-tests: + # Code from module unictype/base: + # Code from module unictype/ctype-space: + # Code from module unictype/ctype-space-tests: + # Code from module uninorm/base: + # Code from module unistd: + # Code from module unistd-safer: + # Code from module unistd-safer-tests: + # Code from module unistd-tests: + # Code from module unitypes: + # Code from module uniwidth/base: + # Code from module uniwidth/width: + # Code from module uniwidth/width-tests: + # Code from module unlocked-io: + # Code from module unlocked-io-internal: + # Code from module unsetenv: + # Code from module unsetenv-tests: + # Code from module update-copyright: + # Code from module update-copyright-tests: + # Code from module useless-if-before-free: + # Code from module vararrays: + # Code from module vasnprintf: + # Code from module vasnprintf-tests: + # Code from module vc-list-files: + # Code from module vc-list-files-tests: + # Code from module verify: + # Code from module verify-tests: + # Code from module version-etc: + # Code from module version-etc-fsf: + # Code from module version-etc-tests: + # Code from module warnings: + # Code from module wchar: + # Code from module wchar-tests: + # Code from module wcrtomb: + # Code from module wcrtomb-tests: + # Code from module wctob: + # Code from module wctomb: + # Code from module wctype-h: + # Code from module wctype-h-tests: + # Code from module wcwidth: + # Code from module wcwidth-tests: + # Code from module windows-mutex: + # Code from module windows-once: + # Code from module windows-recmutex: + # Code from module windows-rwlock: + # Code from module windows-thread: + # Code from module windows-tls: + # Code from module wmemchr: + # Code from module wmempcpy: + # Code from module xalloc: + # Code from module xalloc-die: + # Code from module xalloc-die-tests: + # Code from module xalloc-oversized: + # Code from module xfreopen: + # Code from module xmalloca: + # Code from module xreadlink: + # Code from module xsize: + # Code from module xstdopen: + # Code from module xstdopen-tests: + # Code from module xstrtoimax: + # Code from module xstrtoimax-tests: + # Code from module xstrtol: + # Code from module xstrtol-error: + # Code from module xstrtol-tests: + # Code from module year2038: + AC_REQUIRE([AC_SYS_YEAR2038]) + # Code from module year2038-tests: +]) + +# This macro should be invoked from ./configure.ac, in the section +# "Check for header files, types and library functions". +AC_DEFUN([gl_INIT], +[ + AC_CONFIG_LIBOBJ_DIR([gnulib-tests]) + AM_CONDITIONAL([GL_COND_LIBTOOL], [false]) + gl_cond_libtool=false + gl_libdeps= + gl_ltlibdeps= + gl_m4_base='m4' + m4_pushdef([AC_LIBOBJ], m4_defn([gl_LIBOBJ])) + m4_pushdef([AC_REPLACE_FUNCS], m4_defn([gl_REPLACE_FUNCS])) + m4_pushdef([AC_LIBSOURCES], m4_defn([gl_LIBSOURCES])) + m4_pushdef([gl_LIBSOURCES_LIST], []) + m4_pushdef([gl_LIBSOURCES_DIR], []) + m4_pushdef([GL_MACRO_PREFIX], [gl]) + m4_pushdef([GL_MODULE_INDICATOR_PREFIX], [GL]) + gl_COMMON + gl_source_base='lib' + gl_source_base_prefix= + gl_ALIGNASOF + gl_FUNC_ALLOCA + gl_CONDITIONAL_HEADER([alloca.h]) + AC_PROG_MKDIR_P + gl_ASSERT_H + gl_CONDITIONAL_HEADER([assert.h]) + AC_PROG_MKDIR_P + AC_REQUIRE([AC_CANONICAL_HOST]) + gl_FUNC_BTOWC + gl_CONDITIONAL([GL_COND_OBJ_BTOWC], + [test $HAVE_BTOWC = 0 || test $REPLACE_BTOWC = 1]) + AM_COND_IF([GL_COND_OBJ_BTOWC], [ + gl_PREREQ_BTOWC + ]) + gl_WCHAR_MODULE_INDICATOR([btowc]) + gl___BUILTIN_EXPECT + gl_C_STACK + AC_REQUIRE([gl_UCHAR_H]) + dnl Determine REPLACE_MBSTATE_T, from which GNULIB_defined_mbstate_t is + dnl determined. It describes how mbrtoc32 is implemented. + AC_REQUIRE([gl_MBSTATE_T_BROKEN]) + AC_REQUIRE([gl_MBRTOC32_SANITYCHECK]) + gl_UCHAR_MODULE_INDICATOR([c32isspace]) + AC_REQUIRE([gl_UCHAR_H]) + dnl Determine REPLACE_MBSTATE_T, from which GNULIB_defined_mbstate_t is + dnl determined. It describes how mbrtoc32 is implemented. + AC_REQUIRE([gl_MBSTATE_T_BROKEN]) + AC_REQUIRE([gl_MBRTOC32_SANITYCHECK]) + gl_UCHAR_MODULE_INDICATOR([c32tolower]) + AC_REQUIRE([gl_UCHAR_H]) + dnl Determine REPLACE_MBSTATE_T, from which GNULIB_defined_mbstate_t is + dnl determined. It describes how mbrtoc32 is implemented. + AC_REQUIRE([gl_MBSTATE_T_BROKEN]) + AC_REQUIRE([gl_MBRTOC32_SANITYCHECK]) + gl_UCHAR_MODULE_INDICATOR([c32width]) + gl_FUNC_CALLOC_GNU + if test $REPLACE_CALLOC_FOR_CALLOC_GNU = 1; then + AC_LIBOBJ([calloc]) + fi + gl_STDLIB_MODULE_INDICATOR([calloc-gnu]) + gl_FUNC_CALLOC_POSIX + if test $REPLACE_CALLOC_FOR_CALLOC_POSIX = 1; then + AC_LIBOBJ([calloc]) + fi + gl_STDLIB_MODULE_INDICATOR([calloc-posix]) + AC_REQUIRE([AC_C_RESTRICT]) + gl_CHECK_FUNCS_ANDROID([readlinkat], [[#include ]]) + gl_UNISTD_MODULE_INDICATOR([chdir]) + gl_FUNC_CHDIR_LONG + gl_CONDITIONAL([GL_COND_OBJ_CHDIR_LONG], + [test $gl_cv_have_unlimited_file_name_length = no]) + AM_COND_IF([GL_COND_OBJ_CHDIR_LONG], [ + gl_PREREQ_CHDIR_LONG + ]) + gl_CLOCK_TIME + gl_MODULE_INDICATOR_FOR_TESTS([cloexec]) + gl_FUNC_CLOSE + gl_CONDITIONAL([GL_COND_OBJ_CLOSE], [test $REPLACE_CLOSE = 1]) + gl_UNISTD_MODULE_INDICATOR([close]) + gl_FUNC_CLOSEDIR + gl_CONDITIONAL([GL_COND_OBJ_CLOSEDIR], + [test $HAVE_CLOSEDIR = 0 || test $REPLACE_CLOSEDIR = 1]) + gl_DIRENT_MODULE_INDICATOR([closedir]) + gl_CONFIG_H + gl_CTYPE_H + gl_CTYPE_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_DIRENT_H + gl_DIRENT_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_FUNC_DIRFD + gl_CONDITIONAL([GL_COND_OBJ_DIRFD], + [test $HAVE_DIRFD = 0 || test $REPLACE_DIRFD = 1]) + AM_COND_IF([GL_COND_OBJ_DIRFD], [ + gl_PREREQ_DIRFD + ]) + gl_DIRENT_MODULE_INDICATOR([dirfd]) + gl_MODULE_INDICATOR([dirname]) + gl_DOUBLE_SLASH_ROOT + gl_FUNC_DUP + gl_CONDITIONAL([GL_COND_OBJ_DUP], [test $REPLACE_DUP = 1]) + AM_COND_IF([GL_COND_OBJ_DUP], [ + gl_PREREQ_DUP + ]) + gl_UNISTD_MODULE_INDICATOR([dup]) + gl_FUNC_DUP2 + gl_CONDITIONAL([GL_COND_OBJ_DUP2], [test $REPLACE_DUP2 = 1]) + AM_COND_IF([GL_COND_OBJ_DUP2], [ + gl_PREREQ_DUP2 + ]) + gl_UNISTD_MODULE_INDICATOR([dup2]) + gl_ENVIRON + gl_UNISTD_MODULE_INDICATOR([environ]) + gl_HEADER_ERRNO_H + gl_CONDITIONAL_HEADER([errno.h]) + AC_PROG_MKDIR_P + AC_REQUIRE([gl_ERROR_H]) + gl_ERROR + gl_CONDITIONAL([GL_COND_OBJ_ERROR], [test $COMPILE_ERROR_C = 1]) + AM_COND_IF([GL_COND_OBJ_ERROR], [ + gl_PREREQ_ERROR + ]) + m4_ifdef([AM_XGETTEXT_OPTION], + [AM_][XGETTEXT_OPTION([--flag=error:3:c-format]) + AM_][XGETTEXT_OPTION([--flag=error_at_line:5:c-format])]) + gl_ERROR_H + AC_PROG_MKDIR_P + AC_REQUIRE([gl_EXTERN_INLINE]) + gl_FUNC_FCHDIR + gl_CONDITIONAL([GL_COND_OBJ_FCHDIR], [test $HAVE_FCHDIR = 0]) + AM_COND_IF([GL_COND_OBJ_FCHDIR], [ + gl_PREREQ_FCHDIR + ]) + gl_UNISTD_MODULE_INDICATOR([fchdir]) + gl_FUNC_FCNTL + gl_CONDITIONAL([GL_COND_OBJ_FCNTL], + [test $HAVE_FCNTL = 0 || test $REPLACE_FCNTL = 1]) + gl_FCNTL_MODULE_INDICATOR([fcntl]) + gl_FCNTL_H + gl_FCNTL_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_MODULE_INDICATOR([fd-safer-flag]) + gl_FUNC_FDOPENDIR + gl_CONDITIONAL([GL_COND_OBJ_FDOPENDIR], + [test $HAVE_FDOPENDIR = 0 || test $REPLACE_FDOPENDIR = 1]) + gl_DIRENT_MODULE_INDICATOR([fdopendir]) + gl_MODULE_INDICATOR([fdopendir]) + gl_FILE_NAME_CONCAT + gl_MODULE_INDICATOR([filenamecat]) + gl_FILE_NAME_CONCAT_LGPL + AC_C_FLEXIBLE_ARRAY_MEMBER + gl_FUNC_FNMATCH_POSIX + dnl Because of gl_REPLACE_FNMATCH_H: + gl_CONDITIONAL_HEADER([fnmatch.h]) + if test $HAVE_FNMATCH = 0 || test $REPLACE_FNMATCH = 1; then + AC_LIBOBJ([fnmatch]) + gl_PREREQ_FNMATCH + fi + gl_FNMATCH_MODULE_INDICATOR([fnmatch]) + gl_FUNC_FNMATCH_GNU + if test $HAVE_FNMATCH = 0 || test $REPLACE_FNMATCH = 1; then + AC_LIBOBJ([fnmatch]) + gl_PREREQ_FNMATCH + fi + gl_MODULE_INDICATOR([fnmatch-gnu]) + gl_FNMATCH_H + gl_FNMATCH_H_REQUIRE_DEFAULTS + gl_CONDITIONAL_HEADER([fnmatch.h]) + AC_PROG_MKDIR_P + gl_FUNC_FOPEN + if test $REPLACE_FOPEN = 1; then + AC_LIBOBJ([fopen]) + gl_PREREQ_FOPEN + fi + gl_STDIO_MODULE_INDICATOR([fopen]) + gl_FUNC_FOPEN_GNU + if test $REPLACE_FOPEN_FOR_FOPEN_GNU = 1; then + AC_LIBOBJ([fopen]) + gl_PREREQ_FOPEN + fi + gl_MODULE_INDICATOR([fopen-gnu]) + gl_STDIO_MODULE_INDICATOR([fopen-gnu]) + gl_FUNC_FREE + gl_CONDITIONAL([GL_COND_OBJ_FREE], [test $REPLACE_FREE = 1]) + AM_COND_IF([GL_COND_OBJ_FREE], [ + gl_PREREQ_FREE + ]) + gl_STDLIB_MODULE_INDICATOR([free-posix]) + gl_FUNC_FREOPEN + gl_CONDITIONAL([GL_COND_OBJ_FREOPEN], [test $REPLACE_FREOPEN = 1]) + AM_COND_IF([GL_COND_OBJ_FREOPEN], [ + gl_PREREQ_FREOPEN + ]) + gl_STDIO_MODULE_INDICATOR([freopen]) + gl_FUNC_FSTAT + gl_CONDITIONAL([GL_COND_OBJ_FSTAT], [test $REPLACE_FSTAT = 1]) + AM_COND_IF([GL_COND_OBJ_FSTAT], [ + case "$host_os" in + mingw*) + AC_LIBOBJ([stat-w32]) + ;; + esac + gl_PREREQ_FSTAT + ]) + gl_SYS_STAT_MODULE_INDICATOR([fstat]) + gl_FUNC_GETCWD_LGPL + gl_CONDITIONAL([GL_COND_OBJ_GETCWD_LGPL], [test $REPLACE_GETCWD = 1]) + gl_UNISTD_MODULE_INDICATOR([getcwd]) + gl_FUNC_GETDTABLESIZE + gl_CONDITIONAL([GL_COND_OBJ_GETDTABLESIZE], + [test $HAVE_GETDTABLESIZE = 0 || test $REPLACE_GETDTABLESIZE = 1]) + AM_COND_IF([GL_COND_OBJ_GETDTABLESIZE], [ + gl_PREREQ_GETDTABLESIZE + ]) + gl_UNISTD_MODULE_INDICATOR([getdtablesize]) + gl_FUNC_GETOPT_GNU + dnl Because of the way gl_FUNC_GETOPT_GNU is implemented (the gl_getopt_required + dnl mechanism), there is no need to do any AC_LIBOBJ or AC_SUBST here; they are + dnl done in the getopt-posix module. + gl_FUNC_GETOPT_POSIX + gl_CONDITIONAL_HEADER([getopt.h]) + gl_CONDITIONAL_HEADER([getopt-cdefs.h]) + AC_PROG_MKDIR_P + gl_CONDITIONAL([GL_COND_OBJ_GETOPT], [test $REPLACE_GETOPT = 1]) + AM_COND_IF([GL_COND_OBJ_GETOPT], [ + dnl Define the substituted variable GNULIB_UNISTD_H_GETOPT to 1. + gl_UNISTD_H_REQUIRE_DEFAULTS + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNISTD_H_GETOPT], [1]) + ]) + gl_UNISTD_MODULE_INDICATOR([getopt-posix]) + gl_FUNC_GETPAGESIZE + gl_CONDITIONAL([GL_COND_OBJ_GETPAGESIZE], [test $REPLACE_GETPAGESIZE = 1]) + gl_UNISTD_MODULE_INDICATOR([getpagesize]) + gl_FUNC_GETPROGNAME + gl_CONDITIONAL([GL_COND_OBJ_GETPROGNAME], + [test $HAVE_GETPROGNAME = 0 || test $REPLACE_GETPROGNAME = 1]) + AM_COND_IF([GL_COND_OBJ_GETPROGNAME], [ + gl_PREREQ_GETPROGNAME + ]) + gl_STDLIB_MODULE_INDICATOR([getprogname]) + AC_REQUIRE([AC_CANONICAL_HOST]) + gl_FUNC_GETRANDOM + gl_CONDITIONAL([GL_COND_OBJ_GETRANDOM], + [test $HAVE_GETRANDOM = 0 || test $REPLACE_GETRANDOM = 1]) + gl_SYS_RANDOM_MODULE_INDICATOR([getrandom]) + AC_SUBST([LIBINTL]) + AC_SUBST([LTLIBINTL]) + gl_GETTIME + gl_FUNC_GETTIMEOFDAY + gl_CONDITIONAL([GL_COND_OBJ_GETTIMEOFDAY], + [test $HAVE_GETTIMEOFDAY = 0 || test $REPLACE_GETTIMEOFDAY = 1]) + AM_COND_IF([GL_COND_OBJ_GETTIMEOFDAY], [ + gl_PREREQ_GETTIMEOFDAY + ]) + gl_SYS_TIME_MODULE_INDICATOR([gettimeofday]) + AC_PROG_MKDIR_P + gl_GNU_MAKE + # Autoconf 2.61a.99 and earlier don't support linking a file only + # in VPATH builds. But since GNUmakefile is for maintainer use + # only, it does not matter if we skip the link with older autoconf. + # Automake 1.10.1 and earlier try to remove GNUmakefile in non-VPATH + # builds, so use a shell variable to bypass this. + GNUmakefile=GNUmakefile + m4_if(m4_version_compare([2.61a.100], + m4_defn([m4_PACKAGE_VERSION])), [1], [], + [AC_CONFIG_LINKS([$GNUmakefile:$GNUmakefile], [], + [GNUmakefile=$GNUmakefile])]) + AC_REQUIRE([gl_FUNC_SETLOCALE_NULL]) + HARD_LOCALE_LIB="$SETLOCALE_NULL_LIB" + AC_SUBST([HARD_LOCALE_LIB]) + dnl For backward compatibility. + LIB_HARD_LOCALE="$HARD_LOCALE_LIB" + AC_SUBST([LIB_HARD_LOCALE]) + AC_DEFUN([gl_HAVE_MODULE_HAVELIB]) + AC_REQUIRE([gl_HOST_CPU_C_ABI]) + gl_INTTYPES_H + gl_INTTYPES_INCOMPLETE + gl_INTTYPES_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_FUNC_ISBLANK + gl_CONDITIONAL([GL_COND_OBJ_ISBLANK], [test $HAVE_ISBLANK = 0]) + gl_MODULE_INDICATOR([isblank]) + gl_CTYPE_MODULE_INDICATOR([isblank]) + gl_FUNC_ISWBLANK + gl_CONDITIONAL([GL_COND_OBJ_ISWBLANK], + [! { test $HAVE_ISWCNTRL = 0 || test $REPLACE_ISWCNTRL = 1; } && { test $HAVE_ISWBLANK = 0 || test $REPLACE_ISWBLANK = 1; }]) + gl_WCTYPE_MODULE_INDICATOR([iswblank]) + gl_FUNC_ISWDIGIT + gl_CONDITIONAL([GL_COND_OBJ_ISWDIGIT], + [! { test $HAVE_ISWCNTRL = 0 || test $REPLACE_ISWCNTRL = 1; } && test $REPLACE_ISWDIGIT = 1]) + gl_WCTYPE_MODULE_INDICATOR([iswdigit]) + gl_FUNC_ISWXDIGIT + gl_CONDITIONAL([GL_COND_OBJ_ISWXDIGIT], + [! { test $HAVE_ISWCNTRL = 0 || test $REPLACE_ISWCNTRL = 1; } && test $REPLACE_ISWXDIGIT = 1]) + gl_WCTYPE_MODULE_INDICATOR([iswxdigit]) + gl_LANGINFO_H + gl_LANGINFO_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + AC_REQUIRE([gl_LARGEFILE]) + gl___INLINE + gl_LIMITS_H + gl_CONDITIONAL_HEADER([limits.h]) + AC_PROG_MKDIR_P + gl_LOCALCHARSET + dnl For backward compatibility. Some packages still use this. + LOCALCHARSET_TESTS_ENVIRONMENT= + AC_SUBST([LOCALCHARSET_TESTS_ENVIRONMENT]) + gl_LOCALE_H + gl_LOCALE_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_FUNC_LOCALECONV + gl_CONDITIONAL([GL_COND_OBJ_LOCALECONV], [test $REPLACE_LOCALECONV = 1]) + AM_COND_IF([GL_COND_OBJ_LOCALECONV], [ + gl_PREREQ_LOCALECONV + ]) + gl_LOCALE_MODULE_INDICATOR([localeconv]) + gl_LOCK + gl_MODULE_INDICATOR([lock]) + gl_FUNC_LSTAT + gl_CONDITIONAL([GL_COND_OBJ_LSTAT], [test $REPLACE_LSTAT = 1]) + AM_COND_IF([GL_COND_OBJ_LSTAT], [ + gl_PREREQ_LSTAT + ]) + gl_SYS_STAT_MODULE_INDICATOR([lstat]) + AC_CONFIG_COMMANDS_PRE([m4_ifdef([AH_HEADER], + [AC_SUBST([CONFIG_INCLUDE], m4_defn([AH_HEADER]))])]) + AC_REQUIRE([AC_PROG_SED]) + AC_REQUIRE([AC_PROG_GREP]) + gl_FUNC_MALLOC_GNU + if test $REPLACE_MALLOC_FOR_MALLOC_GNU = 1; then + AC_LIBOBJ([malloc]) + fi + gl_STDLIB_MODULE_INDICATOR([malloc-gnu]) + AC_REQUIRE([gl_FUNC_MALLOC_POSIX]) + if test $REPLACE_MALLOC_FOR_MALLOC_POSIX = 1; then + AC_LIBOBJ([malloc]) + fi + gl_STDLIB_MODULE_INDICATOR([malloc-posix]) + gl_MALLOCA + gl_MBCHAR + gl_FUNC_MBRTOC32 + gl_CONDITIONAL([GL_COND_OBJ_MBRTOC32], + [test $HAVE_MBRTOC32 = 0 || test $REPLACE_MBRTOC32 = 1]) + AM_COND_IF([GL_COND_OBJ_MBRTOC32], [ + if test $REPLACE_MBSTATE_T = 1; then + AC_LIBOBJ([lc-charset-dispatch]) + AC_LIBOBJ([mbtowc-lock]) + gl_PREREQ_MBTOWC_LOCK + fi + gl_PREREQ_MBRTOC32 + ]) + gl_UCHAR_MODULE_INDICATOR([mbrtoc32]) + gl_FUNC_MBRTOWC + gl_CONDITIONAL([GL_COND_OBJ_MBRTOWC], + [test $HAVE_MBRTOWC = 0 || test $REPLACE_MBRTOWC = 1]) + AM_COND_IF([GL_COND_OBJ_MBRTOWC], [ + if test $REPLACE_MBSTATE_T = 1; then + AC_LIBOBJ([lc-charset-dispatch]) + AC_LIBOBJ([mbtowc-lock]) + gl_PREREQ_MBTOWC_LOCK + fi + gl_PREREQ_MBRTOWC + ]) + gl_WCHAR_MODULE_INDICATOR([mbrtowc]) + gl_STRING_MODULE_INDICATOR([mbscasecmp]) + gl_FUNC_MBSINIT + gl_CONDITIONAL([GL_COND_OBJ_MBSINIT], + [test $HAVE_MBSINIT = 0 || test $REPLACE_MBSINIT = 1]) + AM_COND_IF([GL_COND_OBJ_MBSINIT], [ + gl_PREREQ_MBSINIT + ]) + gl_WCHAR_MODULE_INDICATOR([mbsinit]) + gl_FUNC_MBSRTOWCS + gl_CONDITIONAL([GL_COND_OBJ_MBSRTOWCS], + [test $HAVE_MBSRTOWCS = 0 || test $REPLACE_MBSRTOWCS = 1]) + AM_COND_IF([GL_COND_OBJ_MBSRTOWCS], [ + AC_LIBOBJ([mbsrtowcs-state]) + gl_PREREQ_MBSRTOWCS + ]) + gl_WCHAR_MODULE_INDICATOR([mbsrtowcs]) + gl_FUNC_MBTOWC + gl_CONDITIONAL([GL_COND_OBJ_MBTOWC], + [test $HAVE_MBTOWC = 0 || test $REPLACE_MBTOWC = 1]) + AM_COND_IF([GL_COND_OBJ_MBTOWC], [ + gl_PREREQ_MBTOWC + ]) + gl_STDLIB_MODULE_INDICATOR([mbtowc]) + gl_MBITER + gl_FUNC_MEMCHR + gl_CONDITIONAL([GL_COND_OBJ_MEMCHR], [test $REPLACE_MEMCHR = 1]) + AM_COND_IF([GL_COND_OBJ_MEMCHR], [ + gl_PREREQ_MEMCHR + ]) + gl_STRING_MODULE_INDICATOR([memchr]) + gl_FUNC_MEMPCPY + gl_CONDITIONAL([GL_COND_OBJ_MEMPCPY], + [test $HAVE_MEMPCPY = 0 || test $REPLACE_MEMPCPY = 1]) + AM_COND_IF([GL_COND_OBJ_MEMPCPY], [ + gl_PREREQ_MEMPCPY + ]) + gl_STRING_MODULE_INDICATOR([mempcpy]) + gl_FUNC_MEMRCHR + gl_CONDITIONAL([GL_COND_OBJ_MEMRCHR], [test $ac_cv_func_memrchr = no]) + AM_COND_IF([GL_COND_OBJ_MEMRCHR], [ + gl_PREREQ_MEMRCHR + ]) + gl_STRING_MODULE_INDICATOR([memrchr]) + gl_MINMAX + gl_FUNC_MKDIR + gl_CONDITIONAL([GL_COND_OBJ_MKDIR], [test $REPLACE_MKDIR = 1]) + gl_SYS_STAT_MODULE_INDICATOR([mkdir]) + gl_FUNC_MKSTEMP + gl_CONDITIONAL([GL_COND_OBJ_MKSTEMP], + [test $HAVE_MKSTEMP = 0 || test $REPLACE_MKSTEMP = 1]) + AM_COND_IF([GL_COND_OBJ_MKSTEMP], [ + gl_PREREQ_MKSTEMP + ]) + gl_STDLIB_MODULE_INDICATOR([mkstemp]) + gl_FUNC_MKTIME + if test $REPLACE_MKTIME = 1; then + AC_LIBOBJ([mktime]) + gl_PREREQ_MKTIME + fi + gl_TIME_MODULE_INDICATOR([mktime]) + gl_FUNC_MKTIME_INTERNAL + if test $WANT_MKTIME_INTERNAL = 1; then + AC_LIBOBJ([mktime]) + gl_PREREQ_MKTIME + fi + AC_REQUIRE([gl_MSVC_INVAL]) + gl_CONDITIONAL([GL_COND_OBJ_MSVC_INVAL], + [test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1]) + AC_REQUIRE([gl_MSVC_NOTHROW]) + gl_CONDITIONAL([GL_COND_OBJ_MSVC_NOTHROW], + [test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1]) + gl_MODULE_INDICATOR([msvc-nothrow]) + gl_MULTIARCH + gl_FUNC_NL_LANGINFO + gl_CONDITIONAL([GL_COND_OBJ_NL_LANGINFO], + [test $HAVE_NL_LANGINFO = 0 || test $REPLACE_NL_LANGINFO = 1]) + gl_CONDITIONAL([GL_COND_OBJ_NL_LANGINFO_LOCK], + [test $REPLACE_NL_LANGINFO = 1 && test $NL_LANGINFO_MTSAFE = 0]) + if test $REPLACE_NL_LANGINFO = 1 && test $NL_LANGINFO_MTSAFE = 0; then + gl_PREREQ_NL_LANGINFO_LOCK + fi + gl_LANGINFO_MODULE_INDICATOR([nl_langinfo]) + gl_FUNC_GNU_STRFTIME + gl_NULLPTR + gl_FUNC_OPEN + gl_CONDITIONAL([GL_COND_OBJ_OPEN], [test $REPLACE_OPEN = 1]) + AM_COND_IF([GL_COND_OBJ_OPEN], [ + gl_PREREQ_OPEN + ]) + gl_FCNTL_MODULE_INDICATOR([open]) + gl_FUNC_OPENAT + gl_CONDITIONAL([GL_COND_OBJ_OPENAT], + [test $HAVE_OPENAT = 0 || test $REPLACE_OPENAT = 1]) + AM_COND_IF([GL_COND_OBJ_OPENAT], [ + gl_PREREQ_OPENAT + ]) + gl_MODULE_INDICATOR([openat]) dnl for lib/getcwd.c + gl_FCNTL_MODULE_INDICATOR([openat]) + gl_FUNC_OPENDIR + gl_CONDITIONAL([GL_COND_OBJ_OPENDIR], + [test $HAVE_OPENDIR = 0 || test $REPLACE_OPENDIR = 1]) + gl_DIRENT_MODULE_INDICATOR([opendir]) + gl_PATHMAX + gl_PERL + gl_FUNC_PIPE + gl_CONDITIONAL([GL_COND_OBJ_PIPE], [test $HAVE_PIPE = 0]) + gl_UNISTD_MODULE_INDICATOR([pipe]) + AC_CHECK_DECLS([program_invocation_name], [], [], [#include ]) + AC_CHECK_DECLS([program_invocation_short_name], [], [], [#include ]) + m4_ifdef([AM_XGETTEXT_OPTION], + [AM_][XGETTEXT_OPTION([--keyword='proper_name_lite:1,\"This is a proper name. See the gettext manual, section Names.\"'])]) + gl_QUOTE + gl_QUOTEARG + gl_FUNC_RAISE + gl_CONDITIONAL([GL_COND_OBJ_RAISE], + [test $HAVE_RAISE = 0 || test $REPLACE_RAISE = 1]) + AM_COND_IF([GL_COND_OBJ_RAISE], [ + gl_PREREQ_RAISE + ]) + gl_SIGNAL_MODULE_INDICATOR([raise]) + gl_FUNC_RAWMEMCHR + gl_CONDITIONAL([GL_COND_OBJ_RAWMEMCHR], [test $HAVE_RAWMEMCHR = 0]) + AM_COND_IF([GL_COND_OBJ_RAWMEMCHR], [ + gl_PREREQ_RAWMEMCHR + ]) + gl_STRING_MODULE_INDICATOR([rawmemchr]) + gl_FUNC_READLINK + gl_CONDITIONAL([GL_COND_OBJ_READLINK], + [test $HAVE_READLINK = 0 || test $REPLACE_READLINK = 1]) + AM_COND_IF([GL_COND_OBJ_READLINK], [ + gl_PREREQ_READLINK + ]) + gl_UNISTD_MODULE_INDICATOR([readlink]) + gl_FUNC_REALLOC_GNU + if test $REPLACE_REALLOC_FOR_REALLOC_GNU = 1; then + AC_LIBOBJ([realloc]) + fi + gl_STDLIB_MODULE_INDICATOR([realloc-gnu]) + gl_FUNC_REALLOC_POSIX + if test $REPLACE_REALLOC_FOR_REALLOC_POSIX = 1; then + AC_LIBOBJ([realloc]) + fi + gl_STDLIB_MODULE_INDICATOR([realloc-posix]) + gl_FUNC_REALLOCARRAY + gl_CONDITIONAL([GL_COND_OBJ_REALLOCARRAY], + [test $HAVE_REALLOCARRAY = 0 || test $REPLACE_REALLOCARRAY = 1]) + AM_COND_IF([GL_COND_OBJ_REALLOCARRAY], [ + gl_PREREQ_REALLOCARRAY + ]) + gl_MODULE_INDICATOR([reallocarray]) + gl_STDLIB_MODULE_INDICATOR([reallocarray]) + gl_REGEX + gl_CONDITIONAL([GL_COND_OBJ_REGEX], [test $ac_use_included_regex = yes]) + AM_COND_IF([GL_COND_OBJ_REGEX], [ + gl_PREREQ_REGEX + ]) + gl_SAVE_CWD + gl_FUNC_SETENV + gl_CONDITIONAL([GL_COND_OBJ_SETENV], + [test $HAVE_SETENV = 0 || test $REPLACE_SETENV = 1]) + gl_STDLIB_MODULE_INDICATOR([setenv]) + gl_FUNC_SETLOCALE_NULL + gl_CONDITIONAL([GL_COND_OBJ_SETLOCALE_LOCK], + [test $SETLOCALE_NULL_ALL_MTSAFE = 0 || test $SETLOCALE_NULL_ONE_MTSAFE = 0]) + AM_COND_IF([GL_COND_OBJ_SETLOCALE_LOCK], [ + gl_PREREQ_SETLOCALE_LOCK + ]) + gl_LOCALE_MODULE_INDICATOR([setlocale_null]) + AC_REQUIRE([AC_C_RESTRICT]) + gl_SIGNAL_H + gl_SIGNAL_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_SIGNALBLOCKING + gl_CONDITIONAL([GL_COND_OBJ_SIGPROCMASK], [test $HAVE_POSIX_SIGNALBLOCKING = 0]) + AM_COND_IF([GL_COND_OBJ_SIGPROCMASK], [ + gl_PREREQ_SIGPROCMASK + ]) + gl_SIGNAL_MODULE_INDICATOR([sigprocmask]) + AC_REQUIRE([gl_SIGSEGV]) + if test $gl_sigsegv_uses_libsigsegv = yes; then + GL_GENERATE_SIGSEGV_H=false + else + GL_GENERATE_SIGSEGV_H=true + fi + gl_CONDITIONAL_HEADER([sigsegv.h]) + AC_PROG_MKDIR_P + if $GL_GENERATE_SIGSEGV_H; then + dnl Persuade glibc to declare macros designating register + dnl indices: REG_RSP on x86_64, REG_ESP on i386. + dnl Persuade Solaris OpenIndiana to include , + dnl which declares macros designating register indices, such as ESP on i386. + dnl Persuade Solaris OpenIndiana to declare mincore(). + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + gl_MUSL_LIBC + AC_REQUIRE([AC_CANONICAL_HOST]) + case "$host_os" in + solaris2.11) + AC_DEFINE([SOLARIS11], [1], [Define on Solaris 11 and its derivates.]) + ;; + esac + gl_FUNC_MMAP_ANON + dnl Stack direction. + SV_STACK_DIRECTION + dnl Catching stack overflow requires an alternate signal stack. + dnl The old "install a guard page" trick would be unreliable, because + dnl we don't know where exactly to place the guard page. + SV_SIGALTSTACK + AC_CHECK_FUNCS_ONCE([getrlimit]) + fi + gt_TYPE_SSIZE_T + gl_FUNC_STAT + gl_CONDITIONAL([GL_COND_OBJ_STAT], [test $REPLACE_STAT = 1]) + AM_COND_IF([GL_COND_OBJ_STAT], [ + case "$host_os" in + mingw*) + AC_LIBOBJ([stat-w32]) + ;; + esac + gl_PREREQ_STAT + ]) + gl_SYS_STAT_MODULE_INDICATOR([stat]) + gl_STAT_TIME + gl_STAT_BIRTHTIME + gl_STDARG_H + gl_CONDITIONAL_HEADER([stdarg.h]) + AC_PROG_MKDIR_P + gl_C_BOOL + AC_CHECK_HEADERS_ONCE([stdckdint.h]) + if test $ac_cv_header_stdckdint_h = yes; then + GL_GENERATE_STDCKDINT_H=false + else + GL_GENERATE_STDCKDINT_H=true + fi + gl_CONDITIONAL_HEADER([stdckdint.h]) + AC_PROG_MKDIR_P + gl_STDDEF_H + gl_STDDEF_H_REQUIRE_DEFAULTS + gl_CONDITIONAL_HEADER([stddef.h]) + AC_PROG_MKDIR_P + gl_STDINT_H + gl_CONDITIONAL_HEADER([stdint.h]) + dnl Because of gl_REPLACE_LIMITS_H: + gl_CONDITIONAL_HEADER([limits.h]) + AC_PROG_MKDIR_P + gl_STDIO_H + gl_STDIO_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_CONDITIONAL([GL_COND_OBJ_STDIO_READ], [test $REPLACE_STDIO_READ_FUNCS = 1]) + gl_CONDITIONAL([GL_COND_OBJ_STDIO_WRITE], [test $REPLACE_STDIO_WRITE_FUNCS = 1]) + dnl No need to create extra modules for these functions. Everyone who uses + dnl likely needs them. + gl_STDIO_MODULE_INDICATOR([fscanf]) + gl_MODULE_INDICATOR([fscanf]) + gl_STDIO_MODULE_INDICATOR([scanf]) + gl_MODULE_INDICATOR([scanf]) + gl_STDIO_MODULE_INDICATOR([fgetc]) + gl_STDIO_MODULE_INDICATOR([getc]) + gl_STDIO_MODULE_INDICATOR([getchar]) + gl_STDIO_MODULE_INDICATOR([fgets]) + gl_STDIO_MODULE_INDICATOR([fread]) + dnl No need to create extra modules for these functions. Everyone who uses + dnl likely needs them. + gl_STDIO_MODULE_INDICATOR([fprintf]) + gl_STDIO_MODULE_INDICATOR([printf]) + gl_STDIO_MODULE_INDICATOR([vfprintf]) + gl_STDIO_MODULE_INDICATOR([vprintf]) + gl_STDIO_MODULE_INDICATOR([fputc]) + gl_STDIO_MODULE_INDICATOR([putc]) + gl_STDIO_MODULE_INDICATOR([putchar]) + gl_STDIO_MODULE_INDICATOR([fputs]) + gl_STDIO_MODULE_INDICATOR([puts]) + gl_STDIO_MODULE_INDICATOR([fwrite]) + gl_STDLIB_H + gl_STDLIB_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_FUNC_STPCPY + gl_CONDITIONAL([GL_COND_OBJ_STPCPY], + [test $HAVE_STPCPY = 0 || test $REPLACE_STPCPY = 1]) + AM_COND_IF([GL_COND_OBJ_STPCPY], [ + gl_PREREQ_STPCPY + ]) + gl_STRING_MODULE_INDICATOR([stpcpy]) + gl_STRCASE + gl_CONDITIONAL([GL_COND_OBJ_STRCASECMP], [test $HAVE_STRCASECMP = 0]) + AM_COND_IF([GL_COND_OBJ_STRCASECMP], [ + gl_PREREQ_STRCASECMP + ]) + gl_CONDITIONAL([GL_COND_OBJ_STRNCASECMP], [test $HAVE_STRNCASECMP = 0]) + AM_COND_IF([GL_COND_OBJ_STRNCASECMP], [ + gl_PREREQ_STRNCASECMP + ]) + gl_FUNC_STRDUP_POSIX + gl_CONDITIONAL([GL_COND_OBJ_STRDUP], [test $REPLACE_STRDUP = 1]) + AM_COND_IF([GL_COND_OBJ_STRDUP], [ + gl_PREREQ_STRDUP + ]) + gl_STRING_MODULE_INDICATOR([strdup]) + gl_FUNC_STRERROR + gl_CONDITIONAL([GL_COND_OBJ_STRERROR], [test $REPLACE_STRERROR = 1]) + gl_MODULE_INDICATOR([strerror]) + gl_STRING_MODULE_INDICATOR([strerror]) + AC_REQUIRE([gl_HEADER_ERRNO_H]) + AC_REQUIRE([gl_FUNC_STRERROR_0]) + gl_CONDITIONAL([GL_COND_OBJ_STRERROR_OVERRIDE], + [test -n "$ERRNO_H" || test $REPLACE_STRERROR_0 = 1]) + AM_COND_IF([GL_COND_OBJ_STRERROR_OVERRIDE], [ + gl_PREREQ_SYS_H_WINSOCK2 + ]) + gl_STRING_H + gl_STRING_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_STRINGS_H + gl_STRINGS_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_FUNC_STRNLEN + gl_CONDITIONAL([GL_COND_OBJ_STRNLEN], + [test $HAVE_DECL_STRNLEN = 0 || test $REPLACE_STRNLEN = 1]) + AM_COND_IF([GL_COND_OBJ_STRNLEN], [ + gl_PREREQ_STRNLEN + ]) + gl_STRING_MODULE_INDICATOR([strnlen]) + gl_FUNC_STRPTIME + gl_CONDITIONAL([GL_COND_OBJ_STRPTIME], [test $HAVE_STRPTIME = 0]) + AM_COND_IF([GL_COND_OBJ_STRPTIME], [ + gl_PREREQ_STRPTIME + ]) + gl_TIME_MODULE_INDICATOR([strptime]) + gl_FUNC_STRTOIMAX + gl_CONDITIONAL([GL_COND_OBJ_STRTOIMAX], + [test $HAVE_DECL_STRTOIMAX = 0 || test $REPLACE_STRTOIMAX = 1]) + AM_COND_IF([GL_COND_OBJ_STRTOIMAX], [ + gl_PREREQ_STRTOIMAX + ]) + gl_INTTYPES_MODULE_INDICATOR([strtoimax]) + gl_FUNC_STRTOLL + gl_CONDITIONAL([GL_COND_OBJ_STRTOLL], + [test $HAVE_STRTOLL = 0 || test $REPLACE_STRTOLL = 1]) + AM_COND_IF([GL_COND_OBJ_STRTOLL], [ + gl_PREREQ_STRTOLL + ]) + gl_STDLIB_MODULE_INDICATOR([strtoll]) + gl_SYS_RANDOM_H + gl_SYS_RANDOM_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_SYS_STAT_H + gl_SYS_STAT_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_SYS_TIME_H + gl_SYS_TIME_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_SYS_TYPES_H + gl_SYS_TYPES_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_SYS_WAIT_H + gl_SYS_WAIT_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + AC_REQUIRE([AC_C_RESTRICT]) + gl_FUNC_GEN_TEMPNAME + gl_MODULE_INDICATOR([tempname]) + AC_REQUIRE([gl_THREADLIB]) + gl_TIME_H + gl_TIME_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_TIME_R + gl_CONDITIONAL([GL_COND_OBJ_TIME_R], + [test $HAVE_LOCALTIME_R = 0 || test $REPLACE_LOCALTIME_R = 1]) + AM_COND_IF([GL_COND_OBJ_TIME_R], [ + gl_PREREQ_TIME_R + ]) + gl_TIME_MODULE_INDICATOR([time_r]) + gl_TIME_RZ + gl_CONDITIONAL([GL_COND_OBJ_TIME_RZ], [test $HAVE_TIMEZONE_T = 0]) + gl_TIME_MODULE_INDICATOR([time_rz]) + gl_FUNC_TIMEGM + gl_CONDITIONAL([GL_COND_OBJ_TIMEGM], + [test $HAVE_TIMEGM = 0 || test $REPLACE_TIMEGM = 1]) + AM_COND_IF([GL_COND_OBJ_TIMEGM], [ + gl_PREREQ_TIMEGM + ]) + gl_TIME_MODULE_INDICATOR([timegm]) + gl_TIMESPEC + gl_FUNC_TIMESPEC_GET + gl_CONDITIONAL([GL_COND_OBJ_TIMESPEC_GET], + [test $HAVE_TIMESPEC_GET = 0 || test $REPLACE_TIMESPEC_GET = 1]) + gl_TIME_MODULE_INDICATOR([timespec_get]) + gl_FUNC_TZSET + gl_CONDITIONAL([GL_COND_OBJ_TZSET], [test $REPLACE_TZSET = 1]) + gl_TIME_MODULE_INDICATOR([tzset]) + gl_UCHAR_H + gl_UCHAR_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_LIBUNISTRING_LIBHEADER([1.2], [unicase.h]) + gl_UNICASE_H + gl_UNICASE_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_LIBUNISTRING_MODULE([0.9.11], [unicase/tolower]) + gl_LIBUNISTRING_LIBHEADER([1.2], [unictype.h]) + gl_UNICTYPE_H + gl_UNICTYPE_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + AC_REQUIRE([AC_C_INLINE]) + gl_LIBUNISTRING_MODULE([0.9.8], [unictype/ctype-space]) + gl_LIBUNISTRING_LIBHEADER([1.2], [uninorm.h]) + gl_UNINORM_H + gl_UNINORM_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_UNISTD_H + gl_UNISTD_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_UNISTD_SAFER + gl_LIBUNISTRING_LIBHEADER([0.9.11], [unitypes.h]) + AC_PROG_MKDIR_P + AH_VERBATIM([unitypes_restrict], [ + /* This definition is a duplicate of the one in unitypes.h. + It is here so that we can cope with an older version of unitypes.h + that does not contain this definition and that is pre-installed among + the public header files. */ + # if defined __restrict \ + || 2 < __GNUC__ + (95 <= __GNUC_MINOR__) \ + || __clang_major__ >= 3 + # define _UC_RESTRICT __restrict + # elif 199901L <= __STDC_VERSION__ || defined restrict + # define _UC_RESTRICT restrict + # else + # define _UC_RESTRICT + # endif + ]) + gl_LIBUNISTRING_LIBHEADER([0.9.11], [uniwidth.h]) + AC_PROG_MKDIR_P + gl_LIBUNISTRING_MODULE([1.1], [uniwidth/width]) + AC_DEFINE([GNULIB_STDIO_SINGLE_THREAD], [1], + [Define to 1 if you want the FILE stream functions getc, putc, etc. + to use unlocked I/O if available, throughout the package. + Unlocked I/O can improve performance, sometimes dramatically. + But unlocked I/O is safe only in single-threaded programs, + as well as in multithreaded programs for which you can guarantee that + every FILE stream, including stdin, stdout, stderr, is used only + in a single thread.]) + AC_DEFINE([USE_UNLOCKED_IO], [GNULIB_STDIO_SINGLE_THREAD], + [An alias of GNULIB_STDIO_SINGLE_THREAD.]) + gl_FUNC_GLIBC_UNLOCKED_IO + gl_FUNC_UNSETENV + gl_CONDITIONAL([GL_COND_OBJ_UNSETENV], + [test $HAVE_UNSETENV = 0 || test $REPLACE_UNSETENV = 1]) + AM_COND_IF([GL_COND_OBJ_UNSETENV], [ + gl_PREREQ_UNSETENV + ]) + gl_STDLIB_MODULE_INDICATOR([unsetenv]) + AC_C_VARARRAYS + gl_VERSION_ETC + gl_WCHAR_H + gl_WCHAR_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_FUNC_WCRTOMB + gl_CONDITIONAL([GL_COND_OBJ_WCRTOMB], + [test $HAVE_WCRTOMB = 0 || test $REPLACE_WCRTOMB = 1]) + AM_COND_IF([GL_COND_OBJ_WCRTOMB], [ + gl_PREREQ_WCRTOMB + ]) + gl_WCHAR_MODULE_INDICATOR([wcrtomb]) + gl_WCTYPE_H + gl_WCTYPE_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_FUNC_WCWIDTH + gl_CONDITIONAL([GL_COND_OBJ_WCWIDTH], + [test $HAVE_WCWIDTH = 0 || test $REPLACE_WCWIDTH = 1]) + AM_COND_IF([GL_COND_OBJ_WCWIDTH], [ + gl_PREREQ_WCWIDTH + ]) + gl_WCHAR_MODULE_INDICATOR([wcwidth]) + AC_REQUIRE([AC_CANONICAL_HOST]) + gl_CONDITIONAL([GL_COND_OBJ_WINDOWS_MUTEX], + [case "$host_os" in mingw*) true;; *) false;; esac]) + AC_REQUIRE([AC_CANONICAL_HOST]) + gl_CONDITIONAL([GL_COND_OBJ_WINDOWS_ONCE], + [case "$host_os" in mingw*) true;; *) false;; esac]) + AC_REQUIRE([AC_CANONICAL_HOST]) + gl_CONDITIONAL([GL_COND_OBJ_WINDOWS_RECMUTEX], + [case "$host_os" in mingw*) true;; *) false;; esac]) + AC_REQUIRE([AC_CANONICAL_HOST]) + gl_CONDITIONAL([GL_COND_OBJ_WINDOWS_RWLOCK], + [case "$host_os" in mingw*) true;; *) false;; esac]) + gl_FUNC_WMEMCHR + gl_CONDITIONAL([GL_COND_OBJ_WMEMCHR], [test $HAVE_WMEMCHR = 0]) + gl_WCHAR_MODULE_INDICATOR([wmemchr]) + gl_FUNC_WMEMPCPY + gl_CONDITIONAL([GL_COND_OBJ_WMEMPCPY], + [test $HAVE_WMEMPCPY = 0 || test $REPLACE_WMEMPCPY = 1]) + gl_WCHAR_MODULE_INDICATOR([wmempcpy]) + gl_XALLOC + gl_MODULE_INDICATOR([xalloc]) + gl_MODULE_INDICATOR([xalloc-die]) + gl_XSTRTOL + # End of code from modules + m4_ifval(gl_LIBSOURCES_LIST, [ + m4_syscmd([test ! -d ]m4_defn([gl_LIBSOURCES_DIR])[ || + for gl_file in ]gl_LIBSOURCES_LIST[ ; do + if test ! -r ]m4_defn([gl_LIBSOURCES_DIR])[/$gl_file ; then + echo "missing file ]m4_defn([gl_LIBSOURCES_DIR])[/$gl_file" >&2 + exit 1 + fi + done])dnl + m4_if(m4_sysval, [0], [], + [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])]) + ]) + m4_popdef([GL_MODULE_INDICATOR_PREFIX]) + m4_popdef([GL_MACRO_PREFIX]) + m4_popdef([gl_LIBSOURCES_DIR]) + m4_popdef([gl_LIBSOURCES_LIST]) + m4_popdef([AC_LIBSOURCES]) + m4_popdef([AC_REPLACE_FUNCS]) + m4_popdef([AC_LIBOBJ]) + AC_CONFIG_COMMANDS_PRE([ + gl_libobjs= + gl_ltlibobjs= + gl_libobjdeps= + if test -n "$gl_LIBOBJS"; then + # Remove the extension. +changequote(,)dnl + sed_drop_objext='s/\.o$//;s/\.obj$//' + sed_dirname1='s,//*,/,g' + sed_dirname2='s,\(.\)/$,\1,' + sed_dirname3='s,^[^/]*$,.,' + sed_dirname4='s,\(.\)/[^/]*$,\1,' + sed_basename1='s,.*/,,' +changequote([, ])dnl + for i in `for i in $gl_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do + gl_libobjs="$gl_libobjs $i.$ac_objext" + gl_ltlibobjs="$gl_ltlibobjs $i.lo" + i_dir=`echo "$i" | sed -e "$sed_dirname1" -e "$sed_dirname2" -e "$sed_dirname3" -e "$sed_dirname4"` + i_base=`echo "$i" | sed -e "$sed_basename1"` + gl_libobjdeps="$gl_libobjdeps $i_dir/\$(DEPDIR)/$i_base.Po" + done + fi + AC_SUBST([gl_LIBOBJS], [$gl_libobjs]) + AC_SUBST([gl_LTLIBOBJS], [$gl_ltlibobjs]) + AC_SUBST([gl_LIBOBJDEPS], [$gl_libobjdeps]) + ]) + gltests_libdeps= + gltests_ltlibdeps= + m4_pushdef([AC_LIBOBJ], m4_defn([gltests_LIBOBJ])) + m4_pushdef([AC_REPLACE_FUNCS], m4_defn([gltests_REPLACE_FUNCS])) + m4_pushdef([AC_LIBSOURCES], m4_defn([gltests_LIBSOURCES])) + m4_pushdef([gltests_LIBSOURCES_LIST], []) + m4_pushdef([gltests_LIBSOURCES_DIR], []) + m4_pushdef([GL_MACRO_PREFIX], [gltests]) + m4_pushdef([GL_MODULE_INDICATOR_PREFIX], [GL]) + gl_COMMON + AC_REQUIRE([gl_CC_ALLOW_WARNINGS]) + AC_REQUIRE([gl_CXX_ALLOW_WARNINGS]) + gl_source_base='gnulib-tests' + gl_source_base_prefix= +changequote(,)dnl + gltests_WITNESS=IN_`echo "${PACKAGE-$PACKAGE_TARNAME}" | LC_ALL=C tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ | LC_ALL=C sed -e 's/[^A-Z0-9_]/_/g'`_GNULIB_TESTS +changequote([, ])dnl + AC_SUBST([gltests_WITNESS]) + gl_module_indicator_condition=$gltests_WITNESS + m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [$gl_module_indicator_condition]) + AC_REQUIRE([gl_SYS_SOCKET_H]) + gl_CONDITIONAL([GL_COND_OBJ_ACCEPT], [test "$ac_cv_header_winsock2_h" = yes]) + gl_SYS_SOCKET_MODULE_INDICATOR([accept]) + gl_ARPA_INET_H + gl_ARPA_INET_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_FUNC_ATOLL + gl_CONDITIONAL([GL_COND_OBJ_ATOLL], [test $HAVE_ATOLL = 0]) + AM_COND_IF([GL_COND_OBJ_ATOLL], [ + gl_PREREQ_ATOLL + ]) + gl_STDLIB_MODULE_INDICATOR([atoll]) + AC_REQUIRE([gl_SYS_SOCKET_H]) + gl_CONDITIONAL([GL_COND_OBJ_BIND], [test "$ac_cv_header_winsock2_h" = yes]) + gl_SYS_SOCKET_MODULE_INDICATOR([bind]) + gl_UCHAR_MODULE_INDICATOR([btoc32]) + gt_LOCALE_FR + gt_LOCALE_FR_UTF8 + gt_LOCALE_FR + gt_LOCALE_FR_UTF8 + gt_LOCALE_FR + gt_LOCALE_TR_UTF8 + gt_LOCALE_FR + gt_LOCALE_FR_UTF8 + gt_LOCALE_JA + gt_LOCALE_ZH_CN + gl_FUNC_C32RTOMB + gl_CONDITIONAL([GL_COND_OBJ_C32RTOMB], + [test $HAVE_C32RTOMB = 0 || test $REPLACE_C32RTOMB = 1]) + gl_UCHAR_MODULE_INDICATOR([c32rtomb]) + gt_LOCALE_FR + gt_LOCALE_FR_UTF8 + gt_LOCALE_JA + gt_LOCALE_ZH_CN + AC_REQUIRE([gl_MBRTOC32_SANITYCHECK]) + gl_UCHAR_MODULE_INDICATOR([c32tob]) + gt_LOCALE_FR + gt_LOCALE_FR_UTF8 + gt_LOCALE_JA + gt_LOCALE_ZH_CN + AC_REQUIRE([gl_SYS_SOCKET_H]) + gl_CONDITIONAL([GL_COND_OBJ_CONNECT], [test "$ac_cv_header_winsock2_h" = yes]) + gl_SYS_SOCKET_MODULE_INDICATOR([connect]) + gl_FUNC_FDOPEN + gl_CONDITIONAL([GL_COND_OBJ_FDOPEN], [test $REPLACE_FDOPEN = 1]) + AM_COND_IF([GL_COND_OBJ_FDOPEN], [ + gl_PREREQ_FDOPEN + ]) + gl_STDIO_MODULE_INDICATOR([fdopen]) + gl_FLOAT_H + gl_CONDITIONAL_HEADER([float.h]) + AC_PROG_MKDIR_P + gl_CONDITIONAL([GL_COND_OBJ_FLOAT], [test $REPLACE_FLOAT_LDBL = 1]) + gl_CONDITIONAL([GL_COND_OBJ_ITOLD], [test $REPLACE_ITOLD = 1]) + gl_FUNC_FTRUNCATE + gl_CONDITIONAL([GL_COND_OBJ_FTRUNCATE], + [test $HAVE_FTRUNCATE = 0 || test $REPLACE_FTRUNCATE = 1]) + AM_COND_IF([GL_COND_OBJ_FTRUNCATE], [ + gl_PREREQ_FTRUNCATE + ]) + gl_UNISTD_MODULE_INDICATOR([ftruncate]) + gl_MUSL_LIBC + dnl Distinguish OpenBSD >= 6.2 from OpenBSD < 6.2. + gl_CHECK_FUNCS_ANDROID([duplocale], [[#include ]]) + gl_FUNC_INET_PTON + gl_CONDITIONAL([GL_COND_OBJ_INET_PTON], + [test $HAVE_INET_PTON = 0 || test $REPLACE_INET_PTON = 1]) + AM_COND_IF([GL_COND_OBJ_INET_PTON], [ + gl_PREREQ_INET_PTON + ]) + gl_ARPA_INET_MODULE_INDICATOR([inet_pton]) + AC_C_BIGENDIAN + gl_INTTOSTR + gl_FUNC_IOCTL + gl_CONDITIONAL([GL_COND_OBJ_IOCTL], + [test $HAVE_IOCTL = 0 || test $REPLACE_IOCTL = 1]) + gl_SYS_IOCTL_MODULE_INDICATOR([ioctl]) + gt_LOCALE_FR + gt_LOCALE_FR_UTF8 + gt_LOCALE_JA + gt_LOCALE_ZH_CN + gt_LOCALE_FR + gt_LOCALE_FR_UTF8 + gt_LOCALE_JA + gt_LOCALE_ZH_CN + AC_REQUIRE([gl_SYS_SOCKET_H]) + gl_CONDITIONAL([GL_COND_OBJ_LISTEN], [test "$ac_cv_header_winsock2_h" = yes]) + gl_SYS_SOCKET_MODULE_INDICATOR([listen]) + gl_CHECK_FUNCS_ANDROID([newlocale], [[#include ]]) + gt_LOCALE_FR + gt_LOCALE_FR_UTF8 + gt_LOCALE_JA + gt_LOCALE_ZH_CN + gt_LOCALE_FR + gt_LOCALE_FR_UTF8 + gt_LOCALE_JA + gt_LOCALE_ZH_CN + gt_LOCALE_TR_UTF8 + gt_LOCALE_FR_UTF8 + gt_LOCALE_FR + gt_LOCALE_FR_UTF8 + gt_LOCALE_JA + gt_LOCALE_ZH_CN + dnl Check for prerequisites for memory fence checks. + gl_FUNC_MMAP_ANON + AC_CHECK_HEADERS_ONCE([sys/mman.h]) + AC_CHECK_FUNCS_ONCE([mprotect]) + gl_FUNC_MMAP_ANON + AC_CHECK_HEADERS_ONCE([sys/mman.h]) + AC_CHECK_FUNCS_ONCE([mprotect]) + gl_FUNC_NANOSLEEP + gl_CONDITIONAL([GL_COND_OBJ_NANOSLEEP], + [test $HAVE_NANOSLEEP = 0 || test $REPLACE_NANOSLEEP = 1]) + gl_TIME_MODULE_INDICATOR([nanosleep]) + AC_CHECK_DECLS_ONCE([alarm]) + gl_HEADER_NETINET_IN + gl_CONDITIONAL_HEADER([netinet/in.h]) + AC_PROG_MKDIR_P + gt_LOCALE_FR + gt_LOCALE_FR_UTF8 + gt_FUNC_USELOCALE + gl_FUNC_PERROR + gl_CONDITIONAL([GL_COND_OBJ_PERROR], [test $REPLACE_PERROR = 1]) + gl_STRING_MODULE_INDICATOR([perror]) + gl_FUNC_PSELECT + gl_CONDITIONAL([GL_COND_OBJ_PSELECT], + [test $HAVE_PSELECT = 0 || test $REPLACE_PSELECT = 1]) + gl_SYS_SELECT_MODULE_INDICATOR([pselect]) + AC_CHECK_HEADERS_ONCE([sys/wait.h]) + gl_PTHREAD_H + gl_PTHREAD_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_PTHREAD_THREAD + gl_CONDITIONAL([GL_COND_OBJ_PTHREAD_THREAD], + [test $HAVE_PTHREAD_CREATE = 0 || test $REPLACE_PTHREAD_CREATE = 1]) + gl_PTHREAD_MODULE_INDICATOR([pthread-thread]) + gl_FUNC_PTHREAD_SIGMASK + gl_CONDITIONAL([GL_COND_OBJ_PTHREAD_SIGMASK], + [test $HAVE_PTHREAD_SIGMASK = 0 || test $REPLACE_PTHREAD_SIGMASK = 1]) + AM_COND_IF([GL_COND_OBJ_PTHREAD_SIGMASK], [ + gl_PREREQ_PTHREAD_SIGMASK + ]) + gl_SIGNAL_MODULE_INDICATOR([pthread_sigmask]) + gl_FUNC_PUTENV + gl_CONDITIONAL([GL_COND_OBJ_PUTENV], [test $REPLACE_PUTENV = 1]) + AM_COND_IF([GL_COND_OBJ_PUTENV], [ + gl_PREREQ_PUTENV + ]) + gl_STDLIB_MODULE_INDICATOR([putenv]) + dnl Check for prerequisites for memory fence checks. + dnl FIXME: zerosize-ptr.h requires these: make a module for it + gl_FUNC_MMAP_ANON + AC_CHECK_HEADERS_ONCE([sys/mman.h]) + AC_CHECK_FUNCS_ONCE([mprotect]) + dnl Check for prerequisites for memory fence checks. + gl_FUNC_MMAP_ANON + AC_CHECK_HEADERS_ONCE([sys/mman.h]) + AC_CHECK_FUNCS_ONCE([mprotect]) + gl_SCHED_H + gl_SCHED_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_FUNC_SELECT + gl_CONDITIONAL([GL_COND_OBJ_SELECT], [test $REPLACE_SELECT = 1]) + gl_SYS_SELECT_MODULE_INDICATOR([select]) + AC_CHECK_HEADERS_ONCE([sys/wait.h]) + AC_REQUIRE([gl_SYS_SOCKET_H]) + gl_CONDITIONAL([GL_COND_OBJ_SETSOCKOPT], + [test "$ac_cv_header_winsock2_h" = yes]) + gl_SYS_SOCKET_MODULE_INDICATOR([setsockopt]) + AC_CHECK_FUNCS_ONCE([setrlimit]) + gl_FUNC_MMAP_ANON + gl_SIZE_MAX + gl_FUNC_SLEEP + gl_CONDITIONAL([GL_COND_OBJ_SLEEP], + [test $HAVE_SLEEP = 0 || test $REPLACE_SLEEP = 1]) + gl_UNISTD_MODULE_INDICATOR([sleep]) + AC_CHECK_DECLS_ONCE([alarm]) + gl_FUNC_SNPRINTF + gl_STDIO_MODULE_INDICATOR([snprintf]) + gl_MODULE_INDICATOR([snprintf]) + AC_REQUIRE([gl_SYS_SOCKET_H]) + gl_CONDITIONAL([GL_COND_OBJ_SOCKET], [test "$ac_cv_header_winsock2_h" = yes]) + # When this module is used, sockets may actually occur as file descriptors, + # hence it is worth warning if the modules 'close' and 'ioctl' are not used. + m4_ifdef([gl_UNISTD_H_DEFAULTS], [gl_UNISTD_H_REQUIRE_DEFAULTS]) + m4_ifdef([gl_SYS_IOCTL_H_DEFAULTS], [gl_SYS_IOCTL_H_REQUIRE_DEFAULTS]) + AC_REQUIRE([gl_PREREQ_SYS_H_WINSOCK2]) + if test "$ac_cv_header_winsock2_h" = yes; then + UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS=1 + SYS_IOCTL_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS=1 + fi + gl_SYS_SOCKET_MODULE_INDICATOR([socket]) + AC_REQUIRE([gl_SOCKETLIB]) + AC_REQUIRE([gl_SOCKETS]) + gl_TYPE_SOCKLEN_T + AC_REQUIRE([gt_TYPE_WCHAR_T]) + AC_REQUIRE([gt_TYPE_WINT_T]) + gl_DOUBLE_EXPONENT_LOCATION + gl_FUNC_STRERROR_R + AS_IF([test $HAVE_DECL_STRERROR_R = 0 || test $REPLACE_STRERROR_R = 1], [ + AC_LIBOBJ([strerror_r]) + gl_PREREQ_STRERROR_R + ]) + gl_STRING_MODULE_INDICATOR([strerror_r]) + dnl For the modules argp, error. + gl_MODULE_INDICATOR([strerror_r-posix]) + dnl Check for prerequisites for memory fence checks. + gl_FUNC_MMAP_ANON + AC_CHECK_HEADERS_ONCE([sys/mman.h]) + AC_CHECK_FUNCS_ONCE([mprotect]) + gl_FUNC_SYMLINK + gl_CONDITIONAL([GL_COND_OBJ_SYMLINK], + [test $HAVE_SYMLINK = 0 || test $REPLACE_SYMLINK = 1]) + gl_UNISTD_MODULE_INDICATOR([symlink]) + gl_SYS_IOCTL_H + gl_SYS_IOCTL_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_SYS_SELECT_H + gl_SYS_SELECT_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_SYS_SOCKET_H + gl_SYS_SOCKET_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + AC_CHECK_FUNCS_ONCE([shutdown]) + gl_SYS_UIO_H + gl_SYS_UIO_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_THREAD + gl_FUNC_TIME + gl_CONDITIONAL([GL_COND_OBJ_TIME], [test $REPLACE_TIME = 1]) + AM_COND_IF([GL_COND_OBJ_TIME], [ + gl_PREREQ_TIME + ]) + gl_TIME_MODULE_INDICATOR([time]) + abs_aux_dir=`cd "$ac_aux_dir"; pwd` + AC_SUBST([abs_aux_dir]) + AC_REQUIRE([AC_C_RESTRICT]) + gl_FUNC_VASNPRINTF + abs_aux_dir=`cd "$ac_aux_dir"; pwd` + AC_SUBST([abs_aux_dir]) + gt_LOCALE_FR + gt_LOCALE_FR_UTF8 + gt_LOCALE_JA + gt_LOCALE_ZH_CN + gl_FUNC_WCTOB + gl_CONDITIONAL([GL_COND_OBJ_WCTOB], + [test $HAVE_WCTOB = 0 || test $REPLACE_WCTOB = 1]) + AM_COND_IF([GL_COND_OBJ_WCTOB], [ + gl_PREREQ_WCTOB + ]) + gl_WCHAR_MODULE_INDICATOR([wctob]) + gl_FUNC_WCTOMB + gl_CONDITIONAL([GL_COND_OBJ_WCTOMB], [test $REPLACE_WCTOMB = 1]) + AM_COND_IF([GL_COND_OBJ_WCTOMB], [ + gl_PREREQ_WCTOMB + ]) + gl_STDLIB_MODULE_INDICATOR([wctomb]) + AC_REQUIRE([AC_CANONICAL_HOST]) + gl_CONDITIONAL([GL_COND_OBJ_WINDOWS_THREAD], + [case "$host_os" in mingw*) true;; *) false;; esac]) + AC_REQUIRE([AC_CANONICAL_HOST]) + gl_CONDITIONAL([GL_COND_OBJ_WINDOWS_TLS], + [case "$host_os" in mingw*) true;; *) false;; esac]) + gl_XSIZE + m4_popdef([gl_MODULE_INDICATOR_CONDITION]) + m4_ifval(gltests_LIBSOURCES_LIST, [ + m4_syscmd([test ! -d ]m4_defn([gltests_LIBSOURCES_DIR])[ || + for gl_file in ]gltests_LIBSOURCES_LIST[ ; do + if test ! -r ]m4_defn([gltests_LIBSOURCES_DIR])[/$gl_file ; then + echo "missing file ]m4_defn([gltests_LIBSOURCES_DIR])[/$gl_file" >&2 + exit 1 + fi + done])dnl + m4_if(m4_sysval, [0], [], + [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])]) + ]) + m4_popdef([GL_MODULE_INDICATOR_PREFIX]) + m4_popdef([GL_MACRO_PREFIX]) + m4_popdef([gltests_LIBSOURCES_DIR]) + m4_popdef([gltests_LIBSOURCES_LIST]) + m4_popdef([AC_LIBSOURCES]) + m4_popdef([AC_REPLACE_FUNCS]) + m4_popdef([AC_LIBOBJ]) + AC_CONFIG_COMMANDS_PRE([ + gltests_libobjs= + gltests_ltlibobjs= + gltests_libobjdeps= + if test -n "$gltests_LIBOBJS"; then + # Remove the extension. +changequote(,)dnl + sed_drop_objext='s/\.o$//;s/\.obj$//' + sed_dirname1='s,//*,/,g' + sed_dirname2='s,\(.\)/$,\1,' + sed_dirname3='s,^[^/]*$,.,' + sed_dirname4='s,\(.\)/[^/]*$,\1,' + sed_basename1='s,.*/,,' +changequote([, ])dnl + for i in `for i in $gltests_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do + gltests_libobjs="$gltests_libobjs $i.$ac_objext" + gltests_ltlibobjs="$gltests_ltlibobjs $i.lo" + i_dir=`echo "$i" | sed -e "$sed_dirname1" -e "$sed_dirname2" -e "$sed_dirname3" -e "$sed_dirname4"` + i_base=`echo "$i" | sed -e "$sed_basename1"` + gltests_libobjdeps="$gltests_libobjdeps $i_dir/\$(DEPDIR)/$i_base.Po" + done + fi + AC_SUBST([gltests_LIBOBJS], [$gltests_libobjs]) + AC_SUBST([gltests_LTLIBOBJS], [$gltests_ltlibobjs]) + AC_SUBST([gltests_LIBOBJDEPS], [$gltests_libobjdeps]) + ]) + AC_REQUIRE([gl_CC_GNULIB_WARNINGS]) + LIBDIFFUTILS_LIBDEPS="$gl_libdeps" + AC_SUBST([LIBDIFFUTILS_LIBDEPS]) + LIBDIFFUTILS_LTLIBDEPS="$gl_ltlibdeps" + AC_SUBST([LIBDIFFUTILS_LTLIBDEPS]) + LIBTESTS_LIBDEPS="$gltests_libdeps" + AC_SUBST([LIBTESTS_LIBDEPS]) +]) + +# Like AC_LIBOBJ, except that the module name goes +# into gl_LIBOBJS instead of into LIBOBJS. +AC_DEFUN([gl_LIBOBJ], [ + AS_LITERAL_IF([$1], [gl_LIBSOURCES([$1.c])])dnl + gl_LIBOBJS="$gl_LIBOBJS $1.$ac_objext" +]) + +# Like AC_REPLACE_FUNCS, except that the module name goes +# into gl_LIBOBJS instead of into LIBOBJS. +AC_DEFUN([gl_REPLACE_FUNCS], [ + m4_foreach_w([gl_NAME], [$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl + AC_CHECK_FUNCS([$1], , [gl_LIBOBJ($ac_func)]) +]) + +# Like AC_LIBSOURCES, except the directory where the source file is +# expected is derived from the gnulib-tool parameterization, +# and alloca is special cased (for the alloca-opt module). +# We could also entirely rely on EXTRA_lib..._SOURCES. +AC_DEFUN([gl_LIBSOURCES], [ + m4_foreach([_gl_NAME], [$1], [ + m4_if(_gl_NAME, [alloca.c], [], [ + m4_define([gl_LIBSOURCES_DIR], [lib]) + m4_append([gl_LIBSOURCES_LIST], _gl_NAME, [ ]) + ]) + ]) +]) + +# Like AC_LIBOBJ, except that the module name goes +# into gltests_LIBOBJS instead of into LIBOBJS. +AC_DEFUN([gltests_LIBOBJ], [ + AS_LITERAL_IF([$1], [gltests_LIBSOURCES([$1.c])])dnl + gltests_LIBOBJS="$gltests_LIBOBJS $1.$ac_objext" +]) + +# Like AC_REPLACE_FUNCS, except that the module name goes +# into gltests_LIBOBJS instead of into LIBOBJS. +AC_DEFUN([gltests_REPLACE_FUNCS], [ + m4_foreach_w([gl_NAME], [$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl + AC_CHECK_FUNCS([$1], , [gltests_LIBOBJ($ac_func)]) +]) + +# Like AC_LIBSOURCES, except the directory where the source file is +# expected is derived from the gnulib-tool parameterization, +# and alloca is special cased (for the alloca-opt module). +# We could also entirely rely on EXTRA_lib..._SOURCES. +AC_DEFUN([gltests_LIBSOURCES], [ + m4_foreach([_gl_NAME], [$1], [ + m4_if(_gl_NAME, [alloca.c], [], [ + m4_define([gltests_LIBSOURCES_DIR], [gnulib-tests]) + m4_append([gltests_LIBSOURCES_LIST], _gl_NAME, [ ]) + ]) + ]) +]) + +# This macro records the list of files which have been installed by +# gnulib-tool and may be removed by future gnulib-tool invocations. +AC_DEFUN([gl_FILE_LIST], [ + build-aux/announce-gen + build-aux/config.rpath + build-aux/do-release-commit-and-tag + build-aux/gendocs.sh + build-aux/git-version-gen + build-aux/gitlog-to-changelog + build-aux/gnu-web-doc-update + build-aux/gnupload + build-aux/update-copyright + build-aux/useless-if-before-free + build-aux/vc-list-files + doc/gendocs_template + doc/gendocs_template_min + lib/_Noreturn.h + lib/alloca.in.h + lib/allocator.c + lib/allocator.h + lib/areadlink.c + lib/areadlink.h + lib/arg-nonnull.h + lib/argmatch.c + lib/argmatch.h + lib/assert.in.h + lib/assure.h + lib/attribute.h + lib/basename-lgpl.c + lib/basename-lgpl.h + lib/basename.c + lib/binary-io.c + lib/binary-io.h + lib/bitrotate.c + lib/bitrotate.h + lib/btowc.c + lib/c++defs.h + lib/c-ctype.c + lib/c-ctype.h + lib/c-stack.c + lib/c-stack.h + lib/c-strcase.h + lib/c-strcasecmp.c + lib/c-strcaseeq.h + lib/c-strncasecmp.c + lib/c32is-impl.h + lib/c32isspace.c + lib/c32to-impl.h + lib/c32tolower.c + lib/c32width.c + lib/calloc.c + lib/careadlinkat.c + lib/careadlinkat.h + lib/cdefs.h + lib/chdir-long.c + lib/chdir-long.h + lib/cloexec.c + lib/cloexec.h + lib/close.c + lib/closedir.c + lib/count-leading-zeros.c + lib/count-leading-zeros.h + lib/ctype.in.h + lib/diffseq.h + lib/dirent-private.h + lib/dirent.in.h + lib/dirfd.c + lib/dirname-lgpl.c + lib/dirname.c + lib/dirname.h + lib/dup-safer-flag.c + lib/dup-safer.c + lib/dup.c + lib/dup2.c + lib/dynarray.h + lib/errno.in.h + lib/error.c + lib/error.in.h + lib/exclude.c + lib/exclude.h + lib/exitfail.c + lib/exitfail.h + lib/fchdir.c + lib/fcntl.c + lib/fcntl.in.h + lib/fd-hook.c + lib/fd-hook.h + lib/fd-safer-flag.c + lib/fd-safer.c + lib/fdopendir.c + lib/file-type.c + lib/file-type.h + lib/filename.h + lib/filenamecat-lgpl.c + lib/filenamecat.c + lib/filenamecat.h + lib/flexmember.h + lib/fnmatch.c + lib/fnmatch.in.h + lib/fnmatch_loop.c + lib/fopen.c + lib/free.c + lib/freopen.c + lib/fstat.c + lib/getcwd-lgpl.c + lib/getdtablesize.c + lib/getopt-cdefs.in.h + lib/getopt-core.h + lib/getopt-ext.h + lib/getopt-pfx-core.h + lib/getopt-pfx-ext.h + lib/getopt.c + lib/getopt.in.h + lib/getopt1.c + lib/getopt_int.h + lib/getpagesize.c + lib/getprogname.c + lib/getprogname.h + lib/getrandom.c + lib/gettext.h + lib/gettime.c + lib/gettimeofday.c + lib/glthread/lock.c + lib/glthread/lock.h + lib/glthread/threadlib.c + lib/hard-locale.c + lib/hard-locale.h + lib/hash.c + lib/hash.h + lib/ialloc.c + lib/ialloc.h + lib/idx.h + lib/ignore-value.h + lib/intprops-internal.h + lib/intprops.h + lib/inttypes.in.h + lib/isblank.c + lib/iswblank.c + lib/iswdigit.c + lib/iswxdigit.c + lib/langinfo.in.h + lib/lc-charset-dispatch.c + lib/lc-charset-dispatch.h + lib/libc-config.h + lib/limits.in.h + lib/localcharset.c + lib/localcharset.h + lib/locale.in.h + lib/localeconv.c + lib/lstat.c + lib/malloc.c + lib/malloc/dynarray-skeleton.c + lib/malloc/dynarray.h + lib/malloc/dynarray_at_failure.c + lib/malloc/dynarray_emplace_enlarge.c + lib/malloc/dynarray_finalize.c + lib/malloc/dynarray_resize.c + lib/malloc/dynarray_resize_clear.c + lib/malloca.c + lib/malloca.h + lib/mbchar.c + lib/mbchar.h + lib/mbrtoc32.c + lib/mbrtowc-impl-utf8.h + lib/mbrtowc-impl.h + lib/mbrtowc.c + lib/mbscasecmp.c + lib/mbsinit.c + lib/mbsrtowcs-impl.h + lib/mbsrtowcs-state.c + lib/mbsrtowcs.c + lib/mbtowc-impl.h + lib/mbtowc-lock.c + lib/mbtowc-lock.h + lib/mbtowc.c + lib/mbuiter.c + lib/mbuiter.h + lib/memchr.c + lib/memchr.valgrind + lib/mempcpy.c + lib/memrchr.c + lib/minmax.h + lib/mkdir.c + lib/mkstemp.c + lib/mktime-internal.h + lib/mktime.c + lib/msvc-inval.c + lib/msvc-inval.h + lib/msvc-nothrow.c + lib/msvc-nothrow.h + lib/nl_langinfo-lock.c + lib/nl_langinfo.c + lib/nstrftime.c + lib/open.c + lib/openat-die.c + lib/openat-priv.h + lib/openat-proc.c + lib/openat.c + lib/openat.h + lib/opendir.c + lib/pathmax.h + lib/pipe-safer.c + lib/pipe.c + lib/progname.c + lib/progname.h + lib/propername-lite.c + lib/propername.h + lib/quote.h + lib/quotearg.c + lib/quotearg.h + lib/raise.c + lib/rawmemchr.c + lib/rawmemchr.valgrind + lib/readlink.c + lib/realloc.c + lib/reallocarray.c + lib/regcomp.c + lib/regex.c + lib/regex.h + lib/regex_internal.c + lib/regex_internal.h + lib/regexec.c + lib/same-inode.h + lib/save-cwd.c + lib/save-cwd.h + lib/setenv.c + lib/setlocale-lock.c + lib/setlocale_null.c + lib/setlocale_null.h + lib/sh-quote.c + lib/sh-quote.h + lib/signal.in.h + lib/sigprocmask.c + lib/sigsegv.c + lib/sigsegv.in.h + lib/stackvma.c + lib/stackvma.h + lib/stat-macros.h + lib/stat-time.c + lib/stat-time.h + lib/stat-w32.c + lib/stat-w32.h + lib/stat.c + lib/stdarg.in.h + lib/stdckdint.in.h + lib/stddef.in.h + lib/stdint.in.h + lib/stdio-read.c + lib/stdio-write.c + lib/stdio.in.h + lib/stdlib.in.h + lib/stdopen.c + lib/stdopen.h + lib/stpcpy.c + lib/strcasecmp.c + lib/strdup.c + lib/streq.h + lib/strerror-override.c + lib/strerror-override.h + lib/strerror.c + lib/strftime.h + lib/string.in.h + lib/strings.in.h + lib/stripslash.c + lib/strncasecmp.c + lib/strnlen.c + lib/strnlen1.c + lib/strnlen1.h + lib/strptime.c + lib/strtoimax.c + lib/strtol.c + lib/strtoll.c + lib/sys_random.in.h + lib/sys_stat.in.h + lib/sys_time.in.h + lib/sys_types.in.h + lib/sys_wait.in.h + lib/system-quote.c + lib/system-quote.h + lib/tempname.c + lib/tempname.h + lib/time-internal.h + lib/time.in.h + lib/time_r.c + lib/time_rz.c + lib/timegm.c + lib/timespec.c + lib/timespec.h + lib/timespec_get.c + lib/tzset.c + lib/uchar.in.h + lib/unicase.in.h + lib/unicase/simple-mapping.h + lib/unicase/tolower.c + lib/unicase/tolower.h + lib/unictype.in.h + lib/unictype/bitmap.h + lib/unictype/ctype_space.c + lib/unictype/ctype_space.h + lib/uninorm.in.h + lib/unistd--.h + lib/unistd-safer.h + lib/unistd.c + lib/unistd.in.h + lib/unitypes.in.h + lib/uniwidth.in.h + lib/uniwidth/cjk.h + lib/uniwidth/width.c + lib/uniwidth/width0.h + lib/uniwidth/width2.h + lib/unlocked-io.h + lib/unsetenv.c + lib/verify.h + lib/version-etc-fsf.c + lib/version-etc.c + lib/version-etc.h + lib/warn-on-use.h + lib/wchar.in.h + lib/wcrtomb.c + lib/wctype-h.c + lib/wctype.in.h + lib/wcwidth.c + lib/windows-initguard.h + 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 + lib/wmemchr-impl.h + lib/wmemchr.c + lib/wmempcpy.c + lib/xalloc-die.c + lib/xalloc-oversized.h + lib/xalloc.h + lib/xfreopen.c + lib/xfreopen.h + lib/xmalloc.c + lib/xmalloca.c + lib/xmalloca.h + lib/xreadlink.c + lib/xreadlink.h + lib/xstdopen.c + lib/xstdopen.h + lib/xstrtoimax.c + lib/xstrtol.c + lib/xstrtol.h + lib/xstrtoul.c + m4/00gnulib.m4 + m4/__inline.m4 + m4/absolute-header.m4 + m4/alloca.m4 + m4/arpa_inet_h.m4 + m4/asm-underscore.m4 + m4/assert_h.m4 + m4/atoll.m4 + m4/btowc.m4 + m4/builtin-expect.m4 + m4/c-bool.m4 + m4/c-stack.m4 + m4/c32rtomb.m4 + m4/calloc.m4 + m4/chdir-long.m4 + m4/clock_time.m4 + m4/close.m4 + m4/closedir.m4 + m4/codeset.m4 + m4/config-h.m4 + m4/ctype_h.m4 + m4/dirent_h.m4 + m4/dirfd.m4 + m4/double-slash-root.m4 + m4/dup.m4 + m4/dup2.m4 + m4/eealloc.m4 + m4/environ.m4 + m4/errno_h.m4 + m4/error.m4 + m4/error_h.m4 + m4/exponentd.m4 + m4/extensions.m4 + m4/extern-inline.m4 + m4/fchdir.m4 + m4/fclose.m4 + m4/fcntl-o.m4 + m4/fcntl.m4 + m4/fcntl_h.m4 + m4/fdopen.m4 + m4/fdopendir.m4 + m4/fflush.m4 + m4/filenamecat.m4 + m4/flexmember.m4 + m4/float_h.m4 + m4/fnmatch.m4 + m4/fnmatch_h.m4 + m4/fopen.m4 + m4/fpieee.m4 + m4/free.m4 + m4/freopen.m4 + m4/fstat.m4 + m4/ftruncate.m4 + m4/getcwd.m4 + m4/getdtablesize.m4 + m4/getopt.m4 + m4/getpagesize.m4 + m4/getprogname.m4 + m4/getrandom.m4 + m4/gettime.m4 + m4/gettimeofday.m4 + m4/gnu-make.m4 + m4/gnulib-common.m4 + m4/host-cpu-c-abi.m4 + m4/include_next.m4 + m4/inet_pton.m4 + m4/intl-thread-locale.m4 + m4/intmax_t.m4 + m4/inttostr.m4 + m4/inttypes.m4 + m4/inttypes_h.m4 + m4/ioctl.m4 + m4/isblank.m4 + m4/iswblank.m4 + m4/iswdigit.m4 + m4/iswxdigit.m4 + m4/langinfo_h.m4 + m4/largefile.m4 + m4/lib-ld.m4 + m4/lib-link.m4 + m4/lib-prefix.m4 + m4/libsigsegv.m4 + m4/libunistring-base.m4 + m4/limits-h.m4 + m4/localcharset.m4 + m4/locale-fr.m4 + m4/locale-ja.m4 + m4/locale-tr.m4 + m4/locale-zh.m4 + m4/locale_h.m4 + m4/localeconv.m4 + m4/lock.m4 + m4/lstat.m4 + m4/malloc.m4 + m4/malloca.m4 + m4/manywarnings-c++.m4 + m4/manywarnings.m4 + m4/math_h.m4 + m4/mbchar.m4 + m4/mbiter.m4 + m4/mbrtoc32.m4 + m4/mbrtowc.m4 + m4/mbsinit.m4 + m4/mbsrtowcs.m4 + m4/mbstate_t.m4 + m4/mbtowc.m4 + m4/memchr.m4 + m4/mempcpy.m4 + m4/memrchr.m4 + m4/minmax.m4 + m4/mkdir.m4 + m4/mkstemp.m4 + m4/mktime.m4 + m4/mmap-anon.m4 + m4/mode_t.m4 + m4/msvc-inval.m4 + m4/msvc-nothrow.m4 + m4/multiarch.m4 + m4/musl.m4 + m4/nanosleep.m4 + m4/netinet_in_h.m4 + m4/nl_langinfo.m4 + m4/nocrash.m4 + m4/nstrftime.m4 + m4/nullptr.m4 + m4/off_t.m4 + m4/open-cloexec.m4 + m4/open-slash.m4 + m4/open.m4 + m4/openat.m4 + m4/opendir.m4 + m4/pathmax.m4 + m4/perl.m4 + m4/perror.m4 + m4/pid_t.m4 + m4/pipe.m4 + m4/printf.m4 + m4/pselect.m4 + m4/pthread-thread.m4 + m4/pthread_h.m4 + m4/pthread_rwlock_rdlock.m4 + m4/pthread_sigmask.m4 + m4/putenv.m4 + m4/quote.m4 + m4/quotearg.m4 + m4/raise.m4 + m4/rawmemchr.m4 + m4/readlink.m4 + m4/realloc.m4 + m4/reallocarray.m4 + m4/regex.m4 + m4/save-cwd.m4 + m4/sched_h.m4 + m4/select.m4 + m4/setenv.m4 + m4/setlocale_null.m4 + m4/sigaltstack.m4 + m4/signal_h.m4 + m4/signalblocking.m4 + m4/sigsegv.m4 + m4/size_max.m4 + m4/sleep.m4 + m4/snprintf.m4 + m4/socketlib.m4 + m4/sockets.m4 + m4/socklen.m4 + m4/sockpfaf.m4 + m4/ssize_t.m4 + m4/stack-direction.m4 + m4/stat-time.m4 + m4/stat.m4 + m4/std-gnu11.m4 + m4/stdalign.m4 + m4/stdarg.m4 + m4/stddef_h.m4 + m4/stdint.m4 + m4/stdint_h.m4 + m4/stdio_h.m4 + m4/stdlib_h.m4 + m4/stpcpy.m4 + m4/strcase.m4 + m4/strdup.m4 + m4/strerror.m4 + m4/strerror_r.m4 + m4/string_h.m4 + m4/strings_h.m4 + m4/strnlen.m4 + m4/strptime.m4 + m4/strtoimax.m4 + m4/strtoll.m4 + m4/symlink.m4 + m4/sys_ioctl_h.m4 + m4/sys_random_h.m4 + m4/sys_select_h.m4 + m4/sys_socket_h.m4 + m4/sys_stat_h.m4 + m4/sys_time_h.m4 + m4/sys_types_h.m4 + m4/sys_uio_h.m4 + m4/sys_wait_h.m4 + m4/tempname.m4 + m4/thread.m4 + m4/threadlib.m4 + m4/time.m4 + m4/time_h.m4 + m4/time_r.m4 + m4/time_rz.m4 + m4/timegm.m4 + m4/timespec.m4 + m4/timespec_get.m4 + m4/tm_gmtoff.m4 + m4/tzset.m4 + m4/uchar_h.m4 + m4/unicase_h.m4 + m4/unictype_h.m4 + m4/uninorm_h.m4 + m4/unistd-safer.m4 + m4/unistd_h.m4 + m4/unlocked-io.m4 + m4/vararrays.m4 + m4/vasnprintf.m4 + m4/version-etc.m4 + m4/visibility.m4 + m4/warn-on-use.m4 + m4/warnings.m4 + m4/wchar_h.m4 + m4/wchar_t.m4 + m4/wcrtomb.m4 + m4/wctob.m4 + m4/wctomb.m4 + m4/wctype_h.m4 + m4/wcwidth.m4 + m4/wint_t.m4 + m4/wmemchr.m4 + m4/wmempcpy.m4 + m4/xalloc.m4 + m4/xsize.m4 + m4/xstrtol.m4 + m4/zzgnulib.m4 + tests/altstack-util.h + tests/init.sh + tests/locale.c + tests/macros.h + tests/mmap-anon-util.h + tests/nan.h + tests/nap.h + tests/signature.h + tests/test-accept.c + tests/test-alignasof.c + tests/test-alloca-opt.c + tests/test-areadlink.c + tests/test-areadlink.h + tests/test-argmatch.c + tests/test-arpa_inet.c + tests/test-assert.c + tests/test-binary-io.c + tests/test-binary-io.sh + tests/test-bind.c + tests/test-bitrotate.c + tests/test-btoc32-1.sh + tests/test-btoc32-2.sh + tests/test-btoc32-3.sh + tests/test-btoc32.c + tests/test-btowc.c + tests/test-btowc1.sh + tests/test-btowc2.sh + tests/test-btowc3.sh + tests/test-c-ctype.c + tests/test-c-stack.c + tests/test-c-stack.sh + tests/test-c-stack2.sh + tests/test-c-strcase.sh + tests/test-c-strcasecmp.c + tests/test-c-strcasestr.c + tests/test-c-strncasecmp.c + tests/test-c32isspace.c + tests/test-c32isspace.sh + tests/test-c32rtomb-w32-1.sh + tests/test-c32rtomb-w32-2.sh + tests/test-c32rtomb-w32-3.sh + tests/test-c32rtomb-w32-4.sh + tests/test-c32rtomb-w32-5.sh + tests/test-c32rtomb-w32-6.sh + tests/test-c32rtomb-w32-7.sh + tests/test-c32rtomb-w32.c + tests/test-c32rtomb.c + tests/test-c32rtomb.sh + tests/test-c32tolower.c + tests/test-c32tolower.sh + tests/test-c32width.c + tests/test-calloc-gnu.c + tests/test-chdir.c + tests/test-cloexec.c + tests/test-close.c + tests/test-connect.c + tests/test-count-leading-zeros.c + tests/test-ctype.c + tests/test-dirent.c + tests/test-dirfd.c + tests/test-dirname.c + tests/test-dup-safer.c + tests/test-dup.c + tests/test-dup2.c + tests/test-dynarray.c + tests/test-environ.c + tests/test-errno.c + tests/test-error.c + tests/test-error.sh + tests/test-exclude.c + tests/test-exclude1.sh + tests/test-exclude2.sh + tests/test-exclude3.sh + tests/test-exclude4.sh + tests/test-exclude5.sh + tests/test-exclude6.sh + tests/test-exclude7.sh + tests/test-exclude8.sh + tests/test-fchdir.c + tests/test-fcntl-h.c + tests/test-fcntl.c + tests/test-fdopen.c + tests/test-fdopendir.c + tests/test-fgetc.c + tests/test-filenamecat.c + tests/test-float.c + tests/test-fnmatch-h.c + tests/test-fnmatch.c + tests/test-fopen-gnu.c + tests/test-fopen.c + tests/test-fopen.h + tests/test-fputc.c + tests/test-fread.c + tests/test-free.c + tests/test-freopen.c + tests/test-fstat.c + tests/test-ftruncate.c + tests/test-ftruncate.sh + tests/test-fwrite.c + tests/test-getcwd-lgpl.c + tests/test-getdtablesize.c + tests/test-getopt-gnu.c + tests/test-getopt-main.h + tests/test-getopt-posix.c + tests/test-getopt.h + tests/test-getopt_long.h + tests/test-getprogname.c + tests/test-getrandom.c + tests/test-gettimeofday.c + tests/test-hard-locale.c + tests/test-hash.c + tests/test-ignore-value.c + tests/test-inet_pton.c + tests/test-init.sh + tests/test-intprops.c + tests/test-inttostr.c + tests/test-inttypes.c + tests/test-ioctl.c + tests/test-isblank.c + tests/test-iswblank.c + tests/test-iswdigit.c + tests/test-iswdigit.sh + tests/test-iswxdigit.c + tests/test-iswxdigit.sh + tests/test-langinfo.c + tests/test-largefile.c + tests/test-limits-h.c + tests/test-listen.c + tests/test-localcharset.c + tests/test-locale.c + tests/test-localeconv.c + tests/test-lstat.c + tests/test-lstat.h + tests/test-malloc-gnu.c + tests/test-malloca.c + tests/test-mbrtoc32-1.sh + tests/test-mbrtoc32-2.sh + tests/test-mbrtoc32-3.sh + tests/test-mbrtoc32-4.sh + tests/test-mbrtoc32-5.sh + tests/test-mbrtoc32-w32-1.sh + tests/test-mbrtoc32-w32-2.sh + tests/test-mbrtoc32-w32-3.sh + tests/test-mbrtoc32-w32-4.sh + tests/test-mbrtoc32-w32-5.sh + tests/test-mbrtoc32-w32-6.sh + tests/test-mbrtoc32-w32-7.sh + tests/test-mbrtoc32-w32.c + tests/test-mbrtoc32.c + tests/test-mbrtowc-w32-1.sh + tests/test-mbrtowc-w32-2.sh + tests/test-mbrtowc-w32-3.sh + tests/test-mbrtowc-w32-4.sh + tests/test-mbrtowc-w32-5.sh + tests/test-mbrtowc-w32-6.sh + tests/test-mbrtowc-w32-7.sh + tests/test-mbrtowc-w32.c + tests/test-mbrtowc.c + tests/test-mbrtowc1.sh + tests/test-mbrtowc2.sh + tests/test-mbrtowc3.sh + tests/test-mbrtowc4.sh + tests/test-mbrtowc5.sh + tests/test-mbscasecmp.c + tests/test-mbscasecmp.sh + tests/test-mbsinit.c + tests/test-mbsinit.sh + tests/test-mbsrtowcs.c + tests/test-mbsrtowcs1.sh + tests/test-mbsrtowcs2.sh + tests/test-mbsrtowcs3.sh + tests/test-mbsrtowcs4.sh + tests/test-mbsrtowcs5.sh + tests/test-memchr.c + tests/test-memrchr.c + tests/test-mkdir.c + tests/test-mkdir.h + tests/test-nanosleep.c + tests/test-netinet_in.c + tests/test-nl_langinfo-mt.c + tests/test-nl_langinfo1.c + tests/test-nl_langinfo1.sh + tests/test-nl_langinfo2.c + tests/test-nl_langinfo2.sh + tests/test-nstrftime.c + tests/test-nullptr.c + tests/test-open.c + tests/test-open.h + tests/test-openat.c + tests/test-pathmax.c + tests/test-perror.c + tests/test-perror.sh + tests/test-perror2.c + tests/test-pipe.c + tests/test-pselect.c + tests/test-pthread-thread.c + tests/test-pthread.c + tests/test-pthread_sigmask1.c + tests/test-pthread_sigmask2.c + tests/test-quotearg-simple.c + tests/test-quotearg.h + tests/test-raise.c + tests/test-rawmemchr.c + tests/test-readlink.c + tests/test-readlink.h + tests/test-realloc-gnu.c + tests/test-reallocarray.c + tests/test-regex.c + tests/test-sched.c + tests/test-select-fd.c + tests/test-select-in.sh + tests/test-select-out.sh + tests/test-select-stdin.c + tests/test-select.c + tests/test-select.h + tests/test-setenv.c + tests/test-setlocale_null-mt-all.c + tests/test-setlocale_null-mt-one.c + tests/test-setlocale_null.c + tests/test-setsockopt.c + tests/test-sh-quote.c + tests/test-signal-h.c + tests/test-sigprocmask.c + tests/test-sigsegv-catch-segv1.c + tests/test-sigsegv-catch-segv2.c + tests/test-sigsegv-catch-stackoverflow1.c + tests/test-sigsegv-catch-stackoverflow2.c + tests/test-sleep.c + tests/test-snprintf.c + tests/test-sockets.c + tests/test-stat-time.c + tests/test-stat.c + tests/test-stat.h + tests/test-stdbool.c + tests/test-stdckdint.c + tests/test-stddef.c + tests/test-stdint.c + tests/test-stdio.c + tests/test-stdlib.c + tests/test-strerror.c + tests/test-strerror_r.c + tests/test-string.c + tests/test-strings.c + tests/test-strnlen.c + tests/test-strtoimax.c + tests/test-strtoll.c + tests/test-symlink.c + tests/test-symlink.h + tests/test-sys_ioctl.c + tests/test-sys_random.c + tests/test-sys_select.c + tests/test-sys_socket.c + tests/test-sys_stat.c + tests/test-sys_time.c + tests/test-sys_types.c + tests/test-sys_uio.c + tests/test-sys_wait.c + tests/test-sys_wait.h + tests/test-thread_create.c + tests/test-thread_self.c + tests/test-time-h.c + tests/test-time.c + tests/test-timespec.c + tests/test-timespec_get.c + tests/test-uchar.c + tests/test-unistd.c + tests/test-unsetenv.c + tests/test-update-copyright.sh + tests/test-vasnprintf.c + tests/test-vc-list-files-cvs.sh + tests/test-vc-list-files-git.sh + tests/test-verify-try.c + tests/test-verify.c + tests/test-verify.sh + tests/test-version-etc.c + tests/test-version-etc.sh + tests/test-wchar.c + tests/test-wcrtomb-w32-1.sh + tests/test-wcrtomb-w32-2.sh + tests/test-wcrtomb-w32-3.sh + tests/test-wcrtomb-w32-4.sh + tests/test-wcrtomb-w32-5.sh + tests/test-wcrtomb-w32-6.sh + tests/test-wcrtomb-w32-7.sh + tests/test-wcrtomb-w32.c + tests/test-wcrtomb.c + tests/test-wcrtomb.sh + tests/test-wctype-h.c + tests/test-wcwidth.c + tests/test-xalloc-die.c + tests/test-xalloc-die.sh + tests/test-xstdopen.c + tests/test-xstdopen.sh + tests/test-xstrtoimax.c + tests/test-xstrtoimax.sh + tests/test-xstrtol.c + tests/test-xstrtol.sh + tests/test-xstrtoul.c + tests/test-year2038.c + tests/unicase/test-mapping-part1.h + tests/unicase/test-mapping-part2.h + tests/unicase/test-uc_tolower.c + tests/unictype/test-ctype_space.c + tests/unictype/test-predicate-part1.h + tests/unictype/test-predicate-part2.h + tests/uniwidth/test-uc_width.c + tests/uniwidth/test-uc_width2.c + tests/uniwidth/test-uc_width2.sh + tests/zerosize-ptr.h + tests=lib/_Noreturn.h + tests=lib/accept.c + tests=lib/alloca.c + tests=lib/anytostr.c + tests=lib/arg-nonnull.h + tests=lib/arpa_inet.in.h + tests=lib/asnprintf.c + tests=lib/atoll.c + tests=lib/bind.c + tests=lib/btoc32.c + tests=lib/c++defs.h + tests=lib/c-strcasestr.c + tests=lib/c-strcasestr.h + tests=lib/c32rtomb.c + tests=lib/c32tob.c + tests=lib/connect.c + tests=lib/dtotimespec.c + tests=lib/fdopen.c + tests=lib/float+.h + tests=lib/float.c + tests=lib/float.in.h + tests=lib/fpucw.h + tests=lib/ftruncate.c + tests=lib/glthread/thread.c + tests=lib/glthread/thread.h + tests=lib/hash-pjw.c + tests=lib/hash-pjw.h + tests=lib/imaxtostr.c + tests=lib/inet_pton.c + tests=lib/inttostr.c + tests=lib/inttostr.h + tests=lib/ioctl.c + tests=lib/itold.c + tests=lib/listen.c + tests=lib/nanosleep.c + tests=lib/netinet_in.in.h + tests=lib/offtostr.c + tests=lib/perror.c + tests=lib/printf-args.c + tests=lib/printf-args.h + tests=lib/printf-parse.c + tests=lib/printf-parse.h + tests=lib/pselect.c + tests=lib/pthread-thread.c + tests=lib/pthread.in.h + tests=lib/pthread_sigmask.c + tests=lib/putenv.c + tests=lib/sched.in.h + tests=lib/select.c + tests=lib/setsockopt.c + tests=lib/size_max.h + tests=lib/sleep.c + tests=lib/snprintf.c + tests=lib/socket.c + tests=lib/sockets.c + tests=lib/sockets.h + tests=lib/str-two-way.h + tests=lib/strerror_r.c + tests=lib/symlink.c + tests=lib/sys_ioctl.in.h + tests=lib/sys_select.in.h + tests=lib/sys_socket.c + tests=lib/sys_socket.in.h + tests=lib/sys_uio.in.h + tests=lib/time.c + tests=lib/timespec-add.c + tests=lib/timespec-sub.c + tests=lib/uinttostr.c + tests=lib/umaxtostr.c + tests=lib/vasnprintf.c + tests=lib/vasnprintf.h + tests=lib/w32sock.h + tests=lib/warn-on-use.h + tests=lib/wctob.c + tests=lib/wctomb-impl.h + tests=lib/wctomb.c + tests=lib/windows-thread.c + tests=lib/windows-thread.h + tests=lib/windows-tls.c + tests=lib/windows-tls.h + tests=lib/xsize.c + tests=lib/xsize.h + tests=lib/xstrtol-error.c + tests=lib/xstrtol-error.h + top/GNUmakefile + top/README-release + top/maint.mk +]) diff --git a/gnulib-tool-tests/import-tests/test-all.sh b/gnulib-tool-tests/import-tests/test-all.sh index 8325f0a9..273dd83d 100755 --- a/gnulib-tool-tests/import-tests/test-all.sh +++ b/gnulib-tool-tests/import-tests/test-all.sh @@ -98,4 +98,5 @@ run_test_group ' test-gettext-6.sh test-gettext-7.sh test-gettext-8.sh + test-diffutils-1.sh ' diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.err b/gnulib-tool-tests/import-tests/test-diffutils-1.err new file mode 100644 index 00000000..e69de29b diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.out b/gnulib-tool-tests/import-tests/test-diffutils-1.out new file mode 100644 index 00000000..db49a9ff --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.out @@ -0,0 +1,3066 @@ +Module list with included dependencies (indented): + absolute-header + accept + accept-tests + alignasof + alignasof-tests + alloca + alloca-opt + alloca-opt-tests + allocator + announce-gen + argmatch + argmatch-tests + arpa_inet + arpa_inet-tests + assert-h + assert-h-tests + assure + at-internal + atoll + attribute + basename-lgpl + binary-io + binary-io-tests + bind + bind-tests + bitrotate + bitrotate-tests + btoc32 + btoc32-tests + btowc + btowc-tests + builtin-expect + c-ctype + c-ctype-tests + c-file-type + c-stack + c-stack-tests + c-strcase + c-strcase-tests + c-strcaseeq + c-strcasestr + c-strcasestr-tests + c32_apply_type_test + c32_apply_type_test-tests + c32_get_type_test + c32_get_type_test-tests + c32isalnum + c32isalnum-tests + c32isalpha + c32isalpha-tests + c32isblank + c32isblank-tests + c32iscntrl + c32iscntrl-tests + c32isdigit + c32isdigit-tests + c32isgraph + c32isgraph-tests + c32islower + c32islower-tests + c32isprint + c32isprint-tests + c32ispunct + c32ispunct-tests + c32isspace + c32isspace-tests + c32isupper + c32isupper-tests + c32isxdigit + c32isxdigit-tests + c32rtomb + c32rtomb-tests + c32tob + c32tolower + c32tolower-tests + c32width + c32width-tests + c99 + calloc-gnu + calloc-gnu-tests + calloc-posix + careadlinkat + chdir + chdir-long + chdir-tests + clock-time + cloexec + cloexec-tests + close + close-tests + closedir + config-h + connect + connect-tests + count-leading-zeros + count-leading-zeros-tests + ctype + ctype-tests + diffseq + dirent + dirent-tests + dirfd + dirfd-tests + dirname + dirname-lgpl + dirname-tests + do-release-commit-and-tag + double-slash-root + dtotimespec + dup + dup-tests + dup2 + dup2-tests + environ + environ-tests + errno + errno-tests + error + error-h + error-tests + exclude + exclude-tests + exitfail + extensions + extern-inline + fchdir + fchdir-tests + fcntl + fcntl-h + fcntl-h-tests + fcntl-tests + fd-hook + fd-safer-flag + fdopen + fdopen-tests + fdopendir + fdopendir-tests + fgetc-tests + file-type + filename + filenamecat + filenamecat-lgpl + filenamecat-tests + flexmember + float + float-tests + fnmatch + fnmatch-gnu + fnmatch-h + fnmatch-h-tests + fnmatch-tests + fopen + fopen-gnu + fopen-gnu-tests + fopen-tests + fpieee + fpucw + fputc-tests + fread-tests + free-posix + free-posix-tests + freopen + freopen-tests + fstat + fstat-tests + fstatat + fstatat-tests + ftruncate + ftruncate-tests + fwrite-tests + gen-header + gendocs + getcwd-lgpl + getcwd-lgpl-tests + getdtablesize + getdtablesize-tests + getopt-gnu + getopt-gnu-tests + getopt-posix + getopt-posix-tests + getpagesize + getprogname + getprogname-tests + getrandom + getrandom-tests + gettext-h + gettime + gettimeofday + gettimeofday-tests + git-version-gen + gitlog-to-changelog + glibc-internal/dynarray + glibc-internal/dynarray-tests + gnu-make + gnu-web-doc-update + gnumakefile + gnupload + hard-locale + hard-locale-tests + hash + hash-pjw + hash-tests + havelib + host-cpu-c-abi + ialloc + idx + ignore-value + ignore-value-tests + include_next + inet_pton + inet_pton-tests + inline + intprops + intprops-tests + inttostr + inttostr-tests + inttypes + inttypes-incomplete + inttypes-tests + ioctl + ioctl-tests + isblank + isblank-tests + isnand-nolibm + isnand-nolibm-tests + isnanf-nolibm + isnanf-nolibm-tests + isnanl-nolibm + isnanl-nolibm-tests + iswblank + iswblank-tests + iswctype + iswctype-tests + iswdigit + iswdigit-tests + iswpunct + iswpunct-tests + iswxdigit + iswxdigit-tests + langinfo + langinfo-tests + largefile + largefile-tests + libc-config + limits-h + limits-h-tests + listen + listen-tests + localcharset + localcharset-tests + locale + locale-tests + localeconv + localeconv-tests + lock + lstat + lstat-tests + maintainer-makefile + malloc-gnu + malloc-gnu-tests + malloc-posix + malloca + malloca-tests + manywarnings + math + math-tests + mbchar + mbrtoc32 + mbrtoc32-tests + mbrtowc + mbrtowc-tests + mbscasecmp + mbscasecmp-tests + mbsinit + mbsinit-tests + mbsrtoc32s + mbsrtoc32s-tests + mbsrtowcs + mbsrtowcs-tests + mbszero + mbtowc + mbuiter + mbuiterf + memchr + memchr-tests + mempcpy + memrchr + memrchr-tests + minmax + mkdir + mkdir-tests + mkstemp + mktime + mktime-internal + msvc-inval + msvc-nothrow + multiarch + nan + nanosleep + nanosleep-tests + netinet_in + netinet_in-tests + nl_langinfo + nl_langinfo-tests + nocrash + nstrftime + nstrftime-tests + nullptr + nullptr-tests + open + open-tests + openat + openat-die + openat-h + openat-tests + opendir + pathmax + pathmax-tests + pclose + pclose-tests + perl + perror + perror-tests + pipe-posix + pipe-posix-tests + popen + popen-tests + priv-set + priv-set-tests + progname + propername-lite + pselect + pselect-tests + pthread-h + pthread-h-tests + pthread-thread + pthread-thread-tests + pthread_sigmask + pthread_sigmask-tests + putenv + quote + quotearg + quotearg-simple + quotearg-simple-tests + raise + raise-tests + rawmemchr + rawmemchr-tests + readdir + readlink + readlink-tests + readlinkat + readlinkat-tests + readme-release + realloc-gnu + realloc-gnu-tests + realloc-posix + reallocarray + reallocarray-tests + regex + regex-tests + rmdir + rmdir-tests + root-uid + same-inode + save-cwd + sched + sched-tests + select + select-tests + setenv + setenv-tests + setlocale-null + setlocale-null-tests + setsockopt + setsockopt-tests + sh-quote + sh-quote-tests + sigaction + sigaction-tests + signal + signal-h + signal-h-tests + signbit + signbit-tests + signed-nan + signed-snan + sigprocmask + sigprocmask-tests + sigsegv + sigsegv-tests + size_max + sleep + sleep-tests + snan + snippet/_Noreturn + snippet/arg-nonnull + snippet/c++defs + snippet/warn-on-use + snprintf + snprintf-tests + socket + socketlib + sockets + sockets-tests + socklen + ssize_t + stat + stat-macros + stat-tests + stat-time + stat-time-tests + std-gnu11 + stdarg + stdarg-tests + stdbool + stdbool-tests + stdckdint + stdckdint-tests + stddef + stddef-tests + stdint + stdint-tests + stdio + stdio-tests + stdlib + stdlib-tests + stdopen + stpcpy + strcase + strdup-posix + streq + strerror + strerror-override + strerror-tests + strerror_r-posix + strerror_r-posix-tests + string + string-tests + strings + strings-tests + strnlen + strnlen-tests + strnlen1 + strptime + strtoimax + strtoimax-tests + strtoll + strtoll-tests + symlink + symlink-tests + symlinkat + symlinkat-tests + sys_ioctl + sys_ioctl-tests + sys_random + sys_random-tests + sys_select + sys_select-tests + sys_socket + sys_socket-tests + sys_stat + sys_stat-tests + sys_time + sys_time-tests + sys_types + sys_types-tests + sys_uio + sys_uio-tests + sys_wait + sys_wait-tests + system-quote + tempname + test-framework-sh + test-framework-sh-tests + thread + thread-tests + threadlib + time + time-h + time-h-tests + time-tests + time_r + time_rz + timegm + timespec + timespec-add + timespec-sub + timespec-tests + timespec_get + timespec_get-tests + tzset + uchar + uchar-tests + unicase/base + unicase/tolower + unicase/tolower-tests + unictype/base + unictype/ctype-alnum + unictype/ctype-alnum-tests + unictype/ctype-alpha + unictype/ctype-alpha-tests + unictype/ctype-blank + unictype/ctype-blank-tests + unictype/ctype-cntrl + unictype/ctype-cntrl-tests + unictype/ctype-digit + unictype/ctype-digit-tests + unictype/ctype-graph + unictype/ctype-graph-tests + unictype/ctype-lower + unictype/ctype-lower-tests + unictype/ctype-print + unictype/ctype-print-tests + unictype/ctype-punct + unictype/ctype-punct-tests + unictype/ctype-space + unictype/ctype-space-tests + unictype/ctype-upper + unictype/ctype-upper-tests + unictype/ctype-xdigit + unictype/ctype-xdigit-tests + uninorm/base + unistd + unistd-safer + unistd-safer-tests + unistd-tests + unistr/base + unistr/u32-chr + unistr/u32-chr-tests + unistr/u32-cpy + unistr/u32-cpy-tests + unistr/u32-pcpy + unistr/u32-pcpy-tests + unistr/u32-set + unistr/u32-set-tests + unistr/u32-strcat + unistr/u32-strcat-tests + unistr/u32-strlen + unistr/u32-strlen-tests + unitypes + uniwidth/base + uniwidth/width + uniwidth/width-tests + unlink + unlink-tests + unlinkat + unlinkat-tests + unlinkdir + unlocked-io + unlocked-io-internal + unsetenv + unsetenv-tests + update-copyright + update-copyright-tests + useless-if-before-free + vararrays + vasnprintf + vasnprintf-tests + vc-list-files + vc-list-files-tests + verify + verify-tests + version-etc + version-etc-fsf + version-etc-tests + warnings + wchar + wchar-tests + wcrtomb + wcrtomb-tests + wctob + wctomb + wctype + wctype-h + wctype-h-tests + wctype-tests + wcwidth + wcwidth-tests + windows-mutex + windows-once + windows-recmutex + windows-rwlock + windows-thread + windows-tls + wmemchr + wmempcpy + xalloc + xalloc-die + xalloc-die-tests + xalloc-oversized + xfreopen + xmalloca + xsize + xstdopen + xstdopen-tests + xstrtoimax + xstrtoimax-tests + xstrtol + xstrtol-error + xstrtol-tests + year2038 + year2038-tests +File list: + build-aux/announce-gen + build-aux/config.rpath + build-aux/do-release-commit-and-tag + build-aux/gendocs.sh + build-aux/git-version-gen + build-aux/gitlog-to-changelog + build-aux/gnu-web-doc-update + build-aux/gnupload + build-aux/update-copyright + build-aux/useless-if-before-free + build-aux/vc-list-files + doc/gendocs_template + doc/gendocs_template_min + lib/_Noreturn.h + lib/alloca.in.h + lib/allocator.c + lib/allocator.h + lib/arg-nonnull.h + lib/argmatch.c + lib/argmatch.h + lib/assert.in.h + lib/assure.h + lib/at-func.c + lib/attribute.h + lib/basename-lgpl.c + lib/basename-lgpl.h + lib/basename.c + lib/binary-io.c + lib/binary-io.h + lib/bitrotate.c + lib/bitrotate.h + lib/btoc32.c + lib/btowc.c + lib/c++defs.h + lib/c-ctype.c + lib/c-ctype.h + lib/c-file-type.c + lib/c-stack.c + lib/c-stack.h + lib/c-strcase.h + lib/c-strcasecmp.c + lib/c-strcaseeq.h + lib/c-strncasecmp.c + lib/c32_apply_type_test.c + lib/c32_get_type_test.c + lib/c32is-impl.h + lib/c32isalnum.c + lib/c32isalpha.c + lib/c32isblank.c + lib/c32iscntrl.c + lib/c32isdigit.c + lib/c32isgraph.c + lib/c32islower.c + lib/c32isprint.c + lib/c32ispunct.c + lib/c32isspace.c + lib/c32isupper.c + lib/c32isxdigit.c + lib/c32to-impl.h + lib/c32tolower.c + lib/c32width.c + lib/calloc.c + lib/careadlinkat.c + lib/careadlinkat.h + lib/cdefs.h + lib/chdir-long.c + lib/chdir-long.h + lib/cloexec.c + lib/cloexec.h + lib/close.c + lib/closedir.c + lib/count-leading-zeros.c + lib/count-leading-zeros.h + lib/ctype.in.h + lib/diffseq.h + lib/dirent-private.h + lib/dirent.in.h + lib/dirfd.c + lib/dirname-lgpl.c + lib/dirname.c + lib/dirname.h + lib/dup-safer-flag.c + lib/dup-safer.c + lib/dup.c + lib/dup2.c + lib/dynarray.h + lib/errno.in.h + lib/error.c + lib/error.in.h + lib/exclude.c + lib/exclude.h + lib/exitfail.c + lib/exitfail.h + lib/fchdir.c + lib/fcntl.c + lib/fcntl.in.h + lib/fd-hook.c + lib/fd-hook.h + lib/fd-safer-flag.c + lib/fd-safer.c + lib/fdopendir.c + lib/file-type.c + lib/file-type.h + lib/filename.h + lib/filenamecat-lgpl.c + lib/filenamecat.c + lib/filenamecat.h + lib/flexmember.h + lib/fnmatch.c + lib/fnmatch.in.h + lib/fnmatch_loop.c + lib/fopen.c + lib/free.c + lib/freopen.c + lib/fstat.c + lib/fstatat.c + lib/getcwd-lgpl.c + lib/getdtablesize.c + lib/getopt-cdefs.in.h + lib/getopt-core.h + lib/getopt-ext.h + lib/getopt-pfx-core.h + lib/getopt-pfx-ext.h + lib/getopt.c + lib/getopt.in.h + lib/getopt1.c + lib/getopt_int.h + lib/getpagesize.c + lib/getprogname.c + lib/getprogname.h + lib/getrandom.c + lib/gettext.h + lib/gettime.c + lib/gettimeofday.c + lib/glthread/lock.c + lib/glthread/lock.h + lib/glthread/threadlib.c + lib/hard-locale.c + lib/hard-locale.h + lib/hash.c + lib/hash.h + lib/ialloc.c + lib/ialloc.h + lib/idx.h + lib/ignore-value.h + lib/intprops-internal.h + lib/intprops.h + lib/inttypes.in.h + lib/isblank.c + lib/iswblank.c + lib/iswctype-impl.h + lib/iswctype.c + lib/iswdigit.c + lib/iswpunct.c + lib/iswxdigit.c + lib/langinfo.in.h + lib/lc-charset-dispatch.c + lib/lc-charset-dispatch.h + lib/libc-config.h + lib/limits.in.h + lib/localcharset.c + lib/localcharset.h + lib/locale.in.h + lib/localeconv.c + lib/lstat.c + lib/malloc.c + lib/malloc/dynarray-skeleton.c + lib/malloc/dynarray.h + lib/malloc/dynarray_at_failure.c + lib/malloc/dynarray_emplace_enlarge.c + lib/malloc/dynarray_finalize.c + lib/malloc/dynarray_resize.c + lib/malloc/dynarray_resize_clear.c + lib/malloca.c + lib/malloca.h + lib/mbchar.c + lib/mbchar.h + lib/mbrtoc32.c + lib/mbrtowc-impl-utf8.h + lib/mbrtowc-impl.h + lib/mbrtowc.c + lib/mbscasecmp.c + lib/mbsinit.c + lib/mbsrtoc32s-state.c + lib/mbsrtoc32s.c + lib/mbsrtowcs-impl.h + lib/mbsrtowcs-state.c + lib/mbsrtowcs.c + lib/mbszero.c + lib/mbtowc-impl.h + lib/mbtowc-lock.c + lib/mbtowc-lock.h + lib/mbtowc.c + lib/mbuiter.c + lib/mbuiter.h + lib/mbuiterf.c + lib/mbuiterf.h + lib/memchr.c + lib/memchr.valgrind + lib/mempcpy.c + lib/memrchr.c + lib/minmax.h + lib/mkdir.c + lib/mkstemp.c + lib/mktime-internal.h + lib/mktime.c + lib/msvc-inval.c + lib/msvc-inval.h + lib/msvc-nothrow.c + lib/msvc-nothrow.h + lib/nl_langinfo-lock.c + lib/nl_langinfo.c + lib/nstrftime.c + lib/open.c + lib/openat-die.c + lib/openat-priv.h + lib/openat-proc.c + lib/openat.c + lib/openat.h + lib/opendir.c + lib/pathmax.h + lib/pclose.c + lib/pipe-safer.c + lib/pipe.c + lib/popen.c + lib/progname.c + lib/progname.h + lib/propername-lite.c + lib/propername.h + lib/quote.h + lib/quotearg.c + lib/quotearg.h + lib/raise.c + lib/rawmemchr.c + lib/rawmemchr.valgrind + lib/readdir.c + lib/readlink.c + lib/readlinkat.c + lib/realloc.c + lib/reallocarray.c + lib/regcomp.c + lib/regex.c + lib/regex.h + lib/regex_internal.c + lib/regex_internal.h + lib/regexec.c + lib/same-inode.c + lib/same-inode.h + lib/save-cwd.c + lib/save-cwd.h + lib/setenv.c + lib/setlocale-lock.c + lib/setlocale_null.c + lib/setlocale_null.h + lib/sh-quote.c + lib/sh-quote.h + lib/sig-handler.c + lib/sig-handler.h + lib/sigaction.c + lib/signal.in.h + lib/sigprocmask.c + lib/sigsegv.c + lib/sigsegv.in.h + lib/stackvma.c + lib/stackvma.h + lib/stat-macros.h + lib/stat-time.c + lib/stat-time.h + lib/stat-w32.c + lib/stat-w32.h + lib/stat.c + lib/stdarg.in.h + lib/stdckdint.in.h + lib/stddef.in.h + lib/stdint.in.h + lib/stdio-read.c + lib/stdio-write.c + lib/stdio.in.h + lib/stdlib.in.h + lib/stdopen.c + lib/stdopen.h + lib/stpcpy.c + lib/strcasecmp.c + lib/strdup.c + lib/streq.h + lib/strerror-override.c + lib/strerror-override.h + lib/strerror.c + lib/strftime.h + lib/string.in.h + lib/strings.in.h + lib/stripslash.c + lib/strncasecmp.c + lib/strnlen.c + lib/strnlen1.c + lib/strnlen1.h + lib/strptime.c + lib/strtoimax.c + lib/strtol.c + lib/strtoll.c + lib/sys_random.in.h + lib/sys_stat.in.h + lib/sys_time.in.h + lib/sys_types.in.h + lib/sys_wait.in.h + lib/system-quote.c + lib/system-quote.h + lib/tempname.c + lib/tempname.h + lib/time-internal.h + lib/time.in.h + lib/time_r.c + lib/time_rz.c + lib/timegm.c + lib/timespec.c + lib/timespec.h + lib/timespec_get.c + lib/tzset.c + lib/uchar.in.h + lib/unicase.in.h + lib/unicase/simple-mapping.h + lib/unicase/tolower.c + lib/unicase/tolower.h + lib/unictype.in.h + lib/unictype/bitmap.h + lib/unictype/ctype_alnum.c + lib/unictype/ctype_alnum.h + lib/unictype/ctype_alpha.c + lib/unictype/ctype_alpha.h + lib/unictype/ctype_blank.c + lib/unictype/ctype_blank.h + lib/unictype/ctype_cntrl.c + lib/unictype/ctype_cntrl.h + lib/unictype/ctype_digit.c + lib/unictype/ctype_digit.h + lib/unictype/ctype_graph.c + lib/unictype/ctype_graph.h + lib/unictype/ctype_lower.c + lib/unictype/ctype_lower.h + lib/unictype/ctype_print.c + lib/unictype/ctype_print.h + lib/unictype/ctype_punct.c + lib/unictype/ctype_punct.h + lib/unictype/ctype_space.c + lib/unictype/ctype_space.h + lib/unictype/ctype_upper.c + lib/unictype/ctype_upper.h + lib/unictype/ctype_xdigit.c + lib/unictype/ctype_xdigit.h + lib/uninorm.in.h + lib/unistd--.h + lib/unistd-safer.h + lib/unistd.c + lib/unistd.in.h + lib/unistr.in.h + lib/unistr/u-cpy.h + lib/unistr/u-pcpy.h + lib/unistr/u-strcat.h + lib/unistr/u-strlen.h + lib/unistr/u32-chr.c + lib/unistr/u32-cpy.c + lib/unistr/u32-pcpy.c + lib/unistr/u32-strcat.c + lib/unistr/u32-strlen.c + lib/unitypes.in.h + lib/uniwidth.in.h + lib/uniwidth/cjk.h + lib/uniwidth/width.c + lib/uniwidth/width0.h + lib/uniwidth/width2.h + lib/unlocked-io.h + lib/unsetenv.c + lib/verify.h + lib/version-etc-fsf.c + lib/version-etc.c + lib/version-etc.h + lib/warn-on-use.h + lib/wchar.in.h + lib/wcrtomb.c + lib/wctype-h.c + lib/wctype-impl.h + lib/wctype.c + lib/wctype.in.h + lib/wcwidth.c + lib/windows-initguard.h + 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 + lib/wmemchr-impl.h + lib/wmemchr.c + lib/wmempcpy.c + lib/xalloc-die.c + lib/xalloc-oversized.h + lib/xalloc.h + lib/xfreopen.c + lib/xfreopen.h + lib/xmalloc.c + lib/xmalloca.c + lib/xmalloca.h + lib/xstdopen.c + lib/xstdopen.h + lib/xstrtoimax.c + lib/xstrtol.c + lib/xstrtol.h + lib/xstrtoul.c + m4/00gnulib.m4 + m4/__inline.m4 + m4/absolute-header.m4 + m4/alloca.m4 + m4/arpa_inet_h.m4 + m4/asm-underscore.m4 + m4/assert_h.m4 + m4/atoll.m4 + m4/btowc.m4 + m4/builtin-expect.m4 + m4/c-bool.m4 + m4/c-stack.m4 + m4/c32rtomb.m4 + m4/calloc.m4 + m4/chdir-long.m4 + m4/clock_time.m4 + m4/close.m4 + m4/closedir.m4 + m4/codeset.m4 + m4/config-h.m4 + m4/ctype_h.m4 + m4/dirent_h.m4 + m4/dirfd.m4 + m4/double-slash-root.m4 + m4/dup.m4 + m4/dup2.m4 + m4/eealloc.m4 + m4/environ.m4 + m4/errno_h.m4 + m4/error.m4 + m4/error_h.m4 + m4/exponentd.m4 + m4/exponentf.m4 + m4/exponentl.m4 + m4/extensions.m4 + m4/extern-inline.m4 + m4/fchdir.m4 + m4/fclose.m4 + m4/fcntl-o.m4 + m4/fcntl.m4 + m4/fcntl_h.m4 + m4/fdopen.m4 + m4/fdopendir.m4 + m4/fflush.m4 + m4/filenamecat.m4 + m4/flexmember.m4 + m4/float_h.m4 + m4/fnmatch.m4 + m4/fnmatch_h.m4 + m4/fopen.m4 + m4/fpieee.m4 + m4/free.m4 + m4/freopen.m4 + m4/fstat.m4 + m4/fstatat.m4 + m4/ftruncate.m4 + m4/getcwd.m4 + m4/getdtablesize.m4 + m4/getopt.m4 + m4/getpagesize.m4 + m4/getprogname.m4 + m4/getrandom.m4 + m4/gettime.m4 + m4/gettimeofday.m4 + m4/gnu-make.m4 + m4/gnulib-common.m4 + m4/host-cpu-c-abi.m4 + m4/include_next.m4 + m4/inet_pton.m4 + m4/inline.m4 + m4/intl-thread-locale.m4 + m4/intmax_t.m4 + m4/inttostr.m4 + m4/inttypes.m4 + m4/inttypes_h.m4 + m4/ioctl.m4 + m4/isblank.m4 + m4/isnand.m4 + m4/isnanf.m4 + m4/isnanl.m4 + m4/iswblank.m4 + m4/iswctype.m4 + m4/iswdigit.m4 + m4/iswpunct.m4 + m4/iswxdigit.m4 + m4/langinfo_h.m4 + m4/largefile.m4 + m4/lib-ld.m4 + m4/lib-link.m4 + m4/lib-prefix.m4 + m4/libsigsegv.m4 + m4/libunistring-base.m4 + m4/limits-h.m4 + m4/localcharset.m4 + m4/locale-fr.m4 + m4/locale-ja.m4 + m4/locale-tr.m4 + m4/locale-zh.m4 + m4/locale_h.m4 + m4/localeconv.m4 + m4/lock.m4 + m4/lstat.m4 + m4/malloc.m4 + m4/malloca.m4 + m4/manywarnings-c++.m4 + m4/manywarnings.m4 + m4/math_h.m4 + m4/mbchar.m4 + m4/mbiter.m4 + m4/mbrtoc32.m4 + m4/mbrtowc.m4 + m4/mbsinit.m4 + m4/mbsrtowcs.m4 + m4/mbstate_t.m4 + m4/mbtowc.m4 + m4/memchr.m4 + m4/mempcpy.m4 + m4/memrchr.m4 + m4/minmax.m4 + m4/mkdir.m4 + m4/mkstemp.m4 + m4/mktime.m4 + m4/mmap-anon.m4 + m4/mode_t.m4 + m4/msvc-inval.m4 + m4/msvc-nothrow.m4 + m4/multiarch.m4 + m4/musl.m4 + m4/nan-mips.m4 + m4/nanosleep.m4 + m4/netinet_in_h.m4 + m4/nl_langinfo.m4 + m4/nocrash.m4 + m4/nstrftime.m4 + m4/nullptr.m4 + m4/off_t.m4 + m4/open-cloexec.m4 + m4/open-slash.m4 + m4/open.m4 + m4/openat.m4 + m4/opendir.m4 + m4/pathmax.m4 + m4/pclose.m4 + m4/perl.m4 + m4/perror.m4 + m4/pid_t.m4 + m4/pipe.m4 + m4/popen.m4 + m4/printf.m4 + m4/priv-set.m4 + m4/pselect.m4 + m4/pthread-thread.m4 + m4/pthread_h.m4 + m4/pthread_rwlock_rdlock.m4 + m4/pthread_sigmask.m4 + m4/putenv.m4 + m4/quote.m4 + m4/quotearg.m4 + m4/raise.m4 + m4/rawmemchr.m4 + m4/readdir.m4 + m4/readlink.m4 + m4/readlinkat.m4 + m4/realloc.m4 + m4/reallocarray.m4 + m4/regex.m4 + m4/rmdir.m4 + m4/save-cwd.m4 + m4/sched_h.m4 + m4/select.m4 + m4/setenv.m4 + m4/setlocale_null.m4 + m4/sigaction.m4 + m4/sigaltstack.m4 + m4/signal_h.m4 + m4/signalblocking.m4 + m4/signbit.m4 + m4/sigsegv.m4 + m4/size_max.m4 + m4/sleep.m4 + m4/snan.m4 + m4/snprintf.m4 + m4/socketlib.m4 + m4/sockets.m4 + m4/socklen.m4 + m4/sockpfaf.m4 + m4/ssize_t.m4 + m4/stack-direction.m4 + m4/stat-time.m4 + m4/stat.m4 + m4/std-gnu11.m4 + m4/stdalign.m4 + m4/stdarg.m4 + m4/stddef_h.m4 + m4/stdint.m4 + m4/stdint_h.m4 + m4/stdio_h.m4 + m4/stdlib_h.m4 + m4/stpcpy.m4 + m4/strcase.m4 + m4/strdup.m4 + m4/strerror.m4 + m4/strerror_r.m4 + m4/string_h.m4 + m4/strings_h.m4 + m4/strnlen.m4 + m4/strptime.m4 + m4/strtoimax.m4 + m4/strtoll.m4 + m4/symlink.m4 + m4/symlinkat.m4 + m4/sys_ioctl_h.m4 + m4/sys_random_h.m4 + m4/sys_select_h.m4 + m4/sys_socket_h.m4 + m4/sys_stat_h.m4 + m4/sys_time_h.m4 + m4/sys_types_h.m4 + m4/sys_uio_h.m4 + m4/sys_wait_h.m4 + m4/tempname.m4 + m4/thread.m4 + m4/threadlib.m4 + m4/time.m4 + m4/time_h.m4 + m4/time_r.m4 + m4/time_rz.m4 + m4/timegm.m4 + m4/timespec.m4 + m4/timespec_get.m4 + m4/tm_gmtoff.m4 + m4/tzset.m4 + m4/uchar_h.m4 + m4/unicase_h.m4 + m4/unictype_h.m4 + m4/uninorm_h.m4 + m4/unistd-safer.m4 + m4/unistd_h.m4 + m4/unlink.m4 + m4/unlinkat.m4 + m4/unlinkdir.m4 + m4/unlocked-io.m4 + m4/vararrays.m4 + m4/vasnprintf.m4 + m4/version-etc.m4 + m4/visibility.m4 + m4/warn-on-use.m4 + m4/warnings.m4 + m4/wchar_h.m4 + m4/wchar_t.m4 + m4/wcrtomb.m4 + m4/wctob.m4 + m4/wctomb.m4 + m4/wctype.m4 + m4/wctype_h.m4 + m4/wcwidth.m4 + m4/wint_t.m4 + m4/wmemchr.m4 + m4/wmempcpy.m4 + m4/xalloc.m4 + m4/xsize.m4 + m4/xstrtol.m4 + m4/zzgnulib.m4 + tests/altstack-util.h + tests/infinity.h + tests/init.sh + tests/locale.c + tests/macros.h + tests/minus-zero.h + tests/mmap-anon-util.h + tests/nap.h + tests/signature.h + tests/test-accept.c + tests/test-alignasof.c + tests/test-alloca-opt.c + tests/test-argmatch.c + tests/test-arpa_inet.c + tests/test-assert.c + tests/test-binary-io.c + tests/test-binary-io.sh + tests/test-bind.c + tests/test-bitrotate.c + tests/test-btoc32-1.sh + tests/test-btoc32-2.sh + tests/test-btoc32-3.sh + tests/test-btoc32.c + tests/test-btowc-1.sh + tests/test-btowc-2.sh + tests/test-btowc-3.sh + tests/test-btowc.c + tests/test-c-ctype.c + tests/test-c-stack.c + tests/test-c-stack.sh + tests/test-c-stack2.sh + tests/test-c-strcase.sh + tests/test-c-strcasecmp.c + tests/test-c-strcasestr.c + tests/test-c-strncasecmp.c + tests/test-c32_apply_type_test.c + tests/test-c32_get_type_test.c + tests/test-c32isalnum.c + tests/test-c32isalnum.sh + tests/test-c32isalpha.c + tests/test-c32isalpha.sh + tests/test-c32isblank.c + tests/test-c32isblank.sh + tests/test-c32iscntrl.c + tests/test-c32iscntrl.sh + tests/test-c32isdigit.c + tests/test-c32isdigit.sh + tests/test-c32isgraph.c + tests/test-c32isgraph.sh + tests/test-c32islower.c + tests/test-c32islower.sh + tests/test-c32isprint.c + tests/test-c32isprint.sh + tests/test-c32ispunct.c + tests/test-c32ispunct.sh + tests/test-c32isspace.c + tests/test-c32isspace.sh + tests/test-c32isupper.c + tests/test-c32isupper.sh + tests/test-c32isxdigit.c + tests/test-c32isxdigit.sh + tests/test-c32rtomb-w32-2.sh + tests/test-c32rtomb-w32-3.sh + tests/test-c32rtomb-w32-4.sh + tests/test-c32rtomb-w32-5.sh + tests/test-c32rtomb-w32-6.sh + tests/test-c32rtomb-w32-7.sh + tests/test-c32rtomb-w32-8.sh + tests/test-c32rtomb-w32.c + tests/test-c32rtomb.c + tests/test-c32rtomb.sh + tests/test-c32tolower.c + tests/test-c32tolower.sh + tests/test-c32width.c + tests/test-calloc-gnu.c + tests/test-chdir.c + tests/test-cloexec.c + tests/test-close.c + tests/test-connect.c + tests/test-count-leading-zeros.c + tests/test-ctype.c + tests/test-dirent.c + tests/test-dirfd.c + tests/test-dirname.c + tests/test-dup-safer.c + tests/test-dup.c + tests/test-dup2.c + tests/test-dynarray.c + tests/test-environ.c + tests/test-errno.c + tests/test-error.c + tests/test-error.sh + tests/test-exclude.c + tests/test-exclude1.sh + tests/test-exclude2.sh + tests/test-exclude3.sh + tests/test-exclude4.sh + tests/test-exclude5.sh + tests/test-exclude6.sh + tests/test-exclude7.sh + tests/test-exclude8.sh + tests/test-fchdir.c + tests/test-fcntl-h.c + tests/test-fcntl.c + tests/test-fdopen.c + tests/test-fdopendir.c + tests/test-fgetc.c + tests/test-filenamecat.c + tests/test-float.c + tests/test-fnmatch-1.sh + tests/test-fnmatch-2.sh + tests/test-fnmatch-3.sh + tests/test-fnmatch-4.sh + tests/test-fnmatch-5.sh + tests/test-fnmatch-h.c + tests/test-fnmatch-w32-2.sh + tests/test-fnmatch-w32-3.sh + tests/test-fnmatch-w32-4.sh + tests/test-fnmatch-w32-5.sh + tests/test-fnmatch-w32-6.sh + tests/test-fnmatch-w32-7.sh + tests/test-fnmatch-w32-8.sh + tests/test-fnmatch-w32.c + tests/test-fnmatch.c + tests/test-fopen-gnu.c + tests/test-fopen.c + tests/test-fopen.h + tests/test-fputc.c + tests/test-fread.c + tests/test-free.c + tests/test-freopen.c + tests/test-fstat.c + tests/test-fstatat.c + tests/test-ftruncate.c + tests/test-ftruncate.sh + tests/test-fwrite.c + tests/test-getcwd-lgpl.c + tests/test-getdtablesize.c + tests/test-getopt-gnu.c + tests/test-getopt-main.h + tests/test-getopt-posix.c + tests/test-getopt.h + tests/test-getopt_long.h + tests/test-getprogname.c + tests/test-getrandom.c + tests/test-gettimeofday.c + tests/test-hard-locale.c + tests/test-hash.c + tests/test-ignore-value.c + tests/test-inet_pton.c + tests/test-init.sh + tests/test-intprops.c + tests/test-inttostr.c + tests/test-inttypes.c + tests/test-ioctl.c + tests/test-isblank.c + tests/test-isnand-nolibm.c + tests/test-isnand.h + tests/test-isnanf-nolibm.c + tests/test-isnanf.h + tests/test-isnanl-nolibm.c + tests/test-isnanl.h + tests/test-iswblank.c + tests/test-iswctype.c + tests/test-iswdigit.c + tests/test-iswdigit.sh + tests/test-iswpunct.c + tests/test-iswpunct.sh + tests/test-iswxdigit.c + tests/test-iswxdigit.sh + tests/test-langinfo.c + tests/test-largefile.c + tests/test-limits-h.c + tests/test-listen.c + tests/test-localcharset.c + tests/test-locale.c + tests/test-localeconv.c + tests/test-lstat.c + tests/test-lstat.h + tests/test-malloc-gnu.c + tests/test-malloca.c + tests/test-math.c + tests/test-mbrtoc32-1.sh + tests/test-mbrtoc32-2.sh + tests/test-mbrtoc32-3.sh + tests/test-mbrtoc32-4.sh + tests/test-mbrtoc32-5.sh + tests/test-mbrtoc32-w32-2.sh + tests/test-mbrtoc32-w32-3.sh + tests/test-mbrtoc32-w32-4.sh + tests/test-mbrtoc32-w32-5.sh + tests/test-mbrtoc32-w32-6.sh + tests/test-mbrtoc32-w32-7.sh + tests/test-mbrtoc32-w32-8.sh + tests/test-mbrtoc32-w32.c + tests/test-mbrtoc32.c + tests/test-mbrtowc-1.sh + tests/test-mbrtowc-2.sh + tests/test-mbrtowc-3.sh + tests/test-mbrtowc-4.sh + tests/test-mbrtowc-5.sh + tests/test-mbrtowc-w32-2.sh + tests/test-mbrtowc-w32-3.sh + tests/test-mbrtowc-w32-4.sh + tests/test-mbrtowc-w32-5.sh + tests/test-mbrtowc-w32-6.sh + tests/test-mbrtowc-w32-7.sh + tests/test-mbrtowc-w32-8.sh + tests/test-mbrtowc-w32.c + tests/test-mbrtowc.c + tests/test-mbscasecmp.c + tests/test-mbscasecmp.sh + tests/test-mbsinit.c + tests/test-mbsinit.sh + tests/test-mbsrtoc32s-1.sh + tests/test-mbsrtoc32s-2.sh + tests/test-mbsrtoc32s-3.sh + tests/test-mbsrtoc32s-4.sh + tests/test-mbsrtoc32s-5.sh + tests/test-mbsrtoc32s.c + tests/test-mbsrtowcs-1.sh + tests/test-mbsrtowcs-2.sh + tests/test-mbsrtowcs-3.sh + tests/test-mbsrtowcs-4.sh + tests/test-mbsrtowcs-5.sh + tests/test-mbsrtowcs.c + tests/test-memchr.c + tests/test-memrchr.c + tests/test-mkdir.c + tests/test-mkdir.h + tests/test-nanosleep.c + tests/test-netinet_in.c + tests/test-nl_langinfo-mt.c + tests/test-nl_langinfo1.c + tests/test-nl_langinfo1.sh + tests/test-nl_langinfo2.c + tests/test-nl_langinfo2.sh + tests/test-nstrftime.c + tests/test-nullptr.c + tests/test-open.c + tests/test-open.h + tests/test-openat.c + tests/test-pathmax.c + tests/test-perror.c + tests/test-perror.sh + tests/test-perror2.c + tests/test-pipe.c + tests/test-popen.c + tests/test-popen.h + tests/test-priv-set.c + tests/test-pselect.c + tests/test-pthread-thread.c + tests/test-pthread.c + tests/test-pthread_sigmask1.c + tests/test-pthread_sigmask2.c + tests/test-quotearg-simple.c + tests/test-quotearg.h + tests/test-raise.c + tests/test-rawmemchr.c + tests/test-readlink.c + tests/test-readlink.h + tests/test-readlinkat.c + tests/test-realloc-gnu.c + tests/test-reallocarray.c + tests/test-regex.c + tests/test-rmdir.c + tests/test-rmdir.h + tests/test-sched.c + tests/test-select-fd.c + tests/test-select-in.sh + tests/test-select-out.sh + tests/test-select-stdin.c + tests/test-select.c + tests/test-select.h + tests/test-setenv.c + tests/test-setlocale_null-mt-all.c + tests/test-setlocale_null-mt-one.c + tests/test-setlocale_null.c + tests/test-setsockopt.c + tests/test-sh-quote.c + tests/test-sigaction.c + tests/test-signal-h.c + tests/test-signbit.c + tests/test-sigprocmask.c + tests/test-sigsegv-catch-segv1.c + tests/test-sigsegv-catch-segv2.c + tests/test-sigsegv-catch-stackoverflow1.c + tests/test-sigsegv-catch-stackoverflow2.c + tests/test-sleep.c + tests/test-snprintf.c + tests/test-sockets.c + tests/test-stat-time.c + tests/test-stat.c + tests/test-stat.h + tests/test-stdbool.c + tests/test-stdckdint.c + tests/test-stddef.c + tests/test-stdint.c + tests/test-stdio.c + tests/test-stdlib.c + tests/test-strerror.c + tests/test-strerror_r.c + tests/test-string.c + tests/test-strings.c + tests/test-strnlen.c + tests/test-strtoimax.c + tests/test-strtoll.c + tests/test-symlink.c + tests/test-symlink.h + tests/test-symlinkat.c + tests/test-sys_ioctl.c + tests/test-sys_random.c + tests/test-sys_select.c + tests/test-sys_socket.c + tests/test-sys_stat.c + tests/test-sys_time.c + tests/test-sys_types.c + tests/test-sys_uio.c + tests/test-sys_wait.c + tests/test-sys_wait.h + tests/test-thread_create.c + tests/test-thread_self.c + tests/test-time-h.c + tests/test-time.c + tests/test-timespec.c + tests/test-timespec_get.c + tests/test-uchar.c + tests/test-unistd.c + tests/test-unlink.c + tests/test-unlink.h + tests/test-unlinkat.c + tests/test-unsetenv.c + tests/test-update-copyright.sh + tests/test-vasnprintf.c + tests/test-vc-list-files-cvs.sh + tests/test-vc-list-files-git.sh + tests/test-verify-try.c + tests/test-verify.c + tests/test-verify.sh + tests/test-version-etc.c + tests/test-version-etc.sh + tests/test-wchar.c + tests/test-wcrtomb-w32-2.sh + tests/test-wcrtomb-w32-3.sh + tests/test-wcrtomb-w32-4.sh + tests/test-wcrtomb-w32-5.sh + tests/test-wcrtomb-w32-6.sh + tests/test-wcrtomb-w32-7.sh + tests/test-wcrtomb-w32-8.sh + tests/test-wcrtomb-w32.c + tests/test-wcrtomb.c + tests/test-wcrtomb.sh + tests/test-wctype-h.c + tests/test-wctype.c + tests/test-wcwidth.c + tests/test-xalloc-die.c + tests/test-xalloc-die.sh + tests/test-xstdopen.c + tests/test-xstdopen.sh + tests/test-xstrtoimax.c + tests/test-xstrtoimax.sh + tests/test-xstrtol.c + tests/test-xstrtol.sh + tests/test-xstrtoul.c + tests/test-year2038.c + tests/unicase/test-mapping-part1.h + tests/unicase/test-mapping-part2.h + tests/unicase/test-uc_tolower.c + tests/unictype/test-ctype_alnum.c + tests/unictype/test-ctype_alpha.c + tests/unictype/test-ctype_blank.c + tests/unictype/test-ctype_cntrl.c + tests/unictype/test-ctype_digit.c + tests/unictype/test-ctype_graph.c + tests/unictype/test-ctype_lower.c + tests/unictype/test-ctype_print.c + tests/unictype/test-ctype_punct.c + tests/unictype/test-ctype_space.c + tests/unictype/test-ctype_upper.c + tests/unictype/test-ctype_xdigit.c + tests/unictype/test-predicate-part1.h + tests/unictype/test-predicate-part2.h + tests/unistr/test-chr.h + tests/unistr/test-cpy.h + tests/unistr/test-pcpy.h + tests/unistr/test-set.h + tests/unistr/test-strcat.h + tests/unistr/test-u32-chr.c + tests/unistr/test-u32-cpy.c + tests/unistr/test-u32-pcpy.c + tests/unistr/test-u32-set.c + tests/unistr/test-u32-strcat.c + tests/unistr/test-u32-strlen.c + tests/uniwidth/test-uc_width.c + tests/uniwidth/test-uc_width2.c + tests/uniwidth/test-uc_width2.sh + tests/zerosize-ptr.h + lib/_Noreturn.h -> tests/_Noreturn.h + lib/accept.c -> tests/accept.c + lib/alloca.c -> tests/alloca.c + lib/anytostr.c -> tests/anytostr.c + lib/arg-nonnull.h -> tests/arg-nonnull.h + lib/arpa_inet.in.h -> tests/arpa_inet.in.h + lib/asnprintf.c -> tests/asnprintf.c + lib/at-func.c -> tests/at-func.c + lib/atoll.c -> tests/atoll.c + lib/bind.c -> tests/bind.c + lib/c++defs.h -> tests/c++defs.h + lib/c-strcasestr.c -> tests/c-strcasestr.c + lib/c-strcasestr.h -> tests/c-strcasestr.h + lib/c32rtomb.c -> tests/c32rtomb.c + lib/c32tob.c -> tests/c32tob.c + lib/connect.c -> tests/connect.c + lib/dtotimespec.c -> tests/dtotimespec.c + lib/fdopen.c -> tests/fdopen.c + lib/float+.h -> tests/float+.h + lib/float.c -> tests/float.c + lib/float.in.h -> tests/float.in.h + lib/fpucw.h -> tests/fpucw.h + lib/ftruncate.c -> tests/ftruncate.c + lib/glthread/thread.c -> tests/glthread/thread.c + lib/glthread/thread.h -> tests/glthread/thread.h + lib/hash-pjw.c -> tests/hash-pjw.c + lib/hash-pjw.h -> tests/hash-pjw.h + lib/imaxtostr.c -> tests/imaxtostr.c + lib/inet_pton.c -> tests/inet_pton.c + lib/inttostr.c -> tests/inttostr.c + lib/inttostr.h -> tests/inttostr.h + lib/ioctl.c -> tests/ioctl.c + lib/isnan.c -> tests/isnan.c + lib/isnand-nolibm.h -> tests/isnand-nolibm.h + lib/isnand.c -> tests/isnand.c + lib/isnanf-nolibm.h -> tests/isnanf-nolibm.h + lib/isnanf.c -> tests/isnanf.c + lib/isnanl-nolibm.h -> tests/isnanl-nolibm.h + lib/isnanl.c -> tests/isnanl.c + lib/itold.c -> tests/itold.c + lib/listen.c -> tests/listen.c + lib/math.c -> tests/math.c + lib/math.in.h -> tests/math.in.h + lib/nan.h -> tests/nan.h + lib/nanosleep.c -> tests/nanosleep.c + lib/netinet_in.in.h -> tests/netinet_in.in.h + lib/offtostr.c -> tests/offtostr.c + lib/perror.c -> tests/perror.c + lib/printf-args.c -> tests/printf-args.c + lib/printf-args.h -> tests/printf-args.h + lib/printf-parse.c -> tests/printf-parse.c + lib/printf-parse.h -> tests/printf-parse.h + lib/priv-set.c -> tests/priv-set.c + lib/priv-set.h -> tests/priv-set.h + lib/pselect.c -> tests/pselect.c + lib/pthread-thread.c -> tests/pthread-thread.c + lib/pthread.in.h -> tests/pthread.in.h + lib/pthread_sigmask.c -> tests/pthread_sigmask.c + lib/putenv.c -> tests/putenv.c + lib/rmdir.c -> tests/rmdir.c + lib/root-uid.h -> tests/root-uid.h + lib/sched.in.h -> tests/sched.in.h + lib/select.c -> tests/select.c + lib/setsockopt.c -> tests/setsockopt.c + lib/signbitd.c -> tests/signbitd.c + lib/signbitf.c -> tests/signbitf.c + lib/signbitl.c -> tests/signbitl.c + lib/signed-nan.h -> tests/signed-nan.h + lib/signed-snan.h -> tests/signed-snan.h + lib/size_max.h -> tests/size_max.h + lib/sleep.c -> tests/sleep.c + lib/snan.h -> tests/snan.h + lib/snprintf.c -> tests/snprintf.c + lib/socket.c -> tests/socket.c + lib/sockets.c -> tests/sockets.c + lib/sockets.h -> tests/sockets.h + lib/str-two-way.h -> tests/str-two-way.h + lib/strerror_r.c -> tests/strerror_r.c + lib/symlink.c -> tests/symlink.c + lib/symlinkat.c -> tests/symlinkat.c + lib/sys_ioctl.in.h -> tests/sys_ioctl.in.h + lib/sys_select.in.h -> tests/sys_select.in.h + lib/sys_socket.c -> tests/sys_socket.c + lib/sys_socket.in.h -> tests/sys_socket.in.h + lib/sys_uio.in.h -> tests/sys_uio.in.h + lib/time.c -> tests/time.c + lib/timespec-add.c -> tests/timespec-add.c + lib/timespec-sub.c -> tests/timespec-sub.c + lib/uinttostr.c -> tests/uinttostr.c + lib/umaxtostr.c -> tests/umaxtostr.c + lib/unistr/u-set.h -> tests/unistr/u-set.h + lib/unistr/u32-set.c -> tests/unistr/u32-set.c + lib/unlink.c -> tests/unlink.c + lib/unlinkat.c -> tests/unlinkat.c + lib/unlinkdir.c -> tests/unlinkdir.c + lib/unlinkdir.h -> tests/unlinkdir.h + lib/vasnprintf.c -> tests/vasnprintf.c + lib/vasnprintf.h -> tests/vasnprintf.h + lib/w32sock.h -> tests/w32sock.h + lib/warn-on-use.h -> tests/warn-on-use.h + lib/wctob.c -> tests/wctob.c + lib/wctomb-impl.h -> tests/wctomb-impl.h + lib/wctomb.c -> tests/wctomb.c + lib/windows-thread.c -> tests/windows-thread.c + lib/windows-thread.h -> tests/windows-thread.h + lib/windows-tls.c -> tests/windows-tls.c + lib/windows-tls.h -> tests/windows-tls.h + lib/xsize.c -> tests/xsize.c + lib/xsize.h -> tests/xsize.h + lib/xstrtol-error.c -> tests/xstrtol-error.c + lib/xstrtol-error.h -> tests/xstrtol-error.h + top/GNUmakefile + top/README-release + top/maint.mk +Copying file gnulib-tests/at-func.c +Copying file gnulib-tests/infinity.h +Copying file gnulib-tests/isnan.c +Copying file gnulib-tests/isnand-nolibm.h +Copying file gnulib-tests/isnand.c +Copying file gnulib-tests/isnanf-nolibm.h +Copying file gnulib-tests/isnanf.c +Copying file gnulib-tests/isnanl-nolibm.h +Copying file gnulib-tests/isnanl.c +Copying file gnulib-tests/math.c +Copying file gnulib-tests/math.in.h +Copying file gnulib-tests/minus-zero.h +Copying file gnulib-tests/priv-set.c +Copying file gnulib-tests/priv-set.h +Copying file gnulib-tests/rmdir.c +Copying file gnulib-tests/root-uid.h +Copying file gnulib-tests/signbitd.c +Copying file gnulib-tests/signbitf.c +Copying file gnulib-tests/signbitl.c +Copying file gnulib-tests/signed-nan.h +Copying file gnulib-tests/signed-snan.h +Copying file gnulib-tests/snan.h +Copying file gnulib-tests/symlinkat.c +Copying file gnulib-tests/test-btowc-1.sh +Copying file gnulib-tests/test-btowc-2.sh +Copying file gnulib-tests/test-btowc-3.sh +Copying file gnulib-tests/test-c32_apply_type_test.c +Copying file gnulib-tests/test-c32_get_type_test.c +Copying file gnulib-tests/test-c32isalnum.c +Copying file gnulib-tests/test-c32isalnum.sh +Copying file gnulib-tests/test-c32isalpha.c +Copying file gnulib-tests/test-c32isalpha.sh +Copying file gnulib-tests/test-c32isblank.c +Copying file gnulib-tests/test-c32isblank.sh +Copying file gnulib-tests/test-c32iscntrl.c +Copying file gnulib-tests/test-c32iscntrl.sh +Copying file gnulib-tests/test-c32isdigit.c +Copying file gnulib-tests/test-c32isdigit.sh +Copying file gnulib-tests/test-c32isgraph.c +Copying file gnulib-tests/test-c32isgraph.sh +Copying file gnulib-tests/test-c32islower.c +Copying file gnulib-tests/test-c32islower.sh +Copying file gnulib-tests/test-c32isprint.c +Copying file gnulib-tests/test-c32isprint.sh +Copying file gnulib-tests/test-c32ispunct.c +Copying file gnulib-tests/test-c32ispunct.sh +Copying file gnulib-tests/test-c32isupper.c +Copying file gnulib-tests/test-c32isupper.sh +Copying file gnulib-tests/test-c32isxdigit.c +Copying file gnulib-tests/test-c32isxdigit.sh +Copying file gnulib-tests/test-c32rtomb-w32-8.sh +Copying file gnulib-tests/test-fnmatch-1.sh +Copying file gnulib-tests/test-fnmatch-2.sh +Copying file gnulib-tests/test-fnmatch-3.sh +Copying file gnulib-tests/test-fnmatch-4.sh +Copying file gnulib-tests/test-fnmatch-5.sh +Copying file gnulib-tests/test-fnmatch-w32-2.sh +Copying file gnulib-tests/test-fnmatch-w32-3.sh +Copying file gnulib-tests/test-fnmatch-w32-4.sh +Copying file gnulib-tests/test-fnmatch-w32-5.sh +Copying file gnulib-tests/test-fnmatch-w32-6.sh +Copying file gnulib-tests/test-fnmatch-w32-7.sh +Copying file gnulib-tests/test-fnmatch-w32-8.sh +Copying file gnulib-tests/test-fnmatch-w32.c +Copying file gnulib-tests/test-fstatat.c +Copying file gnulib-tests/test-isnand-nolibm.c +Copying file gnulib-tests/test-isnand.h +Copying file gnulib-tests/test-isnanf-nolibm.c +Copying file gnulib-tests/test-isnanf.h +Copying file gnulib-tests/test-isnanl-nolibm.c +Copying file gnulib-tests/test-isnanl.h +Copying file gnulib-tests/test-iswctype.c +Copying file gnulib-tests/test-iswpunct.c +Copying file gnulib-tests/test-iswpunct.sh +Copying file gnulib-tests/test-math.c +Copying file gnulib-tests/test-mbrtoc32-w32-8.sh +Copying file gnulib-tests/test-mbrtowc-1.sh +Copying file gnulib-tests/test-mbrtowc-2.sh +Copying file gnulib-tests/test-mbrtowc-3.sh +Copying file gnulib-tests/test-mbrtowc-4.sh +Copying file gnulib-tests/test-mbrtowc-5.sh +Copying file gnulib-tests/test-mbrtowc-w32-8.sh +Copying file gnulib-tests/test-mbsrtoc32s-1.sh +Copying file gnulib-tests/test-mbsrtoc32s-2.sh +Copying file gnulib-tests/test-mbsrtoc32s-3.sh +Copying file gnulib-tests/test-mbsrtoc32s-4.sh +Copying file gnulib-tests/test-mbsrtoc32s-5.sh +Copying file gnulib-tests/test-mbsrtoc32s.c +Copying file gnulib-tests/test-mbsrtowcs-1.sh +Copying file gnulib-tests/test-mbsrtowcs-2.sh +Copying file gnulib-tests/test-mbsrtowcs-3.sh +Copying file gnulib-tests/test-mbsrtowcs-4.sh +Copying file gnulib-tests/test-mbsrtowcs-5.sh +Copying file gnulib-tests/test-popen.c +Copying file gnulib-tests/test-popen.h +Copying file gnulib-tests/test-priv-set.c +Copying file gnulib-tests/test-readlinkat.c +Copying file gnulib-tests/test-rmdir.c +Copying file gnulib-tests/test-rmdir.h +Copying file gnulib-tests/test-sigaction.c +Copying file gnulib-tests/test-signbit.c +Copying file gnulib-tests/test-symlinkat.c +Copying file gnulib-tests/test-unlink.c +Copying file gnulib-tests/test-unlink.h +Copying file gnulib-tests/test-unlinkat.c +Copying file gnulib-tests/test-wcrtomb-w32-8.sh +Copying file gnulib-tests/test-wctype.c +Copying file gnulib-tests/unictype/test-ctype_alnum.c +Copying file gnulib-tests/unictype/test-ctype_alpha.c +Copying file gnulib-tests/unictype/test-ctype_blank.c +Copying file gnulib-tests/unictype/test-ctype_cntrl.c +Copying file gnulib-tests/unictype/test-ctype_digit.c +Copying file gnulib-tests/unictype/test-ctype_graph.c +Copying file gnulib-tests/unictype/test-ctype_lower.c +Copying file gnulib-tests/unictype/test-ctype_print.c +Copying file gnulib-tests/unictype/test-ctype_punct.c +Copying file gnulib-tests/unictype/test-ctype_upper.c +Copying file gnulib-tests/unictype/test-ctype_xdigit.c +Copying file gnulib-tests/unistr/test-chr.h +Copying file gnulib-tests/unistr/test-cpy.h +Copying file gnulib-tests/unistr/test-pcpy.h +Copying file gnulib-tests/unistr/test-set.h +Copying file gnulib-tests/unistr/test-strcat.h +Copying file gnulib-tests/unistr/test-u32-chr.c +Copying file gnulib-tests/unistr/test-u32-cpy.c +Copying file gnulib-tests/unistr/test-u32-pcpy.c +Copying file gnulib-tests/unistr/test-u32-set.c +Copying file gnulib-tests/unistr/test-u32-strcat.c +Copying file gnulib-tests/unistr/test-u32-strlen.c +Copying file gnulib-tests/unistr/u-set.h +Copying file gnulib-tests/unistr/u32-set.c +Copying file gnulib-tests/unlink.c +Copying file gnulib-tests/unlinkat.c +Copying file gnulib-tests/unlinkdir.c +Copying file gnulib-tests/unlinkdir.h +Copying file lib/at-func.c +Copying file lib/btoc32.c +Copying file lib/c-file-type.c +Copying file lib/c32_apply_type_test.c +Copying file lib/c32_get_type_test.c +Copying file lib/c32isalnum.c +Copying file lib/c32isalpha.c +Copying file lib/c32isblank.c +Copying file lib/c32iscntrl.c +Copying file lib/c32isdigit.c +Copying file lib/c32isgraph.c +Copying file lib/c32islower.c +Copying file lib/c32isprint.c +Copying file lib/c32ispunct.c +Copying file lib/c32isupper.c +Copying file lib/c32isxdigit.c +Copying file lib/fstatat.c +Copying file lib/iswctype-impl.h +Copying file lib/iswctype.c +Copying file lib/iswpunct.c +Copying file lib/mbsrtoc32s-state.c +Copying file lib/mbsrtoc32s.c +Copying file lib/mbszero.c +Copying file lib/mbuiterf.c +Copying file lib/mbuiterf.h +Copying file lib/pclose.c +Copying file lib/popen.c +Copying file lib/readdir.c +Copying file lib/readlinkat.c +Copying file lib/same-inode.c +Copying file lib/sig-handler.c +Copying file lib/sig-handler.h +Copying file lib/sigaction.c +Copying file lib/unictype/ctype_alnum.c +Copying file lib/unictype/ctype_alnum.h +Copying file lib/unictype/ctype_alpha.c +Copying file lib/unictype/ctype_alpha.h +Copying file lib/unictype/ctype_blank.c +Copying file lib/unictype/ctype_blank.h +Copying file lib/unictype/ctype_cntrl.c +Copying file lib/unictype/ctype_cntrl.h +Copying file lib/unictype/ctype_digit.c +Copying file lib/unictype/ctype_digit.h +Copying file lib/unictype/ctype_graph.c +Copying file lib/unictype/ctype_graph.h +Copying file lib/unictype/ctype_lower.c +Copying file lib/unictype/ctype_lower.h +Copying file lib/unictype/ctype_print.c +Copying file lib/unictype/ctype_print.h +Copying file lib/unictype/ctype_punct.c +Copying file lib/unictype/ctype_punct.h +Copying file lib/unictype/ctype_upper.c +Copying file lib/unictype/ctype_upper.h +Copying file lib/unictype/ctype_xdigit.c +Copying file lib/unictype/ctype_xdigit.h +Copying file lib/unistr.in.h +Copying file lib/unistr/u-cpy.h +Copying file lib/unistr/u-pcpy.h +Copying file lib/unistr/u-strcat.h +Copying file lib/unistr/u-strlen.h +Copying file lib/unistr/u32-chr.c +Copying file lib/unistr/u32-cpy.c +Copying file lib/unistr/u32-pcpy.c +Copying file lib/unistr/u32-strcat.c +Copying file lib/unistr/u32-strlen.c +Copying file lib/wctype-impl.h +Copying file lib/wctype.c +Copying file m4/exponentf.m4 +Copying file m4/exponentl.m4 +Copying file m4/fstatat.m4 +Copying file m4/gnulib-tool.m4 +Copying file m4/inline.m4 +Copying file m4/isnand.m4 +Copying file m4/isnanf.m4 +Copying file m4/isnanl.m4 +Copying file m4/iswctype.m4 +Copying file m4/iswpunct.m4 +Copying file m4/nan-mips.m4 +Copying file m4/pclose.m4 +Copying file m4/popen.m4 +Copying file m4/priv-set.m4 +Copying file m4/readdir.m4 +Copying file m4/readlinkat.m4 +Copying file m4/rmdir.m4 +Copying file m4/sigaction.m4 +Copying file m4/signbit.m4 +Copying file m4/snan.m4 +Copying file m4/symlinkat.m4 +Copying file m4/unlink.m4 +Copying file m4/unlinkat.m4 +Copying file m4/unlinkdir.m4 +Copying file m4/wctype.m4 +Copying file GNUmakefile +Copying file README-release +Copying file build-aux/announce-gen +Copying file build-aux/config.rpath +Copying file build-aux/do-release-commit-and-tag +Copying file build-aux/gendocs.sh +Copying file build-aux/git-version-gen +Copying file build-aux/gitlog-to-changelog +Copying file build-aux/gnu-web-doc-update +Copying file build-aux/gnupload +Copying file build-aux/update-copyright +Copying file build-aux/useless-if-before-free +Copying file build-aux/vc-list-files +Copying file doc/gendocs_template +Copying file doc/gendocs_template_min +Copying file gnulib-tests/_Noreturn.h +Copying file gnulib-tests/accept.c +Copying file gnulib-tests/alloca.c +Copying file gnulib-tests/altstack-util.h +Copying file gnulib-tests/anytostr.c +Copying file gnulib-tests/arg-nonnull.h +Copying file gnulib-tests/arpa_inet.in.h +Copying file gnulib-tests/asnprintf.c +Copying file gnulib-tests/atoll.c +Copying file gnulib-tests/bind.c +Copying file gnulib-tests/c++defs.h +Copying file gnulib-tests/c-strcasestr.c +Copying file gnulib-tests/c-strcasestr.h +Copying file gnulib-tests/c32rtomb.c +Copying file gnulib-tests/c32tob.c +Copying file gnulib-tests/connect.c +Copying file gnulib-tests/dtotimespec.c +Copying file gnulib-tests/fdopen.c +Copying file gnulib-tests/float+.h +Copying file gnulib-tests/float.c +Copying file gnulib-tests/float.in.h +Copying file gnulib-tests/fpucw.h +Copying file gnulib-tests/ftruncate.c +Copying file gnulib-tests/glthread/thread.c +Copying file gnulib-tests/glthread/thread.h +Copying file gnulib-tests/hash-pjw.c +Copying file gnulib-tests/hash-pjw.h +Copying file gnulib-tests/imaxtostr.c +Copying file gnulib-tests/inet_pton.c +Copying file gnulib-tests/init.sh +Copying file gnulib-tests/inttostr.c +Copying file gnulib-tests/inttostr.h +Copying file gnulib-tests/ioctl.c +Copying file gnulib-tests/itold.c +Copying file gnulib-tests/listen.c +Copying file gnulib-tests/locale.c +Copying file gnulib-tests/macros.h +Copying file gnulib-tests/mmap-anon-util.h +Updating file gnulib-tests/nan.h (backup in gnulib-tests/nan.h~) +Copying file gnulib-tests/nanosleep.c +Copying file gnulib-tests/nap.h +Copying file gnulib-tests/netinet_in.in.h +Copying file gnulib-tests/offtostr.c +Copying file gnulib-tests/perror.c +Copying file gnulib-tests/printf-args.c +Copying file gnulib-tests/printf-args.h +Copying file gnulib-tests/printf-parse.c +Copying file gnulib-tests/printf-parse.h +Copying file gnulib-tests/pselect.c +Copying file gnulib-tests/pthread-thread.c +Copying file gnulib-tests/pthread.in.h +Copying file gnulib-tests/pthread_sigmask.c +Copying file gnulib-tests/putenv.c +Copying file gnulib-tests/sched.in.h +Copying file gnulib-tests/select.c +Copying file gnulib-tests/setsockopt.c +Copying file gnulib-tests/signature.h +Copying file gnulib-tests/size_max.h +Copying file gnulib-tests/sleep.c +Copying file gnulib-tests/snprintf.c +Copying file gnulib-tests/socket.c +Copying file gnulib-tests/sockets.c +Copying file gnulib-tests/sockets.h +Copying file gnulib-tests/str-two-way.h +Copying file gnulib-tests/strerror_r.c +Copying file gnulib-tests/symlink.c +Copying file gnulib-tests/sys_ioctl.in.h +Copying file gnulib-tests/sys_select.in.h +Copying file gnulib-tests/sys_socket.c +Copying file gnulib-tests/sys_socket.in.h +Copying file gnulib-tests/sys_uio.in.h +Copying file gnulib-tests/test-accept.c +Copying file gnulib-tests/test-alignasof.c +Copying file gnulib-tests/test-alloca-opt.c +Copying file gnulib-tests/test-argmatch.c +Copying file gnulib-tests/test-arpa_inet.c +Copying file gnulib-tests/test-assert.c +Copying file gnulib-tests/test-binary-io.c +Copying file gnulib-tests/test-binary-io.sh +Copying file gnulib-tests/test-bind.c +Copying file gnulib-tests/test-bitrotate.c +Copying file gnulib-tests/test-btoc32-1.sh +Copying file gnulib-tests/test-btoc32-2.sh +Copying file gnulib-tests/test-btoc32-3.sh +Copying file gnulib-tests/test-btoc32.c +Copying file gnulib-tests/test-btowc.c +Copying file gnulib-tests/test-c-ctype.c +Copying file gnulib-tests/test-c-stack.c +Copying file gnulib-tests/test-c-stack.sh +Copying file gnulib-tests/test-c-stack2.sh +Copying file gnulib-tests/test-c-strcase.sh +Copying file gnulib-tests/test-c-strcasecmp.c +Copying file gnulib-tests/test-c-strcasestr.c +Copying file gnulib-tests/test-c-strncasecmp.c +Copying file gnulib-tests/test-c32isspace.c +Copying file gnulib-tests/test-c32isspace.sh +Copying file gnulib-tests/test-c32rtomb-w32-2.sh +Copying file gnulib-tests/test-c32rtomb-w32-3.sh +Copying file gnulib-tests/test-c32rtomb-w32-4.sh +Copying file gnulib-tests/test-c32rtomb-w32-5.sh +Copying file gnulib-tests/test-c32rtomb-w32-6.sh +Copying file gnulib-tests/test-c32rtomb-w32-7.sh +Copying file gnulib-tests/test-c32rtomb-w32.c +Copying file gnulib-tests/test-c32rtomb.c +Copying file gnulib-tests/test-c32rtomb.sh +Copying file gnulib-tests/test-c32tolower.c +Copying file gnulib-tests/test-c32tolower.sh +Copying file gnulib-tests/test-c32width.c +Copying file gnulib-tests/test-calloc-gnu.c +Copying file gnulib-tests/test-chdir.c +Copying file gnulib-tests/test-cloexec.c +Copying file gnulib-tests/test-close.c +Copying file gnulib-tests/test-connect.c +Copying file gnulib-tests/test-count-leading-zeros.c +Copying file gnulib-tests/test-ctype.c +Copying file gnulib-tests/test-dirent.c +Copying file gnulib-tests/test-dirfd.c +Copying file gnulib-tests/test-dirname.c +Copying file gnulib-tests/test-dup-safer.c +Copying file gnulib-tests/test-dup.c +Copying file gnulib-tests/test-dup2.c +Copying file gnulib-tests/test-dynarray.c +Copying file gnulib-tests/test-environ.c +Copying file gnulib-tests/test-errno.c +Copying file gnulib-tests/test-error.c +Copying file gnulib-tests/test-error.sh +Copying file gnulib-tests/test-exclude.c +Copying file gnulib-tests/test-exclude1.sh +Copying file gnulib-tests/test-exclude2.sh +Copying file gnulib-tests/test-exclude3.sh +Copying file gnulib-tests/test-exclude4.sh +Copying file gnulib-tests/test-exclude5.sh +Copying file gnulib-tests/test-exclude6.sh +Copying file gnulib-tests/test-exclude7.sh +Copying file gnulib-tests/test-exclude8.sh +Copying file gnulib-tests/test-fchdir.c +Copying file gnulib-tests/test-fcntl-h.c +Copying file gnulib-tests/test-fcntl.c +Copying file gnulib-tests/test-fdopen.c +Copying file gnulib-tests/test-fdopendir.c +Copying file gnulib-tests/test-fgetc.c +Copying file gnulib-tests/test-filenamecat.c +Copying file gnulib-tests/test-float.c +Copying file gnulib-tests/test-fnmatch-h.c +Copying file gnulib-tests/test-fnmatch.c +Copying file gnulib-tests/test-fopen-gnu.c +Copying file gnulib-tests/test-fopen.c +Copying file gnulib-tests/test-fopen.h +Copying file gnulib-tests/test-fputc.c +Copying file gnulib-tests/test-fread.c +Copying file gnulib-tests/test-free.c +Copying file gnulib-tests/test-freopen.c +Copying file gnulib-tests/test-fstat.c +Copying file gnulib-tests/test-ftruncate.c +Copying file gnulib-tests/test-ftruncate.sh +Copying file gnulib-tests/test-fwrite.c +Copying file gnulib-tests/test-getcwd-lgpl.c +Copying file gnulib-tests/test-getdtablesize.c +Copying file gnulib-tests/test-getopt-gnu.c +Copying file gnulib-tests/test-getopt-main.h +Copying file gnulib-tests/test-getopt-posix.c +Copying file gnulib-tests/test-getopt.h +Copying file gnulib-tests/test-getopt_long.h +Copying file gnulib-tests/test-getprogname.c +Copying file gnulib-tests/test-getrandom.c +Copying file gnulib-tests/test-gettimeofday.c +Copying file gnulib-tests/test-hard-locale.c +Copying file gnulib-tests/test-hash.c +Copying file gnulib-tests/test-ignore-value.c +Copying file gnulib-tests/test-inet_pton.c +Copying file gnulib-tests/test-init.sh +Copying file gnulib-tests/test-intprops.c +Copying file gnulib-tests/test-inttostr.c +Copying file gnulib-tests/test-inttypes.c +Copying file gnulib-tests/test-ioctl.c +Copying file gnulib-tests/test-isblank.c +Copying file gnulib-tests/test-iswblank.c +Copying file gnulib-tests/test-iswdigit.c +Copying file gnulib-tests/test-iswdigit.sh +Copying file gnulib-tests/test-iswxdigit.c +Copying file gnulib-tests/test-iswxdigit.sh +Copying file gnulib-tests/test-langinfo.c +Copying file gnulib-tests/test-largefile.c +Copying file gnulib-tests/test-limits-h.c +Copying file gnulib-tests/test-listen.c +Copying file gnulib-tests/test-localcharset.c +Copying file gnulib-tests/test-locale.c +Copying file gnulib-tests/test-localeconv.c +Copying file gnulib-tests/test-lstat.c +Copying file gnulib-tests/test-lstat.h +Copying file gnulib-tests/test-malloc-gnu.c +Copying file gnulib-tests/test-malloca.c +Copying file gnulib-tests/test-mbrtoc32-1.sh +Copying file gnulib-tests/test-mbrtoc32-2.sh +Copying file gnulib-tests/test-mbrtoc32-3.sh +Copying file gnulib-tests/test-mbrtoc32-4.sh +Copying file gnulib-tests/test-mbrtoc32-5.sh +Copying file gnulib-tests/test-mbrtoc32-w32-2.sh +Copying file gnulib-tests/test-mbrtoc32-w32-3.sh +Copying file gnulib-tests/test-mbrtoc32-w32-4.sh +Copying file gnulib-tests/test-mbrtoc32-w32-5.sh +Copying file gnulib-tests/test-mbrtoc32-w32-6.sh +Copying file gnulib-tests/test-mbrtoc32-w32-7.sh +Copying file gnulib-tests/test-mbrtoc32-w32.c +Copying file gnulib-tests/test-mbrtoc32.c +Copying file gnulib-tests/test-mbrtowc-w32-2.sh +Copying file gnulib-tests/test-mbrtowc-w32-3.sh +Copying file gnulib-tests/test-mbrtowc-w32-4.sh +Copying file gnulib-tests/test-mbrtowc-w32-5.sh +Copying file gnulib-tests/test-mbrtowc-w32-6.sh +Copying file gnulib-tests/test-mbrtowc-w32-7.sh +Copying file gnulib-tests/test-mbrtowc-w32.c +Copying file gnulib-tests/test-mbrtowc.c +Copying file gnulib-tests/test-mbscasecmp.c +Copying file gnulib-tests/test-mbscasecmp.sh +Copying file gnulib-tests/test-mbsinit.c +Copying file gnulib-tests/test-mbsinit.sh +Copying file gnulib-tests/test-mbsrtowcs.c +Copying file gnulib-tests/test-memchr.c +Copying file gnulib-tests/test-memrchr.c +Copying file gnulib-tests/test-mkdir.c +Copying file gnulib-tests/test-mkdir.h +Copying file gnulib-tests/test-nanosleep.c +Copying file gnulib-tests/test-netinet_in.c +Copying file gnulib-tests/test-nl_langinfo-mt.c +Copying file gnulib-tests/test-nl_langinfo1.c +Copying file gnulib-tests/test-nl_langinfo1.sh +Copying file gnulib-tests/test-nl_langinfo2.c +Copying file gnulib-tests/test-nl_langinfo2.sh +Copying file gnulib-tests/test-nstrftime.c +Copying file gnulib-tests/test-nullptr.c +Copying file gnulib-tests/test-open.c +Copying file gnulib-tests/test-open.h +Copying file gnulib-tests/test-openat.c +Copying file gnulib-tests/test-pathmax.c +Copying file gnulib-tests/test-perror.c +Copying file gnulib-tests/test-perror.sh +Copying file gnulib-tests/test-perror2.c +Copying file gnulib-tests/test-pipe.c +Copying file gnulib-tests/test-pselect.c +Copying file gnulib-tests/test-pthread-thread.c +Copying file gnulib-tests/test-pthread.c +Copying file gnulib-tests/test-pthread_sigmask1.c +Copying file gnulib-tests/test-pthread_sigmask2.c +Copying file gnulib-tests/test-quotearg-simple.c +Copying file gnulib-tests/test-quotearg.h +Updating file gnulib-tests/test-raise.c (backup in gnulib-tests/test-raise.c~) +Copying file gnulib-tests/test-rawmemchr.c +Copying file gnulib-tests/test-readlink.c +Copying file gnulib-tests/test-readlink.h +Copying file gnulib-tests/test-realloc-gnu.c +Copying file gnulib-tests/test-reallocarray.c +Copying file gnulib-tests/test-regex.c +Copying file gnulib-tests/test-sched.c +Copying file gnulib-tests/test-select-fd.c +Copying file gnulib-tests/test-select-in.sh +Copying file gnulib-tests/test-select-out.sh +Copying file gnulib-tests/test-select-stdin.c +Copying file gnulib-tests/test-select.c +Copying file gnulib-tests/test-select.h +Copying file gnulib-tests/test-setenv.c +Copying file gnulib-tests/test-setlocale_null-mt-all.c +Copying file gnulib-tests/test-setlocale_null-mt-one.c +Copying file gnulib-tests/test-setlocale_null.c +Copying file gnulib-tests/test-setsockopt.c +Copying file gnulib-tests/test-sh-quote.c +Copying file gnulib-tests/test-signal-h.c +Copying file gnulib-tests/test-sigprocmask.c +Copying file gnulib-tests/test-sigsegv-catch-segv1.c +Copying file gnulib-tests/test-sigsegv-catch-segv2.c +Copying file gnulib-tests/test-sigsegv-catch-stackoverflow1.c +Copying file gnulib-tests/test-sigsegv-catch-stackoverflow2.c +Copying file gnulib-tests/test-sleep.c +Copying file gnulib-tests/test-snprintf.c +Copying file gnulib-tests/test-sockets.c +Copying file gnulib-tests/test-stat-time.c +Copying file gnulib-tests/test-stat.c +Copying file gnulib-tests/test-stat.h +Copying file gnulib-tests/test-stdbool.c +Copying file gnulib-tests/test-stdckdint.c +Copying file gnulib-tests/test-stddef.c +Copying file gnulib-tests/test-stdint.c +Copying file gnulib-tests/test-stdio.c +Copying file gnulib-tests/test-stdlib.c +Copying file gnulib-tests/test-strerror.c +Copying file gnulib-tests/test-strerror_r.c +Copying file gnulib-tests/test-string.c +Copying file gnulib-tests/test-strings.c +Copying file gnulib-tests/test-strnlen.c +Copying file gnulib-tests/test-strtoimax.c +Copying file gnulib-tests/test-strtoll.c +Copying file gnulib-tests/test-symlink.c +Copying file gnulib-tests/test-symlink.h +Copying file gnulib-tests/test-sys_ioctl.c +Copying file gnulib-tests/test-sys_random.c +Copying file gnulib-tests/test-sys_select.c +Copying file gnulib-tests/test-sys_socket.c +Copying file gnulib-tests/test-sys_stat.c +Copying file gnulib-tests/test-sys_time.c +Copying file gnulib-tests/test-sys_types.c +Copying file gnulib-tests/test-sys_uio.c +Copying file gnulib-tests/test-sys_wait.c +Copying file gnulib-tests/test-sys_wait.h +Copying file gnulib-tests/test-thread_create.c +Copying file gnulib-tests/test-thread_self.c +Copying file gnulib-tests/test-time-h.c +Copying file gnulib-tests/test-time.c +Copying file gnulib-tests/test-timespec.c +Copying file gnulib-tests/test-timespec_get.c +Copying file gnulib-tests/test-uchar.c +Copying file gnulib-tests/test-unistd.c +Copying file gnulib-tests/test-unsetenv.c +Copying file gnulib-tests/test-update-copyright.sh +Copying file gnulib-tests/test-vasnprintf.c +Copying file gnulib-tests/test-vc-list-files-cvs.sh +Copying file gnulib-tests/test-vc-list-files-git.sh +Copying file gnulib-tests/test-verify-try.c +Copying file gnulib-tests/test-verify.c +Copying file gnulib-tests/test-verify.sh +Copying file gnulib-tests/test-version-etc.c +Copying file gnulib-tests/test-version-etc.sh +Copying file gnulib-tests/test-wchar.c +Copying file gnulib-tests/test-wcrtomb-w32-2.sh +Copying file gnulib-tests/test-wcrtomb-w32-3.sh +Copying file gnulib-tests/test-wcrtomb-w32-4.sh +Copying file gnulib-tests/test-wcrtomb-w32-5.sh +Copying file gnulib-tests/test-wcrtomb-w32-6.sh +Copying file gnulib-tests/test-wcrtomb-w32-7.sh +Copying file gnulib-tests/test-wcrtomb-w32.c +Copying file gnulib-tests/test-wcrtomb.c +Copying file gnulib-tests/test-wcrtomb.sh +Copying file gnulib-tests/test-wctype-h.c +Copying file gnulib-tests/test-wcwidth.c +Copying file gnulib-tests/test-xalloc-die.c +Copying file gnulib-tests/test-xalloc-die.sh +Copying file gnulib-tests/test-xstdopen.c +Copying file gnulib-tests/test-xstdopen.sh +Copying file gnulib-tests/test-xstrtoimax.c +Copying file gnulib-tests/test-xstrtoimax.sh +Copying file gnulib-tests/test-xstrtol.c +Copying file gnulib-tests/test-xstrtol.sh +Copying file gnulib-tests/test-xstrtoul.c +Copying file gnulib-tests/test-year2038.c +Copying file gnulib-tests/time.c +Copying file gnulib-tests/timespec-add.c +Copying file gnulib-tests/timespec-sub.c +Copying file gnulib-tests/uinttostr.c +Copying file gnulib-tests/umaxtostr.c +Copying file gnulib-tests/unicase/test-mapping-part1.h +Copying file gnulib-tests/unicase/test-mapping-part2.h +Copying file gnulib-tests/unicase/test-uc_tolower.c +Copying file gnulib-tests/unictype/test-ctype_space.c +Copying file gnulib-tests/unictype/test-predicate-part1.h +Copying file gnulib-tests/unictype/test-predicate-part2.h +Copying file gnulib-tests/uniwidth/test-uc_width.c +Copying file gnulib-tests/uniwidth/test-uc_width2.c +Copying file gnulib-tests/uniwidth/test-uc_width2.sh +Copying file gnulib-tests/vasnprintf.c +Copying file gnulib-tests/vasnprintf.h +Copying file gnulib-tests/w32sock.h +Copying file gnulib-tests/warn-on-use.h +Copying file gnulib-tests/wctob.c +Copying file gnulib-tests/wctomb-impl.h +Copying file gnulib-tests/wctomb.c +Copying file gnulib-tests/windows-thread.c +Copying file gnulib-tests/windows-thread.h +Copying file gnulib-tests/windows-tls.c +Copying file gnulib-tests/windows-tls.h +Copying file gnulib-tests/xsize.c +Copying file gnulib-tests/xsize.h +Copying file gnulib-tests/xstrtol-error.c +Copying file gnulib-tests/xstrtol-error.h +Copying file gnulib-tests/zerosize-ptr.h +Copying file lib/_Noreturn.h +Copying file lib/alloca.in.h +Copying file lib/allocator.c +Copying file lib/allocator.h +Copying file lib/arg-nonnull.h +Copying file lib/argmatch.c +Copying file lib/argmatch.h +Copying file lib/assert.in.h +Copying file lib/assure.h +Copying file lib/attribute.h +Copying file lib/basename-lgpl.c +Copying file lib/basename-lgpl.h +Copying file lib/basename.c +Copying file lib/binary-io.c +Copying file lib/binary-io.h +Copying file lib/bitrotate.c +Copying file lib/bitrotate.h +Copying file lib/btowc.c +Copying file lib/c++defs.h +Copying file lib/c-ctype.c +Copying file lib/c-ctype.h +Copying file lib/c-stack.c +Copying file lib/c-stack.h +Copying file lib/c-strcase.h +Copying file lib/c-strcasecmp.c +Copying file lib/c-strcaseeq.h +Copying file lib/c-strncasecmp.c +Copying file lib/c32is-impl.h +Copying file lib/c32isspace.c +Copying file lib/c32to-impl.h +Copying file lib/c32tolower.c +Copying file lib/c32width.c +Copying file lib/calloc.c +Copying file lib/careadlinkat.c +Copying file lib/careadlinkat.h +Copying file lib/cdefs.h +Copying file lib/chdir-long.c +Copying file lib/chdir-long.h +Copying file lib/cloexec.c +Copying file lib/cloexec.h +Copying file lib/close.c +Copying file lib/closedir.c +Copying file lib/count-leading-zeros.c +Copying file lib/count-leading-zeros.h +Copying file lib/ctype.in.h +Copying file lib/diffseq.h +Copying file lib/dirent-private.h +Copying file lib/dirent.in.h +Copying file lib/dirfd.c +Copying file lib/dirname-lgpl.c +Copying file lib/dirname.c +Copying file lib/dirname.h +Copying file lib/dup-safer-flag.c +Copying file lib/dup-safer.c +Copying file lib/dup.c +Copying file lib/dup2.c +Copying file lib/dynarray.h +Copying file lib/errno.in.h +Copying file lib/error.c +Copying file lib/error.in.h +Copying file lib/exclude.c +Copying file lib/exclude.h +Copying file lib/exitfail.c +Copying file lib/exitfail.h +Copying file lib/fchdir.c +Copying file lib/fcntl.c +Copying file lib/fcntl.in.h +Copying file lib/fd-hook.c +Copying file lib/fd-hook.h +Copying file lib/fd-safer-flag.c +Copying file lib/fd-safer.c +Copying file lib/fdopendir.c +Copying file lib/file-type.c +Copying file lib/file-type.h +Copying file lib/filename.h +Copying file lib/filenamecat-lgpl.c +Copying file lib/filenamecat.c +Copying file lib/filenamecat.h +Copying file lib/flexmember.h +Copying file lib/fnmatch.c +Copying file lib/fnmatch.in.h +Copying file lib/fnmatch_loop.c +Copying file lib/fopen.c +Copying file lib/free.c +Copying file lib/freopen.c +Copying file lib/fstat.c +Copying file lib/getcwd-lgpl.c +Copying file lib/getdtablesize.c +Copying file lib/getopt-cdefs.in.h +Copying file lib/getopt-core.h +Copying file lib/getopt-ext.h +Copying file lib/getopt-pfx-core.h +Copying file lib/getopt-pfx-ext.h +Copying file lib/getopt.c +Copying file lib/getopt.in.h +Copying file lib/getopt1.c +Copying file lib/getopt_int.h +Copying file lib/getpagesize.c +Copying file lib/getprogname.c +Copying file lib/getprogname.h +Copying file lib/getrandom.c +Copying file lib/gettext.h +Copying file lib/gettime.c +Copying file lib/gettimeofday.c +Copying file lib/glthread/lock.c +Copying file lib/glthread/lock.h +Copying file lib/glthread/threadlib.c +Copying file lib/hard-locale.c +Copying file lib/hard-locale.h +Copying file lib/hash.c +Copying file lib/hash.h +Copying file lib/ialloc.c +Copying file lib/ialloc.h +Copying file lib/idx.h +Copying file lib/ignore-value.h +Copying file lib/intprops-internal.h +Copying file lib/intprops.h +Copying file lib/inttypes.in.h +Copying file lib/isblank.c +Copying file lib/iswblank.c +Copying file lib/iswdigit.c +Copying file lib/iswxdigit.c +Copying file lib/langinfo.in.h +Copying file lib/lc-charset-dispatch.c +Copying file lib/lc-charset-dispatch.h +Copying file lib/libc-config.h +Copying file lib/limits.in.h +Copying file lib/localcharset.c +Copying file lib/localcharset.h +Copying file lib/locale.in.h +Copying file lib/localeconv.c +Copying file lib/lstat.c +Copying file lib/malloc.c +Copying file lib/malloc/dynarray-skeleton.c +Copying file lib/malloc/dynarray.h +Copying file lib/malloc/dynarray_at_failure.c +Copying file lib/malloc/dynarray_emplace_enlarge.c +Copying file lib/malloc/dynarray_finalize.c +Copying file lib/malloc/dynarray_resize.c +Copying file lib/malloc/dynarray_resize_clear.c +Copying file lib/malloca.c +Copying file lib/malloca.h +Copying file lib/mbchar.c +Copying file lib/mbchar.h +Copying file lib/mbrtoc32.c +Copying file lib/mbrtowc-impl-utf8.h +Copying file lib/mbrtowc-impl.h +Copying file lib/mbrtowc.c +Copying file lib/mbscasecmp.c +Copying file lib/mbsinit.c +Copying file lib/mbsrtowcs-impl.h +Copying file lib/mbsrtowcs-state.c +Copying file lib/mbsrtowcs.c +Copying file lib/mbtowc-impl.h +Copying file lib/mbtowc-lock.c +Copying file lib/mbtowc-lock.h +Copying file lib/mbtowc.c +Copying file lib/mbuiter.c +Copying file lib/mbuiter.h +Copying file lib/memchr.c +Copying file lib/memchr.valgrind +Copying file lib/mempcpy.c +Copying file lib/memrchr.c +Copying file lib/minmax.h +Copying file lib/mkdir.c +Copying file lib/mkstemp.c +Copying file lib/mktime-internal.h +Copying file lib/mktime.c +Copying file lib/msvc-inval.c +Copying file lib/msvc-inval.h +Copying file lib/msvc-nothrow.c +Copying file lib/msvc-nothrow.h +Copying file lib/nl_langinfo-lock.c +Copying file lib/nl_langinfo.c +Copying file lib/nstrftime.c +Copying file lib/open.c +Copying file lib/openat-die.c +Copying file lib/openat-priv.h +Copying file lib/openat-proc.c +Copying file lib/openat.c +Copying file lib/openat.h +Copying file lib/opendir.c +Copying file lib/pathmax.h +Copying file lib/pipe-safer.c +Copying file lib/pipe.c +Copying file lib/progname.c +Copying file lib/progname.h +Copying file lib/propername-lite.c +Copying file lib/propername.h +Copying file lib/quote.h +Copying file lib/quotearg.c +Copying file lib/quotearg.h +Copying file lib/raise.c +Copying file lib/rawmemchr.c +Copying file lib/rawmemchr.valgrind +Copying file lib/readlink.c +Copying file lib/realloc.c +Copying file lib/reallocarray.c +Copying file lib/regcomp.c +Copying file lib/regex.c +Copying file lib/regex.h +Copying file lib/regex_internal.c +Copying file lib/regex_internal.h +Copying file lib/regexec.c +Copying file lib/same-inode.h +Copying file lib/save-cwd.c +Copying file lib/save-cwd.h +Copying file lib/setenv.c +Copying file lib/setlocale-lock.c +Copying file lib/setlocale_null.c +Copying file lib/setlocale_null.h +Copying file lib/sh-quote.c +Copying file lib/sh-quote.h +Copying file lib/signal.in.h +Copying file lib/sigprocmask.c +Copying file lib/sigsegv.c +Copying file lib/sigsegv.in.h +Copying file lib/stackvma.c +Copying file lib/stackvma.h +Copying file lib/stat-macros.h +Copying file lib/stat-time.c +Copying file lib/stat-time.h +Copying file lib/stat-w32.c +Copying file lib/stat-w32.h +Copying file lib/stat.c +Copying file lib/stdarg.in.h +Copying file lib/stdckdint.in.h +Copying file lib/stddef.in.h +Copying file lib/stdint.in.h +Copying file lib/stdio-read.c +Copying file lib/stdio-write.c +Copying file lib/stdio.in.h +Copying file lib/stdlib.in.h +Copying file lib/stdopen.c +Copying file lib/stdopen.h +Copying file lib/stpcpy.c +Copying file lib/strcasecmp.c +Copying file lib/strdup.c +Copying file lib/streq.h +Copying file lib/strerror-override.c +Copying file lib/strerror-override.h +Copying file lib/strerror.c +Copying file lib/strftime.h +Copying file lib/string.in.h +Copying file lib/strings.in.h +Copying file lib/stripslash.c +Copying file lib/strncasecmp.c +Copying file lib/strnlen.c +Copying file lib/strnlen1.c +Copying file lib/strnlen1.h +Copying file lib/strptime.c +Copying file lib/strtoimax.c +Copying file lib/strtol.c +Copying file lib/strtoll.c +Copying file lib/sys_random.in.h +Copying file lib/sys_stat.in.h +Copying file lib/sys_time.in.h +Copying file lib/sys_types.in.h +Copying file lib/sys_wait.in.h +Copying file lib/system-quote.c +Copying file lib/system-quote.h +Copying file lib/tempname.c +Copying file lib/tempname.h +Copying file lib/time-internal.h +Copying file lib/time.in.h +Copying file lib/time_r.c +Copying file lib/time_rz.c +Copying file lib/timegm.c +Copying file lib/timespec.c +Copying file lib/timespec.h +Copying file lib/timespec_get.c +Copying file lib/tzset.c +Copying file lib/uchar.in.h +Copying file lib/unicase.in.h +Copying file lib/unicase/simple-mapping.h +Copying file lib/unicase/tolower.c +Copying file lib/unicase/tolower.h +Copying file lib/unictype.in.h +Copying file lib/unictype/bitmap.h +Copying file lib/unictype/ctype_space.c +Copying file lib/unictype/ctype_space.h +Copying file lib/uninorm.in.h +Copying file lib/unistd--.h +Copying file lib/unistd-safer.h +Copying file lib/unistd.c +Copying file lib/unistd.in.h +Copying file lib/unitypes.in.h +Copying file lib/uniwidth.in.h +Copying file lib/uniwidth/cjk.h +Copying file lib/uniwidth/width.c +Copying file lib/uniwidth/width0.h +Copying file lib/uniwidth/width2.h +Copying file lib/unlocked-io.h +Copying file lib/unsetenv.c +Copying file lib/verify.h +Copying file lib/version-etc-fsf.c +Copying file lib/version-etc.c +Copying file lib/version-etc.h +Copying file lib/warn-on-use.h +Copying file lib/wchar.in.h +Copying file lib/wcrtomb.c +Copying file lib/wctype-h.c +Copying file lib/wctype.in.h +Copying file lib/wcwidth.c +Copying file lib/windows-initguard.h +Copying file lib/windows-mutex.c +Copying file lib/windows-mutex.h +Copying file lib/windows-once.c +Copying file lib/windows-once.h +Copying file lib/windows-recmutex.c +Copying file lib/windows-recmutex.h +Copying file lib/windows-rwlock.c +Copying file lib/windows-rwlock.h +Copying file lib/wmemchr-impl.h +Copying file lib/wmemchr.c +Copying file lib/wmempcpy.c +Copying file lib/xalloc-die.c +Copying file lib/xalloc-oversized.h +Copying file lib/xalloc.h +Copying file lib/xfreopen.c +Copying file lib/xfreopen.h +Copying file lib/xmalloc.c +Copying file lib/xmalloca.c +Copying file lib/xmalloca.h +Copying file lib/xstdopen.c +Copying file lib/xstdopen.h +Copying file lib/xstrtoimax.c +Copying file lib/xstrtol.c +Copying file lib/xstrtol.h +Copying file lib/xstrtoul.c +Copying file m4/00gnulib.m4 +Copying file m4/__inline.m4 +Copying file m4/absolute-header.m4 +Copying file m4/alloca.m4 +Copying file m4/arpa_inet_h.m4 +Copying file m4/asm-underscore.m4 +Copying file m4/assert_h.m4 +Copying file m4/atoll.m4 +Copying file m4/btowc.m4 +Copying file m4/builtin-expect.m4 +Copying file m4/c-bool.m4 +Copying file m4/c-stack.m4 +Copying file m4/c32rtomb.m4 +Copying file m4/calloc.m4 +Copying file m4/chdir-long.m4 +Copying file m4/clock_time.m4 +Copying file m4/close.m4 +Copying file m4/closedir.m4 +Copying file m4/codeset.m4 +Copying file m4/config-h.m4 +Copying file m4/ctype_h.m4 +Copying file m4/dirent_h.m4 +Copying file m4/dirfd.m4 +Copying file m4/double-slash-root.m4 +Copying file m4/dup.m4 +Copying file m4/dup2.m4 +Copying file m4/eealloc.m4 +Copying file m4/environ.m4 +Copying file m4/errno_h.m4 +Copying file m4/error.m4 +Copying file m4/error_h.m4 +Copying file m4/exponentd.m4 +Copying file m4/extensions.m4 +Copying file m4/extern-inline.m4 +Copying file m4/fchdir.m4 +Copying file m4/fclose.m4 +Copying file m4/fcntl-o.m4 +Copying file m4/fcntl.m4 +Copying file m4/fcntl_h.m4 +Copying file m4/fdopen.m4 +Copying file m4/fdopendir.m4 +Copying file m4/fflush.m4 +Copying file m4/filenamecat.m4 +Copying file m4/flexmember.m4 +Copying file m4/float_h.m4 +Copying file m4/fnmatch.m4 +Copying file m4/fnmatch_h.m4 +Copying file m4/fopen.m4 +Copying file m4/fpieee.m4 +Copying file m4/free.m4 +Copying file m4/freopen.m4 +Copying file m4/fstat.m4 +Copying file m4/ftruncate.m4 +Copying file m4/getcwd.m4 +Copying file m4/getdtablesize.m4 +Copying file m4/getopt.m4 +Copying file m4/getpagesize.m4 +Copying file m4/getprogname.m4 +Copying file m4/getrandom.m4 +Copying file m4/gettime.m4 +Copying file m4/gettimeofday.m4 +Copying file m4/gnu-make.m4 +Copying file m4/gnulib-common.m4 +Copying file m4/host-cpu-c-abi.m4 +Copying file m4/include_next.m4 +Copying file m4/inet_pton.m4 +Copying file m4/intl-thread-locale.m4 +Copying file m4/intmax_t.m4 +Copying file m4/inttostr.m4 +Copying file m4/inttypes.m4 +Copying file m4/inttypes_h.m4 +Copying file m4/ioctl.m4 +Copying file m4/isblank.m4 +Copying file m4/iswblank.m4 +Copying file m4/iswdigit.m4 +Copying file m4/iswxdigit.m4 +Copying file m4/langinfo_h.m4 +Copying file m4/largefile.m4 +Copying file m4/lib-ld.m4 +Copying file m4/lib-link.m4 +Copying file m4/lib-prefix.m4 +Copying file m4/libsigsegv.m4 +Copying file m4/libunistring-base.m4 +Copying file m4/limits-h.m4 +Copying file m4/localcharset.m4 +Copying file m4/locale-fr.m4 +Copying file m4/locale-ja.m4 +Copying file m4/locale-tr.m4 +Copying file m4/locale-zh.m4 +Copying file m4/locale_h.m4 +Copying file m4/localeconv.m4 +Copying file m4/lock.m4 +Copying file m4/lstat.m4 +Copying file m4/malloc.m4 +Copying file m4/malloca.m4 +Copying file m4/manywarnings-c++.m4 +Copying file m4/manywarnings.m4 +Copying file m4/math_h.m4 +Copying file m4/mbchar.m4 +Copying file m4/mbiter.m4 +Copying file m4/mbrtoc32.m4 +Copying file m4/mbrtowc.m4 +Copying file m4/mbsinit.m4 +Copying file m4/mbsrtowcs.m4 +Copying file m4/mbstate_t.m4 +Copying file m4/mbtowc.m4 +Copying file m4/memchr.m4 +Copying file m4/mempcpy.m4 +Copying file m4/memrchr.m4 +Copying file m4/minmax.m4 +Copying file m4/mkdir.m4 +Copying file m4/mkstemp.m4 +Copying file m4/mktime.m4 +Copying file m4/mmap-anon.m4 +Copying file m4/mode_t.m4 +Copying file m4/msvc-inval.m4 +Copying file m4/msvc-nothrow.m4 +Copying file m4/multiarch.m4 +Copying file m4/musl.m4 +Copying file m4/nanosleep.m4 +Copying file m4/netinet_in_h.m4 +Copying file m4/nl_langinfo.m4 +Copying file m4/nocrash.m4 +Copying file m4/nstrftime.m4 +Copying file m4/nullptr.m4 +Copying file m4/off_t.m4 +Copying file m4/open-cloexec.m4 +Copying file m4/open-slash.m4 +Copying file m4/open.m4 +Copying file m4/openat.m4 +Copying file m4/opendir.m4 +Copying file m4/pathmax.m4 +Copying file m4/perl.m4 +Copying file m4/perror.m4 +Copying file m4/pid_t.m4 +Copying file m4/pipe.m4 +Copying file m4/printf.m4 +Copying file m4/pselect.m4 +Copying file m4/pthread-thread.m4 +Copying file m4/pthread_h.m4 +Copying file m4/pthread_rwlock_rdlock.m4 +Copying file m4/pthread_sigmask.m4 +Copying file m4/putenv.m4 +Copying file m4/quote.m4 +Copying file m4/quotearg.m4 +Copying file m4/raise.m4 +Copying file m4/rawmemchr.m4 +Copying file m4/readlink.m4 +Copying file m4/realloc.m4 +Copying file m4/reallocarray.m4 +Copying file m4/regex.m4 +Copying file m4/save-cwd.m4 +Copying file m4/sched_h.m4 +Copying file m4/select.m4 +Copying file m4/setenv.m4 +Copying file m4/setlocale_null.m4 +Copying file m4/sigaltstack.m4 +Copying file m4/signal_h.m4 +Copying file m4/signalblocking.m4 +Copying file m4/sigsegv.m4 +Copying file m4/size_max.m4 +Copying file m4/sleep.m4 +Copying file m4/snprintf.m4 +Copying file m4/socketlib.m4 +Copying file m4/sockets.m4 +Copying file m4/socklen.m4 +Copying file m4/sockpfaf.m4 +Copying file m4/ssize_t.m4 +Copying file m4/stack-direction.m4 +Copying file m4/stat-time.m4 +Copying file m4/stat.m4 +Copying file m4/std-gnu11.m4 +Copying file m4/stdalign.m4 +Copying file m4/stdarg.m4 +Copying file m4/stddef_h.m4 +Copying file m4/stdint.m4 +Copying file m4/stdint_h.m4 +Copying file m4/stdio_h.m4 +Copying file m4/stdlib_h.m4 +Copying file m4/stpcpy.m4 +Copying file m4/strcase.m4 +Copying file m4/strdup.m4 +Copying file m4/strerror.m4 +Copying file m4/strerror_r.m4 +Copying file m4/string_h.m4 +Copying file m4/strings_h.m4 +Copying file m4/strnlen.m4 +Copying file m4/strptime.m4 +Copying file m4/strtoimax.m4 +Copying file m4/strtoll.m4 +Copying file m4/symlink.m4 +Copying file m4/sys_ioctl_h.m4 +Copying file m4/sys_random_h.m4 +Copying file m4/sys_select_h.m4 +Copying file m4/sys_socket_h.m4 +Copying file m4/sys_stat_h.m4 +Copying file m4/sys_time_h.m4 +Copying file m4/sys_types_h.m4 +Copying file m4/sys_uio_h.m4 +Copying file m4/sys_wait_h.m4 +Copying file m4/tempname.m4 +Copying file m4/thread.m4 +Copying file m4/threadlib.m4 +Copying file m4/time.m4 +Copying file m4/time_h.m4 +Copying file m4/time_r.m4 +Copying file m4/time_rz.m4 +Copying file m4/timegm.m4 +Copying file m4/timespec.m4 +Copying file m4/timespec_get.m4 +Copying file m4/tm_gmtoff.m4 +Copying file m4/tzset.m4 +Copying file m4/uchar_h.m4 +Copying file m4/unicase_h.m4 +Copying file m4/unictype_h.m4 +Copying file m4/uninorm_h.m4 +Copying file m4/unistd-safer.m4 +Copying file m4/unistd_h.m4 +Copying file m4/unlocked-io.m4 +Copying file m4/vararrays.m4 +Copying file m4/vasnprintf.m4 +Copying file m4/version-etc.m4 +Copying file m4/visibility.m4 +Copying file m4/warn-on-use.m4 +Copying file m4/warnings.m4 +Copying file m4/wchar_h.m4 +Copying file m4/wchar_t.m4 +Copying file m4/wcrtomb.m4 +Copying file m4/wctob.m4 +Copying file m4/wctomb.m4 +Copying file m4/wctype_h.m4 +Copying file m4/wcwidth.m4 +Copying file m4/wint_t.m4 +Copying file m4/wmemchr.m4 +Copying file m4/wmempcpy.m4 +Copying file m4/xalloc.m4 +Copying file m4/xsize.m4 +Copying file m4/xstrtol.m4 +Copying file m4/zzgnulib.m4 +Copying file maint.mk +Updating m4/gnulib-cache.m4 (backup in m4/gnulib-cache.m4~) +Updating m4/gnulib-comp.m4 (backup in m4/gnulib-comp.m4~) +Creating lib/gnulib.mk +Creating gnulib-tests/gnulib.mk +Updating gnulib-tests/.gitignore (backup in gnulib-tests/.gitignore~) +Updating lib/.gitignore (backup in lib/.gitignore~) +Updating m4/.gitignore (backup in m4/.gitignore~) +Finished. + +You may need to add #include directives for the following .h files. + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include "argmatch.h" + #include "attribute.h" + #include "binary-io.h" + #include "c-ctype.h" + #include "c-stack.h" + #include "careadlinkat.h" + #include "count-leading-zeros.h" + #include "diffseq.h" + #include "dirname.h" + #include "exclude.h" + #include "exitfail.h" + #include "file-type.h" + #include "filenamecat.h" + #include "flexmember.h" + #include "gettext.h" + #include "hard-locale.h" + #include "ialloc.h" + #include "idx.h" + #include "intprops.h" + #include "minmax.h" + #include "progname.h" + #include "propername.h" + #include "same-inode.h" + #include "sh-quote.h" + #include "stat-macros.h" + #include "stat-time.h" + #include "strftime.h" + #include "system-quote.h" + #include "timespec.h" + #include "unlocked-io.h" + #include "verify.h" + #include "version-etc.h" + #include "xalloc.h" + #include "xfreopen.h" + #include "xmalloca.h" + #include "xstdopen.h" + #include "xstrtol.h" + +You may need to use the following Makefile variables when linking. +Use them in _LDADD when linking a program, or +in _a_LDFLAGS or _la_LDFLAGS when linking a library. + $(CLOCK_TIME_LIB) + $(GETRANDOM_LIB) + $(HARD_LOCALE_LIB) + $(LIBTHREAD) + $(LTLIBC32CONV) when linking with libtool, $(LIBC32CONV) otherwise + $(LTLIBCSTACK) when linking with libtool, $(LIBCSTACK) otherwise + $(LTLIBINTL) when linking with libtool, $(LIBINTL) otherwise + $(LTLIBSIGSEGV) when linking with libtool, $(LIBSIGSEGV) otherwise + $(LTLIBUNISTRING) when linking with libtool, $(LIBUNISTRING) otherwise + $(MBRTOWC_LIB) + $(SETLOCALE_NULL_LIB) + +Don't forget to + - "include gnulib.mk" from within "lib/Makefile.am", + - "include gnulib.mk" from within "gnulib-tests/Makefile.am", + - mention "-I m4" in ACLOCAL_AMFLAGS in Makefile.am + or add an AC_CONFIG_MACRO_DIRS([m4]) invocation in ./configure.ac, + - mention "m4/gnulib-cache.m4" in EXTRA_DIST in Makefile.am, + - invoke gl_EARLY in ./configure.ac, right after AC_PROG_CC, + - invoke gl_INIT in ./configure.ac. diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/.gitignore b/gnulib-tool-tests/import-tests/test-diffutils-1.result/.gitignore new file mode 100644 index 00000000..0e163f80 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/.gitignore @@ -0,0 +1,117 @@ +*.a +*.exe +*.o +*.orig +*.patch +*.rej +*~ +.Tpo +.deps/ +.dirstamp +.gdb-history +/*.diff +/ABOUT-NLS +/GNUmakefile +/INSTALL +/README-release +/aclocal.m4 +/autom4te.cache/ +/build-aux/ +/confdefs* +/config.cache +/config.log +/config.status +/configure +/conftest* +/diffutils-*.tar.xz +/gnulib-tests/ +/m4/ +/maint.mk +ChangeLog +ID +Makefile +Makefile.in +TAGS +doc/.gitignore +doc/diffutils.aux +doc/diffutils.cp +doc/diffutils.cps +doc/diffutils.info +doc/diffutils.log +doc/diffutils.toc +doc/stamp-vti +doc/version.texi +lib/*/ +lib/.gitignore +lib/alloca.h +lib/arg-nonnull.h +lib/c++defs.h +lib/charset.alias +lib/config.h +lib/config.hin +lib/configmake.h +lib/ctype.h +lib/dirent.h +lib/error.h +lib/errno.h +lib/fcntl.h +lib/fnmatch.h +lib/getopt-cdefs.h +lib/getopt.h +lib/iconv*.h +lib/inttypes.h +lib/langinfo.h +lib/limits.h +lib/locale.h +lib/ref-add.sed +lib/ref-del.sed +lib/signal.h +lib/sigsegv.h +lib/stamp-h1 +lib/stdarg.h +lib/stdckdint.h +lib/stddef.h +lib/stdint.h +lib/stdio.h +lib/stdlib.h +# For some reason 'bootstrap' doesn't add /stdopen.[ch] to lib/.gitignore. +lib/stdopen.[ch] +lib/string.h +lib/strings.h +lib/time.h +lib/unicase.h +lib/unictype.h +lib/uninorm.h +lib/unistd.h +lib/unistr/ +lib/unistr.h +lib/unitypes.h +lib/uniwidth/ +lib/uniwidth.h +lib/warn-on-use.h +lib/wchar.h +lib/wctype.h +lib/uchar.h +man/*.1 +po/*.gmo +po/*.po +po/*.pot +po/*.sed +po/.gitignore +po/.reference +po/LINGUAS +po/Makefile.in.in +po/Makevars +po/Makevars.template +po/POTFILES +po/Rules-quot +po/stamp-po +src/cmp +src/diff +src/diff3 +src/paths.h +src/sdiff +src/version.[ch] +tests/*.log +tests/*.trs +vc-dwim-log-* diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/GNUmakefile b/gnulib-tool-tests/import-tests/test-diffutils-1.result/GNUmakefile new file mode 100644 index 00000000..0f469c8a --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/GNUmakefile @@ -0,0 +1,127 @@ +# Having a separate GNUmakefile lets me 'include' the dynamically +# generated rules created via cfg.mk (package-local configuration) +# as well as maint.mk (generic maintainer rules). +# This makefile is used only if you run GNU Make. +# It is necessary if you want to build targets usually of interest +# only to the maintainer. + +# Copyright (C) 2001, 2003, 2006-2024 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 . + +# If the user runs GNU make but has not yet run ./configure, +# give them a diagnostic. +_gl-Makefile := $(wildcard [M]akefile) +ifneq ($(_gl-Makefile),) + +# Make tar archive easier to reproduce. +export TAR_OPTIONS = --owner=0 --group=0 --numeric-owner --sort=name + +# Allow the user to add to this in the Makefile. +ALL_RECURSIVE_TARGETS = + +include Makefile + +# Some projects override e.g., _autoreconf here. +-include $(srcdir)/cfg.mk + +# Allow cfg.mk to override these. +_build-aux ?= build-aux +_autoreconf ?= autoreconf -v + +include $(srcdir)/maint.mk + +# Ensure that $(VERSION) is up to date for dist-related targets, but not +# for others: rerunning autoreconf and recompiling everything isn't cheap. +_have-git-version-gen := \ + $(shell test -f $(srcdir)/$(_build-aux)/git-version-gen && echo yes) +ifeq ($(_have-git-version-gen)0,yes$(MAKELEVEL)) + _is-dist-target ?= $(filter-out %clean, \ + $(filter maintainer-% dist% alpha beta stable,$(MAKECMDGOALS))) + _is-install-target ?= $(filter-out %check, $(filter install%,$(MAKECMDGOALS))) + ifneq (,$(_is-dist-target)$(_is-install-target)) + _curr-ver := $(shell cd $(srcdir) \ + && $(_build-aux)/git-version-gen \ + .tarball-version \ + $(git-version-gen-tag-sed-script)) + ifneq ($(_curr-ver),$(VERSION)) + ifeq ($(_curr-ver),UNKNOWN) + $(info WARNING: unable to verify if $(VERSION) is the correct version) + else + ifneq (,$(_is-install-target)) + # GNU Coding Standards state that 'make install' should not cause + # recompilation after 'make all'. But as long as changing the version + # string alters config.h, the cost of having 'make all' always have an + # up-to-date version is prohibitive. So, as a compromise, we merely + # warn when installing a version string that is out of date; the user + # should run 'autoreconf' (or something like 'make distcheck') to + # fix the version, 'make all' to propagate it, then 'make install'. + $(info WARNING: version string $(VERSION) is out of date;) + $(info run '$(MAKE) _version' to fix it) + else + $(info INFO: running autoreconf for new version string: $(_curr-ver)) +GNUmakefile: _version + touch GNUmakefile + endif + endif + endif + endif +endif + +.PHONY: _version +_version: + cd $(srcdir) && rm -rf autom4te.cache .version && $(_autoreconf) + $(MAKE) $(AM_MAKEFLAGS) Makefile + +else + +.DEFAULT_GOAL := abort-due-to-no-makefile +srcdir = . + +# The package can override .DEFAULT_GOAL to run actions like autoreconf. +-include ./cfg.mk + +# Allow cfg.mk to override these. +_build-aux ?= build-aux +_autoreconf ?= autoreconf -v + +include ./maint.mk + +ifeq ($(.DEFAULT_GOAL),abort-due-to-no-makefile) +$(MAKECMDGOALS): abort-due-to-no-makefile +endif + +abort-due-to-no-makefile: + @echo There seems to be no Makefile in this directory. 1>&2 + @echo "You must run ./configure before running '$(MAKE)'." 1>&2 + @exit 1 + +endif + +# Tell version 3.79 and up of GNU make to not build goals in this +# directory in parallel, in case someone tries to build multiple +# targets, and one of them can cause a recursive target to be invoked. + +# Only set this if Automake doesn't provide it. +AM_RECURSIVE_TARGETS ?= $(RECURSIVE_TARGETS:-recursive=) \ + $(RECURSIVE_CLEAN_TARGETS:-recursive=) \ + dist distcheck tags ctags + +ALL_RECURSIVE_TARGETS += $(AM_RECURSIVE_TARGETS) + +ifneq ($(word 2, $(MAKECMDGOALS)), ) +ifneq ($(filter $(ALL_RECURSIVE_TARGETS), $(MAKECMDGOALS)), ) +.NOTPARALLEL: +endif +endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/Makefile.am b/gnulib-tool-tests/import-tests/test-diffutils-1.result/Makefile.am new file mode 100644 index 00000000..c47bc830 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/Makefile.am @@ -0,0 +1,58 @@ +# Main Automakefile for GNU diffutils. + +# Copyright (C) 2001-2002, 2004, 2006, 2009-2013, 2015-2023 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 . + +ALL_RECURSIVE_TARGETS = + +EXTRA_DIST = bootstrap exgettext ChangeLog-2008 cfg.mk dist-check.mk +SUBDIRS = lib src tests doc man po gnulib-tests + +ACLOCAL_AMFLAGS = -I m4 +AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS) + +# Arrange so that .tarball-version appears only in the distribution +# tarball, and never in a checked-out repository. +dist-hook: gen-ChangeLog + $(AM_V_GEN)echo $(VERSION) > $(distdir)/.tarball-version + +gen_start_date = '2009-11-11 15:00' +.PHONY: gen-ChangeLog +gen-ChangeLog: + $(AM_V_GEN)if test -d .git; then \ + $(top_srcdir)/build-aux/gitlog-to-changelog \ + --since=$(gen_start_date) > $(distdir)/cl-t && \ + { rm -f $(distdir)/ChangeLog && \ + mv $(distdir)/cl-t $(distdir)/ChangeLog; } \ + fi + +ALL_RECURSIVE_TARGETS += distcheck-hook +distcheck-hook: + $(MAKE) my-distcheck + +# Some of our git hook scripts are supposed to be identical to git's samples. +# See if they are still in sync. +.PHONY: check-git-hook-script-sync +check-git-hook-script-sync: + @fail=0; \ + t=$$(mktemp -d) \ + && cd $$t && git init -q && cd .git/hooks \ + && for i in pre-commit pre-applypatch applypatch-msg; do \ + diff -u $(abs_top_srcdir)/scripts/git-hooks/$$i $$i.sample \ + || fail=1; \ + done; \ + rm -rf $$t; \ + test $$fail = 0 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/README-release b/gnulib-tool-tests/import-tests/test-diffutils-1.result/README-release new file mode 100644 index 00000000..536eef3a --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/README-release @@ -0,0 +1,101 @@ +Here are most of the steps we (maintainers) follow when making a release. + +* Start from a clean, up-to-date git directory on "master": + + make -k maintainer-clean || { ./configure && make maintainer-clean; } + git checkout master + git pull origin master + +* Ensure that the latest stable versions of autoconf, automake, etc. + are in your PATH. See the buildreq list in bootstrap.conf for + the complete list of tools. + +* Ensure that you have no uncommitted diffs. This should produce no + output: + + git diff + +* Ensure that you've pushed all changes that belong in the release: + + git push origin master + +* Check that the NixOS/Hydra autobuilder is reporting all is well: + + https://hydra.nixos.org/project/gnu/@PACKAGE@-master + +* Run the following command to download any new translations: + + ./bootstrap && ./configure + +* Pre-release testing: ensure that the following commands succeed: + + c=check ve=check-very-expensive; git grep -q "^$ve:\$" && c=$ve + make $c syntax-check distcheck + +* To (i) set the date, version number, and release TYPE on line 3 of + NEWS, (ii) commit that, and (iii) tag the release, run + + # "TYPE" must be stable, beta or alpha + make release-commit RELEASE='X.Y TYPE' + +* Run the following to create release tarballs. Your choice selects the + corresponding upload-to destination in the emitted gnupload command. + The different destinations are specified in cfg.mk. See the definitions + of gnu_ftp_host-{alpha,beta,stable}. + + make release RELEASE='X.Y TYPE' + +* Test the tarball. Copy it to a few odd-ball systems and ensure that + it builds and passes all tests. + +* While that's happening, write the release announcement that you will + soon post. Start with the template, $HOME/announce-@PACKAGE@-X.Y + that was just created by that "make" command. + +Once all the builds and tests have passed, + +* Run the gnupload command that was suggested by your "make release" + run above, or run + + make upload RELEASE='X.Y TYPE' + +* Wait a few minutes (maybe up to 30?) and then use the release URLs to + download all tarball/signature pairs and use gpg --verify to ensure + that they're all valid. + +* Push the NEWS-updating changes and the new tag: + + v=$(cat .prev-version) + git push origin master tag v$v + +* Announce it on Savannah first, so you can include the savannah.org + announcement link in the email message. + + Go to the news-submission form: + + https://savannah.gnu.org/news/submit.php?group=@PACKAGE@ + + If it does not work, then enable "News" for the project via this link: + + https://savannah.gnu.org/project/admin/editgroupfeatures.php?group=@PACKAGE@ + + Write something like the following: + + Subject: @PACKAGE@-X.Y released [stable] + +verbatim+ + ...paste the announcement here... + -verbatim- + + Then go here to approve it: + + https://savannah.gnu.org/news/approve.php?group=@PACKAGE@ + +* Send the announcement email message. + +* After each non-alpha release, run + + make web-manual-update + + to update the on-line manual accessible at + + https://www.gnu.org/software/@PACKAGE@/manual/ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/build-aux/.gitignore b/gnulib-tool-tests/import-tests/test-diffutils-1.result/build-aux/.gitignore new file mode 100644 index 00000000..dbc68bb5 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/build-aux/.gitignore @@ -0,0 +1,11 @@ +/config.rpath +/announce-gen +/do-release-commit-and-tag +/gendocs.sh +/git-version-gen +/gitlog-to-changelog +/gnu-web-doc-update +/gnupload +/update-copyright +/useless-if-before-free +/vc-list-files diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/build-aux/announce-gen b/gnulib-tool-tests/import-tests/test-diffutils-1.result/build-aux/announce-gen new file mode 100755 index 00000000..f9e20129 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/build-aux/announce-gen @@ -0,0 +1,704 @@ +#!/bin/sh +#! -*-perl-*- + +# Generate a release announcement message. + +# Copyright (C) 2002-2024 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 . +# +# Written by Jim Meyering + +# This is a prologue that allows to run a perl script as an executable +# on systems that are compliant to a POSIX version before POSIX:2017. +# On such systems, the usual invocation of an executable through execlp() +# or execvp() fails with ENOEXEC if it is a script that does not start +# with a #! line. The script interpreter mentioned in the #! line has +# to be /bin/sh, because on GuixSD systems that is the only program that +# has a fixed file name. The second line is essential for perl and is +# also useful for editing this file in Emacs. The next two lines below +# are valid code in both sh and perl. When executed by sh, they re-execute +# the script through the perl program found in $PATH. The '-x' option +# is essential as well; without it, perl would re-execute the script +# through /bin/sh. When executed by perl, the next two lines are a no-op. +eval 'exec perl -wSx "$0" "$@"' + if 0; + +my $VERSION = '2023-12-29 18:26'; # UTC +# The definition above must lie within the first 8 lines in order +# for the Emacs time-stamp write hook (at end) to update it. +# If you change this file with Emacs, please let the write hook +# do its job. Otherwise, update this string manually. + +my $copyright_year = '2022'; + +use strict; +use Getopt::Long; +use POSIX qw(strftime); + +(my $ME = $0) =~ s|.*/||; + +my %valid_release_types = map {$_ => 1} qw (alpha beta stable); +my @archive_suffixes = qw (tar.gz tar.bz2 tar.lz tar.lzma tar.xz); +my $srcdir = '.'; + +sub usage ($) +{ + my ($exit_code) = @_; + my $STREAM = ($exit_code == 0 ? *STDOUT : *STDERR); + if ($exit_code != 0) + { + print $STREAM "Try '$ME --help' for more information.\n"; + } + else + { + my @types = sort keys %valid_release_types; + print $STREAM < = C + +Compute the sizes of the C<@file> and return them as a hash. Return +C if one of the computation failed. + +=cut + +sub sizes (@) +{ + my (@file) = @_; + + my $fail = 0; + my %res; + foreach my $f (@file) + { + my $cmd = "du -h $f"; + my $t = `$cmd`; + # FIXME-someday: give a better diagnostic, a la $PROCESS_STATUS + $@ + and (warn "command failed: '$cmd'\n"), $fail = 1; + chomp $t; + $t =~ s/^\s*([\d.]+[MkK]).*/${1}B/; + $res{$f} = $t; + } + return $fail ? undef : %res; +} + +=item C dedicated to the list of <@file>, which +sizes are stored in C<%size>, and which are available from the C<@url>. + +=cut + +sub print_locations ($\@\%@) +{ + my ($title, $url, $size, @file) = @_; + print "Here are the $title:\n"; + foreach my $url (@{$url}) + { + for my $file (@file) + { + print " $url/$file"; + print " (", $$size{$file}, ")" + if exists $$size{$file}; + print "\n"; + } + } + print "\n"; +} + +=item C. + +=cut + +# This digest function omits the "=" padding that is required by cksum, +# so add the 0..2 bytes of padding required for each of Digest's algorithms. +sub digest_file_base64_wrap ($$) +{ + my ($file, $alg) = @_; + my $h = digest_file_base64($file, $alg); + $alg =~ tr{-}{}d; + my %pad = (MD5 => 2, SHA1 => 1, SHA256 => 1, SHA384 => 0, SHA512 => 2); + return $h . '=' x $pad{$alg}; +} + +sub print_checksums (@) +{ + my (@file) = @_; + + print "Here are the SHA1 and SHA256 checksums:\n"; + print "\n"; + + use Digest::file qw(digest_file_hex digest_file_base64); + + foreach my $f (@file) + { + print ' ', digest_file_hex ($f, "SHA-1"), " $f\n"; + print ' ', digest_file_base64_wrap ($f, "SHA-256"), " $f\n"; + } + print "\nVerify the base64 SHA256 checksum with cksum -a sha256 --check\n"; + print "from coreutils-9.2 or OpenBSD's cksum since 2007.\n\n"; +} + +=item C addressing changes +between versions C<$prev_version> and C<$curr_version>. + +=cut + +sub print_news_deltas ($$$) +{ + my ($news_file, $prev_version, $curr_version) = @_; + + my $news_name = $news_file; + $news_name =~ s|^\Q$srcdir\E/||; + + print "\n$news_name\n\n"; + + # Print all lines from $news_file, starting with the first one + # that mentions $curr_version up to but not including + # the first occurrence of $prev_version. + my $in_items; + + my $re_prefix = qr/(?:\* )?(?:Noteworthy c|Major c|C)(?i:hanges)/; + + my $found_news; + open NEWS, '<', $news_file + or die "$ME: $news_file: cannot open for reading: $!\n"; + while (defined (my $line = )) + { + if ( ! $in_items) + { + # Match lines like these: + # * Major changes in release 5.0.1: + # * Noteworthy changes in release 6.6 (2006-11-22) [stable] + $line =~ /^$re_prefix.*(?:[^\d.]|$)\Q$curr_version\E(?:[^\d.]|$)/o + or next; + $in_items = 1; + print $line; + } + else + { + # This regexp must not match version numbers in NEWS items. + # For example, they might well say "introduced in 4.5.5", + # and we don't want that to match. + $line =~ /^$re_prefix.*(?:[^\d.]|$)\Q$prev_version\E(?:[^\d.]|$)/o + and last; + print $line; + $line =~ /\S/ + and $found_news = 1; + } + } + close NEWS; + + $in_items + or die "$ME: $news_file: no matching lines for '$curr_version'\n"; + $found_news + or die "$ME: $news_file: no news item found for '$curr_version'\n"; +} + +sub print_changelog_deltas ($$) +{ + my ($package_name, $prev_version) = @_; + + # Print new ChangeLog entries. + + # First find all CVS-controlled ChangeLog files. + use File::Find; + my @changelog; + find ({wanted => sub {$_ eq 'ChangeLog' && -d 'CVS' + and push @changelog, $File::Find::name}}, + '.'); + + # If there are no ChangeLog files, we're done. + @changelog + or return; + my %changelog = map {$_ => 1} @changelog; + + # Reorder the list of files so that if there are ChangeLog + # files in the specified directories, they're listed first, + # in this order: + my @dir = qw ( . src lib m4 config doc ); + + # A typical @changelog array might look like this: + # ./ChangeLog + # ./po/ChangeLog + # ./m4/ChangeLog + # ./lib/ChangeLog + # ./doc/ChangeLog + # ./config/ChangeLog + my @reordered; + foreach my $d (@dir) + { + my $dot_slash = $d eq '.' ? $d : "./$d"; + my $target = "$dot_slash/ChangeLog"; + delete $changelog{$target} + and push @reordered, $target; + } + + # Append any remaining ChangeLog files. + push @reordered, sort keys %changelog; + + # Remove leading './'. + @reordered = map { s!^\./!!; $_ } @reordered; + + print "\nChangeLog entries:\n\n"; + # print join ("\n", @reordered), "\n"; + + $prev_version =~ s/\./_/g; + my $prev_cvs_tag = "\U$package_name\E-$prev_version"; + + my $cmd = "cvs -n diff -u -r$prev_cvs_tag -rHEAD @reordered"; + open DIFF, '-|', $cmd + or die "$ME: cannot run '$cmd': $!\n"; + # Print two types of lines, making minor changes: + # Lines starting with '+++ ', e.g., + # +++ ChangeLog 22 Feb 2003 16:52:51 -0000 1.247 + # and those starting with '+'. + # Don't print the others. + my $prev_printed_line_empty = 1; + while (defined (my $line = )) + { + if ($line =~ /^\+\+\+ /) + { + my $separator = "*"x70 ."\n"; + $line =~ s///; + $line =~ s/\s.*//; + $prev_printed_line_empty + or print "\n"; + print $separator, $line, $separator; + } + elsif ($line =~ /^\+/) + { + $line =~ s///; + print $line; + $prev_printed_line_empty = ($line =~ /^$/); + } + } + close DIFF; + + # The exit code should be 1. + # Allow in case there are no modified ChangeLog entries. + $? == 256 || $? == 128 + or warn "warning: '$cmd' had unexpected exit code or signal ($?)\n"; +} + +sub get_tool_versions ($$) +{ + my ($tool_list, $gnulib_version) = @_; + @$tool_list + or return (); + + my $fail; + my @tool_version_pair; + foreach my $t (@$tool_list) + { + if ($t eq 'gnulib') + { + push @tool_version_pair, ucfirst $t . ' ' . $gnulib_version; + next; + } + # Assume that the last "word" on the first line of + # 'tool --version' output is the version string. + my ($first_line, undef) = split ("\n", `$t --version`); + if ($first_line =~ /.* (\d[\w.-]+)$/) + { + $t = ucfirst $t; + push @tool_version_pair, "$t $1"; + } + else + { + defined $first_line + and $first_line = ''; + warn "$t: unexpected --version output\n:$first_line"; + $fail = 1; + } + } + + $fail + and exit 1; + + return @tool_version_pair; +} + +# Print a more human-friendly representation of $SEC seconds. +sub readable_interval0($) +{ + my $sec = shift; + $sec < 60 and return "$sec seconds"; + + my $min = int($sec / 60); $sec %= 60; + 30 < $sec and $min++; + $min < 60 and return "$min minutes"; + + my $hr = int($min / 60); $min %= 60; + 30 < $min and $hr++; + $hr < 24 and return "$hr hours"; + + my $day = int($hr / 24); $hr %= 24; + 12 < $hr and $day++; + $day < 50 and return "$day days"; + + my $wk = int($day / 7); $day %= 7; + 4 < $day and $wk++; + return "$wk weeks"; +} + +# Convert e.g., "1 weeks", to "1 week". +sub readable_interval($) +{ + my $interval_str = shift; + my $i = readable_interval0 $interval_str; + $i =~ m{^1 \w+s$} and chop $i; + return $i; +} + +{ + # Use the C locale so that, for instance, "du" does not + # print "1,2" instead of "1.2", which would confuse our regexps. + $ENV{LC_ALL} = "C"; + + my $mail_headers; + my $release_type; + my $package_name; + my $prev_version; + my $curr_version; + my $gpg_key_id; + my @url_dir_list; + my @news_file; + my $bootstrap_tools; + my $gnulib_version; + my $print_checksums_p = 1; + my $gpg_key_email; + my $gpg_keyring_url; + + # Reformat the warnings before displaying them. + local $SIG{__WARN__} = sub + { + my ($msg) = @_; + # Warnings from GetOptions. + $msg =~ s/Option (\w)/option --$1/; + warn "$ME: $msg"; + }; + + GetOptions + ( + 'mail-headers=s' => \$mail_headers, + 'release-type=s' => \$release_type, + 'package-name=s' => \$package_name, + 'previous-version=s' => \$prev_version, + 'current-version=s' => \$curr_version, + 'gpg-key-id=s' => \$gpg_key_id, + 'gpg-key-email=s' => \$gpg_key_email, + 'gpg-keyring-url=s' => \$gpg_keyring_url, + 'url-directory=s' => \@url_dir_list, + 'news=s' => \@news_file, + 'srcdir=s' => \$srcdir, + 'bootstrap-tools=s' => \$bootstrap_tools, + 'gnulib-version=s' => \$gnulib_version, + 'print-checksums!' => \$print_checksums_p, + 'archive-suffix=s' => \@archive_suffixes, + + help => sub { usage 0 }, + version => + sub + { + print "$ME version $VERSION\n"; + print "Copyright (C) $copyright_year Free Software Foundation, Inc.\n"; + print "License GPLv3+: GNU GPL version 3 or later .\n" + . "This is free software: you are free to change and redistribute it.\n" + . "There is NO WARRANTY, to the extent permitted by law.\n"; + print "\n"; + my $author = "Jim Meyering"; + print "Written by $author.\n"; + exit + }, + ) or usage 1; + + my $fail = 0; + # Ensure that each required option is specified. + $release_type + or (warn "release type not specified\n"), $fail = 1; + $package_name + or (warn "package name not specified\n"), $fail = 1; + $prev_version + or (warn "previous version string not specified\n"), $fail = 1; + $curr_version + or (warn "current version string not specified\n"), $fail = 1; + $gpg_key_id + or (warn "GnuPG key ID not specified\n"), $fail = 1; + @url_dir_list + or (warn "URL directory name(s) not specified\n"), $fail = 1; + + my @tool_list = split ',', $bootstrap_tools + if $bootstrap_tools; + + grep (/^gnulib$/, @tool_list) && ! defined $gnulib_version + and (warn "when specifying gnulib as a tool, you must also specify\n" + . "--gnulib-version=V, where V is the result of running git describe\n" + . "in the gnulib source directory.\n"), $fail = 1; + + ! grep (/^gnulib$/, @tool_list) && defined $gnulib_version + and (warn "with --gnulib-version=V you must use --bootstrap-tools=...\n" + . "including gnulib in that list"), $fail = 1; + + !$release_type || exists $valid_release_types{$release_type} + or (warn "'$release_type': invalid release type\n"), $fail = 1; + + @ARGV + and (warn "too many arguments:\n", join ("\n", @ARGV), "\n"), + $fail = 1; + $fail + and usage 1; + + my $my_distdir = "$package_name-$curr_version"; + + my $xd = "$package_name-$prev_version-$curr_version.xdelta"; + + my @candidates = map { "$my_distdir.$_" } @archive_suffixes; + my @tarballs = grep {-f $_} @candidates; + + @tarballs + or die "$ME: none of " . join(', ', @candidates) . " were found\n"; + my @sizable = @tarballs; + -f $xd + and push @sizable, $xd; + my %size = sizes (@sizable); + %size + or exit 1; + + my $headers = ''; + if (defined $mail_headers) + { + ($headers = $mail_headers) =~ s/\s+(\S+:)/\n$1/g; + $headers .= "\n"; + } + + # The markup is escaped as <\# so that when this script is sent by + # mail (or part of a diff), Gnus is not triggered. + print < +This is to announce $package_name-$curr_version, a $release_type release. + +FIXME: put comments here + +EOF + + my $v0 = $prev_version; + my $v1 = $curr_version; + + (my $first_name = `git config user.name|cut -d' ' -f1`) + =~ m{\S} or die "no name? set user.name in ~/.gitconfig\n"; + + chomp (my $n_ci = `git rev-list "v$v0..v$v1" | wc -l`); + chomp (my $n_p = `git shortlog "v$v0..v$v1" | grep -c '^[^ ]'`); + + my $prev_release_date = `git log --pretty=%ct -1 "v$v0"`; + my $this_release_date = `git log --pretty=%ct -1 "v$v1"`; + my $n_seconds = $this_release_date - $prev_release_date; + my $time_since_prev = readable_interval $n_seconds; + my $names = `git shortlog "v$v0..v$v1"|perl -lne '/^(\\w.*):/ and print " ".\$1'`; + + print <, 1996 +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. +# +# The first argument passed to this file is the canonical host specification, +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# The environment variables CC, GCC, LDFLAGS, LD, with_gnu_ld +# should be set by the caller. +# +# The set of defined variables is at the end of this script. + +# Known limitations: +# - On IRIX 6.5 with CC="cc", the run time search patch must not be longer +# than 256 bytes, otherwise the compiler driver will dump core. The only +# known workaround is to choose shorter directory names for the build +# directory and/or the installation directory. + +# All known linkers require a '.a' archive for static linking (except MSVC, +# which needs '.lib'). +libext=a +shrext=.so + +host="$1" +host_cpu=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +host_vendor=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +host_os=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` + +# Code taken from libtool.m4's _LT_CC_BASENAME. + +for cc_temp in $CC""; do + case $cc_temp in + compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; + distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; + \-*) ;; + *) break;; + esac +done +cc_basename=`echo "$cc_temp" | sed -e 's%^.*/%%'` + +# Code taken from libtool.m4's _LT_COMPILER_PIC. + +wl= +if test "$GCC" = yes; then + wl='-Wl,' +else + case "$host_os" in + aix*) + wl='-Wl,' + ;; + mingw* | cygwin* | pw32* | os2* | cegcc*) + ;; + hpux9* | hpux10* | hpux11*) + wl='-Wl,' + ;; + irix5* | irix6* | nonstopux*) + wl='-Wl,' + ;; + linux* | k*bsd*-gnu | kopensolaris*-gnu) + case $cc_basename in + ecc*) + wl='-Wl,' + ;; + icc* | ifort*) + wl='-Wl,' + ;; + lf95*) + wl='-Wl,' + ;; + nagfor*) + wl='-Wl,-Wl,,' + ;; + pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) + wl='-Wl,' + ;; + ccc*) + wl='-Wl,' + ;; + xl* | bgxl* | bgf* | mpixl*) + wl='-Wl,' + ;; + como) + wl='-lopt=' + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ F* | *Sun*Fortran*) + wl= + ;; + *Sun\ C*) + wl='-Wl,' + ;; + esac + ;; + esac + ;; + newsos6) + ;; + *nto* | *qnx*) + ;; + osf3* | osf4* | osf5*) + wl='-Wl,' + ;; + rdos*) + ;; + solaris*) + case $cc_basename in + f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) + wl='-Qoption ld ' + ;; + *) + wl='-Wl,' + ;; + esac + ;; + sunos4*) + wl='-Qoption ld ' + ;; + sysv4 | sysv4.2uw2* | sysv4.3*) + wl='-Wl,' + ;; + sysv4*MP*) + ;; + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + wl='-Wl,' + ;; + unicos*) + wl='-Wl,' + ;; + uts4*) + ;; + esac +fi + +# Code taken from libtool.m4's _LT_LINKER_SHLIBS. + +hardcode_libdir_flag_spec= +hardcode_libdir_separator= +hardcode_direct=no +hardcode_minus_L=no + +case "$host_os" in + cygwin* | mingw* | pw32* | cegcc*) + # FIXME: the MSVC++ port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + if test "$GCC" != yes; then + with_gnu_ld=no + fi + ;; + interix*) + # we just hope/assume this is gcc and not c89 (= MSVC++) + with_gnu_ld=yes + ;; + openbsd*) + with_gnu_ld=no + ;; +esac + +ld_shlibs=yes +if test "$with_gnu_ld" = yes; then + # Set some defaults for GNU ld with shared library support. These + # are reset later if shared libraries are not supported. Putting them + # here allows them to be overridden if necessary. + # Unlike libtool, we use -rpath here, not --rpath, since the documented + # option of GNU ld is called -rpath, not --rpath. + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + case "$host_os" in + aix[3-9]*) + # On AIX/PPC, the GNU linker is very broken + if test "$host_cpu" != ia64; then + ld_shlibs=no + fi + ;; + amigaos*) + case "$host_cpu" in + powerpc) + ;; + m68k) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + ;; + esac + ;; + beos*) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + cygwin* | mingw* | pw32* | cegcc*) + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + hardcode_libdir_flag_spec='-L$libdir' + if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + haiku*) + ;; + interix[3-9]*) + hardcode_direct=no + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + ;; + gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + netbsd*) + ;; + solaris*) + if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then + ld_shlibs=no + elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) + case `$LD -v 2>&1` in + *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) + ld_shlibs=no + ;; + *) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`' + else + ld_shlibs=no + fi + ;; + esac + ;; + sunos4*) + hardcode_direct=yes + ;; + *) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + esac + if test "$ld_shlibs" = no; then + hardcode_libdir_flag_spec= + fi +else + case "$host_os" in + aix3*) + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + hardcode_minus_L=yes + if test "$GCC" = yes; then + # Neither direct hardcoding nor static linking is supported with a + # broken collect2. + hardcode_direct=unsupported + fi + ;; + aix[4-9]*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + else + aix_use_runtimelinking=no + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) + for ld_flag in $LDFLAGS; do + if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then + aix_use_runtimelinking=yes + break + fi + done + ;; + esac + fi + hardcode_direct=yes + hardcode_libdir_separator=':' + if test "$GCC" = yes; then + case $host_os in aix4.[012]|aix4.[012].*) + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && \ + strings "$collect2name" | grep resolve_lib_name >/dev/null + then + # We have reworked collect2 + : + else + # We have old collect2 + hardcode_direct=unsupported + hardcode_minus_L=yes + hardcode_libdir_flag_spec='-L$libdir' + hardcode_libdir_separator= + fi + ;; + esac + fi + # Begin _LT_AC_SYS_LIBPATH_AIX. + echo 'int main () { return 0; }' > conftest.c + ${CC} ${LDFLAGS} conftest.c -o conftest + aix_libpath=`dump -H conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` + if test -z "$aix_libpath"; then + aix_libpath=`dump -HX64 conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` + fi + if test -z "$aix_libpath"; then + aix_libpath="/usr/lib:/lib" + fi + rm -f conftest.c conftest + # End _LT_AC_SYS_LIBPATH_AIX. + if test "$aix_use_runtimelinking" = yes; then + hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" + else + if test "$host_cpu" = ia64; then + hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' + else + hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" + fi + fi + ;; + amigaos*) + case "$host_cpu" in + powerpc) + ;; + m68k) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + ;; + esac + ;; + bsdi[45]*) + ;; + cygwin* | mingw* | pw32* | cegcc*) + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + hardcode_libdir_flag_spec=' ' + libext=lib + ;; + darwin* | rhapsody*) + hardcode_direct=no + if { case $cc_basename in ifort*) true;; *) test "$GCC" = yes;; esac; }; then + : + else + ld_shlibs=no + fi + ;; + dgux*) + hardcode_libdir_flag_spec='-L$libdir' + ;; + freebsd2.[01]*) + hardcode_direct=yes + hardcode_minus_L=yes + ;; + freebsd* | dragonfly* | midnightbsd*) + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + ;; + hpux9*) + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + hardcode_direct=yes + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + ;; + hpux10*) + if test "$with_gnu_ld" = no; then + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + hardcode_direct=yes + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + fi + ;; + hpux11*) + if test "$with_gnu_ld" = no; then + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + case $host_cpu in + hppa*64*|ia64*) + hardcode_direct=no + ;; + *) + hardcode_direct=yes + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + ;; + esac + fi + ;; + irix5* | irix6* | nonstopux*) + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + netbsd*) + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + ;; + newsos6) + hardcode_direct=yes + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + *nto* | *qnx*) + ;; + openbsd*) + if test -f /usr/libexec/ld.so; then + hardcode_direct=yes + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + else + case "$host_os" in + openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) + hardcode_libdir_flag_spec='-R$libdir' + ;; + *) + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + ;; + esac + fi + else + ld_shlibs=no + fi + ;; + os2*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + ;; + osf3*) + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + osf4* | osf5*) + if test "$GCC" = yes; then + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + else + # Both cc and cxx compiler support -rpath directly + hardcode_libdir_flag_spec='-rpath $libdir' + fi + hardcode_libdir_separator=: + ;; + solaris*) + hardcode_libdir_flag_spec='-R$libdir' + ;; + sunos4*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_direct=yes + hardcode_minus_L=yes + ;; + sysv4) + case $host_vendor in + sni) + hardcode_direct=yes # is this really true??? + ;; + siemens) + hardcode_direct=no + ;; + motorola) + hardcode_direct=no #Motorola manual says yes, but my tests say they lie + ;; + esac + ;; + sysv4.3*) + ;; + sysv4*MP*) + if test -d /usr/nec; then + ld_shlibs=yes + fi + ;; + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) + ;; + sysv5* | sco3.2v5* | sco5v6*) + hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`' + hardcode_libdir_separator=':' + ;; + uts4*) + hardcode_libdir_flag_spec='-L$libdir' + ;; + *) + ld_shlibs=no + ;; + esac +fi + +# Check dynamic linker characteristics +# Code taken from libtool.m4's _LT_SYS_DYNAMIC_LINKER. +# Unlike libtool.m4, here we don't care about _all_ names of the library, but +# only about the one the linker finds when passed -lNAME. This is the last +# element of library_names_spec in libtool.m4, or possibly two of them if the +# linker has special search rules. +library_names_spec= # the last element of library_names_spec in libtool.m4 +libname_spec='lib$name' +case "$host_os" in + aix3*) + library_names_spec='$libname.a' + ;; + aix[4-9]*) + library_names_spec='$libname$shrext' + ;; + amigaos*) + case "$host_cpu" in + powerpc*) + library_names_spec='$libname$shrext' ;; + m68k) + library_names_spec='$libname.a' ;; + esac + ;; + beos*) + library_names_spec='$libname$shrext' + ;; + bsdi[45]*) + library_names_spec='$libname$shrext' + ;; + cygwin* | mingw* | pw32* | cegcc*) + shrext=.dll + library_names_spec='$libname.dll.a $libname.lib' + ;; + darwin* | rhapsody*) + shrext=.dylib + library_names_spec='$libname$shrext' + ;; + dgux*) + library_names_spec='$libname$shrext' + ;; + freebsd[23].*) + library_names_spec='$libname$shrext$versuffix' + ;; + freebsd* | dragonfly* | midnightbsd*) + library_names_spec='$libname$shrext' + ;; + gnu*) + library_names_spec='$libname$shrext' + ;; + haiku*) + library_names_spec='$libname$shrext' + ;; + hpux9* | hpux10* | hpux11*) + case $host_cpu in + ia64*) + shrext=.so + ;; + hppa*64*) + shrext=.sl + ;; + *) + shrext=.sl + ;; + esac + library_names_spec='$libname$shrext' + ;; + interix[3-9]*) + library_names_spec='$libname$shrext' + ;; + irix5* | irix6* | nonstopux*) + library_names_spec='$libname$shrext' + case "$host_os" in + irix5* | nonstopux*) + libsuff= shlibsuff= + ;; + *) + case $LD in + *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= ;; + *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 ;; + *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 ;; + *) libsuff= shlibsuff= ;; + esac + ;; + esac + ;; + linux*oldld* | linux*aout* | linux*coff*) + ;; + linux* | k*bsd*-gnu | kopensolaris*-gnu) + library_names_spec='$libname$shrext' + ;; + knetbsd*-gnu) + library_names_spec='$libname$shrext' + ;; + netbsd*) + library_names_spec='$libname$shrext' + ;; + newsos6) + library_names_spec='$libname$shrext' + ;; + *nto* | *qnx*) + library_names_spec='$libname$shrext' + ;; + openbsd*) + library_names_spec='$libname$shrext$versuffix' + ;; + os2*) + libname_spec='$name' + shrext=.dll + library_names_spec='$libname.a' + ;; + osf3* | osf4* | osf5*) + library_names_spec='$libname$shrext' + ;; + rdos*) + ;; + solaris*) + library_names_spec='$libname$shrext' + ;; + sunos4*) + library_names_spec='$libname$shrext$versuffix' + ;; + sysv4 | sysv4.3*) + library_names_spec='$libname$shrext' + ;; + sysv4*MP*) + library_names_spec='$libname$shrext' + ;; + sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + library_names_spec='$libname$shrext' + ;; + tpf*) + library_names_spec='$libname$shrext' + ;; + uts4*) + library_names_spec='$libname$shrext' + ;; +esac + +sed_quote_subst='s/\(["`$\\]\)/\\\1/g' +escaped_wl=`echo "X$wl" | sed -e 's/^X//' -e "$sed_quote_subst"` +shlibext=`echo "$shrext" | sed -e 's,^\.,,'` +escaped_libname_spec=`echo "X$libname_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` +escaped_library_names_spec=`echo "X$library_names_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` +escaped_hardcode_libdir_flag_spec=`echo "X$hardcode_libdir_flag_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` + +LC_ALL=C sed -e 's/^\([a-zA-Z0-9_]*\)=/acl_cv_\1=/' <. + +# Written by Jim Meyering + +ME=$(basename "$0") +warn() { printf '%s: %s\n' "$ME" "$*" >&2; } +die() { warn "$*"; exit 1; } + +help() +{ + cat <. +EOF + exit +} + +version() +{ + year=$(echo "$VERSION" | sed 's/[^0-9].*//') + cat < +This is free software: you are free to change and redistribute it. +There is NO WARRANTY, to the extent permitted by law. +EOF + exit +} + +## ------ ## +## Main. ## +## ------ ## + +# Constants. +noteworthy='* Noteworthy changes in release' +noteworthy_stub="$noteworthy ?.? (????-??-??) [?]" + +# Variables. +branch=$(git branch | sed -ne '/^\* /{s///;p;q;}') +builddir=. + +while test $# != 0 +do + # Handle --option=value by splitting apart and putting back on argv. + case $1 in + --*=*) + opt=$(echo "$1" | sed -e 's/=.*//') + val=$(echo "$1" | sed -e 's/[^=]*=//') + shift + set dummy "$opt" "$val" "$@"; shift + ;; + esac + + case $1 in + --help|--version) ${1#--};; + --branch) shift; branch=$1; shift ;; + -C|--builddir) shift; builddir=$1; shift ;; + --*) die "unrecognized option: $1";; + *) break;; + esac +done + +test $# = 2 \ + || die "Usage: $ME [OPTION...] VERSION TYPE" + +ver=$1 +type=$2 + + +## ---------------------- ## +## First, sanity checks. ## +## ---------------------- ## + +# Verify that $ver looks like a version number, and... +echo "$ver"|grep -E '^[0-9][0-9.]*[0-9]$' > /dev/null \ + || die "invalid version: $ver" +prev_ver=$(cat .prev-version) \ + || die 'failed to determine previous version number from .prev-version' + +# Verify that $ver is sensible (> .prev-version). +case $(printf "%s\n%s\n" "$prev_ver" "$ver"|sort -V -u|tr '\n' ':') in + "$prev_ver:$ver:") ;; + *) die "invalid version: $ver (<= $prev_ver)";; +esac + +case $type in + alpha|beta|stable) ;; + *) die "invalid release type: $type";; +esac + +# No local modifications allowed. +case $(git diff-index --name-only HEAD) in + '') ;; + *) die 'this tree is dirty; commit your changes first';; +esac + +# Ensure the current branch name is correct: +curr_br=$(git rev-parse --symbolic-full-name HEAD) +test "$curr_br" = "refs/heads/$branch" || die not on branch $branch + +# Extract package name from Makefile. +Makefile=$builddir/Makefile +pkg=$(sed -n 's/^PACKAGE = \(.*\)/\1/p' "$Makefile") \ + || die "failed to determine package name from $Makefile" + +# Check that line 3 of NEWS is the stub line about to be replaced. +test "$(sed -n 3p NEWS)" = "$noteworthy_stub" \ + || die "line 3 of NEWS must be exactly '$noteworthy_stub'" + +## --------------- ## +## Then, changes. ## +## --------------- ## + +# Update NEWS to have today's date, plus desired version number and $type. +perl -MPOSIX -ni -e 'my $today = strftime "%F", localtime time;' \ + -e 'my ($type, $ver) = qw('"$type $ver"');' \ + -e 'my $pfx = "'"$noteworthy"'";' \ + -e 'print $.==3 ? "$pfx $ver ($today) [$type]\n" : $_' \ + NEWS || die 'failed to update NEWS' + +printf "version %s\n\n* NEWS: Record release date.\n" "$ver" \ + | git commit -F - -a || die 'git commit failed' +git tag -s -m "$pkg $ver" v$ver HEAD || die 'git tag failed' + +# Local variables: +# indent-tabs-mode: nil +# eval: (add-hook 'before-save-hook 'time-stamp) +# time-stamp-start: "VERSION=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC0" +# time-stamp-end: " # UTC" +# End: diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/build-aux/gendocs.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/build-aux/gendocs.sh new file mode 100755 index 00000000..b0433c79 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/build-aux/gendocs.sh @@ -0,0 +1,524 @@ +#!/bin/sh -e +# gendocs.sh -- generate a GNU manual in many formats. This script is +# mentioned in maintain.texi. See the help message below for usage details. + +scriptversion=2024-01-01.00 + +# Copyright 2003-2024 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 . +# +# Original author: Mohit Agarwal. +# Send bug reports and any other correspondence to bug-gnulib@gnu.org. +# +# The latest version of this script, and the companion template, is +# available from the Gnulib repository: +# +# https://git.savannah.gnu.org/cgit/gnulib.git/tree/build-aux/gendocs.sh +# https://git.savannah.gnu.org/cgit/gnulib.git/tree/doc/gendocs_template + +# TODO: +# - image importing was only implemented for HTML generated by +# makeinfo. But it should be simple enough to adjust. +# - images are not imported in the source tarball. All the needed +# formats (PDF, PNG, etc.) should be included. + +prog=`basename "$0"` +srcdir=`pwd` + +scripturl="https://git.savannah.gnu.org/cgit/gnulib.git/plain/build-aux/gendocs.sh" +templateurl="https://git.savannah.gnu.org/cgit/gnulib.git/plain/doc/gendocs_template" + +: "${SETLANG="env LANG= LC_TIME= LC_MESSAGES= LC_ALL= LANGUAGE="}" +: "${MAKEINFO="makeinfo"}" +: "${TEXI2DVI="texi2dvi"}" +: "${DOCBOOK2HTML="docbook2html"}" +: "${DOCBOOK2PDF="docbook2pdf"}" +: "${DOCBOOK2TXT="docbook2txt"}" +: "${GENDOCS_TEMPLATE_DIR="."}" +: "${PERL="perl"}" +: "${TEXI2HTML="texi2html"}" +unset CDPATH +unset use_texi2html + +MANUAL_TITLE= +PACKAGE= +EMAIL=webmasters@gnu.org # please override with --email +commonarg= # passed to all makeinfo/texi2html invocations. +dirargs= # passed to all tools (-I dir). +dirs= # -I directories. +htmlarg="--css-ref=https://www.gnu.org/software/gnulib/manual.css -c TOP_NODE_UP_URL=/manual" +default_htmlarg=true +infoarg=--no-split +generate_ascii=true +generate_html=true +generate_info=true +generate_tex=true +outdir=manual +source_extra= +split=node +srcfile= +texarg="-t @finalout" + +version="gendocs.sh $scriptversion + +Copyright 2024 Free Software Foundation, Inc. +There is NO warranty. You may redistribute this software +under the terms of the GNU General Public License. +For more information about these matters, see the files named COPYING." + +usage="Usage: $prog [OPTION]... PACKAGE MANUAL-TITLE + +Generate output in various formats from PACKAGE.texinfo (or .texi or +.txi) source. See the GNU Maintainers document for a more extensive +discussion: + https://www.gnu.org/prep/maintain_toc.html + +Options: + --email ADR use ADR as contact in generated web pages; always give this. + + -s SRCFILE read Texinfo from SRCFILE, instead of PACKAGE.{texinfo|texi|txi} + -o OUTDIR write files into OUTDIR, instead of manual/. + -I DIR append DIR to the Texinfo search path. + --common ARG pass ARG in all invocations. + --html ARG pass ARG to makeinfo or texi2html for HTML targets, + instead of '$htmlarg'. + --info ARG pass ARG to makeinfo for Info, instead of --no-split. + --no-ascii skip generating the plain text output. + --no-html skip generating the html output. + --no-info skip generating the info output. + --no-tex skip generating the dvi and pdf output. + --source ARG include ARG in tar archive of sources. + --split HOW make split HTML by node, section, chapter; default node. + --tex ARG pass ARG to texi2dvi for DVI and PDF, instead of -t @finalout. + + --texi2html use texi2html to make HTML target, with all split versions. + --docbook convert through DocBook too (xml, txt, html, pdf). + + --help display this help and exit successfully. + --version display version information and exit successfully. + +Simple example: $prog --email bug-gnu-emacs@gnu.org emacs \"GNU Emacs Manual\" + +Typical sequence: + cd PACKAGESOURCE/doc + wget \"$scripturl\" + wget \"$templateurl\" + $prog --email BUGLIST MANUAL \"GNU MANUAL - One-line description\" + +Output will be in a new subdirectory \"manual\" (by default; +use -o OUTDIR to override). Move all the new files into your web CVS +tree, as explained in the Web Pages node of maintain.texi. + +Please use the --email ADDRESS option so your own bug-reporting +address will be used in the generated HTML pages. + +MANUAL-TITLE is included as part of the HTML of the overall +manual/index.html file. It should include the name of the package being +documented. manual/index.html is created by substitution from the file +$GENDOCS_TEMPLATE_DIR/gendocs_template. (Feel free to modify the +generic template for your own purposes.) + +If you have several manuals, you'll need to run this script several +times with different MANUAL values, specifying a different output +directory with -o each time. Then write (by hand) an overall index.html +with links to them all. + +If a manual's Texinfo sources are spread across several directories, +first copy or symlink all Texinfo sources into a single directory. +(Part of the script's work is to make a tar.gz of the sources.) + +As implied above, by default monolithic Info files are generated. +If you want split Info, or other Info options, use --info to override. + +You can set the environment variables MAKEINFO, TEXI2DVI, TEXI2HTML, +and PERL to control the programs that get executed, and +GENDOCS_TEMPLATE_DIR to control where the gendocs_template file is +looked for. With --docbook, the environment variables DOCBOOK2HTML, +DOCBOOK2PDF, and DOCBOOK2TXT are also consulted. + +By default, makeinfo and texi2dvi are run in the default (English) +locale, since that's the language of most Texinfo manuals. If you +happen to have a non-English manual and non-English web site, see the +SETLANG setting in the source. + +Email bug reports or enhancement requests to bug-gnulib@gnu.org. +" + +while test $# -gt 0; do + case $1 in + -s) shift; srcfile=$1;; + -o) shift; outdir=$1;; + -I) shift; dirargs="$dirargs -I '$1'"; dirs="$dirs $1";; + --common) shift; commonarg=$1;; + --docbook) docbook=yes;; + --email) shift; EMAIL=$1;; + --html) shift; default_htmlarg=false; htmlarg=$1;; + --info) shift; infoarg=$1;; + --no-ascii) generate_ascii=false;; + --no-html) generate_ascii=false;; + --no-info) generate_info=false;; + --no-tex) generate_tex=false;; + --source) shift; source_extra=$1;; + --split) shift; split=$1;; + --tex) shift; texarg=$1;; + --texi2html) use_texi2html=1;; + + --help) echo "$usage"; exit 0;; + --version) echo "$version"; exit 0;; + -*) + echo "$0: Unknown option \`$1'." >&2 + echo "$0: Try \`--help' for more information." >&2 + exit 1;; + *) + if test -z "$PACKAGE"; then + PACKAGE=$1 + elif test -z "$MANUAL_TITLE"; then + MANUAL_TITLE=$1 + else + echo "$0: extra non-option argument \`$1'." >&2 + exit 1 + fi;; + esac + shift +done + +# makeinfo uses the dirargs, but texi2dvi doesn't. +commonarg=" $dirargs $commonarg" + +# For most of the following, the base name is just $PACKAGE +base=$PACKAGE + +if $default_htmlarg && test -n "$use_texi2html"; then + # The legacy texi2html doesn't support TOP_NODE_UP_URL + htmlarg="--css-ref=https://www.gnu.org/software/gnulib/manual.css" +fi + +if test -n "$srcfile"; then + # but here, we use the basename of $srcfile + base=`basename "$srcfile"` + case $base in + *.txi|*.texi|*.texinfo) base=`echo "$base"|sed 's/\.[texinfo]*$//'`;; + esac + PACKAGE=$base +elif test -s "$srcdir/$PACKAGE.texinfo"; then + srcfile=$srcdir/$PACKAGE.texinfo +elif test -s "$srcdir/$PACKAGE.texi"; then + srcfile=$srcdir/$PACKAGE.texi +elif test -s "$srcdir/$PACKAGE.txi"; then + srcfile=$srcdir/$PACKAGE.txi +else + echo "$0: cannot find .texinfo or .texi or .txi for $PACKAGE in $srcdir." >&2 + exit 1 +fi + +if test ! -r $GENDOCS_TEMPLATE_DIR/gendocs_template; then + echo "$0: cannot read $GENDOCS_TEMPLATE_DIR/gendocs_template." >&2 + echo "$0: it is available from $templateurl." >&2 + exit 1 +fi + +# Function to return size of $1 in something resembling kilobytes. +calcsize() +{ + size=`ls -ksl $1 | awk '{print $1}'` + echo $size +} + +# copy_images OUTDIR HTML-FILE... +# ------------------------------- +# Copy all the images needed by the HTML-FILEs into OUTDIR. +# Look for them in . and the -I directories; this is simpler than what +# makeinfo supports with -I, but hopefully it will suffice. +copy_images() +{ + local odir + odir=$1 + shift + $PERL -n -e " +BEGIN { + \$me = '$prog'; + \$odir = '$odir'; + @dirs = qw(. $dirs); +} +" -e ' +/<img src="(.*?)"/g && ++$need{$1}; + +END { + #print "$me: @{[keys %need]}\n"; # for debugging, show images found. + FILE: for my $f (keys %need) { + for my $d (@dirs) { + if (-f "$d/$f") { + use File::Basename; + my $dest = dirname ("$odir/$f"); + # + use File::Path; + -d $dest || mkpath ($dest) + || die "$me: cannot mkdir $dest: $!\n"; + # + use File::Copy; + copy ("$d/$f", $dest) + || die "$me: cannot copy $d/$f to $dest: $!\n"; + next FILE; + } + } + die "$me: $ARGV: cannot find image $f\n"; + } +} +' -- "$@" || exit 1 +} + +case $outdir in + /*) abs_outdir=$outdir;; + *) abs_outdir=$srcdir/$outdir;; +esac + +echo "Making output for $srcfile" +echo " in `pwd`" +mkdir -p "$outdir/" + +# +if $generate_info; then + cmd="$SETLANG $MAKEINFO -o $PACKAGE.info $commonarg $infoarg \"$srcfile\"" + echo "Generating info... ($cmd)" + rm -f $PACKAGE.info* # get rid of any strays + eval "$cmd" + tar czf "$outdir/$PACKAGE.info.tar.gz" $PACKAGE.info* + ls -l "$outdir/$PACKAGE.info.tar.gz" + info_tgz_size=`calcsize "$outdir/$PACKAGE.info.tar.gz"` + # do not mv the info files, there's no point in having them available + # separately on the web. +fi # end info + +# +if $generate_tex; then + cmd="$SETLANG $TEXI2DVI $dirargs $texarg \"$srcfile\"" + printf "\nGenerating dvi... (%s)\n" "$cmd" + eval "$cmd" + # compress/finish dvi: + gzip -f -9 $PACKAGE.dvi + dvi_gz_size=`calcsize $PACKAGE.dvi.gz` + mv $PACKAGE.dvi.gz "$outdir/" + ls -l "$outdir/$PACKAGE.dvi.gz" + + cmd="$SETLANG $TEXI2DVI --pdf $dirargs $texarg \"$srcfile\"" + printf "\nGenerating pdf... (%s)\n" "$cmd" + eval "$cmd" + pdf_size=`calcsize $PACKAGE.pdf` + mv $PACKAGE.pdf "$outdir/" + ls -l "$outdir/$PACKAGE.pdf" +fi # end tex (dvi + pdf) + +# +if $generate_ascii; then + opt="-o $PACKAGE.txt --no-split --no-headers $commonarg" + cmd="$SETLANG $MAKEINFO $opt \"$srcfile\"" + printf "\nGenerating ascii... (%s)\n" "$cmd" + eval "$cmd" + ascii_size=`calcsize $PACKAGE.txt` + gzip -f -9 -c $PACKAGE.txt >"$outdir/$PACKAGE.txt.gz" + ascii_gz_size=`calcsize "$outdir/$PACKAGE.txt.gz"` + mv $PACKAGE.txt "$outdir/" + ls -l "$outdir/$PACKAGE.txt" "$outdir/$PACKAGE.txt.gz" +fi + +# + +if $generate_html; then +# Split HTML at level $1. Used for texi2html. +html_split() +{ + opt="--split=$1 --node-files $commonarg $htmlarg" + cmd="$SETLANG $TEXI2HTML --output $PACKAGE.html $opt \"$srcfile\"" + printf "\nGenerating html by %s... (%s)\n" "$1" "$cmd" + eval "$cmd" + split_html_dir=$PACKAGE.html + ( + cd ${split_html_dir} || exit 1 + ln -sf ${PACKAGE}.html index.html + tar -czf "$abs_outdir/${PACKAGE}.html_$1.tar.gz" -- *.html + ) + eval html_$1_tgz_size=`calcsize "$outdir/${PACKAGE}.html_$1.tar.gz"` + rm -f "$outdir"/html_$1/*.html + mkdir -p "$outdir/html_$1/" + mv ${split_html_dir}/*.html "$outdir/html_$1/" + rmdir ${split_html_dir} +} + +if test -z "$use_texi2html"; then + opt="--no-split --html -o $PACKAGE.html $commonarg $htmlarg" + cmd="$SETLANG $MAKEINFO $opt \"$srcfile\"" + printf "\nGenerating monolithic html... (%s)\n" "$cmd" + rm -rf $PACKAGE.html # in case a directory is left over + eval "$cmd" + html_mono_size=`calcsize $PACKAGE.html` + gzip -f -9 -c $PACKAGE.html >"$outdir/$PACKAGE.html.gz" + html_mono_gz_size=`calcsize "$outdir/$PACKAGE.html.gz"` + copy_images "$outdir/" $PACKAGE.html + mv $PACKAGE.html "$outdir/" + ls -l "$outdir/$PACKAGE.html" "$outdir/$PACKAGE.html.gz" + + # Before Texinfo 5.0, makeinfo did not accept a --split=HOW option, + # it just always split by node. So if we're splitting by node anyway, + # leave it out. + if test "x$split" = xnode; then + split_arg= + else + split_arg=--split=$split + fi + # + opt="--html -o $PACKAGE.html $split_arg $commonarg $htmlarg" + cmd="$SETLANG $MAKEINFO $opt \"$srcfile\"" + printf "\nGenerating html by %s... (%s)\n" "$split" "$cmd" + eval "$cmd" + split_html_dir=$PACKAGE.html + copy_images $split_html_dir/ $split_html_dir/*.html + ( + cd $split_html_dir || exit 1 + tar -czf "$abs_outdir/$PACKAGE.html_$split.tar.gz" -- * + ) + eval \ + html_${split}_tgz_size=`calcsize "$outdir/$PACKAGE.html_$split.tar.gz"` + rm -rf "$outdir/html_$split/" + mv $split_html_dir "$outdir/html_$split/" + du -s "$outdir/html_$split/" + ls -l "$outdir/$PACKAGE.html_$split.tar.gz" + +else # use texi2html: + opt="--output $PACKAGE.html $commonarg $htmlarg" + cmd="$SETLANG $TEXI2HTML $opt \"$srcfile\"" + printf "\nGenerating monolithic html with texi2html... (%s)\n" "$cmd" + rm -rf $PACKAGE.html # in case a directory is left over + eval "$cmd" + html_mono_size=`calcsize $PACKAGE.html` + gzip -f -9 -c $PACKAGE.html >"$outdir/$PACKAGE.html.gz" + html_mono_gz_size=`calcsize "$outdir/$PACKAGE.html.gz"` + mv $PACKAGE.html "$outdir/" + + html_split node + html_split chapter + html_split section +fi +fi # end html + +# +printf "\nMaking .tar.gz for sources...\n" +d=`dirname $srcfile` +( + cd "$d" + srcfiles=`ls -d *.texinfo *.texi *.txi *.eps $source_extra 2>/dev/null` || true + tar czfh "$abs_outdir/$PACKAGE.texi.tar.gz" $srcfiles + ls -l "$abs_outdir/$PACKAGE.texi.tar.gz" +) +texi_tgz_size=`calcsize "$outdir/$PACKAGE.texi.tar.gz"` + +# +# Do everything again through docbook. +if test -n "$docbook"; then + opt="-o - --docbook $commonarg" + cmd="$SETLANG $MAKEINFO $opt \"$srcfile\" >${srcdir}/$PACKAGE-db.xml" + printf "\nGenerating docbook XML... (%s)\n" "$cmd" + eval "$cmd" + docbook_xml_size=`calcsize $PACKAGE-db.xml` + gzip -f -9 -c $PACKAGE-db.xml >"$outdir/$PACKAGE-db.xml.gz" + docbook_xml_gz_size=`calcsize "$outdir/$PACKAGE-db.xml.gz"` + mv $PACKAGE-db.xml "$outdir/" + + split_html_db_dir=html_node_db + opt="$commonarg -o $split_html_db_dir" + cmd="$DOCBOOK2HTML $opt \"${outdir}/$PACKAGE-db.xml\"" + printf "\nGenerating docbook HTML... (%s)\n" "$cmd" + eval "$cmd" + ( + cd ${split_html_db_dir} || exit 1 + tar -czf "$abs_outdir/${PACKAGE}.html_node_db.tar.gz" -- *.html + ) + html_node_db_tgz_size=`calcsize "$outdir/${PACKAGE}.html_node_db.tar.gz"` + rm -f "$outdir"/html_node_db/*.html + mkdir -p "$outdir/html_node_db" + mv ${split_html_db_dir}/*.html "$outdir/html_node_db/" + rmdir ${split_html_db_dir} + + cmd="$DOCBOOK2TXT \"${outdir}/$PACKAGE-db.xml\"" + printf "\nGenerating docbook ASCII... (%s)\n" "$cmd" + eval "$cmd" + docbook_ascii_size=`calcsize $PACKAGE-db.txt` + mv $PACKAGE-db.txt "$outdir/" + + cmd="$DOCBOOK2PDF \"${outdir}/$PACKAGE-db.xml\"" + printf "\nGenerating docbook PDF... (%s)\n" "$cmd" + eval "$cmd" + docbook_pdf_size=`calcsize $PACKAGE-db.pdf` + mv $PACKAGE-db.pdf "$outdir/" +fi + +# +printf "\nMaking index.html for %s...\n" "$PACKAGE" +if test -z "$use_texi2html"; then + if test x$split = xnode; then + CONDS="/%%IF *HTML_NODE%%/d;/%%ENDIF *HTML_NODE%%/d;\ + /%%IF *HTML_CHAPTER%%/,/%%ENDIF *HTML_CHAPTER%%/d;\ + /%%IF *HTML_SECTION%%/,/%%ENDIF *HTML_SECTION%%/d;" + elif test x$split = xchapter; then + CONDS="/%%IF *HTML_CHAPTER%%/d;/%%ENDIF *HTML_CHAPTER%%/d;\ + /%%IF *HTML_SECTION%%/,/%%ENDIF *HTML_SECTION%%/d;\ + /%%IF *HTML_NODE%%/,/%%ENDIF *HTML_NODE%%/d;" + elif test x$split = xsection; then + CONDS="/%%IF *HTML_SECTION%%/d;/%%ENDIF *HTML_SECTION%%/d;\ + /%%IF *HTML_CHAPTER%%/,/%%ENDIF *HTML_CHAPTER%%/d;\ + /%%IF *HTML_NODE%%/,/%%ENDIF *HTML_NODE%%/d;" + else + CONDS="/%%IF.*%%/d;/%%ENDIF.*%%/d;" # invalid split argument + fi +else + # for texi2html, we do not take account of --split and simply output + # all variants + CONDS="/%%IF.*%%/d;/%%ENDIF.*%%/d;" +fi + +curdate=`$SETLANG date '+%B %d, %Y'` +sed \ + -e "s!%%TITLE%%!$MANUAL_TITLE!g" \ + -e "s!%%EMAIL%%!$EMAIL!g" \ + -e "s!%%PACKAGE%%!$PACKAGE!g" \ + -e "s!%%DATE%%!$curdate!g" \ + -e "s!%%HTML_MONO_SIZE%%!$html_mono_size!g" \ + -e "s!%%HTML_MONO_GZ_SIZE%%!$html_mono_gz_size!g" \ + -e "s!%%HTML_NODE_TGZ_SIZE%%!$html_node_tgz_size!g" \ + -e "s!%%HTML_SECTION_TGZ_SIZE%%!$html_section_tgz_size!g" \ + -e "s!%%HTML_CHAPTER_TGZ_SIZE%%!$html_chapter_tgz_size!g" \ + -e "s!%%INFO_TGZ_SIZE%%!$info_tgz_size!g" \ + -e "s!%%DVI_GZ_SIZE%%!$dvi_gz_size!g" \ + -e "s!%%PDF_SIZE%%!$pdf_size!g" \ + -e "s!%%ASCII_SIZE%%!$ascii_size!g" \ + -e "s!%%ASCII_GZ_SIZE%%!$ascii_gz_size!g" \ + -e "s!%%TEXI_TGZ_SIZE%%!$texi_tgz_size!g" \ + -e "s!%%DOCBOOK_HTML_NODE_TGZ_SIZE%%!$html_node_db_tgz_size!g" \ + -e "s!%%DOCBOOK_ASCII_SIZE%%!$docbook_ascii_size!g" \ + -e "s!%%DOCBOOK_PDF_SIZE%%!$docbook_pdf_size!g" \ + -e "s!%%DOCBOOK_XML_SIZE%%!$docbook_xml_size!g" \ + -e "s!%%DOCBOOK_XML_GZ_SIZE%%!$docbook_xml_gz_size!g" \ + -e "s,%%SCRIPTURL%%,$scripturl,g" \ + -e "s!%%SCRIPTNAME%%!$prog!g" \ + -e "$CONDS" \ +$GENDOCS_TEMPLATE_DIR/gendocs_template >"$outdir/index.html" + +echo "Done, see $outdir/ subdirectory for new files." + +# Local variables: +# eval: (add-hook 'before-save-hook 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-end: "$" +# End: diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/build-aux/git-version-gen b/gnulib-tool-tests/import-tests/test-diffutils-1.result/build-aux/git-version-gen new file mode 100755 index 00000000..aa168e19 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/build-aux/git-version-gen @@ -0,0 +1,227 @@ +#!/bin/sh +# Print a version string. +scriptversion=2022-07-09.08; # UTC + +# Copyright (C) 2007-2024 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/>. + +# This script is derived from GIT-VERSION-GEN from GIT: https://git-scm.com/. +# It may be run two ways: +# - from a git repository in which the "git describe" command below +# produces useful output (thus requiring at least one signed tag) +# - from a non-git-repo directory containing a .tarball-version file, which +# presumes this script is invoked like "./git-version-gen .tarball-version". + +# In order to use intra-version strings in your project, you will need two +# separate generated version string files: +# +# .tarball-version - present only in a distribution tarball, and not in +# a checked-out repository. Created with contents that were learned at +# the last time autoconf was run, and used by git-version-gen. Must not +# be present in either $(srcdir) or $(builddir) for git-version-gen to +# give accurate answers during normal development with a checked out tree, +# but must be present in a tarball when there is no version control system. +# Therefore, it cannot be used in any dependencies. GNUmakefile has +# hooks to force a reconfigure at distribution time to get the value +# correct, without penalizing normal development with extra reconfigures. +# +# .version - present in a checked-out repository and in a distribution +# tarball. Usable in dependencies, particularly for files that don't +# want to depend on config.h but do want to track version changes. +# Delete this file prior to any autoconf run where you want to rebuild +# files to pick up a version string change; and leave it stale to +# minimize rebuild time after unrelated changes to configure sources. +# +# As with any generated file in a VC'd directory, you should add +# /.version to .gitignore, so that you don't accidentally commit it. +# .tarball-version is never generated in a VC'd directory, so needn't +# be listed there. +# +# Use the following line in your configure.ac, so that $(VERSION) will +# automatically be up-to-date each time configure is run (and note that +# since configure.ac no longer includes a version string, Makefile rules +# should not depend on configure.ac for version updates). +# +# AC_INIT([GNU project], +# m4_esyscmd([build-aux/git-version-gen .tarball-version]), +# [bug-project@example]) +# +# Then use the following lines in your Makefile.am, so that .version +# will be present for dependencies, and so that .version and +# .tarball-version will exist in distribution tarballs. +# +# EXTRA_DIST = $(top_srcdir)/.version +# BUILT_SOURCES = $(top_srcdir)/.version +# $(top_srcdir)/.version: +# echo '$(VERSION)' > $@-t +# mv $@-t $@ +# dist-hook: +# echo '$(VERSION)' > $(distdir)/.tarball-version + + +me=$0 + +year=`expr "$scriptversion" : '\([^-]*\)'` +version="git-version-gen $scriptversion + +Copyright (C) ${year} Free Software Foundation, Inc. +License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>. +This is free software: you are free to change and redistribute it. +There is NO WARRANTY, to the extent permitted by law." + +usage="\ +Usage: $me [OPTION]... \$srcdir/.tarball-version [TAG-NORMALIZATION-SED-SCRIPT] +Print a version string. + +Options: + + --prefix PREFIX prefix of git tags (default 'v') + --fallback VERSION + fallback version to use if \"git --version\" fails + + --help display this help and exit + --version output version information and exit + +Send patches and bug reports to <bug-gnulib@gnu.org>." + +prefix=v +fallback= + +while test $# -gt 0; do + case $1 in + --help) echo "$usage"; exit 0;; + --version) echo "$version"; exit 0;; + --prefix) shift; prefix=${1?};; + --fallback) shift; fallback=${1?};; + -*) + echo "$0: Unknown option '$1'." >&2 + echo "$0: Try '--help' for more information." >&2 + exit 1;; + *) + if test "x$tarball_version_file" = x; then + tarball_version_file="$1" + elif test "x$tag_sed_script" = x; then + tag_sed_script="$1" + else + echo "$0: extra non-option argument '$1'." >&2 + exit 1 + fi;; + esac + shift +done + +if test "x$tarball_version_file" = x; then + echo "$usage" + exit 1 +fi + +tag_sed_script="${tag_sed_script:-s/x/x/}" + +nl=' +' + +# Avoid meddling by environment variable of the same name. +v= +v_from_git= + +# First see if there is a tarball-only version file. +# then try "git describe", then default. +if test -f $tarball_version_file +then + v=`cat $tarball_version_file` || v= + case $v in + *$nl*) v= ;; # reject multi-line output + esac + test "x$v" = x \ + && echo "$0: WARNING: $tarball_version_file is damaged" 1>&2 +fi + +if test "x$v" != x +then + : # use $v +# Otherwise, if there is at least one git commit involving the working +# directory, and "git describe" output looks sensible, use that to +# derive a version string. +elif test "`git log -1 --pretty=format:x . 2>&1`" = x \ + && v=`git describe --abbrev=4 --match="$prefix*" HEAD 2>/dev/null \ + || git describe --abbrev=4 HEAD 2>/dev/null` \ + && v=`printf '%s\n' "$v" | sed "$tag_sed_script"` \ + && case $v in + $prefix[0-9]*) ;; + *) (exit 1) ;; + esac +then + # Is this a new git that lists number of commits since the last + # tag or the previous older version that did not? + # Newer: v6.10-77-g0f8faeb + # Older: v6.10-g0f8faeb + vprefix=`expr "X$v" : 'X\(.*\)-g[^-]*$'` || vprefix=$v + case $vprefix in + *-*) : git describe is probably okay three part flavor ;; + *) + : git describe is older two part flavor + # Recreate the number of commits and rewrite such that the + # result is the same as if we were using the newer version + # of git describe. + vtag=`echo "$v" | sed 's/-.*//'` + commit_list=`git rev-list "$vtag"..HEAD 2>/dev/null` \ + || { commit_list=failed; + echo "$0: WARNING: git rev-list failed" 1>&2; } + numcommits=`echo "$commit_list" | wc -l` + v=`echo "$v" | sed "s/\(.*\)-\(.*\)/\1-$numcommits-\2/"`; + test "$commit_list" = failed && v=UNKNOWN + ;; + esac + + # Change the penultimate "-" to ".", for version-comparing tools. + # Remove the "g" to save a byte. + v=`echo "$v" | sed 's/-\([^-]*\)-g\([^-]*\)$/.\1-\2/'`; + v_from_git=1 +elif test "x$fallback" = x || git --version >/dev/null 2>&1; then + v=UNKNOWN +else + v=$fallback +fi + +v=`echo "$v" |sed "s/^$prefix//"` + +# Test whether to append the "-dirty" suffix only if the version +# string we're using came from git. I.e., skip the test if it's "UNKNOWN" +# or if it came from .tarball-version. +if test "x$v_from_git" != x; then + # Don't declare a version "dirty" merely because a timestamp has changed. + git update-index --refresh > /dev/null 2>&1 + + dirty=`exec 2>/dev/null;git diff-index --name-only HEAD` || dirty= + case "$dirty" in + '') ;; + *) # Append the suffix only if there isn't one already. + case $v in + *-dirty) ;; + *) v="$v-dirty" ;; + esac ;; + esac +fi + +# Omit the trailing newline, so that m4_esyscmd can use the result directly. +printf %s "$v" + +# Local variables: +# eval: (add-hook 'before-save-hook 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC0" +# time-stamp-end: "; # UTC" +# End: diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/build-aux/gitlog-to-changelog b/gnulib-tool-tests/import-tests/test-diffutils-1.result/build-aux/gitlog-to-changelog new file mode 100755 index 00000000..90e81731 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/build-aux/gitlog-to-changelog @@ -0,0 +1,516 @@ +#!/bin/sh +#! -*-perl-*- + +# Convert git log output to ChangeLog format. + +# Copyright (C) 2008-2024 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 Jim Meyering + +# This is a prologue that allows to run a perl script as an executable +# on systems that are compliant to a POSIX version before POSIX:2017. +# On such systems, the usual invocation of an executable through execlp() +# or execvp() fails with ENOEXEC if it is a script that does not start +# with a #! line. The script interpreter mentioned in the #! line has +# to be /bin/sh, because on GuixSD systems that is the only program that +# has a fixed file name. The second line is essential for perl and is +# also useful for editing this file in Emacs. The next two lines below +# are valid code in both sh and perl. When executed by sh, they re-execute +# the script through the perl program found in $PATH. The '-x' option +# is essential as well; without it, perl would re-execute the script +# through /bin/sh. When executed by perl, the next two lines are a no-op. +eval 'exec perl -wSx "$0" "$@"' + if 0; + +my $VERSION = '2023-06-24 21:59'; # UTC +# The definition above must lie within the first 8 lines in order +# for the Emacs time-stamp write hook (at end) to update it. +# If you change this file with Emacs, please let the write hook +# do its job. Otherwise, update this string manually. + +use strict; +use warnings; +use Getopt::Long; +use POSIX qw(strftime); + +(my $ME = $0) =~ s|.*/||; + +# use File::Coda; # https://meyering.net/code/Coda/ +END { + defined fileno STDOUT or return; + close STDOUT and return; + warn "$ME: failed to close standard output: $!\n"; + $? ||= 1; +} + +sub usage ($) +{ + my ($exit_code) = @_; + my $STREAM = ($exit_code == 0 ? *STDOUT : *STDERR); + if ($exit_code != 0) + { + print $STREAM "Try '$ME --help' for more information.\n"; + } + else + { + print $STREAM <<EOF; +Usage: $ME [OPTIONS] [ARGS] + +Convert git log output to ChangeLog format. If present, any ARGS +are passed to "git log". To avoid ARGS being parsed as options to +$ME, they may be preceded by '--'. + +OPTIONS: + + --amend=FILE FILE maps from an SHA1 to perl code (i.e., s/old/new/) that + makes a change to SHA1's commit log text or metadata. + --append-dot append a dot to the first line of each commit message if + there is no other punctuation or blank at the end. + --no-cluster never cluster commit messages under the same date/author + header; the default is to cluster adjacent commit messages + if their headers are the same and neither commit message + contains multiple paragraphs. + --srcdir=DIR the root of the source tree, from which the .git/ + directory can be derived. + --since=DATE convert only the logs since DATE; + the default is to convert all log entries. + --until=DATE convert only the logs older than DATE. + --ignore-matching=PAT ignore commit messages whose first lines match PAT. + --ignore-line=PAT ignore lines of commit messages that match PAT. + --format=FMT set format string for commit subject and body; + see 'man git-log' for the list of format metacharacters; + the default is '%s%n%b%n' + --strip-tab remove one additional leading TAB from commit message lines. + --strip-cherry-pick remove data inserted by "git cherry-pick"; + this includes the "cherry picked from commit ..." line, + and the possible final "Conflicts:" paragraph. + --help display this help and exit + --version output version information and exit + +EXAMPLE: + + $ME --since=2008-01-01 > ChangeLog + $ME -- -n 5 foo > last-5-commits-to-branch-foo + +SPECIAL SYNTAX: + +The following types of strings are interpreted specially when they appear +at the beginning of a log message line. They are not copied to the output. + + Copyright-paperwork-exempt: Yes + Append the "(tiny change)" notation to the usual "date name email" + ChangeLog header to mark a change that does not require a copyright + assignment. + Co-authored-by: Joe User <user\@example.com> + List the specified name and email address on a second + ChangeLog header, denoting a co-author. + Signed-off-by: Joe User <user\@example.com> + These lines are simply elided. + +In a FILE specified via --amend, comment lines (starting with "#") are ignored. +FILE must consist of <SHA,CODE+> pairs where SHA is a 40-byte SHA1 (alone on +a line) referring to a commit in the current project, and CODE refers to one +or more consecutive lines of Perl code. Pairs must be separated by one or +more blank line. + +Here is sample input for use with --amend=FILE, from coreutils: + +3a169f4c5d9159283548178668d2fae6fced3030 +# fix typo in title: +s/all tile types/all file types/ + +1379ed974f1fa39b12e2ffab18b3f7a607082202 +# Due to a bug in vc-dwim, I mis-attributed a patch by Paul to myself. +# Change the author to be Paul. Note the escaped "@": +s,Jim .*>,Paul Eggert <eggert\\\@cs.ucla.edu>, + +EOF + } + exit $exit_code; +} + +# If the string $S is a well-behaved file name, simply return it. +# If it contains white space, quotes, etc., quote it, and return the new string. +sub shell_quote($) +{ + my ($s) = @_; + if ($s =~ m![^\w+/.,-]!) + { + # Convert each single quote to '\'' + $s =~ s/\'/\'\\\'\'/g; + # Then single quote the string. + $s = "'$s'"; + } + return $s; +} + +sub quoted_cmd(@) +{ + return join (' ', map {shell_quote $_} @_); +} + +# Parse file F. +# Comment lines (starting with "#") are ignored. +# F must consist of <SHA,CODE+> pairs where SHA is a 40-byte SHA1 +# (alone on a line) referring to a commit in the current project, and +# CODE refers to one or more consecutive lines of Perl code. +# Pairs must be separated by one or more blank line. +sub parse_amend_file($) +{ + my ($f) = @_; + + open F, '<', $f + or die "$ME: $f: failed to open for reading: $!\n"; + + my $fail; + my $h = {}; + my $in_code = 0; + my $sha; + while (defined (my $line = <F>)) + { + $line =~ /^\#/ + and next; + chomp $line; + $line eq '' + and $in_code = 0, next; + + if (!$in_code) + { + $line =~ /^([[:xdigit:]]{40})$/ + or (warn "$ME: $f:$.: invalid line; expected an SHA1\n"), + $fail = 1, next; + $sha = lc $1; + $in_code = 1; + exists $h->{$sha} + and (warn "$ME: $f:$.: duplicate SHA1\n"), + $fail = 1, next; + } + else + { + $h->{$sha} ||= ''; + $h->{$sha} .= "$line\n"; + } + } + close F; + + $fail + and exit 1; + + return $h; +} + +# git_dir_option $SRCDIR +# +# From $SRCDIR, the --git-dir option to pass to git (none if $SRCDIR +# is undef). Return as a list (0 or 1 element). +sub git_dir_option($) +{ + my ($srcdir) = @_; + my @res = (); + if (defined $srcdir) + { + my $qdir = shell_quote $srcdir; + my $cmd = "cd $qdir && git rev-parse --show-toplevel"; + my $qcmd = shell_quote $cmd; + my $git_dir = qx($cmd); + defined $git_dir + or die "$ME: cannot run $qcmd: $!\n"; + $? == 0 + or die "$ME: $qcmd had unexpected exit code or signal ($?)\n"; + chomp $git_dir; + push @res, "--git-dir=$git_dir/.git"; + } + @res; +} + +{ + my $since_date; + my $until_date; + my $format_string = '%s%n%b%n'; + my $amend_file; + my $append_dot = 0; + my $cluster = 1; + my $ignore_matching; + my $ignore_line; + my $strip_tab = 0; + my $strip_cherry_pick = 0; + my $srcdir; + GetOptions + ( + help => sub { usage 0 }, + version => sub { print "$ME version $VERSION\n"; exit }, + 'since=s' => \$since_date, + 'until=s' => \$until_date, + 'format=s' => \$format_string, + 'amend=s' => \$amend_file, + 'append-dot' => \$append_dot, + 'cluster!' => \$cluster, + 'ignore-matching=s' => \$ignore_matching, + 'ignore-line=s' => \$ignore_line, + 'strip-tab' => \$strip_tab, + 'strip-cherry-pick' => \$strip_cherry_pick, + 'srcdir=s' => \$srcdir, + ) or usage 1; + + defined $since_date + and unshift @ARGV, "--since=$since_date"; + defined $until_date + and unshift @ARGV, "--until=$until_date"; + + # This is a hash that maps an SHA1 to perl code (i.e., s/old/new/) + # that makes a correction in the log or attribution of that commit. + my $amend_code = defined $amend_file ? parse_amend_file $amend_file : {}; + + my @cmd = ('git', + git_dir_option $srcdir, + qw(log --log-size), + '--pretty=format:%H:%ct %an <%ae>%n%n'.$format_string, @ARGV); + open PIPE, '-|', @cmd + or die ("$ME: failed to run '". quoted_cmd (@cmd) ."': $!\n" + . "(Is your Git too old? Version 1.5.1 or later is required.)\n"); + + my $prev_multi_paragraph; + my $prev_date_line = ''; + my @prev_coauthors = (); + my @skipshas = (); + while (1) + { + defined (my $in = <PIPE>) + or last; + $in =~ /^log size (\d+)$/ + or die "$ME:$.: Invalid line (expected log size):\n$in"; + my $log_nbytes = $1; + + my $log; + my $n_read = read PIPE, $log, $log_nbytes; + $n_read == $log_nbytes + or die "$ME:$.: unexpected EOF\n"; + + # Extract leading hash. + my ($sha, $rest) = split ':', $log, 2; + defined $sha + or die "$ME:$.: malformed log entry\n"; + $sha =~ /^[[:xdigit:]]{40}$/ + or die "$ME:$.: invalid SHA1: $sha\n"; + + my $skipflag = 0; + if (@skipshas) + { + foreach(@skipshas) + { + if ($sha =~ /^$_/) + { + $skipflag = $_; + last; + } + } + } + + # If this commit's log requires any transformation, do it now. + my $code = $amend_code->{$sha}; + if (defined $code) + { + eval 'use Safe'; + my $s = new Safe; + # Put the unpreprocessed entry into "$_". + $_ = $rest; + + # Let $code operate on it, safely. + my $r = $s->reval("$code") + or die "$ME:$.:$sha: failed to eval \"$code\":\n$@\n"; + + # Note that we've used this entry. + delete $amend_code->{$sha}; + + # Update $rest upon success. + $rest = $_; + } + + # Remove lines inserted by "git cherry-pick". + if ($strip_cherry_pick) + { + $rest =~ s/^\s*Conflicts:\n.*//sm; + $rest =~ s/^\s*\(cherry picked from commit [\da-f]+\)\n//m; + } + + my @line = split /[ \t]*\n/, $rest; + my $author_line = shift @line; + defined $author_line + or die "$ME:$.: unexpected EOF\n"; + $author_line =~ /^(\d+) (.*>)$/ + or die "$ME:$.: Invalid line " + . "(expected date/author/email):\n$author_line\n"; + + # Format 'Copyright-paperwork-exempt: Yes' as a standard ChangeLog + # '(tiny change)' annotation. + my $tiny = (grep (/^(?:Copyright-paperwork-exempt|Tiny-change):\s+[Yy]es$/, @line) + ? ' (tiny change)' : ''); + + my $date_line = sprintf "%s %s$tiny\n", + strftime ("%Y-%m-%d", localtime ($1)), $2; + + my @coauthors = grep /^Co-authored-by:.*$/, @line; + # Omit meta-data lines we've already interpreted. + @line = grep !/^(?:Signed-off-by:[ ].*>$ + |Co-authored-by:[ ] + |Copyright-paperwork-exempt:[ ] + |Tiny-change:[ ] + )/x, @line; + + # Remove leading and trailing blank lines. + if (@line) + { + while ($line[0] =~ /^\s*$/) { shift @line; } + while ($line[$#line] =~ /^\s*$/) { pop @line; } + } + + # Handle Emacs gitmerge.el "skipped" commits. + # Yes, this should be controlled by an option. So sue me. + if ( grep /^(; )?Merge from /, @line ) + { + my $found = 0; + foreach (@line) + { + if (grep /^The following commit.*skipped:$/, $_) + { + $found = 1; + ## Reset at each merge to reduce chance of false matches. + @skipshas = (); + next; + } + if ($found && $_ =~ /^([[:xdigit:]]{7,}) [^ ]/) + { + push ( @skipshas, $1 ); + } + } + } + + # Ignore commits that match the --ignore-matching pattern, if specified. + if (defined $ignore_matching && @line && $line[0] =~ /$ignore_matching/) + { + $skipflag = 1; + } + elsif ($skipflag) + { + ## Perhaps only warn if a pattern matches more than once? + warn "$ME: warning: skipping $sha due to $skipflag\n"; + } + + if (! $skipflag) + { + if (defined $ignore_line && @line) + { + @line = grep ! /$ignore_line/, @line; + while ($line[$#line] =~ /^\s*$/) { pop @line; } + } + + # Record whether there are two or more paragraphs. + my $multi_paragraph = grep /^\s*$/, @line; + + # Format 'Co-authored-by: A U Thor <email@example.com>' lines in + # standard multi-author ChangeLog format. + for (@coauthors) + { + s/^Co-authored-by:\s*/\t /; + s/\s*</ </; + + /<.*?@.*\..*>/ + or warn "$ME: warning: missing email address for " + . substr ($_, 5) . "\n"; + } + + # If clustering of commit messages has been disabled, if this header + # would be different from the previous date/name/etc. header, + # or if this or the previous entry consists of two or more paragraphs, + # then print the header. + if ( ! $cluster + || $date_line ne $prev_date_line + || "@coauthors" ne "@prev_coauthors" + || $multi_paragraph + || $prev_multi_paragraph) + { + $prev_date_line eq '' + or print "\n"; + print $date_line; + @coauthors + and print join ("\n", @coauthors), "\n"; + } + $prev_date_line = $date_line; + @prev_coauthors = @coauthors; + $prev_multi_paragraph = $multi_paragraph; + + # If there were any lines + if (@line == 0) + { + warn "$ME: warning: empty commit message:\n" + . " commit $sha\n $date_line\n"; + } + else + { + if ($append_dot) + { + # If the first line of the message has enough room, then + if (length $line[0] < 72) + { + # append a dot if there is no other punctuation or blank + # at the end. + $line[0] =~ /[[:punct:]\s]$/ + or $line[0] .= '.'; + } + } + + # Remove one additional leading TAB from each line. + $strip_tab + and map { s/^\t// } @line; + + # Prefix each non-empty line with a TAB. + @line = map { length $_ ? "\t$_" : '' } @line; + + print "\n", join ("\n", @line), "\n"; + } + } + + defined ($in = <PIPE>) + or last; + $in ne "\n" + and die "$ME:$.: unexpected line:\n$in"; + } + + close PIPE + or die "$ME: error closing pipe from " . quoted_cmd (@cmd) . "\n"; + # FIXME-someday: include $PROCESS_STATUS in the diagnostic + + # Complain about any unused entry in the --amend=F specified file. + my $fail = 0; + foreach my $sha (keys %$amend_code) + { + warn "$ME:$amend_file: unused entry: $sha\n"; + $fail = 1; + } + + exit $fail; +} + +# Local Variables: +# mode: perl +# indent-tabs-mode: nil +# eval: (add-hook 'before-save-hook 'time-stamp) +# time-stamp-line-limit: 50 +# time-stamp-start: "my $VERSION = '" +# time-stamp-format: "%:y-%02m-%02d %02H:%02M" +# time-stamp-time-zone: "UTC0" +# time-stamp-end: "'; # UTC" +# End: diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/build-aux/gnu-web-doc-update b/gnulib-tool-tests/import-tests/test-diffutils-1.result/build-aux/gnu-web-doc-update new file mode 100755 index 00000000..b51fc101 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/build-aux/gnu-web-doc-update @@ -0,0 +1,216 @@ +#!/bin/sh +# Run this after each non-alpha release, to update the web documentation at +# https://www.gnu.org/software/$pkg/manual/ + +VERSION=2023-09-11.20; # UTC + +# Copyright (C) 2009-2024 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/>. + +ME=$(basename "$0") +warn() { printf '%s: %s\n' "$ME" "$*" >&2; } +die() { warn "$*"; exit 1; } + +help() +{ + cat <<EOF +Usage: $ME + +Run this script from top_srcdir (no arguments) after each non-alpha +release, to update the web documentation at +https://www.gnu.org/software/\$pkg/manual/ + +This script assumes you're using git for revision control, and +requires a .prev-version file as well as a Makefile, from which it +extracts the version number and package name, respectively. Also, it +assumes all documentation is in the doc/ sub-directory. + +Options: + -C, --builddir=DIR location of (configured) Makefile (default: .) + -n, --dry-run don't actually commit anything + -m, --mirror remove out of date files from document server + -u, --user the name of the CVS user on Savannah + --help print this help, then exit + --version print version number, then exit + +Report bugs and patches to <bug-gnulib@gnu.org>. +EOF + exit +} + +version() +{ + year=$(echo "$VERSION" | sed 's/[^0-9].*//') + cat <<EOF +$ME $VERSION +Copyright (C) $year Free Software Foundation, Inc, +License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html> +This is free software: you are free to change and redistribute it. +There is NO WARRANTY, to the extent permitted by law. +EOF + exit +} + +# find_tool ENVVAR NAMES... +# ------------------------- +# Search for a required program. Use the value of ENVVAR, if set, +# otherwise find the first of the NAMES that can be run (i.e., +# supports --version). If found, set ENVVAR to the program name, +# die otherwise. +# +# FIXME: code duplication, see also bootstrap. +find_tool () +{ + find_tool_envvar=$1 + shift + find_tool_names=$@ + eval "find_tool_res=\$$find_tool_envvar" + if test x"$find_tool_res" = x; then + for i + do + if ($i --version </dev/null) >/dev/null 2>&1; then + find_tool_res=$i + break + fi + done + else + find_tool_error_prefix="\$$find_tool_envvar: " + fi + test x"$find_tool_res" != x \ + || die "one of these is required: $find_tool_names" + ($find_tool_res --version </dev/null) >/dev/null 2>&1 \ + || die "${find_tool_error_prefix}cannot run $find_tool_res --version" + eval "$find_tool_envvar=\$find_tool_res" + eval "export $find_tool_envvar" +} + +## ------ ## +## Main. ## +## ------ ## + +# Requirements: everything required to bootstrap your package, plus +# these. +find_tool CVS cvs +find_tool GIT git +find_tool RSYNC rsync +find_tool XARGS gxargs xargs + +builddir=. +dryrun= +rm_stale='echo' +cvs_user="$USER" +while test $# != 0 +do + # Handle --option=value by splitting apart and putting back on argv. + case $1 in + --*=*) + opt=$(echo "$1" | sed -e 's/=.*//') + val=$(echo "$1" | sed -e 's/[^=]*=//') + shift + set dummy "$opt" "$val" "$@"; shift + ;; + esac + + case $1 in + --help|--version) ${1#--};; + -C|--builddir) shift; builddir=$1; shift ;; + -n|--dry-run) dryrun=echo; shift;; + -m|--mirror) rm_stale=''; shift;; + -u|--user) shift; cvs_user=$1; shift ;; + --*) die "unrecognized option: $1";; + *) break;; + esac +done + +test $# = 0 \ + || die "too many arguments" + +prev=.prev-version +version=$(cat $prev) || die "no $prev file?" +pkg=$(sed -n 's/^PACKAGE = \(.*\)/\1/p' $builddir/Makefile) \ + || die "no Makefile?" +tmp_branch=web-doc-$version-$$ +current_branch=$($GIT branch | sed -ne '/^\* /{s///;p;q;}') + +cleanup() +{ + __st=$? + $dryrun rm -rf "$tmp" + $GIT checkout "$current_branch" + $GIT submodule update --recursive + $GIT branch -d $tmp_branch + exit $__st +} +trap cleanup EXIT +trap 'exit $?' HUP INT PIPE TERM + +# We must build using sources for which --version reports the +# just-released version number, not some string like 7.6.18-20761. +# That version string propagates into all documentation. +set -e +$GIT checkout -b $tmp_branch v$version +$GIT submodule update --recursive +./bootstrap +srcdir=$(pwd) +cd "$builddir" +builddir=$(pwd) + ./config.status --recheck + ./config.status + make + make web-manual +cd "$srcdir" +set +e + +tmp=$(mktemp -d web-doc-update.XXXXXX) || exit 1 +( cd $tmp \ + && $CVS -d $cvs_user@cvs.savannah.gnu.org:/webcvs/$pkg co $pkg ) +$RSYNC -avP "$builddir"/doc/manual/ $tmp/$pkg/manual + +( + cd $tmp/$pkg + test -d manual/CVS || $dryrun $CVS add -ko manual + + cd manual + + # Add all the files. This is simpler than trying to add only the + # new ones because of new directories + # First add non empty dirs individually + find . -name CVS -prune -o -type d \! -empty -print \ + | $XARGS -n1 --no-run-if-empty -- $dryrun $CVS add -ko + # Now add all files + find . -name CVS -prune -o -type f -print \ + | $XARGS --no-run-if-empty -- $dryrun $CVS add -ko + + # Report/Remove stale files + # excluding doc server specific files like CVS/* and .symlinks + if test -n "$rm_stale"; then + echo 'Consider the --mirror option if all of the manual is generated,' >&2 + echo 'which will run `cvs remove` to remove stale files.' >&2 + fi + { find . \( -name CVS -o -type f -name '.*' \) -prune -o -type f -print + (cd "$builddir"/doc/manual/ && find . -type f -print | sed p) + } | sort | uniq -u \ + | $XARGS --no-run-if-empty -- ${rm_stale:-$dryrun} $CVS remove -f + + $dryrun $CVS ci -m $version +) + +# Local variables: +# eval: (add-hook 'before-save-hook 'time-stamp) +# time-stamp-start: "VERSION=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC0" +# time-stamp-end: "; # UTC" +# End: diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/build-aux/gnupload b/gnulib-tool-tests/import-tests/test-diffutils-1.result/build-aux/gnupload new file mode 100755 index 00000000..298a6766 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/build-aux/gnupload @@ -0,0 +1,480 @@ +#!/bin/sh +# Sign files and upload them. + +scriptversion=2022-01-27.18; # UTC + +# Copyright (C) 2004-2024 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. + +# Originally written by Alexandre Duret-Lutz <adl@gnu.org>. +# The master copy of this file is maintained in the gnulib Git repository. +# Please send bug reports and feature requests to bug-gnulib@gnu.org. + +set -e + +GPG=gpg +# Choose the proper version of gpg, so as to avoid a +# "gpg-agent is not available in this session" error +# when gpg-agent is version 2 but gpg is still version 1. +# FIXME-2020: remove, once all major distros ship gpg version 2 as /usr/bin/gpg +gpg_agent_version=`(gpg-agent --version) 2>/dev/null | sed -e '2,$d' -e 's/^[^0-9]*//'` +case "$gpg_agent_version" in + 2.*) + gpg_version=`(gpg --version) 2>/dev/null | sed -e '2,$d' -e 's/^[^0-9]*//'` + case "$gpg_version" in + 1.*) + if (type gpg2) >/dev/null 2>/dev/null; then + # gpg2 is present. + GPG=gpg2 + else + # gpg2 is missing. Ubuntu users should install the package 'gnupg2'. + echo "WARNING: Using 'gpg', which is too old. You should install 'gpg2'." 1>&2 + fi + ;; + esac + ;; +esac + +GPG="${GPG} --batch --no-tty" +conffile=.gnuploadrc +to= +dry_run=false +replace= +symlink_files= +delete_files= +delete_symlinks= +collect_var= +dbg= +nl=' +' + +usage="Usage: $0 [OPTION]... [CMD] FILE... [[CMD] FILE...] + +Sign all FILES, and process them at the destinations specified with --to. +If CMD is not given, it defaults to uploading. See examples below. + +Commands: + --delete delete FILES from destination + --symlink create symbolic links + --rmsymlink remove symbolic links + -- treat the remaining arguments as files to upload + +Options: + --to DEST specify a destination DEST for FILES + (multiple --to options are allowed) + --user NAME sign with key NAME + --replace allow replacements of existing files + --symlink-regex[=EXPR] use sed script EXPR to compute symbolic link names + -n, --dry-run do nothing, show what would have been done + (including the constructed directive file) + --version output version information and exit + -h, --help print this help text and exit + +If --symlink-regex is given without EXPR, then the link target name +is created by replacing the version information with '-latest', e.g.: + foo-1.3.4.tar.gz -> foo-latest.tar.gz + +Recognized destinations are: + alpha.gnu.org:DIRECTORY + savannah.gnu.org:DIRECTORY + savannah.nongnu.org:DIRECTORY + ftp.gnu.org:DIRECTORY + build directive files and upload files by FTP + download.gnu.org.ua:{alpha|ftp}/DIRECTORY + build directive files and upload files by SFTP + [user@]host:DIRECTORY upload files with scp + +Options and commands are applied in order. If the file $conffile exists +in the current working directory, its contents are prepended to the +actual command line options. Use this to keep your defaults. Comments +(#) and empty lines in $conffile are allowed. + +<https://www.gnu.org/prep/maintain/html_node/Automated-FTP-Uploads.html> +gives some further background. + +Examples: +1. Upload foobar-1.0.tar.gz to ftp.gnu.org: + gnupload --to ftp.gnu.org:foobar foobar-1.0.tar.gz + +2. Upload foobar-1.0.tar.gz and foobar-1.0.tar.xz to ftp.gnu.org: + gnupload --to ftp.gnu.org:foobar foobar-1.0.tar.gz foobar-1.0.tar.xz + +3. Same as above, and also create symbolic links to foobar-latest.tar.*: + gnupload --to ftp.gnu.org:foobar \\ + --symlink-regex \\ + foobar-1.0.tar.gz foobar-1.0.tar.xz + +4. Create a symbolic link foobar-latest.tar.gz -> foobar-1.0.tar.gz + and likewise for the corresponding .sig file: + gnupload --to ftp.gnu.org:foobar \\ + --symlink foobar-1.0.tar.gz foobar-latest.tar.gz \\ + foobar-1.0.tar.gz.sig foobar-latest.tar.gz.sig + or (equivalent): + gnupload --to ftp.gnu.org:foobar \\ + --symlink foobar-1.0.tar.gz foobar-latest.tar.gz \\ + --symlink foobar-1.0.tar.gz.sig foobar-latest.tar.gz.sig + +5. Upload foobar-0.9.90.tar.gz to two sites: + gnupload --to alpha.gnu.org:foobar \\ + --to sources.redhat.com:~ftp/pub/foobar \\ + foobar-0.9.90.tar.gz + +6. Delete oopsbar-0.9.91.tar.gz and upload foobar-0.9.91.tar.gz + (the -- terminates the list of files to delete): + gnupload --to alpha.gnu.org:foobar \\ + --to sources.redhat.com:~ftp/pub/foobar \\ + --delete oopsbar-0.9.91.tar.gz \\ + -- foobar-0.9.91.tar.gz + +gnupload executes a program ncftpput to do the transfers; if you don't +happen to have an ncftp package installed, the ncftpput-ftp script in +the build-aux/ directory of the gnulib package +(https://savannah.gnu.org/projects/gnulib) may serve as a replacement. + +Send patches and bug reports to <bug-gnulib@gnu.org>." + +copyright_year=`echo "$scriptversion" | sed -e 's/[^0-9].*//'` +copyright="Copyright (C) ${copyright_year} Free Software Foundation, Inc. +License GPLv2+: GNU GPL version 2 or later <https://gnu.org/licenses/gpl.html>. +This is free software: you are free to change and redistribute it. +There is NO WARRANTY, to the extent permitted by law." + +# Read local configuration file +if test -r "$conffile"; then + echo "$0: Reading configuration file $conffile" + conf=`sed 's/#.*$//;/^$/d' "$conffile" | tr "\015$nl" ' '` + eval set x "$conf \"\$@\"" + shift +fi + +while test -n "$1"; do + case $1 in + -*) + collect_var= + case $1 in + -h | --help) + echo "$usage" + exit $? + ;; + --to) + if test -z "$2"; then + echo "$0: Missing argument for --to" 1>&2 + exit 1 + elif echo "$2" | grep 'ftp-upload\.gnu\.org' >/dev/null; then + echo "$0: Use ftp.gnu.org:PKGNAME or alpha.gnu.org:PKGNAME" >&2 + echo "$0: for the destination, not ftp-upload.gnu.org (which" >&2 + echo "$0: is used for direct ftp uploads, not with gnupload)." >&2 + echo "$0: See --help and its examples if need be." >&2 + exit 1 + else + to="$to $2" + shift + fi + ;; + --user) + if test -z "$2"; then + echo "$0: Missing argument for --user" 1>&2 + exit 1 + else + GPG="$GPG --local-user $2" + shift + fi + ;; + --delete) + collect_var=delete_files + ;; + --replace) + replace="replace: true" + ;; + --rmsymlink) + collect_var=delete_symlinks + ;; + --symlink-regex=*) + symlink_expr=`expr "$1" : '[^=]*=\(.*\)'` + ;; + --symlink-regex) + symlink_expr='s|-[0-9][0-9\.]*\(-[0-9][0-9]*\)\{0,1\}\.|-latest.|' + ;; + --symlink) + collect_var=symlink_files + ;; + -n | --dry-run) + dry_run=: + ;; + --version) + echo "gnupload $scriptversion" + echo "$copyright" + exit 0 + ;; + --) + shift + break + ;; + -*) + echo "$0: Unknown option '$1', try '$0 --help'" 1>&2 + exit 1 + ;; + esac + ;; + *) + if test -z "$collect_var"; then + break + else + eval "$collect_var=\"\$$collect_var $1\"" + fi + ;; + esac + shift +done + +dprint() +{ + echo "Running $* ..." +} + +if $dry_run; then + dbg=dprint +fi + +if test -z "$to"; then + echo "$0: Missing destination sites" >&2 + exit 1 +fi + +if test -n "$symlink_files"; then + x=`echo "$symlink_files" | sed 's/[^ ]//g;s/ //g'` + if test -n "$x"; then + echo "$0: Odd number of symlink arguments" >&2 + exit 1 + fi +fi + +if test $# = 0; then + if test -z "${symlink_files}${delete_files}${delete_symlinks}"; then + echo "$0: No file to upload" 1>&2 + exit 1 + fi +else + # Make sure all files exist. We don't want to ask + # for the passphrase if the script will fail. + for file + do + if test ! -f $file; then + echo "$0: Cannot find '$file'" 1>&2 + exit 1 + elif test -n "$symlink_expr"; then + linkname=`echo $file | sed "$symlink_expr"` + if test -z "$linkname"; then + echo "$0: symlink expression produces empty results" >&2 + exit 1 + elif test "$linkname" = $file; then + echo "$0: symlink expression does not alter file name" >&2 + exit 1 + fi + fi + done +fi + +# Make sure passphrase is not exported in the environment. +unset passphrase +unset passphrase_fd_0 +GNUPGHOME=${GNUPGHOME:-$HOME/.gnupg} + +# Reset PATH to be sure that echo is a built-in. We will later use +# 'echo $passphrase' to output the passphrase, so it is important that +# it is a built-in (third-party programs tend to appear in 'ps' +# listings with their arguments...). +# Remember this script runs with 'set -e', so if echo is not built-in +# it will exit now. +if $dry_run || grep -q "^use-agent" $GNUPGHOME/gpg.conf; then :; else + PATH=/empty echo -n "Enter GPG passphrase: " + stty -echo + read -r passphrase + stty echo + echo + passphrase_fd_0="--passphrase-fd 0" +fi + +if test $# -ne 0; then + for file + do + echo "Signing $file ..." + rm -f $file.sig + echo "$passphrase" | $dbg $GPG $passphrase_fd_0 -ba -o $file.sig $file + done +fi + + +# mkdirective DESTDIR BASE FILE STMT +# Arguments: See upload, below +mkdirective () +{ + stmt="$4" + if test -n "$3"; then + stmt=" +filename: $3$stmt" + fi + + cat >${2}.directive<<EOF +version: 1.2 +directory: $1 +comment: gnupload v. $scriptversion$stmt +EOF + if $dry_run; then + echo "File ${2}.directive:" + cat ${2}.directive + echo "File ${2}.directive:" | sed 's/./-/g' + fi +} + +mksymlink () +{ + while test $# -ne 0 + do + echo "symlink: $1 $2" + shift + shift + done +} + +# upload DEST DESTDIR BASE FILE STMT FILES +# Arguments: +# DEST Destination site; +# DESTDIR Destination directory; +# BASE Base name for the directive file; +# FILE Name of the file to distribute (may be empty); +# STMT Additional statements for the directive file; +# FILES List of files to upload. +upload () +{ + dest=$1 + destdir=$2 + base=$3 + file=$4 + stmt=$5 + files=$6 + + rm -f $base.directive $base.directive.asc + case $dest in + alpha.gnu.org:*) + mkdirective "$destdir" "$base" "$file" "$stmt" + echo "$passphrase" | $dbg $GPG $passphrase_fd_0 --clearsign $base.directive + $dbg ncftpput ftp-upload.gnu.org /incoming/alpha $files $base.directive.asc + ;; + ftp.gnu.org:*) + mkdirective "$destdir" "$base" "$file" "$stmt" + echo "$passphrase" | $dbg $GPG $passphrase_fd_0 --clearsign $base.directive + $dbg ncftpput ftp-upload.gnu.org /incoming/ftp $files $base.directive.asc + ;; + savannah.gnu.org:*) + if test -z "$files"; then + echo "$0: warning: standalone directives not applicable for $dest" >&2 + fi + $dbg ncftpput savannah.gnu.org /incoming/savannah/$destdir $files + ;; + savannah.nongnu.org:*) + if test -z "$files"; then + echo "$0: warning: standalone directives not applicable for $dest" >&2 + fi + $dbg ncftpput savannah.nongnu.org /incoming/savannah/$destdir $files + ;; + download.gnu.org.ua:alpha/*|download.gnu.org.ua:ftp/*) + destdir_p1=`echo "$destdir" | sed 's,^[^/]*/,,'` + destdir_topdir=`echo "$destdir" | sed 's,/.*,,'` + mkdirective "$destdir_p1" "$base" "$file" "$stmt" + echo "$passphrase" | $dbg $GPG $passphrase_fd_0 --clearsign $base.directive + for f in $files $base.directive.asc + do + echo put $f + done | $dbg sftp -b - download.gnu.org.ua:/incoming/$destdir_topdir + ;; + /*) + dest_host=`echo "$dest" | sed 's,:.*,,'` + mkdirective "$destdir" "$base" "$file" "$stmt" + echo "$passphrase" | $dbg $GPG $passphrase_fd_0 --clearsign $base.directive + $dbg cp $files $base.directive.asc $dest_host + ;; + *) + if test -z "$files"; then + echo "$0: warning: standalone directives not applicable for $dest" >&2 + fi + $dbg scp $files $dest + ;; + esac + rm -f $base.directive $base.directive.asc +} + +##### +# Process any standalone directives +stmt= +if test -n "$symlink_files"; then + stmt="$stmt +`mksymlink $symlink_files`" +fi + +for file in $delete_files +do + stmt="$stmt +archive: $file" +done + +for file in $delete_symlinks +do + stmt="$stmt +rmsymlink: $file" +done + +if test -n "$stmt"; then + for dest in $to + do + destdir=`echo $dest | sed 's/[^:]*://'` + upload "$dest" "$destdir" "`hostname`-$$" "" "$stmt" + done +fi + +# Process actual uploads +for dest in $to +do + for file + do + echo "Uploading $file to $dest ..." + stmt= + # + # allowing file replacement is all or nothing. + if test -n "$replace"; then stmt="$stmt +$replace" + fi + # + files="$file $file.sig" + destdir=`echo $dest | sed 's/[^:]*://'` + if test -n "$symlink_expr"; then + linkname=`echo $file | sed "$symlink_expr"` + stmt="$stmt +symlink: $file $linkname +symlink: $file.sig $linkname.sig" + fi + upload "$dest" "$destdir" "$file" "$file" "$stmt" "$files" + done +done + +exit 0 + +# Local variables: +# eval: (add-hook 'before-save-hook 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC0" +# time-stamp-end: "; # UTC" +# End: diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/build-aux/update-copyright b/gnulib-tool-tests/import-tests/test-diffutils-1.result/build-aux/update-copyright new file mode 100755 index 00000000..efda7548 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/build-aux/update-copyright @@ -0,0 +1,307 @@ +#!/bin/sh +#! -*-perl-*- + +# Update an FSF copyright year list to include the current year. + +# Copyright (C) 2009-2024 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 Jim Meyering and Joel E. Denny + +# This script updates an FSF copyright year list to include the current year. +# Usage: update-copyright [FILE...] +# +# The arguments to this script should be names of files that contain +# copyright statements to be updated. The copyright holder's name +# defaults to "Free Software Foundation, Inc." but may be changed to +# any other name by using the "UPDATE_COPYRIGHT_HOLDER" environment +# variable. +# +# For example, you might wish to use the update-copyright target rule +# in maint.mk from gnulib's maintainer-makefile module. +# +# Iff a copyright statement is recognized in a file and the final +# year is not the current year, then the statement is updated for the +# new year and it is reformatted to: +# +# 1. Fit within 72 columns. +# 2. Convert 2-digit years to 4-digit years by prepending "19". +# 3. Expand copyright year intervals. (See "Environment variables" +# below.) +# +# A warning is printed for every file for which no copyright +# statement is recognized. +# +# Each file's copyright statement must be formatted correctly in +# order to be recognized. For example, each of these is fine: +# +# Copyright @copyright{} 1990-2005, 2007-2009 Free Software +# Foundation, Inc. +# +# # Copyright (C) 1990-2005, 2007-2009 Free Software +# # Foundation, Inc. +# +# /* +# * Copyright © 90,2005,2007-2009 +# * Free Software Foundation, Inc. +# */ +# +# However, the following format is not recognized because the line +# prefix changes after the first line: +# +# ## Copyright (C) 1990-2005, 2007-2009 Free Software +# # Foundation, Inc. +# +# However, any correctly formatted copyright statement following +# a non-matching copyright statements would be recognized. +# +# The exact conditions that a file's copyright statement must meet +# to be recognized are: +# +# 1. It is the first copyright statement that meets all of the +# following conditions. Subsequent copyright statements are +# ignored. +# 2. Its format is "Copyright (C)", then a list of copyright years, +# and then the name of the copyright holder. +# 3. The "(C)" takes one of the following forms or is omitted +# entirely: +# +# A. (C) +# B. (c) +# C. @copyright{} +# D. © +# E. © +# +# 4. The "Copyright" appears at the beginning of a line, except that it +# may be prefixed by any sequence (e.g., a comment) of no more than +# 5 characters -- including white space. +# 5. Iff such a prefix is present, the same prefix appears at the +# beginning of each remaining line within the FSF copyright +# statement. There is one exception in order to support C-style +# comments: if the first line's prefix contains nothing but +# whitespace surrounding a "/*", then the prefix for all subsequent +# lines is the same as the first line's prefix except with each of +# "/" and possibly "*" replaced by a " ". The replacement of "*" +# by " " is consistent throughout all subsequent lines. +# 6. Blank lines, even if preceded by the prefix, do not appear +# within the FSF copyright statement. +# 7. Each copyright year is 2 or 4 digits, and years are separated by +# commas, "-", "--", or "\(en" (for troff). Whitespace may appear +# after commas. +# +# Environment variables: +# +# 1. If UPDATE_COPYRIGHT_FORCE=1, a recognized FSF copyright statement +# is reformatted even if it does not need updating for the new +# year. If unset or set to 0, only updated FSF copyright +# statements are reformatted. +# 2. If UPDATE_COPYRIGHT_USE_INTERVALS=1, every series of consecutive +# copyright years (such as 90, 1991, 1992-2007, 2008) in a +# reformatted FSF copyright statement is collapsed to a single +# interval (such as 1990-2008). If unset or set to 0, all existing +# copyright year intervals in a reformatted FSF copyright statement +# are expanded instead. +# If UPDATE_COPYRIGHT_USE_INTERVALS=2, convert a sequence with gaps +# to the minimal containing range. For example, convert +# 2000, 2004-2007, 2009 to 2000-2009. +# 3. For testing purposes, you can set the assumed current year in +# UPDATE_COPYRIGHT_YEAR. +# 4. The default maximum line length for a copyright line is 72. +# Set UPDATE_COPYRIGHT_MAX_LINE_LENGTH to use a different length. +# 5. Set UPDATE_COPYRIGHT_HOLDER if the copyright holder is other +# than "Free Software Foundation, Inc.". + +# This is a prologue that allows to run a perl script as an executable +# on systems that are compliant to a POSIX version before POSIX:2017. +# On such systems, the usual invocation of an executable through execlp() +# or execvp() fails with ENOEXEC if it is a script that does not start +# with a #! line. The script interpreter mentioned in the #! line has +# to be /bin/sh, because on GuixSD systems that is the only program that +# has a fixed file name. The second line is essential for perl and is +# also useful for editing this file in Emacs. The next two lines below +# are valid code in both sh and perl. When executed by sh, they re-execute +# the script through the perl program found in $PATH. The '-x' option +# is essential as well; without it, perl would re-execute the script +# through /bin/sh. When executed by perl, the next two lines are a no-op. +eval 'exec perl -wSx -0777 -pi "$0" "$@"' + if 0; + +my $VERSION = '2023-10-03.12:14'; # UTC +# The definition above must lie within the first 8 lines in order +# for the Emacs time-stamp write hook (at end) to update it. +# If you change this file with Emacs, please let the write hook +# do its job. Otherwise, update this string manually. + +use strict; +use warnings; +use re 'eval'; + +my $copyright_re = 'Copyright'; +my $circle_c_re = '(?:\([cC]\)|@copyright\{}|\\\\\(co|©|©)'; +my $ndash_re = '(?:--?|\\\\\(en)'; +my $holder = $ENV{UPDATE_COPYRIGHT_HOLDER}; +$holder ||= 'Free Software Foundation, Inc.'; +my $prefix_max = 5; +my $margin = $ENV{UPDATE_COPYRIGHT_MAX_LINE_LENGTH}; +!$margin || $margin !~ m/^\d+$/ + and $margin = 72; + +my $tab_width = 8; + +my $this_year = $ENV{UPDATE_COPYRIGHT_YEAR}; +if (!$this_year || $this_year !~ m/^\d{4}$/) + { + my ($sec, $min, $hour, $mday, $month, $year) = localtime (time ()); + $this_year = $year + 1900; + } + +# Unless the file consistently uses "\r\n" as the EOL, use "\n" instead. +my $eol = /(?:^|[^\r])\n/ ? "\n" : "\r\n"; + +my $leading; +my $prefix; +my $ws_re; +my $stmt_re; +while (/(^|\n)(.{0,$prefix_max})$copyright_re/g) + { + $leading = "$1$2"; + $prefix = $2; + if ($prefix =~ /^(\s*\/)\*(\s*)$/) + { + $prefix =~ s,/, ,; + my $prefix_ws = $prefix; + $prefix_ws =~ s/\*/ /; # Only whitespace. + if (/\G(?:[^*\n]|\*[^\/\n])*\*?\n$prefix_ws/) + { + $prefix = $prefix_ws; + } + } + $ws_re = '[ \t\r\f]'; # \s without \n + $ws_re = + "(?:$ws_re*(?:$ws_re|\\n" . quotemeta($prefix) . ")$ws_re*)"; + my $holder_re = $holder; + $holder_re =~ s/\s/$ws_re/g; + my $stmt_remainder_re = + "(?:$ws_re$circle_c_re)?" + . "$ws_re(?:(?:\\d\\d)?\\d\\d(?:,$ws_re?|$ndash_re))*" + . "((?:\\d\\d)?\\d\\d)$ws_re$holder_re"; + if (/\G$stmt_remainder_re/) + { + $stmt_re = + quotemeta($leading) . "($copyright_re$stmt_remainder_re)"; + last; + } + } +if (defined $stmt_re) + { + /$stmt_re/ or die; # Should never die. + my $stmt = $1; + my $final_year_orig = $2; + + # Handle two-digit year numbers like "98" and "99". + my $final_year = $final_year_orig; + $final_year <= 99 + and $final_year += 1900; + + if ($final_year != $this_year) + { + # Update the year. + $stmt =~ s/(^|[^\d])$final_year_orig\b/$1$final_year, $this_year/; + } + if ($final_year != $this_year || $ENV{'UPDATE_COPYRIGHT_FORCE'}) + { + # Normalize all whitespace including newline-prefix sequences. + $stmt =~ s/$ws_re/ /g; + + # Put spaces after commas. + $stmt =~ s/, ?/, /g; + + # Convert 2-digit to 4-digit years. + $stmt =~ s/(\b\d\d\b)/19$1/g; + + # Make the use of intervals consistent. + if (!$ENV{UPDATE_COPYRIGHT_USE_INTERVALS}) + { + $stmt =~ s/(\d{4})$ndash_re(\d{4})/join(', ', $1..$2)/eg; + } + else + { + my $ndash = ($ARGV =~ /\.tex(i(nfo)?)?$/ ? "--" + : $ARGV =~ /\.(\d[a-z]*|man)$/ ? "\\(en" + : "-"); + + $stmt =~ + s/ + (\d{4}) + (?: + (,\ |$ndash_re) + ((??{ + if ($2 ne ', ') { '\d{4}'; } + elsif (!$3) { $1 + 1; } + else { $3 + 1; } + })) + )+ + /$1$ndash$3/gx; + + # When it's 2, emit a single range encompassing all year numbers. + $ENV{UPDATE_COPYRIGHT_USE_INTERVALS} == 2 + and $stmt =~ s/(^|[^\d])(\d{4})\b.*(?:[^\d])(\d{4})\b/$1$2$ndash$3/; + } + + # Format within margin. + my $stmt_wrapped; + my $text_margin = $margin - length($prefix); + if ($prefix =~ /^(\t+)/) + { + $text_margin -= length($1) * ($tab_width - 1); + } + while (length $stmt) + { + if (($stmt =~ s/^(.{1,$text_margin})(?: |$)//) + || ($stmt =~ s/^([\S]+)(?: |$)//)) + { + my $line = $1; + $stmt_wrapped .= $stmt_wrapped ? "$eol$prefix" : $leading; + $stmt_wrapped .= $line; + } + else + { + # Should be unreachable, but we don't want an infinite + # loop if it can be reached. + die; + } + } + + # Replace the old copyright statement. + s/$stmt_re/$stmt_wrapped/g; + } + } +else + { + print STDERR "$ARGV: warning: copyright statement not found\n"; + } + +# Hey Emacs! +# Local variables: +# coding: utf-8 +# mode: perl +# indent-tabs-mode: nil +# eval: (add-hook 'before-save-hook 'time-stamp) +# time-stamp-line-limit: 200 +# time-stamp-start: "my $VERSION = '" +# time-stamp-format: "%:y-%02m-%02d.%02H:%02M" +# time-stamp-time-zone: "UTC0" +# time-stamp-end: "'; # UTC" +# End: diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/build-aux/useless-if-before-free b/gnulib-tool-tests/import-tests/test-diffutils-1.result/build-aux/useless-if-before-free new file mode 100755 index 00000000..ac9c8901 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/build-aux/useless-if-before-free @@ -0,0 +1,240 @@ +#!/bin/sh +#! -*-perl-*- + +# Detect instances of "if (p) free (p);". +# Likewise "if (p != 0)", "if (0 != p)", or with NULL; and with braces. + +# Copyright (C) 2008-2024 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 Jim Meyering + +# This is a prologue that allows to run a perl script as an executable +# on systems that are compliant to a POSIX version before POSIX:2017. +# On such systems, the usual invocation of an executable through execlp() +# or execvp() fails with ENOEXEC if it is a script that does not start +# with a #! line. The script interpreter mentioned in the #! line has +# to be /bin/sh, because on GuixSD systems that is the only program that +# has a fixed file name. The second line is essential for perl and is +# also useful for editing this file in Emacs. The next two lines below +# are valid code in both sh and perl. When executed by sh, they re-execute +# the script through the perl program found in $PATH. The '-x' option +# is essential as well; without it, perl would re-execute the script +# through /bin/sh. When executed by perl, the next two lines are a no-op. +eval 'exec perl -wSx "$0" "$@"' + if 0; + +my $VERSION = '2022-01-27 18:51'; # UTC +# The definition above must lie within the first 8 lines in order +# for the Emacs time-stamp write hook (at end) to update it. +# If you change this file with Emacs, please let the write hook +# do its job. Otherwise, update this string manually. + +my $copyright_year = '2022'; + +use strict; +use warnings; +use Getopt::Long; + +(my $ME = $0) =~ s|.*/||; + +# use File::Coda; # https://meyering.net/code/Coda/ +END { + defined fileno STDOUT or return; + close STDOUT and return; + warn "$ME: failed to close standard output: $!\n"; + $? ||= 1; +} + +sub usage ($) +{ + my ($exit_code) = @_; + my $STREAM = ($exit_code == 0 ? *STDOUT : *STDERR); + if ($exit_code != 0) + { + print $STREAM "Try '$ME --help' for more information.\n"; + } + else + { + print $STREAM <<EOF; +Usage: $ME [OPTIONS] FILE... + +Detect any instance in FILE of a useless "if" test before a free call, e.g., +"if (p) free (p);". Any such test may be safely removed without affecting +the semantics of the C code in FILE. Use --name=FOO --name=BAR to also +detect free-like functions named FOO and BAR. + +OPTIONS: + + --list print only the name of each matching FILE (\\0-terminated) + --name=N add name N to the list of \'free\'-like functions to detect; + may be repeated + + --help display this help and exit + --version output version information and exit + +Exit status: + + 0 one or more matches + 1 no match + 2 an error + +EXAMPLE: + +For example, this command prints all removable "if" tests before "free" +and "kfree" calls in the linux kernel sources: + + git ls-files -z |xargs -0 $ME --name=kfree + +EOF + } + exit $exit_code; +} + +sub is_NULL ($) +{ + my ($expr) = @_; + return ($expr eq 'NULL' || $expr eq '0'); +} + +{ + sub EXIT_MATCH {0} + sub EXIT_NO_MATCH {1} + sub EXIT_ERROR {2} + my $err = EXIT_NO_MATCH; + + my $list; + my @name = qw(free); + GetOptions + ( + help => sub { usage 0 }, + version => + sub + { + print "$ME version $VERSION\n"; + print "Copyright (C) $copyright_year Free Software Foundation, Inc.\n"; + print "License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.\n" + . "This is free software: you are free to change and redistribute it.\n" + . "There is NO WARRANTY, to the extent permitted by law.\n"; + print "\n"; + my $author = "Jim Meyering"; + print "Written by $author.\n"; + exit + }, + list => \$list, + 'name=s@' => \@name, + ) or usage 1; + + # Make sure we have the right number of non-option arguments. + # Always tell the user why we fail. + @ARGV < 1 + and (warn "$ME: missing FILE argument\n"), usage EXIT_ERROR; + + my $or = join '|', @name; + my $regexp = qr/(?:$or)/; + + # Set the input record separator. + # Note: this makes it impractical to print line numbers. + $/ = '"'; + + my $found_match = 0; + FILE: + foreach my $file (@ARGV) + { + open FH, '<', $file + or (warn "$ME: can't open '$file' for reading: $!\n"), + $err = EXIT_ERROR, next; + while (defined (my $line = <FH>)) + { + # Skip non-matching lines early to save time + $line =~ /\bif\b/ + or next; + while ($line =~ + /\b(if\s*\(\s*([^)]+?)(?:\s*!=\s*([^)]+?))?\s*\) + # 1 2 3 + (?: \s*$regexp\s*\((?:\s*\([^)]+\))?\s*([^)]+)\)\s*;| + \s*\{\s*$regexp\s*\((?:\s*\([^)]+\))?\s*([^)]+)\)\s*;\s*\}))/sxg) + { + my $all = $1; + my ($lhs, $rhs) = ($2, $3); + my ($free_opnd, $braced_free_opnd) = ($4, $5); + my $non_NULL; + if (!defined $rhs) { $non_NULL = $lhs } + elsif (is_NULL $rhs) { $non_NULL = $lhs } + elsif (is_NULL $lhs) { $non_NULL = $rhs } + else { next } + + # Compare the non-NULL part of the "if" expression and the + # free'd expression, without regard to white space. + $non_NULL =~ tr/ \t//d; + my $e2 = defined $free_opnd ? $free_opnd : $braced_free_opnd; + $e2 =~ tr/ \t//d; + if ($non_NULL eq $e2) + { + $found_match = 1; + $list + and (print "$file\0"), next FILE; + print "$file: $all\n"; + } + } + } + } + continue + { + close FH; + } + + $found_match && $err == EXIT_NO_MATCH + and $err = EXIT_MATCH; + + exit $err; +} + +my $foo = <<'EOF'; +# The above is to *find* them. +# This adjusts them, removing the unnecessary "if (p)" part. + +# FIXME: do something like this as an option (doesn't do braces): +free=xfree +git grep -l -z "$free *(" \ + | xargs -0 useless-if-before-free -l --name="$free" \ + | xargs -0 perl -0x3b -pi -e \ + 's/\bif\s*\(\s*(\S+?)(?:\s*!=\s*(?:0|NULL))?\s*\)\s+('"$free"'\s*\((?:\s*\([^)]+\))?\s*\1\s*\)\s*;)/$2/s' + +# Use the following to remove redundant uses of kfree inside braces. +# Note that -0777 puts perl in slurp-whole-file mode; +# but we have plenty of memory, these days... +free=kfree +git grep -l -z "$free *(" \ + | xargs -0 useless-if-before-free -l --name="$free" \ + | xargs -0 perl -0777 -pi -e \ + 's/\bif\s*\(\s*(\S+?)(?:\s*!=\s*(?:0|NULL))?\s*\)\s*\{\s*('"$free"'\s*\((?:\s*\([^)]+\))?\s*\1\s*\);)\s*\}[^\n]*$/$2/gms' + +Be careful that the result of the above transformation is valid. +If the matched string is followed by "else", then obviously, it won't be. + +When modifying files, refuse to process anything other than a regular file. +EOF + +## Local Variables: +## mode: perl +## indent-tabs-mode: nil +## eval: (add-hook 'before-save-hook 'time-stamp) +## time-stamp-line-limit: 50 +## time-stamp-start: "my $VERSION = '" +## time-stamp-format: "%:y-%02m-%02d %02H:%02M" +## time-stamp-time-zone: "UTC0" +## time-stamp-end: "'; # UTC" +## End: diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/build-aux/vc-list-files b/gnulib-tool-tests/import-tests/test-diffutils-1.result/build-aux/vc-list-files new file mode 100755 index 00000000..70365764 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/build-aux/vc-list-files @@ -0,0 +1,113 @@ +#!/bin/sh +# List version-controlled file names. + +# Print a version string. +scriptversion=2018-03-07.03; # UTC + +# Copyright (C) 2006-2024 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/>. + + +# List the specified version-controlled files. +# With no argument, list them all. With a single DIRECTORY argument, +# list the version-controlled files in that directory. + +# If there's an argument, it must be a single, "."-relative directory name. +# cvsu is part of the cvsutils package: https://www.red-bean.com/cvsutils/ + +postprocess= +case $1 in + --help) cat <<EOF +Usage: $0 [-C SRCDIR] [DIR...] + +Output a list of version-controlled files in DIR (default .), relative to +SRCDIR (default .). SRCDIR must be the top directory of a checkout. + +Options: + --help print this help, then exit + --version print version number, then exit + -C SRCDIR change directory to SRCDIR before generating list + +Report bugs and patches to <bug-gnulib@gnu.org>. +EOF + exit ;; + + --version) + year=`echo "$scriptversion" | sed 's/[^0-9].*//'` + cat <<EOF +vc-list-files $scriptversion +Copyright (C) $year Free Software Foundation, Inc, +License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html> +This is free software: you are free to change and redistribute it. +There is NO WARRANTY, to the extent permitted by law. +EOF + exit ;; + + -C) + test "$2" = . || postprocess="| sed 's|^|$2/|'" + cd "$2" || exit 1 + shift; shift ;; +esac + +test $# = 0 && set . + +for dir +do + if test -d .git || test -f .git; then + test "x$dir" = x. \ + && dir= sed_esc= \ + || { dir="$dir/"; sed_esc=`echo "$dir"|env sed 's,\([\\/]\),\\\\\1,g'`; } + # Ignore git symlinks - either they point into the tree, in which case + # we don't need to visit the target twice, or they point somewhere + # else (often into a submodule), in which case the content does not + # belong to this package. + eval exec git ls-tree -r 'HEAD:"$dir"' \ + \| sed -n '"s/^100[^ ]*./$sed_esc/p"' $postprocess + elif test -d .hg; then + eval exec hg locate '"$dir/*"' $postprocess + elif test -d .bzr; then + test "$postprocess" = '' && postprocess="| sed 's|^\./||'" + eval exec bzr ls -R --versioned '"$dir"' $postprocess + elif test -d CVS; then + test "$postprocess" = '' && postprocess="| sed 's|^\./||'" + if test -x build-aux/cvsu; then + eval build-aux/cvsu --find --types=AFGM '"$dir"' $postprocess + elif (cvsu --help) >/dev/null 2>&1; then + eval cvsu --find --types=AFGM '"$dir"' $postprocess + else + eval awk -F/ \''{ \ + if (!$1 && $3 !~ /^-/) { \ + f=FILENAME; \ + if (f ~ /CVS\/Entries$/) \ + f = substr(f, 1, length(f)-11); \ + print f $2; \ + }}'\'' \ + `find "$dir" -name Entries -print` /dev/null' $postprocess + fi + elif test -d .svn; then + eval exec svn list -R '"$dir"' $postprocess + else + echo "$0: Failed to determine type of version control used in `pwd`" 1>&2 + exit 1 + fi +done + +# Local variables: +# eval: (add-hook 'before-save-hook 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC0" +# time-stamp-end: "; # UTC" +# End: diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/configure.ac b/gnulib-tool-tests/import-tests/test-diffutils-1.result/configure.ac new file mode 100644 index 00000000..1779fcda --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/configure.ac @@ -0,0 +1,182 @@ +# Configure template for GNU Diffutils. + +# Copyright (C) 1994-1995, 1998, 2001-2002, 2004, 2006, 2009-2013, 2015-2023 +# Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +AC_PREREQ([2.64]) + +AC_INIT([GNU diffutils], + m4_esyscmd([build-aux/git-version-gen .tarball-version]), + [bug-diffutils@gnu.org], + [diffutils], + [https://www.gnu.org/software/diffutils/]) + +AC_CONFIG_SRCDIR([src/diff.c]) +AC_CONFIG_AUX_DIR([build-aux]) +AC_CONFIG_MACRO_DIR([m4]) + +AM_INIT_AUTOMAKE([1.11 dist-xz no-dist-gzip subdir-objects + color-tests parallel-tests]) +AM_SILENT_RULES([yes]) # make --enable-silent-rules the default. + +AC_CONFIG_HEADERS([lib/config.h:lib/config.hin]) + +AC_PROG_AWK +AC_PROG_CC +AM_MISSING_PROG([HELP2MAN], [help2man]) +AC_PROG_RANLIB +gl_EARLY +gl_USE_SYSTEM_EXTENSIONS +gl_INIT + +# Ensure VLAs are not used. +# Note -Wvla is implicitly added by gl_MANYWARN_ALL_GCC +AC_DEFINE([GNULIB_NO_VLA], [1], [Define to 1 to disable use of VLAs]) + +# diffutils is single-threaded; optimize for this. +AC_DEFINE([GNULIB_EXCLUDE_SINGLE_THREAD], [1], + ['exclude' code is called only from 1 thread.]) +AC_DEFINE([GNULIB_MBRTOWC_SINGLE_THREAD], [1], + ['mbrtowc', 'mbrtoc32', 'regex' code is called only from 1 thread.]) +AC_DEFINE([GNULIB_REGEX_SINGLE_THREAD], [1], + ['regex' code is called only from 1 thread.]) +AC_DEFINE([GNULIB_WCHAR_SINGLE_LOCALE], [1], + [Locale-sensitive functions are called only after locale is set.]) + +# gl_GCC_VERSION_IFELSE([major], [minor], [run-if-found], [run-if-not-found]) +# ------------------------------------------------ +# If $CPP is gcc-MAJOR.MINOR or newer, then run RUN-IF-FOUND. +# Otherwise, run RUN-IF-NOT-FOUND. +AC_DEFUN([gl_GCC_VERSION_IFELSE], + [AC_PREPROC_IFELSE( + [AC_LANG_PROGRAM( + [[ +#if ($1) < __GNUC__ || (($1) == __GNUC__ && ($2) <= __GNUC_MINOR__) +/* ok */ +#else +# error "your version of gcc is older than $1.$2" +#endif + ]]), + ], [$3], [$4]) + ] +) + +AC_ARG_ENABLE([gcc-warnings], + [AS_HELP_STRING([[--enable-gcc-warnings[=TYPE]]], + [control generation of GCC warnings. The TYPE 'no' disables + warnings (default for non-developer builds); 'yes' generates + cheap warnings if available (default for developer builds); + 'expensive' in addition generates expensive-to-compute warnings + if available.])], + [case $enableval in + no|yes|expensive) ;; + *) AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;; + esac + gl_gcc_warnings=$enableval], + [ + # GCC provides fine-grained control over diagnostics which + # is used in gnulib for example to suppress warnings from + # certain sections of code. So if this is available and + # we're running from a git repo, then auto enable the warnings. + gl_gcc_warnings=no + gl_GCC_VERSION_IFELSE([4], [6], + [test -d "$srcdir"/.git \ + && ! test -f "$srcdir"/.tarball-version \ + && gl_gcc_warnings=yes])] +) + +if test $gl_gcc_warnings != no; then + gl_WARN_ADD([-Werror], [WERROR_CFLAGS]) + AC_SUBST([WERROR_CFLAGS]) + + ew= + AS_IF([test $gl_gcc_warnings != expensive], + [# -fanalyzer and related options slow GCC considerably. + ew="$ew -fanalyzer -Wno-analyzer-malloc-leak"]) + + # This, $nw, is the list of warnings we disable. + nw=$ew + nw="$nw -Winline" # not a correctness warning + nw="$nw -Wstack-protector" # not a correctness warning + + gl_MANYWARN_ALL_GCC([ws]) + gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw]) + for w in $ws; do + gl_WARN_ADD([$w]) + done + gl_WARN_ADD([-Wno-sign-compare]) # Too many false positives + gl_WARN_ADD([-Wno-format-nonliteral]) + + AC_SUBST([WARN_CFLAGS]) + + AH_VERBATIM([FORTIFY_SOURCE], + [/* Enable compile-time and run-time bounds-checking, and some warnings, + without upsetting glibc 2.15+. */ + #if !defined _FORTIFY_SOURCE && defined __OPTIMIZE__ && __OPTIMIZE__ \ + && !defined __MINGW32__ + # define _FORTIFY_SOURCE 2 + #endif + ]) + AC_DEFINE([GNULIB_PORTCHECK], [1], [enable some gnulib portability checks]) +fi + +AC_C_INLINE + +AC_DEFINE([DEFAULT_EDITOR_PROGRAM], ["ed"], + [Name of editor program, unless overridden.]) + +AC_PATH_PROG([PR_PROGRAM], [pr], [""]) +AC_DEFINE_UNQUOTED([PR_PROGRAM], ["$PR_PROGRAM"], [Name of "pr" program.]) + +AC_CHECK_MEMBERS([struct stat.st_blksize]) +AC_CHECK_MEMBERS([struct stat.st_rdev]) +AC_HEADER_DIRENT +AC_HEADER_SYS_WAIT +AC_TYPE_PID_T + +AC_CHECK_FUNCS_ONCE([sigaction sigprocmask]) +if test $ac_cv_func_sigprocmask = no; then + AC_CHECK_FUNCS([sigblock]) +fi +AC_FUNC_FORK + +# When .tarball-version exists, we're building from a tarball +# and must not make man/*.1 files depend on the generated src/version.c, +# because that would induce a requirement to run the help2man perl script. +# We are not yet prepared to make perl a build-from-tarball requirement. +# Hence, here we detect .tarball-version existence. When not present, +# we define a variable to be used in man/Makefile.am to induce the +# proper dependency (so that man/*.1 will be rebuilt upon any version change), +# but not when built from a tarball. +AC_SUBST([SRC_VERSION_C]) +test -f $srcdir/.tarball-version \ + && SRC_VERSION_C= \ + || SRC_VERSION_C=../src/version.c + +AM_GNU_GETTEXT([external], [need-ngettext]) +AM_GNU_GETTEXT_VERSION([0.19.2]) +XGETTEXT="AWK='$AWK' \$(SHELL) \$(top_srcdir)/exgettext $XGETTEXT" + +AC_CONFIG_FILES([ + Makefile doc/Makefile + lib/Makefile + src/Makefile + tests/Makefile + gnulib-tests/Makefile + man/Makefile + po/Makefile.in +]) +AC_OUTPUT diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/doc/.gitignore b/gnulib-tool-tests/import-tests/test-diffutils-1.result/doc/.gitignore new file mode 100644 index 00000000..847f66f4 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/doc/.gitignore @@ -0,0 +1,2 @@ +/gendocs_template +/gendocs_template_min diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/doc/gendocs_template b/gnulib-tool-tests/import-tests/test-diffutils-1.result/doc/gendocs_template new file mode 100644 index 00000000..277b1755 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/doc/gendocs_template @@ -0,0 +1,103 @@ +<!--#include virtual="/server/header.html" --> +<!-- Parent-Version: 1.78 --> + +<!-- +Copyright (C) 2006-2024 Free Software Foundation, Inc. + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. This file is offered as-is, +without any warranty. +--> + +<title>%%TITLE%% - GNU Project - Free Software Foundation + +

%%TITLE%%

+ +
Free Software Foundation
+
last updated %%DATE%%
+ +

This manual (%%PACKAGE%%) is available in the following formats:

+ + + +

You can buy printed copies of +some manuals (among other items) from the Free Software Foundation; +this helps support FSF activities.

+ +

(This page generated by the %%SCRIPTNAME%% +script.)

+ + + + + + + + diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/doc/gendocs_template_min b/gnulib-tool-tests/import-tests/test-diffutils-1.result/doc/gendocs_template_min new file mode 100644 index 00000000..5518a1a4 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/doc/gendocs_template_min @@ -0,0 +1,108 @@ + + + + + + + +%%TITLE%% - GNU Project - Free Software Foundation + + + + + + +

%%TITLE%%

+ +
Free Software Foundation
+
last updated %%DATE%%
+

+ +  [image of the head of a GNU] + +

+
+ +

This manual (%%PACKAGE%%) is available in the following formats:

+ + + +

(This page generated by the %%SCRIPTNAME%% +script.)

+ + + + +

Copyright © 2020 Free Software Foundation, Inc.

+ +

This page is licensed under a Creative +Commons Attribution-NoDerivs 3.0 United States License.

+ + + + + + diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/.gitignore b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/.gitignore new file mode 100644 index 00000000..95041a56 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/.gitignore @@ -0,0 +1,495 @@ +/_Noreturn.h +/accept.c +/alloca.c +/altstack-util.h +/arg-nonnull.h +/arpa_inet.in.h +/asnprintf.c +/atoll.c +/bind.c +/c++defs.h +/c-strcasestr.c +/c-strcasestr.h +/connect.c +/dtotimespec.c +/fdopen.c +/float+.h +/float.c +/float.in.h +/fpucw.h +/ftruncate.c +/gnulib.mk +/hash-pjw.c +/hash-pjw.h +/inet_pton.c +/init.sh +/ioctl.c +/itold.c +/listen.c +/locale.c +/macros.h +/mmap-anon-util.h +/nan.h +/nanosleep.c +/nap.h +/netinet_in.in.h +/perror.c +/printf-args.c +/printf-args.h +/printf-parse.c +/printf-parse.h +/pselect.c +/pthread-thread.c +/pthread.in.h +/pthread_sigmask.c +/putenv.c +/sched.in.h +/select.c +/setsockopt.c +/signature.h +/size_max.h +/sleep.c +/snprintf.c +/socket.c +/sockets.c +/sockets.h +/str-two-way.h +/strerror_r.c +/symlink.c +/sys_ioctl.in.h +/sys_select.in.h +/sys_socket.c +/sys_socket.in.h +/sys_uio.in.h +/test-accept.c +/test-alignasof.c +/test-alloca-opt.c +/test-argmatch.c +/test-arpa_inet.c +/test-assert.c +/test-binary-io.c +/test-binary-io.sh +/test-bind.c +/test-bitrotate.c +/test-btowc.c +/test-btowc1.sh +/test-btowc2.sh +/test-btowc3.sh +/test-c-ctype.c +/test-c-stack.c +/test-c-stack.sh +/test-c-stack2.sh +/test-c-strcase.sh +/test-c-strcasecmp.c +/test-c-strcasestr.c +/test-c-strncasecmp.c +/test-calloc-gnu.c +/test-cloexec.c +/test-close.c +/test-connect.c +/test-ctype.c +/test-dirname.c +/test-dup2.c +/test-dynarray.c +/test-environ.c +/test-errno.c +/test-error.c +/test-error.sh +/test-exclude.c +/test-exclude1.sh +/test-exclude2.sh +/test-exclude3.sh +/test-exclude4.sh +/test-exclude5.sh +/test-exclude6.sh +/test-exclude7.sh +/test-exclude8.sh +/test-fcntl-h.c +/test-fcntl.c +/test-fdopen.c +/test-fgetc.c +/test-filenamecat.c +/test-float.c +/test-fnmatch-h.c +/test-fnmatch.c +/test-fopen-gnu.c +/test-fopen.c +/test-fopen.h +/test-fputc.c +/test-fread.c +/test-free.c +/test-freopen.c +/test-fstat.c +/test-ftruncate.c +/test-ftruncate.sh +/test-fwrite.c +/test-getcwd-lgpl.c +/test-getdtablesize.c +/test-getopt-gnu.c +/test-getopt-main.h +/test-getopt-posix.c +/test-getopt.h +/test-getopt_long.h +/test-getprogname.c +/test-getrandom.c +/test-gettimeofday.c +/test-hard-locale.c +/test-hash.c +/test-ignore-value.c +/test-inet_pton.c +/test-init.sh +/test-intprops.c +/test-inttostr.c +/test-inttypes.c +/test-ioctl.c +/test-isblank.c +/test-iswblank.c +/test-iswdigit.c +/test-iswdigit.sh +/test-iswxdigit.c +/test-iswxdigit.sh +/test-langinfo.c +/test-largefile.c +/test-limits-h.c +/test-listen.c +/test-localcharset.c +/test-locale.c +/test-localeconv.c +/test-lstat.c +/test-lstat.h +/test-malloc-gnu.c +/test-malloca.c +/test-mbrtowc-w32-1.sh +/test-mbrtowc-w32-2.sh +/test-mbrtowc-w32-3.sh +/test-mbrtowc-w32-4.sh +/test-mbrtowc-w32-5.sh +/test-mbrtowc-w32-6.sh +/test-mbrtowc-w32-7.sh +/test-mbrtowc-w32.c +/test-mbrtowc.c +/test-mbrtowc1.sh +/test-mbrtowc2.sh +/test-mbrtowc3.sh +/test-mbrtowc4.sh +/test-mbrtowc5.sh +/test-mbscasecmp.c +/test-mbscasecmp.sh +/test-mbsinit.c +/test-mbsinit.sh +/test-mbsrtowcs.c +/test-mbsrtowcs1.sh +/test-mbsrtowcs2.sh +/test-mbsrtowcs3.sh +/test-mbsrtowcs4.sh +/test-mbsrtowcs5.sh +/test-memchr.c +/test-mkdir.c +/test-mkdir.h +/test-nanosleep.c +/test-netinet_in.c +/test-nl_langinfo-mt.c +/test-nl_langinfo1.c +/test-nl_langinfo1.sh +/test-nl_langinfo2.c +/test-nl_langinfo2.sh +/test-nstrftime.c +/test-nullptr.c +/test-open.c +/test-open.h +/test-pathmax.c +/test-perror.c +/test-perror.sh +/test-perror2.c +/test-pipe.c +/test-pselect.c +/test-pthread-thread.c +/test-pthread.c +/test-pthread_sigmask1.c +/test-pthread_sigmask2.c +/test-quotearg-simple.c +/test-quotearg.h +/test-raise.c +/test-rawmemchr.c +/test-realloc-gnu.c +/test-reallocarray.c +/test-regex.c +/test-sched.c +/test-select-fd.c +/test-select-in.sh +/test-select-out.sh +/test-select-stdin.c +/test-select.c +/test-select.h +/test-setenv.c +/test-setlocale_null-mt-all.c +/test-setlocale_null-mt-one.c +/test-setlocale_null.c +/test-setsockopt.c +/test-sh-quote.c +/test-signal-h.c +/test-sigprocmask.c +/test-sigsegv-catch-segv1.c +/test-sigsegv-catch-segv2.c +/test-sigsegv-catch-stackoverflow1.c +/test-sigsegv-catch-stackoverflow2.c +/test-sleep.c +/test-snprintf.c +/test-sockets.c +/test-stat-time.c +/test-stat.c +/test-stat.h +/test-stdbool.c +/test-stdckdint.c +/test-stddef.c +/test-stdint.c +/test-stdio.c +/test-stdlib.c +/test-strerror.c +/test-strerror_r.c +/test-string.c +/test-strings.c +/test-strnlen.c +/test-strtoimax.c +/test-strtoll.c +/test-symlink.c +/test-symlink.h +/test-sys_ioctl.c +/test-sys_random.c +/test-sys_select.c +/test-sys_socket.c +/test-sys_stat.c +/test-sys_time.c +/test-sys_types.c +/test-sys_uio.c +/test-sys_wait.c +/test-sys_wait.h +/test-thread_create.c +/test-thread_self.c +/test-time-h.c +/test-time.c +/test-timespec.c +/test-unistd.c +/test-unsetenv.c +/test-update-copyright.sh +/test-vasnprintf.c +/test-vc-list-files-cvs.sh +/test-vc-list-files-git.sh +/test-verify-try.c +/test-verify.c +/test-verify.sh +/test-version-etc.c +/test-version-etc.sh +/test-wchar.c +/test-wcrtomb-w32-1.sh +/test-wcrtomb-w32-2.sh +/test-wcrtomb-w32-3.sh +/test-wcrtomb-w32-4.sh +/test-wcrtomb-w32-5.sh +/test-wcrtomb-w32-6.sh +/test-wcrtomb-w32-7.sh +/test-wcrtomb-w32.c +/test-wcrtomb.c +/test-wcrtomb.sh +/test-wctype-h.c +/test-wcwidth.c +/test-xalloc-die.c +/test-xalloc-die.sh +/test-xstdopen.c +/test-xstdopen.sh +/test-xstrtoimax.c +/test-xstrtoimax.sh +/test-xstrtol.c +/test-xstrtol.sh +/test-xstrtoul.c +/test-year2038.c +/time.c +/timespec-add.c +/timespec-sub.c +/vasnprintf.c +/vasnprintf.h +/w32sock.h +/warn-on-use.h +/wctob.c +/wctomb-impl.h +/wctomb.c +/windows-thread.c +/windows-thread.h +/windows-tls.c +/windows-tls.h +/xsize.c +/xsize.h +/xstrtol-error.c +/xstrtol-error.h +/zerosize-ptr.h +/c32rtomb.c +/c32tob.c +/test-btoc32-1.sh +/test-btoc32-2.sh +/test-btoc32-3.sh +/test-btoc32.c +/test-c32rtomb-w32-1.sh +/test-c32rtomb-w32-2.sh +/test-c32rtomb-w32-3.sh +/test-c32rtomb-w32-4.sh +/test-c32rtomb-w32-5.sh +/test-c32rtomb-w32-6.sh +/test-c32rtomb-w32-7.sh +/test-c32rtomb-w32.c +/test-c32rtomb.c +/test-c32rtomb.sh +/test-c32width.c +/test-count-leading-zeros.c +/test-mbrtoc32-1.sh +/test-mbrtoc32-2.sh +/test-mbrtoc32-3.sh +/test-mbrtoc32-4.sh +/test-mbrtoc32-5.sh +/test-mbrtoc32-w32-1.sh +/test-mbrtoc32-w32-2.sh +/test-mbrtoc32-w32-3.sh +/test-mbrtoc32-w32-4.sh +/test-mbrtoc32-w32-5.sh +/test-mbrtoc32-w32-6.sh +/test-mbrtoc32-w32-7.sh +/test-mbrtoc32-w32.c +/test-mbrtoc32.c +/test-uchar.c +/anytostr.c +/imaxtostr.c +/inttostr.c +/inttostr.h +/offtostr.c +/test-c32_apply_type_test.c +/test-c32_get_type_test.c +/test-c32isalnum.c +/test-c32isalnum.sh +/test-c32isalpha.c +/test-c32isalpha.sh +/test-c32isblank.c +/test-c32isblank.sh +/test-c32iscntrl.c +/test-c32iscntrl.sh +/test-c32isdigit.c +/test-c32isdigit.sh +/test-c32isgraph.c +/test-c32isgraph.sh +/test-c32islower.c +/test-c32islower.sh +/test-c32isprint.c +/test-c32isprint.sh +/test-c32ispunct.c +/test-c32ispunct.sh +/test-c32isspace.c +/test-c32isspace.sh +/test-c32isupper.c +/test-c32isupper.sh +/test-c32isxdigit.c +/test-c32isxdigit.sh +/test-c32tolower.c +/test-c32tolower.sh +/test-chdir.c +/test-dirent.c +/test-dirfd.c +/test-dup-safer.c +/test-dup.c +/test-fchdir.c +/test-fdopendir.c +/test-fnmatch-1.sh +/test-fnmatch-2.sh +/test-fnmatch-3.sh +/test-fnmatch-4.sh +/test-fnmatch-5.sh +/test-fnmatch-w32-1.sh +/test-fnmatch-w32-2.sh +/test-fnmatch-w32-3.sh +/test-fnmatch-w32-4.sh +/test-fnmatch-w32-5.sh +/test-fnmatch-w32-6.sh +/test-fnmatch-w32-7.sh +/test-fnmatch-w32.c +/test-fstatat.c +/test-mbsrtoc32s-1.sh +/test-mbsrtoc32s-2.sh +/test-mbsrtoc32s-3.sh +/test-mbsrtoc32s-4.sh +/test-mbsrtoc32s-5.sh +/test-mbsrtoc32s.c +/test-memrchr.c +/test-openat.c +/test-timespec_get.c +/uinttostr.c +/umaxtostr.c +/at-func.c +/priv-set.c +/priv-set.h +/rmdir.c +/root-uid.h +/symlinkat.c +/test-priv-set.c +/test-readlink.c +/test-readlink.h +/test-readlinkat.c +/test-rmdir.c +/test-rmdir.h +/test-sigaction.c +/test-symlinkat.c +/test-unlink.c +/test-unlink.h +/test-unlinkat.c +/unlink.c +/unlinkat.c +/unlinkdir.c +/unlinkdir.h +/test-popen.c +/test-popen.h +/btoc32.c +/test-areadlink.c +/test-areadlink.h +/infinity.h +/isnan.c +/isnand-nolibm.h +/isnand.c +/isnanf-nolibm.h +/isnanf.c +/isnanl-nolibm.h +/isnanl.c +/math.c +/math.in.h +/minus-zero.h +/signbitd.c +/signbitf.c +/signbitl.c +/signed-nan.h +/signed-snan.h +/snan.h +/test-btowc-1.sh +/test-btowc-2.sh +/test-btowc-3.sh +/test-c32rtomb-w32-8.sh +/test-fnmatch-w32-8.sh +/test-isnand-nolibm.c +/test-isnand.h +/test-isnanf-nolibm.c +/test-isnanf.h +/test-isnanl-nolibm.c +/test-isnanl.h +/test-iswctype.c +/test-iswpunct.c +/test-iswpunct.sh +/test-math.c +/test-mbrtoc32-w32-8.sh +/test-mbrtowc-1.sh +/test-mbrtowc-2.sh +/test-mbrtowc-3.sh +/test-mbrtowc-4.sh +/test-mbrtowc-5.sh +/test-mbrtowc-w32-8.sh +/test-mbsrtowcs-1.sh +/test-mbsrtowcs-2.sh +/test-mbsrtowcs-3.sh +/test-mbsrtowcs-4.sh +/test-mbsrtowcs-5.sh +/test-signbit.c +/test-wcrtomb-w32-8.sh +/test-wctype.c diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/.gitignore~ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/.gitignore~ new file mode 100644 index 00000000..daa3020b --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/.gitignore~ @@ -0,0 +1,448 @@ +/_Noreturn.h +/accept.c +/alloca.c +/altstack-util.h +/arg-nonnull.h +/arpa_inet.in.h +/asnprintf.c +/atoll.c +/bind.c +/c++defs.h +/c-strcasestr.c +/c-strcasestr.h +/connect.c +/dtotimespec.c +/fdopen.c +/float+.h +/float.c +/float.in.h +/fpucw.h +/ftruncate.c +/gnulib.mk +/hash-pjw.c +/hash-pjw.h +/inet_pton.c +/init.sh +/ioctl.c +/itold.c +/listen.c +/locale.c +/macros.h +/mmap-anon-util.h +/nan.h +/nanosleep.c +/nap.h +/netinet_in.in.h +/perror.c +/printf-args.c +/printf-args.h +/printf-parse.c +/printf-parse.h +/pselect.c +/pthread-thread.c +/pthread.in.h +/pthread_sigmask.c +/putenv.c +/sched.in.h +/select.c +/setsockopt.c +/signature.h +/size_max.h +/sleep.c +/snprintf.c +/socket.c +/sockets.c +/sockets.h +/str-two-way.h +/strerror_r.c +/symlink.c +/sys_ioctl.in.h +/sys_select.in.h +/sys_socket.c +/sys_socket.in.h +/sys_uio.in.h +/test-accept.c +/test-alignasof.c +/test-alloca-opt.c +/test-argmatch.c +/test-arpa_inet.c +/test-assert.c +/test-binary-io.c +/test-binary-io.sh +/test-bind.c +/test-bitrotate.c +/test-btowc.c +/test-btowc1.sh +/test-btowc2.sh +/test-btowc3.sh +/test-c-ctype.c +/test-c-stack.c +/test-c-stack.sh +/test-c-stack2.sh +/test-c-strcase.sh +/test-c-strcasecmp.c +/test-c-strcasestr.c +/test-c-strncasecmp.c +/test-calloc-gnu.c +/test-cloexec.c +/test-close.c +/test-connect.c +/test-ctype.c +/test-dirname.c +/test-dup2.c +/test-dynarray.c +/test-environ.c +/test-errno.c +/test-error.c +/test-error.sh +/test-exclude.c +/test-exclude1.sh +/test-exclude2.sh +/test-exclude3.sh +/test-exclude4.sh +/test-exclude5.sh +/test-exclude6.sh +/test-exclude7.sh +/test-exclude8.sh +/test-fcntl-h.c +/test-fcntl.c +/test-fdopen.c +/test-fgetc.c +/test-filenamecat.c +/test-float.c +/test-fnmatch-h.c +/test-fnmatch.c +/test-fopen-gnu.c +/test-fopen.c +/test-fopen.h +/test-fputc.c +/test-fread.c +/test-free.c +/test-freopen.c +/test-fstat.c +/test-ftruncate.c +/test-ftruncate.sh +/test-fwrite.c +/test-getcwd-lgpl.c +/test-getdtablesize.c +/test-getopt-gnu.c +/test-getopt-main.h +/test-getopt-posix.c +/test-getopt.h +/test-getopt_long.h +/test-getprogname.c +/test-getrandom.c +/test-gettimeofday.c +/test-hard-locale.c +/test-hash.c +/test-ignore-value.c +/test-inet_pton.c +/test-init.sh +/test-intprops.c +/test-inttostr.c +/test-inttypes.c +/test-ioctl.c +/test-isblank.c +/test-iswblank.c +/test-iswdigit.c +/test-iswdigit.sh +/test-iswxdigit.c +/test-iswxdigit.sh +/test-langinfo.c +/test-largefile.c +/test-limits-h.c +/test-listen.c +/test-localcharset.c +/test-locale.c +/test-localeconv.c +/test-lstat.c +/test-lstat.h +/test-malloc-gnu.c +/test-malloca.c +/test-mbrtowc-w32-1.sh +/test-mbrtowc-w32-2.sh +/test-mbrtowc-w32-3.sh +/test-mbrtowc-w32-4.sh +/test-mbrtowc-w32-5.sh +/test-mbrtowc-w32-6.sh +/test-mbrtowc-w32-7.sh +/test-mbrtowc-w32.c +/test-mbrtowc.c +/test-mbrtowc1.sh +/test-mbrtowc2.sh +/test-mbrtowc3.sh +/test-mbrtowc4.sh +/test-mbrtowc5.sh +/test-mbscasecmp.c +/test-mbscasecmp.sh +/test-mbsinit.c +/test-mbsinit.sh +/test-mbsrtowcs.c +/test-mbsrtowcs1.sh +/test-mbsrtowcs2.sh +/test-mbsrtowcs3.sh +/test-mbsrtowcs4.sh +/test-mbsrtowcs5.sh +/test-memchr.c +/test-mkdir.c +/test-mkdir.h +/test-nanosleep.c +/test-netinet_in.c +/test-nl_langinfo-mt.c +/test-nl_langinfo1.c +/test-nl_langinfo1.sh +/test-nl_langinfo2.c +/test-nl_langinfo2.sh +/test-nstrftime.c +/test-nullptr.c +/test-open.c +/test-open.h +/test-pathmax.c +/test-perror.c +/test-perror.sh +/test-perror2.c +/test-pipe.c +/test-pselect.c +/test-pthread-thread.c +/test-pthread.c +/test-pthread_sigmask1.c +/test-pthread_sigmask2.c +/test-quotearg-simple.c +/test-quotearg.h +/test-raise.c +/test-rawmemchr.c +/test-realloc-gnu.c +/test-reallocarray.c +/test-regex.c +/test-sched.c +/test-select-fd.c +/test-select-in.sh +/test-select-out.sh +/test-select-stdin.c +/test-select.c +/test-select.h +/test-setenv.c +/test-setlocale_null-mt-all.c +/test-setlocale_null-mt-one.c +/test-setlocale_null.c +/test-setsockopt.c +/test-sh-quote.c +/test-signal-h.c +/test-sigprocmask.c +/test-sigsegv-catch-segv1.c +/test-sigsegv-catch-segv2.c +/test-sigsegv-catch-stackoverflow1.c +/test-sigsegv-catch-stackoverflow2.c +/test-sleep.c +/test-snprintf.c +/test-sockets.c +/test-stat-time.c +/test-stat.c +/test-stat.h +/test-stdbool.c +/test-stdckdint.c +/test-stddef.c +/test-stdint.c +/test-stdio.c +/test-stdlib.c +/test-strerror.c +/test-strerror_r.c +/test-string.c +/test-strings.c +/test-strnlen.c +/test-strtoimax.c +/test-strtoll.c +/test-symlink.c +/test-symlink.h +/test-sys_ioctl.c +/test-sys_random.c +/test-sys_select.c +/test-sys_socket.c +/test-sys_stat.c +/test-sys_time.c +/test-sys_types.c +/test-sys_uio.c +/test-sys_wait.c +/test-sys_wait.h +/test-thread_create.c +/test-thread_self.c +/test-time-h.c +/test-time.c +/test-timespec.c +/test-unistd.c +/test-unsetenv.c +/test-update-copyright.sh +/test-vasnprintf.c +/test-vc-list-files-cvs.sh +/test-vc-list-files-git.sh +/test-verify-try.c +/test-verify.c +/test-verify.sh +/test-version-etc.c +/test-version-etc.sh +/test-wchar.c +/test-wcrtomb-w32-1.sh +/test-wcrtomb-w32-2.sh +/test-wcrtomb-w32-3.sh +/test-wcrtomb-w32-4.sh +/test-wcrtomb-w32-5.sh +/test-wcrtomb-w32-6.sh +/test-wcrtomb-w32-7.sh +/test-wcrtomb-w32.c +/test-wcrtomb.c +/test-wcrtomb.sh +/test-wctype-h.c +/test-wcwidth.c +/test-xalloc-die.c +/test-xalloc-die.sh +/test-xstdopen.c +/test-xstdopen.sh +/test-xstrtoimax.c +/test-xstrtoimax.sh +/test-xstrtol.c +/test-xstrtol.sh +/test-xstrtoul.c +/test-year2038.c +/time.c +/timespec-add.c +/timespec-sub.c +/vasnprintf.c +/vasnprintf.h +/w32sock.h +/warn-on-use.h +/wctob.c +/wctomb-impl.h +/wctomb.c +/windows-thread.c +/windows-thread.h +/windows-tls.c +/windows-tls.h +/xsize.c +/xsize.h +/xstrtol-error.c +/xstrtol-error.h +/zerosize-ptr.h +/c32rtomb.c +/c32tob.c +/test-btoc32-1.sh +/test-btoc32-2.sh +/test-btoc32-3.sh +/test-btoc32.c +/test-c32rtomb-w32-1.sh +/test-c32rtomb-w32-2.sh +/test-c32rtomb-w32-3.sh +/test-c32rtomb-w32-4.sh +/test-c32rtomb-w32-5.sh +/test-c32rtomb-w32-6.sh +/test-c32rtomb-w32-7.sh +/test-c32rtomb-w32.c +/test-c32rtomb.c +/test-c32rtomb.sh +/test-c32width.c +/test-count-leading-zeros.c +/test-mbrtoc32-1.sh +/test-mbrtoc32-2.sh +/test-mbrtoc32-3.sh +/test-mbrtoc32-4.sh +/test-mbrtoc32-5.sh +/test-mbrtoc32-w32-1.sh +/test-mbrtoc32-w32-2.sh +/test-mbrtoc32-w32-3.sh +/test-mbrtoc32-w32-4.sh +/test-mbrtoc32-w32-5.sh +/test-mbrtoc32-w32-6.sh +/test-mbrtoc32-w32-7.sh +/test-mbrtoc32-w32.c +/test-mbrtoc32.c +/test-uchar.c +/anytostr.c +/imaxtostr.c +/inttostr.c +/inttostr.h +/offtostr.c +/test-c32_apply_type_test.c +/test-c32_get_type_test.c +/test-c32isalnum.c +/test-c32isalnum.sh +/test-c32isalpha.c +/test-c32isalpha.sh +/test-c32isblank.c +/test-c32isblank.sh +/test-c32iscntrl.c +/test-c32iscntrl.sh +/test-c32isdigit.c +/test-c32isdigit.sh +/test-c32isgraph.c +/test-c32isgraph.sh +/test-c32islower.c +/test-c32islower.sh +/test-c32isprint.c +/test-c32isprint.sh +/test-c32ispunct.c +/test-c32ispunct.sh +/test-c32isspace.c +/test-c32isspace.sh +/test-c32isupper.c +/test-c32isupper.sh +/test-c32isxdigit.c +/test-c32isxdigit.sh +/test-c32tolower.c +/test-c32tolower.sh +/test-chdir.c +/test-dirent.c +/test-dirfd.c +/test-dup-safer.c +/test-dup.c +/test-fchdir.c +/test-fdopendir.c +/test-fnmatch-1.sh +/test-fnmatch-2.sh +/test-fnmatch-3.sh +/test-fnmatch-4.sh +/test-fnmatch-5.sh +/test-fnmatch-w32-1.sh +/test-fnmatch-w32-2.sh +/test-fnmatch-w32-3.sh +/test-fnmatch-w32-4.sh +/test-fnmatch-w32-5.sh +/test-fnmatch-w32-6.sh +/test-fnmatch-w32-7.sh +/test-fnmatch-w32.c +/test-fstatat.c +/test-mbsrtoc32s-1.sh +/test-mbsrtoc32s-2.sh +/test-mbsrtoc32s-3.sh +/test-mbsrtoc32s-4.sh +/test-mbsrtoc32s-5.sh +/test-mbsrtoc32s.c +/test-memrchr.c +/test-openat.c +/test-timespec_get.c +/uinttostr.c +/umaxtostr.c +/at-func.c +/priv-set.c +/priv-set.h +/rmdir.c +/root-uid.h +/symlinkat.c +/test-priv-set.c +/test-readlink.c +/test-readlink.h +/test-readlinkat.c +/test-rmdir.c +/test-rmdir.h +/test-sigaction.c +/test-symlinkat.c +/test-unlink.c +/test-unlink.h +/test-unlinkat.c +/unlink.c +/unlinkat.c +/unlinkdir.c +/unlinkdir.h +/test-popen.c +/test-popen.h +/btoc32.c +/test-areadlink.c +/test-areadlink.h diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/_Noreturn.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/_Noreturn.h new file mode 100644 index 00000000..7326bd47 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/_Noreturn.h @@ -0,0 +1,50 @@ +/* A C macro for declaring that a function does not return. + Copyright (C) 2011-2024 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef _Noreturn +# if (defined __cplusplus \ + && ((201103 <= __cplusplus && !(__GNUC__ == 4 && __GNUC_MINOR__ == 7)) \ + || (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 __clang__ && __clang_major__ < 16 \ + && defined _GL_WORK_AROUND_LLVM_BUG_59792) + /* Compile with -D_GL_WORK_AROUND_LLVM_BUG_59792 to work around + that rare LLVM bug, though you may get many false-alarm warnings. */ +# define _Noreturn +# elif ((!defined __cplusplus || defined __clang__) \ + && (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \ + || (!defined __STRICT_ANSI__ \ + && (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__) || defined __clang__ \ + || 0x5110 <= __SUNPRO_C) +# define _Noreturn __attribute__ ((__noreturn__)) +# elif 1200 <= (defined _MSC_VER ? _MSC_VER : 0) +# define _Noreturn __declspec (noreturn) +# else +# define _Noreturn +# endif +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/accept.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/accept.c new file mode 100644 index 00000000..18ce80c6 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/accept.c @@ -0,0 +1,52 @@ +/* accept.c --- wrappers for Windows accept function + + Copyright (C) 2008-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Paolo Bonzini */ + +#include + +#define WIN32_LEAN_AND_MEAN +/* Get winsock2.h. */ +#include + +/* Get set_winsock_errno, FD_TO_SOCKET etc. */ +#include "w32sock.h" + +#undef accept + +int +rpl_accept (int fd, struct sockaddr *addr, socklen_t *addrlen) +{ + SOCKET sock = FD_TO_SOCKET (fd); + + if (sock == INVALID_SOCKET) + { + errno = EBADF; + return -1; + } + else + { + SOCKET fh = accept (sock, addr, addrlen); + if (fh == INVALID_SOCKET) + { + set_winsock_errno (); + return -1; + } + else + return SOCKET_TO_FD (fh); + } +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/alloca.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/alloca.c new file mode 100644 index 00000000..5eb16a9f --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/alloca.c @@ -0,0 +1,167 @@ +/* alloca.c -- allocate automatically reclaimed memory + This file is in the public domain. */ + +/* (Mostly) portable implementation -- D A Gwyn + + This implementation of the PWB library alloca function, + which is used to allocate space off the run-time stack so + that it is automatically reclaimed upon procedure exit, + was inspired by discussions with J. Q. Johnson of Cornell. + J.Otto Tennant contributed the Cray support. + + There are some preprocessor constants that can + be defined when compiling for your specific system, for + improved efficiency; however, the defaults should be okay. + + The general concept of this implementation is to keep + track of all alloca-allocated blocks, and reclaim any + that are found to be deeper in the stack than the current + invocation. This heuristic does not reclaim storage as + soon as it becomes invalid, but it will do so eventually. + + As a special case, alloca(0) reclaims storage without + allocating any. It is a good idea to use alloca(0) in + your main control loop, etc. to force garbage collection. */ + +#include + +#include + +#include +#include + +/* If compiling with GCC or clang, this file is not needed. */ +#if !(defined __GNUC__ || defined __clang__) + +/* If someone has defined alloca as a macro, + there must be some other way alloca is supposed to work. */ +# ifndef alloca + +/* Define STACK_DIRECTION if you know the direction of stack + growth for your system; otherwise it will be automatically + deduced at run-time. + + STACK_DIRECTION > 0 => grows toward higher addresses + STACK_DIRECTION < 0 => grows toward lower addresses + STACK_DIRECTION = 0 => direction of growth unknown */ + +# ifndef STACK_DIRECTION +# define STACK_DIRECTION 0 /* Direction unknown. */ +# endif + +# if STACK_DIRECTION != 0 + +# define STACK_DIR STACK_DIRECTION /* Known at compile-time. */ + +# else /* STACK_DIRECTION == 0; need run-time code. */ + +static int stack_dir; /* 1 or -1 once known. */ +# define STACK_DIR stack_dir + +static int +find_stack_direction (int *addr, int depth) +{ + int dir, dummy = 0; + if (! addr) + addr = &dummy; + *addr = addr < &dummy ? 1 : addr == &dummy ? 0 : -1; + dir = depth ? find_stack_direction (addr, depth - 1) : 0; + return dir + dummy; +} + +# endif /* STACK_DIRECTION == 0 */ + +/* An "alloca header" is used to: + (a) chain together all alloca'ed blocks; + (b) keep track of stack depth. + + It is very important that sizeof(header) agree with malloc + alignment chunk size. The following default should work okay. */ + +# ifndef ALIGN_SIZE +# define ALIGN_SIZE sizeof(double) +# endif + +typedef union hdr +{ + char align[ALIGN_SIZE]; /* To force sizeof(header). */ + struct + { + union hdr *next; /* For chaining headers. */ + char *deep; /* For stack depth measure. */ + } h; +} header; + +static header *last_alloca_header = NULL; /* -> last alloca header. */ + +/* Return a pointer to at least SIZE bytes of storage, + which will be automatically reclaimed upon exit from + the procedure that called alloca. Originally, this space + was supposed to be taken from the current stack frame of the + caller, but that method cannot be made to work for some + implementations of C, for example under Gould's UTX/32. */ + +void * +alloca (size_t size) +{ + auto char probe; /* Probes stack depth: */ + register char *depth = &probe; + +# if STACK_DIRECTION == 0 + if (STACK_DIR == 0) /* Unknown growth direction. */ + STACK_DIR = find_stack_direction (NULL, (size & 1) + 20); +# endif + + /* Reclaim garbage, defined as all alloca'd storage that + was allocated from deeper in the stack than currently. */ + + { + register header *hp; /* Traverses linked list. */ + + for (hp = last_alloca_header; hp != NULL;) + if ((STACK_DIR > 0 && hp->h.deep > depth) + || (STACK_DIR < 0 && hp->h.deep < depth)) + { + register header *np = hp->h.next; + + free (hp); /* Collect garbage. */ + + hp = np; /* -> next header. */ + } + else + break; /* Rest are not deeper. */ + + last_alloca_header = hp; /* -> last valid storage. */ + } + + if (size == 0) + return NULL; /* No allocation required. */ + + /* Allocate combined header + user data storage. */ + + { + /* Address of header. */ + register header *new; + + size_t combined_size = sizeof (header) + size; + if (combined_size < sizeof (header)) + memory_full (); + + new = malloc (combined_size); + + if (! new) + memory_full (); + + new->h.next = last_alloca_header; + new->h.deep = depth; + + last_alloca_header = new; + + /* User storage begins just after header. */ + + return (void *) (new + 1); + } +} + +# endif /* no alloca */ +#endif /* not GCC || clang */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/altstack-util.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/altstack-util.h new file mode 100644 index 00000000..1bd5f33b --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/altstack-util.h @@ -0,0 +1,66 @@ +/* Some auxiliary stuff for defining an alternate stack. + Copyright (C) 2010-2024 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 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 . */ + +/* Written by Eric Blake and Bruno Haible. */ + +#include /* uintptr_t */ +#include /* for memset */ + +#define MYSTACK_SIZE (1 << 24) + +/* glibc says: Users should use SIGSTKSZ as the size of user-supplied + buffers. We want to detect stack overflow of the alternate stack + in a nicer manner than just crashing, so we overallocate in + comparison to what we hand libsigsegv. Also, we intentionally hand + an unaligned pointer, to ensure the alternate stack still ends up + aligned. */ +#define MYSTACK_CRUMPLE_ZONE 8192 +static char mystack_storage[MYSTACK_SIZE + 2 * MYSTACK_CRUMPLE_ZONE + 31]; +static char *mystack; /* MYSTACK_SIZE bytes in the middle of storage. */ + +static void +prepare_alternate_stack (void) +{ +#ifdef SIGSTKSZ + if (MYSTACK_SIZE < SIGSTKSZ) + { + size_t size = SIGSTKSZ; + printf ("SIGSTKSZ=%zu exceeds MYSTACK_SIZE=%d\n", size, MYSTACK_SIZE); + exit (1); + } +#endif + memset (mystack_storage, 's', sizeof mystack_storage); + mystack = (char *) ((uintptr_t) (mystack_storage + MYSTACK_CRUMPLE_ZONE) | 31); +} + +static void +check_alternate_stack_no_overflow (void) +{ + unsigned int i; + + for (i = MYSTACK_CRUMPLE_ZONE; i > 0; i--) + if (*(mystack - i) != 's') + { + printf ("Alternate stack was exceeded by %u bytes!!\n", i); + exit (1); + } + for (i = MYSTACK_CRUMPLE_ZONE; i > 0; i--) + if (*(mystack + MYSTACK_SIZE - 1 + i) != 's') + { + printf ("Alternate stack was exceeded by %u bytes!!\n", i); + exit (1); + } +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/anytostr.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/anytostr.c new file mode 100644 index 00000000..11ef4478 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/anytostr.c @@ -0,0 +1,50 @@ +/* anytostr.c -- convert integers to printable strings + + Copyright (C) 2001, 2006, 2008-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Paul Eggert */ + +#include + +#include "inttostr.h" + +/* Convert I to a printable string in BUF, which must be at least + INT_BUFSIZE_BOUND (INTTYPE) bytes long. Return the address of the + printable string, which need not start at BUF. */ + +_GL_ATTRIBUTE_NODISCARD char * +anytostr (inttype i, char *buf) +{ + char *p = buf + INT_STRLEN_BOUND (inttype); + *p = 0; + + if (i < 0) + { + do + *--p = '0' - i % 10; + while ((i /= 10) != 0); + + *--p = '-'; + } + else + { + do + *--p = '0' + i % 10; + while ((i /= 10) != 0); + } + + return p; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/arg-nonnull.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/arg-nonnull.h new file mode 100644 index 00000000..46c711ca --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/arg-nonnull.h @@ -0,0 +1,26 @@ +/* A C macro for declaring that specific arguments must not be NULL. + Copyright (C) 2009-2024 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools + that the values passed as arguments n, ..., m must be non-NULL pointers. + n = 1 stands for the first argument, n = 2 for the second argument etc. */ +#ifndef _GL_ARG_NONNULL +# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || defined __clang__ +# define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params)) +# else +# define _GL_ARG_NONNULL(params) +# endif +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/arpa_inet.in.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/arpa_inet.in.h new file mode 100644 index 00000000..523a448c --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/arpa_inet.in.h @@ -0,0 +1,155 @@ +/* A GNU-like . + + Copyright (C) 2005-2006, 2008-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef _@GUARD_PREFIX@_ARPA_INET_H + +#if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +#endif +@PRAGMA_COLUMNS@ + +#if @HAVE_FEATURES_H@ +# include /* for __GLIBC__ */ +#endif + +/* Gnulib's sys/socket.h is responsible for defining socklen_t (used below) and + for pulling in winsock2.h etc. under MinGW. + But avoid namespace pollution on glibc systems. */ +#ifndef __GLIBC__ +# include +#endif + +/* On NonStop Kernel, inet_ntop and inet_pton are declared in . + But avoid namespace pollution on glibc systems. */ +#if defined __TANDEM && !defined __GLIBC__ +# include +#endif + +#if @HAVE_ARPA_INET_H@ + +/* The include_next requires a split double-inclusion guard. */ +# @INCLUDE_NEXT@ @NEXT_ARPA_INET_H@ + +#endif + +#ifndef _@GUARD_PREFIX@_ARPA_INET_H +#define _@GUARD_PREFIX@_ARPA_INET_H + +/* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +/* Get all possible declarations of inet_ntop() and inet_pton(). */ +#if (@GNULIB_INET_NTOP@ || @GNULIB_INET_PTON@ || defined GNULIB_POSIXCHECK) \ + && @HAVE_WS2TCPIP_H@ +# include +#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. */ + + +#if @GNULIB_INET_NTOP@ +/* Converts an internet address from internal format to a printable, + presentable format. + AF is an internet address family, such as AF_INET or AF_INET6. + SRC points to a 'struct in_addr' (for AF_INET) or 'struct in6_addr' + (for AF_INET6). + DST points to a buffer having room for CNT bytes. + The printable representation of the address (in numeric form, not + surrounded by [...], no reverse DNS is done) is placed in DST, and + DST is returned. If an error occurs, the return value is NULL and + errno is set. If CNT bytes are not sufficient to hold the result, + the return value is NULL and errno is set to ENOSPC. A good value + for CNT is 46. + + For more details, see the POSIX:2008 specification + . */ +# if @REPLACE_INET_NTOP@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef inet_ntop +# define inet_ntop rpl_inet_ntop +# endif +_GL_FUNCDECL_RPL (inet_ntop, const char *, + (int af, const void *restrict src, + char *restrict dst, socklen_t cnt) + _GL_ARG_NONNULL ((2, 3))); +_GL_CXXALIAS_RPL (inet_ntop, const char *, + (int af, const void *restrict src, + char *restrict dst, socklen_t cnt)); +# else +# if !@HAVE_DECL_INET_NTOP@ +_GL_FUNCDECL_SYS (inet_ntop, const char *, + (int af, const void *restrict src, + char *restrict dst, socklen_t cnt) + _GL_ARG_NONNULL ((2, 3))); +# endif +/* Need to cast, because on NonStop Kernel, the fourth parameter is + size_t cnt. */ +_GL_CXXALIAS_SYS_CAST (inet_ntop, const char *, + (int af, const void *restrict src, + char *restrict dst, socklen_t cnt)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (inet_ntop); +# endif +#elif defined GNULIB_POSIXCHECK +# undef inet_ntop +# if HAVE_RAW_DECL_INET_NTOP +_GL_WARN_ON_USE (inet_ntop, "inet_ntop is unportable - " + "use gnulib module inet_ntop for portability"); +# endif +#endif + +#if @GNULIB_INET_PTON@ +# if @REPLACE_INET_PTON@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef inet_pton +# define inet_pton rpl_inet_pton +# endif +_GL_FUNCDECL_RPL (inet_pton, int, + (int af, const char *restrict src, void *restrict dst) + _GL_ARG_NONNULL ((2, 3))); +_GL_CXXALIAS_RPL (inet_pton, int, + (int af, const char *restrict src, void *restrict dst)); +# else +# if !@HAVE_DECL_INET_PTON@ +_GL_FUNCDECL_SYS (inet_pton, int, + (int af, const char *restrict src, void *restrict dst) + _GL_ARG_NONNULL ((2, 3))); +# endif +_GL_CXXALIAS_SYS (inet_pton, int, + (int af, const char *restrict src, void *restrict dst)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (inet_pton); +# endif +#elif defined GNULIB_POSIXCHECK +# undef inet_pton +# if HAVE_RAW_DECL_INET_PTON +_GL_WARN_ON_USE (inet_pton, "inet_pton is unportable - " + "use gnulib module inet_pton for portability"); +# endif +#endif + + +#endif /* _@GUARD_PREFIX@_ARPA_INET_H */ +#endif /* _@GUARD_PREFIX@_ARPA_INET_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/asnprintf.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/asnprintf.c new file mode 100644 index 00000000..a6c09bc2 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/asnprintf.c @@ -0,0 +1,34 @@ +/* Formatted output to strings. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "vasnprintf.h" + +#include + +char * +asnprintf (char *resultbuf, size_t *lengthp, const char *format, ...) +{ + va_list args; + char *result; + + va_start (args, format); + result = vasnprintf (resultbuf, lengthp, format, args); + va_end (args); + return result; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/at-func.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/at-func.c new file mode 100644 index 00000000..56b313f4 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/at-func.c @@ -0,0 +1,146 @@ +/* Define at-style functions like fstatat, unlinkat, fchownat, etc. + Copyright (C) 2006, 2009-2024 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 . */ + +/* written by Jim Meyering */ + +#include "filename.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */ + +#ifdef GNULIB_SUPPORT_ONLY_AT_FDCWD +# include +# ifndef ENOTSUP +# define ENOTSUP EINVAL +# endif +#else +# include "openat.h" +# include "openat-priv.h" +# include "save-cwd.h" +#endif + +#ifdef AT_FUNC_USE_F1_COND +# define CALL_FUNC(F) \ + (flag == AT_FUNC_USE_F1_COND \ + ? AT_FUNC_F1 (F AT_FUNC_POST_FILE_ARGS) \ + : AT_FUNC_F2 (F AT_FUNC_POST_FILE_ARGS)) +# define VALIDATE_FLAG(F) \ + if (flag & ~AT_FUNC_USE_F1_COND) \ + { \ + errno = EINVAL; \ + return FUNC_FAIL; \ + } +#else +# define CALL_FUNC(F) (AT_FUNC_F1 (F AT_FUNC_POST_FILE_ARGS)) +# define VALIDATE_FLAG(F) /* empty */ +#endif + +#ifdef AT_FUNC_RESULT +# define FUNC_RESULT AT_FUNC_RESULT +#else +# define FUNC_RESULT int +#endif + +#ifdef AT_FUNC_FAIL +# define FUNC_FAIL AT_FUNC_FAIL +#else +# define FUNC_FAIL -1 +#endif + +/* Call AT_FUNC_F1 to operate on FILE, which is in the directory + open on descriptor FD. If AT_FUNC_USE_F1_COND is defined to a value, + AT_FUNC_POST_FILE_PARAM_DECLS must include a parameter named flag; + call AT_FUNC_F2 if FLAG is 0 or fail if FLAG contains more bits than + AT_FUNC_USE_F1_COND. Return int and fail with -1 unless AT_FUNC_RESULT + or AT_FUNC_FAIL are defined. If possible, do it without changing the + working directory. Otherwise, resort to using save_cwd/fchdir, + then AT_FUNC_F?/restore_cwd. If either the save_cwd or the restore_cwd + fails, then give a diagnostic and exit nonzero. */ +FUNC_RESULT +AT_FUNC_NAME (int fd, char const *file AT_FUNC_POST_FILE_PARAM_DECLS) +{ + VALIDATE_FLAG (flag); + + if (fd == AT_FDCWD || IS_ABSOLUTE_FILE_NAME (file)) + return CALL_FUNC (file); + +#ifdef GNULIB_SUPPORT_ONLY_AT_FDCWD + errno = ENOTSUP; + return FUNC_FAIL; +#else + { + /* Be careful to choose names unlikely to conflict with + AT_FUNC_POST_FILE_PARAM_DECLS. */ + struct saved_cwd saved_cwd; + int saved_errno; + FUNC_RESULT err; + + { + char proc_buf[OPENAT_BUFFER_SIZE]; + char *proc_file = openat_proc_name (proc_buf, fd, file); + if (proc_file) + { + FUNC_RESULT proc_result = CALL_FUNC (proc_file); + int proc_errno = errno; + if (proc_file != proc_buf) + free (proc_file); + /* If the syscall succeeds, or if it fails with an unexpected + errno value, then return right away. Otherwise, fall through + and resort to using save_cwd/restore_cwd. */ + if (FUNC_FAIL != proc_result) + return proc_result; + if (! EXPECTED_ERRNO (proc_errno)) + { + errno = proc_errno; + return proc_result; + } + } + } + + if (save_cwd (&saved_cwd) != 0) + openat_save_fail (errno); + if (0 <= fd && fd == saved_cwd.desc) + { + /* If saving the working directory collides with the user's + requested fd, then the user's fd must have been closed to + begin with. */ + free_cwd (&saved_cwd); + errno = EBADF; + return FUNC_FAIL; + } + + if (fchdir (fd) != 0) + { + saved_errno = errno; + free_cwd (&saved_cwd); + errno = saved_errno; + return FUNC_FAIL; + } + + err = CALL_FUNC (file); + saved_errno = (err == FUNC_FAIL ? errno : 0); + + if (restore_cwd (&saved_cwd) != 0) + openat_restore_fail (errno); + + free_cwd (&saved_cwd); + + if (saved_errno) + errno = saved_errno; + return err; + } +#endif +} +#undef CALL_FUNC +#undef FUNC_RESULT +#undef FUNC_FAIL diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/atoll.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/atoll.c new file mode 100644 index 00000000..84dd9579 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/atoll.c @@ -0,0 +1,34 @@ +/* Copyright (C) 1991, 1997-1998, 2008-2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#if !_LIBC +# include +#endif + +/* Specification. */ +#include + +#if _LIBC +# undef atoll +#endif + + +/* Convert a string to a long long int. */ +long long int +atoll (const char *nptr) +{ + return strtoll (nptr, (char **) NULL, 10); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/bind.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/bind.c new file mode 100644 index 00000000..7c557448 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/bind.c @@ -0,0 +1,49 @@ +/* bind.c --- wrappers for Windows bind function + + Copyright (C) 2008-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Paolo Bonzini */ + +#include + +#define WIN32_LEAN_AND_MEAN +/* Get winsock2.h. */ +#include + +/* Get set_winsock_errno, FD_TO_SOCKET etc. */ +#include "w32sock.h" + +#undef bind + +int +rpl_bind (int fd, const struct sockaddr *sockaddr, socklen_t len) +{ + SOCKET sock = FD_TO_SOCKET (fd); + + if (sock == INVALID_SOCKET) + { + errno = EBADF; + return -1; + } + else + { + int r = bind (sock, sockaddr, len); + if (r < 0) + set_winsock_errno (); + + return r; + } +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/c++defs.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/c++defs.h new file mode 100644 index 00000000..eb66967b --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/c++defs.h @@ -0,0 +1,337 @@ +/* C++ compatible function declaration macros. + Copyright (C) 2010-2024 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef _GL_CXXDEFS_H +#define _GL_CXXDEFS_H + +/* Begin/end the GNULIB_NAMESPACE namespace. */ +#if defined __cplusplus && defined GNULIB_NAMESPACE +# define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE { +# define _GL_END_NAMESPACE } +#else +# define _GL_BEGIN_NAMESPACE +# define _GL_END_NAMESPACE +#endif + +/* The three most frequent use cases of these macros are: + + * For providing a substitute for a function that is missing on some + platforms, but is declared and works fine on the platforms on which + it exists: + + #if @GNULIB_FOO@ + # if !@HAVE_FOO@ + _GL_FUNCDECL_SYS (foo, ...); + # endif + _GL_CXXALIAS_SYS (foo, ...); + _GL_CXXALIASWARN (foo); + #elif defined GNULIB_POSIXCHECK + ... + #endif + + * For providing a replacement for a function that exists on all platforms, + but is broken/insufficient and needs to be replaced on some platforms: + + #if @GNULIB_FOO@ + # if @REPLACE_FOO@ + # if !(defined __cplusplus && defined GNULIB_NAMESPACE) + # undef foo + # define foo rpl_foo + # endif + _GL_FUNCDECL_RPL (foo, ...); + _GL_CXXALIAS_RPL (foo, ...); + # else + _GL_CXXALIAS_SYS (foo, ...); + # endif + _GL_CXXALIASWARN (foo); + #elif defined GNULIB_POSIXCHECK + ... + #endif + + * For providing a replacement for a function that exists on some platforms + but is broken/insufficient and needs to be replaced on some of them and + is additionally either missing or undeclared on some other platforms: + + #if @GNULIB_FOO@ + # if @REPLACE_FOO@ + # if !(defined __cplusplus && defined GNULIB_NAMESPACE) + # undef foo + # define foo rpl_foo + # endif + _GL_FUNCDECL_RPL (foo, ...); + _GL_CXXALIAS_RPL (foo, ...); + # else + # if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@ + _GL_FUNCDECL_SYS (foo, ...); + # endif + _GL_CXXALIAS_SYS (foo, ...); + # endif + _GL_CXXALIASWARN (foo); + #elif defined GNULIB_POSIXCHECK + ... + #endif +*/ + +/* _GL_EXTERN_C declaration; + performs the declaration with C linkage. */ +#if defined __cplusplus +# define _GL_EXTERN_C extern "C" +#else +# define _GL_EXTERN_C extern +#endif + +/* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes); + declares a replacement function, named rpl_func, with the given prototype, + consisting of return type, parameters, and attributes. + Example: + _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...) + _GL_ARG_NONNULL ((1))); + + Note: Attributes, such as _GL_ATTRIBUTE_DEPRECATED, are supported in front + of a _GL_FUNCDECL_RPL invocation only in C mode, not in C++ mode. (That's + because + [[...]] extern "C" ; + is invalid syntax in C++.) + */ +#define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \ + _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes) +#define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \ + _GL_EXTERN_C rettype rpl_func parameters_and_attributes + +/* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes); + declares the system function, named func, with the given prototype, + consisting of return type, parameters, and attributes. + Example: + _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...) + _GL_ARG_NONNULL ((1))); + */ +#define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \ + _GL_EXTERN_C rettype func parameters_and_attributes + +/* _GL_CXXALIAS_RPL (func, rettype, parameters); + declares a C++ alias called GNULIB_NAMESPACE::func + that redirects to rpl_func, if GNULIB_NAMESPACE is defined. + Example: + _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...)); + + Wrapping rpl_func in an object with an inline conversion operator + avoids a reference to rpl_func unless GNULIB_NAMESPACE::func is + actually used in the program. */ +#define _GL_CXXALIAS_RPL(func,rettype,parameters) \ + _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters) +#if defined __cplusplus && defined GNULIB_NAMESPACE +# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ + namespace GNULIB_NAMESPACE \ + { \ + static const struct _gl_ ## func ## _wrapper \ + { \ + typedef rettype (*type) parameters; \ + \ + inline operator type () const \ + { \ + return ::rpl_func; \ + } \ + } func = {}; \ + } \ + _GL_EXTERN_C int _gl_cxxalias_dummy +#else +# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ + _GL_EXTERN_C int _gl_cxxalias_dummy +#endif + +/* _GL_CXXALIAS_MDA (func, rettype, parameters); + is to be used when func is a Microsoft deprecated alias, on native Windows. + It declares a C++ alias called GNULIB_NAMESPACE::func + that redirects to _func, if GNULIB_NAMESPACE is defined. + Example: + _GL_CXXALIAS_MDA (open, int, (const char *filename, int flags, ...)); + */ +#define _GL_CXXALIAS_MDA(func,rettype,parameters) \ + _GL_CXXALIAS_RPL_1 (func, _##func, rettype, parameters) + +/* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters); + is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters); + except that the C function rpl_func may have a slightly different + declaration. A cast is used to silence the "invalid conversion" error + that would otherwise occur. */ +#if defined __cplusplus && defined GNULIB_NAMESPACE +# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ + namespace GNULIB_NAMESPACE \ + { \ + static const struct _gl_ ## func ## _wrapper \ + { \ + typedef rettype (*type) parameters; \ + \ + inline operator type () const \ + { \ + return reinterpret_cast(::rpl_func); \ + } \ + } func = {}; \ + } \ + _GL_EXTERN_C int _gl_cxxalias_dummy +#else +# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ + _GL_EXTERN_C int _gl_cxxalias_dummy +#endif + +/* _GL_CXXALIAS_MDA_CAST (func, rettype, parameters); + is like _GL_CXXALIAS_MDA (func, rettype, parameters); + except that the C function func may have a slightly different declaration. + A cast is used to silence the "invalid conversion" error that would + otherwise occur. */ +#define _GL_CXXALIAS_MDA_CAST(func,rettype,parameters) \ + _GL_CXXALIAS_RPL_CAST_1 (func, _##func, rettype, parameters) + +/* _GL_CXXALIAS_SYS (func, rettype, parameters); + declares a C++ alias called GNULIB_NAMESPACE::func + that redirects to the system provided function func, if GNULIB_NAMESPACE + is defined. + Example: + _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...)); + + Wrapping func in an object with an inline conversion operator + avoids a reference to func unless GNULIB_NAMESPACE::func is + actually used in the program. */ +#if defined __cplusplus && defined GNULIB_NAMESPACE +# define _GL_CXXALIAS_SYS(func,rettype,parameters) \ + namespace GNULIB_NAMESPACE \ + { \ + static const struct _gl_ ## func ## _wrapper \ + { \ + typedef rettype (*type) parameters; \ + \ + inline operator type () const \ + { \ + return ::func; \ + } \ + } func = {}; \ + } \ + _GL_EXTERN_C int _gl_cxxalias_dummy +#else +# define _GL_CXXALIAS_SYS(func,rettype,parameters) \ + _GL_EXTERN_C int _gl_cxxalias_dummy +#endif + +/* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters); + is like _GL_CXXALIAS_SYS (func, rettype, parameters); + except that the C function func may have a slightly different declaration. + A cast is used to silence the "invalid conversion" error that would + otherwise occur. */ +#if defined __cplusplus && defined GNULIB_NAMESPACE +# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ + namespace GNULIB_NAMESPACE \ + { \ + static const struct _gl_ ## func ## _wrapper \ + { \ + typedef rettype (*type) parameters; \ + \ + inline operator type () const \ + { \ + return reinterpret_cast(::func); \ + } \ + } func = {}; \ + } \ + _GL_EXTERN_C int _gl_cxxalias_dummy +#else +# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ + _GL_EXTERN_C int _gl_cxxalias_dummy +#endif + +/* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2); + is like _GL_CXXALIAS_SYS (func, rettype, parameters); + except that the C function is picked among a set of overloaded functions, + namely the one with rettype2 and parameters2. Two consecutive casts + are used to silence the "cannot find a match" and "invalid conversion" + errors that would otherwise occur. */ +#if defined __cplusplus && defined GNULIB_NAMESPACE + /* The outer cast must be a reinterpret_cast. + The inner cast: When the function is defined as a set of overloaded + functions, it works as a static_cast<>, choosing the designated variant. + When the function is defined as a single variant, it works as a + reinterpret_cast<>. The parenthesized cast syntax works both ways. */ +# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ + namespace GNULIB_NAMESPACE \ + { \ + static const struct _gl_ ## func ## _wrapper \ + { \ + typedef rettype (*type) parameters; \ + \ + inline operator type () const \ + { \ + return reinterpret_cast((rettype2 (*) parameters2)(::func)); \ + } \ + } func = {}; \ + } \ + _GL_EXTERN_C int _gl_cxxalias_dummy +#else +# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ + _GL_EXTERN_C int _gl_cxxalias_dummy +#endif + +/* _GL_CXXALIASWARN (func); + causes a warning to be emitted when ::func is used but not when + GNULIB_NAMESPACE::func is used. func must be defined without overloaded + variants. */ +#if defined __cplusplus && defined GNULIB_NAMESPACE +# define _GL_CXXALIASWARN(func) \ + _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE) +# define _GL_CXXALIASWARN_1(func,namespace) \ + _GL_CXXALIASWARN_2 (func, namespace) +/* To work around GCC bug , + we enable the warning only when not optimizing. */ +# if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__) +# define _GL_CXXALIASWARN_2(func,namespace) \ + _GL_WARN_ON_USE (func, \ + "The symbol ::" #func " refers to the system function. " \ + "Use " #namespace "::" #func " instead.") +# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING +# define _GL_CXXALIASWARN_2(func,namespace) \ + extern __typeof__ (func) func +# else +# define _GL_CXXALIASWARN_2(func,namespace) \ + _GL_EXTERN_C int _gl_cxxalias_dummy +# endif +#else +# define _GL_CXXALIASWARN(func) \ + _GL_EXTERN_C int _gl_cxxalias_dummy +#endif + +/* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes); + causes a warning to be emitted when the given overloaded variant of ::func + is used but not when GNULIB_NAMESPACE::func is used. */ +#if defined __cplusplus && defined GNULIB_NAMESPACE +# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ + _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \ + GNULIB_NAMESPACE) +# define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \ + _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace) +/* To work around GCC bug , + we enable the warning only when not optimizing. */ +# if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__) +# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ + _GL_WARN_ON_USE_CXX (func, rettype, rettype, parameters_and_attributes, \ + "The symbol ::" #func " refers to the system function. " \ + "Use " #namespace "::" #func " instead.") +# else +# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ + _GL_EXTERN_C int _gl_cxxalias_dummy +# endif +#else +# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ + _GL_EXTERN_C int _gl_cxxalias_dummy +#endif + +#endif /* _GL_CXXDEFS_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/c-strcasestr.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/c-strcasestr.c new file mode 100644 index 00000000..e5648bf2 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/c-strcasestr.c @@ -0,0 +1,76 @@ +/* c-strcasestr.c -- case insensitive substring search in C locale + Copyright (C) 2005-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2005. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "c-strcasestr.h" + +#include + +#include "c-ctype.h" +#include "c-strcase.h" + +/* Two-Way algorithm. */ +#define RETURN_TYPE char * +#define AVAILABLE(h, h_l, j, n_l) \ + (!memchr ((h) + (h_l), '\0', (j) + (n_l) - (h_l)) \ + && ((h_l) = (j) + (n_l))) +#define CANON_ELEMENT c_tolower +#define CMP_FUNC(p1, p2, l) \ + c_strncasecmp ((const char *) (p1), (const char *) (p2), l) +#include "str-two-way.h" + +/* Find the first occurrence of NEEDLE in HAYSTACK, using case-insensitive + comparison from the C locale, regardless of the current locale. */ +char * +c_strcasestr (const char *haystack_start, const char *needle_start) +{ + const char *haystack = haystack_start; + const char *needle = needle_start; + size_t needle_len; /* Length of NEEDLE. */ + size_t haystack_len; /* Known minimum length of HAYSTACK. */ + bool ok = true; /* True if NEEDLE is prefix of HAYSTACK. */ + + /* Determine length of NEEDLE, and in the process, make sure + HAYSTACK is at least as long (no point processing all of a long + NEEDLE if HAYSTACK is too short). */ + while (*haystack && *needle) + ok &= (c_tolower ((unsigned char) *haystack++) + == c_tolower ((unsigned char) *needle++)); + if (*needle) + return NULL; + if (ok) + return (char *) haystack_start; + needle_len = needle - needle_start; + haystack = haystack_start + 1; + haystack_len = needle_len - 1; + + /* Perform the search. Abstract memory is considered to be an array + of 'unsigned char' values, not an array of 'char' values. See + ISO C 99 section 6.2.6.1. */ + if (needle_len < LONG_NEEDLE_THRESHOLD) + return two_way_short_needle ((const unsigned char *) haystack, + haystack_len, + (const unsigned char *) needle_start, + needle_len); + return two_way_long_needle ((const unsigned char *) haystack, haystack_len, + (const unsigned char *) needle_start, + needle_len); +} + +#undef LONG_NEEDLE_THRESHOLD diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/c-strcasestr.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/c-strcasestr.h new file mode 100644 index 00000000..7f3ef1d4 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/c-strcasestr.h @@ -0,0 +1,36 @@ +/* Case-insensitive searching in a string in C locale. + Copyright (C) 2005, 2009-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef C_STRCASESTR_H +#define C_STRCASESTR_H + + +#ifdef __cplusplus +extern "C" { +#endif + + +/* Find the first occurrence of NEEDLE in HAYSTACK, using case-insensitive + comparison. */ +extern char *c_strcasestr (const char *haystack, const char *needle); + + +#ifdef __cplusplus +} +#endif + + +#endif /* C_STRCASESTR_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/c32rtomb.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/c32rtomb.c new file mode 100644 index 00000000..260bf097 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/c32rtomb.c @@ -0,0 +1,132 @@ +/* Convert 32-bit wide character to multibyte character. + Copyright (C) 2020-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 2020. */ + +#include + +/* Specification. */ +#include + +#include +#include + +#include "attribute.h" /* FALLTHROUGH */ +#include "localcharset.h" +#include "streq.h" + +#if GL_CHAR32_T_IS_UNICODE +# include "lc-charset-unicode.h" +#endif + +size_t +c32rtomb (char *s, char32_t wc, mbstate_t *ps) +#undef c32rtomb +{ +#if HAVE_WORKING_MBRTOC32 + +# if C32RTOMB_RETVAL_BUG + if (s == NULL) + /* We know the NUL wide character corresponds to the NUL character. */ + return 1; +# endif + + return c32rtomb (s, wc, ps); + +#elif _GL_SMALL_WCHAR_T + + if (s == NULL) + return wcrtomb (NULL, 0, ps); + else + { + /* Special-case all encodings that may produce wide character values + > WCHAR_MAX. */ + const char *encoding = locale_charset (); + if (STREQ_OPT (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0, 0)) + { + /* Special-case the UTF-8 encoding. Assume that the wide-character + encoding in a UTF-8 locale is UCS-2 or, equivalently, UTF-16. */ + if (wc < 0x80) + { + s[0] = (unsigned char) wc; + return 1; + } + else + { + int count; + + if (wc < 0x800) + count = 2; + else if (wc < 0x10000) + { + if (wc < 0xd800 || wc >= 0xe000) + count = 3; + else + { + errno = EILSEQ; + return (size_t)(-1); + } + } + else if (wc < 0x110000) + count = 4; + else + { + errno = EILSEQ; + return (size_t)(-1); + } + + switch (count) /* note: code falls through cases! */ + { + case 4: s[3] = 0x80 | (wc & 0x3f); wc = wc >> 6; wc |= 0x10000; + FALLTHROUGH; + case 3: s[2] = 0x80 | (wc & 0x3f); wc = wc >> 6; wc |= 0x800; + FALLTHROUGH; + case 2: s[1] = 0x80 | (wc & 0x3f); wc = wc >> 6; wc |= 0xc0; + /*case 1:*/ s[0] = wc; + } + return count; + } + } + else + { + if ((wchar_t) wc == wc) + return wcrtomb (s, (wchar_t) wc, ps); + else + { + errno = EILSEQ; + return (size_t)(-1); + } + } + } + +#else + + /* char32_t and wchar_t are equivalent. */ +# if GL_CHAR32_T_IS_UNICODE && GL_CHAR32_T_VS_WCHAR_T_NEEDS_CONVERSION + if (wc != 0) + { + wc = unicode_to_locale_encoding (wc); + if (wc == 0) + { + errno = EILSEQ; + return (size_t)(-1); + } + } +# endif + return wcrtomb (s, (wchar_t) wc, ps); + +#endif +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/c32tob.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/c32tob.c new file mode 100644 index 00000000..901c9249 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/c32tob.c @@ -0,0 +1,70 @@ +/* Convert 32-bit wide character to unibyte character. + Copyright (C) 2020-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 2020. */ + +#include + +#define IN_C32TOB +/* Specification. */ +#include + +#include +#include +#include + +#if GL_CHAR32_T_IS_UNICODE +# include "lc-charset-unicode.h" +#endif + +#if _GL_WCHAR_T_IS_UCS4 +_GL_EXTERN_INLINE +#endif +int +c32tob (wint_t wc) +{ +#if HAVE_WORKING_MBRTOC32 && !_GL_WCHAR_T_IS_UCS4 + /* The char32_t encoding of a multibyte character may be different than its + wchar_t encoding. */ + if (wc != WEOF) + { + mbstate_t state; + char buf[8]; + + mbszero (&state); + if (c32rtomb (buf, wc, &state) == 1) + return (unsigned char) buf[0]; + } + return EOF; +#elif _GL_SMALL_WCHAR_T + /* In all known encodings, unibyte characters correspond only to + characters in the BMP. */ + if (wc != WEOF && (wchar_t) wc == wc) + return wctob ((wchar_t) wc); + else + return EOF; +#else +# if GL_CHAR32_T_IS_UNICODE && GL_CHAR32_T_VS_WCHAR_T_NEEDS_CONVERSION + if (wc != 0) + { + wc = unicode_to_locale_encoding (wc); + if (wc == 0) + return EOF; + } +# endif + return wctob (wc); +#endif +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/connect.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/connect.c new file mode 100644 index 00000000..421849c1 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/connect.c @@ -0,0 +1,56 @@ +/* connect.c --- wrappers for Windows connect function + + Copyright (C) 2008-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Paolo Bonzini */ + +#include + +#define WIN32_LEAN_AND_MEAN +/* Get winsock2.h. */ +#include + +/* Get set_winsock_errno, FD_TO_SOCKET etc. */ +#include "w32sock.h" + +#undef connect + +int +rpl_connect (int fd, const struct sockaddr *sockaddr, socklen_t len) +{ + SOCKET sock = FD_TO_SOCKET (fd); + + if (sock == INVALID_SOCKET) + { + errno = EBADF; + return -1; + } + else + { + int r = connect (sock, sockaddr, len); + if (r < 0) + { + /* EINPROGRESS is not returned by WinSock 2.0; for backwards + compatibility, connect(2) uses EWOULDBLOCK. */ + if (WSAGetLastError () == WSAEWOULDBLOCK) + WSASetLastError (WSAEINPROGRESS); + + set_winsock_errno (); + } + + return r; + } +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/dtotimespec.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/dtotimespec.c new file mode 100644 index 00000000..0557961c --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/dtotimespec.c @@ -0,0 +1,53 @@ +/* Convert double to timespec. + + Copyright (C) 2011-2024 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 . */ + +/* written by Paul Eggert */ + +/* Convert the double value SEC to a struct timespec. Round toward + positive infinity. On overflow, return an extremal value. */ + +#include + +#include "timespec.h" + +#include "intprops.h" + +struct timespec +dtotimespec (double sec) +{ + if (! (TYPE_MINIMUM (time_t) < sec)) + return make_timespec (TYPE_MINIMUM (time_t), 0); + else if (! (sec < 1.0 + TYPE_MAXIMUM (time_t))) + return make_timespec (TYPE_MAXIMUM (time_t), TIMESPEC_HZ - 1); + else + { + time_t s = sec; + double frac = TIMESPEC_HZ * (sec - s); + long ns = frac; + ns += ns < frac; + s += ns / TIMESPEC_HZ; + ns %= TIMESPEC_HZ; + + if (ns < 0) + { + s--; + ns += TIMESPEC_HZ; + } + + return make_timespec (s, ns); + } +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/fdopen.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/fdopen.c new file mode 100644 index 00000000..5a8cd535 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/fdopen.c @@ -0,0 +1,73 @@ +/* Open a stream with a given file descriptor. + Copyright (C) 2011-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +#include + +#if HAVE_MSVC_INVALID_PARAMETER_HANDLER +# include "msvc-inval.h" +#endif + +#undef fdopen + +#if defined _WIN32 && !defined __CYGWIN__ +# if HAVE_MSVC_INVALID_PARAMETER_HANDLER +static FILE * +fdopen_nothrow (int fd, const char *mode) +{ + FILE *result; + + TRY_MSVC_INVAL + { + result = _fdopen (fd, mode); + } + CATCH_MSVC_INVAL + { + result = NULL; + } + DONE_MSVC_INVAL; + + return result; +} +# else +# define fdopen_nothrow _fdopen +# endif +#else +# define fdopen_nothrow fdopen +#endif + +FILE * +rpl_fdopen (int fd, const char *mode) +{ + int saved_errno = errno; + FILE *fp; + + errno = 0; + fp = fdopen_nothrow (fd, mode); + if (fp == NULL) + { + if (errno == 0) + errno = EBADF; + } + else + errno = saved_errno; + + return fp; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/float+.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/float+.h new file mode 100644 index 00000000..104f477f --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/float+.h @@ -0,0 +1,147 @@ +/* Supplemental information about the floating-point formats. + Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2007. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef _FLOATPLUS_H +#define _FLOATPLUS_H + +#include +#include + +/* Number of bits in the mantissa of a floating-point number, including the + "hidden bit". */ +#if FLT_RADIX == 2 +# define FLT_MANT_BIT FLT_MANT_DIG +# define DBL_MANT_BIT DBL_MANT_DIG +# define LDBL_MANT_BIT LDBL_MANT_DIG +#elif FLT_RADIX == 4 +# define FLT_MANT_BIT (FLT_MANT_DIG * 2) +# define DBL_MANT_BIT (DBL_MANT_DIG * 2) +# define LDBL_MANT_BIT (LDBL_MANT_DIG * 2) +#elif FLT_RADIX == 16 +# define FLT_MANT_BIT (FLT_MANT_DIG * 4) +# define DBL_MANT_BIT (DBL_MANT_DIG * 4) +# define LDBL_MANT_BIT (LDBL_MANT_DIG * 4) +#endif + +/* Bit mask that can be used to mask the exponent, as an unsigned number. */ +#define FLT_EXP_MASK ((FLT_MAX_EXP - FLT_MIN_EXP) | 7) +#define DBL_EXP_MASK ((DBL_MAX_EXP - DBL_MIN_EXP) | 7) +#define LDBL_EXP_MASK ((LDBL_MAX_EXP - LDBL_MIN_EXP) | 7) + +/* Number of bits used for the exponent of a floating-point number, including + the exponent's sign. */ +#define FLT_EXP_BIT \ + (FLT_EXP_MASK < 0x100 ? 8 : \ + FLT_EXP_MASK < 0x200 ? 9 : \ + FLT_EXP_MASK < 0x400 ? 10 : \ + FLT_EXP_MASK < 0x800 ? 11 : \ + FLT_EXP_MASK < 0x1000 ? 12 : \ + FLT_EXP_MASK < 0x2000 ? 13 : \ + FLT_EXP_MASK < 0x4000 ? 14 : \ + FLT_EXP_MASK < 0x8000 ? 15 : \ + FLT_EXP_MASK < 0x10000 ? 16 : \ + FLT_EXP_MASK < 0x20000 ? 17 : \ + FLT_EXP_MASK < 0x40000 ? 18 : \ + FLT_EXP_MASK < 0x80000 ? 19 : \ + FLT_EXP_MASK < 0x100000 ? 20 : \ + FLT_EXP_MASK < 0x200000 ? 21 : \ + FLT_EXP_MASK < 0x400000 ? 22 : \ + FLT_EXP_MASK < 0x800000 ? 23 : \ + FLT_EXP_MASK < 0x1000000 ? 24 : \ + FLT_EXP_MASK < 0x2000000 ? 25 : \ + FLT_EXP_MASK < 0x4000000 ? 26 : \ + FLT_EXP_MASK < 0x8000000 ? 27 : \ + FLT_EXP_MASK < 0x10000000 ? 28 : \ + FLT_EXP_MASK < 0x20000000 ? 29 : \ + FLT_EXP_MASK < 0x40000000 ? 30 : \ + FLT_EXP_MASK <= 0x7fffffff ? 31 : \ + 32) +#define DBL_EXP_BIT \ + (DBL_EXP_MASK < 0x100 ? 8 : \ + DBL_EXP_MASK < 0x200 ? 9 : \ + DBL_EXP_MASK < 0x400 ? 10 : \ + DBL_EXP_MASK < 0x800 ? 11 : \ + DBL_EXP_MASK < 0x1000 ? 12 : \ + DBL_EXP_MASK < 0x2000 ? 13 : \ + DBL_EXP_MASK < 0x4000 ? 14 : \ + DBL_EXP_MASK < 0x8000 ? 15 : \ + DBL_EXP_MASK < 0x10000 ? 16 : \ + DBL_EXP_MASK < 0x20000 ? 17 : \ + DBL_EXP_MASK < 0x40000 ? 18 : \ + DBL_EXP_MASK < 0x80000 ? 19 : \ + DBL_EXP_MASK < 0x100000 ? 20 : \ + DBL_EXP_MASK < 0x200000 ? 21 : \ + DBL_EXP_MASK < 0x400000 ? 22 : \ + DBL_EXP_MASK < 0x800000 ? 23 : \ + DBL_EXP_MASK < 0x1000000 ? 24 : \ + DBL_EXP_MASK < 0x2000000 ? 25 : \ + DBL_EXP_MASK < 0x4000000 ? 26 : \ + DBL_EXP_MASK < 0x8000000 ? 27 : \ + DBL_EXP_MASK < 0x10000000 ? 28 : \ + DBL_EXP_MASK < 0x20000000 ? 29 : \ + DBL_EXP_MASK < 0x40000000 ? 30 : \ + DBL_EXP_MASK <= 0x7fffffff ? 31 : \ + 32) +#define LDBL_EXP_BIT \ + (LDBL_EXP_MASK < 0x100 ? 8 : \ + LDBL_EXP_MASK < 0x200 ? 9 : \ + LDBL_EXP_MASK < 0x400 ? 10 : \ + LDBL_EXP_MASK < 0x800 ? 11 : \ + LDBL_EXP_MASK < 0x1000 ? 12 : \ + LDBL_EXP_MASK < 0x2000 ? 13 : \ + LDBL_EXP_MASK < 0x4000 ? 14 : \ + LDBL_EXP_MASK < 0x8000 ? 15 : \ + LDBL_EXP_MASK < 0x10000 ? 16 : \ + LDBL_EXP_MASK < 0x20000 ? 17 : \ + LDBL_EXP_MASK < 0x40000 ? 18 : \ + LDBL_EXP_MASK < 0x80000 ? 19 : \ + LDBL_EXP_MASK < 0x100000 ? 20 : \ + LDBL_EXP_MASK < 0x200000 ? 21 : \ + LDBL_EXP_MASK < 0x400000 ? 22 : \ + LDBL_EXP_MASK < 0x800000 ? 23 : \ + LDBL_EXP_MASK < 0x1000000 ? 24 : \ + LDBL_EXP_MASK < 0x2000000 ? 25 : \ + LDBL_EXP_MASK < 0x4000000 ? 26 : \ + LDBL_EXP_MASK < 0x8000000 ? 27 : \ + LDBL_EXP_MASK < 0x10000000 ? 28 : \ + LDBL_EXP_MASK < 0x20000000 ? 29 : \ + LDBL_EXP_MASK < 0x40000000 ? 30 : \ + LDBL_EXP_MASK <= 0x7fffffff ? 31 : \ + 32) + +/* Number of bits used for a floating-point number: the mantissa (not + counting the "hidden bit", since it may or may not be explicit), the + exponent, and the sign. */ +#define FLT_TOTAL_BIT ((FLT_MANT_BIT - 1) + FLT_EXP_BIT + 1) +#define DBL_TOTAL_BIT ((DBL_MANT_BIT - 1) + DBL_EXP_BIT + 1) +#define LDBL_TOTAL_BIT ((LDBL_MANT_BIT - 1) + LDBL_EXP_BIT + 1) + +/* Number of bytes used for a floating-point number. + This can be smaller than the 'sizeof'. For example, on i386 systems, + 'long double' most often have LDBL_MANT_BIT = 64, LDBL_EXP_BIT = 16, hence + LDBL_TOTAL_BIT = 80 bits, i.e. 10 bytes of consecutive memory, but + sizeof (long double) = 12 or = 16. */ +#define SIZEOF_FLT ((FLT_TOTAL_BIT + CHAR_BIT - 1) / CHAR_BIT) +#define SIZEOF_DBL ((DBL_TOTAL_BIT + CHAR_BIT - 1) / CHAR_BIT) +#define SIZEOF_LDBL ((LDBL_TOTAL_BIT + CHAR_BIT - 1) / CHAR_BIT) + +/* Verify that SIZEOF_FLT <= sizeof (float) etc. */ +typedef int verify_sizeof_flt[SIZEOF_FLT <= sizeof (float) ? 1 : -1]; +typedef int verify_sizeof_dbl[SIZEOF_DBL <= sizeof (double) ? 1 : - 1]; +typedef int verify_sizeof_ldbl[SIZEOF_LDBL <= sizeof (long double) ? 1 : - 1]; + +#endif /* _FLOATPLUS_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/float.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/float.c new file mode 100644 index 00000000..a9ea40b0 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/float.c @@ -0,0 +1,33 @@ +/* Auxiliary definitions for . + Copyright (C) 2011-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2011. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +#if (defined _ARCH_PPC || defined _POWER) && (defined _AIX || defined __linux__) && (LDBL_MANT_DIG == 106) && defined __GNUC__ +const union gl_long_double_union gl_LDBL_MAX = + { { DBL_MAX, DBL_MAX / (double)134217728UL / (double)134217728UL } }; +#elif defined __i386__ +const union gl_long_double_union gl_LDBL_MAX = + { { 0xFFFFFFFF, 0xFFFFFFFF, 32766 } }; +#else +/* This declaration is solely to ensure that after preprocessing + this file is never empty. */ +typedef int dummy; +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/float.in.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/float.in.h new file mode 100644 index 00000000..73e8d406 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/float.in.h @@ -0,0 +1,194 @@ +/* A correct . + + Copyright (C) 2007-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef _@GUARD_PREFIX@_FLOAT_H + +#if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +#endif +@PRAGMA_COLUMNS@ + +/* The include_next requires a split double-inclusion guard. */ +#@INCLUDE_NEXT@ @NEXT_FLOAT_H@ + +#ifndef _@GUARD_PREFIX@_FLOAT_H +#define _@GUARD_PREFIX@_FLOAT_H + +/* 'long double' properties. */ + +#if defined __i386__ && (defined __BEOS__ || defined __OpenBSD__) +/* Number of mantissa units, in base FLT_RADIX. */ +# undef LDBL_MANT_DIG +# define LDBL_MANT_DIG 64 +/* Number of decimal digits that is sufficient for representing a number. */ +# undef LDBL_DIG +# define LDBL_DIG 18 +/* x-1 where x is the smallest representable number > 1. */ +# undef LDBL_EPSILON +# define LDBL_EPSILON 1.0842021724855044340E-19L +/* Minimum e such that FLT_RADIX^(e-1) is a normalized number. */ +# undef LDBL_MIN_EXP +# define LDBL_MIN_EXP (-16381) +/* Maximum e such that FLT_RADIX^(e-1) is a representable finite number. */ +# undef LDBL_MAX_EXP +# define LDBL_MAX_EXP 16384 +/* Minimum positive normalized number. */ +# undef LDBL_MIN +# define LDBL_MIN 3.3621031431120935063E-4932L +/* Maximum representable finite number. */ +# undef LDBL_MAX +# define LDBL_MAX 1.1897314953572317650E+4932L +/* Minimum e such that 10^e is in the range of normalized numbers. */ +# undef LDBL_MIN_10_EXP +# define LDBL_MIN_10_EXP (-4931) +/* Maximum e such that 10^e is in the range of representable finite numbers. */ +# undef LDBL_MAX_10_EXP +# define LDBL_MAX_10_EXP 4932 +#endif + +/* On FreeBSD/x86 6.4, the 'long double' type really has only 53 bits of + precision in the compiler but 64 bits of precision at runtime. See + . */ +#if defined __i386__ && (defined __FreeBSD__ || defined __DragonFly__) +/* Number of mantissa units, in base FLT_RADIX. */ +# undef LDBL_MANT_DIG +# define LDBL_MANT_DIG 64 +/* Number of decimal digits that is sufficient for representing a number. */ +# undef LDBL_DIG +# define LDBL_DIG 18 +/* x-1 where x is the smallest representable number > 1. */ +# undef LDBL_EPSILON +# define LDBL_EPSILON 1.084202172485504434007452800869941711426e-19L /* 2^-63 */ +/* Minimum e such that FLT_RADIX^(e-1) is a normalized number. */ +# undef LDBL_MIN_EXP +# define LDBL_MIN_EXP (-16381) +/* Maximum e such that FLT_RADIX^(e-1) is a representable finite number. */ +# undef LDBL_MAX_EXP +# define LDBL_MAX_EXP 16384 +/* Minimum positive normalized number. */ +# undef LDBL_MIN +# define LDBL_MIN 3.362103143112093506262677817321752E-4932L /* = 0x1p-16382L */ +/* Maximum representable finite number. */ +# undef LDBL_MAX +/* LDBL_MAX is represented as { 0xFFFFFFFF, 0xFFFFFFFF, 32766 }. + But the largest literal that GCC allows us to write is + 0x0.fffffffffffff8p16384L = { 0xFFFFF800, 0xFFFFFFFF, 32766 }. + So, define it like this through a reference to an external variable + + const unsigned int LDBL_MAX[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 32766 }; + extern const long double LDBL_MAX; + + Unfortunately, this is not a constant expression. */ +# if !GNULIB_defined_long_double_union +union gl_long_double_union + { + struct { unsigned int lo; unsigned int hi; unsigned int exponent; } xd; + long double ld; + }; +# define GNULIB_defined_long_double_union 1 +# endif +extern const union gl_long_double_union gl_LDBL_MAX; +# define LDBL_MAX (gl_LDBL_MAX.ld) +/* Minimum e such that 10^e is in the range of normalized numbers. */ +# undef LDBL_MIN_10_EXP +# define LDBL_MIN_10_EXP (-4931) +/* Maximum e such that 10^e is in the range of representable finite numbers. */ +# undef LDBL_MAX_10_EXP +# define LDBL_MAX_10_EXP 4932 +#endif + +/* On AIX 7.1 with gcc 4.2, the values of LDBL_MIN_EXP, LDBL_MIN, LDBL_MAX are + wrong. + On Linux/PowerPC with gcc 4.4, the value of LDBL_MAX is wrong. */ +#if (defined _ARCH_PPC || defined _POWER) && defined _AIX && (LDBL_MANT_DIG == 106) && defined __GNUC__ +# undef LDBL_MIN_EXP +# define LDBL_MIN_EXP DBL_MIN_EXP +# undef LDBL_MIN_10_EXP +# define LDBL_MIN_10_EXP DBL_MIN_10_EXP +# undef LDBL_MIN +# define LDBL_MIN 2.22507385850720138309023271733240406422e-308L /* DBL_MIN = 2^-1022 */ +#endif +#if (defined _ARCH_PPC || defined _POWER) && (defined _AIX || defined __linux__) && (LDBL_MANT_DIG == 106) && defined __GNUC__ +# undef LDBL_MAX +/* LDBL_MAX is represented as { 0x7FEFFFFF, 0xFFFFFFFF, 0x7C8FFFFF, 0xFFFFFFFF }. + It is not easy to define: + #define LDBL_MAX 1.79769313486231580793728971405302307166e308L + is too small, whereas + #define LDBL_MAX 1.79769313486231580793728971405302307167e308L + is too large. Apparently a bug in GCC decimal-to-binary conversion. + Also, I can't get values larger than + #define LDBL63 ((long double) (1ULL << 63)) + #define LDBL882 (LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63) + #define LDBL945 (LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63) + #define LDBL1008 (LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63) + #define LDBL_MAX (LDBL1008 * 65535.0L + LDBL945 * (long double) 9223372036821221375ULL + LDBL882 * (long double) 4611686018427387904ULL) + which is represented as { 0x7FEFFFFF, 0xFFFFFFFF, 0x7C8FFFFF, 0xF8000000 }. + So, define it like this through a reference to an external variable + + const double LDBL_MAX[2] = { DBL_MAX, DBL_MAX / (double)134217728UL / (double)134217728UL }; + extern const long double LDBL_MAX; + + or through a pointer cast + + #define LDBL_MAX \ + (*(const long double *) (double[]) { DBL_MAX, DBL_MAX / (double)134217728UL / (double)134217728UL }) + + Unfortunately, this is not a constant expression, and the latter expression + does not work well when GCC is optimizing.. */ +# if !GNULIB_defined_long_double_union +union gl_long_double_union + { + struct { double hi; double lo; } dd; + long double ld; + }; +# define GNULIB_defined_long_double_union 1 +# endif +extern const union gl_long_double_union gl_LDBL_MAX; +# define LDBL_MAX (gl_LDBL_MAX.ld) +#endif + +/* On IRIX 6.5, with cc, the value of LDBL_MANT_DIG is wrong. + On IRIX 6.5, with gcc 4.2, the values of LDBL_MIN_EXP, LDBL_MIN, LDBL_EPSILON + are wrong. */ +#if defined __sgi && (LDBL_MANT_DIG >= 106) +# undef LDBL_MANT_DIG +# define LDBL_MANT_DIG 106 +# if defined __GNUC__ +# undef LDBL_MIN_EXP +# define LDBL_MIN_EXP DBL_MIN_EXP +# undef LDBL_MIN_10_EXP +# define LDBL_MIN_10_EXP DBL_MIN_10_EXP +# undef LDBL_MIN +# define LDBL_MIN 2.22507385850720138309023271733240406422e-308L /* DBL_MIN = 2^-1022 */ +# undef LDBL_EPSILON +# define LDBL_EPSILON 2.46519032881566189191165176650870696773e-32L /* 2^-105 */ +# endif +#endif + +#if @REPLACE_ITOLD@ +/* Pull in a function that fixes the 'int' to 'long double' conversion + of glibc 2.7. */ +extern +# ifdef __cplusplus +"C" +# endif +void _Qp_itoq (long double *, int); +static void (*_gl_float_fix_itold) (long double *, int) = _Qp_itoq; +#endif + +#endif /* _@GUARD_PREFIX@_FLOAT_H */ +#endif /* _@GUARD_PREFIX@_FLOAT_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/fpucw.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/fpucw.h new file mode 100644 index 00000000..c7387a22 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/fpucw.h @@ -0,0 +1,108 @@ +/* Manipulating the FPU control word. -*- coding: utf-8 -*- + Copyright (C) 2007-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2007. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef _FPUCW_H +#define _FPUCW_H + +/* The i386 floating point hardware (the 387 compatible FPU, not the modern + SSE/SSE2 hardware) has a controllable rounding precision. It is specified + through the 'PC' bits in the FPU control word ('fctrl' register). (See + the GNU libc i386 header for details.) + + On some platforms, such as Linux or Solaris, the default precision setting + is set to "extended precision". This means that 'long double' instructions + operate correctly, but 'double' computations often produce slightly + different results as on strictly IEEE 754 conforming systems. + + On some platforms, such as NetBSD, the default precision is set to + "double precision". This means that 'long double' instructions will operate + only as 'double', i.e. lead to wrong results. Similarly on FreeBSD 6.4, at + least for the division of 'long double' numbers. + + The FPU control word is under control of the application, i.e. it is + not required to be set either way by the ABI. (In fact, the i386 ABI + https://www.linux-mips.org/pub/linux/mips/doc/ABI/abi386-4.pdf page 3-12 = page 38 + is not clear about it. But in any case, gcc treats the control word + like a "preserved" register: it emits code that assumes that the control + word is preserved across calls, and it restores the control word at the + end of functions that modify it.) + + See Vincent Lefèvre's page https://www.vinc17.net/research/extended.en.html + for a good explanation. + See https://web.archive.org/web/20060905133417/http://www.uwsg.iu.edu/hypermail/linux/kernel/0103.0/0453.html + some argumentation which setting should be the default. */ + +/* This header file provides the following facilities: + fpucw_t integral type holding the value of 'fctrl' + FPU_PC_MASK bit mask denoting the precision control + FPU_PC_DOUBLE precision control for 53 bits mantissa + FPU_PC_EXTENDED precision control for 64 bits mantissa + GET_FPUCW () yields the current FPU control word + SET_FPUCW (word) sets the FPU control word + DECL_LONG_DOUBLE_ROUNDING variable declaration for + BEGIN/END_LONG_DOUBLE_ROUNDING + BEGIN_LONG_DOUBLE_ROUNDING () starts a sequence of instructions with + 'long double' safe operation precision + END_LONG_DOUBLE_ROUNDING () ends a sequence of instructions with + 'long double' safe operation precision + */ + +/* Inline assembler like this works only with GNU C and clang. */ +#if (defined __i386__ || defined __x86_64__) && (defined __GNUC__ || defined __clang__) + +typedef unsigned short fpucw_t; /* glibc calls this fpu_control_t */ + +# define FPU_PC_MASK 0x0300 +# define FPU_PC_DOUBLE 0x200 /* glibc calls this _FPU_DOUBLE */ +# define FPU_PC_EXTENDED 0x300 /* glibc calls this _FPU_EXTENDED */ + +# define GET_FPUCW() __extension__ \ + ({ fpucw_t _cw; \ + __asm__ __volatile__ ("fnstcw %0" : "=m" (*&_cw)); \ + _cw; \ + }) +# define SET_FPUCW(word) __extension__ \ + (void)({ fpucw_t _ncw = (word); \ + __asm__ __volatile__ ("fldcw %0" : : "m" (*&_ncw)); \ + }) + +# define DECL_LONG_DOUBLE_ROUNDING \ + fpucw_t oldcw; +# define BEGIN_LONG_DOUBLE_ROUNDING() \ + (void)(oldcw = GET_FPUCW (), \ + SET_FPUCW ((oldcw & ~FPU_PC_MASK) | FPU_PC_EXTENDED)) +# define END_LONG_DOUBLE_ROUNDING() \ + SET_FPUCW (oldcw) + +#else + +typedef unsigned int fpucw_t; + +# define FPU_PC_MASK 0 +# define FPU_PC_DOUBLE 0 +# define FPU_PC_EXTENDED 0 + +# define GET_FPUCW() 0 +# define SET_FPUCW(word) (void)(word) + +# define DECL_LONG_DOUBLE_ROUNDING +# define BEGIN_LONG_DOUBLE_ROUNDING() +# define END_LONG_DOUBLE_ROUNDING() + +#endif + +#endif /* _FPUCW_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/ftruncate.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/ftruncate.c new file mode 100644 index 00000000..63947257 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/ftruncate.c @@ -0,0 +1,195 @@ +/* ftruncate emulations for native Windows. + Copyright (C) 1992-2024 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 . */ + +#include + +/* Specification. */ +#include + +#if HAVE__CHSIZE +/* A native Windows platform. */ + +# include + +# if _GL_WINDOWS_64_BIT_OFF_T + +/* Large File Support: off_t is 64-bit, but _chsize() takes only a 32-bit + argument. So, define a 64-bit safe SetFileSize function ourselves. */ + +/* Ensure that declares GetFileSizeEx. */ +# if !defined _WIN32_WINNT || (_WIN32_WINNT < _WIN32_WINNT_WIN2K) +# undef _WIN32_WINNT +# define _WIN32_WINNT _WIN32_WINNT_WIN2K +# endif + +/* Get declarations of the native Windows API functions. */ +# define WIN32_LEAN_AND_MEAN +# include + +/* Get _get_osfhandle. */ +# if GNULIB_MSVC_NOTHROW +# include "msvc-nothrow.h" +# else +# include +# endif + +static BOOL +SetFileSize (HANDLE h, LONGLONG size) +{ + LARGE_INTEGER old_size; + + if (!GetFileSizeEx (h, &old_size)) + return FALSE; + + if (size != old_size.QuadPart) + { + /* Duplicate the handle, so we are free to modify its file position. */ + HANDLE curr_process = GetCurrentProcess (); + HANDLE tmph; + + if (!DuplicateHandle (curr_process, /* SourceProcessHandle */ + h, /* SourceHandle */ + curr_process, /* TargetProcessHandle */ + (PHANDLE) &tmph, /* TargetHandle */ + (DWORD) 0, /* DesiredAccess */ + FALSE, /* InheritHandle */ + DUPLICATE_SAME_ACCESS)) /* Options */ + return FALSE; + + if (size < old_size.QuadPart) + { + /* Reduce the size. */ + LONG size_hi = (LONG) (size >> 32); + if (SetFilePointer (tmph, (LONG) size, &size_hi, FILE_BEGIN) + == INVALID_SET_FILE_POINTER + && GetLastError() != NO_ERROR) + { + CloseHandle (tmph); + return FALSE; + } + if (!SetEndOfFile (tmph)) + { + CloseHandle (tmph); + return FALSE; + } + } + else + { + /* Increase the size by adding zero bytes at the end. */ + static char zero_bytes[1024]; + LONG pos_hi = 0; + LONG pos_lo = SetFilePointer (tmph, (LONG) 0, &pos_hi, FILE_END); + LONGLONG pos; + if (pos_lo == INVALID_SET_FILE_POINTER + && GetLastError() != NO_ERROR) + { + CloseHandle (tmph); + return FALSE; + } + pos = ((LONGLONG) pos_hi << 32) | (ULONGLONG) (ULONG) pos_lo; + while (pos < size) + { + DWORD written; + LONGLONG count = size - pos; + if (count > sizeof (zero_bytes)) + count = sizeof (zero_bytes); + if (!WriteFile (tmph, zero_bytes, (DWORD) count, &written, NULL) + || written == 0) + { + CloseHandle (tmph); + return FALSE; + } + pos += (ULONGLONG) (ULONG) written; + } + } + /* Close the handle. */ + CloseHandle (tmph); + } + return TRUE; +} + +int +ftruncate (int fd, off_t length) +{ + HANDLE handle = (HANDLE) _get_osfhandle (fd); + + if (handle == INVALID_HANDLE_VALUE) + { + errno = EBADF; + return -1; + } + if (length < 0) + { + errno = EINVAL; + return -1; + } + if (!SetFileSize (handle, length)) + { + switch (GetLastError ()) + { + case ERROR_ACCESS_DENIED: + errno = EACCES; + break; + case ERROR_HANDLE_DISK_FULL: + case ERROR_DISK_FULL: + case ERROR_DISK_TOO_FRAGMENTED: + errno = ENOSPC; + break; + default: + errno = EIO; + break; + } + return -1; + } + return 0; +} + +# else + +# include + +# if HAVE_MSVC_INVALID_PARAMETER_HANDLER +# include "msvc-inval.h" +static int +chsize_nothrow (int fd, long length) +{ + int result; + + TRY_MSVC_INVAL + { + result = _chsize (fd, length); + } + CATCH_MSVC_INVAL + { + result = -1; + errno = EBADF; + } + DONE_MSVC_INVAL; + + return result; +} +# else +# define chsize_nothrow _chsize +# endif + +int +ftruncate (int fd, off_t length) +{ + return chsize_nothrow (fd, length); +} + +# endif +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/glthread/.gitignore b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/glthread/.gitignore new file mode 100644 index 00000000..55a7d140 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/glthread/.gitignore @@ -0,0 +1,2 @@ +/thread.c +/thread.h diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/glthread/thread.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/glthread/thread.c new file mode 100644 index 00000000..9c8c3035 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/glthread/thread.c @@ -0,0 +1,218 @@ +/* Creating and controlling threads. + Copyright (C) 2005-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 2005. + Based on GCC's gthr-posix.h, gthr-posix95.h, gthr-win32.h. */ + +#include + +/* Specification. */ +#include "glthread/thread.h" + +#include +#include "glthread/lock.h" + +/* ========================================================================= */ + +#if USE_ISOC_THREADS + +struct thrd_with_exitvalue +{ + thrd_t volatile tid; + void * volatile exitvalue; +}; + +/* The Thread-Specific Storage (TSS) key that allows to access each thread's + 'struct thrd_with_exitvalue *' pointer. */ +static tss_t thrd_with_exitvalue_key; + +/* Initializes thrd_with_exitvalue_key. + This function must only be called once. */ +static void +do_init_thrd_with_exitvalue_key (void) +{ + if (tss_create (&thrd_with_exitvalue_key, NULL) != thrd_success) + abort (); +} + +/* Initializes thrd_with_exitvalue_key. */ +static void +init_thrd_with_exitvalue_key (void) +{ + static once_flag once = ONCE_FLAG_INIT; + call_once (&once, do_init_thrd_with_exitvalue_key); +} + +typedef union + { + struct thrd_with_exitvalue t; + struct + { + thrd_t tid; /* reserve memory for t.tid */ + void *(*mainfunc) (void *); + void *arg; + } a; + } + main_arg_t; + +static int +thrd_main_func (void *pmarg) +{ + /* Unpack the object that combines mainfunc and arg. */ + main_arg_t *main_arg = (main_arg_t *) pmarg; + void *(*mainfunc) (void *) = main_arg->a.mainfunc; + void *arg = main_arg->a.arg; + + if (tss_set (thrd_with_exitvalue_key, &main_arg->t) != thrd_success) + abort (); + + /* Execute mainfunc, with arg as argument. */ + { + void *exitvalue = mainfunc (arg); + /* Store the exitvalue, for use by glthread_join(). */ + main_arg->t.exitvalue = exitvalue; + return 0; + } +} + +int +glthread_create (gl_thread_t *threadp, void *(*mainfunc) (void *), void *arg) +{ + init_thrd_with_exitvalue_key (); + { + /* Combine mainfunc and arg in a single object. + A stack-allocated object does not work, because it would be out of + existence when thrd_create returns before thrd_main_func is + entered. So, allocate it in the heap. */ + main_arg_t *main_arg = (main_arg_t *) malloc (sizeof (main_arg_t)); + if (main_arg == NULL) + return ENOMEM; + main_arg->a.mainfunc = mainfunc; + main_arg->a.arg = arg; + switch (thrd_create ((thrd_t *) &main_arg->t.tid, thrd_main_func, main_arg)) + { + case thrd_success: + break; + case thrd_nomem: + free (main_arg); + return ENOMEM; + default: + free (main_arg); + return EAGAIN; + } + *threadp = &main_arg->t; + return 0; + } +} + +gl_thread_t +gl_thread_self (void) +{ + init_thrd_with_exitvalue_key (); + { + gl_thread_t thread = + (struct thrd_with_exitvalue *) tss_get (thrd_with_exitvalue_key); + if (thread == NULL) + { + /* This happens only in threads that have not been created through + glthread_create(), such as the main thread. */ + for (;;) + { + thread = + (struct thrd_with_exitvalue *) + malloc (sizeof (struct thrd_with_exitvalue)); + if (thread != NULL) + break; + /* Memory allocation failed. There is not much we can do. Have to + busy-loop, waiting for the availability of memory. */ + { + struct timespec ts = + { + .tv_sec = 1, + .tv_nsec = 0 + }; + thrd_sleep (&ts, NULL); + } + } + thread->tid = thrd_current (); + thread->exitvalue = NULL; /* just to be deterministic */ + if (tss_set (thrd_with_exitvalue_key, thread) != thrd_success) + abort (); + } + return thread; + } +} + +int +glthread_join (gl_thread_t thread, void **return_value_ptr) +{ + /* On Solaris 11.4, thrd_join crashes when the second argument we pass is + NULL. */ + int dummy; + + if (thread == gl_thread_self ()) + return EINVAL; + if (thrd_join (thread->tid, &dummy) != thrd_success) + return EINVAL; + if (return_value_ptr != NULL) + *return_value_ptr = thread->exitvalue; + free (thread); + return 0; +} + +_Noreturn void +gl_thread_exit (void *return_value) +{ + gl_thread_t thread = gl_thread_self (); + thread->exitvalue = return_value; + thrd_exit (0); +} + +#endif + +/* ========================================================================= */ + +#if USE_POSIX_THREADS || USE_ISOC_AND_POSIX_THREADS + +#include + +#if defined PTW32_VERSION || defined __MVS__ + +const gl_thread_t gl_null_thread /* = { .p = NULL } */; + +#endif + +#endif + +/* ========================================================================= */ + +#if USE_WINDOWS_THREADS + +#endif + +/* ========================================================================= */ + +gl_thread_t +gl_thread_create (void *(*func) (void *arg), void *arg) +{ + gl_thread_t thread; + int ret; + + ret = glthread_create (&thread, func, arg); + if (ret != 0) + abort (); + return thread; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/glthread/thread.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/glthread/thread.h new file mode 100644 index 00000000..748bb045 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/glthread/thread.h @@ -0,0 +1,346 @@ +/* Creating and controlling threads. + Copyright (C) 2005-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 2005. + Based on GCC's gthr-posix.h, gthr-posix95.h, gthr-win32.h. */ + +/* This file contains primitives for creating and controlling threads. + + Thread data type: gl_thread_t. + + Creating a thread: + thread = gl_thread_create (func, arg); + Or with control of error handling: + err = glthread_create (&thread, func, arg); + extern int glthread_create (gl_thread_t *result, + void *(*func) (void *), void *arg); + + Querying and changing the signal mask of a thread (not supported on all + platforms): + gl_thread_sigmask (how, newmask, oldmask); + Or with control of error handling: + err = glthread_sigmask (how, newmask, oldmask); + extern int glthread_sigmask (int how, const sigset_t *newmask, sigset_t *oldmask); + + Waiting for termination of another thread: + gl_thread_join (thread, &return_value); + Or with control of error handling: + err = glthread_join (thread, &return_value); + extern int glthread_join (gl_thread_t thread, void **return_value_ptr); + + Getting a reference to the current thread: + current = gl_thread_self (); + extern gl_thread_t gl_thread_self (void); + + Getting a reference to the current thread as a pointer, for debugging: + ptr = gl_thread_self_pointer (); + extern void * gl_thread_self_pointer (void); + + Terminating the current thread: + gl_thread_exit (return_value); + extern _Noreturn void gl_thread_exit (void *return_value); + + Requesting custom code to be executed at fork() time (not supported on all + platforms): + gl_thread_atfork (prepare_func, parent_func, child_func); + Or with control of error handling: + err = glthread_atfork (prepare_func, parent_func, child_func); + extern int glthread_atfork (void (*prepare_func) (void), + void (*parent_func) (void), + void (*child_func) (void)); + Note that even on platforms where this is supported, use of fork() and + threads together is problematic, see + + */ + + +#ifndef _GLTHREAD_THREAD_H +#define _GLTHREAD_THREAD_H + +/* This file uses _Noreturn, HAVE_THREADS_H, HAVE_PTHREAD_ATFORK. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +#include +#include + +#if !defined c11_threads_in_use +# if HAVE_THREADS_H && USE_POSIX_THREADS_FROM_LIBC +# define c11_threads_in_use() 1 +# elif HAVE_THREADS_H && USE_POSIX_THREADS_WEAK +# include +# pragma weak thrd_exit +# define c11_threads_in_use() (thrd_exit != NULL) +# else +# define c11_threads_in_use() 0 +# endif +#endif + +/* ========================================================================= */ + +#if USE_ISOC_THREADS + +/* Use the ISO C threads library. */ + +# include + +# ifdef __cplusplus +extern "C" { +# endif + +/* -------------------------- gl_thread_t datatype -------------------------- */ + +typedef struct thrd_with_exitvalue *gl_thread_t; +extern int glthread_create (gl_thread_t *threadp, + void *(*func) (void *), void *arg); +# define glthread_sigmask(HOW, SET, OSET) \ + pthread_sigmask (HOW, SET, OSET) +extern int glthread_join (gl_thread_t thread, void **return_value_ptr); +extern gl_thread_t gl_thread_self (void); +# define gl_thread_self_pointer() \ + (void *) gl_thread_self () +extern _Noreturn void gl_thread_exit (void *return_value); +# define glthread_atfork(PREPARE_FUNC, PARENT_FUNC, CHILD_FUNC) 0 + +# ifdef __cplusplus +} +# endif + +#endif + +/* ========================================================================= */ + +#if USE_POSIX_THREADS || USE_ISOC_AND_POSIX_THREADS + +/* Use the POSIX threads library. */ + +# include + +/* Get intptr_t. */ +# include + +/* On IRIX, pthread_atfork is declared in , not in . */ +# if defined __sgi +# include +# endif + +# if USE_POSIX_THREADS_WEAK +/* Compilers other than GCC need to see the declaration of pthread_sigmask + before the "#pragma weak pthread_sigmask" below. */ +# include +# endif + +# 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. */ + +# ifndef pthread_sigmask /* Do not declare rpl_pthread_sigmask weak. */ +# pragma weak pthread_sigmask +# endif + +# pragma weak pthread_join +# ifndef pthread_self +# pragma weak pthread_self +# endif +# pragma weak pthread_exit +# if HAVE_PTHREAD_ATFORK +# pragma weak pthread_atfork +# endif + +# if !PTHREAD_IN_USE_DETECTION_HARD +# 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_thread_t datatype -------------------------- */ + +/* This choice of gl_thread_t assumes that + pthread_equal (a, b) is equivalent to ((a) == (b)). + This is the case on all platforms in use in 2008. */ +typedef pthread_t gl_thread_t; +# define glthread_create(THREADP, FUNC, ARG) \ + (pthread_in_use () ? pthread_create (THREADP, NULL, FUNC, ARG) : ENOSYS) +# define glthread_sigmask(HOW, SET, OSET) \ + (pthread_in_use () ? pthread_sigmask (HOW, SET, OSET) : 0) +# define glthread_join(THREAD, RETVALP) \ + (pthread_in_use () ? pthread_join (THREAD, RETVALP) : 0) +# ifdef PTW32_VERSION + /* In pthreads-win32, pthread_t is a struct with a pointer field 'p' and + other fields. */ +# define gl_thread_self() \ + (pthread_in_use () ? pthread_self () : gl_null_thread) +# define gl_thread_self_pointer() \ + (pthread_in_use () ? pthread_self ().p : NULL) +extern const gl_thread_t gl_null_thread; +# elif defined __MVS__ + /* On IBM z/OS, pthread_t is a struct with an 8-byte '__' field. + The first three bytes of this field appear to uniquely identify a + pthread_t, though not necessarily representing a pointer. */ +# define gl_thread_self() \ + (pthread_in_use () ? pthread_self () : gl_null_thread) +# define gl_thread_self_pointer() \ + (pthread_in_use () ? *((void **) pthread_self ().__) : NULL) +extern const gl_thread_t gl_null_thread; +# else +# define gl_thread_self() \ + (pthread_in_use () ? pthread_self () : (pthread_t) 0) +# define gl_thread_self_pointer() \ + (pthread_in_use () ? (void *) (intptr_t) (pthread_t) pthread_self () : NULL) +# endif +# define gl_thread_exit(RETVAL) \ + (void) (pthread_in_use () ? (pthread_exit (RETVAL), 0) : 0) + +# if HAVE_PTHREAD_ATFORK +# define glthread_atfork(PREPARE_FUNC, PARENT_FUNC, CHILD_FUNC) \ + (pthread_in_use () ? pthread_atfork (PREPARE_FUNC, PARENT_FUNC, CHILD_FUNC) : 0) +# else +# define glthread_atfork(PREPARE_FUNC, PARENT_FUNC, CHILD_FUNC) 0 +# endif + +# ifdef __cplusplus +} +# endif + +#endif + +/* ========================================================================= */ + +#if USE_WINDOWS_THREADS + +# define WIN32_LEAN_AND_MEAN /* avoid including junk */ +# include + +# include "windows-thread.h" + +# ifdef __cplusplus +extern "C" { +# endif + +/* -------------------------- gl_thread_t datatype -------------------------- */ + +typedef glwthread_thread_t gl_thread_t; +# define glthread_create(THREADP, FUNC, ARG) \ + glwthread_thread_create (THREADP, 0, FUNC, ARG) +# define glthread_sigmask(HOW, SET, OSET) \ + /* unsupported */ 0 +# define glthread_join(THREAD, RETVALP) \ + glwthread_thread_join (THREAD, RETVALP) +# define gl_thread_self() \ + glwthread_thread_self () +# define gl_thread_self_pointer() \ + gl_thread_self () +# define gl_thread_exit(RETVAL) \ + glwthread_thread_exit (RETVAL) +# define glthread_atfork(PREPARE_FUNC, PARENT_FUNC, CHILD_FUNC) 0 + +# ifdef __cplusplus +} +# endif + +#endif + +/* ========================================================================= */ + +#if !(USE_ISOC_THREADS || USE_POSIX_THREADS || USE_ISOC_AND_POSIX_THREADS || USE_WINDOWS_THREADS) + +/* Provide dummy implementation if threads are not supported. */ + +typedef int gl_thread_t; +# define glthread_create(THREADP, FUNC, ARG) ENOSYS +# define glthread_sigmask(HOW, SET, OSET) 0 +# define glthread_join(THREAD, RETVALP) 0 +# define gl_thread_self() 0 +# define gl_thread_self_pointer() \ + ((void *) gl_thread_self ()) +# define gl_thread_exit(RETVAL) (void)0 +# define glthread_atfork(PREPARE_FUNC, PARENT_FUNC, CHILD_FUNC) 0 + +#endif + +/* ========================================================================= */ + +/* Macros with built-in error handling. */ + +#ifdef __cplusplus +extern "C" { +#endif + +extern gl_thread_t gl_thread_create (void *(*func) (void *arg), void *arg); +#define gl_thread_sigmask(HOW, SET, OSET) \ + do \ + { \ + if (glthread_sigmask (HOW, SET, OSET)) \ + abort (); \ + } \ + while (0) +#define gl_thread_join(THREAD, RETVAL) \ + do \ + { \ + if (glthread_join (THREAD, RETVAL)) \ + abort (); \ + } \ + while (0) +#define gl_thread_atfork(PREPARE, PARENT, CHILD) \ + do \ + { \ + if (glthread_atfork (PREPARE, PARENT, CHILD)) \ + abort (); \ + } \ + while (0) + +#ifdef __cplusplus +} +#endif + +#endif /* _GLTHREAD_THREAD_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/gnulib.mk b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/gnulib.mk new file mode 100644 index 00000000..52eb1225 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/gnulib.mk @@ -0,0 +1,3518 @@ +## DO NOT EDIT! GENERATED AUTOMATICALLY! +## Process this file with automake to produce Makefile.in. +# Copyright (C) 2002-2024 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 +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This file 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 file. If not, see . +# +# As a special exception to the GNU General Public License, +# this file may be distributed as part of a program that +# contains a configuration script generated by Autoconf, under +# the same distribution terms as the rest of that program. +# +# Generated by gnulib-tool. + +AUTOMAKE_OPTIONS = 1.14 foreign subdir-objects + +SUBDIRS = . +TESTS = +XFAIL_TESTS = +TESTS_ENVIRONMENT = +noinst_PROGRAMS = +check_PROGRAMS = +EXTRA_PROGRAMS = +noinst_HEADERS = +noinst_LIBRARIES = +check_LIBRARIES = libtests.a +pkgdata_DATA = +EXTRA_DIST = +BUILT_SOURCES = +SUFFIXES = +MOSTLYCLEANFILES = core *.stackdump +MOSTLYCLEANDIRS = +CLEANFILES = +DISTCLEANFILES = +MAINTAINERCLEANFILES = + +CFLAGS = @GL_CFLAG_ALLOW_WARNINGS@ $(GL_CFLAG_GNULIB_WARNINGS) @CFLAGS@ +CXXFLAGS = @GL_CXXFLAG_ALLOW_WARNINGS@ @CXXFLAGS@ + +AM_CPPFLAGS = \ + -D@gltests_WITNESS@=1 \ + -I. -I$(srcdir) \ + -I.. -I$(srcdir)/.. \ + -I../lib -I$(srcdir)/../lib + +LDADD = libtests.a ../lib/libdiffutils.a libtests.a ../lib/libdiffutils.a libtests.a $(LIBTESTS_LIBDEPS) + +libtests_a_SOURCES = +libtests_a_LIBADD = $(gltests_LIBOBJS) +libtests_a_DEPENDENCIES = $(gltests_LIBOBJS) +EXTRA_libtests_a_SOURCES = +AM_LIBTOOLFLAGS = --preserve-dup-deps + +TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='$(srcdir)' + +## begin gnulib module accept + +if GL_COND_OBJ_ACCEPT +libtests_a_SOURCES += accept.c +endif + +EXTRA_DIST += w32sock.h + +## end gnulib module accept + +## begin gnulib module accept-tests + +TESTS += test-accept +check_PROGRAMS += test-accept +test_accept_LDADD = $(LDADD) @LIBSOCKET@ +EXTRA_DIST += test-accept.c signature.h macros.h + +## end gnulib module accept-tests + +## begin gnulib module alignasof-tests + +TESTS += test-alignasof +check_PROGRAMS += test-alignasof +EXTRA_DIST += test-alignasof.c macros.h + +## end gnulib module alignasof-tests + +## begin gnulib module alloca + + +libtests_a_LIBADD += @ALLOCA@ +libtests_a_DEPENDENCIES += @ALLOCA@ +EXTRA_DIST += alloca.c + +EXTRA_libtests_a_SOURCES += alloca.c + +## end gnulib module alloca + +## begin gnulib module alloca-opt-tests + +TESTS += test-alloca-opt +check_PROGRAMS += test-alloca-opt + +EXTRA_DIST += test-alloca-opt.c + +## end gnulib module alloca-opt-tests + +## begin gnulib module argmatch-tests + +TESTS += test-argmatch +check_PROGRAMS += test-argmatch +test_argmatch_LDADD = $(LDADD) $(LIBUNISTRING) @LIBINTL@ $(MBRTOWC_LIB) $(LIBC32CONV) + +EXTRA_DIST += test-argmatch.c macros.h + +## end gnulib module argmatch-tests + +## begin gnulib module arpa_inet + +BUILT_SOURCES += arpa/inet.h + +# We need the following in order to create when the system +# doesn't have one. +arpa/inet.h: arpa_inet.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H) + $(AM_V_GEN)$(MKDIR_P) '%reldir%/arpa' + $(AM_V_at)$(SED_HEADER_STDOUT) \ + -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|@''HAVE_FEATURES_H''@|$(HAVE_FEATURES_H)|g' \ + -e 's|@''NEXT_ARPA_INET_H''@|$(NEXT_ARPA_INET_H)|g' \ + -e 's|@''HAVE_ARPA_INET_H''@|$(HAVE_ARPA_INET_H)|g' \ + -e 's/@''GNULIB_INET_NTOP''@/$(GL_GNULIB_INET_NTOP)/g' \ + -e 's/@''GNULIB_INET_PTON''@/$(GL_GNULIB_INET_PTON)/g' \ + -e 's|@''HAVE_WS2TCPIP_H''@|$(HAVE_WS2TCPIP_H)|g' \ + -e 's|@''HAVE_DECL_INET_NTOP''@|$(HAVE_DECL_INET_NTOP)|g' \ + -e 's|@''HAVE_DECL_INET_PTON''@|$(HAVE_DECL_INET_PTON)|g' \ + -e 's|@''REPLACE_INET_NTOP''@|$(REPLACE_INET_NTOP)|g' \ + -e 's|@''REPLACE_INET_PTON''@|$(REPLACE_INET_PTON)|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)/arpa_inet.in.h > $@-t + $(AM_V_at)mv $@-t $@ +MOSTLYCLEANFILES += arpa/inet.h arpa/inet.h-t +MOSTLYCLEANDIRS += arpa + +EXTRA_DIST += arpa_inet.in.h + +## end gnulib module arpa_inet + +## begin gnulib module arpa_inet-tests + +TESTS += test-arpa_inet +check_PROGRAMS += test-arpa_inet +EXTRA_DIST += test-arpa_inet.c + +## end gnulib module arpa_inet-tests + +## begin gnulib module assert-h-tests + +TESTS += test-assert +check_PROGRAMS += test-assert +EXTRA_DIST += test-assert.c + +## end gnulib module assert-h-tests + +## begin gnulib module atoll + +if GL_COND_OBJ_ATOLL +libtests_a_SOURCES += atoll.c +endif + +## end gnulib module atoll + +## begin gnulib module binary-io-tests + +TESTS += test-binary-io.sh +check_PROGRAMS += test-binary-io + +EXTRA_DIST += test-binary-io.sh test-binary-io.c macros.h + +## end gnulib module binary-io-tests + +## begin gnulib module bind + +if GL_COND_OBJ_BIND +libtests_a_SOURCES += bind.c +endif + +EXTRA_DIST += w32sock.h + +## end gnulib module bind + +## begin gnulib module bind-tests + +TESTS += test-bind +check_PROGRAMS += test-bind +test_bind_LDADD = $(LDADD) @LIBSOCKET@ $(INET_PTON_LIB) +EXTRA_DIST += test-bind.c signature.h macros.h + +## end gnulib module bind-tests + +## begin gnulib module bitrotate-tests + +TESTS += test-bitrotate +check_PROGRAMS += test-bitrotate +EXTRA_DIST += test-bitrotate.c macros.h + +## end gnulib module bitrotate-tests + +## begin gnulib module btoc32-tests + +TESTS += test-btoc32-1.sh test-btoc32-2.sh test-btoc32-3.sh +TESTS_ENVIRONMENT += LOCALE_FR='@LOCALE_FR@' LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' +check_PROGRAMS += test-btoc32 +test_btoc32_LDADD = $(LDADD) $(LIBUNISTRING) $(SETLOCALE_LIB) $(LIBC32CONV) +EXTRA_DIST += test-btoc32-1.sh test-btoc32-2.sh test-btoc32-3.sh test-btoc32.c signature.h macros.h + +## end gnulib module btoc32-tests + +## begin gnulib module btowc-tests + +TESTS += test-btowc-1.sh test-btowc-2.sh test-btowc-3.sh +TESTS_ENVIRONMENT += LOCALE_FR='@LOCALE_FR@' LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' +check_PROGRAMS += test-btowc +test_btowc_LDADD = $(LDADD) $(SETLOCALE_LIB) +EXTRA_DIST += test-btowc-1.sh test-btowc-2.sh test-btowc-3.sh test-btowc.c signature.h macros.h + +## end gnulib module btowc-tests + +## begin gnulib module c-ctype-tests + +TESTS += test-c-ctype +check_PROGRAMS += test-c-ctype +test_c_ctype_LDADD = $(LDADD) $(SETLOCALE_LIB) +EXTRA_DIST += test-c-ctype.c macros.h + +## end gnulib module c-ctype-tests + +## begin gnulib module c-stack-tests + +TESTS += test-c-stack.sh test-c-stack2.sh +TESTS_ENVIRONMENT += LIBSIGSEGV='@LIBSIGSEGV@' +check_PROGRAMS += test-c-stack +test_c_stack_LDADD = $(LDADD) $(LIBCSTACK) @LIBINTL@ +MOSTLYCLEANFILES += t-c-stack.tmp t-c-stack2.tmp +EXTRA_DIST += test-c-stack.c test-c-stack.sh test-c-stack2.sh macros.h + +## end gnulib module c-stack-tests + +## begin gnulib module c-strcase-tests + +TESTS += test-c-strcase.sh +TESTS_ENVIRONMENT += LOCALE_FR='@LOCALE_FR@' LOCALE_TR_UTF8='@LOCALE_TR_UTF8@' +check_PROGRAMS += test-c-strcasecmp test-c-strncasecmp +test_c_strcasecmp_LDADD = $(LDADD) $(SETLOCALE_LIB) +test_c_strncasecmp_LDADD = $(LDADD) $(SETLOCALE_LIB) +EXTRA_DIST += test-c-strcase.sh test-c-strcasecmp.c test-c-strncasecmp.c macros.h + +## end gnulib module c-strcase-tests + +## begin gnulib module c-strcasestr + +libtests_a_SOURCES += c-strcasestr.h c-strcasestr.c + +EXTRA_DIST += str-two-way.h + +## end gnulib module c-strcasestr + +## begin gnulib module c-strcasestr-tests + +TESTS += test-c-strcasestr +check_PROGRAMS += test-c-strcasestr + +EXTRA_DIST += test-c-strcasestr.c macros.h + +## end gnulib module c-strcasestr-tests + +## begin gnulib module c32_apply_type_test-tests + +TESTS += test-c32_apply_type_test +check_PROGRAMS += test-c32_apply_type_test +test_c32_apply_type_test_LDADD = $(LDADD) $(LIBUNISTRING) $(LIBC32CONV) +EXTRA_DIST += test-c32_apply_type_test.c signature.h macros.h + +## end gnulib module c32_apply_type_test-tests + +## begin gnulib module c32_get_type_test-tests + +TESTS += test-c32_get_type_test +check_PROGRAMS += test-c32_get_type_test +test_c32_get_type_test_LDADD = $(LDADD) $(LIBUNISTRING) $(LIBC32CONV) +EXTRA_DIST += test-c32_get_type_test.c signature.h macros.h + +## end gnulib module c32_get_type_test-tests + +## begin gnulib module c32isalnum-tests + +TESTS += test-c32isalnum.sh +TESTS_ENVIRONMENT += \ + LOCALE_FR='@LOCALE_FR@' \ + LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' \ + LOCALE_JA='@LOCALE_JA@' \ + LOCALE_ZH_CN='@LOCALE_ZH_CN@' +check_PROGRAMS += test-c32isalnum +test_c32isalnum_LDADD = $(LDADD) $(SETLOCALE_LIB) $(MBRTOWC_LIB) $(LIBUNISTRING) $(LIBC32CONV) +EXTRA_DIST += test-c32isalnum.sh test-c32isalnum.c signature.h macros.h + +## end gnulib module c32isalnum-tests + +## begin gnulib module c32isalpha-tests + +TESTS += test-c32isalpha.sh +TESTS_ENVIRONMENT += \ + LOCALE_FR='@LOCALE_FR@' \ + LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' \ + LOCALE_JA='@LOCALE_JA@' \ + LOCALE_ZH_CN='@LOCALE_ZH_CN@' +check_PROGRAMS += test-c32isalpha +test_c32isalpha_LDADD = $(LDADD) $(SETLOCALE_LIB) $(MBRTOWC_LIB) $(LIBUNISTRING) $(LIBC32CONV) +EXTRA_DIST += test-c32isalpha.sh test-c32isalpha.c signature.h macros.h + +## end gnulib module c32isalpha-tests + +## begin gnulib module c32isblank-tests + +TESTS += test-c32isblank.sh +TESTS_ENVIRONMENT += \ + LOCALE_FR='@LOCALE_FR@' \ + LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' \ + LOCALE_JA='@LOCALE_JA@' \ + LOCALE_ZH_CN='@LOCALE_ZH_CN@' +check_PROGRAMS += test-c32isblank +test_c32isblank_LDADD = $(LDADD) $(SETLOCALE_LIB) $(MBRTOWC_LIB) $(LIBUNISTRING) $(LIBC32CONV) +EXTRA_DIST += test-c32isblank.sh test-c32isblank.c signature.h macros.h + +## end gnulib module c32isblank-tests + +## begin gnulib module c32iscntrl-tests + +TESTS += test-c32iscntrl.sh +TESTS_ENVIRONMENT += \ + LOCALE_FR='@LOCALE_FR@' \ + LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' \ + LOCALE_JA='@LOCALE_JA@' \ + LOCALE_ZH_CN='@LOCALE_ZH_CN@' +check_PROGRAMS += test-c32iscntrl +test_c32iscntrl_LDADD = $(LDADD) $(SETLOCALE_LIB) $(MBRTOWC_LIB) $(LIBUNISTRING) $(LIBC32CONV) +EXTRA_DIST += test-c32iscntrl.sh test-c32iscntrl.c signature.h macros.h + +## end gnulib module c32iscntrl-tests + +## begin gnulib module c32isdigit-tests + +TESTS += test-c32isdigit.sh +TESTS_ENVIRONMENT += \ + LOCALE_FR='@LOCALE_FR@' \ + LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' \ + LOCALE_JA='@LOCALE_JA@' \ + LOCALE_ZH_CN='@LOCALE_ZH_CN@' +check_PROGRAMS += test-c32isdigit +test_c32isdigit_LDADD = $(LDADD) $(SETLOCALE_LIB) $(MBRTOWC_LIB) $(LIBUNISTRING) $(LIBC32CONV) +EXTRA_DIST += test-c32isdigit.sh test-c32isdigit.c signature.h macros.h + +## end gnulib module c32isdigit-tests + +## begin gnulib module c32isgraph-tests + +TESTS += test-c32isgraph.sh +TESTS_ENVIRONMENT += \ + LOCALE_FR='@LOCALE_FR@' \ + LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' \ + LOCALE_JA='@LOCALE_JA@' \ + LOCALE_ZH_CN='@LOCALE_ZH_CN@' +check_PROGRAMS += test-c32isgraph +test_c32isgraph_LDADD = $(LDADD) $(SETLOCALE_LIB) $(MBRTOWC_LIB) $(LIBUNISTRING) $(LIBC32CONV) +EXTRA_DIST += test-c32isgraph.sh test-c32isgraph.c signature.h macros.h + +## end gnulib module c32isgraph-tests + +## begin gnulib module c32islower-tests + +TESTS += test-c32islower.sh +TESTS_ENVIRONMENT += \ + LOCALE_FR='@LOCALE_FR@' \ + LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' \ + LOCALE_JA='@LOCALE_JA@' \ + LOCALE_ZH_CN='@LOCALE_ZH_CN@' +check_PROGRAMS += test-c32islower +test_c32islower_LDADD = $(LDADD) $(SETLOCALE_LIB) $(MBRTOWC_LIB) $(LIBUNISTRING) $(LIBC32CONV) +EXTRA_DIST += test-c32islower.sh test-c32islower.c signature.h macros.h + +## end gnulib module c32islower-tests + +## begin gnulib module c32isprint-tests + +TESTS += test-c32isprint.sh +TESTS_ENVIRONMENT += \ + LOCALE_FR='@LOCALE_FR@' \ + LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' \ + LOCALE_JA='@LOCALE_JA@' \ + LOCALE_ZH_CN='@LOCALE_ZH_CN@' +check_PROGRAMS += test-c32isprint +test_c32isprint_LDADD = $(LDADD) $(SETLOCALE_LIB) $(MBRTOWC_LIB) $(LIBUNISTRING) $(LIBC32CONV) +EXTRA_DIST += test-c32isprint.sh test-c32isprint.c signature.h macros.h + +## end gnulib module c32isprint-tests + +## begin gnulib module c32ispunct-tests + +TESTS += test-c32ispunct.sh +TESTS_ENVIRONMENT += \ + LOCALE_FR='@LOCALE_FR@' \ + LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' \ + LOCALE_JA='@LOCALE_JA@' \ + LOCALE_ZH_CN='@LOCALE_ZH_CN@' +check_PROGRAMS += test-c32ispunct +test_c32ispunct_LDADD = $(LDADD) $(SETLOCALE_LIB) $(MBRTOWC_LIB) $(LIBUNISTRING) $(LIBC32CONV) +EXTRA_DIST += test-c32ispunct.sh test-c32ispunct.c signature.h macros.h + +## end gnulib module c32ispunct-tests + +## begin gnulib module c32isspace-tests + +TESTS += test-c32isspace.sh +TESTS_ENVIRONMENT += \ + LOCALE_FR='@LOCALE_FR@' \ + LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' \ + LOCALE_JA='@LOCALE_JA@' \ + LOCALE_ZH_CN='@LOCALE_ZH_CN@' +check_PROGRAMS += test-c32isspace +test_c32isspace_LDADD = $(LDADD) $(SETLOCALE_LIB) $(MBRTOWC_LIB) $(LIBUNISTRING) $(LIBC32CONV) +EXTRA_DIST += test-c32isspace.sh test-c32isspace.c signature.h macros.h + +## end gnulib module c32isspace-tests + +## begin gnulib module c32isupper-tests + +TESTS += test-c32isupper.sh +TESTS_ENVIRONMENT += \ + LOCALE_FR='@LOCALE_FR@' \ + LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' \ + LOCALE_JA='@LOCALE_JA@' \ + LOCALE_ZH_CN='@LOCALE_ZH_CN@' +check_PROGRAMS += test-c32isupper +test_c32isupper_LDADD = $(LDADD) $(SETLOCALE_LIB) $(MBRTOWC_LIB) $(LIBUNISTRING) $(LIBC32CONV) +EXTRA_DIST += test-c32isupper.sh test-c32isupper.c signature.h macros.h + +## end gnulib module c32isupper-tests + +## begin gnulib module c32isxdigit-tests + +TESTS += test-c32isxdigit.sh +TESTS_ENVIRONMENT += \ + LOCALE_FR='@LOCALE_FR@' \ + LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' \ + LOCALE_JA='@LOCALE_JA@' \ + LOCALE_ZH_CN='@LOCALE_ZH_CN@' +check_PROGRAMS += test-c32isxdigit +test_c32isxdigit_LDADD = $(LDADD) $(SETLOCALE_LIB) $(MBRTOWC_LIB) $(LIBUNISTRING) $(LIBC32CONV) +EXTRA_DIST += test-c32isxdigit.sh test-c32isxdigit.c signature.h macros.h + +## end gnulib module c32isxdigit-tests + +## begin gnulib module c32rtomb + +if GL_COND_OBJ_C32RTOMB +libtests_a_SOURCES += c32rtomb.c +endif + +## end gnulib module c32rtomb + +## begin gnulib module c32rtomb-tests + +TESTS += \ + test-c32rtomb.sh \ + test-c32rtomb-w32-2.sh test-c32rtomb-w32-3.sh test-c32rtomb-w32-4.sh \ + test-c32rtomb-w32-5.sh test-c32rtomb-w32-6.sh test-c32rtomb-w32-7.sh \ + test-c32rtomb-w32-8.sh +TESTS_ENVIRONMENT += \ + LOCALE_FR='@LOCALE_FR@' \ + LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' \ + LOCALE_JA='@LOCALE_JA@' \ + LOCALE_ZH_CN='@LOCALE_ZH_CN@' +check_PROGRAMS += test-c32rtomb test-c32rtomb-w32 +test_c32rtomb_LDADD = $(LDADD) $(LIBUNISTRING) $(SETLOCALE_LIB) $(LIBC32CONV) +EXTRA_DIST += test-c32rtomb.sh test-c32rtomb.c test-c32rtomb-w32-2.sh test-c32rtomb-w32-3.sh test-c32rtomb-w32-4.sh test-c32rtomb-w32-5.sh test-c32rtomb-w32-6.sh test-c32rtomb-w32-7.sh test-c32rtomb-w32-8.sh test-c32rtomb-w32.c signature.h macros.h + +## end gnulib module c32rtomb-tests + +## begin gnulib module c32tob + +libtests_a_SOURCES += c32tob.c + +## end gnulib module c32tob + +## begin gnulib module c32tolower-tests + +TESTS += test-c32tolower.sh +TESTS_ENVIRONMENT += \ + LOCALE_FR='@LOCALE_FR@' \ + LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' \ + LOCALE_JA='@LOCALE_JA@' \ + LOCALE_ZH_CN='@LOCALE_ZH_CN@' +check_PROGRAMS += test-c32tolower +test_c32tolower_LDADD = $(LDADD) $(SETLOCALE_LIB) $(MBRTOWC_LIB) $(LIBUNISTRING) $(LIBC32CONV) +EXTRA_DIST += test-c32tolower.sh test-c32tolower.c signature.h macros.h + +## end gnulib module c32tolower-tests + +## begin gnulib module c32width-tests + +TESTS += test-c32width +check_PROGRAMS += test-c32width +test_c32width_LDADD = $(LDADD) $(SETLOCALE_LIB) $(LIBUNISTRING) $(LIBC32CONV) +EXTRA_DIST += test-c32width.c signature.h macros.h + +## end gnulib module c32width-tests + +## begin gnulib module calloc-gnu-tests + +TESTS += test-calloc-gnu +check_PROGRAMS += test-calloc-gnu +EXTRA_DIST += test-calloc-gnu.c macros.h + +## end gnulib module calloc-gnu-tests + +## begin gnulib module chdir-tests + +TESTS += test-chdir +check_PROGRAMS += test-chdir +EXTRA_DIST += test-chdir.c signature.h macros.h + +## end gnulib module chdir-tests + +## begin gnulib module cloexec-tests + +TESTS += test-cloexec +check_PROGRAMS += test-cloexec +EXTRA_DIST += test-cloexec.c macros.h + +## end gnulib module cloexec-tests + +## begin gnulib module close-tests + +TESTS += test-close +check_PROGRAMS += test-close +EXTRA_DIST += test-close.c signature.h macros.h + +## end gnulib module close-tests + +## begin gnulib module connect + +if GL_COND_OBJ_CONNECT +libtests_a_SOURCES += connect.c +endif + +EXTRA_DIST += w32sock.h + +## end gnulib module connect + +## begin gnulib module connect-tests + +TESTS += test-connect +check_PROGRAMS += test-connect +test_connect_LDADD = $(LDADD) @LIBSOCKET@ $(INET_PTON_LIB) +EXTRA_DIST += test-connect.c signature.h macros.h + +## end gnulib module connect-tests + +## begin gnulib module count-leading-zeros-tests + +TESTS += test-count-leading-zeros +check_PROGRAMS += test-count-leading-zeros +EXTRA_DIST += test-count-leading-zeros.c macros.h + +## end gnulib module count-leading-zeros-tests + +## begin gnulib module ctype-tests + +TESTS += test-ctype +check_PROGRAMS += test-ctype +EXTRA_DIST += test-ctype.c + +## end gnulib module ctype-tests + +## begin gnulib module dirent-tests + +TESTS += test-dirent +check_PROGRAMS += test-dirent +EXTRA_DIST += test-dirent.c + +## end gnulib module dirent-tests + +## begin gnulib module dirfd-tests + +TESTS += test-dirfd +check_PROGRAMS += test-dirfd +EXTRA_DIST += test-dirfd.c macros.h + +## end gnulib module dirfd-tests + +## begin gnulib module dirname-tests + +TESTS += test-dirname +check_PROGRAMS += test-dirname +test_dirname_LDADD = $(LDADD) @LIBINTL@ +EXTRA_DIST += test-dirname.c + +## end gnulib module dirname-tests + +## begin gnulib module dtotimespec + +libtests_a_SOURCES += dtotimespec.c + +## end gnulib module dtotimespec + +## begin gnulib module dup-tests + +TESTS += test-dup +check_PROGRAMS += test-dup +EXTRA_DIST += test-dup.c signature.h macros.h + +## end gnulib module dup-tests + +## begin gnulib module dup2-tests + +TESTS += test-dup2 +check_PROGRAMS += test-dup2 +EXTRA_DIST += test-dup2.c signature.h macros.h + +## end gnulib module dup2-tests + +## begin gnulib module environ-tests + +TESTS += test-environ +check_PROGRAMS += test-environ + +EXTRA_DIST += test-environ.c + +## end gnulib module environ-tests + +## begin gnulib module errno-tests + +TESTS += test-errno +check_PROGRAMS += test-errno + +EXTRA_DIST += test-errno.c + +## end gnulib module errno-tests + +## begin gnulib module error-tests + +TESTS += test-error.sh +check_PROGRAMS += test-error +test_error_LDADD = $(LDADD) $(LIBINTL) +EXTRA_DIST += test-error.sh test-error.c macros.h + +## end gnulib module error-tests + +## begin gnulib module exclude-tests + +TESTS += \ + test-exclude1.sh\ + test-exclude2.sh\ + test-exclude3.sh\ + test-exclude4.sh\ + test-exclude5.sh\ + test-exclude6.sh\ + test-exclude7.sh\ + test-exclude8.sh + +check_PROGRAMS += test-exclude +test_exclude_LDADD = $(LDADD) $(LIBUNISTRING) @LIBINTL@ $(MBRTOWC_LIB) $(LIBTHREAD) $(LIBC32CONV) +EXTRA_DIST += test-exclude.c test-exclude1.sh test-exclude2.sh test-exclude3.sh test-exclude4.sh test-exclude5.sh test-exclude6.sh test-exclude7.sh test-exclude8.sh + +## end gnulib module exclude-tests + +## begin gnulib module fchdir-tests + +TESTS += test-fchdir +check_PROGRAMS += test-fchdir +test_fchdir_LDADD = $(LDADD) $(LIBINTL) +EXTRA_DIST += test-fchdir.c signature.h macros.h + +## end gnulib module fchdir-tests + +## begin gnulib module fcntl-h-tests + +TESTS += test-fcntl-h +check_PROGRAMS += test-fcntl-h +EXTRA_DIST += test-fcntl-h.c + +## end gnulib module fcntl-h-tests + +## begin gnulib module fcntl-tests + +TESTS += test-fcntl +check_PROGRAMS += test-fcntl +EXTRA_DIST += test-fcntl.c signature.h macros.h + +## end gnulib module fcntl-tests + +## begin gnulib module fdopen + +if GL_COND_OBJ_FDOPEN +libtests_a_SOURCES += fdopen.c +endif + +## end gnulib module fdopen + +## begin gnulib module fdopen-tests + +TESTS += test-fdopen +check_PROGRAMS += test-fdopen +EXTRA_DIST += test-fdopen.c signature.h macros.h + +## end gnulib module fdopen-tests + +## begin gnulib module fdopendir-tests + +TESTS += test-fdopendir +check_PROGRAMS += test-fdopendir +test_fdopendir_LDADD = $(LDADD) @LIBINTL@ +EXTRA_DIST += test-fdopendir.c signature.h macros.h + +## end gnulib module fdopendir-tests + +## begin gnulib module fgetc-tests + +TESTS += test-fgetc +check_PROGRAMS += test-fgetc +EXTRA_DIST += test-fgetc.c signature.h macros.h + +## end gnulib module fgetc-tests + +## begin gnulib module filenamecat-tests + +TESTS += test-filenamecat +check_PROGRAMS += test-filenamecat +test_filenamecat_LDADD = $(LDADD) @LIBINTL@ +EXTRA_DIST += test-filenamecat.c + +## end gnulib module filenamecat-tests + +## begin gnulib module float + +BUILT_SOURCES += $(FLOAT_H) + +# We need the following in order to create when the system +# doesn't have one that works with the given compiler. +if GL_GENERATE_FLOAT_H +float.h: float.in.h $(top_builddir)/config.status + $(gl_V_at)$(SED_HEADER_STDOUT) \ + -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_FLOAT_H''@|$(NEXT_FLOAT_H)|g' \ + -e 's|@''REPLACE_ITOLD''@|$(REPLACE_ITOLD)|g' \ + $(srcdir)/float.in.h > $@-t + $(AM_V_at)mv $@-t $@ +else +float.h: $(top_builddir)/config.status + rm -f $@ +endif +MOSTLYCLEANFILES += float.h float.h-t + +if GL_COND_OBJ_FLOAT +libtests_a_SOURCES += float.c +endif +if GL_COND_OBJ_ITOLD +libtests_a_SOURCES += itold.c +endif + +EXTRA_DIST += float.in.h + +## end gnulib module float + +## begin gnulib module float-tests + +TESTS += test-float +check_PROGRAMS += test-float +EXTRA_DIST += test-float.c macros.h + +## end gnulib module float-tests + +## begin gnulib module fnmatch-h-tests + +TESTS += test-fnmatch-h +check_PROGRAMS += test-fnmatch-h +EXTRA_DIST += test-fnmatch-h.c + +## end gnulib module fnmatch-h-tests + +## begin gnulib module fnmatch-tests + +TESTS += \ + test-fnmatch-1.sh test-fnmatch-2.sh test-fnmatch-3.sh test-fnmatch-4.sh \ + test-fnmatch-5.sh \ + test-fnmatch-w32-2.sh test-fnmatch-w32-3.sh test-fnmatch-w32-4.sh \ + test-fnmatch-w32-5.sh test-fnmatch-w32-6.sh test-fnmatch-w32-7.sh \ + test-fnmatch-w32-8.sh +TESTS_ENVIRONMENT += \ + LOCALE_FR='@LOCALE_FR@' \ + LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' \ + LOCALE_JA='@LOCALE_JA@' \ + LOCALE_ZH_CN='@LOCALE_ZH_CN@' +check_PROGRAMS += test-fnmatch test-fnmatch-w32 +test_fnmatch_LDADD = $(LDADD) $(SETLOCALE_LIB) $(LIBUNISTRING) $(MBRTOWC_LIB) +test_fnmatch_w32_LDADD = $(LDADD) $(SETLOCALE_LIB) $(LIBUNISTRING) $(MBRTOWC_LIB) +EXTRA_DIST += test-fnmatch-1.sh test-fnmatch-2.sh test-fnmatch-3.sh test-fnmatch-4.sh test-fnmatch-5.sh test-fnmatch.c test-fnmatch-w32-2.sh test-fnmatch-w32-3.sh test-fnmatch-w32-4.sh test-fnmatch-w32-5.sh test-fnmatch-w32-6.sh test-fnmatch-w32-7.sh test-fnmatch-w32-8.sh test-fnmatch-w32.c signature.h macros.h + +## end gnulib module fnmatch-tests + +## begin gnulib module fopen-gnu-tests + +TESTS += test-fopen-gnu +check_PROGRAMS += test-fopen-gnu +EXTRA_DIST += test-fopen-gnu.c macros.h + +## end gnulib module fopen-gnu-tests + +## begin gnulib module fopen-tests + +TESTS += test-fopen +check_PROGRAMS += test-fopen + +EXTRA_DIST += test-fopen.h test-fopen.c signature.h macros.h + +## end gnulib module fopen-tests + +## begin gnulib module fpucw + + +EXTRA_DIST += fpucw.h + +## end gnulib module fpucw + +## begin gnulib module fputc-tests + +TESTS += test-fputc +check_PROGRAMS += test-fputc +EXTRA_DIST += test-fputc.c signature.h macros.h + +## end gnulib module fputc-tests + +## begin gnulib module fread-tests + +TESTS += test-fread +check_PROGRAMS += test-fread +EXTRA_DIST += test-fread.c signature.h macros.h + +## end gnulib module fread-tests + +## begin gnulib module free-posix-tests + +TESTS += test-free +check_PROGRAMS += test-free +EXTRA_DIST += test-free.c macros.h + +## end gnulib module free-posix-tests + +## begin gnulib module freopen-tests + +TESTS += test-freopen +check_PROGRAMS += test-freopen + +EXTRA_DIST += test-freopen.c signature.h macros.h + +## end gnulib module freopen-tests + +## begin gnulib module fstat-tests + +TESTS += test-fstat +check_PROGRAMS += test-fstat +EXTRA_DIST += test-fstat.c signature.h macros.h + +## end gnulib module fstat-tests + +## begin gnulib module fstatat-tests + +TESTS += test-fstatat +check_PROGRAMS += test-fstatat +test_fstatat_LDADD = $(LDADD) @LIBINTL@ +EXTRA_DIST += test-fstatat.c test-lstat.h test-stat.h signature.h macros.h + +## end gnulib module fstatat-tests + +## begin gnulib module ftruncate + +if GL_COND_OBJ_FTRUNCATE +libtests_a_SOURCES += ftruncate.c +endif + +## end gnulib module ftruncate + +## begin gnulib module ftruncate-tests + +TESTS += test-ftruncate.sh +check_PROGRAMS += test-ftruncate +EXTRA_DIST += test-ftruncate.c test-ftruncate.sh signature.h macros.h + +## end gnulib module ftruncate-tests + +## begin gnulib module fwrite-tests + +TESTS += test-fwrite +check_PROGRAMS += test-fwrite +EXTRA_DIST += test-fwrite.c signature.h macros.h + +## end gnulib module fwrite-tests + +## begin gnulib module gen-header + +# In 'sed', replace the pattern space with a "DO NOT EDIT" comment. +SED_HEADER_NOEDIT = s,.*,/* DO NOT EDIT! GENERATED AUTOMATICALLY! */, + +# '$(SED_HEADER_STDOUT) -e "..."' runs 'sed' but first outputs "DO NOT EDIT". +SED_HEADER_STDOUT = sed -e 1h -e '1$(SED_HEADER_NOEDIT)' -e 1G + +# '$(SED_HEADER_TO_AT_t) FILE' copies FILE to $@-t, prepending a leading +# "DO_NOT_EDIT". Although this could be done more simply via: +# SED_HEADER_TO_AT_t = $(SED_HEADER_STDOUT) > $@-t +# the -n and 'w' avoid a fork+exec, at least when GNU Make is used. +SED_HEADER_TO_AT_t = $(SED_HEADER_STDOUT) -n -e 'w $@-t' + +# Use $(gl_V_at) instead of $(AM_V_GEN) or $(AM_V_at) on a line that +# is its recipe's first line if and only if @NMD@ lines are absent. +gl_V_at = $(AM_V_GEN) + +## end gnulib module gen-header + +## begin gnulib module getcwd-lgpl-tests + +TESTS += test-getcwd-lgpl +check_PROGRAMS += test-getcwd-lgpl +test_getcwd_lgpl_LDADD = $(LDADD) $(LIBINTL) +EXTRA_DIST += test-getcwd-lgpl.c signature.h macros.h + +## end gnulib module getcwd-lgpl-tests + +## begin gnulib module getdtablesize-tests + +TESTS += test-getdtablesize +check_PROGRAMS += test-getdtablesize +EXTRA_DIST += test-getdtablesize.c signature.h macros.h + +## end gnulib module getdtablesize-tests + +## begin gnulib module getopt-gnu-tests + +TESTS += test-getopt-gnu +check_PROGRAMS += test-getopt-gnu +test_getopt_gnu_LDADD = $(LDADD) $(LIBINTL) +EXTRA_DIST += macros.h signature.h test-getopt-gnu.c test-getopt-main.h test-getopt.h test-getopt_long.h + +## end gnulib module getopt-gnu-tests + +## begin gnulib module getopt-posix-tests + +TESTS += test-getopt-posix +check_PROGRAMS += test-getopt-posix +test_getopt_posix_LDADD = $(LDADD) $(LIBINTL) +EXTRA_DIST += macros.h signature.h test-getopt-posix.c test-getopt-main.h test-getopt.h + +## end gnulib module getopt-posix-tests + +## begin gnulib module getprogname-tests + +DEFS += -DEXEEXT=\"@EXEEXT@\" +TESTS += test-getprogname +check_PROGRAMS += test-getprogname +test_getprogname_LDADD = $(LDADD) +EXTRA_DIST += test-getprogname.c + +## end gnulib module getprogname-tests + +## begin gnulib module getrandom-tests + +TESTS += test-getrandom +check_PROGRAMS += test-getrandom +test_getrandom_LDADD = $(LDADD) @GETRANDOM_LIB@ +EXTRA_DIST += test-getrandom.c signature.h macros.h + +## end gnulib module getrandom-tests + +## begin gnulib module gettimeofday-tests + +TESTS += test-gettimeofday +check_PROGRAMS += test-gettimeofday + +EXTRA_DIST += test-gettimeofday.c signature.h macros.h + +## end gnulib module gettimeofday-tests + +## begin gnulib module glibc-internal/dynarray-tests + +TESTS += test-dynarray +check_PROGRAMS += test-dynarray +EXTRA_DIST += test-dynarray.c macros.h + +## end gnulib module glibc-internal/dynarray-tests + +## begin gnulib module hard-locale-tests + +TESTS += test-hard-locale +check_PROGRAMS += test-hard-locale +test_hard_locale_LDADD = $(LDADD) $(SETLOCALE_LIB) @HARD_LOCALE_LIB@ +# We cannot call this program 'locale', because the C++ compiler on Mac OS X +# would then barf upon '#include '. So, call it 'current-locale'. +noinst_PROGRAMS += current-locale +current_locale_SOURCES = locale.c +EXTRA_DIST += test-hard-locale.c locale.c + +## end gnulib module hard-locale-tests + +## begin gnulib module hash-pjw + +libtests_a_SOURCES += hash-pjw.h hash-pjw.c + +## end gnulib module hash-pjw + +## begin gnulib module hash-tests + +TESTS += test-hash +check_PROGRAMS += test-hash +EXTRA_DIST += test-hash.c macros.h + +## end gnulib module hash-tests + +## begin gnulib module ignore-value-tests + +TESTS += test-ignore-value +check_PROGRAMS += test-ignore-value +EXTRA_DIST += test-ignore-value.c + +## end gnulib module ignore-value-tests + +## begin gnulib module inet_pton + +if GL_COND_OBJ_INET_PTON +libtests_a_SOURCES += inet_pton.c +endif + +## end gnulib module inet_pton + +## begin gnulib module inet_pton-tests + +TESTS += test-inet_pton +check_PROGRAMS += test-inet_pton +test_inet_pton_LDADD = $(LDADD) @INET_PTON_LIB@ +EXTRA_DIST += test-inet_pton.c signature.h macros.h + +## end gnulib module inet_pton-tests + +## begin gnulib module intprops-tests + +TESTS += test-intprops +check_PROGRAMS += test-intprops +EXTRA_DIST += test-intprops.c macros.h + +## end gnulib module intprops-tests + +## begin gnulib module inttostr + +libtests_a_SOURCES += imaxtostr.c inttostr.c offtostr.c uinttostr.c umaxtostr.c + +EXTRA_DIST += anytostr.c inttostr.h + +EXTRA_libtests_a_SOURCES += anytostr.c + +## end gnulib module inttostr + +## begin gnulib module inttostr-tests + +TESTS += test-inttostr +check_PROGRAMS += test-inttostr +EXTRA_DIST += macros.h test-inttostr.c + +## end gnulib module inttostr-tests + +## begin gnulib module inttypes-tests + +TESTS += test-inttypes +check_PROGRAMS += test-inttypes +EXTRA_DIST += test-inttypes.c + +## end gnulib module inttypes-tests + +## begin gnulib module ioctl + +if GL_COND_OBJ_IOCTL +libtests_a_SOURCES += ioctl.c +endif + +EXTRA_DIST += w32sock.h + +## end gnulib module ioctl + +## begin gnulib module ioctl-tests + +TESTS += test-ioctl +check_PROGRAMS += test-ioctl +EXTRA_DIST += test-ioctl.c signature.h macros.h + +## end gnulib module ioctl-tests + +## begin gnulib module isblank-tests + +TESTS += test-isblank +check_PROGRAMS += test-isblank +EXTRA_DIST += test-isblank.c signature.h macros.h + +## end gnulib module isblank-tests + +## begin gnulib module isnand-nolibm + + +EXTRA_DIST += float+.h isnan.c isnand-nolibm.h isnand.c + +EXTRA_libtests_a_SOURCES += isnan.c isnand.c + +## end gnulib module isnand-nolibm + +## begin gnulib module isnand-nolibm-tests + +TESTS += test-isnand-nolibm +check_PROGRAMS += test-isnand-nolibm + +EXTRA_DIST += test-isnand-nolibm.c test-isnand.h minus-zero.h infinity.h macros.h + +## end gnulib module isnand-nolibm-tests + +## begin gnulib module isnanf-nolibm + + +EXTRA_DIST += float+.h isnan.c isnanf-nolibm.h isnanf.c + +EXTRA_libtests_a_SOURCES += isnan.c isnanf.c + +## end gnulib module isnanf-nolibm + +## begin gnulib module isnanf-nolibm-tests + +TESTS += test-isnanf-nolibm +check_PROGRAMS += test-isnanf-nolibm + +EXTRA_DIST += test-isnanf-nolibm.c test-isnanf.h minus-zero.h infinity.h macros.h + +## end gnulib module isnanf-nolibm-tests + +## begin gnulib module isnanl-nolibm + + +EXTRA_DIST += float+.h isnan.c isnanl-nolibm.h isnanl.c + +EXTRA_libtests_a_SOURCES += isnan.c isnanl.c + +## end gnulib module isnanl-nolibm + +## begin gnulib module isnanl-nolibm-tests + +TESTS += test-isnanl-nolibm +check_PROGRAMS += test-isnanl-nolibm + +EXTRA_DIST += test-isnanl-nolibm.c test-isnanl.h minus-zero.h infinity.h macros.h + +## end gnulib module isnanl-nolibm-tests + +## begin gnulib module iswblank-tests + +TESTS += test-iswblank +check_PROGRAMS += test-iswblank +EXTRA_DIST += test-iswblank.c macros.h + +## end gnulib module iswblank-tests + +## begin gnulib module iswctype-tests + +TESTS += test-iswctype +check_PROGRAMS += test-iswctype +EXTRA_DIST += test-iswctype.c signature.h macros.h + +## end gnulib module iswctype-tests + +## begin gnulib module iswdigit-tests + +TESTS += test-iswdigit.sh +TESTS_ENVIRONMENT += \ + LOCALE_FR='@LOCALE_FR@' \ + LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' \ + LOCALE_JA='@LOCALE_JA@' \ + LOCALE_ZH_CN='@LOCALE_ZH_CN@' +check_PROGRAMS += test-iswdigit +test_iswdigit_LDADD = $(LDADD) $(SETLOCALE_LIB) $(MBRTOWC_LIB) +EXTRA_DIST += test-iswdigit.sh test-iswdigit.c signature.h macros.h + +## end gnulib module iswdigit-tests + +## begin gnulib module iswpunct-tests + +TESTS += test-iswpunct.sh +check_PROGRAMS += test-iswpunct +test_iswpunct_LDADD = $(LDADD) $(SETLOCALE_LIB) $(MBRTOWC_LIB) +EXTRA_DIST += test-iswpunct.sh test-iswpunct.c signature.h macros.h + +## end gnulib module iswpunct-tests + +## begin gnulib module iswxdigit-tests + +TESTS += test-iswxdigit.sh +TESTS_ENVIRONMENT += \ + LOCALE_FR='@LOCALE_FR@' \ + LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' \ + LOCALE_JA='@LOCALE_JA@' \ + LOCALE_ZH_CN='@LOCALE_ZH_CN@' +check_PROGRAMS += test-iswxdigit +test_iswxdigit_LDADD = $(LDADD) $(SETLOCALE_LIB) $(MBRTOWC_LIB) +EXTRA_DIST += test-iswxdigit.sh test-iswxdigit.c signature.h macros.h + +## end gnulib module iswxdigit-tests + +## begin gnulib module langinfo-tests + +TESTS += test-langinfo +check_PROGRAMS += test-langinfo +EXTRA_DIST += test-langinfo.c + +## end gnulib module langinfo-tests + +## begin gnulib module largefile-tests + +TESTS += test-largefile +check_PROGRAMS += test-largefile +EXTRA_DIST += test-largefile.c + +## end gnulib module largefile-tests + +## begin gnulib module limits-h-tests + +TESTS += test-limits-h +check_PROGRAMS += test-limits-h +EXTRA_DIST += test-limits-h.c + +## end gnulib module limits-h-tests + +## begin gnulib module listen + +if GL_COND_OBJ_LISTEN +libtests_a_SOURCES += listen.c +endif + +EXTRA_DIST += w32sock.h + +## end gnulib module listen + +## begin gnulib module listen-tests + +TESTS += test-listen +check_PROGRAMS += test-listen +test_listen_LDADD = $(LDADD) @LIBSOCKET@ +EXTRA_DIST += test-listen.c signature.h macros.h + +## end gnulib module listen-tests + +## begin gnulib module localcharset-tests + +noinst_PROGRAMS += test-localcharset +test_localcharset_LDADD = $(LDADD) $(SETLOCALE_LIB) +EXTRA_DIST += test-localcharset.c + +## end gnulib module localcharset-tests + +## begin gnulib module locale-tests + +TESTS += test-locale +check_PROGRAMS += test-locale +EXTRA_DIST += test-locale.c + +## end gnulib module locale-tests + +## begin gnulib module localeconv-tests + +TESTS += test-localeconv +check_PROGRAMS += test-localeconv +EXTRA_DIST += test-localeconv.c signature.h macros.h + +## end gnulib module localeconv-tests + +## begin gnulib module lstat-tests + +TESTS += test-lstat +check_PROGRAMS += test-lstat +EXTRA_DIST += test-lstat.h test-lstat.c signature.h macros.h + +## end gnulib module lstat-tests + +## begin gnulib module malloc-gnu-tests + +TESTS += test-malloc-gnu +check_PROGRAMS += test-malloc-gnu +EXTRA_DIST += test-malloc-gnu.c macros.h + +## end gnulib module malloc-gnu-tests + +## begin gnulib module malloca-tests + +TESTS += test-malloca +check_PROGRAMS += test-malloca + +EXTRA_DIST += test-malloca.c + +## end gnulib module malloca-tests + +## begin gnulib module math + +BUILT_SOURCES += math.h +libtests_a_SOURCES += math.c + +# We need the following in order to create when the system +# doesn't have one that works with the given compiler. +math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) + $(gl_V_at)$(SED_HEADER_STDOUT) \ + -e 's|@''GUARD_PREFIX''@|GL|g' \ + -e 's|@''INCLUDE_NEXT_AS_FIRST_DIRECTIVE''@|$(INCLUDE_NEXT_AS_FIRST_DIRECTIVE)|g' \ + -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ + -e 's|@''NEXT_AS_FIRST_DIRECTIVE_MATH_H''@|$(NEXT_AS_FIRST_DIRECTIVE_MATH_H)|g' \ + -e 's/@''GNULIB_ACOSF''@/$(GL_GNULIB_ACOSF)/g' \ + -e 's/@''GNULIB_ACOSL''@/$(GL_GNULIB_ACOSL)/g' \ + -e 's/@''GNULIB_ASINF''@/$(GL_GNULIB_ASINF)/g' \ + -e 's/@''GNULIB_ASINL''@/$(GL_GNULIB_ASINL)/g' \ + -e 's/@''GNULIB_ATANF''@/$(GL_GNULIB_ATANF)/g' \ + -e 's/@''GNULIB_ATANL''@/$(GL_GNULIB_ATANL)/g' \ + -e 's/@''GNULIB_ATAN2F''@/$(GL_GNULIB_ATAN2F)/g' \ + -e 's/@''GNULIB_CBRT''@/$(GL_GNULIB_CBRT)/g' \ + -e 's/@''GNULIB_CBRTF''@/$(GL_GNULIB_CBRTF)/g' \ + -e 's/@''GNULIB_CBRTL''@/$(GL_GNULIB_CBRTL)/g' \ + -e 's/@''GNULIB_CEIL''@/$(GL_GNULIB_CEIL)/g' \ + -e 's/@''GNULIB_CEILF''@/$(GL_GNULIB_CEILF)/g' \ + -e 's/@''GNULIB_CEILL''@/$(GL_GNULIB_CEILL)/g' \ + -e 's/@''GNULIB_COPYSIGN''@/$(GL_GNULIB_COPYSIGN)/g' \ + -e 's/@''GNULIB_COPYSIGNF''@/$(GL_GNULIB_COPYSIGNF)/g' \ + -e 's/@''GNULIB_COPYSIGNL''@/$(GL_GNULIB_COPYSIGNL)/g' \ + -e 's/@''GNULIB_COSF''@/$(GL_GNULIB_COSF)/g' \ + -e 's/@''GNULIB_COSL''@/$(GL_GNULIB_COSL)/g' \ + -e 's/@''GNULIB_COSHF''@/$(GL_GNULIB_COSHF)/g' \ + -e 's/@''GNULIB_EXPF''@/$(GL_GNULIB_EXPF)/g' \ + -e 's/@''GNULIB_EXPL''@/$(GL_GNULIB_EXPL)/g' \ + -e 's/@''GNULIB_EXP2''@/$(GL_GNULIB_EXP2)/g' \ + -e 's/@''GNULIB_EXP2F''@/$(GL_GNULIB_EXP2F)/g' \ + -e 's/@''GNULIB_EXP2L''@/$(GL_GNULIB_EXP2L)/g' \ + -e 's/@''GNULIB_EXPM1''@/$(GL_GNULIB_EXPM1)/g' \ + -e 's/@''GNULIB_EXPM1F''@/$(GL_GNULIB_EXPM1F)/g' \ + -e 's/@''GNULIB_EXPM1L''@/$(GL_GNULIB_EXPM1L)/g' \ + -e 's/@''GNULIB_FABSF''@/$(GL_GNULIB_FABSF)/g' \ + -e 's/@''GNULIB_FABSL''@/$(GL_GNULIB_FABSL)/g' \ + -e 's/@''GNULIB_FLOOR''@/$(GL_GNULIB_FLOOR)/g' \ + -e 's/@''GNULIB_FLOORF''@/$(GL_GNULIB_FLOORF)/g' \ + -e 's/@''GNULIB_FLOORL''@/$(GL_GNULIB_FLOORL)/g' \ + -e 's/@''GNULIB_FMA''@/$(GL_GNULIB_FMA)/g' \ + -e 's/@''GNULIB_FMAF''@/$(GL_GNULIB_FMAF)/g' \ + -e 's/@''GNULIB_FMAL''@/$(GL_GNULIB_FMAL)/g' \ + -e 's/@''GNULIB_FMOD''@/$(GL_GNULIB_FMOD)/g' \ + -e 's/@''GNULIB_FMODF''@/$(GL_GNULIB_FMODF)/g' \ + -e 's/@''GNULIB_FMODL''@/$(GL_GNULIB_FMODL)/g' \ + -e 's/@''GNULIB_FREXPF''@/$(GL_GNULIB_FREXPF)/g' \ + -e 's/@''GNULIB_FREXP''@/$(GL_GNULIB_FREXP)/g' \ + -e 's/@''GNULIB_FREXPL''@/$(GL_GNULIB_FREXPL)/g' \ + -e 's/@''GNULIB_HYPOT''@/$(GL_GNULIB_HYPOT)/g' \ + -e 's/@''GNULIB_HYPOTF''@/$(GL_GNULIB_HYPOTF)/g' \ + -e 's/@''GNULIB_HYPOTL''@/$(GL_GNULIB_HYPOTL)/g' \ + < $(srcdir)/math.in.h > $@-t1 + $(AM_V_at)sed \ + -e 's/@''GNULIB_ILOGB''@/$(GL_GNULIB_ILOGB)/g' \ + -e 's/@''GNULIB_ILOGBF''@/$(GL_GNULIB_ILOGBF)/g' \ + -e 's/@''GNULIB_ILOGBL''@/$(GL_GNULIB_ILOGBL)/g' \ + -e 's/@''GNULIB_ISFINITE''@/$(GL_GNULIB_ISFINITE)/g' \ + -e 's/@''GNULIB_ISINF''@/$(GL_GNULIB_ISINF)/g' \ + -e 's/@''GNULIB_ISNAN''@/$(GL_GNULIB_ISNAN)/g' \ + -e 's/@''GNULIB_ISNANF''@/$(GL_GNULIB_ISNANF)/g' \ + -e 's/@''GNULIB_ISNAND''@/$(GL_GNULIB_ISNAND)/g' \ + -e 's/@''GNULIB_ISNANL''@/$(GL_GNULIB_ISNANL)/g' \ + -e 's/@''GNULIB_LDEXP''@/$(GL_GNULIB_LDEXP)/g' \ + -e 's/@''GNULIB_LDEXPF''@/$(GL_GNULIB_LDEXPF)/g' \ + -e 's/@''GNULIB_LDEXPL''@/$(GL_GNULIB_LDEXPL)/g' \ + -e 's/@''GNULIB_LOG''@/$(GL_GNULIB_LOG)/g' \ + -e 's/@''GNULIB_LOGF''@/$(GL_GNULIB_LOGF)/g' \ + -e 's/@''GNULIB_LOGL''@/$(GL_GNULIB_LOGL)/g' \ + -e 's/@''GNULIB_LOG10''@/$(GL_GNULIB_LOG10)/g' \ + -e 's/@''GNULIB_LOG10F''@/$(GL_GNULIB_LOG10F)/g' \ + -e 's/@''GNULIB_LOG10L''@/$(GL_GNULIB_LOG10L)/g' \ + -e 's/@''GNULIB_LOG1P''@/$(GL_GNULIB_LOG1P)/g' \ + -e 's/@''GNULIB_LOG1PF''@/$(GL_GNULIB_LOG1PF)/g' \ + -e 's/@''GNULIB_LOG1PL''@/$(GL_GNULIB_LOG1PL)/g' \ + -e 's/@''GNULIB_LOG2''@/$(GL_GNULIB_LOG2)/g' \ + -e 's/@''GNULIB_LOG2F''@/$(GL_GNULIB_LOG2F)/g' \ + -e 's/@''GNULIB_LOG2L''@/$(GL_GNULIB_LOG2L)/g' \ + -e 's/@''GNULIB_LOGB''@/$(GL_GNULIB_LOGB)/g' \ + -e 's/@''GNULIB_LOGBF''@/$(GL_GNULIB_LOGBF)/g' \ + -e 's/@''GNULIB_LOGBL''@/$(GL_GNULIB_LOGBL)/g' \ + -e 's/@''GNULIB_MODF''@/$(GL_GNULIB_MODF)/g' \ + -e 's/@''GNULIB_MODFF''@/$(GL_GNULIB_MODFF)/g' \ + -e 's/@''GNULIB_MODFL''@/$(GL_GNULIB_MODFL)/g' \ + -e 's/@''GNULIB_POWF''@/$(GL_GNULIB_POWF)/g' \ + -e 's/@''GNULIB_REMAINDER''@/$(GL_GNULIB_REMAINDER)/g' \ + -e 's/@''GNULIB_REMAINDERF''@/$(GL_GNULIB_REMAINDERF)/g' \ + -e 's/@''GNULIB_REMAINDERL''@/$(GL_GNULIB_REMAINDERL)/g' \ + -e 's/@''GNULIB_RINT''@/$(GL_GNULIB_RINT)/g' \ + -e 's/@''GNULIB_RINTF''@/$(GL_GNULIB_RINTF)/g' \ + -e 's/@''GNULIB_RINTL''@/$(GL_GNULIB_RINTL)/g' \ + -e 's/@''GNULIB_ROUND''@/$(GL_GNULIB_ROUND)/g' \ + -e 's/@''GNULIB_ROUNDF''@/$(GL_GNULIB_ROUNDF)/g' \ + -e 's/@''GNULIB_ROUNDL''@/$(GL_GNULIB_ROUNDL)/g' \ + -e 's/@''GNULIB_SIGNBIT''@/$(GL_GNULIB_SIGNBIT)/g' \ + -e 's/@''GNULIB_SINF''@/$(GL_GNULIB_SINF)/g' \ + -e 's/@''GNULIB_SINL''@/$(GL_GNULIB_SINL)/g' \ + -e 's/@''GNULIB_SINHF''@/$(GL_GNULIB_SINHF)/g' \ + -e 's/@''GNULIB_SQRTF''@/$(GL_GNULIB_SQRTF)/g' \ + -e 's/@''GNULIB_SQRTL''@/$(GL_GNULIB_SQRTL)/g' \ + -e 's/@''GNULIB_TANF''@/$(GL_GNULIB_TANF)/g' \ + -e 's/@''GNULIB_TANL''@/$(GL_GNULIB_TANL)/g' \ + -e 's/@''GNULIB_TANHF''@/$(GL_GNULIB_TANHF)/g' \ + -e 's/@''GNULIB_TRUNC''@/$(GL_GNULIB_TRUNC)/g' \ + -e 's/@''GNULIB_TRUNCF''@/$(GL_GNULIB_TRUNCF)/g' \ + -e 's/@''GNULIB_TRUNCL''@/$(GL_GNULIB_TRUNCL)/g' \ + -e 's/@''GNULIB_TOTALORDER''@/$(GL_GNULIB_TOTALORDER)/g' \ + -e 's/@''GNULIB_TOTALORDERF''@/$(GL_GNULIB_TOTALORDERF)/g' \ + -e 's/@''GNULIB_TOTALORDERL''@/$(GL_GNULIB_TOTALORDERL)/g' \ + -e 's/@''GNULIB_MDA_J0''@/$(GL_GNULIB_MDA_J0)/g' \ + -e 's/@''GNULIB_MDA_J1''@/$(GL_GNULIB_MDA_J1)/g' \ + -e 's/@''GNULIB_MDA_JN''@/$(GL_GNULIB_MDA_JN)/g' \ + -e 's/@''GNULIB_MDA_Y0''@/$(GL_GNULIB_MDA_Y0)/g' \ + -e 's/@''GNULIB_MDA_Y1''@/$(GL_GNULIB_MDA_Y1)/g' \ + -e 's/@''GNULIB_MDA_YN''@/$(GL_GNULIB_MDA_YN)/g' \ + < $@-t1 > $@-t2 + $(AM_V_at)sed \ + -e 's|@''HAVE_ACOSF''@|$(HAVE_ACOSF)|g' \ + -e 's|@''HAVE_ACOSL''@|$(HAVE_ACOSL)|g' \ + -e 's|@''HAVE_ASINF''@|$(HAVE_ASINF)|g' \ + -e 's|@''HAVE_ASINL''@|$(HAVE_ASINL)|g' \ + -e 's|@''HAVE_ATANF''@|$(HAVE_ATANF)|g' \ + -e 's|@''HAVE_ATANL''@|$(HAVE_ATANL)|g' \ + -e 's|@''HAVE_ATAN2F''@|$(HAVE_ATAN2F)|g' \ + -e 's|@''HAVE_CBRT''@|$(HAVE_CBRT)|g' \ + -e 's|@''HAVE_CBRTF''@|$(HAVE_CBRTF)|g' \ + -e 's|@''HAVE_CBRTL''@|$(HAVE_CBRTL)|g' \ + -e 's|@''HAVE_COPYSIGN''@|$(HAVE_COPYSIGN)|g' \ + -e 's|@''HAVE_COPYSIGNL''@|$(HAVE_COPYSIGNL)|g' \ + -e 's|@''HAVE_COSF''@|$(HAVE_COSF)|g' \ + -e 's|@''HAVE_COSL''@|$(HAVE_COSL)|g' \ + -e 's|@''HAVE_COSHF''@|$(HAVE_COSHF)|g' \ + -e 's|@''HAVE_EXPF''@|$(HAVE_EXPF)|g' \ + -e 's|@''HAVE_EXPL''@|$(HAVE_EXPL)|g' \ + -e 's|@''HAVE_EXPM1''@|$(HAVE_EXPM1)|g' \ + -e 's|@''HAVE_EXPM1F''@|$(HAVE_EXPM1F)|g' \ + -e 's|@''HAVE_FABSF''@|$(HAVE_FABSF)|g' \ + -e 's|@''HAVE_FABSL''@|$(HAVE_FABSL)|g' \ + -e 's|@''HAVE_FMA''@|$(HAVE_FMA)|g' \ + -e 's|@''HAVE_FMAF''@|$(HAVE_FMAF)|g' \ + -e 's|@''HAVE_FMAL''@|$(HAVE_FMAL)|g' \ + -e 's|@''HAVE_FMODF''@|$(HAVE_FMODF)|g' \ + -e 's|@''HAVE_FMODL''@|$(HAVE_FMODL)|g' \ + -e 's|@''HAVE_FREXPF''@|$(HAVE_FREXPF)|g' \ + -e 's|@''HAVE_HYPOTF''@|$(HAVE_HYPOTF)|g' \ + -e 's|@''HAVE_HYPOTL''@|$(HAVE_HYPOTL)|g' \ + -e 's|@''HAVE_ILOGB''@|$(HAVE_ILOGB)|g' \ + -e 's|@''HAVE_ILOGBF''@|$(HAVE_ILOGBF)|g' \ + -e 's|@''HAVE_ILOGBL''@|$(HAVE_ILOGBL)|g' \ + -e 's|@''HAVE_ISNANF''@|$(HAVE_ISNANF)|g' \ + -e 's|@''HAVE_ISNAND''@|$(HAVE_ISNAND)|g' \ + -e 's|@''HAVE_ISNANL''@|$(HAVE_ISNANL)|g' \ + -e 's|@''HAVE_LDEXPF''@|$(HAVE_LDEXPF)|g' \ + -e 's|@''HAVE_LOGF''@|$(HAVE_LOGF)|g' \ + -e 's|@''HAVE_LOGL''@|$(HAVE_LOGL)|g' \ + -e 's|@''HAVE_LOG10F''@|$(HAVE_LOG10F)|g' \ + -e 's|@''HAVE_LOG10L''@|$(HAVE_LOG10L)|g' \ + -e 's|@''HAVE_LOG1P''@|$(HAVE_LOG1P)|g' \ + -e 's|@''HAVE_LOG1PF''@|$(HAVE_LOG1PF)|g' \ + -e 's|@''HAVE_LOG1PL''@|$(HAVE_LOG1PL)|g' \ + -e 's|@''HAVE_LOGBF''@|$(HAVE_LOGBF)|g' \ + -e 's|@''HAVE_LOGBL''@|$(HAVE_LOGBL)|g' \ + -e 's|@''HAVE_MODFF''@|$(HAVE_MODFF)|g' \ + -e 's|@''HAVE_MODFL''@|$(HAVE_MODFL)|g' \ + -e 's|@''HAVE_POWF''@|$(HAVE_POWF)|g' \ + -e 's|@''HAVE_REMAINDER''@|$(HAVE_REMAINDER)|g' \ + -e 's|@''HAVE_REMAINDERF''@|$(HAVE_REMAINDERF)|g' \ + -e 's|@''HAVE_RINT''@|$(HAVE_RINT)|g' \ + -e 's|@''HAVE_RINTL''@|$(HAVE_RINTL)|g' \ + -e 's|@''HAVE_SINF''@|$(HAVE_SINF)|g' \ + -e 's|@''HAVE_SINL''@|$(HAVE_SINL)|g' \ + -e 's|@''HAVE_SINHF''@|$(HAVE_SINHF)|g' \ + -e 's|@''HAVE_SQRTF''@|$(HAVE_SQRTF)|g' \ + -e 's|@''HAVE_SQRTL''@|$(HAVE_SQRTL)|g' \ + -e 's|@''HAVE_TANF''@|$(HAVE_TANF)|g' \ + -e 's|@''HAVE_TANL''@|$(HAVE_TANL)|g' \ + -e 's|@''HAVE_TANHF''@|$(HAVE_TANHF)|g' \ + -e 's|@''HAVE_TOTALORDER''@|$(HAVE_TOTALORDER)|g' \ + -e 's|@''HAVE_TOTALORDERF''@|$(HAVE_TOTALORDERF)|g' \ + -e 's|@''HAVE_TOTALORDERL''@|$(HAVE_TOTALORDERL)|g' \ + < $@-t2 > $@-t3 + $(AM_V_at)sed \ + -e 's|@''HAVE_DECL_ACOSL''@|$(HAVE_DECL_ACOSL)|g' \ + -e 's|@''HAVE_DECL_ASINL''@|$(HAVE_DECL_ASINL)|g' \ + -e 's|@''HAVE_DECL_ATANL''@|$(HAVE_DECL_ATANL)|g' \ + -e 's|@''HAVE_DECL_CBRTF''@|$(HAVE_DECL_CBRTF)|g' \ + -e 's|@''HAVE_DECL_CBRTL''@|$(HAVE_DECL_CBRTL)|g' \ + -e 's|@''HAVE_DECL_CEILF''@|$(HAVE_DECL_CEILF)|g' \ + -e 's|@''HAVE_DECL_CEILL''@|$(HAVE_DECL_CEILL)|g' \ + -e 's|@''HAVE_DECL_COPYSIGNF''@|$(HAVE_DECL_COPYSIGNF)|g' \ + -e 's|@''HAVE_DECL_COSL''@|$(HAVE_DECL_COSL)|g' \ + -e 's|@''HAVE_DECL_EXPL''@|$(HAVE_DECL_EXPL)|g' \ + -e 's|@''HAVE_DECL_EXP2''@|$(HAVE_DECL_EXP2)|g' \ + -e 's|@''HAVE_DECL_EXP2F''@|$(HAVE_DECL_EXP2F)|g' \ + -e 's|@''HAVE_DECL_EXP2L''@|$(HAVE_DECL_EXP2L)|g' \ + -e 's|@''HAVE_DECL_EXPM1L''@|$(HAVE_DECL_EXPM1L)|g' \ + -e 's|@''HAVE_DECL_FLOORF''@|$(HAVE_DECL_FLOORF)|g' \ + -e 's|@''HAVE_DECL_FLOORL''@|$(HAVE_DECL_FLOORL)|g' \ + -e 's|@''HAVE_DECL_FREXPL''@|$(HAVE_DECL_FREXPL)|g' \ + -e 's|@''HAVE_DECL_LDEXPL''@|$(HAVE_DECL_LDEXPL)|g' \ + -e 's|@''HAVE_DECL_LOGL''@|$(HAVE_DECL_LOGL)|g' \ + -e 's|@''HAVE_DECL_LOG10L''@|$(HAVE_DECL_LOG10L)|g' \ + -e 's|@''HAVE_DECL_LOG2''@|$(HAVE_DECL_LOG2)|g' \ + -e 's|@''HAVE_DECL_LOG2F''@|$(HAVE_DECL_LOG2F)|g' \ + -e 's|@''HAVE_DECL_LOG2L''@|$(HAVE_DECL_LOG2L)|g' \ + -e 's|@''HAVE_DECL_LOGB''@|$(HAVE_DECL_LOGB)|g' \ + -e 's|@''HAVE_DECL_REMAINDER''@|$(HAVE_DECL_REMAINDER)|g' \ + -e 's|@''HAVE_DECL_REMAINDERL''@|$(HAVE_DECL_REMAINDERL)|g' \ + -e 's|@''HAVE_DECL_RINTF''@|$(HAVE_DECL_RINTF)|g' \ + -e 's|@''HAVE_DECL_ROUND''@|$(HAVE_DECL_ROUND)|g' \ + -e 's|@''HAVE_DECL_ROUNDF''@|$(HAVE_DECL_ROUNDF)|g' \ + -e 's|@''HAVE_DECL_ROUNDL''@|$(HAVE_DECL_ROUNDL)|g' \ + -e 's|@''HAVE_DECL_SINL''@|$(HAVE_DECL_SINL)|g' \ + -e 's|@''HAVE_DECL_SQRTL''@|$(HAVE_DECL_SQRTL)|g' \ + -e 's|@''HAVE_DECL_TANL''@|$(HAVE_DECL_TANL)|g' \ + -e 's|@''HAVE_DECL_TRUNC''@|$(HAVE_DECL_TRUNC)|g' \ + -e 's|@''HAVE_DECL_TRUNCF''@|$(HAVE_DECL_TRUNCF)|g' \ + -e 's|@''HAVE_DECL_TRUNCL''@|$(HAVE_DECL_TRUNCL)|g' \ + < $@-t3 > $@-t4 + $(AM_V_at)sed \ + -e 's|@''REPLACE_ACOSF''@|$(REPLACE_ACOSF)|g' \ + -e 's|@''REPLACE_ASINF''@|$(REPLACE_ASINF)|g' \ + -e 's|@''REPLACE_ATANF''@|$(REPLACE_ATANF)|g' \ + -e 's|@''REPLACE_ATAN2F''@|$(REPLACE_ATAN2F)|g' \ + -e 's|@''REPLACE_CBRTF''@|$(REPLACE_CBRTF)|g' \ + -e 's|@''REPLACE_CBRTL''@|$(REPLACE_CBRTL)|g' \ + -e 's|@''REPLACE_CEIL''@|$(REPLACE_CEIL)|g' \ + -e 's|@''REPLACE_CEILF''@|$(REPLACE_CEILF)|g' \ + -e 's|@''REPLACE_CEILL''@|$(REPLACE_CEILL)|g' \ + -e 's|@''REPLACE_COSF''@|$(REPLACE_COSF)|g' \ + -e 's|@''REPLACE_COSHF''@|$(REPLACE_COSHF)|g' \ + -e 's|@''REPLACE_EXPF''@|$(REPLACE_EXPF)|g' \ + -e 's|@''REPLACE_EXPL''@|$(REPLACE_EXPL)|g' \ + -e 's|@''REPLACE_EXPM1''@|$(REPLACE_EXPM1)|g' \ + -e 's|@''REPLACE_EXPM1F''@|$(REPLACE_EXPM1F)|g' \ + -e 's|@''REPLACE_EXPM1L''@|$(REPLACE_EXPM1L)|g' \ + -e 's|@''REPLACE_EXP2''@|$(REPLACE_EXP2)|g' \ + -e 's|@''REPLACE_EXP2L''@|$(REPLACE_EXP2L)|g' \ + -e 's|@''REPLACE_FABSL''@|$(REPLACE_FABSL)|g' \ + -e 's|@''REPLACE_FLOOR''@|$(REPLACE_FLOOR)|g' \ + -e 's|@''REPLACE_FLOORF''@|$(REPLACE_FLOORF)|g' \ + -e 's|@''REPLACE_FLOORL''@|$(REPLACE_FLOORL)|g' \ + -e 's|@''REPLACE_FMA''@|$(REPLACE_FMA)|g' \ + -e 's|@''REPLACE_FMAF''@|$(REPLACE_FMAF)|g' \ + -e 's|@''REPLACE_FMAL''@|$(REPLACE_FMAL)|g' \ + -e 's|@''REPLACE_FMOD''@|$(REPLACE_FMOD)|g' \ + -e 's|@''REPLACE_FMODF''@|$(REPLACE_FMODF)|g' \ + -e 's|@''REPLACE_FMODL''@|$(REPLACE_FMODL)|g' \ + -e 's|@''REPLACE_FREXPF''@|$(REPLACE_FREXPF)|g' \ + -e 's|@''REPLACE_FREXP''@|$(REPLACE_FREXP)|g' \ + -e 's|@''REPLACE_FREXPL''@|$(REPLACE_FREXPL)|g' \ + -e 's|@''REPLACE_HUGE_VAL''@|$(REPLACE_HUGE_VAL)|g' \ + -e 's|@''REPLACE_HYPOT''@|$(REPLACE_HYPOT)|g' \ + -e 's|@''REPLACE_HYPOTF''@|$(REPLACE_HYPOTF)|g' \ + -e 's|@''REPLACE_HYPOTL''@|$(REPLACE_HYPOTL)|g' \ + -e 's|@''REPLACE_ILOGB''@|$(REPLACE_ILOGB)|g' \ + -e 's|@''REPLACE_ILOGBF''@|$(REPLACE_ILOGBF)|g' \ + -e 's|@''REPLACE_ILOGBL''@|$(REPLACE_ILOGBL)|g' \ + -e 's|@''REPLACE_ISFINITE''@|$(REPLACE_ISFINITE)|g' \ + -e 's|@''REPLACE_ISINF''@|$(REPLACE_ISINF)|g' \ + -e 's|@''REPLACE_ISNAN''@|$(REPLACE_ISNAN)|g' \ + -e 's|@''REPLACE_ITOLD''@|$(REPLACE_ITOLD)|g' \ + < $@-t4 > $@-t5 + $(AM_V_at)sed \ + -e 's|@''REPLACE_LDEXP''@|$(REPLACE_LDEXP)|g' \ + -e 's|@''REPLACE_LDEXPL''@|$(REPLACE_LDEXPL)|g' \ + -e 's|@''REPLACE_LOG''@|$(REPLACE_LOG)|g' \ + -e 's|@''REPLACE_LOGF''@|$(REPLACE_LOGF)|g' \ + -e 's|@''REPLACE_LOGL''@|$(REPLACE_LOGL)|g' \ + -e 's|@''REPLACE_LOG10''@|$(REPLACE_LOG10)|g' \ + -e 's|@''REPLACE_LOG10F''@|$(REPLACE_LOG10F)|g' \ + -e 's|@''REPLACE_LOG10L''@|$(REPLACE_LOG10L)|g' \ + -e 's|@''REPLACE_LOG1P''@|$(REPLACE_LOG1P)|g' \ + -e 's|@''REPLACE_LOG1PF''@|$(REPLACE_LOG1PF)|g' \ + -e 's|@''REPLACE_LOG1PL''@|$(REPLACE_LOG1PL)|g' \ + -e 's|@''REPLACE_LOG2''@|$(REPLACE_LOG2)|g' \ + -e 's|@''REPLACE_LOG2F''@|$(REPLACE_LOG2F)|g' \ + -e 's|@''REPLACE_LOG2L''@|$(REPLACE_LOG2L)|g' \ + -e 's|@''REPLACE_LOGB''@|$(REPLACE_LOGB)|g' \ + -e 's|@''REPLACE_LOGBF''@|$(REPLACE_LOGBF)|g' \ + -e 's|@''REPLACE_LOGBL''@|$(REPLACE_LOGBL)|g' \ + -e 's|@''REPLACE_MODF''@|$(REPLACE_MODF)|g' \ + -e 's|@''REPLACE_MODFF''@|$(REPLACE_MODFF)|g' \ + -e 's|@''REPLACE_MODFL''@|$(REPLACE_MODFL)|g' \ + -e 's|@''REPLACE_NAN''@|$(REPLACE_NAN)|g' \ + -e 's|@''REPLACE_REMAINDER''@|$(REPLACE_REMAINDER)|g' \ + -e 's|@''REPLACE_REMAINDERF''@|$(REPLACE_REMAINDERF)|g' \ + -e 's|@''REPLACE_REMAINDERL''@|$(REPLACE_REMAINDERL)|g' \ + -e 's|@''REPLACE_RINTL''@|$(REPLACE_RINTL)|g' \ + -e 's|@''REPLACE_ROUND''@|$(REPLACE_ROUND)|g' \ + -e 's|@''REPLACE_ROUNDF''@|$(REPLACE_ROUNDF)|g' \ + -e 's|@''REPLACE_ROUNDL''@|$(REPLACE_ROUNDL)|g' \ + -e 's|@''REPLACE_SIGNBIT''@|$(REPLACE_SIGNBIT)|g' \ + -e 's|@''REPLACE_SIGNBIT_USING_BUILTINS''@|$(REPLACE_SIGNBIT_USING_BUILTINS)|g' \ + -e 's|@''REPLACE_SINF''@|$(REPLACE_SINF)|g' \ + -e 's|@''REPLACE_SINHF''@|$(REPLACE_SINHF)|g' \ + -e 's|@''REPLACE_SQRTF''@|$(REPLACE_SQRTF)|g' \ + -e 's|@''REPLACE_SQRTL''@|$(REPLACE_SQRTL)|g' \ + -e 's|@''REPLACE_TANF''@|$(REPLACE_TANF)|g' \ + -e 's|@''REPLACE_TANHF''@|$(REPLACE_TANHF)|g' \ + -e 's|@''REPLACE_TOTALORDER''@|$(REPLACE_TOTALORDER)|g' \ + -e 's|@''REPLACE_TOTALORDERF''@|$(REPLACE_TOTALORDERF)|g' \ + -e 's|@''REPLACE_TOTALORDERL''@|$(REPLACE_TOTALORDERL)|g' \ + -e 's|@''REPLACE_TRUNC''@|$(REPLACE_TRUNC)|g' \ + -e 's|@''REPLACE_TRUNCF''@|$(REPLACE_TRUNCF)|g' \ + -e 's|@''REPLACE_TRUNCL''@|$(REPLACE_TRUNCL)|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)' \ + < $@-t5 > $@-t6 + $(AM_V_at)rm -f $@-t1 $@-t2 $@-t3 $@-t4 $@-t5 + $(AM_V_at)mv $@-t6 $@ +MOSTLYCLEANFILES += math.h math.h-t1 math.h-t2 math.h-t3 math.h-t4 math.h-t5 math.h-t6 + +EXTRA_DIST += math.in.h + +## end gnulib module math + +## begin gnulib module math-tests + +TESTS += test-math +check_PROGRAMS += test-math +EXTRA_DIST += test-math.c macros.h + +## end gnulib module math-tests + +## begin gnulib module mbrtoc32-tests + +TESTS += \ + test-mbrtoc32-1.sh test-mbrtoc32-2.sh test-mbrtoc32-3.sh test-mbrtoc32-4.sh \ + test-mbrtoc32-5.sh \ + test-mbrtoc32-w32-2.sh test-mbrtoc32-w32-3.sh test-mbrtoc32-w32-4.sh \ + test-mbrtoc32-w32-5.sh test-mbrtoc32-w32-6.sh test-mbrtoc32-w32-7.sh \ + test-mbrtoc32-w32-8.sh +TESTS_ENVIRONMENT += \ + LOCALE_FR='@LOCALE_FR@' \ + LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' \ + LOCALE_JA='@LOCALE_JA@' \ + LOCALE_ZH_CN='@LOCALE_ZH_CN@' +check_PROGRAMS += test-mbrtoc32 test-mbrtoc32-w32 +test_mbrtoc32_LDADD = $(LDADD) $(LIBUNISTRING) $(SETLOCALE_LIB) $(MBRTOWC_LIB) $(LIBC32CONV) +EXTRA_DIST += test-mbrtoc32-1.sh test-mbrtoc32-2.sh test-mbrtoc32-3.sh test-mbrtoc32-4.sh test-mbrtoc32-5.sh test-mbrtoc32.c test-mbrtoc32-w32-2.sh test-mbrtoc32-w32-3.sh test-mbrtoc32-w32-4.sh test-mbrtoc32-w32-5.sh test-mbrtoc32-w32-6.sh test-mbrtoc32-w32-7.sh test-mbrtoc32-w32-8.sh test-mbrtoc32-w32.c signature.h macros.h + +## end gnulib module mbrtoc32-tests + +## begin gnulib module mbrtowc-tests + +TESTS += \ + test-mbrtowc-1.sh test-mbrtowc-2.sh test-mbrtowc-3.sh test-mbrtowc-4.sh \ + test-mbrtowc-5.sh \ + test-mbrtowc-w32-2.sh test-mbrtowc-w32-3.sh test-mbrtowc-w32-4.sh \ + test-mbrtowc-w32-5.sh test-mbrtowc-w32-6.sh test-mbrtowc-w32-7.sh \ + test-mbrtowc-w32-8.sh +TESTS_ENVIRONMENT += \ + LOCALE_FR='@LOCALE_FR@' \ + LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' \ + LOCALE_JA='@LOCALE_JA@' \ + LOCALE_ZH_CN='@LOCALE_ZH_CN@' +check_PROGRAMS += test-mbrtowc test-mbrtowc-w32 +test_mbrtowc_LDADD = $(LDADD) $(SETLOCALE_LIB) $(MBRTOWC_LIB) +EXTRA_DIST += test-mbrtowc-1.sh test-mbrtowc-2.sh test-mbrtowc-3.sh test-mbrtowc-4.sh test-mbrtowc-5.sh test-mbrtowc.c test-mbrtowc-w32-2.sh test-mbrtowc-w32-3.sh test-mbrtowc-w32-4.sh test-mbrtowc-w32-5.sh test-mbrtowc-w32-6.sh test-mbrtowc-w32-7.sh test-mbrtowc-w32-8.sh test-mbrtowc-w32.c signature.h macros.h + +## end gnulib module mbrtowc-tests + +## begin gnulib module mbscasecmp-tests + +TESTS += test-mbscasecmp.sh +TESTS_ENVIRONMENT += LOCALE_TR_UTF8='@LOCALE_TR_UTF8@' +check_PROGRAMS += test-mbscasecmp +test_mbscasecmp_LDADD = $(LDADD) $(LIBUNISTRING) $(SETLOCALE_LIB) $(MBRTOWC_LIB) $(LIBC32CONV) +EXTRA_DIST += test-mbscasecmp.sh test-mbscasecmp.c macros.h + +## end gnulib module mbscasecmp-tests + +## begin gnulib module mbsinit-tests + +TESTS += test-mbsinit.sh +TESTS_ENVIRONMENT += LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' +check_PROGRAMS += test-mbsinit +test_mbsinit_LDADD = $(LDADD) $(SETLOCALE_LIB) $(MBRTOWC_LIB) +EXTRA_DIST += test-mbsinit.sh test-mbsinit.c signature.h macros.h + +## end gnulib module mbsinit-tests + +## begin gnulib module mbsrtoc32s-tests + +TESTS += \ + test-mbsrtoc32s-1.sh test-mbsrtoc32s-2.sh test-mbsrtoc32s-3.sh \ + test-mbsrtoc32s-4.sh test-mbsrtoc32s-5.sh +TESTS_ENVIRONMENT += \ + LOCALE_FR='@LOCALE_FR@' \ + LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' \ + LOCALE_JA='@LOCALE_JA@' \ + LOCALE_ZH_CN='@LOCALE_ZH_CN@' +check_PROGRAMS += test-mbsrtoc32s +test_mbsrtoc32s_LDADD = $(LDADD) $(LIBUNISTRING) $(SETLOCALE_LIB) $(MBRTOWC_LIB) $(LIBC32CONV) +EXTRA_DIST += test-mbsrtoc32s-1.sh test-mbsrtoc32s-2.sh test-mbsrtoc32s-3.sh test-mbsrtoc32s-4.sh test-mbsrtoc32s-5.sh test-mbsrtoc32s.c signature.h macros.h + +## end gnulib module mbsrtoc32s-tests + +## begin gnulib module mbsrtowcs-tests + +TESTS += \ + test-mbsrtowcs-1.sh test-mbsrtowcs-2.sh test-mbsrtowcs-3.sh \ + test-mbsrtowcs-4.sh test-mbsrtowcs-5.sh +TESTS_ENVIRONMENT += \ + LOCALE_FR='@LOCALE_FR@' \ + LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' \ + LOCALE_JA='@LOCALE_JA@' \ + LOCALE_ZH_CN='@LOCALE_ZH_CN@' +check_PROGRAMS += test-mbsrtowcs +test_mbsrtowcs_LDADD = $(LDADD) $(SETLOCALE_LIB) $(MBRTOWC_LIB) +EXTRA_DIST += test-mbsrtowcs-1.sh test-mbsrtowcs-2.sh test-mbsrtowcs-3.sh test-mbsrtowcs-4.sh test-mbsrtowcs-5.sh test-mbsrtowcs.c signature.h macros.h + +## end gnulib module mbsrtowcs-tests + +## begin gnulib module memchr-tests + +TESTS += test-memchr +check_PROGRAMS += test-memchr +EXTRA_DIST += test-memchr.c zerosize-ptr.h signature.h macros.h + +## end gnulib module memchr-tests + +## begin gnulib module memrchr-tests + +TESTS += test-memrchr +check_PROGRAMS += test-memrchr +EXTRA_DIST += test-memrchr.c zerosize-ptr.h signature.h macros.h + +## end gnulib module memrchr-tests + +## begin gnulib module mkdir-tests + +TESTS += test-mkdir +check_PROGRAMS += test-mkdir +EXTRA_DIST += test-mkdir.h test-mkdir.c signature.h macros.h + +## end gnulib module mkdir-tests + +## begin gnulib module nan + +libtests_a_SOURCES += nan.h + +## end gnulib module nan + +## begin gnulib module nanosleep + +if GL_COND_OBJ_NANOSLEEP +libtests_a_SOURCES += nanosleep.c +endif + +## end gnulib module nanosleep + +## begin gnulib module nanosleep-tests + +TESTS += test-nanosleep +check_PROGRAMS += test-nanosleep +test_nanosleep_LDADD = $(LDADD) $(NANOSLEEP_LIB) +EXTRA_DIST += test-nanosleep.c signature.h macros.h + +## end gnulib module nanosleep-tests + +## begin gnulib module netinet_in + +BUILT_SOURCES += $(NETINET_IN_H) + +# We need the following in order to create when the system +# doesn't have one. +if GL_GENERATE_NETINET_IN_H +netinet/in.h: netinet_in.in.h $(top_builddir)/config.status + $(AM_V_GEN)$(MKDIR_P) '%reldir%/netinet' + $(AM_V_at)$(SED_HEADER_STDOUT) \ + -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_NETINET_IN_H''@|$(NEXT_NETINET_IN_H)|g' \ + -e 's|@''HAVE_NETINET_IN_H''@|$(HAVE_NETINET_IN_H)|g' \ + $(srcdir)/netinet_in.in.h > $@-t + $(AM_V_at)mv $@-t $@ +else +netinet/in.h: $(top_builddir)/config.status + rm -f $@ +endif +MOSTLYCLEANFILES += netinet/in.h netinet/in.h-t +MOSTLYCLEANDIRS += netinet + +EXTRA_DIST += netinet_in.in.h + +## end gnulib module netinet_in + +## begin gnulib module netinet_in-tests + +TESTS += test-netinet_in +check_PROGRAMS += test-netinet_in +EXTRA_DIST += test-netinet_in.c + +## end gnulib module netinet_in-tests + +## begin gnulib module nl_langinfo-tests + +TESTS += test-nl_langinfo1.sh test-nl_langinfo2.sh test-nl_langinfo-mt +TESTS_ENVIRONMENT += LOCALE_FR='@LOCALE_FR@' LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' +check_PROGRAMS += test-nl_langinfo1 test-nl_langinfo2 test-nl_langinfo-mt +test_nl_langinfo1_LDADD = $(LDADD) $(SETLOCALE_LIB) +test_nl_langinfo2_LDADD = $(LDADD) $(SETLOCALE_LIB) +test_nl_langinfo_mt_LDADD = $(LDADD) $(SETLOCALE_LIB) $(LIBMULTITHREAD) $(NANOSLEEP_LIB) +EXTRA_DIST += test-nl_langinfo1.sh test-nl_langinfo2.sh test-nl_langinfo1.c test-nl_langinfo2.c test-nl_langinfo-mt.c signature.h macros.h + +## end gnulib module nl_langinfo-tests + +## begin gnulib module nstrftime-tests + +TESTS += test-nstrftime +check_PROGRAMS += test-nstrftime +EXTRA_DIST += test-nstrftime.c macros.h + +## end gnulib module nstrftime-tests + +## begin gnulib module nullptr-tests + +TESTS += test-nullptr +check_PROGRAMS += test-nullptr +EXTRA_DIST += test-nullptr.c macros.h + +## end gnulib module nullptr-tests + +## begin gnulib module open-tests + +TESTS += test-open +check_PROGRAMS += test-open +EXTRA_DIST += test-open.h test-open.c signature.h macros.h + +## end gnulib module open-tests + +## begin gnulib module openat-tests + +TESTS += test-openat +check_PROGRAMS += test-openat +test_openat_LDADD = $(LDADD) @LIBINTL@ +EXTRA_DIST += test-openat.c test-open.h signature.h macros.h + +## end gnulib module openat-tests + +## begin gnulib module pathmax-tests + +TESTS += test-pathmax +check_PROGRAMS += test-pathmax +EXTRA_DIST += test-pathmax.c + +## end gnulib module pathmax-tests + +## begin gnulib module perror + +if GL_COND_OBJ_PERROR +libtests_a_SOURCES += perror.c +endif + +## end gnulib module perror + +## begin gnulib module perror-tests + +TESTS += test-perror.sh test-perror2 +check_PROGRAMS += test-perror test-perror2 +EXTRA_DIST += macros.h signature.h test-perror.c test-perror2.c test-perror.sh + +## end gnulib module perror-tests + +## begin gnulib module pipe-posix-tests + +TESTS += test-pipe +check_PROGRAMS += test-pipe +EXTRA_DIST += test-pipe.c signature.h macros.h + +## end gnulib module pipe-posix-tests + +## begin gnulib module popen-tests + +TESTS += test-popen +check_PROGRAMS += test-popen +EXTRA_DIST += test-popen.h test-popen.c signature.h macros.h + +## end gnulib module popen-tests + +## begin gnulib module priv-set + +libtests_a_SOURCES += priv-set.c + +EXTRA_DIST += priv-set.h + +## end gnulib module priv-set + +## begin gnulib module priv-set-tests + +TESTS += test-priv-set +check_PROGRAMS += test-priv-set +EXTRA_DIST += test-priv-set.c macros.h + +## end gnulib module priv-set-tests + +## begin gnulib module pselect + +if GL_COND_OBJ_PSELECT +libtests_a_SOURCES += pselect.c +endif + +## end gnulib module pselect + +## begin gnulib module pselect-tests + +TESTS += test-pselect +check_PROGRAMS += test-pselect +test_pselect_LDADD = $(LDADD) @SELECT_LIB@ @LIBSOCKET@ @PTHREAD_SIGMASK_LIB@ $(INET_PTON_LIB) +EXTRA_DIST += test-pselect.c test-select.h macros.h signature.h + +## end gnulib module pselect-tests + +## begin gnulib module pthread-h + +BUILT_SOURCES += pthread.h + +# We need the following in order to create when the system +# doesn't have one that works with the given compiler. +pthread.h: pthread.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(_NORETURN_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) + $(gl_V_at)$(SED_HEADER_STDOUT) \ + -e 's|@''GUARD_PREFIX''@|GL|g' \ + -e 's|@''HAVE_PTHREAD_H''@|$(HAVE_PTHREAD_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_PTHREAD_H''@|$(NEXT_PTHREAD_H)|g' \ + -e 's/@''GNULIB_PTHREAD_THREAD''@/$(GL_GNULIB_PTHREAD_THREAD)/g' \ + -e 's/@''GNULIB_PTHREAD_ONCE''@/$(GL_GNULIB_PTHREAD_ONCE)/g' \ + -e 's/@''GNULIB_PTHREAD_MUTEX''@/$(GL_GNULIB_PTHREAD_MUTEX)/g' \ + -e 's/@''GNULIB_PTHREAD_RWLOCK''@/$(GL_GNULIB_PTHREAD_RWLOCK)/g' \ + -e 's/@''GNULIB_PTHREAD_COND''@/$(GL_GNULIB_PTHREAD_COND)/g' \ + -e 's/@''GNULIB_PTHREAD_TSS''@/$(GL_GNULIB_PTHREAD_TSS)/g' \ + -e 's/@''GNULIB_PTHREAD_SPIN''@/$(GL_GNULIB_PTHREAD_SPIN)/g' \ + -e 's/@''GNULIB_PTHREAD_MUTEX_TIMEDLOCK''@/$(GL_GNULIB_PTHREAD_MUTEX_TIMEDLOCK)/g' \ + -e 's|@''HAVE_PTHREAD_T''@|$(HAVE_PTHREAD_T)|g' \ + -e 's|@''HAVE_PTHREAD_SPINLOCK_T''@|$(HAVE_PTHREAD_SPINLOCK_T)|g' \ + -e 's|@''HAVE_PTHREAD_CREATE_DETACHED''@|$(HAVE_PTHREAD_CREATE_DETACHED)|g' \ + -e 's|@''HAVE_PTHREAD_MUTEX_RECURSIVE''@|$(HAVE_PTHREAD_MUTEX_RECURSIVE)|g' \ + -e 's|@''HAVE_PTHREAD_MUTEX_ROBUST''@|$(HAVE_PTHREAD_MUTEX_ROBUST)|g' \ + -e 's|@''HAVE_PTHREAD_PROCESS_SHARED''@|$(HAVE_PTHREAD_PROCESS_SHARED)|g' \ + -e 's|@''HAVE_PTHREAD_CREATE''@|$(HAVE_PTHREAD_CREATE)|g' \ + -e 's|@''HAVE_PTHREAD_ATTR_INIT''@|$(HAVE_PTHREAD_ATTR_INIT)|g' \ + -e 's|@''HAVE_PTHREAD_ATTR_GETDETACHSTATE''@|$(HAVE_PTHREAD_ATTR_GETDETACHSTATE)|g' \ + -e 's|@''HAVE_PTHREAD_ATTR_SETDETACHSTATE''@|$(HAVE_PTHREAD_ATTR_SETDETACHSTATE)|g' \ + -e 's|@''HAVE_PTHREAD_ATTR_DESTROY''@|$(HAVE_PTHREAD_ATTR_DESTROY)|g' \ + -e 's|@''HAVE_PTHREAD_SELF''@|$(HAVE_PTHREAD_SELF)|g' \ + -e 's|@''HAVE_PTHREAD_EQUAL''@|$(HAVE_PTHREAD_EQUAL)|g' \ + -e 's|@''HAVE_PTHREAD_DETACH''@|$(HAVE_PTHREAD_DETACH)|g' \ + -e 's|@''HAVE_PTHREAD_JOIN''@|$(HAVE_PTHREAD_JOIN)|g' \ + -e 's|@''HAVE_PTHREAD_EXIT''@|$(HAVE_PTHREAD_EXIT)|g' \ + < $(srcdir)/pthread.in.h > $@-t1 + $(AM_V_at)sed \ + -e 's|@''HAVE_PTHREAD_ONCE''@|$(HAVE_PTHREAD_ONCE)|g' \ + -e 's|@''HAVE_PTHREAD_MUTEX_INIT''@|$(HAVE_PTHREAD_MUTEX_INIT)|g' \ + -e 's|@''HAVE_PTHREAD_MUTEXATTR_INIT''@|$(HAVE_PTHREAD_MUTEXATTR_INIT)|g' \ + -e 's|@''HAVE_PTHREAD_MUTEXATTR_GETTYPE''@|$(HAVE_PTHREAD_MUTEXATTR_GETTYPE)|g' \ + -e 's|@''HAVE_PTHREAD_MUTEXATTR_SETTYPE''@|$(HAVE_PTHREAD_MUTEXATTR_SETTYPE)|g' \ + -e 's|@''HAVE_PTHREAD_MUTEXATTR_GETROBUST''@|$(HAVE_PTHREAD_MUTEXATTR_GETROBUST)|g' \ + -e 's|@''HAVE_PTHREAD_MUTEXATTR_SETROBUST''@|$(HAVE_PTHREAD_MUTEXATTR_SETROBUST)|g' \ + -e 's|@''HAVE_PTHREAD_MUTEXATTR_DESTROY''@|$(HAVE_PTHREAD_MUTEXATTR_DESTROY)|g' \ + -e 's|@''HAVE_PTHREAD_MUTEX_LOCK''@|$(HAVE_PTHREAD_MUTEX_LOCK)|g' \ + -e 's|@''HAVE_PTHREAD_MUTEX_TRYLOCK''@|$(HAVE_PTHREAD_MUTEX_TRYLOCK)|g' \ + -e 's|@''HAVE_PTHREAD_MUTEX_TIMEDLOCK''@|$(HAVE_PTHREAD_MUTEX_TIMEDLOCK)|g' \ + -e 's|@''HAVE_PTHREAD_MUTEX_UNLOCK''@|$(HAVE_PTHREAD_MUTEX_UNLOCK)|g' \ + -e 's|@''HAVE_PTHREAD_MUTEX_DESTROY''@|$(HAVE_PTHREAD_MUTEX_DESTROY)|g' \ + -e 's|@''HAVE_PTHREAD_RWLOCK_INIT''@|$(HAVE_PTHREAD_RWLOCK_INIT)|g' \ + -e 's|@''HAVE_PTHREAD_RWLOCKATTR_INIT''@|$(HAVE_PTHREAD_RWLOCKATTR_INIT)|g' \ + -e 's|@''HAVE_PTHREAD_RWLOCKATTR_DESTROY''@|$(HAVE_PTHREAD_RWLOCKATTR_DESTROY)|g' \ + -e 's|@''HAVE_PTHREAD_RWLOCK_RDLOCK''@|$(HAVE_PTHREAD_RWLOCK_RDLOCK)|g' \ + -e 's|@''HAVE_PTHREAD_RWLOCK_WRLOCK''@|$(HAVE_PTHREAD_RWLOCK_WRLOCK)|g' \ + -e 's|@''HAVE_PTHREAD_RWLOCK_TRYRDLOCK''@|$(HAVE_PTHREAD_RWLOCK_TRYRDLOCK)|g' \ + -e 's|@''HAVE_PTHREAD_RWLOCK_TRYWRLOCK''@|$(HAVE_PTHREAD_RWLOCK_TRYWRLOCK)|g' \ + -e 's|@''HAVE_PTHREAD_RWLOCK_TIMEDRDLOCK''@|$(HAVE_PTHREAD_RWLOCK_TIMEDRDLOCK)|g' \ + -e 's|@''HAVE_PTHREAD_RWLOCK_TIMEDWRLOCK''@|$(HAVE_PTHREAD_RWLOCK_TIMEDWRLOCK)|g' \ + -e 's|@''HAVE_PTHREAD_RWLOCK_UNLOCK''@|$(HAVE_PTHREAD_RWLOCK_UNLOCK)|g' \ + -e 's|@''HAVE_PTHREAD_RWLOCK_DESTROY''@|$(HAVE_PTHREAD_RWLOCK_DESTROY)|g' \ + -e 's|@''HAVE_PTHREAD_COND_INIT''@|$(HAVE_PTHREAD_COND_INIT)|g' \ + -e 's|@''HAVE_PTHREAD_CONDATTR_INIT''@|$(HAVE_PTHREAD_CONDATTR_INIT)|g' \ + -e 's|@''HAVE_PTHREAD_CONDATTR_DESTROY''@|$(HAVE_PTHREAD_CONDATTR_DESTROY)|g' \ + -e 's|@''HAVE_PTHREAD_COND_WAIT''@|$(HAVE_PTHREAD_COND_WAIT)|g' \ + -e 's|@''HAVE_PTHREAD_COND_TIMEDWAIT''@|$(HAVE_PTHREAD_COND_TIMEDWAIT)|g' \ + -e 's|@''HAVE_PTHREAD_COND_SIGNAL''@|$(HAVE_PTHREAD_COND_SIGNAL)|g' \ + -e 's|@''HAVE_PTHREAD_COND_BROADCAST''@|$(HAVE_PTHREAD_COND_BROADCAST)|g' \ + -e 's|@''HAVE_PTHREAD_COND_DESTROY''@|$(HAVE_PTHREAD_COND_DESTROY)|g' \ + -e 's|@''HAVE_PTHREAD_KEY_CREATE''@|$(HAVE_PTHREAD_KEY_CREATE)|g' \ + -e 's|@''HAVE_PTHREAD_SETSPECIFIC''@|$(HAVE_PTHREAD_SETSPECIFIC)|g' \ + -e 's|@''HAVE_PTHREAD_GETSPECIFIC''@|$(HAVE_PTHREAD_GETSPECIFIC)|g' \ + -e 's|@''HAVE_PTHREAD_KEY_DELETE''@|$(HAVE_PTHREAD_KEY_DELETE)|g' \ + -e 's|@''HAVE_PTHREAD_SPIN_INIT''@|$(HAVE_PTHREAD_SPIN_INIT)|g' \ + -e 's|@''HAVE_PTHREAD_SPIN_LOCK''@|$(HAVE_PTHREAD_SPIN_LOCK)|g' \ + -e 's|@''HAVE_PTHREAD_SPIN_TRYLOCK''@|$(HAVE_PTHREAD_SPIN_TRYLOCK)|g' \ + -e 's|@''HAVE_PTHREAD_SPIN_UNLOCK''@|$(HAVE_PTHREAD_SPIN_UNLOCK)|g' \ + -e 's|@''HAVE_PTHREAD_SPIN_DESTROY''@|$(HAVE_PTHREAD_SPIN_DESTROY)|g' \ + < $@-t1 > $@-t2 + $(AM_V_at)sed \ + -e 's|@''REPLACE_PTHREAD_CREATE''@|$(REPLACE_PTHREAD_CREATE)|g' \ + -e 's|@''REPLACE_PTHREAD_ATTR_INIT''@|$(REPLACE_PTHREAD_ATTR_INIT)|g' \ + -e 's|@''REPLACE_PTHREAD_ATTR_GETDETACHSTATE''@|$(REPLACE_PTHREAD_ATTR_GETDETACHSTATE)|g' \ + -e 's|@''REPLACE_PTHREAD_ATTR_SETDETACHSTATE''@|$(REPLACE_PTHREAD_ATTR_SETDETACHSTATE)|g' \ + -e 's|@''REPLACE_PTHREAD_ATTR_DESTROY''@|$(REPLACE_PTHREAD_ATTR_DESTROY)|g' \ + -e 's|@''REPLACE_PTHREAD_SELF''@|$(REPLACE_PTHREAD_SELF)|g' \ + -e 's|@''REPLACE_PTHREAD_EQUAL''@|$(REPLACE_PTHREAD_EQUAL)|g' \ + -e 's|@''REPLACE_PTHREAD_DETACH''@|$(REPLACE_PTHREAD_DETACH)|g' \ + -e 's|@''REPLACE_PTHREAD_JOIN''@|$(REPLACE_PTHREAD_JOIN)|g' \ + -e 's|@''REPLACE_PTHREAD_EXIT''@|$(REPLACE_PTHREAD_EXIT)|g' \ + -e 's|@''REPLACE_PTHREAD_ONCE''@|$(REPLACE_PTHREAD_ONCE)|g' \ + -e 's|@''REPLACE_PTHREAD_MUTEX_INIT''@|$(REPLACE_PTHREAD_MUTEX_INIT)|g' \ + -e 's|@''REPLACE_PTHREAD_MUTEXATTR_INIT''@|$(REPLACE_PTHREAD_MUTEXATTR_INIT)|g' \ + -e 's|@''REPLACE_PTHREAD_MUTEXATTR_GETTYPE''@|$(REPLACE_PTHREAD_MUTEXATTR_GETTYPE)|g' \ + -e 's|@''REPLACE_PTHREAD_MUTEXATTR_SETTYPE''@|$(REPLACE_PTHREAD_MUTEXATTR_SETTYPE)|g' \ + -e 's|@''REPLACE_PTHREAD_MUTEXATTR_GETROBUST''@|$(REPLACE_PTHREAD_MUTEXATTR_GETROBUST)|g' \ + -e 's|@''REPLACE_PTHREAD_MUTEXATTR_SETROBUST''@|$(REPLACE_PTHREAD_MUTEXATTR_SETROBUST)|g' \ + -e 's|@''REPLACE_PTHREAD_MUTEXATTR_DESTROY''@|$(REPLACE_PTHREAD_MUTEXATTR_DESTROY)|g' \ + -e 's|@''REPLACE_PTHREAD_MUTEX_LOCK''@|$(REPLACE_PTHREAD_MUTEX_LOCK)|g' \ + -e 's|@''REPLACE_PTHREAD_MUTEX_TRYLOCK''@|$(REPLACE_PTHREAD_MUTEX_TRYLOCK)|g' \ + -e 's|@''REPLACE_PTHREAD_MUTEX_TIMEDLOCK''@|$(REPLACE_PTHREAD_MUTEX_TIMEDLOCK)|g' \ + -e 's|@''REPLACE_PTHREAD_MUTEX_UNLOCK''@|$(REPLACE_PTHREAD_MUTEX_UNLOCK)|g' \ + -e 's|@''REPLACE_PTHREAD_MUTEX_DESTROY''@|$(REPLACE_PTHREAD_MUTEX_DESTROY)|g' \ + -e 's|@''REPLACE_PTHREAD_RWLOCK_INIT''@|$(REPLACE_PTHREAD_RWLOCK_INIT)|g' \ + -e 's|@''REPLACE_PTHREAD_RWLOCKATTR_INIT''@|$(REPLACE_PTHREAD_RWLOCKATTR_INIT)|g' \ + -e 's|@''REPLACE_PTHREAD_RWLOCKATTR_DESTROY''@|$(REPLACE_PTHREAD_RWLOCKATTR_DESTROY)|g' \ + -e 's|@''REPLACE_PTHREAD_RWLOCK_RDLOCK''@|$(REPLACE_PTHREAD_RWLOCK_RDLOCK)|g' \ + -e 's|@''REPLACE_PTHREAD_RWLOCK_WRLOCK''@|$(REPLACE_PTHREAD_RWLOCK_WRLOCK)|g' \ + -e 's|@''REPLACE_PTHREAD_RWLOCK_TRYRDLOCK''@|$(REPLACE_PTHREAD_RWLOCK_TRYRDLOCK)|g' \ + -e 's|@''REPLACE_PTHREAD_RWLOCK_TRYWRLOCK''@|$(REPLACE_PTHREAD_RWLOCK_TRYWRLOCK)|g' \ + -e 's|@''REPLACE_PTHREAD_RWLOCK_TIMEDRDLOCK''@|$(REPLACE_PTHREAD_RWLOCK_TIMEDRDLOCK)|g' \ + -e 's|@''REPLACE_PTHREAD_RWLOCK_TIMEDWRLOCK''@|$(REPLACE_PTHREAD_RWLOCK_TIMEDWRLOCK)|g' \ + -e 's|@''REPLACE_PTHREAD_RWLOCK_UNLOCK''@|$(REPLACE_PTHREAD_RWLOCK_UNLOCK)|g' \ + -e 's|@''REPLACE_PTHREAD_RWLOCK_DESTROY''@|$(REPLACE_PTHREAD_RWLOCK_DESTROY)|g' \ + < $@-t2 > $@-t3 + $(AM_V_at)sed \ + -e 's|@''REPLACE_PTHREAD_COND_INIT''@|$(REPLACE_PTHREAD_COND_INIT)|g' \ + -e 's|@''REPLACE_PTHREAD_CONDATTR_INIT''@|$(REPLACE_PTHREAD_CONDATTR_INIT)|g' \ + -e 's|@''REPLACE_PTHREAD_CONDATTR_DESTROY''@|$(REPLACE_PTHREAD_CONDATTR_DESTROY)|g' \ + -e 's|@''REPLACE_PTHREAD_COND_WAIT''@|$(REPLACE_PTHREAD_COND_WAIT)|g' \ + -e 's|@''REPLACE_PTHREAD_COND_TIMEDWAIT''@|$(REPLACE_PTHREAD_COND_TIMEDWAIT)|g' \ + -e 's|@''REPLACE_PTHREAD_COND_SIGNAL''@|$(REPLACE_PTHREAD_COND_SIGNAL)|g' \ + -e 's|@''REPLACE_PTHREAD_COND_BROADCAST''@|$(REPLACE_PTHREAD_COND_BROADCAST)|g' \ + -e 's|@''REPLACE_PTHREAD_COND_DESTROY''@|$(REPLACE_PTHREAD_COND_DESTROY)|g' \ + -e 's|@''REPLACE_PTHREAD_KEY_CREATE''@|$(REPLACE_PTHREAD_KEY_CREATE)|g' \ + -e 's|@''REPLACE_PTHREAD_SETSPECIFIC''@|$(REPLACE_PTHREAD_SETSPECIFIC)|g' \ + -e 's|@''REPLACE_PTHREAD_GETSPECIFIC''@|$(REPLACE_PTHREAD_GETSPECIFIC)|g' \ + -e 's|@''REPLACE_PTHREAD_KEY_DELETE''@|$(REPLACE_PTHREAD_KEY_DELETE)|g' \ + -e 's|@''REPLACE_PTHREAD_SPIN_INIT''@|$(REPLACE_PTHREAD_SPIN_INIT)|g' \ + -e 's|@''REPLACE_PTHREAD_SPIN_LOCK''@|$(REPLACE_PTHREAD_SPIN_LOCK)|g' \ + -e 's|@''REPLACE_PTHREAD_SPIN_TRYLOCK''@|$(REPLACE_PTHREAD_SPIN_TRYLOCK)|g' \ + -e 's|@''REPLACE_PTHREAD_SPIN_UNLOCK''@|$(REPLACE_PTHREAD_SPIN_UNLOCK)|g' \ + -e 's|@''REPLACE_PTHREAD_SPIN_DESTROY''@|$(REPLACE_PTHREAD_SPIN_DESTROY)|g' \ + -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ + -e '/definition of _Noreturn/r $(_NORETURN_H)' \ + -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ + -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ + < $@-t3 > $@-t4 + $(AM_V_at)rm -f $@-t1 $@-t2 $@-t3 + $(AM_V_at)mv $@-t4 $@ +MOSTLYCLEANFILES += pthread.h pthread.h-t1 pthread.h-t2 pthread.h-t3 pthread.h-t4 + +EXTRA_DIST += pthread.in.h + +## end gnulib module pthread-h + +## begin gnulib module pthread-h-tests + +TESTS += test-pthread +check_PROGRAMS += test-pthread +EXTRA_DIST += test-pthread.c + +## end gnulib module pthread-h-tests + +## begin gnulib module pthread-thread + +if GL_COND_OBJ_PTHREAD_THREAD +libtests_a_SOURCES += pthread-thread.c +endif + +## end gnulib module pthread-thread + +## begin gnulib module pthread-thread-tests + +TESTS += test-pthread-thread +check_PROGRAMS += test-pthread-thread +test_pthread_thread_LDADD = $(LDADD) @LIBPMULTITHREAD@ +EXTRA_DIST += test-pthread-thread.c macros.h + +## end gnulib module pthread-thread-tests + +## begin gnulib module pthread_sigmask + +if GL_COND_OBJ_PTHREAD_SIGMASK +libtests_a_SOURCES += pthread_sigmask.c +endif + +## end gnulib module pthread_sigmask + +## begin gnulib module pthread_sigmask-tests + +TESTS += test-pthread_sigmask1 test-pthread_sigmask2 +check_PROGRAMS += test-pthread_sigmask1 test-pthread_sigmask2 +test_pthread_sigmask1_LDADD = $(LDADD) @PTHREAD_SIGMASK_LIB@ +test_pthread_sigmask2_LDADD = $(LDADD) @PTHREAD_SIGMASK_LIB@ @LIBMULTITHREAD@ +EXTRA_DIST += test-pthread_sigmask1.c test-pthread_sigmask2.c signature.h macros.h + +## end gnulib module pthread_sigmask-tests + +## begin gnulib module putenv + +if GL_COND_OBJ_PUTENV +libtests_a_SOURCES += putenv.c +endif + +## end gnulib module putenv + +## begin gnulib module quotearg-simple-tests + +TESTS += test-quotearg-simple +check_PROGRAMS += test-quotearg-simple +test_quotearg_simple_LDADD = $(LDADD) $(LIBUNISTRING) @LIBINTL@ $(MBRTOWC_LIB) $(LIBC32CONV) +EXTRA_DIST += test-quotearg-simple.c test-quotearg.h macros.h zerosize-ptr.h + +## end gnulib module quotearg-simple-tests + +## begin gnulib module raise-tests + +TESTS += test-raise +check_PROGRAMS += test-raise +EXTRA_DIST += test-raise.c signature.h macros.h + +## end gnulib module raise-tests + +## begin gnulib module rawmemchr-tests + +TESTS += test-rawmemchr +check_PROGRAMS += test-rawmemchr +EXTRA_DIST += test-rawmemchr.c zerosize-ptr.h signature.h macros.h + +## end gnulib module rawmemchr-tests + +## begin gnulib module readlink-tests + +TESTS += test-readlink +check_PROGRAMS += test-readlink +EXTRA_DIST += test-readlink.h test-readlink.c signature.h macros.h + +## end gnulib module readlink-tests + +## begin gnulib module readlinkat-tests + +TESTS += test-readlinkat +check_PROGRAMS += test-readlinkat +test_readlinkat_LDADD = $(LDADD) @LIBINTL@ +EXTRA_DIST += test-readlink.h test-readlinkat.c signature.h macros.h + +## end gnulib module readlinkat-tests + +## begin gnulib module realloc-gnu-tests + +TESTS += test-realloc-gnu +check_PROGRAMS += test-realloc-gnu +EXTRA_DIST += test-realloc-gnu.c macros.h + +## end gnulib module realloc-gnu-tests + +## begin gnulib module reallocarray-tests + +TESTS += test-reallocarray +check_PROGRAMS += test-reallocarray +EXTRA_DIST += test-reallocarray.c signature.h macros.h + +## end gnulib module reallocarray-tests + +## begin gnulib module regex-tests + +TESTS += test-regex +check_PROGRAMS += test-regex +test_regex_LDADD = $(LDADD) $(SETLOCALE_LIB) $(MBRTOWC_LIB) @LIBINTL@ $(LIBTHREAD) +EXTRA_DIST += test-regex.c macros.h + +## end gnulib module regex-tests + +## begin gnulib module rmdir + +if GL_COND_OBJ_RMDIR +libtests_a_SOURCES += rmdir.c +endif + +## end gnulib module rmdir + +## begin gnulib module rmdir-tests + +TESTS += test-rmdir +check_PROGRAMS += test-rmdir +EXTRA_DIST += test-rmdir.h test-rmdir.c signature.h macros.h + +## end gnulib module rmdir-tests + +## begin gnulib module root-uid + + +EXTRA_DIST += root-uid.h + +## end gnulib module root-uid + +## begin gnulib module sched + +BUILT_SOURCES += sched.h + +# We need the following in order to create a replacement for when +# the system doesn't have one. +sched.h: sched.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) + $(gl_V_at)$(SED_HEADER_STDOUT) \ + -e 's|@''GUARD_PREFIX''@|GL|g' \ + -e 's|@''HAVE_SCHED_H''@|$(HAVE_SCHED_H)|g' \ + -e 's|@''HAVE_SYS_CDEFS_H''@|$(HAVE_SYS_CDEFS_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_SCHED_H''@|$(NEXT_SCHED_H)|g' \ + -e 's|@''HAVE_STRUCT_SCHED_PARAM''@|$(HAVE_STRUCT_SCHED_PARAM)|g' \ + -e 's/@''GNULIB_SCHED_YIELD''@/$(GL_GNULIB_SCHED_YIELD)/g' \ + -e 's|@''HAVE_SCHED_YIELD''@|$(HAVE_SCHED_YIELD)|g' \ + -e 's|@''REPLACE_SCHED_YIELD''@|$(REPLACE_SCHED_YIELD)|g' \ + -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ + -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ + $(srcdir)/sched.in.h > $@-t + $(AM_V_at)mv $@-t $@ +MOSTLYCLEANFILES += sched.h sched.h-t + +EXTRA_DIST += sched.in.h + +## end gnulib module sched + +## begin gnulib module sched-tests + +TESTS += test-sched +check_PROGRAMS += test-sched +EXTRA_DIST += test-sched.c + +## end gnulib module sched-tests + +## begin gnulib module select + +if GL_COND_OBJ_SELECT +libtests_a_SOURCES += select.c +endif + +## end gnulib module select + +## begin gnulib module select-tests + +TESTS += test-select test-select-in.sh test-select-out.sh +# test-select-stdin has to be run by hand. +check_PROGRAMS += test-select test-select-fd test-select-stdin +test_select_LDADD = $(LDADD) @SELECT_LIB@ @LIBSOCKET@ $(INET_PTON_LIB) +test_select_fd_LDADD = $(LDADD) @SELECT_LIB@ +test_select_stdin_LDADD = $(LDADD) @SELECT_LIB@ +EXTRA_DIST += macros.h signature.h test-select.c test-select.h test-select-fd.c test-select-in.sh test-select-out.sh test-select-stdin.c + +## end gnulib module select-tests + +## begin gnulib module setenv-tests + +TESTS += test-setenv +check_PROGRAMS += test-setenv +EXTRA_DIST += test-setenv.c signature.h macros.h + +## end gnulib module setenv-tests + +## begin gnulib module setlocale-null-tests + +TESTS += \ + test-setlocale_null \ + test-setlocale_null-mt-one \ + test-setlocale_null-mt-all +check_PROGRAMS += \ + test-setlocale_null \ + test-setlocale_null-mt-one \ + test-setlocale_null-mt-all +test_setlocale_null_LDADD = $(LDADD) @SETLOCALE_NULL_LIB@ +test_setlocale_null_mt_one_LDADD = $(LDADD) @SETLOCALE_NULL_LIB@ $(LIBMULTITHREAD) $(NANOSLEEP_LIB) +test_setlocale_null_mt_all_LDADD = $(LDADD) @SETLOCALE_NULL_LIB@ $(LIBMULTITHREAD) $(NANOSLEEP_LIB) +EXTRA_DIST += test-setlocale_null.c test-setlocale_null-mt-one.c test-setlocale_null-mt-all.c + +## end gnulib module setlocale-null-tests + +## begin gnulib module setsockopt + +if GL_COND_OBJ_SETSOCKOPT +libtests_a_SOURCES += setsockopt.c +endif + +EXTRA_DIST += w32sock.h + +## end gnulib module setsockopt + +## begin gnulib module setsockopt-tests + +TESTS += test-setsockopt +check_PROGRAMS += test-setsockopt +test_setsockopt_LDADD = $(LDADD) @LIBSOCKET@ +EXTRA_DIST += test-setsockopt.c signature.h macros.h + +## end gnulib module setsockopt-tests + +## begin gnulib module sh-quote-tests + +TESTS += test-sh-quote +check_PROGRAMS += test-sh-quote +test_sh_quote_LDADD = $(LDADD) $(LIBUNISTRING) @LIBINTL@ $(MBRTOWC_LIB) $(LIBC32CONV) +EXTRA_DIST += test-sh-quote.c macros.h + +## end gnulib module sh-quote-tests + +## begin gnulib module sigaction-tests + +TESTS += test-sigaction +check_PROGRAMS += test-sigaction +EXTRA_DIST += test-sigaction.c signature.h macros.h + +## end gnulib module sigaction-tests + +## begin gnulib module signal-h-tests + +TESTS += test-signal-h +check_PROGRAMS += test-signal-h +EXTRA_DIST += test-signal-h.c + +## end gnulib module signal-h-tests + +## begin gnulib module signbit + +if GL_COND_OBJ_SIGNBIT3 +libtests_a_SOURCES += signbitf.c signbitd.c signbitl.c +endif + +EXTRA_DIST += float+.h + +## end gnulib module signbit + +## begin gnulib module signbit-tests + +TESTS += test-signbit +check_PROGRAMS += test-signbit + +EXTRA_DIST += test-signbit.c minus-zero.h infinity.h macros.h + +## end gnulib module signbit-tests + +## begin gnulib module signed-nan + +libtests_a_SOURCES += signed-nan.h + +## end gnulib module signed-nan + +## begin gnulib module signed-snan + +libtests_a_SOURCES += signed-snan.h + +## end gnulib module signed-snan + +## begin gnulib module sigprocmask-tests + +TESTS += test-sigprocmask +check_PROGRAMS += test-sigprocmask +EXTRA_DIST += test-sigprocmask.c signature.h macros.h + +## end gnulib module sigprocmask-tests + +## begin gnulib module sigsegv-tests + +TESTS += \ + test-sigsegv-catch-segv1 \ + test-sigsegv-catch-segv2 \ + test-sigsegv-catch-stackoverflow1 \ + test-sigsegv-catch-stackoverflow2 +check_PROGRAMS += \ + test-sigsegv-catch-segv1 \ + test-sigsegv-catch-segv2 \ + test-sigsegv-catch-stackoverflow1 \ + test-sigsegv-catch-stackoverflow2 +test_sigsegv_catch_segv1_LDADD = $(LDADD) $(LIBSIGSEGV) +test_sigsegv_catch_segv2_LDADD = $(LDADD) $(LIBSIGSEGV) +test_sigsegv_catch_stackoverflow1_LDADD = $(LDADD) $(LIBSIGSEGV) +test_sigsegv_catch_stackoverflow2_LDADD = $(LDADD) $(LIBSIGSEGV) +EXTRA_DIST += test-sigsegv-catch-segv1.c test-sigsegv-catch-segv2.c test-sigsegv-catch-stackoverflow1.c test-sigsegv-catch-stackoverflow2.c altstack-util.h mmap-anon-util.h + +## end gnulib module sigsegv-tests + +## begin gnulib module size_max + +libtests_a_SOURCES += size_max.h + +## end gnulib module size_max + +## begin gnulib module sleep + +if GL_COND_OBJ_SLEEP +libtests_a_SOURCES += sleep.c +endif + +## end gnulib module sleep + +## begin gnulib module sleep-tests + +TESTS += test-sleep +check_PROGRAMS += test-sleep +EXTRA_DIST += test-sleep.c signature.h macros.h + +## end gnulib module sleep-tests + +## begin gnulib module snan + +libtests_a_SOURCES += snan.h + +## end gnulib module snan + +## begin gnulib module snippet/_Noreturn + +# Because this Makefile snippet defines a variable used by other +# gnulib Makefile snippets, it must be present in all makefiles that +# need it. This is ensured by the applicability 'all' defined above. + +_NORETURN_H=$(srcdir)/_Noreturn.h + +EXTRA_DIST += _Noreturn.h + +## end gnulib module snippet/_Noreturn + +## begin gnulib module snippet/arg-nonnull + +# Because this Makefile snippet defines a variable used by other +# gnulib Makefile snippets, it must be present in all makefiles that +# need it. This is ensured by the applicability 'all' defined above. + +ARG_NONNULL_H=$(srcdir)/arg-nonnull.h + +EXTRA_DIST += arg-nonnull.h + +## end gnulib module snippet/arg-nonnull + +## begin gnulib module snippet/c++defs + +# Because this Makefile snippet defines a variable used by other +# gnulib Makefile snippets, it must be present in all makefiles that +# need it. This is ensured by the applicability 'all' defined above. + +CXXDEFS_H=$(srcdir)/c++defs.h + +EXTRA_DIST += c++defs.h + +## end gnulib module snippet/c++defs + +## begin gnulib module snippet/warn-on-use + +# Because this Makefile snippet defines a variable used by other +# gnulib Makefile snippets, it must be present in all makefiles that +# need it. This is ensured by the applicability 'all' defined above. + +WARN_ON_USE_H=$(srcdir)/warn-on-use.h + +EXTRA_DIST += warn-on-use.h + +## end gnulib module snippet/warn-on-use + +## begin gnulib module snprintf + + +EXTRA_DIST += snprintf.c + +EXTRA_libtests_a_SOURCES += snprintf.c + +## end gnulib module snprintf + +## begin gnulib module snprintf-tests + +TESTS += test-snprintf +check_PROGRAMS += test-snprintf + +EXTRA_DIST += test-snprintf.c signature.h macros.h + +## end gnulib module snprintf-tests + +## begin gnulib module socket + +if GL_COND_OBJ_SOCKET +libtests_a_SOURCES += socket.c +endif + +EXTRA_DIST += w32sock.h + +## end gnulib module socket + +## begin gnulib module sockets + +libtests_a_SOURCES += sockets.h sockets.c + +EXTRA_DIST += w32sock.h + +## end gnulib module sockets + +## begin gnulib module sockets-tests + +TESTS += test-sockets +check_PROGRAMS += test-sockets +test_sockets_LDADD = $(LDADD) @LIBSOCKET@ +EXTRA_DIST += test-sockets.c + +## end gnulib module sockets-tests + +## begin gnulib module stat-tests + +TESTS += test-stat +check_PROGRAMS += test-stat +test_stat_LDADD = $(LDADD) $(LIBINTL) +EXTRA_DIST += test-stat.h test-stat.c signature.h macros.h + +## end gnulib module stat-tests + +## begin gnulib module stat-time-tests + +TESTS += test-stat-time +check_PROGRAMS += test-stat-time +test_stat_time_LDADD = $(LDADD) $(NANOSLEEP_LIB) +EXTRA_DIST += test-stat-time.c macros.h nap.h + +## end gnulib module stat-time-tests + +## begin gnulib module stdbool-tests + +TESTS += test-stdbool +check_PROGRAMS += test-stdbool +EXTRA_DIST += test-stdbool.c + +## end gnulib module stdbool-tests + +## begin gnulib module stdckdint-tests + +TESTS += test-stdckdint +check_PROGRAMS += test-stdckdint +EXTRA_DIST += macros.h test-intprops.c test-stdckdint.c + +## end gnulib module stdckdint-tests + +## begin gnulib module stddef-tests + +TESTS += test-stddef +check_PROGRAMS += test-stddef +EXTRA_DIST += test-stddef.c + +## end gnulib module stddef-tests + +## begin gnulib module stdint-tests + +TESTS += test-stdint +check_PROGRAMS += test-stdint +EXTRA_DIST += test-stdint.c + +## end gnulib module stdint-tests + +## begin gnulib module stdio-tests + +TESTS += test-stdio +check_PROGRAMS += test-stdio +EXTRA_DIST += test-stdio.c macros.h + +## end gnulib module stdio-tests + +## begin gnulib module stdlib-tests + +TESTS += test-stdlib +check_PROGRAMS += test-stdlib +EXTRA_DIST += test-stdlib.c test-sys_wait.h + +## end gnulib module stdlib-tests + +## begin gnulib module strerror-tests + +TESTS += test-strerror +check_PROGRAMS += test-strerror +EXTRA_DIST += test-strerror.c signature.h macros.h + +## end gnulib module strerror-tests + +## begin gnulib module strerror_r-posix + + +EXTRA_DIST += strerror_r.c + +EXTRA_libtests_a_SOURCES += strerror_r.c + +## end gnulib module strerror_r-posix + +## begin gnulib module strerror_r-posix-tests + +TESTS += test-strerror_r +check_PROGRAMS += test-strerror_r +EXTRA_DIST += test-strerror_r.c signature.h macros.h + +## end gnulib module strerror_r-posix-tests + +## begin gnulib module string-tests + +TESTS += test-string +check_PROGRAMS += test-string +EXTRA_DIST += test-string.c + +## end gnulib module string-tests + +## begin gnulib module strings-tests + +TESTS += test-strings +check_PROGRAMS += test-strings +EXTRA_DIST += test-strings.c + +## end gnulib module strings-tests + +## begin gnulib module strnlen-tests + +TESTS += test-strnlen +check_PROGRAMS += test-strnlen +EXTRA_DIST += test-strnlen.c zerosize-ptr.h signature.h macros.h + +## end gnulib module strnlen-tests + +## begin gnulib module strtoimax-tests + +TESTS += test-strtoimax +check_PROGRAMS += test-strtoimax +EXTRA_DIST += test-strtoimax.c signature.h macros.h + +## end gnulib module strtoimax-tests + +## begin gnulib module strtoll-tests + +TESTS += test-strtoll +check_PROGRAMS += test-strtoll +EXTRA_DIST += test-strtoll.c signature.h macros.h + +## end gnulib module strtoll-tests + +## begin gnulib module symlink + +if GL_COND_OBJ_SYMLINK +libtests_a_SOURCES += symlink.c +endif + +## end gnulib module symlink + +## begin gnulib module symlink-tests + +TESTS += test-symlink +check_PROGRAMS += test-symlink +EXTRA_DIST += test-symlink.h test-symlink.c signature.h macros.h + +## end gnulib module symlink-tests + +## begin gnulib module symlinkat + +if GL_COND_OBJ_SYMLINKAT +libtests_a_SOURCES += symlinkat.c +endif + +EXTRA_DIST += at-func.c + +EXTRA_libtests_a_SOURCES += at-func.c + +## end gnulib module symlinkat + +## begin gnulib module symlinkat-tests + +TESTS += test-symlinkat +check_PROGRAMS += test-symlinkat +test_symlinkat_LDADD = $(LDADD) @LIBINTL@ +EXTRA_DIST += test-symlink.h test-symlinkat.c signature.h macros.h + +## end gnulib module symlinkat-tests + +## begin gnulib module sys_ioctl + +BUILT_SOURCES += sys/ioctl.h + +# We need the following in order to create when the system +# does not have a complete one. +sys/ioctl.h: sys_ioctl.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) + $(AM_V_GEN)$(MKDIR_P) '%reldir%/sys' + $(AM_V_at)$(SED_HEADER_STDOUT) \ + -e 's|@''GUARD_PREFIX''@|GL|g' \ + -e 's|@''HAVE_SYS_IOCTL_H''@|$(HAVE_SYS_IOCTL_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_SYS_IOCTL_H''@|$(NEXT_SYS_IOCTL_H)|g' \ + -e 's/@''GNULIB_IOCTL''@/$(GL_GNULIB_IOCTL)/g' \ + -e 's|@''SYS_IOCTL_H_HAVE_WINSOCK2_H''@|$(SYS_IOCTL_H_HAVE_WINSOCK2_H)|g' \ + -e 's|@''SYS_IOCTL_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS''@|$(SYS_IOCTL_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS)|g' \ + -e 's|@''REPLACE_IOCTL''@|$(REPLACE_IOCTL)|g' \ + -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ + -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ + $(srcdir)/sys_ioctl.in.h > $@-t + $(AM_V_at)mv $@-t $@ +MOSTLYCLEANFILES += sys/ioctl.h sys/ioctl.h-t +MOSTLYCLEANDIRS += sys + +EXTRA_DIST += sys_ioctl.in.h + +## end gnulib module sys_ioctl + +## begin gnulib module sys_ioctl-tests + +TESTS += test-sys_ioctl +check_PROGRAMS += test-sys_ioctl +EXTRA_DIST += test-sys_ioctl.c + +## end gnulib module sys_ioctl-tests + +## begin gnulib module sys_random-tests + +TESTS += test-sys_random +check_PROGRAMS += test-sys_random +EXTRA_DIST += test-sys_random.c + +## end gnulib module sys_random-tests + +## begin gnulib module sys_select + +BUILT_SOURCES += sys/select.h + +# We need the following in order to create when the system +# doesn't have one that works with the given compiler. +sys/select.h: sys_select.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) + $(AM_V_GEN)$(MKDIR_P) '%reldir%/sys' + $(AM_V_at)$(SED_HEADER_STDOUT) \ + -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_SYS_SELECT_H''@|$(NEXT_SYS_SELECT_H)|g' \ + -e 's|@''HAVE_SYS_SELECT_H''@|$(HAVE_SYS_SELECT_H)|g' \ + -e 's/@''GNULIB_PSELECT''@/$(GL_GNULIB_PSELECT)/g' \ + -e 's/@''GNULIB_SELECT''@/$(GL_GNULIB_SELECT)/g' \ + -e 's|@''HAVE_WINSOCK2_H''@|$(HAVE_WINSOCK2_H)|g' \ + -e 's|@''HAVE_PSELECT''@|$(HAVE_PSELECT)|g' \ + -e 's|@''REPLACE_PSELECT''@|$(REPLACE_PSELECT)|g' \ + -e 's|@''REPLACE_SELECT''@|$(REPLACE_SELECT)|g' \ + -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ + -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ + $(srcdir)/sys_select.in.h > $@-t + $(AM_V_at)mv $@-t $@ +MOSTLYCLEANFILES += sys/select.h sys/select.h-t +MOSTLYCLEANDIRS += sys + +EXTRA_DIST += sys_select.in.h + +## end gnulib module sys_select + +## begin gnulib module sys_select-tests + +TESTS += test-sys_select +check_PROGRAMS += test-sys_select +EXTRA_DIST += test-sys_select.c signature.h + +## end gnulib module sys_select-tests + +## begin gnulib module sys_socket + +BUILT_SOURCES += sys/socket.h +libtests_a_SOURCES += sys_socket.c + +# We need the following in order to create when the system +# doesn't have one that works with the given compiler. +sys/socket.h: sys_socket.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H) + $(AM_V_GEN)$(MKDIR_P) '%reldir%/sys' + $(AM_V_at)$(SED_HEADER_STDOUT) \ + -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_SYS_SOCKET_H''@|$(NEXT_SYS_SOCKET_H)|g' \ + -e 's|@''HAVE_SYS_SOCKET_H''@|$(HAVE_SYS_SOCKET_H)|g' \ + -e 's/@''GNULIB_CLOSE''@/$(GL_GNULIB_CLOSE)/g' \ + -e 's/@''GNULIB_SOCKET''@/$(GL_GNULIB_SOCKET)/g' \ + -e 's/@''GNULIB_CONNECT''@/$(GL_GNULIB_CONNECT)/g' \ + -e 's/@''GNULIB_ACCEPT''@/$(GL_GNULIB_ACCEPT)/g' \ + -e 's/@''GNULIB_BIND''@/$(GL_GNULIB_BIND)/g' \ + -e 's/@''GNULIB_GETPEERNAME''@/$(GL_GNULIB_GETPEERNAME)/g' \ + -e 's/@''GNULIB_GETSOCKNAME''@/$(GL_GNULIB_GETSOCKNAME)/g' \ + -e 's/@''GNULIB_GETSOCKOPT''@/$(GL_GNULIB_GETSOCKOPT)/g' \ + -e 's/@''GNULIB_LISTEN''@/$(GL_GNULIB_LISTEN)/g' \ + -e 's/@''GNULIB_RECV''@/$(GL_GNULIB_RECV)/g' \ + -e 's/@''GNULIB_SEND''@/$(GL_GNULIB_SEND)/g' \ + -e 's/@''GNULIB_RECVFROM''@/$(GL_GNULIB_RECVFROM)/g' \ + -e 's/@''GNULIB_SENDTO''@/$(GL_GNULIB_SENDTO)/g' \ + -e 's/@''GNULIB_SETSOCKOPT''@/$(GL_GNULIB_SETSOCKOPT)/g' \ + -e 's/@''GNULIB_SHUTDOWN''@/$(GL_GNULIB_SHUTDOWN)/g' \ + -e 's/@''GNULIB_ACCEPT4''@/$(GL_GNULIB_ACCEPT4)/g' \ + -e 's|@''HAVE_WINSOCK2_H''@|$(HAVE_WINSOCK2_H)|g' \ + -e 's|@''HAVE_WS2TCPIP_H''@|$(HAVE_WS2TCPIP_H)|g' \ + -e 's|@''HAVE_STRUCT_SOCKADDR_STORAGE''@|$(HAVE_STRUCT_SOCKADDR_STORAGE)|g' \ + -e 's|@''HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY''@|$(HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY)|g' \ + -e 's|@''HAVE_SA_FAMILY_T''@|$(HAVE_SA_FAMILY_T)|g' \ + -e 's|@''HAVE_ACCEPT4''@|$(HAVE_ACCEPT4)|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)/sys_socket.in.h > $@-t + $(AM_V_at)mv $@-t $@ +MOSTLYCLEANFILES += sys/socket.h sys/socket.h-t +MOSTLYCLEANDIRS += sys + +EXTRA_DIST += sys_socket.in.h + +## end gnulib module sys_socket + +## begin gnulib module sys_socket-tests + +TESTS += test-sys_socket +check_PROGRAMS += test-sys_socket +EXTRA_DIST += test-sys_socket.c + +## end gnulib module sys_socket-tests + +## begin gnulib module sys_stat-tests + +TESTS += test-sys_stat +check_PROGRAMS += test-sys_stat +EXTRA_DIST += test-sys_stat.c + +## end gnulib module sys_stat-tests + +## begin gnulib module sys_time-tests + +TESTS += test-sys_time +check_PROGRAMS += test-sys_time +EXTRA_DIST += test-sys_time.c + +## end gnulib module sys_time-tests + +## begin gnulib module sys_types-tests + +TESTS += test-sys_types +check_PROGRAMS += test-sys_types +EXTRA_DIST += test-sys_types.c + +## end gnulib module sys_types-tests + +## begin gnulib module sys_uio + +BUILT_SOURCES += sys/uio.h + +# We need the following in order to create when the system +# doesn't have one that works with the given compiler. +sys/uio.h: sys_uio.in.h $(top_builddir)/config.status + $(AM_V_GEN)$(MKDIR_P) '%reldir%/sys' + $(AM_V_at)$(SED_HEADER_STDOUT) \ + -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_SYS_UIO_H''@|$(NEXT_SYS_UIO_H)|g' \ + -e 's|@''HAVE_SYS_UIO_H''@|$(HAVE_SYS_UIO_H)|g' \ + $(srcdir)/sys_uio.in.h > $@-t + $(AM_V_at)mv $@-t $@ +MOSTLYCLEANFILES += sys/uio.h sys/uio.h-t +MOSTLYCLEANDIRS += sys + +EXTRA_DIST += sys_uio.in.h + +## end gnulib module sys_uio + +## begin gnulib module sys_uio-tests + +TESTS += test-sys_uio +check_PROGRAMS += test-sys_uio +EXTRA_DIST += test-sys_uio.c + +## end gnulib module sys_uio-tests + +## begin gnulib module sys_wait-tests + +TESTS += test-sys_wait +check_PROGRAMS += test-sys_wait +EXTRA_DIST += test-sys_wait.c test-sys_wait.h + +## end gnulib module sys_wait-tests + +## begin gnulib module test-framework-sh-tests + +TESTS += test-init.sh +EXTRA_DIST += init.sh +EXTRA_DIST += test-init.sh + +## end gnulib module test-framework-sh-tests + +## begin gnulib module thread + +libtests_a_SOURCES += glthread/thread.h glthread/thread.c + +## end gnulib module thread + +## begin gnulib module thread-tests + +TESTS += test-thread_self test-thread_create +check_PROGRAMS += test-thread_self test-thread_create +test_thread_self_LDADD = $(LDADD) @LIBTHREAD@ +test_thread_create_LDADD = $(LDADD) @LIBMULTITHREAD@ +EXTRA_DIST += test-thread_self.c test-thread_create.c macros.h + +## end gnulib module thread-tests + +## begin gnulib module time + +if GL_COND_OBJ_TIME +libtests_a_SOURCES += time.c +endif + +## end gnulib module time + +## begin gnulib module time-h-tests + +TESTS += test-time-h +check_PROGRAMS += test-time-h +EXTRA_DIST += test-time-h.c + +## end gnulib module time-h-tests + +## begin gnulib module time-tests + +TESTS += test-time +check_PROGRAMS += test-time +EXTRA_DIST += test-time.c signature.h macros.h + +## end gnulib module time-tests + +## begin gnulib module timespec-add + +libtests_a_SOURCES += timespec-add.c + +## end gnulib module timespec-add + +## begin gnulib module timespec-sub + +libtests_a_SOURCES += timespec-sub.c + +## end gnulib module timespec-sub + +## begin gnulib module timespec-tests + +TESTS += test-timespec +check_PROGRAMS += test-timespec +EXTRA_DIST += test-timespec.c macros.h + +## end gnulib module timespec-tests + +## begin gnulib module timespec_get-tests + +TESTS += test-timespec_get +check_PROGRAMS += test-timespec_get +test_timespec_get_LDADD = $(LDADD) @CLOCK_TIME_LIB@ +EXTRA_DIST += test-timespec_get.c signature.h macros.h + +## end gnulib module timespec_get-tests + +## begin gnulib module uchar-tests + +TESTS += test-uchar +check_PROGRAMS += test-uchar +EXTRA_DIST += test-uchar.c + +## end gnulib module uchar-tests + +## begin gnulib module unicase/tolower-tests + +TESTS += test-uc_tolower +check_PROGRAMS += test-uc_tolower +test_uc_tolower_SOURCES = unicase/test-uc_tolower.c +test_uc_tolower_LDADD = $(LDADD) $(LIBUNISTRING) +EXTRA_DIST += unicase/test-uc_tolower.c unicase/test-mapping-part1.h unicase/test-mapping-part2.h macros.h + +## end gnulib module unicase/tolower-tests + +## begin gnulib module unictype/ctype-alnum-tests + +TESTS += test-ctype_alnum +check_PROGRAMS += test-ctype_alnum +test_ctype_alnum_SOURCES = unictype/test-ctype_alnum.c +test_ctype_alnum_LDADD = $(LDADD) $(LIBUNISTRING) +EXTRA_DIST += unictype/test-ctype_alnum.c unictype/test-predicate-part1.h unictype/test-predicate-part2.h macros.h + +## end gnulib module unictype/ctype-alnum-tests + +## begin gnulib module unictype/ctype-alpha-tests + +TESTS += test-ctype_alpha +check_PROGRAMS += test-ctype_alpha +test_ctype_alpha_SOURCES = unictype/test-ctype_alpha.c +test_ctype_alpha_LDADD = $(LDADD) $(LIBUNISTRING) +EXTRA_DIST += unictype/test-ctype_alpha.c unictype/test-predicate-part1.h unictype/test-predicate-part2.h macros.h + +## end gnulib module unictype/ctype-alpha-tests + +## begin gnulib module unictype/ctype-blank-tests + +TESTS += test-ctype_blank +check_PROGRAMS += test-ctype_blank +test_ctype_blank_SOURCES = unictype/test-ctype_blank.c +test_ctype_blank_LDADD = $(LDADD) $(LIBUNISTRING) +EXTRA_DIST += unictype/test-ctype_blank.c unictype/test-predicate-part1.h unictype/test-predicate-part2.h macros.h + +## end gnulib module unictype/ctype-blank-tests + +## begin gnulib module unictype/ctype-cntrl-tests + +TESTS += test-ctype_cntrl +check_PROGRAMS += test-ctype_cntrl +test_ctype_cntrl_SOURCES = unictype/test-ctype_cntrl.c +test_ctype_cntrl_LDADD = $(LDADD) $(LIBUNISTRING) +EXTRA_DIST += unictype/test-ctype_cntrl.c unictype/test-predicate-part1.h unictype/test-predicate-part2.h macros.h + +## end gnulib module unictype/ctype-cntrl-tests + +## begin gnulib module unictype/ctype-digit-tests + +TESTS += test-ctype_digit +check_PROGRAMS += test-ctype_digit +test_ctype_digit_SOURCES = unictype/test-ctype_digit.c +test_ctype_digit_LDADD = $(LDADD) $(LIBUNISTRING) +EXTRA_DIST += unictype/test-ctype_digit.c unictype/test-predicate-part1.h unictype/test-predicate-part2.h macros.h + +## end gnulib module unictype/ctype-digit-tests + +## begin gnulib module unictype/ctype-graph-tests + +TESTS += test-ctype_graph +check_PROGRAMS += test-ctype_graph +test_ctype_graph_SOURCES = unictype/test-ctype_graph.c +test_ctype_graph_LDADD = $(LDADD) $(LIBUNISTRING) +EXTRA_DIST += unictype/test-ctype_graph.c unictype/test-predicate-part1.h unictype/test-predicate-part2.h macros.h + +## end gnulib module unictype/ctype-graph-tests + +## begin gnulib module unictype/ctype-lower-tests + +TESTS += test-ctype_lower +check_PROGRAMS += test-ctype_lower +test_ctype_lower_SOURCES = unictype/test-ctype_lower.c +test_ctype_lower_LDADD = $(LDADD) $(LIBUNISTRING) +EXTRA_DIST += unictype/test-ctype_lower.c unictype/test-predicate-part1.h unictype/test-predicate-part2.h macros.h + +## end gnulib module unictype/ctype-lower-tests + +## begin gnulib module unictype/ctype-print-tests + +TESTS += test-ctype_print +check_PROGRAMS += test-ctype_print +test_ctype_print_SOURCES = unictype/test-ctype_print.c +test_ctype_print_LDADD = $(LDADD) $(LIBUNISTRING) +EXTRA_DIST += unictype/test-ctype_print.c unictype/test-predicate-part1.h unictype/test-predicate-part2.h macros.h + +## end gnulib module unictype/ctype-print-tests + +## begin gnulib module unictype/ctype-punct-tests + +TESTS += test-ctype_punct +check_PROGRAMS += test-ctype_punct +test_ctype_punct_SOURCES = unictype/test-ctype_punct.c +test_ctype_punct_LDADD = $(LDADD) $(LIBUNISTRING) +EXTRA_DIST += unictype/test-ctype_punct.c unictype/test-predicate-part1.h unictype/test-predicate-part2.h macros.h + +## end gnulib module unictype/ctype-punct-tests + +## begin gnulib module unictype/ctype-space-tests + +TESTS += test-ctype_space +check_PROGRAMS += test-ctype_space +test_ctype_space_SOURCES = unictype/test-ctype_space.c +test_ctype_space_LDADD = $(LDADD) $(LIBUNISTRING) +EXTRA_DIST += unictype/test-ctype_space.c unictype/test-predicate-part1.h unictype/test-predicate-part2.h macros.h + +## end gnulib module unictype/ctype-space-tests + +## begin gnulib module unictype/ctype-upper-tests + +TESTS += test-ctype_upper +check_PROGRAMS += test-ctype_upper +test_ctype_upper_SOURCES = unictype/test-ctype_upper.c +test_ctype_upper_LDADD = $(LDADD) $(LIBUNISTRING) +EXTRA_DIST += unictype/test-ctype_upper.c unictype/test-predicate-part1.h unictype/test-predicate-part2.h macros.h + +## end gnulib module unictype/ctype-upper-tests + +## begin gnulib module unictype/ctype-xdigit-tests + +TESTS += test-ctype_xdigit +check_PROGRAMS += test-ctype_xdigit +test_ctype_xdigit_SOURCES = unictype/test-ctype_xdigit.c +test_ctype_xdigit_LDADD = $(LDADD) $(LIBUNISTRING) +EXTRA_DIST += unictype/test-ctype_xdigit.c unictype/test-predicate-part1.h unictype/test-predicate-part2.h macros.h + +## end gnulib module unictype/ctype-xdigit-tests + +## begin gnulib module unistd-safer-tests + +TESTS += test-dup-safer +check_PROGRAMS += test-dup-safer +EXTRA_DIST += test-dup-safer.c macros.h + +## end gnulib module unistd-safer-tests + +## begin gnulib module unistd-tests + +TESTS += test-unistd +check_PROGRAMS += test-unistd +EXTRA_DIST += test-unistd.c + +## end gnulib module unistd-tests + +## begin gnulib module unistr/u32-chr-tests + +TESTS += test-u32-chr +check_PROGRAMS += test-u32-chr +test_u32_chr_SOURCES = unistr/test-u32-chr.c +test_u32_chr_LDADD = $(LDADD) $(LIBUNISTRING) +EXTRA_DIST += unistr/test-u32-chr.c unistr/test-chr.h zerosize-ptr.h macros.h + +## end gnulib module unistr/u32-chr-tests + +## begin gnulib module unistr/u32-cpy-tests + +TESTS += test-u32-cpy +check_PROGRAMS += test-u32-cpy +test_u32_cpy_SOURCES = unistr/test-u32-cpy.c +test_u32_cpy_LDADD = $(LDADD) $(LIBUNISTRING) +EXTRA_DIST += unistr/test-u32-cpy.c unistr/test-cpy.h macros.h + +## end gnulib module unistr/u32-cpy-tests + +## begin gnulib module unistr/u32-pcpy-tests + +TESTS += test-u32-pcpy +check_PROGRAMS += test-u32-pcpy +test_u32_pcpy_SOURCES = unistr/test-u32-pcpy.c +test_u32_pcpy_LDADD = $(LDADD) $(LIBUNISTRING) +EXTRA_DIST += unistr/test-u32-pcpy.c unistr/test-pcpy.h macros.h + +## end gnulib module unistr/u32-pcpy-tests + +## begin gnulib module unistr/u32-set + +if LIBUNISTRING_COMPILE_UNISTR_U32_SET +libtests_a_SOURCES += unistr/u32-set.c +endif + +EXTRA_DIST += unistr/u-set.h + +## end gnulib module unistr/u32-set + +## begin gnulib module unistr/u32-set-tests + +TESTS += test-u32-set +check_PROGRAMS += test-u32-set +test_u32_set_SOURCES = unistr/test-u32-set.c +test_u32_set_LDADD = $(LDADD) $(LIBUNISTRING) +EXTRA_DIST += unistr/test-u32-set.c unistr/test-set.h macros.h + +## end gnulib module unistr/u32-set-tests + +## begin gnulib module unistr/u32-strcat-tests + +TESTS += test-u32-strcat +check_PROGRAMS += test-u32-strcat +test_u32_strcat_SOURCES = unistr/test-u32-strcat.c +test_u32_strcat_LDADD = $(LDADD) $(LIBUNISTRING) +EXTRA_DIST += unistr/test-u32-strcat.c unistr/test-strcat.h macros.h + +## end gnulib module unistr/u32-strcat-tests + +## begin gnulib module unistr/u32-strlen-tests + +TESTS += test-u32-strlen +check_PROGRAMS += test-u32-strlen +test_u32_strlen_SOURCES = unistr/test-u32-strlen.c +test_u32_strlen_LDADD = $(LDADD) $(LIBUNISTRING) +EXTRA_DIST += unistr/test-u32-strlen.c macros.h + +## end gnulib module unistr/u32-strlen-tests + +## begin gnulib module uniwidth/width-tests + +TESTS += test-uc_width uniwidth/test-uc_width2.sh +check_PROGRAMS += test-uc_width test-uc_width2 +test_uc_width_SOURCES = uniwidth/test-uc_width.c +test_uc_width_LDADD = $(LDADD) $(LIBUNISTRING) +test_uc_width2_SOURCES = uniwidth/test-uc_width2.c +test_uc_width2_LDADD = $(LDADD) $(LIBUNISTRING) +EXTRA_DIST += uniwidth/test-uc_width.c uniwidth/test-uc_width2.c uniwidth/test-uc_width2.sh macros.h + +## end gnulib module uniwidth/width-tests + +## begin gnulib module unlink + +if GL_COND_OBJ_UNLINK +libtests_a_SOURCES += unlink.c +endif + +## end gnulib module unlink + +## begin gnulib module unlink-tests + +TESTS += test-unlink +check_PROGRAMS += test-unlink +EXTRA_DIST += test-unlink.h test-unlink.c signature.h macros.h + +## end gnulib module unlink-tests + +## begin gnulib module unlinkat + +if GL_COND_OBJ_UNLINKAT +libtests_a_SOURCES += unlinkat.c +endif + +EXTRA_DIST += at-func.c + +EXTRA_libtests_a_SOURCES += at-func.c + +## end gnulib module unlinkat + +## begin gnulib module unlinkat-tests + +TESTS += test-unlinkat +check_PROGRAMS += test-unlinkat +test_unlinkat_LDADD = $(LDADD) @LIBINTL@ +EXTRA_DIST += test-unlinkat.c test-rmdir.h test-unlink.h signature.h macros.h + +## end gnulib module unlinkat-tests + +## begin gnulib module unlinkdir + +libtests_a_SOURCES += unlinkdir.c + +EXTRA_DIST += unlinkdir.h + +## end gnulib module unlinkdir + +## begin gnulib module unsetenv-tests + +TESTS += test-unsetenv +check_PROGRAMS += test-unsetenv +EXTRA_DIST += test-unsetenv.c signature.h macros.h + +## end gnulib module unsetenv-tests + +## begin gnulib module update-copyright-tests + +TESTS += test-update-copyright.sh +TESTS_ENVIRONMENT += abs_aux_dir='$(abs_aux_dir)' +EXTRA_DIST += test-update-copyright.sh + +## end gnulib module update-copyright-tests + +## begin gnulib module vasnprintf + + +EXTRA_DIST += asnprintf.c float+.h printf-args.c printf-args.h printf-parse.c printf-parse.h vasnprintf.c vasnprintf.h + +EXTRA_libtests_a_SOURCES += asnprintf.c printf-args.c printf-parse.c vasnprintf.c + +## end gnulib module vasnprintf + +## begin gnulib module vasnprintf-tests + +TESTS += test-vasnprintf +check_PROGRAMS += test-vasnprintf + +EXTRA_DIST += test-vasnprintf.c macros.h + +## end gnulib module vasnprintf-tests + +## begin gnulib module vc-list-files-tests + +TESTS += test-vc-list-files-git.sh +TESTS += test-vc-list-files-cvs.sh +TESTS_ENVIRONMENT += abs_aux_dir='$(abs_aux_dir)' +EXTRA_DIST += test-vc-list-files-git.sh test-vc-list-files-cvs.sh + +## end gnulib module vc-list-files-tests + +## begin gnulib module verify-tests + +TESTS_ENVIRONMENT += MAKE='$(MAKE)' +TESTS += test-verify test-verify.sh +check_PROGRAMS += test-verify +# test-verify-try is never built, but test-verify.sh needs a rule to +# build test-verify-try.o. +EXTRA_PROGRAMS += test-verify-try + +# This test expects compilation of test-verify-try.c to fail, and +# each time it fails, the makefile rule does not perform the usual +# "mv -f $name.Tpo $name.po, so tell make clean to remove that file. +MOSTLYCLEANFILES += .deps/test-verify-try.Tpo +EXTRA_DIST += test-verify.c test-verify-try.c test-verify.sh + +## end gnulib module verify-tests + +## begin gnulib module version-etc-tests + +TESTS += test-version-etc.sh +check_PROGRAMS += test-version-etc +test_version_etc_LDADD = $(LDADD) @LIBINTL@ +EXTRA_DIST += test-version-etc.c test-version-etc.sh + +## end gnulib module version-etc-tests + +## begin gnulib module wchar-tests + +TESTS += test-wchar +check_PROGRAMS += test-wchar +EXTRA_DIST += test-wchar.c + +## end gnulib module wchar-tests + +## begin gnulib module wcrtomb-tests + +TESTS += \ + test-wcrtomb.sh \ + test-wcrtomb-w32-2.sh test-wcrtomb-w32-3.sh test-wcrtomb-w32-4.sh \ + test-wcrtomb-w32-5.sh test-wcrtomb-w32-6.sh test-wcrtomb-w32-7.sh \ + test-wcrtomb-w32-8.sh +TESTS_ENVIRONMENT += \ + LOCALE_FR='@LOCALE_FR@' \ + LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' \ + LOCALE_JA='@LOCALE_JA@' \ + LOCALE_ZH_CN='@LOCALE_ZH_CN@' +check_PROGRAMS += test-wcrtomb test-wcrtomb-w32 +test_wcrtomb_LDADD = $(LDADD) $(SETLOCALE_LIB) +EXTRA_DIST += test-wcrtomb.sh test-wcrtomb.c test-wcrtomb-w32-2.sh test-wcrtomb-w32-3.sh test-wcrtomb-w32-4.sh test-wcrtomb-w32-5.sh test-wcrtomb-w32-6.sh test-wcrtomb-w32-7.sh test-wcrtomb-w32-8.sh test-wcrtomb-w32.c signature.h macros.h + +## end gnulib module wcrtomb-tests + +## begin gnulib module wctob + +if GL_COND_OBJ_WCTOB +libtests_a_SOURCES += wctob.c +endif + +## end gnulib module wctob + +## begin gnulib module wctomb + +if GL_COND_OBJ_WCTOMB +libtests_a_SOURCES += wctomb.c +endif + +EXTRA_DIST += wctomb-impl.h + +## end gnulib module wctomb + +## begin gnulib module wctype-h-tests + +TESTS += test-wctype-h +check_PROGRAMS += test-wctype-h +EXTRA_DIST += test-wctype-h.c macros.h + +## end gnulib module wctype-h-tests + +## begin gnulib module wctype-tests + +TESTS += test-wctype +check_PROGRAMS += test-wctype +EXTRA_DIST += test-wctype.c signature.h macros.h + +## end gnulib module wctype-tests + +## begin gnulib module wcwidth-tests + +TESTS += test-wcwidth +check_PROGRAMS += test-wcwidth +test_wcwidth_LDADD = $(LDADD) $(SETLOCALE_LIB) $(LIBUNISTRING) +EXTRA_DIST += test-wcwidth.c signature.h macros.h + +## end gnulib module wcwidth-tests + +## begin gnulib module windows-thread + +if GL_COND_OBJ_WINDOWS_THREAD +libtests_a_SOURCES += windows-thread.c +endif + +EXTRA_DIST += windows-thread.h + +## end gnulib module windows-thread + +## begin gnulib module windows-tls + +if GL_COND_OBJ_WINDOWS_TLS +libtests_a_SOURCES += windows-tls.c +endif + +EXTRA_DIST += windows-tls.h + +## end gnulib module windows-tls + +## begin gnulib module xalloc-die-tests + +TESTS += test-xalloc-die.sh +check_PROGRAMS += test-xalloc-die +test_xalloc_die_LDADD = $(LDADD) @LIBINTL@ +EXTRA_DIST += test-xalloc-die.c test-xalloc-die.sh + +## end gnulib module xalloc-die-tests + +## begin gnulib module xsize + +libtests_a_SOURCES += xsize.h xsize.c + +## end gnulib module xsize + +## begin gnulib module xstdopen-tests + +TESTS += test-xstdopen.sh +check_PROGRAMS += test-xstdopen +test_xstdopen_LDADD = $(LDADD) @LIBINTL@ +EXTRA_DIST += test-xstdopen.c test-xstdopen.sh macros.h + +## end gnulib module xstdopen-tests + +## begin gnulib module xstrtoimax-tests + +TESTS += test-xstrtoimax.sh +check_PROGRAMS += test-xstrtoimax +test_xstrtoimax_LDADD = $(LDADD) @LIBINTL@ +EXTRA_DIST += test-xstrtoimax.c test-xstrtoimax.sh + +## end gnulib module xstrtoimax-tests + +## begin gnulib module xstrtol-error + +libtests_a_SOURCES += xstrtol-error.c + +EXTRA_DIST += xstrtol-error.h + +## end gnulib module xstrtol-error + +## begin gnulib module xstrtol-tests + +TESTS += test-xstrtol.sh +check_PROGRAMS += test-xstrtol test-xstrtoul +test_xstrtol_LDADD = $(LDADD) @LIBINTL@ +test_xstrtoul_LDADD = $(LDADD) @LIBINTL@ +EXTRA_DIST += test-xstrtol.c test-xstrtoul.c test-xstrtol.sh + +## end gnulib module xstrtol-tests + +## begin gnulib module year2038-tests + +TESTS += test-year2038 +check_PROGRAMS += test-year2038 +EXTRA_DIST += test-year2038.c + +## end gnulib module year2038-tests + +all: all-notice +all-notice: + @echo '## ---------------------------------------------------- ##' + @echo '## ------------------- Gnulib tests ------------------- ##' + @echo '## You can ignore compiler warnings in this directory. ##' + @echo '## ---------------------------------------------------- ##' + +check-am: check-notice +check-notice: + @echo '## ---------------------------------------------------------------------- ##' + @echo '## ---------------------------- Gnulib tests ---------------------------- ##' + @echo '## Please report test failures in this directory to . ##' + @echo '## ---------------------------------------------------------------------- ##' + +# Clean up after Solaris cc. +clean-local: + rm -rf SunWS_cache + +mostlyclean-local: mostlyclean-generic + @for dir in '' $(MOSTLYCLEANDIRS); do \ + if test -n "$$dir" && test -d $$dir; then \ + echo "rmdir $$dir"; rmdir $$dir; \ + fi; \ + done; \ + : diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/hash-pjw.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/hash-pjw.c new file mode 100644 index 00000000..d8517ea4 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/hash-pjw.c @@ -0,0 +1,40 @@ +/* hash-pjw.c -- compute a hash value from a NUL-terminated string. + + Copyright (C) 2001, 2003, 2006, 2009-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +#include "hash-pjw.h" + +#include + +#define SIZE_BITS (sizeof (size_t) * CHAR_BIT) + +/* A hash function for NUL-terminated char* strings using + the method described by Bruno Haible. + See https://www.haible.de/bruno/hashfunc.html. */ + +size_t +hash_pjw (const void *x, size_t tablesize) +{ + const char *s; + size_t h = 0; + + for (s = x; *s; s++) + h = *s + ((h << 9) | (h >> (SIZE_BITS - 9))); + + return h % tablesize; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/hash-pjw.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/hash-pjw.h new file mode 100644 index 00000000..7c60d16f --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/hash-pjw.h @@ -0,0 +1,28 @@ +/* hash-pjw.h -- declaration for a simple hash function + Copyright (C) 2001, 2003, 2009-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* This file uses _GL_ATTRIBUTE_PURE. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +#include + +/* Compute a hash code for a NUL-terminated string starting at X, + and return the hash code modulo TABLESIZE. + The result is platform dependent: it depends on the size of the 'size_t' + type and on the signedness of the 'char' type. */ +extern size_t hash_pjw (void const *x, size_t tablesize) _GL_ATTRIBUTE_PURE; diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/imaxtostr.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/imaxtostr.c new file mode 100644 index 00000000..98f6fafa --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/imaxtostr.c @@ -0,0 +1,20 @@ +/* Convert 'intmax_t' integer to printable string. + + Copyright (C) 2004-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#define anytostr imaxtostr +#define inttype intmax_t +#include "anytostr.c" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/inet_pton.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/inet_pton.c new file mode 100644 index 00000000..2d29608d --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/inet_pton.c @@ -0,0 +1,268 @@ +/* inet_pton.c -- convert IPv4 and IPv6 addresses from text to binary form + + Copyright (C) 2006, 2008-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* + * Copyright (c) 1996,1999 by Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE + * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS + * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +#include + +/* Specification. */ +#include + +#if HAVE_DECL_INET_PTON + +# undef inet_pton + +int +rpl_inet_pton (int af, const char *restrict src, void *restrict dst) +{ + return inet_pton (af, src, dst); +} + +#else + +# include +# include +# include + +# define NS_INADDRSZ 4 +# define NS_IN6ADDRSZ 16 +# define NS_INT16SZ 2 + +/* + * WARNING: Don't even consider trying to compile this on a system where + * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX. + */ + +static int inet_pton4 (const char *src, unsigned char *dst); +# if HAVE_IPV6 +static int inet_pton6 (const char *src, unsigned char *dst); +# endif + +/* int + * inet_pton(af, src, dst) + * convert from presentation format (which usually means ASCII printable) + * to network format (which is usually some kind of binary format). + * return: + * 1 if the address was valid for the specified address family + * 0 if the address wasn't valid ('dst' is untouched in this case) + * -1 if some other error occurred ('dst' is untouched in this case, too) + * author: + * Paul Vixie, 1996. + */ +int +inet_pton (int af, const char *restrict src, void *restrict dst) +{ + switch (af) + { + case AF_INET: + return (inet_pton4 (src, dst)); + +# if HAVE_IPV6 + case AF_INET6: + return (inet_pton6 (src, dst)); +# endif + + default: + errno = EAFNOSUPPORT; + return (-1); + } + /* NOTREACHED */ +} + +/* int + * inet_pton4(src, dst) + * like inet_aton() but without all the hexadecimal, octal (with the + * exception of 0) and shorthand. + * return: + * 1 if 'src' is a valid dotted quad, else 0. + * notice: + * does not touch 'dst' unless it's returning 1. + * author: + * Paul Vixie, 1996. + */ +static int +inet_pton4 (const char *restrict src, unsigned char *restrict dst) +{ + int saw_digit, octets, ch; + unsigned char tmp[NS_INADDRSZ], *tp; + + saw_digit = 0; + octets = 0; + *(tp = tmp) = 0; + while ((ch = *src++) != '\0') + { + + if (ch >= '0' && ch <= '9') + { + unsigned new = *tp * 10 + (ch - '0'); + + if (saw_digit && *tp == 0) + return (0); + if (new > 255) + return (0); + *tp = new; + if (!saw_digit) + { + if (++octets > 4) + return (0); + saw_digit = 1; + } + } + else if (ch == '.' && saw_digit) + { + if (octets == 4) + return (0); + *++tp = 0; + saw_digit = 0; + } + else + return (0); + } + if (octets < 4) + return (0); + memcpy (dst, tmp, NS_INADDRSZ); + return (1); +} + +# if HAVE_IPV6 + +/* int + * inet_pton6(src, dst) + * convert presentation level address to network order binary form. + * return: + * 1 if 'src' is a valid [RFC1884 2.2] address, else 0. + * notice: + * (1) does not touch 'dst' unless it's returning 1. + * (2) :: in a full address is silently ignored. + * credit: + * inspired by Mark Andrews. + * author: + * Paul Vixie, 1996. + */ +static int +inet_pton6 (const char *restrict src, unsigned char *restrict dst) +{ + static const char xdigits[] = "0123456789abcdef"; + unsigned char tmp[NS_IN6ADDRSZ], *tp, *endp, *colonp; + const char *curtok; + int ch, saw_xdigit; + unsigned val; + + tp = memset (tmp, '\0', NS_IN6ADDRSZ); + endp = tp + NS_IN6ADDRSZ; + colonp = NULL; + /* Leading :: requires some special handling. */ + if (*src == ':') + if (*++src != ':') + return (0); + curtok = src; + saw_xdigit = 0; + val = 0; + while ((ch = c_tolower (*src++)) != '\0') + { + const char *pch; + + pch = strchr (xdigits, ch); + if (pch != NULL) + { + val <<= 4; + val |= (pch - xdigits); + if (val > 0xffff) + return (0); + saw_xdigit = 1; + continue; + } + if (ch == ':') + { + curtok = src; + if (!saw_xdigit) + { + if (colonp) + return (0); + colonp = tp; + continue; + } + else if (*src == '\0') + { + return (0); + } + if (tp + NS_INT16SZ > endp) + return (0); + *tp++ = (u_char) (val >> 8) & 0xff; + *tp++ = (u_char) val & 0xff; + saw_xdigit = 0; + val = 0; + continue; + } + if (ch == '.' && ((tp + NS_INADDRSZ) <= endp) && + inet_pton4 (curtok, tp) > 0) + { + tp += NS_INADDRSZ; + saw_xdigit = 0; + break; /* '\0' was seen by inet_pton4(). */ + } + return (0); + } + if (saw_xdigit) + { + if (tp + NS_INT16SZ > endp) + return (0); + *tp++ = (u_char) (val >> 8) & 0xff; + *tp++ = (u_char) val & 0xff; + } + if (colonp != NULL) + { + /* + * Since some memmove()'s erroneously fail to handle + * overlapping regions, we'll do the shift by hand. + */ + const int n = tp - colonp; + int i; + + if (tp == endp) + return (0); + for (i = 1; i <= n; i++) + { + endp[-i] = colonp[n - i]; + colonp[n - i] = 0; + } + tp = endp; + } + if (tp != endp) + return (0); + memcpy (dst, tmp, NS_IN6ADDRSZ); + return (1); +} + +# endif + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/infinity.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/infinity.h new file mode 100644 index 00000000..40e663ff --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/infinity.h @@ -0,0 +1,66 @@ +/* Macros for infinity. + Copyright (C) 2011-2024 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 . */ + + +/* Infinityf () returns a 'float' +Infinity. */ + +/* The Microsoft MSVC 9 compiler chokes on the expression 1.0f / 0.0f. + The IBM XL C compiler on z/OS complains. + PGI 16.10 complains. */ +#if defined _MSC_VER || (defined __MVS__ && defined __IBMC__) || defined __PGI +static float +Infinityf () +{ + static float zero = 0.0f; + return 1.0f / zero; +} +#else +# define Infinityf() (1.0f / 0.0f) +#endif + + +/* Infinityd () returns a 'double' +Infinity. */ + +/* The Microsoft MSVC 9 compiler chokes on the expression 1.0 / 0.0. + The IBM XL C compiler on z/OS complains. + PGI 16.10 complains. */ +#if defined _MSC_VER || (defined __MVS__ && defined __IBMC__) || defined __PGI +static double +Infinityd () +{ + static double zero = 0.0; + return 1.0 / zero; +} +#else +# define Infinityd() (1.0 / 0.0) +#endif + + +/* Infinityl () returns a 'long double' +Infinity. */ + +/* The Microsoft MSVC 9 compiler chokes on the expression 1.0L / 0.0L. + The IBM XL C compiler on z/OS complains. + PGI 16.10 complains. */ +#if defined _MSC_VER || (defined __MVS__ && defined __IBMC__) || defined __PGI +static long double +Infinityl () +{ + static long double zero = 0.0L; + return 1.0L / zero; +} +#else +# define Infinityl() (1.0L / 0.0L) +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/init.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/init.sh new file mode 100644 index 00000000..c5ec5cfd --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/init.sh @@ -0,0 +1,706 @@ +# source this file; set up for tests + +# Copyright (C) 2009-2024 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 . + +# Using this file in a test +# ========================= +# +# The typical skeleton of a test looks like this: +# +# #!/bin/sh +# . "${srcdir=.}/init.sh"; path_prepend_ . +# Execute some commands. +# Note that these commands are executed in a subdirectory, therefore you +# need to prepend "../" to relative filenames in the build directory. +# Note that the "path_prepend_ ." is useful only if the body of your +# test invokes programs residing in the initial directory. +# For example, if the programs you want to test are in src/, and this test +# script is named tests/test-1, then you would use "path_prepend_ ../src", +# or perhaps export PATH='$(abs_top_builddir)/src$(PATH_SEPARATOR)'"$$PATH" +# to all tests via automake's TESTS_ENVIRONMENT. +# Set the exit code 0 for success, 77 for skipped, or 1 or other for failure. +# Use the skip_ and fail_ functions to print a diagnostic and then exit +# with the corresponding exit code. +# Exit $? + +# Executing a test that uses this file +# ==================================== +# +# Running a single test: +# $ make check TESTS=test-foo.sh +# +# Running a single test, with verbose output: +# $ make check TESTS=test-foo.sh VERBOSE=yes +# +# Running a single test, keeping the temporary directory: +# $ make check TESTS=test-foo.sh KEEP=yes +# +# Running a single test, with single-stepping: +# 1. Go into a sub-shell: +# $ bash +# 2. Set relevant environment variables from TESTS_ENVIRONMENT in the +# Makefile: +# $ export srcdir=../../tests # this is an example +# 3. Execute the commands from the test, copy&pasting them one by one: +# $ . "$srcdir/init.sh"; path_prepend_ . +# ... +# 4. Finally +# $ exit + +# ============================================================================= +# Elementary diagnostics + +ME_=`expr "./$0" : '.*/\(.*\)$'` + +# Prepare PATH_SEPARATOR. +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which + # contains only /bin. Note that ksh looks also at the FPATH variable, + # so we have to set that as well for the test. + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ + && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ + || PATH_SEPARATOR=';' + } +fi + +# We use a trap below for cleanup. This requires us to go through +# hoops to get the right exit status transported through the handler. +# So use 'Exit STATUS' instead of 'exit STATUS' inside of the tests. +# Turn off errexit here so that we don't trip the bug with OSF1/Tru64 +# sh inside this function. +Exit () { set +e; (exit $1); exit $1; } + +# Print warnings (e.g., about skipped and failed tests) to this file number. +# Override by defining to say, 9, in init.cfg, and putting say, +# export ...ENVVAR_SETTINGS...; $(SHELL) 9>&2 +# in the definition of TESTS_ENVIRONMENT in your tests/Makefile.am file. +# This is useful when using automake's parallel tests mode, to print +# the reason for skip/failure to console, rather than to the .log files. +: ${stderr_fileno_=2} + +# Note that correct expansion of "$*" depends on IFS starting with ' '. +# Always write the full diagnostic to stderr. +# When stderr_fileno_ is not 2, also emit the first line of the +# diagnostic to that file descriptor. +warn_ () +{ + # If IFS does not start with ' ', set it and emit the warning in a subshell. + case $IFS in + ' '*) printf '%s\n' "$*" >&2 + test $stderr_fileno_ = 2 \ + || { printf '%s\n' "$*" | sed 1q >&$stderr_fileno_ ; } ;; + *) (IFS=' '; warn_ "$@");; + esac +} +fail_ () { warn_ "$ME_: failed test: $@"; Exit 1; } +skip_ () { warn_ "$ME_: skipped test: $@"; Exit 77; } +fatal_ () { warn_ "$ME_: hard error: $@"; Exit 99; } +framework_failure_ () { warn_ "$ME_: set-up failure: $@"; Exit 99; } + +# ============================================================================= +# Ensure the shell supports modern syntax. + +# Sanitize this shell to POSIX mode, if possible. +DUALCASE=1; export DUALCASE +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; + esac +fi + +# We require $(...) support unconditionally. +# We require that the printf built-in work correctly regarding octal escapes; +# this eliminates /bin/sh on AIX 7.2. +# We require non-surprising "local" semantics (this eliminates dash). +# This takes the admittedly draconian step of eliminating dash, because the +# assignment tab=$(printf '\t') works fine, yet preceding it with "local " +# transforms it into an assignment that sets the variable to the empty string. +# That is too counter-intuitive, and can lead to subtle run-time malfunction. +# The example below is less subtle in that with dash, it evokes the run-time +# exception "dash: 1: local: 1: bad variable name". +# We require a few additional shell features only when $EXEEXT is nonempty, +# in order to support automatic $EXEEXT emulation: +# - hyphen-containing alias names +# - we prefer to use ${var#...} substitution, rather than having +# to work around lack of support for that feature. +# The following code attempts to find a shell with support for these features. +# If the current shell passes the test, we're done. Otherwise, test other +# shells until we find one that passes. If one is found, re-exec it. +# If no acceptable shell is found, skip the current test. +# +# The "...set -x; P=1 true 2>err..." test is to disqualify any shell that +# emits "P=1" into err, as /bin/sh from SunOS 5.11 and OpenBSD 4.7 do. +# +# Use "9" to indicate success (rather than 0), in case some shell acts +# like Solaris 10's /bin/sh but exits successfully instead of with status 2. + +# Eval this code in a subshell to determine a shell's suitability. +# 10 - passes all tests; ok to use +# 9 - ok, but enabling "set -x" corrupts app stderr; prefer higher score +# ? - not ok +gl_shell_test_script_=' +test $(echo y) = y || exit 1 +LC_ALL=en_US.UTF-8 printf "\\351" 2>/dev/null \ + | LC_ALL=C tr "\\351" x | LC_ALL=C grep "^x$" > /dev/null \ + || exit 1 +printf "\\351" 2>/dev/null \ + | LC_ALL=C tr "\\351" x | LC_ALL=C grep "^x$" > /dev/null \ + || exit 1 +f_local_() { local v=1; }; f_local_ || exit 1 +f_dash_local_fail_() { local t=$(printf " 1"); }; f_dash_local_fail_ +score_=10 +if test "$VERBOSE" = yes; then + test -n "$( (exec 3>&1; set -x; P=1 true 2>&3) 2> /dev/null)" && score_=9 +fi +test -z "$EXEEXT" && exit $score_ +shopt -s expand_aliases +alias a-b="echo zoo" +v=abx + test ${v%x} = ab \ + && test ${v#a} = bx \ + && test $(a-b) = zoo \ + && exit $score_ +' + +if test "x$1" = "x--no-reexec"; then + shift +else + # Assume a working shell. Export to subshells (setup_ needs this). + gl_set_x_corrupts_stderr_=false + export gl_set_x_corrupts_stderr_ + + # Record the first marginally acceptable shell. + marginal_= + + # Search for a shell that meets our requirements. + for re_shell_ in __current__ "${CONFIG_SHELL:-no_shell}" \ + /bin/sh bash dash zsh pdksh fail + do + test "$re_shell_" = no_shell && continue + + # If we've made it all the way to the sentinel, "fail" without + # finding even a marginal shell, skip this test. + if test "$re_shell_" = fail; then + test -z "$marginal_" && skip_ failed to find an adequate shell + re_shell_=$marginal_ + break + fi + + # When testing the current shell, simply "eval" the test code. + # Otherwise, run it via $re_shell_ -c ... + if test "$re_shell_" = __current__; then + # 'eval'ing this code makes Solaris 10's /bin/sh exit with + # $? set to 2. It does not evaluate any of the code after the + # "unexpected" first '('. Thus, we must run it in a subshell. + ( eval "$gl_shell_test_script_" ) > /dev/null 2>&1 + else + "$re_shell_" -c "$gl_shell_test_script_" 2>/dev/null + fi + + st_=$? + + # $re_shell_ works just fine. Use it. + if test $st_ = 10; then + gl_set_x_corrupts_stderr_=false + break + fi + + # If this is our first marginally acceptable shell, remember it. + if test "$st_:$marginal_" = 9: ; then + marginal_="$re_shell_" + gl_set_x_corrupts_stderr_=true + fi + done + + if test "$re_shell_" != __current__; then + # Found a usable shell. Preserve -v and -x. + case $- in + *v*x* | *x*v*) opts_=-vx ;; + *v*) opts_=-v ;; + *x*) opts_=-x ;; + *) opts_= ;; + esac + re_shell=$re_shell_ + export re_shell + exec "$re_shell_" $opts_ "$0" --no-reexec "$@" + echo "$ME_: exec failed" 1>&2 + exit 127 + fi +fi + +# ============================================================================= +# Ensure the shell behaves reasonably. + +# If this is bash, turn off all aliases. +test -n "$BASH_VERSION" && unalias -a + +# Note that when supporting $EXEEXT (transparently mapping from PROG_NAME to +# PROG_NAME.exe), we want to support hyphen-containing names like test-acos. +# That is part of the shell-selection test above. Why use aliases rather +# than functions? Because support for hyphen-containing aliases is more +# widespread than that for hyphen-containing function names. +test -n "$EXEEXT" && test -n "$BASH_VERSION" && shopt -s expand_aliases + +# ============================================================================= +# Creating a temporary directory (needed by the core test framework) + +# Create a temporary directory, much like mktemp -d does. +# Written by Jim Meyering. +# +# Usage: mktempd_ /tmp phoey.XXXXXXXXXX +# +# First, try to use the mktemp program. +# Failing that, we'll roll our own mktemp-like function: +# - try to get random bytes from /dev/urandom, mapping them to file-name bytes +# - failing that, generate output from a combination of quickly-varying +# sources and awk. +# - try to create the desired directory. +# - make only $MAX_TRIES_ attempts + +# Helper function. Print $N pseudo-random bytes from a-zA-Z0-9. +rand_bytes_ () +{ + n_=$1 + + # Maybe try openssl rand -base64 $n_prime_|tr '+/=\012' abcd first? + # But if they have openssl, they probably have mktemp, too. + + chars_=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 + dev_rand_=/dev/urandom + if test -r "$dev_rand_"; then + # Note: 256-length($chars_) == 194; 3 copies of $chars_ is 186 + 8 = 194. + dd ibs=$n_ count=1 if=$dev_rand_ 2>/dev/null \ + | LC_ALL=C tr -c $chars_ 01234567$chars_$chars_$chars_ + return + fi + + # Fall back on quickly-varying sources + awk. + # Limit awk program to 7th Edition Unix so that it works even on Solaris 10. + + (date; date +%N; free; who -a; w; ps auxww; ps -ef) 2>&1 | awk ' + BEGIN { + n = '"$n_"' + for (i = 0; i < 256; i++) + ordinal[sprintf ("%c", i)] = i + } + { + for (i = 1; i <= length; i++) + a[ai++ % n] += ordinal[substr ($0, i, 1)] + } + END { + chars = "'"$chars_"'" + charslen = length (chars) + for (i = 0; i < n; i++) + printf "%s", substr (chars, a[i] % charslen + 1, 1) + printf "\n" + } + ' +} + +mktempd_ () +{ + case $# in + 2);; + *) fail_ "Usage: mktempd_ DIR TEMPLATE";; + esac + + destdir_=$1 + template_=$2 + + MAX_TRIES_=4 + + # Disallow any trailing slash on specified destdir: + # it would subvert the post-mktemp "case"-based destdir test. + case $destdir_ in + / | //) destdir_slash_=$destdir;; + */) fail_ "invalid destination dir: remove trailing slash(es)";; + *) destdir_slash_=$destdir_/;; + esac + + case $template_ in + *XXXX) ;; + *) fail_ \ + "invalid template: $template_ (must have a suffix of at least 4 X's)";; + esac + + # First, try to use mktemp. + d=`unset TMPDIR; { mktemp -d -t -p "$destdir_" "$template_"; } 2>/dev/null` && + + # The resulting name must be in the specified directory. + case $d in "$destdir_slash_"*) :;; *) false;; esac && + + # It must have created the directory. + test -d "$d" && + + # It must have 0700 permissions. Handle sticky "S" bits. + perms=`ls -dgo "$d" 2>/dev/null` && + case $perms in drwx--[-S]---*) :;; *) false;; esac && { + echo "$d" + return + } + + # If we reach this point, we'll have to create a directory manually. + + # Get a copy of the template without its suffix of X's. + base_template_=`echo "$template_"|sed 's/XX*$//'` + + # Calculate how many X's we've just removed. + template_length_=`echo "$template_" | wc -c` + nx_=`echo "$base_template_" | wc -c` + nx_=`expr $template_length_ - $nx_` + + err_= + i_=1 + while :; do + X_=`rand_bytes_ $nx_` + candidate_dir_="$destdir_slash_$base_template_$X_" + err_=`mkdir -m 0700 "$candidate_dir_" 2>&1` \ + && { echo "$candidate_dir_"; return; } + test $MAX_TRIES_ -le $i_ && break; + i_=`expr $i_ + 1` + done + fail_ "$err_" +} + +# ============================================================================= +# Core test framework + +# An arbitrary prefix to help distinguish test directories. +testdir_prefix_ () { printf gt; } + +# Set up the environment for the test to run in. +setup_ () +{ + if test "$VERBOSE" = yes; then + # Test whether set -x may cause the selected shell to corrupt an + # application's stderr. Many do, including zsh-4.3.10 and the /bin/sh + # from SunOS 5.11, OpenBSD 4.7 and Irix 6.5. + # If enabling verbose output this way would cause trouble, simply + # issue a warning and refrain. + if $gl_set_x_corrupts_stderr_; then + warn_ "using SHELL=$SHELL with 'set -x' corrupts stderr" + else + set -x + fi + fi + + initial_cwd_=$PWD + + # Create and enter the temporary directory. + pfx_=`testdir_prefix_` + test_dir_=`mktempd_ "$initial_cwd_" "$pfx_-$ME_.XXXX"` \ + || fail_ "failed to create temporary directory in $initial_cwd_" + cd "$test_dir_" || fail_ "failed to cd to temporary directory" + # Set variables srcdir, builddir, for the convenience of the test. + case $srcdir in + /* | ?:*) ;; + *) srcdir="../$srcdir" ;; + esac + builddir=".." + export srcdir builddir + + # As autoconf-generated configure scripts do, ensure that IFS + # is defined initially, so that saving and restoring $IFS works. + gl_init_sh_nl_=' +' + IFS=" "" $gl_init_sh_nl_" + + # This trap statement, along with a trap on 0 below, ensure that the + # temporary directory, $test_dir_, is removed upon exit as well as + # upon receipt of any of the listed signals. + for sig_ in 1 2 3 13 15; do + eval "trap 'Exit $(expr $sig_ + 128)' $sig_" + done + + # Remove relative and non-accessible directories from PATH, including '.' + # and Zero-length entries. + saved_IFS="$IFS"; IFS="$PATH_SEPARATOR" + new_PATH= + for dir in $PATH; do + IFS="$saved_IFS" + case "$dir" in + [\\/]* | ?:[\\/]*) + test -d "$dir/." || continue + new_PATH="${new_PATH}${new_PATH:+$PATH_SEPARATOR}${dir}" + ;; + esac + done + IFS="$saved_IFS" + PATH="$new_PATH" + export PATH +} + +# This is a stub function that is run upon trap (upon regular exit and +# interrupt). Override it with a per-test function, e.g., to unmount +# a partition, or to undo any other global state changes. +cleanup_ () { :; } + +# Run the user-overridable cleanup_ function, remove the temporary +# directory and exit with the incoming value of $?. +remove_tmp_ () +{ + __st=$? + cleanup_ + if test "$KEEP" = yes; then + echo "Not removing temporary directory $test_dir_" + else + # cd out of the directory we're about to remove + cd "$initial_cwd_" || cd / || cd /tmp + chmod -R u+rwx "$test_dir_" + # If removal fails and exit status was to be 0, then change it to 1. + rm -rf "$test_dir_" || { test $__st = 0 && __st=1; } + fi + exit $__st +} + +# ============================================================================= +# Prepending directories to PATH + +# Given a directory name, DIR, if every entry in it that matches *.exe +# contains only the specified bytes (see the case stmt below), then print +# a space-separated list of those names and return 0. Otherwise, don't +# print anything and return 1. Naming constraints apply also to DIR. +find_exe_basenames_ () +{ + feb_dir_=$1 + feb_fail_=0 + feb_result_= + feb_sp_= + for feb_file_ in $feb_dir_/*.exe; do + # If there was no *.exe file, or there existed a file named "*.exe" that + # was deleted between the above glob expansion and the existence test + # below, just skip it. + test "x$feb_file_" = "x$feb_dir_/*.exe" && test ! -f "$feb_file_" \ + && continue + # Exempt [.exe, since we can't create a function by that name, yet + # we can't invoke [ by PATH search anyways due to shell builtins. + test "x$feb_file_" = "x$feb_dir_/[.exe" && continue + case $feb_file_ in + *[!-a-zA-Z/0-9_.+]*) feb_fail_=1; break;; + *) # Remove leading file name components as well as the .exe suffix. + feb_file_=${feb_file_##*/} + feb_file_=${feb_file_%.exe} + feb_result_="$feb_result_$feb_sp_$feb_file_";; + esac + feb_sp_=' ' + done + test $feb_fail_ = 0 && printf %s "$feb_result_" + return $feb_fail_ +} + +# Consider the files in directory, $1. +# For each file name of the form PROG.exe, create an alias named +# PROG that simply invokes PROG.exe, then return 0. If any selected +# file name or the directory name, $1, contains an unexpected character, +# define no alias and return 1. +create_exe_shims_ () +{ + case $EXEEXT in + '') return 0 ;; + .exe) ;; + *) echo "$0: unexpected \$EXEEXT value: $EXEEXT" 1>&2; return 1 ;; + esac + + base_names_=`find_exe_basenames_ $1` \ + || { echo "$0 (exe_shim): skipping directory: $1" 1>&2; return 0; } + + if test -n "$base_names_"; then + for base_ in $base_names_; do + alias "$base_"="$base_$EXEEXT" + done + fi + + return 0 +} + +# Use this function to prepend to PATH an absolute name for each +# specified, possibly-$initial_cwd_-relative, directory. +path_prepend_ () +{ + while test $# != 0; do + path_dir_=$1 + case $path_dir_ in + '') fail_ "invalid path dir: '$1'";; + /* | ?:*) abs_path_dir_=$path_dir_;; + *) abs_path_dir_=$initial_cwd_/$path_dir_;; + esac + case $abs_path_dir_ in + *$PATH_SEPARATOR*) fail_ "invalid path dir: '$abs_path_dir_'";; + esac + PATH="$abs_path_dir_$PATH_SEPARATOR$PATH" + + # Create an alias, FOO, for each FOO.exe in this directory. + create_exe_shims_ "$abs_path_dir_" \ + || fail_ "something failed (above): $abs_path_dir_" + shift + done + export PATH +} + +# ============================================================================= +# Convenience environment variables for the tests + +# ----------------------------------------------------------------------------- + +# Enable glibc's malloc-perturbing option. +# This is useful for exposing code that depends on the fact that +# malloc-related functions often return memory that is mostly zeroed. +# If you have the time and cycles, use valgrind to do an even better job. +: ${MALLOC_PERTURB_=87} +export MALLOC_PERTURB_ + +# ----------------------------------------------------------------------------- + +# The interpreter for Bourne-shell scripts. +# No special standards compatibility requirements. +# Some environments, such as Android, don't have /bin/sh. +if test -f /bin/sh$EXEEXT; then + BOURNE_SHELL=/bin/sh +else + BOURNE_SHELL=sh +fi + +# ============================================================================= +# Convenience functions for the tests + +# ----------------------------------------------------------------------------- +# Return value checking + +# This is used to simplify checking of the return value +# which is useful when ensuring a command fails as desired. +# I.e., just doing `command ... &&fail=1` will not catch +# a segfault in command for example. With this helper you +# instead check an explicit exit code like +# returns_ 1 command ... || fail +returns_ () { + # Disable tracing so it doesn't interfere with stderr of the wrapped command + { set +x; } 2>/dev/null + + local exp_exit="$1" + shift + "$@" + test $? -eq $exp_exit && ret_=0 || ret_=1 + + if test "$VERBOSE" = yes && test "$gl_set_x_corrupts_stderr_" = false; then + set -x + fi + { return $ret_; } 2>/dev/null +} + +# ----------------------------------------------------------------------------- +# Text file comparison + +# Emit a header similar to that from diff -u; Print the simulated "diff" +# command so that the order of arguments is clear. Don't bother with @@ lines. +emit_diff_u_header_ () +{ + printf '%s\n' "diff -u $*" \ + "--- $1 1970-01-01" \ + "+++ $2 1970-01-01" +} + +# Arrange not to let diff or cmp operate on /dev/null, +# since on some systems (at least OSF/1 5.1), that doesn't work. +# When there are not two arguments, or no argument is /dev/null, return 2. +# When one argument is /dev/null and the other is not empty, +# cat the nonempty file to stderr and return 1. +# Otherwise, return 0. +compare_dev_null_ () +{ + test $# = 2 || return 2 + + if test "x$1" = x/dev/null; then + test -s "$2" || return 0 + emit_diff_u_header_ "$@"; sed 's/^/+/' "$2" + return 1 + fi + + if test "x$2" = x/dev/null; then + test -s "$1" || return 0 + emit_diff_u_header_ "$@"; sed 's/^/-/' "$1" + return 1 + fi + + return 2 +} + +for diff_opt_ in -u -U3 -c '' no; do + test "$diff_opt_" != no && + diff_out_=`exec 2>/dev/null + LC_ALL=C diff $diff_opt_ "$0" "$0" < /dev/null` && + break +done +if test "$diff_opt_" != no; then + if test -z "$diff_out_"; then + compare_ () { LC_ALL=C diff $diff_opt_ "$@"; } + else + compare_ () + { + # If no differences were found, AIX and HP-UX 'diff' produce output + # like "No differences encountered". Hide this output. + LC_ALL=C diff $diff_opt_ "$@" > diff.out + diff_status_=$? + test $diff_status_ -eq 0 || cat diff.out || diff_status_=2 + rm -f diff.out || diff_status_=2 + return $diff_status_ + } + fi +elif cmp -s /dev/null /dev/null 2>/dev/null; then + compare_ () { cmp -s "$@"; } +else + compare_ () { cmp "$@"; } +fi + +# Usage: compare EXPECTED ACTUAL +# +# Given compare_dev_null_'s preprocessing, defer to compare_ if 2 or more. +# Otherwise, propagate $? to caller: any diffs have already been printed. +compare () +{ + # This looks like it can be factored to use a simple "case $?" + # after unchecked compare_dev_null_ invocation, but that would + # fail in a "set -e" environment. + if compare_dev_null_ "$@"; then + return 0 + else + case $? in + 1) return 1;; + *) compare_ "$@";; + esac + fi +} + +# ----------------------------------------------------------------------------- + +# If you want to override the testdir_prefix_ function, +# or to add more utility functions, use this file. +test -f "$srcdir/init.cfg" \ + && . "$srcdir/init.cfg" + +# ============================================================================= +# Set up the environment for the test to run in. + +setup_ "$@" +# This trap is here, rather than in the setup_ function, because some +# shells run the exit trap at shell function exit, rather than script exit. +trap remove_tmp_ EXIT diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/inttostr.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/inttostr.c new file mode 100644 index 00000000..3f31d620 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/inttostr.c @@ -0,0 +1,20 @@ +/* Convert 'int' integer to printable string. + + Copyright (C) 2004-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#define anytostr inttostr +#define inttype int +#include "anytostr.c" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/inttostr.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/inttostr.h new file mode 100644 index 00000000..51cadf42 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/inttostr.h @@ -0,0 +1,34 @@ +/* inttostr.h -- convert integers to printable strings + + Copyright (C) 2001-2006, 2009-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Paul Eggert */ + +/* This file uses _GL_ATTRIBUTE_NODISCARD. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +#include +#include + +#include "intprops.h" + +_GL_ATTRIBUTE_NODISCARD char *imaxtostr (intmax_t, char *); +_GL_ATTRIBUTE_NODISCARD char *inttostr (int, char *); +_GL_ATTRIBUTE_NODISCARD char *offtostr (off_t, char *); +_GL_ATTRIBUTE_NODISCARD char *uinttostr (unsigned int, char *); +_GL_ATTRIBUTE_NODISCARD char *umaxtostr (uintmax_t, char *); diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/ioctl.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/ioctl.c new file mode 100644 index 00000000..3ee63fd8 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/ioctl.c @@ -0,0 +1,92 @@ +/* ioctl.c --- wrappers for Windows ioctl function + + Copyright (C) 2008-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Paolo Bonzini */ + +#include + +#include + +#include + +#if HAVE_IOCTL + +/* Provide a wrapper with the POSIX prototype. */ +# undef ioctl +int +rpl_ioctl (int fd, int request, ... /* {void *,char *} arg */) +{ + void *buf; + va_list args; + + va_start (args, request); + buf = va_arg (args, void *); + va_end (args); + + /* Cast 'request' so that when the system's ioctl function takes a 64-bit + request argument, the value gets zero-extended, not sign-extended. */ + return ioctl (fd, (unsigned int) request, buf); +} + +#else /* mingw */ + +# include + +/* Get HANDLE. */ +# define WIN32_LEAN_AND_MEAN +# include + +# include "fd-hook.h" +/* Get _get_osfhandle. */ +# if GNULIB_MSVC_NOTHROW +# include "msvc-nothrow.h" +# else +# include +# endif + +static int +primary_ioctl (int fd, int request, void *arg) +{ + /* We don't support FIONBIO on pipes here. If you want to make pipe + fds non-blocking, use the gnulib 'nonblocking' module, until + gnulib implements fcntl F_GETFL / F_SETFL with O_NONBLOCK. */ + + if ((HANDLE) _get_osfhandle (fd) != INVALID_HANDLE_VALUE) + errno = ENOSYS; + else + errno = EBADF; + return -1; +} + +int +ioctl (int fd, int request, ... /* {void *,char *} arg */) +{ + void *arg; + va_list args; + + va_start (args, request); + arg = va_arg (args, void *); + va_end (args); + +# if WINDOWS_SOCKETS + return execute_all_ioctl_hooks (primary_ioctl, fd, request, arg); +# else + return primary_ioctl (fd, request, arg); +# endif +} + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/isnan.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/isnan.c new file mode 100644 index 00000000..c7d84e8d --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/isnan.c @@ -0,0 +1,190 @@ +/* Test for NaN that does not need libm. + Copyright (C) 2007-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 2007. */ + +#include + +/* Specification. */ +#ifdef USE_LONG_DOUBLE +/* Specification found in math.h or isnanl-nolibm.h. */ +extern int rpl_isnanl (long double x) _GL_ATTRIBUTE_CONST; +#elif ! defined USE_FLOAT +/* Specification found in math.h or isnand-nolibm.h. */ +extern int rpl_isnand (double x); +#else /* defined USE_FLOAT */ +/* Specification found in math.h or isnanf-nolibm.h. */ +extern int rpl_isnanf (float x); +#endif + +#include +#include + +#include "float+.h" + +#ifdef USE_LONG_DOUBLE +# define FUNC rpl_isnanl +# define DOUBLE long double +# define MAX_EXP LDBL_MAX_EXP +# define MIN_EXP LDBL_MIN_EXP +# if defined LDBL_EXPBIT0_WORD && defined LDBL_EXPBIT0_BIT +# define KNOWN_EXPBIT0_LOCATION +# define EXPBIT0_WORD LDBL_EXPBIT0_WORD +# define EXPBIT0_BIT LDBL_EXPBIT0_BIT +# endif +# define SIZE SIZEOF_LDBL +# define L_(literal) literal##L +#elif ! defined USE_FLOAT +# define FUNC rpl_isnand +# define DOUBLE double +# define MAX_EXP DBL_MAX_EXP +# define MIN_EXP DBL_MIN_EXP +# if defined DBL_EXPBIT0_WORD && defined DBL_EXPBIT0_BIT +# define KNOWN_EXPBIT0_LOCATION +# define EXPBIT0_WORD DBL_EXPBIT0_WORD +# define EXPBIT0_BIT DBL_EXPBIT0_BIT +# endif +# define SIZE SIZEOF_DBL +# define L_(literal) literal +#else /* defined USE_FLOAT */ +# define FUNC rpl_isnanf +# define DOUBLE float +# define MAX_EXP FLT_MAX_EXP +# define MIN_EXP FLT_MIN_EXP +# if defined FLT_EXPBIT0_WORD && defined FLT_EXPBIT0_BIT +# define KNOWN_EXPBIT0_LOCATION +# define EXPBIT0_WORD FLT_EXPBIT0_WORD +# define EXPBIT0_BIT FLT_EXPBIT0_BIT +# endif +# define SIZE SIZEOF_FLT +# define L_(literal) literal##f +#endif + +#define EXP_MASK ((MAX_EXP - MIN_EXP) | 7) + +#define NWORDS \ + ((sizeof (DOUBLE) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) +typedef union { DOUBLE value; unsigned int word[NWORDS]; } memory_double; + +/* Most hosts nowadays use IEEE floating point, so they use IEC 60559 + representations, have infinities and NaNs, and do not trap on + exceptions. Define IEEE_FLOATING_POINT if this host is one of the + typical ones. The C23 macro __STDC_IEC_60559_BFP__ macro (or its cousin, + the now-obsolescent C11 macro __STDC_IEC_559__) is close to what is + wanted here, but is not quite right because this file does not require + all the features of C23 Annex F (and works even with pre-C11 platforms, + for that matter). */ + +#define IEEE_FLOATING_POINT (FLT_RADIX == 2 && FLT_MANT_DIG == 24 \ + && FLT_MIN_EXP == -125 && FLT_MAX_EXP == 128) + +int +FUNC (DOUBLE x) +{ +#if defined KNOWN_EXPBIT0_LOCATION && IEEE_FLOATING_POINT +# if defined USE_LONG_DOUBLE && ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_)) && !HAVE_SAME_LONG_DOUBLE_AS_DOUBLE + /* Special CPU dependent code is needed to treat bit patterns outside the + IEEE 754 specification (such as Pseudo-NaNs, Pseudo-Infinities, + Pseudo-Zeroes, Unnormalized Numbers, and Pseudo-Denormals) as NaNs. + These bit patterns are: + - exponent = 0x0001..0x7FFF, mantissa bit 63 = 0, + - exponent = 0x0000, mantissa bit 63 = 1. + The NaN bit pattern is: + - exponent = 0x7FFF, mantissa >= 0x8000000000000001. */ + memory_double m; + unsigned int exponent; + + m.value = x; + exponent = (m.word[EXPBIT0_WORD] >> EXPBIT0_BIT) & EXP_MASK; +# ifdef WORDS_BIGENDIAN + /* Big endian: EXPBIT0_WORD = 0, EXPBIT0_BIT = 16. */ + if (exponent == 0) + return 1 & (m.word[0] >> 15); + else if (exponent == EXP_MASK) + return (((m.word[0] ^ 0x8000U) << 16) | m.word[1] | (m.word[2] >> 16)) != 0; + else + return 1 & ~(m.word[0] >> 15); +# else + /* Little endian: EXPBIT0_WORD = 2, EXPBIT0_BIT = 0. */ + if (exponent == 0) + return (m.word[1] >> 31); + else if (exponent == EXP_MASK) + return ((m.word[1] ^ 0x80000000U) | m.word[0]) != 0; + else + return (m.word[1] >> 31) ^ 1; +# endif +# else + /* Be careful to not do any floating-point operation on x, such as x == x, + because x may be a signaling NaN. */ +# if defined __SUNPRO_C || defined __ICC || defined _MSC_VER \ + || defined __DECC || defined __TINYC__ \ + || (defined __sgi && !defined __GNUC__) + /* The Sun C 5.0, Intel ICC 10.0, Microsoft Visual C/C++ 9.0, Compaq (ex-DEC) + 6.4, and TinyCC compilers don't recognize the initializers as constant + expressions. The Compaq compiler also fails when constant-folding + 0.0 / 0.0 even when constant-folding is not required. The Microsoft + Visual C/C++ compiler also fails when constant-folding 1.0 / 0.0 even + when constant-folding is not required. The SGI MIPSpro C compiler + complains about "floating-point operation result is out of range". */ + static DOUBLE zero = L_(0.0); + memory_double nan; + DOUBLE plus_inf = L_(1.0) / zero; + DOUBLE minus_inf = -L_(1.0) / zero; + nan.value = zero / zero; +# else + static memory_double nan = { L_(0.0) / L_(0.0) }; + static DOUBLE plus_inf = L_(1.0) / L_(0.0); + static DOUBLE minus_inf = -L_(1.0) / L_(0.0); +# endif + { + memory_double m; + + /* A NaN can be recognized through its exponent. But exclude +Infinity and + -Infinity, which have the same exponent. */ + m.value = x; + if (((m.word[EXPBIT0_WORD] ^ nan.word[EXPBIT0_WORD]) + & (EXP_MASK << EXPBIT0_BIT)) + == 0) + return (memcmp (&m.value, &plus_inf, SIZE) != 0 + && memcmp (&m.value, &minus_inf, SIZE) != 0); + else + return 0; + } +# endif +#else + /* The configuration did not find sufficient information, or does + not use IEEE floating point. Give up about the signaling NaNs; + handle only the quiet NaNs. */ + if (x == x) + { +# if defined USE_LONG_DOUBLE && ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_)) && !HAVE_SAME_LONG_DOUBLE_AS_DOUBLE + /* Detect any special bit patterns that pass ==; see comment above. */ + memory_double m1; + memory_double m2; + + memset (&m1.value, 0, SIZE); + memset (&m2.value, 0, SIZE); + m1.value = x; + m2.value = x + (x ? 0.0L : -0.0L); + if (memcmp (&m1.value, &m2.value, SIZE) != 0) + return 1; +# endif + return 0; + } + else + return 1; +#endif +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/isnand-nolibm.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/isnand-nolibm.h new file mode 100644 index 00000000..4d8b0e8f --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/isnand-nolibm.h @@ -0,0 +1,38 @@ +/* Test for NaN that does not need libm. + Copyright (C) 2007-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* This file uses HAVE_ISNAND_IN_LIBC. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +#if HAVE_ISNAND_IN_LIBC +/* Get declaration of isnan macro. */ +# include +# if (__GNUC__ >= 4) || (__clang_major__ >= 4) + /* GCC >= 4.0 and clang provide a type-generic built-in for isnan. */ +# undef isnand +# define isnand(x) __builtin_isnan ((double)(x)) +# else +# undef isnand +# define isnand(x) isnan ((double)(x)) +# endif +#else +/* Test whether X is a NaN. */ +# undef isnand +# define isnand rpl_isnand +extern int isnand (double x); +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/isnand.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/isnand.c new file mode 100644 index 00000000..1287144a --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/isnand.c @@ -0,0 +1,19 @@ +/* Test for NaN that does not need libm. + Copyright (C) 2008-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 2008. */ + +#include "isnan.c" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/isnanf-nolibm.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/isnanf-nolibm.h new file mode 100644 index 00000000..520b8147 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/isnanf-nolibm.h @@ -0,0 +1,46 @@ +/* Test for NaN that does not need libm. + Copyright (C) 2007-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* This file uses HAVE_ISNANF_IN_LIBC. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +#if HAVE_ISNANF_IN_LIBC +/* Get declaration of isnan macro or (older) isnanf function. */ +# include +# if (__GNUC__ >= 4) || (__clang_major__ >= 4) + /* GCC >= 4.0 and clang provide a type-generic built-in for isnan. + GCC >= 4.0 also provides __builtin_isnanf, but clang doesn't. */ +# undef isnanf +# define isnanf(x) __builtin_isnan ((float)(x)) +# elif defined isnan +# undef isnanf +# define isnanf(x) isnan ((float)(x)) +# else + /* Get declaration of isnanf(), if not declared in . */ +# if defined __sgi + /* We can't include , because it conflicts with our definition of + isnand. Therefore declare isnanf separately. */ +extern int isnanf (float x); +# endif +# endif +#else +/* Test whether X is a NaN. */ +# undef isnanf +# define isnanf rpl_isnanf +extern int isnanf (float x); +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/isnanf.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/isnanf.c new file mode 100644 index 00000000..c5400117 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/isnanf.c @@ -0,0 +1,20 @@ +/* Test for NaN that does not need libm. + Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 2007. */ + +#define USE_FLOAT +#include "isnan.c" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/isnanl-nolibm.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/isnanl-nolibm.h new file mode 100644 index 00000000..3ea82f7d --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/isnanl-nolibm.h @@ -0,0 +1,39 @@ +/* Test for NaN that does not need libm. + Copyright (C) 2007-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* This file uses HAVE_ISNANL_IN_LIBC. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +#if HAVE_ISNANL_IN_LIBC +/* Get declaration of isnan macro or (older) isnanl function. */ +# include +# if (__GNUC__ >= 4) || (__clang_major__ >= 4) + /* GCC >= 4.0 and clang provide a type-generic built-in for isnan. + GCC >= 4.0 also provides __builtin_isnanl, but clang doesn't. */ +# undef isnanl +# define isnanl(x) __builtin_isnan ((long double)(x)) +# elif defined isnan +# undef isnanl +# define isnanl(x) isnan ((long double)(x)) +# endif +#else +/* Test whether X is a NaN. */ +# undef isnanl +# define isnanl rpl_isnanl +extern int isnanl (long double x); +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/isnanl.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/isnanl.c new file mode 100644 index 00000000..6d2ee67d --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/isnanl.c @@ -0,0 +1,20 @@ +/* Test for NaN that does not need libm. + Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 2007. */ + +#define USE_LONG_DOUBLE +#include "isnan.c" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/itold.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/itold.c new file mode 100644 index 00000000..e6fbcff4 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/itold.c @@ -0,0 +1,28 @@ +/* Replacement for 'int' to 'long double' conversion routine. + Copyright (C) 2011-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2011. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +void +_Qp_itoq (long double *result, int a) +{ + /* Convert from 'int' to 'double', then from 'double' to 'long double'. */ + *result = (double) a; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/listen.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/listen.c new file mode 100644 index 00000000..785b1319 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/listen.c @@ -0,0 +1,49 @@ +/* listen.c --- wrappers for Windows listen function + + Copyright (C) 2008-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Paolo Bonzini */ + +#include + +#define WIN32_LEAN_AND_MEAN +/* Get winsock2.h. */ +#include + +/* Get set_winsock_errno, FD_TO_SOCKET etc. */ +#include "w32sock.h" + +#undef listen + +int +rpl_listen (int fd, int backlog) +{ + SOCKET sock = FD_TO_SOCKET (fd); + + if (sock == INVALID_SOCKET) + { + errno = EBADF; + return -1; + } + else + { + int r = listen (sock, backlog); + if (r < 0) + set_winsock_errno (); + + return r; + } +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/locale.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/locale.c new file mode 100644 index 00000000..bd2bc00e --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/locale.c @@ -0,0 +1,85 @@ +/* Program that prints the names of the categories of the current locale. + Copyright (C) 2019-2024 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 . */ + +/* Written by Bruno Haible , 2019. */ + +#include + +#include +#include +#include + +/* We want to use the system's setlocale() function here, not the gnulib + override. */ +#undef setlocale + +/* Specification: + + Here we implement only the invocation without any command-line options. */ + +static const char * +defaulted_getenv (const char *variable) +{ + const char *value = getenv (variable); + return (value != NULL ? value : ""); +} + +static void +print_category (int category, const char *variable) +{ + const char *value = defaulted_getenv (variable); + if (value[0] != '\0' && defaulted_getenv ("LC_ALL")[0] == '\0') + /* The variable is set in the environment and not overridden by LC_ALL. */ + printf ("%s=%s\n", variable, value); + else + printf ("%s=\"%s\"\n", variable, setlocale (category, NULL)); +} + +int +main (void) +{ + setlocale (LC_ALL, ""); + + printf ("LANG=%s\n", defaulted_getenv ("LANG")); + print_category (LC_CTYPE, "LC_CTYPE"); + print_category (LC_NUMERIC, "LC_NUMERIC"); + print_category (LC_TIME, "LC_TIME"); + print_category (LC_COLLATE, "LC_COLLATE"); + print_category (LC_MONETARY, "LC_MONETARY"); + print_category (LC_MESSAGES, "LC_MESSAGES"); +#ifdef LC_PAPER + print_category (LC_PAPER, "LC_PAPER"); +#endif +#ifdef LC_NAME + print_category (LC_NAME, "LC_NAME"); +#endif +#ifdef LC_ADDRESS + print_category (LC_ADDRESS, "LC_ADDRESS"); +#endif +#ifdef LC_TELEPHONE + print_category (LC_TELEPHONE, "LC_TELEPHONE"); +#endif +#ifdef LC_MEASUREMENT + print_category (LC_MEASUREMENT, "LC_MEASUREMENT"); +#endif +#ifdef LC_IDENTIFICATION + print_category (LC_IDENTIFICATION, "LC_IDENTIFICATION"); +#endif + + printf ("LC_ALL=%s\n", defaulted_getenv ("LC_ALL")); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/macros.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/macros.h new file mode 100644 index 00000000..d182cd6f --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/macros.h @@ -0,0 +1,109 @@ +/* Common macros used by gnulib tests. + Copyright (C) 2006-2024 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 . */ + + +/* This file contains macros that are used by many gnulib tests. + Put here only frequently used macros, say, used by 10 tests or more. */ + +#include +#include + +#ifndef FALLTHROUGH +# if (__GNUC__ >= 7) || (__clang_major__ >= 10) +# define FALLTHROUGH __attribute__ ((__fallthrough__)) +# else +# define FALLTHROUGH ((void) 0) +# endif +#endif + +/* Define ASSERT_STREAM before including this file if ASSERT must + target a stream other than stderr. */ +#ifndef ASSERT_STREAM +# define ASSERT_STREAM stderr +#endif + +/* ASSERT (condition); + verifies that the specified condition is fulfilled. If not, a message + is printed to ASSERT_STREAM if defined (defaulting to stderr if + undefined) and the program is terminated with an error code. + + This macro has the following properties: + - The programmer specifies the expected condition, not the failure + condition. This simplifies thinking. + - The condition is tested always, regardless of compilation flags. + (Unlike the macro from .) + - On Unix platforms, the tester can debug the test program with a + debugger (provided core dumps are enabled: "ulimit -c unlimited"). + - For the sake of platforms where no debugger is available (such as + some mingw systems), an error message is printed on the error + stream that includes the source location of the ASSERT invocation. + */ +#define ASSERT(expr) \ + do \ + { \ + if (!(expr)) \ + { \ + fprintf (ASSERT_STREAM, "%s:%d: assertion '%s' failed\n", \ + __FILE__, __LINE__, #expr); \ + fflush (ASSERT_STREAM); \ + abort (); \ + } \ + } \ + while (0) + +/* Like ASSERT, except that it uses no stdio. + Requires #include and #include . */ +#define ASSERT_NO_STDIO(expr) \ + do \ + { \ + if (!(expr)) \ + { \ + WRITE_TO_STDERR (__FILE__); \ + WRITE_TO_STDERR (":"); \ + WRITE_MACROEXPANDED_INTEGER_TO_STDERR (__LINE__); \ + WRITE_TO_STDERR (": assertion '"); \ + WRITE_TO_STDERR (#expr); \ + WRITE_TO_STDERR ("' failed\n"); \ + abort (); \ + } \ + } \ + while (0) +#define WRITE_MACROEXPANDED_INTEGER_TO_STDERR(integer) \ + WRITE_INTEGER_TO_STDERR(integer) +#define WRITE_INTEGER_TO_STDERR(integer) \ + WRITE_TO_STDERR (#integer) +#define WRITE_TO_STDERR(string_literal) \ + { \ + const char *s = string_literal; \ + int ret = write (2, s, strlen (s)); \ + (void) ret; \ + } + +/* SIZEOF (array) + returns the number of elements of an array. It works for arrays that are + declared outside functions and for local variables of array type. It does + *not* work for function parameters of array type, because they are actually + parameters of pointer type. */ +#define SIZEOF(array) (sizeof (array) / sizeof (array[0])) + +/* STREQ (str1, str2) + Return true if two strings compare equal. */ +#define STREQ(a, b) (strcmp (a, b) == 0) + +/* Some numbers in the interval [0,1). */ +extern const float randomf[1000]; +extern const double randomd[1000]; +extern const long double randoml[1000]; diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/math.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/math.c new file mode 100644 index 00000000..78da4d4a --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/math.c @@ -0,0 +1,22 @@ +/* Inline functions for . + + Copyright (C) 2012-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +#define _GL_MATH_INLINE _GL_EXTERN_INLINE +#include +typedef int dummy; diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/math.in.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/math.in.h new file mode 100644 index 00000000..72a61d70 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/math.in.h @@ -0,0 +1,2857 @@ +/* A GNU-like . + + Copyright (C) 2002-2003, 2007-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* On Android, in C++ mode, when /usr/include/c++/v1/math.h is being included + and /usr/include/math.h has not yet been included, skip this file, since it + would lead to many syntax errors. */ +#if !(defined __ANDROID__ && defined _LIBCPP_MATH_H && !defined INFINITY) + +#ifndef _@GUARD_PREFIX@_MATH_H + +#if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +#endif +@PRAGMA_COLUMNS@ + +#if defined _GL_INCLUDING_MATH_H +/* Special invocation convention: + - On FreeBSD 12.2 we have a sequence of nested includes + -> -> -> -> + -> -> -> -> + In this situation, the functions are not yet declared, therefore we cannot + provide the C++ aliases. */ + +#@INCLUDE_NEXT_AS_FIRST_DIRECTIVE@ @NEXT_AS_FIRST_DIRECTIVE_MATH_H@ + +#else +/* Normal invocation convention. */ + +/* The include_next requires a split double-inclusion guard. */ +#define _GL_INCLUDING_MATH_H +#@INCLUDE_NEXT_AS_FIRST_DIRECTIVE@ @NEXT_AS_FIRST_DIRECTIVE_MATH_H@ +#undef _GL_INCLUDING_MATH_H + +#ifndef _@GUARD_PREFIX@_MATH_H +#define _@GUARD_PREFIX@_MATH_H + +/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, _GL_ATTRIBUTE_CONST, + GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +/* On OpenVMS, NAN, INFINITY, and HUGEVAL macros are defined in . */ +#if defined __VMS && ! defined NAN +# include +#endif + +_GL_INLINE_HEADER_BEGIN +#ifndef _GL_MATH_INLINE +# define _GL_MATH_INLINE _GL_INLINE +#endif + +/* The __attribute__ feature is available in gcc versions 2.5 and later. + The attribute __const__ was added in gcc 2.95. */ +#ifndef _GL_ATTRIBUTE_CONST +# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) || defined __clang__ +# define _GL_ATTRIBUTE_CONST __attribute__ ((__const__)) +# else +# define _GL_ATTRIBUTE_CONST /* empty */ +# endif +#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. */ + +#ifdef __cplusplus +/* Helper macros to define type-generic function FUNC as overloaded functions, + rather than as macros like in C. POSIX declares these with an argument of + real-floating (that is, one of float, double, or long double). */ +# define _GL_MATH_CXX_REAL_FLOATING_DECL_1(func) \ +static inline int \ +_gl_cxx_ ## func ## f (float f) \ +{ \ + return func (f); \ +} \ +static inline int \ +_gl_cxx_ ## func ## d (double d) \ +{ \ + return func (d); \ +} \ +static inline int \ +_gl_cxx_ ## func ## l (long double l) \ +{ \ + return func (l); \ +} +# define _GL_MATH_CXX_REAL_FLOATING_DECL_2(func,rpl_func,rettype) \ +_GL_BEGIN_NAMESPACE \ +inline rettype \ +rpl_func (float f) \ +{ \ + return _gl_cxx_ ## func ## f (f); \ +} \ +inline rettype \ +rpl_func (double d) \ +{ \ + return _gl_cxx_ ## func ## d (d); \ +} \ +inline rettype \ +rpl_func (long double l) \ +{ \ + return _gl_cxx_ ## func ## l (l); \ +} \ +_GL_END_NAMESPACE +#endif + +/* Helper macros to define a portability warning for the + classification macro FUNC called with VALUE. POSIX declares the + classification macros with an argument of real-floating (that is, + one of float, double, or long double). */ +#define _GL_WARN_REAL_FLOATING_DECL(func) \ +_GL_MATH_INLINE int \ +_GL_WARN_ON_USE_ATTRIBUTE (#func " is unportable - " \ + "use gnulib module " #func " for portability") \ +rpl_ ## func ## f (float f) \ +{ \ + return func (f); \ +} \ +_GL_MATH_INLINE int \ +_GL_WARN_ON_USE_ATTRIBUTE (#func " is unportable - " \ + "use gnulib module " #func " for portability") \ +rpl_ ## func ## d (double d) \ +{ \ + return func (d); \ +} \ +_GL_MATH_INLINE int \ +_GL_WARN_ON_USE_ATTRIBUTE (#func " is unportable - " \ + "use gnulib module " #func " for portability") \ +rpl_ ## func ## l (long double l) \ +{ \ + return func (l); \ +} +#define _GL_WARN_REAL_FLOATING_IMPL(func, value) \ + (sizeof (value) == sizeof (float) ? rpl_ ## func ## f (value) \ + : sizeof (value) == sizeof (double) ? rpl_ ## func ## d (value) \ + : rpl_ ## func ## l (value)) + + +#if @REPLACE_ITOLD@ +/* Pull in a function that fixes the 'int' to 'long double' conversion + of glibc 2.7. */ +_GL_EXTERN_C void _Qp_itoq (long double *, int); +static void (*_gl_math_fix_itold) (long double *, int) = _Qp_itoq; +#endif + + +/* POSIX allows platforms that don't support NAN. But all major + machines in the past 15 years have supported something close to + IEEE NaN, so we define this unconditionally. We also must define + it on platforms like Solaris 10, where NAN is present but defined + as a function pointer rather than a floating point constant. */ +#if !defined NAN || @REPLACE_NAN@ +# if !GNULIB_defined_NAN +# undef NAN + /* The Compaq (ex-DEC) C 6.4 compiler and the Microsoft MSVC 9 compiler + choke on the expression 0.0 / 0.0. */ +# if defined __DECC || defined _MSC_VER +_GL_MATH_INLINE float +_NaN () +{ + static float zero = 0.0f; + return zero / zero; +} +# define NAN (_NaN()) +# else +# define NAN (0.0f / 0.0f) +# endif +# define GNULIB_defined_NAN 1 +# endif +#endif + +/* Solaris 10 defines HUGE_VAL, but as a function pointer rather + than a floating point constant. */ +#if @REPLACE_HUGE_VAL@ +# undef HUGE_VALF +# define HUGE_VALF (1.0f / 0.0f) +# undef HUGE_VAL +# define HUGE_VAL (1.0 / 0.0) +# undef HUGE_VALL +# define HUGE_VALL (1.0L / 0.0L) +#endif + +/* HUGE_VALF is a 'float' Infinity. */ +#ifndef HUGE_VALF +# if defined _MSC_VER +/* The Microsoft MSVC 9 compiler chokes on the expression 1.0f / 0.0f. */ +# define HUGE_VALF (1e25f * 1e25f) +# else +# define HUGE_VALF (1.0f / 0.0f) +# endif +#endif + +/* HUGE_VAL is a 'double' Infinity. */ +#ifndef HUGE_VAL +# if defined _MSC_VER +/* The Microsoft MSVC 9 compiler chokes on the expression 1.0 / 0.0. */ +# define HUGE_VAL (1e250 * 1e250) +# else +# define HUGE_VAL (1.0 / 0.0) +# endif +#endif + +/* HUGE_VALL is a 'long double' Infinity. */ +#ifndef HUGE_VALL +# if defined _MSC_VER +/* The Microsoft MSVC 9 compiler chokes on the expression 1.0L / 0.0L. */ +# define HUGE_VALL (1e250L * 1e250L) +# else +# define HUGE_VALL (1.0L / 0.0L) +# endif +#endif + + +#if defined FP_ILOGB0 && defined FP_ILOGBNAN + /* Ensure FP_ILOGB0 and FP_ILOGBNAN are correct. */ +# if defined __HAIKU__ + /* Haiku: match what ilogb() does */ +# undef FP_ILOGB0 +# undef FP_ILOGBNAN +# define FP_ILOGB0 (- 2147483647 - 1) /* INT_MIN */ +# define FP_ILOGBNAN (- 2147483647 - 1) /* INT_MIN */ +# endif +#else + /* Ensure FP_ILOGB0 and FP_ILOGBNAN are defined. */ +# if defined __NetBSD__ || defined __sgi + /* NetBSD, IRIX 6.5: match what ilogb() does */ +# define FP_ILOGB0 (- 2147483647 - 1) /* INT_MIN */ +# define FP_ILOGBNAN (- 2147483647 - 1) /* INT_MIN */ +# elif defined _AIX + /* AIX 5.1: match what ilogb() does in AIX >= 5.2 */ +# define FP_ILOGB0 (- 2147483647 - 1) /* INT_MIN */ +# define FP_ILOGBNAN 2147483647 /* INT_MAX */ +# elif defined __sun + /* Solaris 9: match what ilogb() does */ +# define FP_ILOGB0 (- 2147483647) /* - INT_MAX */ +# define FP_ILOGBNAN 2147483647 /* INT_MAX */ +# else + /* Gnulib defined values. */ +# define FP_ILOGB0 (- 2147483647) /* - INT_MAX */ +# define FP_ILOGBNAN (- 2147483647 - 1) /* INT_MIN */ +# endif +#endif + + +#if @GNULIB_ACOSF@ +# if @REPLACE_ACOSF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef acosf +# define acosf rpl_acosf +# endif +_GL_FUNCDECL_RPL (acosf, float, (float x)); +_GL_CXXALIAS_RPL (acosf, float, (float x)); +# else +# if !@HAVE_ACOSF@ +# undef acosf +_GL_FUNCDECL_SYS (acosf, float, (float x)); +# endif +_GL_CXXALIAS_SYS (acosf, float, (float x)); +# endif +_GL_CXXALIASWARN (acosf); +#elif defined GNULIB_POSIXCHECK +# undef acosf +# if HAVE_RAW_DECL_ACOSF +_GL_WARN_ON_USE (acosf, "acosf is unportable - " + "use gnulib module acosf for portability"); +# endif +#endif + +#if @GNULIB_ACOSL@ +# if !@HAVE_ACOSL@ || !@HAVE_DECL_ACOSL@ +# undef acosl +_GL_FUNCDECL_SYS (acosl, long double, (long double x)); +# endif +_GL_CXXALIAS_SYS (acosl, long double, (long double x)); +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (acosl); +# endif +#elif defined GNULIB_POSIXCHECK +# undef acosl +# if HAVE_RAW_DECL_ACOSL +_GL_WARN_ON_USE (acosl, "acosl is unportable - " + "use gnulib module acosl for portability"); +# endif +#endif + + +#if @GNULIB_ASINF@ +# if @REPLACE_ASINF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef asinf +# define asinf rpl_asinf +# endif +_GL_FUNCDECL_RPL (asinf, float, (float x)); +_GL_CXXALIAS_RPL (asinf, float, (float x)); +# else +# if !@HAVE_ASINF@ +# undef asinf +_GL_FUNCDECL_SYS (asinf, float, (float x)); +# endif +_GL_CXXALIAS_SYS (asinf, float, (float x)); +# endif +_GL_CXXALIASWARN (asinf); +#elif defined GNULIB_POSIXCHECK +# undef asinf +# if HAVE_RAW_DECL_ASINF +_GL_WARN_ON_USE (asinf, "asinf is unportable - " + "use gnulib module asinf for portability"); +# endif +#endif + +#if @GNULIB_ASINL@ +# if !@HAVE_ASINL@ || !@HAVE_DECL_ASINL@ +# undef asinl +_GL_FUNCDECL_SYS (asinl, long double, (long double x)); +# endif +_GL_CXXALIAS_SYS (asinl, long double, (long double x)); +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (asinl); +# endif +#elif defined GNULIB_POSIXCHECK +# undef asinl +# if HAVE_RAW_DECL_ASINL +_GL_WARN_ON_USE (asinl, "asinl is unportable - " + "use gnulib module asinl for portability"); +# endif +#endif + + +#if @GNULIB_ATANF@ +# if @REPLACE_ATANF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef atanf +# define atanf rpl_atanf +# endif +_GL_FUNCDECL_RPL (atanf, float, (float x)); +_GL_CXXALIAS_RPL (atanf, float, (float x)); +# else +# if !@HAVE_ATANF@ +# undef atanf +_GL_FUNCDECL_SYS (atanf, float, (float x)); +# endif +_GL_CXXALIAS_SYS (atanf, float, (float x)); +# endif +_GL_CXXALIASWARN (atanf); +#elif defined GNULIB_POSIXCHECK +# undef atanf +# if HAVE_RAW_DECL_ATANF +_GL_WARN_ON_USE (atanf, "atanf is unportable - " + "use gnulib module atanf for portability"); +# endif +#endif + +#if @GNULIB_ATANL@ +# if !@HAVE_ATANL@ || !@HAVE_DECL_ATANL@ +# undef atanl +_GL_FUNCDECL_SYS (atanl, long double, (long double x)); +# endif +_GL_CXXALIAS_SYS (atanl, long double, (long double x)); +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (atanl); +# endif +#elif defined GNULIB_POSIXCHECK +# undef atanl +# if HAVE_RAW_DECL_ATANL +_GL_WARN_ON_USE (atanl, "atanl is unportable - " + "use gnulib module atanl for portability"); +# endif +#endif + + +#if @GNULIB_ATAN2F@ +# if @REPLACE_ATAN2F@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef atan2f +# define atan2f rpl_atan2f +# endif +_GL_FUNCDECL_RPL (atan2f, float, (float y, float x)); +_GL_CXXALIAS_RPL (atan2f, float, (float y, float x)); +# else +# if !@HAVE_ATAN2F@ +# undef atan2f +_GL_FUNCDECL_SYS (atan2f, float, (float y, float x)); +# endif +_GL_CXXALIAS_SYS (atan2f, float, (float y, float x)); +# endif +_GL_CXXALIASWARN (atan2f); +#elif defined GNULIB_POSIXCHECK +# undef atan2f +# if HAVE_RAW_DECL_ATAN2F +_GL_WARN_ON_USE (atan2f, "atan2f is unportable - " + "use gnulib module atan2f for portability"); +# endif +#endif + + +#if @GNULIB_CBRTF@ +# if @REPLACE_CBRTF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef cbrtf +# define cbrtf rpl_cbrtf +# endif +_GL_FUNCDECL_RPL (cbrtf, float, (float x)); +_GL_CXXALIAS_RPL (cbrtf, float, (float x)); +# else +# if !@HAVE_DECL_CBRTF@ +_GL_FUNCDECL_SYS (cbrtf, float, (float x)); +# endif +_GL_CXXALIAS_SYS (cbrtf, float, (float x)); +# endif +_GL_CXXALIASWARN (cbrtf); +#elif defined GNULIB_POSIXCHECK +# undef cbrtf +# if HAVE_RAW_DECL_CBRTF +_GL_WARN_ON_USE (cbrtf, "cbrtf is unportable - " + "use gnulib module cbrtf for portability"); +# endif +#endif + +#if @GNULIB_CBRT@ +# if !@HAVE_CBRT@ +_GL_FUNCDECL_SYS (cbrt, double, (double x)); +# endif +_GL_CXXALIAS_SYS (cbrt, double, (double x)); +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN1 (cbrt, double, (double x)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef cbrt +# if HAVE_RAW_DECL_CBRT +_GL_WARN_ON_USE (cbrt, "cbrt is unportable - " + "use gnulib module cbrt for portability"); +# endif +#endif + +#if @GNULIB_CBRTL@ +# if @REPLACE_CBRTL@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef cbrtl +# define cbrtl rpl_cbrtl +# endif +_GL_FUNCDECL_RPL (cbrtl, long double, (long double x)); +_GL_CXXALIAS_RPL (cbrtl, long double, (long double x)); +# else +# if !@HAVE_DECL_CBRTL@ +_GL_FUNCDECL_SYS (cbrtl, long double, (long double x)); +# endif +_GL_CXXALIAS_SYS (cbrtl, long double, (long double x)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (cbrtl); +# endif +#elif defined GNULIB_POSIXCHECK +# undef cbrtl +# if HAVE_RAW_DECL_CBRTL +_GL_WARN_ON_USE (cbrtl, "cbrtl is unportable - " + "use gnulib module cbrtl for portability"); +# endif +#endif + + +#if @GNULIB_CEILF@ +# if @REPLACE_CEILF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef ceilf +# define ceilf rpl_ceilf +# endif +_GL_FUNCDECL_RPL (ceilf, float, (float x)); +_GL_CXXALIAS_RPL (ceilf, float, (float x)); +# else +# if !@HAVE_DECL_CEILF@ +# undef ceilf +_GL_FUNCDECL_SYS (ceilf, float, (float x)); +# endif +_GL_CXXALIAS_SYS (ceilf, float, (float x)); +# endif +_GL_CXXALIASWARN (ceilf); +#elif defined GNULIB_POSIXCHECK +# undef ceilf +# if HAVE_RAW_DECL_CEILF +_GL_WARN_ON_USE (ceilf, "ceilf is unportable - " + "use gnulib module ceilf for portability"); +# endif +#endif + +#if @GNULIB_CEIL@ +# if @REPLACE_CEIL@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef ceil +# define ceil rpl_ceil +# endif +_GL_FUNCDECL_RPL (ceil, double, (double x)); +_GL_CXXALIAS_RPL (ceil, double, (double x)); +# else +_GL_CXXALIAS_SYS (ceil, double, (double x)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN1 (ceil, double, (double x)); +# endif +#endif + +#if @GNULIB_CEILL@ +# if @REPLACE_CEILL@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef ceill +# define ceill rpl_ceill +# endif +_GL_FUNCDECL_RPL (ceill, long double, (long double x)); +_GL_CXXALIAS_RPL (ceill, long double, (long double x)); +# else +# if !@HAVE_DECL_CEILL@ +# undef ceill +_GL_FUNCDECL_SYS (ceill, long double, (long double x)); +# endif +_GL_CXXALIAS_SYS (ceill, long double, (long double x)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (ceill); +# endif +#elif defined GNULIB_POSIXCHECK +# undef ceill +# if HAVE_RAW_DECL_CEILL +_GL_WARN_ON_USE (ceill, "ceill is unportable - " + "use gnulib module ceill for portability"); +# endif +#endif + + +#if @GNULIB_COPYSIGNF@ +# if !@HAVE_DECL_COPYSIGNF@ +# undef copysignf +_GL_FUNCDECL_SYS (copysignf, float, (float x, float y)); +# endif +_GL_CXXALIAS_SYS (copysignf, float, (float x, float y)); +_GL_CXXALIASWARN (copysignf); +#elif defined GNULIB_POSIXCHECK +# undef copysignf +# if HAVE_RAW_DECL_COPYSIGNF +_GL_WARN_ON_USE (copysignf, "copysignf is unportable - " + "use gnulib module copysignf for portability"); +# endif +#endif + +#if @GNULIB_COPYSIGN@ +# if !@HAVE_COPYSIGN@ +_GL_FUNCDECL_SYS (copysign, double, (double x, double y)); +# endif +_GL_CXXALIAS_SYS (copysign, double, (double x, double y)); +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN1 (copysign, double, (double x, double y)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef copysign +# if HAVE_RAW_DECL_COPYSIGN +_GL_WARN_ON_USE (copysign, "copysign is unportable - " + "use gnulib module copysign for portability"); +# endif +#endif + +#if @GNULIB_COPYSIGNL@ +# if !@HAVE_COPYSIGNL@ +_GL_FUNCDECL_SYS (copysignl, long double, (long double x, long double y)); +# endif +_GL_CXXALIAS_SYS (copysignl, long double, (long double x, long double y)); +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (copysignl); +# endif +#elif defined GNULIB_POSIXCHECK +# undef copysignl +# if HAVE_RAW_DECL_COPYSIGNL +_GL_WARN_ON_USE (copysign, "copysignl is unportable - " + "use gnulib module copysignl for portability"); +# endif +#endif + + +#if @GNULIB_COSF@ +# if @REPLACE_COSF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef cosf +# define cosf rpl_cosf +# endif +_GL_FUNCDECL_RPL (cosf, float, (float x)); +_GL_CXXALIAS_RPL (cosf, float, (float x)); +# else +# if !@HAVE_COSF@ +# undef cosf +_GL_FUNCDECL_SYS (cosf, float, (float x)); +# endif +_GL_CXXALIAS_SYS (cosf, float, (float x)); +# endif +_GL_CXXALIASWARN (cosf); +#elif defined GNULIB_POSIXCHECK +# undef cosf +# if HAVE_RAW_DECL_COSF +_GL_WARN_ON_USE (cosf, "cosf is unportable - " + "use gnulib module cosf for portability"); +# endif +#endif + +#if @GNULIB_COSL@ +# if !@HAVE_COSL@ || !@HAVE_DECL_COSL@ +# undef cosl +_GL_FUNCDECL_SYS (cosl, long double, (long double x)); +# endif +_GL_CXXALIAS_SYS (cosl, long double, (long double x)); +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (cosl); +# endif +#elif defined GNULIB_POSIXCHECK +# undef cosl +# if HAVE_RAW_DECL_COSL +_GL_WARN_ON_USE (cosl, "cosl is unportable - " + "use gnulib module cosl for portability"); +# endif +#endif + + +#if @GNULIB_COSHF@ +# if @REPLACE_COSHF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef coshf +# define coshf rpl_coshf +# endif +_GL_FUNCDECL_RPL (coshf, float, (float x)); +_GL_CXXALIAS_RPL (coshf, float, (float x)); +# else +# if !@HAVE_COSHF@ +# undef coshf +_GL_FUNCDECL_SYS (coshf, float, (float x)); +# endif +_GL_CXXALIAS_SYS (coshf, float, (float x)); +# endif +_GL_CXXALIASWARN (coshf); +#elif defined GNULIB_POSIXCHECK +# undef coshf +# if HAVE_RAW_DECL_COSHF +_GL_WARN_ON_USE (coshf, "coshf is unportable - " + "use gnulib module coshf for portability"); +# endif +#endif + + +#if @GNULIB_EXPF@ +# if @REPLACE_EXPF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef expf +# define expf rpl_expf +# endif +_GL_FUNCDECL_RPL (expf, float, (float x)); +_GL_CXXALIAS_RPL (expf, float, (float x)); +# else +# if !@HAVE_EXPF@ +# undef expf +_GL_FUNCDECL_SYS (expf, float, (float x)); +# endif +_GL_CXXALIAS_SYS (expf, float, (float x)); +# endif +_GL_CXXALIASWARN (expf); +#elif defined GNULIB_POSIXCHECK +# undef expf +# if HAVE_RAW_DECL_EXPF +_GL_WARN_ON_USE (expf, "expf is unportable - " + "use gnulib module expf for portability"); +# endif +#endif + +#if @GNULIB_EXPL@ +# if @REPLACE_EXPL@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef expl +# define expl rpl_expl +# endif +_GL_FUNCDECL_RPL (expl, long double, (long double x)); +_GL_CXXALIAS_RPL (expl, long double, (long double x)); +# else +# if !@HAVE_EXPL@ || !@HAVE_DECL_EXPL@ +# undef expl +_GL_FUNCDECL_SYS (expl, long double, (long double x)); +# endif +_GL_CXXALIAS_SYS (expl, long double, (long double x)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (expl); +# endif +#elif defined GNULIB_POSIXCHECK +# undef expl +# if HAVE_RAW_DECL_EXPL +_GL_WARN_ON_USE (expl, "expl is unportable - " + "use gnulib module expl for portability"); +# endif +#endif + + +#if @GNULIB_EXP2F@ +# if !@HAVE_DECL_EXP2F@ +_GL_FUNCDECL_SYS (exp2f, float, (float x)); +# endif +_GL_CXXALIAS_SYS (exp2f, float, (float x)); +_GL_CXXALIASWARN (exp2f); +#elif defined GNULIB_POSIXCHECK +# undef exp2f +# if HAVE_RAW_DECL_EXP2F +_GL_WARN_ON_USE (exp2f, "exp2f is unportable - " + "use gnulib module exp2f for portability"); +# endif +#endif + +#if @GNULIB_EXP2@ +# if @REPLACE_EXP2@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef exp2 +# define exp2 rpl_exp2 +# endif +_GL_FUNCDECL_RPL (exp2, double, (double x)); +_GL_CXXALIAS_RPL (exp2, double, (double x)); +# else +# if !@HAVE_DECL_EXP2@ +_GL_FUNCDECL_SYS (exp2, double, (double x)); +# endif +_GL_CXXALIAS_SYS (exp2, double, (double x)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN1 (exp2, double, (double x)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef exp2 +# if HAVE_RAW_DECL_EXP2 +_GL_WARN_ON_USE (exp2, "exp2 is unportable - " + "use gnulib module exp2 for portability"); +# endif +#endif + +#if @GNULIB_EXP2L@ +# if @REPLACE_EXP2L@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef exp2l +# define exp2l rpl_exp2l +# endif +_GL_FUNCDECL_RPL (exp2l, long double, (long double x)); +_GL_CXXALIAS_RPL (exp2l, long double, (long double x)); +# else +# if !@HAVE_DECL_EXP2L@ +# undef exp2l +_GL_FUNCDECL_SYS (exp2l, long double, (long double x)); +# endif +_GL_CXXALIAS_SYS (exp2l, long double, (long double x)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (exp2l); +# endif +#elif defined GNULIB_POSIXCHECK +# undef exp2l +# if HAVE_RAW_DECL_EXP2L +_GL_WARN_ON_USE (exp2l, "exp2l is unportable - " + "use gnulib module exp2l for portability"); +# endif +#endif + + +#if @GNULIB_EXPM1F@ +# if @REPLACE_EXPM1F@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef expm1f +# define expm1f rpl_expm1f +# endif +_GL_FUNCDECL_RPL (expm1f, float, (float x)); +_GL_CXXALIAS_RPL (expm1f, float, (float x)); +# else +# if !@HAVE_EXPM1F@ +_GL_FUNCDECL_SYS (expm1f, float, (float x)); +# endif +_GL_CXXALIAS_SYS (expm1f, float, (float x)); +# endif +_GL_CXXALIASWARN (expm1f); +#elif defined GNULIB_POSIXCHECK +# undef expm1f +# if HAVE_RAW_DECL_EXPM1F +_GL_WARN_ON_USE (expm1f, "expm1f is unportable - " + "use gnulib module expm1f for portability"); +# endif +#endif + +#if @GNULIB_EXPM1@ +# if @REPLACE_EXPM1@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef expm1 +# define expm1 rpl_expm1 +# endif +_GL_FUNCDECL_RPL (expm1, double, (double x)); +_GL_CXXALIAS_RPL (expm1, double, (double x)); +# else +# if !@HAVE_EXPM1@ +_GL_FUNCDECL_SYS (expm1, double, (double x)); +# endif +_GL_CXXALIAS_SYS (expm1, double, (double x)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN1 (expm1, double, (double x)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef expm1 +# if HAVE_RAW_DECL_EXPM1 +_GL_WARN_ON_USE (expm1, "expm1 is unportable - " + "use gnulib module expm1 for portability"); +# endif +#endif + +#if @GNULIB_EXPM1L@ +# if @REPLACE_EXPM1L@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef expm1l +# define expm1l rpl_expm1l +# endif +_GL_FUNCDECL_RPL (expm1l, long double, (long double x)); +_GL_CXXALIAS_RPL (expm1l, long double, (long double x)); +# else +# if !@HAVE_DECL_EXPM1L@ +# undef expm1l +# if !(defined __cplusplus && defined _AIX) +_GL_FUNCDECL_SYS (expm1l, long double, (long double x)); +# endif +# endif +_GL_CXXALIAS_SYS (expm1l, long double, (long double x)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (expm1l); +# endif +#elif defined GNULIB_POSIXCHECK +# undef expm1l +# if HAVE_RAW_DECL_EXPM1L +_GL_WARN_ON_USE (expm1l, "expm1l is unportable - " + "use gnulib module expm1l for portability"); +# endif +#endif + + +#if @GNULIB_FABSF@ +# if !@HAVE_FABSF@ +# undef fabsf +_GL_FUNCDECL_SYS (fabsf, float, (float x)); +# endif +_GL_CXXALIAS_SYS (fabsf, float, (float x)); +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (fabsf); +# endif +#elif defined GNULIB_POSIXCHECK +# undef fabsf +# if HAVE_RAW_DECL_FABSF +_GL_WARN_ON_USE (fabsf, "fabsf is unportable - " + "use gnulib module fabsf for portability"); +# endif +#endif + +#if @GNULIB_FABSL@ +# if @REPLACE_FABSL@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef fabsl +# define fabsl rpl_fabsl +# endif +_GL_FUNCDECL_RPL (fabsl, long double, (long double x)); +_GL_CXXALIAS_RPL (fabsl, long double, (long double x)); +# else +# if !@HAVE_FABSL@ +# undef fabsl +_GL_FUNCDECL_SYS (fabsl, long double, (long double x)); +# endif +_GL_CXXALIAS_SYS (fabsl, long double, (long double x)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (fabsl); +# endif +#elif defined GNULIB_POSIXCHECK +# undef fabsl +# if HAVE_RAW_DECL_FABSL +_GL_WARN_ON_USE (fabsl, "fabsl is unportable - " + "use gnulib module fabsl for portability"); +# endif +#endif + + +#if @GNULIB_FLOORF@ +# if @REPLACE_FLOORF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef floorf +# define floorf rpl_floorf +# endif +_GL_FUNCDECL_RPL (floorf, float, (float x)); +_GL_CXXALIAS_RPL (floorf, float, (float x)); +# else +# if !@HAVE_DECL_FLOORF@ +# undef floorf +_GL_FUNCDECL_SYS (floorf, float, (float x)); +# endif +_GL_CXXALIAS_SYS (floorf, float, (float x)); +# endif +_GL_CXXALIASWARN (floorf); +#elif defined GNULIB_POSIXCHECK +# undef floorf +# if HAVE_RAW_DECL_FLOORF +_GL_WARN_ON_USE (floorf, "floorf is unportable - " + "use gnulib module floorf for portability"); +# endif +#endif + +#if @GNULIB_FLOOR@ +# if @REPLACE_FLOOR@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef floor +# define floor rpl_floor +# endif +_GL_FUNCDECL_RPL (floor, double, (double x)); +_GL_CXXALIAS_RPL (floor, double, (double x)); +# else +_GL_CXXALIAS_SYS (floor, double, (double x)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN1 (floor, double, (double x)); +# endif +#endif + +#if @GNULIB_FLOORL@ +# if @REPLACE_FLOORL@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef floorl +# define floorl rpl_floorl +# endif +_GL_FUNCDECL_RPL (floorl, long double, (long double x)); +_GL_CXXALIAS_RPL (floorl, long double, (long double x)); +# else +# if !@HAVE_DECL_FLOORL@ +# undef floorl +_GL_FUNCDECL_SYS (floorl, long double, (long double x)); +# endif +_GL_CXXALIAS_SYS (floorl, long double, (long double x)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (floorl); +# endif +#elif defined GNULIB_POSIXCHECK +# undef floorl +# if HAVE_RAW_DECL_FLOORL +_GL_WARN_ON_USE (floorl, "floorl is unportable - " + "use gnulib module floorl for portability"); +# endif +#endif + + +#if @GNULIB_FMAF@ +# if @REPLACE_FMAF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef fmaf +# define fmaf rpl_fmaf +# endif +_GL_FUNCDECL_RPL (fmaf, float, (float x, float y, float z)); +_GL_CXXALIAS_RPL (fmaf, float, (float x, float y, float z)); +# else +# if !@HAVE_FMAF@ +# undef fmaf +_GL_FUNCDECL_SYS (fmaf, float, (float x, float y, float z)); +# endif +_GL_CXXALIAS_SYS (fmaf, float, (float x, float y, float z)); +# endif +_GL_CXXALIASWARN (fmaf); +#elif defined GNULIB_POSIXCHECK +# undef fmaf +# if HAVE_RAW_DECL_FMAF +_GL_WARN_ON_USE (fmaf, "fmaf is unportable - " + "use gnulib module fmaf for portability"); +# endif +#endif + +#if @GNULIB_FMA@ +# if @REPLACE_FMA@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef fma +# define fma rpl_fma +# endif +_GL_FUNCDECL_RPL (fma, double, (double x, double y, double z)); +_GL_CXXALIAS_RPL (fma, double, (double x, double y, double z)); +# else +# if !@HAVE_FMA@ +# undef fma +_GL_FUNCDECL_SYS (fma, double, (double x, double y, double z)); +# endif +_GL_CXXALIAS_SYS (fma, double, (double x, double y, double z)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN1 (fma, double, (double x, double y, double z)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef fma +# if HAVE_RAW_DECL_FMA +_GL_WARN_ON_USE (fma, "fma is unportable - " + "use gnulib module fma for portability"); +# endif +#endif + +#if @GNULIB_FMAL@ +# if @REPLACE_FMAL@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef fmal +# define fmal rpl_fmal +# endif +_GL_FUNCDECL_RPL (fmal, long double, + (long double x, long double y, long double z)); +_GL_CXXALIAS_RPL (fmal, long double, + (long double x, long double y, long double z)); +# else +# if !@HAVE_FMAL@ +# undef fmal +# if !(defined __cplusplus && defined _AIX) +_GL_FUNCDECL_SYS (fmal, long double, + (long double x, long double y, long double z)); +# endif +# endif +_GL_CXXALIAS_SYS (fmal, long double, + (long double x, long double y, long double z)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (fmal); +# endif +#elif defined GNULIB_POSIXCHECK +# undef fmal +# if HAVE_RAW_DECL_FMAL +_GL_WARN_ON_USE (fmal, "fmal is unportable - " + "use gnulib module fmal for portability"); +# endif +#endif + + +#if @GNULIB_FMODF@ +# if @REPLACE_FMODF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef fmodf +# define fmodf rpl_fmodf +# endif +_GL_FUNCDECL_RPL (fmodf, float, (float x, float y)); +_GL_CXXALIAS_RPL (fmodf, float, (float x, float y)); +# else +# if !@HAVE_FMODF@ +# undef fmodf +_GL_FUNCDECL_SYS (fmodf, float, (float x, float y)); +# endif +_GL_CXXALIAS_SYS (fmodf, float, (float x, float y)); +# endif +_GL_CXXALIASWARN (fmodf); +#elif defined GNULIB_POSIXCHECK +# undef fmodf +# if HAVE_RAW_DECL_FMODF +_GL_WARN_ON_USE (fmodf, "fmodf is unportable - " + "use gnulib module fmodf for portability"); +# endif +#endif + +#if @GNULIB_FMOD@ +# if @REPLACE_FMOD@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef fmod +# define fmod rpl_fmod +# endif +_GL_FUNCDECL_RPL (fmod, double, (double x, double y)); +_GL_CXXALIAS_RPL (fmod, double, (double x, double y)); +# else +_GL_CXXALIAS_SYS (fmod, double, (double x, double y)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN1 (fmod, double, (double x, double y)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef fmod +# if HAVE_RAW_DECL_FMOD +_GL_WARN_ON_USE (fmod, "fmod has portability problems - " + "use gnulib module fmod for portability"); +# endif +#endif + +#if @GNULIB_FMODL@ +# if @REPLACE_FMODL@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef fmodl +# define fmodl rpl_fmodl +# endif +_GL_FUNCDECL_RPL (fmodl, long double, (long double x, long double y)); +_GL_CXXALIAS_RPL (fmodl, long double, (long double x, long double y)); +# else +# if !@HAVE_FMODL@ +# undef fmodl +_GL_FUNCDECL_SYS (fmodl, long double, (long double x, long double y)); +# endif +_GL_CXXALIAS_SYS (fmodl, long double, (long double x, long double y)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (fmodl); +# endif +#elif defined GNULIB_POSIXCHECK +# undef fmodl +# if HAVE_RAW_DECL_FMODL +_GL_WARN_ON_USE (fmodl, "fmodl is unportable - " + "use gnulib module fmodl for portability"); +# endif +#endif + + +/* Write x as + x = mantissa * 2^exp + where + If x finite and nonzero: 0.5 <= |mantissa| < 1.0. + If x is zero: mantissa = x, exp = 0. + If x is infinite or NaN: mantissa = x, exp unspecified. + Store exp in *EXPPTR and return mantissa. */ +#if @GNULIB_FREXPF@ +# if @REPLACE_FREXPF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef frexpf +# define frexpf rpl_frexpf +# endif +_GL_FUNCDECL_RPL (frexpf, float, (float x, int *expptr) _GL_ARG_NONNULL ((2))); +_GL_CXXALIAS_RPL (frexpf, float, (float x, int *expptr)); +# else +# if !@HAVE_FREXPF@ +# undef frexpf +_GL_FUNCDECL_SYS (frexpf, float, (float x, int *expptr) _GL_ARG_NONNULL ((2))); +# endif +_GL_CXXALIAS_SYS (frexpf, float, (float x, int *expptr)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (frexpf); +# endif +#elif defined GNULIB_POSIXCHECK +# undef frexpf +# if HAVE_RAW_DECL_FREXPF +_GL_WARN_ON_USE (frexpf, "frexpf is unportable - " + "use gnulib module frexpf for portability"); +# endif +#endif + +/* Write x as + x = mantissa * 2^exp + where + If x finite and nonzero: 0.5 <= |mantissa| < 1.0. + If x is zero: mantissa = x, exp = 0. + If x is infinite or NaN: mantissa = x, exp unspecified. + Store exp in *EXPPTR and return mantissa. */ +#if @GNULIB_FREXP@ +# if @REPLACE_FREXP@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef frexp +# define frexp rpl_frexp +# endif +_GL_FUNCDECL_RPL (frexp, double, (double x, int *expptr) _GL_ARG_NONNULL ((2))); +_GL_CXXALIAS_RPL (frexp, double, (double x, int *expptr)); +# else +_GL_CXXALIAS_SYS (frexp, double, (double x, int *expptr)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN1 (frexp, double, (double x, int *expptr)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef frexp +/* Assume frexp is always declared. */ +_GL_WARN_ON_USE (frexp, "frexp is unportable - " + "use gnulib module frexp for portability"); +#endif + +/* Write x as + x = mantissa * 2^exp + where + If x finite and nonzero: 0.5 <= |mantissa| < 1.0. + If x is zero: mantissa = x, exp = 0. + If x is infinite or NaN: mantissa = x, exp unspecified. + Store exp in *EXPPTR and return mantissa. */ +#if @GNULIB_FREXPL@ && @REPLACE_FREXPL@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef frexpl +# define frexpl rpl_frexpl +# endif +_GL_FUNCDECL_RPL (frexpl, long double, + (long double x, int *expptr) _GL_ARG_NONNULL ((2))); +_GL_CXXALIAS_RPL (frexpl, long double, (long double x, int *expptr)); +#else +# if !@HAVE_DECL_FREXPL@ +_GL_FUNCDECL_SYS (frexpl, long double, + (long double x, int *expptr) _GL_ARG_NONNULL ((2))); +# endif +# if @GNULIB_FREXPL@ +_GL_CXXALIAS_SYS (frexpl, long double, (long double x, int *expptr)); +# endif +#endif +#if @GNULIB_FREXPL@ && !(@REPLACE_FREXPL@ && !@HAVE_DECL_FREXPL@) +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (frexpl); +# endif +#endif +#if !@GNULIB_FREXPL@ && defined GNULIB_POSIXCHECK +# undef frexpl +# if HAVE_RAW_DECL_FREXPL +_GL_WARN_ON_USE (frexpl, "frexpl is unportable - " + "use gnulib module frexpl for portability"); +# endif +#endif + + +/* Return sqrt(x^2+y^2). */ +#if @GNULIB_HYPOTF@ +# if @REPLACE_HYPOTF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef hypotf +# define hypotf rpl_hypotf +# endif +_GL_FUNCDECL_RPL (hypotf, float, (float x, float y)); +_GL_CXXALIAS_RPL (hypotf, float, (float x, float y)); +# else +# if !@HAVE_HYPOTF@ +_GL_FUNCDECL_SYS (hypotf, float, (float x, float y)); +# endif +_GL_CXXALIAS_SYS (hypotf, float, (float x, float y)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (hypotf); +# endif +#elif defined GNULIB_POSIXCHECK +# undef hypotf +# if HAVE_RAW_DECL_HYPOTF +_GL_WARN_ON_USE (hypotf, "hypotf is unportable - " + "use gnulib module hypotf for portability"); +# endif +#endif + +/* Return sqrt(x^2+y^2). */ +#if @GNULIB_HYPOT@ +# if @REPLACE_HYPOT@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef hypot +# define hypot rpl_hypot +# endif +_GL_FUNCDECL_RPL (hypot, double, (double x, double y)); +_GL_CXXALIAS_RPL (hypot, double, (double x, double y)); +# else +_GL_CXXALIAS_SYS (hypot, double, (double x, double y)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN1 (hypot, double, (double x, double y)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef hypot +# if HAVE_RAW_DECL_HYPOT +_GL_WARN_ON_USE (hypotf, "hypot has portability problems - " + "use gnulib module hypot for portability"); +# endif +#endif + +/* Return sqrt(x^2+y^2). */ +#if @GNULIB_HYPOTL@ +# if @REPLACE_HYPOTL@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef hypotl +# define hypotl rpl_hypotl +# endif +_GL_FUNCDECL_RPL (hypotl, long double, (long double x, long double y)); +_GL_CXXALIAS_RPL (hypotl, long double, (long double x, long double y)); +# else +# if !@HAVE_HYPOTL@ +_GL_FUNCDECL_SYS (hypotl, long double, (long double x, long double y)); +# endif +_GL_CXXALIAS_SYS (hypotl, long double, (long double x, long double y)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (hypotl); +# endif +#elif defined GNULIB_POSIXCHECK +# undef hypotl +# if HAVE_RAW_DECL_HYPOTL +_GL_WARN_ON_USE (hypotl, "hypotl is unportable - " + "use gnulib module hypotl for portability"); +# endif +#endif + + +#if @GNULIB_ILOGBF@ +# if @REPLACE_ILOGBF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef ilogbf +# define ilogbf rpl_ilogbf +# endif +_GL_FUNCDECL_RPL (ilogbf, int, (float x)); +_GL_CXXALIAS_RPL (ilogbf, int, (float x)); +# else +# if !@HAVE_ILOGBF@ +_GL_FUNCDECL_SYS (ilogbf, int, (float x)); +# endif +_GL_CXXALIAS_SYS (ilogbf, int, (float x)); +# endif +_GL_CXXALIASWARN (ilogbf); +#elif defined GNULIB_POSIXCHECK +# undef ilogbf +# if HAVE_RAW_DECL_ILOGBF +_GL_WARN_ON_USE (ilogbf, "ilogbf is unportable - " + "use gnulib module ilogbf for portability"); +# endif +#endif + +#if @GNULIB_ILOGB@ +# if @REPLACE_ILOGB@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef ilogb +# define ilogb rpl_ilogb +# endif +_GL_FUNCDECL_RPL (ilogb, int, (double x)); +_GL_CXXALIAS_RPL (ilogb, int, (double x)); +# else +# if !@HAVE_ILOGB@ +_GL_FUNCDECL_SYS (ilogb, int, (double x)); +# endif +_GL_CXXALIAS_SYS (ilogb, int, (double x)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN1 (ilogb, int, (double x)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef ilogb +# if HAVE_RAW_DECL_ILOGB +_GL_WARN_ON_USE (ilogb, "ilogb is unportable - " + "use gnulib module ilogb for portability"); +# endif +#endif + +#if @GNULIB_ILOGBL@ +# if @REPLACE_ILOGBL@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef ilogbl +# define ilogbl rpl_ilogbl +# endif +_GL_FUNCDECL_RPL (ilogbl, int, (long double x)); +_GL_CXXALIAS_RPL (ilogbl, int, (long double x)); +# else +# if !@HAVE_ILOGBL@ +# undef ilogbl +_GL_FUNCDECL_SYS (ilogbl, int, (long double x)); +# endif +_GL_CXXALIAS_SYS (ilogbl, int, (long double x)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (ilogbl); +# endif +#elif defined GNULIB_POSIXCHECK +# undef ilogbl +# if HAVE_RAW_DECL_ILOGBL +_GL_WARN_ON_USE (ilogbl, "ilogbl is unportable - " + "use gnulib module ilogbl for portability"); +# endif +#endif + + +#if @GNULIB_MDA_J0@ +/* On native Windows, map 'j0' to '_j0', so that -loldnames is not + required. In C++ with GNULIB_NAMESPACE, avoid differences between + platforms by defining GNULIB_NAMESPACE::j0 always. */ +# if defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef j0 +# define j0 _j0 +# endif +_GL_CXXALIAS_MDA (j0, double, (double x)); +# else +_GL_CXXALIAS_SYS (j0, double, (double x)); +# endif +_GL_CXXALIASWARN (j0); +#endif + +#if @GNULIB_MDA_J1@ +/* On native Windows, map 'j1' to '_j1', so that -loldnames is not + required. In C++ with GNULIB_NAMESPACE, avoid differences between + platforms by defining GNULIB_NAMESPACE::j1 always. */ +# if defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef j1 +# define j1 _j1 +# endif +_GL_CXXALIAS_MDA (j1, double, (double x)); +# else +_GL_CXXALIAS_SYS (j1, double, (double x)); +# endif +_GL_CXXALIASWARN (j1); +#endif + +#if @GNULIB_MDA_JN@ +/* On native Windows, map 'jn' to '_jn', so that -loldnames is not + required. In C++ with GNULIB_NAMESPACE, avoid differences between + platforms by defining GNULIB_NAMESPACE::jn always. */ +# if defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef jn +# define jn _jn +# endif +_GL_CXXALIAS_MDA (jn, double, (int n, double x)); +# else +_GL_CXXALIAS_SYS (jn, double, (int n, double x)); +# endif +_GL_CXXALIASWARN (jn); +#endif + + +/* Return x * 2^exp. */ +#if @GNULIB_LDEXPF@ +# if !@HAVE_LDEXPF@ +# undef ldexpf +_GL_FUNCDECL_SYS (ldexpf, float, (float x, int exp)); +# endif +_GL_CXXALIAS_SYS (ldexpf, float, (float x, int exp)); +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (ldexpf); +# endif +#elif defined GNULIB_POSIXCHECK +# undef ldexpf +# if HAVE_RAW_DECL_LDEXPF +_GL_WARN_ON_USE (ldexpf, "ldexpf is unportable - " + "use gnulib module ldexpf for portability"); +# endif +#endif + +/* Return x * 2^exp. */ +#if @GNULIB_LDEXP@ +# if @REPLACE_LDEXP@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef ldexp +# define ldexp rpl_ldexp +# endif +_GL_FUNCDECL_RPL (ldexp, double, (double x, int exp)); +_GL_CXXALIAS_RPL (ldexp, double, (double x, int exp)); +# else +/* Assume ldexp is always declared. */ +_GL_CXXALIAS_SYS (ldexp, double, (double x, int exp)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN1 (ldexp, double, (double x, int exp)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef ldexp +/* Assume ldexp is always declared. */ +_GL_WARN_ON_USE (ldexp, "ldexp is unportable - " + "use gnulib module ldexp for portability"); +#endif + +/* Return x * 2^exp. */ +#if @GNULIB_LDEXPL@ && @REPLACE_LDEXPL@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef ldexpl +# define ldexpl rpl_ldexpl +# endif +_GL_FUNCDECL_RPL (ldexpl, long double, (long double x, int exp)); +_GL_CXXALIAS_RPL (ldexpl, long double, (long double x, int exp)); +#else +# if !@HAVE_DECL_LDEXPL@ +_GL_FUNCDECL_SYS (ldexpl, long double, (long double x, int exp)); +# endif +# if @GNULIB_LDEXPL@ +_GL_CXXALIAS_SYS (ldexpl, long double, (long double x, int exp)); +# endif +#endif +#if @GNULIB_LDEXPL@ +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (ldexpl); +# endif +#endif +#if !@GNULIB_LDEXPL@ && defined GNULIB_POSIXCHECK +# undef ldexpl +# if HAVE_RAW_DECL_LDEXPL +_GL_WARN_ON_USE (ldexpl, "ldexpl is unportable - " + "use gnulib module ldexpl for portability"); +# endif +#endif + + +#if @GNULIB_LOGF@ +# if @REPLACE_LOGF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef logf +# define logf rpl_logf +# endif +_GL_FUNCDECL_RPL (logf, float, (float x)); +_GL_CXXALIAS_RPL (logf, float, (float x)); +# else +# if !@HAVE_LOGF@ +# undef logf +_GL_FUNCDECL_SYS (logf, float, (float x)); +# endif +_GL_CXXALIAS_SYS (logf, float, (float x)); +# endif +_GL_CXXALIASWARN (logf); +#elif defined GNULIB_POSIXCHECK +# undef logf +# if HAVE_RAW_DECL_LOGF +_GL_WARN_ON_USE (logf, "logf is unportable - " + "use gnulib module logf for portability"); +# endif +#endif + +#if @GNULIB_LOG@ +# if @REPLACE_LOG@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef log +# define log rpl_log +# endif +_GL_FUNCDECL_RPL (log, double, (double x)); +_GL_CXXALIAS_RPL (log, double, (double x)); +# else +_GL_CXXALIAS_SYS (log, double, (double x)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN1 (log, double, (double x)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef log +# if HAVE_RAW_DECL_LOG +_GL_WARN_ON_USE (log, "log has portability problems - " + "use gnulib module log for portability"); +# endif +#endif + +#if @GNULIB_LOGL@ +# if @REPLACE_LOGL@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef logl +# define logl rpl_logl +# endif +_GL_FUNCDECL_RPL (logl, long double, (long double x)); +_GL_CXXALIAS_RPL (logl, long double, (long double x)); +# else +# if !@HAVE_LOGL@ || !@HAVE_DECL_LOGL@ +# undef logl +_GL_FUNCDECL_SYS (logl, long double, (long double x)); +# endif +_GL_CXXALIAS_SYS (logl, long double, (long double x)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (logl); +# endif +#elif defined GNULIB_POSIXCHECK +# undef logl +# if HAVE_RAW_DECL_LOGL +_GL_WARN_ON_USE (logl, "logl is unportable - " + "use gnulib module logl for portability"); +# endif +#endif + + +#if @GNULIB_LOG10F@ +# if @REPLACE_LOG10F@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef log10f +# define log10f rpl_log10f +# endif +_GL_FUNCDECL_RPL (log10f, float, (float x)); +_GL_CXXALIAS_RPL (log10f, float, (float x)); +# else +# if !@HAVE_LOG10F@ +# undef log10f +_GL_FUNCDECL_SYS (log10f, float, (float x)); +# endif +_GL_CXXALIAS_SYS (log10f, float, (float x)); +# endif +_GL_CXXALIASWARN (log10f); +#elif defined GNULIB_POSIXCHECK +# undef log10f +# if HAVE_RAW_DECL_LOG10F +_GL_WARN_ON_USE (log10f, "log10f is unportable - " + "use gnulib module log10f for portability"); +# endif +#endif + +#if @GNULIB_LOG10@ +# if @REPLACE_LOG10@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef log10 +# define log10 rpl_log10 +# endif +_GL_FUNCDECL_RPL (log10, double, (double x)); +_GL_CXXALIAS_RPL (log10, double, (double x)); +# else +_GL_CXXALIAS_SYS (log10, double, (double x)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN1 (log10, double, (double x)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef log10 +# if HAVE_RAW_DECL_LOG10 +_GL_WARN_ON_USE (log10, "log10 has portability problems - " + "use gnulib module log10 for portability"); +# endif +#endif + +#if @GNULIB_LOG10L@ +# if @REPLACE_LOG10L@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef log10l +# define log10l rpl_log10l +# endif +_GL_FUNCDECL_RPL (log10l, long double, (long double x)); +_GL_CXXALIAS_RPL (log10l, long double, (long double x)); +# else +# if !@HAVE_LOG10L@ || !@HAVE_DECL_LOG10L@ +# undef log10l +_GL_FUNCDECL_SYS (log10l, long double, (long double x)); +# endif +_GL_CXXALIAS_SYS (log10l, long double, (long double x)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (log10l); +# endif +#elif defined GNULIB_POSIXCHECK +# undef log10l +# if HAVE_RAW_DECL_LOG10L +_GL_WARN_ON_USE (log10l, "log10l is unportable - " + "use gnulib module log10l for portability"); +# endif +#endif + + +#if @GNULIB_LOG1PF@ +# if @REPLACE_LOG1PF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef log1pf +# define log1pf rpl_log1pf +# endif +_GL_FUNCDECL_RPL (log1pf, float, (float x)); +_GL_CXXALIAS_RPL (log1pf, float, (float x)); +# else +# if !@HAVE_LOG1PF@ +_GL_FUNCDECL_SYS (log1pf, float, (float x)); +# endif +_GL_CXXALIAS_SYS (log1pf, float, (float x)); +# endif +_GL_CXXALIASWARN (log1pf); +#elif defined GNULIB_POSIXCHECK +# undef log1pf +# if HAVE_RAW_DECL_LOG1PF +_GL_WARN_ON_USE (log1pf, "log1pf is unportable - " + "use gnulib module log1pf for portability"); +# endif +#endif + +#if @GNULIB_LOG1P@ +# if @REPLACE_LOG1P@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef log1p +# define log1p rpl_log1p +# endif +_GL_FUNCDECL_RPL (log1p, double, (double x)); +_GL_CXXALIAS_RPL (log1p, double, (double x)); +# else +# if !@HAVE_LOG1P@ +_GL_FUNCDECL_SYS (log1p, double, (double x)); +# endif +_GL_CXXALIAS_SYS (log1p, double, (double x)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN1 (log1p, double, (double x)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef log1p +# if HAVE_RAW_DECL_LOG1P +_GL_WARN_ON_USE (log1p, "log1p has portability problems - " + "use gnulib module log1p for portability"); +# endif +#endif + +#if @GNULIB_LOG1PL@ +# if @REPLACE_LOG1PL@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef log1pl +# define log1pl rpl_log1pl +# endif +_GL_FUNCDECL_RPL (log1pl, long double, (long double x)); +_GL_CXXALIAS_RPL (log1pl, long double, (long double x)); +# else +# if !@HAVE_LOG1PL@ +_GL_FUNCDECL_SYS (log1pl, long double, (long double x)); +# endif +_GL_CXXALIAS_SYS (log1pl, long double, (long double x)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (log1pl); +# endif +#elif defined GNULIB_POSIXCHECK +# undef log1pl +# if HAVE_RAW_DECL_LOG1PL +_GL_WARN_ON_USE (log1pl, "log1pl has portability problems - " + "use gnulib module log1pl for portability"); +# endif +#endif + + +#if @GNULIB_LOG2F@ +# if @REPLACE_LOG2F@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef log2f +# define log2f rpl_log2f +# endif +_GL_FUNCDECL_RPL (log2f, float, (float x)); +_GL_CXXALIAS_RPL (log2f, float, (float x)); +# else +# if !@HAVE_DECL_LOG2F@ +# undef log2f +_GL_FUNCDECL_SYS (log2f, float, (float x)); +# endif +_GL_CXXALIAS_SYS (log2f, float, (float x)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (log2f); +# endif +#elif defined GNULIB_POSIXCHECK +# undef log2f +# if HAVE_RAW_DECL_LOG2F +_GL_WARN_ON_USE (log2f, "log2f is unportable - " + "use gnulib module log2f for portability"); +# endif +#endif + +#if @GNULIB_LOG2@ +# if @REPLACE_LOG2@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef log2 +# define log2 rpl_log2 +# endif +_GL_FUNCDECL_RPL (log2, double, (double x)); +_GL_CXXALIAS_RPL (log2, double, (double x)); +# else +# if !@HAVE_DECL_LOG2@ +# undef log2 +_GL_FUNCDECL_SYS (log2, double, (double x)); +# endif +_GL_CXXALIAS_SYS (log2, double, (double x)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN1 (log2, double, (double x)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef log2 +# if HAVE_RAW_DECL_LOG2 +_GL_WARN_ON_USE (log2, "log2 is unportable - " + "use gnulib module log2 for portability"); +# endif +#endif + +#if @GNULIB_LOG2L@ +# if @REPLACE_LOG2L@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef log2l +# define log2l rpl_log2l +# endif +_GL_FUNCDECL_RPL (log2l, long double, (long double x)); +_GL_CXXALIAS_RPL (log2l, long double, (long double x)); +# else +# if !@HAVE_DECL_LOG2L@ +_GL_FUNCDECL_SYS (log2l, long double, (long double x)); +# endif +_GL_CXXALIAS_SYS (log2l, long double, (long double x)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (log2l); +# endif +#elif defined GNULIB_POSIXCHECK +# undef log2l +# if HAVE_RAW_DECL_LOG2L +_GL_WARN_ON_USE (log2l, "log2l is unportable - " + "use gnulib module log2l for portability"); +# endif +#endif + + +#if @GNULIB_LOGBF@ +# if @REPLACE_LOGBF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef logbf +# define logbf rpl_logbf +# endif +_GL_FUNCDECL_RPL (logbf, float, (float x)); +_GL_CXXALIAS_RPL (logbf, float, (float x)); +# else +# if !@HAVE_LOGBF@ +_GL_FUNCDECL_SYS (logbf, float, (float x)); +# endif +_GL_CXXALIAS_SYS (logbf, float, (float x)); +# endif +_GL_CXXALIASWARN (logbf); +#elif defined GNULIB_POSIXCHECK +# undef logbf +# if HAVE_RAW_DECL_LOGBF +_GL_WARN_ON_USE (logbf, "logbf is unportable - " + "use gnulib module logbf for portability"); +# endif +#endif + +#if @GNULIB_LOGB@ +# if @REPLACE_LOGB@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef logb +# define logb rpl_logb +# endif +_GL_FUNCDECL_RPL (logb, double, (double x)); +_GL_CXXALIAS_RPL (logb, double, (double x)); +# else +# if !@HAVE_DECL_LOGB@ +_GL_FUNCDECL_SYS (logb, double, (double x)); +# endif +_GL_CXXALIAS_SYS (logb, double, (double x)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN1 (logb, double, (double x)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef logb +# if HAVE_RAW_DECL_LOGB +_GL_WARN_ON_USE (logb, "logb is unportable - " + "use gnulib module logb for portability"); +# endif +#endif + +#if @GNULIB_LOGBL@ +# if @REPLACE_LOGBL@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef logbl +# define logbl rpl_logbl +# endif +_GL_FUNCDECL_RPL (logbl, long double, (long double x)); +_GL_CXXALIAS_RPL (logbl, long double, (long double x)); +# else +# if !@HAVE_LOGBL@ +_GL_FUNCDECL_SYS (logbl, long double, (long double x)); +# endif +_GL_CXXALIAS_SYS (logbl, long double, (long double x)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (logbl); +# endif +#elif defined GNULIB_POSIXCHECK +# undef logbl +# if HAVE_RAW_DECL_LOGBL +_GL_WARN_ON_USE (logbl, "logbl is unportable - " + "use gnulib module logbl for portability"); +# endif +#endif + + +#if @GNULIB_MODFF@ +# if @REPLACE_MODFF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef modff +# define modff rpl_modff +# endif +_GL_FUNCDECL_RPL (modff, float, (float x, float *iptr) _GL_ARG_NONNULL ((2))); +_GL_CXXALIAS_RPL (modff, float, (float x, float *iptr)); +# else +# if !@HAVE_MODFF@ +# undef modff +_GL_FUNCDECL_SYS (modff, float, (float x, float *iptr) _GL_ARG_NONNULL ((2))); +# endif +_GL_CXXALIAS_SYS (modff, float, (float x, float *iptr)); +# endif +_GL_CXXALIASWARN (modff); +#elif defined GNULIB_POSIXCHECK +# undef modff +# if HAVE_RAW_DECL_MODFF +_GL_WARN_ON_USE (modff, "modff is unportable - " + "use gnulib module modff for portability"); +# endif +#endif + +#if @GNULIB_MODF@ +# if @REPLACE_MODF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef modf +# define modf rpl_modf +# endif +_GL_FUNCDECL_RPL (modf, double, (double x, double *iptr) _GL_ARG_NONNULL ((2))); +_GL_CXXALIAS_RPL (modf, double, (double x, double *iptr)); +# else +_GL_CXXALIAS_SYS (modf, double, (double x, double *iptr)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN1 (modf, double, (double x, double *iptr)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef modf +# if HAVE_RAW_DECL_MODF +_GL_WARN_ON_USE (modf, "modf has portability problems - " + "use gnulib module modf for portability"); +# endif +#endif + +#if @GNULIB_MODFL@ +# if @REPLACE_MODFL@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef modfl +# define modfl rpl_modfl +# endif +_GL_FUNCDECL_RPL (modfl, long double, (long double x, long double *iptr) + _GL_ARG_NONNULL ((2))); +_GL_CXXALIAS_RPL (modfl, long double, (long double x, long double *iptr)); +# else +# if !@HAVE_MODFL@ +# undef modfl +_GL_FUNCDECL_SYS (modfl, long double, (long double x, long double *iptr) + _GL_ARG_NONNULL ((2))); +# endif +_GL_CXXALIAS_SYS (modfl, long double, (long double x, long double *iptr)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (modfl); +# endif +#elif defined GNULIB_POSIXCHECK +# undef modfl +# if HAVE_RAW_DECL_MODFL +_GL_WARN_ON_USE (modfl, "modfl is unportable - " + "use gnulib module modfl for portability"); +# endif +#endif + + +#if @GNULIB_POWF@ +# if !@HAVE_POWF@ +# undef powf +_GL_FUNCDECL_SYS (powf, float, (float x, float y)); +# endif +_GL_CXXALIAS_SYS (powf, float, (float x, float y)); +_GL_CXXALIASWARN (powf); +#elif defined GNULIB_POSIXCHECK +# undef powf +# if HAVE_RAW_DECL_POWF +_GL_WARN_ON_USE (powf, "powf is unportable - " + "use gnulib module powf for portability"); +# endif +#endif + + +#if @GNULIB_REMAINDERF@ +# if @REPLACE_REMAINDERF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef remainderf +# define remainderf rpl_remainderf +# endif +_GL_FUNCDECL_RPL (remainderf, float, (float x, float y)); +_GL_CXXALIAS_RPL (remainderf, float, (float x, float y)); +# else +# if !@HAVE_REMAINDERF@ +_GL_FUNCDECL_SYS (remainderf, float, (float x, float y)); +# endif +_GL_CXXALIAS_SYS (remainderf, float, (float x, float y)); +# endif +_GL_CXXALIASWARN (remainderf); +#elif defined GNULIB_POSIXCHECK +# undef remainderf +# if HAVE_RAW_DECL_REMAINDERF +_GL_WARN_ON_USE (remainderf, "remainderf is unportable - " + "use gnulib module remainderf for portability"); +# endif +#endif + +#if @GNULIB_REMAINDER@ +# if @REPLACE_REMAINDER@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef remainder +# define remainder rpl_remainder +# endif +_GL_FUNCDECL_RPL (remainder, double, (double x, double y)); +_GL_CXXALIAS_RPL (remainder, double, (double x, double y)); +# else +# if !@HAVE_REMAINDER@ || !@HAVE_DECL_REMAINDER@ +_GL_FUNCDECL_SYS (remainder, double, (double x, double y)); +# endif +_GL_CXXALIAS_SYS (remainder, double, (double x, double y)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN1 (remainder, double, (double x, double y)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef remainder +# if HAVE_RAW_DECL_REMAINDER +_GL_WARN_ON_USE (remainder, "remainder is unportable - " + "use gnulib module remainder for portability"); +# endif +#endif + +#if @GNULIB_REMAINDERL@ +# if @REPLACE_REMAINDERL@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef remainderl +# define remainderl rpl_remainderl +# endif +_GL_FUNCDECL_RPL (remainderl, long double, (long double x, long double y)); +_GL_CXXALIAS_RPL (remainderl, long double, (long double x, long double y)); +# else +# if !@HAVE_DECL_REMAINDERL@ +# undef remainderl +# if !(defined __cplusplus && defined _AIX) +_GL_FUNCDECL_SYS (remainderl, long double, (long double x, long double y)); +# endif +# endif +_GL_CXXALIAS_SYS (remainderl, long double, (long double x, long double y)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (remainderl); +# endif +#elif defined GNULIB_POSIXCHECK +# undef remainderl +# if HAVE_RAW_DECL_REMAINDERL +_GL_WARN_ON_USE (remainderl, "remainderl is unportable - " + "use gnulib module remainderl for portability"); +# endif +#endif + + +#if @GNULIB_RINTF@ +# if !@HAVE_DECL_RINTF@ +_GL_FUNCDECL_SYS (rintf, float, (float x)); +# endif +_GL_CXXALIAS_SYS (rintf, float, (float x)); +_GL_CXXALIASWARN (rintf); +#elif defined GNULIB_POSIXCHECK +# undef rintf +# if HAVE_RAW_DECL_RINTF +_GL_WARN_ON_USE (rintf, "rintf is unportable - " + "use gnulib module rintf for portability"); +# endif +#endif + +#if @GNULIB_RINT@ +# if !@HAVE_RINT@ +_GL_FUNCDECL_SYS (rint, double, (double x)); +# endif +_GL_CXXALIAS_SYS (rint, double, (double x)); +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN1 (rint, double, (double x)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef rint +# if HAVE_RAW_DECL_RINT +_GL_WARN_ON_USE (rint, "rint is unportable - " + "use gnulib module rint for portability"); +# endif +#endif + +#if @GNULIB_RINTL@ +# if @REPLACE_RINTL@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef rintl +# define rintl rpl_rintl +# endif +_GL_FUNCDECL_RPL (rintl, long double, (long double x)); +_GL_CXXALIAS_RPL (rintl, long double, (long double x)); +# else +# if !@HAVE_RINTL@ +_GL_FUNCDECL_SYS (rintl, long double, (long double x)); +# endif +_GL_CXXALIAS_SYS (rintl, long double, (long double x)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (rintl); +# endif +#elif defined GNULIB_POSIXCHECK +# undef rintl +# if HAVE_RAW_DECL_RINTL +_GL_WARN_ON_USE (rintl, "rintl is unportable - " + "use gnulib module rintl for portability"); +# endif +#endif + + +#if @GNULIB_ROUNDF@ +# if @REPLACE_ROUNDF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef roundf +# define roundf rpl_roundf +# endif +_GL_FUNCDECL_RPL (roundf, float, (float x)); +_GL_CXXALIAS_RPL (roundf, float, (float x)); +# else +# if !@HAVE_DECL_ROUNDF@ +_GL_FUNCDECL_SYS (roundf, float, (float x)); +# endif +_GL_CXXALIAS_SYS (roundf, float, (float x)); +# endif +_GL_CXXALIASWARN (roundf); +#elif defined GNULIB_POSIXCHECK +# undef roundf +# if HAVE_RAW_DECL_ROUNDF +_GL_WARN_ON_USE (roundf, "roundf is unportable - " + "use gnulib module roundf for portability"); +# endif +#endif + +#if @GNULIB_ROUND@ +# if @REPLACE_ROUND@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef round +# define round rpl_round +# endif +_GL_FUNCDECL_RPL (round, double, (double x)); +_GL_CXXALIAS_RPL (round, double, (double x)); +# else +# if !@HAVE_DECL_ROUND@ +_GL_FUNCDECL_SYS (round, double, (double x)); +# endif +_GL_CXXALIAS_SYS (round, double, (double x)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN1 (round, double, (double x)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef round +# if HAVE_RAW_DECL_ROUND +_GL_WARN_ON_USE (round, "round is unportable - " + "use gnulib module round for portability"); +# endif +#endif + +#if @GNULIB_ROUNDL@ +# if @REPLACE_ROUNDL@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef roundl +# define roundl rpl_roundl +# endif +_GL_FUNCDECL_RPL (roundl, long double, (long double x)); +_GL_CXXALIAS_RPL (roundl, long double, (long double x)); +# else +# if !@HAVE_DECL_ROUNDL@ +# undef roundl +# if !(defined __cplusplus && defined _AIX) +_GL_FUNCDECL_SYS (roundl, long double, (long double x)); +# endif +# endif +_GL_CXXALIAS_SYS (roundl, long double, (long double x)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (roundl); +# endif +#elif defined GNULIB_POSIXCHECK +# undef roundl +# if HAVE_RAW_DECL_ROUNDL +_GL_WARN_ON_USE (roundl, "roundl is unportable - " + "use gnulib module roundl for portability"); +# endif +#endif + + +#if @GNULIB_SINF@ +# if @REPLACE_SINF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef sinf +# define sinf rpl_sinf +# endif +_GL_FUNCDECL_RPL (sinf, float, (float x)); +_GL_CXXALIAS_RPL (sinf, float, (float x)); +# else +# if !@HAVE_SINF@ +# undef sinf +_GL_FUNCDECL_SYS (sinf, float, (float x)); +# endif +_GL_CXXALIAS_SYS (sinf, float, (float x)); +# endif +_GL_CXXALIASWARN (sinf); +#elif defined GNULIB_POSIXCHECK +# undef sinf +# if HAVE_RAW_DECL_SINF +_GL_WARN_ON_USE (sinf, "sinf is unportable - " + "use gnulib module sinf for portability"); +# endif +#endif + +#if @GNULIB_SINL@ +# if !@HAVE_SINL@ || !@HAVE_DECL_SINL@ +# undef sinl +_GL_FUNCDECL_SYS (sinl, long double, (long double x)); +# endif +_GL_CXXALIAS_SYS (sinl, long double, (long double x)); +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (sinl); +# endif +#elif defined GNULIB_POSIXCHECK +# undef sinl +# if HAVE_RAW_DECL_SINL +_GL_WARN_ON_USE (sinl, "sinl is unportable - " + "use gnulib module sinl for portability"); +# endif +#endif + + +#if @GNULIB_SINHF@ +# if @REPLACE_SINHF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef sinhf +# define sinhf rpl_sinhf +# endif +_GL_FUNCDECL_RPL (sinhf, float, (float x)); +_GL_CXXALIAS_RPL (sinhf, float, (float x)); +# else +# if !@HAVE_SINHF@ +# undef sinhf +_GL_FUNCDECL_SYS (sinhf, float, (float x)); +# endif +_GL_CXXALIAS_SYS (sinhf, float, (float x)); +# endif +_GL_CXXALIASWARN (sinhf); +#elif defined GNULIB_POSIXCHECK +# undef sinhf +# if HAVE_RAW_DECL_SINHF +_GL_WARN_ON_USE (sinhf, "sinhf is unportable - " + "use gnulib module sinhf for portability"); +# endif +#endif + + +#if @GNULIB_SQRTF@ +# if @REPLACE_SQRTF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef sqrtf +# define sqrtf rpl_sqrtf +# endif +_GL_FUNCDECL_RPL (sqrtf, float, (float x)); +_GL_CXXALIAS_RPL (sqrtf, float, (float x)); +# else +# if !@HAVE_SQRTF@ +# undef sqrtf +_GL_FUNCDECL_SYS (sqrtf, float, (float x)); +# endif +_GL_CXXALIAS_SYS (sqrtf, float, (float x)); +# endif +_GL_CXXALIASWARN (sqrtf); +#elif defined GNULIB_POSIXCHECK +# undef sqrtf +# if HAVE_RAW_DECL_SQRTF +_GL_WARN_ON_USE (sqrtf, "sqrtf is unportable - " + "use gnulib module sqrtf for portability"); +# endif +#endif + +#if @GNULIB_SQRTL@ +# if @REPLACE_SQRTL@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef sqrtl +# define sqrtl rpl_sqrtl +# endif +_GL_FUNCDECL_RPL (sqrtl, long double, (long double x)); +_GL_CXXALIAS_RPL (sqrtl, long double, (long double x)); +# else +# if !@HAVE_SQRTL@ || !@HAVE_DECL_SQRTL@ +# undef sqrtl +_GL_FUNCDECL_SYS (sqrtl, long double, (long double x)); +# endif +_GL_CXXALIAS_SYS (sqrtl, long double, (long double x)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (sqrtl); +# endif +#elif defined GNULIB_POSIXCHECK +# undef sqrtl +# if HAVE_RAW_DECL_SQRTL +_GL_WARN_ON_USE (sqrtl, "sqrtl is unportable - " + "use gnulib module sqrtl for portability"); +# endif +#endif + + +#if @GNULIB_TANF@ +# if @REPLACE_TANF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef tanf +# define tanf rpl_tanf +# endif +_GL_FUNCDECL_RPL (tanf, float, (float x)); +_GL_CXXALIAS_RPL (tanf, float, (float x)); +# else +# if !@HAVE_TANF@ +# undef tanf +_GL_FUNCDECL_SYS (tanf, float, (float x)); +# endif +_GL_CXXALIAS_SYS (tanf, float, (float x)); +# endif +_GL_CXXALIASWARN (tanf); +#elif defined GNULIB_POSIXCHECK +# undef tanf +# if HAVE_RAW_DECL_TANF +_GL_WARN_ON_USE (tanf, "tanf is unportable - " + "use gnulib module tanf for portability"); +# endif +#endif + +#if @GNULIB_TANL@ +# if !@HAVE_TANL@ || !@HAVE_DECL_TANL@ +# undef tanl +_GL_FUNCDECL_SYS (tanl, long double, (long double x)); +# endif +_GL_CXXALIAS_SYS (tanl, long double, (long double x)); +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (tanl); +# endif +#elif defined GNULIB_POSIXCHECK +# undef tanl +# if HAVE_RAW_DECL_TANL +_GL_WARN_ON_USE (tanl, "tanl is unportable - " + "use gnulib module tanl for portability"); +# endif +#endif + + +#if @GNULIB_TANHF@ +# if @REPLACE_TANHF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef tanhf +# define tanhf rpl_tanhf +# endif +_GL_FUNCDECL_RPL (tanhf, float, (float x)); +_GL_CXXALIAS_RPL (tanhf, float, (float x)); +# else +# if !@HAVE_TANHF@ +# undef tanhf +_GL_FUNCDECL_SYS (tanhf, float, (float x)); +# endif +_GL_CXXALIAS_SYS (tanhf, float, (float x)); +# endif +_GL_CXXALIASWARN (tanhf); +#elif defined GNULIB_POSIXCHECK +# undef tanhf +# if HAVE_RAW_DECL_TANHF +_GL_WARN_ON_USE (tanhf, "tanhf is unportable - " + "use gnulib module tanhf for portability"); +# endif +#endif + + +#if @GNULIB_TRUNCF@ +# if @REPLACE_TRUNCF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef truncf +# define truncf rpl_truncf +# endif +_GL_FUNCDECL_RPL (truncf, float, (float x)); +_GL_CXXALIAS_RPL (truncf, float, (float x)); +# else +# if !@HAVE_DECL_TRUNCF@ +_GL_FUNCDECL_SYS (truncf, float, (float x)); +# endif +_GL_CXXALIAS_SYS (truncf, float, (float x)); +# endif +_GL_CXXALIASWARN (truncf); +#elif defined GNULIB_POSIXCHECK +# undef truncf +# if HAVE_RAW_DECL_TRUNCF +_GL_WARN_ON_USE (truncf, "truncf is unportable - " + "use gnulib module truncf for portability"); +# endif +#endif + +#if @GNULIB_TRUNC@ +# if @REPLACE_TRUNC@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef trunc +# define trunc rpl_trunc +# endif +_GL_FUNCDECL_RPL (trunc, double, (double x)); +_GL_CXXALIAS_RPL (trunc, double, (double x)); +# else +# if !@HAVE_DECL_TRUNC@ +_GL_FUNCDECL_SYS (trunc, double, (double x)); +# endif +_GL_CXXALIAS_SYS (trunc, double, (double x)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN1 (trunc, double, (double x)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef trunc +# if HAVE_RAW_DECL_TRUNC +_GL_WARN_ON_USE (trunc, "trunc is unportable - " + "use gnulib module trunc for portability"); +# endif +#endif + +#if @GNULIB_TRUNCL@ +# if @REPLACE_TRUNCL@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef truncl +# define truncl rpl_truncl +# endif +_GL_FUNCDECL_RPL (truncl, long double, (long double x)); +_GL_CXXALIAS_RPL (truncl, long double, (long double x)); +# else +# if !@HAVE_DECL_TRUNCL@ +_GL_FUNCDECL_SYS (truncl, long double, (long double x)); +# endif +_GL_CXXALIAS_SYS (truncl, long double, (long double x)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (truncl); +# endif +#elif defined GNULIB_POSIXCHECK +# undef truncl +# if HAVE_RAW_DECL_TRUNCL +_GL_WARN_ON_USE (truncl, "truncl is unportable - " + "use gnulib module truncl for portability"); +# endif +#endif + + +#if @GNULIB_MDA_Y0@ +/* On native Windows, map 'y0' to '_y0', so that -loldnames is not + required. In C++ with GNULIB_NAMESPACE, avoid differences between + platforms by defining GNULIB_NAMESPACE::y0 always. */ +# if defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef y0 +# define y0 _y0 +# endif +_GL_CXXALIAS_MDA (y0, double, (double x)); +# else +_GL_CXXALIAS_SYS (y0, double, (double x)); +# endif +_GL_CXXALIASWARN (y0); +#endif + +#if @GNULIB_MDA_Y1@ +/* On native Windows, map 'y1' to '_y1', so that -loldnames is not + required. In C++ with GNULIB_NAMESPACE, avoid differences between + platforms by defining GNULIB_NAMESPACE::y1 always. */ +# if defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef y1 +# define y1 _y1 +# endif +_GL_CXXALIAS_MDA (y1, double, (double x)); +# else +_GL_CXXALIAS_SYS (y1, double, (double x)); +# endif +_GL_CXXALIASWARN (y1); +#endif + +#if @GNULIB_MDA_YN@ +/* On native Windows, map 'yn' to '_yn', so that -loldnames is not + required. In C++ with GNULIB_NAMESPACE, avoid differences between + platforms by defining GNULIB_NAMESPACE::yn always. */ +# if defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef yn +# define yn _yn +# endif +_GL_CXXALIAS_MDA (yn, double, (int n, double x)); +# else +_GL_CXXALIAS_SYS (yn, double, (int n, double x)); +# endif +_GL_CXXALIASWARN (yn); +#endif + + +/* Definitions of function-like macros come here, after the function + declarations. */ + + +#if @GNULIB_ISFINITE@ +# if @REPLACE_ISFINITE@ +_GL_EXTERN_C int gl_isfinitef (float x); +_GL_EXTERN_C int gl_isfinited (double x); +_GL_EXTERN_C int gl_isfinitel (long double x); +# undef isfinite +# define isfinite(x) \ + (sizeof (x) == sizeof (long double) ? gl_isfinitel (x) : \ + sizeof (x) == sizeof (double) ? gl_isfinited (x) : \ + gl_isfinitef (x)) +# endif +# ifdef __cplusplus +# if defined isfinite || defined GNULIB_NAMESPACE +_GL_MATH_CXX_REAL_FLOATING_DECL_1 (isfinite) +# undef isfinite +# if __GNUC__ >= 6 || (defined __clang__ && !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __OpenBSD__ || defined _AIX || (defined _WIN32 && !defined __CYGWIN__))) + /* This platform's possibly defines isfinite through a set of inline + functions. */ +_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isfinite, rpl_isfinite, bool) +# define isfinite rpl_isfinite +# define GNULIB_NAMESPACE_LACKS_ISFINITE 1 +# else +_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isfinite, isfinite, bool) +# endif +# endif +# endif +#elif defined GNULIB_POSIXCHECK +# if defined isfinite +_GL_WARN_REAL_FLOATING_DECL (isfinite); +# undef isfinite +# define isfinite(x) _GL_WARN_REAL_FLOATING_IMPL (isfinite, x) +# endif +#endif + + +#if @GNULIB_ISINF@ +# if @REPLACE_ISINF@ +_GL_EXTERN_C int gl_isinff (float x); +_GL_EXTERN_C int gl_isinfd (double x); +_GL_EXTERN_C int gl_isinfl (long double x); +# undef isinf +# define isinf(x) \ + (sizeof (x) == sizeof (long double) ? gl_isinfl (x) : \ + sizeof (x) == sizeof (double) ? gl_isinfd (x) : \ + gl_isinff (x)) +# endif +# ifdef __cplusplus +# if defined isinf || defined GNULIB_NAMESPACE +_GL_MATH_CXX_REAL_FLOATING_DECL_1 (isinf) +# undef isinf +# if __GNUC__ >= 6 || (defined __clang__ && !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __OpenBSD__ || (defined _WIN32 && !defined __CYGWIN__))) + /* This platform's possibly defines isinf through a set of inline + functions. */ +_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isinf, rpl_isinf, bool) +# define isinf rpl_isinf +# define GNULIB_NAMESPACE_LACKS_ISINF 1 +# else +_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isinf, isinf, bool) +# endif +# endif +# endif +#elif defined GNULIB_POSIXCHECK +# if defined isinf +_GL_WARN_REAL_FLOATING_DECL (isinf); +# undef isinf +# define isinf(x) _GL_WARN_REAL_FLOATING_IMPL (isinf, x) +# endif +#endif + + +#if @GNULIB_ISNANF@ +/* Test for NaN for 'float' numbers. */ +# if @HAVE_ISNANF@ +# if defined __sun || defined __sgi +/* Solaris and IRIX have isnanf() and declare it in . We cannot + define isnanf as a macro, because that would conflict with . */ +_GL_EXTERN_C int isnanf (float x); +# else +/* The original included above provides a declaration of isnan macro + or (older) isnanf function. */ +# if (__GNUC__ >= 4) || (__clang_major__ >= 4) + /* GCC >= 4.0 and clang provide a type-generic built-in for isnan. + GCC >= 4.0 also provides __builtin_isnanf, but clang doesn't. */ +# undef isnanf +# define isnanf(x) __builtin_isnan ((float)(x)) +# elif defined isnan +# undef isnanf +# define isnanf(x) isnan ((float)(x)) +# endif +# endif +# else +/* Test whether X is a NaN. */ +# undef isnanf +# define isnanf rpl_isnanf +_GL_EXTERN_C int isnanf (float x); +# endif +#endif + +#if @GNULIB_ISNAND@ +/* Test for NaN for 'double' numbers. + This function is a gnulib extension, unlike isnan() which applied only + to 'double' numbers earlier but now is a type-generic macro. */ +# if @HAVE_ISNAND@ +# if defined __sun || defined __sgi +/* Solaris and IRIX have isnand() and declare it in . We cannot + define isnand as a macro, because that would conflict with . */ +_GL_EXTERN_C int isnand (double x); +# else +/* The original included above provides a declaration of isnan + macro. */ +# if (__GNUC__ >= 4) || (__clang_major__ >= 4) + /* GCC >= 4.0 and clang provide a type-generic built-in for isnan. */ +# undef isnand +# define isnand(x) __builtin_isnan ((double)(x)) +# else +# undef isnand +# define isnand(x) isnan ((double)(x)) +# endif +# endif +# else +/* Test whether X is a NaN. */ +# undef isnand +# define isnand rpl_isnand +_GL_EXTERN_C int isnand (double x); +# endif +#endif + +#if @GNULIB_ISNANL@ +/* Test for NaN for 'long double' numbers. */ +# if @HAVE_ISNANL@ +/* The original included above provides a declaration of isnan + macro or (older) isnanl function. */ +# if (__GNUC__ >= 4) || (__clang_major__ >= 4) + /* GCC >= 4.0 and clang provide a type-generic built-in for isnan. + GCC >= 4.0 also provides __builtin_isnanl, but clang doesn't. */ +# undef isnanl +# define isnanl(x) __builtin_isnan ((long double)(x)) +# elif defined isnan +# undef isnanl +# define isnanl(x) isnan ((long double)(x)) +# endif +# else +/* Test whether X is a NaN. */ +# undef isnanl +# define isnanl rpl_isnanl +_GL_EXTERN_C int isnanl (long double x) _GL_ATTRIBUTE_CONST; +# endif +#endif + +/* This must come *after* the snippets for GNULIB_ISNANF and GNULIB_ISNANL! */ +#if @GNULIB_ISNAN@ +# if @REPLACE_ISNAN@ +/* We can't just use the isnanf macro (e.g.) as exposed by + isnanf.h (e.g.) here, because those may end up being macros + that recursively expand back to isnan. So use the gnulib + replacements for them directly. */ +# if @HAVE_ISNANF@ && (__GNUC__ >= 4) || (__clang_major__ >= 4) +# define gl_isnan_f(x) __builtin_isnan ((float)(x)) +# else +_GL_EXTERN_C int rpl_isnanf (float x); +# define gl_isnan_f(x) rpl_isnanf (x) +# endif +# if @HAVE_ISNAND@ && (__GNUC__ >= 4) || (__clang_major__ >= 4) +# define gl_isnan_d(x) __builtin_isnan ((double)(x)) +# else +_GL_EXTERN_C int rpl_isnand (double x); +# define gl_isnan_d(x) rpl_isnand (x) +# endif +# if @HAVE_ISNANL@ && (__GNUC__ >= 4) || (__clang_major__ >= 4) +# define gl_isnan_l(x) __builtin_isnan ((long double)(x)) +# else +_GL_EXTERN_C int rpl_isnanl (long double x) _GL_ATTRIBUTE_CONST; +# define gl_isnan_l(x) rpl_isnanl (x) +# endif +# undef isnan +# define isnan(x) \ + (sizeof (x) == sizeof (long double) ? gl_isnan_l (x) : \ + sizeof (x) == sizeof (double) ? gl_isnan_d (x) : \ + gl_isnan_f (x)) +# elif (__GNUC__ >= 4) || (__clang_major__ >= 4) +# undef isnan +# define isnan(x) \ + (sizeof (x) == sizeof (long double) ? __builtin_isnan ((long double)(x)) : \ + sizeof (x) == sizeof (double) ? __builtin_isnan ((double)(x)) : \ + __builtin_isnan ((float)(x))) +# endif +# ifdef __cplusplus +# if defined isnan || defined GNULIB_NAMESPACE +_GL_MATH_CXX_REAL_FLOATING_DECL_1 (isnan) +# undef isnan +# if __GNUC__ >= 6 || (defined __clang__ && !((defined __APPLE__ && defined __MACH__ && __clang_major__ != 12) || (defined __FreeBSD__ && (__clang_major__ < 7 || __clang_major__ >= 11)) || defined __OpenBSD__ || (defined _WIN32 && !defined __CYGWIN__))) + /* This platform's possibly defines isnan through a set of inline + functions. */ +_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isnan, rpl_isnan, bool) +# define isnan rpl_isnan +# define GNULIB_NAMESPACE_LACKS_ISNAN 1 +# elif __clang_major__ >= 14 + /* Neither of the two possible _GL_MATH_CXX_REAL_FLOATING_DECL_2 invocations + works. Inline functions are already present in /usr/include/c++/v1/math.h, + which comes from LLVM. */ +# define GNULIB_NAMESPACE_LACKS_ISNAN 1 +# else +_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isnan, isnan, bool) +# endif +# endif +# else +/* Ensure isnan is a macro. */ +# ifndef isnan +# define isnan isnan +# endif +# endif +#elif defined GNULIB_POSIXCHECK +# if defined isnan +_GL_WARN_REAL_FLOATING_DECL (isnan); +# undef isnan +# define isnan(x) _GL_WARN_REAL_FLOATING_IMPL (isnan, x) +# endif +#endif + + +#if @GNULIB_SIGNBIT@ +# if (@REPLACE_SIGNBIT_USING_BUILTINS@ \ + && (!defined __cplusplus || __cplusplus < 201103)) +# undef signbit + /* GCC >= 4.0 and clang provide three built-ins for signbit. */ +# define signbit(x) \ + (sizeof (x) == sizeof (long double) ? __builtin_signbitl (x) : \ + sizeof (x) == sizeof (double) ? __builtin_signbit (x) : \ + __builtin_signbitf (x)) +# endif +# if @REPLACE_SIGNBIT@ && !GNULIB_defined_signbit +# undef signbit +_GL_EXTERN_C int gl_signbitf (float arg); +_GL_EXTERN_C int gl_signbitd (double arg); +_GL_EXTERN_C int gl_signbitl (long double arg); +# if __GNUC__ >= 2 || defined __clang__ +# define _GL_NUM_UINT_WORDS(type) \ + ((sizeof (type) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) +# if defined FLT_SIGNBIT_WORD && defined FLT_SIGNBIT_BIT && !defined gl_signbitf +# define gl_signbitf_OPTIMIZED_MACRO +# define gl_signbitf(arg) \ + __extension__ \ + ({ union { float _value; \ + unsigned int _word[_GL_NUM_UINT_WORDS (float)]; \ + } _m; \ + _m._value = (arg); \ + (_m._word[FLT_SIGNBIT_WORD] >> FLT_SIGNBIT_BIT) & 1; \ + }) +# endif +# if defined DBL_SIGNBIT_WORD && defined DBL_SIGNBIT_BIT && !defined gl_signbitd +# define gl_signbitd_OPTIMIZED_MACRO +# define gl_signbitd(arg) \ + __extension__ \ + ({ union { double _value; \ + unsigned int _word[_GL_NUM_UINT_WORDS (double)]; \ + } _m; \ + _m._value = (arg); \ + (_m._word[DBL_SIGNBIT_WORD] >> DBL_SIGNBIT_BIT) & 1; \ + }) +# endif +# if defined LDBL_SIGNBIT_WORD && defined LDBL_SIGNBIT_BIT && !defined gl_signbitl +# define gl_signbitl_OPTIMIZED_MACRO +# define gl_signbitl(arg) \ + __extension__ \ + ({ union { long double _value; \ + unsigned int _word[_GL_NUM_UINT_WORDS (long double)]; \ + } _m; \ + _m._value = (arg); \ + (_m._word[LDBL_SIGNBIT_WORD] >> LDBL_SIGNBIT_BIT) & 1; \ + }) +# endif +# endif +# define signbit(x) \ + (sizeof (x) == sizeof (long double) ? gl_signbitl (x) : \ + sizeof (x) == sizeof (double) ? gl_signbitd (x) : \ + gl_signbitf (x)) +# define GNULIB_defined_signbit 1 +# endif +# ifdef __cplusplus +# if defined signbit || defined GNULIB_NAMESPACE +_GL_MATH_CXX_REAL_FLOATING_DECL_1 (signbit) +# undef signbit +# if __GNUC__ >= 6 || (defined __clang__ && !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __OpenBSD__ || defined _AIX || (defined _WIN32 && !defined __CYGWIN__))) + /* This platform's possibly defines signbit through a set of inline + functions. */ +_GL_MATH_CXX_REAL_FLOATING_DECL_2 (signbit, rpl_signbit, bool) +# define signbit rpl_signbit +# define GNULIB_NAMESPACE_LACKS_SIGNBIT 1 +# else +_GL_MATH_CXX_REAL_FLOATING_DECL_2 (signbit, signbit, bool) +# endif +# endif +# endif +#elif defined GNULIB_POSIXCHECK +# if defined signbit +_GL_WARN_REAL_FLOATING_DECL (signbit); +# undef signbit +# define signbit(x) _GL_WARN_REAL_FLOATING_IMPL (signbit, x) +# endif +#endif + + +#if @GNULIB_TOTALORDERF@ +# if @REPLACE_TOTALORDERF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef totalorderf +# define totalorderf rpl_totalorderf +# endif +_GL_FUNCDECL_RPL (totalorderf, int, (float const *, float const *)); +_GL_CXXALIAS_RPL (totalorderf, int, (float const *, float const *)); +# else +# if !@HAVE_TOTALORDERF@ +_GL_FUNCDECL_SYS (totalorderf, int, (float const *, float const *)); +# endif +_GL_CXXALIAS_SYS (totalorderf, int, (float const *, float const *)); +# endif +_GL_CXXALIASWARN (totalorderf); +#elif defined GNULIB_POSIXCHECK +# undef totalorderf +# if HAVE_RAW_DECL_TOTALORDERF +_GL_WARN_ON_USE (totalorderf, "totalorderf is unportable - " + "use gnulib module totalorderf for portability"); +# endif +#endif + +#if @GNULIB_TOTALORDER@ +# if @REPLACE_TOTALORDER@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef totalorder +# define totalorder rpl_totalorder +# endif +_GL_FUNCDECL_RPL (totalorder, int, (double const *, double const *)); +_GL_CXXALIAS_RPL (totalorder, int, (double const *, double const *)); +# else +# if !@HAVE_TOTALORDER@ +_GL_FUNCDECL_SYS (totalorder, int, (double const *, double const *)); +# endif +_GL_CXXALIAS_SYS (totalorder, int, (double const *, double const *)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN1 (totalorder, int, (double const *, double const *)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef totalorder +# if HAVE_RAW_DECL_TOTALORDER +_GL_WARN_ON_USE (totalorder, "totalorder is unportable - " + "use gnulib module totalorder for portability"); +# endif +#endif + +#if @GNULIB_TOTALORDERL@ +# if @REPLACE_TOTALORDERL@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef totalorderl +# define totalorderl rpl_totalorderl +# endif +_GL_FUNCDECL_RPL (totalorderl, int, + (long double const *, long double const *)); +_GL_CXXALIAS_RPL (totalorderl, int, + (long double const *, long double const *)); +# else +# if !@HAVE_TOTALORDERL@ +_GL_FUNCDECL_SYS (totalorderl, int, + (long double const *, long double const *)); +# endif +_GL_CXXALIAS_SYS (totalorderl, int, + (long double const *, long double const *)); +# endif +_GL_CXXALIASWARN (totalorderl); +#elif defined GNULIB_POSIXCHECK +# undef totalorderl +# if HAVE_RAW_DECL_TOTALORDERL +_GL_WARN_ON_USE (totalorderl, "totalorderl is unportable - " + "use gnulib module totalorderl for portability"); +# endif +#endif + +_GL_INLINE_HEADER_END + +#endif /* _@GUARD_PREFIX@_MATH_H */ +#endif /* _GL_INCLUDING_MATH_H */ +#endif /* _@GUARD_PREFIX@_MATH_H */ +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/minus-zero.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/minus-zero.h new file mode 100644 index 00000000..73a388f6 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/minus-zero.h @@ -0,0 +1,74 @@ +/* Macros for floating-point negative zero. + Copyright (C) 2010-2024 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 . */ + +/* Keep in sync with m4/minus-zero.m4! */ + +#include + + +/* minus_zerof represents the value -0.0f. */ + +/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0f. + ICC 10.0 has a bug when optimizing the expression -zero. + The expression -FLT_MIN * FLT_MIN does not work when cross-compiling + to PowerPC on Mac OS X 10.5. */ +#if defined __hpux || defined __sgi || defined __ICC +static float +compute_minus_zerof (void) +{ + return -FLT_MIN * FLT_MIN; +} +# define minus_zerof compute_minus_zerof () +#else +float minus_zerof = -0.0f; +#endif + + +/* minus_zerod represents the value -0.0. */ + +/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0. + ICC 10.0 has a bug when optimizing the expression -zero. + The expression -DBL_MIN * DBL_MIN does not work when cross-compiling + to PowerPC on Mac OS X 10.5. */ +#if defined __hpux || defined __sgi || defined __ICC +static double +compute_minus_zerod (void) +{ + return -DBL_MIN * DBL_MIN; +} +# define minus_zerod compute_minus_zerod () +#else +double minus_zerod = -0.0; +#endif + + +/* minus_zerol represents the value -0.0L. */ + +/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0L. + IRIX cc can't put -0.0L into .data, but can compute at runtime. + ICC 10.0 has a bug when optimizing the expression -zero. + The expression -LDBL_MIN * LDBL_MIN does not work when cross-compiling + to PowerPC on Mac OS X 10.5. */ +#if defined __hpux || defined __sgi || defined __ICC +static long double +compute_minus_zerol (void) +{ + return -LDBL_MIN * LDBL_MIN; +} +# define minus_zerol compute_minus_zerol () +#else +long double minus_zerol = -0.0L; +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/mmap-anon-util.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/mmap-anon-util.h new file mode 100644 index 00000000..767b3312 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/mmap-anon-util.h @@ -0,0 +1,99 @@ +/* Some auxiliary stuff for using mmap & friends. + Copyright (C) 2002-2024 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 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 . */ + +/* Written by Bruno Haible. */ + +#if defined _WIN32 && !defined __CYGWIN__ + +/* ------------------------ Windows ------------------------ */ + +# define WIN32_LEAN_AND_MEAN /* avoid including junk */ +# include +# include +# define PROT_NONE PAGE_NOACCESS +# define PROT_READ PAGE_READONLY +# define PROT_READ_WRITE PAGE_READWRITE + +static void * +mmap_zeromap (void *map_addr_hint, size_t map_len) +{ + if (VirtualAlloc ((void *)((uintptr_t) map_addr_hint & -0x10000), + (((uintptr_t) map_addr_hint + map_len - 1) | 0xffff) + 1 + - ((uintptr_t) map_addr_hint & -0x10000), + MEM_RESERVE, PAGE_NOACCESS) + && VirtualAlloc (map_addr_hint, map_len, MEM_COMMIT, PAGE_READWRITE)) + return map_addr_hint; + else + return (void *)(-1); +} + +int +munmap (void *addr, size_t len) +{ + if (VirtualFree (addr, len, MEM_DECOMMIT)) + return 0; + else + return -1; +} + +int +mprotect (void *addr, size_t len, int prot) +{ + DWORD oldprot; + + if (VirtualProtect (addr, len, prot, &oldprot)) + return 0; + else + return -1; +} + +#else + +/* ------------------------ Unix ------------------------ */ + +# include +# include +# include + +# ifndef PROT_NONE +# define PROT_NONE 0 +# endif +# define PROT_READ_WRITE (PROT_READ|PROT_WRITE) + +# if HAVE_MAP_ANONYMOUS +# define zero_fd -1 +# define map_flags MAP_ANONYMOUS | MAP_PRIVATE +# else +# ifndef MAP_FILE +# define MAP_FILE 0 +# endif +static int zero_fd; +# define map_flags MAP_FILE | MAP_PRIVATE +# endif + +static void * +mmap_zeromap (void *map_addr_hint, size_t map_len) +{ +# ifdef __hpux + /* HP-UX 10 mmap() often fails when given a hint. So give the OS complete + freedom about the address range. */ + return (void *) mmap ((void *) 0, map_len, PROT_READ_WRITE, map_flags, zero_fd, 0); +# else + return (void *) mmap (map_addr_hint, map_len, PROT_READ_WRITE, map_flags, zero_fd, 0); +# endif +} + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/nan.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/nan.h new file mode 100644 index 00000000..d540a0bb --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/nan.h @@ -0,0 +1,97 @@ +/* Macros for quiet not-a-number. + Copyright (C) 2007-2024 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 . */ + +#ifndef _GL_NAN_H +#define _GL_NAN_H + + +/* IBM z/OS supports both hexadecimal and IEEE floating-point formats. The + former does not support NaN and its isnan() implementation returns zero + for all values. */ +#if defined __MVS__ && defined __IBMC__ && !defined __BFP__ +# error "NaN is not supported with IBM's hexadecimal floating-point format; please re-compile with -qfloat=ieee" +#endif + +/* NaNf () returns a 'float' not-a-number. */ + +/* The Compaq (ex-DEC) C 6.4 compiler and the Microsoft MSVC 9 compiler choke + on the expression 0.0 / 0.0. The IBM XL C compiler on z/OS complains. + PGI 16.10 complains. clang 13 on mips64 does incorrect constant-folding. */ +#if (defined __DECC || defined _MSC_VER \ + || (defined __MVS__ && defined __IBMC__) \ + || defined __PGI \ + || defined __mips__) +static float +NaNf () +{ + static float volatile zero = 0.0f; + return zero / zero; +} +#else +# define NaNf() (0.0f / 0.0f) +#endif + + +/* NaNd () returns a 'double' not-a-number. */ + +/* The Compaq (ex-DEC) C 6.4 compiler and the Microsoft MSVC 9 compiler choke + on the expression 0.0 / 0.0. The IBM XL C compiler on z/OS complains. + PGI 16.10 complains. clang 13 on mips64 does incorrect constant-folding. */ +#if (defined __DECC || defined _MSC_VER \ + || (defined __MVS__ && defined __IBMC__) \ + || defined __PGI \ + || defined __mips__) +static double +NaNd () +{ + static double volatile zero = 0.0; + return zero / zero; +} +#else +# define NaNd() (0.0 / 0.0) +#endif + + +/* NaNl () returns a 'long double' not-a-number. */ + +/* On Irix 6.5, gcc 3.4.3 can't compute compile-time NaN, and needs the + runtime type conversion. + The Microsoft MSVC 9 compiler chokes on the expression 0.0L / 0.0L. + The IBM XL C compiler on z/OS complains. + PGI 16.10 complains. + Avoid possible incorrect constant-folding on mips. */ +#ifdef __sgi +static long double NaNl () +{ + double zero = 0.0; + return zero / zero; +} +#elif (defined _MSC_VER \ + || (defined __MVS__ && defined __IBMC__) \ + || defined __PGI \ + || defined __mips__) +static long double +NaNl () +{ + static long double volatile zero = 0.0L; + return zero / zero; +} +#else +# define NaNl() (0.0L / 0.0L) +#endif + + +#endif /* _GL_NAN_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/nan.h~ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/nan.h~ new file mode 100644 index 00000000..05f141d2 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/nan.h~ @@ -0,0 +1,85 @@ +/* Macros for not-a-number. + Copyright (C) 2007-2023 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 . */ + + +/* IBM z/OS supports both hexadecimal and IEEE floating-point formats. The + former does not support NaN and its isnan() implementation returns zero + for all values. */ +#if defined __MVS__ && defined __IBMC__ && !defined __BFP__ +# error "NaN is not supported with IBM's hexadecimal floating-point format; please re-compile with -qfloat=ieee" +#endif + +/* NaNf () returns a 'float' not-a-number. */ + +/* The Compaq (ex-DEC) C 6.4 compiler and the Microsoft MSVC 9 compiler choke + on the expression 0.0 / 0.0. The IBM XL C compiler on z/OS complains. + PGI 16.10 complains. */ +#if (defined __DECC || defined _MSC_VER \ + || (defined __MVS__ && defined __IBMC__) \ + || defined __PGI) +static float +NaNf () +{ + static float zero = 0.0f; + return zero / zero; +} +#else +# define NaNf() (0.0f / 0.0f) +#endif + + +/* NaNd () returns a 'double' not-a-number. */ + +/* The Compaq (ex-DEC) C 6.4 compiler and the Microsoft MSVC 9 compiler choke + on the expression 0.0 / 0.0. The IBM XL C compiler on z/OS complains. + PGI 16.10 complains. */ +#if (defined __DECC || defined _MSC_VER \ + || (defined __MVS__ && defined __IBMC__) \ + || defined __PGI) +static double +NaNd () +{ + static double zero = 0.0; + return zero / zero; +} +#else +# define NaNd() (0.0 / 0.0) +#endif + + +/* NaNl () returns a 'long double' not-a-number. */ + +/* On Irix 6.5, gcc 3.4.3 can't compute compile-time NaN, and needs the + runtime type conversion. + The Microsoft MSVC 9 compiler chokes on the expression 0.0L / 0.0L. + The IBM XL C compiler on z/OS complains. + PGI 16.10 complains. */ +#ifdef __sgi +static long double NaNl () +{ + double zero = 0.0; + return zero / zero; +} +#elif defined _MSC_VER || (defined __MVS__ && defined __IBMC__) || defined __PGI +static long double +NaNl () +{ + static long double zero = 0.0L; + return zero / zero; +} +#else +# define NaNl() (0.0L / 0.0L) +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/nanosleep.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/nanosleep.c new file mode 100644 index 00000000..c6a76ec0 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/nanosleep.c @@ -0,0 +1,192 @@ +/* Provide a replacement for the POSIX nanosleep function. + + Copyright (C) 1999-2000, 2002, 2004-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* written by Jim Meyering + and Bruno Haible for the native Windows part */ + +#include + +#include + +#include "intprops.h" + +#include +#include +#include +#include + +#include + +#include + + +enum { BILLION = 1000 * 1000 * 1000 }; + +#if HAVE_BUG_BIG_NANOSLEEP + +int +nanosleep (const struct timespec *requested_delay, + struct timespec *remaining_delay) +# undef nanosleep +{ + /* nanosleep mishandles large sleeps due to internal overflow problems. + The worst known case of this is Linux 2.6.9 with glibc 2.3.4, which + can't sleep more than 24.85 days (2^31 milliseconds). Similarly, + cygwin 1.5.x, which can't sleep more than 49.7 days (2^32 milliseconds). + Solve this by breaking the sleep up into smaller chunks. */ + + if (requested_delay->tv_nsec < 0 || BILLION <= requested_delay->tv_nsec) + { + errno = EINVAL; + return -1; + } + + { + /* Verify that time_t is large enough. */ + static_assert (TYPE_MAXIMUM (time_t) / 24 / 24 / 60 / 60); + const time_t limit = 24 * 24 * 60 * 60; + time_t seconds = requested_delay->tv_sec; + struct timespec intermediate = *requested_delay; + + while (limit < seconds) + { + int result; + intermediate.tv_sec = limit; + result = nanosleep (&intermediate, remaining_delay); + seconds -= limit; + if (result) + { + if (remaining_delay) + remaining_delay->tv_sec += seconds; + return result; + } + intermediate.tv_nsec = 0; + } + intermediate.tv_sec = seconds; + return nanosleep (&intermediate, remaining_delay); + } +} + +#elif defined _WIN32 && ! defined __CYGWIN__ +/* Native Windows platforms. */ + +# define WIN32_LEAN_AND_MEAN +# include + +/* The Windows API function Sleep() has a resolution of about 15 ms and takes + at least 5 ms to execute. We use this function for longer time periods. + Additionally, we use busy-looping over short time periods, to get a + resolution of about 0.01 ms. In order to measure such short timespans, + we use the QueryPerformanceCounter() function. */ + +int +nanosleep (const struct timespec *requested_delay, + struct timespec *remaining_delay) +{ + static bool initialized; + /* Number of performance counter increments per nanosecond, + or zero if it could not be determined. */ + static double ticks_per_nanosecond; + + if (requested_delay->tv_nsec < 0 || BILLION <= requested_delay->tv_nsec) + { + errno = EINVAL; + return -1; + } + + /* For requested delays of one second or more, 15ms resolution is + sufficient. */ + if (requested_delay->tv_sec == 0) + { + if (!initialized) + { + /* Initialize ticks_per_nanosecond. */ + LARGE_INTEGER ticks_per_second; + + if (QueryPerformanceFrequency (&ticks_per_second)) + ticks_per_nanosecond = + (double) ticks_per_second.QuadPart / 1000000000.0; + + initialized = true; + } + if (ticks_per_nanosecond) + { + /* QueryPerformanceFrequency worked. We can use + QueryPerformanceCounter. Use a combination of Sleep and + busy-looping. */ + /* Number of milliseconds to pass to the Sleep function. + Since Sleep can take up to 8 ms less or 8 ms more than requested + (or maybe more if the system is loaded), we subtract 10 ms. */ + int sleep_millis = (int) requested_delay->tv_nsec / 1000000 - 10; + /* Determine how many ticks to delay. */ + LONGLONG wait_ticks = requested_delay->tv_nsec * ticks_per_nanosecond; + /* Start. */ + LARGE_INTEGER counter_before; + if (QueryPerformanceCounter (&counter_before)) + { + /* Wait until the performance counter has reached this value. + We don't need to worry about overflow, because the performance + counter is reset at reboot, and with a frequency of 3.6E6 + ticks per second 63 bits suffice for over 80000 years. */ + LONGLONG wait_until = counter_before.QuadPart + wait_ticks; + /* Use Sleep for the longest part. */ + if (sleep_millis > 0) + Sleep (sleep_millis); + /* Busy-loop for the rest. */ + for (;;) + { + LARGE_INTEGER counter_after; + if (!QueryPerformanceCounter (&counter_after)) + /* QueryPerformanceCounter failed, but succeeded earlier. + Should not happen. */ + break; + if (counter_after.QuadPart >= wait_until) + /* The requested time has elapsed. */ + break; + } + goto done; + } + } + } + /* Implementation for long delays and as fallback. */ + Sleep (requested_delay->tv_sec * 1000 + requested_delay->tv_nsec / 1000000); + + done: + /* Sleep is not interruptible. So there is no remaining delay. */ + if (remaining_delay != NULL) + { + remaining_delay->tv_sec = 0; + remaining_delay->tv_nsec = 0; + } + return 0; +} + +#else +/* Other platforms lacking nanosleep. + It's not clear whether these are still practical porting targets. + For now, just fall back on pselect. */ + +/* Suspend execution for at least *REQUESTED_DELAY seconds. The + *REMAINING_DELAY part isn't implemented yet. */ + +int +nanosleep (const struct timespec *requested_delay, + struct timespec *remaining_delay) +{ + return pselect (0, NULL, NULL, NULL, requested_delay, NULL); +} +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/nap.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/nap.h new file mode 100644 index 00000000..cf7d998b --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/nap.h @@ -0,0 +1,161 @@ +/* Assist in file system timestamp tests. + Copyright (C) 2009-2024 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 . */ + +/* Written by Eric Blake , 2009. */ + +#ifndef GLTEST_NAP_H +# define GLTEST_NAP_H + +# include + +# include + +/* Avoid a conflict with a function called nap() on UnixWare. */ +# if defined _SCO_DS || (defined __SCO_VERSION__ || defined __sysv5__) /* OpenServer, UnixWare */ +# include +# undef nap +# define nap gl_nap +# endif + +/* Name of the witness file. */ +#define TEMPFILE BASE "nap.tmp" + +/* File descriptor used for the witness file. */ +static int nap_fd = -1; + +/* Return A - B, in ns. + Return 0 if the true result would be negative. + Return INT_MAX if the true result would be greater than INT_MAX. */ +static int +diff_timespec (struct timespec a, struct timespec b) +{ + time_t as = a.tv_sec; + time_t bs = b.tv_sec; + int ans = a.tv_nsec; + int bns = b.tv_nsec; + int sdiff; + + ASSERT (0 <= ans && ans < 2000000000); + ASSERT (0 <= bns && bns < 2000000000); + + if (! (bs < as || (bs == as && bns < ans))) + return 0; + + if (ckd_sub (&sdiff, as, bs) + || ckd_mul (&sdiff, sdiff, 1000000000) + || ckd_add (&sdiff, sdiff, ans - bns)) + return INT_MAX; + + return sdiff; +} + +/* If DO_WRITE, bump the modification time of the file designated by NAP_FD. + Then fetch the new STAT information of NAP_FD. */ +static void +nap_get_stat (struct stat *st, int do_write) +{ + if (do_write) + { + ASSERT (write (nap_fd, "\n", 1) == 1); +#if defined _WIN32 || defined __CYGWIN__ + /* On Windows, the modification times are not changed until NAP_FD + is closed. See + */ + close (nap_fd); + nap_fd = open (TEMPFILE, O_RDWR, 0600); + ASSERT (nap_fd != -1); + lseek (nap_fd, 0, SEEK_END); +#endif + } + ASSERT (fstat (nap_fd, st) == 0); +} + +/* Given a file whose descriptor is FD, see whether delaying by DELAY + nanoseconds causes a change in a file's mtime. + OLD_ST is the file's status, recently gotten. */ +static bool +nap_works (int delay, struct stat old_st) +{ + struct stat st; + struct timespec delay_spec; + delay_spec.tv_sec = delay / 1000000000; + delay_spec.tv_nsec = delay % 1000000000; + ASSERT (nanosleep (&delay_spec, 0) == 0); + nap_get_stat (&st, 1); + + if (diff_timespec (get_stat_mtime (&st), get_stat_mtime (&old_st))) + return true; + + return false; +} + +static void +clear_temp_file (void) +{ + if (0 <= nap_fd) + { + ASSERT (close (nap_fd) != -1); + ASSERT (unlink (TEMPFILE) != -1); + } +} + +/* Sleep long enough to notice a timestamp difference on the file + system in the current directory. Use an adaptive approach, trying + to find the smallest delay which works on the current file system + to make the timestamp difference appear. Assert a maximum delay of + ~2 seconds, more precisely sum(2^n) from 0 to 30 = 2^31 - 1 = 2.1s. + Assumes that BASE is defined, and requires that the test module + depends on nanosleep. */ +static void +nap (void) +{ + struct stat old_st; + static int delay = 1; + + if (-1 == nap_fd) + { + atexit (clear_temp_file); + ASSERT ((nap_fd = creat (TEMPFILE, 0600)) != -1); + nap_get_stat (&old_st, 0); + } + else + { + ASSERT (0 <= nap_fd); + nap_get_stat (&old_st, 1); + } + + if (1 < delay) + delay = delay / 2; /* Try half of the previous delay. */ + ASSERT (0 < delay); + + for (;;) + { + if (nap_works (delay, old_st)) + return; + if (delay <= (2147483647 - 1) / 2) + { + delay = delay * 2 + 1; + continue; + } + else + break; + } + + /* Bummer: even the highest nap delay didn't work. */ + ASSERT (0); +} + +#endif /* GLTEST_NAP_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/netinet_in.in.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/netinet_in.in.h new file mode 100644 index 00000000..4e9f6f2d --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/netinet_in.in.h @@ -0,0 +1,47 @@ +/* Substitute for . + Copyright (C) 2007-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef _@GUARD_PREFIX@_NETINET_IN_H + +#if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +#endif +@PRAGMA_COLUMNS@ + +#if @HAVE_NETINET_IN_H@ + +/* On many platforms, assumes prior inclusion of + . */ +# include + +/* The include_next requires a split double-inclusion guard. */ +# @INCLUDE_NEXT@ @NEXT_NETINET_IN_H@ + +#endif + +#ifndef _@GUARD_PREFIX@_NETINET_IN_H +#define _@GUARD_PREFIX@_NETINET_IN_H + +#if !@HAVE_NETINET_IN_H@ + +/* A platform that lacks . */ + +# include + +#endif + +#endif /* _@GUARD_PREFIX@_NETINET_IN_H */ +#endif /* _@GUARD_PREFIX@_NETINET_IN_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/offtostr.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/offtostr.c new file mode 100644 index 00000000..e46763ef --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/offtostr.c @@ -0,0 +1,20 @@ +/* Convert 'off_t' integer to printable string. + + Copyright (C) 2004-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#define anytostr offtostr +#define inttype off_t +#include "anytostr.c" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/perror.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/perror.c new file mode 100644 index 00000000..f29cd031 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/perror.c @@ -0,0 +1,49 @@ +/* Print a message describing error code. + Copyright (C) 2008-2024 Free Software Foundation, Inc. + Written by Bruno Haible and Simon Josefsson. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +#include +#include +#include + +#include "strerror-override.h" + +/* Use the system functions, not the gnulib overrides in this file. */ +#undef fprintf + +void +perror (const char *string) +{ + char stackbuf[STACKBUF_LEN]; + int ret; + + /* Our implementation guarantees that this will be a non-empty + string, even if it returns EINVAL; and stackbuf should be sized + large enough to avoid ERANGE. */ + ret = strerror_r (errno, stackbuf, sizeof stackbuf); + if (ret == ERANGE) + abort (); + + if (string != NULL && *string != '\0') + fprintf (stderr, "%s: %s\n", string, stackbuf); + else + fprintf (stderr, "%s\n", stackbuf); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/printf-args.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/printf-args.c new file mode 100644 index 00000000..eb0d2cdc --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/printf-args.c @@ -0,0 +1,306 @@ +/* Decomposed printf argument list. + Copyright (C) 1999, 2002-2003, 2005-2007, 2009-2024 Free Software + Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* This file can be parametrized with the following macros: + ENABLE_UNISTDIO Set to 1 to enable the unistdio extensions. + PRINTF_FETCHARGS Name of the function to be defined. + STATIC Set to 'static' to declare the function static. */ + +#ifndef PRINTF_FETCHARGS +# include +#endif + +/* Specification. */ +#ifndef PRINTF_FETCHARGS +# include "printf-args.h" +#endif + +/* Get INT_WIDTH. */ +#include + +#ifdef STATIC +STATIC +#endif +int +PRINTF_FETCHARGS (va_list args, arguments *a) +{ + size_t i; + argument *ap; + + for (i = 0, ap = &a->arg[0]; i < a->count; i++, ap++) + switch (ap->type) + { + case TYPE_SCHAR: + ap->a.a_schar = va_arg (args, /*signed char*/ int); + break; + case TYPE_UCHAR: + ap->a.a_uchar = va_arg (args, /*unsigned char*/ int); + break; + case TYPE_SHORT: + ap->a.a_short = va_arg (args, /*short*/ int); + break; + case TYPE_USHORT: + ap->a.a_ushort = va_arg (args, /*unsigned short*/ int); + break; + case TYPE_INT: + ap->a.a_int = va_arg (args, int); + break; + case TYPE_UINT: + ap->a.a_uint = va_arg (args, unsigned int); + break; + case TYPE_LONGINT: + ap->a.a_longint = va_arg (args, long int); + break; + case TYPE_ULONGINT: + ap->a.a_ulongint = va_arg (args, unsigned long int); + break; + 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; + case TYPE_INT8_T: + #if INT8_WIDTH < INT_WIDTH + ap->a.a_int8_t = va_arg (args, /* int8_t */ int); + #else + ap->a.a_int8_t = va_arg (args, int8_t); + #endif + break; + case TYPE_UINT8_T: + #if UINT8_WIDTH < INT_WIDTH + ap->a.a_uint8_t = va_arg (args, /* uint8_t */ int); + #else + ap->a.a_uint8_t = va_arg (args, uint8_t); + #endif + break; + case TYPE_INT16_T: + #if INT16_WIDTH < INT_WIDTH + ap->a.a_int16_t = va_arg (args, /* int16_t */ int); + #else + ap->a.a_int16_t = va_arg (args, int16_t); + #endif + break; + case TYPE_UINT16_T: + #if UINT16_WIDTH < INT_WIDTH + ap->a.a_uint16_t = va_arg (args, /* uint16_t */ int); + #else + ap->a.a_uint16_t = va_arg (args, uint16_t); + #endif + break; + case TYPE_INT32_T: + #if INT32_WIDTH < INT_WIDTH + ap->a.a_int32_t = va_arg (args, /* int32_t */ int); + #else + ap->a.a_int32_t = va_arg (args, int32_t); + #endif + break; + case TYPE_UINT32_T: + #if UINT32_WIDTH < INT_WIDTH + ap->a.a_uint32_t = va_arg (args, /* uint32_t */ int); + #else + ap->a.a_uint32_t = va_arg (args, uint32_t); + #endif + break; + case TYPE_INT64_T: + ap->a.a_int64_t = va_arg (args, int64_t); + break; + case TYPE_UINT64_T: + ap->a.a_uint64_t = va_arg (args, uint64_t); + break; + case TYPE_INT_FAST8_T: + #if INT_FAST8_WIDTH < INT_WIDTH + ap->a.a_int_fast8_t = va_arg (args, /* int_fast8_t */ int); + #else + ap->a.a_int_fast8_t = va_arg (args, int_fast8_t); + #endif + break; + case TYPE_UINT_FAST8_T: + #if UINT_FAST8_WIDTH < INT_WIDTH + ap->a.a_uint_fast8_t = va_arg (args, /* uint_fast8_t */ int); + #else + ap->a.a_uint_fast8_t = va_arg (args, uint_fast8_t); + #endif + break; + case TYPE_INT_FAST16_T: + #if INT_FAST16_WIDTH < INT_WIDTH + ap->a.a_int_fast16_t = va_arg (args, /* int_fast16_t */ int); + #else + ap->a.a_int_fast16_t = va_arg (args, int_fast16_t); + #endif + break; + case TYPE_UINT_FAST16_T: + #if UINT_FAST16_WIDTH < INT_WIDTH + ap->a.a_uint_fast16_t = va_arg (args, /* uint_fast16_t */ int); + #else + ap->a.a_uint_fast16_t = va_arg (args, uint_fast16_t); + #endif + break; + case TYPE_INT_FAST32_T: + #if INT_FAST32_WIDTH < INT_WIDTH + ap->a.a_int_fast32_t = va_arg (args, /* int_fast32_t */ int); + #else + ap->a.a_int_fast32_t = va_arg (args, int_fast32_t); + #endif + break; + case TYPE_UINT_FAST32_T: + #if UINT_FAST32_WIDTH < INT_WIDTH + ap->a.a_uint_fast32_t = va_arg (args, /* uint_fast32_t */ int); + #else + ap->a.a_uint_fast32_t = va_arg (args, uint_fast32_t); + #endif + break; + case TYPE_INT_FAST64_T: + ap->a.a_int_fast64_t = va_arg (args, int_fast64_t); + break; + case TYPE_UINT_FAST64_T: + ap->a.a_uint_fast64_t = va_arg (args, uint_fast64_t); + break; + case TYPE_DOUBLE: + ap->a.a_double = va_arg (args, double); + break; + case TYPE_LONGDOUBLE: + ap->a.a_longdouble = va_arg (args, long double); + break; + case TYPE_CHAR: + ap->a.a_char = va_arg (args, int); + break; +#if HAVE_WINT_T + case TYPE_WIDE_CHAR: + /* Although ISO C 99 7.24.1.(2) says that wint_t is "unchanged by + default argument promotions", this is not the case in mingw32, + where wint_t is 'unsigned short'. */ + ap->a.a_wide_char = + (sizeof (wint_t) < sizeof (int) + ? (wint_t) va_arg (args, int) + : va_arg (args, wint_t)); + break; +#endif + case TYPE_STRING: + ap->a.a_string = va_arg (args, const char *); + /* A null pointer is an invalid argument for "%s", but in practice + it occurs quite frequently in printf statements that produce + debug output. Use a fallback in this case. */ + if (ap->a.a_string == NULL) + ap->a.a_string = "(NULL)"; + break; +#if HAVE_WCHAR_T + case TYPE_WIDE_STRING: + ap->a.a_wide_string = va_arg (args, const wchar_t *); + /* A null pointer is an invalid argument for "%ls", but in practice + it occurs quite frequently in printf statements that produce + debug output. Use a fallback in this case. */ + if (ap->a.a_wide_string == NULL) + { + static const wchar_t wide_null_string[] = + { + (wchar_t)'(', + (wchar_t)'N', (wchar_t)'U', (wchar_t)'L', (wchar_t)'L', + (wchar_t)')', + (wchar_t)0 + }; + ap->a.a_wide_string = wide_null_string; + } + break; +#endif + case TYPE_POINTER: + ap->a.a_pointer = va_arg (args, void *); + break; + case TYPE_COUNT_SCHAR_POINTER: + ap->a.a_count_schar_pointer = va_arg (args, signed char *); + break; + case TYPE_COUNT_SHORT_POINTER: + ap->a.a_count_short_pointer = va_arg (args, short *); + break; + case TYPE_COUNT_INT_POINTER: + ap->a.a_count_int_pointer = va_arg (args, int *); + break; + case TYPE_COUNT_LONGINT_POINTER: + ap->a.a_count_longint_pointer = va_arg (args, long int *); + break; + case TYPE_COUNT_LONGLONGINT_POINTER: + ap->a.a_count_longlongint_pointer = va_arg (args, long long int *); + break; + case TYPE_COUNT_INT8_T_POINTER: + ap->a.a_count_int8_t_pointer = va_arg (args, int8_t *); + break; + case TYPE_COUNT_INT16_T_POINTER: + ap->a.a_count_int16_t_pointer = va_arg (args, int16_t *); + break; + case TYPE_COUNT_INT32_T_POINTER: + ap->a.a_count_int32_t_pointer = va_arg (args, int32_t *); + break; + case TYPE_COUNT_INT64_T_POINTER: + ap->a.a_count_int64_t_pointer = va_arg (args, int64_t *); + break; + case TYPE_COUNT_INT_FAST8_T_POINTER: + ap->a.a_count_int_fast8_t_pointer = va_arg (args, int_fast8_t *); + break; + case TYPE_COUNT_INT_FAST16_T_POINTER: + ap->a.a_count_int_fast16_t_pointer = va_arg (args, int_fast16_t *); + break; + case TYPE_COUNT_INT_FAST32_T_POINTER: + ap->a.a_count_int_fast32_t_pointer = va_arg (args, int_fast32_t *); + break; + case TYPE_COUNT_INT_FAST64_T_POINTER: + ap->a.a_count_int_fast64_t_pointer = va_arg (args, int_fast64_t *); + break; +#if ENABLE_UNISTDIO + /* The unistdio extensions. */ + case TYPE_U8_STRING: + ap->a.a_u8_string = va_arg (args, const uint8_t *); + /* A null pointer is an invalid argument for "%U", but in practice + it occurs quite frequently in printf statements that produce + debug output. Use a fallback in this case. */ + if (ap->a.a_u8_string == NULL) + { + static const uint8_t u8_null_string[] = + { '(', 'N', 'U', 'L', 'L', ')', 0 }; + ap->a.a_u8_string = u8_null_string; + } + break; + case TYPE_U16_STRING: + ap->a.a_u16_string = va_arg (args, const uint16_t *); + /* A null pointer is an invalid argument for "%lU", but in practice + it occurs quite frequently in printf statements that produce + debug output. Use a fallback in this case. */ + if (ap->a.a_u16_string == NULL) + { + static const uint16_t u16_null_string[] = + { '(', 'N', 'U', 'L', 'L', ')', 0 }; + ap->a.a_u16_string = u16_null_string; + } + break; + case TYPE_U32_STRING: + ap->a.a_u32_string = va_arg (args, const uint32_t *); + /* A null pointer is an invalid argument for "%llU", but in practice + it occurs quite frequently in printf statements that produce + debug output. Use a fallback in this case. */ + if (ap->a.a_u32_string == NULL) + { + static const uint32_t u32_null_string[] = + { '(', 'N', 'U', 'L', 'L', ')', 0 }; + ap->a.a_u32_string = u32_null_string; + } + break; +#endif + default: + /* Unknown type. */ + return -1; + } + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/printf-args.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/printf-args.h new file mode 100644 index 00000000..9b80bb39 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/printf-args.h @@ -0,0 +1,205 @@ +/* Decomposed printf argument list. + Copyright (C) 1999, 2002-2003, 2006-2007, 2011-2024 Free Software + Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef _PRINTF_ARGS_H +#define _PRINTF_ARGS_H + +/* This file can be parametrized with the following macros: + ENABLE_UNISTDIO Set to 1 to enable the unistdio extensions. + PRINTF_FETCHARGS Name of the function to be declared. + STATIC Set to 'static' to declare the function static. */ + +/* Default parameters. */ +#ifndef PRINTF_FETCHARGS +# define PRINTF_FETCHARGS printf_fetchargs +#endif + +/* Get size_t. */ +#include + +/* Get wchar_t. */ +#if HAVE_WCHAR_T +# include +#endif + +/* Get wint_t. */ +#if HAVE_WINT_T +# include +#endif + +/* Get intN_t, uintN_t, intN_fast_t, uintN_fast_t. */ +#include + +/* Get va_list. */ +#include + + +/* Argument types */ +typedef enum +{ + TYPE_NONE, + TYPE_SCHAR, + TYPE_UCHAR, + TYPE_SHORT, + TYPE_USHORT, + TYPE_INT, + TYPE_UINT, + TYPE_LONGINT, + TYPE_ULONGINT, + TYPE_LONGLONGINT, + TYPE_ULONGLONGINT, + /* According to ISO C 23 § 7.23.6.1, "all exact-width integer types", + "all minimum-width integer types", and "all fastest minimum-width integer + types" defined in should be supported. But for portability + between platforms, we support only those with N = 8, 16, 32, 64. */ + TYPE_INT8_T, + TYPE_UINT8_T, + TYPE_INT16_T, + TYPE_UINT16_T, + TYPE_INT32_T, + TYPE_UINT32_T, + TYPE_INT64_T, + TYPE_UINT64_T, + TYPE_INT_FAST8_T, + TYPE_UINT_FAST8_T, + TYPE_INT_FAST16_T, + TYPE_UINT_FAST16_T, + TYPE_INT_FAST32_T, + TYPE_UINT_FAST32_T, + TYPE_INT_FAST64_T, + TYPE_UINT_FAST64_T, + TYPE_DOUBLE, + TYPE_LONGDOUBLE, + TYPE_CHAR, +#if HAVE_WINT_T + TYPE_WIDE_CHAR, +#endif + TYPE_STRING, +#if HAVE_WCHAR_T + TYPE_WIDE_STRING, +#endif + TYPE_POINTER, + TYPE_COUNT_SCHAR_POINTER, + TYPE_COUNT_SHORT_POINTER, + TYPE_COUNT_INT_POINTER, + TYPE_COUNT_LONGINT_POINTER, + TYPE_COUNT_LONGLONGINT_POINTER, + TYPE_COUNT_INT8_T_POINTER, + TYPE_COUNT_INT16_T_POINTER, + TYPE_COUNT_INT32_T_POINTER, + TYPE_COUNT_INT64_T_POINTER, + TYPE_COUNT_INT_FAST8_T_POINTER, + TYPE_COUNT_INT_FAST16_T_POINTER, + TYPE_COUNT_INT_FAST32_T_POINTER, + TYPE_COUNT_INT_FAST64_T_POINTER +#if ENABLE_UNISTDIO + /* The unistdio extensions. */ +, TYPE_U8_STRING +, TYPE_U16_STRING +, TYPE_U32_STRING +#endif +} arg_type; + +/* Polymorphic argument */ +typedef struct +{ + arg_type type; + union + { + signed char a_schar; + unsigned char a_uchar; + short a_short; + unsigned short a_ushort; + int a_int; + unsigned int a_uint; + long int a_longint; + unsigned long int a_ulongint; + long long int a_longlongint; + unsigned long long int a_ulonglongint; + int8_t a_int8_t; + uint8_t a_uint8_t; + int16_t a_int16_t; + uint16_t a_uint16_t; + int32_t a_int32_t; + uint32_t a_uint32_t; + int64_t a_int64_t; + uint64_t a_uint64_t; + int_fast8_t a_int_fast8_t; + uint_fast8_t a_uint_fast8_t; + int_fast16_t a_int_fast16_t; + uint_fast16_t a_uint_fast16_t; + int_fast32_t a_int_fast32_t; + uint_fast32_t a_uint_fast32_t; + int_fast64_t a_int_fast64_t; + uint_fast64_t a_uint_fast64_t; + float a_float; /* unused */ + double a_double; + long double a_longdouble; + int a_char; +#if HAVE_WINT_T + wint_t a_wide_char; +#endif + const char* a_string; +#if HAVE_WCHAR_T + const wchar_t* a_wide_string; +#endif + void* a_pointer; + signed char * a_count_schar_pointer; + short * a_count_short_pointer; + int * a_count_int_pointer; + long int * a_count_longint_pointer; + long long int * a_count_longlongint_pointer; + int8_t * a_count_int8_t_pointer; + int16_t * a_count_int16_t_pointer; + int32_t * a_count_int32_t_pointer; + int64_t * a_count_int64_t_pointer; + int_fast8_t * a_count_int_fast8_t_pointer; + int_fast16_t * a_count_int_fast16_t_pointer; + int_fast32_t * a_count_int_fast32_t_pointer; + int_fast64_t * a_count_int_fast64_t_pointer; +#if ENABLE_UNISTDIO + /* The unistdio extensions. */ + const uint8_t * a_u8_string; + const uint16_t * a_u16_string; + const uint32_t * a_u32_string; +#endif + } + a; +} +argument; + +/* Number of directly allocated arguments (no malloc() needed). */ +#define N_DIRECT_ALLOC_ARGUMENTS 7 + +typedef struct +{ + size_t count; + argument *arg; + argument direct_alloc_arg[N_DIRECT_ALLOC_ARGUMENTS]; +} +arguments; + + +/* Fetch the arguments, putting them into a. */ +#ifdef STATIC +STATIC +#else +extern +#endif +int PRINTF_FETCHARGS (va_list args, arguments *a); + +#endif /* _PRINTF_ARGS_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/printf-parse.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/printf-parse.c new file mode 100644 index 00000000..c0532900 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/printf-parse.c @@ -0,0 +1,714 @@ +/* Formatted output to strings. + Copyright (C) 1999-2000, 2002-2003, 2006-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* This file can be parametrized with the following macros: + CHAR_T The element type of the format string. + CHAR_T_ONLY_ASCII Set to 1 to enable verification that all characters + in the format string are ASCII. + DIRECTIVE Structure denoting a format directive. + Depends on CHAR_T. + DIRECTIVES Structure denoting the set of format directives of a + format string. Depends on CHAR_T. + PRINTF_PARSE Function that parses a format string. + Depends on CHAR_T. + STATIC Set to 'static' to declare the function static. + ENABLE_UNISTDIO Set to 1 to enable the unistdio extensions. */ + +#ifndef PRINTF_PARSE +# include +#endif + +/* Specification. */ +#ifndef PRINTF_PARSE +# include "printf-parse.h" +#endif + +/* Default parameters. */ +#ifndef PRINTF_PARSE +# define PRINTF_PARSE printf_parse +# define CHAR_T char +# define DIRECTIVE char_directive +# define DIRECTIVES char_directives +#endif + +/* Get size_t, NULL. */ +#include + +/* Get intmax_t. */ +#include + +/* malloc(), realloc(), free(). */ +#include + +/* memcpy(). */ +#include + +/* errno. */ +#include + +/* Checked size_t computations. */ +#include "xsize.h" + +#if CHAR_T_ONLY_ASCII +/* c_isascii(). */ +# include "c-ctype.h" +#endif + +#ifdef STATIC +STATIC +#endif +int +PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a) +{ + const CHAR_T *cp = format; /* pointer into format */ + size_t arg_posn = 0; /* number of regular arguments consumed */ + size_t d_allocated; /* allocated elements of d->dir */ + size_t a_allocated; /* allocated elements of a->arg */ + size_t max_width_length = 0; + size_t max_precision_length = 0; + + d->count = 0; + d_allocated = N_DIRECT_ALLOC_DIRECTIVES; + d->dir = d->direct_alloc_dir; + + a->count = 0; + a_allocated = N_DIRECT_ALLOC_ARGUMENTS; + a->arg = a->direct_alloc_arg; + +#define REGISTER_ARG(_index_,_type_) \ + { \ + size_t n = (_index_); \ + if (n >= a_allocated) \ + { \ + size_t memory_size; \ + argument *memory; \ + \ + a_allocated = xtimes (a_allocated, 2); \ + if (a_allocated <= n) \ + a_allocated = xsum (n, 1); \ + memory_size = xtimes (a_allocated, sizeof (argument)); \ + if (size_overflow_p (memory_size)) \ + /* Overflow, would lead to out of memory. */ \ + goto out_of_memory; \ + memory = (argument *) (a->arg != a->direct_alloc_arg \ + ? realloc (a->arg, memory_size) \ + : malloc (memory_size)); \ + if (memory == NULL) \ + /* Out of memory. */ \ + goto out_of_memory; \ + if (a->arg == a->direct_alloc_arg) \ + memcpy (memory, a->arg, a->count * sizeof (argument)); \ + a->arg = memory; \ + } \ + while (a->count <= n) \ + a->arg[a->count++].type = TYPE_NONE; \ + if (a->arg[n].type == TYPE_NONE) \ + a->arg[n].type = (_type_); \ + else if (a->arg[n].type != (_type_)) \ + /* Ambiguous type for positional argument. */ \ + goto error; \ + } + + while (*cp != '\0') + { + CHAR_T c = *cp++; + if (c == '%') + { + size_t arg_index = ARG_NONE; + DIRECTIVE *dp = &d->dir[d->count]; /* pointer to next directive */ + + /* Initialize the next directive. */ + dp->dir_start = cp - 1; + dp->flags = 0; + dp->width_start = NULL; + dp->width_end = NULL; + dp->width_arg_index = ARG_NONE; + dp->precision_start = NULL; + dp->precision_end = NULL; + dp->precision_arg_index = ARG_NONE; + dp->arg_index = ARG_NONE; + + /* Test for positional argument. */ + if (*cp >= '0' && *cp <= '9') + { + const CHAR_T *np; + + for (np = cp; *np >= '0' && *np <= '9'; np++) + ; + if (*np == '$') + { + size_t n = 0; + + for (np = cp; *np >= '0' && *np <= '9'; np++) + n = xsum (xtimes (n, 10), *np - '0'); + if (n == 0) + /* Positional argument 0. */ + goto error; + if (size_overflow_p (n)) + /* n too large, would lead to out of memory later. */ + goto error; + arg_index = n - 1; + cp = np + 1; + } + } + + /* Read the flags. */ + for (;;) + { + if (*cp == '\'') + { + dp->flags |= FLAG_GROUP; + cp++; + } + else if (*cp == '-') + { + dp->flags |= FLAG_LEFT; + cp++; + } + else if (*cp == '+') + { + dp->flags |= FLAG_SHOWSIGN; + cp++; + } + else if (*cp == ' ') + { + dp->flags |= FLAG_SPACE; + cp++; + } + else if (*cp == '#') + { + dp->flags |= FLAG_ALT; + cp++; + } + else if (*cp == '0') + { + dp->flags |= FLAG_ZERO; + cp++; + } +#if __GLIBC__ >= 2 && !defined __UCLIBC__ + else if (*cp == 'I') + { + dp->flags |= FLAG_LOCALIZED; + cp++; + } +#endif + else + break; + } + + /* Parse the field width. */ + if (*cp == '*') + { + dp->width_start = cp; + cp++; + dp->width_end = cp; + if (max_width_length < 1) + max_width_length = 1; + + /* Test for positional argument. */ + if (*cp >= '0' && *cp <= '9') + { + const CHAR_T *np; + + for (np = cp; *np >= '0' && *np <= '9'; np++) + ; + if (*np == '$') + { + size_t n = 0; + + for (np = cp; *np >= '0' && *np <= '9'; np++) + n = xsum (xtimes (n, 10), *np - '0'); + if (n == 0) + /* Positional argument 0. */ + goto error; + if (size_overflow_p (n)) + /* n too large, would lead to out of memory later. */ + goto error; + dp->width_arg_index = n - 1; + cp = np + 1; + } + } + if (dp->width_arg_index == ARG_NONE) + { + dp->width_arg_index = arg_posn++; + if (dp->width_arg_index == ARG_NONE) + /* arg_posn wrapped around. */ + goto error; + } + REGISTER_ARG (dp->width_arg_index, TYPE_INT); + } + else if (*cp >= '0' && *cp <= '9') + { + size_t width_length; + + dp->width_start = cp; + for (; *cp >= '0' && *cp <= '9'; cp++) + ; + dp->width_end = cp; + width_length = dp->width_end - dp->width_start; + if (max_width_length < width_length) + max_width_length = width_length; + } + + /* Parse the precision. */ + if (*cp == '.') + { + cp++; + if (*cp == '*') + { + dp->precision_start = cp - 1; + cp++; + dp->precision_end = cp; + if (max_precision_length < 2) + max_precision_length = 2; + + /* Test for positional argument. */ + if (*cp >= '0' && *cp <= '9') + { + const CHAR_T *np; + + for (np = cp; *np >= '0' && *np <= '9'; np++) + ; + if (*np == '$') + { + size_t n = 0; + + for (np = cp; *np >= '0' && *np <= '9'; np++) + n = xsum (xtimes (n, 10), *np - '0'); + if (n == 0) + /* Positional argument 0. */ + goto error; + if (size_overflow_p (n)) + /* n too large, would lead to out of memory + later. */ + goto error; + dp->precision_arg_index = n - 1; + cp = np + 1; + } + } + if (dp->precision_arg_index == ARG_NONE) + { + dp->precision_arg_index = arg_posn++; + if (dp->precision_arg_index == ARG_NONE) + /* arg_posn wrapped around. */ + goto error; + } + REGISTER_ARG (dp->precision_arg_index, TYPE_INT); + } + else + { + size_t precision_length; + + dp->precision_start = cp - 1; + for (; *cp >= '0' && *cp <= '9'; cp++) + ; + dp->precision_end = cp; + precision_length = dp->precision_end - dp->precision_start; + if (max_precision_length < precision_length) + max_precision_length = precision_length; + } + } + + { + arg_type type; + + /* Parse argument type/size specifiers. */ + /* Relevant for the conversion characters d, i. */ + arg_type signed_type = TYPE_INT; + /* Relevant for the conversion characters b, o, u, x, X. */ + arg_type unsigned_type = TYPE_UINT; + /* Relevant for the conversion characters n. */ + arg_type pointer_type = TYPE_COUNT_INT_POINTER; + /* Relevant for the conversion characters a, A, e, E, f, F, g, G. */ + arg_type floatingpoint_type = TYPE_DOUBLE; + + if (*cp == 'h') + { + if (cp[1] == 'h') + { + signed_type = TYPE_SCHAR; + unsigned_type = TYPE_UCHAR; + pointer_type = TYPE_COUNT_SCHAR_POINTER; + cp += 2; + } + else + { + signed_type = TYPE_SHORT; + unsigned_type = TYPE_USHORT; + pointer_type = TYPE_COUNT_SHORT_POINTER; + cp++; + } + } + else if (*cp == 'l') + { + if (cp[1] == 'l') + { + signed_type = TYPE_LONGLONGINT; + unsigned_type = TYPE_ULONGLONGINT; + pointer_type = TYPE_COUNT_LONGLONGINT_POINTER; + /* For backward compatibility only. */ + floatingpoint_type = TYPE_LONGDOUBLE; + cp += 2; + } + else + { + signed_type = TYPE_LONGINT; + unsigned_type = TYPE_ULONGINT; + pointer_type = TYPE_COUNT_LONGINT_POINTER; + cp++; + } + } + else if (*cp == 'j') + { + if (sizeof (intmax_t) > sizeof (long)) + { + /* intmax_t = long long */ + signed_type = TYPE_LONGLONGINT; + unsigned_type = TYPE_ULONGLONGINT; + pointer_type = TYPE_COUNT_LONGLONGINT_POINTER; + /* For backward compatibility only. */ + floatingpoint_type = TYPE_LONGDOUBLE; + } + else if (sizeof (intmax_t) > sizeof (int)) + { + /* intmax_t = long */ + signed_type = TYPE_LONGINT; + unsigned_type = TYPE_ULONGINT; + pointer_type = TYPE_COUNT_LONGINT_POINTER; + } + cp++; + } + else if (*cp == 'z' || *cp == 'Z') + { + /* 'z' is standardized in ISO C 99, but glibc uses 'Z' + because the warning facility in gcc-2.95.2 understands + only 'Z' (see gcc-2.95.2/gcc/c-common.c:1784). */ + if (sizeof (size_t) > sizeof (long)) + { + /* size_t = unsigned long long */ + signed_type = TYPE_LONGLONGINT; + unsigned_type = TYPE_ULONGLONGINT; + pointer_type = TYPE_COUNT_LONGLONGINT_POINTER; + /* For backward compatibility only. */ + floatingpoint_type = TYPE_LONGDOUBLE; + } + else if (sizeof (size_t) > sizeof (int)) + { + /* size_t = unsigned long */ + signed_type = TYPE_LONGINT; + unsigned_type = TYPE_ULONGINT; + pointer_type = TYPE_COUNT_LONGINT_POINTER; + } + cp++; + } + else if (*cp == 't') + { + if (sizeof (ptrdiff_t) > sizeof (long)) + { + /* ptrdiff_t = long long */ + signed_type = TYPE_LONGLONGINT; + unsigned_type = TYPE_ULONGLONGINT; + pointer_type = TYPE_COUNT_LONGLONGINT_POINTER; + /* For backward compatibility only. */ + floatingpoint_type = TYPE_LONGDOUBLE; + } + else if (sizeof (ptrdiff_t) > sizeof (int)) + { + /* ptrdiff_t = long */ + signed_type = TYPE_LONGINT; + unsigned_type = TYPE_ULONGINT; + pointer_type = TYPE_COUNT_LONGINT_POINTER; + } + cp++; + } + else if (*cp == 'w') + { + /* wN and wfN are standardized in ISO C 23. */ + if (cp[1] == 'f') + { + if (cp[2] == '8') + { + signed_type = TYPE_INT_FAST8_T; + unsigned_type = TYPE_UINT_FAST8_T; + pointer_type = TYPE_COUNT_INT_FAST8_T_POINTER; + cp += 3; + } + else if (cp[2] == '1' && cp[3] == '6') + { + signed_type = TYPE_INT_FAST16_T; + unsigned_type = TYPE_UINT_FAST16_T; + pointer_type = TYPE_COUNT_INT_FAST16_T_POINTER; + cp += 4; + } + else if (cp[2] == '3' && cp[3] == '2') + { + signed_type = TYPE_INT_FAST32_T; + unsigned_type = TYPE_UINT_FAST32_T; + pointer_type = TYPE_COUNT_INT_FAST32_T_POINTER; + cp += 4; + } + else if (cp[2] == '6' && cp[3] == '4') + { + signed_type = TYPE_INT_FAST64_T; + unsigned_type = TYPE_UINT_FAST64_T; + pointer_type = TYPE_COUNT_INT_FAST64_T_POINTER; + cp += 4; + } + } + else + { + if (cp[1] == '8') + { + signed_type = TYPE_INT8_T; + unsigned_type = TYPE_UINT8_T; + pointer_type = TYPE_COUNT_INT8_T_POINTER; + cp += 2; + } + else if (cp[1] == '1' && cp[2] == '6') + { + signed_type = TYPE_INT16_T; + unsigned_type = TYPE_UINT16_T; + pointer_type = TYPE_COUNT_INT16_T_POINTER; + cp += 3; + } + else if (cp[1] == '3' && cp[2] == '2') + { + signed_type = TYPE_INT32_T; + unsigned_type = TYPE_UINT32_T; + pointer_type = TYPE_COUNT_INT32_T_POINTER; + cp += 3; + } + else if (cp[1] == '6' && cp[2] == '4') + { + signed_type = TYPE_INT64_T; + unsigned_type = TYPE_UINT64_T; + pointer_type = TYPE_COUNT_INT64_T_POINTER; + cp += 3; + } + } + } + else if (*cp == 'L') + { + signed_type = TYPE_LONGLONGINT; + unsigned_type = TYPE_ULONGLONGINT; + pointer_type = TYPE_COUNT_LONGLONGINT_POINTER; + floatingpoint_type = TYPE_LONGDOUBLE; + cp++; + } +#if defined __APPLE__ && defined __MACH__ + /* On Mac OS X 10.3, PRIdMAX is defined as "qd". + We cannot change it to "lld" because PRIdMAX must also + be understood by the system's printf routines. */ + else if (*cp == 'q') + { + if (64 / 8 > sizeof (long)) + { + /* int64_t = long long */ + signed_type = TYPE_LONGLONGINT; + unsigned_type = TYPE_ULONGLONGINT; + pointer_type = TYPE_COUNT_LONGLONGINT_POINTER; + /* For backward compatibility only. */ + floatingpoint_type = TYPE_LONGDOUBLE; + } + else + { + /* int64_t = long */ + signed_type = TYPE_LONGINT; + unsigned_type = TYPE_ULONGINT; + pointer_type = TYPE_COUNT_LONGINT_POINTER; + } + cp++; + } +#endif +#if defined _WIN32 && ! defined __CYGWIN__ + /* On native Windows, PRIdMAX is defined as "I64d". + We cannot change it to "lld" because PRIdMAX must also + be understood by the system's printf routines. */ + else if (*cp == 'I' && cp[1] == '6' && cp[2] == '4') + { + if (64 / 8 > sizeof (long)) + { + /* __int64_t = long long */ + signed_type = TYPE_LONGLONGINT; + unsigned_type = TYPE_ULONGLONGINT; + pointer_type = TYPE_COUNT_LONGLONGINT_POINTER; + /* For backward compatibility only. */ + floatingpoint_type = TYPE_LONGDOUBLE; + } + else + { + /* __int64_t = long */ + signed_type = TYPE_LONGINT; + unsigned_type = TYPE_ULONGINT; + pointer_type = TYPE_COUNT_LONGINT_POINTER; + } + cp += 3; + } +#endif + + /* Read the conversion character. */ + c = *cp++; + switch (c) + { + case 'd': case 'i': + type = signed_type; + break; + case 'b': case 'o': case 'u': case 'x': case 'X': + #if SUPPORT_GNU_PRINTF_DIRECTIVES \ + || (__GLIBC__ + (__GLIBC_MINOR__ >= 35) > 2) + case 'B': + #endif + type = unsigned_type; + break; + case 'f': case 'F': case 'e': case 'E': case 'g': case 'G': + case 'a': case 'A': + type = floatingpoint_type; + break; + case 'c': + if (signed_type == TYPE_LONGINT + /* For backward compatibility only. */ + || signed_type == TYPE_LONGLONGINT) +#if HAVE_WINT_T + type = TYPE_WIDE_CHAR; +#else + goto error; +#endif + else + type = TYPE_CHAR; + break; +#if HAVE_WINT_T + case 'C': + type = TYPE_WIDE_CHAR; + c = 'c'; + break; +#endif + case 's': + if (signed_type == TYPE_LONGINT + /* For backward compatibility only. */ + || signed_type == TYPE_LONGLONGINT) +#if HAVE_WCHAR_T + type = TYPE_WIDE_STRING; +#else + goto error; +#endif + else + type = TYPE_STRING; + break; +#if HAVE_WCHAR_T + case 'S': + type = TYPE_WIDE_STRING; + c = 's'; + break; +#endif + case 'p': + type = TYPE_POINTER; + break; + case 'n': + type = pointer_type; + break; +#if ENABLE_UNISTDIO + /* The unistdio extensions. */ + case 'U': + if (signed_type == TYPE_LONGLONGINT) + type = TYPE_U32_STRING; + else if (signed_type == TYPE_LONGINT) + type = TYPE_U16_STRING; + else + type = TYPE_U8_STRING; + break; +#endif + case '%': + type = TYPE_NONE; + break; + default: + /* Unknown conversion character. */ + goto error; + } + + if (type != TYPE_NONE) + { + dp->arg_index = arg_index; + if (dp->arg_index == ARG_NONE) + { + dp->arg_index = arg_posn++; + if (dp->arg_index == ARG_NONE) + /* arg_posn wrapped around. */ + goto error; + } + REGISTER_ARG (dp->arg_index, type); + } + dp->conversion = c; + dp->dir_end = cp; + } + + d->count++; + if (d->count >= d_allocated) + { + size_t memory_size; + DIRECTIVE *memory; + + d_allocated = xtimes (d_allocated, 2); + memory_size = xtimes (d_allocated, sizeof (DIRECTIVE)); + if (size_overflow_p (memory_size)) + /* Overflow, would lead to out of memory. */ + goto out_of_memory; + memory = (DIRECTIVE *) (d->dir != d->direct_alloc_dir + ? realloc (d->dir, memory_size) + : malloc (memory_size)); + if (memory == NULL) + /* Out of memory. */ + goto out_of_memory; + if (d->dir == d->direct_alloc_dir) + memcpy (memory, d->dir, d->count * sizeof (DIRECTIVE)); + d->dir = memory; + } + } +#if CHAR_T_ONLY_ASCII + else if (!c_isascii (c)) + { + /* Non-ASCII character. Not supported. */ + goto error; + } +#endif + } + d->dir[d->count].dir_start = cp; + + d->max_width_length = max_width_length; + d->max_precision_length = max_precision_length; + return 0; + +error: + if (a->arg != a->direct_alloc_arg) + free (a->arg); + if (d->dir != d->direct_alloc_dir) + free (d->dir); + errno = EINVAL; + return -1; + +out_of_memory: + if (a->arg != a->direct_alloc_arg) + free (a->arg); + if (d->dir != d->direct_alloc_dir) + free (d->dir); + errno = ENOMEM; + return -1; +} + +#undef PRINTF_PARSE +#undef DIRECTIVES +#undef DIRECTIVE +#undef CHAR_T_ONLY_ASCII +#undef CHAR_T diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/printf-parse.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/printf-parse.h new file mode 100644 index 00000000..949b8754 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/printf-parse.h @@ -0,0 +1,193 @@ +/* Parse printf format string. + Copyright (C) 1999, 2002-2003, 2005, 2007, 2010-2024 Free Software + Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef _PRINTF_PARSE_H +#define _PRINTF_PARSE_H + +/* This file can be parametrized with the following macros: + ENABLE_UNISTDIO Set to 1 to enable the unistdio extensions. + STATIC Set to 'static' to declare the function static. */ + +#if HAVE_FEATURES_H +# include /* for __GLIBC__, __UCLIBC__ */ +#endif + +#include "printf-args.h" + + +/* Flags */ +#define FLAG_GROUP 1 /* ' flag */ +#define FLAG_LEFT 2 /* - flag */ +#define FLAG_SHOWSIGN 4 /* + flag */ +#define FLAG_SPACE 8 /* space flag */ +#define FLAG_ALT 16 /* # flag */ +#define FLAG_ZERO 32 +#if __GLIBC__ >= 2 && !defined __UCLIBC__ +# define FLAG_LOCALIZED 64 /* I flag, uses localized digits */ +#endif + +/* arg_index value indicating that no argument is consumed. */ +#define ARG_NONE (~(size_t)0) + +/* xxx_directive: A parsed directive. + xxx_directives: A parsed format string. */ + +/* Number of directly allocated directives (no malloc() needed). */ +#define N_DIRECT_ALLOC_DIRECTIVES 7 + +/* A parsed directive. */ +typedef struct +{ + const char* dir_start; + const char* dir_end; + int flags; + const char* width_start; + const char* width_end; + size_t width_arg_index; + const char* precision_start; + const char* precision_end; + size_t precision_arg_index; + char conversion; /* d i b B o u x X f F e E g G a A c s p n U % but not C S */ + size_t arg_index; +} +char_directive; + +/* A parsed format string. */ +typedef struct +{ + size_t count; + char_directive *dir; + size_t max_width_length; + size_t max_precision_length; + char_directive direct_alloc_dir[N_DIRECT_ALLOC_DIRECTIVES]; +} +char_directives; + +#if ENABLE_UNISTDIO + +/* A parsed directive. */ +typedef struct +{ + const uint8_t* dir_start; + const uint8_t* dir_end; + int flags; + const uint8_t* width_start; + const uint8_t* width_end; + size_t width_arg_index; + const uint8_t* precision_start; + const uint8_t* precision_end; + size_t precision_arg_index; + uint8_t conversion; /* d i b B o u x X f F e E g G a A c s p n U % but not C S */ + size_t arg_index; +} +u8_directive; + +/* A parsed format string. */ +typedef struct +{ + size_t count; + u8_directive *dir; + size_t max_width_length; + size_t max_precision_length; + u8_directive direct_alloc_dir[N_DIRECT_ALLOC_DIRECTIVES]; +} +u8_directives; + +/* A parsed directive. */ +typedef struct +{ + const uint16_t* dir_start; + const uint16_t* dir_end; + int flags; + const uint16_t* width_start; + const uint16_t* width_end; + size_t width_arg_index; + const uint16_t* precision_start; + const uint16_t* precision_end; + size_t precision_arg_index; + uint16_t conversion; /* d i b B o u x X f F e E g G a A c s p n U % but not C S */ + size_t arg_index; +} +u16_directive; + +/* A parsed format string. */ +typedef struct +{ + size_t count; + u16_directive *dir; + size_t max_width_length; + size_t max_precision_length; + u16_directive direct_alloc_dir[N_DIRECT_ALLOC_DIRECTIVES]; +} +u16_directives; + +/* A parsed directive. */ +typedef struct +{ + const uint32_t* dir_start; + const uint32_t* dir_end; + int flags; + const uint32_t* width_start; + const uint32_t* width_end; + size_t width_arg_index; + const uint32_t* precision_start; + const uint32_t* precision_end; + size_t precision_arg_index; + uint32_t conversion; /* d i b B o u x X f F e E g G a A c s p n U % but not C S */ + size_t arg_index; +} +u32_directive; + +/* A parsed format string. */ +typedef struct +{ + size_t count; + u32_directive *dir; + size_t max_width_length; + size_t max_precision_length; + u32_directive direct_alloc_dir[N_DIRECT_ALLOC_DIRECTIVES]; +} +u32_directives; + +#endif + + +/* Parses the format string. Fills in the number N of directives, and fills + in directives[0], ..., directives[N-1], and sets directives[N].dir_start + to the end of the format string. Also fills in the arg_type fields of the + arguments and the needed count of arguments. */ +#if ENABLE_UNISTDIO +extern int + ulc_printf_parse (const char *format, char_directives *d, arguments *a); +extern int + u8_printf_parse (const uint8_t *format, u8_directives *d, arguments *a); +extern int + u16_printf_parse (const uint16_t *format, u16_directives *d, + arguments *a); +extern int + u32_printf_parse (const uint32_t *format, u32_directives *d, + arguments *a); +#else +# ifdef STATIC +STATIC +# else +extern +# endif +int printf_parse (const char *format, char_directives *d, arguments *a); +#endif + +#endif /* _PRINTF_PARSE_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/priv-set.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/priv-set.c new file mode 100644 index 00000000..2731bc96 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/priv-set.c @@ -0,0 +1,144 @@ +/* Query, remove, or restore a Solaris privilege. + + Copyright (C) 2009-2024 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 . + + Written by David Bartley. */ + +#include + +#define PRIV_SET_INLINE _GL_EXTERN_INLINE + +#include "priv-set.h" + +#if HAVE_GETPPRIV && HAVE_PRIV_H + +# include +# include + +/* Holds a (cached) copy of the effective set. */ +static priv_set_t *eff_set; + +/* Holds a set of privileges that we have removed. */ +static priv_set_t *rem_set; + +static bool initialized; + +static int +priv_set_initialize (void) +{ + if (! initialized) + { + eff_set = priv_allocset (); + if (!eff_set) + { + return -1; + } + rem_set = priv_allocset (); + if (!rem_set) + { + priv_freeset (eff_set); + return -1; + } + if (getppriv (PRIV_EFFECTIVE, eff_set) != 0) + { + priv_freeset (eff_set); + priv_freeset (rem_set); + return -1; + } + priv_emptyset (rem_set); + initialized = true; + } + + return 0; +} + + +/* Check if priv is in the effective set. + Returns 1 if priv is a member and 0 if not. + Returns -1 on error with errno set appropriately. */ +int +priv_set_ismember (const char *priv) +{ + if (! initialized && priv_set_initialize () != 0) + return -1; + + return priv_ismember (eff_set, priv); +} + + +/* Try to remove priv from the effective set. + Returns 0 if priv was removed. + Returns -1 on error with errno set appropriately. */ +int +priv_set_remove (const char *priv) +{ + if (! initialized && priv_set_initialize () != 0) + return -1; + + if (priv_ismember (eff_set, priv)) + { + /* priv_addset/priv_delset can only fail if priv is invalid, which is + checked above by the priv_ismember call. */ + priv_delset (eff_set, priv); + if (setppriv (PRIV_SET, PRIV_EFFECTIVE, eff_set) != 0) + { + priv_addset (eff_set, priv); + return -1; + } + priv_addset (rem_set, priv); + } + else + { + errno = EINVAL; + return -1; + } + + return 0; +} + + +/* Try to restore priv to the effective set. + Returns 0 if priv was re-added to the effective set (after being previously + removed by a call to priv_set_remove). + Returns -1 on error with errno set appropriately. */ +int +priv_set_restore (const char *priv) +{ + if (! initialized && priv_set_initialize () != 0) + return -1; + + if (priv_ismember (rem_set, priv)) + { + /* priv_addset/priv_delset can only fail if priv is invalid, which is + checked above by the priv_ismember call. */ + priv_addset (eff_set, priv); + if (setppriv (PRIV_SET, PRIV_EFFECTIVE, eff_set) != 0) + { + priv_delset (eff_set, priv); + return -1; + } + priv_delset (rem_set, priv); + } + else + { + errno = EINVAL; + return -1; + } + + return 0; +} + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/priv-set.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/priv-set.h new file mode 100644 index 00000000..3f040e9e --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/priv-set.h @@ -0,0 +1,67 @@ +/* Query, remove, or restore a Solaris privilege. + + Copyright (C) 2009-2024 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 . + + Written by David Bartley. */ + +/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, HAVE_PRIV_H, + HAVE_GETPPRIV. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +_GL_INLINE_HEADER_BEGIN +#ifndef PRIV_SET_INLINE +# define PRIV_SET_INLINE _GL_INLINE +#endif + +#if HAVE_GETPPRIV && HAVE_PRIV_H + +# include + +int priv_set_ismember (const char *priv); +int priv_set_remove (const char *priv); +int priv_set_restore (const char *priv); + +PRIV_SET_INLINE int +priv_set_remove_linkdir (void) +{ + return priv_set_remove (PRIV_SYS_LINKDIR); +} + +PRIV_SET_INLINE int +priv_set_restore_linkdir (void) +{ + return priv_set_restore (PRIV_SYS_LINKDIR); +} + +#else + +PRIV_SET_INLINE int +priv_set_remove_linkdir (void) +{ + return -1; +} + +PRIV_SET_INLINE int +priv_set_restore_linkdir (void) +{ + return -1; +} + +#endif + +_GL_INLINE_HEADER_END diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/pselect.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/pselect.c new file mode 100644 index 00000000..54732e5c --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/pselect.c @@ -0,0 +1,118 @@ +/* pselect - synchronous I/O multiplexing + + Copyright 2011-2024 Free Software Foundation, Inc. + + This file is part of gnulib. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* written by Paul Eggert */ + +#include + +#include + +#include +#include + +/* Examine the size-NFDS file descriptor sets in RFDS, WFDS, and XFDS + to see whether some of their descriptors are ready for reading, + ready for writing, or have exceptions pending. Wait for at most + TIMEOUT seconds, and use signal mask SIGMASK while waiting. A null + pointer parameter stands for no descriptors, an infinite timeout, + or an unaffected signal mask. */ + +#if !HAVE_PSELECT + +int +pselect (int nfds, fd_set *restrict rfds, + fd_set *restrict wfds, fd_set *restrict xfds, + struct timespec const *restrict timeout, + sigset_t const *restrict sigmask) +{ + int select_result; + sigset_t origmask; + struct timeval tv, *tvp; + + if (nfds < 0 || nfds > FD_SETSIZE) + { + errno = EINVAL; + return -1; + } + + if (timeout) + { + if (! (0 <= timeout->tv_nsec && timeout->tv_nsec < 1000000000)) + { + errno = EINVAL; + return -1; + } + + tv = (struct timeval) { + .tv_sec = timeout->tv_sec, + .tv_usec = (timeout->tv_nsec + 999) / 1000 + }; + tvp = &tv; + } + else + tvp = NULL; + + /* Signal mask munging should be atomic, but this is the best we can + do in this emulation. */ + if (sigmask) + pthread_sigmask (SIG_SETMASK, sigmask, &origmask); + + select_result = select (nfds, rfds, wfds, xfds, tvp); + + if (sigmask) + { + int select_errno = errno; + pthread_sigmask (SIG_SETMASK, &origmask, NULL); + errno = select_errno; + } + + return select_result; +} + +#else /* HAVE_PSELECT */ +# include +# undef pselect + +int +rpl_pselect (int nfds, fd_set *restrict rfds, + fd_set *restrict wfds, fd_set *restrict xfds, + struct timespec const *restrict timeout, + sigset_t const *restrict sigmask) +{ + int i; + + /* FreeBSD 8.2 has a bug: it does not always detect invalid fds. */ + if (nfds < 0 || nfds > FD_SETSIZE) + { + errno = EINVAL; + return -1; + } + for (i = 0; i < nfds; i++) + { + if (((rfds && FD_ISSET (i, rfds)) + || (wfds && FD_ISSET (i, wfds)) + || (xfds && FD_ISSET (i, xfds))) + && dup2 (i, i) != i) + return -1; + } + + return pselect (nfds, rfds, wfds, xfds, timeout, sigmask); +} + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/pthread-thread.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/pthread-thread.c new file mode 100644 index 00000000..b81748d1 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/pthread-thread.c @@ -0,0 +1,178 @@ +/* Creating and controlling POSIX threads. + Copyright (C) 2010-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Paul Eggert, 2010, and Bruno Haible , 2019. */ + +#include + +/* Specification. */ +#include + +#if (defined _WIN32 && ! defined __CYGWIN__) && USE_WINDOWS_THREADS +# include "windows-thread.h" +#else +# include +#endif + +typedef void * (* pthread_main_function_t) (void *); + +#if ((defined _WIN32 && ! defined __CYGWIN__) && USE_WINDOWS_THREADS) || !HAVE_PTHREAD_H + +int +pthread_attr_init (pthread_attr_t *attr) +{ + *attr = PTHREAD_CREATE_JOINABLE; + return 0; +} + +int +pthread_attr_getdetachstate (const pthread_attr_t *attr, int *detachstatep) +{ + *detachstatep = *attr & (PTHREAD_CREATE_JOINABLE | PTHREAD_CREATE_DETACHED); + return 0; +} + +int +pthread_attr_setdetachstate (pthread_attr_t *attr, int detachstate) +{ + if (!(detachstate == PTHREAD_CREATE_JOINABLE + || detachstate == PTHREAD_CREATE_DETACHED)) + return EINVAL; + *attr ^= (*attr ^ detachstate) + & (PTHREAD_CREATE_JOINABLE | PTHREAD_CREATE_DETACHED); + return 0; +} + +int +pthread_attr_destroy (_GL_UNUSED pthread_attr_t *attr) +{ + return 0; +} + +#endif + +#if (defined _WIN32 && ! defined __CYGWIN__) && USE_WINDOWS_THREADS +/* Use Windows threads. */ + +int +pthread_create (pthread_t *threadp, const pthread_attr_t *attr, + pthread_main_function_t mainfunc, void *arg) +{ + unsigned int glwthread_attr = + (attr != NULL + && (*attr & (PTHREAD_CREATE_JOINABLE | PTHREAD_CREATE_DETACHED)) + != PTHREAD_CREATE_JOINABLE + ? GLWTHREAD_ATTR_DETACHED + : 0); + return glwthread_thread_create (threadp, glwthread_attr, mainfunc, arg); +} + +pthread_t +pthread_self (void) +{ + return glwthread_thread_self (); +} + +int +pthread_equal (pthread_t thread1, pthread_t thread2) +{ + return thread1 == thread2; +} + +int +pthread_detach (pthread_t thread) +{ + return glwthread_thread_detach (thread); +} + +int +pthread_join (pthread_t thread, void **valuep) +{ + return glwthread_thread_join (thread, valuep); +} + +void +pthread_exit (void *value) +{ + glwthread_thread_exit (value); +} + +#elif HAVE_PTHREAD_H +/* Provide workarounds for POSIX threads. */ + +# if PTHREAD_CREATE_IS_INLINE +int +pthread_create (pthread_t *threadp, const pthread_attr_t *attr, + pthread_main_function_t mainfunc, void *arg) +# undef pthread_create +{ + return pthread_create (threadp, attr, mainfunc, arg); +} + +int +pthread_attr_init (pthread_attr_t *attr) +# undef pthread_attr_init +{ + return pthread_attr_init (attr); +} + +# endif + +#else +/* Provide a dummy implementation for single-threaded applications. */ + +int +pthread_create (pthread_t *threadp, const pthread_attr_t *attr, + pthread_main_function_t mainfunc, void *arg) +{ + /* The maximum number of threads is reached. Do not create a thread. */ + return EAGAIN; +} + +pthread_t +pthread_self (void) +{ + return 42; +} + +int +pthread_equal (pthread_t thread1, pthread_t thread2) +{ + return thread1 == thread2; +} + +int +pthread_detach (pthread_t thread) +{ + /* There are no joinable threads. */ + return EINVAL; +} + +int +pthread_join (pthread_t thread, void **valuep) +{ + /* There are no joinable threads. */ + return EINVAL; +} + +void +pthread_exit (void *value) +{ + /* There is just one thread, so the process exits. */ + exit (0); +} + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/pthread.in.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/pthread.in.h new file mode 100644 index 00000000..cd705fbd --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/pthread.in.h @@ -0,0 +1,2022 @@ +/* Implement the most essential subset of POSIX 1003.1-2008 pthread.h. + + Copyright (C) 2009-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Paul Eggert, Glen Lenker, and Bruno Haible. */ + +#if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +#endif +@PRAGMA_COLUMNS@ + +#if defined _GL_ALREADY_INCLUDING_PTHREAD_H +/* Special invocation convention: + On Android, we have a sequence of nested includes + -> -> -> -> + -> . + In this situation, PTHREAD_COND_INITIALIZER is not yet defined, + therefore we should not attempt to define PTHREAD_MUTEX_NORMAL etc. */ + +#@INCLUDE_NEXT@ @NEXT_PTHREAD_H@ + +#else +/* Normal invocation convention. */ + +#ifndef _@GUARD_PREFIX@_PTHREAD_H_ + +#if @HAVE_PTHREAD_H@ + +# define _GL_ALREADY_INCLUDING_PTHREAD_H + +/* The include_next requires a split double-inclusion guard. */ +# @INCLUDE_NEXT@ @NEXT_PTHREAD_H@ + +# undef _GL_ALREADY_INCLUDING_PTHREAD_H + +#endif + +#ifndef _@GUARD_PREFIX@_PTHREAD_H_ +#define _@GUARD_PREFIX@_PTHREAD_H_ + +/* This file uses _Noreturn, _GL_ATTRIBUTE_PURE, GNULIB_POSIXCHECK, + HAVE_RAW_DECL_*. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +#define __need_system_stdlib_h +#include +#undef __need_system_stdlib_h + + +/* The pthreads-win32 defines a couple of broken macros. */ +#undef asctime_r +#undef ctime_r +#undef gmtime_r +#undef localtime_r +#undef rand_r +#undef strtok_r + +#include +#include +#include +#include + +/* The __attribute__ feature is available in gcc versions 2.5 and later. + The attribute __pure__ was added in gcc 2.96. */ +#ifndef _GL_ATTRIBUTE_PURE +# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined __clang__ +# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) +# else +# define _GL_ATTRIBUTE_PURE /* empty */ +# endif +#endif + +/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ + +/* The definition of _Noreturn is copied here. */ + +/* The definition of _GL_ARG_NONNULL is copied here. */ + +/* The definition of _GL_WARN_ON_USE is copied here. */ + +/* =========== Thread types and macros =========== */ + +#if (defined _WIN32 && ! defined __CYGWIN__) && USE_WINDOWS_THREADS +# if @GNULIB_PTHREAD_THREAD@ +# include "windows-thread.h" +# if @HAVE_PTHREAD_T@ +# define pthread_t rpl_pthread_t +# define pthread_attr_t rpl_pthread_attr_t +# endif +# if !GNULIB_defined_pthread_thread_types +typedef glwthread_thread_t pthread_t; +typedef unsigned int pthread_attr_t; +# define GNULIB_defined_pthread_thread_types 1 +# endif +# else +# if @HAVE_PTHREAD_T@ +# define pthread_t rpl_pthread_t +# define pthread_attr_t rpl_pthread_attr_t +# endif +# if !GNULIB_defined_pthread_thread_types +typedef int pthread_t; +typedef unsigned int pthread_attr_t; +# define GNULIB_defined_pthread_thread_types 1 +# endif +# endif +# undef PTHREAD_CREATE_JOINABLE +# undef PTHREAD_CREATE_DETACHED +# define PTHREAD_CREATE_JOINABLE 0 +# define PTHREAD_CREATE_DETACHED 1 +#else +# if !@HAVE_PTHREAD_T@ +# if !GNULIB_defined_pthread_thread_types +typedef int pthread_t; +typedef unsigned int pthread_attr_t; +# define GNULIB_defined_pthread_thread_types 1 +# endif +# endif +# if !@HAVE_PTHREAD_CREATE_DETACHED@ +# define PTHREAD_CREATE_JOINABLE 0 +# define PTHREAD_CREATE_DETACHED 1 +# endif +#endif + +/* =========== Once-only control (initialization) types and macros ========== */ + +#if (defined _WIN32 && ! defined __CYGWIN__) && USE_WINDOWS_THREADS +# if @GNULIB_PTHREAD_ONCE@ +# include "windows-once.h" +# if @HAVE_PTHREAD_T@ +# define pthread_once_t rpl_pthread_once_t +# endif +# if !GNULIB_defined_pthread_once_types +typedef glwthread_once_t pthread_once_t; +# define GNULIB_defined_pthread_once_types 1 +# endif +# undef PTHREAD_ONCE_INIT +# define PTHREAD_ONCE_INIT GLWTHREAD_ONCE_INIT +# else +# if @HAVE_PTHREAD_T@ +# define pthread_once_t rpl_pthread_once_t +# endif +# if !GNULIB_defined_pthread_once_types +typedef int pthread_once_t; +# define GNULIB_defined_pthread_once_types 1 +# endif +# undef PTHREAD_ONCE_INIT +# define PTHREAD_ONCE_INIT { 0 } +# endif +#else +# if !@HAVE_PTHREAD_T@ +# if !GNULIB_defined_pthread_once_types +typedef int pthread_once_t; +# define GNULIB_defined_pthread_once_types 1 +# endif +# undef PTHREAD_ONCE_INIT +# define PTHREAD_ONCE_INIT { 0 } +# endif +#endif + +/* =========== Mutex types and macros =========== */ + +#if (defined _WIN32 && ! defined __CYGWIN__) && USE_WINDOWS_THREADS +# if @GNULIB_PTHREAD_MUTEX@ +# include "windows-timedmutex.h" +# include "windows-timedrecmutex.h" +# if @HAVE_PTHREAD_T@ +# define pthread_mutex_t rpl_pthread_mutex_t +# define pthread_mutexattr_t rpl_pthread_mutexattr_t +# endif +# if !GNULIB_defined_pthread_mutex_types +typedef struct + { + int type; + union + { + glwthread_timedmutex_t u_timedmutex; + glwthread_timedrecmutex_t u_timedrecmutex; + } + u; + } + pthread_mutex_t; +typedef unsigned int pthread_mutexattr_t; +# define GNULIB_defined_pthread_mutex_types 1 +# endif +# undef PTHREAD_MUTEX_INITIALIZER +# define PTHREAD_MUTEX_INITIALIZER { 1, { GLWTHREAD_TIMEDMUTEX_INIT } } +# else +# if @HAVE_PTHREAD_T@ +# define pthread_mutex_t rpl_pthread_mutex_t +# define pthread_mutexattr_t rpl_pthread_mutexattr_t +# endif +# if !GNULIB_defined_pthread_mutex_types +typedef int pthread_mutex_t; +typedef unsigned int pthread_mutexattr_t; +# define GNULIB_defined_pthread_mutex_types 1 +# endif +# undef PTHREAD_MUTEX_INITIALIZER +# define PTHREAD_MUTEX_INITIALIZER { 0 } +# endif +# undef PTHREAD_MUTEX_DEFAULT +# undef PTHREAD_MUTEX_NORMAL +# undef PTHREAD_MUTEX_ERRORCHECK +# undef PTHREAD_MUTEX_RECURSIVE +# define PTHREAD_MUTEX_DEFAULT PTHREAD_MUTEX_NORMAL +# define PTHREAD_MUTEX_NORMAL 0 +# define PTHREAD_MUTEX_ERRORCHECK 1 +# define PTHREAD_MUTEX_RECURSIVE 2 +# undef PTHREAD_MUTEX_STALLED +# undef PTHREAD_MUTEX_ROBUST +# define PTHREAD_MUTEX_STALLED 0 +# define PTHREAD_MUTEX_ROBUST 1 +#else +# if !@HAVE_PTHREAD_T@ +# if !GNULIB_defined_pthread_mutex_types +typedef int pthread_mutex_t; +typedef unsigned int pthread_mutexattr_t; +# define GNULIB_defined_pthread_mutex_types 1 +# endif +# undef PTHREAD_MUTEX_INITIALIZER +# define PTHREAD_MUTEX_INITIALIZER { 0 } +# endif +# if !@HAVE_PTHREAD_MUTEX_RECURSIVE@ +# define PTHREAD_MUTEX_DEFAULT PTHREAD_MUTEX_NORMAL +# define PTHREAD_MUTEX_NORMAL 0 +# define PTHREAD_MUTEX_ERRORCHECK 1 +# define PTHREAD_MUTEX_RECURSIVE 2 +# endif +# if !@HAVE_PTHREAD_MUTEX_ROBUST@ +# define PTHREAD_MUTEX_STALLED 0 +# define PTHREAD_MUTEX_ROBUST 1 +# endif +#endif + +/* =========== Read-write lock types and macros =========== */ + +#if (defined _WIN32 && ! defined __CYGWIN__) && USE_WINDOWS_THREADS +# if @GNULIB_PTHREAD_RWLOCK@ +# include "windows-timedrwlock.h" +# if @HAVE_PTHREAD_T@ +# define pthread_rwlock_t rpl_pthread_rwlock_t +# define pthread_rwlockattr_t rpl_pthread_rwlockattr_t +# endif +# if !GNULIB_defined_pthread_rwlock_types +typedef glwthread_timedrwlock_t pthread_rwlock_t; +typedef unsigned int pthread_rwlockattr_t; +# define GNULIB_defined_pthread_rwlock_types 1 +# endif +# undef PTHREAD_RWLOCK_INITIALIZER +# define PTHREAD_RWLOCK_INITIALIZER GLWTHREAD_TIMEDRWLOCK_INIT +# else +# if @HAVE_PTHREAD_T@ +# define pthread_rwlock_t rpl_pthread_rwlock_t +# define pthread_rwlockattr_t rpl_pthread_rwlockattr_t +# endif +# if !GNULIB_defined_pthread_rwlock_types +typedef int pthread_rwlock_t; +typedef unsigned int pthread_rwlockattr_t; +# define GNULIB_defined_pthread_rwlock_types 1 +# endif +# undef PTHREAD_RWLOCK_INITIALIZER +# define PTHREAD_RWLOCK_INITIALIZER { 0 } +# endif +#elif @GNULIB_PTHREAD_RWLOCK@ && @REPLACE_PTHREAD_RWLOCK_INIT@ /* i.e. PTHREAD_RWLOCK_UNIMPLEMENTED */ +# if @HAVE_PTHREAD_T@ +# define pthread_rwlock_t rpl_pthread_rwlock_t +# define pthread_rwlockattr_t rpl_pthread_rwlockattr_t +# endif +# if !GNULIB_defined_pthread_rwlock_types +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 */ + } + pthread_rwlock_t; +typedef unsigned int pthread_rwlockattr_t; +# define GNULIB_defined_pthread_rwlock_types 1 +# endif +# undef PTHREAD_RWLOCK_INITIALIZER +# define PTHREAD_RWLOCK_INITIALIZER \ + { PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, PTHREAD_COND_INITIALIZER, 0, 0 } +#else +# if @HAVE_PTHREAD_T@ +# if !defined PTHREAD_RWLOCK_INITIALIZER && defined PTHREAD_RWLOCK_INITIALIZER_NP /* z/OS */ +# define PTHREAD_RWLOCK_INITIALIZER PTHREAD_RWLOCK_INITIALIZER_NP +# endif +# else +# if !GNULIB_defined_pthread_rwlock_types +typedef int pthread_rwlock_t; +typedef unsigned int pthread_rwlockattr_t; +# define GNULIB_defined_pthread_rwlock_types 1 +# endif +# undef PTHREAD_RWLOCK_INITIALIZER +# define PTHREAD_RWLOCK_INITIALIZER { 0 } +# endif +#endif + +/* =========== Condition variable types and macros =========== */ + +#if (defined _WIN32 && ! defined __CYGWIN__) && USE_WINDOWS_THREADS +# if @GNULIB_PTHREAD_COND@ +# include "windows-cond.h" +# if @HAVE_PTHREAD_T@ +# define pthread_cond_t rpl_pthread_cond_t +# define pthread_condattr_t rpl_pthread_condattr_t +# endif +# if !GNULIB_defined_pthread_cond_types +typedef glwthread_cond_t pthread_cond_t; +typedef unsigned int pthread_condattr_t; +# define GNULIB_defined_pthread_cond_types 1 +# endif +# undef PTHREAD_COND_INITIALIZER +# define PTHREAD_COND_INITIALIZER GLWTHREAD_COND_INIT +# else +# if @HAVE_PTHREAD_T@ +# define pthread_cond_t rpl_pthread_cond_t +# define pthread_condattr_t rpl_pthread_condattr_t +# endif +# if !GNULIB_defined_pthread_cond_types +typedef int pthread_cond_t; +typedef unsigned int pthread_condattr_t; +# define GNULIB_defined_pthread_cond_types 1 +# endif +# undef PTHREAD_COND_INITIALIZER +# define PTHREAD_COND_INITIALIZER { 0 } +# endif +#else +# if !@HAVE_PTHREAD_T@ +# if !GNULIB_defined_pthread_cond_types +typedef int pthread_cond_t; +typedef unsigned int pthread_condattr_t; +# define GNULIB_defined_pthread_cond_types 1 +# endif +# undef PTHREAD_COND_INITIALIZER +# define PTHREAD_COND_INITIALIZER { 0 } +# endif +#endif + +/* =========== Thread-specific storage types and macros =========== */ + +#if (defined _WIN32 && ! defined __CYGWIN__) && USE_WINDOWS_THREADS +# if @GNULIB_PTHREAD_TSS@ +# include "windows-tls.h" +# if @HAVE_PTHREAD_T@ +# define pthread_key_t rpl_pthread_key_t +# endif +# if !GNULIB_defined_pthread_tss_types +typedef glwthread_tls_key_t pthread_key_t; +# define GNULIB_defined_pthread_tss_types 1 +# endif +# undef PTHREAD_DESTRUCTOR_ITERATIONS +# define PTHREAD_DESTRUCTOR_ITERATIONS GLWTHREAD_DESTRUCTOR_ITERATIONS +# else +# if @HAVE_PTHREAD_T@ +# define pthread_key_t rpl_pthread_key_t +# endif +# if !GNULIB_defined_pthread_tss_types +typedef void ** pthread_key_t; +# define GNULIB_defined_pthread_tss_types 1 +# endif +# undef PTHREAD_DESTRUCTOR_ITERATIONS +# define PTHREAD_DESTRUCTOR_ITERATIONS 0 +# endif +#else +# if !@HAVE_PTHREAD_T@ +# if !GNULIB_defined_pthread_tss_types +typedef void ** pthread_key_t; +# define GNULIB_defined_pthread_tss_types 1 +# endif +# undef PTHREAD_DESTRUCTOR_ITERATIONS +# define PTHREAD_DESTRUCTOR_ITERATIONS 0 +# endif +#endif + +/* =========== Spinlock types and macros =========== */ + +#if (defined _WIN32 && ! defined __CYGWIN__) && USE_WINDOWS_THREADS +# if @GNULIB_PTHREAD_SPIN@ +# include "windows-spin.h" +# if @HAVE_PTHREAD_T@ +# define pthread_spinlock_t rpl_pthread_spinlock_t +# endif +# if !GNULIB_defined_pthread_spin_types +typedef glwthread_spinlock_t pthread_spinlock_t; +# define GNULIB_defined_pthread_spin_types 1 +# endif +# else +# if @HAVE_PTHREAD_T@ +# define pthread_spinlock_t rpl_pthread_spinlock_t +# endif +# if !GNULIB_defined_pthread_spin_types +typedef pthread_mutex_t pthread_spinlock_t; +# define GNULIB_defined_pthread_spin_types 1 +# endif +# endif +# undef PTHREAD_PROCESS_PRIVATE +# undef PTHREAD_PROCESS_SHARED +# define PTHREAD_PROCESS_PRIVATE 0 +# define PTHREAD_PROCESS_SHARED 1 +#else +# if @HAVE_PTHREAD_SPINLOCK_T@ +/* exists and defines pthread_spinlock_t. */ +# if !(((__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7) \ + || __clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 1)) \ + || (((__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) \ + && !defined __ANDROID__) \ + || __clang_major__ >= 3)) \ + && !defined __ibmxl__) +/* We can't use GCC built-ins. Approximate spinlocks with mutexes. */ +# if !GNULIB_defined_pthread_spin_types +# define pthread_spinlock_t pthread_mutex_t +# define GNULIB_defined_pthread_spin_types 1 +# endif +# endif +# else +/* Approximate spinlocks with mutexes. */ +# if !GNULIB_defined_pthread_spin_types +typedef pthread_mutex_t pthread_spinlock_t; +# define GNULIB_defined_pthread_spin_types 1 +# endif +# endif +# if !@HAVE_PTHREAD_PROCESS_SHARED@ +# define PTHREAD_PROCESS_PRIVATE 0 +# define PTHREAD_PROCESS_SHARED 1 +# endif +#endif + +/* =========== Other types and macros =========== */ + +#if !@HAVE_PTHREAD_T@ +# if !GNULIB_defined_other_pthread_types +typedef int pthread_barrier_t; +typedef unsigned int pthread_barrierattr_t; +# define GNULIB_defined_other_pthread_types 1 +# endif +#endif + +#if !defined PTHREAD_CANCELED + +# define PTHREAD_BARRIER_SERIAL_THREAD (-1) + +# define PTHREAD_CANCEL_DEFERRED 0 +# define PTHREAD_CANCEL_ASYNCHRONOUS 1 + +# define PTHREAD_CANCEL_ENABLE 0 +# define PTHREAD_CANCEL_DISABLE 1 + +# define PTHREAD_CANCELED ((void *) -1) + +# define PTHREAD_INHERIT_SCHED 0 +# define PTHREAD_EXPLICIT_SCHED 1 + +# define PTHREAD_PRIO_NONE 0 +# define PTHREAD_PRIO_INHERIT 1 +# define PTHREAD_PRIO_PROTECT 2 + +# define PTHREAD_SCOPE_SYSTEM 0 +# define PTHREAD_SCOPE_PROCESS 1 + +#endif + +/* =========== Thread functions =========== */ + +#if @GNULIB_PTHREAD_THREAD@ +/* The 'restrict' qualifier on ARG is nonsense, but POSIX specifies it this way. + Sigh. */ +# if @REPLACE_PTHREAD_CREATE@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pthread_create +# define pthread_create rpl_pthread_create +# endif +_GL_FUNCDECL_RPL (pthread_create, int, + (pthread_t *restrict threadp, + const pthread_attr_t *restrict attr, + void * (*mainfunc) (void *), void *restrict arg) + _GL_ARG_NONNULL ((1, 3))); +_GL_CXXALIAS_RPL (pthread_create, int, + (pthread_t *restrict threadp, + const pthread_attr_t *restrict attr, + void * (*mainfunc) (void *), void *restrict arg)); +# else +# if !@HAVE_PTHREAD_CREATE@ +_GL_FUNCDECL_SYS (pthread_create, int, + (pthread_t *restrict threadp, + const pthread_attr_t *restrict attr, + void * (*mainfunc) (void *), void *restrict arg) + _GL_ARG_NONNULL ((1, 3))); +# endif +_GL_CXXALIAS_SYS_CAST (pthread_create, int, + (pthread_t *restrict threadp, + const pthread_attr_t *restrict attr, + void * (*mainfunc) (void *), void *restrict arg)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (pthread_create); +# endif +#elif defined GNULIB_POSIXCHECK +# undef pthread_create +# if HAVE_RAW_DECL_PTHREAD_CREATE +_GL_WARN_ON_USE (pthread_create, "pthread_create is not portable - " + "use gnulib module pthread-thread for portability"); +# endif +#endif + +#if @GNULIB_PTHREAD_THREAD@ +# if @REPLACE_PTHREAD_ATTR_INIT@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pthread_attr_init +# define pthread_attr_init rpl_pthread_attr_init +# endif +_GL_FUNCDECL_RPL (pthread_attr_init, int, (pthread_attr_t *attr) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (pthread_attr_init, int, (pthread_attr_t *attr)); +# else +# if !@HAVE_PTHREAD_ATTR_INIT@ +_GL_FUNCDECL_SYS (pthread_attr_init, int, (pthread_attr_t *attr) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (pthread_attr_init, int, (pthread_attr_t *attr)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (pthread_attr_init); +# endif +#elif defined GNULIB_POSIXCHECK +# undef pthread_attr_init +# if HAVE_RAW_DECL_PTHREAD_ATTR_INIT +_GL_WARN_ON_USE (pthread_attr_init, "pthread_attr_init is not portable - " + "use gnulib module pthread-thread for portability"); +# endif +#endif + +#if @GNULIB_PTHREAD_THREAD@ +# if @REPLACE_PTHREAD_ATTR_GETDETACHSTATE@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pthread_attr_getdetachstate +# define pthread_attr_getdetachstate rpl_pthread_attr_getdetachstate +# endif +_GL_FUNCDECL_RPL (pthread_attr_getdetachstate, int, + (const pthread_attr_t *attr, int *detachstatep) + _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (pthread_attr_getdetachstate, int, + (const pthread_attr_t *attr, int *detachstatep)); +# else +# if !@HAVE_PTHREAD_ATTR_GETDETACHSTATE@ +_GL_FUNCDECL_SYS (pthread_attr_getdetachstate, int, + (const pthread_attr_t *attr, int *detachstatep) + _GL_ARG_NONNULL ((1, 2))); +# endif +_GL_CXXALIAS_SYS (pthread_attr_getdetachstate, int, + (const pthread_attr_t *attr, int *detachstatep)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (pthread_attr_getdetachstate); +# endif +#elif defined GNULIB_POSIXCHECK +# undef pthread_attr_getdetachstate +# if HAVE_RAW_DECL_PTHREAD_ATTR_GETDETACHSTATE +_GL_WARN_ON_USE (pthread_attr_getdetachstate, "pthread_attr_getdetachstate is not portable - " + "use gnulib module pthread-thread for portability"); +# endif +#endif + +#if @GNULIB_PTHREAD_THREAD@ +# if @REPLACE_PTHREAD_ATTR_SETDETACHSTATE@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pthread_attr_setdetachstate +# define pthread_attr_setdetachstate rpl_pthread_attr_setdetachstate +# endif +_GL_FUNCDECL_RPL (pthread_attr_setdetachstate, int, + (pthread_attr_t *attr, int detachstate) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (pthread_attr_setdetachstate, int, + (pthread_attr_t *attr, int detachstate)); +# else +# if !@HAVE_PTHREAD_ATTR_SETDETACHSTATE@ +_GL_FUNCDECL_SYS (pthread_attr_setdetachstate, int, + (pthread_attr_t *attr, int detachstate) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (pthread_attr_setdetachstate, int, + (pthread_attr_t *attr, int detachstate)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (pthread_attr_setdetachstate); +# endif +#elif defined GNULIB_POSIXCHECK +# undef pthread_attr_setdetachstate +# if HAVE_RAW_DECL_PTHREAD_ATTR_SETDETACHSTATE +_GL_WARN_ON_USE (pthread_attr_setdetachstate, "pthread_attr_setdetachstate is not portable - " + "use gnulib module pthread-thread for portability"); +# endif +#endif + +#if @GNULIB_PTHREAD_THREAD@ +# if @REPLACE_PTHREAD_ATTR_DESTROY@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pthread_attr_destroy +# define pthread_attr_destroy rpl_pthread_attr_destroy +# endif +_GL_FUNCDECL_RPL (pthread_attr_destroy, int, (pthread_attr_t *attr) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (pthread_attr_destroy, int, (pthread_attr_t *attr)); +# else +# if !@HAVE_PTHREAD_ATTR_DESTROY@ +_GL_FUNCDECL_SYS (pthread_attr_destroy, int, (pthread_attr_t *attr) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (pthread_attr_destroy, int, (pthread_attr_t *attr)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (pthread_attr_destroy); +# endif +#elif defined GNULIB_POSIXCHECK +# undef pthread_attr_destroy +# if HAVE_RAW_DECL_PTHREAD_ATTR_DESTROY +_GL_WARN_ON_USE (pthread_attr_destroy, "pthread_attr_destroy is not portable - " + "use gnulib module pthread-thread for portability"); +# endif +#endif + +#if @GNULIB_PTHREAD_THREAD@ +# if @REPLACE_PTHREAD_SELF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pthread_self +# define pthread_self rpl_pthread_self +# endif +_GL_FUNCDECL_RPL (pthread_self, pthread_t, (void) _GL_ATTRIBUTE_PURE); +_GL_CXXALIAS_RPL (pthread_self, pthread_t, (void)); +# else +# if !@HAVE_PTHREAD_SELF@ +_GL_FUNCDECL_SYS (pthread_self, pthread_t, (void) _GL_ATTRIBUTE_PURE); +# endif +_GL_CXXALIAS_SYS (pthread_self, pthread_t, (void)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (pthread_self); +# endif +#elif defined GNULIB_POSIXCHECK +# undef pthread_self +# if HAVE_RAW_DECL_PTHREAD_SELF +_GL_WARN_ON_USE (pthread_self, "pthread_self is not portable - " + "use gnulib module pthread-thread for portability"); +# endif +#endif + +#if @GNULIB_PTHREAD_THREAD@ +# if @REPLACE_PTHREAD_EQUAL@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pthread_equal +# define pthread_equal rpl_pthread_equal +# endif +_GL_FUNCDECL_RPL (pthread_equal, int, (pthread_t thread1, pthread_t thread2)); +_GL_CXXALIAS_RPL (pthread_equal, int, (pthread_t thread1, pthread_t thread2)); +# else +# if !@HAVE_PTHREAD_EQUAL@ +_GL_FUNCDECL_SYS (pthread_equal, int, (pthread_t thread1, pthread_t thread2)); +# endif +_GL_CXXALIAS_SYS (pthread_equal, int, (pthread_t thread1, pthread_t thread2)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (pthread_equal); +# endif +#elif defined GNULIB_POSIXCHECK +# undef pthread_equal +# if HAVE_RAW_DECL_PTHREAD_EQUAL +_GL_WARN_ON_USE (pthread_equal, "pthread_equal is not portable - " + "use gnulib module pthread-thread for portability"); +# endif +#endif + +#if @GNULIB_PTHREAD_THREAD@ +# if @REPLACE_PTHREAD_DETACH@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pthread_detach +# define pthread_detach rpl_pthread_detach +# endif +_GL_FUNCDECL_RPL (pthread_detach, int, (pthread_t thread)); +_GL_CXXALIAS_RPL (pthread_detach, int, (pthread_t thread)); +# else +# if !@HAVE_PTHREAD_DETACH@ +_GL_FUNCDECL_SYS (pthread_detach, int, (pthread_t thread)); +# endif +_GL_CXXALIAS_SYS (pthread_detach, int, (pthread_t thread)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (pthread_detach); +# endif +#elif defined GNULIB_POSIXCHECK +# undef pthread_detach +# if HAVE_RAW_DECL_PTHREAD_DETACH +_GL_WARN_ON_USE (pthread_detach, "pthread_detach is not portable - " + "use gnulib module pthread-thread for portability"); +# endif +#endif + +#if @GNULIB_PTHREAD_THREAD@ +# if @REPLACE_PTHREAD_JOIN@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pthread_join +# define pthread_join rpl_pthread_join +# endif +_GL_FUNCDECL_RPL (pthread_join, int, (pthread_t thread, void **valuep)); +_GL_CXXALIAS_RPL (pthread_join, int, (pthread_t thread, void **valuep)); +# else +# if !@HAVE_PTHREAD_JOIN@ +_GL_FUNCDECL_SYS (pthread_join, int, (pthread_t thread, void **valuep)); +# endif +_GL_CXXALIAS_SYS (pthread_join, int, (pthread_t thread, void **valuep)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (pthread_join); +# endif +#elif defined GNULIB_POSIXCHECK +# undef pthread_join +# if HAVE_RAW_DECL_PTHREAD_JOIN +_GL_WARN_ON_USE (pthread_join, "pthread_join is not portable - " + "use gnulib module pthread-thread for portability"); +# endif +#endif + +#if @GNULIB_PTHREAD_THREAD@ +# if @REPLACE_PTHREAD_EXIT@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pthread_exit +# define pthread_exit rpl_pthread_exit +# endif +_GL_FUNCDECL_RPL (pthread_exit, _Noreturn void, (void *value)); +_GL_CXXALIAS_RPL (pthread_exit, void, (void *value)); +# else +# if !@HAVE_PTHREAD_EXIT@ +_GL_FUNCDECL_SYS (pthread_exit, _Noreturn void, (void *value)); +# endif +/* Need to cast because of AIX with xlclang++. */ +_GL_CXXALIAS_SYS_CAST (pthread_exit, void, (void *value)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (pthread_exit); +# endif +#elif defined GNULIB_POSIXCHECK +# undef pthread_exit +# if HAVE_RAW_DECL_PTHREAD_EXIT +_GL_WARN_ON_USE (pthread_exit, "pthread_exit is not portable - " + "use gnulib module pthread-thread for portability"); +# endif +#endif + +/* =========== Once-only control (initialization) functions =========== */ + +#if @GNULIB_PTHREAD_ONCE@ +# if @REPLACE_PTHREAD_ONCE@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pthread_once +# define pthread_once rpl_pthread_once +# endif +_GL_FUNCDECL_RPL (pthread_once, int, + (pthread_once_t *once_control, void (*initfunction) (void)) + _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (pthread_once, int, + (pthread_once_t *once_control, void (*initfunction) (void))); +# else +# if !@HAVE_PTHREAD_ONCE@ +_GL_FUNCDECL_SYS (pthread_once, int, + (pthread_once_t *once_control, void (*initfunction) (void)) + _GL_ARG_NONNULL ((1, 2))); +# endif +_GL_CXXALIAS_SYS_CAST (pthread_once, int, + (pthread_once_t *once_control, + void (*initfunction) (void))); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (pthread_once); +# endif +#elif defined GNULIB_POSIXCHECK +# undef pthread_once +# if HAVE_RAW_DECL_PTHREAD_ONCE +_GL_WARN_ON_USE (pthread_once, "pthread_once is not portable - " + "use gnulib module pthread-once for portability"); +# endif +#endif + +/* =========== Mutex functions =========== */ + +#if @GNULIB_PTHREAD_MUTEX@ +# if @REPLACE_PTHREAD_MUTEX_INIT@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pthread_mutex_init +# define pthread_mutex_init rpl_pthread_mutex_init +# endif +_GL_FUNCDECL_RPL (pthread_mutex_init, int, + (pthread_mutex_t *restrict mutex, + const pthread_mutexattr_t *restrict attr) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (pthread_mutex_init, int, + (pthread_mutex_t *restrict mutex, + const pthread_mutexattr_t *restrict attr)); +# else +# if !@HAVE_PTHREAD_MUTEX_INIT@ +_GL_FUNCDECL_SYS (pthread_mutex_init, int, + (pthread_mutex_t *restrict mutex, + const pthread_mutexattr_t *restrict attr) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (pthread_mutex_init, int, + (pthread_mutex_t *restrict mutex, + const pthread_mutexattr_t *restrict attr)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (pthread_mutex_init); +# endif +#elif defined GNULIB_POSIXCHECK +# undef pthread_mutex_init +# if HAVE_RAW_DECL_PTHREAD_MUTEX_INIT +_GL_WARN_ON_USE (pthread_mutex_init, "pthread_mutex_init is not portable - " + "use gnulib module pthread-mutex for portability"); +# endif +#endif + +#if @GNULIB_PTHREAD_MUTEX@ +# if @REPLACE_PTHREAD_MUTEXATTR_INIT@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pthread_mutexattr_init +# define pthread_mutexattr_init rpl_pthread_mutexattr_init +# endif +_GL_FUNCDECL_RPL (pthread_mutexattr_init, int, (pthread_mutexattr_t *attr) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (pthread_mutexattr_init, int, (pthread_mutexattr_t *attr)); +# else +# if !@HAVE_PTHREAD_MUTEXATTR_INIT@ +_GL_FUNCDECL_SYS (pthread_mutexattr_init, int, (pthread_mutexattr_t *attr) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (pthread_mutexattr_init, int, (pthread_mutexattr_t *attr)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (pthread_mutexattr_init); +# endif +#elif defined GNULIB_POSIXCHECK +# undef pthread_mutexattr_init +# if HAVE_RAW_DECL_PTHREAD_MUTEXATTR_INIT +_GL_WARN_ON_USE (pthread_mutexattr_init, "pthread_mutexattr_init is not portable - " + "use gnulib module pthread-mutex for portability"); +# endif +#endif + +#if @GNULIB_PTHREAD_MUTEX@ +# if @REPLACE_PTHREAD_MUTEXATTR_GETTYPE@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pthread_mutexattr_gettype +# define pthread_mutexattr_gettype rpl_pthread_mutexattr_gettype +# endif +_GL_FUNCDECL_RPL (pthread_mutexattr_gettype, int, + (const pthread_mutexattr_t *restrict attr, + int *restrict typep) + _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (pthread_mutexattr_gettype, int, + (const pthread_mutexattr_t *restrict attr, + int *restrict typep)); +# else +# if !@HAVE_PTHREAD_MUTEXATTR_GETTYPE@ +_GL_FUNCDECL_SYS (pthread_mutexattr_gettype, int, + (const pthread_mutexattr_t *restrict attr, + int *restrict typep) + _GL_ARG_NONNULL ((1, 2))); +# endif +/* Need to cast, because on FreeBSD the first parameter is + pthread_mutexattr_t *attr. */ +_GL_CXXALIAS_SYS_CAST (pthread_mutexattr_gettype, int, + (const pthread_mutexattr_t *restrict attr, + int *restrict typep)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (pthread_mutexattr_gettype); +# endif +#elif defined GNULIB_POSIXCHECK +# undef pthread_mutexattr_gettype +# if HAVE_RAW_DECL_PTHREAD_MUTEXATTR_GETTYPE +_GL_WARN_ON_USE (pthread_mutexattr_gettype, "pthread_mutexattr_gettype is not portable - " + "use gnulib module pthread-mutex for portability"); +# endif +#endif + +#if @GNULIB_PTHREAD_MUTEX@ +# if @REPLACE_PTHREAD_MUTEXATTR_SETTYPE@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pthread_mutexattr_settype +# define pthread_mutexattr_settype rpl_pthread_mutexattr_settype +# endif +_GL_FUNCDECL_RPL (pthread_mutexattr_settype, int, + (pthread_mutexattr_t *attr, int type) _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (pthread_mutexattr_settype, int, + (pthread_mutexattr_t *attr, int type)); +# else +# if !@HAVE_PTHREAD_MUTEXATTR_SETTYPE@ +_GL_FUNCDECL_SYS (pthread_mutexattr_settype, int, + (pthread_mutexattr_t *attr, int type) _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (pthread_mutexattr_settype, int, + (pthread_mutexattr_t *attr, int type)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (pthread_mutexattr_settype); +# endif +#elif defined GNULIB_POSIXCHECK +# undef pthread_mutexattr_settype +# if HAVE_RAW_DECL_PTHREAD_MUTEXATTR_SETTYPE +_GL_WARN_ON_USE (pthread_mutexattr_settype, "pthread_mutexattr_settype is not portable - " + "use gnulib module pthread-mutex for portability"); +# endif +#endif + +#if @GNULIB_PTHREAD_MUTEX@ +# if @REPLACE_PTHREAD_MUTEXATTR_GETROBUST@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pthread_mutexattr_getrobust +# define pthread_mutexattr_getrobust rpl_pthread_mutexattr_getrobust +# endif +_GL_FUNCDECL_RPL (pthread_mutexattr_getrobust, int, + (const pthread_mutexattr_t *restrict attr, + int *restrict robustp) + _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (pthread_mutexattr_getrobust, int, + (const pthread_mutexattr_t *restrict attr, + int *restrict robustp)); +# else +# if !@HAVE_PTHREAD_MUTEXATTR_GETROBUST@ +_GL_FUNCDECL_SYS (pthread_mutexattr_getrobust, int, + (const pthread_mutexattr_t *restrict attr, + int *restrict robustp) + _GL_ARG_NONNULL ((1, 2))); +# endif +/* Need to cast, because on FreeBSD the first parameter is + pthread_mutexattr_t *attr. */ +_GL_CXXALIAS_SYS_CAST (pthread_mutexattr_getrobust, int, + (const pthread_mutexattr_t *restrict attr, + int *restrict robustp)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (pthread_mutexattr_getrobust); +# endif +#elif defined GNULIB_POSIXCHECK +# undef pthread_mutexattr_getrobust +# if HAVE_RAW_DECL_PTHREAD_MUTEXATTR_GETROBUST +_GL_WARN_ON_USE (pthread_mutexattr_getrobust, "pthread_mutexattr_getrobust is not portable - " + "use gnulib module pthread-mutex for portability"); +# endif +#endif + +#if @GNULIB_PTHREAD_MUTEX@ +# if @REPLACE_PTHREAD_MUTEXATTR_SETROBUST@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pthread_mutexattr_setrobust +# define pthread_mutexattr_setrobust rpl_pthread_mutexattr_setrobust +# endif +_GL_FUNCDECL_RPL (pthread_mutexattr_setrobust, int, + (pthread_mutexattr_t *attr, int robust) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (pthread_mutexattr_setrobust, int, + (pthread_mutexattr_t *attr, int robust)); +# else +# if !@HAVE_PTHREAD_MUTEXATTR_SETROBUST@ +_GL_FUNCDECL_SYS (pthread_mutexattr_setrobust, int, + (pthread_mutexattr_t *attr, int robust) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (pthread_mutexattr_setrobust, int, + (pthread_mutexattr_t *attr, int robust)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (pthread_mutexattr_setrobust); +# endif +#elif defined GNULIB_POSIXCHECK +# undef pthread_mutexattr_setrobust +# if HAVE_RAW_DECL_PTHREAD_MUTEXATTR_SETROBUST +_GL_WARN_ON_USE (pthread_mutexattr_setrobust, "pthread_mutexattr_setrobust is not portable - " + "use gnulib module pthread-mutex for portability"); +# endif +#endif + +#if @GNULIB_PTHREAD_MUTEX@ +# if @REPLACE_PTHREAD_MUTEXATTR_DESTROY@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pthread_mutexattr_destroy +# define pthread_mutexattr_destroy rpl_pthread_mutexattr_destroy +# endif +_GL_FUNCDECL_RPL (pthread_mutexattr_destroy, int, (pthread_mutexattr_t *attr) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (pthread_mutexattr_destroy, int, (pthread_mutexattr_t *attr)); +# else +# if !@HAVE_PTHREAD_MUTEXATTR_DESTROY@ +_GL_FUNCDECL_SYS (pthread_mutexattr_destroy, int, (pthread_mutexattr_t *attr) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (pthread_mutexattr_destroy, int, (pthread_mutexattr_t *attr)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (pthread_mutexattr_destroy); +# endif +#elif defined GNULIB_POSIXCHECK +# undef pthread_mutexattr_destroy +# if HAVE_RAW_DECL_PTHREAD_MUTEXATTR_DESTROY +_GL_WARN_ON_USE (pthread_mutexattr_destroy, "pthread_mutexattr_destroy is not portable - " + "use gnulib module pthread-mutex for portability"); +# endif +#endif + +#if @GNULIB_PTHREAD_MUTEX@ +# if @REPLACE_PTHREAD_MUTEX_LOCK@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pthread_mutex_lock +# define pthread_mutex_lock rpl_pthread_mutex_lock +# endif +_GL_FUNCDECL_RPL (pthread_mutex_lock, int, (pthread_mutex_t *mutex) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (pthread_mutex_lock, int, (pthread_mutex_t *mutex)); +# else +# if !@HAVE_PTHREAD_MUTEX_LOCK@ +_GL_FUNCDECL_SYS (pthread_mutex_lock, int, (pthread_mutex_t *mutex) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (pthread_mutex_lock, int, (pthread_mutex_t *mutex)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (pthread_mutex_lock); +# endif +#elif defined GNULIB_POSIXCHECK +# undef pthread_mutex_lock +# if HAVE_RAW_DECL_PTHREAD_MUTEX_LOCK +_GL_WARN_ON_USE (pthread_mutex_lock, "pthread_mutex_lock is not portable - " + "use gnulib module pthread-mutex for portability"); +# endif +#endif + +#if @GNULIB_PTHREAD_MUTEX@ +# if @REPLACE_PTHREAD_MUTEX_TRYLOCK@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pthread_mutex_trylock +# define pthread_mutex_trylock rpl_pthread_mutex_trylock +# endif +_GL_FUNCDECL_RPL (pthread_mutex_trylock, int, (pthread_mutex_t *mutex) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (pthread_mutex_trylock, int, (pthread_mutex_t *mutex)); +# else +# if !@HAVE_PTHREAD_MUTEX_TRYLOCK@ +_GL_FUNCDECL_SYS (pthread_mutex_trylock, int, (pthread_mutex_t *mutex) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (pthread_mutex_trylock, int, (pthread_mutex_t *mutex)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (pthread_mutex_trylock); +# endif +#elif defined GNULIB_POSIXCHECK +# undef pthread_mutex_trylock +# if HAVE_RAW_DECL_PTHREAD_MUTEX_TRYLOCK +_GL_WARN_ON_USE (pthread_mutex_trylock, "pthread_mutex_trylock is not portable - " + "use gnulib module pthread-mutex for portability"); +# endif +#endif + +#if @GNULIB_PTHREAD_MUTEX_TIMEDLOCK@ +# if @REPLACE_PTHREAD_MUTEX_TIMEDLOCK@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pthread_mutex_timedlock +# define pthread_mutex_timedlock rpl_pthread_mutex_timedlock +# endif +_GL_FUNCDECL_RPL (pthread_mutex_timedlock, int, + (pthread_mutex_t *restrict mutex, + const struct timespec *restrict abstime) + _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (pthread_mutex_timedlock, int, + (pthread_mutex_t *restrict mutex, + const struct timespec *restrict abstime)); +# else +# if !@HAVE_PTHREAD_MUTEX_TIMEDLOCK@ +_GL_FUNCDECL_SYS (pthread_mutex_timedlock, int, + (pthread_mutex_t *restrict mutex, + const struct timespec *restrict abstime) + _GL_ARG_NONNULL ((1, 2))); +# endif +_GL_CXXALIAS_SYS (pthread_mutex_timedlock, int, + (pthread_mutex_t *restrict mutex, + const struct timespec *restrict abstime)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (pthread_mutex_timedlock); +# endif +#elif defined GNULIB_POSIXCHECK +# undef pthread_mutex_timedlock +# if HAVE_RAW_DECL_PTHREAD_MUTEX_TIMEDLOCK +_GL_WARN_ON_USE (pthread_mutex_timedlock, "pthread_mutex_timedlock is not portable - " + "use gnulib module pthread_mutex_timedlock for portability"); +# endif +#endif + +#if @GNULIB_PTHREAD_MUTEX@ +# if @REPLACE_PTHREAD_MUTEX_UNLOCK@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pthread_mutex_unlock +# define pthread_mutex_unlock rpl_pthread_mutex_unlock +# endif +_GL_FUNCDECL_RPL (pthread_mutex_unlock, int, (pthread_mutex_t *mutex) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (pthread_mutex_unlock, int, (pthread_mutex_t *mutex)); +# else +# if !@HAVE_PTHREAD_MUTEX_UNLOCK@ +_GL_FUNCDECL_SYS (pthread_mutex_unlock, int, (pthread_mutex_t *mutex) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (pthread_mutex_unlock, int, (pthread_mutex_t *mutex)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (pthread_mutex_unlock); +# endif +#elif defined GNULIB_POSIXCHECK +# undef pthread_mutex_unlock +# if HAVE_RAW_DECL_PTHREAD_MUTEX_UNLOCK +_GL_WARN_ON_USE (pthread_mutex_unlock, "pthread_mutex_unlock is not portable - " + "use gnulib module pthread-mutex for portability"); +# endif +#endif + +#if @GNULIB_PTHREAD_MUTEX@ +# if @REPLACE_PTHREAD_MUTEX_DESTROY@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pthread_mutex_destroy +# define pthread_mutex_destroy rpl_pthread_mutex_destroy +# endif +_GL_FUNCDECL_RPL (pthread_mutex_destroy, int, (pthread_mutex_t *mutex) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (pthread_mutex_destroy, int, (pthread_mutex_t *mutex)); +# else +# if !@HAVE_PTHREAD_MUTEX_DESTROY@ +_GL_FUNCDECL_SYS (pthread_mutex_destroy, int, (pthread_mutex_t *mutex) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (pthread_mutex_destroy, int, (pthread_mutex_t *mutex)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (pthread_mutex_destroy); +# endif +#elif defined GNULIB_POSIXCHECK +# undef pthread_mutex_destroy +# if HAVE_RAW_DECL_PTHREAD_MUTEX_DESTROY +_GL_WARN_ON_USE (pthread_mutex_destroy, "pthread_mutex_destroy is not portable - " + "use gnulib module pthread-mutex for portability"); +# endif +#endif + +/* =========== Read-write lock functions =========== */ + +#if @GNULIB_PTHREAD_RWLOCK@ +# if @REPLACE_PTHREAD_RWLOCK_INIT@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pthread_rwlock_init +# define pthread_rwlock_init rpl_pthread_rwlock_init +# endif +_GL_FUNCDECL_RPL (pthread_rwlock_init, int, + (pthread_rwlock_t *restrict lock, + const pthread_rwlockattr_t *restrict attr) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (pthread_rwlock_init, int, + (pthread_rwlock_t *restrict lock, + const pthread_rwlockattr_t *restrict attr)); +# else +# if !@HAVE_PTHREAD_RWLOCK_INIT@ +_GL_FUNCDECL_SYS (pthread_rwlock_init, int, + (pthread_rwlock_t *restrict lock, + const pthread_rwlockattr_t *restrict attr) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (pthread_rwlock_init, int, + (pthread_rwlock_t *restrict lock, + const pthread_rwlockattr_t *restrict attr)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (pthread_rwlock_init); +# endif +#elif defined GNULIB_POSIXCHECK +# undef pthread_rwlock_init +# if HAVE_RAW_DECL_PTHREAD_RWLOCK_INIT +_GL_WARN_ON_USE (pthread_rwlock_init, "pthread_rwlock_init is not portable - " + "use gnulib module pthread-rwlock for portability"); +# endif +#endif + +#if @GNULIB_PTHREAD_RWLOCK@ +# if @REPLACE_PTHREAD_RWLOCKATTR_INIT@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pthread_rwlockattr_init +# define pthread_rwlockattr_init rpl_pthread_rwlockattr_init +# endif +_GL_FUNCDECL_RPL (pthread_rwlockattr_init, int, (pthread_rwlockattr_t *attr) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (pthread_rwlockattr_init, int, (pthread_rwlockattr_t *attr)); +# else +# if !@HAVE_PTHREAD_RWLOCKATTR_INIT@ +_GL_FUNCDECL_SYS (pthread_rwlockattr_init, int, (pthread_rwlockattr_t *attr) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (pthread_rwlockattr_init, int, (pthread_rwlockattr_t *attr)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (pthread_rwlockattr_init); +# endif +#elif defined GNULIB_POSIXCHECK +# undef pthread_rwlockattr_init +# if HAVE_RAW_DECL_PTHREAD_RWLOCKATTR_INIT +_GL_WARN_ON_USE (pthread_rwlockattr_init, "pthread_rwlockattr_init is not portable - " + "use gnulib module pthread-rwlock for portability"); +# endif +#endif + +#if @GNULIB_PTHREAD_RWLOCK@ +# if @REPLACE_PTHREAD_RWLOCKATTR_DESTROY@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pthread_rwlockattr_destroy +# define pthread_rwlockattr_destroy rpl_pthread_rwlockattr_destroy +# endif +_GL_FUNCDECL_RPL (pthread_rwlockattr_destroy, int, + (pthread_rwlockattr_t *attr) _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (pthread_rwlockattr_destroy, int, + (pthread_rwlockattr_t *attr)); +# else +# if !@HAVE_PTHREAD_RWLOCKATTR_DESTROY@ +_GL_FUNCDECL_SYS (pthread_rwlockattr_destroy, int, + (pthread_rwlockattr_t *attr) _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (pthread_rwlockattr_destroy, int, + (pthread_rwlockattr_t *attr)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (pthread_rwlockattr_destroy); +# endif +#elif defined GNULIB_POSIXCHECK +# undef pthread_rwlockattr_destroy +# if HAVE_RAW_DECL_PTHREAD_RWLOCKATTR_DESTROY +_GL_WARN_ON_USE (pthread_rwlockattr_destroy, "pthread_rwlockattr_destroy is not portable - " + "use gnulib module pthread-rwlock for portability"); +# endif +#endif + +#if @GNULIB_PTHREAD_RWLOCK@ +# if @REPLACE_PTHREAD_RWLOCK_RDLOCK@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pthread_rwlock_rdlock +# define pthread_rwlock_rdlock rpl_pthread_rwlock_rdlock +# endif +_GL_FUNCDECL_RPL (pthread_rwlock_rdlock, int, (pthread_rwlock_t *lock) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (pthread_rwlock_rdlock, int, (pthread_rwlock_t *lock)); +# else +# if !@HAVE_PTHREAD_RWLOCK_RDLOCK@ +_GL_FUNCDECL_SYS (pthread_rwlock_rdlock, int, (pthread_rwlock_t *lock) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (pthread_rwlock_rdlock, int, (pthread_rwlock_t *lock)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (pthread_rwlock_rdlock); +# endif +#elif defined GNULIB_POSIXCHECK +# undef pthread_rwlock_rdlock +# if HAVE_RAW_DECL_PTHREAD_RWLOCK_RDLOCK +_GL_WARN_ON_USE (pthread_rwlock_rdlock, "pthread_rwlock_rdlock is not portable - " + "use gnulib module pthread-rwlock for portability"); +# endif +#endif + +#if @GNULIB_PTHREAD_RWLOCK@ +# if @REPLACE_PTHREAD_RWLOCK_WRLOCK@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pthread_rwlock_wrlock +# define pthread_rwlock_wrlock rpl_pthread_rwlock_wrlock +# endif +_GL_FUNCDECL_RPL (pthread_rwlock_wrlock, int, (pthread_rwlock_t *lock) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (pthread_rwlock_wrlock, int, (pthread_rwlock_t *lock)); +# else +# if !@HAVE_PTHREAD_RWLOCK_WRLOCK@ +_GL_FUNCDECL_SYS (pthread_rwlock_wrlock, int, (pthread_rwlock_t *lock) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (pthread_rwlock_wrlock, int, (pthread_rwlock_t *lock)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (pthread_rwlock_wrlock); +# endif +#elif defined GNULIB_POSIXCHECK +# undef pthread_rwlock_wrlock +# if HAVE_RAW_DECL_PTHREAD_RWLOCK_WRLOCK +_GL_WARN_ON_USE (pthread_rwlock_wrlock, "pthread_rwlock_wrlock is not portable - " + "use gnulib module pthread-rwlock for portability"); +# endif +#endif + +#if @GNULIB_PTHREAD_RWLOCK@ +# if @REPLACE_PTHREAD_RWLOCK_TRYRDLOCK@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pthread_rwlock_tryrdlock +# define pthread_rwlock_tryrdlock rpl_pthread_rwlock_tryrdlock +# endif +_GL_FUNCDECL_RPL (pthread_rwlock_tryrdlock, int, (pthread_rwlock_t *lock) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (pthread_rwlock_tryrdlock, int, (pthread_rwlock_t *lock)); +# else +# if !@HAVE_PTHREAD_RWLOCK_TRYRDLOCK@ +_GL_FUNCDECL_SYS (pthread_rwlock_tryrdlock, int, (pthread_rwlock_t *lock) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (pthread_rwlock_tryrdlock, int, (pthread_rwlock_t *lock)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (pthread_rwlock_tryrdlock); +# endif +#elif defined GNULIB_POSIXCHECK +# undef pthread_rwlock_tryrdlock +# if HAVE_RAW_DECL_PTHREAD_RWLOCK_TRYRDLOCK +_GL_WARN_ON_USE (pthread_rwlock_tryrdlock, "pthread_rwlock_tryrdlock is not portable - " + "use gnulib module pthread-rwlock for portability"); +# endif +#endif + +#if @GNULIB_PTHREAD_RWLOCK@ +# if @REPLACE_PTHREAD_RWLOCK_TRYWRLOCK@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pthread_rwlock_trywrlock +# define pthread_rwlock_trywrlock rpl_pthread_rwlock_trywrlock +# endif +_GL_FUNCDECL_RPL (pthread_rwlock_trywrlock, int, (pthread_rwlock_t *lock) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (pthread_rwlock_trywrlock, int, (pthread_rwlock_t *lock)); +# else +# if !@HAVE_PTHREAD_RWLOCK_TRYWRLOCK@ +_GL_FUNCDECL_SYS (pthread_rwlock_trywrlock, int, (pthread_rwlock_t *lock) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (pthread_rwlock_trywrlock, int, (pthread_rwlock_t *lock)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (pthread_rwlock_trywrlock); +# endif +#elif defined GNULIB_POSIXCHECK +# undef pthread_rwlock_trywrlock +# if HAVE_RAW_DECL_PTHREAD_RWLOCK_TRYWRLOCK +_GL_WARN_ON_USE (pthread_rwlock_trywrlock, "pthread_rwlock_trywrlock is not portable - " + "use gnulib module pthread-rwlock for portability"); +# endif +#endif + +#if @GNULIB_PTHREAD_RWLOCK@ +# if @REPLACE_PTHREAD_RWLOCK_TIMEDRDLOCK@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pthread_rwlock_timedrdlock +# define pthread_rwlock_timedrdlock rpl_pthread_rwlock_timedrdlock +# endif +_GL_FUNCDECL_RPL (pthread_rwlock_timedrdlock, int, + (pthread_rwlock_t *restrict lock, + const struct timespec *restrict abstime) + _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (pthread_rwlock_timedrdlock, int, + (pthread_rwlock_t *restrict lock, + const struct timespec *restrict abstime)); +# else +# if !@HAVE_PTHREAD_RWLOCK_TIMEDRDLOCK@ +_GL_FUNCDECL_SYS (pthread_rwlock_timedrdlock, int, + (pthread_rwlock_t *restrict lock, + const struct timespec *restrict abstime) + _GL_ARG_NONNULL ((1, 2))); +# endif +_GL_CXXALIAS_SYS (pthread_rwlock_timedrdlock, int, + (pthread_rwlock_t *restrict lock, + const struct timespec *restrict abstime)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (pthread_rwlock_timedrdlock); +# endif +#elif defined GNULIB_POSIXCHECK +# undef pthread_rwlock_timedrdlock +# if HAVE_RAW_DECL_PTHREAD_RWLOCK_TIMEDRDLOCK +_GL_WARN_ON_USE (pthread_rwlock_timedrdlock, "pthread_rwlock_timedrdlock is not portable - " + "use gnulib module pthread-rwlock for portability"); +# endif +#endif + +#if @GNULIB_PTHREAD_RWLOCK@ +# if @REPLACE_PTHREAD_RWLOCK_TIMEDWRLOCK@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pthread_rwlock_timedwrlock +# define pthread_rwlock_timedwrlock rpl_pthread_rwlock_timedwrlock +# endif +_GL_FUNCDECL_RPL (pthread_rwlock_timedwrlock, int, + (pthread_rwlock_t *restrict lock, + const struct timespec *restrict abstime) + _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (pthread_rwlock_timedwrlock, int, + (pthread_rwlock_t *restrict lock, + const struct timespec *restrict abstime)); +# else +# if !@HAVE_PTHREAD_RWLOCK_TIMEDWRLOCK@ +_GL_FUNCDECL_SYS (pthread_rwlock_timedwrlock, int, + (pthread_rwlock_t *restrict lock, + const struct timespec *restrict abstime) + _GL_ARG_NONNULL ((1, 2))); +# endif +_GL_CXXALIAS_SYS (pthread_rwlock_timedwrlock, int, + (pthread_rwlock_t *restrict lock, + const struct timespec *restrict abstime)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (pthread_rwlock_timedwrlock); +# endif +#elif defined GNULIB_POSIXCHECK +# undef pthread_rwlock_timedwrlock +# if HAVE_RAW_DECL_PTHREAD_RWLOCK_TIMEDWRLOCK +_GL_WARN_ON_USE (pthread_rwlock_timedwrlock, "pthread_rwlock_timedwrlock is not portable - " + "use gnulib module pthread-rwlock for portability"); +# endif +#endif + +#if @GNULIB_PTHREAD_RWLOCK@ +# if @REPLACE_PTHREAD_RWLOCK_UNLOCK@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pthread_rwlock_unlock +# define pthread_rwlock_unlock rpl_pthread_rwlock_unlock +# endif +_GL_FUNCDECL_RPL (pthread_rwlock_unlock, int, (pthread_rwlock_t *lock) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (pthread_rwlock_unlock, int, (pthread_rwlock_t *lock)); +# else +# if !@HAVE_PTHREAD_RWLOCK_UNLOCK@ +_GL_FUNCDECL_SYS (pthread_rwlock_unlock, int, (pthread_rwlock_t *lock) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (pthread_rwlock_unlock, int, (pthread_rwlock_t *lock)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (pthread_rwlock_unlock); +# endif +#elif defined GNULIB_POSIXCHECK +# undef pthread_rwlock_unlock +# if HAVE_RAW_DECL_PTHREAD_RWLOCK_UNLOCK +_GL_WARN_ON_USE (pthread_rwlock_unlock, "pthread_rwlock_unlock is not portable - " + "use gnulib module pthread-rwlock for portability"); +# endif +#endif + +#if @GNULIB_PTHREAD_RWLOCK@ +# if @REPLACE_PTHREAD_RWLOCK_DESTROY@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pthread_rwlock_destroy +# define pthread_rwlock_destroy rpl_pthread_rwlock_destroy +# endif +_GL_FUNCDECL_RPL (pthread_rwlock_destroy, int, (pthread_rwlock_t *lock) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (pthread_rwlock_destroy, int, (pthread_rwlock_t *lock)); +# else +# if !@HAVE_PTHREAD_RWLOCK_DESTROY@ +_GL_FUNCDECL_SYS (pthread_rwlock_destroy, int, (pthread_rwlock_t *lock) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (pthread_rwlock_destroy, int, (pthread_rwlock_t *lock)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (pthread_rwlock_destroy); +# endif +#elif defined GNULIB_POSIXCHECK +# undef pthread_rwlock_destroy +# if HAVE_RAW_DECL_PTHREAD_RWLOCK_DESTROY +_GL_WARN_ON_USE (pthread_rwlock_destroy, "pthread_rwlock_destroy is not portable - " + "use gnulib module pthread-rwlock for portability"); +# endif +#endif + +/* =========== Condition variable functions =========== */ + +#if @GNULIB_PTHREAD_COND@ +# if @REPLACE_PTHREAD_COND_INIT@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pthread_cond_init +# define pthread_cond_init rpl_pthread_cond_init +# endif +_GL_FUNCDECL_RPL (pthread_cond_init, int, + (pthread_cond_t *restrict cond, + const pthread_condattr_t *restrict attr) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (pthread_cond_init, int, + (pthread_cond_t *restrict cond, + const pthread_condattr_t *restrict attr)); +# else +# if !@HAVE_PTHREAD_COND_INIT@ +_GL_FUNCDECL_SYS (pthread_cond_init, int, + (pthread_cond_t *restrict cond, + const pthread_condattr_t *restrict attr) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (pthread_cond_init, int, + (pthread_cond_t *restrict cond, + const pthread_condattr_t *restrict attr)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (pthread_cond_init); +# endif +#elif defined GNULIB_POSIXCHECK +# undef pthread_cond_init +# if HAVE_RAW_DECL_PTHREAD_COND_INIT +_GL_WARN_ON_USE (pthread_cond_init, "pthread_cond_init is not portable - " + "use gnulib module pthread-cond for portability"); +# endif +#endif + +#if @GNULIB_PTHREAD_COND@ +# if @REPLACE_PTHREAD_CONDATTR_INIT@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pthread_condattr_init +# define pthread_condattr_init rpl_pthread_condattr_init +# endif +_GL_FUNCDECL_RPL (pthread_condattr_init, int, (pthread_condattr_t *attr) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (pthread_condattr_init, int, (pthread_condattr_t *attr)); +# else +# if !@HAVE_PTHREAD_CONDATTR_INIT@ +_GL_FUNCDECL_SYS (pthread_condattr_init, int, (pthread_condattr_t *attr) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (pthread_condattr_init, int, (pthread_condattr_t *attr)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (pthread_condattr_init); +# endif +#elif defined GNULIB_POSIXCHECK +# undef pthread_condattr_init +# if HAVE_RAW_DECL_PTHREAD_CONDATTR_INIT +_GL_WARN_ON_USE (pthread_condattr_init, "pthread_condattr_init is not portable - " + "use gnulib module pthread-cond for portability"); +# endif +#endif + +#if @GNULIB_PTHREAD_COND@ +# if @REPLACE_PTHREAD_CONDATTR_DESTROY@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pthread_condattr_destroy +# define pthread_condattr_destroy rpl_pthread_condattr_destroy +# endif +_GL_FUNCDECL_RPL (pthread_condattr_destroy, int, (pthread_condattr_t *attr) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (pthread_condattr_destroy, int, (pthread_condattr_t *attr)); +# else +# if !@HAVE_PTHREAD_CONDATTR_DESTROY@ +_GL_FUNCDECL_SYS (pthread_condattr_destroy, int, (pthread_condattr_t *attr) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (pthread_condattr_destroy, int, (pthread_condattr_t *attr)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (pthread_condattr_destroy); +# endif +#elif defined GNULIB_POSIXCHECK +# undef pthread_condattr_destroy +# if HAVE_RAW_DECL_PTHREAD_CONDATTR_DESTROY +_GL_WARN_ON_USE (pthread_condattr_destroy, "pthread_condattr_destroy is not portable - " + "use gnulib module pthread-cond for portability"); +# endif +#endif + +#if @GNULIB_PTHREAD_COND@ +# if @REPLACE_PTHREAD_COND_WAIT@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pthread_cond_wait +# define pthread_cond_wait rpl_pthread_cond_wait +# endif +_GL_FUNCDECL_RPL (pthread_cond_wait, int, + (pthread_cond_t *restrict cond, + pthread_mutex_t *restrict mutex) + _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (pthread_cond_wait, int, + (pthread_cond_t *restrict cond, + pthread_mutex_t *restrict mutex)); +# else +# if !@HAVE_PTHREAD_COND_WAIT@ +_GL_FUNCDECL_SYS (pthread_cond_wait, int, + (pthread_cond_t *restrict cond, + pthread_mutex_t *restrict mutex) + _GL_ARG_NONNULL ((1, 2))); +# endif +_GL_CXXALIAS_SYS (pthread_cond_wait, int, + (pthread_cond_t *restrict cond, + pthread_mutex_t *restrict mutex)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (pthread_cond_wait); +# endif +#elif defined GNULIB_POSIXCHECK +# undef pthread_cond_wait +# if HAVE_RAW_DECL_PTHREAD_COND_WAIT +_GL_WARN_ON_USE (pthread_cond_wait, "pthread_cond_wait is not portable - " + "use gnulib module pthread-cond for portability"); +# endif +#endif + +#if @GNULIB_PTHREAD_COND@ +# if @REPLACE_PTHREAD_COND_TIMEDWAIT@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pthread_cond_timedwait +# define pthread_cond_timedwait rpl_pthread_cond_timedwait +# endif +_GL_FUNCDECL_RPL (pthread_cond_timedwait, int, + (pthread_cond_t *restrict cond, + pthread_mutex_t *restrict mutex, + const struct timespec *restrict abstime) + _GL_ARG_NONNULL ((1, 2, 3))); +_GL_CXXALIAS_RPL (pthread_cond_timedwait, int, + (pthread_cond_t *restrict cond, + pthread_mutex_t *restrict mutex, + const struct timespec *restrict abstime)); +# else +# if !@HAVE_PTHREAD_COND_TIMEDWAIT@ +_GL_FUNCDECL_SYS (pthread_cond_timedwait, int, + (pthread_cond_t *restrict cond, + pthread_mutex_t *restrict mutex, + const struct timespec *restrict abstime) + _GL_ARG_NONNULL ((1, 2, 3))); +# endif +_GL_CXXALIAS_SYS (pthread_cond_timedwait, int, + (pthread_cond_t *restrict cond, + pthread_mutex_t *restrict mutex, + const struct timespec *restrict abstime)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (pthread_cond_timedwait); +# endif +#elif defined GNULIB_POSIXCHECK +# undef pthread_cond_timedwait +# if HAVE_RAW_DECL_PTHREAD_COND_TIMEDWAIT +_GL_WARN_ON_USE (pthread_cond_timedwait, "pthread_cond_timedwait is not portable - " + "use gnulib module pthread-cond for portability"); +# endif +#endif + +#if @GNULIB_PTHREAD_COND@ +# if @REPLACE_PTHREAD_COND_SIGNAL@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pthread_cond_signal +# define pthread_cond_signal rpl_pthread_cond_signal +# endif +_GL_FUNCDECL_RPL (pthread_cond_signal, int, (pthread_cond_t *cond) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (pthread_cond_signal, int, (pthread_cond_t *cond)); +# else +# if !@HAVE_PTHREAD_COND_SIGNAL@ +_GL_FUNCDECL_SYS (pthread_cond_signal, int, (pthread_cond_t *cond) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (pthread_cond_signal, int, (pthread_cond_t *cond)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (pthread_cond_signal); +# endif +#elif defined GNULIB_POSIXCHECK +# undef pthread_cond_signal +# if HAVE_RAW_DECL_PTHREAD_COND_SIGNAL +_GL_WARN_ON_USE (pthread_cond_signal, "pthread_cond_signal is not portable - " + "use gnulib module pthread-cond for portability"); +# endif +#endif + +#if @GNULIB_PTHREAD_COND@ +# if @REPLACE_PTHREAD_COND_BROADCAST@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pthread_cond_broadcast +# define pthread_cond_broadcast rpl_pthread_cond_broadcast +# endif +_GL_FUNCDECL_RPL (pthread_cond_broadcast, int, (pthread_cond_t *cond) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (pthread_cond_broadcast, int, (pthread_cond_t *cond)); +# else +# if !@HAVE_PTHREAD_COND_BROADCAST@ +_GL_FUNCDECL_SYS (pthread_cond_broadcast, int, (pthread_cond_t *cond) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (pthread_cond_broadcast, int, (pthread_cond_t *cond)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (pthread_cond_broadcast); +# endif +#elif defined GNULIB_POSIXCHECK +# undef pthread_cond_broadcast +# if HAVE_RAW_DECL_PTHREAD_COND_BROADCAST +_GL_WARN_ON_USE (pthread_cond_broadcast, "pthread_cond_broadcast is not portable - " + "use gnulib module pthread-cond for portability"); +# endif +#endif + +#if @GNULIB_PTHREAD_COND@ +# if @REPLACE_PTHREAD_COND_DESTROY@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pthread_cond_destroy +# define pthread_cond_destroy rpl_pthread_cond_destroy +# endif +_GL_FUNCDECL_RPL (pthread_cond_destroy, int, (pthread_cond_t *cond) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (pthread_cond_destroy, int, (pthread_cond_t *cond)); +# else +# if !@HAVE_PTHREAD_COND_DESTROY@ +_GL_FUNCDECL_SYS (pthread_cond_destroy, int, (pthread_cond_t *cond) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (pthread_cond_destroy, int, (pthread_cond_t *cond)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (pthread_cond_destroy); +# endif +#elif defined GNULIB_POSIXCHECK +# undef pthread_cond_destroy +# if HAVE_RAW_DECL_PTHREAD_COND_DESTROY +_GL_WARN_ON_USE (pthread_cond_destroy, "pthread_cond_destroy is not portable - " + "use gnulib module pthread-cond for portability"); +# endif +#endif + +/* =========== Thread-specific storage functions =========== */ + +#if @GNULIB_PTHREAD_TSS@ +# if @REPLACE_PTHREAD_KEY_CREATE@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pthread_key_create +# define pthread_key_create rpl_pthread_key_create +# endif +_GL_FUNCDECL_RPL (pthread_key_create, int, + (pthread_key_t *keyp, void (*destructor) (void *)) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (pthread_key_create, int, + (pthread_key_t *keyp, void (*destructor) (void *))); +# else +# if !@HAVE_PTHREAD_KEY_CREATE@ +_GL_FUNCDECL_SYS (pthread_key_create, int, + (pthread_key_t *keyp, void (*destructor) (void *)) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS_CAST (pthread_key_create, int, + (pthread_key_t *keyp, void (*destructor) (void *))); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (pthread_key_create); +# endif +#elif defined GNULIB_POSIXCHECK +# undef pthread_key_create +# if HAVE_RAW_DECL_PTHREAD_KEY_CREATE +_GL_WARN_ON_USE (pthread_key_create, "pthread_key_create is not portable - " + "use gnulib module pthread-tss for portability"); +# endif +#endif + +#if @GNULIB_PTHREAD_TSS@ +# if @REPLACE_PTHREAD_SETSPECIFIC@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pthread_setspecific +# define pthread_setspecific rpl_pthread_setspecific +# endif +_GL_FUNCDECL_RPL (pthread_setspecific, int, + (pthread_key_t key, const void *value)); +_GL_CXXALIAS_RPL (pthread_setspecific, int, + (pthread_key_t key, const void *value)); +# else +# if !@HAVE_PTHREAD_SETSPECIFIC@ +_GL_FUNCDECL_SYS (pthread_setspecific, int, + (pthread_key_t key, const void *value)); +# endif +_GL_CXXALIAS_SYS (pthread_setspecific, int, + (pthread_key_t key, const void *value)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (pthread_setspecific); +# endif +#elif defined GNULIB_POSIXCHECK +# undef pthread_setspecific +# if HAVE_RAW_DECL_PTHREAD_SETSPECIFIC +_GL_WARN_ON_USE (pthread_setspecific, "pthread_setspecific is not portable - " + "use gnulib module pthread-tss for portability"); +# endif +#endif + +#if @GNULIB_PTHREAD_TSS@ +# if @REPLACE_PTHREAD_GETSPECIFIC@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pthread_getspecific +# define pthread_getspecific rpl_pthread_getspecific +# endif +_GL_FUNCDECL_RPL (pthread_getspecific, void *, (pthread_key_t key)); +_GL_CXXALIAS_RPL (pthread_getspecific, void *, (pthread_key_t key)); +# else +# if !@HAVE_PTHREAD_GETSPECIFIC@ +_GL_FUNCDECL_SYS (pthread_getspecific, void *, (pthread_key_t key)); +# endif +_GL_CXXALIAS_SYS (pthread_getspecific, void *, (pthread_key_t key)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (pthread_getspecific); +# endif +#elif defined GNULIB_POSIXCHECK +# undef pthread_getspecific +# if HAVE_RAW_DECL_PTHREAD_GETSPECIFIC +_GL_WARN_ON_USE (pthread_getspecific, "pthread_getspecific is not portable - " + "use gnulib module pthread-tss for portability"); +# endif +#endif + +#if @GNULIB_PTHREAD_TSS@ +# if @REPLACE_PTHREAD_KEY_DELETE@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pthread_key_delete +# define pthread_key_delete rpl_pthread_key_delete +# endif +_GL_FUNCDECL_RPL (pthread_key_delete, int, (pthread_key_t key)); +_GL_CXXALIAS_RPL (pthread_key_delete, int, (pthread_key_t key)); +# else +# if !@HAVE_PTHREAD_KEY_DELETE@ +_GL_FUNCDECL_SYS (pthread_key_delete, int, (pthread_key_t key)); +# endif +_GL_CXXALIAS_SYS (pthread_key_delete, int, (pthread_key_t key)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (pthread_key_delete); +# endif +#elif defined GNULIB_POSIXCHECK +# undef pthread_key_delete +# if HAVE_RAW_DECL_PTHREAD_KEY_DELETE +_GL_WARN_ON_USE (pthread_key_delete, "pthread_key_delete is not portable - " + "use gnulib module pthread-tss for portability"); +# endif +#endif + +/* =========== Spinlock functions =========== */ + +#if @GNULIB_PTHREAD_SPIN@ +# if @REPLACE_PTHREAD_SPIN_INIT@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pthread_spin_init +# define pthread_spin_init rpl_pthread_spin_init +# endif +_GL_FUNCDECL_RPL (pthread_spin_init, int, + (pthread_spinlock_t *lock, int shared_across_processes) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (pthread_spin_init, int, + (pthread_spinlock_t *lock, int shared_across_processes)); +# else +# if !@HAVE_PTHREAD_SPIN_INIT@ +_GL_FUNCDECL_SYS (pthread_spin_init, int, + (pthread_spinlock_t *lock, int shared_across_processes) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (pthread_spin_init, int, + (pthread_spinlock_t *lock, int shared_across_processes)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (pthread_spin_init); +# endif +#elif defined GNULIB_POSIXCHECK +# undef pthread_spin_init +# if HAVE_RAW_DECL_PTHREAD_SPIN_INIT +_GL_WARN_ON_USE (pthread_spin_init, "pthread_spin_init is not portable - " + "use gnulib module pthread-spin for portability"); +# endif +#endif + +#if @GNULIB_PTHREAD_SPIN@ +# if @REPLACE_PTHREAD_SPIN_LOCK@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pthread_spin_lock +# define pthread_spin_lock rpl_pthread_spin_lock +# endif +_GL_FUNCDECL_RPL (pthread_spin_lock, int, (pthread_spinlock_t *lock) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (pthread_spin_lock, int, (pthread_spinlock_t *lock)); +# else +# if !@HAVE_PTHREAD_SPIN_LOCK@ +_GL_FUNCDECL_SYS (pthread_spin_lock, int, (pthread_spinlock_t *lock) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (pthread_spin_lock, int, (pthread_spinlock_t *lock)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (pthread_spin_lock); +# endif +#elif defined GNULIB_POSIXCHECK +# undef pthread_spin_lock +# if HAVE_RAW_DECL_PTHREAD_SPIN_LOCK +_GL_WARN_ON_USE (pthread_spin_lock, "pthread_spin_lock is not portable - " + "use gnulib module pthread-spin for portability"); +# endif +#endif + +#if @GNULIB_PTHREAD_SPIN@ +# if @REPLACE_PTHREAD_SPIN_TRYLOCK@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pthread_spin_trylock +# define pthread_spin_trylock rpl_pthread_spin_trylock +# endif +_GL_FUNCDECL_RPL (pthread_spin_trylock, int, (pthread_spinlock_t *lock) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (pthread_spin_trylock, int, (pthread_spinlock_t *lock)); +# else +# if !@HAVE_PTHREAD_SPIN_TRYLOCK@ +_GL_FUNCDECL_SYS (pthread_spin_trylock, int, (pthread_spinlock_t *lock) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (pthread_spin_trylock, int, (pthread_spinlock_t *lock)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (pthread_spin_trylock); +# endif +#elif defined GNULIB_POSIXCHECK +# undef pthread_spin_trylock +# if HAVE_RAW_DECL_PTHREAD_SPIN_TRYLOCK +_GL_WARN_ON_USE (pthread_spin_trylock, "pthread_spin_trylock is not portable - " + "use gnulib module pthread-spin for portability"); +# endif +#endif + +#if @GNULIB_PTHREAD_SPIN@ +# if @REPLACE_PTHREAD_SPIN_UNLOCK@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pthread_spin_unlock +# define pthread_spin_unlock rpl_pthread_spin_unlock +# endif +_GL_FUNCDECL_RPL (pthread_spin_unlock, int, (pthread_spinlock_t *lock) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (pthread_spin_unlock, int, (pthread_spinlock_t *lock)); +# else +# if !@HAVE_PTHREAD_SPIN_UNLOCK@ +_GL_FUNCDECL_SYS (pthread_spin_unlock, int, (pthread_spinlock_t *lock) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (pthread_spin_unlock, int, (pthread_spinlock_t *lock)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (pthread_spin_unlock); +# endif +#elif defined GNULIB_POSIXCHECK +# undef pthread_spin_unlock +# if HAVE_RAW_DECL_PTHREAD_SPIN_UNLOCK +_GL_WARN_ON_USE (pthread_spin_unlock, "pthread_spin_unlock is not portable - " + "use gnulib module pthread-spin for portability"); +# endif +#endif + +#if @GNULIB_PTHREAD_SPIN@ +# if @REPLACE_PTHREAD_SPIN_DESTROY@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pthread_spin_destroy +# define pthread_spin_destroy rpl_pthread_spin_destroy +# endif +_GL_FUNCDECL_RPL (pthread_spin_destroy, int, (pthread_spinlock_t *lock) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (pthread_spin_destroy, int, (pthread_spinlock_t *lock)); +# else +# if !@HAVE_PTHREAD_SPIN_DESTROY@ +_GL_FUNCDECL_SYS (pthread_spin_destroy, int, (pthread_spinlock_t *lock) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (pthread_spin_destroy, int, (pthread_spinlock_t *lock)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (pthread_spin_destroy); +# endif +#elif defined GNULIB_POSIXCHECK +# undef pthread_spin_destroy +# if HAVE_RAW_DECL_PTHREAD_SPIN_DESTROY +_GL_WARN_ON_USE (pthread_spin_destroy, "pthread_spin_destroy is not portable - " + "use gnulib module pthread-spin for portability"); +# endif +#endif + + +#if defined __cplusplus && defined GNULIB_NAMESPACE && !@HAVE_PTHREAD_H@ && defined __MINGW32__ +/* Provide the symbols required by mingw's . */ +using GNULIB_NAMESPACE::pthread_create; +using GNULIB_NAMESPACE::pthread_self; +using GNULIB_NAMESPACE::pthread_equal; +using GNULIB_NAMESPACE::pthread_detach; +using GNULIB_NAMESPACE::pthread_join; +using GNULIB_NAMESPACE::pthread_once; +using GNULIB_NAMESPACE::pthread_mutex_init; +using GNULIB_NAMESPACE::pthread_mutexattr_init; +using GNULIB_NAMESPACE::pthread_mutexattr_settype; +using GNULIB_NAMESPACE::pthread_mutexattr_destroy; +using GNULIB_NAMESPACE::pthread_mutex_lock; +using GNULIB_NAMESPACE::pthread_mutex_trylock; +using GNULIB_NAMESPACE::pthread_mutex_timedlock; +using GNULIB_NAMESPACE::pthread_mutex_unlock; +using GNULIB_NAMESPACE::pthread_mutex_destroy; +using GNULIB_NAMESPACE::pthread_cond_wait; +using GNULIB_NAMESPACE::pthread_cond_timedwait; +using GNULIB_NAMESPACE::pthread_cond_signal; +using GNULIB_NAMESPACE::pthread_cond_broadcast; +using GNULIB_NAMESPACE::pthread_cond_destroy; +using GNULIB_NAMESPACE::pthread_key_create; +using GNULIB_NAMESPACE::pthread_setspecific; +using GNULIB_NAMESPACE::pthread_getspecific; +using GNULIB_NAMESPACE::pthread_key_delete; +#endif + + +#endif /* _@GUARD_PREFIX@_PTHREAD_H_ */ +#endif /* _@GUARD_PREFIX@_PTHREAD_H_ */ +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/pthread_sigmask.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/pthread_sigmask.c new file mode 100644 index 00000000..3b6e6e45 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/pthread_sigmask.c @@ -0,0 +1,92 @@ +/* POSIX compatible signal blocking for threads. + Copyright (C) 2011-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +#include +#include + +#if PTHREAD_SIGMASK_INEFFECTIVE +# include +#endif + +#if PTHREAD_SIGMASK_UNBLOCK_BUG +# include +#endif + +int +pthread_sigmask (int how, const sigset_t *new_mask, sigset_t *old_mask) +#undef pthread_sigmask +{ +#if HAVE_PTHREAD_SIGMASK + int ret; + +# if PTHREAD_SIGMASK_INEFFECTIVE + sigset_t omask, omask_copy; + sigset_t *old_mask_ptr = &omask; + sigemptyset (&omask); + /* Add a signal unlikely to be blocked, so that OMASK_COPY + is unlikely to match the actual mask. */ + sigaddset (&omask, SIGILL); + memcpy (&omask_copy, &omask, sizeof omask); +# else + sigset_t *old_mask_ptr = old_mask; +# endif + + ret = pthread_sigmask (how, new_mask, old_mask_ptr); + +# if PTHREAD_SIGMASK_INEFFECTIVE + if (ret == 0) + { + /* Detect whether pthread_sigmask is currently ineffective. + Don't cache the information: libpthread.so could be dynamically + loaded after the program started and after pthread_sigmask was + called for the first time. */ + if (memcmp (&omask_copy, &omask, sizeof omask) == 0 + && pthread_sigmask (1729, &omask_copy, NULL) == 0) + { + /* pthread_sigmask is currently ineffective. The program is not + linked to -lpthread. So use sigprocmask instead. */ + return (sigprocmask (how, new_mask, old_mask) < 0 ? errno : 0); + } + + if (old_mask) + memcpy (old_mask, &omask, sizeof omask); + } +# endif +# if PTHREAD_SIGMASK_FAILS_WITH_ERRNO + if (ret == -1) + return errno; +# endif +# if PTHREAD_SIGMASK_UNBLOCK_BUG + if (ret == 0 + && new_mask != NULL + && (how == SIG_UNBLOCK || how == SIG_SETMASK)) + { + /* Give the OS the opportunity to raise signals that were pending before + the pthread_sigmask call and have now been unblocked. */ + usleep (1); + } +# endif + return ret; +#else + int ret = sigprocmask (how, new_mask, old_mask); + return (ret < 0 ? errno : 0); +#endif +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/putenv.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/putenv.c new file mode 100644 index 00000000..2ab6f248 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/putenv.c @@ -0,0 +1,196 @@ +/* Copyright (C) 1991, 1994, 1997-1998, 2000, 2003-2024 Free Software + Foundation, Inc. + + NOTE: The canonical source of this file is maintained with the GNU C + Library. Bugs can be reported to bug-glibc@prep.ai.mit.edu. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +#include + +/* Include errno.h *after* sys/types.h to work around header problems + on AIX 3.2.5. */ +#include +#ifndef __set_errno +# define __set_errno(ev) ((errno) = (ev)) +#endif + +#include +#include + +#if defined _WIN32 && ! defined __CYGWIN__ +# define WIN32_LEAN_AND_MEAN +# include +#endif + +#if _LIBC +# if HAVE_GNU_LD +# define environ __environ +# else +extern char **environ; +# endif +#endif + +#if _LIBC +/* This lock protects against simultaneous modifications of 'environ'. */ +# include +__libc_lock_define_initialized (static, envlock) +# define LOCK __libc_lock_lock (envlock) +# define UNLOCK __libc_lock_unlock (envlock) +#else +# define LOCK +# define UNLOCK +#endif + +#if defined _WIN32 && ! defined __CYGWIN__ +/* Don't assume that UNICODE is not defined. */ +# undef SetEnvironmentVariable +# define SetEnvironmentVariable SetEnvironmentVariableA +#endif + +static int +_unsetenv (const char *name) +{ + size_t len; +#if !HAVE_DECL__PUTENV + char **ep; +#endif + + if (name == NULL || *name == '\0' || strchr (name, '=') != NULL) + { + __set_errno (EINVAL); + return -1; + } + + len = strlen (name); + +#if HAVE_DECL__PUTENV + { + int putenv_result; + char *name_ = malloc (len + 2); + memcpy (name_, name, len); + name_[len] = '='; + name_[len + 1] = 0; + putenv_result = _putenv (name_); + free (name_); + return putenv_result; + } +#else + + LOCK; + + ep = environ; + while (*ep != NULL) + if (!strncmp (*ep, name, len) && (*ep)[len] == '=') + { + /* Found it. Remove this pointer by moving later ones back. */ + char **dp = ep; + + do + dp[0] = dp[1]; + while (*dp++); + /* Continue the loop in case NAME appears again. */ + } + else + ++ep; + + UNLOCK; + + return 0; +#endif +} + + +/* Put STRING, which is of the form "NAME=VALUE", in the environment. + If STRING contains no '=', then remove STRING from the environment. */ +int +putenv (char *string) +{ + const char *name_end = strchr (string, '='); + char **ep; + + if (name_end == NULL) + { + /* Remove the variable from the environment. */ + return _unsetenv (string); + } + +#if HAVE_DECL__PUTENV + /* Rely on _putenv to allocate the new environment. If other + parts of the application use _putenv, the !HAVE_DECL__PUTENV code + would fight over who owns the environ vector, causing a crash. */ + if (name_end[1]) + return _putenv (string); + else + { + /* _putenv ("NAME=") unsets NAME, so invoke _putenv ("NAME= ") + to allocate the environ vector and then replace the new + entry with "NAME=". */ + int putenv_result; + char *name_x = malloc (name_end - string + sizeof "= "); + if (!name_x) + return -1; + memcpy (name_x, string, name_end - string + 1); + name_x[name_end - string + 1] = ' '; + name_x[name_end - string + 2] = 0; + putenv_result = _putenv (name_x); + for (ep = environ; *ep; ep++) + if (strcmp (*ep, name_x) == 0) + { + *ep = string; + break; + } +# if defined _WIN32 && ! defined __CYGWIN__ + if (putenv_result == 0) + { + /* _putenv propagated "NAME= " into the subprocess environment; + fix that by calling SetEnvironmentVariable directly. */ + name_x[name_end - string] = 0; + putenv_result = SetEnvironmentVariable (name_x, "") ? 0 : -1; + errno = ENOMEM; /* ENOMEM is the only way to fail. */ + } +# endif + free (name_x); + return putenv_result; + } +#else + for (ep = environ; *ep; ep++) + if (strncmp (*ep, string, name_end - string) == 0 + && (*ep)[name_end - string] == '=') + break; + + if (*ep) + *ep = string; + else + { + static char **last_environ = NULL; + size_t size = ep - environ; + char **new_environ = malloc ((size + 2) * sizeof *new_environ); + if (! new_environ) + return -1; + new_environ[0] = string; + memcpy (new_environ + 1, environ, (size + 1) * sizeof *new_environ); + free (last_environ); + last_environ = new_environ; + environ = new_environ; + } + + return 0; +#endif +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/rmdir.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/rmdir.c new file mode 100644 index 00000000..04e43162 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/rmdir.c @@ -0,0 +1,56 @@ +/* Work around rmdir bugs. + + Copyright (C) 1988, 1990, 1999, 2003-2006, 2009-2024 Free Software + Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +#include + +#include +#include + +#include "filename.h" + +#undef rmdir +#if defined _WIN32 && !defined __CYGWIN__ +# define rmdir _rmdir +#endif + +/* Remove directory DIR. + Return 0 if successful, -1 if not. */ + +int +rpl_rmdir (char const *dir) +{ + /* Work around cygwin 1.5.x bug where rmdir("dir/./") succeeds. */ + size_t len = strlen (dir); + int result; + while (len && ISSLASH (dir[len - 1])) + len--; + if (len && dir[len - 1] == '.' && (1 == len || ISSLASH (dir[len - 2]))) + { + errno = EINVAL; + return -1; + } + result = rmdir (dir); + /* Work around mingw bug, where rmdir("file/") fails with EINVAL + instead of ENOTDIR. We've already filtered out trailing ., the + only reason allowed by POSIX for EINVAL. */ + if (result == -1 && errno == EINVAL) + errno = ENOTDIR; + return result; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/root-uid.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/root-uid.h new file mode 100644 index 00000000..ba50bfd4 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/root-uid.h @@ -0,0 +1,30 @@ +/* The user ID that always has appropriate privileges in the POSIX sense. + + Copyright 2012-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Paul Eggert. */ + +#ifndef ROOT_UID_H_ +#define ROOT_UID_H_ + +/* The user ID that always has appropriate privileges in the POSIX sense. */ +#ifdef __TANDEM +# define ROOT_UID 65535 +#else +# define ROOT_UID 0 +#endif + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/sched.in.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/sched.in.h new file mode 100644 index 00000000..838fb12b --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/sched.in.h @@ -0,0 +1,111 @@ +/* A GNU-like . + Copyright (C) 2008-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef _@GUARD_PREFIX@_SCHED_H + +#if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +#endif +@PRAGMA_COLUMNS@ + +/* This file uses #include_next of a system file that defines time_t. + For the 'year2038' module to work right, needs to have been + included before. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +/* The include_next requires a split double-inclusion guard. */ +#if @HAVE_SCHED_H@ +# if @HAVE_SYS_CDEFS_H@ +# include +# endif +# @INCLUDE_NEXT@ @NEXT_SCHED_H@ +#endif + +#ifndef _@GUARD_PREFIX@_SCHED_H +#define _@GUARD_PREFIX@_SCHED_H + +/* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +/* Get pid_t. + This is needed on glibc 2.11 (see + glibc bug ) + and Mac OS X 10.5. */ +#include + +#ifdef __KLIBC__ +/* On OS/2 kLIBC, struct sched_param is in spawn.h. */ +# include +#endif + +#ifdef __VMS +/* On OpenVMS, struct sched_param is in . */ +# include +#endif + +/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ + +/* The definition of _GL_WARN_ON_USE is copied here. */ + +#if !@HAVE_STRUCT_SCHED_PARAM@ + +# if !GNULIB_defined_struct_sched_param +struct sched_param +{ + int sched_priority; +}; +# define GNULIB_defined_struct_sched_param 1 +# endif + +#endif + +#if !(defined SCHED_FIFO && defined SCHED_RR && defined SCHED_OTHER) +# define SCHED_FIFO 1 +# define SCHED_RR 2 +# define SCHED_OTHER 0 +#endif + +#if @GNULIB_SCHED_YIELD@ +# if @REPLACE_SCHED_YIELD@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef sched_yield +# define sched_yield rpl_sched_yield +# endif +_GL_FUNCDECL_RPL (sched_yield, int, (void)); +_GL_CXXALIAS_RPL (sched_yield, int, (void)); +# else +# if !@HAVE_SCHED_YIELD@ +_GL_FUNCDECL_SYS (sched_yield, int, (void)); +# endif +_GL_CXXALIAS_SYS (sched_yield, int, (void)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (sched_yield); +# endif +#elif defined GNULIB_POSIXCHECK +# undef sched_yield +# if HAVE_RAW_DECL_SCHED_YIELD +_GL_WARN_ON_USE (sched_yield, "sched_yield is not portable - " + "use gnulib module sched_yield for portability"); +# endif +#endif + +#endif /* _@GUARD_PREFIX@_SCHED_H */ +#endif /* _@GUARD_PREFIX@_SCHED_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/select.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/select.c new file mode 100644 index 00000000..5f7a5d00 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/select.c @@ -0,0 +1,601 @@ +/* Emulation for select(2) + Contributed by Paolo Bonzini. + + Copyright 2008-2024 Free Software Foundation, Inc. + + This file is part of gnulib. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +#if defined _WIN32 && ! defined __CYGWIN__ +/* Native Windows. */ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +/* Get the overridden 'struct timeval'. */ +#include + +#if GNULIB_MSVC_NOTHROW +# include "msvc-nothrow.h" +#else +# include +#endif + +#undef select + +/* Don't assume that UNICODE is not defined. */ +#undef GetModuleHandle +#define GetModuleHandle GetModuleHandleA +#undef PeekConsoleInput +#define PeekConsoleInput PeekConsoleInputA +#undef CreateEvent +#define CreateEvent CreateEventA +#undef PeekMessage +#define PeekMessage PeekMessageA +#undef DispatchMessage +#define DispatchMessage DispatchMessageA + +/* Avoid warnings from gcc -Wcast-function-type. */ +#define GetProcAddress \ + (void *) GetProcAddress + +struct bitset { + unsigned char in[FD_SETSIZE / CHAR_BIT]; + unsigned char out[FD_SETSIZE / CHAR_BIT]; +}; + +/* Declare data structures for ntdll functions. */ +typedef struct _FILE_PIPE_LOCAL_INFORMATION { + ULONG NamedPipeType; + ULONG NamedPipeConfiguration; + ULONG MaximumInstances; + ULONG CurrentInstances; + ULONG InboundQuota; + ULONG ReadDataAvailable; + ULONG OutboundQuota; + ULONG WriteQuotaAvailable; + ULONG NamedPipeState; + ULONG NamedPipeEnd; +} FILE_PIPE_LOCAL_INFORMATION, *PFILE_PIPE_LOCAL_INFORMATION; + +typedef struct _IO_STATUS_BLOCK +{ + union { + DWORD Status; + PVOID Pointer; + } u; + ULONG_PTR Information; +} IO_STATUS_BLOCK, *PIO_STATUS_BLOCK; + +typedef enum _FILE_INFORMATION_CLASS { + FilePipeLocalInformation = 24 +} FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS; + +typedef DWORD (WINAPI *PNtQueryInformationFile) + (HANDLE, IO_STATUS_BLOCK *, VOID *, ULONG, FILE_INFORMATION_CLASS); + +#ifndef PIPE_BUF +#define PIPE_BUF 512 +#endif + +static BOOL IsConsoleHandle (HANDLE h) +{ + DWORD mode; + return GetConsoleMode (h, &mode) != 0; +} + +static BOOL +IsSocketHandle (HANDLE h) +{ + WSANETWORKEVENTS ev; + + if (IsConsoleHandle (h)) + return FALSE; + + /* Under Wine, it seems that getsockopt returns 0 for pipes too. + WSAEnumNetworkEvents instead distinguishes the two correctly. */ + ev.lNetworkEvents = 0xDEADBEEF; + WSAEnumNetworkEvents ((SOCKET) h, NULL, &ev); + return ev.lNetworkEvents != 0xDEADBEEF; +} + +/* Compute output fd_sets for libc descriptor FD (whose Windows handle is + H). */ + +static int +windows_poll_handle (HANDLE h, int fd, + struct bitset *rbits, + struct bitset *wbits, + struct bitset *xbits) +{ + BOOL read, write, except; + int i, ret; + INPUT_RECORD *irbuffer; + DWORD avail, nbuffer; + BOOL bRet; + IO_STATUS_BLOCK iosb; + FILE_PIPE_LOCAL_INFORMATION fpli; + static PNtQueryInformationFile NtQueryInformationFile; + static BOOL once_only; + + read = write = except = FALSE; + switch (GetFileType (h)) + { + case FILE_TYPE_DISK: + read = TRUE; + write = TRUE; + break; + + case FILE_TYPE_PIPE: + if (!once_only) + { + NtQueryInformationFile = (PNtQueryInformationFile) + GetProcAddress (GetModuleHandle ("ntdll.dll"), + "NtQueryInformationFile"); + once_only = TRUE; + } + + if (PeekNamedPipe (h, NULL, 0, NULL, &avail, NULL) != 0) + { + if (avail) + read = TRUE; + } + else if (GetLastError () == ERROR_BROKEN_PIPE) + ; + + else + { + /* It was the write-end of the pipe. Check if it is writable. + If NtQueryInformationFile fails, optimistically assume the pipe is + writable. This could happen on Windows 9x, where + NtQueryInformationFile is not available, or if we inherit a pipe + that doesn't permit FILE_READ_ATTRIBUTES access on the write end + (I think this should not happen since Windows XP SP2; WINE seems + fine too). Otherwise, ensure that enough space is available for + atomic writes. */ + memset (&iosb, 0, sizeof (iosb)); + memset (&fpli, 0, sizeof (fpli)); + + if (!NtQueryInformationFile + || NtQueryInformationFile (h, &iosb, &fpli, sizeof (fpli), + FilePipeLocalInformation) + || fpli.WriteQuotaAvailable >= PIPE_BUF + || (fpli.OutboundQuota < PIPE_BUF && + fpli.WriteQuotaAvailable == fpli.OutboundQuota)) + write = TRUE; + } + break; + + case FILE_TYPE_CHAR: + write = TRUE; + if (!(rbits->in[fd / CHAR_BIT] & (1 << (fd & (CHAR_BIT - 1))))) + break; + + ret = WaitForSingleObject (h, 0); + if (ret == WAIT_OBJECT_0) + { + if (!IsConsoleHandle (h)) + { + read = TRUE; + break; + } + + nbuffer = avail = 0; + bRet = GetNumberOfConsoleInputEvents (h, &nbuffer); + + /* Screen buffers handles are filtered earlier. */ + assert (bRet); + if (nbuffer == 0) + { + except = TRUE; + break; + } + + irbuffer = (INPUT_RECORD *) alloca (nbuffer * sizeof (INPUT_RECORD)); + bRet = PeekConsoleInput (h, irbuffer, nbuffer, &avail); + if (!bRet || avail == 0) + { + except = TRUE; + break; + } + + for (i = 0; i < avail; i++) + if (irbuffer[i].EventType == KEY_EVENT) + read = TRUE; + } + break; + + default: + ret = WaitForSingleObject (h, 0); + write = TRUE; + if (ret == WAIT_OBJECT_0) + read = TRUE; + + break; + } + + ret = 0; + if (read && (rbits->in[fd / CHAR_BIT] & (1 << (fd & (CHAR_BIT - 1))))) + { + rbits->out[fd / CHAR_BIT] |= (1 << (fd & (CHAR_BIT - 1))); + ret++; + } + + if (write && (wbits->in[fd / CHAR_BIT] & (1 << (fd & (CHAR_BIT - 1))))) + { + wbits->out[fd / CHAR_BIT] |= (1 << (fd & (CHAR_BIT - 1))); + ret++; + } + + if (except && (xbits->in[fd / CHAR_BIT] & (1 << (fd & (CHAR_BIT - 1))))) + { + xbits->out[fd / CHAR_BIT] |= (1 << (fd & (CHAR_BIT - 1))); + ret++; + } + + return ret; +} + +int +rpl_select (int nfds, fd_set *rfds, fd_set *wfds, fd_set *xfds, + struct timeval *timeout) +#undef timeval +{ + static struct timeval tv0; + static HANDLE hEvent; + HANDLE h, handle_array[FD_SETSIZE + 2]; + fd_set handle_rfds, handle_wfds, handle_xfds; + struct bitset rbits, wbits, xbits; + unsigned char anyfds_in[FD_SETSIZE / CHAR_BIT]; + DWORD ret, wait_timeout, nhandles, nsock, nbuffer; + MSG msg; + int i, fd, rc; + clock_t tend; + + if (nfds < 0 || nfds > FD_SETSIZE) + { + errno = EINVAL; + return -1; + } + + if (!timeout) + wait_timeout = INFINITE; + else + { + wait_timeout = timeout->tv_sec * 1000 + timeout->tv_usec / 1000; + + /* select is also used as a portable usleep. */ + if (!rfds && !wfds && !xfds) + { + Sleep (wait_timeout); + return 0; + } + } + + if (!hEvent) + hEvent = CreateEvent (NULL, FALSE, FALSE, NULL); + + handle_array[0] = hEvent; + nhandles = 1; + nsock = 0; + + /* Copy descriptors to bitsets. At the same time, eliminate + bits in the "wrong" direction for console input buffers + and screen buffers, because screen buffers are waitable + and they will block until a character is available. */ + memset (&rbits, 0, sizeof (rbits)); + memset (&wbits, 0, sizeof (wbits)); + memset (&xbits, 0, sizeof (xbits)); + memset (anyfds_in, 0, sizeof (anyfds_in)); + if (rfds) + for (i = 0; i < rfds->fd_count; i++) + { + fd = rfds->fd_array[i]; + h = (HANDLE) _get_osfhandle (fd); + if (IsConsoleHandle (h) + && !GetNumberOfConsoleInputEvents (h, &nbuffer)) + continue; + + rbits.in[fd / CHAR_BIT] |= 1 << (fd & (CHAR_BIT - 1)); + anyfds_in[fd / CHAR_BIT] |= 1 << (fd & (CHAR_BIT - 1)); + } + else + rfds = (fd_set *) alloca (sizeof (fd_set)); + + if (wfds) + for (i = 0; i < wfds->fd_count; i++) + { + fd = wfds->fd_array[i]; + h = (HANDLE) _get_osfhandle (fd); + if (IsConsoleHandle (h) + && GetNumberOfConsoleInputEvents (h, &nbuffer)) + continue; + + wbits.in[fd / CHAR_BIT] |= 1 << (fd & (CHAR_BIT - 1)); + anyfds_in[fd / CHAR_BIT] |= 1 << (fd & (CHAR_BIT - 1)); + } + else + wfds = (fd_set *) alloca (sizeof (fd_set)); + + if (xfds) + for (i = 0; i < xfds->fd_count; i++) + { + fd = xfds->fd_array[i]; + xbits.in[fd / CHAR_BIT] |= 1 << (fd & (CHAR_BIT - 1)); + anyfds_in[fd / CHAR_BIT] |= 1 << (fd & (CHAR_BIT - 1)); + } + else + xfds = (fd_set *) alloca (sizeof (fd_set)); + + /* Zero all the fd_sets, including the application's. */ + FD_ZERO (rfds); + FD_ZERO (wfds); + FD_ZERO (xfds); + FD_ZERO (&handle_rfds); + FD_ZERO (&handle_wfds); + FD_ZERO (&handle_xfds); + + /* Classify handles. Create fd sets for sockets, poll the others. */ + for (i = 0; i < nfds; i++) + { + if ((anyfds_in[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1)))) == 0) + continue; + + h = (HANDLE) _get_osfhandle (i); + if (!h) + { + errno = EBADF; + return -1; + } + + if (IsSocketHandle (h)) + { + int requested = FD_CLOSE; + + /* See above; socket handles are mapped onto select, but we + need to map descriptors to handles. */ + if (rbits.in[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1)))) + { + requested |= FD_READ | FD_ACCEPT; + FD_SET ((SOCKET) h, rfds); + FD_SET ((SOCKET) h, &handle_rfds); + } + if (wbits.in[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1)))) + { + requested |= FD_WRITE | FD_CONNECT; + FD_SET ((SOCKET) h, wfds); + FD_SET ((SOCKET) h, &handle_wfds); + } + if (xbits.in[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1)))) + { + requested |= FD_OOB; + FD_SET ((SOCKET) h, xfds); + FD_SET ((SOCKET) h, &handle_xfds); + } + + WSAEventSelect ((SOCKET) h, hEvent, requested); + nsock++; + } + else + { + handle_array[nhandles++] = h; + + /* Poll now. If we get an event, do not wait below. */ + if (wait_timeout != 0 + && windows_poll_handle (h, i, &rbits, &wbits, &xbits)) + wait_timeout = 0; + } + } + + /* Place a sentinel at the end of the array. */ + handle_array[nhandles] = NULL; + + /* When will the waiting period expire? */ + if (wait_timeout != INFINITE) + tend = clock () + wait_timeout; + +restart: + if (wait_timeout == 0 || nsock == 0) + rc = 0; + else + { + /* See if we need to wait in the loop below. If any select is ready, + do MsgWaitForMultipleObjects anyway to dispatch messages, but + no need to call select again. */ + rc = select (0, &handle_rfds, &handle_wfds, &handle_xfds, &tv0); + if (rc == 0) + { + /* Restore the fd_sets for the other select we do below. */ + memcpy (&handle_rfds, rfds, sizeof (fd_set)); + memcpy (&handle_wfds, wfds, sizeof (fd_set)); + memcpy (&handle_xfds, xfds, sizeof (fd_set)); + } + else + wait_timeout = 0; + } + + /* How much is left to wait? */ + if (wait_timeout != INFINITE) + { + clock_t tnow = clock (); + if (tend >= tnow) + wait_timeout = tend - tnow; + else + wait_timeout = 0; + } + + for (;;) + { + ret = MsgWaitForMultipleObjects (nhandles, handle_array, FALSE, + wait_timeout, QS_ALLINPUT); + + if (ret == WAIT_OBJECT_0 + nhandles) + { + /* new input of some other kind */ + BOOL bRet; + while ((bRet = PeekMessage (&msg, NULL, 0, 0, PM_REMOVE)) != 0) + { + TranslateMessage (&msg); + DispatchMessage (&msg); + } + } + else + break; + } + + /* If we haven't done it yet, check the status of the sockets. */ + if (rc == 0 && nsock > 0) + rc = select (0, &handle_rfds, &handle_wfds, &handle_xfds, &tv0); + + if (nhandles > 1) + { + /* Count results that are not counted in the return value of select. */ + nhandles = 1; + for (i = 0; i < nfds; i++) + { + if ((anyfds_in[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1)))) == 0) + continue; + + h = (HANDLE) _get_osfhandle (i); + if (h == handle_array[nhandles]) + { + /* Not a socket. */ + nhandles++; + windows_poll_handle (h, i, &rbits, &wbits, &xbits); + if (rbits.out[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1))) + || wbits.out[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1))) + || xbits.out[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1)))) + rc++; + } + } + + if (rc == 0 + && (wait_timeout == INFINITE + /* If NHANDLES > 1, but no bits are set, it means we've + been told incorrectly that some handle was signaled. + This happens with anonymous pipes, which always cause + MsgWaitForMultipleObjects to exit immediately, but no + data is found ready to be read by windows_poll_handle. + To avoid a total failure (whereby we return zero and + don't wait at all), let's poll in a more busy loop. */ + || (wait_timeout != 0 && nhandles > 1))) + { + /* Sleep 1 millisecond to avoid busy wait and retry with the + original fd_sets. */ + memcpy (&handle_rfds, rfds, sizeof (fd_set)); + memcpy (&handle_wfds, wfds, sizeof (fd_set)); + memcpy (&handle_xfds, xfds, sizeof (fd_set)); + SleepEx (1, TRUE); + goto restart; + } + if (timeout && wait_timeout == 0 && rc == 0) + timeout->tv_sec = timeout->tv_usec = 0; + } + + /* Now fill in the results. */ + FD_ZERO (rfds); + FD_ZERO (wfds); + FD_ZERO (xfds); + nhandles = 1; + for (i = 0; i < nfds; i++) + { + if ((anyfds_in[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1)))) == 0) + continue; + + h = (HANDLE) _get_osfhandle (i); + if (h != handle_array[nhandles]) + { + /* Perform handle->descriptor mapping. */ + SOCKET s = (SOCKET) h; + WSAEventSelect (s, NULL, 0); + if (FD_ISSET (s, &handle_rfds)) + FD_SET (i, rfds); + if (FD_ISSET (s, &handle_wfds)) + FD_SET (i, wfds); + if (FD_ISSET (s, &handle_xfds)) + FD_SET (i, xfds); + } + else + { + /* Not a socket. */ + nhandles++; + if (rbits.out[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1)))) + FD_SET (i, rfds); + if (wbits.out[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1)))) + FD_SET (i, wfds); + if (xbits.out[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1)))) + FD_SET (i, xfds); + } + } + + return rc; +} + +#else /* ! Native Windows. */ + +#include /* NULL */ +#include +#include + +#undef select + +int +rpl_select (int nfds, fd_set *rfds, fd_set *wfds, fd_set *xfds, + struct timeval *timeout) +{ + int i; + + /* FreeBSD 8.2 has a bug: it does not always detect invalid fds. */ + if (nfds < 0 || nfds > FD_SETSIZE) + { + errno = EINVAL; + return -1; + } + for (i = 0; i < nfds; i++) + { + if (((rfds && FD_ISSET (i, rfds)) + || (wfds && FD_ISSET (i, wfds)) + || (xfds && FD_ISSET (i, xfds))) + && dup2 (i, i) != i) + return -1; + } + + /* Interix 3.5 has a bug: it does not support nfds == 0. */ + if (nfds == 0) + { + nfds = 1; + rfds = NULL; + wfds = NULL; + xfds = NULL; + } + return select (nfds, rfds, wfds, xfds, timeout); +} + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/setsockopt.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/setsockopt.c new file mode 100644 index 00000000..42cc3dcc --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/setsockopt.c @@ -0,0 +1,65 @@ +/* setsockopt.c --- wrappers for Windows setsockopt function + + Copyright (C) 2008-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Paolo Bonzini */ + +#include + +#define WIN32_LEAN_AND_MEAN +/* Get winsock2.h. */ +#include + +/* Get struct timeval. */ +#include + +/* Get set_winsock_errno, FD_TO_SOCKET etc. */ +#include "w32sock.h" + +#undef setsockopt + +int +rpl_setsockopt (int fd, int level, int optname, const void *optval, socklen_t optlen) +{ + SOCKET sock = FD_TO_SOCKET (fd); + int r; + + if (sock == INVALID_SOCKET) + { + errno = EBADF; + return -1; + } + else + { + if (level == SOL_SOCKET + && (optname == SO_RCVTIMEO || optname == SO_SNDTIMEO)) + { + const struct timeval *tv = optval; + int milliseconds = tv->tv_sec * 1000 + tv->tv_usec / 1000; + optval = &milliseconds; + r = setsockopt (sock, level, optname, optval, sizeof (int)); + } + else + { + r = setsockopt (sock, level, optname, optval, optlen); + } + + if (r < 0) + set_winsock_errno (); + + return r; + } +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/signature.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/signature.h new file mode 100644 index 00000000..d2a24622 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/signature.h @@ -0,0 +1,48 @@ +/* Macro for checking that a function declaration is compliant. + Copyright (C) 2009-2024 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 . */ + +#ifndef SIGNATURE_CHECK + +/* Check that the function FN takes the specified arguments ARGS with + a return type of RET. This header is designed to be included after + and the one system header that is supposed to contain + the function being checked, but prior to any other system headers + that are necessary for the unit test. Therefore, this file does + not include any system headers, nor reference anything outside of + the macro arguments. For an example, if foo.h should provide: + + extern int foo (char, float); + + then the unit test named test-foo.c would start out with: + + #include + #include + #include "signature.h" + SIGNATURE_CHECK (foo, int, (char, float)); + #include + ... +*/ +# define SIGNATURE_CHECK(fn, ret, args) \ + SIGNATURE_CHECK1 (fn, ret, args, __LINE__) + +/* Necessary to allow multiple SIGNATURE_CHECK lines in a unit test. + Note that the checks must not occupy the same line. */ +# define SIGNATURE_CHECK1(fn, ret, args, id) \ + SIGNATURE_CHECK2 (fn, ret, args, id) /* macroexpand line */ +# define SIGNATURE_CHECK2(fn, ret, args, id) \ + _GL_UNUSED static ret (*signature_check ## id) args = fn + +#endif /* SIGNATURE_CHECK */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/signbitd.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/signbitd.c new file mode 100644 index 00000000..d662192a --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/signbitd.c @@ -0,0 +1,64 @@ +/* signbit() macro: Determine the sign bit of a floating-point number. + Copyright (C) 2007-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +#include +#include "isnand-nolibm.h" +#include "float+.h" + +#ifdef gl_signbitd_OPTIMIZED_MACRO +# undef gl_signbitd +#endif + +int +gl_signbitd (double arg) +{ +#if defined DBL_SIGNBIT_WORD && defined DBL_SIGNBIT_BIT + /* The use of a union to extract the bits of the representation of a + 'long double' is safe in practice, despite of the "aliasing rules" of + C99, because the GCC docs say + "Even with '-fstrict-aliasing', type-punning is allowed, provided the + memory is accessed through the union type." + and similarly for other compilers. */ +# define NWORDS \ + ((sizeof (double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) + union { double value; unsigned int word[NWORDS]; } m; + m.value = arg; + return (m.word[DBL_SIGNBIT_WORD] >> DBL_SIGNBIT_BIT) & 1; +#elif HAVE_COPYSIGN_IN_LIBC + return copysign (1.0, arg) < 0; +#else + /* This does not do the right thing for NaN, but this is irrelevant for + most use cases. */ + if (isnand (arg)) + return 0; + if (arg < 0.0) + return 1; + else if (arg == 0.0) + { + /* Distinguish 0.0 and -0.0. */ + static double plus_zero = 0.0; + double arg_mem = arg; + return (memcmp (&plus_zero, &arg_mem, SIZEOF_DBL) != 0); + } + else + return 0; +#endif +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/signbitf.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/signbitf.c new file mode 100644 index 00000000..f24caf4a --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/signbitf.c @@ -0,0 +1,64 @@ +/* signbit() macro: Determine the sign bit of a floating-point number. + Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +#include +#include "isnanf-nolibm.h" +#include "float+.h" + +#ifdef gl_signbitf_OPTIMIZED_MACRO +# undef gl_signbitf +#endif + +int +gl_signbitf (float arg) +{ +#if defined FLT_SIGNBIT_WORD && defined FLT_SIGNBIT_BIT + /* The use of a union to extract the bits of the representation of a + 'long double' is safe in practice, despite of the "aliasing rules" of + C99, because the GCC docs say + "Even with '-fstrict-aliasing', type-punning is allowed, provided the + memory is accessed through the union type." + and similarly for other compilers. */ +# define NWORDS \ + ((sizeof (float) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) + union { float value; unsigned int word[NWORDS]; } m; + m.value = arg; + return (m.word[FLT_SIGNBIT_WORD] >> FLT_SIGNBIT_BIT) & 1; +#elif HAVE_COPYSIGNF_IN_LIBC + return copysignf (1.0f, arg) < 0; +#else + /* This does not do the right thing for NaN, but this is irrelevant for + most use cases. */ + if (isnanf (arg)) + return 0; + if (arg < 0.0f) + return 1; + else if (arg == 0.0f) + { + /* Distinguish 0.0f and -0.0f. */ + static float plus_zero = 0.0f; + float arg_mem = arg; + return (memcmp (&plus_zero, &arg_mem, SIZEOF_FLT) != 0); + } + else + return 0; +#endif +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/signbitl.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/signbitl.c new file mode 100644 index 00000000..164b89ac --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/signbitl.c @@ -0,0 +1,64 @@ +/* signbit() macro: Determine the sign bit of a floating-point number. + Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +#include +#include "isnanl-nolibm.h" +#include "float+.h" + +#ifdef gl_signbitl_OPTIMIZED_MACRO +# undef gl_signbitl +#endif + +int +gl_signbitl (long double arg) +{ +#if defined LDBL_SIGNBIT_WORD && defined LDBL_SIGNBIT_BIT + /* The use of a union to extract the bits of the representation of a + 'long double' is safe in practice, despite of the "aliasing rules" of + C99, because the GCC docs say + "Even with '-fstrict-aliasing', type-punning is allowed, provided the + memory is accessed through the union type." + and similarly for other compilers. */ +# define NWORDS \ + ((sizeof (long double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) + union { long double value; unsigned int word[NWORDS]; } m; + m.value = arg; + return (m.word[LDBL_SIGNBIT_WORD] >> LDBL_SIGNBIT_BIT) & 1; +#elif HAVE_COPYSIGNL_IN_LIBC + return copysignl (1.0L, arg) < 0; +#else + /* This does not do the right thing for NaN, but this is irrelevant for + most use cases. */ + if (isnanl (arg)) + return 0; + if (arg < 0.0L) + return 1; + else if (arg == 0.0L) + { + /* Distinguish 0.0L and -0.0L. */ + static long double plus_zero = 0.0L; + long double arg_mem = arg; + return (memcmp (&plus_zero, &arg_mem, SIZEOF_LDBL) != 0); + } + else + return 0; +#endif +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/signed-nan.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/signed-nan.h new file mode 100644 index 00000000..18a550a7 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/signed-nan.h @@ -0,0 +1,88 @@ +/* Macros for quiet not-a-number. + Copyright (C) 2023-2024 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 . */ + +#ifndef _SIGNED_NAN_H +#define _SIGNED_NAN_H + +#include + +#include "nan.h" + + +/* Returns a quiet 'float' NaN with sign bit == 0. */ +_GL_UNUSED static float +positive_NaNf () +{ + /* 'volatile' works around a GCC bug: + */ + float volatile nan = NaNf (); + return (signbit (nan) ? - nan : nan); +} + +/* Returns a quiet 'float' NaN with sign bit == 1. */ +_GL_UNUSED static float +negative_NaNf () +{ + /* 'volatile' works around a GCC bug: + */ + float volatile nan = NaNf (); + return (signbit (nan) ? nan : - nan); +} + + +/* Returns a quiet 'double' NaN with sign bit == 0. */ +_GL_UNUSED static double +positive_NaNd () +{ + /* 'volatile' works around a GCC bug: + */ + double volatile nan = NaNd (); + return (signbit (nan) ? - nan : nan); +} + +/* Returns a quiet 'double' NaN with sign bit == 1. */ +_GL_UNUSED static double +negative_NaNd () +{ + /* 'volatile' works around a GCC bug: + */ + double volatile nan = NaNd (); + return (signbit (nan) ? nan : - nan); +} + + +/* Returns a quiet 'long double' NaN with sign bit == 0. */ +_GL_UNUSED static long double +positive_NaNl () +{ + /* 'volatile' works around a GCC bug: + */ + long double volatile nan = NaNl (); + return (signbit (nan) ? - nan : nan); +} + +/* Returns a quiet 'long double' NaN with sign bit == 1. */ +_GL_UNUSED static long double +negative_NaNl () +{ + /* 'volatile' works around a GCC bug: + */ + long double volatile nan = NaNl (); + return (signbit (nan) ? nan : - nan); +} + + +#endif /* _SIGNED_NAN_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/signed-snan.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/signed-snan.h new file mode 100644 index 00000000..7e6483a7 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/signed-snan.h @@ -0,0 +1,142 @@ +/* Macros for signalling not-a-number. + Copyright (C) 2023-2024 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 . */ + +#ifndef _SIGNED_SNAN_H +#define _SIGNED_SNAN_H + +#include "signed-nan.h" +#include "snan.h" + + +#if HAVE_SNANF + +/* Returns a signalling 'float' NaN with sign bit == 0 in memory. */ +_GL_UNUSED static memory_float +memory_positive_SNaNf () +{ + return construct_memory_SNaNf (positive_NaNf ()); +} + +/* Returns a signalling 'float' NaN with sign bit == 1 in memory. */ +_GL_UNUSED static memory_float +memory_negative_SNaNf () +{ + return construct_memory_SNaNf (negative_NaNf ()); +} + +/* Note: On 32-bit x86 processors, as well as on x86_64 processors with + CC="gcc -mfpmath=387", the following functions may return a quiet NaN + instead. Use the functions with 'memory_' prefix if you need to avoid this. + See + for details. */ + +/* Returns a signalling 'float' NaN with sign bit == 0. */ +_GL_UNUSED static float +positive_SNaNf () +{ + return memory_positive_SNaNf ().value; +} + +/* Returns a signalling 'float' NaN with sign bit == 1. */ +_GL_UNUSED static float +negative_SNaNf () +{ + return memory_negative_SNaNf ().value; +} + +#endif + + +#if HAVE_SNAND + +/* Returns a signalling 'double' NaN with sign bit == 0 in memory. */ +_GL_UNUSED static memory_double +memory_positive_SNaNd () +{ + return construct_memory_SNaNd (positive_NaNd ()); +} + +/* Returns a signalling 'double' NaN with sign bit == 1 in memory. */ +_GL_UNUSED static memory_double +memory_negative_SNaNd () +{ + return construct_memory_SNaNd (negative_NaNd ()); +} + +/* Note: On 32-bit x86 processors, as well as on x86_64 processors with + CC="gcc -mfpmath=387", the following functions may return a quiet NaN + instead. Use the functions with 'memory_' prefix if you need to avoid this. + See + for details. */ + +/* Returns a signalling 'double' NaN with sign bit == 0. */ +_GL_UNUSED static double +positive_SNaNd () +{ + return memory_positive_SNaNd ().value; +} + +/* Returns a signalling 'double' NaN with sign bit == 1. */ +_GL_UNUSED static double +negative_SNaNd () +{ + return memory_negative_SNaNd ().value; +} + +#endif + + +#if HAVE_SNANL + +/* Returns a signalling 'long double' NaN with sign bit == 0 in memory. */ +_GL_UNUSED static memory_long_double +memory_positive_SNaNl () +{ + return construct_memory_SNaNl (positive_NaNl ()); +} + +/* Returns a signalling 'long double' NaN with sign bit == 1 in memory. */ +_GL_UNUSED static memory_long_double +memory_negative_SNaNl () +{ + return construct_memory_SNaNl (negative_NaNl ()); +} + +/* Note: On 32-bit x86 processors, as well as on x86_64 processors with + CC="gcc -mfpmath=387", if HAVE_SAME_LONG_DOUBLE_AS_DOUBLE is 1, the + following functions may return a quiet NaN instead. Use the functions + with 'memory_' prefix if you need to avoid this. See + + for details. */ + +/* Returns a signalling 'long double' NaN with sign bit == 0. */ +_GL_UNUSED static long double +positive_SNaNl () +{ + return memory_positive_SNaNl ().value; +} + +/* Returns a signalling 'long double' NaN with sign bit == 1. */ +_GL_UNUSED static long double +negative_SNaNl () +{ + return memory_negative_SNaNl ().value; +} + +#endif + + +#endif /* _SIGNED_SNAN_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/size_max.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/size_max.h new file mode 100644 index 00000000..bd2eb43e --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/size_max.h @@ -0,0 +1,35 @@ +/* size_max.h -- declare SIZE_MAX through system headers + Copyright (C) 2005-2006, 2009-2024 Free Software Foundation, Inc. + Written by Simon Josefsson. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef GNULIB_SIZE_MAX_H +#define GNULIB_SIZE_MAX_H + +/* This file uses HAVE_STDINT_H. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +/* Get SIZE_MAX declaration on systems like Solaris 7/8/9. */ +# include +/* Get SIZE_MAX declaration on systems like glibc 2. */ +# if HAVE_STDINT_H +# include +# endif +/* On systems where these include files don't define it, SIZE_MAX is defined + in config.h. */ + +#endif /* GNULIB_SIZE_MAX_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/sleep.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/sleep.c new file mode 100644 index 00000000..1cab9aa6 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/sleep.c @@ -0,0 +1,74 @@ +/* Pausing execution of the current thread. + Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2007. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +#include + +#if defined _WIN32 && ! defined __CYGWIN__ + +# define WIN32_LEAN_AND_MEAN /* avoid including junk */ +# include + +unsigned int +sleep (unsigned int seconds) +{ + unsigned int remaining; + + /* Sleep for 1 second many times, because + 1. Sleep is not interruptible by Ctrl-C, + 2. we want to avoid arithmetic overflow while multiplying with 1000. */ + for (remaining = seconds; remaining > 0; remaining--) + Sleep (1000); + + return remaining; +} + +#elif HAVE_SLEEP + +# undef sleep + +/* Guarantee unlimited sleep and a reasonable return value. Cygwin + 1.5.x rejects attempts to sleep more than 49.7 days (2**32 + milliseconds), but uses uninitialized memory which results in a + garbage answer. Similarly, Linux 2.6.9 with glibc 2.3.4 has a too + small return value when asked to sleep more than 24.85 days. */ +unsigned int +rpl_sleep (unsigned int seconds) +{ + /* This requires int larger than 16 bits. */ + static_assert (UINT_MAX / 24 / 24 / 60 / 60); + const unsigned int limit = 24 * 24 * 60 * 60; + while (limit < seconds) + { + unsigned int result; + seconds -= limit; + result = sleep (limit); + if (result) + return seconds + result; + } + return sleep (seconds); +} + +#else /* !HAVE_SLEEP */ + + #error "Please port gnulib sleep.c to your platform, possibly using usleep() or select(), then report this to bug-gnulib." + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/snan.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/snan.h new file mode 100644 index 00000000..95235040 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/snan.h @@ -0,0 +1,276 @@ +/* Macros for signalling not-a-number. + Copyright (C) 2007-2024 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 . */ + +#ifndef _SNAN_H +#define _SNAN_H + +#include +#include +#include + +#include "nan.h" + + +/* The bit that distinguishes a quiet NaN from a signalling NaN is, according to + , the most significant bit of the + mantissa field. + According to , this is the + next bit, right below the bit 0 of the exponent. + This bit is + * == 0 to indicate a quiet NaN or Infinity, + == 1 to indicate a signalling NaN, + on these CPUs: hppa, mips (*), sh4. + * == 1 to indicate a quiet NaN, + == 0 to indicate a signalling NaN or Infinity, + on all other CPUs. + On these platforms, additionally a signalling NaN must have some other + mantissa bit == 1, because when all exponent bits are == 1 and all + mantissa bits are == 0, the number denotes ±Infinity. + This NaN encoding is specified by IEEE 754-2008 § 6.2.1. + + (*) On mips CPUs, it depends on the CPU model. The classical behaviour is + as indicated above. On some newer models, it's like on the other CPUs. + On some (but not all!) models this meta-info can be determined from two + special CPU registers: If the "Floating Point Implementation Register" (fir) + bit 23, also known as Has2008 bit, is set, the "Floating Point Control and + Status Register" (fcsr) bit 18, also known as the NAN2008 bit, has the value + - 0 for the classical behaviour, + - 1 for like on the other CPUs. + Both of these bits are read-only. + This module has determined the behaviour at configure time and defines the + C macros MIPS_NAN2008_FLOAT, MIPS_NAN2008_DOUBLE, MIPS_NAN2008_LONG_DOUBLE + accordingly. */ + + +/* 'float' = IEEE 754 single-precision + */ + +#define NWORDS \ + ((sizeof (float) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) +typedef union { float value; unsigned int word[NWORDS]; } memory_float; + +#if defined FLT_EXPBIT0_WORD && defined FLT_EXPBIT0_BIT + +# define HAVE_SNANF 1 + +_GL_UNUSED static memory_float +construct_memory_SNaNf (float quiet_value) +{ + memory_float m; + m.value = quiet_value; + /* Turn the quiet NaN into a signalling NaN. */ + #if FLT_EXPBIT0_BIT > 0 + m.word[FLT_EXPBIT0_WORD] ^= (unsigned int) 1 << (FLT_EXPBIT0_BIT - 1); + #else + m.word[FLT_EXPBIT0_WORD + (FLT_EXPBIT0_WORD < NWORDS / 2 ? 1 : - 1)] + ^= (unsigned int) 1 << (sizeof (unsigned int) * CHAR_BIT - 1); + #endif + /* Set some arbitrary mantissa bit. */ + if (FLT_EXPBIT0_WORD < NWORDS / 2) /* NWORDS > 1 and big endian */ + m.word[FLT_EXPBIT0_WORD + 1] |= (unsigned int) 1 << FLT_EXPBIT0_BIT; + else /* NWORDS == 1 or little endian */ + m.word[0] |= (unsigned int) 1; + return m; +} + +/* Returns a signalling 'float' NaN in memory. */ +_GL_UNUSED static memory_float +memory_SNaNf () +{ + return construct_memory_SNaNf (NaNf ()); +} + +_GL_UNUSED static float +construct_SNaNf (float quiet_value) +{ + return construct_memory_SNaNf (quiet_value).value; +} + +/* Returns a signalling 'float' NaN. + Note: On 32-bit x86 processors, as well as on x86_64 processors with + CC="gcc -mfpmath=387", this function may return a quiet NaN instead. + Use memory_SNaNf() if you need to avoid this. See + + for details. */ +_GL_UNUSED static float +SNaNf () +{ + return memory_SNaNf ().value; +} + +#endif + +#undef NWORDS + + +/* 'double' = IEEE 754 double-precision + */ + +#define NWORDS \ + ((sizeof (double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) +typedef union { double value; unsigned int word[NWORDS]; } memory_double; + +#if defined DBL_EXPBIT0_WORD && defined DBL_EXPBIT0_BIT + +# define HAVE_SNAND 1 + +_GL_UNUSED static memory_double +construct_memory_SNaNd (double quiet_value) +{ + memory_double m; + m.value = quiet_value; + /* Turn the quiet NaN into a signalling NaN. */ + #if DBL_EXPBIT0_BIT > 0 + m.word[DBL_EXPBIT0_WORD] ^= (unsigned int) 1 << (DBL_EXPBIT0_BIT - 1); + #else + m.word[DBL_EXPBIT0_WORD + (DBL_EXPBIT0_WORD < NWORDS / 2 ? 1 : - 1)] + ^= (unsigned int) 1 << (sizeof (unsigned int) * CHAR_BIT - 1); + #endif + /* Set some arbitrary mantissa bit. */ + m.word[DBL_EXPBIT0_WORD + (DBL_EXPBIT0_WORD < NWORDS / 2 ? 1 : - 1)] + |= (unsigned int) 1 << DBL_EXPBIT0_BIT; + return m; +} + +/* Returns a signalling 'double' NaN in memory. */ +_GL_UNUSED static memory_double +memory_SNaNd () +{ + return construct_memory_SNaNd (NaNd ()); +} + +_GL_UNUSED static double +construct_SNaNd (double quiet_value) +{ + return construct_memory_SNaNd (quiet_value).value; +} + +/* Returns a signalling 'double' NaN. + Note: On 32-bit x86 processors, as well as on x86_64 processors with + CC="gcc -mfpmath=387", this function may return a quiet NaN instead. + Use memory_SNaNf() if you need to avoid this. See + + for details. */ +_GL_UNUSED static double +SNaNd () +{ + return memory_SNaNd ().value; +} + +#endif + +#undef NWORDS + + +/* 'long double' = + * if HAVE_SAME_LONG_DOUBLE_AS_DOUBLE: + IEEE 754 double-precision + + * Otherwise: + - On i386, x86_64, ia64: + 80-bits extended-precision + + - On alpha, arm64, loongarch64, mips64, riscv64, s390x, sparc64: + IEEE 754 quadruple-precision + + - On powerpc, powerpc64, powerpc64le: + 2x64-bits double-double + + - On m68k: + 80-bits extended-precision, padded to 96 bits, with non-IEEE exponent + */ + +#define NWORDS \ + ((sizeof (long double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) +typedef union { long double value; unsigned int word[NWORDS]; } + memory_long_double; + +#if defined LDBL_EXPBIT0_WORD && defined LDBL_EXPBIT0_BIT + +# define HAVE_SNANL 1 + +_GL_UNUSED static memory_long_double +construct_memory_SNaNl (long double quiet_value) +{ + memory_long_double m; + m.value = quiet_value; + #if defined __powerpc__ && LDBL_MANT_DIG == 106 + /* This is PowerPC "double double", a pair of two doubles. Inf and NaN are + represented as the corresponding 64-bit IEEE values in the first double; + the second is ignored. Manipulate only the first double. */ + #define HNWORDS \ + ((sizeof (double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) + #else + #define HNWORDS NWORDS + #endif + /* Turn the quiet NaN into a signalling NaN. */ + #if ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_)) && !HAVE_SAME_LONG_DOUBLE_AS_DOUBLE + /* In this representation, the leading 1 of the mantissa is explicitly + stored. */ + #if LDBL_EXPBIT0_BIT > 1 + m.word[LDBL_EXPBIT0_WORD] ^= (unsigned int) 1 << (LDBL_EXPBIT0_BIT - 2); + #else + m.word[LDBL_EXPBIT0_WORD + (LDBL_EXPBIT0_WORD < HNWORDS / 2 ? 1 : - 1)] + ^= (unsigned int) 1 << (sizeof (unsigned int) * CHAR_BIT - 2); + #endif + #else + /* In this representation, the leading 1 of the mantissa is implicit. */ + #if LDBL_EXPBIT0_BIT > 0 + m.word[LDBL_EXPBIT0_WORD] ^= (unsigned int) 1 << (LDBL_EXPBIT0_BIT - 1); + #else + m.word[LDBL_EXPBIT0_WORD + (LDBL_EXPBIT0_WORD < HNWORDS / 2 ? 1 : - 1)] + ^= (unsigned int) 1 << (sizeof (unsigned int) * CHAR_BIT - 1); + #endif + #endif + /* Set some arbitrary mantissa bit. */ + m.word[LDBL_EXPBIT0_WORD + (LDBL_EXPBIT0_WORD < HNWORDS / 2 ? 1 : - 1)] + |= (unsigned int) 1 << LDBL_EXPBIT0_BIT; + #undef HNWORDS + return m; +} + +/* Returns a signalling 'long double' NaN in memory. */ +_GL_UNUSED static memory_long_double +memory_SNaNl () +{ + return construct_memory_SNaNl (NaNl ()); +} + +_GL_UNUSED static long double +construct_SNaNl (long double quiet_value) +{ + return construct_memory_SNaNl (quiet_value).value; +} + +/* Returns a signalling 'long double' NaN. + Note: On 32-bit x86 processors, as well as on x86_64 processors with + CC="gcc -mfpmath=387", if HAVE_SAME_LONG_DOUBLE_AS_DOUBLE is 1, this + function may return a quiet NaN instead. Use memory_SNaNf() if you + need to avoid this. See + + for details. */ +_GL_UNUSED static long double +SNaNl () +{ + return memory_SNaNl ().value; +} + +#endif + +#undef NWORDS + + +#endif /* _SNAN_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/snprintf.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/snprintf.c new file mode 100644 index 00000000..c1b93562 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/snprintf.c @@ -0,0 +1,71 @@ +/* Formatted output to strings. + Copyright (C) 2004, 2006-2024 Free Software Foundation, Inc. + Written by Simon Josefsson and Paul Eggert. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +#include +#include +#include +#include +#include + +#include "vasnprintf.h" + +/* Print formatted output to string STR. Similar to sprintf, but + additional length SIZE limit how much is written into STR. Returns + string length of formatted string (which may be larger than SIZE). + STR may be NULL, in which case nothing will be written. On error, + return a negative value. */ +int +snprintf (char *str, size_t size, const char *format, ...) +{ + char *output; + size_t len; + size_t lenbuf = size; + va_list args; + + va_start (args, format); + output = vasnprintf (str, &lenbuf, format, args); + len = lenbuf; + va_end (args); + + if (!output) + return -1; + + if (output != str) + { + if (size) + { + size_t pruned_len = (len < size ? len : size - 1); + memcpy (str, output, pruned_len); + str[pruned_len] = '\0'; + } + + free (output); + } + + if (INT_MAX < len) + { + errno = EOVERFLOW; + return -1; + } + + return len; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/socket.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/socket.c new file mode 100644 index 00000000..6061a3fb --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/socket.c @@ -0,0 +1,53 @@ +/* socket.c --- wrappers for Windows socket function + + Copyright (C) 2008-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Paolo Bonzini */ + +#include + +#define WIN32_LEAN_AND_MEAN +/* Get winsock2.h. */ +#include + +/* Get set_winsock_errno, FD_TO_SOCKET etc. */ +#include "w32sock.h" + +#include "sockets.h" + +/* Don't assume that UNICODE is defined. */ +#undef WSASocket +#define WSASocket WSASocketW + +int +rpl_socket (int domain, int type, int protocol) +{ + SOCKET fh; + + gl_sockets_startup (SOCKETS_1_1); + + /* We have to use WSASocket() to create non-overlapped IO sockets. + Overlapped IO sockets cannot be used with read/write. */ + fh = WSASocket (domain, type, protocol, NULL, 0, 0); + + if (fh == INVALID_SOCKET) + { + set_winsock_errno (); + return -1; + } + else + return SOCKET_TO_FD (fh); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/sockets.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/sockets.c new file mode 100644 index 00000000..92beb7d3 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/sockets.c @@ -0,0 +1,161 @@ +/* sockets.c --- wrappers for Windows socket functions + + Copyright (C) 2008-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Simon Josefsson */ + +#include + +/* Specification. */ +#include "sockets.h" + +#if WINDOWS_SOCKETS + +/* This includes winsock2.h on MinGW. */ +# include + +# include "fd-hook.h" +# if GNULIB_MSVC_NOTHROW +# include "msvc-nothrow.h" +# else +# include +# endif + +/* Get set_winsock_errno, FD_TO_SOCKET etc. */ +# include "w32sock.h" + +static int +close_fd_maybe_socket (const struct fd_hook *remaining_list, + gl_close_fn primary, + int fd) +{ + /* Note about multithread-safety: There is a race condition where, between + our calls to closesocket() and the primary close(), some other thread + could make system calls that allocate precisely the same HANDLE value + as sock; then the primary close() would call CloseHandle() on it. */ + SOCKET sock; + WSANETWORKEVENTS ev; + + /* Test whether fd refers to a socket. */ + sock = FD_TO_SOCKET (fd); + ev.lNetworkEvents = 0xDEADBEEF; + WSAEnumNetworkEvents (sock, NULL, &ev); + if (ev.lNetworkEvents != 0xDEADBEEF) + { + /* fd refers to a socket. */ + /* FIXME: other applications, like squid, use an undocumented + _free_osfhnd free function. But this is not enough: The 'osfile' + flags for fd also needs to be cleared, but it is hard to access it. + Instead, here we just close twice the file descriptor. */ + if (closesocket (sock)) + { + set_winsock_errno (); + return -1; + } + else + { + /* This call frees the file descriptor and does a + CloseHandle ((HANDLE) _get_osfhandle (fd)), which fails. */ + _close (fd); + return 0; + } + } + else + /* Some other type of file descriptor. */ + return execute_close_hooks (remaining_list, primary, fd); +} + +static int +ioctl_fd_maybe_socket (const struct fd_hook *remaining_list, + gl_ioctl_fn primary, + int fd, int request, void *arg) +{ + SOCKET sock; + WSANETWORKEVENTS ev; + + /* Test whether fd refers to a socket. */ + sock = FD_TO_SOCKET (fd); + ev.lNetworkEvents = 0xDEADBEEF; + WSAEnumNetworkEvents (sock, NULL, &ev); + if (ev.lNetworkEvents != 0xDEADBEEF) + { + /* fd refers to a socket. */ + if (ioctlsocket (sock, request, arg) < 0) + { + set_winsock_errno (); + return -1; + } + else + return 0; + } + else + /* Some other type of file descriptor. */ + return execute_ioctl_hooks (remaining_list, primary, fd, request, arg); +} + +static struct fd_hook fd_sockets_hook; + +static int initialized_sockets_version /* = 0 */; + +#endif /* WINDOWS_SOCKETS */ + +int +gl_sockets_startup (_GL_UNUSED int version) +{ +#if WINDOWS_SOCKETS + if (version > initialized_sockets_version) + { + WSADATA data; + int err; + + err = WSAStartup (version, &data); + if (err != 0) + return 1; + + if (data.wVersion != version) + { + WSACleanup (); + return 2; + } + + if (initialized_sockets_version == 0) + register_fd_hook (close_fd_maybe_socket, ioctl_fd_maybe_socket, + &fd_sockets_hook); + + initialized_sockets_version = version; + } +#endif + + return 0; +} + +int +gl_sockets_cleanup (void) +{ +#if WINDOWS_SOCKETS + int err; + + initialized_sockets_version = 0; + + unregister_fd_hook (&fd_sockets_hook); + + err = WSACleanup (); + if (err != 0) + return 1; +#endif + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/sockets.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/sockets.h new file mode 100644 index 00000000..99d6efca --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/sockets.h @@ -0,0 +1,71 @@ +/* sockets.h - wrappers for Windows socket functions + + Copyright (C) 2008-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Simon Josefsson */ + +#ifndef SOCKETS_H +#define SOCKETS_H 1 + +/* This file uses _GL_ATTRIBUTE_CONST. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +#define SOCKETS_1_0 0x0001 +#define SOCKETS_1_1 0x0101 +#define SOCKETS_2_0 0x0002 +#define SOCKETS_2_1 0x0102 +#define SOCKETS_2_2 0x0202 + +int gl_sockets_startup (int version) +#ifndef WINDOWS_SOCKETS + _GL_ATTRIBUTE_CONST +#endif + ; + +int gl_sockets_cleanup (void) +#ifndef WINDOWS_SOCKETS + _GL_ATTRIBUTE_CONST +#endif + ; + +/* This function is useful it you create a socket using gnulib's + Winsock wrappers but needs to pass on the socket handle to some + other library that only accepts sockets. */ +#ifdef WINDOWS_SOCKETS + +# include + +# if GNULIB_MSVC_NOTHROW +# include "msvc-nothrow.h" +# else +# include +# endif + +static inline SOCKET +gl_fd_to_handle (int fd) +{ + return _get_osfhandle (fd); +} + +#else + +# define gl_fd_to_handle(x) (x) + +#endif /* WINDOWS_SOCKETS */ + +#endif /* SOCKETS_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/str-two-way.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/str-two-way.h new file mode 100644 index 00000000..cf85e268 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/str-two-way.h @@ -0,0 +1,452 @@ +/* Byte-wise substring search, using the Two-Way algorithm. + Copyright (C) 2008-2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Written by Eric Blake , 2008. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Before including this file, you need to include and + , and define: + RETURN_TYPE A macro that expands to the return type. + AVAILABLE(h, h_l, j, n_l) + A macro that returns nonzero if there are + at least N_L bytes left starting at H[J]. + H is 'unsigned char *', H_L, J, and N_L + are 'size_t'; H_L is an lvalue. For + NUL-terminated searches, H_L can be + modified each iteration to avoid having + to compute the end of H up front. + + For case-insensitivity, you may optionally define: + CMP_FUNC(p1, p2, l) A macro that returns 0 iff the first L + characters of P1 and P2 are equal. + CANON_ELEMENT(c) A macro that canonicalizes an element right after + it has been fetched from one of the two strings. + The argument is an 'unsigned char'; the result + must be an 'unsigned char' as well. + + This file undefines the macros documented above, and defines + LONG_NEEDLE_THRESHOLD. +*/ + +#include +#include + +/* We use the Two-Way string matching algorithm (also known as + Chrochemore-Perrin), which guarantees linear complexity with + constant space. Additionally, for long needles, we also use a bad + character shift table similar to the Boyer-Moore algorithm to + achieve improved (potentially sub-linear) performance. + + See https://www-igm.univ-mlv.fr/~lecroq/string/node26.html#SECTION00260, + https://en.wikipedia.org/wiki/Boyer-Moore_string_search_algorithm, + https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.34.6641&rep=rep1&type=pdf +*/ + +/* Point at which computing a bad-byte shift table is likely to be + worthwhile. Small needles should not compute a table, since it + adds (1 << CHAR_BIT) + NEEDLE_LEN computations of preparation for a + speedup no greater than a factor of NEEDLE_LEN. The larger the + needle, the better the potential performance gain. On the other + hand, on non-POSIX systems with CHAR_BIT larger than eight, the + memory required for the table is prohibitive. */ +#if CHAR_BIT < 10 +# define LONG_NEEDLE_THRESHOLD 32U +#else +# define LONG_NEEDLE_THRESHOLD SIZE_MAX +#endif + +#ifndef MAX +# define MAX(a, b) ((a < b) ? (b) : (a)) +#endif + +#ifndef CANON_ELEMENT +# define CANON_ELEMENT(c) c +#endif +#ifndef CMP_FUNC +# define CMP_FUNC memcmp +#endif + +/* Perform a critical factorization of NEEDLE, of length NEEDLE_LEN. + Return the index of the first byte in the right half, and set + *PERIOD to the global period of the right half. + + The global period of a string is the smallest index (possibly its + length) at which all remaining bytes in the string are repetitions + of the prefix (the last repetition may be a subset of the prefix). + + When NEEDLE is factored into two halves, a local period is the + length of the smallest word that shares a suffix with the left half + and shares a prefix with the right half. All factorizations of a + non-empty NEEDLE have a local period of at least 1 and no greater + than NEEDLE_LEN. + + A critical factorization has the property that the local period + equals the global period. All strings have at least one critical + factorization with the left half smaller than the global period. + And while some strings have more than one critical factorization, + it is provable that with an ordered alphabet, at least one of the + critical factorizations corresponds to a maximal suffix. + + Given an ordered alphabet, a critical factorization can be computed + in linear time, with 2 * NEEDLE_LEN comparisons, by computing the + shorter of two ordered maximal suffixes. The ordered maximal + suffixes are determined by lexicographic comparison while tracking + periodicity. */ +static size_t +critical_factorization (const unsigned char *needle, size_t needle_len, + size_t *period) +{ + /* Index of last byte of left half, or SIZE_MAX. */ + size_t max_suffix, max_suffix_rev; + size_t j; /* Index into NEEDLE for current candidate suffix. */ + size_t k; /* Offset into current period. */ + size_t p; /* Intermediate period. */ + unsigned char a, b; /* Current comparison bytes. */ + + /* Special case NEEDLE_LEN of 1 or 2 (all callers already filtered + out 0-length needles. */ + if (needle_len < 3) + { + *period = 1; + return needle_len - 1; + } + + /* Invariants: + 0 <= j < NEEDLE_LEN - 1 + -1 <= max_suffix{,_rev} < j (treating SIZE_MAX as if it were signed) + min(max_suffix, max_suffix_rev) < global period of NEEDLE + 1 <= p <= global period of NEEDLE + p == global period of the substring NEEDLE[max_suffix{,_rev}+1...j] + 1 <= k <= p + */ + + /* Perform lexicographic search. */ + max_suffix = SIZE_MAX; + j = 0; + k = p = 1; + while (j + k < needle_len) + { + a = CANON_ELEMENT (needle[j + k]); + b = CANON_ELEMENT (needle[max_suffix + k]); + if (a < b) + { + /* Suffix is smaller, period is entire prefix so far. */ + j += k; + k = 1; + p = j - max_suffix; + } + else if (a == b) + { + /* Advance through repetition of the current period. */ + if (k != p) + ++k; + else + { + j += p; + k = 1; + } + } + else /* b < a */ + { + /* Suffix is larger, start over from current location. */ + max_suffix = j++; + k = p = 1; + } + } + *period = p; + + /* Perform reverse lexicographic search. */ + max_suffix_rev = SIZE_MAX; + j = 0; + k = p = 1; + while (j + k < needle_len) + { + a = CANON_ELEMENT (needle[j + k]); + b = CANON_ELEMENT (needle[max_suffix_rev + k]); + if (b < a) + { + /* Suffix is smaller, period is entire prefix so far. */ + j += k; + k = 1; + p = j - max_suffix_rev; + } + else if (a == b) + { + /* Advance through repetition of the current period. */ + if (k != p) + ++k; + else + { + j += p; + k = 1; + } + } + else /* a < b */ + { + /* Suffix is larger, start over from current location. */ + max_suffix_rev = j++; + k = p = 1; + } + } + + /* Choose the shorter suffix. Return the index of the first byte of + the right half, rather than the last byte of the left half. + + For some examples, 'banana' has two critical factorizations, both + exposed by the two lexicographic extreme suffixes of 'anana' and + 'nana', where both suffixes have a period of 2. On the other + hand, with 'aab' and 'bba', both strings have a single critical + factorization of the last byte, with the suffix having a period + of 1. While the maximal lexicographic suffix of 'aab' is 'b', + the maximal lexicographic suffix of 'bba' is 'ba', which is not a + critical factorization. Conversely, the maximal reverse + lexicographic suffix of 'a' works for 'bba', but not 'ab' for + 'aab'. The shorter suffix of the two will always be a critical + factorization. */ + if (max_suffix_rev + 1 < max_suffix + 1) + return max_suffix + 1; + *period = p; + return max_suffix_rev + 1; +} + +/* Return the first location of non-empty NEEDLE within HAYSTACK, or + NULL. HAYSTACK_LEN is the minimum known length of HAYSTACK. This + method is optimized for NEEDLE_LEN < LONG_NEEDLE_THRESHOLD. + Performance is guaranteed to be linear, with an initialization cost + of 2 * NEEDLE_LEN comparisons. + + If AVAILABLE does not modify HAYSTACK_LEN (as in memmem), then at + most 2 * HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching. + If AVAILABLE modifies HAYSTACK_LEN (as in strstr), then at most 3 * + HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching. */ +static RETURN_TYPE _GL_ATTRIBUTE_PURE +two_way_short_needle (const unsigned char *haystack, size_t haystack_len, + const unsigned char *needle, size_t needle_len) +{ + size_t i; /* Index into current byte of NEEDLE. */ + size_t j; /* Index into current window of HAYSTACK. */ + size_t period; /* The period of the right half of needle. */ + size_t suffix; /* The index of the right half of needle. */ + + /* Factor the needle into two halves, such that the left half is + smaller than the global period, and the right half is + periodic (with a period as large as NEEDLE_LEN - suffix). */ + suffix = critical_factorization (needle, needle_len, &period); + + /* Perform the search. Each iteration compares the right half + first. */ + if (CMP_FUNC (needle, needle + period, suffix) == 0) + { + /* Entire needle is periodic; a mismatch in the left half can + only advance by the period, so use memory to avoid rescanning + known occurrences of the period in the right half. */ + size_t memory = 0; + j = 0; + while (AVAILABLE (haystack, haystack_len, j, needle_len)) + { + /* Scan for matches in right half. */ + i = MAX (suffix, memory); + while (i < needle_len && (CANON_ELEMENT (needle[i]) + == CANON_ELEMENT (haystack[i + j]))) + ++i; + if (needle_len <= i) + { + /* Scan for matches in left half. */ + i = suffix - 1; + while (memory < i + 1 && (CANON_ELEMENT (needle[i]) + == CANON_ELEMENT (haystack[i + j]))) + --i; + if (i + 1 < memory + 1) + return (RETURN_TYPE) (haystack + j); + /* No match, so remember how many repetitions of period + on the right half were scanned. */ + j += period; + memory = needle_len - period; + } + else + { + j += i - suffix + 1; + memory = 0; + } + } + } + else + { + /* The two halves of needle are distinct; no extra memory is + required, and any mismatch results in a maximal shift. */ + period = MAX (suffix, needle_len - suffix) + 1; + j = 0; + while (AVAILABLE (haystack, haystack_len, j, needle_len)) + { + /* Scan for matches in right half. */ + i = suffix; + while (i < needle_len && (CANON_ELEMENT (needle[i]) + == CANON_ELEMENT (haystack[i + j]))) + ++i; + if (needle_len <= i) + { + /* Scan for matches in left half. */ + i = suffix - 1; + while (i != SIZE_MAX && (CANON_ELEMENT (needle[i]) + == CANON_ELEMENT (haystack[i + j]))) + --i; + if (i == SIZE_MAX) + return (RETURN_TYPE) (haystack + j); + j += period; + } + else + j += i - suffix + 1; + } + } + return NULL; +} + +/* Return the first location of non-empty NEEDLE within HAYSTACK, or + NULL. HAYSTACK_LEN is the minimum known length of HAYSTACK. This + method is optimized for LONG_NEEDLE_THRESHOLD <= NEEDLE_LEN. + Performance is guaranteed to be linear, with an initialization cost + of 3 * NEEDLE_LEN + (1 << CHAR_BIT) operations. + + If AVAILABLE does not modify HAYSTACK_LEN (as in memmem), then at + most 2 * HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching, + and sublinear performance O(HAYSTACK_LEN / NEEDLE_LEN) is possible. + If AVAILABLE modifies HAYSTACK_LEN (as in strstr), then at most 3 * + HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching, and + sublinear performance is not possible. */ +static RETURN_TYPE _GL_ATTRIBUTE_PURE +two_way_long_needle (const unsigned char *haystack, size_t haystack_len, + const unsigned char *needle, size_t needle_len) +{ + size_t i; /* Index into current byte of NEEDLE. */ + size_t j; /* Index into current window of HAYSTACK. */ + size_t period; /* The period of the right half of needle. */ + size_t suffix; /* The index of the right half of needle. */ + size_t shift_table[1U << CHAR_BIT]; /* See below. */ + + /* Factor the needle into two halves, such that the left half is + smaller than the global period, and the right half is + periodic (with a period as large as NEEDLE_LEN - suffix). */ + suffix = critical_factorization (needle, needle_len, &period); + + /* Populate shift_table. For each possible byte value c, + shift_table[c] is the distance from the last occurrence of c to + the end of NEEDLE, or NEEDLE_LEN if c is absent from the NEEDLE. + shift_table[NEEDLE[NEEDLE_LEN - 1]] contains the only 0. */ + for (i = 0; i < 1U << CHAR_BIT; i++) + shift_table[i] = needle_len; + for (i = 0; i < needle_len; i++) + shift_table[CANON_ELEMENT (needle[i])] = needle_len - i - 1; + + /* Perform the search. Each iteration compares the right half + first. */ + if (CMP_FUNC (needle, needle + period, suffix) == 0) + { + /* Entire needle is periodic; a mismatch in the left half can + only advance by the period, so use memory to avoid rescanning + known occurrences of the period in the right half. */ + size_t memory = 0; + size_t shift; + j = 0; + while (AVAILABLE (haystack, haystack_len, j, needle_len)) + { + /* Check the last byte first; if it does not match, then + shift to the next possible match location. */ + shift = shift_table[CANON_ELEMENT (haystack[j + needle_len - 1])]; + if (0 < shift) + { + if (memory && shift < period) + { + /* Since needle is periodic, but the last period has + a byte out of place, there can be no match until + after the mismatch. */ + shift = needle_len - period; + } + memory = 0; + j += shift; + continue; + } + /* Scan for matches in right half. The last byte has + already been matched, by virtue of the shift table. */ + i = MAX (suffix, memory); + while (i < needle_len - 1 && (CANON_ELEMENT (needle[i]) + == CANON_ELEMENT (haystack[i + j]))) + ++i; + if (needle_len - 1 <= i) + { + /* Scan for matches in left half. */ + i = suffix - 1; + while (memory < i + 1 && (CANON_ELEMENT (needle[i]) + == CANON_ELEMENT (haystack[i + j]))) + --i; + if (i + 1 < memory + 1) + return (RETURN_TYPE) (haystack + j); + /* No match, so remember how many repetitions of period + on the right half were scanned. */ + j += period; + memory = needle_len - period; + } + else + { + j += i - suffix + 1; + memory = 0; + } + } + } + else + { + /* The two halves of needle are distinct; no extra memory is + required, and any mismatch results in a maximal shift. */ + size_t shift; + period = MAX (suffix, needle_len - suffix) + 1; + j = 0; + while (AVAILABLE (haystack, haystack_len, j, needle_len)) + { + /* Check the last byte first; if it does not match, then + shift to the next possible match location. */ + shift = shift_table[CANON_ELEMENT (haystack[j + needle_len - 1])]; + if (0 < shift) + { + j += shift; + continue; + } + /* Scan for matches in right half. The last byte has + already been matched, by virtue of the shift table. */ + i = suffix; + while (i < needle_len - 1 && (CANON_ELEMENT (needle[i]) + == CANON_ELEMENT (haystack[i + j]))) + ++i; + if (needle_len - 1 <= i) + { + /* Scan for matches in left half. */ + i = suffix - 1; + while (i != SIZE_MAX && (CANON_ELEMENT (needle[i]) + == CANON_ELEMENT (haystack[i + j]))) + --i; + if (i == SIZE_MAX) + return (RETURN_TYPE) (haystack + j); + j += period; + } + else + j += i - suffix + 1; + } + } + return NULL; +} + +#undef AVAILABLE +#undef CANON_ELEMENT +#undef CMP_FUNC +#undef MAX +#undef RETURN_TYPE diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/strerror_r.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/strerror_r.c new file mode 100644 index 00000000..0cd28ade --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/strerror_r.c @@ -0,0 +1,454 @@ +/* strerror_r.c --- POSIX compatible system error routine + + Copyright (C) 2010-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 2010. */ + +#include + +/* Enable declaration of sys_nerr and sys_errlist in on NetBSD. */ +#define _NETBSD_SOURCE 1 + +/* Specification. */ +#include + +#include +#include +#include +#if !HAVE_SNPRINTF +# include +#endif + +#include "strerror-override.h" + +#if STRERROR_R_CHAR_P + +# if HAVE___XPG_STRERROR_R +_GL_EXTERN_C int __xpg_strerror_r (int errnum, char *buf, size_t buflen); +# endif + +#elif HAVE_DECL_STRERROR_R + +/* The system's strerror_r function's API is OK, except that its third argument + is 'int', not 'size_t', or its return type is wrong. */ + +# include + +#else + +/* Use the system's strerror(). Exclude glibc and cygwin because the + system strerror_r has the wrong return type, and cygwin 1.7.9 + strerror_r clobbers strerror. */ +# undef strerror + +# if defined __NetBSD__ || defined __hpux || (defined _WIN32 && !defined __CYGWIN__) || defined __sgi || (defined __sun && !defined _LP64) || defined __CYGWIN__ + +/* No locking needed. */ + +/* Get catgets internationalization functions. */ +# if HAVE_CATGETS +# include +# endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* Get sys_nerr, sys_errlist on HP-UX (otherwise only declared in C++ mode). + Get sys_nerr, sys_errlist on IRIX (otherwise only declared with _SGIAPI). */ +# if defined __hpux || defined __sgi +extern int sys_nerr; +extern char *sys_errlist[]; +# endif + +/* Get sys_nerr on Solaris. */ +# if defined __sun && !defined _LP64 +extern int sys_nerr; +# endif + +#ifdef __cplusplus +} +#endif + +# else + +# include "glthread/lock.h" + +/* This lock protects the buffer returned by strerror(). We assume that + no other uses of strerror() exist in the program. */ +gl_lock_define_initialized(static, strerror_lock) + +# endif + +#endif + +/* On MSVC, there is no snprintf() function, just a _snprintf(). + It is of lower quality, but sufficient for the simple use here. + We only have to make sure to NUL terminate the result (_snprintf + does not NUL terminate, like strncpy). */ +#if !HAVE_SNPRINTF +static int +local_snprintf (char *buf, size_t buflen, const char *format, ...) +{ + va_list args; + int result; + + va_start (args, format); + result = _vsnprintf (buf, buflen, format, args); + va_end (args); + if (buflen > 0 && (result < 0 || result >= buflen)) + buf[buflen - 1] = '\0'; + return result; +} +# undef snprintf +# define snprintf local_snprintf +#endif + +/* Copy as much of MSG into BUF as possible, without corrupting errno. + Return 0 if MSG fit in BUFLEN, otherwise return ERANGE. */ +static int +safe_copy (char *buf, size_t buflen, const char *msg) +{ + size_t len = strlen (msg); + size_t moved = len < buflen ? len : buflen - 1; + + /* Although POSIX lets memmove corrupt errno, we don't + know of any implementation where this is a real problem. */ + memmove (buf, msg, moved); + buf[moved] = '\0'; + return len < buflen ? 0 : ERANGE; +} + + +int +strerror_r (int errnum, char *buf, size_t buflen) +#undef strerror_r +{ + /* Filter this out now, so that rest of this replacement knows that + there is room for a non-empty message and trailing NUL. */ + if (buflen <= 1) + { + if (buflen) + *buf = '\0'; + return ERANGE; + } + *buf = '\0'; + + /* Check for gnulib overrides. */ + { + char const *msg = strerror_override (errnum); + + if (msg) + return safe_copy (buf, buflen, msg); + } + + { + int ret; + int saved_errno = errno; + +#if STRERROR_R_CHAR_P + + { + ret = 0; + +# if HAVE___XPG_STRERROR_R + ret = __xpg_strerror_r (errnum, buf, buflen); + /* ret is 0 upon success, or EINVAL or ERANGE upon failure. */ +# endif + + if (!*buf) + { + /* glibc 2.13 ... 2.34 (at least) don't touch buf upon failure. + Therefore we have to fall back to strerror_r which, for valid + errnum, returns a thread-safe untruncated string. For invalid + errnum, though, it returns a truncated string, which does not + allow us to determine whether to return ERANGE or 0. Thus we + need to pass a sufficiently large buffer. */ + char stackbuf[80]; + char *errstring = strerror_r (errnum, stackbuf, sizeof stackbuf); + ret = errstring ? safe_copy (buf, buflen, errstring) : errno; + } + } + +#elif HAVE_DECL_STRERROR_R + + if (buflen > INT_MAX) + buflen = INT_MAX; + +# ifdef __hpux + /* On HP-UX 11.31, strerror_r always fails when buflen < 80; it + also fails to change buf on EINVAL. */ + { + char stackbuf[80]; + + if (buflen < sizeof stackbuf) + { + ret = strerror_r (errnum, stackbuf, sizeof stackbuf); + if (ret == 0) + ret = safe_copy (buf, buflen, stackbuf); + } + else + ret = strerror_r (errnum, buf, buflen); + } +# else + ret = strerror_r (errnum, buf, buflen); + + /* Some old implementations may return (-1, EINVAL) instead of EINVAL. + But on Haiku, valid error numbers are negative. */ +# if !defined __HAIKU__ + if (ret < 0) + ret = errno; +# endif +# endif + +# if defined _AIX || defined __HAIKU__ + /* AIX and Haiku return 0 rather than ERANGE when truncating strings; try + again until we are sure we got the entire string. */ + if (!ret && strlen (buf) == buflen - 1) + { + char stackbuf[STACKBUF_LEN]; + size_t len; + strerror_r (errnum, stackbuf, sizeof stackbuf); + len = strlen (stackbuf); + /* STACKBUF_LEN should have been large enough. */ + if (len + 1 == sizeof stackbuf) + abort (); + if (buflen <= len) + ret = ERANGE; + } +# else + /* Solaris 10 does not populate buf on ERANGE. OpenBSD 4.7 + truncates early on ERANGE rather than return a partial integer. + We prefer the maximal string. We set buf[0] earlier, and we + know of no implementation that modifies buf to be an + unterminated string, so this strlen should be portable in + practice (rather than pulling in a safer strnlen). */ + if (ret == ERANGE && strlen (buf) < buflen - 1) + { + char stackbuf[STACKBUF_LEN]; + + /* STACKBUF_LEN should have been large enough. */ + if (strerror_r (errnum, stackbuf, sizeof stackbuf) == ERANGE) + abort (); + safe_copy (buf, buflen, stackbuf); + } +# endif + +#else /* strerror_r is not declared. */ + + /* Try to do what strerror (errnum) does, but without clobbering the + buffer used by strerror(). */ + +# if defined __NetBSD__ || defined __hpux || (defined _WIN32 && !defined __CYGWIN__) || defined __CYGWIN__ /* NetBSD, HP-UX, native Windows, Cygwin */ + + /* NetBSD: sys_nerr, sys_errlist are declared through _NETBSD_SOURCE + and above. + HP-UX: sys_nerr, sys_errlist are declared explicitly above. + native Windows: sys_nerr, sys_errlist are declared in . + Cygwin: sys_nerr, sys_errlist are declared in . */ + if (errnum >= 0 && errnum < sys_nerr) + { +# if HAVE_CATGETS && (defined __NetBSD__ || defined __hpux) +# if defined __NetBSD__ + nl_catd catd = catopen ("libc", NL_CAT_LOCALE); + const char *errmsg = + (catd != (nl_catd)-1 + ? catgets (catd, 1, errnum, sys_errlist[errnum]) + : sys_errlist[errnum]); +# endif +# if defined __hpux + nl_catd catd = catopen ("perror", NL_CAT_LOCALE); + const char *errmsg = + (catd != (nl_catd)-1 + ? catgets (catd, 1, 1 + errnum, sys_errlist[errnum]) + : sys_errlist[errnum]); +# endif +# else + const char *errmsg = sys_errlist[errnum]; +# endif + if (errmsg == NULL || *errmsg == '\0') + ret = EINVAL; + else + ret = safe_copy (buf, buflen, errmsg); +# if HAVE_CATGETS && (defined __NetBSD__ || defined __hpux) + if (catd != (nl_catd)-1) + catclose (catd); +# endif + } + else + ret = EINVAL; + +# elif defined __sgi || (defined __sun && !defined _LP64) /* IRIX, Solaris <= 9 32-bit */ + + /* For a valid error number, the system's strerror() function returns + a pointer to a not copied string, not to a buffer. */ + if (errnum >= 0 && errnum < sys_nerr) + { + char *errmsg = strerror (errnum); + + if (errmsg == NULL || *errmsg == '\0') + ret = EINVAL; + else + ret = safe_copy (buf, buflen, errmsg); + } + else + ret = EINVAL; + +# else + + gl_lock_lock (strerror_lock); + + { + char *errmsg = strerror (errnum); + + /* For invalid error numbers, strerror() on + - IRIX 6.5 returns NULL, + - HP-UX 11 returns an empty string. */ + if (errmsg == NULL || *errmsg == '\0') + ret = EINVAL; + else + ret = safe_copy (buf, buflen, errmsg); + } + + gl_lock_unlock (strerror_lock); + +# endif + +#endif + +#if defined _WIN32 && !defined __CYGWIN__ + /* MSVC 14 defines names for many error codes in the range 100..140, + but _sys_errlist contains strings only for the error codes + < _sys_nerr = 43. */ + if (ret == EINVAL) + { + const char *errmsg; + + switch (errnum) + { + case 100 /* EADDRINUSE */: + errmsg = "Address already in use"; + break; + case 101 /* EADDRNOTAVAIL */: + errmsg = "Cannot assign requested address"; + break; + case 102 /* EAFNOSUPPORT */: + errmsg = "Address family not supported by protocol"; + break; + case 103 /* EALREADY */: + errmsg = "Operation already in progress"; + break; + case 105 /* ECANCELED */: + errmsg = "Operation canceled"; + break; + case 106 /* ECONNABORTED */: + errmsg = "Software caused connection abort"; + break; + case 107 /* ECONNREFUSED */: + errmsg = "Connection refused"; + break; + case 108 /* ECONNRESET */: + errmsg = "Connection reset by peer"; + break; + case 109 /* EDESTADDRREQ */: + errmsg = "Destination address required"; + break; + case 110 /* EHOSTUNREACH */: + errmsg = "No route to host"; + break; + case 112 /* EINPROGRESS */: + errmsg = "Operation now in progress"; + break; + case 113 /* EISCONN */: + errmsg = "Transport endpoint is already connected"; + break; + case 114 /* ELOOP */: + errmsg = "Too many levels of symbolic links"; + break; + case 115 /* EMSGSIZE */: + errmsg = "Message too long"; + break; + case 116 /* ENETDOWN */: + errmsg = "Network is down"; + break; + case 117 /* ENETRESET */: + errmsg = "Network dropped connection on reset"; + break; + case 118 /* ENETUNREACH */: + errmsg = "Network is unreachable"; + break; + case 119 /* ENOBUFS */: + errmsg = "No buffer space available"; + break; + case 123 /* ENOPROTOOPT */: + errmsg = "Protocol not available"; + break; + case 126 /* ENOTCONN */: + errmsg = "Transport endpoint is not connected"; + break; + case 128 /* ENOTSOCK */: + errmsg = "Socket operation on non-socket"; + break; + case 129 /* ENOTSUP */: + errmsg = "Not supported"; + break; + case 130 /* EOPNOTSUPP */: + errmsg = "Operation not supported"; + break; + case 132 /* EOVERFLOW */: + errmsg = "Value too large for defined data type"; + break; + case 133 /* EOWNERDEAD */: + errmsg = "Owner died"; + break; + case 134 /* EPROTO */: + errmsg = "Protocol error"; + break; + case 135 /* EPROTONOSUPPORT */: + errmsg = "Protocol not supported"; + break; + case 136 /* EPROTOTYPE */: + errmsg = "Protocol wrong type for socket"; + break; + case 138 /* ETIMEDOUT */: + errmsg = "Connection timed out"; + break; + case 140 /* EWOULDBLOCK */: + errmsg = "Operation would block"; + break; + default: + errmsg = NULL; + break; + } + if (errmsg != NULL) + ret = safe_copy (buf, buflen, errmsg); + } +#endif + + if (ret == EINVAL && !*buf) + { +#if defined __HAIKU__ + /* For consistency with perror(). */ + snprintf (buf, buflen, "Unknown Application Error (%d)", errnum); +#else + snprintf (buf, buflen, "Unknown error %d", errnum); +#endif + } + + errno = saved_errno; + return ret; + } +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/symlink.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/symlink.c new file mode 100644 index 00000000..6ba83666 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/symlink.c @@ -0,0 +1,57 @@ +/* Stub for symlink(). + Copyright (C) 2009-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +#include +#include +#include + + +#if HAVE_SYMLINK + +# undef symlink + +/* Create a symlink, but reject trailing slash. */ +int +rpl_symlink (char const *contents, char const *name) +{ + size_t len = strlen (name); + if (len && name[len - 1] == '/') + { + struct stat st; + if (lstat (name, &st) == 0 || errno == EOVERFLOW) + errno = EEXIST; + return -1; + } + return symlink (contents, name); +} + +#else /* !HAVE_SYMLINK */ + +/* The system does not support symlinks. */ +int +symlink (_GL_UNUSED char const *contents, + _GL_UNUSED char const *name) +{ + errno = ENOSYS; + return -1; +} + +#endif /* !HAVE_SYMLINK */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/symlinkat.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/symlinkat.c new file mode 100644 index 00000000..920001a6 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/symlinkat.c @@ -0,0 +1,101 @@ +/* Create a symlink relative to an open directory. + Copyright (C) 2009-2024 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 . */ + +/* written by Eric Blake */ + +#include + +/* Specification. */ +#include + +#include +#include + +#if HAVE_SYMLINKAT +# undef symlinkat + +#include +#include +#include + +/* Create a symlink, but reject trailing slash. */ +int +rpl_symlinkat (char const *contents, int fd, char const *name) +{ + size_t len = strlen (name); + if (len && name[len - 1] == '/') + { + struct stat st; + if (fstatat (fd, name, &st, AT_SYMLINK_NOFOLLOW) == 0 + || errno == EOVERFLOW) + errno = EEXIST; + return -1; + } + return symlinkat (contents, fd, name); +} + +#elif !HAVE_SYMLINK +/* Mingw lacks symlink, and it is more efficient to provide a trivial + wrapper than to go through at-func.c to call rpl_symlink. */ + +int +symlinkat (_GL_UNUSED char const *path1, _GL_UNUSED int fd, + _GL_UNUSED char const *path2) +{ + errno = ENOSYS; + return -1; +} + +#else /* HAVE_SYMLINK */ + +/* Our openat helper functions expect the directory parameter first, + not second. These shims make life easier. */ + +/* Like symlink, but with arguments reversed. */ +static int +symlink_reversed (char const *file, char const *contents) +{ + return symlink (contents, file); +} + +/* Like symlinkat, but with arguments reversed. */ + +static int +symlinkat_reversed (int fd, char const *file, char const *contents); + +# define AT_FUNC_NAME symlinkat_reversed +# define AT_FUNC_F1 symlink_reversed +# define AT_FUNC_POST_FILE_PARAM_DECLS , char const *contents +# define AT_FUNC_POST_FILE_ARGS , contents +# include "at-func.c" +# undef AT_FUNC_NAME +# undef AT_FUNC_F1 +# undef AT_FUNC_POST_FILE_PARAM_DECLS +# undef AT_FUNC_POST_FILE_ARGS + +/* Create a symlink FILE, in the directory open on descriptor FD, + holding CONTENTS. If possible, do it without changing the + working directory. Otherwise, resort to using save_cwd/fchdir, + then symlink/restore_cwd. If either the save_cwd or the restore_cwd + fails, then give a diagnostic and exit nonzero. */ + +int +symlinkat (char const *contents, int fd, char const *file) +{ + return symlinkat_reversed (fd, file, contents); +} + +#endif /* HAVE_SYMLINK */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/sys_ioctl.in.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/sys_ioctl.in.h new file mode 100644 index 00000000..787d35f7 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/sys_ioctl.in.h @@ -0,0 +1,86 @@ +/* Substitute for and wrapper around . + Copyright (C) 2008-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef _@GUARD_PREFIX@_SYS_IOCTL_H + +#if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +#endif +@PRAGMA_COLUMNS@ + +/* The include_next requires a split double-inclusion guard. */ +#if @HAVE_SYS_IOCTL_H@ +# @INCLUDE_NEXT@ @NEXT_SYS_IOCTL_H@ +#endif + +#ifndef _@GUARD_PREFIX@_SYS_IOCTL_H +#define _@GUARD_PREFIX@_SYS_IOCTL_H + +/* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +/* AIX 5.1 and Solaris 10 declare ioctl() in and in , + but not in . + Haiku declares ioctl() in , but not in . + But avoid namespace pollution on glibc systems. */ +#ifndef __GLIBC__ +# include +#endif + +/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ + +/* The definition of _GL_WARN_ON_USE is copied here. */ + + +/* Declare overridden functions. */ + +#if @GNULIB_IOCTL@ +# if @REPLACE_IOCTL@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef ioctl +# define ioctl rpl_ioctl +# endif +_GL_FUNCDECL_RPL (ioctl, int, + (int fd, int request, ... /* {void *,char *} arg */)); +_GL_CXXALIAS_RPL (ioctl, int, + (int fd, int request, ... /* {void *,char *} arg */)); +# else +# if @SYS_IOCTL_H_HAVE_WINSOCK2_H@ || 1 +_GL_FUNCDECL_SYS (ioctl, int, + (int fd, int request, ... /* {void *,char *} arg */)); +# endif +_GL_CXXALIAS_SYS (ioctl, int, + (int fd, int request, ... /* {void *,char *} arg */)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (ioctl); +# endif +#elif @SYS_IOCTL_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@ +# undef ioctl +# define ioctl ioctl_used_without_requesting_gnulib_module_ioctl +#elif defined GNULIB_POSIXCHECK +# undef ioctl +# if HAVE_RAW_DECL_IOCTL +_GL_WARN_ON_USE (ioctl, "ioctl does not portably work on sockets - " + "use gnulib module ioctl for portability"); +# endif +#endif + + +#endif /* _@GUARD_PREFIX@_SYS_IOCTL_H */ +#endif /* _@GUARD_PREFIX@_SYS_IOCTL_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/sys_select.in.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/sys_select.in.h new file mode 100644 index 00000000..de29c779 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/sys_select.in.h @@ -0,0 +1,346 @@ +/* Substitute for . + Copyright (C) 2007-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +# if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +# endif +@PRAGMA_COLUMNS@ + +/* This file uses #include_next of a system file that defines time_t. + For the 'year2038' module to work right, needs to have been + included before. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +/* On OSF/1 and Solaris 2.6, and + both include . + On Cygwin and OpenBSD, includes . + Simply delegate to the system's header in this case. */ +#if (@HAVE_SYS_SELECT_H@ \ + && !defined _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TYPES_H \ + && ((defined __osf__ && defined _SYS_TYPES_H_ \ + && defined _OSF_SOURCE) \ + || (defined __sun && defined _SYS_TYPES_H \ + && (! (defined _XOPEN_SOURCE || defined _POSIX_C_SOURCE) \ + || defined __EXTENSIONS__)))) + +# define _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TYPES_H +# @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@ + +#elif (@HAVE_SYS_SELECT_H@ \ + && (defined _CYGWIN_SYS_TIME_H \ + || (!defined _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TIME_H \ + && ((defined __osf__ && defined _SYS_TIME_H_ \ + && defined _OSF_SOURCE) \ + || (defined __OpenBSD__ && defined _SYS_TIME_H_) \ + || (defined __sun && defined _SYS_TIME_H \ + && (! (defined _XOPEN_SOURCE \ + || defined _POSIX_C_SOURCE) \ + || defined __EXTENSIONS__)))))) + +# define _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TIME_H +# @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@ + +/* On IRIX 6.5, includes , which includes + , which includes . At this point we cannot + include , because that includes , which + gives a syntax error because has not been completely + processed. Simply delegate to the system's header in this case. */ +#elif @HAVE_SYS_SELECT_H@ && defined __sgi && (defined _SYS_BSD_TYPES_H && !defined _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_BSD_TYPES_H) + +# define _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_BSD_TYPES_H +# @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@ + +/* On OpenBSD 5.0, includes , which includes + . At this point we cannot include , because that + includes gnulib's pthread.h override, which gives a syntax error because + /usr/include/pthread.h has not been completely processed. Simply delegate + to the system's header in this case. */ +#elif @HAVE_SYS_SELECT_H@ && defined __OpenBSD__ && (defined _PTHREAD_H_ && !defined PTHREAD_MUTEX_INITIALIZER) + +# @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@ + +#else + +#ifndef _@GUARD_PREFIX@_SYS_SELECT_H + +/* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +/* On many platforms, assumes prior inclusion of + . Also, mingw defines sigset_t there, instead of + in where it belongs. */ +#include + +#if @HAVE_SYS_SELECT_H@ + +/* On OSF/1 4.0, provides only a forward declaration + of 'struct timeval', and no definition of this type. + Also, Mac OS X, AIX, HP-UX, IRIX, Solaris, Interix declare select() + in . + But avoid namespace pollution on glibc systems, a circular include + -> -> on FreeBSD 13.1, and + "unknown type name" problems on Cygwin. */ +# if !(defined __GLIBC__ || defined __FreeBSD__ || defined __CYGWIN__) +# include +# endif + +/* On AIX 7 and Solaris 10, provides an FD_ZERO implementation + that relies on memset(), but without including . + But in any case avoid namespace pollution on glibc systems. */ +# if (defined __OpenBSD__ || defined _AIX || defined __sun || defined __osf__ || defined __BEOS__) \ + && ! defined __GLIBC__ +# include +# endif + +/* The include_next requires a split double-inclusion guard. */ +# @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@ + +#endif + +/* Get definition of 'sigset_t'. + But avoid namespace pollution on glibc systems and "unknown type + name" problems on Cygwin. + On OS/2 kLIBC, sigset_t is defined in , too. In addition, + if is included, -> -> + are included. Then -> are included by GNULIB. By the + way, requires PAGE_SIZE defined in . However, + has not been processed, yet. As a result, 'PAGE_SIZE' + undeclared error occurs in . + Do this after the include_next (for the sake of OpenBSD 5.0) but before + the split double-inclusion guard (for the sake of Solaris). */ +#if !((defined __GLIBC__ || defined __CYGWIN__ || defined __KLIBC__) \ + && !defined __UCLIBC__) +# include +#endif + +#ifndef _@GUARD_PREFIX@_SYS_SELECT_H +#define _@GUARD_PREFIX@_SYS_SELECT_H + +#if !@HAVE_SYS_SELECT_H@ +/* A platform that lacks . */ +/* Get the 'struct timeval' and 'fd_set' types and the FD_* macros + on most platforms. */ +# include +/* On HP-UX 11, provides an FD_ZERO implementation + that relies on memset(), but without including . */ +# if defined __hpux +# include +# endif +/* On native Windows platforms: + Get the 'fd_set' type. + Get the close() declaration before we override it. */ +# if @HAVE_WINSOCK2_H@ +# if !defined _GL_INCLUDING_WINSOCK2_H +# define _GL_INCLUDING_WINSOCK2_H +# include +# undef _GL_INCLUDING_WINSOCK2_H +# endif +# include +# endif +#endif + +/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ + +/* The definition of _GL_WARN_ON_USE is copied here. */ + + +/* Fix some definitions from . */ + +#if @HAVE_WINSOCK2_H@ + +# if !GNULIB_defined_rpl_fd_isset + +/* Re-define FD_ISSET to avoid a WSA call while we are not using + network sockets. */ +static int +rpl_fd_isset (SOCKET fd, fd_set * set) +{ + u_int i; + if (set == NULL) + return 0; + + for (i = 0; i < set->fd_count; i++) + if (set->fd_array[i] == fd) + return 1; + + return 0; +} + +# define GNULIB_defined_rpl_fd_isset 1 +# endif + +# undef FD_ISSET +# define FD_ISSET(fd, set) rpl_fd_isset(fd, set) + +#endif + +/* Hide some function declarations from . */ + +#if @HAVE_WINSOCK2_H@ +# if !defined _@GUARD_PREFIX@_UNISTD_H +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef close +# define close close_used_without_including_unistd_h +# elif !defined __clang__ + _GL_WARN_ON_USE (close, + "close() used without including "); +# endif +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef gethostname +# define gethostname gethostname_used_without_including_unistd_h +# elif !defined __clang__ + _GL_WARN_ON_USE (gethostname, + "gethostname() used without including "); +# endif +# endif +# if !defined _@GUARD_PREFIX@_SYS_SOCKET_H +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef socket +# define socket socket_used_without_including_sys_socket_h +# undef connect +# define connect connect_used_without_including_sys_socket_h +# undef accept +# define accept accept_used_without_including_sys_socket_h +# undef bind +# define bind bind_used_without_including_sys_socket_h +# undef getpeername +# define getpeername getpeername_used_without_including_sys_socket_h +# undef getsockname +# define getsockname getsockname_used_without_including_sys_socket_h +# undef getsockopt +# define getsockopt getsockopt_used_without_including_sys_socket_h +# undef listen +# define listen listen_used_without_including_sys_socket_h +# undef recv +# define recv recv_used_without_including_sys_socket_h +# undef send +# define send send_used_without_including_sys_socket_h +# undef recvfrom +# define recvfrom recvfrom_used_without_including_sys_socket_h +# undef sendto +# define sendto sendto_used_without_including_sys_socket_h +# undef setsockopt +# define setsockopt setsockopt_used_without_including_sys_socket_h +# undef shutdown +# define shutdown shutdown_used_without_including_sys_socket_h +# elif !defined __clang__ + _GL_WARN_ON_USE (socket, + "socket() used without including "); + _GL_WARN_ON_USE (connect, + "connect() used without including "); + _GL_WARN_ON_USE (accept, + "accept() used without including "); + _GL_WARN_ON_USE (bind, + "bind() used without including "); + _GL_WARN_ON_USE (getpeername, + "getpeername() used without including "); + _GL_WARN_ON_USE (getsockname, + "getsockname() used without including "); + _GL_WARN_ON_USE (getsockopt, + "getsockopt() used without including "); + _GL_WARN_ON_USE (listen, + "listen() used without including "); + _GL_WARN_ON_USE (recv, + "recv() used without including "); + _GL_WARN_ON_USE (send, + "send() used without including "); + _GL_WARN_ON_USE (recvfrom, + "recvfrom() used without including "); + _GL_WARN_ON_USE (sendto, + "sendto() used without including "); + _GL_WARN_ON_USE (setsockopt, + "setsockopt() used without including "); + _GL_WARN_ON_USE (shutdown, + "shutdown() used without including "); +# endif +# endif +#endif + + +#if @GNULIB_PSELECT@ +# if @REPLACE_PSELECT@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pselect +# define pselect rpl_pselect +# endif +_GL_FUNCDECL_RPL (pselect, int, + (int, fd_set *restrict, fd_set *restrict, fd_set *restrict, + struct timespec const *restrict, const sigset_t *restrict)); +_GL_CXXALIAS_RPL (pselect, int, + (int, fd_set *restrict, fd_set *restrict, fd_set *restrict, + struct timespec const *restrict, const sigset_t *restrict)); +# else +# if !@HAVE_PSELECT@ +_GL_FUNCDECL_SYS (pselect, int, + (int, fd_set *restrict, fd_set *restrict, fd_set *restrict, + struct timespec const *restrict, const sigset_t *restrict)); +# endif +/* Need to cast, because on AIX 7, the second, third, fourth argument may be + void *restrict, void *restrict, void *restrict. */ +_GL_CXXALIAS_SYS_CAST (pselect, int, + (int, + fd_set *restrict, fd_set *restrict, fd_set *restrict, + struct timespec const *restrict, + const sigset_t *restrict)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (pselect); +# endif +#elif defined GNULIB_POSIXCHECK +# undef pselect +# if HAVE_RAW_DECL_PSELECT +_GL_WARN_ON_USE (pselect, "pselect is not portable - " + "use gnulib module pselect for portability"); +# endif +#endif + +#if @GNULIB_SELECT@ +# if @REPLACE_SELECT@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef select +# define select rpl_select +# endif +_GL_FUNCDECL_RPL (select, int, + (int, fd_set *restrict, fd_set *restrict, fd_set *restrict, + struct timeval *restrict)); +_GL_CXXALIAS_RPL (select, int, + (int, fd_set *restrict, fd_set *restrict, fd_set *restrict, + timeval *restrict)); +# else +_GL_CXXALIAS_SYS (select, int, + (int, fd_set *restrict, fd_set *restrict, fd_set *restrict, + timeval *restrict)); +# endif +_GL_CXXALIASWARN (select); +#elif @HAVE_WINSOCK2_H@ +# undef select +# define select select_used_without_requesting_gnulib_module_select +#elif defined GNULIB_POSIXCHECK +# undef select +# if HAVE_RAW_DECL_SELECT +_GL_WARN_ON_USE (select, "select is not always POSIX compliant - " + "use gnulib module select for portability"); +# endif +#endif + + +#endif /* _@GUARD_PREFIX@_SYS_SELECT_H */ +#endif /* _@GUARD_PREFIX@_SYS_SELECT_H */ +#endif /* OSF/1 */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/sys_socket.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/sys_socket.c new file mode 100644 index 00000000..672d3aac --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/sys_socket.c @@ -0,0 +1,22 @@ +/* Inline functions for . + + Copyright (C) 2012-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +#define _GL_SYS_SOCKET_INLINE _GL_EXTERN_INLINE +#include +typedef int dummy; diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/sys_socket.in.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/sys_socket.in.h new file mode 100644 index 00000000..13833c0f --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/sys_socket.in.h @@ -0,0 +1,744 @@ +/* Provide a sys/socket header file for systems lacking it (read: MinGW) + and for systems where it is incomplete. + Copyright (C) 2005-2024 Free Software Foundation, Inc. + Written by Simon Josefsson. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* This file is supposed to be used on platforms that lack , + on platforms where cannot be included standalone, and on + platforms where does not provide all necessary definitions. + It is intended to provide definitions and prototypes needed by an + application. */ + +#if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +#endif +@PRAGMA_COLUMNS@ + +#if defined _GL_ALREADY_INCLUDING_SYS_SOCKET_H +/* Special invocation convention: + - On Cygwin 1.5.x we have a sequence of nested includes + -> -> -> , + and the latter includes . In this situation, the functions + are not yet declared, therefore we cannot provide the C++ aliases. */ + +#@INCLUDE_NEXT@ @NEXT_SYS_SOCKET_H@ + +#else +/* Normal invocation convention. */ + +#ifndef _@GUARD_PREFIX@_SYS_SOCKET_H + +#if @HAVE_SYS_SOCKET_H@ + +# define _GL_ALREADY_INCLUDING_SYS_SOCKET_H + +/* On many platforms, assumes prior inclusion of + . */ +# include + +/* On FreeBSD 6.4, defines some macros that assume that NULL + is defined. */ +# include + +/* The include_next requires a split double-inclusion guard. */ +# @INCLUDE_NEXT@ @NEXT_SYS_SOCKET_H@ + +# undef _GL_ALREADY_INCLUDING_SYS_SOCKET_H + +#endif + +#ifndef _@GUARD_PREFIX@_SYS_SOCKET_H +#define _@GUARD_PREFIX@_SYS_SOCKET_H + +/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, GNULIB_POSIXCHECK, + HAVE_RAW_DECL_*, alignof. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +_GL_INLINE_HEADER_BEGIN +#ifndef _GL_SYS_SOCKET_INLINE +# define _GL_SYS_SOCKET_INLINE _GL_INLINE +#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. */ + +#if !@HAVE_SA_FAMILY_T@ +# if !GNULIB_defined_sa_family_t +/* On OS/2 kLIBC, sa_family_t is unsigned char unless TCPV40HDRS is defined. */ +# if !defined __KLIBC__ || defined TCPV40HDRS +typedef unsigned short sa_family_t; +# else +typedef unsigned char sa_family_t; +# endif +# define GNULIB_defined_sa_family_t 1 +# endif +#endif + +#if @HAVE_STRUCT_SOCKADDR_STORAGE@ +/* Make the 'struct sockaddr_storage' field 'ss_family' visible on AIX 7.1. */ +# if !@HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY@ +# ifndef ss_family +# define ss_family __ss_family +# endif +# endif +#else +/* Code taken from glibc sysdeps/unix/sysv/linux/bits/socket.h on + 2009-05-08, licensed under LGPLv2.1+, plus portability fixes. */ +# define __ss_aligntype unsigned long int +# define _SS_SIZE 256 +# define _SS_PADSIZE \ + (_SS_SIZE - ((sizeof (sa_family_t) >= alignof (__ss_aligntype) \ + ? sizeof (sa_family_t) \ + : alignof (__ss_aligntype)) \ + + sizeof (__ss_aligntype))) + +# if !GNULIB_defined_struct_sockaddr_storage +struct sockaddr_storage +{ + sa_family_t ss_family; /* Address family, etc. */ + __ss_aligntype __ss_align; /* Force desired alignment. */ + char __ss_padding[_SS_PADSIZE]; +}; +# define GNULIB_defined_struct_sockaddr_storage 1 +# endif + +#endif + +/* Get struct iovec. */ +/* But avoid namespace pollution on glibc systems. */ +#if ! defined __GLIBC__ +# include +#endif + +#if @HAVE_SYS_SOCKET_H@ + +/* A platform that has . */ + +/* For shutdown(). */ +# if !defined SHUT_RD +# define SHUT_RD 0 +# endif +# if !defined SHUT_WR +# define SHUT_WR 1 +# endif +# if !defined SHUT_RDWR +# define SHUT_RDWR 2 +# endif + +# ifdef __VMS /* OpenVMS */ +# ifndef CMSG_SPACE +# define CMSG_SPACE(length) _CMSG_SPACE(length) +# endif +# ifndef CMSG_LEN +# define CMSG_LEN(length) _CMSG_LEN(length) +# endif +# endif + +#else + +# ifdef __CYGWIN__ +# error "Cygwin does have a sys/socket.h, doesn't it?!?" +# endif + +/* A platform that lacks . + + Currently only MinGW is supported. See the gnulib manual regarding + Windows sockets. MinGW has the header files winsock2.h and + ws2tcpip.h that declare the sys/socket.h definitions we need. Note + that you can influence which definitions you get by setting the + WINVER symbol before including these two files. For example, + getaddrinfo is only available if _WIN32_WINNT >= 0x0501 (that + symbol is set indirectly through WINVER). You can set this by + adding AC_DEFINE(WINVER, 0x0501) to configure.ac. Note that your + code may not run on older Windows releases then. My Windows 2000 + box was not able to run the code, for example. The situation is + slightly confusing because + + suggests that getaddrinfo should be available on all Windows + releases. */ + +# if @HAVE_WINSOCK2_H@ +# include +# endif +# if @HAVE_WS2TCPIP_H@ +# include +# endif + +/* For shutdown(). */ +# if !defined SHUT_RD && defined SD_RECEIVE +# define SHUT_RD SD_RECEIVE +# endif +# if !defined SHUT_WR && defined SD_SEND +# define SHUT_WR SD_SEND +# endif +# if !defined SHUT_RDWR && defined SD_BOTH +# define SHUT_RDWR SD_BOTH +# endif + +# if @HAVE_WINSOCK2_H@ +/* Include headers needed by the emulation code. */ +# include +# include +/* If these headers don't define socklen_t, does. */ +# endif + +/* Rudimentary 'struct msghdr'; this works as long as you don't try to + access msg_control or msg_controllen. */ +struct msghdr { + void *msg_name; + socklen_t msg_namelen; + struct iovec *msg_iov; + int msg_iovlen; + int msg_flags; +}; + +#endif + +/* Ensure SO_REUSEPORT is defined. */ +/* For the subtle differences between SO_REUSEPORT and SO_REUSEADDR, see + https://stackoverflow.com/questions/14388706/socket-options-so-reuseaddr-and-so-reuseport-how-do-they-differ-do-they-mean-t + and https://lwn.net/Articles/542629/ + */ +#ifndef SO_REUSEPORT +# define SO_REUSEPORT SO_REUSEADDR +#endif + +/* Fix some definitions from . */ + +#if @HAVE_WINSOCK2_H@ + +# if !GNULIB_defined_rpl_fd_isset + +/* Re-define FD_ISSET to avoid a WSA call while we are not using + network sockets. */ +_GL_SYS_SOCKET_INLINE int +rpl_fd_isset (SOCKET fd, fd_set * set) +{ + u_int i; + if (set == NULL) + return 0; + + for (i = 0; i < set->fd_count; i++) + if (set->fd_array[i] == fd) + return 1; + + return 0; +} + +# define GNULIB_defined_rpl_fd_isset 1 +# endif + +# undef FD_ISSET +# define FD_ISSET(fd, set) rpl_fd_isset(fd, set) + +#endif + +/* Hide some function declarations from . */ + +#if @HAVE_WINSOCK2_H@ +# if !defined _@GUARD_PREFIX@_UNISTD_H +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef close +# define close close_used_without_including_unistd_h +# elif !defined __clang__ + _GL_WARN_ON_USE (close, + "close() used without including "); +# endif +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef gethostname +# define gethostname gethostname_used_without_including_unistd_h +# else + _GL_WARN_ON_USE (gethostname, + "gethostname() used without including "); +# endif +# endif +# if !defined _@GUARD_PREFIX@_SYS_SELECT_H +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef select +# define select select_used_without_including_sys_select_h +# else + _GL_WARN_ON_USE (select, + "select() used without including "); +# endif +# endif +#endif + +/* Wrap everything else to use libc file descriptors for sockets. */ + +#if @GNULIB_SOCKET@ +# if @HAVE_WINSOCK2_H@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef socket +# define socket rpl_socket +# endif +_GL_FUNCDECL_RPL (socket, int, (int domain, int type, int protocol)); +_GL_CXXALIAS_RPL (socket, int, (int domain, int type, int protocol)); +# else +_GL_CXXALIAS_SYS (socket, int, (int domain, int type, int protocol)); +# endif +_GL_CXXALIASWARN (socket); +#elif @HAVE_WINSOCK2_H@ +# undef socket +# define socket socket_used_without_requesting_gnulib_module_socket +#elif defined GNULIB_POSIXCHECK +# undef socket +# if HAVE_RAW_DECL_SOCKET +_GL_WARN_ON_USE (socket, "socket is not always POSIX compliant - " + "use gnulib module socket for portability"); +# endif +#endif + +#if @GNULIB_CONNECT@ +# if @HAVE_WINSOCK2_H@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef connect +# define connect rpl_connect +# endif +_GL_FUNCDECL_RPL (connect, int, + (int fd, const struct sockaddr *addr, socklen_t addrlen) + _GL_ARG_NONNULL ((2))); +_GL_CXXALIAS_RPL (connect, int, + (int fd, const struct sockaddr *addr, socklen_t addrlen)); +# else +/* Need to cast, because on NonStop Kernel, the third parameter is + size_t addrlen. */ +_GL_CXXALIAS_SYS_CAST (connect, int, + (int fd, + const struct sockaddr *addr, socklen_t addrlen)); +# endif +_GL_CXXALIASWARN (connect); +#elif @HAVE_WINSOCK2_H@ +# undef connect +# define connect socket_used_without_requesting_gnulib_module_connect +#elif defined GNULIB_POSIXCHECK +# undef connect +# if HAVE_RAW_DECL_CONNECT +_GL_WARN_ON_USE (connect, "connect is not always POSIX compliant - " + "use gnulib module connect for portability"); +# endif +#endif + +#if @GNULIB_ACCEPT@ +# if @HAVE_WINSOCK2_H@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef accept +# define accept rpl_accept +# endif +_GL_FUNCDECL_RPL (accept, int, + (int fd, + struct sockaddr *restrict addr, + socklen_t *restrict addrlen)); +_GL_CXXALIAS_RPL (accept, int, + (int fd, + struct sockaddr *restrict addr, + socklen_t *restrict addrlen)); +# else +/* Need to cast, because on Solaris 10 systems, the third parameter is + void *addrlen. */ +_GL_CXXALIAS_SYS_CAST (accept, int, + (int fd, + struct sockaddr *restrict addr, + socklen_t *restrict addrlen)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (accept); +# endif +#elif @HAVE_WINSOCK2_H@ +# undef accept +# define accept accept_used_without_requesting_gnulib_module_accept +#elif defined GNULIB_POSIXCHECK +# undef accept +# if HAVE_RAW_DECL_ACCEPT +_GL_WARN_ON_USE (accept, "accept is not always POSIX compliant - " + "use gnulib module accept for portability"); +# endif +#endif + +#if @GNULIB_BIND@ +# if @HAVE_WINSOCK2_H@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef bind +# define bind rpl_bind +# endif +_GL_FUNCDECL_RPL (bind, int, + (int fd, const struct sockaddr *addr, socklen_t addrlen) + _GL_ARG_NONNULL ((2))); +_GL_CXXALIAS_RPL (bind, int, + (int fd, const struct sockaddr *addr, socklen_t addrlen)); +# else +/* Need to cast, because on NonStop Kernel, the third parameter is + size_t addrlen. */ +_GL_CXXALIAS_SYS_CAST (bind, int, + (int fd, + const struct sockaddr *addr, socklen_t addrlen)); +# endif +_GL_CXXALIASWARN (bind); +#elif @HAVE_WINSOCK2_H@ +# undef bind +# define bind bind_used_without_requesting_gnulib_module_bind +#elif defined GNULIB_POSIXCHECK +# undef bind +# if HAVE_RAW_DECL_BIND +_GL_WARN_ON_USE (bind, "bind is not always POSIX compliant - " + "use gnulib module bind for portability"); +# endif +#endif + +#if @GNULIB_GETPEERNAME@ +# if @HAVE_WINSOCK2_H@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef getpeername +# define getpeername rpl_getpeername +# endif +_GL_FUNCDECL_RPL (getpeername, int, + (int fd, struct sockaddr *restrict addr, + socklen_t *restrict addrlen) + _GL_ARG_NONNULL ((2, 3))); +_GL_CXXALIAS_RPL (getpeername, int, + (int fd, struct sockaddr *restrict addr, + socklen_t *restrict addrlen)); +# else +/* Need to cast, because on Solaris 10 systems, the third parameter is + void *addrlen. */ +_GL_CXXALIAS_SYS_CAST (getpeername, int, + (int fd, struct sockaddr *restrict addr, + socklen_t *restrict addrlen)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (getpeername); +# endif +#elif @HAVE_WINSOCK2_H@ +# undef getpeername +# define getpeername getpeername_used_without_requesting_gnulib_module_getpeername +#elif defined GNULIB_POSIXCHECK +# undef getpeername +# if HAVE_RAW_DECL_GETPEERNAME +_GL_WARN_ON_USE (getpeername, "getpeername is not always POSIX compliant - " + "use gnulib module getpeername for portability"); +# endif +#endif + +#if @GNULIB_GETSOCKNAME@ +# if @HAVE_WINSOCK2_H@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef getsockname +# define getsockname rpl_getsockname +# endif +_GL_FUNCDECL_RPL (getsockname, int, + (int fd, struct sockaddr *restrict addr, + socklen_t *restrict addrlen) + _GL_ARG_NONNULL ((2, 3))); +_GL_CXXALIAS_RPL (getsockname, int, + (int fd, struct sockaddr *restrict addr, + socklen_t *restrict addrlen)); +# else +/* Need to cast, because on Solaris 10 systems, the third parameter is + void *addrlen. */ +_GL_CXXALIAS_SYS_CAST (getsockname, int, + (int fd, struct sockaddr *restrict addr, + socklen_t *restrict addrlen)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (getsockname); +# endif +#elif @HAVE_WINSOCK2_H@ +# undef getsockname +# define getsockname getsockname_used_without_requesting_gnulib_module_getsockname +#elif defined GNULIB_POSIXCHECK +# undef getsockname +# if HAVE_RAW_DECL_GETSOCKNAME +_GL_WARN_ON_USE (getsockname, "getsockname is not always POSIX compliant - " + "use gnulib module getsockname for portability"); +# endif +#endif + +#if @GNULIB_GETSOCKOPT@ +# if @HAVE_WINSOCK2_H@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef getsockopt +# define getsockopt rpl_getsockopt +# endif +_GL_FUNCDECL_RPL (getsockopt, int, + (int fd, int level, int optname, + void *restrict optval, socklen_t *restrict optlen) + _GL_ARG_NONNULL ((4, 5))); +_GL_CXXALIAS_RPL (getsockopt, int, + (int fd, int level, int optname, + void *restrict optval, socklen_t *restrict optlen)); +# else +/* Need to cast, because on Solaris 10 systems, the fifth parameter is + void *optlen. */ +_GL_CXXALIAS_SYS_CAST (getsockopt, int, + (int fd, int level, int optname, + void *restrict optval, socklen_t *restrict optlen)); +# endif +_GL_CXXALIASWARN (getsockopt); +#elif @HAVE_WINSOCK2_H@ +# undef getsockopt +# define getsockopt getsockopt_used_without_requesting_gnulib_module_getsockopt +#elif defined GNULIB_POSIXCHECK +# undef getsockopt +# if HAVE_RAW_DECL_GETSOCKOPT +_GL_WARN_ON_USE (getsockopt, "getsockopt is not always POSIX compliant - " + "use gnulib module getsockopt for portability"); +# endif +#endif + +#if @GNULIB_LISTEN@ +# if @HAVE_WINSOCK2_H@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef listen +# define listen rpl_listen +# endif +_GL_FUNCDECL_RPL (listen, int, (int fd, int backlog)); +_GL_CXXALIAS_RPL (listen, int, (int fd, int backlog)); +# else +_GL_CXXALIAS_SYS (listen, int, (int fd, int backlog)); +# endif +_GL_CXXALIASWARN (listen); +#elif @HAVE_WINSOCK2_H@ +# undef listen +# define listen listen_used_without_requesting_gnulib_module_listen +#elif defined GNULIB_POSIXCHECK +# undef listen +# if HAVE_RAW_DECL_LISTEN +_GL_WARN_ON_USE (listen, "listen is not always POSIX compliant - " + "use gnulib module listen for portability"); +# endif +#endif + +#if @GNULIB_RECV@ +# if @HAVE_WINSOCK2_H@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef recv +# define recv rpl_recv +# endif +_GL_FUNCDECL_RPL (recv, ssize_t, (int fd, void *buf, size_t len, int flags) + _GL_ARG_NONNULL ((2))); +_GL_CXXALIAS_RPL (recv, ssize_t, (int fd, void *buf, size_t len, int flags)); +# else +/* Need to cast, because on HP-UX 11.31 the return type may be + int, + depending on compiler options. */ +_GL_CXXALIAS_SYS_CAST (recv, ssize_t, (int fd, void *buf, size_t len, int flags)); +# endif +_GL_CXXALIASWARN (recv); +#elif @HAVE_WINSOCK2_H@ +# undef recv +# define recv recv_used_without_requesting_gnulib_module_recv +#elif defined GNULIB_POSIXCHECK +# undef recv +# if HAVE_RAW_DECL_RECV +_GL_WARN_ON_USE (recv, "recv is not always POSIX compliant - " + "use gnulib module recv for portability"); +# endif +#endif + +#if @GNULIB_SEND@ +# if @HAVE_WINSOCK2_H@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef send +# define send rpl_send +# endif +_GL_FUNCDECL_RPL (send, ssize_t, + (int fd, const void *buf, size_t len, int flags) + _GL_ARG_NONNULL ((2))); +_GL_CXXALIAS_RPL (send, ssize_t, + (int fd, const void *buf, size_t len, int flags)); +# else +/* Need to cast, because on HP-UX 11.31 the return type may be + int, + depending on compiler options. */ +_GL_CXXALIAS_SYS_CAST (send, ssize_t, + (int fd, const void *buf, size_t len, int flags)); +# endif +_GL_CXXALIASWARN (send); +#elif @HAVE_WINSOCK2_H@ +# undef send +# define send send_used_without_requesting_gnulib_module_send +#elif defined GNULIB_POSIXCHECK +# undef send +# if HAVE_RAW_DECL_SEND +_GL_WARN_ON_USE (send, "send is not always POSIX compliant - " + "use gnulib module send for portability"); +# endif +#endif + +#if @GNULIB_RECVFROM@ +# if @HAVE_WINSOCK2_H@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef recvfrom +# define recvfrom rpl_recvfrom +# endif +_GL_FUNCDECL_RPL (recvfrom, ssize_t, + (int fd, void *restrict buf, size_t len, int flags, + struct sockaddr *restrict from, + socklen_t *restrict fromlen) + _GL_ARG_NONNULL ((2))); +_GL_CXXALIAS_RPL (recvfrom, ssize_t, + (int fd, void *restrict buf, size_t len, int flags, + struct sockaddr *restrict from, + socklen_t *restrict fromlen)); +# else +/* Need to cast, because on Solaris 10 systems, the sixth parameter is + void *fromlen. */ +_GL_CXXALIAS_SYS_CAST (recvfrom, ssize_t, + (int fd, void *restrict buf, size_t len, int flags, + struct sockaddr *restrict from, + socklen_t *restrict fromlen)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (recvfrom); +# endif +#elif @HAVE_WINSOCK2_H@ +# undef recvfrom +# define recvfrom recvfrom_used_without_requesting_gnulib_module_recvfrom +#elif defined GNULIB_POSIXCHECK +# undef recvfrom +# if HAVE_RAW_DECL_RECVFROM +_GL_WARN_ON_USE (recvfrom, "recvfrom is not always POSIX compliant - " + "use gnulib module recvfrom for portability"); +# endif +#endif + +#if @GNULIB_SENDTO@ +# if @HAVE_WINSOCK2_H@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef sendto +# define sendto rpl_sendto +# endif +_GL_FUNCDECL_RPL (sendto, ssize_t, + (int fd, const void *buf, size_t len, int flags, + const struct sockaddr *to, socklen_t tolen) + _GL_ARG_NONNULL ((2))); +_GL_CXXALIAS_RPL (sendto, ssize_t, + (int fd, const void *buf, size_t len, int flags, + const struct sockaddr *to, socklen_t tolen)); +# else +/* Need to cast, because on NonStop Kernel, the sixth parameter is + size_t tolen. */ +_GL_CXXALIAS_SYS_CAST (sendto, ssize_t, + (int fd, const void *buf, size_t len, int flags, + const struct sockaddr *to, socklen_t tolen)); +# endif +_GL_CXXALIASWARN (sendto); +#elif @HAVE_WINSOCK2_H@ +# undef sendto +# define sendto sendto_used_without_requesting_gnulib_module_sendto +#elif defined GNULIB_POSIXCHECK +# undef sendto +# if HAVE_RAW_DECL_SENDTO +_GL_WARN_ON_USE (sendto, "sendto is not always POSIX compliant - " + "use gnulib module sendto for portability"); +# endif +#endif + +#if @GNULIB_SETSOCKOPT@ +# if @HAVE_WINSOCK2_H@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef setsockopt +# define setsockopt rpl_setsockopt +# endif +_GL_FUNCDECL_RPL (setsockopt, int, (int fd, int level, int optname, + const void * optval, socklen_t optlen) + _GL_ARG_NONNULL ((4))); +_GL_CXXALIAS_RPL (setsockopt, int, (int fd, int level, int optname, + const void * optval, socklen_t optlen)); +# else +/* Need to cast, because on NonStop Kernel, the fifth parameter is + size_t optlen. */ +_GL_CXXALIAS_SYS_CAST (setsockopt, int, + (int fd, int level, int optname, + const void * optval, socklen_t optlen)); +# endif +_GL_CXXALIASWARN (setsockopt); +#elif @HAVE_WINSOCK2_H@ +# undef setsockopt +# define setsockopt setsockopt_used_without_requesting_gnulib_module_setsockopt +#elif defined GNULIB_POSIXCHECK +# undef setsockopt +# if HAVE_RAW_DECL_SETSOCKOPT +_GL_WARN_ON_USE (setsockopt, "setsockopt is not always POSIX compliant - " + "use gnulib module setsockopt for portability"); +# endif +#endif + +#if @GNULIB_SHUTDOWN@ +# if @HAVE_WINSOCK2_H@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef shutdown +# define shutdown rpl_shutdown +# endif +_GL_FUNCDECL_RPL (shutdown, int, (int fd, int how)); +_GL_CXXALIAS_RPL (shutdown, int, (int fd, int how)); +# else +_GL_CXXALIAS_SYS (shutdown, int, (int fd, int how)); +# endif +_GL_CXXALIASWARN (shutdown); +#elif @HAVE_WINSOCK2_H@ +# undef shutdown +# define shutdown shutdown_used_without_requesting_gnulib_module_shutdown +#elif defined GNULIB_POSIXCHECK +# undef shutdown +# if HAVE_RAW_DECL_SHUTDOWN +_GL_WARN_ON_USE (shutdown, "shutdown is not always POSIX compliant - " + "use gnulib module shutdown for portability"); +# endif +#endif + +#if @GNULIB_ACCEPT4@ +/* Accept a connection on a socket, with specific opening flags. + The flags are a bitmask, possibly including O_CLOEXEC (defined in ) + and O_TEXT, O_BINARY (defined in "binary-io.h"). + See also the Linux man page at + . */ +# if @HAVE_ACCEPT4@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define accept4 rpl_accept4 +# endif +_GL_FUNCDECL_RPL (accept4, int, + (int sockfd, struct sockaddr *addr, socklen_t *addrlen, + int flags)); +_GL_CXXALIAS_RPL (accept4, int, + (int sockfd, struct sockaddr *addr, socklen_t *addrlen, + int flags)); +# else +_GL_FUNCDECL_SYS (accept4, int, + (int sockfd, struct sockaddr *addr, socklen_t *addrlen, + int flags)); +_GL_CXXALIAS_SYS (accept4, int, + (int sockfd, struct sockaddr *addr, socklen_t *addrlen, + int flags)); +# endif +_GL_CXXALIASWARN (accept4); +#elif defined GNULIB_POSIXCHECK +# undef accept4 +# if HAVE_RAW_DECL_ACCEPT4 +_GL_WARN_ON_USE (accept4, "accept4 is unportable - " + "use gnulib module accept4 for portability"); +# endif +#endif + +_GL_INLINE_HEADER_END + +#endif /* _@GUARD_PREFIX@_SYS_SOCKET_H */ +#endif /* _@GUARD_PREFIX@_SYS_SOCKET_H */ +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/sys_uio.in.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/sys_uio.in.h new file mode 100644 index 00000000..5e71859d --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/sys_uio.in.h @@ -0,0 +1,63 @@ +/* Substitute for . + Copyright (C) 2011-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +# if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +# endif +@PRAGMA_COLUMNS@ + +#ifndef _@GUARD_PREFIX@_SYS_UIO_H + +#if @HAVE_SYS_UIO_H@ + +/* On OpenBSD 4.4, assumes prior inclusion of . */ +# include + +/* The include_next requires a split double-inclusion guard. */ +# @INCLUDE_NEXT@ @NEXT_SYS_UIO_H@ + +#endif + +#ifndef _@GUARD_PREFIX@_SYS_UIO_H +#define _@GUARD_PREFIX@_SYS_UIO_H + +#if !@HAVE_SYS_UIO_H@ +/* A platform that lacks . */ +/* Get 'size_t' and 'ssize_t'. */ +# include + +# ifdef __cplusplus +extern "C" { +# endif + +# if !GNULIB_defined_struct_iovec +/* All known platforms that lack also lack any declaration + of struct iovec in any other header. */ +struct iovec { + void *iov_base; + size_t iov_len; +}; +# define GNULIB_defined_struct_iovec 1 +# endif + +# ifdef __cplusplus +} +# endif + +#endif + +#endif /* _@GUARD_PREFIX@_SYS_UIO_H */ +#endif /* _@GUARD_PREFIX@_SYS_UIO_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-accept.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-accept.c new file mode 100644 index 00000000..ed02450b --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-accept.c @@ -0,0 +1,56 @@ +/* Test accepting a connection to a server socket. + Copyright (C) 2011-2024 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 . */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (accept, int, (int, struct sockaddr *, socklen_t *)); + +#include +#include +#include + +#include "sockets.h" +#include "macros.h" + +int +main (void) +{ + (void) gl_sockets_startup (SOCKETS_1_1); + + /* Test behaviour for invalid file descriptors. */ + { + struct sockaddr_in addr; + socklen_t addrlen = sizeof (addr); + + errno = 0; + ASSERT (accept (-1, (struct sockaddr *) &addr, &addrlen) == -1); + ASSERT (errno == EBADF); + } + { + struct sockaddr_in addr; + socklen_t addrlen = sizeof (addr); + + close (99); + errno = 0; + ASSERT (accept (99, (struct sockaddr *) &addr, &addrlen) == -1); + ASSERT (errno == EBADF); + } + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-alignasof.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-alignasof.c new file mode 100644 index 00000000..1cc75b0f --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-alignasof.c @@ -0,0 +1,100 @@ +/* Test of alignasof module. + Copyright 2009-2024 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 . */ + +/* Written by Paul Eggert, inspired by Bruno Haible's test-alignof.c. */ + +#include + +#include +#include + +#include "macros.h" + +typedef long double longdouble; +typedef struct { char a[1]; } struct1; +typedef struct { char a[2]; } struct2; +typedef struct { char a[3]; } struct3; +typedef struct { char a[4]; } struct4; + +#if (202311 <= __STDC_VERSION__ || __alignas_is_defined \ + || 201103 <= __cplusplus) +/* mingw can go up only to 8. 8 is all that GNU Emacs needs, so let's + limit the test to 8 for now. */ +# define TEST_ALIGNMENT 8 +#else +# undef alignas +# define alignas(alignment) +# define TEST_ALIGNMENT 1 +#endif + +#define CHECK_STATIC(type) \ + typedef struct { char slot1; type slot2; } type##_helper; \ + static_assert (alignof (type) == offsetof (type##_helper, slot2)); \ + const int type##_alignment = alignof (type); \ + type alignas (TEST_ALIGNMENT) static_##type##_alignas + +#define CHECK_ALIGNED(var) ASSERT ((uintptr_t) &(var) % TEST_ALIGNMENT == 0) + +CHECK_STATIC (char); +CHECK_STATIC (short); +CHECK_STATIC (int); +CHECK_STATIC (long); +#ifdef INT64_MAX +CHECK_STATIC (int64_t); +#endif +CHECK_STATIC (float); +CHECK_STATIC (double); +/* CHECK_STATIC (longdouble); */ +CHECK_STATIC (struct1); +CHECK_STATIC (struct2); +CHECK_STATIC (struct3); +CHECK_STATIC (struct4); + +int +main () +{ +#if defined __SUNPRO_C && __SUNPRO_C < 0x5150 + /* Avoid a test failure due to Sun Studio Developer Bug Report #2125432. */ + fputs ("Skipping test: known Sun C compiler bug\n", stderr); + return 77; +#elif defined __HP_cc && __ia64 + /* Avoid a test failure due to HP-UX Itanium cc bug; see: + https://lists.gnu.org/r/bug-gnulib/2017-03/msg00078.html */ + fputs ("Skipping test: known HP-UX Itanium cc compiler bug\n", stderr); + return 77; +#elif defined __clang__ && defined __ibmxl__ + /* Avoid a test failure with IBM xlc 16.1. It ignores alignas (8), + _Alignas (8), and __attribute__ ((__aligned__ (8))). */ + fputs ("Skipping test: known AIX XL C compiler deficiency\n", stderr); + return 77; +#else + CHECK_ALIGNED (static_char_alignas); + CHECK_ALIGNED (static_short_alignas); + CHECK_ALIGNED (static_int_alignas); + CHECK_ALIGNED (static_long_alignas); +# ifdef INT64_MAX + CHECK_ALIGNED (static_int64_t_alignas); +# endif + CHECK_ALIGNED (static_float_alignas); + CHECK_ALIGNED (static_double_alignas); + /* CHECK_ALIGNED (static_longdouble_alignas); */ + CHECK_ALIGNED (static_struct1_alignas); + CHECK_ALIGNED (static_struct2_alignas); + CHECK_ALIGNED (static_struct3_alignas); + CHECK_ALIGNED (static_struct4_alignas); + return 0; +#endif +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-alloca-opt.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-alloca-opt.c new file mode 100644 index 00000000..3f20779c --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-alloca-opt.c @@ -0,0 +1,62 @@ +/* Test of optional automatic memory allocation. + Copyright (C) 2005, 2007, 2009-2024 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 . */ + +/* Written by Bruno Haible , 2007. */ + +#include + +#include + +#if HAVE_ALLOCA + +static void +do_allocation (int n) +{ + void *volatile ptr = alloca (n); + (void) ptr; +} + +void (*func) (int) = do_allocation; + +#endif + +int +main () +{ +#if HAVE_ALLOCA + int i; + + /* Repeat a lot of times, to make sure there's no memory leak. */ + for (i = 0; i < 100000; i++) + { + /* Try various values. + n = 0 gave a crash on Alpha with gcc-2.5.8. + Some versions of Mac OS X have a stack size limit of 512 KB. */ + func (34); + func (134); + func (399); + func (510823); + func (129321); + func (0); + func (4070); + func (4095); + func (1); + func (16582); + } +#endif + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-argmatch.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-argmatch.c new file mode 100644 index 00000000..2c18077f --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-argmatch.c @@ -0,0 +1,189 @@ +/* Test of exact or abbreviated match search. + Copyright (C) 1990, 1998-1999, 2001-2024 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 . */ + +/* Written by Bruno Haible , 2007, based on test code + by David MacKenzie . */ + +#include + +/* As of GCC 11.2.1, gcc -Wanalyzer-too-complex reports that main's + use of CHECK macros expands to code that is too complicated for gcc + -fanalyzer. Suppress the resulting bogus warnings. */ +#if 10 <= __GNUC__ +# pragma GCC diagnostic ignored "-Wanalyzer-null-argument" +#endif + +#include "argmatch.h" + +#include + +#include "macros.h" + +# define N_(Msgid) (Msgid) + +/* Some packages define ARGMATCH_DIE and ARGMATCH_DIE_DECL in , and + thus must link with a definition of that function. Provide it here. */ +#ifdef ARGMATCH_DIE_DECL + +_Noreturn ARGMATCH_DIE_DECL; +ARGMATCH_DIE_DECL { exit (1); } + +#endif + +enum backup_type +{ + no_backups, + simple_backups, + numbered_existing_backups, + numbered_backups +}; + +static const char *const backup_args[] = +{ + "no", "none", "off", + "simple", "never", "single", + "existing", "nil", "numbered-existing", + "numbered", "t", "newstyle", + NULL +}; + +static const enum backup_type backup_vals[] = +{ + no_backups, no_backups, no_backups, + simple_backups, simple_backups, simple_backups, + numbered_existing_backups, numbered_existing_backups, numbered_existing_backups, + numbered_backups, numbered_backups, numbered_backups +}; + +ARGMATCH_DEFINE_GROUP(backup, enum backup_type) + +static const argmatch_backup_doc argmatch_backup_docs[] = +{ + { "no", N_("never make backups (even if --backup is given)") }, + { "numbered", N_("make numbered backups") }, + { "existing", N_("numbered if numbered backups exist, simple otherwise") }, + { "simple", N_("always make simple backups") }, + { NULL, NULL } +}; + +static const argmatch_backup_arg argmatch_backup_args[] = +{ + { "no", no_backups }, + { "none", no_backups }, + { "off", no_backups }, + { "simple", simple_backups }, + { "never", simple_backups }, + { "single", simple_backups }, + { "existing", numbered_existing_backups }, + { "nil", numbered_existing_backups }, + { "numbered-existing", numbered_existing_backups }, + { "numbered", numbered_backups }, + { "t", numbered_backups }, + { "newstyle", numbered_backups }, + { NULL, no_backups } +}; + +const argmatch_backup_group_type argmatch_backup_group = +{ + argmatch_backup_args, + argmatch_backup_docs, + N_("\ +The backup suffix is '~', unless set with --suffix or SIMPLE_BACKUP_SUFFIX.\n\ +The version control method may be selected via the --backup option or through\n\ +the VERSION_CONTROL environment variable. Here are the values:\n"), + NULL +}; + +int +main (int argc, char *argv[]) +{ +#define CHECK(Input, Output) \ + do { \ + ASSERT (ARGMATCH (Input, backup_args, backup_vals) == Output); \ + ASSERT (argmatch_backup_choice (Input) == Output); \ + if (0 <= Output) \ + { \ + enum backup_type val \ + = argmatch_backup_args[Output < 0 ? 0 : Output].val; \ + ASSERT (*argmatch_backup_value ("test", Input) == val); \ + ASSERT (*argmatch_backup_value ("test", \ + argmatch_backup_argument (&val)) \ + == val); \ + } \ + } while (0) + +#define CHECK_EXACT(Input, Output) \ + do { \ + ASSERT (ARGMATCH_EXACT (Input, backup_args) == Output); \ + } while (0) + + /* Not found. */ + CHECK ("klingon", -1); + CHECK_EXACT ("klingon", -1); + + /* Exact match. */ + CHECK ("none", 1); + CHECK_EXACT ("none", 1); + CHECK ("nil", 7); + CHECK_EXACT ("nil", 7); + + /* Too long. */ + CHECK ("nilpotent", -1); + CHECK_EXACT ("nilpotent", -1); + + /* Abbreviated. */ + CHECK ("simpl", 3); + CHECK_EXACT ("simpl", -1); + CHECK ("simp", 3); + CHECK_EXACT ("simp", -1); + CHECK ("sim", 3); + CHECK_EXACT ("sim", -1); + + /* Exact match and abbreviated. */ + CHECK ("numbered", 9); + CHECK_EXACT ("numbered", 9); + CHECK ("numbere", -2); + CHECK_EXACT ("numbere", -1); + CHECK ("number", -2); + CHECK_EXACT ("number", -1); + CHECK ("numbe", -2); + CHECK_EXACT ("numbe", -1); + CHECK ("numb", -2); + CHECK_EXACT ("numb", -1); + CHECK ("num", -2); + CHECK_EXACT ("num", -1); + CHECK ("nu", -2); + CHECK_EXACT ("nu", -1); + CHECK ("n", -2); + CHECK_EXACT ("n", -1); + + /* Ambiguous abbreviated. */ + CHECK ("ne", -2); + CHECK_EXACT ("ne", -1); + + /* Ambiguous abbreviated, but same value ("single" and "simple"). */ + CHECK ("si", 3); + CHECK_EXACT ("si", -1); + CHECK ("s", 3); + CHECK_EXACT ("s", -1); + +#undef CHECK +#undef CHECK_EXACT + + argmatch_backup_usage (stdout); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-arpa_inet.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-arpa_inet.c new file mode 100644 index 00000000..77222638 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-arpa_inet.c @@ -0,0 +1,27 @@ +/* Test of substitute. + Copyright (C) 2007, 2009-2024 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 . */ + +/* Written by Bruno Haible , 2007. */ + +#include + +#include + +int +main (void) +{ + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-assert.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-assert.c new file mode 100644 index 00000000..771eec34 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-assert.c @@ -0,0 +1,72 @@ +/* Test assert.h and static_assert. + Copyright 2022-2024 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 . */ + +/* Written by Paul Eggert. */ + +#include + +#define STATIC_ASSERT_TESTS \ + static_assert (2 + 2 == 4, "arithmetic does not work"); \ + static_assert (2 + 2 == 4); \ + static_assert (sizeof (char) == 1, "sizeof does not work"); \ + static_assert (sizeof (char) == 1) + +STATIC_ASSERT_TESTS; + +static char const * +assert (char const *p, int i) +{ + return p + i; +} + +static char const * +f (char const *p) +{ + return assert (p, 0); +} + +#include + +STATIC_ASSERT_TESTS; + +static int +g (void) +{ + assert (f ("this should work")); + return 0; +} + +#define NDEBUG 1 +#include + +STATIC_ASSERT_TESTS; + +static int +h (void) +{ + assert (f ("this should work")); + return 0; +} + +int +main (void) +{ + STATIC_ASSERT_TESTS; + f (""); + g (); + h (); + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-binary-io.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-binary-io.c new file mode 100644 index 00000000..32de2fe4 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-binary-io.c @@ -0,0 +1,63 @@ +/* Test of binary mode I/O. + Copyright (C) 2005, 2007-2024 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 . */ + +/* Written by Bruno Haible , 2005. */ + +#include + +#include "binary-io.h" + +#include +#include +#include +#include +#include +#include + +#include "macros.h" + +int +main (_GL_UNUSED int argc, char *argv[]) +{ + /* Test the O_BINARY macro. */ + { + int fd = + open ("t-bin-out0.tmp", O_CREAT | O_TRUNC | O_RDWR | O_BINARY, 0600); + if (write (fd, "Hello\n", 6) < 0) + exit (1); + close (fd); + } + { + struct stat statbuf; + if (stat ("t-bin-out0.tmp", &statbuf) < 0) + exit (1); + ASSERT (statbuf.st_size == 6); + } + + switch (argv[1][0]) + { + case '1': + /* Test the set_binary_mode() function. */ + set_binary_mode (1, O_BINARY); + fputs ("Hello\n", stdout); + break; + + default: + break; + } + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-binary-io.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-binary-io.sh new file mode 100755 index 00000000..7bc5aa07 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-binary-io.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +tmpfiles="" +trap 'rm -fr $tmpfiles' HUP INT QUIT TERM + +tmpfiles="$tmpfiles t-bin-out0.tmp t-bin-out1.tmp" +${CHECKER} ./test-binary-io${EXEEXT} 1 > t-bin-out1.tmp || exit 1 +cmp t-bin-out0.tmp t-bin-out1.tmp > /dev/null || exit 1 + +rm -fr $tmpfiles + +exit 0 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-bind.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-bind.c new file mode 100644 index 00000000..0f8e783a --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-bind.c @@ -0,0 +1,58 @@ +/* Test binding a server socket to a port. + Copyright (C) 2011-2024 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 . */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (bind, int, (int, const struct sockaddr *, socklen_t)); + +#include +#include +#include +#include + +#include "sockets.h" +#include "macros.h" + +int +main (void) +{ + (void) gl_sockets_startup (SOCKETS_1_1); + + /* Test behaviour for invalid file descriptors. */ + { + struct sockaddr_in addr; + + addr.sin_family = AF_INET; + inet_pton (AF_INET, "127.0.0.1", &addr.sin_addr); + addr.sin_port = htons (80); + { + errno = 0; + ASSERT (bind (-1, (const struct sockaddr *) &addr, sizeof (addr)) == -1); + ASSERT (errno == EBADF); + } + { + close (99); + errno = 0; + ASSERT (bind (99, (const struct sockaddr *) &addr, sizeof (addr)) == -1); + ASSERT (errno == EBADF); + } + } + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-bitrotate.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-bitrotate.c new file mode 100644 index 00000000..73d75b5b --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-bitrotate.c @@ -0,0 +1,279 @@ +/* Test of substitute. + Copyright (C) 2007-2024 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 . */ + +/* Written by Simon Josefsson , 2008. */ + +#include + +#include "bitrotate.h" + +#include "macros.h" + +int +main (void) +{ + ASSERT (rotl8 (42, 0) == 42); + ASSERT (rotl8 (42, 1) == 84); + ASSERT (rotl8 (42, 2) == 168); + ASSERT (rotl8 (42, 3) == 81); + ASSERT (rotl8 (42, 4) == 162); + ASSERT (rotl8 (42, 5) == 69); + ASSERT (rotl8 (42, 6) == 138); + ASSERT (rotl8 (42, 7) == 21); + ASSERT (rotl8 (42, 8) == 42); + + ASSERT (rotr8 (42, 0) == 42); + ASSERT (rotr8 (42, 1) == 21); + ASSERT (rotr8 (42, 2) == 138); + ASSERT (rotr8 (42, 3) == 69); + ASSERT (rotr8 (42, 4) == 162); + ASSERT (rotr8 (42, 5) == 81); + ASSERT (rotr8 (42, 6) == 168); + ASSERT (rotr8 (42, 7) == 84); + ASSERT (rotr8 (42, 8) == 42); + + ASSERT (rotl16 (43981, 0) == 43981); + ASSERT (rotl16 (43981, 1) == 22427); + ASSERT (rotl16 (43981, 2) == 44854); + ASSERT (rotl16 (43981, 3) == 24173); + ASSERT (rotl16 (43981, 4) == 48346); + ASSERT (rotl16 (43981, 5) == 31157); + ASSERT (rotl16 (43981, 6) == 62314); + ASSERT (rotl16 (43981, 7) == 59093); + ASSERT (rotl16 (43981, 8) == 52651); + ASSERT (rotl16 (43981, 9) == 39767); + ASSERT (rotl16 (43981, 10) == 13999); + ASSERT (rotl16 (43981, 11) == 27998); + ASSERT (rotl16 (43981, 12) == 55996); + ASSERT (rotl16 (43981, 13) == 46457); + ASSERT (rotl16 (43981, 14) == 27379); + ASSERT (rotl16 (43981, 15) == 54758); + ASSERT (rotl16 (43981, 16) == 43981); + + ASSERT (rotr16 (43981, 0) == 43981); + ASSERT (rotr16 (43981, 1) == 54758); + ASSERT (rotr16 (43981, 2) == 27379); + ASSERT (rotr16 (43981, 3) == 46457); + ASSERT (rotr16 (43981, 4) == 55996); + ASSERT (rotr16 (43981, 5) == 27998); + ASSERT (rotr16 (43981, 6) == 13999); + ASSERT (rotr16 (43981, 7) == 39767); + ASSERT (rotr16 (43981, 8) == 52651); + ASSERT (rotr16 (43981, 9) == 59093); + ASSERT (rotr16 (43981, 10) == 62314); + ASSERT (rotr16 (43981, 11) == 31157); + ASSERT (rotr16 (43981, 12) == 48346); + ASSERT (rotr16 (43981, 13) == 24173); + ASSERT (rotr16 (43981, 14) == 44854); + ASSERT (rotr16 (43981, 15) == 22427); + ASSERT (rotr16 (43981, 16) == 43981); + + ASSERT (rotl32 (2309737967U, 1) == 324508639U); + ASSERT (rotl32 (2309737967U, 2) == 649017278U); + ASSERT (rotl32 (2309737967U, 3) == 1298034556U); + ASSERT (rotl32 (2309737967U, 4) == 2596069112U); + ASSERT (rotl32 (2309737967U, 5) == 897170929U); + ASSERT (rotl32 (2309737967U, 6) == 1794341858U); + ASSERT (rotl32 (2309737967U, 7) == 3588683716U); + ASSERT (rotl32 (2309737967U, 8) == 2882400137U); + ASSERT (rotl32 (2309737967U, 9) == 1469832979U); + ASSERT (rotl32 (2309737967U, 10) == 2939665958U); + ASSERT (rotl32 (2309737967U, 11) == 1584364621U); + ASSERT (rotl32 (2309737967U, 12) == 3168729242U); + ASSERT (rotl32 (2309737967U, 13) == 2042491189U); + ASSERT (rotl32 (2309737967U, 14) == 4084982378U); + ASSERT (rotl32 (2309737967U, 15) == 3874997461U); + ASSERT (rotl32 (2309737967U, 16) == 3455027627U); + ASSERT (rotl32 (2309737967U, 17) == 2615087959U); + ASSERT (rotl32 (2309737967U, 18) == 935208623U); + ASSERT (rotl32 (2309737967U, 19) == 1870417246U); + ASSERT (rotl32 (2309737967U, 20) == 3740834492U); + ASSERT (rotl32 (2309737967U, 21) == 3186701689U); + ASSERT (rotl32 (2309737967U, 22) == 2078436083U); + ASSERT (rotl32 (2309737967U, 23) == 4156872166U); + ASSERT (rotl32 (2309737967U, 24) == 4018777037U); + ASSERT (rotl32 (2309737967U, 25) == 3742586779U); + ASSERT (rotl32 (2309737967U, 26) == 3190206263U); + ASSERT (rotl32 (2309737967U, 27) == 2085445231U); + ASSERT (rotl32 (2309737967U, 28) == 4170890462U); + ASSERT (rotl32 (2309737967U, 29) == 4046813629U); + ASSERT (rotl32 (2309737967U, 30) == 3798659963U); + ASSERT (rotl32 (2309737967U, 31) == 3302352631U); + + ASSERT (rotr32 (2309737967U, 1) == 3302352631lU); + ASSERT (rotr32 (2309737967U, 2) == 3798659963lU); + ASSERT (rotr32 (2309737967U, 3) == 4046813629lU); + ASSERT (rotr32 (2309737967U, 4) == 4170890462lU); + ASSERT (rotr32 (2309737967U, 5) == 2085445231lU); + ASSERT (rotr32 (2309737967U, 6) == 3190206263lU); + ASSERT (rotr32 (2309737967U, 7) == 3742586779lU); + ASSERT (rotr32 (2309737967U, 8) == 4018777037lU); + ASSERT (rotr32 (2309737967U, 9) == 4156872166lU); + ASSERT (rotr32 (2309737967U, 10) == 2078436083lU); + ASSERT (rotr32 (2309737967U, 11) == 3186701689lU); + ASSERT (rotr32 (2309737967U, 12) == 3740834492lU); + ASSERT (rotr32 (2309737967U, 13) == 1870417246lU); + ASSERT (rotr32 (2309737967U, 14) == 935208623lU); + ASSERT (rotr32 (2309737967U, 15) == 2615087959lU); + ASSERT (rotr32 (2309737967U, 16) == 3455027627lU); + ASSERT (rotr32 (2309737967U, 17) == 3874997461lU); + ASSERT (rotr32 (2309737967U, 18) == 4084982378lU); + ASSERT (rotr32 (2309737967U, 19) == 2042491189lU); + ASSERT (rotr32 (2309737967U, 20) == 3168729242lU); + ASSERT (rotr32 (2309737967U, 21) == 1584364621lU); + ASSERT (rotr32 (2309737967U, 22) == 2939665958lU); + ASSERT (rotr32 (2309737967U, 23) == 1469832979lU); + ASSERT (rotr32 (2309737967U, 24) == 2882400137lU); + ASSERT (rotr32 (2309737967U, 25) == 3588683716lU); + ASSERT (rotr32 (2309737967U, 26) == 1794341858lU); + ASSERT (rotr32 (2309737967U, 27) == 897170929lU); + ASSERT (rotr32 (2309737967U, 28) == 2596069112lU); + ASSERT (rotr32 (2309737967U, 29) == 1298034556lU); + ASSERT (rotr32 (2309737967U, 30) == 649017278lU); + ASSERT (rotr32 (2309737967U, 31) == 324508639lU); + +#ifdef UINT64_MAX + ASSERT (rotl64 (16045690984503098046ULL, 1) == 13644637895296644477ULL); + ASSERT (rotl64 (16045690984503098046ULL, 2) == 8842531716883737339ULL); + ASSERT (rotl64 (16045690984503098046ULL, 3) == 17685063433767474678ULL); + ASSERT (rotl64 (16045690984503098046ULL, 4) == 16923382793825397741ULL); + ASSERT (rotl64 (16045690984503098046ULL, 5) == 15400021513941243867ULL); + ASSERT (rotl64 (16045690984503098046ULL, 6) == 12353298954172936119ULL); + ASSERT (rotl64 (16045690984503098046ULL, 7) == 6259853834636320623ULL); + ASSERT (rotl64 (16045690984503098046ULL, 8) == 12519707669272641246ULL); + ASSERT (rotl64 (16045690984503098046ULL, 9) == 6592671264835730877ULL); + ASSERT (rotl64 (16045690984503098046ULL, 10) == 13185342529671461754ULL); + ASSERT (rotl64 (16045690984503098046ULL, 11) == 7923940985633371893ULL); + ASSERT (rotl64 (16045690984503098046ULL, 12) == 15847881971266743786ULL); + ASSERT (rotl64 (16045690984503098046ULL, 13) == 13249019868823935957ULL); + ASSERT (rotl64 (16045690984503098046ULL, 14) == 8051295663938320299ULL); + ASSERT (rotl64 (16045690984503098046ULL, 15) == 16102591327876640598ULL); + ASSERT (rotl64 (16045690984503098046ULL, 16) == 13758438582043729581ULL); + ASSERT (rotl64 (16045690984503098046ULL, 17) == 9070133090377907547ULL); + ASSERT (rotl64 (16045690984503098046ULL, 18) == 18140266180755815094ULL); + ASSERT (rotl64 (16045690984503098046ULL, 19) == 17833788287802078573ULL); + ASSERT (rotl64 (16045690984503098046ULL, 20) == 17220832501894605531ULL); + ASSERT (rotl64 (16045690984503098046ULL, 21) == 15994920930079659447ULL); + ASSERT (rotl64 (16045690984503098046ULL, 22) == 13543097786449767279ULL); + ASSERT (rotl64 (16045690984503098046ULL, 23) == 8639451499189982943ULL); + ASSERT (rotl64 (16045690984503098046ULL, 24) == 17278902998379965886ULL); + ASSERT (rotl64 (16045690984503098046ULL, 25) == 16111061923050380157ULL); + ASSERT (rotl64 (16045690984503098046ULL, 26) == 13775379772391208699ULL); + ASSERT (rotl64 (16045690984503098046ULL, 27) == 9104015471072865783ULL); + ASSERT (rotl64 (16045690984503098046ULL, 28) == 18208030942145731566ULL); + ASSERT (rotl64 (16045690984503098046ULL, 29) == 17969317810581911517ULL); + ASSERT (rotl64 (16045690984503098046ULL, 30) == 17491891547454271419ULL); + ASSERT (rotl64 (16045690984503098046ULL, 31) == 16537039021198991223ULL); + ASSERT (rotl64 (16045690984503098046ULL, 32) == 14627333968688430831ULL); + ASSERT (rotl64 (16045690984503098046ULL, 33) == 10807923863667310047ULL); + ASSERT (rotl64 (16045690984503098046ULL, 34) == 3169103653625068479ULL); + ASSERT (rotl64 (16045690984503098046ULL, 35) == 6338207307250136958ULL); + ASSERT (rotl64 (16045690984503098046ULL, 36) == 12676414614500273916ULL); + ASSERT (rotl64 (16045690984503098046ULL, 37) == 6906085155290996217ULL); + ASSERT (rotl64 (16045690984503098046ULL, 38) == 13812170310581992434ULL); + ASSERT (rotl64 (16045690984503098046ULL, 39) == 9177596547454433253ULL); + ASSERT (rotl64 (16045690984503098046ULL, 40) == 18355193094908866506ULL); + ASSERT (rotl64 (16045690984503098046ULL, 41) == 18263642116108181397ULL); + ASSERT (rotl64 (16045690984503098046ULL, 42) == 18080540158506811179ULL); + ASSERT (rotl64 (16045690984503098046ULL, 43) == 17714336243304070743ULL); + ASSERT (rotl64 (16045690984503098046ULL, 44) == 16981928412898589871ULL); + ASSERT (rotl64 (16045690984503098046ULL, 45) == 15517112752087628127ULL); + ASSERT (rotl64 (16045690984503098046ULL, 46) == 12587481430465704639ULL); + ASSERT (rotl64 (16045690984503098046ULL, 47) == 6728218787221857663ULL); + ASSERT (rotl64 (16045690984503098046ULL, 48) == 13456437574443715326ULL); + ASSERT (rotl64 (16045690984503098046ULL, 49) == 8466131075177879037ULL); + ASSERT (rotl64 (16045690984503098046ULL, 50) == 16932262150355758074ULL); + ASSERT (rotl64 (16045690984503098046ULL, 51) == 15417780227001964533ULL); + ASSERT (rotl64 (16045690984503098046ULL, 52) == 12388816380294377451ULL); + ASSERT (rotl64 (16045690984503098046ULL, 53) == 6330888686879203287ULL); + ASSERT (rotl64 (16045690984503098046ULL, 54) == 12661777373758406574ULL); + ASSERT (rotl64 (16045690984503098046ULL, 55) == 6876810673807261533ULL); + ASSERT (rotl64 (16045690984503098046ULL, 56) == 13753621347614523066ULL); + ASSERT (rotl64 (16045690984503098046ULL, 57) == 9060498621519494517ULL); + ASSERT (rotl64 (16045690984503098046ULL, 58) == 18120997243038989034ULL); + ASSERT (rotl64 (16045690984503098046ULL, 59) == 17795250412368426453ULL); + ASSERT (rotl64 (16045690984503098046ULL, 60) == 17143756751027301291ULL); + ASSERT (rotl64 (16045690984503098046ULL, 61) == 15840769428345050967ULL); + ASSERT (rotl64 (16045690984503098046ULL, 62) == 13234794782980550319ULL); + ASSERT (rotl64 (16045690984503098046ULL, 63) == 8022845492251549023ULL); + + ASSERT (rotr64 (16045690984503098046ULL, 1) == 8022845492251549023ULL); + ASSERT (rotr64 (16045690984503098046ULL, 2) == 13234794782980550319ULL); + ASSERT (rotr64 (16045690984503098046ULL, 3) == 15840769428345050967ULL); + ASSERT (rotr64 (16045690984503098046ULL, 4) == 17143756751027301291ULL); + ASSERT (rotr64 (16045690984503098046ULL, 5) == 17795250412368426453ULL); + ASSERT (rotr64 (16045690984503098046ULL, 6) == 18120997243038989034ULL); + ASSERT (rotr64 (16045690984503098046ULL, 7) == 9060498621519494517ULL); + ASSERT (rotr64 (16045690984503098046ULL, 8) == 13753621347614523066ULL); + ASSERT (rotr64 (16045690984503098046ULL, 9) == 6876810673807261533ULL); + ASSERT (rotr64 (16045690984503098046ULL, 10) == 12661777373758406574ULL); + ASSERT (rotr64 (16045690984503098046ULL, 11) == 6330888686879203287ULL); + ASSERT (rotr64 (16045690984503098046ULL, 12) == 12388816380294377451ULL); + ASSERT (rotr64 (16045690984503098046ULL, 13) == 15417780227001964533ULL); + ASSERT (rotr64 (16045690984503098046ULL, 14) == 16932262150355758074ULL); + ASSERT (rotr64 (16045690984503098046ULL, 15) == 8466131075177879037ULL); + ASSERT (rotr64 (16045690984503098046ULL, 16) == 13456437574443715326ULL); + ASSERT (rotr64 (16045690984503098046ULL, 17) == 6728218787221857663ULL); + ASSERT (rotr64 (16045690984503098046ULL, 18) == 12587481430465704639ULL); + ASSERT (rotr64 (16045690984503098046ULL, 19) == 15517112752087628127ULL); + ASSERT (rotr64 (16045690984503098046ULL, 20) == 16981928412898589871ULL); + ASSERT (rotr64 (16045690984503098046ULL, 21) == 17714336243304070743ULL); + ASSERT (rotr64 (16045690984503098046ULL, 22) == 18080540158506811179ULL); + ASSERT (rotr64 (16045690984503098046ULL, 23) == 18263642116108181397ULL); + ASSERT (rotr64 (16045690984503098046ULL, 24) == 18355193094908866506ULL); + ASSERT (rotr64 (16045690984503098046ULL, 25) == 9177596547454433253ULL); + ASSERT (rotr64 (16045690984503098046ULL, 26) == 13812170310581992434ULL); + ASSERT (rotr64 (16045690984503098046ULL, 27) == 6906085155290996217ULL); + ASSERT (rotr64 (16045690984503098046ULL, 28) == 12676414614500273916ULL); + ASSERT (rotr64 (16045690984503098046ULL, 29) == 6338207307250136958ULL); + ASSERT (rotr64 (16045690984503098046ULL, 30) == 3169103653625068479ULL); + ASSERT (rotr64 (16045690984503098046ULL, 31) == 10807923863667310047ULL); + ASSERT (rotr64 (16045690984503098046ULL, 32) == 14627333968688430831ULL); + ASSERT (rotr64 (16045690984503098046ULL, 33) == 16537039021198991223ULL); + ASSERT (rotr64 (16045690984503098046ULL, 34) == 17491891547454271419ULL); + ASSERT (rotr64 (16045690984503098046ULL, 35) == 17969317810581911517ULL); + ASSERT (rotr64 (16045690984503098046ULL, 36) == 18208030942145731566ULL); + ASSERT (rotr64 (16045690984503098046ULL, 37) == 9104015471072865783ULL); + ASSERT (rotr64 (16045690984503098046ULL, 38) == 13775379772391208699ULL); + ASSERT (rotr64 (16045690984503098046ULL, 39) == 16111061923050380157ULL); + ASSERT (rotr64 (16045690984503098046ULL, 40) == 17278902998379965886ULL); + ASSERT (rotr64 (16045690984503098046ULL, 41) == 8639451499189982943ULL); + ASSERT (rotr64 (16045690984503098046ULL, 42) == 13543097786449767279ULL); + ASSERT (rotr64 (16045690984503098046ULL, 43) == 15994920930079659447ULL); + ASSERT (rotr64 (16045690984503098046ULL, 44) == 17220832501894605531ULL); + ASSERT (rotr64 (16045690984503098046ULL, 45) == 17833788287802078573ULL); + ASSERT (rotr64 (16045690984503098046ULL, 46) == 18140266180755815094ULL); + ASSERT (rotr64 (16045690984503098046ULL, 47) == 9070133090377907547ULL); + ASSERT (rotr64 (16045690984503098046ULL, 48) == 13758438582043729581ULL); + ASSERT (rotr64 (16045690984503098046ULL, 49) == 16102591327876640598ULL); + ASSERT (rotr64 (16045690984503098046ULL, 50) == 8051295663938320299ULL); + ASSERT (rotr64 (16045690984503098046ULL, 51) == 13249019868823935957ULL); + ASSERT (rotr64 (16045690984503098046ULL, 52) == 15847881971266743786ULL); + ASSERT (rotr64 (16045690984503098046ULL, 53) == 7923940985633371893ULL); + ASSERT (rotr64 (16045690984503098046ULL, 54) == 13185342529671461754ULL); + ASSERT (rotr64 (16045690984503098046ULL, 55) == 6592671264835730877ULL); + ASSERT (rotr64 (16045690984503098046ULL, 56) == 12519707669272641246ULL); + ASSERT (rotr64 (16045690984503098046ULL, 57) == 6259853834636320623ULL); + ASSERT (rotr64 (16045690984503098046ULL, 58) == 12353298954172936119ULL); + ASSERT (rotr64 (16045690984503098046ULL, 59) == 15400021513941243867ULL); + ASSERT (rotr64 (16045690984503098046ULL, 60) == 16923382793825397741ULL); + ASSERT (rotr64 (16045690984503098046ULL, 61) == 17685063433767474678ULL); + ASSERT (rotr64 (16045690984503098046ULL, 62) == 8842531716883737339ULL); + ASSERT (rotr64 (16045690984503098046ULL, 63) == 13644637895296644477ULL); +#endif /* UINT64_MAX */ + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-btoc32-1.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-btoc32-1.sh new file mode 100755 index 00000000..25caea64 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-btoc32-1.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +# Test whether the POSIX locale has encoding errors. +LC_ALL=C \ +${CHECKER} ./test-btoc32${EXEEXT} 1 || exit 1 +LC_ALL=POSIX \ +${CHECKER} ./test-btoc32${EXEEXT} 1 || exit 1 + +exit 0 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-btoc32-2.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-btoc32-2.sh new file mode 100755 index 00000000..ba52767b --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-btoc32-2.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Test in an ISO-8859-1 or ISO-8859-15 locale. +: "${LOCALE_FR=fr_FR}" +if test $LOCALE_FR = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no traditional french locale is installed" + else + echo "Skipping test: no traditional french locale is supported" + fi + exit 77 +fi + +LC_ALL=$LOCALE_FR \ +${CHECKER} ./test-btoc32${EXEEXT} 2 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-btoc32-3.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-btoc32-3.sh new file mode 100755 index 00000000..8c6b1803 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-btoc32-3.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Test whether a specific UTF-8 locale is installed. +: "${LOCALE_FR_UTF8=fr_FR.UTF-8}" +if test $LOCALE_FR_UTF8 = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no french Unicode locale is installed" + else + echo "Skipping test: no french Unicode locale is supported" + fi + exit 77 +fi + +LC_ALL=$LOCALE_FR_UTF8 \ +${CHECKER} ./test-btoc32${EXEEXT} 3 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-btoc32.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-btoc32.c new file mode 100644 index 00000000..7e15dcce --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-btoc32.c @@ -0,0 +1,94 @@ +/* Test of conversion of unibyte character to 32-bit wide character. + Copyright (C) 2008-2024 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 . */ + +/* Written by Bruno Haible , 2008. */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (btoc32, wint_t, (int)); + +#include +#include +#include + +#include "macros.h" + +int +main (int argc, char *argv[]) +{ + int c; + + /* configure should already have checked that the locale is supported. */ + if (setlocale (LC_ALL, "") == NULL) + return 1; + + ASSERT (btoc32 (EOF) == WEOF); + +#ifdef __ANDROID__ + /* On Android ≥ 5.0, the default locale is the "C.UTF-8" locale, not the + "C" locale. Furthermore, when you attempt to set the "C" or "POSIX" + locale via setlocale(), what you get is a "C" locale with UTF-8 encoding, + that is, effectively the "C.UTF-8" locale. */ + if (argc > 1 && strcmp (argv[1], "1") == 0 && MB_CUR_MAX > 1) + argv[1] = "3"; +#endif + + if (argc > 1) + switch (argv[1][0]) + { + case '1': + /* C or POSIX locale. */ + for (c = 0; c < 0x100; c++) + if (c != 0) + { + /* We are testing all nonnull bytes. */ + wint_t wc = btoc32 (c); + /* POSIX:2018 says regarding btowc: "In the POSIX locale, btowc() + shall not return WEOF if c has a value in the range 0 to 255 + inclusive." It is reasonable to expect btoc32 to behave in + the same way. */ + if (c < 0x80) + /* c is an ASCII character. */ + ASSERT (wc == c); + else + /* On most platforms, the bytes 0x80..0xFF map to U+0080..U+00FF. + But on musl libc, the bytes 0x80..0xFF map to U+DF80..U+DFFF. */ + ASSERT (wc == c || wc == 0xDF00 + c); + } + return 0; + + case '2': + /* Locale encoding is ISO-8859-1 or ISO-8859-15. */ + for (c = 0; c < 0x80; c++) + ASSERT (btoc32 (c) == c); + for (c = 0xA0; c < 0x100; c++) + ASSERT (btoc32 (c) != WEOF); + return 0; + + case '3': + /* Locale encoding is UTF-8. */ + for (c = 0; c < 0x80; c++) + ASSERT (btoc32 (c) == c); + for (c = 0x80; c < 0x100; c++) + ASSERT (btoc32 (c) == WEOF); + return 0; + } + + return 1; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-btowc-1.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-btowc-1.sh new file mode 100755 index 00000000..d6776565 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-btowc-1.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +# Test whether the POSIX locale has encoding errors. +LC_ALL=C \ +${CHECKER} ./test-btowc${EXEEXT} 1 || exit 1 +LC_ALL=POSIX \ +${CHECKER} ./test-btowc${EXEEXT} 1 || exit 1 + +exit 0 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-btowc-2.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-btowc-2.sh new file mode 100755 index 00000000..9f939d6c --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-btowc-2.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Test in an ISO-8859-1 or ISO-8859-15 locale. +: "${LOCALE_FR=fr_FR}" +if test $LOCALE_FR = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no traditional french locale is installed" + else + echo "Skipping test: no traditional french locale is supported" + fi + exit 77 +fi + +LC_ALL=$LOCALE_FR \ +${CHECKER} ./test-btowc${EXEEXT} 2 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-btowc-3.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-btowc-3.sh new file mode 100755 index 00000000..41244765 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-btowc-3.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Test whether a specific UTF-8 locale is installed. +: "${LOCALE_FR_UTF8=fr_FR.UTF-8}" +if test $LOCALE_FR_UTF8 = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no french Unicode locale is installed" + else + echo "Skipping test: no french Unicode locale is supported" + fi + exit 77 +fi + +LC_ALL=$LOCALE_FR_UTF8 \ +${CHECKER} ./test-btowc${EXEEXT} 3 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-btowc.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-btowc.c new file mode 100644 index 00000000..aeac4bbf --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-btowc.c @@ -0,0 +1,91 @@ +/* Test of conversion of unibyte character to wide character. + Copyright (C) 2008-2024 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 . */ + +/* Written by Bruno Haible , 2008. */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (btowc, wint_t, (int)); + +#include +#include + +#include "macros.h" + +int +main (int argc, char *argv[]) +{ + int c; + + /* configure should already have checked that the locale is supported. */ + if (setlocale (LC_ALL, "") == NULL) + return 1; + + ASSERT (btowc (EOF) == WEOF); + +#ifdef __ANDROID__ + /* On Android ≥ 5.0, the default locale is the "C.UTF-8" locale, not the + "C" locale. Furthermore, when you attempt to set the "C" or "POSIX" + locale via setlocale(), what you get is a "C" locale with UTF-8 encoding, + that is, effectively the "C.UTF-8" locale. */ + if (argc > 1 && strcmp (argv[1], "1") == 0 && MB_CUR_MAX > 1) + argv[1] = "3"; +#endif + + if (argc > 1) + switch (argv[1][0]) + { + case '1': + /* C or POSIX locale. */ + for (c = 0; c < 0x100; c++) + if (c != 0) + { + /* We are testing all nonnull bytes. */ + wint_t wc = btowc (c); + /* POSIX:2018 says: "In the POSIX locale, btowc() shall not return + WEOF if c has a value in the range 0 to 255 inclusive." */ + if (c < 0x80) + /* c is an ASCII character. */ + ASSERT (wc == c); + else + /* On most platforms, the bytes 0x80..0xFF map to U+0080..U+00FF. + But on musl libc, the bytes 0x80..0xFF map to U+DF80..U+DFFF. */ + ASSERT (wc == c || wc == 0xDF00 + c); + } + return 0; + + case '2': + /* Locale encoding is ISO-8859-1 or ISO-8859-15. */ + for (c = 0; c < 0x80; c++) + ASSERT (btowc (c) == c); + for (c = 0xA0; c < 0x100; c++) + ASSERT (btowc (c) != WEOF); + return 0; + + case '3': + /* Locale encoding is UTF-8. */ + for (c = 0; c < 0x80; c++) + ASSERT (btowc (c) == c); + for (c = 0x80; c < 0x100; c++) + ASSERT (btowc (c) == WEOF); + return 0; + } + + return 1; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c-ctype.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c-ctype.c new file mode 100644 index 00000000..8414a31d --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c-ctype.c @@ -0,0 +1,228 @@ +/* Test of character handling in C locale. + Copyright (C) 2005, 2007-2024 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 . */ + +/* Written by Bruno Haible , 2005. */ + +#include + +#include "c-ctype.h" + +#include +#include +#include + +#include "macros.h" + +static void +test_agree_with_C_locale (void) +{ + int c; + + for (c = 0; c <= UCHAR_MAX; c++) + { + ASSERT (c_isascii (c) == (isascii (c) != 0)); + if (c_isascii (c)) + { + ASSERT (c_isalnum (c) == (isalnum (c) != 0)); + ASSERT (c_isalpha (c) == (isalpha (c) != 0)); + ASSERT (c_isblank (c) == (isblank (c) != 0)); + ASSERT (c_iscntrl (c) == (iscntrl (c) != 0)); + ASSERT (c_isdigit (c) == (isdigit (c) != 0)); + ASSERT (c_islower (c) == (islower (c) != 0)); + ASSERT (c_isgraph (c) == (isgraph (c) != 0)); + ASSERT (c_isprint (c) == (isprint (c) != 0)); + ASSERT (c_ispunct (c) == (ispunct (c) != 0)); + ASSERT (c_isspace (c) == (isspace (c) != 0)); + ASSERT (c_isupper (c) == (isupper (c) != 0)); + ASSERT (c_isxdigit (c) == (isxdigit (c) != 0)); + ASSERT (c_tolower (c) == tolower (c)); + ASSERT (c_toupper (c) == toupper (c)); + } + } +} + +static void +test_all (void) +{ + int c; + int n_isascii = 0; + + for (c = CHAR_MIN; c <= UCHAR_MAX; c++) + { + if (! (0 <= c && c <= CHAR_MAX)) + { + ASSERT (! c_isascii (c)); + ASSERT (! c_isalnum (c)); + ASSERT (! c_isalpha (c)); + ASSERT (! c_isblank (c)); + ASSERT (! c_iscntrl (c)); + ASSERT (! c_isdigit (c)); + ASSERT (! c_islower (c)); + ASSERT (! c_isgraph (c)); + ASSERT (! c_isprint (c)); + ASSERT (! c_ispunct (c)); + ASSERT (! c_isspace (c)); + ASSERT (! c_isupper (c)); + ASSERT (! c_isxdigit (c)); + ASSERT (c_tolower (c) == c); + ASSERT (c_toupper (c) == c); + } + + n_isascii += c_isascii (c); + +#ifdef C_CTYPE_ASCII + ASSERT (c_isascii (c) == (0 <= c && c <= 0x7f)); +#endif + + ASSERT (c_isascii (c) == (c_isprint (c) || c_iscntrl (c))); + + ASSERT (c_isalnum (c) == (c_isalpha (c) || c_isdigit (c))); + + ASSERT (c_isalpha (c) == (c_islower (c) || c_isupper (c))); + + switch (c) + { + case '\t': case ' ': + ASSERT (c_isblank (c) == 1); + break; + default: + ASSERT (c_isblank (c) == 0); + break; + } + +#ifdef C_CTYPE_ASCII + ASSERT (c_iscntrl (c) == ((c >= 0 && c < 0x20) || c == 0x7f)); +#endif + + switch (c) + { + case '\a': case '\b': case '\f': case '\n': + case '\r': case '\t': case '\v': + ASSERT (c_iscntrl (c)); + break; + } + + ASSERT (! (c_iscntrl (c) && c_isprint (c))); + + switch (c) + { + case '0': case '1': case '2': case '3': case '4': case '5': + case '6': case '7': case '8': case '9': + ASSERT (c_isdigit (c) == 1); + break; + default: + ASSERT (c_isdigit (c) == 0); + break; + } + + switch (c) + { + case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': + case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': + case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': + case 's': case 't': case 'u': case 'v': case 'w': case 'x': + case 'y': case 'z': + ASSERT (c_islower (c) == 1); + ASSERT (c_toupper (c) == c - 'a' + 'A'); + break; + default: + ASSERT (c_islower (c) == 0); + ASSERT (c_toupper (c) == c); + break; + } + +#ifdef C_CTYPE_ASCII + ASSERT (c_isgraph (c) == ((c >= 0x20 && c < 0x7f) && c != ' ')); + + ASSERT (c_isprint (c) == (c >= 0x20 && c < 0x7f)); +#endif + + ASSERT (c_isgraph (c) == (c_isalnum (c) || c_ispunct (c))); + + ASSERT (c_isprint (c) == (c_isgraph (c) || c == ' ')); + + switch (c) + { + case '!': case '"': case '#': case '$': case '%': case '&': case '\'': + case '(': case ')': case '*': case '+': case ',': case '-': case '.': + case '/': case ':': case ';': case '<': case '=': case '>': case '?': + case '@': case '[': case'\\': case ']': case '^': case '_': case '`': + case '{': case '|': case '}': case '~': + ASSERT (c_ispunct (c) == 1); + break; + default: + ASSERT (c_ispunct (c) == 0); + break; + } + + switch (c) + { + case ' ': case '\t': case '\n': case '\v': case '\f': case '\r': + ASSERT (c_isspace (c) == 1); + break; + default: + ASSERT (c_isspace (c) == 0); + break; + } + + switch (c) + { + case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': + case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': + case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': + case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': + case 'Y': case 'Z': + ASSERT (c_isupper (c) == 1); + ASSERT (c_tolower (c) == c - 'A' + 'a'); + break; + default: + ASSERT (c_isupper (c) == 0); + ASSERT (c_tolower (c) == c); + break; + } + + switch (c) + { + case '0': case '1': case '2': case '3': case '4': case '5': + case '6': case '7': case '8': case '9': + case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': + case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': + ASSERT (c_isxdigit (c) == 1); + break; + default: + ASSERT (c_isxdigit (c) == 0); + break; + } + } + + ASSERT (n_isascii == 128); +} + +int +main () +{ + test_agree_with_C_locale (); + + test_all (); + + setlocale (LC_ALL, "de_DE"); + test_all (); + + setlocale (LC_ALL, "ja_JP.EUC-JP"); + test_all (); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c-stack.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c-stack.c new file mode 100644 index 00000000..b5ab3330 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c-stack.c @@ -0,0 +1,73 @@ +/* Test of c-stack module. + Copyright (C) 2002, 2004, 2006, 2008-2024 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 . */ + +#include + +#include "c-stack.h" + +#include "exitfail.h" +#include +#if HAVE_SETRLIMIT +/* At least FreeBSD 5.0 needs extra headers before + will compile. */ +# include +# include +# include +#endif + +#include "macros.h" + +static volatile int * +recurse_1 (volatile int n, volatile int *p) +{ + if (n >= 0) + *recurse_1 (n + 1, p) += n; + return p; +} + +static int +recurse (volatile int n) +{ + int sum = 0; + return *recurse_1 (n, &sum); +} + +int +main (int argc, char **argv) +{ +#if HAVE_SETRLIMIT && defined RLIMIT_STACK + /* Before starting the endless recursion, try to be friendly to the + user's machine. On some Linux 2.2.x systems, there is no stack + limit for user processes at all. We don't want to kill such + systems. */ + struct rlimit rl; + rl.rlim_cur = rl.rlim_max = 0x100000; /* 1 MB */ + setrlimit (RLIMIT_STACK, &rl); +#endif + + if (c_stack_action (NULL) == 0) + { + if (1 < argc) + { + exit_failure = 77; + ++*argv[argc]; /* Intentionally dereference NULL. */ + } + return recurse (0); + } + fputs ("skipping test: ", stderr); + perror ("c_stack_action"); + return 77; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c-stack.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c-stack.sh new file mode 100755 index 00000000..f0bec55e --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c-stack.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +tmpfiles="" +trap 'rm -fr $tmpfiles' HUP INT QUIT TERM + +tmpfiles="t-c-stack.tmp" +${CHECKER} ./test-c-stack${EXEEXT} 2> t-c-stack.tmp +case $? in + 77) cat t-c-stack.tmp >&2; (exit 77); exit 77 ;; + 1) ;; + *) (exit 1); exit 1 ;; +esac +if grep 'stack overflow' t-c-stack.tmp >/dev/null ; then + : +else + (exit 1); exit 1 +fi + +rm -fr $tmpfiles + +exit 0 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c-stack2.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c-stack2.sh new file mode 100755 index 00000000..b7f8b26b --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c-stack2.sh @@ -0,0 +1,43 @@ +#!/bin/sh + +tmpfiles="" +trap 'rm -fr $tmpfiles' HUP INT QUIT TERM + +tmpfiles="t-c-stack2.tmp" + +# Sanitize exit status within a subshell, since some shells fail to +# redirect stderr on their message about death due to signal. +(${CHECKER} ./test-c-stack${EXEEXT} 1; exit $?) 2> t-c-stack2.tmp + +case $? in + 77) if grep 'stack overflow' t-c-stack2.tmp >/dev/null ; then + if test -z "$LIBSIGSEGV"; then + echo 'cannot tell stack overflow from crash; consider installing libsigsegv' >&2 + exit 77 + else + echo 'cannot tell stack overflow from crash, in spite of libsigsegv' >&2 + exit 1 + fi + else + cat t-c-stack2.tmp >&2 + exit 77 + fi + ;; + 1) + # Dereferencing NULL exits the program with status 1, + # so this test doesn't check the c-stack testing harness like it should. + # https://lists.gnu.org/r/grep-devel/2020-09/msg00034.html + cat t-c-stack2.tmp >&2 + echo 'skipping test (perhaps gcc -fsanitize=undefined is in use?)' + exit 77;; + 0) (exit 1); exit 1 ;; +esac +if grep 'program error' t-c-stack2.tmp >/dev/null ; then + : +else + (exit 1); exit 1 +fi + +rm -fr $tmpfiles + +exit 0 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c-strcase.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c-strcase.sh new file mode 100755 index 00000000..9f491e0f --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c-strcase.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +# Test in the C locale. +${CHECKER} ./test-c-strcasecmp${EXEEXT} || exit 1 +${CHECKER} ./test-c-strncasecmp${EXEEXT} || exit 1 + +# Test in an ISO-8859-1 or ISO-8859-15 locale. +: "${LOCALE_FR=fr_FR}" +if test $LOCALE_FR != none; then + LC_ALL=$LOCALE_FR ${CHECKER} ./test-c-strcasecmp${EXEEXT} locale || exit 1 + LC_ALL=$LOCALE_FR ${CHECKER} ./test-c-strncasecmp${EXEEXT} locale || exit 1 +fi + +# Test in a Turkish UTF-8 locale. +: "${LOCALE_TR_UTF8=tr_TR.UTF-8}" +if test $LOCALE_TR_UTF8 != none; then + LC_ALL=$LOCALE_TR_UTF8 ${CHECKER} ./test-c-strcasecmp${EXEEXT} locale || exit 1 + LC_ALL=$LOCALE_TR_UTF8 ${CHECKER} ./test-c-strncasecmp${EXEEXT} locale || exit 1 +fi + +exit 0 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c-strcasecmp.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c-strcasecmp.c new file mode 100644 index 00000000..fd07e009 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c-strcasecmp.c @@ -0,0 +1,68 @@ +/* Test of case-insensitive string comparison function. + Copyright (C) 2007-2024 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 . */ + +/* Written by Bruno Haible , 2007. */ + +#include + +#include "c-strcase.h" +#include "c-ctype.h" + +#include +#include + +#include "macros.h" + +int +main (int argc, char *argv[]) +{ + if (argc > 1) + { + /* configure should already have checked that the locale is supported. */ + if (setlocale (LC_ALL, "") == NULL) + return 1; + } + + ASSERT (c_strcasecmp ("paragraph", "Paragraph") == 0); + + ASSERT (c_strcasecmp ("paragrapH", "parAgRaph") == 0); + + ASSERT (c_strcasecmp ("paragraph", "paraLyzed") < 0); + ASSERT (c_strcasecmp ("paraLyzed", "paragraph") > 0); + + ASSERT (c_strcasecmp ("para", "paragraph") < 0); + ASSERT (c_strcasecmp ("paragraph", "para") > 0); + + /* The following tests shows how c_strcasecmp() is different from + strcasecmp(). */ + + ASSERT (c_strcasecmp ("\311mile", "\351mile") < 0); + ASSERT (c_strcasecmp ("\351mile", "\311mile") > 0); + + /* The following tests shows how c_strcasecmp() is different from + mbscasecmp(). */ + + ASSERT (c_strcasecmp ("\303\266zg\303\274r", "\303\226ZG\303\234R") > 0); /* özgür */ + ASSERT (c_strcasecmp ("\303\226ZG\303\234R", "\303\266zg\303\274r") < 0); /* özgür */ + +#if C_CTYPE_ASCII + /* This test shows how strings of different size cannot compare equal. */ + ASSERT (c_strcasecmp ("turkish", "TURK\304\260SH") < 0); + ASSERT (c_strcasecmp ("TURK\304\260SH", "turkish") > 0); +#endif + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c-strcasestr.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c-strcasestr.c new file mode 100644 index 00000000..39fad3cc --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c-strcasestr.c @@ -0,0 +1,272 @@ +/* Test of case-insensitive searching in a string. + Copyright (C) 2007-2024 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 . */ + +/* Written by Bruno Haible , 2007. */ + +#include + +#include "c-strcasestr.h" + +#include +#include + +#include "macros.h" + +int +main () +{ + { + const char input[] = "foo"; + const char *result = c_strcasestr (input, ""); + ASSERT (result == input); + } + + { + const char input[] = "foo"; + const char *result = c_strcasestr (input, "O"); + ASSERT (result == input + 1); + } + + { + const char input[] = "ABC ABCDAB ABCDABCDABDE"; + const char *result = c_strcasestr (input, "ABCDaBD"); + ASSERT (result == input + 15); + } + + { + const char input[] = "ABC ABCDAB ABCDABCDABDE"; + const char *result = c_strcasestr (input, "ABCDaBE"); + ASSERT (result == NULL); + } + + { + const char input[] = "ABC ABCDAB ABCDABCDABDE"; + const char *result = c_strcasestr (input, "ABCDaBCD"); + ASSERT (result == input + 11); + } + + /* Check that a long periodic needle does not cause false positives. */ + { + const char input[] = "F_BD_CE_BD_EF_BF_BD_EF_BF_BD_EF_BF_BD_EF_BF_BD" + "_C3_88_20_EF_BF_BD_EF_BF_BD_EF_BF_BD" + "_C3_A7_20_EF_BF_BD"; + const char need[] = "_EF_BF_BD_EF_BF_BD_EF_BF_BD_EF_BF_BD_EF_BF_BD"; + const char *result = c_strcasestr (input, need); + ASSERT (result == NULL); + } + { + const char input[] = "F_BD_CE_BD_EF_BF_BD_EF_BF_BD_EF_BF_BD_EF_BF_BD" + "_C3_88_20_EF_BF_BD_EF_BF_BD_EF_BF_BD" + "_C3_A7_20_EF_BF_BD_DA_B5_C2_A6_20" + "_EF_BF_BD_EF_BF_BD_EF_BF_BD_EF_BF_BD_EF_BF_BD"; + const char need[] = "_EF_BF_BD_EF_BF_BD_EF_BF_BD_EF_BF_BD_EF_BF_BD"; + const char *result = c_strcasestr (input, need); + ASSERT (result == input + 115); + } + + /* Check that a very long haystack is handled quickly if the needle is + short and occurs near the beginning. */ + { + size_t repeat = 10000; + size_t m = 1000000; + const char *needle = + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaAaaaaaaAAAAaaaaaaa" + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + char *haystack = (char *) malloc (m + 1); + if (haystack != NULL) + { + memset (haystack, 'A', m); + haystack[0] = 'B'; + haystack[m] = '\0'; + + for (; repeat > 0; repeat--) + { + ASSERT (c_strcasestr (haystack, needle) == haystack + 1); + } + + free (haystack); + } + } + + /* Check that a very long needle is discarded quickly if the haystack is + short. */ + { + size_t repeat = 10000; + size_t m = 1000000; + const char *haystack = + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB"; + char *needle = (char *) malloc (m + 1); + if (needle != NULL) + { + memset (needle, 'A', m); + needle[m] = '\0'; + + for (; repeat > 0; repeat--) + { + ASSERT (c_strcasestr (haystack, needle) == NULL); + } + + free (needle); + } + } + + /* Check that the asymptotic worst-case complexity is not quadratic. */ + { + size_t m = 1000000; + char *haystack = (char *) malloc (2 * m + 2); + char *needle = (char *) malloc (m + 2); + if (haystack != NULL && needle != NULL) + { + const char *result; + + memset (haystack, 'A', 2 * m); + haystack[2 * m] = 'B'; + haystack[2 * m + 1] = '\0'; + + memset (needle, 'a', m); + needle[m] = 'B'; + needle[m + 1] = '\0'; + + result = c_strcasestr (haystack, needle); + ASSERT (result == haystack + m); + } + free (needle); + free (haystack); + } + + { + /* Ensure that with a barely periodic "short" needle, c_strcasestr's + search does not mistakenly skip just past the match point. + This use of c_strcasestr would mistakenly return NULL before + gnulib v0.0-4927. */ + const char *haystack = + "\n" + "with_build_libsubdir\n" + "with_local_prefix\n" + "with_gxx_include_dir\n" + "with_cpp_install_dir\n" + "enable_generated_files_in_srcdir\n" + "with_gnu_ld\n" + "with_ld\n" + "with_demangler_in_ld\n" + "with_gnu_as\n" + "with_as\n" + "enable_largefile\n" + "enable_werror_always\n" + "enable_checking\n" + "enable_coverage\n" + "enable_gather_detailed_mem_stats\n" + "enable_build_with_cxx\n" + "with_stabs\n" + "enable_multilib\n" + "enable___cxa_atexit\n" + "enable_decimal_float\n" + "enable_fixed_point\n" + "enable_threads\n" + "enable_tls\n" + "enable_objc_gc\n" + "with_dwarf2\n" + "enable_shared\n" + "with_build_sysroot\n" + "with_sysroot\n" + "with_specs\n" + "with_pkgversion\n" + "with_bugurl\n" + "enable_languages\n" + "with_multilib_list\n"; + const char *needle = "\n" + "with_GNU_ld\n"; + const char* p = c_strcasestr (haystack, needle); + ASSERT (p - haystack == 114); + } + + { + /* Same bug, shorter trigger. */ + const char *haystack = "..wi.D."; + const char *needle = ".d."; + const char* p = c_strcasestr (haystack, needle); + ASSERT (p - haystack == 4); + } + + { + /* Like the above, but trigger the flaw in two_way_long_needle + by using a needle of length LONG_NEEDLE_THRESHOLD (32) or greater. + Rather than trying to find the right alignment manually, I've + arbitrarily chosen the following needle and template for the + haystack, and ensure that for each placement of the needle in + that haystack, c_strcasestr finds it. */ + const char *needle = "\nwith_gnu_ld-extend-to-len-32-b\n"; + const char *h = + "\n" + "with_build_libsubdir\n" + "with_local_prefix\n" + "with_gxx_include_dir\n" + "with_cpp_install_dir\n" + "with_e_\n" + "..............................\n" + "with_FGHIJKLMNOPQRSTUVWXYZ\n" + "with_567890123456789\n" + "with_multilib_list\n"; + size_t h_len = strlen (h); + char *haystack = malloc (h_len + 1); + size_t i; + ASSERT (haystack); + for (i = 0; i < h_len - strlen (needle); i++) + { + const char *p; + memcpy (haystack, h, h_len + 1); + memcpy (haystack + i, needle, strlen (needle) + 1); + p = c_strcasestr (haystack, needle); + ASSERT (p); + ASSERT (p - haystack == i); + } + free (haystack); + } + + /* Test case from Yves Bastide. + */ + { + const char input[] = "playing PLAY play PLAY always"; + const char *result = c_strcasestr (input, "play PLAY play"); + ASSERT (result == input + 8); + } + + /* Test long needles. */ + { + size_t m = 1024; + char *haystack = (char *) malloc (2 * m + 1); + char *needle = (char *) malloc (m + 1); + if (haystack != NULL && needle != NULL) + { + const char *p; + haystack[0] = 'x'; + memset (haystack + 1, ' ', m - 1); + memset (haystack + m, 'x', m); + haystack[2 * m] = '\0'; + memset (needle, 'X', m); + needle[m] = '\0'; + p = c_strcasestr (haystack, needle); + ASSERT (p); + ASSERT (p - haystack == m); + } + free (needle); + free (haystack); + } + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c-strncasecmp.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c-strncasecmp.c new file mode 100644 index 00000000..a8bb3358 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c-strncasecmp.c @@ -0,0 +1,82 @@ +/* Test of case-insensitive string comparison function. + Copyright (C) 2007-2024 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 . */ + +/* Written by Bruno Haible , 2007. */ + +#include + +#include "c-strcase.h" +#include "c-ctype.h" + +#include +#include + +#include "macros.h" + +int +main (int argc, char *argv[]) +{ + if (argc > 1) + { + /* configure should already have checked that the locale is supported. */ + if (setlocale (LC_ALL, "") == NULL) + return 1; + } + + ASSERT (c_strncasecmp ("paragraph", "Paragraph", 1000000) == 0); + ASSERT (c_strncasecmp ("paragraph", "Paragraph", 9) == 0); + + ASSERT (c_strncasecmp ("paragrapH", "parAgRaph", 1000000) == 0); + ASSERT (c_strncasecmp ("paragrapH", "parAgRaph", 9) == 0); + + ASSERT (c_strncasecmp ("paragraph", "paraLyzed", 10) < 0); + ASSERT (c_strncasecmp ("paragraph", "paraLyzed", 9) < 0); + ASSERT (c_strncasecmp ("paragraph", "paraLyzed", 5) < 0); + ASSERT (c_strncasecmp ("paragraph", "paraLyzed", 4) == 0); + ASSERT (c_strncasecmp ("paraLyzed", "paragraph", 10) > 0); + ASSERT (c_strncasecmp ("paraLyzed", "paragraph", 9) > 0); + ASSERT (c_strncasecmp ("paraLyzed", "paragraph", 5) > 0); + ASSERT (c_strncasecmp ("paraLyzed", "paragraph", 4) == 0); + + ASSERT (c_strncasecmp ("para", "paragraph", 10) < 0); + ASSERT (c_strncasecmp ("para", "paragraph", 9) < 0); + ASSERT (c_strncasecmp ("para", "paragraph", 5) < 0); + ASSERT (c_strncasecmp ("para", "paragraph", 4) == 0); + ASSERT (c_strncasecmp ("paragraph", "para", 10) > 0); + ASSERT (c_strncasecmp ("paragraph", "para", 9) > 0); + ASSERT (c_strncasecmp ("paragraph", "para", 5) > 0); + ASSERT (c_strncasecmp ("paragraph", "para", 4) == 0); + + /* The following tests shows how c_strncasecmp() is different from + strncasecmp(). */ + + ASSERT (c_strncasecmp ("\311mily", "\351mile", 4) < 0); + ASSERT (c_strncasecmp ("\351mile", "\311mily", 4) > 0); + + /* The following tests shows how c_strncasecmp() is different from + mbsncasecmp(). */ + + ASSERT (c_strncasecmp ("\303\266zg\303\274r", "\303\226ZG\303\234R", 99) > 0); /* özgür */ + ASSERT (c_strncasecmp ("\303\226ZG\303\234R", "\303\266zg\303\274r", 99) < 0); /* özgür */ + +#if C_CTYPE_ASCII + /* This test shows how strings of different size cannot compare equal. */ + ASSERT (c_strncasecmp ("turkish", "TURK\304\260SH", 7) < 0); + ASSERT (c_strncasecmp ("TURK\304\260SH", "turkish", 7) > 0); +#endif + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32_apply_type_test.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32_apply_type_test.c new file mode 100644 index 00000000..e943ed95 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32_apply_type_test.c @@ -0,0 +1,170 @@ +/* Test of 32-bit wide character properties. + Copyright (C) 2023-2024 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 . */ + +/* Written by Bruno Haible , 2023. */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (c32_apply_type_test, int, (wint_t, c32_type_test_t)); + +#include "macros.h" + +int +main (int argc, char *argv[]) +{ + c32_type_test_t desc; + + desc = c32_get_type_test ("any"); + ASSERT (desc == (c32_type_test_t) 0); + + desc = c32_get_type_test ("blank"); + ASSERT (desc != (c32_type_test_t) 0); + ASSERT (c32_apply_type_test ((char32_t) ' ', desc)); + ASSERT (c32_apply_type_test ((char32_t) '\t', desc)); + ASSERT (! c32_apply_type_test ((char32_t) '\n', desc)); + ASSERT (! c32_apply_type_test ((char32_t) 'a', desc)); + ASSERT (! c32_apply_type_test ((char32_t) '_', desc)); + ASSERT (! c32_apply_type_test (WEOF, desc)); + + desc = c32_get_type_test ("space"); + ASSERT (desc != (c32_type_test_t) 0); + ASSERT (c32_apply_type_test ((char32_t) ' ', desc)); + ASSERT (c32_apply_type_test ((char32_t) '\t', desc)); + ASSERT (c32_apply_type_test ((char32_t) '\n', desc)); + ASSERT (! c32_apply_type_test ((char32_t) 'a', desc)); + ASSERT (! c32_apply_type_test ((char32_t) '_', desc)); + ASSERT (! c32_apply_type_test (WEOF, desc)); + + desc = c32_get_type_test ("punct"); + ASSERT (desc != (c32_type_test_t) 0); + ASSERT (c32_apply_type_test ((char32_t) '$', desc)); + ASSERT (c32_apply_type_test ((char32_t) '.', desc)); + ASSERT (c32_apply_type_test ((char32_t) '<', desc)); + ASSERT (c32_apply_type_test ((char32_t) '>', desc)); + ASSERT (! c32_apply_type_test ((char32_t) ' ', desc)); + ASSERT (! c32_apply_type_test ((char32_t) 'a', desc)); + ASSERT (! c32_apply_type_test ((char32_t) '1', desc)); + ASSERT (! c32_apply_type_test (WEOF, desc)); + + desc = c32_get_type_test ("lower"); + ASSERT (desc != (c32_type_test_t) 0); + ASSERT (c32_apply_type_test ((char32_t) 'a', desc)); + ASSERT (c32_apply_type_test ((char32_t) 'z', desc)); + ASSERT (! c32_apply_type_test ((char32_t) 'A', desc)); + ASSERT (! c32_apply_type_test ((char32_t) 'Z', desc)); + ASSERT (! c32_apply_type_test ((char32_t) '1', desc)); + ASSERT (! c32_apply_type_test ((char32_t) '_', desc)); + ASSERT (! c32_apply_type_test (WEOF, desc)); + + desc = c32_get_type_test ("upper"); + ASSERT (desc != (c32_type_test_t) 0); + ASSERT (c32_apply_type_test ((char32_t) 'A', desc)); + ASSERT (c32_apply_type_test ((char32_t) 'Z', desc)); + ASSERT (! c32_apply_type_test ((char32_t) 'a', desc)); + ASSERT (! c32_apply_type_test ((char32_t) 'z', desc)); + ASSERT (! c32_apply_type_test ((char32_t) '1', desc)); + ASSERT (! c32_apply_type_test ((char32_t) '_', desc)); + ASSERT (! c32_apply_type_test (WEOF, desc)); + + desc = c32_get_type_test ("alpha"); + ASSERT (desc != (c32_type_test_t) 0); + ASSERT (c32_apply_type_test ((char32_t) 'a', desc)); + ASSERT (c32_apply_type_test ((char32_t) 'z', desc)); + ASSERT (c32_apply_type_test ((char32_t) 'A', desc)); + ASSERT (c32_apply_type_test ((char32_t) 'Z', desc)); + ASSERT (! c32_apply_type_test ((char32_t) '1', desc)); + ASSERT (! c32_apply_type_test ((char32_t) '$', desc)); + ASSERT (! c32_apply_type_test (WEOF, desc)); + + desc = c32_get_type_test ("digit"); + ASSERT (desc != (c32_type_test_t) 0); + ASSERT (c32_apply_type_test ((char32_t) '0', desc)); + ASSERT (c32_apply_type_test ((char32_t) '9', desc)); + ASSERT (! c32_apply_type_test ((char32_t) 'a', desc)); + ASSERT (! c32_apply_type_test ((char32_t) 'f', desc)); + ASSERT (! c32_apply_type_test ((char32_t) 'A', desc)); + ASSERT (! c32_apply_type_test ((char32_t) 'F', desc)); + ASSERT (! c32_apply_type_test (WEOF, desc)); + + desc = c32_get_type_test ("xdigit"); + ASSERT (desc != (c32_type_test_t) 0); + ASSERT (c32_apply_type_test ((char32_t) '0', desc)); + ASSERT (c32_apply_type_test ((char32_t) '9', desc)); + ASSERT (c32_apply_type_test ((char32_t) 'a', desc)); + ASSERT (c32_apply_type_test ((char32_t) 'f', desc)); + ASSERT (c32_apply_type_test ((char32_t) 'A', desc)); + ASSERT (c32_apply_type_test ((char32_t) 'F', desc)); + ASSERT (! c32_apply_type_test ((char32_t) 'g', desc)); + ASSERT (! c32_apply_type_test ((char32_t) 'G', desc)); + ASSERT (! c32_apply_type_test (WEOF, desc)); + + desc = c32_get_type_test ("alnum"); + ASSERT (desc != (c32_type_test_t) 0); + ASSERT (c32_apply_type_test ((char32_t) 'a', desc)); + ASSERT (c32_apply_type_test ((char32_t) 'z', desc)); + ASSERT (c32_apply_type_test ((char32_t) 'A', desc)); + ASSERT (c32_apply_type_test ((char32_t) 'Z', desc)); + ASSERT (c32_apply_type_test ((char32_t) '0', desc)); + ASSERT (c32_apply_type_test ((char32_t) '9', desc)); + ASSERT (! c32_apply_type_test ((char32_t) ' ', desc)); + ASSERT (! c32_apply_type_test ((char32_t) '_', desc)); + ASSERT (! c32_apply_type_test (WEOF, desc)); + + desc = c32_get_type_test ("cntrl"); + ASSERT (desc != (c32_type_test_t) 0); + ASSERT (c32_apply_type_test ((char32_t) '\0', desc)); + ASSERT (c32_apply_type_test ((char32_t) '\n', desc)); + ASSERT (c32_apply_type_test ((char32_t) '\t', desc)); + ASSERT (! c32_apply_type_test ((char32_t) ' ', desc)); + ASSERT (! c32_apply_type_test ((char32_t) 'a', desc)); + ASSERT (! c32_apply_type_test ((char32_t) '\\', desc)); + ASSERT (! c32_apply_type_test (WEOF, desc)); + + desc = c32_get_type_test ("graph"); + ASSERT (desc != (c32_type_test_t) 0); + ASSERT (c32_apply_type_test ((char32_t) 'a', desc)); + ASSERT (c32_apply_type_test ((char32_t) 'z', desc)); + ASSERT (c32_apply_type_test ((char32_t) 'A', desc)); + ASSERT (c32_apply_type_test ((char32_t) 'Z', desc)); + ASSERT (c32_apply_type_test ((char32_t) '0', desc)); + ASSERT (c32_apply_type_test ((char32_t) '9', desc)); + ASSERT (c32_apply_type_test ((char32_t) '$', desc)); + ASSERT (! c32_apply_type_test ((char32_t) ' ', desc)); + ASSERT (! c32_apply_type_test ((char32_t) '\t', desc)); + ASSERT (! c32_apply_type_test ((char32_t) '\n', desc)); + ASSERT (! c32_apply_type_test ((char32_t) '\0', desc)); + ASSERT (! c32_apply_type_test (WEOF, desc)); + + desc = c32_get_type_test ("print"); + ASSERT (desc != (c32_type_test_t) 0); + ASSERT (c32_apply_type_test ((char32_t) 'a', desc)); + ASSERT (c32_apply_type_test ((char32_t) 'z', desc)); + ASSERT (c32_apply_type_test ((char32_t) 'A', desc)); + ASSERT (c32_apply_type_test ((char32_t) 'Z', desc)); + ASSERT (c32_apply_type_test ((char32_t) '0', desc)); + ASSERT (c32_apply_type_test ((char32_t) '9', desc)); + ASSERT (c32_apply_type_test ((char32_t) '$', desc)); + ASSERT (c32_apply_type_test ((char32_t) ' ', desc)); + ASSERT (! c32_apply_type_test ((char32_t) '\t', desc)); + ASSERT (! c32_apply_type_test ((char32_t) '\n', desc)); + ASSERT (! c32_apply_type_test ((char32_t) '\0', desc)); + ASSERT (! c32_apply_type_test (WEOF, desc)); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32_get_type_test.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32_get_type_test.c new file mode 100644 index 00000000..24b15bdc --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32_get_type_test.c @@ -0,0 +1,73 @@ +/* Test of getting descriptor for a 32-bit wide character property. + Copyright (C) 2023-2024 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 . */ + +/* Written by Bruno Haible , 2023. */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (c32_get_type_test, c32_type_test_t, (const char *)); + +#include "macros.h" + +int +main (int argc, char *argv[]) +{ + c32_type_test_t desc; + + desc = c32_get_type_test ("any"); + ASSERT (desc == (c32_type_test_t) 0); + + desc = c32_get_type_test ("blank"); + ASSERT (desc != (c32_type_test_t) 0); + + desc = c32_get_type_test ("space"); + ASSERT (desc != (c32_type_test_t) 0); + + desc = c32_get_type_test ("punct"); + ASSERT (desc != (c32_type_test_t) 0); + + desc = c32_get_type_test ("lower"); + ASSERT (desc != (c32_type_test_t) 0); + + desc = c32_get_type_test ("upper"); + ASSERT (desc != (c32_type_test_t) 0); + + desc = c32_get_type_test ("alpha"); + ASSERT (desc != (c32_type_test_t) 0); + + desc = c32_get_type_test ("digit"); + ASSERT (desc != (c32_type_test_t) 0); + + desc = c32_get_type_test ("xdigit"); + ASSERT (desc != (c32_type_test_t) 0); + + desc = c32_get_type_test ("alnum"); + ASSERT (desc != (c32_type_test_t) 0); + + desc = c32_get_type_test ("cntrl"); + ASSERT (desc != (c32_type_test_t) 0); + + desc = c32_get_type_test ("graph"); + ASSERT (desc != (c32_type_test_t) 0); + + desc = c32_get_type_test ("print"); + ASSERT (desc != (c32_type_test_t) 0); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isalnum.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isalnum.c new file mode 100644 index 00000000..4f75e0f4 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isalnum.c @@ -0,0 +1,261 @@ +/* Test of c32isalnum() function. + Copyright (C) 2020-2024 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 . */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (c32isalnum, int, (wint_t)); + +#include +#include +#include +#include + +#include "macros.h" + +/* Returns the value of c32isalnum for the multibyte character s[0..n-1]. */ +static int +for_character (const char *s, size_t n) +{ + mbstate_t state; + char32_t wc; + size_t ret; + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, s, n, &state); + ASSERT (ret == n); + + return c32isalnum (wc); +} + +int +main (int argc, char *argv[]) +{ + int is; + char buf[4]; + + /* configure should already have checked that the locale is supported. */ + if (setlocale (LC_ALL, "") == NULL) + return 1; + + /* Test WEOF. */ + is = c32isalnum (WEOF); + ASSERT (is == 0); + + /* Test single-byte characters. + POSIX specifies in + + that + - in all locales, the alphanumeric characters include the uppercase and + lowercase characters and digits and, consequently, include the A ... Z + and a ... z and 0 ... 9 characters. + - in the "POSIX" locale (which is usually the same as the "C" locale), + the alphanumeric characters include only the ASCII A ... Z and a ... z + and 0 ... 9 characters. */ + { + int c; + + for (c = 0; c < 0x100; c++) + switch (c) + { + case '\t': case '\v': case '\f': + case ' ': case '!': case '"': case '#': case '%': + case '&': case '\'': case '(': case ')': case '*': + case '+': case ',': case '-': case '.': case '/': + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + case ':': case ';': case '<': case '=': case '>': + case '?': + case 'A': case 'B': case 'C': case 'D': case 'E': + case 'F': case 'G': case 'H': case 'I': case 'J': + case 'K': case 'L': case 'M': case 'N': case 'O': + case 'P': case 'Q': case 'R': case 'S': case 'T': + case 'U': case 'V': case 'W': case 'X': case 'Y': + case 'Z': + case '[': case '\\': case ']': case '^': case '_': + case 'a': case 'b': case 'c': case 'd': case 'e': + case 'f': case 'g': case 'h': case 'i': case 'j': + case 'k': case 'l': case 'm': case 'n': case 'o': + case 'p': case 'q': case 'r': case 's': case 't': + case 'u': case 'v': case 'w': case 'x': case 'y': + case 'z': case '{': case '|': case '}': case '~': + /* c is in the ISO C "basic character set". */ + buf[0] = (unsigned char) c; + is = for_character (buf, 1); + switch (c) + { + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + case 'A': case 'B': case 'C': case 'D': case 'E': + case 'F': case 'G': case 'H': case 'I': case 'J': + case 'K': case 'L': case 'M': case 'N': case 'O': + case 'P': case 'Q': case 'R': case 'S': case 'T': + case 'U': case 'V': case 'W': case 'X': case 'Y': + case 'Z': + case 'a': case 'b': case 'c': case 'd': case 'e': + case 'f': case 'g': case 'h': case 'i': case 'j': + case 'k': case 'l': case 'm': case 'n': case 'o': + case 'p': case 'q': case 'r': case 's': case 't': + case 'u': case 'v': case 'w': case 'x': case 'y': + case 'z': + ASSERT (is != 0); + break; + default: + ASSERT (is == 0); + break; + } + break; + } + } + + if (argc > 1) + switch (argv[1][0]) + { + case '0': + /* C locale; tested above. */ + return 0; + + case '1': + /* Locale encoding is ISO-8859-1 or ISO-8859-15. */ + { + /* U+00D7 MULTIPLICATION SIGN */ + is = for_character ("\327", 1); + ASSERT (is == 0); + /* U+00D8 LATIN CAPITAL LETTER O WITH STROKE */ + is = for_character ("\330", 1); + ASSERT (is != 0); + } + return 0; + + case '2': + /* Locale encoding is EUC-JP. */ + { + /* U+00D7 MULTIPLICATION SIGN */ + is = for_character ("\241\337", 2); + ASSERT (is == 0); + #if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__) + /* U+00D8 LATIN CAPITAL LETTER O WITH STROKE */ + is = for_character ("\217\251\254", 3); + ASSERT (is != 0); + /* U+0141 LATIN CAPITAL LETTER L WITH STROKE */ + is = for_character ("\217\251\250", 3); + ASSERT (is != 0); + #endif + /* U+3001 IDEOGRAPHIC COMMA */ + is = for_character ("\241\242", 2); + ASSERT (is == 0); + #if defined __GLIBC__ + /* U+FF11 FULLWIDTH DIGIT ONE */ + is = for_character ("\243\261", 2); + ASSERT (is != 0); + #endif + #if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__) + /* U+FF4D FULLWIDTH LATIN SMALL LETTER M */ + is = for_character ("\243\355", 2); + ASSERT (is != 0); + #endif + } + return 0; + + case '3': + /* Locale encoding is UTF-8. */ + { + /* U+00D7 MULTIPLICATION SIGN */ + is = for_character ("\303\227", 2); + ASSERT (is == 0); + /* U+00D8 LATIN CAPITAL LETTER O WITH STROKE */ + is = for_character ("\303\230", 2); + ASSERT (is != 0); + /* U+0141 LATIN CAPITAL LETTER L WITH STROKE */ + is = for_character ("\305\201", 2); + ASSERT (is != 0); + /* U+3001 IDEOGRAPHIC COMMA */ + is = for_character ("\343\200\201", 3); + ASSERT (is == 0); + #if defined __GLIBC__ + /* U+FF11 FULLWIDTH DIGIT ONE */ + is = for_character ("\357\274\221", 3); + ASSERT (is != 0); + #endif + /* U+FF4D FULLWIDTH LATIN SMALL LETTER M */ + is = for_character ("\357\275\215", 3); + ASSERT (is != 0); + #if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__ || defined __sun) + /* U+10330 GOTHIC LETTER AHSA */ + is = for_character ("\360\220\214\260", 4); + ASSERT (is != 0); + #endif + /* U+1D100 MUSICAL SYMBOL SINGLE BARLINE */ + is = for_character ("\360\235\204\200", 4); + ASSERT (is == 0); + /* U+E0061 TAG LATIN SMALL LETTER A */ + is = for_character ("\363\240\201\241", 4); + ASSERT (is == 0); + } + return 0; + + case '4': + /* Locale encoding is GB18030. */ + #if (defined __GLIBC__ && __GLIBC__ == 2 && __GLIBC_MINOR__ >= 13 && __GLIBC_MINOR__ <= 15) || (GL_CHAR32_T_IS_UNICODE && (defined __FreeBSD__ || defined __NetBSD__ || defined __sun)) + fputs ("Skipping test: The GB18030 converter in this system's iconv is broken.\n", stderr); + return 77; + #endif + { + /* U+00D7 MULTIPLICATION SIGN */ + is = for_character ("\241\301", 2); + ASSERT (is == 0); + #if !(defined __FreeBSD__ || defined __DragonFly__ || defined __sun) + /* U+00D8 LATIN CAPITAL LETTER O WITH STROKE */ + is = for_character ("\201\060\211\061", 4); + ASSERT (is != 0); + /* U+0141 LATIN CAPITAL LETTER L WITH STROKE */ + is = for_character ("\201\060\221\071", 4); + ASSERT (is != 0); + #endif + /* U+3001 IDEOGRAPHIC COMMA */ + is = for_character ("\241\242", 2); + ASSERT (is == 0); + #if defined __GLIBC__ + /* U+FF11 FULLWIDTH DIGIT ONE */ + is = for_character ("\243\261", 2); + ASSERT (is != 0); + #endif + #if !defined __DragonFly__ + /* U+FF4D FULLWIDTH LATIN SMALL LETTER M */ + is = for_character ("\243\355", 2); + ASSERT (is != 0); + #endif + #if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__ || defined __sun) + /* U+10330 GOTHIC LETTER AHSA */ + is = for_character ("\220\060\322\066", 4); + ASSERT (is != 0); + #endif + /* U+1D100 MUSICAL SYMBOL SINGLE BARLINE */ + is = for_character ("\224\062\273\064", 4); + ASSERT (is == 0); + /* U+E0061 TAG LATIN SMALL LETTER A */ + is = for_character ("\323\066\237\065", 4); + ASSERT (is == 0); + } + return 0; + + } + + return 1; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isalnum.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isalnum.sh new file mode 100755 index 00000000..df94aade --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isalnum.sh @@ -0,0 +1,42 @@ +#!/bin/sh + +# Test in the POSIX locale. +LC_ALL=C ${CHECKER} ./test-c32isalnum${EXEEXT} 0 || exit 1 +LC_ALL=POSIX ${CHECKER} ./test-c32isalnum${EXEEXT} 0 || exit 1 + +# Test in an ISO-8859-1 or ISO-8859-15 locale. +: "${LOCALE_FR=fr_FR}" +if test $LOCALE_FR != none; then + LC_ALL=$LOCALE_FR \ + ${CHECKER} ./test-c32isalnum${EXEEXT} 1 \ + || exit 1 +fi + +# Test whether a specific EUC-JP locale is installed. +: "${LOCALE_JA=ja_JP}" +if test $LOCALE_JA != none; then + LC_ALL=$LOCALE_JA \ + ${CHECKER} ./test-c32isalnum${EXEEXT} 2 \ + || exit 1 +fi + +# Test whether a specific UTF-8 locale is installed. +: "${LOCALE_FR_UTF8=fr_FR.UTF-8}" +if test $LOCALE_FR_UTF8 != none; then + LC_ALL=$LOCALE_FR_UTF8 \ + ${CHECKER} ./test-c32isalnum${EXEEXT} 3 \ + || exit 1 +fi + +# Test whether a specific GB18030 locale is installed. +: "${LOCALE_ZH_CN=zh_CN.GB18030}" +if test $LOCALE_ZH_CN != none; then + LC_ALL=$LOCALE_ZH_CN \ + ${CHECKER} ./test-c32isalnum${EXEEXT} 4 + case $? in + 0 | 77) ;; + *) exit 1 ;; + esac +fi + +exit 0 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isalpha.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isalpha.c new file mode 100644 index 00000000..14c78d7d --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isalpha.c @@ -0,0 +1,259 @@ +/* Test of c32isalpha() function. + Copyright (C) 2020-2024 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 . */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (c32isalpha, int, (wint_t)); + +#include +#include +#include +#include + +#include "macros.h" + +/* Returns the value of c32isalpha for the multibyte character s[0..n-1]. */ +static int +for_character (const char *s, size_t n) +{ + mbstate_t state; + char32_t wc; + size_t ret; + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, s, n, &state); + ASSERT (ret == n); + + return c32isalpha (wc); +} + +int +main (int argc, char *argv[]) +{ + int is; + char buf[4]; + + /* configure should already have checked that the locale is supported. */ + if (setlocale (LC_ALL, "") == NULL) + return 1; + + /* Test WEOF. */ + is = c32isalpha (WEOF); + ASSERT (is == 0); + + /* Test single-byte characters. + POSIX specifies in + + that + - in all locales, the alphabetic characters include the uppercase and + lowercase characters and, consequently, include the A ... Z and a ... z + characters. + - in the "POSIX" locale (which is usually the same as the "C" locale), + the alphabetic characters include only the ASCII A ... Z and a ... z + characters. */ + { + int c; + + for (c = 0; c < 0x100; c++) + switch (c) + { + case '\t': case '\v': case '\f': + case ' ': case '!': case '"': case '#': case '%': + case '&': case '\'': case '(': case ')': case '*': + case '+': case ',': case '-': case '.': case '/': + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + case ':': case ';': case '<': case '=': case '>': + case '?': + case 'A': case 'B': case 'C': case 'D': case 'E': + case 'F': case 'G': case 'H': case 'I': case 'J': + case 'K': case 'L': case 'M': case 'N': case 'O': + case 'P': case 'Q': case 'R': case 'S': case 'T': + case 'U': case 'V': case 'W': case 'X': case 'Y': + case 'Z': + case '[': case '\\': case ']': case '^': case '_': + case 'a': case 'b': case 'c': case 'd': case 'e': + case 'f': case 'g': case 'h': case 'i': case 'j': + case 'k': case 'l': case 'm': case 'n': case 'o': + case 'p': case 'q': case 'r': case 's': case 't': + case 'u': case 'v': case 'w': case 'x': case 'y': + case 'z': case '{': case '|': case '}': case '~': + /* c is in the ISO C "basic character set". */ + buf[0] = (unsigned char) c; + is = for_character (buf, 1); + switch (c) + { + case 'A': case 'B': case 'C': case 'D': case 'E': + case 'F': case 'G': case 'H': case 'I': case 'J': + case 'K': case 'L': case 'M': case 'N': case 'O': + case 'P': case 'Q': case 'R': case 'S': case 'T': + case 'U': case 'V': case 'W': case 'X': case 'Y': + case 'Z': + case 'a': case 'b': case 'c': case 'd': case 'e': + case 'f': case 'g': case 'h': case 'i': case 'j': + case 'k': case 'l': case 'm': case 'n': case 'o': + case 'p': case 'q': case 'r': case 's': case 't': + case 'u': case 'v': case 'w': case 'x': case 'y': + case 'z': + ASSERT (is != 0); + break; + default: + ASSERT (is == 0); + break; + } + break; + } + } + + if (argc > 1) + switch (argv[1][0]) + { + case '0': + /* C locale; tested above. */ + return 0; + + case '1': + /* Locale encoding is ISO-8859-1 or ISO-8859-15. */ + { + /* U+00D7 MULTIPLICATION SIGN */ + is = for_character ("\327", 1); + ASSERT (is == 0); + /* U+00D8 LATIN CAPITAL LETTER O WITH STROKE */ + is = for_character ("\330", 1); + ASSERT (is != 0); + } + return 0; + + case '2': + /* Locale encoding is EUC-JP. */ + { + /* U+00D7 MULTIPLICATION SIGN */ + is = for_character ("\241\337", 2); + ASSERT (is == 0); + #if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__) + /* U+00D8 LATIN CAPITAL LETTER O WITH STROKE */ + is = for_character ("\217\251\254", 3); + ASSERT (is != 0); + /* U+0141 LATIN CAPITAL LETTER L WITH STROKE */ + is = for_character ("\217\251\250", 3); + ASSERT (is != 0); + #endif + /* U+3001 IDEOGRAPHIC COMMA */ + is = for_character ("\241\242", 2); + ASSERT (is == 0); + #if !(defined __GLIBC__ || (defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __NetBSD__ || defined __sun || defined __CYGWIN__) + /* U+FF11 FULLWIDTH DIGIT ONE */ + is = for_character ("\243\261", 2); + ASSERT (is == 0); + #endif + #if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__) + /* U+FF4D FULLWIDTH LATIN SMALL LETTER M */ + is = for_character ("\243\355", 2); + ASSERT (is != 0); + #endif + } + return 0; + + case '3': + /* Locale encoding is UTF-8. */ + { + /* U+00D7 MULTIPLICATION SIGN */ + is = for_character ("\303\227", 2); + ASSERT (is == 0); + /* U+00D8 LATIN CAPITAL LETTER O WITH STROKE */ + is = for_character ("\303\230", 2); + ASSERT (is != 0); + /* U+0141 LATIN CAPITAL LETTER L WITH STROKE */ + is = for_character ("\305\201", 2); + ASSERT (is != 0); + /* U+3001 IDEOGRAPHIC COMMA */ + is = for_character ("\343\200\201", 3); + ASSERT (is == 0); + #if !(defined __GLIBC__ || defined MUSL_LIBC || (defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __NetBSD__ || defined _AIX || defined __sun || defined __CYGWIN__) + /* U+FF11 FULLWIDTH DIGIT ONE */ + is = for_character ("\357\274\221", 3); + ASSERT (is == 0); + #endif + /* U+FF4D FULLWIDTH LATIN SMALL LETTER M */ + is = for_character ("\357\275\215", 3); + ASSERT (is != 0); + #if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__ || defined __sun) + /* U+10330 GOTHIC LETTER AHSA */ + is = for_character ("\360\220\214\260", 4); + ASSERT (is != 0); + #endif + /* U+1D100 MUSICAL SYMBOL SINGLE BARLINE */ + is = for_character ("\360\235\204\200", 4); + ASSERT (is == 0); + /* U+E0061 TAG LATIN SMALL LETTER A */ + is = for_character ("\363\240\201\241", 4); + ASSERT (is == 0); + } + return 0; + + case '4': + /* Locale encoding is GB18030. */ + #if (defined __GLIBC__ && __GLIBC__ == 2 && __GLIBC_MINOR__ >= 13 && __GLIBC_MINOR__ <= 15) || (GL_CHAR32_T_IS_UNICODE && (defined __FreeBSD__ || defined __NetBSD__ || defined __sun)) + fputs ("Skipping test: The GB18030 converter in this system's iconv is broken.\n", stderr); + return 77; + #endif + { + /* U+00D7 MULTIPLICATION SIGN */ + is = for_character ("\241\301", 2); + ASSERT (is == 0); + #if !(defined __FreeBSD__ || defined __DragonFly__ || defined __sun) + /* U+00D8 LATIN CAPITAL LETTER O WITH STROKE */ + is = for_character ("\201\060\211\061", 4); + ASSERT (is != 0); + /* U+0141 LATIN CAPITAL LETTER L WITH STROKE */ + is = for_character ("\201\060\221\071", 4); + ASSERT (is != 0); + #endif + /* U+3001 IDEOGRAPHIC COMMA */ + is = for_character ("\241\242", 2); + ASSERT (is == 0); + #if !(defined __GLIBC__ || (defined __APPLE__ && defined __MACH__) || defined __FreeBSD__) + /* U+FF11 FULLWIDTH DIGIT ONE */ + is = for_character ("\243\261", 2); + ASSERT (is == 0); + #endif + #if !defined __DragonFly__ + /* U+FF4D FULLWIDTH LATIN SMALL LETTER M */ + is = for_character ("\243\355", 2); + ASSERT (is != 0); + #endif + #if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__ || defined __sun) + /* U+10330 GOTHIC LETTER AHSA */ + is = for_character ("\220\060\322\066", 4); + ASSERT (is != 0); + #endif + /* U+1D100 MUSICAL SYMBOL SINGLE BARLINE */ + is = for_character ("\224\062\273\064", 4); + ASSERT (is == 0); + /* U+E0061 TAG LATIN SMALL LETTER A */ + is = for_character ("\323\066\237\065", 4); + ASSERT (is == 0); + } + return 0; + + } + + return 1; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isalpha.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isalpha.sh new file mode 100755 index 00000000..11c896fa --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isalpha.sh @@ -0,0 +1,42 @@ +#!/bin/sh + +# Test in the POSIX locale. +LC_ALL=C ${CHECKER} ./test-c32isalpha${EXEEXT} 0 || exit 1 +LC_ALL=POSIX ${CHECKER} ./test-c32isalpha${EXEEXT} 0 || exit 1 + +# Test in an ISO-8859-1 or ISO-8859-15 locale. +: "${LOCALE_FR=fr_FR}" +if test $LOCALE_FR != none; then + LC_ALL=$LOCALE_FR \ + ${CHECKER} ./test-c32isalpha${EXEEXT} 1 \ + || exit 1 +fi + +# Test whether a specific EUC-JP locale is installed. +: "${LOCALE_JA=ja_JP}" +if test $LOCALE_JA != none; then + LC_ALL=$LOCALE_JA \ + ${CHECKER} ./test-c32isalpha${EXEEXT} 2 \ + || exit 1 +fi + +# Test whether a specific UTF-8 locale is installed. +: "${LOCALE_FR_UTF8=fr_FR.UTF-8}" +if test $LOCALE_FR_UTF8 != none; then + LC_ALL=$LOCALE_FR_UTF8 \ + ${CHECKER} ./test-c32isalpha${EXEEXT} 3 \ + || exit 1 +fi + +# Test whether a specific GB18030 locale is installed. +: "${LOCALE_ZH_CN=zh_CN.GB18030}" +if test $LOCALE_ZH_CN != none; then + LC_ALL=$LOCALE_ZH_CN \ + ${CHECKER} ./test-c32isalpha${EXEEXT} 4 + case $? in + 0 | 77) ;; + *) exit 1 ;; + esac +fi + +exit 0 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isblank.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isblank.c new file mode 100644 index 00000000..0e722b25 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isblank.c @@ -0,0 +1,205 @@ +/* Test of c32isblank() function. + Copyright (C) 2020-2024 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 . */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (c32isblank, int, (wint_t)); + +#include +#include +#include +#include + +#include "macros.h" + +/* Returns the value of c32isblank for the multibyte character s[0..n-1]. */ +static int +for_character (const char *s, size_t n) +{ + mbstate_t state; + char32_t wc; + size_t ret; + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, s, n, &state); + ASSERT (ret == n); + + return c32isblank (wc); +} + +int +main (int argc, char *argv[]) +{ + int is; + char buf[4]; + + /* configure should already have checked that the locale is supported. */ + if (setlocale (LC_ALL, "") == NULL) + return 1; + + /* Test WEOF. */ + is = c32isblank (WEOF); + ASSERT (is == 0); + + /* Test single-byte characters. + POSIX specifies in + + that + - in all locales, the blank characters include the and + characters, + - in the "POSIX" locale (which is usually the same as the "C" locale), + the blank characters include only the ASCII and + characters. */ + { + int c; + + for (c = 0; c < 0x100; c++) + switch (c) + { + case '\t': + #if !(defined __FreeBSD__ || defined __NetBSD__) + case '\v': + #endif + case '\f': + case ' ': case '!': case '"': case '#': case '%': + case '&': case '\'': case '(': case ')': case '*': + case '+': case ',': case '-': case '.': case '/': + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + case ':': case ';': case '<': case '=': case '>': + case '?': + case 'A': case 'B': case 'C': case 'D': case 'E': + case 'F': case 'G': case 'H': case 'I': case 'J': + case 'K': case 'L': case 'M': case 'N': case 'O': + case 'P': case 'Q': case 'R': case 'S': case 'T': + case 'U': case 'V': case 'W': case 'X': case 'Y': + case 'Z': + case '[': case '\\': case ']': case '^': case '_': + case 'a': case 'b': case 'c': case 'd': case 'e': + case 'f': case 'g': case 'h': case 'i': case 'j': + case 'k': case 'l': case 'm': case 'n': case 'o': + case 'p': case 'q': case 'r': case 's': case 't': + case 'u': case 'v': case 'w': case 'x': case 'y': + case 'z': case '{': case '|': case '}': case '~': + /* c is in the ISO C "basic character set". */ + buf[0] = (unsigned char) c; + is = for_character (buf, 1); + if (c == '\t' || c == ' ') + ASSERT (is != 0); + else + ASSERT (is == 0); + break; + } + } + + if (argc > 1) + switch (argv[1][0]) + { + case '0': + /* C locale; tested above. */ + return 0; + + case '1': + /* Locale encoding is ISO-8859-1 or ISO-8859-15. */ + { + #if defined __GLIBC__ + /* U+00A0 NO-BREAK SPACE */ + is = for_character ("\240", 1); + ASSERT (is == 0); + #endif + /* U+00B7 MIDDLE DOT */ + is = for_character ("\267", 1); + ASSERT (is == 0); + } + return 0; + + case '2': + /* Locale encoding is EUC-JP. */ + { + /* U+3002 IDEOGRAPHIC FULL STOP */ + is = for_character ("\241\243", 2); + ASSERT (is == 0); + } + return 0; + + case '3': + /* Locale encoding is UTF-8. */ + { + #if defined __GLIBC__ + /* U+00A0 NO-BREAK SPACE */ + is = for_character ("\302\240", 2); + ASSERT (is == 0); + #endif + /* U+00B7 MIDDLE DOT */ + is = for_character ("\302\267", 2); + ASSERT (is == 0); + #if defined __GLIBC__ + /* U+202F NARROW NO-BREAK SPACE */ + is = for_character ("\342\200\257", 3); + ASSERT (is == 0); + #endif + /* U+3002 IDEOGRAPHIC FULL STOP */ + is = for_character ("\343\200\202", 3); + ASSERT (is == 0); + /* U+1D13D MUSICAL SYMBOL QUARTER REST */ + is = for_character ("\360\235\204\275", 4); + ASSERT (is == 0); + /* U+E0020 TAG SPACE */ + is = for_character ("\363\240\200\240", 4); + ASSERT (is == 0); + } + return 0; + + case '4': + /* Locale encoding is GB18030. */ + #if (defined __GLIBC__ && __GLIBC__ == 2 && __GLIBC_MINOR__ >= 13 && __GLIBC_MINOR__ <= 15) || (GL_CHAR32_T_IS_UNICODE && (defined __FreeBSD__ || defined __NetBSD__ || defined __sun)) + fputs ("Skipping test: The GB18030 converter in this system's iconv is broken.\n", stderr); + return 77; + #endif + { + #if defined __GLIBC__ + /* U+00A0 NO-BREAK SPACE */ + is = for_character ("\201\060\204\062", 4); + ASSERT (is == 0); + #endif + /* U+00B7 MIDDLE DOT */ + is = for_character ("\241\244", 2); + ASSERT (is == 0); + #if defined __GLIBC__ + /* U+202F NARROW NO-BREAK SPACE */ + is = for_character ("\201\066\247\062", 4); + ASSERT (is == 0); + #endif + /* U+3002 IDEOGRAPHIC FULL STOP */ + is = for_character ("\241\243", 2); + ASSERT (is == 0); + /* U+1D13D MUSICAL SYMBOL QUARTER REST */ + is = for_character ("\224\062\301\065", 4); + ASSERT (is == 0); + /* U+E0020 TAG SPACE */ + is = for_character ("\323\066\231\060", 4); + ASSERT (is == 0); + } + return 0; + + } + + return 1; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isblank.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isblank.sh new file mode 100755 index 00000000..fe5f9b86 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isblank.sh @@ -0,0 +1,42 @@ +#!/bin/sh + +# Test in the POSIX locale. +LC_ALL=C ${CHECKER} ./test-c32isblank${EXEEXT} 0 || exit 1 +LC_ALL=POSIX ${CHECKER} ./test-c32isblank${EXEEXT} 0 || exit 1 + +# Test in an ISO-8859-1 or ISO-8859-15 locale. +: "${LOCALE_FR=fr_FR}" +if test $LOCALE_FR != none; then + LC_ALL=$LOCALE_FR \ + ${CHECKER} ./test-c32isblank${EXEEXT} 1 \ + || exit 1 +fi + +# Test whether a specific EUC-JP locale is installed. +: "${LOCALE_JA=ja_JP}" +if test $LOCALE_JA != none; then + LC_ALL=$LOCALE_JA \ + ${CHECKER} ./test-c32isblank${EXEEXT} 2 \ + || exit 1 +fi + +# Test whether a specific UTF-8 locale is installed. +: "${LOCALE_FR_UTF8=fr_FR.UTF-8}" +if test $LOCALE_FR_UTF8 != none; then + LC_ALL=$LOCALE_FR_UTF8 \ + ${CHECKER} ./test-c32isblank${EXEEXT} 3 \ + || exit 1 +fi + +# Test whether a specific GB18030 locale is installed. +: "${LOCALE_ZH_CN=zh_CN.GB18030}" +if test $LOCALE_ZH_CN != none; then + LC_ALL=$LOCALE_ZH_CN \ + ${CHECKER} ./test-c32isblank${EXEEXT} 4 + case $? in + 0 | 77) ;; + *) exit 1 ;; + esac +fi + +exit 0 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32iscntrl.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32iscntrl.c new file mode 100644 index 00000000..674c5804 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32iscntrl.c @@ -0,0 +1,212 @@ +/* Test of c32iscntrl() function. + Copyright (C) 2020-2024 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 . */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (c32iscntrl, int, (wint_t)); + +#include +#include +#include +#include + +#include "macros.h" + +/* Returns the value of c32iscntrl for the multibyte character s[0..n-1]. */ +static int +for_character (const char *s, size_t n) +{ + mbstate_t state; + char32_t wc; + size_t ret; + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, s, n, &state); + ASSERT (ret == n); + + return c32iscntrl (wc); +} + +int +main (int argc, char *argv[]) +{ + int is; + char buf[4]; + + /* configure should already have checked that the locale is supported. */ + if (setlocale (LC_ALL, "") == NULL) + return 1; + + /* Test WEOF. */ + is = c32iscntrl (WEOF); + ASSERT (is == 0); + + /* Test single-byte characters. + POSIX specifies in + + no explicit list of control characters. */ + { + int c; + + for (c = 0; c < 0x100; c++) + switch (c) + { + case '\t': case '\v': case '\f': + case ' ': case '!': case '"': case '#': case '%': + case '&': case '\'': case '(': case ')': case '*': + case '+': case ',': case '-': case '.': case '/': + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + case ':': case ';': case '<': case '=': case '>': + case '?': + case 'A': case 'B': case 'C': case 'D': case 'E': + case 'F': case 'G': case 'H': case 'I': case 'J': + case 'K': case 'L': case 'M': case 'N': case 'O': + case 'P': case 'Q': case 'R': case 'S': case 'T': + case 'U': case 'V': case 'W': case 'X': case 'Y': + case 'Z': + case '[': case '\\': case ']': case '^': case '_': + case 'a': case 'b': case 'c': case 'd': case 'e': + case 'f': case 'g': case 'h': case 'i': case 'j': + case 'k': case 'l': case 'm': case 'n': case 'o': + case 'p': case 'q': case 'r': case 's': case 't': + case 'u': case 'v': case 'w': case 'x': case 'y': + case 'z': case '{': case '|': case '}': case '~': + /* c is in the ISO C "basic character set". */ + buf[0] = (unsigned char) c; + is = for_character (buf, 1); + switch (c) + { + case '\t': case '\v': case '\f': + ASSERT (is != 0); + break; + default: + ASSERT (is == 0); + break; + } + break; + } + } + + if (argc > 1) + switch (argv[1][0]) + { + case '0': + /* C locale; tested above. */ + return 0; + + case '1': + /* Locale encoding is ISO-8859-1 or ISO-8859-15. */ + { + /* U+007F */ + is = for_character ("\177", 1); + ASSERT (is != 0); + /* U+00A0 NO-BREAK SPACE */ + is = for_character ("\240", 1); + ASSERT (is == 0); + } + return 0; + + case '2': + /* Locale encoding is EUC-JP. */ + { + /* U+007F */ + is = for_character ("\177", 1); + ASSERT (is != 0); + /* U+3000 IDEOGRAPHIC SPACE */ + is = for_character ("\241\241", 2); + ASSERT (is == 0); + } + return 0; + + case '3': + /* Locale encoding is UTF-8. */ + { + /* U+007F */ + is = for_character ("\177", 1); + ASSERT (is != 0); + /* U+00A0 NO-BREAK SPACE */ + is = for_character ("\302\240", 2); + ASSERT (is == 0); + #if !(defined __GLIBC__ || defined MUSL_LIBC || (defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__ || defined _AIX || defined __sun || defined __CYGWIN__) + /* U+202E RIGHT-TO-LEFT OVERRIDE */ + is = for_character ("\342\200\256", 3); + ASSERT (is != 0); + #endif + /* U+3000 IDEOGRAPHIC SPACE */ + is = for_character ("\343\200\200", 3); + ASSERT (is == 0); + #if !(defined __GLIBC__ || defined MUSL_LIBC || (defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__ || defined _AIX || defined __sun || defined __CYGWIN__) + /* U+FEFF ZERO WIDTH NO-BREAK SPACE */ + is = for_character ("\357\273\277", 3); + ASSERT (is != 0); + #endif + /* U+20000 */ + is = for_character ("\360\240\200\200", 4); + ASSERT (is == 0); + #if !(defined __GLIBC__ || defined MUSL_LIBC || (defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__ || defined _AIX || defined __sun || defined __CYGWIN__ || (defined _WIN32 && !defined __CYGWIN__)) + /* U+E0001 LANGUAGE TAG */ + is = for_character ("\363\240\200\201", 4); + ASSERT (is != 0); + #endif + } + return 0; + + case '4': + /* Locale encoding is GB18030. */ + #if (defined __GLIBC__ && __GLIBC__ == 2 && __GLIBC_MINOR__ >= 13 && __GLIBC_MINOR__ <= 15) || (GL_CHAR32_T_IS_UNICODE && (defined __FreeBSD__ || defined __NetBSD__ || defined __sun)) + fputs ("Skipping test: The GB18030 converter in this system's iconv is broken.\n", stderr); + return 77; + #endif + { + /* U+007F */ + is = for_character ("\177", 1); + ASSERT (is != 0); + /* U+00A0 NO-BREAK SPACE */ + is = for_character ("\201\060\204\062", 4); + ASSERT (is == 0); + #if !(defined __GLIBC__ || (defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__ || defined __sun) + /* U+202E RIGHT-TO-LEFT OVERRIDE */ + is = for_character ("\201\066\247\061", 4); + ASSERT (is != 0); + #endif + /* U+3000 IDEOGRAPHIC SPACE */ + is = for_character ("\241\241", 2); + ASSERT (is == 0); + #if !(defined __GLIBC__ || (defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__ || defined __sun) + /* U+FEFF ZERO WIDTH NO-BREAK SPACE */ + is = for_character ("\204\061\225\063", 4); + ASSERT (is != 0); + #endif + /* U+20000 */ + is = for_character ("\225\062\202\066", 4); + ASSERT (is == 0); + #if !(defined __GLIBC__ || (defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__ || defined __sun) + /* U+E0001 LANGUAGE TAG */ + is = for_character ("\323\066\225\071", 4); + ASSERT (is != 0); + #endif + } + return 0; + + } + + return 1; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32iscntrl.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32iscntrl.sh new file mode 100755 index 00000000..b27747c7 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32iscntrl.sh @@ -0,0 +1,42 @@ +#!/bin/sh + +# Test in the POSIX locale. +LC_ALL=C ${CHECKER} ./test-c32iscntrl${EXEEXT} 0 || exit 1 +LC_ALL=POSIX ${CHECKER} ./test-c32iscntrl${EXEEXT} 0 || exit 1 + +# Test in an ISO-8859-1 or ISO-8859-15 locale. +: "${LOCALE_FR=fr_FR}" +if test $LOCALE_FR != none; then + LC_ALL=$LOCALE_FR \ + ${CHECKER} ./test-c32iscntrl${EXEEXT} 1 \ + || exit 1 +fi + +# Test whether a specific EUC-JP locale is installed. +: "${LOCALE_JA=ja_JP}" +if test $LOCALE_JA != none; then + LC_ALL=$LOCALE_JA \ + ${CHECKER} ./test-c32iscntrl${EXEEXT} 2 \ + || exit 1 +fi + +# Test whether a specific UTF-8 locale is installed. +: "${LOCALE_FR_UTF8=fr_FR.UTF-8}" +if test $LOCALE_FR_UTF8 != none; then + LC_ALL=$LOCALE_FR_UTF8 \ + ${CHECKER} ./test-c32iscntrl${EXEEXT} 3 \ + || exit 1 +fi + +# Test whether a specific GB18030 locale is installed. +: "${LOCALE_ZH_CN=zh_CN.GB18030}" +if test $LOCALE_ZH_CN != none; then + LC_ALL=$LOCALE_ZH_CN \ + ${CHECKER} ./test-c32iscntrl${EXEEXT} 4 + case $? in + 0 | 77) ;; + *) exit 1 ;; + esac +fi + +exit 0 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isdigit.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isdigit.c new file mode 100644 index 00000000..82b77015 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isdigit.c @@ -0,0 +1,236 @@ +/* Test of c32isdigit() function. + Copyright (C) 2020-2024 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 . */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (c32isdigit, int, (wint_t)); + +#include +#include +#include +#include + +#include "macros.h" + +/* Returns the value of c32isdigit for the multibyte character s[0..n-1]. */ +static int +for_character (const char *s, size_t n) +{ + mbstate_t state; + char32_t wc; + size_t ret; + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, s, n, &state); + ASSERT (ret == n); + + return c32isdigit (wc); +} + +int +main (int argc, char *argv[]) +{ + int is; + char buf[4]; + + /* configure should already have checked that the locale is supported. */ + if (setlocale (LC_ALL, "") == NULL) + return 1; + + /* Test WEOF. */ + is = c32isdigit (WEOF); + ASSERT (is == 0); + + /* Test single-byte characters. + ISO C 99 sections 7.25.2.1.5 and 5.2.1 specify that the decimal digits + include only the ASCII 0 ... 9 characters. */ + { + int c; + + for (c = 0; c < 0x100; c++) + switch (c) + { + case '\t': case '\v': case '\f': + case ' ': case '!': case '"': case '#': case '%': + case '&': case '\'': case '(': case ')': case '*': + case '+': case ',': case '-': case '.': case '/': + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + case ':': case ';': case '<': case '=': case '>': + case '?': + case 'A': case 'B': case 'C': case 'D': case 'E': + case 'F': case 'G': case 'H': case 'I': case 'J': + case 'K': case 'L': case 'M': case 'N': case 'O': + case 'P': case 'Q': case 'R': case 'S': case 'T': + case 'U': case 'V': case 'W': case 'X': case 'Y': + case 'Z': + case '[': case '\\': case ']': case '^': case '_': + case 'a': case 'b': case 'c': case 'd': case 'e': + case 'f': case 'g': case 'h': case 'i': case 'j': + case 'k': case 'l': case 'm': case 'n': case 'o': + case 'p': case 'q': case 'r': case 's': case 't': + case 'u': case 'v': case 'w': case 'x': case 'y': + case 'z': case '{': case '|': case '}': case '~': + /* c is in the ISO C "basic character set". */ + buf[0] = (unsigned char) c; + is = for_character (buf, 1); + switch (c) + { + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + ASSERT (is != 0); + break; + default: + ASSERT (is == 0); + break; + } + break; + } + } + + if (argc > 1) + switch (argv[1][0]) + { + case '0': + /* C locale; tested above. */ + return 0; + + case '1': + /* Locale encoding is ISO-8859-1 or ISO-8859-15. */ + { + /* U+00B2 SUPERSCRIPT TWO */ + is = for_character ("\262", 1); + ASSERT (is == 0); + /* U+00B3 SUPERSCRIPT THREE */ + is = for_character ("\263", 1); + ASSERT (is == 0); + /* U+00B9 SUPERSCRIPT ONE */ + is = for_character ("\271", 1); + ASSERT (is == 0); + } + return 0; + + case '2': + /* Locale encoding is EUC-JP. */ + { + /* U+FF11 FULLWIDTH DIGIT ONE */ + is = for_character ("\243\261", 2); + ASSERT (is == 0); + } + return 0; + + case '3': + /* Locale encoding is UTF-8. */ + { + /* U+00B2 SUPERSCRIPT TWO */ + is = for_character ("\302\262", 2); + ASSERT (is == 0); + /* U+00B3 SUPERSCRIPT THREE */ + is = for_character ("\302\263", 2); + ASSERT (is == 0); + /* U+00B9 SUPERSCRIPT ONE */ + is = for_character ("\302\271", 2); + ASSERT (is == 0); + /* U+0663 ARABIC-INDIC DIGIT THREE */ + is = for_character ("\331\243", 2); + ASSERT (is == 0); + /* U+2070 SUPERSCRIPT ZERO */ + is = for_character ("\342\201\260", 3); + ASSERT (is == 0); + /* U+2079 SUPERSCRIPT NINE */ + is = for_character ("\342\201\271", 3); + ASSERT (is == 0); + /* U+FF11 FULLWIDTH DIGIT ONE */ + is = for_character ("\357\274\221", 3); + ASSERT (is == 0); + /* U+1D7D1 MATHEMATICAL BOLD DIGIT THREE */ + is = for_character ("\360\235\237\221", 4); + ASSERT (is == 0); + /* U+1D7DB MATHEMATICAL DOUBLE-STRUCK DIGIT THREE */ + is = for_character ("\360\235\237\233", 4); + ASSERT (is == 0); + /* U+1D7E5 MATHEMATICAL SANS-SERIF DIGIT THREE */ + is = for_character ("\360\235\237\245", 4); + ASSERT (is == 0); + /* U+1D7EF MATHEMATICAL SANS-SERIF BOLD DIGIT THREE */ + is = for_character ("\360\235\237\257", 4); + ASSERT (is == 0); + /* U+1D7F9 MATHEMATICAL MONOSPACE DIGIT THREE */ + is = for_character ("\360\235\237\271", 4); + ASSERT (is == 0); + /* U+E0033 TAG DIGIT THREE */ + is = for_character ("\363\240\200\263", 4); + ASSERT (is == 0); + } + return 0; + + case '4': + /* Locale encoding is GB18030. */ + #if (defined __GLIBC__ && __GLIBC__ == 2 && __GLIBC_MINOR__ >= 13 && __GLIBC_MINOR__ <= 15) || (GL_CHAR32_T_IS_UNICODE && (defined __FreeBSD__ || defined __NetBSD__ || defined __sun)) + fputs ("Skipping test: The GB18030 converter in this system's iconv is broken.\n", stderr); + return 77; + #endif + { + /* U+00B2 SUPERSCRIPT TWO */ + is = for_character ("\201\060\205\065", 4); + ASSERT (is == 0); + /* U+00B3 SUPERSCRIPT THREE */ + is = for_character ("\201\060\205\066", 4); + ASSERT (is == 0); + /* U+00B9 SUPERSCRIPT ONE */ + is = for_character ("\201\060\206\061", 4); + ASSERT (is == 0); + /* U+0663 ARABIC-INDIC DIGIT THREE */ + is = for_character ("\201\061\211\071", 4); + ASSERT (is == 0); + /* U+2070 SUPERSCRIPT ZERO */ + is = for_character ("\201\066\255\062", 4); + ASSERT (is == 0); + /* U+2079 SUPERSCRIPT NINE */ + is = for_character ("\201\066\256\061", 4); + ASSERT (is == 0); + /* U+FF11 FULLWIDTH DIGIT ONE */ + is = for_character ("\243\261", 2); + ASSERT (is == 0); + /* U+1D7D1 MATHEMATICAL BOLD DIGIT THREE */ + is = for_character ("\224\063\353\071", 4); + ASSERT (is == 0); + /* U+1D7DB MATHEMATICAL DOUBLE-STRUCK DIGIT THREE */ + is = for_character ("\224\063\354\071", 4); + ASSERT (is == 0); + /* U+1D7E5 MATHEMATICAL SANS-SERIF DIGIT THREE */ + is = for_character ("\224\063\355\071", 4); + ASSERT (is == 0); + /* U+1D7EF MATHEMATICAL SANS-SERIF BOLD DIGIT THREE */ + is = for_character ("\224\063\356\071", 4); + ASSERT (is == 0); + /* U+1D7F9 MATHEMATICAL MONOSPACE DIGIT THREE */ + is = for_character ("\224\063\357\071", 4); + ASSERT (is == 0); + /* U+E0033 TAG DIGIT THREE */ + is = for_character ("\323\066\232\071", 4); + ASSERT (is == 0); + } + return 0; + + } + + return 1; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isdigit.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isdigit.sh new file mode 100755 index 00000000..158d3628 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isdigit.sh @@ -0,0 +1,42 @@ +#!/bin/sh + +# Test in the POSIX locale. +LC_ALL=C ${CHECKER} ./test-c32isdigit${EXEEXT} 0 || exit 1 +LC_ALL=POSIX ${CHECKER} ./test-c32isdigit${EXEEXT} 0 || exit 1 + +# Test in an ISO-8859-1 or ISO-8859-15 locale. +: "${LOCALE_FR=fr_FR}" +if test $LOCALE_FR != none; then + LC_ALL=$LOCALE_FR \ + ${CHECKER} ./test-c32isdigit${EXEEXT} 1 \ + || exit 1 +fi + +# Test whether a specific EUC-JP locale is installed. +: "${LOCALE_JA=ja_JP}" +if test $LOCALE_JA != none; then + LC_ALL=$LOCALE_JA \ + ${CHECKER} ./test-c32isdigit${EXEEXT} 2 \ + || exit 1 +fi + +# Test whether a specific UTF-8 locale is installed. +: "${LOCALE_FR_UTF8=fr_FR.UTF-8}" +if test $LOCALE_FR_UTF8 != none; then + LC_ALL=$LOCALE_FR_UTF8 \ + ${CHECKER} ./test-c32isdigit${EXEEXT} 3 \ + || exit 1 +fi + +# Test whether a specific GB18030 locale is installed. +: "${LOCALE_ZH_CN=zh_CN.GB18030}" +if test $LOCALE_ZH_CN != none; then + LC_ALL=$LOCALE_ZH_CN \ + ${CHECKER} ./test-c32isdigit${EXEEXT} 4 + case $? in + 0 | 77) ;; + *) exit 1 ;; + esac +fi + +exit 0 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isgraph.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isgraph.c new file mode 100644 index 00000000..fb993bbb --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isgraph.c @@ -0,0 +1,247 @@ +/* Test of c32isgraph() function. + Copyright (C) 2020-2024 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 . */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (c32isgraph, int, (wint_t)); + +#include +#include +#include +#include + +#include "macros.h" + +/* Returns the value of c32isgraph for the multibyte character s[0..n-1]. */ +static int +for_character (const char *s, size_t n) +{ + mbstate_t state; + char32_t wc; + size_t ret; + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, s, n, &state); + ASSERT (ret == n); + + return c32isgraph (wc); +} + +int +main (int argc, char *argv[]) +{ + int is; + char buf[4]; + + /* configure should already have checked that the locale is supported. */ + if (setlocale (LC_ALL, "") == NULL) + return 1; + + /* Test WEOF. */ + is = c32isgraph (WEOF); + ASSERT (is == 0); + + /* Test single-byte characters. + POSIX specifies in + + no explicit list of graphic characters. */ + { + int c; + + for (c = 0; c < 0x100; c++) + switch (c) + { + case '\t': case '\v': case '\f': + case ' ': case '!': case '"': case '#': case '%': + case '&': case '\'': case '(': case ')': case '*': + case '+': case ',': case '-': case '.': case '/': + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + case ':': case ';': case '<': case '=': case '>': + case '?': + case 'A': case 'B': case 'C': case 'D': case 'E': + case 'F': case 'G': case 'H': case 'I': case 'J': + case 'K': case 'L': case 'M': case 'N': case 'O': + case 'P': case 'Q': case 'R': case 'S': case 'T': + case 'U': case 'V': case 'W': case 'X': case 'Y': + case 'Z': + case '[': case '\\': case ']': case '^': case '_': + case 'a': case 'b': case 'c': case 'd': case 'e': + case 'f': case 'g': case 'h': case 'i': case 'j': + case 'k': case 'l': case 'm': case 'n': case 'o': + case 'p': case 'q': case 'r': case 's': case 't': + case 'u': case 'v': case 'w': case 'x': case 'y': + case 'z': case '{': case '|': case '}': case '~': + /* c is in the ISO C "basic character set". */ + buf[0] = (unsigned char) c; + is = for_character (buf, 1); + switch (c) + { + case '\t': case '\v': case '\f': + case ' ': + ASSERT (is == 0); + break; + default: + ASSERT (is != 0); + break; + } + break; + } + } + + if (argc > 1) + switch (argv[1][0]) + { + case '0': + /* C locale; tested above. */ + return 0; + + case '1': + /* Locale encoding is ISO-8859-1 or ISO-8859-15. */ + { + /* U+007F */ + is = for_character ("\177", 1); + ASSERT (is == 0); + #if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__ || defined __sgi || defined __sun || defined __CYGWIN__ || (defined _WIN32 && !defined __CYGWIN__)) + /* U+00A0 NO-BREAK SPACE */ + is = for_character ("\240", 1); + ASSERT (is != 0); + #endif + #if !(defined __FreeBSD__ || defined __DragonFly__) + /* U+00B8 CEDILLA */ + is = for_character ("\270", 1); + ASSERT (is != 0); + #endif + } + return 0; + + case '2': + /* Locale encoding is EUC-JP. */ + { + /* U+007F */ + is = for_character ("\177", 1); + ASSERT (is == 0); + #if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__) + /* U+00B8 CEDILLA */ + is = for_character ("\217\242\261", 3); + ASSERT (is != 0); + #endif + /* U+3000 IDEOGRAPHIC SPACE */ + is = for_character ("\241\241", 2); + ASSERT (is == 0); + } + return 0; + + case '3': + /* Locale encoding is UTF-8. */ + { + /* U+007F */ + is = for_character ("\177", 1); + ASSERT (is == 0); + #if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__ || defined __sun || defined __CYGWIN__ || (defined _WIN32 && !defined __CYGWIN__)) + /* U+00A0 NO-BREAK SPACE */ + is = for_character ("\302\240", 2); + ASSERT (is != 0); + #endif + /* U+00B8 CEDILLA */ + is = for_character ("\302\270", 2); + ASSERT (is != 0); + /* U+2002 EN SPACE */ + is = for_character ("\342\200\202", 3); + ASSERT (is == 0); + #if !(defined __GLIBC__ || defined MUSL_LIBC || (defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __NetBSD__ || defined _AIX || defined __sun || defined __CYGWIN__) + /* U+202E RIGHT-TO-LEFT OVERRIDE */ + is = for_character ("\342\200\256", 3); + ASSERT (is == 0); + #endif + /* U+3000 IDEOGRAPHIC SPACE */ + is = for_character ("\343\200\200", 3); + ASSERT (is == 0); + #if !(defined __GLIBC__ || defined MUSL_LIBC || (defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __NetBSD__ || defined _AIX || defined __sun || defined __CYGWIN__) + /* U+FEFF ZERO WIDTH NO-BREAK SPACE */ + is = for_character ("\357\273\277", 3); + ASSERT (is == 0); + #endif + #if !defined __sun + /* U+20000 */ + is = for_character ("\360\240\200\200", 4); + ASSERT (is != 0); + #endif + #if !(defined __GLIBC__ || defined MUSL_LIBC || (defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __NetBSD__ || defined _AIX || defined __sun || defined __CYGWIN__ || (defined _WIN32 && !defined __CYGWIN__)) + /* U+E0001 LANGUAGE TAG */ + is = for_character ("\363\240\200\201", 4); + ASSERT (is == 0); + #endif + } + return 0; + + case '4': + /* Locale encoding is GB18030. */ + #if (defined __GLIBC__ && __GLIBC__ == 2 && __GLIBC_MINOR__ >= 13 && __GLIBC_MINOR__ <= 15) || (GL_CHAR32_T_IS_UNICODE && (defined __NetBSD__ || defined __sun)) + fputs ("Skipping test: The GB18030 converter in this system's iconv is broken.\n", stderr); + return 77; + #endif + { + /* U+007F */ + is = for_character ("\177", 1); + ASSERT (is == 0); + #if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__ || defined __sun) + /* U+00A0 NO-BREAK SPACE */ + is = for_character ("\201\060\204\062", 4); + ASSERT (is != 0); + #endif + #if !(defined __FreeBSD__ || defined __DragonFly__ || defined __sun) + /* U+00B8 CEDILLA */ + is = for_character ("\201\060\206\060", 4); + ASSERT (is != 0); + #endif + /* U+2002 EN SPACE */ + is = for_character ("\201\066\243\070", 4); + ASSERT (is == 0); + #if !(defined __GLIBC__ || (defined __APPLE__ && defined __MACH__) || defined __FreeBSD__) + /* U+202E RIGHT-TO-LEFT OVERRIDE */ + is = for_character ("\201\066\247\061", 4); + ASSERT (is == 0); + #endif + /* U+3000 IDEOGRAPHIC SPACE */ + is = for_character ("\241\241", 2); + ASSERT (is == 0); + #if !(defined __GLIBC__ || (defined __APPLE__ && defined __MACH__) || defined __FreeBSD__) + /* U+FEFF ZERO WIDTH NO-BREAK SPACE */ + is = for_character ("\204\061\225\063", 4); + ASSERT (is == 0); + #endif + #if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__ || defined __sun) + /* U+20000 */ + is = for_character ("\225\062\202\066", 4); + ASSERT (is != 0); + #endif + #if !(defined __GLIBC__ || (defined __APPLE__ && defined __MACH__) || defined __FreeBSD__) + /* U+E0001 LANGUAGE TAG */ + is = for_character ("\323\066\225\071", 4); + ASSERT (is == 0); + #endif + } + return 0; + + } + + return 1; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isgraph.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isgraph.sh new file mode 100755 index 00000000..be760fb2 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isgraph.sh @@ -0,0 +1,42 @@ +#!/bin/sh + +# Test in the POSIX locale. +LC_ALL=C ${CHECKER} ./test-c32isgraph${EXEEXT} 0 || exit 1 +LC_ALL=POSIX ${CHECKER} ./test-c32isgraph${EXEEXT} 0 || exit 1 + +# Test in an ISO-8859-1 or ISO-8859-15 locale. +: "${LOCALE_FR=fr_FR}" +if test $LOCALE_FR != none; then + LC_ALL=$LOCALE_FR \ + ${CHECKER} ./test-c32isgraph${EXEEXT} 1 \ + || exit 1 +fi + +# Test whether a specific EUC-JP locale is installed. +: "${LOCALE_JA=ja_JP}" +if test $LOCALE_JA != none; then + LC_ALL=$LOCALE_JA \ + ${CHECKER} ./test-c32isgraph${EXEEXT} 2 \ + || exit 1 +fi + +# Test whether a specific UTF-8 locale is installed. +: "${LOCALE_FR_UTF8=fr_FR.UTF-8}" +if test $LOCALE_FR_UTF8 != none; then + LC_ALL=$LOCALE_FR_UTF8 \ + ${CHECKER} ./test-c32isgraph${EXEEXT} 3 \ + || exit 1 +fi + +# Test whether a specific GB18030 locale is installed. +: "${LOCALE_ZH_CN=zh_CN.GB18030}" +if test $LOCALE_ZH_CN != none; then + LC_ALL=$LOCALE_ZH_CN \ + ${CHECKER} ./test-c32isgraph${EXEEXT} 4 + case $? in + 0 | 77) ;; + *) exit 1 ;; + esac +fi + +exit 0 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32islower.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32islower.c new file mode 100644 index 00000000..3b799677 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32islower.c @@ -0,0 +1,354 @@ +/* Test of c32islower() function. + Copyright (C) 2020-2024 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 . */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (c32islower, int, (wint_t)); + +#include +#include +#include +#include + +#include "macros.h" + +/* Returns the value of c32islower for the multibyte character s[0..n-1]. */ +static int +for_character (const char *s, size_t n) +{ + mbstate_t state; + char32_t wc; + size_t ret; + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, s, n, &state); + ASSERT (ret == n); + + return c32islower (wc); +} + +int +main (int argc, char *argv[]) +{ + int is; + char buf[4]; + + /* configure should already have checked that the locale is supported. */ + if (setlocale (LC_ALL, "") == NULL) + return 1; + + /* Test WEOF. */ + is = c32islower (WEOF); + ASSERT (is == 0); + + /* Test single-byte characters. + POSIX specifies in + + that + - in all locales, the lowercase characters include the a ... z + characters, + - in the "POSIX" locale (which is usually the same as the "C" locale), + the lowercase characters include only the ASCII a ... z characters. + */ + { + int c; + + for (c = 0; c < 0x100; c++) + switch (c) + { + case '\t': case '\v': case '\f': + case ' ': case '!': case '"': case '#': case '%': + case '&': case '\'': case '(': case ')': case '*': + case '+': case ',': case '-': case '.': case '/': + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + case ':': case ';': case '<': case '=': case '>': + case '?': + case 'A': case 'B': case 'C': case 'D': case 'E': + case 'F': case 'G': case 'H': case 'I': case 'J': + case 'K': case 'L': case 'M': case 'N': case 'O': + case 'P': case 'Q': case 'R': case 'S': case 'T': + case 'U': case 'V': case 'W': case 'X': case 'Y': + case 'Z': + case '[': case '\\': case ']': case '^': case '_': + case 'a': case 'b': case 'c': case 'd': case 'e': + case 'f': case 'g': case 'h': case 'i': case 'j': + case 'k': case 'l': case 'm': case 'n': case 'o': + case 'p': case 'q': case 'r': case 's': case 't': + case 'u': case 'v': case 'w': case 'x': case 'y': + case 'z': case '{': case '|': case '}': case '~': + /* c is in the ISO C "basic character set". */ + buf[0] = (unsigned char) c; + is = for_character (buf, 1); + switch (c) + { + case 'a': case 'b': case 'c': case 'd': case 'e': + case 'f': case 'g': case 'h': case 'i': case 'j': + case 'k': case 'l': case 'm': case 'n': case 'o': + case 'p': case 'q': case 'r': case 's': case 't': + case 'u': case 'v': case 'w': case 'x': case 'y': + case 'z': + ASSERT (is != 0); + break; + default: + ASSERT (is == 0); + break; + } + break; + } + } + + if (argc > 1) + switch (argv[1][0]) + { + case '0': + /* C locale; tested above. */ + return 0; + + case '1': + /* Locale encoding is ISO-8859-1 or ISO-8859-15. */ + { + /* U+00B2 SUPERSCRIPT TWO */ + is = for_character ("\262", 1); + ASSERT (is == 0); + #if !(defined __GLIBC__ || (defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __NetBSD__ || defined __sun || defined __CYGWIN__ || (defined _WIN32 && !defined __CYGWIN__)) + /* U+00B5 MICRO SIGN */ + is = for_character ("\265", 1); + ASSERT (is == 0); + #endif + /* U+00C9 LATIN CAPITAL LETTER E WITH ACUTE */ + is = for_character ("\311", 1); + ASSERT (is == 0); + #if !defined __CYGWIN__ + /* U+00DF LATIN SMALL LETTER SHARP S */ + is = for_character ("\337", 1); + ASSERT (is != 0); + #endif + /* U+00E9 LATIN SMALL LETTER E WITH ACUTE */ + is = for_character ("\351", 1); + ASSERT (is != 0); + /* U+00FF LATIN SMALL LETTER Y WITH DIAERESIS */ + is = for_character ("\377", 1); + ASSERT (is != 0); + } + return 0; + + case '2': + /* Locale encoding is EUC-JP. */ + { + /* U+00C9 LATIN CAPITAL LETTER E WITH ACUTE */ + is = for_character ("\217\252\261", 3); + ASSERT (is == 0); + #if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__ || defined __CYGWIN__) + /* U+00DF LATIN SMALL LETTER SHARP S */ + is = for_character ("\217\251\316", 3); + ASSERT (is != 0); + #endif + #if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__) + /* U+00E9 LATIN SMALL LETTER E WITH ACUTE */ + is = for_character ("\217\253\261", 3); + ASSERT (is != 0); + /* U+00FF LATIN SMALL LETTER Y WITH DIAERESIS */ + is = for_character ("\217\253\363", 3); + ASSERT (is != 0); + #endif + /* U+0141 LATIN CAPITAL LETTER L WITH STROKE */ + is = for_character ("\217\251\250", 3); + ASSERT (is == 0); + #if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__) + /* U+0142 LATIN SMALL LETTER L WITH STROKE */ + is = for_character ("\217\251\310", 3); + ASSERT (is != 0); + #endif + /* U+0429 CYRILLIC CAPITAL LETTER SHCHA */ + is = for_character ("\247\273", 2); + ASSERT (is == 0); + #if !(defined __FreeBSD__ || defined __DragonFly__) + /* U+0449 CYRILLIC SMALL LETTER SHCHA */ + is = for_character ("\247\353", 2); + ASSERT (is != 0); + #endif + /* U+3073 HIRAGANA LETTER BI */ + is = for_character ("\244\323", 2); + ASSERT (is == 0); + #if !defined __DragonFly__ + /* U+FF47 FULLWIDTH LATIN SMALL LETTER G */ + is = for_character ("\243\347", 2); + ASSERT (is != 0); + #endif + } + return 0; + + case '3': + /* Locale encoding is UTF-8. */ + { + /* U+00B2 SUPERSCRIPT TWO */ + is = for_character ("\302\262", 2); + ASSERT (is == 0); + #if !(defined __GLIBC__ || defined MUSL_LIBC || (defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__ || defined _AIX || defined __sun || defined __CYGWIN__ || (defined _WIN32 && !defined __CYGWIN__)) + /* U+00B5 MICRO SIGN */ + is = for_character ("\302\265", 2); + ASSERT (is == 0); + #endif + /* U+00C9 LATIN CAPITAL LETTER E WITH ACUTE */ + is = for_character ("\303\211", 2); + ASSERT (is == 0); + #if !defined __CYGWIN__ + /* U+00DF LATIN SMALL LETTER SHARP S */ + is = for_character ("\303\237", 2); + ASSERT (is != 0); + #endif + /* U+00E9 LATIN SMALL LETTER E WITH ACUTE */ + is = for_character ("\303\251", 2); + ASSERT (is != 0); + /* U+00FF LATIN SMALL LETTER Y WITH DIAERESIS */ + is = for_character ("\303\277", 2); + ASSERT (is != 0); + /* U+0141 LATIN CAPITAL LETTER L WITH STROKE */ + is = for_character ("\305\201", 2); + ASSERT (is == 0); + /* U+0142 LATIN SMALL LETTER L WITH STROKE */ + is = for_character ("\305\202", 2); + ASSERT (is != 0); + /* U+0429 CYRILLIC CAPITAL LETTER SHCHA */ + is = for_character ("\320\251", 2); + ASSERT (is == 0); + /* U+0449 CYRILLIC SMALL LETTER SHCHA */ + is = for_character ("\321\211", 2); + ASSERT (is != 0); + /* U+05D5 HEBREW LETTER VAV */ + is = for_character ("\327\225", 2); + ASSERT (is == 0); + /* U+3073 HIRAGANA LETTER BI */ + is = for_character ("\343\201\263", 3); + ASSERT (is == 0); + /* U+3162 HANGUL LETTER YI */ + is = for_character ("\343\205\242", 3); + ASSERT (is == 0); + /* U+FF47 FULLWIDTH LATIN SMALL LETTER G */ + is = for_character ("\357\275\207", 3); + ASSERT (is != 0); + /* U+FFDB HALFWIDTH HANGUL LETTER YI */ + is = for_character ("\357\277\233", 3); + ASSERT (is == 0); + /* U+10419 DESERET CAPITAL LETTER EF */ + is = for_character ("\360\220\220\231", 4); + ASSERT (is == 0); + #if !(defined __FreeBSD__ || defined __DragonFly__ || defined __sun) + /* U+10441 DESERET SMALL LETTER EF */ + is = for_character ("\360\220\221\201", 4); + ASSERT (is != 0); + #endif + /* U+E0041 TAG LATIN CAPITAL LETTER A */ + is = for_character ("\363\240\201\201", 4); + ASSERT (is == 0); + /* U+E0061 TAG LATIN SMALL LETTER A */ + is = for_character ("\363\240\201\241", 4); + ASSERT (is == 0); + } + return 0; + + case '4': + /* Locale encoding is GB18030. */ + #if (defined __GLIBC__ && __GLIBC__ == 2 && __GLIBC_MINOR__ >= 13 && __GLIBC_MINOR__ <= 15) || (GL_CHAR32_T_IS_UNICODE && (defined __FreeBSD__ || defined __NetBSD__ || defined __sun)) + fputs ("Skipping test: The GB18030 converter in this system's iconv is broken.\n", stderr); + return 77; + #endif + { + /* U+00B2 SUPERSCRIPT TWO */ + is = for_character ("\201\060\205\065", 4); + ASSERT (is == 0); + #if !(defined __GLIBC__ || (defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __NetBSD__) + /* U+00B5 MICRO SIGN */ + is = for_character ("\201\060\205\070", 4); + ASSERT (is == 0); + #endif + /* U+00C9 LATIN CAPITAL LETTER E WITH ACUTE */ + is = for_character ("\201\060\207\067", 4); + ASSERT (is == 0); + #if !(defined __FreeBSD__ || defined __DragonFly__ || defined __sun) + /* U+00DF LATIN SMALL LETTER SHARP S */ + is = for_character ("\201\060\211\070", 4); + ASSERT (is != 0); + #endif + #if !defined __DragonFly__ + /* U+00E9 LATIN SMALL LETTER E WITH ACUTE */ + is = for_character ("\250\246", 2); + ASSERT (is != 0); + #endif + #if !(defined __FreeBSD__ || defined __DragonFly__ || defined __sun) + /* U+00FF LATIN SMALL LETTER Y WITH DIAERESIS */ + is = for_character ("\201\060\213\067", 4); + ASSERT (is != 0); + #endif + /* U+0141 LATIN CAPITAL LETTER L WITH STROKE */ + is = for_character ("\201\060\221\071", 4); + ASSERT (is == 0); + #if !(defined __FreeBSD__ || defined __DragonFly__ || defined __sun) + /* U+0142 LATIN SMALL LETTER L WITH STROKE */ + is = for_character ("\201\060\222\060", 4); + ASSERT (is != 0); + #endif + /* U+0429 CYRILLIC CAPITAL LETTER SHCHA */ + is = for_character ("\247\273", 2); + ASSERT (is == 0); + #if !(defined __FreeBSD__ || defined __DragonFly__) + /* U+0449 CYRILLIC SMALL LETTER SHCHA */ + is = for_character ("\247\353", 2); + ASSERT (is != 0); + #endif + /* U+05D5 HEBREW LETTER VAV */ + is = for_character ("\201\060\371\067", 4); + ASSERT (is == 0); + /* U+3073 HIRAGANA LETTER BI */ + is = for_character ("\244\323", 2); + ASSERT (is == 0); + /* U+3162 HANGUL LETTER YI */ + is = for_character ("\201\071\256\062", 4); + ASSERT (is == 0); + #if !defined __DragonFly__ + /* U+FF47 FULLWIDTH LATIN SMALL LETTER G */ + is = for_character ("\243\347", 2); + ASSERT (is != 0); + #endif + /* U+FFDB HALFWIDTH HANGUL LETTER YI */ + is = for_character ("\204\061\241\071", 4); + ASSERT (is == 0); + /* U+10419 DESERET CAPITAL LETTER EF */ + is = for_character ("\220\060\351\071", 4); + ASSERT (is == 0); + #if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__ || defined __sun) + /* U+10441 DESERET SMALL LETTER EF */ + is = for_character ("\220\060\355\071", 4); + ASSERT (is != 0); + #endif + /* U+E0041 TAG LATIN CAPITAL LETTER A */ + is = for_character ("\323\066\234\063", 4); + ASSERT (is == 0); + /* U+E0061 TAG LATIN SMALL LETTER A */ + is = for_character ("\323\066\237\065", 4); + ASSERT (is == 0); + } + return 0; + + } + + return 1; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32islower.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32islower.sh new file mode 100755 index 00000000..f8b9840c --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32islower.sh @@ -0,0 +1,42 @@ +#!/bin/sh + +# Test in the POSIX locale. +LC_ALL=C ${CHECKER} ./test-c32islower${EXEEXT} 0 || exit 1 +LC_ALL=POSIX ${CHECKER} ./test-c32islower${EXEEXT} 0 || exit 1 + +# Test in an ISO-8859-1 or ISO-8859-15 locale. +: "${LOCALE_FR=fr_FR}" +if test $LOCALE_FR != none; then + LC_ALL=$LOCALE_FR \ + ${CHECKER} ./test-c32islower${EXEEXT} 1 \ + || exit 1 +fi + +# Test whether a specific EUC-JP locale is installed. +: "${LOCALE_JA=ja_JP}" +if test $LOCALE_JA != none; then + LC_ALL=$LOCALE_JA \ + ${CHECKER} ./test-c32islower${EXEEXT} 2 \ + || exit 1 +fi + +# Test whether a specific UTF-8 locale is installed. +: "${LOCALE_FR_UTF8=fr_FR.UTF-8}" +if test $LOCALE_FR_UTF8 != none; then + LC_ALL=$LOCALE_FR_UTF8 \ + ${CHECKER} ./test-c32islower${EXEEXT} 3 \ + || exit 1 +fi + +# Test whether a specific GB18030 locale is installed. +: "${LOCALE_ZH_CN=zh_CN.GB18030}" +if test $LOCALE_ZH_CN != none; then + LC_ALL=$LOCALE_ZH_CN \ + ${CHECKER} ./test-c32islower${EXEEXT} 4 + case $? in + 0 | 77) ;; + *) exit 1 ;; + esac +fi + +exit 0 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isprint.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isprint.c new file mode 100644 index 00000000..d28eb492 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isprint.c @@ -0,0 +1,250 @@ +/* Test of c32isprint() function. + Copyright (C) 2020-2024 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 . */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (c32isprint, int, (wint_t)); + +#include +#include +#include +#include + +#include "macros.h" + +/* Returns the value of c32isprint for the multibyte character s[0..n-1]. */ +static int +for_character (const char *s, size_t n) +{ + mbstate_t state; + char32_t wc; + size_t ret; + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, s, n, &state); + ASSERT (ret == n); + + return c32isprint (wc); +} + +int +main (int argc, char *argv[]) +{ + int is; + char buf[4]; + + /* configure should already have checked that the locale is supported. */ + if (setlocale (LC_ALL, "") == NULL) + return 1; + + /* Test WEOF. */ + is = c32isprint (WEOF); + ASSERT (is == 0); + + /* Test single-byte characters. + POSIX specifies in + + no explicit list of printable characters. */ + { + int c; + + for (c = 0; c < 0x100; c++) + switch (c) + { + case '\t': case '\v': case '\f': + case ' ': case '!': case '"': case '#': case '%': + case '&': case '\'': case '(': case ')': case '*': + case '+': case ',': case '-': case '.': case '/': + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + case ':': case ';': case '<': case '=': case '>': + case '?': + case 'A': case 'B': case 'C': case 'D': case 'E': + case 'F': case 'G': case 'H': case 'I': case 'J': + case 'K': case 'L': case 'M': case 'N': case 'O': + case 'P': case 'Q': case 'R': case 'S': case 'T': + case 'U': case 'V': case 'W': case 'X': case 'Y': + case 'Z': + case '[': case '\\': case ']': case '^': case '_': + case 'a': case 'b': case 'c': case 'd': case 'e': + case 'f': case 'g': case 'h': case 'i': case 'j': + case 'k': case 'l': case 'm': case 'n': case 'o': + case 'p': case 'q': case 'r': case 's': case 't': + case 'u': case 'v': case 'w': case 'x': case 'y': + case 'z': case '{': case '|': case '}': case '~': + /* c is in the ISO C "basic character set". */ + buf[0] = (unsigned char) c; + is = for_character (buf, 1); + switch (c) + { + case '\t': case '\v': case '\f': + ASSERT (is == 0); + break; + default: + ASSERT (is != 0); + break; + } + break; + } + } + + if (argc > 1) + switch (argv[1][0]) + { + case '0': + /* C locale; tested above. */ + return 0; + + case '1': + /* Locale encoding is ISO-8859-1 or ISO-8859-15. */ + { + /* U+007F */ + is = for_character ("\177", 1); + ASSERT (is == 0); + #if !(defined __FreeBSD__ || defined __DragonFly__ || defined __sgi || (defined _WIN32 && !defined __CYGWIN__)) + /* U+00A0 NO-BREAK SPACE */ + is = for_character ("\240", 1); + ASSERT (is != 0); + #endif + #if !(defined __FreeBSD__ || defined __DragonFly__) + /* U+00B8 CEDILLA */ + is = for_character ("\270", 1); + ASSERT (is != 0); + #endif + } + return 0; + + case '2': + /* Locale encoding is EUC-JP. */ + { + /* U+007F */ + is = for_character ("\177", 1); + ASSERT (is == 0); + #if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__) + /* U+00B8 CEDILLA */ + is = for_character ("\217\242\261", 3); + ASSERT (is != 0); + /* U+3000 IDEOGRAPHIC SPACE */ + is = for_character ("\241\241", 2); + ASSERT (is != 0); + #endif + } + return 0; + + case '3': + /* Locale encoding is UTF-8. */ + { + /* U+007F */ + is = for_character ("\177", 1); + ASSERT (is == 0); + #if !(defined __FreeBSD__ || defined __DragonFly__ || defined __sun || (defined _WIN32 && !defined __CYGWIN__)) + /* U+00A0 NO-BREAK SPACE */ + is = for_character ("\302\240", 2); + ASSERT (is != 0); + #endif + /* U+00B8 CEDILLA */ + is = for_character ("\302\270", 2); + ASSERT (is != 0); + #if !(defined __FreeBSD__ || defined __DragonFly__ || defined __sun || (defined _WIN32 && !defined __CYGWIN__)) + /* U+2002 EN SPACE */ + is = for_character ("\342\200\202", 3); + ASSERT (is != 0); + #endif + #if !(defined __GLIBC__ || defined MUSL_LIBC || (defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __NetBSD__ || defined _AIX || defined __sun || defined __CYGWIN__) + /* U+202E RIGHT-TO-LEFT OVERRIDE */ + is = for_character ("\342\200\256", 3); + ASSERT (is == 0); + #endif + #if !(defined __FreeBSD__ || defined __DragonFly__ || defined __sun) + /* U+3000 IDEOGRAPHIC SPACE */ + is = for_character ("\343\200\200", 3); + ASSERT (is != 0); + #endif + #if !(defined __GLIBC__ || defined MUSL_LIBC || (defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __NetBSD__ || defined _AIX || defined __sun || defined __CYGWIN__ || (defined _WIN32 && !defined __CYGWIN__)) + /* U+FEFF ZERO WIDTH NO-BREAK SPACE */ + is = for_character ("\357\273\277", 3); + ASSERT (is == 0); + #endif + #if !defined __sun + /* U+20000 */ + is = for_character ("\360\240\200\200", 4); + ASSERT (is != 0); + #endif + #if !(defined __GLIBC__ || defined MUSL_LIBC || (defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __NetBSD__ || defined _AIX || defined __sun || defined __CYGWIN__ || (defined _WIN32 && !defined __CYGWIN__)) + /* U+E0001 LANGUAGE TAG */ + is = for_character ("\363\240\200\201", 4); + ASSERT (is == 0); + #endif + } + return 0; + + case '4': + /* Locale encoding is GB18030. */ + #if (defined __GLIBC__ && __GLIBC__ == 2 && __GLIBC_MINOR__ >= 13 && __GLIBC_MINOR__ <= 15) || (GL_CHAR32_T_IS_UNICODE && (defined __NetBSD__ || defined __sun)) + fputs ("Skipping test: The GB18030 converter in this system's iconv is broken.\n", stderr); + return 77; + #endif + { + /* U+007F */ + is = for_character ("\177", 1); + ASSERT (is == 0); + #if !(defined __FreeBSD__ || defined __DragonFly__ || defined __sun) + /* U+00A0 NO-BREAK SPACE */ + is = for_character ("\201\060\204\062", 4); + ASSERT (is != 0); + /* U+00B8 CEDILLA */ + is = for_character ("\201\060\206\060", 4); + ASSERT (is != 0); + /* U+2002 EN SPACE */ + is = for_character ("\201\066\243\070", 4); + ASSERT (is != 0); + #endif + #if !(defined __GLIBC__ || (defined __APPLE__ && defined __MACH__) || defined __FreeBSD__) + /* U+202E RIGHT-TO-LEFT OVERRIDE */ + is = for_character ("\201\066\247\061", 4); + ASSERT (is == 0); + #endif + #if !(defined __FreeBSD__ || defined __DragonFly__) + /* U+3000 IDEOGRAPHIC SPACE */ + is = for_character ("\241\241", 2); + ASSERT (is != 0); + #endif + #if !(defined __GLIBC__ || (defined __APPLE__ && defined __MACH__) || defined __FreeBSD__) + /* U+FEFF ZERO WIDTH NO-BREAK SPACE */ + is = for_character ("\204\061\225\063", 4); + ASSERT (is == 0); + #endif + #if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__ || defined __sun) + /* U+20000 */ + is = for_character ("\225\062\202\066", 4); + ASSERT (is != 0); + #endif + #if !(defined __GLIBC__ || (defined __APPLE__ && defined __MACH__) || defined __FreeBSD__) + /* U+E0001 LANGUAGE TAG */ + is = for_character ("\323\066\225\071", 4); + ASSERT (is == 0); + #endif + } + return 0; + + } + + return 1; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isprint.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isprint.sh new file mode 100755 index 00000000..d455413b --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isprint.sh @@ -0,0 +1,42 @@ +#!/bin/sh + +# Test in the POSIX locale. +LC_ALL=C ${CHECKER} ./test-c32isprint${EXEEXT} 0 || exit 1 +LC_ALL=POSIX ${CHECKER} ./test-c32isprint${EXEEXT} 0 || exit 1 + +# Test in an ISO-8859-1 or ISO-8859-15 locale. +: "${LOCALE_FR=fr_FR}" +if test $LOCALE_FR != none; then + LC_ALL=$LOCALE_FR \ + ${CHECKER} ./test-c32isprint${EXEEXT} 1 \ + || exit 1 +fi + +# Test whether a specific EUC-JP locale is installed. +: "${LOCALE_JA=ja_JP}" +if test $LOCALE_JA != none; then + LC_ALL=$LOCALE_JA \ + ${CHECKER} ./test-c32isprint${EXEEXT} 2 \ + || exit 1 +fi + +# Test whether a specific UTF-8 locale is installed. +: "${LOCALE_FR_UTF8=fr_FR.UTF-8}" +if test $LOCALE_FR_UTF8 != none; then + LC_ALL=$LOCALE_FR_UTF8 \ + ${CHECKER} ./test-c32isprint${EXEEXT} 3 \ + || exit 1 +fi + +# Test whether a specific GB18030 locale is installed. +: "${LOCALE_ZH_CN=zh_CN.GB18030}" +if test $LOCALE_ZH_CN != none; then + LC_ALL=$LOCALE_ZH_CN \ + ${CHECKER} ./test-c32isprint${EXEEXT} 4 + case $? in + 0 | 77) ;; + *) exit 1 ;; + esac +fi + +exit 0 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32ispunct.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32ispunct.c new file mode 100644 index 00000000..1b9f8e3b --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32ispunct.c @@ -0,0 +1,330 @@ +/* Test of c32ispunct() function. + Copyright (C) 2020-2024 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 . */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (c32ispunct, int, (wint_t)); + +#include +#include +#include +#include + +#include "macros.h" + +/* Returns the value of c32ispunct for the multibyte character s[0..n-1]. */ +static int +for_character (const char *s, size_t n) +{ + mbstate_t state; + char32_t wc; + size_t ret; + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, s, n, &state); + ASSERT (ret == n); + + return c32ispunct (wc); +} + +int +main (int argc, char *argv[]) +{ + int is; + char buf[4]; + + /* configure should already have checked that the locale is supported. */ + if (setlocale (LC_ALL, "") == NULL) + return 1; + + /* Test WEOF. */ + is = c32ispunct (WEOF); + ASSERT (is == 0); + + /* Test single-byte characters. + POSIX specifies in + + no explicit list of punctuation or symbol characters. */ + { + int c; + + for (c = 0; c < 0x100; c++) + switch (c) + { + case '\t': case '\v': case '\f': + case ' ': case '!': case '"': case '#': case '%': + case '&': case '\'': case '(': case ')': case '*': + case '+': case ',': case '-': case '.': case '/': + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + case ':': case ';': case '<': case '=': case '>': + case '?': + case 'A': case 'B': case 'C': case 'D': case 'E': + case 'F': case 'G': case 'H': case 'I': case 'J': + case 'K': case 'L': case 'M': case 'N': case 'O': + case 'P': case 'Q': case 'R': case 'S': case 'T': + case 'U': case 'V': case 'W': case 'X': case 'Y': + case 'Z': + case '[': case '\\': case ']': case '^': case '_': + case 'a': case 'b': case 'c': case 'd': case 'e': + case 'f': case 'g': case 'h': case 'i': case 'j': + case 'k': case 'l': case 'm': case 'n': case 'o': + case 'p': case 'q': case 'r': case 's': case 't': + case 'u': case 'v': case 'w': case 'x': case 'y': + case 'z': case '{': case '|': case '}': case '~': + /* c is in the ISO C "basic character set". */ + buf[0] = (unsigned char) c; + is = for_character (buf, 1); + switch (c) + { + case ' ': + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + case 'A': case 'B': case 'C': case 'D': case 'E': + case 'F': case 'G': case 'H': case 'I': case 'J': + case 'K': case 'L': case 'M': case 'N': case 'O': + case 'P': case 'Q': case 'R': case 'S': case 'T': + case 'U': case 'V': case 'W': case 'X': case 'Y': + case 'Z': + case 'a': case 'b': case 'c': case 'd': case 'e': + case 'f': case 'g': case 'h': case 'i': case 'j': + case 'k': case 'l': case 'm': case 'n': case 'o': + case 'p': case 'q': case 'r': case 's': case 't': + case 'u': case 'v': case 'w': case 'x': case 'y': + case 'z': + /* c is an alphanumeric or space character. */ + ASSERT (is == 0); + break; + case '!': case '"': case '#': case '%': + case '&': case '\'': case '(': case ')': case '*': + case '+': case ',': case '-': case '.': case '/': + case ':': case ';': case '<': case '=': case '>': + case '?': + case '[': case '\\': case ']': case '^': case '_': + case '{': case '|': case '}': case '~': + /* These characters are usually expected to be punctuation or + symbol characters. */ + ASSERT (is != 0); + break; + default: + ASSERT (is == 0); + break; + } + break; + } + } + + if (argc > 1) + switch (argv[1][0]) + { + case '0': + /* C locale; tested above. */ + /* These characters are not in the ISO C "basic character set", but + are nevertheless usually expected to be punctuation or symbol + characters. */ + is = for_character ("$", 1); + ASSERT (is != 0); + is = for_character ("@", 1); + ASSERT (is != 0); + is = for_character ("`", 1); + ASSERT (is != 0); + return 0; + + case '1': + /* Locale encoding is ISO-8859-1 or ISO-8859-15. */ + { + #if !(defined __FreeBSD__ || defined __DragonFly__) + /* U+00BF INVERTED QUESTION MARK */ + is = for_character ("\277", 1); + ASSERT (is != 0); + #endif + #if !(defined __FreeBSD__ || defined __DragonFly__ || defined __sun) + /* U+00D7 MULTIPLICATION SIGN */ + is = for_character ("\327", 1); + ASSERT (is != 0); + #endif + /* U+00D8 LATIN CAPITAL LETTER O WITH STROKE */ + is = for_character ("\330", 1); + ASSERT (is == 0); + /* U+00DF LATIN SMALL LETTER SHARP S */ + is = for_character ("\337", 1); + ASSERT (is == 0); + } + return 0; + + case '2': + /* Locale encoding is EUC-JP. */ + { + #if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__) + /* U+00BF INVERTED QUESTION MARK */ + is = for_character ("\217\242\304", 3); + ASSERT (is != 0); + #endif + #if !(defined __FreeBSD__ || defined __DragonFly__) + /* U+00D7 MULTIPLICATION SIGN */ + is = for_character ("\241\337", 2); + ASSERT (is != 0); + #endif + /* U+00D8 LATIN CAPITAL LETTER O WITH STROKE */ + is = for_character ("\217\251\254", 3); + ASSERT (is == 0); + /* U+00DF LATIN SMALL LETTER SHARP S */ + is = for_character ("\217\251\316", 3); + ASSERT (is == 0); + /* U+0141 LATIN CAPITAL LETTER L WITH STROKE */ + is = for_character ("\217\251\250", 3); + ASSERT (is == 0); + #if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__) + /* U+2192 RIGHTWARDS ARROW */ + is = for_character ("\242\252", 2); + ASSERT (is != 0); + #endif + #if !(defined __FreeBSD__ || defined __DragonFly__) + /* U+3001 IDEOGRAPHIC COMMA */ + is = for_character ("\241\242", 2); + ASSERT (is != 0); + #endif + /* U+FF11 FULLWIDTH DIGIT ONE */ + is = for_character ("\243\261", 2); + ASSERT (is == 0); + /* U+FF4D FULLWIDTH LATIN SMALL LETTER M */ + is = for_character ("\243\355", 2); + ASSERT (is == 0); + } + return 0; + + case '3': + /* Locale encoding is UTF-8. */ + { + /* U+00BF INVERTED QUESTION MARK */ + is = for_character ("\302\277", 2); + ASSERT (is != 0); + #if !(defined __FreeBSD__ || defined __DragonFly__ || defined __sun) + /* U+00D7 MULTIPLICATION SIGN */ + is = for_character ("\303\227", 2); + ASSERT (is != 0); + #endif + /* U+00D8 LATIN CAPITAL LETTER O WITH STROKE */ + is = for_character ("\303\230", 2); + ASSERT (is == 0); + /* U+00DF LATIN SMALL LETTER SHARP S */ + is = for_character ("\303\237", 2); + ASSERT (is == 0); + /* U+0141 LATIN CAPITAL LETTER L WITH STROKE */ + is = for_character ("\305\201", 2); + ASSERT (is == 0); + /* U+05F3 HEBREW PUNCTUATION GERESH */ + is = for_character ("\327\263", 2); + ASSERT (is != 0); + #if !(defined __FreeBSD__ || defined __DragonFly__ || defined __sun || (defined _WIN32 && !defined __CYGWIN__)) + /* U+2192 RIGHTWARDS ARROW */ + is = for_character ("\342\206\222", 3); + ASSERT (is != 0); + #endif + /* U+3001 IDEOGRAPHIC COMMA */ + is = for_character ("\343\200\201", 3); + ASSERT (is != 0); + /* U+FF11 FULLWIDTH DIGIT ONE */ + is = for_character ("\357\274\221", 3); + ASSERT (is == 0); + /* U+FF4D FULLWIDTH LATIN SMALL LETTER M */ + is = for_character ("\357\275\215", 3); + ASSERT (is == 0); + /* U+10330 GOTHIC LETTER AHSA */ + is = for_character ("\360\220\214\260", 4); + ASSERT (is == 0); + #if !(defined __FreeBSD__ || defined __DragonFly__ || defined __sun) + /* U+1D100 MUSICAL SYMBOL SINGLE BARLINE */ + is = for_character ("\360\235\204\200", 4); + ASSERT (is != 0); + #endif + #if !(defined __GLIBC__ || (defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __NetBSD__ || defined _AIX || defined __sun || defined __CYGWIN__ || (defined _WIN32 && !defined __CYGWIN__)) + /* U+E003A TAG COLON */ + is = for_character ("\363\240\200\272", 4); + ASSERT (is == 0); + #endif + } + return 0; + + case '4': + /* Locale encoding is GB18030. */ + #if (defined __GLIBC__ && __GLIBC__ == 2 && __GLIBC_MINOR__ >= 13 && __GLIBC_MINOR__ <= 15) || (GL_CHAR32_T_IS_UNICODE && (defined __FreeBSD__ || defined __NetBSD__ || defined __sun)) + fputs ("Skipping test: The GB18030 converter in this system's iconv is broken.\n", stderr); + return 77; + #endif + { + #if !(defined __FreeBSD__ || defined __DragonFly__ || defined __sun) + /* U+00BF INVERTED QUESTION MARK */ + is = for_character ("\201\060\206\067", 4); + ASSERT (is != 0); + #endif + #if !(defined __FreeBSD__ || defined __DragonFly__) + /* U+00D7 MULTIPLICATION SIGN */ + is = for_character ("\241\301", 2); + ASSERT (is != 0); + #endif + /* U+00D8 LATIN CAPITAL LETTER O WITH STROKE */ + is = for_character ("\201\060\211\061", 4); + ASSERT (is == 0); + /* U+00DF LATIN SMALL LETTER SHARP S */ + is = for_character ("\201\060\211\070", 4); + ASSERT (is == 0); + /* U+0141 LATIN CAPITAL LETTER L WITH STROKE */ + is = for_character ("\201\060\221\071", 4); + ASSERT (is == 0); + #if !(defined __FreeBSD__ || defined __DragonFly__ || defined __sun) + /* U+05F3 HEBREW PUNCTUATION GERESH */ + is = for_character ("\201\060\374\067", 4); + ASSERT (is != 0); + #endif + #if !(defined __FreeBSD__ || defined __DragonFly__) + /* U+2192 RIGHTWARDS ARROW */ + is = for_character ("\241\372", 2); + ASSERT (is != 0); + /* U+3001 IDEOGRAPHIC COMMA */ + is = for_character ("\241\242", 2); + ASSERT (is != 0); + #endif + /* U+FF11 FULLWIDTH DIGIT ONE */ + is = for_character ("\243\261", 2); + ASSERT (is == 0); + /* U+FF4D FULLWIDTH LATIN SMALL LETTER M */ + is = for_character ("\243\355", 2); + ASSERT (is == 0); + /* U+10330 GOTHIC LETTER AHSA */ + is = for_character ("\220\060\322\066", 4); + ASSERT (is == 0); + #if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__ || defined __sun) + /* U+1D100 MUSICAL SYMBOL SINGLE BARLINE */ + is = for_character ("\224\062\273\064", 4); + ASSERT (is != 0); + #endif + #if !(defined __GLIBC__ || (defined __APPLE__ && defined __MACH__) || defined __FreeBSD__) + /* U+E003A TAG COLON */ + is = for_character ("\323\066\233\066", 4); + ASSERT (is == 0); + #endif + } + return 0; + + } + + return 1; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32ispunct.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32ispunct.sh new file mode 100755 index 00000000..d818bcf7 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32ispunct.sh @@ -0,0 +1,42 @@ +#!/bin/sh + +# Test in the POSIX locale. +LC_ALL=C ${CHECKER} ./test-c32ispunct${EXEEXT} 0 || exit 1 +LC_ALL=POSIX ${CHECKER} ./test-c32ispunct${EXEEXT} 0 || exit 1 + +# Test in an ISO-8859-1 or ISO-8859-15 locale. +: "${LOCALE_FR=fr_FR}" +if test $LOCALE_FR != none; then + LC_ALL=$LOCALE_FR \ + ${CHECKER} ./test-c32ispunct${EXEEXT} 1 \ + || exit 1 +fi + +# Test whether a specific EUC-JP locale is installed. +: "${LOCALE_JA=ja_JP}" +if test $LOCALE_JA != none; then + LC_ALL=$LOCALE_JA \ + ${CHECKER} ./test-c32ispunct${EXEEXT} 2 \ + || exit 1 +fi + +# Test whether a specific UTF-8 locale is installed. +: "${LOCALE_FR_UTF8=fr_FR.UTF-8}" +if test $LOCALE_FR_UTF8 != none; then + LC_ALL=$LOCALE_FR_UTF8 \ + ${CHECKER} ./test-c32ispunct${EXEEXT} 3 \ + || exit 1 +fi + +# Test whether a specific GB18030 locale is installed. +: "${LOCALE_ZH_CN=zh_CN.GB18030}" +if test $LOCALE_ZH_CN != none; then + LC_ALL=$LOCALE_ZH_CN \ + ${CHECKER} ./test-c32ispunct${EXEEXT} 4 + case $? in + 0 | 77) ;; + *) exit 1 ;; + esac +fi + +exit 0 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isspace.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isspace.c new file mode 100644 index 00000000..15cf387d --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isspace.c @@ -0,0 +1,198 @@ +/* Test of c32isspace() function. + Copyright (C) 2020-2024 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 . */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (c32isspace, int, (wint_t)); + +#include +#include +#include +#include + +#include "macros.h" + +/* Returns the value of c32isspace for the multibyte character s[0..n-1]. */ +static int +for_character (const char *s, size_t n) +{ + mbstate_t state; + char32_t wc; + size_t ret; + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, s, n, &state); + ASSERT (ret == n); + + return c32isspace (wc); +} + +int +main (int argc, char *argv[]) +{ + int is; + char buf[4]; + + /* configure should already have checked that the locale is supported. */ + if (setlocale (LC_ALL, "") == NULL) + return 1; + + /* Test WEOF. */ + is = c32isspace (WEOF); + ASSERT (is == 0); + + /* Test single-byte characters. + POSIX specifies in + + that + - in all locales, the white-space characters include the , + , , , , + characters, + - in the "POSIX" locale (which is usually the same as the "C" locale), + the white-space characters include only the ASCII , , + , , , characters. */ + { + int c; + + for (c = 0; c < 0x100; c++) + switch (c) + { + case '\f': case '\n': case '\r': case '\t': case '\v': + case ' ': case '!': case '"': case '#': case '%': + case '&': case '\'': case '(': case ')': case '*': + case '+': case ',': case '-': case '.': case '/': + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + case ':': case ';': case '<': case '=': case '>': + case '?': + case 'A': case 'B': case 'C': case 'D': case 'E': + case 'F': case 'G': case 'H': case 'I': case 'J': + case 'K': case 'L': case 'M': case 'N': case 'O': + case 'P': case 'Q': case 'R': case 'S': case 'T': + case 'U': case 'V': case 'W': case 'X': case 'Y': + case 'Z': + case '[': case '\\': case ']': case '^': case '_': + case 'a': case 'b': case 'c': case 'd': case 'e': + case 'f': case 'g': case 'h': case 'i': case 'j': + case 'k': case 'l': case 'm': case 'n': case 'o': + case 'p': case 'q': case 'r': case 's': case 't': + case 'u': case 'v': case 'w': case 'x': case 'y': + case 'z': case '{': case '|': case '}': case '~': + /* c is in the ISO C "basic character set" or one of the explicitly + mentioned white-space characters. */ + buf[0] = (unsigned char) c; + is = for_character (buf, 1); + switch (c) + { + case ' ': case '\f': case '\n': case '\r': case '\t': case '\v': + ASSERT (is != 0); + break; + default: + ASSERT (is == 0); + break; + } + break; + } + } + + if (argc > 1) + switch (argv[1][0]) + { + case '0': + /* C locale; tested above. */ + return 0; + + case '1': + /* Locale encoding is ISO-8859-1 or ISO-8859-15. */ + { + /* U+00B7 MIDDLE DOT */ + is = for_character ("\267", 1); + ASSERT (is == 0); + } + return 0; + + case '2': + /* Locale encoding is EUC-JP. */ + { + #if !(defined __FreeBSD__ || defined __DragonFly__) + /* U+3000 IDEOGRAPHIC SPACE */ + is = for_character ("\241\241", 2); + ASSERT (is != 0); + #endif + /* U+3001 IDEOGRAPHIC COMMA */ + is = for_character ("\241\242", 2); + ASSERT (is == 0); + } + return 0; + + case '3': + /* Locale encoding is UTF-8. */ + { + /* U+00B7 MIDDLE DOT */ + is = for_character ("\302\267", 2); + ASSERT (is == 0); + /* U+2002 EN SPACE */ + is = for_character ("\342\200\202", 3); + ASSERT (is != 0); + /* U+3000 IDEOGRAPHIC SPACE */ + is = for_character ("\343\200\200", 3); + ASSERT (is != 0); + /* U+3001 IDEOGRAPHIC COMMA */ + is = for_character ("\343\200\201", 3); + ASSERT (is == 0); + /* U+E0020 TAG SPACE */ + is = for_character ("\363\240\200\240", 4); + ASSERT (is == 0); + } + return 0; + + case '4': + /* Locale encoding is GB18030. */ + #if (defined __GLIBC__ && __GLIBC__ == 2 && __GLIBC_MINOR__ >= 13 && __GLIBC_MINOR__ <= 15) || (GL_CHAR32_T_IS_UNICODE && (defined __FreeBSD__ || defined __NetBSD__ || defined __sun)) + fputs ("Skipping test: The GB18030 converter in this system's iconv is broken.\n", stderr); + return 77; + #endif + { + /* U+00B7 MIDDLE DOT */ + is = for_character ("\241\244", 2); + ASSERT (is == 0); + #if !(defined __FreeBSD__ || defined __DragonFly__ || defined __sun) + /* U+2002 EN SPACE */ + is = for_character ("\201\066\243\070", 4); + ASSERT (is != 0); + #endif + #if !(defined __FreeBSD__ || defined __DragonFly__) + /* U+3000 IDEOGRAPHIC SPACE */ + is = for_character ("\241\241", 2); + ASSERT (is != 0); + #endif + /* U+3001 IDEOGRAPHIC COMMA */ + is = for_character ("\241\242", 2); + ASSERT (is == 0); + /* U+E0020 TAG SPACE */ + is = for_character ("\323\066\231\060", 4); + ASSERT (is == 0); + } + return 0; + + } + + return 1; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isspace.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isspace.sh new file mode 100755 index 00000000..a704d86b --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isspace.sh @@ -0,0 +1,42 @@ +#!/bin/sh + +# Test in the POSIX locale. +LC_ALL=C ${CHECKER} ./test-c32isspace${EXEEXT} 0 || exit 1 +LC_ALL=POSIX ${CHECKER} ./test-c32isspace${EXEEXT} 0 || exit 1 + +# Test in an ISO-8859-1 or ISO-8859-15 locale. +: "${LOCALE_FR=fr_FR}" +if test $LOCALE_FR != none; then + LC_ALL=$LOCALE_FR \ + ${CHECKER} ./test-c32isspace${EXEEXT} 1 \ + || exit 1 +fi + +# Test whether a specific EUC-JP locale is installed. +: "${LOCALE_JA=ja_JP}" +if test $LOCALE_JA != none; then + LC_ALL=$LOCALE_JA \ + ${CHECKER} ./test-c32isspace${EXEEXT} 2 \ + || exit 1 +fi + +# Test whether a specific UTF-8 locale is installed. +: "${LOCALE_FR_UTF8=fr_FR.UTF-8}" +if test $LOCALE_FR_UTF8 != none; then + LC_ALL=$LOCALE_FR_UTF8 \ + ${CHECKER} ./test-c32isspace${EXEEXT} 3 \ + || exit 1 +fi + +# Test whether a specific GB18030 locale is installed. +: "${LOCALE_ZH_CN=zh_CN.GB18030}" +if test $LOCALE_ZH_CN != none; then + LC_ALL=$LOCALE_ZH_CN \ + ${CHECKER} ./test-c32isspace${EXEEXT} 4 + case $? in + 0 | 77) ;; + *) exit 1 ;; + esac +fi + +exit 0 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isupper.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isupper.c new file mode 100644 index 00000000..178b0d19 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isupper.c @@ -0,0 +1,340 @@ +/* Test of c32isupper() function. + Copyright (C) 2020-2024 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 . */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (c32isupper, int, (wint_t)); + +#include +#include +#include +#include + +#include "macros.h" + +/* Returns the value of c32isupper for the multibyte character s[0..n-1]. */ +static int +for_character (const char *s, size_t n) +{ + mbstate_t state; + char32_t wc; + size_t ret; + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, s, n, &state); + ASSERT (ret == n); + + return c32isupper (wc); +} + +int +main (int argc, char *argv[]) +{ + int is; + char buf[4]; + + /* configure should already have checked that the locale is supported. */ + if (setlocale (LC_ALL, "") == NULL) + return 1; + + /* Test WEOF. */ + is = c32isupper (WEOF); + ASSERT (is == 0); + + /* Test single-byte characters. + POSIX specifies in + + that + - in all locales, the uppercase characters include the A ... Z + characters, + - in the "POSIX" locale (which is usually the same as the "C" locale), + the uppercase characters include only the ASCII A ... Z characters. + */ + { + int c; + + for (c = 0; c < 0x100; c++) + switch (c) + { + case '\t': case '\v': case '\f': + case ' ': case '!': case '"': case '#': case '%': + case '&': case '\'': case '(': case ')': case '*': + case '+': case ',': case '-': case '.': case '/': + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + case ':': case ';': case '<': case '=': case '>': + case '?': + case 'A': case 'B': case 'C': case 'D': case 'E': + case 'F': case 'G': case 'H': case 'I': case 'J': + case 'K': case 'L': case 'M': case 'N': case 'O': + case 'P': case 'Q': case 'R': case 'S': case 'T': + case 'U': case 'V': case 'W': case 'X': case 'Y': + case 'Z': + case '[': case '\\': case ']': case '^': case '_': + case 'a': case 'b': case 'c': case 'd': case 'e': + case 'f': case 'g': case 'h': case 'i': case 'j': + case 'k': case 'l': case 'm': case 'n': case 'o': + case 'p': case 'q': case 'r': case 's': case 't': + case 'u': case 'v': case 'w': case 'x': case 'y': + case 'z': case '{': case '|': case '}': case '~': + /* c is in the ISO C "basic character set". */ + buf[0] = (unsigned char) c; + is = for_character (buf, 1); + switch (c) + { + case 'A': case 'B': case 'C': case 'D': case 'E': + case 'F': case 'G': case 'H': case 'I': case 'J': + case 'K': case 'L': case 'M': case 'N': case 'O': + case 'P': case 'Q': case 'R': case 'S': case 'T': + case 'U': case 'V': case 'W': case 'X': case 'Y': + case 'Z': + ASSERT (is != 0); + break; + default: + ASSERT (is == 0); + break; + } + break; + } + } + + if (argc > 1) + switch (argv[1][0]) + { + case '0': + /* C locale; tested above. */ + return 0; + + case '1': + /* Locale encoding is ISO-8859-1 or ISO-8859-15. */ + { + /* U+00B2 SUPERSCRIPT TWO */ + is = for_character ("\262", 1); + ASSERT (is == 0); + /* U+00B5 MICRO SIGN */ + is = for_character ("\265", 1); + ASSERT (is == 0); + /* U+00C9 LATIN CAPITAL LETTER E WITH ACUTE */ + is = for_character ("\311", 1); + ASSERT (is != 0); + #if !defined __hpux + /* U+00DF LATIN SMALL LETTER SHARP S */ + is = for_character ("\337", 1); + ASSERT (is == 0); + #endif + /* U+00E9 LATIN SMALL LETTER E WITH ACUTE */ + is = for_character ("\351", 1); + ASSERT (is == 0); + /* U+00FF LATIN SMALL LETTER Y WITH DIAERESIS */ + is = for_character ("\377", 1); + ASSERT (is == 0); + } + return 0; + + case '2': + /* Locale encoding is EUC-JP. */ + { + #if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__) + /* U+00C9 LATIN CAPITAL LETTER E WITH ACUTE */ + is = for_character ("\217\252\261", 3); + ASSERT (is != 0); + #endif + /* U+00DF LATIN SMALL LETTER SHARP S */ + is = for_character ("\217\251\316", 3); + ASSERT (is == 0); + /* U+00E9 LATIN SMALL LETTER E WITH ACUTE */ + is = for_character ("\217\253\261", 3); + ASSERT (is == 0); + /* U+00FF LATIN SMALL LETTER Y WITH DIAERESIS */ + is = for_character ("\217\253\363", 3); + ASSERT (is == 0); + #if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__) + /* U+0141 LATIN CAPITAL LETTER L WITH STROKE */ + is = for_character ("\217\251\250", 3); + ASSERT (is != 0); + #endif + /* U+0142 LATIN SMALL LETTER L WITH STROKE */ + is = for_character ("\217\251\310", 3); + ASSERT (is == 0); + #if !(defined __FreeBSD__ || defined __DragonFly__) + /* U+0429 CYRILLIC CAPITAL LETTER SHCHA */ + is = for_character ("\247\273", 2); + ASSERT (is != 0); + #endif + /* U+0449 CYRILLIC SMALL LETTER SHCHA */ + is = for_character ("\247\353", 2); + ASSERT (is == 0); + /* U+3073 HIRAGANA LETTER BI */ + is = for_character ("\244\323", 2); + ASSERT (is == 0); + #if !defined __DragonFly__ + /* U+FF27 FULLWIDTH LATIN CAPITAL LETTER G */ + is = for_character ("\243\307", 2); + ASSERT (is != 0); + #endif + } + return 0; + + case '3': + /* Locale encoding is UTF-8. */ + { + /* U+00B2 SUPERSCRIPT TWO */ + is = for_character ("\302\262", 2); + ASSERT (is == 0); + /* U+00B5 MICRO SIGN */ + is = for_character ("\302\265", 2); + ASSERT (is == 0); + /* U+00C9 LATIN CAPITAL LETTER E WITH ACUTE */ + is = for_character ("\303\211", 2); + ASSERT (is != 0); + /* U+00DF LATIN SMALL LETTER SHARP S */ + is = for_character ("\303\237", 2); + ASSERT (is == 0); + /* U+00E9 LATIN SMALL LETTER E WITH ACUTE */ + is = for_character ("\303\251", 2); + ASSERT (is == 0); + /* U+00FF LATIN SMALL LETTER Y WITH DIAERESIS */ + is = for_character ("\303\277", 2); + ASSERT (is == 0); + /* U+0141 LATIN CAPITAL LETTER L WITH STROKE */ + is = for_character ("\305\201", 2); + ASSERT (is != 0); + /* U+0142 LATIN SMALL LETTER L WITH STROKE */ + is = for_character ("\305\202", 2); + ASSERT (is == 0); + /* U+0429 CYRILLIC CAPITAL LETTER SHCHA */ + is = for_character ("\320\251", 2); + ASSERT (is != 0); + /* U+0449 CYRILLIC SMALL LETTER SHCHA */ + is = for_character ("\321\211", 2); + ASSERT (is == 0); + /* U+05D5 HEBREW LETTER VAV */ + is = for_character ("\327\225", 2); + ASSERT (is == 0); + /* U+3073 HIRAGANA LETTER BI */ + is = for_character ("\343\201\263", 3); + ASSERT (is == 0); + /* U+3162 HANGUL LETTER YI */ + is = for_character ("\343\205\242", 3); + ASSERT (is == 0); + /* U+FF27 FULLWIDTH LATIN CAPITAL LETTER G */ + is = for_character ("\357\274\247", 3); + ASSERT (is != 0); + /* U+FFDB HALFWIDTH HANGUL LETTER YI */ + is = for_character ("\357\277\233", 3); + ASSERT (is == 0); + #if !(defined __FreeBSD__ || defined __DragonFly__ || defined __sun) + /* U+10419 DESERET CAPITAL LETTER EF */ + is = for_character ("\360\220\220\231", 4); + ASSERT (is != 0); + #endif + /* U+10441 DESERET SMALL LETTER EF */ + is = for_character ("\360\220\221\201", 4); + ASSERT (is == 0); + /* U+E0041 TAG LATIN CAPITAL LETTER A */ + is = for_character ("\363\240\201\201", 4); + ASSERT (is == 0); + /* U+E0061 TAG LATIN SMALL LETTER A */ + is = for_character ("\363\240\201\241", 4); + ASSERT (is == 0); + } + return 0; + + case '4': + /* Locale encoding is GB18030. */ + #if (defined __GLIBC__ && __GLIBC__ == 2 && __GLIBC_MINOR__ >= 13 && __GLIBC_MINOR__ <= 15) || (GL_CHAR32_T_IS_UNICODE && (defined __FreeBSD__ || defined __NetBSD__ || defined __sun)) + fputs ("Skipping test: The GB18030 converter in this system's iconv is broken.\n", stderr); + return 77; + #endif + { + /* U+00B2 SUPERSCRIPT TWO */ + is = for_character ("\201\060\205\065", 4); + ASSERT (is == 0); + /* U+00B5 MICRO SIGN */ + is = for_character ("\201\060\205\070", 4); + ASSERT (is == 0); + #if !(defined __FreeBSD__ || defined __DragonFly__ || defined __sun) + /* U+00C9 LATIN CAPITAL LETTER E WITH ACUTE */ + is = for_character ("\201\060\207\067", 4); + ASSERT (is != 0); + #endif + /* U+00DF LATIN SMALL LETTER SHARP S */ + is = for_character ("\201\060\211\070", 4); + ASSERT (is == 0); + /* U+00E9 LATIN SMALL LETTER E WITH ACUTE */ + is = for_character ("\250\246", 2); + ASSERT (is == 0); + /* U+00FF LATIN SMALL LETTER Y WITH DIAERESIS */ + is = for_character ("\201\060\213\067", 4); + ASSERT (is == 0); + #if !(defined __FreeBSD__ || defined __DragonFly__ || defined __sun) + /* U+0141 LATIN CAPITAL LETTER L WITH STROKE */ + is = for_character ("\201\060\221\071", 4); + ASSERT (is != 0); + #endif + /* U+0142 LATIN SMALL LETTER L WITH STROKE */ + is = for_character ("\201\060\222\060", 4); + ASSERT (is == 0); + #if !(defined __FreeBSD__ || defined __DragonFly__) + /* U+0429 CYRILLIC CAPITAL LETTER SHCHA */ + is = for_character ("\247\273", 2); + ASSERT (is != 0); + #endif + /* U+0449 CYRILLIC SMALL LETTER SHCHA */ + is = for_character ("\247\353", 2); + ASSERT (is == 0); + /* U+05D5 HEBREW LETTER VAV */ + is = for_character ("\201\060\371\067", 4); + ASSERT (is == 0); + /* U+3073 HIRAGANA LETTER BI */ + is = for_character ("\244\323", 2); + ASSERT (is == 0); + /* U+3162 HANGUL LETTER YI */ + is = for_character ("\201\071\256\062", 4); + ASSERT (is == 0); + #if !defined __DragonFly__ + /* U+FF27 FULLWIDTH LATIN CAPITAL LETTER G */ + is = for_character ("\243\307", 2); + ASSERT (is != 0); + #endif + /* U+FFDB HALFWIDTH HANGUL LETTER YI */ + is = for_character ("\204\061\241\071", 4); + ASSERT (is == 0); + #if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__ || defined __sun) + /* U+10419 DESERET CAPITAL LETTER EF */ + is = for_character ("\220\060\351\071", 4); + ASSERT (is != 0); + #endif + /* U+10441 DESERET SMALL LETTER EF */ + is = for_character ("\220\060\355\071", 4); + ASSERT (is == 0); + /* U+E0041 TAG LATIN CAPITAL LETTER A */ + is = for_character ("\323\066\234\063", 4); + ASSERT (is == 0); + /* U+E0061 TAG LATIN SMALL LETTER A */ + is = for_character ("\323\066\237\065", 4); + ASSERT (is == 0); + } + return 0; + + } + + return 1; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isupper.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isupper.sh new file mode 100755 index 00000000..ea3efcb8 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isupper.sh @@ -0,0 +1,42 @@ +#!/bin/sh + +# Test in the POSIX locale. +LC_ALL=C ${CHECKER} ./test-c32isupper${EXEEXT} 0 || exit 1 +LC_ALL=POSIX ${CHECKER} ./test-c32isupper${EXEEXT} 0 || exit 1 + +# Test in an ISO-8859-1 or ISO-8859-15 locale. +: "${LOCALE_FR=fr_FR}" +if test $LOCALE_FR != none; then + LC_ALL=$LOCALE_FR \ + ${CHECKER} ./test-c32isupper${EXEEXT} 1 \ + || exit 1 +fi + +# Test whether a specific EUC-JP locale is installed. +: "${LOCALE_JA=ja_JP}" +if test $LOCALE_JA != none; then + LC_ALL=$LOCALE_JA \ + ${CHECKER} ./test-c32isupper${EXEEXT} 2 \ + || exit 1 +fi + +# Test whether a specific UTF-8 locale is installed. +: "${LOCALE_FR_UTF8=fr_FR.UTF-8}" +if test $LOCALE_FR_UTF8 != none; then + LC_ALL=$LOCALE_FR_UTF8 \ + ${CHECKER} ./test-c32isupper${EXEEXT} 3 \ + || exit 1 +fi + +# Test whether a specific GB18030 locale is installed. +: "${LOCALE_ZH_CN=zh_CN.GB18030}" +if test $LOCALE_ZH_CN != none; then + LC_ALL=$LOCALE_ZH_CN \ + ${CHECKER} ./test-c32isupper${EXEEXT} 4 + case $? in + 0 | 77) ;; + *) exit 1 ;; + esac +fi + +exit 0 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isxdigit.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isxdigit.c new file mode 100644 index 00000000..0c266f47 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isxdigit.c @@ -0,0 +1,262 @@ +/* Test of c32isxdigit() function. + Copyright (C) 2020-2024 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 . */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (c32isxdigit, int, (wint_t)); + +#include +#include +#include +#include + +#include "macros.h" + +/* Returns the value of c32isxdigit for the multibyte character s[0..n-1]. */ +static int +for_character (const char *s, size_t n) +{ + mbstate_t state; + char32_t wc; + size_t ret; + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, s, n, &state); + ASSERT (ret == n); + + return c32isxdigit (wc); +} + +int +main (int argc, char *argv[]) +{ + int is; + char buf[4]; + + /* configure should already have checked that the locale is supported. */ + if (setlocale (LC_ALL, "") == NULL) + return 1; + + /* Test WEOF. */ + is = c32isxdigit (WEOF); + ASSERT (is == 0); + + /* Test single-byte characters. + ISO C 99 sections 7.25.2.1.12 and 6.4.4.1 specify that the hexadecimal + digits include only the ASCII 0 ... 9 A ... F a ... f characters. */ + { + int c; + + for (c = 0; c < 0x100; c++) + switch (c) + { + case '\t': case '\v': case '\f': + case ' ': case '!': case '"': case '#': case '%': + case '&': case '\'': case '(': case ')': case '*': + case '+': case ',': case '-': case '.': case '/': + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + case ':': case ';': case '<': case '=': case '>': + case '?': + case 'A': case 'B': case 'C': case 'D': case 'E': + case 'F': case 'G': case 'H': case 'I': case 'J': + case 'K': case 'L': case 'M': case 'N': case 'O': + case 'P': case 'Q': case 'R': case 'S': case 'T': + case 'U': case 'V': case 'W': case 'X': case 'Y': + case 'Z': + case '[': case '\\': case ']': case '^': case '_': + case 'a': case 'b': case 'c': case 'd': case 'e': + case 'f': case 'g': case 'h': case 'i': case 'j': + case 'k': case 'l': case 'm': case 'n': case 'o': + case 'p': case 'q': case 'r': case 's': case 't': + case 'u': case 'v': case 'w': case 'x': case 'y': + case 'z': case '{': case '|': case '}': case '~': + /* c is in the ISO C "basic character set". */ + buf[0] = (unsigned char) c; + is = for_character (buf, 1); + switch (c) + { + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': + case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': + ASSERT (is != 0); + break; + default: + ASSERT (is == 0); + break; + } + break; + } + } + + if (argc > 1) + switch (argv[1][0]) + { + case '0': + /* C locale; tested above. */ + return 0; + + case '1': + /* Locale encoding is ISO-8859-1 or ISO-8859-15. */ + { + /* U+00B2 SUPERSCRIPT TWO */ + is = for_character ("\262", 1); + ASSERT (is == 0); + /* U+00B3 SUPERSCRIPT THREE */ + is = for_character ("\263", 1); + ASSERT (is == 0); + /* U+00B9 SUPERSCRIPT ONE */ + is = for_character ("\271", 1); + ASSERT (is == 0); + } + return 0; + + case '2': + /* Locale encoding is EUC-JP. */ + { + /* U+FF11 FULLWIDTH DIGIT ONE */ + is = for_character ("\243\261", 2); + ASSERT (is == 0); + /* U+FF21 FULLWIDTH LATIN CAPITAL LETTER A */ + is = for_character ("\243\301", 2); + ASSERT (is == 0); + /* U+FF41 FULLWIDTH LATIN SMALL LETTER A */ + is = for_character ("\243\341", 2); + ASSERT (is == 0); + } + return 0; + + case '3': + /* Locale encoding is UTF-8. */ + { + /* U+00B2 SUPERSCRIPT TWO */ + is = for_character ("\302\262", 2); + ASSERT (is == 0); + /* U+00B3 SUPERSCRIPT THREE */ + is = for_character ("\302\263", 2); + ASSERT (is == 0); + /* U+00B9 SUPERSCRIPT ONE */ + is = for_character ("\302\271", 2); + ASSERT (is == 0); + /* U+0663 ARABIC-INDIC DIGIT THREE */ + is = for_character ("\331\243", 2); + ASSERT (is == 0); + /* U+2070 SUPERSCRIPT ZERO */ + is = for_character ("\342\201\260", 3); + ASSERT (is == 0); + /* U+2079 SUPERSCRIPT NINE */ + is = for_character ("\342\201\271", 3); + ASSERT (is == 0); + /* U+FF11 FULLWIDTH DIGIT ONE */ + is = for_character ("\357\274\221", 3); + ASSERT (is == 0); + /* U+FF21 FULLWIDTH LATIN CAPITAL LETTER A */ + is = for_character ("\357\274\241", 3); + ASSERT (is == 0); + /* U+FF41 FULLWIDTH LATIN SMALL LETTER A */ + is = for_character ("\357\275\201", 3); + ASSERT (is == 0); + /* U+1D7D1 MATHEMATICAL BOLD DIGIT THREE */ + is = for_character ("\360\235\237\221", 4); + ASSERT (is == 0); + /* U+1D7DB MATHEMATICAL DOUBLE-STRUCK DIGIT THREE */ + is = for_character ("\360\235\237\233", 4); + ASSERT (is == 0); + /* U+1D7E5 MATHEMATICAL SANS-SERIF DIGIT THREE */ + is = for_character ("\360\235\237\245", 4); + ASSERT (is == 0); + /* U+1D7EF MATHEMATICAL SANS-SERIF BOLD DIGIT THREE */ + is = for_character ("\360\235\237\257", 4); + ASSERT (is == 0); + /* U+1D7F9 MATHEMATICAL MONOSPACE DIGIT THREE */ + is = for_character ("\360\235\237\271", 4); + ASSERT (is == 0); + /* U+E0033 TAG DIGIT THREE */ + is = for_character ("\363\240\200\263", 4); + ASSERT (is == 0); + /* U+E0041 TAG LATIN CAPITAL LETTER A */ + is = for_character ("\363\240\201\201", 4); + ASSERT (is == 0); + } + return 0; + + case '4': + /* Locale encoding is GB18030. */ + #if (defined __GLIBC__ && __GLIBC__ == 2 && __GLIBC_MINOR__ >= 13 && __GLIBC_MINOR__ <= 15) || (GL_CHAR32_T_IS_UNICODE && (defined __FreeBSD__ || defined __NetBSD__ || defined __sun)) + fputs ("Skipping test: The GB18030 converter in this system's iconv is broken.\n", stderr); + return 77; + #endif + { + /* U+00B2 SUPERSCRIPT TWO */ + is = for_character ("\201\060\205\065", 4); + ASSERT (is == 0); + /* U+00B3 SUPERSCRIPT THREE */ + is = for_character ("\201\060\205\066", 4); + ASSERT (is == 0); + /* U+00B9 SUPERSCRIPT ONE */ + is = for_character ("\201\060\206\061", 4); + ASSERT (is == 0); + /* U+0663 ARABIC-INDIC DIGIT THREE */ + is = for_character ("\201\061\211\071", 4); + ASSERT (is == 0); + /* U+2070 SUPERSCRIPT ZERO */ + is = for_character ("\201\066\255\062", 4); + ASSERT (is == 0); + /* U+2079 SUPERSCRIPT NINE */ + is = for_character ("\201\066\256\061", 4); + ASSERT (is == 0); + /* U+FF11 FULLWIDTH DIGIT ONE */ + is = for_character ("\243\261", 2); + ASSERT (is == 0); + /* U+FF21 FULLWIDTH LATIN CAPITAL LETTER A */ + is = for_character ("\243\301", 2); + ASSERT (is == 0); + /* U+FF41 FULLWIDTH LATIN SMALL LETTER A */ + is = for_character ("\243\341", 2); + ASSERT (is == 0); + /* U+1D7D1 MATHEMATICAL BOLD DIGIT THREE */ + is = for_character ("\224\063\353\071", 4); + ASSERT (is == 0); + /* U+1D7DB MATHEMATICAL DOUBLE-STRUCK DIGIT THREE */ + is = for_character ("\224\063\354\071", 4); + ASSERT (is == 0); + /* U+1D7E5 MATHEMATICAL SANS-SERIF DIGIT THREE */ + is = for_character ("\224\063\355\071", 4); + ASSERT (is == 0); + /* U+1D7EF MATHEMATICAL SANS-SERIF BOLD DIGIT THREE */ + is = for_character ("\224\063\356\071", 4); + ASSERT (is == 0); + /* U+1D7F9 MATHEMATICAL MONOSPACE DIGIT THREE */ + is = for_character ("\224\063\357\071", 4); + ASSERT (is == 0); + /* U+E0033 TAG DIGIT THREE */ + is = for_character ("\323\066\232\071", 4); + ASSERT (is == 0); + /* U+E0041 TAG LATIN CAPITAL LETTER A */ + is = for_character ("\323\066\234\063", 4); + ASSERT (is == 0); + } + return 0; + + } + + return 1; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isxdigit.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isxdigit.sh new file mode 100755 index 00000000..48f8efa7 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32isxdigit.sh @@ -0,0 +1,42 @@ +#!/bin/sh + +# Test in the POSIX locale. +LC_ALL=C ${CHECKER} ./test-c32isxdigit${EXEEXT} 0 || exit 1 +LC_ALL=POSIX ${CHECKER} ./test-c32isxdigit${EXEEXT} 0 || exit 1 + +# Test in an ISO-8859-1 or ISO-8859-15 locale. +: "${LOCALE_FR=fr_FR}" +if test $LOCALE_FR != none; then + LC_ALL=$LOCALE_FR \ + ${CHECKER} ./test-c32isxdigit${EXEEXT} 1 \ + || exit 1 +fi + +# Test whether a specific EUC-JP locale is installed. +: "${LOCALE_JA=ja_JP}" +if test $LOCALE_JA != none; then + LC_ALL=$LOCALE_JA \ + ${CHECKER} ./test-c32isxdigit${EXEEXT} 2 \ + || exit 1 +fi + +# Test whether a specific UTF-8 locale is installed. +: "${LOCALE_FR_UTF8=fr_FR.UTF-8}" +if test $LOCALE_FR_UTF8 != none; then + LC_ALL=$LOCALE_FR_UTF8 \ + ${CHECKER} ./test-c32isxdigit${EXEEXT} 3 \ + || exit 1 +fi + +# Test whether a specific GB18030 locale is installed. +: "${LOCALE_ZH_CN=zh_CN.GB18030}" +if test $LOCALE_ZH_CN != none; then + LC_ALL=$LOCALE_ZH_CN \ + ${CHECKER} ./test-c32isxdigit${EXEEXT} 4 + case $? in + 0 | 77) ;; + *) exit 1 ;; + esac +fi + +exit 0 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32rtomb-w32-2.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32rtomb-w32-2.sh new file mode 100755 index 00000000..e797d0e5 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32rtomb-w32-2.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Test a CP1252 locale. +${CHECKER} ./test-c32rtomb-w32${EXEEXT} French_France 1252 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32rtomb-w32-3.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32rtomb-w32-3.sh new file mode 100755 index 00000000..1b63d472 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32rtomb-w32-3.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Test a CP1256 locale. +${CHECKER} ./test-c32rtomb-w32${EXEEXT} "Arabic_Saudi Arabia" 1256 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32rtomb-w32-4.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32rtomb-w32-4.sh new file mode 100755 index 00000000..3c0f3db4 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32rtomb-w32-4.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Test some UTF-8 locales. +${CHECKER} ./test-c32rtomb-w32${EXEEXT} French_France Japanese_Japan Chinese_Taiwan Chinese_China 65001 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32rtomb-w32-5.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32rtomb-w32-5.sh new file mode 100755 index 00000000..ff59a872 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32rtomb-w32-5.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Test a CP932 locale. +${CHECKER} ./test-c32rtomb-w32${EXEEXT} Japanese_Japan 932 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32rtomb-w32-6.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32rtomb-w32-6.sh new file mode 100755 index 00000000..3cf34065 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32rtomb-w32-6.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Test a CP950 locale. +${CHECKER} ./test-c32rtomb-w32${EXEEXT} Chinese_Taiwan 950 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32rtomb-w32-7.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32rtomb-w32-7.sh new file mode 100755 index 00000000..2174c0b5 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32rtomb-w32-7.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Test a CP936 locale. +${CHECKER} ./test-c32rtomb-w32${EXEEXT} Chinese_China 936 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32rtomb-w32-8.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32rtomb-w32-8.sh new file mode 100755 index 00000000..b7e77b28 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32rtomb-w32-8.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Test a GB18030 locale. +${CHECKER} ./test-c32rtomb-w32${EXEEXT} Chinese_China 54936 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32rtomb-w32.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32rtomb-w32.c new file mode 100644 index 00000000..3e089d11 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32rtomb-w32.c @@ -0,0 +1,349 @@ +/* Test of conversion of wide character to multibyte character. + Copyright (C) 2008-2024 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 . */ + +#include + +#include + +#include +#include +#include +#include + +#include "localcharset.h" +#include "macros.h" + +#if defined _WIN32 && !defined __CYGWIN__ + +static int +test_one_locale (const char *name, int codepage) +{ + char buf[64]; + size_t ret; + +# if 1 + /* Portable code to set the locale. */ + { + char name_with_codepage[1024]; + + sprintf (name_with_codepage, "%s.%d", name, codepage); + + /* Set the locale. */ + if (setlocale (LC_ALL, name_with_codepage) == NULL) + return 77; + } +# else + /* Hacky way to set a locale.codepage combination that setlocale() refuses + to set. */ + { + /* Codepage of the current locale, set with setlocale(). + Not necessarily the same as GetACP(). */ + extern __declspec(dllimport) unsigned int __lc_codepage; + + /* Set the locale. */ + if (setlocale (LC_ALL, name) == NULL) + return 77; + + /* Clobber the codepage and MB_CUR_MAX, both set by setlocale(). */ + __lc_codepage = codepage; + switch (codepage) + { + case 1252: + case 1256: + MB_CUR_MAX = 1; + break; + case 932: + case 950: + case 936: + MB_CUR_MAX = 2; + break; + case 54936: + case 65001: + MB_CUR_MAX = 4; + break; + } + + /* Test whether the codepage is really available. */ + { + mbstate_t state; + wchar_t wc; + + memset (&state, '\0', sizeof (mbstate_t)); + if (mbrtowc (&wc, " ", 1, &state) == (size_t)(-1)) + return 77; + } + } +# endif + + /* Test NUL character. */ + { + buf[0] = 'x'; + ret = c32rtomb (buf, 0, NULL); + ASSERT (ret == 1); + ASSERT (buf[0] == '\0'); + } + + /* Test single bytes. */ + { + int c; + + for (c = 0; c < 0x100; c++) + switch (c) + { + case '\t': case '\v': case '\f': + case ' ': case '!': case '"': case '#': case '%': + case '&': case '\'': case '(': case ')': case '*': + case '+': case ',': case '-': case '.': case '/': + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + case ':': case ';': case '<': case '=': case '>': + case '?': + case 'A': case 'B': case 'C': case 'D': case 'E': + case 'F': case 'G': case 'H': case 'I': case 'J': + case 'K': case 'L': case 'M': case 'N': case 'O': + case 'P': case 'Q': case 'R': case 'S': case 'T': + case 'U': case 'V': case 'W': case 'X': case 'Y': + case 'Z': + case '[': case '\\': case ']': case '^': case '_': + case 'a': case 'b': case 'c': case 'd': case 'e': + case 'f': case 'g': case 'h': case 'i': case 'j': + case 'k': case 'l': case 'm': case 'n': case 'o': + case 'p': case 'q': case 'r': case 's': case 't': + case 'u': case 'v': case 'w': case 'x': case 'y': + case 'z': case '{': case '|': case '}': case '~': + /* c is in the ISO C "basic character set". */ + ret = c32rtomb (buf, btoc32 (c), NULL); + ASSERT (ret == 1); + ASSERT (buf[0] == (char) c); + break; + } + } + + /* Test special calling convention, passing a NULL pointer. */ + { + ret = c32rtomb (NULL, '\0', NULL); + ASSERT (ret == 1); + ret = c32rtomb (NULL, btoc32 ('x'), NULL); + ASSERT (ret == 1); + } + + switch (codepage) + { + case 1252: + /* Locale encoding is CP1252, an extension of ISO-8859-1. */ + { + /* Convert "B\374\337er": "Büßer" */ + memset (buf, 'x', 8); + ret = c32rtomb (buf, 0x00FC, NULL); + ASSERT (ret == 1); + ASSERT (memcmp (buf, "\374", 1) == 0); + ASSERT (buf[1] == 'x'); + + memset (buf, 'x', 8); + ret = c32rtomb (buf, 0x00DF, NULL); + ASSERT (ret == 1); + ASSERT (memcmp (buf, "\337", 1) == 0); + ASSERT (buf[1] == 'x'); + } + return 0; + + case 1256: + /* Locale encoding is CP1256, not the same as ISO-8859-6. */ + { + /* Convert "x\302\341\346y": "xآلوy" */ + memset (buf, 'x', 8); + ret = c32rtomb (buf, 0x0622, NULL); + ASSERT (ret == 1); + ASSERT (memcmp (buf, "\302", 1) == 0); + ASSERT (buf[1] == 'x'); + + memset (buf, 'x', 8); + ret = c32rtomb (buf, 0x0644, NULL); + ASSERT (ret == 1); + ASSERT (memcmp (buf, "\341", 1) == 0); + ASSERT (buf[1] == 'x'); + + memset (buf, 'x', 8); + ret = c32rtomb (buf, 0x0648, NULL); + ASSERT (ret == 1); + ASSERT (memcmp (buf, "\346", 1) == 0); + ASSERT (buf[1] == 'x'); + } + return 0; + + case 65001: + /* Locale encoding is CP65001 = UTF-8. */ + if (strcmp (locale_charset (), "UTF-8") != 0) + return 77; + { + /* Convert "s\303\274\303\237\360\237\230\213!"; "süß😋!" */ + memset (buf, 'x', 8); + ret = c32rtomb (buf, 0x00FC, NULL); + ASSERT (ret == 2); + ASSERT (memcmp (buf, "\303\274", 2) == 0); + ASSERT (buf[2] == 'x'); + + memset (buf, 'x', 8); + ret = c32rtomb (buf, 0x00DF, NULL); + ASSERT (ret == 2); + ASSERT (memcmp (buf, "\303\237", 2) == 0); + ASSERT (buf[2] == 'x'); + + memset (buf, 'x', 8); + ret = c32rtomb (buf, 0x1F60B, NULL); + ASSERT (ret == 4); + ASSERT (memcmp (buf, "\360\237\230\213", 4) == 0); + ASSERT (buf[4] == 'x'); + } + return 0; + + case 932: + /* Locale encoding is CP932, similar to Shift_JIS. */ + { + /* Convert "<\223\372\226\173\214\352>": "<日本語>" */ + memset (buf, 'x', 8); + ret = c32rtomb (buf, 0x65E5, NULL); + ASSERT (ret == 2); + ASSERT (memcmp (buf, "\223\372", 2) == 0); + ASSERT (buf[2] == 'x'); + + memset (buf, 'x', 8); + ret = c32rtomb (buf, 0x672C, NULL); + ASSERT (ret == 2); + ASSERT (memcmp (buf, "\226\173", 2) == 0); + ASSERT (buf[2] == 'x'); + + memset (buf, 'x', 8); + ret = c32rtomb (buf, 0x8A9E, NULL); + ASSERT (ret == 2); + ASSERT (memcmp (buf, "\214\352", 2) == 0); + ASSERT (buf[2] == 'x'); + } + return 0; + + case 950: + /* Locale encoding is CP950, similar to Big5. */ + { + /* Convert "<\244\351\245\273\273\171>": "<日本語>" */ + memset (buf, 'x', 8); + ret = c32rtomb (buf, 0x65E5, NULL); + ASSERT (ret == 2); + ASSERT (memcmp (buf, "\244\351", 2) == 0); + ASSERT (buf[2] == 'x'); + + memset (buf, 'x', 8); + ret = c32rtomb (buf, 0x672C, NULL); + ASSERT (ret == 2); + ASSERT (memcmp (buf, "\245\273", 2) == 0); + ASSERT (buf[2] == 'x'); + + memset (buf, 'x', 8); + ret = c32rtomb (buf, 0x8A9E, NULL); + ASSERT (ret == 2); + ASSERT (memcmp (buf, "\273\171", 2) == 0); + ASSERT (buf[2] == 'x'); + } + return 0; + + case 936: + /* Locale encoding is CP936 = GBK, an extension of GB2312. */ + { + /* Convert "<\310\325\261\276\325\132>": "<日本語>" */ + memset (buf, 'x', 8); + ret = c32rtomb (buf, 0x65E5, NULL); + ASSERT (ret == 2); + ASSERT (memcmp (buf, "\310\325", 2) == 0); + ASSERT (buf[2] == 'x'); + + memset (buf, 'x', 8); + ret = c32rtomb (buf, 0x672C, NULL); + ASSERT (ret == 2); + ASSERT (memcmp (buf, "\261\276", 2) == 0); + ASSERT (buf[2] == 'x'); + + memset (buf, 'x', 8); + ret = c32rtomb (buf, 0x8A9E, NULL); + ASSERT (ret == 2); + ASSERT (memcmp (buf, "\325\132", 2) == 0); + ASSERT (buf[2] == 'x'); + } + return 0; + + case 54936: + /* Locale encoding is CP54936 = GB18030. */ + if (strcmp (locale_charset (), "GB18030") != 0) + return 77; + { + /* Convert "s\250\271\201\060\211\070\224\071\375\067!"; "süß😋!" */ + memset (buf, 'x', 8); + ret = c32rtomb (buf, 0x00FC, NULL); + ASSERT (ret == 2); + ASSERT (memcmp (buf, "\250\271", 2) == 0); + ASSERT (buf[2] == 'x'); + + memset (buf, 'x', 8); + ret = c32rtomb (buf, 0x00DF, NULL); + ASSERT (ret == 4); + ASSERT (memcmp (buf, "\201\060\211\070", 4) == 0); + ASSERT (buf[4] == 'x'); + + memset (buf, 'x', 8); + ret = c32rtomb (buf, 0x1F60B, NULL); + ASSERT (ret == 4); + ASSERT (memcmp (buf, "\224\071\375\067", 4) == 0); + ASSERT (buf[4] == 'x'); + } + return 0; + + default: + return 1; + } +} + +int +main (int argc, char *argv[]) +{ + int codepage = atoi (argv[argc - 1]); + int result; + int i; + + result = 77; + for (i = 1; i < argc - 1; i++) + { + int ret = test_one_locale (argv[i], codepage); + + if (ret != 77) + result = ret; + } + + if (result == 77) + { + fprintf (stderr, "Skipping test: found no locale with codepage %d\n", + codepage); + } + return result; +} + +#else + +int +main (int argc, char *argv[]) +{ + fputs ("Skipping test: not a native Windows system\n", stderr); + return 77; +} + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32rtomb.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32rtomb.c new file mode 100644 index 00000000..c33d08d3 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32rtomb.c @@ -0,0 +1,174 @@ +/* Test of conversion of wide character to multibyte character. + Copyright (C) 2008-2024 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 . */ + +/* Written by Bruno Haible , 2008. */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (c32rtomb, size_t, (char *, char32_t, mbstate_t *)); + +#include +#include +#include + +#include "macros.h" + +/* Check the multibyte character s[0..n-1]. */ +static void +check_character (const char *s, size_t n) +{ + mbstate_t state; + char32_t wc; + char buf[64]; + int iret; + size_t ret; + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (char32_t) 0xBADFACE; + iret = mbrtoc32 (&wc, s, n, &state); + ASSERT (iret == n); + + ret = c32rtomb (buf, wc, NULL); + ASSERT (ret == n); + ASSERT (memcmp (buf, s, n) == 0); + + /* Test special calling convention, passing a NULL pointer. */ + ret = c32rtomb (NULL, wc, NULL); + ASSERT (ret == 1); +} + +int +main (int argc, char *argv[]) +{ + char buf[64]; + size_t ret; + + /* configure should already have checked that the locale is supported. */ + if (setlocale (LC_ALL, "") == NULL) + return 1; + + /* Test NUL character. */ + { + buf[0] = 'x'; + ret = c32rtomb (buf, 0, NULL); + ASSERT (ret == 1); + ASSERT (buf[0] == '\0'); + } + + /* Test single bytes. */ + { + int c; + + for (c = 0; c < 0x100; c++) + switch (c) + { + case '\t': case '\v': case '\f': + case ' ': case '!': case '"': case '#': case '%': + case '&': case '\'': case '(': case ')': case '*': + case '+': case ',': case '-': case '.': case '/': + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + case ':': case ';': case '<': case '=': case '>': + case '?': + case 'A': case 'B': case 'C': case 'D': case 'E': + case 'F': case 'G': case 'H': case 'I': case 'J': + case 'K': case 'L': case 'M': case 'N': case 'O': + case 'P': case 'Q': case 'R': case 'S': case 'T': + case 'U': case 'V': case 'W': case 'X': case 'Y': + case 'Z': + case '[': case '\\': case ']': case '^': case '_': + case 'a': case 'b': case 'c': case 'd': case 'e': + case 'f': case 'g': case 'h': case 'i': case 'j': + case 'k': case 'l': case 'm': case 'n': case 'o': + case 'p': case 'q': case 'r': case 's': case 't': + case 'u': case 'v': case 'w': case 'x': case 'y': + case 'z': case '{': case '|': case '}': case '~': + /* c is in the ISO C "basic character set". */ + ret = c32rtomb (buf, btoc32 (c), NULL); + ASSERT (ret == 1); + ASSERT (buf[0] == (char) c); + break; + } + } + + /* Test special calling convention, passing a NULL pointer. */ + { + ret = c32rtomb (NULL, '\0', NULL); + ASSERT (ret == 1); + ret = c32rtomb (NULL, btoc32 ('x'), NULL); + ASSERT (ret == 1); + } + + if (argc > 1) + switch (argv[1][0]) + { + case '1': + /* C locale; tested above. */ + return 0; + + case '2': + /* Locale encoding is ISO-8859-1 or ISO-8859-15. */ + { + const char input[] = "B\374\337er"; /* "Büßer" */ + + check_character (input + 1, 1); + check_character (input + 2, 1); + } + return 0; + + case '3': + /* Locale encoding is UTF-8. */ + { + const char input[] = "s\303\274\303\237\360\237\230\213!"; /* "süß😋!" */ + + check_character (input + 1, 2); + check_character (input + 3, 2); + check_character (input + 5, 4); + } + return 0; + + case '4': + /* Locale encoding is EUC-JP. */ + { + const char input[] = "<\306\374\313\334\270\354>"; /* "<日本語>" */ + + check_character (input + 1, 2); + check_character (input + 3, 2); + check_character (input + 5, 2); + } + return 0; + + case '5': + /* Locale encoding is GB18030. */ + #if (defined __GLIBC__ && __GLIBC__ == 2 && __GLIBC_MINOR__ >= 13 && __GLIBC_MINOR__ <= 15) || (GL_CHAR32_T_IS_UNICODE && (defined __FreeBSD__ || defined __NetBSD__ || defined __sun)) + fputs ("Skipping test: The GB18030 converter in this system's iconv is broken.\n", stderr); + return 77; + #endif + { + const char input[] = "s\250\271\201\060\211\070\224\071\375\067!"; /* "süß😋!" */ + + check_character (input + 1, 2); + check_character (input + 3, 4); + check_character (input + 7, 4); + } + return 0; + } + + return 1; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32rtomb.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32rtomb.sh new file mode 100755 index 00000000..e5236c97 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32rtomb.sh @@ -0,0 +1,42 @@ +#!/bin/sh + +# Test in the POSIX locale. +LC_ALL=C ${CHECKER} ./test-c32rtomb${EXEEXT} 1 || exit 1 +LC_ALL=POSIX ${CHECKER} ./test-c32rtomb${EXEEXT} 1 || exit 1 + +# Test in an ISO-8859-1 or ISO-8859-15 locale. +: "${LOCALE_FR=fr_FR}" +if test $LOCALE_FR != none; then + LC_ALL=$LOCALE_FR \ + ${CHECKER} ./test-c32rtomb${EXEEXT} 2 \ + || exit 1 +fi + +# Test whether a specific UTF-8 locale is installed. +: "${LOCALE_FR_UTF8=fr_FR.UTF-8}" +if test $LOCALE_FR_UTF8 != none; then + LC_ALL=$LOCALE_FR_UTF8 \ + ${CHECKER} ./test-c32rtomb${EXEEXT} 3 \ + || exit 1 +fi + +# Test whether a specific EUC-JP locale is installed. +: "${LOCALE_JA=ja_JP}" +if test $LOCALE_JA != none; then + LC_ALL=$LOCALE_JA \ + ${CHECKER} ./test-c32rtomb${EXEEXT} 4 \ + || exit 1 +fi + +# Test whether a specific GB18030 locale is installed. +: "${LOCALE_ZH_CN=zh_CN.GB18030}" +if test $LOCALE_ZH_CN != none; then + LC_ALL=$LOCALE_ZH_CN \ + ${CHECKER} ./test-c32rtomb${EXEEXT} 5 + case $? in + 0 | 77) ;; + *) exit 1 ;; + esac +fi + +exit 0 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32tolower.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32tolower.c new file mode 100644 index 00000000..681191b4 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32tolower.c @@ -0,0 +1,440 @@ +/* Test of c32tolower() function. + Copyright (C) 2020-2024 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 . */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (c32tolower, wint_t, (wint_t)); + +#include +#include +#include +#include + +#include "macros.h" + +/* Representation of a multibyte character. */ +#define MBCHAR_BUF_SIZE 6 +struct multibyte +{ + size_t nbytes; /* number of bytes of current character, > 0 */ + char buf[MBCHAR_BUF_SIZE]; /* room for the bytes */ +}; + +/* Returns the value of c32tolower for the multibyte character s[0..n-1], + as a multibyte character. */ +static struct multibyte +for_character (const char *s, size_t n) +{ + mbstate_t state; + char32_t wc; + size_t ret; + struct multibyte result; + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, s, n, &state); + ASSERT (ret == n); + + wc = c32tolower (wc); + ASSERT (wc != WEOF); + + memset (&state, '\0', sizeof (mbstate_t)); + ret = c32rtomb (result.buf, wc, &state); + ASSERT (ret != 0); + if (ret == (size_t)(-1)) + /* wc cannot be converted back to multibyte. */ + result.nbytes = 0; + else + { + ASSERT (ret <= MBCHAR_BUF_SIZE); + result.nbytes = ret; + } + return result; +} + +int +main (int argc, char *argv[]) +{ + wint_t wc; + struct multibyte mb; + char buf[4]; + + /* configure should already have checked that the locale is supported. */ + if (setlocale (LC_ALL, "") == NULL) + return 1; + + /* Test WEOF. */ + wc = c32tolower (WEOF); + ASSERT (wc == WEOF); + + /* Test single-byte characters. + POSIX specifies in + + that + - in all locales, the uppercase characters include the A ... Z + characters, and the corresponding characters a ... z (if not in a + Turkish locale) are lowercase, + - in the "POSIX" locale (which is usually the same as the "C" locale), + the uppercase characters include only the ASCII A ... Z characters, + and the corresponding characters a ... z are lowercase. + */ +#if defined __NetBSD__ + /* towlower is broken in the zh_CN.GB18030 locale on NetBSD 9.0. + See . */ + if (!(argc > 1 && argv[1][0] == '4')) +#endif + { + int c; + + for (c = 0; c < 0x100; c++) + switch (c) + { + case '\t': case '\v': case '\f': + case ' ': case '!': case '"': case '#': case '%': + case '&': case '\'': case '(': case ')': case '*': + case '+': case ',': case '-': case '.': case '/': + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + case ':': case ';': case '<': case '=': case '>': + case '?': + case 'A': case 'B': case 'C': case 'D': case 'E': + case 'F': case 'G': case 'H': case 'I': case 'J': + case 'K': case 'L': case 'M': case 'N': case 'O': + case 'P': case 'Q': case 'R': case 'S': case 'T': + case 'U': case 'V': case 'W': case 'X': case 'Y': + case 'Z': + case '[': case '\\': case ']': case '^': case '_': + case 'a': case 'b': case 'c': case 'd': case 'e': + case 'f': case 'g': case 'h': case 'i': case 'j': + case 'k': case 'l': case 'm': case 'n': case 'o': + case 'p': case 'q': case 'r': case 's': case 't': + case 'u': case 'v': case 'w': case 'x': case 'y': + case 'z': case '{': case '|': case '}': case '~': + /* c is in the ISO C "basic character set". */ + buf[0] = (unsigned char) c; + mb = for_character (buf, 1); + switch (c) + { + case 'A': case 'B': case 'C': case 'D': case 'E': + case 'F': case 'G': case 'H': case 'I': case 'J': + case 'K': case 'L': case 'M': case 'N': case 'O': + case 'P': case 'Q': case 'R': case 'S': case 'T': + case 'U': case 'V': case 'W': case 'X': case 'Y': + case 'Z': + ASSERT (mb.nbytes == 1); + ASSERT ((unsigned char) mb.buf[0] == (unsigned char) c - 'A' + 'a'); + break; + default: + ASSERT (mb.nbytes == 1); + ASSERT ((unsigned char) mb.buf[0] == c); + break; + } + break; + } + } + + if (argc > 1) + switch (argv[1][0]) + { + case '0': + /* C locale; tested above. */ + return 0; + + case '1': + /* Locale encoding is ISO-8859-1 or ISO-8859-15. */ + { + /* U+00B2 SUPERSCRIPT TWO */ + mb = for_character ("\262", 1); + ASSERT (mb.nbytes == 1); + ASSERT (memcmp (mb.buf, "\262", 1) == 0); + /* U+00B5 MICRO SIGN */ + mb = for_character ("\265", 1); + ASSERT (mb.nbytes == 1); + ASSERT (memcmp (mb.buf, "\265", 1) == 0); + /* U+00C9 LATIN CAPITAL LETTER E WITH ACUTE */ + mb = for_character ("\311", 1); + ASSERT (mb.nbytes == 1); + ASSERT (memcmp (mb.buf, "\351", 1) == 0); + /* U+00DF LATIN SMALL LETTER SHARP S */ + mb = for_character ("\337", 1); + ASSERT (mb.nbytes == 1); + ASSERT (memcmp (mb.buf, "\337", 1) == 0); + /* U+00E9 LATIN SMALL LETTER E WITH ACUTE */ + mb = for_character ("\351", 1); + ASSERT (mb.nbytes == 1); + ASSERT (memcmp (mb.buf, "\351", 1) == 0); + /* U+00FF LATIN SMALL LETTER Y WITH DIAERESIS */ + mb = for_character ("\377", 1); + ASSERT (mb.nbytes == 1); + ASSERT (memcmp (mb.buf, "\377", 1) == 0); + } + return 0; + + case '2': + /* Locale encoding is EUC-JP. */ + { + #if !((defined __APPLE__ && defined __MACH__) || defined __DragonFly__) + /* U+00C9 LATIN CAPITAL LETTER E WITH ACUTE */ + mb = for_character ("\217\252\261", 3); + ASSERT (mb.nbytes == 3); + ASSERT (memcmp (mb.buf, "\217\253\261", 3) == 0); + #endif + /* U+00DF LATIN SMALL LETTER SHARP S */ + mb = for_character ("\217\251\316", 3); + ASSERT (mb.nbytes == 3); + ASSERT (memcmp (mb.buf, "\217\251\316", 3) == 0); + /* U+00E9 LATIN SMALL LETTER E WITH ACUTE */ + mb = for_character ("\217\253\261", 3); + ASSERT (mb.nbytes == 3); + ASSERT (memcmp (mb.buf, "\217\253\261", 3) == 0); + /* U+00FF LATIN SMALL LETTER Y WITH DIAERESIS */ + mb = for_character ("\217\253\363", 3); + ASSERT (mb.nbytes == 3); + ASSERT (memcmp (mb.buf, "\217\253\363", 3) == 0); + #if !((defined __APPLE__ && defined __MACH__) || defined __DragonFly__) + /* U+0141 LATIN CAPITAL LETTER L WITH STROKE */ + mb = for_character ("\217\251\250", 3); + ASSERT (mb.nbytes == 3); + ASSERT (memcmp (mb.buf, "\217\251\310", 3) == 0); + #endif + /* U+0142 LATIN SMALL LETTER L WITH STROKE */ + mb = for_character ("\217\251\310", 3); + ASSERT (mb.nbytes == 3); + ASSERT (memcmp (mb.buf, "\217\251\310", 3) == 0); + #if !defined __DragonFly__ + /* U+0429 CYRILLIC CAPITAL LETTER SHCHA */ + mb = for_character ("\247\273", 2); + ASSERT (mb.nbytes == 2); + ASSERT (memcmp (mb.buf, "\247\353", 2) == 0); + #endif + /* U+0449 CYRILLIC SMALL LETTER SHCHA */ + mb = for_character ("\247\353", 2); + ASSERT (mb.nbytes == 2); + ASSERT (memcmp (mb.buf, "\247\353", 2) == 0); + /* U+3073 HIRAGANA LETTER BI */ + mb = for_character ("\244\323", 2); + ASSERT (mb.nbytes == 2); + ASSERT (memcmp (mb.buf, "\244\323", 2) == 0); + #if !defined __DragonFly__ + /* U+FF27 FULLWIDTH LATIN CAPITAL LETTER G */ + mb = for_character ("\243\307", 2); + ASSERT (mb.nbytes == 2); + ASSERT (memcmp (mb.buf, "\243\347", 2) == 0); + #endif + /* U+FF47 FULLWIDTH LATIN SMALL LETTER G */ + mb = for_character ("\243\347", 2); + ASSERT (mb.nbytes == 2); + ASSERT (memcmp (mb.buf, "\243\347", 2) == 0); + } + return 0; + + case '3': + /* Locale encoding is UTF-8. */ + { + /* U+00B2 SUPERSCRIPT TWO */ + mb = for_character ("\302\262", 2); + ASSERT (mb.nbytes == 2); + ASSERT (memcmp (mb.buf, "\302\262", 2) == 0); + /* U+00B5 MICRO SIGN */ + mb = for_character ("\302\265", 2); + ASSERT (mb.nbytes == 2); + ASSERT (memcmp (mb.buf, "\302\265", 2) == 0); + #if !(defined _WIN32 && !defined __CYGWIN__) + /* U+00C9 LATIN CAPITAL LETTER E WITH ACUTE */ + mb = for_character ("\303\211", 2); + ASSERT (mb.nbytes == 2); + ASSERT (memcmp (mb.buf, "\303\251", 2) == 0); + #endif + /* U+00DF LATIN SMALL LETTER SHARP S */ + mb = for_character ("\303\237", 2); + ASSERT (mb.nbytes == 2); + ASSERT (memcmp (mb.buf, "\303\237", 2) == 0); + /* U+00E9 LATIN SMALL LETTER E WITH ACUTE */ + mb = for_character ("\303\251", 2); + ASSERT (mb.nbytes == 2); + ASSERT (memcmp (mb.buf, "\303\251", 2) == 0); + /* U+00FF LATIN SMALL LETTER Y WITH DIAERESIS */ + mb = for_character ("\303\277", 2); + ASSERT (mb.nbytes == 2); + ASSERT (memcmp (mb.buf, "\303\277", 2) == 0); + /* U+0141 LATIN CAPITAL LETTER L WITH STROKE */ + mb = for_character ("\305\201", 2); + ASSERT (mb.nbytes == 2); + ASSERT (memcmp (mb.buf, "\305\202", 2) == 0); + /* U+0142 LATIN SMALL LETTER L WITH STROKE */ + mb = for_character ("\305\202", 2); + ASSERT (mb.nbytes == 2); + ASSERT (memcmp (mb.buf, "\305\202", 2) == 0); + /* U+0429 CYRILLIC CAPITAL LETTER SHCHA */ + mb = for_character ("\320\251", 2); + ASSERT (mb.nbytes == 2); + ASSERT (memcmp (mb.buf, "\321\211", 2) == 0); + /* U+0449 CYRILLIC SMALL LETTER SHCHA */ + mb = for_character ("\321\211", 2); + ASSERT (mb.nbytes == 2); + ASSERT (memcmp (mb.buf, "\321\211", 2) == 0); + /* U+05D5 HEBREW LETTER VAV */ + mb = for_character ("\327\225", 2); + ASSERT (mb.nbytes == 2); + ASSERT (memcmp (mb.buf, "\327\225", 2) == 0); + /* U+3073 HIRAGANA LETTER BI */ + mb = for_character ("\343\201\263", 3); + ASSERT (mb.nbytes == 3); + ASSERT (memcmp (mb.buf, "\343\201\263", 3) == 0); + /* U+3162 HANGUL LETTER YI */ + mb = for_character ("\343\205\242", 3); + ASSERT (mb.nbytes == 3); + ASSERT (memcmp (mb.buf, "\343\205\242", 3) == 0); + /* U+FF27 FULLWIDTH LATIN CAPITAL LETTER G */ + mb = for_character ("\357\274\247", 3); + ASSERT (mb.nbytes == 3); + ASSERT (memcmp (mb.buf, "\357\275\207", 3) == 0); + /* U+FF47 FULLWIDTH LATIN SMALL LETTER G */ + mb = for_character ("\357\275\207", 3); + ASSERT (mb.nbytes == 3); + ASSERT (memcmp (mb.buf, "\357\275\207", 3) == 0); + /* U+FFDB HALFWIDTH HANGUL LETTER YI */ + mb = for_character ("\357\277\233", 3); + ASSERT (mb.nbytes == 3); + ASSERT (memcmp (mb.buf, "\357\277\233", 3) == 0); + #if !(defined __DragonFly__ || defined __sun) + /* U+10419 DESERET CAPITAL LETTER EF */ + mb = for_character ("\360\220\220\231", 4); + ASSERT (mb.nbytes == 4); + ASSERT (memcmp (mb.buf, "\360\220\221\201", 4) == 0); + #endif + /* U+10441 DESERET SMALL LETTER EF */ + mb = for_character ("\360\220\221\201", 4); + ASSERT (mb.nbytes == 4); + ASSERT (memcmp (mb.buf, "\360\220\221\201", 4) == 0); + /* U+E0041 TAG LATIN CAPITAL LETTER A */ + mb = for_character ("\363\240\201\201", 4); + ASSERT (mb.nbytes == 4); + ASSERT (memcmp (mb.buf, "\363\240\201\201", 4) == 0); + /* U+E0061 TAG LATIN SMALL LETTER A */ + mb = for_character ("\363\240\201\241", 4); + ASSERT (mb.nbytes == 4); + ASSERT (memcmp (mb.buf, "\363\240\201\241", 4) == 0); + } + return 0; + + case '4': + /* Locale encoding is GB18030. */ + #if (defined __GLIBC__ && __GLIBC__ == 2 && __GLIBC_MINOR__ >= 13 && __GLIBC_MINOR__ <= 15) || (GL_CHAR32_T_IS_UNICODE && (defined __FreeBSD__ || defined __NetBSD__ || defined __sun)) + fputs ("Skipping test: The GB18030 converter in this system's iconv is broken.\n", stderr); + return 77; + #endif + { + /* U+00B2 SUPERSCRIPT TWO */ + mb = for_character ("\201\060\205\065", 4); + ASSERT (mb.nbytes == 4); + ASSERT (memcmp (mb.buf, "\201\060\205\065", 4) == 0); + /* U+00B5 MICRO SIGN */ + mb = for_character ("\201\060\205\070", 4); + ASSERT (mb.nbytes == 4); + ASSERT (memcmp (mb.buf, "\201\060\205\070", 4) == 0); + #if !(defined __FreeBSD__ || defined __DragonFly__ || defined __sun) + /* U+00C9 LATIN CAPITAL LETTER E WITH ACUTE */ + mb = for_character ("\201\060\207\067", 4); + ASSERT (mb.nbytes == 2); + ASSERT (memcmp (mb.buf, "\250\246", 2) == 0); + #endif + /* U+00DF LATIN SMALL LETTER SHARP S */ + mb = for_character ("\201\060\211\070", 4); + ASSERT (mb.nbytes == 4); + ASSERT (memcmp (mb.buf, "\201\060\211\070", 4) == 0); + /* U+00E9 LATIN SMALL LETTER E WITH ACUTE */ + mb = for_character ("\250\246", 2); + ASSERT (mb.nbytes == 2); + ASSERT (memcmp (mb.buf, "\250\246", 2) == 0); + /* U+00FF LATIN SMALL LETTER Y WITH DIAERESIS */ + mb = for_character ("\201\060\213\067", 4); + ASSERT (mb.nbytes == 4); + ASSERT (memcmp (mb.buf, "\201\060\213\067", 4) == 0); + #if !(defined __FreeBSD__ || defined __DragonFly__ || defined __sun) + /* U+0141 LATIN CAPITAL LETTER L WITH STROKE */ + mb = for_character ("\201\060\221\071", 4); + ASSERT (mb.nbytes == 4); + ASSERT (memcmp (mb.buf, "\201\060\222\060", 4) == 0); + #endif + /* U+0142 LATIN SMALL LETTER L WITH STROKE */ + mb = for_character ("\201\060\222\060", 4); + ASSERT (mb.nbytes == 4); + ASSERT (memcmp (mb.buf, "\201\060\222\060", 4) == 0); + #if !(defined __FreeBSD__ || defined __DragonFly__) + /* U+0429 CYRILLIC CAPITAL LETTER SHCHA */ + mb = for_character ("\247\273", 2); + ASSERT (mb.nbytes == 2); + ASSERT (memcmp (mb.buf, "\247\353", 2) == 0); + #endif + /* U+0449 CYRILLIC SMALL LETTER SHCHA */ + mb = for_character ("\247\353", 2); + ASSERT (mb.nbytes == 2); + ASSERT (memcmp (mb.buf, "\247\353", 2) == 0); + /* U+05D5 HEBREW LETTER VAV */ + mb = for_character ("\201\060\371\067", 4); + ASSERT (mb.nbytes == 4); + ASSERT (memcmp (mb.buf, "\201\060\371\067", 4) == 0); + /* U+3073 HIRAGANA LETTER BI */ + mb = for_character ("\244\323", 2); + ASSERT (mb.nbytes == 2); + ASSERT (memcmp (mb.buf, "\244\323", 2) == 0); + /* U+3162 HANGUL LETTER YI */ + mb = for_character ("\201\071\256\062", 4); + ASSERT (mb.nbytes == 4); + ASSERT (memcmp (mb.buf, "\201\071\256\062", 4) == 0); + #if !defined __DragonFly__ + /* U+FF27 FULLWIDTH LATIN CAPITAL LETTER G */ + mb = for_character ("\243\307", 2); + ASSERT (mb.nbytes == 2); + ASSERT (memcmp (mb.buf, "\243\347", 2) == 0); + #endif + /* U+FF47 FULLWIDTH LATIN SMALL LETTER G */ + mb = for_character ("\243\347", 2); + ASSERT (mb.nbytes == 2); + ASSERT (memcmp (mb.buf, "\243\347", 2) == 0); + /* U+FFDB HALFWIDTH HANGUL LETTER YI */ + mb = for_character ("\204\061\241\071", 4); + ASSERT (mb.nbytes == 4); + ASSERT (memcmp (mb.buf, "\204\061\241\071", 4) == 0); + #if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__ || defined __sun) + /* U+10419 DESERET CAPITAL LETTER EF */ + mb = for_character ("\220\060\351\071", 4); + ASSERT (mb.nbytes == 4); + ASSERT (memcmp (mb.buf, "\220\060\355\071", 4) == 0); + #endif + /* U+10441 DESERET SMALL LETTER EF */ + mb = for_character ("\220\060\355\071", 4); + ASSERT (mb.nbytes == 4); + ASSERT (memcmp (mb.buf, "\220\060\355\071", 4) == 0); + /* U+E0041 TAG LATIN CAPITAL LETTER A */ + mb = for_character ("\323\066\234\063", 4); + ASSERT (mb.nbytes == 4); + ASSERT (memcmp (mb.buf, "\323\066\234\063", 4) == 0); + /* U+E0061 TAG LATIN SMALL LETTER A */ + mb = for_character ("\323\066\237\065", 4); + ASSERT (mb.nbytes == 4); + ASSERT (memcmp (mb.buf, "\323\066\237\065", 4) == 0); + } + return 0; + + } + + return 1; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32tolower.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32tolower.sh new file mode 100755 index 00000000..02f3e5f6 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32tolower.sh @@ -0,0 +1,45 @@ +#!/bin/sh + +# Allow distinguishing the various invocations in the .log file. +set -x + +# Test in the POSIX locale. +LC_ALL=C ${CHECKER} ./test-c32tolower${EXEEXT} 0 || exit 1 +LC_ALL=POSIX ${CHECKER} ./test-c32tolower${EXEEXT} 0 || exit 1 + +# Test in an ISO-8859-1 or ISO-8859-15 locale. +: "${LOCALE_FR=fr_FR}" +if test $LOCALE_FR != none; then + LC_ALL=$LOCALE_FR \ + ${CHECKER} ./test-c32tolower${EXEEXT} 1 \ + || exit 1 +fi + +# Test whether a specific EUC-JP locale is installed. +: "${LOCALE_JA=ja_JP}" +if test $LOCALE_JA != none; then + LC_ALL=$LOCALE_JA \ + ${CHECKER} ./test-c32tolower${EXEEXT} 2 \ + || exit 1 +fi + +# Test whether a specific UTF-8 locale is installed. +: "${LOCALE_FR_UTF8=fr_FR.UTF-8}" +if test $LOCALE_FR_UTF8 != none; then + LC_ALL=$LOCALE_FR_UTF8 \ + ${CHECKER} ./test-c32tolower${EXEEXT} 3 \ + || exit 1 +fi + +# Test whether a specific GB18030 locale is installed. +: "${LOCALE_ZH_CN=zh_CN.GB18030}" +if test $LOCALE_ZH_CN != none; then + LC_ALL=$LOCALE_ZH_CN \ + ${CHECKER} ./test-c32tolower${EXEEXT} 4 + case $? in + 0 | 77) ;; + *) exit 1 ;; + esac +fi + +exit 0 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32width.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32width.c new file mode 100644 index 00000000..4ebc1afa --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-c32width.c @@ -0,0 +1,104 @@ +/* Test of c32width() function. + Copyright (C) 2007-2024 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 . */ + +/* Written by Bruno Haible , 2007. */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (c32width, int, (char32_t)); + +#include +#include + +#include "c-ctype.h" +#include "localcharset.h" +#include "macros.h" + +int +main () +{ + char32_t wc; + +#if !GNULIB_WCHAR_SINGLE_LOCALE +# ifdef C_CTYPE_ASCII + /* Test width of ASCII characters. */ + for (wc = 0x20; wc < 0x7F; wc++) + ASSERT (c32width (wc) == 1); +# endif +#endif + + /* Switch to an UTF-8 locale. */ + if (setlocale (LC_ALL, "fr_FR.UTF-8") != NULL + /* Check whether it's really an UTF-8 locale. + On OpenBSD 4.0, the setlocale call succeeds only for the LC_CTYPE + category and therefore returns "C/fr_FR.UTF-8/C/C/C/C", but the + LC_CTYPE category is effectively set to an ASCII LC_CTYPE category; + in particular, locale_charset() returns "ASCII". */ + && strcmp (locale_charset (), "UTF-8") == 0) + { + /* Test width of ASCII characters. */ + for (wc = 0x20; wc < 0x7F; wc++) + ASSERT (c32width (wc) == 1); + + /* Test width of some non-spacing characters. */ + ASSERT (c32width (0x0301) == 0); + ASSERT (c32width (0x05B0) == 0); + + /* Test width of some format control characters. */ + ASSERT (c32width (0x200E) <= 0); + ASSERT (c32width (0x2060) <= 0); + ASSERT (c32width (0xE0001) <= 0); + ASSERT (c32width (0xE0044) <= 0); + + /* Test width of some zero width characters. */ + /* While it is desirable that U+200B, U+200C, U+200D have width 0, + because this makes wcswidth work better on strings that contain these + characters, it is acceptable if an implementation treats these + characters like control characters. */ + ASSERT (c32width (0x200B) <= 0); + ASSERT (c32width (0xFEFF) <= 0); + + /* Test width of some math symbols. + U+2202 is marked as having ambiguous width (A) in EastAsianWidth.txt + (see ). + The Unicode Standard Annex 11 + + says + "Ambiguous characters behave like wide or narrow characters + depending on the context (language tag, script identification, + associated font, source of data, or explicit markup; all can + provide the context). If the context cannot be established + reliably, they should be treated as narrow characters by default." + For c32width(), the only available context information is the locale. + "fr_FR.UTF-8" is a Western locale, not an East Asian locale, therefore + U+2202 should be treated like a narrow character. */ + ASSERT (c32width (0x2202) == 1); + + /* Test width of some CJK characters. */ + ASSERT (c32width (0x3000) == 2); + ASSERT (c32width (0xB250) == 2); + ASSERT (c32width (0xFF1A) == 2); + #if !(defined __FreeBSD__ && __FreeBSD__ < 13 && !defined __GLIBC__) + ASSERT (c32width (0x20369) == 2); + ASSERT (c32width (0x2F876) == 2); + #endif + } + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-calloc-gnu.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-calloc-gnu.c new file mode 100644 index 00000000..cf8c564a --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-calloc-gnu.c @@ -0,0 +1,73 @@ +/* Test of calloc function. + Copyright (C) 2010-2024 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 . */ + +#include + +/* Specification. */ +#include + +#include +#include + +#include "macros.h" + +/* Return N. + Usual compilers are not able to infer something about the return value. */ +static size_t +identity (size_t n) +{ + unsigned int x = rand (); + unsigned int y = x * x * x * x; + x++; y |= x * x * x * x; + x++; y |= x * x * x * x; + x++; y |= x * x * x * x; + y = y >> 1; + y &= -y; + y -= 8; + /* At this point Y is zero but GCC doesn't infer this. */ + return n + y; +} + +int +main () +{ + /* Check that calloc (0, 0) is not a NULL pointer. */ + { + void * volatile p = calloc (0, 0); + ASSERT (p != NULL); + free (p); + } + + /* Check that calloc fails when requested to allocate a block of memory + larger than PTRDIFF_MAX or SIZE_MAX bytes. + Use 'identity' to avoid a compiler warning from GCC 7. + 'volatile' is needed to defeat an incorrect optimization by clang 10, + see . */ + { + for (size_t n = 2; n != 0; n <<= 1) + { + void *volatile p = calloc (PTRDIFF_MAX / n + 1, identity (n)); + ASSERT (p == NULL); + ASSERT (errno == ENOMEM); + + p = calloc (SIZE_MAX / n + 1, identity (n)); + ASSERT (p == NULL); + ASSERT (errno == ENOMEM); + } + } + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-chdir.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-chdir.c new file mode 100644 index 00000000..25d168b1 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-chdir.c @@ -0,0 +1,33 @@ +/* Test changing to a directory. + Copyright (C) 2011-2024 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 . */ + +#include + +/* Specification. */ +#include + +#include "signature.h" +SIGNATURE_CHECK (chdir, int, (const char *)); + +#include "macros.h" + +int +main (void) +{ + ASSERT (chdir ("/") == 0); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-cloexec.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-cloexec.c new file mode 100644 index 00000000..76480bb6 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-cloexec.c @@ -0,0 +1,152 @@ +/* Test duplicating non-inheritable file descriptors. + Copyright (C) 2009-2024 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 . */ + +/* Written by Eric Blake , 2009. */ + +#include + +#include "cloexec.h" + +#include +#include +#include + +#if defined _WIN32 && ! defined __CYGWIN__ +/* Get declarations of the native Windows API functions. */ +# define WIN32_LEAN_AND_MEAN +# include +/* Get _get_osfhandle. */ +# if GNULIB_MSVC_NOTHROW +# include "msvc-nothrow.h" +# else +# include +# endif +#endif + +#include "binary-io.h" +#include "macros.h" + +/* Return non-zero if FD is open and inheritable across exec/spawn. */ +static int +is_inheritable (int fd) +{ +#if defined _WIN32 && ! defined __CYGWIN__ + /* On native Windows, the initial state of unassigned standard file + descriptors is that they are open but point to an + INVALID_HANDLE_VALUE, and there is no fcntl. */ + HANDLE h = (HANDLE) _get_osfhandle (fd); + DWORD flags; + if (h == INVALID_HANDLE_VALUE || GetHandleInformation (h, &flags) == 0) + return 0; + return (flags & HANDLE_FLAG_INHERIT) != 0; +#else +# ifndef F_GETFD +# error Please port fcntl to your platform +# endif + int i = fcntl (fd, F_GETFD); + return 0 <= i && (i & FD_CLOEXEC) == 0; +#endif +} + +#if !O_BINARY +# define set_binary_mode my_set_binary_mode +static int +set_binary_mode (_GL_UNUSED int fd, _GL_UNUSED int mode) +{ + return 0; +} +#endif + +/* Return non-zero if FD is open in the given MODE, which is either + O_TEXT or O_BINARY. */ +static int +is_mode (int fd, int mode) +{ + int value = set_binary_mode (fd, O_BINARY); + set_binary_mode (fd, value); + return mode == value; +} + +int +main (void) +{ + const char *file = "test-cloexec.tmp"; + int fd = creat (file, 0600); + int fd2; + int bad_fd = getdtablesize (); + + /* Assume std descriptors were provided by invoker. */ + ASSERT (STDERR_FILENO < fd); + ASSERT (is_inheritable (fd)); + + /* Normal use of set_cloexec_flag. */ + ASSERT (set_cloexec_flag (fd, true) == 0); +#if !(defined _WIN32 && ! defined __CYGWIN__) + ASSERT (!is_inheritable (fd)); +#endif + ASSERT (set_cloexec_flag (fd, false) == 0); + ASSERT (is_inheritable (fd)); + + /* Normal use of dup_cloexec. */ + fd2 = dup_cloexec (fd); + ASSERT (fd < fd2); + ASSERT (!is_inheritable (fd2)); + ASSERT (close (fd) == 0); + ASSERT (dup_cloexec (fd2) == fd); + ASSERT (!is_inheritable (fd)); + ASSERT (close (fd2) == 0); + + /* On systems that distinguish between text and binary mode, + dup_cloexec reuses the mode of the source. */ + set_binary_mode (fd, O_BINARY); + ASSERT (is_mode (fd, O_BINARY)); + fd2 = dup_cloexec (fd); + ASSERT (fd < fd2); + ASSERT (is_mode (fd2, O_BINARY)); + ASSERT (close (fd2) == 0); + set_binary_mode (fd, O_TEXT); + ASSERT (is_mode (fd, O_TEXT)); + fd2 = dup_cloexec (fd); + ASSERT (fd < fd2); + ASSERT (is_mode (fd2, O_TEXT)); + ASSERT (close (fd2) == 0); + + /* Test error handling. */ + errno = 0; + ASSERT (set_cloexec_flag (-1, false) == -1); + ASSERT (errno == EBADF); + errno = 0; + ASSERT (set_cloexec_flag (bad_fd, false) == -1); + ASSERT (errno == EBADF); + errno = 0; + ASSERT (set_cloexec_flag (fd2, false) == -1); + ASSERT (errno == EBADF); + errno = 0; + ASSERT (dup_cloexec (-1) == -1); + ASSERT (errno == EBADF); + errno = 0; + ASSERT (dup_cloexec (bad_fd) == -1); + ASSERT (errno == EBADF); + errno = 0; + ASSERT (dup_cloexec (fd2) == -1); + ASSERT (errno == EBADF); + + /* Clean up. */ + ASSERT (close (fd) == 0); + ASSERT (unlink (file) == 0); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-close.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-close.c new file mode 100644 index 00000000..47b3aa45 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-close.c @@ -0,0 +1,45 @@ +/* Test closing a file or socket. + Copyright (C) 2011-2024 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 . */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (close, int, (int)); + +#include + +#include "macros.h" + +int +main (void) +{ + /* Test behaviour for invalid file descriptors. */ + { + errno = 0; + ASSERT (close (-1) == -1); + ASSERT (errno == EBADF); + } + { + close (99); + errno = 0; + ASSERT (close (99) == -1); + ASSERT (errno == EBADF); + } + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-connect.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-connect.c new file mode 100644 index 00000000..ea4b66ed --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-connect.c @@ -0,0 +1,60 @@ +/* Test connecting a client socket. + Copyright (C) 2011-2024 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 . */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (connect, int, (int, const struct sockaddr *, socklen_t)); + +#include +#include +#include +#include + +#include "sockets.h" +#include "macros.h" + +int +main (void) +{ + (void) gl_sockets_startup (SOCKETS_1_1); + + /* Test behaviour for invalid file descriptors. */ + { + struct sockaddr_in addr; + + addr.sin_family = AF_INET; + inet_pton (AF_INET, "127.0.0.1", &addr.sin_addr); + addr.sin_port = htons (80); + { + errno = 0; + ASSERT (connect (-1, (const struct sockaddr *) &addr, sizeof (addr)) + == -1); + ASSERT (errno == EBADF); + } + { + close (99); + errno = 0; + ASSERT (connect (99, (const struct sockaddr *) &addr, sizeof (addr)) + == -1); + ASSERT (errno == EBADF); + } + } + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-count-leading-zeros.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-count-leading-zeros.c new file mode 100644 index 00000000..f748c014 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-count-leading-zeros.c @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2012-2024 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 . */ + +/* Written by Eric Blake. */ + +#include + +#include "count-leading-zeros.h" + +#include +#include + +#include "macros.h" + +#define UINT_BIT (sizeof (unsigned int) * CHAR_BIT) +#define ULONG_BIT (sizeof (unsigned long int) * CHAR_BIT) +#define ULLONG_BIT (sizeof (unsigned long long int) * CHAR_BIT) + +int +main (int argc, char *argv[]) +{ + int i, j; + +#define TEST_COUNT_LEADING_ZEROS(FUNC, TYPE, BITS, MAX, ONE) \ + ASSERT (FUNC (0) == BITS); \ + for (i = 0; i < BITS; i++) \ + { \ + ASSERT (FUNC (ONE << i) == BITS - i - 1); \ + for (j = 0; j < i; j++) \ + ASSERT (FUNC ((ONE << i) | (ONE << j)) == BITS - i - 1); \ + } \ + for (i = 0; i < 1000; i++) \ + { \ + /* RAND_MAX is most often 0x7fff or 0x7fffffff. */ \ + TYPE value = \ + (RAND_MAX <= 0xffff \ + ? ((TYPE) rand () >> 3) \ + ^ (((TYPE) rand () >> 3) << 12) \ + ^ (((TYPE) rand () >> 3) << 24) \ + ^ (((TYPE) rand () >> 3) << 30 << 6) \ + ^ (((TYPE) rand () >> 3) << 30 << 18) \ + ^ (((TYPE) rand () >> 3) << 30 << 30) \ + : ((TYPE) rand () >> 3) \ + ^ (((TYPE) rand () >> 3) << 22) \ + ^ (((TYPE) rand () >> 3) << 22 << 22)); \ + int count = 0; \ + for (j = 0; j < BITS; j++) \ + if (value & (ONE << j)) \ + count = BITS - j - 1; \ + ASSERT (count == FUNC (value)); \ + } \ + ASSERT (FUNC (MAX) == 0); + + TEST_COUNT_LEADING_ZEROS (count_leading_zeros, unsigned int, + UINT_BIT, UINT_MAX, 1U); + TEST_COUNT_LEADING_ZEROS (count_leading_zeros_l, unsigned long int, + ULONG_BIT, ULONG_MAX, 1UL); + TEST_COUNT_LEADING_ZEROS (count_leading_zeros_ll, unsigned long long int, + ULLONG_BIT, ULLONG_MAX, 1ULL); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-ctype.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-ctype.c new file mode 100644 index 00000000..d7a9e415 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-ctype.c @@ -0,0 +1,27 @@ +/* Test of substitute. + Copyright (C) 2009-2024 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 . */ + +/* Written by Eric Blake , 2009. */ + +#include + +#include + +int +main (void) +{ + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-dirent.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-dirent.c new file mode 100644 index 00000000..e3b46a38 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-dirent.c @@ -0,0 +1,32 @@ +/* Test of substitute. + Copyright (C) 2009-2024 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 . */ + +/* Written by Eric Blake , 2009. */ + +#include + +#include + +/* Check for existence of required types. */ +_GL_UNUSED static DIR *dir; +static struct dirent d; +static ino_t i; + +int +main (void) +{ + return d.d_name[0] + i; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-dirfd.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-dirfd.c new file mode 100644 index 00000000..0cfac842 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-dirfd.c @@ -0,0 +1,47 @@ +/* Test of dirfd() function. + Copyright (C) 2023-2024 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 . */ + +/* Written by Bruno Haible , 2023. */ + +#include + +#include + +#include + +#include "macros.h" + +int +main () +{ +#if defined _WIN32 && !defined __CYGWIN__ + fprintf (stderr, "Skipping test: The DIR type does not contain a file descriptor.\n"); + return 77; +#else + /* On all other platforms, we expect to have either + - a dirfd() function, or + - a dirfd macro, or + - a DIR struct with a d_fd member, or + - a DIR struct with a dd_fd member. + If we don't have this, dirfd.c produces a function that always returns -1. + Check here that this does not happen. */ + DIR *d = opendir ("."); + int fd = dirfd (d); + ASSERT (fd >= 0); + + return 0; +#endif +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-dirname.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-dirname.c new file mode 100644 index 00000000..bf69bbde --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-dirname.c @@ -0,0 +1,192 @@ +/* Test the gnulib dirname module. + Copyright (C) 2005-2007, 2009-2024 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 . */ + +#include + +#include "dirname.h" + +#include +#include +#include + +struct test { + const char *name; /* Name under test. */ + const char *dir; /* dir_name (name). */ + const char *last; /* last_component (name). */ + const char *base; /* base_name (name). */ + const char *stripped; /* name after strip_trailing_slashes (name). */ + bool modified; /* result of strip_trailing_slashes (name). */ + bool absolute; /* IS_ABSOLUTE_FILE_NAME (name). */ +}; + +static struct test tests[] = { + {"d/f", "d", "f", "f", "d/f", false, false}, + {"/d/f", "/d", "f", "f", "/d/f", false, true}, + {"d/f/", "d", "f/", "f/", "d/f", true, false}, + {"d/f//", "d", "f//", "f/", "d/f", true, false}, + {"f", ".", "f", "f", "f", false, false}, + {"/", "/", "", "/", "/", false, true}, +#if DOUBLE_SLASH_IS_DISTINCT_ROOT + {"//", "//", "", "//", "//", false, true}, + {"//d", "//", "d", "d", "//d", false, true}, +#else + {"//", "/", "", "/", "/", true, true}, + {"//d", "/", "d", "d", "//d", false, true}, +#endif + {"///", "/", "", "/", "/", true, true}, + {"///a///", "/", "a///", "a/", "///a", true, true}, + /* POSIX requires dirname("") and basename("") to both return ".", + but dir_name and base_name are defined differently. */ + {"", ".", "", "", "", false, false}, + {".", ".", ".", ".", ".", false, false}, + {"..", ".", "..", "..", "..", false, false}, +#if ISSLASH ('\\') + {"a\\", ".", "a\\", "a\\", "a", true, false}, + {"a\\b", "a", "b", "b", "a\\b", false, false}, + {"\\", "\\", "", "\\", "\\", false, true}, + {"\\/\\", "\\", "", "\\", "\\", true, true}, + {"\\\\/", "\\", "", "\\", "\\", true, true}, + {"\\//", "\\", "", "\\", "\\", true, true}, + {"//\\", "/", "", "/", "/", true, true}, +#else + {"a\\", ".", "a\\", "a\\", "a\\", false, false}, + {"a\\b", ".", "a\\b", "a\\b", "a\\b", false, false}, + {"\\", ".", "\\", "\\", "\\", false, false}, + {"\\/\\", "\\", "\\", "\\", "\\/\\",false, false}, + {"\\\\/", ".", "\\\\/","\\\\/","\\\\", true, false}, + {"\\//", ".", "\\//", "\\/", "\\", true, false}, +# if DOUBLE_SLASH_IS_DISTINCT_ROOT + {"//\\", "//", "\\", "\\", "//\\", false, true}, +# else + {"//\\", "/", "\\", "\\", "//\\", false, true}, +# endif +#endif +#if ISSLASH ('\\') +# if FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE + {"c:", "c:", "", "c:", "c:", false, false}, + {"c:/", "c:/", "", "c:/", "c:/", false, true}, + {"c://", "c:/", "", "c:/", "c:/", true, true}, + {"c:/d", "c:/", "d", "d", "c:/d", false, true}, + {"c://d", "c:/", "d", "d", "c://d",false, true}, + {"c:/d/", "c:/", "d/", "d/", "c:/d", true, true}, + {"c:/d/f", "c:/d", "f", "f", "c:/d/f",false, true}, + {"c:d", "c:.", "d", "d", "c:d", false, false}, + {"c:d/", "c:.", "d/", "d/", "c:d", true, false}, + {"c:d/f", "c:d", "f", "f", "c:d/f",false, false}, + {"a:b:c", "a:.", "b:c", "./b:c","a:b:c",false, false}, + {"a/b:c", "a", "b:c", "./b:c","a/b:c",false, false}, + {"a/b:c/", "a", "b:c/", "./b:c/","a/b:c",true, false}, +# else /* ! FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE */ + {"c:", "c:", "", "c:", "c:", false, true}, + {"c:/", "c:", "", "c:", "c:", true, true}, + {"c://", "c:", "", "c:", "c:", true, true}, + {"c:/d", "c:", "d", "d", "c:/d", false, true}, + {"c://d", "c:", "d", "d", "c://d",false, true}, + {"c:/d/", "c:", "d/", "d/", "c:/d", true, true}, + {"c:/d/f", "c:/d", "f", "f", "c:/d/f",false, true}, + {"c:d", "c:", "d", "d", "c:d", false, true}, + {"c:d/", "c:", "d/", "d/", "c:d", true, true}, + {"c:d/f", "c:d", "f", "f", "c:d/f",false, true}, + {"a:b:c", "a:", "b:c", "./b:c","a:b:c",false, true}, + {"a/b:c", "a", "b:c", "./b:c","a/b:c",false, false}, + {"a/b:c/", "a", "b:c/", "./b:c/","a/b:c",true, false}, +# endif +#else /* ! ISSLASH ('\\') */ + {"c:", ".", "c:", "c:", "c:", false, false}, + {"c:/", ".", "c:/", "c:/", "c:", true, false}, + {"c://", ".", "c://", "c:/", "c:", true, false}, + {"c:/d", "c:", "d", "d", "c:/d", false, false}, + {"c://d", "c:", "d", "d", "c://d",false, false}, + {"c:/d/", "c:", "d/", "d/", "c:/d", true, false}, + {"c:/d/f", "c:/d", "f", "f", "c:/d/f",false, false}, + {"c:d", ".", "c:d", "c:d", "c:d", false, false}, + {"c:d/", ".", "c:d/", "c:d/", "c:d", true, false}, + {"c:d/f", "c:d", "f", "f", "c:d/f",false, false}, + {"a:b:c", ".", "a:b:c","a:b:c","a:b:c",false, false}, + {"a/b:c", "a", "b:c", "b:c", "a/b:c",false, false}, + {"a/b:c/", "a", "b:c/", "b:c/", "a/b:c",true, false}, +#endif + {"1:", ".", "1:", "1:", "1:", false, false}, + {"1:/", ".", "1:/", "1:/", "1:", true, false}, + {"/:", "/", ":", ":", "/:", false, true}, + {"/:/", "/", ":/", ":/", "/:", true, true}, + /* End sentinel. */ + {NULL, NULL, NULL, NULL, NULL, false, false} +}; + +int +main (void) +{ + struct test *t; + bool ok = true; + + for (t = tests; t->name; t++) + { + char *dir = dir_name (t->name); + int dirlen = dir_len (t->name); + char *last = last_component (t->name); + char *base = base_name (t->name); + int baselen = base_len (base); + char *stripped = strdup (t->name); + bool modified = strip_trailing_slashes (stripped); + bool absolute = IS_ABSOLUTE_FILE_NAME (t->name); + if (! (strcmp (dir, t->dir) == 0 + && (dirlen == strlen (dir) + || (dirlen + 1 == strlen (dir) && dir[dirlen] == '.')))) + { + ok = false; + printf ("dir_name '%s': got '%s' len %d," + " expected '%s' len %lu\n", + t->name, dir, dirlen, + t->dir, (unsigned long) strlen (t->dir)); + } + if (strcmp (last, t->last)) + { + ok = false; + printf ("last_component '%s': got '%s', expected '%s'\n", + t->name, last, t->last); + } + if (! (strcmp (base, t->base) == 0 + && (baselen == strlen (base) + || (baselen + 1 == strlen (base) + && ISSLASH (base[baselen]))))) + { + ok = false; + printf ("base_name '%s': got '%s' len %d," + " expected '%s' len %lu\n", + t->name, base, baselen, + t->base, (unsigned long) strlen (t->base)); + } + if (strcmp (stripped, t->stripped) || modified != t->modified) + { + ok = false; + printf ("strip_trailing_slashes '%s': got %s %s, expected %s %s\n", + t->name, stripped, modified ? "changed" : "unchanged", + t->stripped, t->modified ? "changed" : "unchanged"); + } + if (t->absolute != absolute) + { + ok = false; + printf ("'%s': got %s, expected %s\n", t->name, + absolute ? "absolute" : "relative", + t->absolute ? "absolute" : "relative"); + } + free (dir); + free (base); + free (stripped); + } + return ok ? 0 : 1; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-dup-safer.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-dup-safer.c new file mode 100644 index 00000000..6ef6a2d3 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-dup-safer.c @@ -0,0 +1,183 @@ +/* Test that dup_safer leaves standard fds alone. + Copyright (C) 2009-2024 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 . */ + +/* Written by Eric Blake , 2009. */ + +#include + +#include "unistd--.h" + +#include +#include +#include +#include + +#include "binary-io.h" +#include "cloexec.h" + +#if defined _WIN32 && ! defined __CYGWIN__ +/* Get declarations of the native Windows API functions. */ +# define WIN32_LEAN_AND_MEAN +# include +/* Get _get_osfhandle. */ +# if GNULIB_MSVC_NOTHROW +# include "msvc-nothrow.h" +# else +# include +# endif +#endif + +#if !O_BINARY +# define set_binary_mode my_set_binary_mode +static int +set_binary_mode (_GL_UNUSED int fd, _GL_UNUSED int mode) +{ + return 0; +} +#endif + +/* This test intentionally closes stderr. So, we arrange to have fd 10 + (outside the range of interesting fd's during the test) set up to + duplicate the original stderr. */ + +#define BACKUP_STDERR_FILENO 10 +#define ASSERT_STREAM myerr +#include "macros.h" + +static FILE *myerr; + +/* Return true if FD is open. */ +static bool +is_open (int fd) +{ +#if defined _WIN32 && ! defined __CYGWIN__ + /* On native Windows, the initial state of unassigned standard file + descriptors is that they are open but point to an + INVALID_HANDLE_VALUE, and there is no fcntl. */ + return (HANDLE) _get_osfhandle (fd) != INVALID_HANDLE_VALUE; +#else +# ifndef F_GETFL +# error Please port fcntl to your platform +# endif + return 0 <= fcntl (fd, F_GETFL); +#endif +} + +/* Return true if FD is open and inheritable across exec/spawn. */ +static bool +is_inheritable (int fd) +{ +#if defined _WIN32 && ! defined __CYGWIN__ + /* On native Windows, the initial state of unassigned standard file + descriptors is that they are open but point to an + INVALID_HANDLE_VALUE, and there is no fcntl. */ + HANDLE h = (HANDLE) _get_osfhandle (fd); + DWORD flags; + if (h == INVALID_HANDLE_VALUE || GetHandleInformation (h, &flags) == 0) + return 0; + return (flags & HANDLE_FLAG_INHERIT) != 0; +#else +# ifndef F_GETFD +# error Please port fcntl to your platform +# endif + int i = fcntl (fd, F_GETFD); + return 0 <= i && (i & FD_CLOEXEC) == 0; +#endif +} + +/* Return true if FD is open in the given MODE, which is either + O_TEXT or O_BINARY. */ +static bool +is_mode (int fd, int mode) +{ + int value = set_binary_mode (fd, O_BINARY); + set_binary_mode (fd, value); + return mode == value; +} + +#define witness "test-dup-safer.txt" + +int +main (void) +{ + int i; + int fd; + int bad_fd = getdtablesize (); + + /* We close fd 2 later, so save it in fd 10. */ + if (dup2 (STDERR_FILENO, BACKUP_STDERR_FILENO) != BACKUP_STDERR_FILENO + || (myerr = fdopen (BACKUP_STDERR_FILENO, "w")) == NULL) + return 2; + + /* Create file for later checks. */ + fd = creat (witness, 0600); + ASSERT (STDERR_FILENO < fd); + + /* Four iterations, with progressively more standard descriptors + closed. */ + for (i = -1; i <= STDERR_FILENO; i++) + { + if (0 <= i) + ASSERT (close (i) == 0); + + /* Detect errors. */ + errno = 0; + ASSERT (dup (-1) == -1); + ASSERT (errno == EBADF); + errno = 0; + ASSERT (dup (bad_fd) == -1); + ASSERT (errno == EBADF); + close (fd + 1); + errno = 0; + ASSERT (dup (fd + 1) == -1); + ASSERT (errno == EBADF); + + /* Preserve text vs. binary. */ + set_binary_mode (fd, O_BINARY); + ASSERT (dup (fd) == fd + 1); + ASSERT (is_open (fd + 1)); + ASSERT (is_inheritable (fd + 1)); + ASSERT (is_mode (fd + 1, O_BINARY)); + + ASSERT (close (fd + 1) == 0); + set_binary_mode (fd, O_TEXT); + ASSERT (dup (fd) == fd + 1); + ASSERT (is_open (fd + 1)); + ASSERT (is_inheritable (fd + 1)); + ASSERT (is_mode (fd + 1, O_TEXT)); + + /* Create cloexec copy. */ + ASSERT (close (fd + 1) == 0); + ASSERT (fd_safer_flag (dup_cloexec (fd), O_CLOEXEC) == fd + 1); + ASSERT (set_cloexec_flag (fd + 1, true) == 0); + ASSERT (is_open (fd + 1)); + ASSERT (!is_inheritable (fd + 1)); + ASSERT (close (fd) == 0); + + /* dup always creates inheritable copies. Also, check that + earliest slot past std fds is used. */ + ASSERT (dup (fd + 1) == fd); + ASSERT (is_open (fd)); + ASSERT (is_inheritable (fd)); + ASSERT (close (fd + 1) == 0); + } + + /* Cleanup. */ + ASSERT (close (fd) == 0); + ASSERT (unlink (witness) == 0); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-dup.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-dup.c new file mode 100644 index 00000000..cb312020 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-dup.c @@ -0,0 +1,45 @@ +/* Test duplicating a file descriptor. + Copyright (C) 2011-2024 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 . */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (dup, int, (int)); + +#include + +#include "macros.h" + +int +main (void) +{ + /* Test behaviour for invalid file descriptors. */ + { + errno = 0; + ASSERT (dup (-1) == -1); + ASSERT (errno == EBADF); + } + { + close (99); + errno = 0; + ASSERT (dup (99) == -1); + ASSERT (errno == EBADF); + } + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-dup2.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-dup2.c new file mode 100644 index 00000000..55f31940 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-dup2.c @@ -0,0 +1,232 @@ +/* Test duplicating file descriptors. + Copyright (C) 2009-2024 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 . */ + +/* Written by Eric Blake , 2009. */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (dup2, int, (int, int)); + +#include +#include + +#if HAVE_SYS_RESOURCE_H +# include +#endif + +#include "binary-io.h" + +#if GNULIB_TEST_CLOEXEC +# include "cloexec.h" +#endif + +#if defined _WIN32 && ! defined __CYGWIN__ +/* Get declarations of the native Windows API functions. */ +# define WIN32_LEAN_AND_MEAN +# include +/* Get _get_osfhandle. */ +# if GNULIB_MSVC_NOTHROW +# include "msvc-nothrow.h" +# else +# include +# endif +#endif + +#include "macros.h" + +/* Tell GCC not to warn about the specific edge cases tested here. */ +#if __GNUC__ >= 13 +# pragma GCC diagnostic ignored "-Wanalyzer-fd-leak" +# pragma GCC diagnostic ignored "-Wanalyzer-fd-use-without-check" +#endif + +/* Return non-zero if FD is open. */ +static int +is_open (int fd) +{ +#if defined _WIN32 && ! defined __CYGWIN__ + /* On native Windows, the initial state of unassigned standard file + descriptors is that they are open but point to an + INVALID_HANDLE_VALUE, and there is no fcntl. */ + return (HANDLE) _get_osfhandle (fd) != INVALID_HANDLE_VALUE; +#else +# ifndef F_GETFL +# error Please port fcntl to your platform +# endif + return 0 <= fcntl (fd, F_GETFL); +#endif +} + +#if GNULIB_TEST_CLOEXEC +/* Return non-zero if FD is open and inheritable across exec/spawn. */ +static int +is_inheritable (int fd) +{ +# if defined _WIN32 && ! defined __CYGWIN__ + /* On native Windows, the initial state of unassigned standard file + descriptors is that they are open but point to an + INVALID_HANDLE_VALUE, and there is no fcntl. */ + HANDLE h = (HANDLE) _get_osfhandle (fd); + DWORD flags; + if (h == INVALID_HANDLE_VALUE || GetHandleInformation (h, &flags) == 0) + return 0; + return (flags & HANDLE_FLAG_INHERIT) != 0; +# else +# ifndef F_GETFD +# error Please port fcntl to your platform +# endif + int i = fcntl (fd, F_GETFD); + return 0 <= i && (i & FD_CLOEXEC) == 0; +# endif +} +#endif /* GNULIB_TEST_CLOEXEC */ + +#if !O_BINARY +# define set_binary_mode my_set_binary_mode +static int +set_binary_mode (_GL_UNUSED int fd, _GL_UNUSED int mode) +{ + return 0; +} +#endif + +/* Return non-zero if FD is open in the given MODE, which is either + O_TEXT or O_BINARY. */ +static int +is_mode (int fd, int mode) +{ + int value = set_binary_mode (fd, O_BINARY); + set_binary_mode (fd, value); + return mode == value; +} + +int +main (void) +{ + const char *file = "test-dup2.tmp"; + char buffer[1]; + int bad_fd = getdtablesize (); + int fd = open (file, O_CREAT | O_TRUNC | O_RDWR, 0600); + + /* Assume std descriptors were provided by invoker. */ + ASSERT (STDERR_FILENO < fd); + ASSERT (is_open (fd)); + /* Ignore any other fd's leaked into this process. */ + close (fd + 1); + close (fd + 2); + ASSERT (!is_open (fd + 1)); + ASSERT (!is_open (fd + 2)); + + /* Assigning to self must be a no-op. */ + ASSERT (dup2 (fd, fd) == fd); + ASSERT (is_open (fd)); + + /* The source must be valid. */ + errno = 0; + ASSERT (dup2 (-1, fd) == -1); + ASSERT (errno == EBADF); + close (99); + errno = 0; + ASSERT (dup2 (99, fd) == -1); + ASSERT (errno == EBADF); + errno = 0; + ASSERT (dup2 (AT_FDCWD, fd) == -1); + ASSERT (errno == EBADF); + ASSERT (is_open (fd)); + + /* If the source is not open, then the destination is unaffected. */ + errno = 0; + ASSERT (dup2 (fd + 1, fd + 1) == -1); + ASSERT (errno == EBADF); + ASSERT (!is_open (fd + 1)); + errno = 0; + ASSERT (dup2 (fd + 1, fd) == -1); + ASSERT (errno == EBADF); + ASSERT (is_open (fd)); + + /* The destination must be valid. */ + errno = 0; + ASSERT (dup2 (fd, -2) == -1); + ASSERT (errno == EBADF); + if (bad_fd > 256) + { + ASSERT (dup2 (fd, 255) == 255); + ASSERT (dup2 (fd, 256) == 256); + ASSERT (close (255) == 0); + ASSERT (close (256) == 0); + } + ASSERT (dup2 (fd, bad_fd - 1) == bad_fd - 1); + ASSERT (close (bad_fd - 1) == 0); + errno = 0; + ASSERT (dup2 (fd, bad_fd) == -1); + ASSERT (errno == EBADF); + + /* Using dup2 can skip fds. */ + ASSERT (dup2 (fd, fd + 2) == fd + 2); + ASSERT (is_open (fd)); + ASSERT (!is_open (fd + 1)); + ASSERT (is_open (fd + 2)); + + /* Verify that dup2 closes the previous occupant of a fd. */ + ASSERT (open ("/dev/null", O_WRONLY, 0600) == fd + 1); + ASSERT (dup2 (fd + 1, fd) == fd); + ASSERT (close (fd + 1) == 0); + ASSERT (write (fd, "1", 1) == 1); + ASSERT (dup2 (fd + 2, fd) == fd); + ASSERT (lseek (fd, 0, SEEK_END) == 0); + ASSERT (write (fd + 2, "2", 1) == 1); + ASSERT (lseek (fd, 0, SEEK_SET) == 0); + ASSERT (read (fd, buffer, 1) == 1); + ASSERT (*buffer == '2'); + +#if GNULIB_TEST_CLOEXEC + /* Any new fd created by dup2 must not be cloexec. */ + ASSERT (close (fd + 2) == 0); + ASSERT (dup_cloexec (fd) == fd + 1); + ASSERT (!is_inheritable (fd + 1)); + ASSERT (dup2 (fd + 1, fd + 1) == fd + 1); + ASSERT (!is_inheritable (fd + 1)); + ASSERT (dup2 (fd + 1, fd + 2) == fd + 2); + ASSERT (!is_inheritable (fd + 1)); + ASSERT (is_inheritable (fd + 2)); + errno = 0; + ASSERT (dup2 (fd + 1, -1) == -1); + ASSERT (errno == EBADF); + ASSERT (!is_inheritable (fd + 1)); +#endif + + /* On systems that distinguish between text and binary mode, dup2 + reuses the mode of the source. */ + set_binary_mode (fd, O_BINARY); + ASSERT (is_mode (fd, O_BINARY)); + ASSERT (dup2 (fd, fd + 1) == fd + 1); + ASSERT (is_mode (fd + 1, O_BINARY)); + set_binary_mode (fd, O_TEXT); + ASSERT (is_mode (fd, O_TEXT)); + ASSERT (dup2 (fd, fd + 1) == fd + 1); + ASSERT (is_mode (fd + 1, O_TEXT)); + + /* Clean up. */ + ASSERT (close (fd + 2) == 0); + ASSERT (close (fd + 1) == 0); + ASSERT (close (fd) == 0); + ASSERT (unlink (file) == 0); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-dynarray.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-dynarray.c new file mode 100644 index 00000000..024bef2d --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-dynarray.c @@ -0,0 +1,53 @@ +/* Test of type-safe arrays that grow dynamically. + Copyright (C) 2021-2024 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, see . */ + +/* Written by Bruno Haible , 2021. */ + +#include + +#define DYNARRAY_STRUCT int_sequence +#define DYNARRAY_ELEMENT int +#define DYNARRAY_PREFIX intseq_ +#include "dynarray.h" + +#include "macros.h" + +#define N 100000 + +static int +value_at (long long int i) +{ + return (i % 13) + ((i * i) % 251); +} + +int +main () +{ + struct int_sequence s; + int i; + + intseq_init (&s); + for (i = 0; i < N; i++) + intseq_add (&s, value_at (i)); + for (i = N - 1; i >= N / 2; i--) + { + ASSERT (* intseq_at (&s, i) == value_at (i)); + intseq_remove_last (&s); + } + intseq_free (&s); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-environ.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-environ.c new file mode 100644 index 00000000..fdd944f6 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-environ.c @@ -0,0 +1,44 @@ +/* Test of environ variable. + Copyright (C) 2008-2024 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 . */ + +/* Written by Bruno Haible , 2008. */ + +#include + +#include + +#include + +int +main () +{ + /* The environment variables that are set even in the weirdest situations + are HOME and PATH. + POSIX says that HOME is initialized by the system, and that PATH may be + unset. But in practice it's more frequent to see HOME unset and PATH + set. So we test the presence of PATH. */ + char **remaining_variables = environ; + char *string; + + for (; (string = *remaining_variables) != NULL; remaining_variables++) + { + if (strncmp (string, "PATH=", 5) == 0) + /* Found the PATH environment variable. */ + return 0; + } + /* Failed to find the PATH environment variable. */ + return 1; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-errno.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-errno.c new file mode 100644 index 00000000..99600add --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-errno.c @@ -0,0 +1,119 @@ +/* Test of substitute. + Copyright (C) 2008-2024 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 . */ + +/* Written by Bruno Haible , 2008. */ + +#include + +#include + +/* Verify that the POSIX mandated errno values exist and can be used as + initializers outside of a function. + The variable names happen to match the Linux/x86 error numbers. */ +int e1 = EPERM; +int e2 = ENOENT; +int e3 = ESRCH; +int e4 = EINTR; +int e5 = EIO; +int e6 = ENXIO; +int e7 = E2BIG; +int e8 = ENOEXEC; +int e9 = EBADF; +int e10 = ECHILD; +int e11 = EAGAIN; +int e11a = EWOULDBLOCK; +int e12 = ENOMEM; +int e13 = EACCES; +int e14 = EFAULT; +int e16 = EBUSY; +int e17 = EEXIST; +int e18 = EXDEV; +int e19 = ENODEV; +int e20 = ENOTDIR; +int e21 = EISDIR; +int e22 = EINVAL; +int e23 = ENFILE; +int e24 = EMFILE; +int e25 = ENOTTY; +int e26 = ETXTBSY; +int e27 = EFBIG; +int e28 = ENOSPC; +int e29 = ESPIPE; +int e30 = EROFS; +int e31 = EMLINK; +int e32 = EPIPE; +int e33 = EDOM; +int e34 = ERANGE; +int e35 = EDEADLK; +int e36 = ENAMETOOLONG; +int e37 = ENOLCK; +int e38 = ENOSYS; +int e39 = ENOTEMPTY; +int e40 = ELOOP; +int e42 = ENOMSG; +int e43 = EIDRM; +int e67 = ENOLINK; +int e71 = EPROTO; +int e72 = EMULTIHOP; +int e74 = EBADMSG; +int e75 = EOVERFLOW; +int e84 = EILSEQ; +int e88 = ENOTSOCK; +int e89 = EDESTADDRREQ; +int e90 = EMSGSIZE; +int e91 = EPROTOTYPE; +int e92 = ENOPROTOOPT; +int e93 = EPROTONOSUPPORT; +int e95 = EOPNOTSUPP; +int e95a = ENOTSUP; +int e97 = EAFNOSUPPORT; +int e98 = EADDRINUSE; +int e99 = EADDRNOTAVAIL; +int e100 = ENETDOWN; +int e101 = ENETUNREACH; +int e102 = ENETRESET; +int e103 = ECONNABORTED; +int e104 = ECONNRESET; +int e105 = ENOBUFS; +int e106 = EISCONN; +int e107 = ENOTCONN; +int e110 = ETIMEDOUT; +int e111 = ECONNREFUSED; +int e113 = EHOSTUNREACH; +int e114 = EALREADY; +int e115 = EINPROGRESS; +int e116 = ESTALE; +int e122 = EDQUOT; +int e125 = ECANCELED; +int e130 = EOWNERDEAD; +int e131 = ENOTRECOVERABLE; + +/* Don't verify that these errno values are all different, except for possibly + EWOULDBLOCK == EAGAIN. Even Linux/x86 does not pass this check: it has + ENOTSUP == EOPNOTSUPP. */ + +int +main () +{ + /* Verify that errno can be assigned. */ + errno = EOVERFLOW; + + /* snprintf() callers want to distinguish EINVAL and EOVERFLOW. */ + if (errno == EINVAL) + return 1; + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-error.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-error.c new file mode 100644 index 00000000..02704d7c --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-error.c @@ -0,0 +1,89 @@ +/* Test of error.h functions. + Copyright (C) 2023-2024 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 . */ + +/* Written by Bruno Haible , 2023. */ + +#include + +/* Specification. */ +#include + +#include + +#include "macros.h" + +/* Custom function to not show the program name in error messages. */ +static void +print_no_progname (void) +{ +} + +int +main () +{ + /* Test error() function with zero STATUS and zero ERRNUM. */ + error (0, 0, "bummer"); + /* With format string arguments. */ + errno = EINVAL; /* should be ignored */ + error (0, 0, "Zonk %d%d%d is too large", 1, 2, 3); + /* With non-ASCII characters. */ + error (0, 0, "Pokémon started"); + /* Verify error_message_count. */ + ASSERT (error_message_count == 3); + + /* Test error_at_line() function with zero STATUS and zero ERRNUM. */ + error_at_line (0, 0, "d1/foo.c", 10, "invalid blub"); + error_at_line (0, 0, "d1/foo.c", 10, "invalid blarn"); + /* Verify error_message_count. */ + ASSERT (error_message_count == 5); + + /* Test error_one_per_line. */ + error_one_per_line = 1; + error_at_line (0, 0, "d1/foo.c", 10, "unsupported glink"); + /* Another line number. */ + error_at_line (0, 0, "d1/foo.c", 13, "invalid brump"); + /* Another file name. */ + error_at_line (0, 0, "d2/foo.c", 13, "unsupported flinge"); + /* Same file name and same line number => message not shown. */ + error_at_line (0, 0, "d2/foo.c", 13, "invalid bark"); + /* Verify error_message_count. */ + ASSERT (error_message_count == 8); + error_one_per_line = 0; + + /* Test error_print_progname. */ + error_print_progname = print_no_progname; + error (0, 0, "hammer"); + error (0, 0, "boing %d%d%d is too large", 1, 2, 3); + #if 0 + /* The documentation does not describe the output if the file name is NULL. */ + error_at_line (0, 0, NULL, 42, "drummer too loud"); + #endif + error_at_line (0, 0, "d2/bar.c", 11, "bark too loud"); + /* Verify error_message_count. */ + ASSERT (error_message_count == 11); + error_print_progname = NULL; + + /* Test error() function with nonzero ERRNUM. */ + errno = EINVAL; /* should be ignored */ + error (0, EACCES, "can't steal"); + /* Verify error_message_count. */ + ASSERT (error_message_count == 12); + + /* Test error() function with nonzero STATUS. */ + error (4, 0, "fatal error"); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-error.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-error.sh new file mode 100755 index 00000000..d173e183 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-error.sh @@ -0,0 +1,36 @@ +#!/bin/sh +# Test of the 'error' module. + +. "${srcdir=.}/init.sh"; path_prepend_ . + +${CHECKER} test-error${EXEEXT} > out 2> err +# Verify the exit code. +case $? in + 4) ;; + *) Exit 1;; +esac + +# Normalize the stderr output on Windows platforms. +tr -d '\015' < err | sed 's,.*test-error[.ex]*:,test-error:,' > err2 || Exit 1 + +# Verify the stderr output. +compare - err2 <<\EOF || Exit 1 +test-error: bummer +test-error: Zonk 123 is too large +test-error: Pokémon started +test-error:d1/foo.c:10: invalid blub +test-error:d1/foo.c:10: invalid blarn +test-error:d1/foo.c:10: unsupported glink +test-error:d1/foo.c:13: invalid brump +test-error:d2/foo.c:13: unsupported flinge +hammer +boing 123 is too large +d2/bar.c:11: bark too loud +test-error: can't steal: Permission denied +test-error: fatal error +EOF + +# Verify the stdout output. +test -s out && Exit 1 + +Exit 0 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-exclude.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-exclude.c new file mode 100644 index 00000000..2af6014d --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-exclude.c @@ -0,0 +1,127 @@ +/* Test suite for exclude. + Copyright (C) 2009-2024 Free Software Foundation, Inc. + This file is part of the GNUlib Library. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include +#include +#include +#include +#include +#include + +#include +#include "exclude.h" +#include "argmatch.h" + +#ifndef FNM_CASEFOLD +# define FNM_CASEFOLD 0 +#endif +#ifndef FNM_LEADING_DIR +# define FNM_LEADING_DIR 0 +#endif + +char const * const exclude_keywords[] = { + "noescape", + "pathname", + "period", + "leading_dir", + "casefold", + "anchored", + "include", + "wildcards", + NULL +}; + +int exclude_flags[] = { + FNM_NOESCAPE, + FNM_PATHNAME, + FNM_PERIOD, + FNM_LEADING_DIR, + FNM_CASEFOLD, + EXCLUDE_ANCHORED, + EXCLUDE_INCLUDE, + EXCLUDE_WILDCARDS +}; + +ARGMATCH_VERIFY (exclude_keywords, exclude_flags); + +/* Some packages define ARGMATCH_DIE and ARGMATCH_DIE_DECL in , and + thus must link with a definition of that function. Provide it here. */ +#ifdef ARGMATCH_DIE_DECL + +_Noreturn ARGMATCH_DIE_DECL; +ARGMATCH_DIE_DECL { exit (1); } + +#endif + +int +main (int argc, char **argv) +{ + int exclude_options = 0; + struct exclude *exclude = new_exclude (); + + if (argc == 1) + error (1, 0, "usage: %s file -- words...", argv[0]); + + while (--argc) + { + char *opt = *++argv; + if (opt[0] == '-') + { + int neg = 0; + int flag; + char *s = opt + 1; + + if (opt[1] == '-' && opt[2] == 0) + { + argc--; + break; + } + if (strlen (s) > 3 && memcmp (s, "no-", 3) == 0) + { + neg = 1; + s += 3; + } + flag = XARGMATCH (opt, s, exclude_keywords, exclude_flags); + if (neg) + exclude_options &= ~flag; + else + exclude_options |= flag; + + /* Skip this test if invoked with -leading-dir on a system that + lacks support for FNM_LEADING_DIR. */ + if (strcmp (s, "leading_dir") == 0 && FNM_LEADING_DIR == 0) + exit (77); + + /* Likewise for -casefold and FNM_CASEFOLD. */ + if (strcmp (s, "casefold") == 0 && FNM_CASEFOLD == 0) + exit (77); + } + else if (add_exclude_file (add_exclude, exclude, opt, + exclude_options, '\n') != 0) + error (1, errno, "error loading %s", opt); + } + + for (; argc; --argc) + { + char *word = *++argv; + + printf ("%s: %d\n", word, excluded_file_name (exclude, word)); + } + + free_exclude (exclude); + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-exclude1.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-exclude1.sh new file mode 100755 index 00000000..8800442c --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-exclude1.sh @@ -0,0 +1,50 @@ +#! /bin/sh +# Test suite for exclude. +# Copyright (C) 2009-2024 Free Software Foundation, Inc. +# This file is part of the GNUlib Library. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ . +fail=0 + +# Test literal matches + +cat > in < expected < out || exit $? + +# Find out how to remove carriage returns from output. Solaris /usr/ucb/tr +# does not understand '\r'. +case $(echo r | tr -d '\r') in '') cr='\015';; *) cr='\r';; esac + +# normalize output +LC_ALL=C tr -d "$cr" < out > k && mv k out + +compare expected out || fail=1 + +Exit $fail diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-exclude2.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-exclude2.sh new file mode 100755 index 00000000..45711554 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-exclude2.sh @@ -0,0 +1,50 @@ +#! /bin/sh +# Test suite for exclude. +# Copyright (C) 2009-2024 Free Software Foundation, Inc. +# This file is part of the GNUlib Library. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ . +fail=0 + +cat > in < expected < out || exit $? + +# Find out how to remove carriage returns from output. Solaris /usr/ucb/tr +# does not understand '\r'. +case $(echo r | tr -d '\r') in '') cr='\015';; *) cr='\r';; esac + +# normalize output +LC_ALL=C tr -d "$cr" < out > k && mv k out + +compare expected out || fail=1 + +Exit $fail diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-exclude3.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-exclude3.sh new file mode 100755 index 00000000..3568a8a7 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-exclude3.sh @@ -0,0 +1,50 @@ +#! /bin/sh +# Test suite for exclude. +# Copyright (C) 2009-2024 Free Software Foundation, Inc. +# This file is part of the GNUlib Library. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ . +fail=0 + +# Test include + +cat > in < expected < out || exit $? + +# Find out how to remove carriage returns from output. Solaris /usr/ucb/tr +# does not understand '\r'. +case $(echo r | tr -d '\r') in '') cr='\015';; *) cr='\r';; esac + +# normalize output +LC_ALL=C tr -d "$cr" < out > k && mv k out + +compare expected out || fail=1 + +Exit $fail diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-exclude4.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-exclude4.sh new file mode 100755 index 00000000..6646e54a --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-exclude4.sh @@ -0,0 +1,45 @@ +#! /bin/sh +# Test suite for exclude. +# Copyright (C) 2009-2024 Free Software Foundation, Inc. +# This file is part of the GNUlib Library. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ . +fail=0 + +# Test wildcard matching + +cat > in < expected < out || exit $? + +# Find out how to remove carriage returns from output. Solaris /usr/ucb/tr +# does not understand '\r'. +case $(echo r | tr -d '\r') in '') cr='\015';; *) cr='\r';; esac + +# normalize output +LC_ALL=C tr -d "$cr" < out > k && mv k out + +compare expected out || fail=1 + +Exit $fail diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-exclude5.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-exclude5.sh new file mode 100755 index 00000000..0c1ab18b --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-exclude5.sh @@ -0,0 +1,48 @@ +#! /bin/sh +# Test suite for exclude. +# Copyright (C) 2009-2024 Free Software Foundation, Inc. +# This file is part of the GNUlib Library. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ . +fail=0 + +# Test FNM_LEADING_DIR + +cat > in < expected < out || exit $? + +# Find out how to remove carriage returns from output. Solaris /usr/ucb/tr +# does not understand '\r'. +case $(echo r | tr -d '\r') in '') cr='\015';; *) cr='\r';; esac + +# normalize output +LC_ALL=C tr -d "$cr" < out > k && mv k out + +compare expected out || fail=1 + +Exit $fail diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-exclude6.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-exclude6.sh new file mode 100755 index 00000000..adfd30f2 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-exclude6.sh @@ -0,0 +1,46 @@ +#! /bin/sh +# Test suite for exclude. +# Copyright (C) 2009-2024 Free Software Foundation, Inc. +# This file is part of the GNUlib Library. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ . +fail=0 + +# Test anchored + +cat > in < expected < out || exit $? + +# Find out how to remove carriage returns from output. Solaris /usr/ucb/tr +# does not understand '\r'. +case $(echo r | tr -d '\r') in '') cr='\015';; *) cr='\r';; esac + +# normalize output +LC_ALL=C tr -d "$cr" < out > k && mv k out + +compare expected out || fail=1 + +Exit $fail diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-exclude7.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-exclude7.sh new file mode 100755 index 00000000..3edaf0cb --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-exclude7.sh @@ -0,0 +1,47 @@ +#! /bin/sh +# Test suite for exclude. +# Copyright (C) 2009-2024 Free Software Foundation, Inc. +# This file is part of the GNUlib Library. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ . +fail=0 + +# Test exclude precedence + +cat > in < expected < out || exit $? +${CHECKER} test-exclude -include in -no-include in -- bar >> out || exit $? + +# Find out how to remove carriage returns from output. Solaris /usr/ucb/tr +# does not understand '\r'. +case $(echo r | tr -d '\r') in '') cr='\015';; *) cr='\r';; esac + +# normalize output +LC_ALL=C tr -d "$cr" < out > k && mv k out + +compare expected out || fail=1 + +Exit $fail diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-exclude8.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-exclude8.sh new file mode 100755 index 00000000..eb8dd205 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-exclude8.sh @@ -0,0 +1,46 @@ +#! /bin/sh +# Test suite for exclude. +# Copyright (C) 2010-2024 Free Software Foundation, Inc. +# This file is part of the GNUlib Library. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ . +fail=0 + +# Test escaped metacharacters. + +cat > in <<'EOT' +f\*e +b[a\*]r +EOT + +cat > expected <<'EOT' +f*e: 1 +file: 0 +bar: 1 +EOT + +${CHECKER} test-exclude -wildcards in -- 'f*e' 'file' 'bar' > out || exit $? + +# Find out how to remove carriage returns from output. Solaris /usr/ucb/tr +# does not understand '\r'. +case $(echo r | tr -d '\r') in '') cr='\015';; *) cr='\r';; esac + +# normalize output +LC_ALL=C tr -d "$cr" < out > k && mv k out + +compare expected out || fail=1 + +Exit $fail diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fchdir.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fchdir.c new file mode 100644 index 00000000..dc529745 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fchdir.c @@ -0,0 +1,110 @@ +/* Test changing to a directory named by a file descriptor. + Copyright (C) 2009-2024 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 . */ + +/* Written by Eric Blake , 2009. */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (fchdir, int, (int)); + +#include +#include +#include +#include + +#include "cloexec.h" +#include "macros.h" + +int +main (void) +{ + char *cwd; + int fd; + int i; + + cwd = getcwd (NULL, 0); + ASSERT (cwd); + + fd = open (".", O_RDONLY); + ASSERT (0 <= fd); + + /* Test behaviour for invalid file descriptors. */ + { + errno = 0; + ASSERT (fchdir (-1) == -1); + ASSERT (errno == EBADF); + } + { + close (99); + errno = 0; + ASSERT (fchdir (99) == -1); + ASSERT (errno == EBADF); + } + + /* Check for other failure cases. */ + { + int bad_fd = open ("/dev/null", O_RDONLY); + ASSERT (0 <= bad_fd); + errno = 0; + ASSERT (fchdir (bad_fd) == -1); + ASSERT (errno == ENOTDIR); + ASSERT (close (bad_fd) == 0); + } + + /* Repeat test twice, once in '.' and once in '..'. */ + for (i = 0; i < 2; i++) + { + ASSERT (chdir (&".."[1 - i]) == 0); + ASSERT (fchdir (fd) == 0); + { + size_t len = strlen (cwd) + 1; + char *new_dir = malloc (len); + ASSERT (new_dir); + ASSERT (getcwd (new_dir, len) == new_dir); + ASSERT (strcmp (cwd, new_dir) == 0); + free (new_dir); + } + + /* For second iteration, use a cloned fd, to ensure that dup + remembers whether an fd was associated with a directory. */ + if (!i) + { + int new_fd = dup (fd); + ASSERT (0 <= new_fd); + ASSERT (close (fd) == 0); + ASSERT (dup2 (new_fd, fd) == fd); + ASSERT (close (new_fd) == 0); + ASSERT (dup_cloexec (fd) == new_fd); + ASSERT (dup2 (new_fd, fd) == fd); + ASSERT (close (new_fd) == 0); + ASSERT (fcntl (fd, F_DUPFD_CLOEXEC, new_fd) == new_fd); + ASSERT (close (fd) == 0); + ASSERT (fcntl (new_fd, F_DUPFD, fd) == fd); + ASSERT (close (new_fd) == 0); +#if GNULIB_TEST_DUP3 + ASSERT (dup3 (fd, new_fd, 0) == new_fd); + ASSERT (dup3 (new_fd, fd, 0) == fd); + ASSERT (close (new_fd) == 0); +#endif + } + } + + free (cwd); + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fcntl-h.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fcntl-h.c new file mode 100644 index 00000000..d6331672 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fcntl-h.c @@ -0,0 +1,130 @@ +/* Test of substitute. + Copyright (C) 2007, 2009-2024 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 . */ + +/* Written by Bruno Haible , 2007. */ + +#include + +#include + +/* Check that the various O_* macros are defined. */ +int o = (O_DIRECT | O_DIRECTORY | O_DSYNC | O_IGNORE_CTTY | O_NDELAY | O_NOATIME + | O_NONBLOCK | O_NOCTTY | O_NOFOLLOW | O_NOLINK | O_NOLINKS | O_NOTRANS + | O_RSYNC | O_SYNC | O_TTY_INIT | O_BINARY | O_TEXT); + +/* Check that the various SEEK_* macros are defined. */ +int sk[] = { SEEK_CUR, SEEK_END, SEEK_SET }; + +/* Check that the FD_* macros are defined. */ +int i = FD_CLOEXEC; + +/* Check that the types are all defined. */ +pid_t t1; +off_t t2; +mode_t t3; + +int +main (void) +{ + /* Ensure no overlap in SEEK_*. */ + switch (0) + { + case SEEK_CUR: + case SEEK_END: + case SEEK_SET: + ; + } + + /* Ensure no dangerous overlap in non-zero gnulib-defined replacements. */ + switch (O_RDONLY) + { + /* Access modes */ + case O_RDONLY: + case O_WRONLY: + case O_RDWR: +#if O_EXEC && O_EXEC != O_RDONLY + case O_EXEC: +#endif +#if O_SEARCH && O_EXEC != O_SEARCH && O_SEARCH != O_RDONLY + case O_SEARCH: +#endif + i = ! (~O_ACCMODE & (O_RDONLY | O_WRONLY | O_RDWR | O_EXEC | O_SEARCH)); + break; + + /* Everyone should have these */ + case O_CREAT: + case O_EXCL: + case O_TRUNC: + case O_APPEND: + break; + + /* These might be 0 or O_RDONLY, only test non-zero versions. */ +#if O_CLOEXEC + case O_CLOEXEC: +#endif +#if O_DIRECT + case O_DIRECT: +#endif +#if O_DIRECTORY + case O_DIRECTORY: +#endif +#if O_DSYNC + case O_DSYNC: +#endif +#if O_IGNORE_CTTY + case O_IGNORE_CTTY: +#endif +#if O_NOATIME + case O_NOATIME: +#endif +#if O_NONBLOCK + case O_NONBLOCK: +#endif +#if O_NOCTTY + case O_NOCTTY: +#endif +#if O_NOFOLLOW + case O_NOFOLLOW: +#endif +#if O_NOLINK + case O_NOLINK: +#endif +#if O_NOLINKS + case O_NOLINKS: +#endif +#if O_NOTRANS + case O_NOTRANS: +#endif +#if O_RSYNC && O_RSYNC != O_DSYNC + case O_RSYNC: +#endif +#if O_SYNC && O_SYNC != O_DSYNC && O_SYNC != O_RSYNC + case O_SYNC: +#endif +#if O_TTY_INIT + case O_TTY_INIT: +#endif +#if O_BINARY + case O_BINARY: +#endif +#if O_TEXT + case O_TEXT: +#endif + ; + } + + return !i; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fcntl.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fcntl.c new file mode 100644 index 00000000..0eb24a9f --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fcntl.c @@ -0,0 +1,444 @@ +/* Test of fcntl(2). + Copyright (C) 2009-2024 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 . */ + +/* Written by Eric Blake , 2009. */ + +#include + +/* Specification. */ +#include + +#include "signature.h" +SIGNATURE_CHECK (fcntl, int, (int, int, ...)); + +/* Helpers. */ +#include +#include +#include + +#if defined _WIN32 && ! defined __CYGWIN__ +/* Get declarations of the native Windows API functions. */ +# define WIN32_LEAN_AND_MEAN +# include +/* Get _get_osfhandle. */ +# if GNULIB_MSVC_NOTHROW +# include "msvc-nothrow.h" +# else +# include +# endif +#endif + +#include "binary-io.h" +#include "macros.h" + +/* Tell GCC not to warn about the specific edge cases tested here. */ +#if __GNUC__ >= 13 +# pragma GCC diagnostic ignored "-Wanalyzer-fd-leak" +# pragma GCC diagnostic ignored "-Wanalyzer-va-arg-type-mismatch" +#endif + +#if !O_BINARY +# define set_binary_mode my_set_binary_mode +static int +set_binary_mode (_GL_UNUSED int fd, _GL_UNUSED int mode) +{ + return 0; +} +#endif + +/* Return true if FD is open. */ +static bool +is_open (int fd) +{ +#if defined _WIN32 && ! defined __CYGWIN__ + /* On native Windows, the initial state of unassigned standard file + descriptors is that they are open but point to an + INVALID_HANDLE_VALUE, and there is no fcntl. */ + return (HANDLE) _get_osfhandle (fd) != INVALID_HANDLE_VALUE; +#else +# ifndef F_GETFL +# error Please port fcntl to your platform +# endif + return 0 <= fcntl (fd, F_GETFL); +#endif +} + +/* Return true if FD is open and inheritable across exec/spawn. */ +static bool +is_inheritable (int fd) +{ +#if defined _WIN32 && ! defined __CYGWIN__ + /* On native Windows, the initial state of unassigned standard file + descriptors is that they are open but point to an + INVALID_HANDLE_VALUE, and there is no fcntl. */ + HANDLE h = (HANDLE) _get_osfhandle (fd); + DWORD flags; + if (h == INVALID_HANDLE_VALUE || GetHandleInformation (h, &flags) == 0) + return false; + return (flags & HANDLE_FLAG_INHERIT) != 0; +#else +# ifndef F_GETFD +# error Please port fcntl to your platform +# endif + int i = fcntl (fd, F_GETFD); + return 0 <= i && (i & FD_CLOEXEC) == 0; +#endif +} + +/* Return non-zero if FD is open in the given MODE, which is either + O_TEXT or O_BINARY. */ +static bool +is_mode (int fd, int mode) +{ + int value = set_binary_mode (fd, O_BINARY); + set_binary_mode (fd, value); + return mode == value; +} + +/* Since native fcntl can have more supported operations than our + replacement is aware of, and since various operations assign + different types to the vararg argument, a wrapper around fcntl must + be able to pass a vararg of unknown type on through to the original + fcntl. Make sure that this works properly: func1 behaves like the + original fcntl interpreting the vararg as an int or a pointer to a + struct, and func2 behaves like rpl_fcntl that doesn't know what + type to forward. */ +struct dummy_struct +{ + long filler; + int value; +}; +static int +func1 (int a, ...) +{ + va_list arg; + int i; + va_start (arg, a); + if (a < 4) + i = va_arg (arg, int); + else + { + struct dummy_struct *s = va_arg (arg, struct dummy_struct *); + i = s->value; + } + va_end (arg); + return i; +} +static int +func2 (int a, ...) +{ + va_list arg; + void *p; + va_start (arg, a); + p = va_arg (arg, void *); + va_end (arg); + return func1 (a, p); +} + +/* Ensure that all supported fcntl actions are distinct, and + usable in preprocessor expressions. */ +static void +check_flags (void) +{ + switch (0) + { + case F_DUPFD: +#if F_DUPFD +#endif + + case F_DUPFD_CLOEXEC: +#if F_DUPFD_CLOEXEC +#endif + + case F_GETFD: +#if F_GETFD +#endif + +#ifdef F_SETFD + case F_SETFD: +# if F_SETFD +# endif +#endif + +#ifdef F_GETFL + case F_GETFL: +# if F_GETFL +# endif +#endif + +#ifdef F_SETFL + case F_SETFL: +# if F_SETFL +# endif +#endif + +#ifdef F_GETOWN + case F_GETOWN: +# if F_GETOWN +# endif +#endif + +#ifdef F_SETOWN + case F_SETOWN: +# if F_SETOWN +# endif +#endif + +#ifdef F_GETLK + case F_GETLK: +# if F_GETLK +# endif +#endif + +#ifdef F_SETLK + case F_SETLK: +# if F_SETLK +# endif +#endif + +#ifdef F_SETLKW + case F_SETLKW: +# if F_SETLKW +# endif +#endif + + default: + ; + } +} + +int +main (int argc, _GL_UNUSED char *argv[]) +{ + if (argc > 1) + /* child process */ + return (is_open (10) ? 42 : 0); + + const char *file = "test-fcntl.tmp"; + int fd; + int bad_fd = getdtablesize (); + + /* Sanity check that rpl_fcntl is likely to work. */ + ASSERT (func2 (1, 2) == 2); + ASSERT (func2 (2, -2) == -2); + ASSERT (func2 (3, 0x80000000) == 0x80000000); + { + struct dummy_struct s = { 0L, 4 }; + ASSERT (func2 (4, &s) == 4); + } + check_flags (); + + /* Assume std descriptors were provided by invoker, and ignore fds + that might have been inherited. */ + fd = creat (file, 0600); + ASSERT (STDERR_FILENO < fd); + close (fd + 1); + close (fd + 2); + + /* For F_DUPFD*, the source must be valid. */ + errno = 0; + ASSERT (fcntl (-1, F_DUPFD, 0) == -1); + ASSERT (errno == EBADF); + errno = 0; + ASSERT (fcntl (fd + 1, F_DUPFD, 0) == -1); + ASSERT (errno == EBADF); + errno = 0; + ASSERT (fcntl (bad_fd, F_DUPFD, 0) == -1); + ASSERT (errno == EBADF); + errno = 0; + ASSERT (fcntl (-1, F_DUPFD_CLOEXEC, 0) == -1); + ASSERT (errno == EBADF); + errno = 0; + ASSERT (fcntl (fd + 1, F_DUPFD_CLOEXEC, 0) == -1); + ASSERT (errno == EBADF); + errno = 0; + ASSERT (fcntl (bad_fd, F_DUPFD_CLOEXEC, 0) == -1); + ASSERT (errno == EBADF); + + /* For F_DUPFD*, the destination must be valid. */ + errno = 0; + ASSERT (fcntl (fd, F_DUPFD, -1) == -1); + ASSERT (errno == EINVAL); + errno = 0; + ASSERT (fcntl (fd, F_DUPFD, bad_fd) == -1); + ASSERT (errno == EINVAL); + errno = 0; + ASSERT (fcntl (fd, F_DUPFD_CLOEXEC, -1) == -1); + ASSERT (errno == EINVAL); + errno = 0; + ASSERT (fcntl (fd, F_DUPFD_CLOEXEC, bad_fd) == -1); + ASSERT (errno == EINVAL + || errno == EMFILE /* WSL */); + + /* For F_DUPFD*, check for correct inheritance, as well as + preservation of text vs. binary. */ + set_binary_mode (fd, O_BINARY); + ASSERT (is_open (fd)); + ASSERT (!is_open (fd + 1)); + ASSERT (!is_open (fd + 2)); + ASSERT (is_inheritable (fd)); + ASSERT (is_mode (fd, O_BINARY)); + + ASSERT (fcntl (fd, F_DUPFD, fd) == fd + 1); + ASSERT (is_open (fd)); + ASSERT (is_open (fd + 1)); + ASSERT (!is_open (fd + 2)); + ASSERT (is_inheritable (fd + 1)); + ASSERT (is_mode (fd, O_BINARY)); + ASSERT (is_mode (fd + 1, O_BINARY)); + ASSERT (close (fd + 1) == 0); + + ASSERT (fcntl (fd, F_DUPFD_CLOEXEC, fd + 2) == fd + 2); + ASSERT (is_open (fd)); + ASSERT (!is_open (fd + 1)); + ASSERT (is_open (fd + 2)); + ASSERT (is_inheritable (fd)); + ASSERT (!is_inheritable (fd + 2)); + ASSERT (is_mode (fd, O_BINARY)); + ASSERT (is_mode (fd + 2, O_BINARY)); + ASSERT (close (fd) == 0); + + set_binary_mode (fd + 2, O_TEXT); + ASSERT (fcntl (fd + 2, F_DUPFD, fd + 1) == fd + 1); + ASSERT (!is_open (fd)); + ASSERT (is_open (fd + 1)); + ASSERT (is_open (fd + 2)); + ASSERT (is_inheritable (fd + 1)); + ASSERT (!is_inheritable (fd + 2)); + ASSERT (is_mode (fd + 1, O_TEXT)); + ASSERT (is_mode (fd + 2, O_TEXT)); + ASSERT (close (fd + 1) == 0); + + ASSERT (fcntl (fd + 2, F_DUPFD_CLOEXEC, 0) == fd); + ASSERT (is_open (fd)); + ASSERT (!is_open (fd + 1)); + ASSERT (is_open (fd + 2)); + ASSERT (!is_inheritable (fd)); + ASSERT (!is_inheritable (fd + 2)); + ASSERT (is_mode (fd, O_TEXT)); + ASSERT (is_mode (fd + 2, O_TEXT)); + ASSERT (close (fd + 2) == 0); + + /* Test F_GETFD on invalid file descriptors. */ + errno = 0; + ASSERT (fcntl (-1, F_GETFD) == -1); + ASSERT (errno == EBADF); + errno = 0; + ASSERT (fcntl (fd + 1, F_GETFD) == -1); + ASSERT (errno == EBADF); + errno = 0; + ASSERT (fcntl (bad_fd, F_GETFD) == -1); + ASSERT (errno == EBADF); + + /* Test F_GETFD, the FD_CLOEXEC bit. */ + { + int result = fcntl (fd, F_GETFD); + ASSERT (0 <= result); + ASSERT ((result & FD_CLOEXEC) == FD_CLOEXEC); + ASSERT (dup (fd) == fd + 1); + result = fcntl (fd + 1, F_GETFD); + ASSERT (0 <= result); + ASSERT ((result & FD_CLOEXEC) == 0); + ASSERT (close (fd + 1) == 0); + } + +#ifdef F_SETFD + /* Test F_SETFD on invalid file descriptors. */ + errno = 0; + ASSERT (fcntl (-1, F_SETFD, 0) == -1); + ASSERT (errno == EBADF); + errno = 0; + ASSERT (fcntl (fd + 1, F_SETFD, 0) == -1); + ASSERT (errno == EBADF); + errno = 0; + ASSERT (fcntl (bad_fd, F_SETFD, 0) == -1); + ASSERT (errno == EBADF); +#endif + +#ifdef F_GETFL + /* Test F_GETFL on invalid file descriptors. */ + errno = 0; + ASSERT (fcntl (-1, F_GETFL) == -1); + ASSERT (errno == EBADF); + errno = 0; + ASSERT (fcntl (fd + 1, F_GETFL) == -1); + ASSERT (errno == EBADF); + errno = 0; + ASSERT (fcntl (bad_fd, F_GETFL) == -1); + ASSERT (errno == EBADF); +#endif + +#ifdef F_SETFL + /* Test F_SETFL on invalid file descriptors. */ + errno = 0; + ASSERT (fcntl (-1, F_SETFL, 0) == -1); + ASSERT (errno == EBADF); + errno = 0; + ASSERT (fcntl (fd + 1, F_SETFL, 0) == -1); + ASSERT (errno == EBADF); + errno = 0; + ASSERT (fcntl (bad_fd, F_SETFL, 0) == -1); + ASSERT (errno == EBADF); +#endif + +#ifdef F_GETOWN + /* Test F_GETOWN on invalid file descriptors. */ + errno = 0; + ASSERT (fcntl (-1, F_GETOWN) == -1); + ASSERT (errno == EBADF); + errno = 0; + ASSERT (fcntl (fd + 1, F_GETOWN) == -1); + ASSERT (errno == EBADF); + errno = 0; + ASSERT (fcntl (bad_fd, F_GETOWN) == -1); + ASSERT (errno == EBADF); +#endif + +#ifdef F_SETOWN + /* Test F_SETFL on invalid file descriptors. */ + errno = 0; + ASSERT (fcntl (-1, F_SETOWN, 0) == -1); + ASSERT (errno == EBADF); + errno = 0; + ASSERT (fcntl (fd + 1, F_SETOWN, 0) == -1); + ASSERT (errno == EBADF); + errno = 0; + ASSERT (fcntl (bad_fd, F_SETOWN, 0) == -1); + ASSERT (errno == EBADF); +#endif + + /* Cleanup. */ + ASSERT (close (fd) == 0); + ASSERT (unlink (file) == 0); + + /* Close file descriptors that may have been inherited from the parent + process and that would cause failures below. + Such file descriptors have been seen: + - with GNU make, when invoked as 'make -j N' with j > 1, + - in some versions of the KDE desktop environment, + - on NetBSD, + - in MacPorts with the "trace mode" enabled. + */ + (void) close (10); + + /* Test whether F_DUPFD_CLOEXEC is effective. */ + ASSERT (fcntl (1, F_DUPFD_CLOEXEC, 10) >= 0); +#if defined _WIN32 && !defined __CYGWIN__ + return _execl ("./test-fcntl", "./test-fcntl", "child", NULL); +#else + return execl ("./test-fcntl", "./test-fcntl", "child", NULL); +#endif +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fdopen.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fdopen.c new file mode 100644 index 00000000..e5aa6442 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fdopen.c @@ -0,0 +1,54 @@ +/* Test opening a stream with a file descriptor. + Copyright (C) 2011-2024 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 . */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (fdopen, FILE *, (int, const char *)); + +#include +#include + +#include "macros.h" + +int +main (void) +{ + /* Test behavior on failure. POSIX makes it hard to check for + failure, since the behavior is not well-defined on invalid file + descriptors, so try fdopen 1000 times and if that's not enough to + fail due to EMFILE, so be it. */ + #if defined __ANDROID__ /* fdsan */ + #define COUNT 1 + #else + #define COUNT 1000 + #endif + + int i; + for (i = 0; i < COUNT; i++) + { + errno = 0; + if (! fdopen (STDOUT_FILENO, "w")) + { + ASSERT (errno != 0); + break; + } + } + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fdopendir.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fdopendir.c new file mode 100644 index 00000000..c92e5db4 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fdopendir.c @@ -0,0 +1,80 @@ +/* Test opening a directory stream from a file descriptor. + Copyright (C) 2009-2024 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 . */ + +/* Written by Eric Blake , 2009. */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (fdopendir, DIR *, (int)); + +#include +#include +#include + +#include "macros.h" + +int +main () +{ + DIR *d; + int fd; + + /* A non-directory cannot be turned into a directory stream. */ + fd = open ("test-fdopendir.tmp", O_RDONLY | O_CREAT, 0600); + ASSERT (0 <= fd); + errno = 0; + ASSERT (fdopendir (fd) == NULL); + ASSERT (errno == ENOTDIR); + ASSERT (close (fd) == 0); + ASSERT (unlink ("test-fdopendir.tmp") == 0); + + /* A bad fd cannot be turned into a stream. */ + { + errno = 0; + ASSERT (fdopendir (-1) == NULL); + ASSERT (errno == EBADF); + } + { + close (99); + errno = 0; + ASSERT (fdopendir (99) == NULL); + ASSERT (errno == EBADF); + } + + /* This should work. */ + fd = open (".", O_RDONLY); + ASSERT (0 <= fd); + d = fdopendir (fd); + ASSERT (d); + /* fdopendir should not close fd. */ + ASSERT (dup2 (fd, fd) == fd); + + /* Don't test dirfd here. dirfd (d) must return fd on current POSIX + platforms, but on pre-2008 platforms or on non-POSIX platforms + dirfd (fd) might return some other descriptor, or -1, and gnulib + does not work around this porting problem. */ + + ASSERT (closedir (d) == 0); + /* Now we can guarantee that fd must be closed. */ + errno = 0; + ASSERT (dup2 (fd, fd) == -1); + ASSERT (errno == EBADF); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fgetc.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fgetc.c new file mode 100644 index 00000000..0d617980 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fgetc.c @@ -0,0 +1,101 @@ +/* Test of fgetc() function. + Copyright (C) 2011-2024 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 . */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (fgetc, int, (FILE *)); + +#include +#include +#include + +#if HAVE_MSVC_INVALID_PARAMETER_HANDLER +# include "msvc-inval.h" +#endif + +#include "macros.h" + +int +main () +{ + const char *filename = "test-fgetc.txt"; + + /* We don't have an fgetc() function that installs an invalid parameter + handler so far. So install that handler here, explicitly. */ +#if HAVE_MSVC_INVALID_PARAMETER_HANDLER \ + && MSVC_INVALID_PARAMETER_HANDLING == DEFAULT_HANDLING + gl_msvc_inval_ensure_handler (); +#endif + + /* Prepare a file. */ + { + const char text[] = "hello world"; + int fd = open (filename, O_RDWR | O_CREAT | O_TRUNC, 0600); + ASSERT (fd >= 0); + ASSERT (write (fd, text, sizeof (text)) == sizeof (text)); + ASSERT (close (fd) == 0); + } + + /* Test that fgetc() sets errno if someone else closes the stream + fd behind the back of stdio. */ + #if !defined __ANDROID__ /* fdsan */ + { + FILE *fp = fopen (filename, "r"); + ASSERT (fp != NULL); + ASSERT (close (fileno (fp)) == 0); + errno = 0; + ASSERT (fgetc (fp) == EOF); + ASSERT (errno == EBADF); + ASSERT (ferror (fp)); + fclose (fp); + } + #endif + + /* Test that fgetc() sets errno if the stream was constructed with + an invalid file descriptor. */ + { + FILE *fp = fdopen (-1, "r"); + if (fp != NULL) + { + errno = 0; + ASSERT (fgetc (fp) == EOF); + ASSERT (errno == EBADF); + ASSERT (ferror (fp)); + fclose (fp); + } + } + { + FILE *fp; + close (99); + fp = fdopen (99, "r"); + if (fp != NULL) + { + errno = 0; + ASSERT (fgetc (fp) == EOF); + ASSERT (errno == EBADF); + ASSERT (ferror (fp)); + fclose (fp); + } + } + + /* Clean up. */ + unlink (filename); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-filenamecat.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-filenamecat.c new file mode 100644 index 00000000..fc00e88b --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-filenamecat.c @@ -0,0 +1,86 @@ +/* Test of concatenation of two arbitrary file names. + + Copyright (C) 1996-2007, 2009-2024 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 . */ + +/* Written by Jim Meyering. */ + +#include + +#include "filenamecat.h" + +#include "idx.h" + +#include +#include +#include +#include + + +int +main (_GL_UNUSED int argc, char *argv[]) +{ + static char const *const tests[][3] = + { + {"a", "b", "a/b"}, + {"a/", "b", "a/b"}, + {"a/", "/b", "a/b"}, + {"a", "/b", "a/b"}, + + {"/", "b", "/b"}, + {"/", "/b", "/./b"}, /* This result could be shorter. */ + {"/", "/", "/./"}, /* This result could be shorter. */ + {"a", "/", "a/"}, /* this might deserve a diagnostic */ + {"/a", "/", "/a/"}, /* this might deserve a diagnostic */ + {"a", "//b", "a//b"}, + {"", "a", "a"}, /* this might deserve a diagnostic */ + }; + unsigned int i; + bool fail = false; + + for (i = 0; i < sizeof tests / sizeof tests[0]; i++) + { + char *base_in_result; + char const *const *t = tests[i]; + char *res = file_name_concat (t[0], t[1], &base_in_result); + idx_t prefixlen = base_in_result - res; + size_t t0len = strlen (t[0]); + size_t reslen = strlen (res); + if (strcmp (res, t[2]) != 0) + { + fprintf (stderr, "test #%u: got %s, expected %s\n", i, res, t[2]); + fail = true; + } + if (strcmp (t[1], base_in_result) != 0) + { + fprintf (stderr, "test #%u: base %s != base_in_result %s\n", + i, t[1], base_in_result); + fail = true; + } + if (! (0 <= prefixlen && prefixlen <= reslen)) + { + fprintf (stderr, "test #%u: base_in_result is not in result\n", i); + fail = true; + } + if (reslen < t0len || memcmp (res, t[0], t0len) != 0) + { + fprintf (stderr, "test #%u: %s is not a prefix of %s\n", + i, t[0], res); + fail = true; + } + free (res); + } + exit (fail ? EXIT_FAILURE : EXIT_SUCCESS); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-float.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-float.c new file mode 100644 index 00000000..e9dc4609 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-float.c @@ -0,0 +1,392 @@ +/* Test of substitute. + Copyright (C) 2011-2024 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 . */ + +/* Written by Bruno Haible , 2011. */ + +#include + +#include + +/* Check that FLT_RADIX is a constant expression. */ +int a[] = { FLT_RADIX }; + +/* ----------------------- Check macros for 'float' ----------------------- */ + +/* Check that the FLT_* macros expand to constant expressions. */ +int fb[] = + { + FLT_MANT_DIG, FLT_MIN_EXP, FLT_MAX_EXP, + FLT_DIG, FLT_MIN_10_EXP, FLT_MAX_10_EXP + }; +float fc[] = { FLT_EPSILON, FLT_MIN, FLT_MAX }; + +/* ----------------------- Check macros for 'double' ----------------------- */ + +/* Check that the DBL_* macros expand to constant expressions. */ +int db[] = + { + DBL_MANT_DIG, DBL_MIN_EXP, DBL_MAX_EXP, + DBL_DIG, DBL_MIN_10_EXP, DBL_MAX_10_EXP + }; +double dc[] = { DBL_EPSILON, DBL_MIN, DBL_MAX }; + +/* -------------------- Check macros for 'long double' -------------------- */ + +/* Check that the LDBL_* macros expand to constant expressions. */ +int lb[] = + { + LDBL_MANT_DIG, LDBL_MIN_EXP, LDBL_MAX_EXP, + LDBL_DIG, LDBL_MIN_10_EXP, LDBL_MAX_10_EXP + }; +long double lc1 = LDBL_EPSILON; +long double lc2 = LDBL_MIN; +#if 0 /* LDBL_MAX is not a constant expression on some platforms. */ +long double lc3 = LDBL_MAX; +#endif + +/* ------------------------------------------------------------------------- */ + +#include "fpucw.h" +#include "macros.h" + +#if FLT_RADIX == 2 + +/* Return 2^n. */ +static float +pow2f (int n) +{ + int k = n; + volatile float x = 1; + volatile float y = 2; + /* Invariant: 2^n == x * y^k. */ + if (k < 0) + { + y = 0.5f; + k = - k; + } + while (k > 0) + { + if (k != 2 * (k / 2)) + { + x = x * y; + k = k - 1; + } + if (k == 0) + break; + y = y * y; + k = k / 2; + } + /* Now k == 0, hence x == 2^n. */ + return x; +} + +/* Return 2^n. */ +static double +pow2d (int n) +{ + int k = n; + volatile double x = 1; + volatile double y = 2; + /* Invariant: 2^n == x * y^k. */ + if (k < 0) + { + y = 0.5; + k = - k; + } + while (k > 0) + { + if (k != 2 * (k / 2)) + { + x = x * y; + k = k - 1; + } + if (k == 0) + break; + y = y * y; + k = k / 2; + } + /* Now k == 0, hence x == 2^n. */ + return x; +} + +/* Return 2^n. */ +static long double +pow2l (int n) +{ + int k = n; + volatile long double x = 1; + volatile long double y = 2; + /* Invariant: 2^n == x * y^k. */ + if (k < 0) + { + y = 0.5L; + k = - k; + } + while (k > 0) + { + if (k != 2 * (k / 2)) + { + x = x * y; + k = k - 1; + } + if (k == 0) + break; + y = y * y; + k = k / 2; + } + /* Now k == 0, hence x == 2^n. */ + return x; +} + +/* ----------------------- Check macros for 'float' ----------------------- */ + +static void +test_float (void) +{ + /* Check that the value of FLT_MIN_EXP is well parenthesized. */ + ASSERT ((FLT_MIN_EXP % 101111) == (FLT_MIN_EXP) % 101111); + + /* Check that the value of DBL_MIN_10_EXP is well parenthesized. */ + ASSERT ((FLT_MIN_10_EXP % 101111) == (FLT_MIN_10_EXP) % 101111); + + /* Check that 'float' is as specified in IEEE 754. */ + ASSERT (FLT_MANT_DIG == 24); + ASSERT (FLT_MIN_EXP == -125); + ASSERT (FLT_MAX_EXP == 128); + + /* Check the value of FLT_MIN_10_EXP. */ + ASSERT (FLT_MIN_10_EXP == - (int) (- (FLT_MIN_EXP - 1) * 0.30103)); + + /* Check the value of FLT_DIG. */ + ASSERT (FLT_DIG == (int) ((FLT_MANT_DIG - 1) * 0.30103)); + + /* Check the value of FLT_MIN_10_EXP. */ + ASSERT (FLT_MIN_10_EXP == - (int) (- (FLT_MIN_EXP - 1) * 0.30103)); + + /* Check the value of FLT_MAX_10_EXP. */ + ASSERT (FLT_MAX_10_EXP == (int) (FLT_MAX_EXP * 0.30103)); + + /* Check the value of FLT_MAX. */ + { + volatile float m = FLT_MAX; + int n; + + ASSERT (m + m > m); + for (n = 0; n <= 2 * FLT_MANT_DIG; n++) + { + volatile float pow2_n = pow2f (n); /* 2^n */ + volatile float x = m + (m / pow2_n); + if (x > m) + ASSERT (x + x == x); + else + ASSERT (!(x + x == x)); + } + } + + /* Check the value of FLT_MIN. */ + { + volatile float m = FLT_MIN; + volatile float x = pow2f (FLT_MIN_EXP - 1); + ASSERT (m == x); + } + + /* Check the value of FLT_EPSILON. */ + { + volatile float e = FLT_EPSILON; + volatile float me; + int n; + + me = 1.0f + e; + ASSERT (me > 1.0f); + ASSERT (me - 1.0f == e); + for (n = 0; n <= 2 * FLT_MANT_DIG; n++) + { + volatile float half_n = pow2f (- n); /* 2^-n */ + volatile float x = me - half_n; + if (x < me) + ASSERT (x <= 1.0f); + } + } +} + +/* ----------------------- Check macros for 'double' ----------------------- */ + +static void +test_double (void) +{ + /* Check that the value of DBL_MIN_EXP is well parenthesized. */ + ASSERT ((DBL_MIN_EXP % 101111) == (DBL_MIN_EXP) % 101111); + + /* Check that the value of DBL_MIN_10_EXP is well parenthesized. */ + ASSERT ((DBL_MIN_10_EXP % 101111) == (DBL_MIN_10_EXP) % 101111); + + /* Check that 'double' is as specified in IEEE 754. */ + ASSERT (DBL_MANT_DIG == 53); + ASSERT (DBL_MIN_EXP == -1021); + ASSERT (DBL_MAX_EXP == 1024); + + /* Check the value of DBL_MIN_10_EXP. */ + ASSERT (DBL_MIN_10_EXP == - (int) (- (DBL_MIN_EXP - 1) * 0.30103)); + + /* Check the value of DBL_DIG. */ + ASSERT (DBL_DIG == (int) ((DBL_MANT_DIG - 1) * 0.30103)); + + /* Check the value of DBL_MIN_10_EXP. */ + ASSERT (DBL_MIN_10_EXP == - (int) (- (DBL_MIN_EXP - 1) * 0.30103)); + + /* Check the value of DBL_MAX_10_EXP. */ + ASSERT (DBL_MAX_10_EXP == (int) (DBL_MAX_EXP * 0.30103)); + + /* Check the value of DBL_MAX. */ + { + volatile double m = DBL_MAX; + int n; + + ASSERT (m + m > m); + for (n = 0; n <= 2 * DBL_MANT_DIG; n++) + { + volatile double pow2_n = pow2d (n); /* 2^n */ + volatile double x = m + (m / pow2_n); + if (x > m) + ASSERT (x + x == x); + else + ASSERT (!(x + x == x)); + } + } + + /* Check the value of DBL_MIN. */ + { + volatile double m = DBL_MIN; + volatile double x = pow2d (DBL_MIN_EXP - 1); + ASSERT (m == x); + } + + /* Check the value of DBL_EPSILON. */ + { + volatile double e = DBL_EPSILON; + volatile double me; + int n; + + me = 1.0 + e; + ASSERT (me > 1.0); + ASSERT (me - 1.0 == e); + for (n = 0; n <= 2 * DBL_MANT_DIG; n++) + { + volatile double half_n = pow2d (- n); /* 2^-n */ + volatile double x = me - half_n; + if (x < me) + ASSERT (x <= 1.0); + } + } +} + +/* -------------------- Check macros for 'long double' -------------------- */ + +static void +test_long_double (void) +{ + /* Check that the value of LDBL_MIN_EXP is well parenthesized. */ + ASSERT ((LDBL_MIN_EXP % 101111) == (LDBL_MIN_EXP) % 101111); + + /* Check that the value of LDBL_MIN_10_EXP is well parenthesized. */ + ASSERT ((LDBL_MIN_10_EXP % 101111) == (LDBL_MIN_10_EXP) % 101111); + + /* Check that 'long double' is at least as wide as 'double'. */ + ASSERT (LDBL_MANT_DIG >= DBL_MANT_DIG); + ASSERT (LDBL_MIN_EXP - LDBL_MANT_DIG <= DBL_MIN_EXP - DBL_MANT_DIG); + ASSERT (LDBL_MAX_EXP >= DBL_MAX_EXP); + + /* Check the value of LDBL_DIG. */ + ASSERT (LDBL_DIG == (int)((LDBL_MANT_DIG - 1) * 0.30103)); + + /* Check the value of LDBL_MIN_10_EXP. */ + ASSERT (LDBL_MIN_10_EXP == - (int) (- (LDBL_MIN_EXP - 1) * 0.30103)); + + /* Check the value of LDBL_MAX_10_EXP. */ + ASSERT (LDBL_MAX_10_EXP == (int) (LDBL_MAX_EXP * 0.30103)); + + /* Check the value of LDBL_MAX. */ + { + volatile long double m = LDBL_MAX; + int n; + + ASSERT (m + m > m); + for (n = 0; n <= 2 * LDBL_MANT_DIG; n++) + { + volatile long double pow2_n = pow2l (n); /* 2^n */ + volatile long double x = m + (m / pow2_n); + if (x > m) + ASSERT (x + x == x); + else + ASSERT (!(x + x == x)); + } + } + + /* Check the value of LDBL_MIN. */ + { + volatile long double m = LDBL_MIN; + volatile long double x = pow2l (LDBL_MIN_EXP - 1); + ASSERT (m == x); + } + + /* Check the value of LDBL_EPSILON. */ + { + volatile long double e = LDBL_EPSILON; + volatile long double me; + int n; + + me = 1.0L + e; + ASSERT (me > 1.0L); + ASSERT (me - 1.0L == e); + for (n = 0; n <= 2 * LDBL_MANT_DIG; n++) + { + volatile long double half_n = pow2l (- n); /* 2^-n */ + volatile long double x = me - half_n; + if (x < me) + ASSERT (x <= 1.0L); + } + } +} + +int +main () +{ + test_float (); + test_double (); + + { + DECL_LONG_DOUBLE_ROUNDING + + BEGIN_LONG_DOUBLE_ROUNDING (); + + test_long_double (); + + END_LONG_DOUBLE_ROUNDING (); + } + + return 0; +} + +#else + +int +main () +{ + fprintf (stderr, "Skipping test: FLT_RADIX is not 2.\n"); + return 77; +} + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch-1.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch-1.sh new file mode 100755 index 00000000..7ecc2706 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch-1.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +# Test in the POSIX locale. +LC_ALL=C \ +${CHECKER} ./test-fnmatch${EXEEXT} 1 || exit 1 +LC_ALL=POSIX \ +${CHECKER} ./test-fnmatch${EXEEXT} 1 || exit 1 + +exit 0 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch-2.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch-2.sh new file mode 100755 index 00000000..c7e17664 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch-2.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Test in an ISO-8859-1 or ISO-8859-15 locale. +: "${LOCALE_FR=fr_FR}" +if test $LOCALE_FR = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no traditional french locale is installed" + else + echo "Skipping test: no traditional french locale is supported" + fi + exit 77 +fi + +LC_ALL=$LOCALE_FR \ +${CHECKER} ./test-fnmatch${EXEEXT} 2 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch-3.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch-3.sh new file mode 100755 index 00000000..7ad5386c --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch-3.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Test whether a specific UTF-8 locale is installed. +: "${LOCALE_FR_UTF8=fr_FR.UTF-8}" +if test $LOCALE_FR_UTF8 = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no french Unicode locale is installed" + else + echo "Skipping test: no french Unicode locale is supported" + fi + exit 77 +fi + +LC_ALL=$LOCALE_FR_UTF8 \ +${CHECKER} ./test-fnmatch${EXEEXT} 3 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch-4.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch-4.sh new file mode 100755 index 00000000..04a86adc --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch-4.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Test whether a specific EUC-JP locale is installed. +: "${LOCALE_JA=ja_JP}" +if test $LOCALE_JA = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no traditional japanese locale is installed" + else + echo "Skipping test: no traditional japanese locale is supported" + fi + exit 77 +fi + +LC_ALL=$LOCALE_JA \ +${CHECKER} ./test-fnmatch${EXEEXT} 4 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch-5.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch-5.sh new file mode 100755 index 00000000..8ba3bf9e --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch-5.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Test whether a specific GB18030 locale is installed. +: "${LOCALE_ZH_CN=zh_CN.GB18030}" +if test $LOCALE_ZH_CN = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no transitional chinese locale is installed" + else + echo "Skipping test: no transitional chinese locale is supported" + fi + exit 77 +fi + +LC_ALL=$LOCALE_ZH_CN \ +${CHECKER} ./test-fnmatch${EXEEXT} 5 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch-h.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch-h.c new file mode 100644 index 00000000..9084cb26 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch-h.c @@ -0,0 +1,31 @@ +/* Test of substitute. + Copyright (C) 2018-2024 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 . */ + +/* Written by Bruno Haible , 2018. */ + +#include + +#include + +/* Check that the various FNM_* macros are defined. */ +int ret = FNM_NOMATCH; +int options[] = { FNM_PATHNAME, FNM_PERIOD, FNM_NOESCAPE }; + +int +main (void) +{ + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch-w32-2.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch-w32-2.sh new file mode 100755 index 00000000..6efe31fe --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch-w32-2.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Test a CP1252 locale. +${CHECKER} ./test-fnmatch-w32${EXEEXT} French_France 1252 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch-w32-3.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch-w32-3.sh new file mode 100755 index 00000000..aacf62a3 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch-w32-3.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Test a CP1256 locale. +${CHECKER} ./test-fnmatch-w32${EXEEXT} "Arabic_Saudi Arabia" 1256 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch-w32-4.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch-w32-4.sh new file mode 100755 index 00000000..15f26faa --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch-w32-4.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Test some UTF-8 locales. +${CHECKER} ./test-fnmatch-w32${EXEEXT} French_France Japanese_Japan Chinese_Taiwan Chinese_China 65001 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch-w32-5.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch-w32-5.sh new file mode 100755 index 00000000..56c8ef1a --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch-w32-5.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Test a CP932 locale. +${CHECKER} ./test-fnmatch-w32${EXEEXT} Japanese_Japan 932 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch-w32-6.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch-w32-6.sh new file mode 100755 index 00000000..e3c51811 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch-w32-6.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Test a CP950 locale. +${CHECKER} ./test-fnmatch-w32${EXEEXT} Chinese_Taiwan 950 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch-w32-7.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch-w32-7.sh new file mode 100755 index 00000000..0c2a048d --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch-w32-7.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Test a CP936 locale. +${CHECKER} ./test-fnmatch-w32${EXEEXT} Chinese_China 936 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch-w32-8.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch-w32-8.sh new file mode 100755 index 00000000..af024428 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch-w32-8.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Test a GB18030 locale. +${CHECKER} ./test-fnmatch-w32${EXEEXT} Chinese_China 54936 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch-w32.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch-w32.c new file mode 100644 index 00000000..0ee8a086 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch-w32.c @@ -0,0 +1,411 @@ +/* Test of fnmatch string matching function. + Copyright (C) 2008-2024 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 . */ + +#include + +#include + +#include +#include +#include +#include +#include + +#include "localcharset.h" +#include "macros.h" + +#if defined _WIN32 && !defined __CYGWIN__ + +static int +test_one_locale (const char *name, int codepage) +{ +# if 1 + /* Portable code to set the locale. */ + { + char name_with_codepage[1024]; + + sprintf (name_with_codepage, "%s.%d", name, codepage); + + /* Set the locale. */ + if (setlocale (LC_ALL, name_with_codepage) == NULL) + return 77; + } +# else + /* Hacky way to set a locale.codepage combination that setlocale() refuses + to set. */ + { + /* Codepage of the current locale, set with setlocale(). + Not necessarily the same as GetACP(). */ + extern __declspec(dllimport) unsigned int __lc_codepage; + + /* Set the locale. */ + if (setlocale (LC_ALL, name) == NULL) + return 77; + + /* Clobber the codepage and MB_CUR_MAX, both set by setlocale(). */ + __lc_codepage = codepage; + switch (codepage) + { + case 1252: + case 1256: + MB_CUR_MAX = 1; + break; + case 932: + case 950: + case 936: + MB_CUR_MAX = 2; + break; + case 54936: + case 65001: + MB_CUR_MAX = 4; + break; + } + + /* Test whether the codepage is really available. */ + mbstate_t state; + wchar_t wc; + memset (&state, '\0', sizeof (mbstate_t)); + if (mbrtowc (&wc, " ", 1, &state) == (size_t)(-1)) + return 77; + } +# endif + + switch (codepage) + { + case 1252: + /* Locale encoding is CP1252, an extension of ISO-8859-1. */ + + ASSERT (fnmatch ("x?y", "x\374y", 0) == 0); /* "xüy" */ + ASSERT (fnmatch ("x?y", "x\337y", 0) == 0); /* "xßy" */ + /* U+00D8 LATIN CAPITAL LETTER O WITH STROKE */ + ASSERT (fnmatch ("x[[:alnum:]]y", "x\330y", 0) == 0); + /* U+00D8 LATIN CAPITAL LETTER O WITH STROKE */ + ASSERT (fnmatch ("x[[:alpha:]]y", "x\330y", 0) == 0); + /* U+00B8 CEDILLA */ + ASSERT (fnmatch ("x[[:graph:]]y", "x\270y", 0) == 0); + /* U+00FF LATIN SMALL LETTER Y WITH DIAERESIS */ + ASSERT (fnmatch ("x[[:lower:]]y", "x\377y", 0) == 0); + /* U+00B8 CEDILLA */ + ASSERT (fnmatch ("x[[:print:]]y", "x\270y", 0) == 0); + /* U+00BF INVERTED QUESTION MARK */ + ASSERT (fnmatch ("x[[:punct:]]y", "x\277y", 0) == 0); + /* U+00C9 LATIN CAPITAL LETTER E WITH ACUTE */ + ASSERT (fnmatch ("x[[:upper:]]y", "x\311y", 0) == 0); + /* U+00D7 MULTIPLICATION SIGN */ + ASSERT (fnmatch ("x[[:alnum:]]y", "x\327y", 0) == FNM_NOMATCH); + /* U+00D7 MULTIPLICATION SIGN */ + ASSERT (fnmatch ("x[[:alpha:]]y", "x\327y", 0) == FNM_NOMATCH); + /* U+00D8 LATIN CAPITAL LETTER O WITH STROKE */ + ASSERT (fnmatch ("x[[:blank:]]y", "x\330y", 0) == FNM_NOMATCH); + /* U+00D8 LATIN CAPITAL LETTER O WITH STROKE */ + ASSERT (fnmatch ("x[[:cntrl:]]y", "x\330y", 0) == FNM_NOMATCH); + /* U+00D8 LATIN CAPITAL LETTER O WITH STROKE */ + ASSERT (fnmatch ("x[[:digit:]]y", "x\330y", 0) == FNM_NOMATCH); + /* U+00B2 SUPERSCRIPT TWO */ + ASSERT (fnmatch ("x[[:lower:]]y", "x\262y", 0) == FNM_NOMATCH); + /* U+00D8 LATIN CAPITAL LETTER O WITH STROKE */ + ASSERT (fnmatch ("x[[:punct:]]y", "x\330y", 0) == FNM_NOMATCH); + /* U+00D8 LATIN CAPITAL LETTER O WITH STROKE */ + ASSERT (fnmatch ("x[[:space:]]y", "x\330y", 0) == FNM_NOMATCH); + /* U+00B2 SUPERSCRIPT TWO */ + ASSERT (fnmatch ("x[[:upper:]]y", "x\262y", 0) == FNM_NOMATCH); + /* U+00D8 LATIN CAPITAL LETTER O WITH STROKE */ + ASSERT (fnmatch ("x[[:xdigit:]]y", "x\330y", 0) == FNM_NOMATCH); + + #if GNULIB_FNMATCH_GNU && defined FNM_CASEFOLD + /* "Höhle" */ + ASSERT (fnmatch ("H\366hle", "H\326hLe", FNM_CASEFOLD) == 0); + ASSERT (fnmatch ("H\326hLe", "H\366hle", FNM_CASEFOLD) == 0); + ASSERT (fnmatch ("H\326hle", "H\366hLe", FNM_CASEFOLD) == 0); + ASSERT (fnmatch ("H\366hLe", "H\326hle", FNM_CASEFOLD) == 0); + #endif + + return 0; + + case 1256: + /* Locale encoding is CP1256, not the same as ISO-8859-6. */ + + ASSERT (fnmatch ("x?y", "x\302y", 0) == 0); /* "xØ¢y" */ + ASSERT (fnmatch ("x?y", "x\341y", 0) == 0); /* "xلy" */ + ASSERT (fnmatch ("x?y", "x\346y", 0) == 0); /* "xوy" */ + + return 0; + + case 65001: + /* Locale encoding is CP65001 = UTF-8. */ + if (strcmp (locale_charset (), "UTF-8") != 0) + return 77; + + ASSERT (fnmatch ("x?y", "x\303\274y", 0) == 0); /* "xüy" */ + ASSERT (fnmatch ("x?y", "x\303\237y", 0) == 0); /* "xßy" */ + ASSERT (fnmatch ("x?y", "x\360\237\230\213y", 0) == 0); /* "x😋y" */ + /* U+0141 LATIN CAPITAL LETTER L WITH STROKE */ + ASSERT (fnmatch ("x[[:alnum:]]y", "x\305\201y", 0) == 0); + /* U+10330 GOTHIC LETTER AHSA */ + ASSERT (fnmatch ("x[[:alnum:]]y", "x\360\220\214\260y", 0) == 0); + /* U+0141 LATIN CAPITAL LETTER L WITH STROKE */ + ASSERT (fnmatch ("x[[:alpha:]]y", "x\305\201y", 0) == 0); + /* U+10330 GOTHIC LETTER AHSA */ + ASSERT (fnmatch ("x[[:alpha:]]y", "x\360\220\214\260y", 0) == 0); + /* U+00B8 CEDILLA */ + ASSERT (fnmatch ("x[[:graph:]]y", "x\302\270y", 0) == 0); + /* U+20000 */ + ASSERT (fnmatch ("x[[:graph:]]y", "x\360\240\200\200y", 0) == 0); + /* U+00FF LATIN SMALL LETTER Y WITH DIAERESIS */ + ASSERT (fnmatch ("x[[:lower:]]y", "x\303\277y", 0) == 0); + /* U+10441 DESERET SMALL LETTER EF */ + ASSERT (fnmatch ("x[[:lower:]]y", "x\360\220\221\201y", 0) == 0); + /* U+00B8 CEDILLA */ + ASSERT (fnmatch ("x[[:print:]]y", "x\302\270y", 0) == 0); + /* U+20000 */ + ASSERT (fnmatch ("x[[:print:]]y", "x\360\240\200\200y", 0) == 0); + /* U+00BF INVERTED QUESTION MARK */ + ASSERT (fnmatch ("x[[:punct:]]y", "x\302\277y", 0) == 0); + /* U+1D100 MUSICAL SYMBOL SINGLE BARLINE */ + ASSERT (fnmatch ("x[[:punct:]]y", "x\360\235\204\200y", 0) == 0); + /* U+3000 IDEOGRAPHIC SPACE */ + ASSERT (fnmatch ("x[[:space:]]y", "x\343\200\200y", 0) == 0); + /* U+0429 CYRILLIC CAPITAL LETTER SHCHA */ + ASSERT (fnmatch ("x[[:upper:]]y", "x\320\251y", 0) == 0); + /* U+10419 DESERET CAPITAL LETTER EF */ + ASSERT (fnmatch ("x[[:upper:]]y", "x\360\220\220\231y", 0) == 0); + /* U+00D7 MULTIPLICATION SIGN */ + ASSERT (fnmatch ("x[[:alnum:]]y", "x\303\227y", 0) == FNM_NOMATCH); + /* U+00D7 MULTIPLICATION SIGN */ + ASSERT (fnmatch ("x[[:alpha:]]y", "x\303\227y", 0) == FNM_NOMATCH); + /* U+0141 LATIN CAPITAL LETTER L WITH STROKE */ + ASSERT (fnmatch ("x[[:blank:]]y", "x\305\201y", 0) == FNM_NOMATCH); + /* U+0141 LATIN CAPITAL LETTER L WITH STROKE */ + ASSERT (fnmatch ("x[[:cntrl:]]y", "x\305\201y", 0) == FNM_NOMATCH); + /* U+0141 LATIN CAPITAL LETTER L WITH STROKE */ + ASSERT (fnmatch ("x[[:digit:]]y", "x\305\201y", 0) == FNM_NOMATCH); + /* U+2002 EN SPACE */ + ASSERT (fnmatch ("x[[:graph:]]y", "x\342\200\202y", 0) == FNM_NOMATCH); + /* U+00B2 SUPERSCRIPT TWO */ + ASSERT (fnmatch ("x[[:lower:]]y", "x\302\262y", 0) == FNM_NOMATCH); + /* U+0141 LATIN CAPITAL LETTER L WITH STROKE */ + ASSERT (fnmatch ("x[[:punct:]]y", "x\305\201y", 0) == FNM_NOMATCH); + /* U+0141 LATIN CAPITAL LETTER L WITH STROKE */ + ASSERT (fnmatch ("x[[:space:]]y", "x\305\201y", 0) == FNM_NOMATCH); + /* U+00B2 SUPERSCRIPT TWO */ + ASSERT (fnmatch ("x[[:upper:]]y", "x\302\262y", 0) == FNM_NOMATCH); + /* U+0141 LATIN CAPITAL LETTER L WITH STROKE */ + ASSERT (fnmatch ("x[[:xdigit:]]y", "x\305\201y", 0) == FNM_NOMATCH); + + #if GNULIB_FNMATCH_GNU && defined FNM_CASEFOLD + /* "özgür" */ + { + /* Some platforms, e.g. MSVC 14, lack the upper/lower mappings for + these wide characters in the *.65001 locales. */ + mbstate_t state; + wchar_t wc; + memset (&state, 0, sizeof (mbstate_t)); + if (mbrtowc (&wc, "\303\274", 2, &state) == 2 + && towupper (wc) != wc) + { + ASSERT (fnmatch ("\303\266zg\303\274r", "\303\226ZG\303\234R", FNM_CASEFOLD) == 0); + ASSERT (fnmatch ("\303\226ZG\303\234R", "\303\266zg\303\274r", FNM_CASEFOLD) == 0); + ASSERT (fnmatch ("\303\266Zg\303\234r", "\303\226zG\303\274R", FNM_CASEFOLD) == 0); + ASSERT (fnmatch ("\303\226zG\303\274R", "\303\266Zg\303\234r", FNM_CASEFOLD) == 0); + } + } + #endif + + return 0; + + case 932: + /* Locale encoding is CP932, similar to Shift_JIS. */ + + ASSERT (fnmatch ("x?y", "x\223\372y", 0) == 0); /* "x日y" */ + ASSERT (fnmatch ("x?y", "x\226\173y", 0) == 0); /* "x本y" */ + ASSERT (fnmatch ("x?y", "x\214\352y", 0) == 0); /* "x語y" */ + + return 0; + + case 950: + /* Locale encoding is CP950, similar to Big5. */ + + ASSERT (fnmatch ("x?y", "x\244\351y", 0) == 0); /* "x日y" */ + ASSERT (fnmatch ("x?y", "x\245\273y", 0) == 0); /* "x本y" */ + ASSERT (fnmatch ("x?y", "x\273\171y", 0) == 0); /* "x語y" */ + + /* U+FF4D FULLWIDTH LATIN SMALL LETTER M */ + ASSERT (fnmatch ("x[[:alnum:]]y", "x\242\365y", 0) == 0); + /* U+FF4D FULLWIDTH LATIN SMALL LETTER M */ + ASSERT (fnmatch ("x[[:alpha:]]y", "x\242\365y", 0) == 0); + /* U+3001 IDEOGRAPHIC COMMA */ + ASSERT (fnmatch ("x[[:graph:]]y", "x\241\102y", 0) == 0); + /* U+FF4D FULLWIDTH LATIN SMALL LETTER M */ + ASSERT (fnmatch ("x[[:lower:]]y", "x\242\365y", 0) == 0); + /* U+3001 IDEOGRAPHIC COMMA */ + ASSERT (fnmatch ("x[[:print:]]y", "x\241\102y", 0) == 0); + /* U+00D7 MULTIPLICATION SIGN */ + ASSERT (fnmatch ("x[[:punct:]]y", "x\241\321y", 0) == 0); + /* U+3000 IDEOGRAPHIC SPACE */ + ASSERT (fnmatch ("x[[:space:]]y", "x\241\100y", 0) == 0); + /* U+FF2D FULLWIDTH LATIN CAPITAL LETTER M */ + ASSERT (fnmatch ("x[[:upper:]]y", "x\242\333y", 0) == 0); + + #if GNULIB_FNMATCH_GNU && defined FNM_CASEFOLD + /* "α-ω" */ + ASSERT (fnmatch ("\243\134-\243\163", "\243\104-\243\133", FNM_CASEFOLD) == 0); + ASSERT (fnmatch ("\243\104-\243\133", "\243\134-\243\163", FNM_CASEFOLD) == 0); + ASSERT (fnmatch ("\243\134-\243\133", "\243\104-\243\163", FNM_CASEFOLD) == 0); + ASSERT (fnmatch ("\243\104-\243\163", "\243\134-\243\133", FNM_CASEFOLD) == 0); + #endif + + return 0; + + case 936: + /* Locale encoding is CP936 = GBK, an extension of GB2312. */ + + ASSERT (fnmatch ("x?y", "x\310\325y", 0) == 0); /* "x日y" */ + ASSERT (fnmatch ("x?y", "x\261\276y", 0) == 0); /* "x本y" */ + ASSERT (fnmatch ("x?y", "x\325\132y", 0) == 0); /* "x語y" */ + + /* U+FF4D FULLWIDTH LATIN SMALL LETTER M */ + ASSERT (fnmatch ("x[[:alnum:]]y", "x\243\355y", 0) == 0); + /* U+FF4D FULLWIDTH LATIN SMALL LETTER M */ + ASSERT (fnmatch ("x[[:alpha:]]y", "x\243\355y", 0) == 0); + /* U+3001 IDEOGRAPHIC COMMA */ + ASSERT (fnmatch ("x[[:graph:]]y", "x\241\242y", 0) == 0); + /* U+FF4D FULLWIDTH LATIN SMALL LETTER M */ + ASSERT (fnmatch ("x[[:lower:]]y", "x\243\355y", 0) == 0); + /* U+3001 IDEOGRAPHIC COMMA */ + ASSERT (fnmatch ("x[[:print:]]y", "x\241\242y", 0) == 0); + /* U+00D7 MULTIPLICATION SIGN */ + ASSERT (fnmatch ("x[[:punct:]]y", "x\241\301y", 0) == 0); + /* U+3000 IDEOGRAPHIC SPACE */ + ASSERT (fnmatch ("x[[:space:]]y", "x\241\241y", 0) == 0); + /* U+FF2D FULLWIDTH LATIN CAPITAL LETTER M */ + ASSERT (fnmatch ("x[[:upper:]]y", "x\243\315y", 0) == 0); + + #if GNULIB_FNMATCH_GNU && defined FNM_CASEFOLD + /* "α-ω" */ + ASSERT (fnmatch ("\246\301-\246\330", "\246\241-\246\270", FNM_CASEFOLD) == 0); + ASSERT (fnmatch ("\246\241-\246\270", "\246\301-\246\330", FNM_CASEFOLD) == 0); + ASSERT (fnmatch ("\246\301-\246\270", "\246\241-\246\330", FNM_CASEFOLD) == 0); + ASSERT (fnmatch ("\246\241-\246\330", "\246\301-\246\270", FNM_CASEFOLD) == 0); + #endif + + return 0; + + case 54936: + /* Locale encoding is CP54936 = GB18030. */ + if (strcmp (locale_charset (), "GB18030") != 0) + return 77; + + ASSERT (fnmatch ("x?y", "x\250\271y", 0) == 0); /* "xüy" */ + ASSERT (fnmatch ("x?y", "x\201\060\211\070y", 0) == 0); /* "xßy" */ + ASSERT (fnmatch ("x?y", "x\224\071\375\067y", 0) == 0); /* "x😋y" */ + /* U+0141 LATIN CAPITAL LETTER L WITH STROKE */ + ASSERT (fnmatch ("x[[:alnum:]]y", "x\201\060\221\071y", 0) == 0); + /* U+0141 LATIN CAPITAL LETTER L WITH STROKE */ + ASSERT (fnmatch ("x[[:alpha:]]y", "x\201\060\221\071y", 0) == 0); + /* U+00B8 CEDILLA */ + ASSERT (fnmatch ("x[[:graph:]]y", "x\201\060\206\060y", 0) == 0); + /* U+20000 */ + ASSERT (fnmatch ("x[[:graph:]]y", "x\225\062\202\066y", 0) == 0); + /* U+00FF LATIN SMALL LETTER Y WITH DIAERESIS */ + ASSERT (fnmatch ("x[[:lower:]]y", "x\201\060\213\067y", 0) == 0); + /* U+10441 DESERET SMALL LETTER EF */ + ASSERT (fnmatch ("x[[:lower:]]y", "x\220\060\355\071y", 0) == 0); + /* U+00B8 CEDILLA */ + ASSERT (fnmatch ("x[[:print:]]y", "x\201\060\206\060y", 0) == 0); + /* U+20000 */ + ASSERT (fnmatch ("x[[:print:]]y", "x\225\062\202\066y", 0) == 0); + /* U+00D7 MULTIPLICATION SIGN */ + ASSERT (fnmatch ("x[[:punct:]]y", "x\241\301y", 0) == 0); + /* U+1D100 MUSICAL SYMBOL SINGLE BARLINE */ + ASSERT (fnmatch ("x[[:punct:]]y", "x\224\062\273\064y", 0) == 0); + /* U+3000 IDEOGRAPHIC SPACE */ + ASSERT (fnmatch ("x[[:space:]]y", "x\241\241y", 0) == 0); + /* U+0429 CYRILLIC CAPITAL LETTER SHCHA */ + ASSERT (fnmatch ("x[[:upper:]]y", "x\247\273y", 0) == 0); + /* U+10419 DESERET CAPITAL LETTER EF */ + ASSERT (fnmatch ("x[[:upper:]]y", "x\220\060\351\071y", 0) == 0); + /* U+3001 IDEOGRAPHIC COMMA */ + ASSERT (fnmatch ("x[[:alnum:]]y", "x\241\242y", 0) == FNM_NOMATCH); + /* U+3001 IDEOGRAPHIC COMMA */ + ASSERT (fnmatch ("x[[:alpha:]]y", "x\241\242y", 0) == FNM_NOMATCH); + /* U+3001 IDEOGRAPHIC COMMA */ + ASSERT (fnmatch ("x[[:blank:]]y", "x\241\242y", 0) == FNM_NOMATCH); + /* U+3001 IDEOGRAPHIC COMMA */ + ASSERT (fnmatch ("x[[:cntrl:]]y", "x\241\242y", 0) == FNM_NOMATCH); + /* U+3001 IDEOGRAPHIC COMMA */ + ASSERT (fnmatch ("x[[:digit:]]y", "x\241\242y", 0) == FNM_NOMATCH); + /* U+3000 IDEOGRAPHIC SPACE */ + ASSERT (fnmatch ("x[[:graph:]]y", "x\241\241y", 0) == FNM_NOMATCH); + /* U+3001 IDEOGRAPHIC COMMA */ + ASSERT (fnmatch ("x[[:lower:]]y", "x\241\242y", 0) == FNM_NOMATCH); + /* U+00D8 LATIN CAPITAL LETTER O WITH STROKE */ + ASSERT (fnmatch ("x[[:punct:]]y", "x\201\060\211\061y", 0) == FNM_NOMATCH); + /* U+3001 IDEOGRAPHIC COMMA */ + ASSERT (fnmatch ("x[[:space:]]y", "x\241\242y", 0) == FNM_NOMATCH); + /* U+3001 IDEOGRAPHIC COMMA */ + ASSERT (fnmatch ("x[[:upper:]]y", "x\241\242y", 0) == FNM_NOMATCH); + /* U+3001 IDEOGRAPHIC COMMA */ + ASSERT (fnmatch ("x[[:xdigit:]]y", "x\241\242y", 0) == FNM_NOMATCH); + + #if GNULIB_FNMATCH_GNU && defined FNM_CASEFOLD + /* "özgür" */ + ASSERT (fnmatch ("\201\060\213\062zg\250\271r", "\201\060\211\060ZG\201\060\211\065R", FNM_CASEFOLD) == 0); + ASSERT (fnmatch ("\201\060\211\060ZG\201\060\211\065R", "\201\060\213\062zg\250\271r", FNM_CASEFOLD) == 0); + ASSERT (fnmatch ("\201\060\213\062Zg\201\060\211\065r", "\201\060\211\060zG\250\271R", FNM_CASEFOLD) == 0); + ASSERT (fnmatch ("\201\060\211\060zG\250\271R", "\201\060\213\062Zg\201\060\211\065r", FNM_CASEFOLD) == 0); + #endif + + return 0; + + default: + return 1; + } +} + +int +main (int argc, char *argv[]) +{ + int codepage = atoi (argv[argc - 1]); + int result; + int i; + + result = 77; + for (i = 1; i < argc - 1; i++) + { + int ret = test_one_locale (argv[i], codepage); + + if (ret != 77) + result = ret; + } + + if (result == 77) + { + fprintf (stderr, "Skipping test: found no locale with codepage %d\n", + codepage); + } + return result; +} + +#else + +int +main (int argc, char *argv[]) +{ + fputs ("Skipping test: not a native Windows system\n", stderr); + return 77; +} + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch.c new file mode 100644 index 00000000..afcad2df --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fnmatch.c @@ -0,0 +1,963 @@ +/* Test of fnmatch string matching function. + Copyright (C) 2009-2024 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 . */ + +/* Written by Simon Josefsson , 2009, + and Bruno Haible , 2023. */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (fnmatch, int, (char const *, char const *, int)); + +#include +#include +#include +#include +#include +#include + +#include "macros.h" + +int +main (int argc, char *argv[]) +{ + /* configure should already have checked that the locale is supported. */ + if (setlocale (LC_ALL, "") == NULL) + return 1; + +#ifdef __ANDROID__ + /* On Android ≥ 5.0, the default locale is the "C.UTF-8" locale, not the + "C" locale. Furthermore, when you attempt to set the "C" or "POSIX" + locale via setlocale(), what you get is a "C" locale with UTF-8 encoding, + that is, effectively the "C.UTF-8" locale. */ + if (argc > 1 && strcmp (argv[1], "1") == 0 && MB_CUR_MAX > 1) + argv[1] = "3"; +#endif + + /* Patterns with ordinary characters. */ + + ASSERT (fnmatch ("", "", 0) == 0); + ASSERT (fnmatch ("", "abc", 0) == FNM_NOMATCH); + + ASSERT (fnmatch ("xy", "xy", 0) == 0); + ASSERT (fnmatch ("xy", "", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("xy", "wxy", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("xy", "xyz", 0) == FNM_NOMATCH); + + /* Patterns with special pattern characters. */ + + ASSERT (fnmatch ("?", "", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("?", "a", 0) == 0); + ASSERT (fnmatch ("?", "z", 0) == 0); + ASSERT (fnmatch ("?", ".", 0) == 0); + ASSERT (fnmatch ("?", "/", 0) == 0); + ASSERT (fnmatch ("?", "az", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("?", "//", 0) == FNM_NOMATCH); + + ASSERT (fnmatch ("x?y", "", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("x?y", "y", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("x?y", "xy", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("x?y", "xay", 0) == 0); + ASSERT (fnmatch ("x?y", "xzy", 0) == 0); + ASSERT (fnmatch ("x?y", "x.y", 0) == 0); + ASSERT (fnmatch ("x?y", "x/y", 0) == 0); + ASSERT (fnmatch ("x?y", "xazy", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("x?y", "x//y", 0) == FNM_NOMATCH); + + ASSERT (fnmatch ("*", "", 0) == 0); + ASSERT (fnmatch ("*", "a", 0) == 0); + ASSERT (fnmatch ("*", "z", 0) == 0); + ASSERT (fnmatch ("*", ".", 0) == 0); + ASSERT (fnmatch ("*", "*", 0) == 0); + ASSERT (fnmatch ("*", "/", 0) == 0); + ASSERT (fnmatch ("*", "az", 0) == 0); + ASSERT (fnmatch ("*", "//", 0) == 0); + ASSERT (fnmatch ("*", "some long text", 0) == 0); + + ASSERT (fnmatch ("x*y", "", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("x*y", "y", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("x*y", "xy", 0) == 0); + ASSERT (fnmatch ("x*y", "xay", 0) == 0); + ASSERT (fnmatch ("x*y", "xzy", 0) == 0); + ASSERT (fnmatch ("x*y", "x.y", 0) == 0); + ASSERT (fnmatch ("x*y", "x*y", 0) == 0); + ASSERT (fnmatch ("x*y", "x/y", 0) == 0); + ASSERT (fnmatch ("x*y", "xazy", 0) == 0); + ASSERT (fnmatch ("x*y", "x//y", 0) == 0); + + ASSERT (fnmatch ("**", "", 0) == 0); + ASSERT (fnmatch ("**", "a", 0) == 0); + ASSERT (fnmatch ("**", "z", 0) == 0); + ASSERT (fnmatch ("**", ".", 0) == 0); + ASSERT (fnmatch ("**", "*", 0) == 0); + ASSERT (fnmatch ("**", "/", 0) == 0); + ASSERT (fnmatch ("**", "az", 0) == 0); + ASSERT (fnmatch ("**", "//", 0) == 0); + ASSERT (fnmatch ("**", "some long text", 0) == 0); + + ASSERT (fnmatch ("x**y", "", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("x**y", "y", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("x**y", "xy", 0) == 0); + ASSERT (fnmatch ("x**y", "xay", 0) == 0); + ASSERT (fnmatch ("x**y", "xzy", 0) == 0); + ASSERT (fnmatch ("x**y", "x.y", 0) == 0); + ASSERT (fnmatch ("x**y", "x*y", 0) == 0); + ASSERT (fnmatch ("x**y", "x/y", 0) == 0); + ASSERT (fnmatch ("x**y", "xazy", 0) == 0); + ASSERT (fnmatch ("x**y", "x//y", 0) == 0); + ASSERT (fnmatch ("x**y", "", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("x**y", "y", 0) == FNM_NOMATCH); + + ASSERT (fnmatch ("*.*", "foo.txt", 0) == 0); + ASSERT (fnmatch ("*.*", "foo.", 0) == 0); + ASSERT (fnmatch ("*.*", "foo", 0) == FNM_NOMATCH); + + ASSERT (fnmatch ("x*y*z", "", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("x*y*z", "x", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("x*y*z", "y", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("x*y*z", "z", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("x*y*z", "xy", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("x*y*z", "xz", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("x*y*z", "yz", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("x*y*z", "xyz", 0) == 0); + ASSERT (fnmatch ("x*y*z", "xayz", 0) == 0); + ASSERT (fnmatch ("x*y*z", "xybz", 0) == 0); + ASSERT (fnmatch ("x*y*z", "xaybz", 0) == 0); + ASSERT (fnmatch ("x*y*z", "xxyz", 0) == 0); + ASSERT (fnmatch ("x*y*z", "xyyz", 0) == 0); + ASSERT (fnmatch ("x*y*z", "xyzz", 0) == 0); + ASSERT (fnmatch ("x*y*z", "xyxyz", 0) == 0); + + ASSERT (fnmatch ("x***??y", "", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("x***??y", "xy", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("x***??y", "x1y", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("x***??y", "x12y", 0) == 0); + ASSERT (fnmatch ("x***??y", "x123y", 0) == 0); + + ASSERT (fnmatch ("x**??*y", "", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("x**??*y", "xy", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("x**??*y", "x1y", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("x**??*y", "x12y", 0) == 0); + ASSERT (fnmatch ("x**??*y", "x123y", 0) == 0); + + ASSERT (fnmatch ("x*??**y", "", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("x*??**y", "xy", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("x*??**y", "x1y", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("x*??**y", "x12y", 0) == 0); + ASSERT (fnmatch ("x*??**y", "x123y", 0) == 0); + + ASSERT (fnmatch ("x??***y", "", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("x??***y", "xy", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("x??***y", "x1y", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("x??***y", "x12y", 0) == 0); + ASSERT (fnmatch ("x??***y", "x123y", 0) == 0); + + ASSERT (fnmatch ("x**?*?y", "", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("x**?*?y", "xy", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("x**?*?y", "x1y", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("x**?*?y", "x12y", 0) == 0); + ASSERT (fnmatch ("x**?*?y", "x123y", 0) == 0); + + ASSERT (fnmatch ("x*?*?*y", "", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("x*?*?*y", "xy", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("x*?*?*y", "x1y", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("x*?*?*y", "x12y", 0) == 0); + ASSERT (fnmatch ("x*?*?*y", "x123y", 0) == 0); + + ASSERT (fnmatch ("x?*?**y", "", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("x?*?**y", "xy", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("x?*?**y", "x1y", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("x?*?**y", "x12y", 0) == 0); + ASSERT (fnmatch ("x?*?**y", "x123y", 0) == 0); + + ASSERT (fnmatch ("x*?**?y", "", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("x*?**?y", "xy", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("x*?**?y", "x1y", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("x*?**?y", "x12y", 0) == 0); + ASSERT (fnmatch ("x*?**?y", "x123y", 0) == 0); + + ASSERT (fnmatch ("x?**?*y", "", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("x?**?*y", "xy", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("x?**?*y", "x1y", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("x?**?*y", "x12y", 0) == 0); + ASSERT (fnmatch ("x?**?*y", "x123y", 0) == 0); + + ASSERT (fnmatch ("x?***?y", "", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("x?***?y", "xy", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("x?***?y", "x1y", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("x?***?y", "x12y", 0) == 0); + ASSERT (fnmatch ("x?***?y", "x123y", 0) == 0); + + /* Patterns with bracket expressions. */ + + ASSERT (fnmatch ("[a-z]", "", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[a-z]", "a", 0) == 0); + ASSERT (fnmatch ("[a-z]", "z", 0) == 0); + ASSERT (fnmatch ("[a-z]", ".", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[a-z]", "/", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[a-z]", "az", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[a-z]", "//", 0) == FNM_NOMATCH); + + ASSERT (fnmatch ("[!a-z]", "", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[!a-z]", "a", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[!a-z]", "z", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[!a-z]", ".", 0) == 0); + ASSERT (fnmatch ("[!a-z]", "/", 0) == 0); + ASSERT (fnmatch ("[!a-z]", "az", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[!a-z]", "//", 0) == FNM_NOMATCH); + + ASSERT (fnmatch ("[[:alnum:]]", "", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:alnum:]]", "a", 0) == 0); + ASSERT (fnmatch ("[[:alnum:]]", "z", 0) == 0); + ASSERT (fnmatch ("[[:alnum:]]", "7", 0) == 0); + ASSERT (fnmatch ("[[:alnum:]]", ".", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:alnum:]]", "/", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:alnum:]]", "az", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:alnum:]]", "//", 0) == FNM_NOMATCH); + + ASSERT (fnmatch ("[[:alpha:]]", "", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:alpha:]]", "a", 0) == 0); + ASSERT (fnmatch ("[[:alpha:]]", "z", 0) == 0); + ASSERT (fnmatch ("[[:alpha:]]", "7", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:alpha:]]", ".", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:alpha:]]", "/", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:alpha:]]", "az", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:alpha:]]", "//", 0) == FNM_NOMATCH); + + ASSERT (fnmatch ("[[:blank:]]", "", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:blank:]]", "a", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:blank:]]", "z", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:blank:]]", "7", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:blank:]]", " ", 0) == 0); + ASSERT (fnmatch ("[[:blank:]]", ".", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:blank:]]", "/", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:blank:]]", "az", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:blank:]]", "//", 0) == FNM_NOMATCH); + + ASSERT (fnmatch ("[[:cntrl:]]", "", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:cntrl:]]", "a", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:cntrl:]]", "z", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:cntrl:]]", "7", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:cntrl:]]", "\n", 0) == 0); + ASSERT (fnmatch ("[[:cntrl:]]", ".", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:cntrl:]]", "/", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:cntrl:]]", "az", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:cntrl:]]", "//", 0) == FNM_NOMATCH); + + ASSERT (fnmatch ("[[:digit:]]", "", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:digit:]]", "a", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:digit:]]", "z", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:digit:]]", "7", 0) == 0); + ASSERT (fnmatch ("[[:digit:]]", ".", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:digit:]]", "/", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:digit:]]", "az", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:digit:]]", "//", 0) == FNM_NOMATCH); + + ASSERT (fnmatch ("[[:graph:]]", "", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:graph:]]", "a", 0) == 0); + ASSERT (fnmatch ("[[:graph:]]", "z", 0) == 0); + ASSERT (fnmatch ("[[:graph:]]", "7", 0) == 0); + ASSERT (fnmatch ("[[:graph:]]", " ", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:graph:]]", ".", 0) == 0); + ASSERT (fnmatch ("[[:graph:]]", "/", 0) == 0); + ASSERT (fnmatch ("[[:graph:]]", "az", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:graph:]]", "//", 0) == FNM_NOMATCH); + + ASSERT (fnmatch ("[[:lower:]]", "", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:lower:]]", "a", 0) == 0); + ASSERT (fnmatch ("[[:lower:]]", "z", 0) == 0); + ASSERT (fnmatch ("[[:lower:]]", "A", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:lower:]]", "Z", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:lower:]]", "7", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:lower:]]", ".", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:lower:]]", "/", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:lower:]]", "az", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:lower:]]", "//", 0) == FNM_NOMATCH); + + ASSERT (fnmatch ("[[:print:]]", "", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:print:]]", "a", 0) == 0); + ASSERT (fnmatch ("[[:print:]]", "z", 0) == 0); + ASSERT (fnmatch ("[[:print:]]", "7", 0) == 0); + ASSERT (fnmatch ("[[:print:]]", " ", 0) == 0); + ASSERT (fnmatch ("[[:print:]]", ".", 0) == 0); + ASSERT (fnmatch ("[[:print:]]", "/", 0) == 0); + ASSERT (fnmatch ("[[:print:]]", "az", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:print:]]", "//", 0) == FNM_NOMATCH); + + ASSERT (fnmatch ("[[:punct:]]", "", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:punct:]]", "a", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:punct:]]", "z", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:punct:]]", "7", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:punct:]]", ".", 0) == 0); + ASSERT (fnmatch ("[[:punct:]]", "/", 0) == 0); + ASSERT (fnmatch ("[[:punct:]]", "az", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:punct:]]", "//", 0) == FNM_NOMATCH); + + ASSERT (fnmatch ("[[:space:]]", "", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:space:]]", "a", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:space:]]", "z", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:space:]]", "7", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:space:]]", " ", 0) == 0); + ASSERT (fnmatch ("[[:space:]]", "\t", 0) == 0); + ASSERT (fnmatch ("[[:space:]]", ".", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:space:]]", "/", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:space:]]", "az", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:space:]]", "//", 0) == FNM_NOMATCH); + + ASSERT (fnmatch ("[[:upper:]]", "", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:upper:]]", "a", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:upper:]]", "z", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:upper:]]", "A", 0) == 0); + ASSERT (fnmatch ("[[:upper:]]", "Z", 0) == 0); + ASSERT (fnmatch ("[[:upper:]]", "7", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:upper:]]", ".", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:upper:]]", "/", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:upper:]]", "az", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:upper:]]", "//", 0) == FNM_NOMATCH); + + ASSERT (fnmatch ("[[:xdigit:]]", "", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:xdigit:]]", "a", 0) == 0); + ASSERT (fnmatch ("[[:xdigit:]]", "F", 0) == 0); + ASSERT (fnmatch ("[[:xdigit:]]", "z", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:xdigit:]]", "7", 0) == 0); + ASSERT (fnmatch ("[[:xdigit:]]", ".", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:xdigit:]]", "/", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:xdigit:]]", "az", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:xdigit:]]", "//", 0) == FNM_NOMATCH); + + ASSERT (fnmatch ("[[:alpha:]'[:alpha:]\0]", "a", 0) == FNM_NOMATCH); + + ASSERT (fnmatch ("[a[.\0.]]", "a", 0) == FNM_NOMATCH); + + /* Verify that an unmatched [ is treated as a literal, as POSIX requires. */ + ASSERT (fnmatch ("[", "[", 0) == 0); + ASSERT (fnmatch ("[", "]", 0) == FNM_NOMATCH); + + /* The FNM_PATHNAME flag. */ + + ASSERT (fnmatch ("x?y", "x/y", 0) == 0); + ASSERT (fnmatch ("x?y", "x/y", FNM_PATHNAME) == FNM_NOMATCH); + + ASSERT (fnmatch ("x*y", "x/y", 0) == 0); + ASSERT (fnmatch ("x*y", "x/y", FNM_PATHNAME) == FNM_NOMATCH); + + ASSERT (fnmatch ("[/-/]", "/", 0) == 0); + ASSERT (fnmatch ("[/-/]", "/", FNM_PATHNAME) == FNM_NOMATCH); + ASSERT (fnmatch ("[!-~]", "/", FNM_PATHNAME) == FNM_NOMATCH); + + ASSERT (fnmatch ("[[:graph:]]", "/", FNM_PATHNAME) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:print:]]", "/", FNM_PATHNAME) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:punct:]]", "/", FNM_PATHNAME) == FNM_NOMATCH); + + /* The FNM_NOESCAPE flag. */ + + ASSERT (fnmatch ("foo\\.txt", "foo.txt", 0) == 0); + ASSERT (fnmatch ("foo\\.txt", "foo.txt", FNM_NOESCAPE) == FNM_NOMATCH); + + ASSERT (fnmatch ("x?y", "x/y", 0) == 0); + ASSERT (fnmatch ("x\\?y", "x/y", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("x\\?y", "x/y", FNM_NOESCAPE) == FNM_NOMATCH); + ASSERT (fnmatch ("x\\?y", "x?y", 0) == 0); + ASSERT (fnmatch ("x\\?y", "x?y", FNM_NOESCAPE) == FNM_NOMATCH); + ASSERT (fnmatch ("x\\?y", "x\\?y", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("x\\?y", "x\\?y", FNM_NOESCAPE) == 0); + + ASSERT (fnmatch ("x*y", "x/y", 0) == 0); + ASSERT (fnmatch ("x\\*y", "x/y", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("x\\*y", "x/y", FNM_NOESCAPE) == FNM_NOMATCH); + ASSERT (fnmatch ("x\\*y", "x*y", 0) == 0); + ASSERT (fnmatch ("x\\*y", "x*y", FNM_NOESCAPE) == FNM_NOMATCH); + ASSERT (fnmatch ("x\\*y", "x\\*y", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("x\\*y", "x\\*y", FNM_NOESCAPE) == 0); + + /* The FNM_PERIOD flag. */ + + ASSERT (fnmatch ("foo.rc", "foo.rc", 0) == 0); + ASSERT (fnmatch ("foo.rc", "foo.rc", FNM_PATHNAME) == 0); + ASSERT (fnmatch ("foo.rc", "foo.rc", FNM_PERIOD) == 0); + ASSERT (fnmatch ("foo.rc", "foo.rc", FNM_PATHNAME | FNM_PERIOD) == 0); + ASSERT (fnmatch ("foo?rc", "foo.rc", 0) == 0); + ASSERT (fnmatch ("foo?rc", "foo.rc", FNM_PATHNAME) == 0); + ASSERT (fnmatch ("foo?rc", "foo.rc", FNM_PERIOD) == 0); + ASSERT (fnmatch ("foo?rc", "foo.rc", FNM_PATHNAME | FNM_PERIOD) == 0); + ASSERT (fnmatch ("foo[[:punct:]]rc", "foo.rc", 0) == 0); + ASSERT (fnmatch ("foo[[:punct:]]rc", "foo.rc", FNM_PATHNAME) == 0); + ASSERT (fnmatch ("foo[[:punct:]]rc", "foo.rc", FNM_PERIOD) == 0); + ASSERT (fnmatch ("foo[[:punct:]]rc", "foo.rc", FNM_PATHNAME | FNM_PERIOD) == 0); + ASSERT (fnmatch ("foo*rc", "foo.rc", 0) == 0); + ASSERT (fnmatch ("foo*rc", "foo.rc", FNM_PATHNAME) == 0); + ASSERT (fnmatch ("foo*rc", "foo.rc", FNM_PERIOD) == 0); + ASSERT (fnmatch ("foo*rc", "foo.rc", FNM_PATHNAME | FNM_PERIOD) == 0); + + ASSERT (fnmatch (".rc", ".rc", 0) == 0); + ASSERT (fnmatch (".rc", ".rc", FNM_PATHNAME) == 0); + ASSERT (fnmatch (".rc", ".rc", FNM_PERIOD) == 0); + ASSERT (fnmatch (".rc", ".rc", FNM_PATHNAME | FNM_PERIOD) == 0); + ASSERT (fnmatch ("?rc", ".rc", 0) == 0); + ASSERT (fnmatch ("?rc", ".rc", FNM_PATHNAME) == 0); + ASSERT (fnmatch ("?rc", ".rc", FNM_PERIOD) == FNM_NOMATCH); + ASSERT (fnmatch ("?rc", ".rc", FNM_PATHNAME | FNM_PERIOD) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:punct:]]rc", ".rc", 0) == 0); + ASSERT (fnmatch ("[[:punct:]]rc", ".rc", FNM_PATHNAME) == 0); + ASSERT (fnmatch ("[[:punct:]]rc", ".rc", FNM_PERIOD) == FNM_NOMATCH); + ASSERT (fnmatch ("[[:punct:]]rc", ".rc", FNM_PATHNAME | FNM_PERIOD) == FNM_NOMATCH); + ASSERT (fnmatch ("*rc", ".rc", 0) == 0); + ASSERT (fnmatch ("*rc", ".rc", FNM_PATHNAME) == 0); + ASSERT (fnmatch ("*rc", ".rc", FNM_PERIOD) == FNM_NOMATCH); + ASSERT (fnmatch ("*rc", ".rc", FNM_PATHNAME | FNM_PERIOD) == FNM_NOMATCH); + + ASSERT (fnmatch ("dir/.rc", "dir/.rc", 0) == 0); + ASSERT (fnmatch ("dir/.rc", "dir/.rc", FNM_PATHNAME) == 0); + ASSERT (fnmatch ("dir/.rc", "dir/.rc", FNM_PERIOD) == 0); + ASSERT (fnmatch ("dir/.rc", "dir/.rc", FNM_PATHNAME | FNM_PERIOD) == 0); + ASSERT (fnmatch ("dir/?rc", "dir/.rc", 0) == 0); + ASSERT (fnmatch ("dir/?rc", "dir/.rc", FNM_PATHNAME) == 0); + ASSERT (fnmatch ("dir/?rc", "dir/.rc", FNM_PERIOD) == 0); + ASSERT (fnmatch ("dir/?rc", "dir/.rc", FNM_PATHNAME | FNM_PERIOD) == FNM_NOMATCH); + ASSERT (fnmatch ("dir/[[:punct:]]rc", "dir/.rc", 0) == 0); + ASSERT (fnmatch ("dir/[[:punct:]]rc", "dir/.rc", FNM_PATHNAME) == 0); + ASSERT (fnmatch ("dir/[[:punct:]]rc", "dir/.rc", FNM_PERIOD) == 0); + ASSERT (fnmatch ("dir/[[:punct:]]rc", "dir/.rc", FNM_PATHNAME | FNM_PERIOD) == FNM_NOMATCH); + ASSERT (fnmatch ("dir/*rc", "dir/.rc", 0) == 0); + ASSERT (fnmatch ("dir/*rc", "dir/.rc", FNM_PATHNAME) == 0); + ASSERT (fnmatch ("dir/*rc", "dir/.rc", FNM_PERIOD) == 0); + ASSERT (fnmatch ("dir/*rc", "dir/.rc", FNM_PATHNAME | FNM_PERIOD) == FNM_NOMATCH); + ASSERT (fnmatch ("*rc", "dir/.rc", 0) == 0); + ASSERT (fnmatch ("*rc", "dir/.rc", FNM_PATHNAME) == FNM_NOMATCH); + ASSERT (fnmatch ("*rc", "dir/.rc", FNM_PERIOD) == 0); + ASSERT (fnmatch ("*rc", "dir/.rc", FNM_PATHNAME | FNM_PERIOD) == FNM_NOMATCH); + + /* The FNM_LEADING_DIR flag (common extension). */ + #if GNULIB_FNMATCH_GNU && defined FNM_LEADING_DIR + + ASSERT (fnmatch ("x", "x", 0) == 0); + ASSERT (fnmatch ("x", "x", FNM_LEADING_DIR) == 0); + ASSERT (fnmatch ("x", "x/", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("x", "x/", FNM_LEADING_DIR) == 0); + ASSERT (fnmatch ("x", "x/y", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("x", "x/y", FNM_LEADING_DIR) == 0); + + ASSERT (fnmatch ("x?y", "x/y", 0) == 0); + ASSERT (fnmatch ("x?y", "x/y", FNM_LEADING_DIR) == 0); + ASSERT (fnmatch ("x?y", "x/y", FNM_PATHNAME) == FNM_NOMATCH); + ASSERT (fnmatch ("x?y", "x/y", FNM_PATHNAME | FNM_LEADING_DIR) == FNM_NOMATCH); + ASSERT (fnmatch ("x?y", "x/y/z", FNM_PATHNAME | FNM_LEADING_DIR) == FNM_NOMATCH); + + #endif + + /* The FNM_CASEFOLD flag (common extension). */ + #if GNULIB_FNMATCH_GNU && defined FNM_CASEFOLD + + ASSERT (fnmatch ("xy", "xy", 0) == 0); + ASSERT (fnmatch ("xy", "xy", FNM_CASEFOLD) == 0); + ASSERT (fnmatch ("xy", "Xy", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("xy", "Xy", FNM_CASEFOLD) == 0); + ASSERT (fnmatch ("xy", "xY", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("xy", "xY", FNM_CASEFOLD) == 0); + ASSERT (fnmatch ("xy", "XY", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("xy", "XY", FNM_CASEFOLD) == 0); + + /* Locales other than the "C" locale may order the ASCII letters like this: + AaBb...Mm...Zz . Seen on FreeBSD and Solaris 11. */ + if (argc == 1 || strcmp (argv[1], "1") == 0) + ASSERT (fnmatch ("[a-z]", "M", 0) == FNM_NOMATCH); + #if !defined GNULIB_defined_fnmatch_function + ASSERT (fnmatch ("[a-z]", "M", FNM_CASEFOLD) == 0); + #endif + if (argc == 1 || strcmp (argv[1], "1") == 0) + ASSERT (fnmatch ("[A-Z]", "m", 0) == FNM_NOMATCH); + #if !defined GNULIB_defined_fnmatch_function + ASSERT (fnmatch ("[A-Z]", "m", FNM_CASEFOLD) == 0); + #endif + + #endif + + /* The FNM_EXTMATCH flag (GNU extension). */ + #if GNULIB_FNMATCH_GNU && defined FNM_EXTMATCH + + ASSERT (fnmatch ("x?($|[[:digit:]])y", "", FNM_EXTMATCH) == FNM_NOMATCH); + ASSERT (fnmatch ("x?($|[[:digit:]])y", "y", FNM_EXTMATCH) == FNM_NOMATCH); + ASSERT (fnmatch ("x?($|[[:digit:]])y", "xy", FNM_EXTMATCH) == 0); + ASSERT (fnmatch ("x?($|[[:digit:]])y", "x$y", FNM_EXTMATCH) == 0); + ASSERT (fnmatch ("x?($|[[:digit:]])y", "x7y", FNM_EXTMATCH) == 0); + ASSERT (fnmatch ("x?($|[[:digit:]])y", "xay", FNM_EXTMATCH) == FNM_NOMATCH); + ASSERT (fnmatch ("x?($|[[:digit:]])y", "xzy", FNM_EXTMATCH) == FNM_NOMATCH); + ASSERT (fnmatch ("x?($|[[:digit:]])y", "x/y", FNM_EXTMATCH) == FNM_NOMATCH); + ASSERT (fnmatch ("x?($|[[:digit:]])y", "x32y", FNM_EXTMATCH) == FNM_NOMATCH); + ASSERT (fnmatch ("x?($|[[:digit:]])y", "x$1y", FNM_EXTMATCH) == FNM_NOMATCH); + ASSERT (fnmatch ("x?($|[[:digit:]])y", "x1$y", FNM_EXTMATCH) == FNM_NOMATCH); + + ASSERT (fnmatch ("x*($|[[:digit:]])y", "", FNM_EXTMATCH) == FNM_NOMATCH); + ASSERT (fnmatch ("x*($|[[:digit:]])y", "y", FNM_EXTMATCH) == FNM_NOMATCH); + ASSERT (fnmatch ("x*($|[[:digit:]])y", "xy", FNM_EXTMATCH) == 0); + ASSERT (fnmatch ("x*($|[[:digit:]])y", "x$y", FNM_EXTMATCH) == 0); + ASSERT (fnmatch ("x*($|[[:digit:]])y", "x7y", FNM_EXTMATCH) == 0); + ASSERT (fnmatch ("x*($|[[:digit:]])y", "xay", FNM_EXTMATCH) == FNM_NOMATCH); + ASSERT (fnmatch ("x*($|[[:digit:]])y", "xzy", FNM_EXTMATCH) == FNM_NOMATCH); + ASSERT (fnmatch ("x*($|[[:digit:]])y", "x/y", FNM_EXTMATCH) == FNM_NOMATCH); + ASSERT (fnmatch ("x*($|[[:digit:]])y", "x32y", FNM_EXTMATCH) == 0); + ASSERT (fnmatch ("x*($|[[:digit:]])y", "x$1y", FNM_EXTMATCH) == 0); + ASSERT (fnmatch ("x*($|[[:digit:]])y", "x1$y", FNM_EXTMATCH) == 0); + + ASSERT (fnmatch ("x+($|[[:digit:]])y", "", FNM_EXTMATCH) == FNM_NOMATCH); + ASSERT (fnmatch ("x+($|[[:digit:]])y", "y", FNM_EXTMATCH) == FNM_NOMATCH); + ASSERT (fnmatch ("x+($|[[:digit:]])y", "xy", FNM_EXTMATCH) == FNM_NOMATCH); + ASSERT (fnmatch ("x+($|[[:digit:]])y", "x$y", FNM_EXTMATCH) == 0); + ASSERT (fnmatch ("x+($|[[:digit:]])y", "x7y", FNM_EXTMATCH) == 0); + ASSERT (fnmatch ("x+($|[[:digit:]])y", "xay", FNM_EXTMATCH) == FNM_NOMATCH); + ASSERT (fnmatch ("x+($|[[:digit:]])y", "xzy", FNM_EXTMATCH) == FNM_NOMATCH); + ASSERT (fnmatch ("x+($|[[:digit:]])y", "x/y", FNM_EXTMATCH) == FNM_NOMATCH); + ASSERT (fnmatch ("x+($|[[:digit:]])y", "x32y", FNM_EXTMATCH) == 0); + ASSERT (fnmatch ("x+($|[[:digit:]])y", "x$1y", FNM_EXTMATCH) == 0); + ASSERT (fnmatch ("x+($|[[:digit:]])y", "x1$y", FNM_EXTMATCH) == 0); + + ASSERT (fnmatch ("x@($|[[:digit:]])y", "", FNM_EXTMATCH) == FNM_NOMATCH); + ASSERT (fnmatch ("x@($|[[:digit:]])y", "y", FNM_EXTMATCH) == FNM_NOMATCH); + ASSERT (fnmatch ("x@($|[[:digit:]])y", "xy", FNM_EXTMATCH) == FNM_NOMATCH); + ASSERT (fnmatch ("x@($|[[:digit:]])y", "x$y", FNM_EXTMATCH) == 0); + ASSERT (fnmatch ("x@($|[[:digit:]])y", "x7y", FNM_EXTMATCH) == 0); + ASSERT (fnmatch ("x@($|[[:digit:]])y", "xay", FNM_EXTMATCH) == FNM_NOMATCH); + ASSERT (fnmatch ("x@($|[[:digit:]])y", "xzy", FNM_EXTMATCH) == FNM_NOMATCH); + ASSERT (fnmatch ("x@($|[[:digit:]])y", "x/y", FNM_EXTMATCH) == FNM_NOMATCH); + ASSERT (fnmatch ("x@($|[[:digit:]])y", "x32y", FNM_EXTMATCH) == FNM_NOMATCH); + ASSERT (fnmatch ("x@($|[[:digit:]])y", "x$1y", FNM_EXTMATCH) == FNM_NOMATCH); + ASSERT (fnmatch ("x@($|[[:digit:]])y", "x1$y", FNM_EXTMATCH) == FNM_NOMATCH); + + ASSERT (fnmatch ("x!($|[[:digit:]])y", "", FNM_EXTMATCH) == FNM_NOMATCH); + ASSERT (fnmatch ("x!($|[[:digit:]])y", "y", FNM_EXTMATCH) == FNM_NOMATCH); + ASSERT (fnmatch ("x!($|[[:digit:]])y", "xy", FNM_EXTMATCH) == 0); + ASSERT (fnmatch ("x!($|[[:digit:]])y", "x$y", FNM_EXTMATCH) == FNM_NOMATCH); + ASSERT (fnmatch ("x!($|[[:digit:]])y", "x7y", FNM_EXTMATCH) == FNM_NOMATCH); + ASSERT (fnmatch ("x!($|[[:digit:]])y", "xay", FNM_EXTMATCH) == 0); + ASSERT (fnmatch ("x!($|[[:digit:]])y", "xzy", FNM_EXTMATCH) == 0); + ASSERT (fnmatch ("x!($|[[:digit:]])y", "x/y", FNM_EXTMATCH) == 0); + ASSERT (fnmatch ("x!($|[[:digit:]])y", "x32y", FNM_EXTMATCH) == 0); + ASSERT (fnmatch ("x!($|[[:digit:]])y", "x$1y", FNM_EXTMATCH) == 0); + ASSERT (fnmatch ("x!($|[[:digit:]])y", "x1$y", FNM_EXTMATCH) == 0); + + ASSERT (fnmatch ("**(!()", "**(!()", FNM_EXTMATCH) == 0); + + #endif + + /* Verify that the test cases from fnmatch.m4 are really working. */ + { + char const *Apat = 'A' < '\\' ? "[A-\\\\]" : "[\\\\-A]"; + char const *apat = 'a' < '\\' ? "[a-\\\\]" : "[\\\\-a]"; + static char const A_1[] = { 'A' - 1, 0 }; + static char const A01[] = { 'A' + 1, 0 }; + static char const a_1[] = { 'a' - 1, 0 }; + static char const a01[] = { 'a' + 1, 0 }; + static char const bs_1[] = { '\\' - 1, 0 }; + static char const bs01[] = { '\\' + 1, 0 }; + /* These are sanity checks. They all succeed on current platforms. */ + ASSERT (fnmatch ("a*", "", 0) == FNM_NOMATCH); + ASSERT (fnmatch ("a*", "abc", 0) == 0); + ASSERT (fnmatch ("d*/*1", "d/s/1", FNM_PATHNAME) == FNM_NOMATCH); + ASSERT (fnmatch ("a\\bc", "abc", 0) == 0); + ASSERT (fnmatch ("a\\bc", "abc", FNM_NOESCAPE) == FNM_NOMATCH); + ASSERT (fnmatch ("*x", ".x", 0) == 0); + ASSERT (fnmatch ("*x", ".x", FNM_PERIOD) == FNM_NOMATCH); + if (argc == 1 || strcmp (argv[1], "1") == 0) + { + /* glibc bug + exists in glibc 2.3.3, fixed in glibc 2.5. */ + ASSERT (fnmatch (Apat, "\\", 0) == 0); + ASSERT (fnmatch (Apat, "A", 0) == 0); + ASSERT (fnmatch (apat, "\\", 0) == 0); + ASSERT (fnmatch (apat, "a", 0) == 0); + ASSERT (fnmatch (Apat, A_1, 0) == ('A' < '\\' ? FNM_NOMATCH : 0)); + ASSERT (fnmatch (apat, a_1, 0) == ('a' < '\\' ? FNM_NOMATCH : 0)); + ASSERT (fnmatch (Apat, A01, 0) == ('A' < '\\' ? 0 : FNM_NOMATCH)); + ASSERT (fnmatch (apat, a01, 0) == ('a' < '\\' ? 0 : FNM_NOMATCH)); + ASSERT (fnmatch (Apat, bs_1, 0) == ('A' < '\\' ? 0 : FNM_NOMATCH)); + ASSERT (fnmatch (apat, bs_1, 0) == ('a' < '\\' ? 0 : FNM_NOMATCH)); + ASSERT (fnmatch (Apat, bs01, 0) == ('A' < '\\' ? FNM_NOMATCH : 0)); + ASSERT (fnmatch (apat, bs01, 0) == ('a' < '\\' ? FNM_NOMATCH : 0)); + } + /* glibc bug + exists in glibc 2.12, fixed in glibc 2.13. */ + ASSERT (fnmatch ("[/b", "[/b", 0) == 0); + /* This test fails on FreeBSD 13.2, NetBSD 9.3, Cygwin 3.4.6. */ + ASSERT (fnmatch ("[[:alnum:]]", "a", 0) == 0); + #if GNULIB_FNMATCH_GNU && defined FNM_CASEFOLD + ASSERT (fnmatch ("xxXX", "xXxX", FNM_CASEFOLD) == 0); + #endif + #if GNULIB_FNMATCH_GNU && defined FNM_EXTMATCH + ASSERT (fnmatch ("a++(x|yy)b", "a+xyyyyxb", FNM_EXTMATCH) == 0); + #endif + #if GNULIB_FNMATCH_GNU && defined FNM_FILE_NAME + ASSERT (fnmatch ("d*/*1", "d/s/1", FNM_FILE_NAME) == FNM_NOMATCH); + ASSERT (fnmatch ("*", "x", FNM_FILE_NAME | FNM_LEADING_DIR) == 0); + ASSERT (fnmatch ("x*", "x/y/z", FNM_FILE_NAME | FNM_LEADING_DIR) == 0); + ASSERT (fnmatch ("*c*", "c/x", FNM_FILE_NAME | FNM_LEADING_DIR) == 0); + #endif + } + + /* Locale specific recognition of multibyte characters. */ + + if (argc > 1) + switch (argv[1][0]) + { + case '1': + /* C or POSIX locale. */ + return 0; + + case '2': + /* Locale encoding is ISO-8859-1 or ISO-8859-15. */ + + ASSERT (fnmatch ("x?y", "x\374y", 0) == 0); /* "xüy" */ + ASSERT (fnmatch ("x?y", "x\337y", 0) == 0); /* "xßy" */ + /* U+00D8 LATIN CAPITAL LETTER O WITH STROKE */ + ASSERT (fnmatch ("x[[:alnum:]]y", "x\330y", 0) == 0); + /* U+00D8 LATIN CAPITAL LETTER O WITH STROKE */ + ASSERT (fnmatch ("x[[:alpha:]]y", "x\330y", 0) == 0); + #if !(defined __FreeBSD__ || defined __DragonFly__) + /* U+00B8 CEDILLA */ + ASSERT (fnmatch ("x[[:graph:]]y", "x\270y", 0) == 0); + #endif + /* U+00FF LATIN SMALL LETTER Y WITH DIAERESIS */ + ASSERT (fnmatch ("x[[:lower:]]y", "x\377y", 0) == 0); + #if !(defined __FreeBSD__ || defined __DragonFly__) + /* U+00B8 CEDILLA */ + ASSERT (fnmatch ("x[[:print:]]y", "x\270y", 0) == 0); + #endif + #if !(defined __FreeBSD__ || defined __DragonFly__) + /* U+00BF INVERTED QUESTION MARK */ + ASSERT (fnmatch ("x[[:punct:]]y", "x\277y", 0) == 0); + #endif + /* U+00C9 LATIN CAPITAL LETTER E WITH ACUTE */ + ASSERT (fnmatch ("x[[:upper:]]y", "x\311y", 0) == 0); + /* U+00D7 MULTIPLICATION SIGN */ + ASSERT (fnmatch ("x[[:alnum:]]y", "x\327y", 0) == FNM_NOMATCH); + /* U+00D7 MULTIPLICATION SIGN */ + ASSERT (fnmatch ("x[[:alpha:]]y", "x\327y", 0) == FNM_NOMATCH); + /* U+00D8 LATIN CAPITAL LETTER O WITH STROKE */ + ASSERT (fnmatch ("x[[:blank:]]y", "x\330y", 0) == FNM_NOMATCH); + /* U+00D8 LATIN CAPITAL LETTER O WITH STROKE */ + ASSERT (fnmatch ("x[[:cntrl:]]y", "x\330y", 0) == FNM_NOMATCH); + /* U+00D8 LATIN CAPITAL LETTER O WITH STROKE */ + ASSERT (fnmatch ("x[[:digit:]]y", "x\330y", 0) == FNM_NOMATCH); + /* U+00B2 SUPERSCRIPT TWO */ + ASSERT (fnmatch ("x[[:lower:]]y", "x\262y", 0) == FNM_NOMATCH); + /* U+00D8 LATIN CAPITAL LETTER O WITH STROKE */ + ASSERT (fnmatch ("x[[:punct:]]y", "x\330y", 0) == FNM_NOMATCH); + /* U+00D8 LATIN CAPITAL LETTER O WITH STROKE */ + ASSERT (fnmatch ("x[[:space:]]y", "x\330y", 0) == FNM_NOMATCH); + /* U+00B2 SUPERSCRIPT TWO */ + ASSERT (fnmatch ("x[[:upper:]]y", "x\262y", 0) == FNM_NOMATCH); + /* U+00D8 LATIN CAPITAL LETTER O WITH STROKE */ + ASSERT (fnmatch ("x[[:xdigit:]]y", "x\330y", 0) == FNM_NOMATCH); + + #if GNULIB_FNMATCH_GNU && defined FNM_CASEFOLD + /* "Höhle" */ + ASSERT (fnmatch ("H\366hle", "H\326hLe", FNM_CASEFOLD) == 0); + ASSERT (fnmatch ("H\326hLe", "H\366hle", FNM_CASEFOLD) == 0); + ASSERT (fnmatch ("H\326hle", "H\366hLe", FNM_CASEFOLD) == 0); + ASSERT (fnmatch ("H\366hLe", "H\326hle", FNM_CASEFOLD) == 0); + #endif + + return 0; + + case '3': + /* Locale encoding is UTF-8. */ + + ASSERT (fnmatch ("x?y", "x\303\274y", 0) == 0); /* "xüy" */ + ASSERT (fnmatch ("x?y", "x\303\237y", 0) == 0); /* "xßy" */ + ASSERT (fnmatch ("x?y", "x\360\237\230\213y", 0) == 0); /* "x😋y" */ + /* U+0141 LATIN CAPITAL LETTER L WITH STROKE */ + ASSERT (fnmatch ("x[[:alnum:]]y", "x\305\201y", 0) == 0); + #if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__ || defined __sun) + /* U+10330 GOTHIC LETTER AHSA */ + ASSERT (fnmatch ("x[[:alnum:]]y", "x\360\220\214\260y", 0) == 0); + #endif + /* U+0141 LATIN CAPITAL LETTER L WITH STROKE */ + ASSERT (fnmatch ("x[[:alpha:]]y", "x\305\201y", 0) == 0); + #if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__ || defined __sun) + /* U+10330 GOTHIC LETTER AHSA */ + ASSERT (fnmatch ("x[[:alpha:]]y", "x\360\220\214\260y", 0) == 0); + #endif + /* U+00B8 CEDILLA */ + ASSERT (fnmatch ("x[[:graph:]]y", "x\302\270y", 0) == 0); + #if !defined __sun + /* U+20000 */ + ASSERT (fnmatch ("x[[:graph:]]y", "x\360\240\200\200y", 0) == 0); + #endif + /* U+00FF LATIN SMALL LETTER Y WITH DIAERESIS */ + ASSERT (fnmatch ("x[[:lower:]]y", "x\303\277y", 0) == 0); + #if !(defined __FreeBSD__ || defined __DragonFly__ || defined __sun) + /* U+10441 DESERET SMALL LETTER EF */ + ASSERT (fnmatch ("x[[:lower:]]y", "x\360\220\221\201y", 0) == 0); + #endif + /* U+00B8 CEDILLA */ + ASSERT (fnmatch ("x[[:print:]]y", "x\302\270y", 0) == 0); + #if !defined __sun + /* U+20000 */ + ASSERT (fnmatch ("x[[:print:]]y", "x\360\240\200\200y", 0) == 0); + #endif + /* U+00BF INVERTED QUESTION MARK */ + ASSERT (fnmatch ("x[[:punct:]]y", "x\302\277y", 0) == 0); + #if !(defined __FreeBSD__ || defined __DragonFly__ || defined __sun) + /* U+1D100 MUSICAL SYMBOL SINGLE BARLINE */ + if (iswpunct (0x1D100)) + ASSERT (fnmatch ("x[[:punct:]]y", "x\360\235\204\200y", 0) == 0); + #endif + /* U+3000 IDEOGRAPHIC SPACE */ + ASSERT (fnmatch ("x[[:space:]]y", "x\343\200\200y", 0) == 0); + /* U+0429 CYRILLIC CAPITAL LETTER SHCHA */ + ASSERT (fnmatch ("x[[:upper:]]y", "x\320\251y", 0) == 0); + #if !(defined __FreeBSD__ || defined __DragonFly__ || defined __sun) + /* U+10419 DESERET CAPITAL LETTER EF */ + ASSERT (fnmatch ("x[[:upper:]]y", "x\360\220\220\231y", 0) == 0); + #endif + /* U+00D7 MULTIPLICATION SIGN */ + ASSERT (fnmatch ("x[[:alnum:]]y", "x\303\227y", 0) == FNM_NOMATCH); + /* U+00D7 MULTIPLICATION SIGN */ + ASSERT (fnmatch ("x[[:alpha:]]y", "x\303\227y", 0) == FNM_NOMATCH); + /* U+0141 LATIN CAPITAL LETTER L WITH STROKE */ + ASSERT (fnmatch ("x[[:blank:]]y", "x\305\201y", 0) == FNM_NOMATCH); + /* U+0141 LATIN CAPITAL LETTER L WITH STROKE */ + ASSERT (fnmatch ("x[[:cntrl:]]y", "x\305\201y", 0) == FNM_NOMATCH); + /* U+0141 LATIN CAPITAL LETTER L WITH STROKE */ + ASSERT (fnmatch ("x[[:digit:]]y", "x\305\201y", 0) == FNM_NOMATCH); + /* U+2002 EN SPACE */ + ASSERT (fnmatch ("x[[:graph:]]y", "x\342\200\202y", 0) == FNM_NOMATCH); + /* U+00B2 SUPERSCRIPT TWO */ + ASSERT (fnmatch ("x[[:lower:]]y", "x\302\262y", 0) == FNM_NOMATCH); + /* U+0141 LATIN CAPITAL LETTER L WITH STROKE */ + ASSERT (fnmatch ("x[[:punct:]]y", "x\305\201y", 0) == FNM_NOMATCH); + /* U+0141 LATIN CAPITAL LETTER L WITH STROKE */ + ASSERT (fnmatch ("x[[:space:]]y", "x\305\201y", 0) == FNM_NOMATCH); + /* U+00B2 SUPERSCRIPT TWO */ + ASSERT (fnmatch ("x[[:upper:]]y", "x\302\262y", 0) == FNM_NOMATCH); + /* U+0141 LATIN CAPITAL LETTER L WITH STROKE */ + ASSERT (fnmatch ("x[[:xdigit:]]y", "x\305\201y", 0) == FNM_NOMATCH); + + #if GNULIB_FNMATCH_GNU && defined FNM_CASEFOLD + /* "özgür" */ + { + /* Some platforms, e.g. MSVC 14, lack the upper/lower mappings for + these wide characters in the *.65001 locales. */ + mbstate_t state; + wchar_t wc; + memset (&state, 0, sizeof (mbstate_t)); + if (mbrtowc (&wc, "\303\274", 2, &state) == 2 + && towupper (wc) != wc) + { + ASSERT (fnmatch ("\303\266zg\303\274r", "\303\226ZG\303\234R", FNM_CASEFOLD) == 0); + ASSERT (fnmatch ("\303\226ZG\303\234R", "\303\266zg\303\274r", FNM_CASEFOLD) == 0); + ASSERT (fnmatch ("\303\266Zg\303\234r", "\303\226zG\303\274R", FNM_CASEFOLD) == 0); + ASSERT (fnmatch ("\303\226zG\303\274R", "\303\266Zg\303\234r", FNM_CASEFOLD) == 0); + } + } + #endif + + return 0; + + case '4': + /* Locale encoding is EUC-JP. */ + + ASSERT (fnmatch ("x?y", "x\306\374y", 0) == 0); /* "x日y" */ + ASSERT (fnmatch ("x?y", "x\313\334y", 0) == 0); /* "x本y" */ + ASSERT (fnmatch ("x?y", "x\270\354y", 0) == 0); /* "x語y" */ + #if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__) + /* U+0141 LATIN CAPITAL LETTER L WITH STROKE */ + ASSERT (fnmatch ("x[[:alnum:]]y", "x\217\251\250y", 0) == 0); + #endif + #if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__) + /* U+0141 LATIN CAPITAL LETTER L WITH STROKE */ + ASSERT (fnmatch ("x[[:alpha:]]y", "x\217\251\250y", 0) == 0); + #endif + #if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__) + /* U+00B8 CEDILLA */ + ASSERT (fnmatch ("x[[:graph:]]y", "x\217\242\261y", 0) == 0); + #endif + #if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__) + /* U+00FF LATIN SMALL LETTER Y WITH DIAERESIS */ + ASSERT (fnmatch ("x[[:lower:]]y", "x\217\253\363y", 0) == 0); + #endif + #if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__) + /* U+00B8 CEDILLA */ + ASSERT (fnmatch ("x[[:print:]]y", "x\217\242\261y", 0) == 0); + #endif + #if !(defined __FreeBSD__ || defined __DragonFly__) + /* U+00D7 MULTIPLICATION SIGN */ + ASSERT (fnmatch ("x[[:punct:]]y", "x\241\337y", 0) == 0); + #endif + #if !(defined __FreeBSD__ || defined __DragonFly__) + /* U+3000 IDEOGRAPHIC SPACE */ + ASSERT (fnmatch ("x[[:space:]]y", "x\241\241y", 0) == 0); + #endif + #if !(defined __FreeBSD__ || defined __DragonFly__) + /* U+0429 CYRILLIC CAPITAL LETTER SHCHA */ + ASSERT (fnmatch ("x[[:upper:]]y", "x\247\273y", 0) == 0); + #endif + /* U+3001 IDEOGRAPHIC COMMA */ + ASSERT (fnmatch ("x[[:alnum:]]y", "x\241\242y", 0) == FNM_NOMATCH); + /* U+3001 IDEOGRAPHIC COMMA */ + ASSERT (fnmatch ("x[[:alpha:]]y", "x\241\242y", 0) == FNM_NOMATCH); + /* U+3001 IDEOGRAPHIC COMMA */ + ASSERT (fnmatch ("x[[:blank:]]y", "x\241\242y", 0) == FNM_NOMATCH); + /* U+3001 IDEOGRAPHIC COMMA */ + ASSERT (fnmatch ("x[[:cntrl:]]y", "x\241\242y", 0) == FNM_NOMATCH); + /* U+3001 IDEOGRAPHIC COMMA */ + ASSERT (fnmatch ("x[[:digit:]]y", "x\241\242y", 0) == FNM_NOMATCH); + /* U+3000 IDEOGRAPHIC SPACE */ + ASSERT (fnmatch ("x[[:graph:]]y", "x\241\241y", 0) == FNM_NOMATCH); + /* U+3073 HIRAGANA LETTER BI */ + ASSERT (fnmatch ("x[[:lower:]]y", "x\244\323y", 0) == FNM_NOMATCH); + /* U+00DF LATIN SMALL LETTER SHARP S */ + ASSERT (fnmatch ("x[[:punct:]]y", "x\217\251\316y", 0) == FNM_NOMATCH); + /* U+3001 IDEOGRAPHIC COMMA */ + ASSERT (fnmatch ("x[[:space:]]y", "x\241\242y", 0) == FNM_NOMATCH); + /* U+3073 HIRAGANA LETTER BI */ + ASSERT (fnmatch ("x[[:upper:]]y", "x\244\323y", 0) == FNM_NOMATCH); + /* U+3001 IDEOGRAPHIC COMMA */ + ASSERT (fnmatch ("x[[:xdigit:]]y", "x\241\242y", 0) == FNM_NOMATCH); + + #if GNULIB_FNMATCH_GNU && defined FNM_CASEFOLD + /* "özgür" */ + { + /* Some platforms, e.g. macOS 12.5 and NetBSD 9.3, lack the + upper/lower mappings for these wide characters in the ja_JP.eucJP + locale. */ + mbstate_t state; + wchar_t wc; + memset (&state, 0, sizeof (mbstate_t)); + if (mbrtowc (&wc, "\217\253\344", 3, &state) == 3 + && towupper (wc) != wc) + { + ASSERT (fnmatch ("\217\253\323zg\217\253\344r", "\217\252\323ZG\217\252\344R", FNM_CASEFOLD) == 0); + ASSERT (fnmatch ("\217\252\323ZG\217\252\344R", "\217\253\323zg\217\253\344r", FNM_CASEFOLD) == 0); + ASSERT (fnmatch ("\217\253\323Zg\217\252\344r", "\217\252\323zG\217\253\344R", FNM_CASEFOLD) == 0); + ASSERT (fnmatch ("\217\252\323zG\217\253\344R", "\217\253\323Zg\217\252\344r", FNM_CASEFOLD) == 0); + } + } + #endif + + return 0; + + case '5': + /* Locale encoding is GB18030. */ + #if (defined __GLIBC__ && __GLIBC__ == 2 && __GLIBC_MINOR__ >= 13 && __GLIBC_MINOR__ <= 15) + fputs ("Skipping test: The GB18030 converter in this system's iconv is broken.\n", stderr); + return 77; + #endif + + ASSERT (fnmatch ("x?y", "x\250\271y", 0) == 0); /* "xüy" */ + ASSERT (fnmatch ("x?y", "x\201\060\211\070y", 0) == 0); /* "xßy" */ + ASSERT (fnmatch ("x?y", "x\224\071\375\067y", 0) == 0); /* "x😋y" */ + #if !(defined __FreeBSD__ || defined __DragonFly__ || defined __sun) + /* U+0141 LATIN CAPITAL LETTER L WITH STROKE */ + ASSERT (fnmatch ("x[[:alnum:]]y", "x\201\060\221\071y", 0) == 0); + #endif + #if !(defined __FreeBSD__ || defined __DragonFly__ || defined __sun) + /* U+0141 LATIN CAPITAL LETTER L WITH STROKE */ + ASSERT (fnmatch ("x[[:alpha:]]y", "x\201\060\221\071y", 0) == 0); + #endif + #if !(defined __FreeBSD__ || defined __DragonFly__ || defined __sun) + /* U+00B8 CEDILLA */ + ASSERT (fnmatch ("x[[:graph:]]y", "x\201\060\206\060y", 0) == 0); + #endif + #if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__ || defined __sun) + /* U+20000 */ + ASSERT (fnmatch ("x[[:graph:]]y", "x\225\062\202\066y", 0) == 0); + #endif + #if !(defined __FreeBSD__ || defined __DragonFly__ || defined __sun) + /* U+00FF LATIN SMALL LETTER Y WITH DIAERESIS */ + ASSERT (fnmatch ("x[[:lower:]]y", "x\201\060\213\067y", 0) == 0); + #endif + #if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__ || defined __sun) + /* U+10441 DESERET SMALL LETTER EF */ + ASSERT (fnmatch ("x[[:lower:]]y", "x\220\060\355\071y", 0) == 0); + #endif + #if !(defined __FreeBSD__ || defined __DragonFly__ || defined __sun) + /* U+00B8 CEDILLA */ + ASSERT (fnmatch ("x[[:print:]]y", "x\201\060\206\060y", 0) == 0); + #endif + #if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__ || defined __sun) + /* U+20000 */ + ASSERT (fnmatch ("x[[:print:]]y", "x\225\062\202\066y", 0) == 0); + #endif + #if !(defined __FreeBSD__ || defined __DragonFly__) + /* U+00D7 MULTIPLICATION SIGN */ + ASSERT (fnmatch ("x[[:punct:]]y", "x\241\301y", 0) == 0); + #endif + #if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__ || defined __sun) + /* U+1D100 MUSICAL SYMBOL SINGLE BARLINE */ + ASSERT (fnmatch ("x[[:punct:]]y", "x\224\062\273\064y", 0) == 0); + #endif + #if !(defined __FreeBSD__ || defined __DragonFly__) + /* U+3000 IDEOGRAPHIC SPACE */ + ASSERT (fnmatch ("x[[:space:]]y", "x\241\241y", 0) == 0); + #endif + #if !(defined __FreeBSD__ || defined __DragonFly__) + /* U+0429 CYRILLIC CAPITAL LETTER SHCHA */ + ASSERT (fnmatch ("x[[:upper:]]y", "x\247\273y", 0) == 0); + #endif + #if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__ || defined __sun) + /* U+10419 DESERET CAPITAL LETTER EF */ + ASSERT (fnmatch ("x[[:upper:]]y", "x\220\060\351\071y", 0) == 0); + #endif + /* U+3001 IDEOGRAPHIC COMMA */ + ASSERT (fnmatch ("x[[:alnum:]]y", "x\241\242y", 0) == FNM_NOMATCH); + /* U+3001 IDEOGRAPHIC COMMA */ + ASSERT (fnmatch ("x[[:alpha:]]y", "x\241\242y", 0) == FNM_NOMATCH); + /* U+3001 IDEOGRAPHIC COMMA */ + ASSERT (fnmatch ("x[[:blank:]]y", "x\241\242y", 0) == FNM_NOMATCH); + /* U+3001 IDEOGRAPHIC COMMA */ + ASSERT (fnmatch ("x[[:cntrl:]]y", "x\241\242y", 0) == FNM_NOMATCH); + /* U+3001 IDEOGRAPHIC COMMA */ + ASSERT (fnmatch ("x[[:digit:]]y", "x\241\242y", 0) == FNM_NOMATCH); + /* U+3000 IDEOGRAPHIC SPACE */ + ASSERT (fnmatch ("x[[:graph:]]y", "x\241\241y", 0) == FNM_NOMATCH); + /* U+3001 IDEOGRAPHIC COMMA */ + ASSERT (fnmatch ("x[[:lower:]]y", "x\241\242y", 0) == FNM_NOMATCH); + /* U+00D8 LATIN CAPITAL LETTER O WITH STROKE */ + ASSERT (fnmatch ("x[[:punct:]]y", "x\201\060\211\061y", 0) == FNM_NOMATCH); + /* U+3001 IDEOGRAPHIC COMMA */ + ASSERT (fnmatch ("x[[:space:]]y", "x\241\242y", 0) == FNM_NOMATCH); + /* U+3001 IDEOGRAPHIC COMMA */ + ASSERT (fnmatch ("x[[:upper:]]y", "x\241\242y", 0) == FNM_NOMATCH); + /* U+3001 IDEOGRAPHIC COMMA */ + ASSERT (fnmatch ("x[[:xdigit:]]y", "x\241\242y", 0) == FNM_NOMATCH); + + #if GNULIB_FNMATCH_GNU && defined FNM_CASEFOLD + /* "özgür" */ + { + /* Some platforms, e.g. FreeBSD 13.2 and Solaris 11.4, lack the + upper/lower mappings for these wide characters in the zh_CN.GB18030 + locale. */ + mbstate_t state; + wchar_t wc; + memset (&state, 0, sizeof (mbstate_t)); + if (mbrtowc (&wc, "\201\060\213\062", 4, &state) == 4 + && towupper (wc) != wc) + { + ASSERT (fnmatch ("\201\060\213\062zg\250\271r", "\201\060\211\060ZG\201\060\211\065R", FNM_CASEFOLD) == 0); + ASSERT (fnmatch ("\201\060\211\060ZG\201\060\211\065R", "\201\060\213\062zg\250\271r", FNM_CASEFOLD) == 0); + ASSERT (fnmatch ("\201\060\213\062Zg\201\060\211\065r", "\201\060\211\060zG\250\271R", FNM_CASEFOLD) == 0); + ASSERT (fnmatch ("\201\060\211\060zG\250\271R", "\201\060\213\062Zg\201\060\211\065r", FNM_CASEFOLD) == 0); + } + } + #endif + + return 0; + } + + return 1; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fopen-gnu.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fopen-gnu.c new file mode 100644 index 00000000..b721d25f --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fopen-gnu.c @@ -0,0 +1,88 @@ +/* Test of opening a file stream. + Copyright (C) 2020-2024 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 . */ + +/* Written by Bruno Haible , 2020. */ + +#include + +/* Specification. */ +#include + +#include +#include +#include + +#include "macros.h" + +#define BASE "test-fopen-gnu.t" + +/* 0x1a is an EOF on Windows. */ +#define DATA "abc\x1axyz" + +int +main (void) +{ + FILE *f; + int fd; + int flags; + char buf[16]; + + /* Remove anything from prior partial run. */ + unlink (BASE "file"); + unlink (BASE "binary"); + + /* Create the file. */ + f = fopen (BASE "file", "w"); + ASSERT (f); + fd = fileno (f); + ASSERT (fd >= 0); + flags = fcntl (fd, F_GETFD); + ASSERT (flags >= 0); + ASSERT ((flags & FD_CLOEXEC) == 0); + ASSERT (fclose (f) == 0); + + /* Create the file and check the 'e' mode. */ + f = fopen (BASE "file", "we"); + ASSERT (f); + fd = fileno (f); + ASSERT (fd >= 0); + flags = fcntl (fd, F_GETFD); + ASSERT (flags >= 0); + ASSERT ((flags & FD_CLOEXEC) != 0); + ASSERT (fclose (f) == 0); + + /* Open the file and check the 'x' mode. */ + f = fopen (BASE "file", "ax"); + ASSERT (f == NULL); + ASSERT (errno == EEXIST); + + /* Open a binary file and check that the 'e' mode doesn't interfere. */ + f = fopen (BASE "binary", "wbe"); + ASSERT (f); + ASSERT (fwrite (DATA, 1, sizeof (DATA)-1, f) == sizeof (DATA)-1); + ASSERT (fclose (f) == 0); + + f = fopen (BASE "binary", "rbe"); + ASSERT (f); + ASSERT (fread (buf, 1, sizeof (buf), f) == sizeof (DATA)-1); + ASSERT (fclose (f) == 0); + + /* Cleanup. */ + ASSERT (unlink (BASE "file") == 0); + ASSERT (unlink (BASE "binary") == 0); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fopen.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fopen.c new file mode 100644 index 00000000..e687de1a --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fopen.c @@ -0,0 +1,34 @@ +/* Test of opening a file stream. + Copyright (C) 2007-2024 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 . */ + +/* Written by Bruno Haible , 2007. */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (fopen, FILE *, (char const *, char const *)); + +#define BASE "test-fopen.t" + +#include "test-fopen.h" + +int +main (void) +{ + return test_fopen (); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fopen.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fopen.h new file mode 100644 index 00000000..52673622 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fopen.h @@ -0,0 +1,94 @@ +/* Test of opening a file stream. + Copyright (C) 2007-2024 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 . */ + +/* Written by Bruno Haible , 2007. */ + +/* Include and a form of first. */ + +#include +#include + +#include "macros.h" + +/* Tell GCC not to warn about the specific edge cases tested here. */ +#if __GNUC__ >= 10 +# pragma GCC diagnostic ignored "-Wanalyzer-file-leak" +#endif + +/* Test fopen. Assumes BASE is defined. */ + +static int +test_fopen (void) +{ + FILE *f; + /* Remove anything from prior partial run. */ + unlink (BASE "file"); + + /* Read requires existing file. */ + errno = 0; + ASSERT (fopen (BASE "file", "r") == NULL); + ASSERT (errno == ENOENT); + + /* Write can create a file. */ + f = fopen (BASE "file", "w"); + ASSERT (f); + ASSERT (fclose (f) == 0); + + /* Trailing slash is invalid on non-directory. */ + errno = 0; + ASSERT (fopen (BASE "file/", "r") == NULL); + ASSERT (errno == ENOTDIR || errno == EISDIR || errno == EINVAL); + + errno = 0; + ASSERT (fopen (BASE "file/", "r+") == NULL); + ASSERT (errno == ENOTDIR || errno == EISDIR || errno == EINVAL); + + /* Cannot create a directory. */ + errno = 0; + ASSERT (fopen ("nonexist.ent/", "w") == NULL); + ASSERT (errno == ENOTDIR || errno == EISDIR || errno == ENOENT + || errno == EINVAL); + + /* Directories cannot be opened for writing. */ + errno = 0; + ASSERT (fopen (".", "w") == NULL); + ASSERT (errno == EISDIR || errno == EINVAL || errno == EACCES); + + errno = 0; + ASSERT (fopen ("./", "w") == NULL); + ASSERT (errno == EISDIR || errno == EINVAL || errno == EACCES); + + errno = 0; + ASSERT (fopen (".", "r+") == NULL); + ASSERT (errno == EISDIR || errno == EINVAL || errno == EACCES); + + errno = 0; + ASSERT (fopen ("./", "r+") == NULL); + ASSERT (errno == EISDIR || errno == EINVAL || errno == EACCES); + + /* /dev/null must exist, and be writable. */ + f = fopen ("/dev/null", "r"); + ASSERT (f); + ASSERT (fclose (f) == 0); + f = fopen ("/dev/null", "w"); + ASSERT (f); + ASSERT (fclose (f) == 0); + + /* Cleanup. */ + ASSERT (unlink (BASE "file") == 0); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fputc.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fputc.c new file mode 100644 index 00000000..0d48a92f --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fputc.c @@ -0,0 +1,95 @@ +/* Test of fputc() function. + Copyright (C) 2011-2024 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 . */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (fputc, int, (int, FILE *)); + +#include +#include +#include + +#if HAVE_MSVC_INVALID_PARAMETER_HANDLER +# include "msvc-inval.h" +#endif + +#include "macros.h" + +int +main () +{ + const char *filename = "test-fputc.txt"; + + /* We don't have an fputc() function that installs an invalid parameter + handler so far. So install that handler here, explicitly. */ +#if HAVE_MSVC_INVALID_PARAMETER_HANDLER \ + && MSVC_INVALID_PARAMETER_HANDLING == DEFAULT_HANDLING + gl_msvc_inval_ensure_handler (); +#endif + + /* Test that fputc() on an unbuffered stream sets errno if someone else + closes the stream fd behind the back of stdio. */ + #if !defined __ANDROID__ /* fdsan */ + { + FILE *fp = fopen (filename, "w"); + ASSERT (fp != NULL); + setvbuf (fp, NULL, _IONBF, 0); + ASSERT (close (fileno (fp)) == 0); + errno = 0; + ASSERT (fputc ('x', fp) == EOF); + ASSERT (errno == EBADF); + ASSERT (ferror (fp)); + fclose (fp); + } + #endif + + /* Test that fputc() on an unbuffered stream sets errno if the stream + was constructed with an invalid file descriptor. */ + { + FILE *fp = fdopen (-1, "w"); + if (fp != NULL) + { + setvbuf (fp, NULL, _IONBF, 0); + errno = 0; + ASSERT (fputc ('x', fp) == EOF); + ASSERT (errno == EBADF); + ASSERT (ferror (fp)); + fclose (fp); + } + } + { + FILE *fp; + close (99); + fp = fdopen (99, "w"); + if (fp != NULL) + { + setvbuf (fp, NULL, _IONBF, 0); + errno = 0; + ASSERT (fputc ('x', fp) == EOF); + ASSERT (errno == EBADF); + ASSERT (ferror (fp)); + fclose (fp); + } + } + + /* Clean up. */ + unlink (filename); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fread.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fread.c new file mode 100644 index 00000000..ac6bdecf --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fread.c @@ -0,0 +1,104 @@ +/* Test of fread() function. + Copyright (C) 2011-2024 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 . */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (fread, size_t, (void *, size_t, size_t, FILE *)); + +#include +#include +#include + +#if HAVE_MSVC_INVALID_PARAMETER_HANDLER +# include "msvc-inval.h" +#endif + +#include "macros.h" + +int +main () +{ + const char *filename = "test-fread.txt"; + + /* We don't have an fread() function that installs an invalid parameter + handler so far. So install that handler here, explicitly. */ +#if HAVE_MSVC_INVALID_PARAMETER_HANDLER \ + && MSVC_INVALID_PARAMETER_HANDLING == DEFAULT_HANDLING + gl_msvc_inval_ensure_handler (); +#endif + + /* Prepare a file. */ + { + const char text[] = "hello world"; + int fd = open (filename, O_RDWR | O_CREAT | O_TRUNC, 0600); + ASSERT (fd >= 0); + ASSERT (write (fd, text, sizeof (text)) == sizeof (text)); + ASSERT (close (fd) == 0); + } + + /* Test that fread() sets errno if someone else closes the stream + fd behind the back of stdio. */ + #if !defined __ANDROID__ /* fdsan */ + { + FILE *fp = fopen (filename, "r"); + char buf[5]; + ASSERT (fp != NULL); + ASSERT (close (fileno (fp)) == 0); + errno = 0; + ASSERT (fread (buf, 1, sizeof (buf), fp) == 0); + ASSERT (errno == EBADF); + ASSERT (ferror (fp)); + fclose (fp); + } + #endif + + /* Test that fread() sets errno if the stream was constructed with + an invalid file descriptor. */ + { + FILE *fp = fdopen (-1, "r"); + if (fp != NULL) + { + char buf[1]; + errno = 0; + ASSERT (fread (buf, 1, 1, fp) == 0); + ASSERT (errno == EBADF); + ASSERT (ferror (fp)); + fclose (fp); + } + } + { + FILE *fp; + close (99); + fp = fdopen (99, "r"); + if (fp != NULL) + { + char buf[1]; + errno = 0; + ASSERT (fread (buf, 1, 1, fp) == 0); + ASSERT (errno == EBADF); + ASSERT (ferror (fp)); + fclose (fp); + } + } + + /* Clean up. */ + unlink (filename); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-free.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-free.c new file mode 100644 index 00000000..703c550e --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-free.c @@ -0,0 +1,175 @@ +/* Test of free() function. + Copyright (C) 2020-2024 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 . */ + +/* Written by Bruno Haible , 2020. */ + +#include + +/* Specification. */ +#include + +#include +#include +#include +#if defined __linux__ +# include +# include +# include +# include +#endif + +#include "macros.h" + +/* The indirection through a volatile function pointer is necessary to prevent + a GCC optimization. Without it, when optimizing, GCC would "know" that errno + is unchanged by calling free(ptr), when ptr was the result of a malloc(...) + call in the same function. */ +static int +get_errno (void) +{ + volatile int err = errno; + return err; +} + +static int (* volatile get_errno_func) (void) = get_errno; + +int +main () +{ + /* Check that free() preserves errno. */ + { + errno = 1789; /* Liberté, égalité, fraternité. */ + free (NULL); + ASSERT_NO_STDIO (get_errno_func () == 1789); + } + { /* Small memory allocations. */ + #define N 10000 + void * volatile ptrs[N]; + size_t i; + for (i = 0; i < N; i++) + ptrs[i] = malloc (15); + for (i = 0; i < N; i++) + { + errno = 1789; + free (ptrs[i]); + ASSERT_NO_STDIO (get_errno_func () == 1789); + } + #undef N + } + { /* Medium memory allocations. */ + #define N 1000 + void * volatile ptrs[N]; + size_t i; + for (i = 0; i < N; i++) + ptrs[i] = malloc (729); + for (i = 0; i < N; i++) + { + errno = 1789; + free (ptrs[i]); + ASSERT_NO_STDIO (get_errno_func () == 1789); + } + #undef N + } + { /* Large memory allocations. */ + #define N 10 + void * volatile ptrs[N]; + size_t i; + for (i = 0; i < N; i++) + ptrs[i] = malloc (5318153); + for (i = 0; i < N; i++) + { + errno = 1789; + free (ptrs[i]); + ASSERT_NO_STDIO (get_errno_func () == 1789); + } + #undef N + } + + /* Test a less common code path. + When malloc() is based on mmap(), free() can sometimes call munmap(). + munmap() usually succeeds, but fails in a particular situation: when + - it has to unmap the middle part of a VMA, and + - the number of VMAs of a process is limited and the limit is + already reached. + The latter condition is fulfilled on Linux, when the file + /proc/sys/vm/max_map_count exists. This file contains the limit + - for Linux >= 2.4.19: 65536 (DEFAULT_MAX_MAP_COUNT in linux/include/linux/sched.h) + - for Linux >= 2.6.31: 65530 (DEFAULT_MAX_MAP_COUNT in linux/include/linux/mm.h). + But do not test it with glibc < 2.15, since that triggers a glibc internal + abort: "malloc.c:3551: munmap_chunk: Assertion `ret == 0' failed." + */ + #if defined __linux__ && !(__GLIBC__ == 2 && __GLIBC_MINOR__ < 15) + if (open ("/proc/sys/vm/max_map_count", O_RDONLY) >= 0) + { + /* Preparations. */ + size_t pagesize = getpagesize (); + void *firstpage_backup = malloc (pagesize); + void *lastpage_backup = malloc (pagesize); + /* Allocate a large memory area, as a bumper, so that the MAP_FIXED + allocation later will not overwrite parts of the memory areas + allocated to ld.so or libc.so. */ + void *bumper_region = + mmap (NULL, 0x1000000, PROT_READ, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); + /* A file descriptor pointing to a regular file. */ + int fd = open ("test-free", O_RDONLY); + + if (firstpage_backup != NULL && lastpage_backup != NULL + && bumper_region != (void *)(-1) + && fd >= 0) + { + /* Do a large memory allocation. */ + size_t big_size = 0x1000000; + void * volatile ptr = malloc (big_size - 0x100); + char *ptr_aligned = (char *) ((uintptr_t) ptr & ~(pagesize - 1)); + /* This large memory allocation allocated a memory area + from ptr_aligned to ptr_aligned + big_size. + Enlarge this memory area by adding a page before and a page + after it. */ + memcpy (firstpage_backup, ptr_aligned, pagesize); + memcpy (lastpage_backup, ptr_aligned + big_size - pagesize, pagesize); + if (mmap (ptr_aligned - pagesize, pagesize + big_size + pagesize, + PROT_READ | PROT_WRITE, + MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0) + != (void *)(-1)) + { + memcpy (ptr_aligned, firstpage_backup, pagesize); + memcpy (ptr_aligned + big_size - pagesize, lastpage_backup, pagesize); + + /* Now add as many mappings as we can. + Stop at 65536, in order not to crash the machine (in case the + limit has been increased by the system administrator). */ + size_t i; + for (i = 0; i < 65536; i++) + if (mmap (NULL, pagesize, PROT_READ, MAP_FILE | MAP_PRIVATE, fd, 0) + == (void *)(-1)) + break; + /* Now the number of VMAs of this process has hopefully attained + its limit. */ + + errno = 1789; + /* This call to free() is supposed to call + munmap (ptr_aligned, big_size); + which increases the number of VMAs by 1, which is supposed + to fail. */ + free (ptr); + ASSERT_NO_STDIO (get_errno_func () == 1789); + } + } + } + #endif + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-freopen.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-freopen.c new file mode 100644 index 00000000..54aa2f79 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-freopen.c @@ -0,0 +1,86 @@ +/* Test of opening a file stream. + Copyright (C) 2007-2024 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 . */ + +/* Written by Bruno Haible , 2007. */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (freopen, FILE *, (char const *, char const *, FILE *)); + +#include +#include + +#include "macros.h" + +int +main () +{ + const char *filename = "test-freopen.txt"; + + close (STDIN_FILENO); + ASSERT (freopen ("/dev/null", "r", stdin) != NULL); + ASSERT (getchar () == EOF); + ASSERT (!ferror (stdin)); + ASSERT (feof (stdin)); + +#if 0 /* freopen (NULL, ...) is unsupported on most platforms. */ + /* Test that freopen() sets errno if someone else closes the stream + fd behind the back of stdio. */ + { + FILE *fp = fopen (filename, "w+"); + ASSERT (fp != NULL); + ASSERT (close (fileno (fp)) == 0); + errno = 0; + ASSERT (freopen (NULL, "r", fp) == NULL); + perror("freopen"); + ASSERT (errno == EBADF); + fclose (fp); + } + + /* Test that freopen() sets errno if the stream was constructed with + an invalid file descriptor. */ + { + FILE *fp = fdopen (-1, "w+"); + if (fp != NULL) + { + errno = 0; + ASSERT (freopen (NULL, "r", fp) == NULL); + ASSERT (errno == EBADF); + fclose (fp); + } + } + { + FILE *fp; + close (99); + fp = fdopen (99, "w+"); + if (fp != NULL) + { + errno = 0; + ASSERT (freopen (NULL, "r", fp) == NULL); + ASSERT (errno == EBADF); + fclose (fp); + } + } +#endif + + /* Clean up. */ + unlink (filename); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fstat.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fstat.c new file mode 100644 index 00000000..7a361b86 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fstat.c @@ -0,0 +1,50 @@ +/* Tests of fstat() function. + Copyright (C) 2011-2024 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 . */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (fstat, int, (int, struct stat *)); + +#include +#include + +#include "macros.h" + +int +main () +{ + /* Test behaviour for invalid file descriptors. */ + { + struct stat statbuf; + + errno = 0; + ASSERT (fstat (-1, &statbuf) == -1); + ASSERT (errno == EBADF); + } + { + struct stat statbuf; + + close (99); + errno = 0; + ASSERT (fstat (99, &statbuf) == -1); + ASSERT (errno == EBADF); + } + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fstatat.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fstatat.c new file mode 100644 index 00000000..3b5dd435 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fstatat.c @@ -0,0 +1,107 @@ +/* Tests of fstatat. + Copyright (C) 2009-2024 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 . */ + +/* Written by Eric Blake , 2009. */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (fstatat, int, (int, char const *, struct stat *, int)); + +#include +#include +#include +#include +#include + +#include "openat.h" +#include "same-inode.h" +#include "ignore-value.h" +#include "macros.h" + +#ifndef BASE +# define BASE "test-fstatat.t" +#endif + +#include "test-lstat.h" +#include "test-stat.h" + +static int dfd = AT_FDCWD; + +/* Wrapper around fstatat to test stat behavior. */ +static int +do_stat (char const *name, struct stat *st) +{ +#ifdef TEST_STATAT + return statat (dfd, name, st); +#else + return fstatat (dfd, name, st, 0); +#endif +} + +/* Wrapper around fstatat to test lstat behavior. */ +static int +do_lstat (char const *name, struct stat *st) +{ +#ifdef TEST_STATAT + return lstatat (dfd, name, st); +#else + return fstatat (dfd, name, st, AT_SYMLINK_NOFOLLOW); +#endif +} + +int +main (_GL_UNUSED int argc, _GL_UNUSED char *argv[]) +{ + int result; + + /* Remove any leftovers from a previous partial run. */ + ignore_value (system ("rm -rf " BASE "*")); + + /* Test behaviour for invalid file descriptors. */ + { + struct stat statbuf; + + errno = 0; + ASSERT (fstatat (-1, "foo", &statbuf, 0) == -1); + ASSERT (errno == EBADF); + } + { + struct stat statbuf; + + close (99); + errno = 0; + ASSERT (fstatat (99, "foo", &statbuf, 0) == -1); + ASSERT (errno == EBADF); + } + + result = test_stat_func (do_stat, false); + ASSERT (test_lstat_func (do_lstat, false) == result); + dfd = open (".", O_RDONLY); + ASSERT (0 <= dfd); + ASSERT (test_stat_func (do_stat, false) == result); + ASSERT (test_lstat_func (do_lstat, false) == result); + ASSERT (close (dfd) == 0); + + /* FIXME - add additional tests of dfd not at current directory. */ + + if (result == 77) + fputs ("skipping test: symlinks not supported on this file system\n", + stderr); + return result; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-ftruncate.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-ftruncate.c new file mode 100644 index 00000000..e9daf1bd --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-ftruncate.c @@ -0,0 +1,60 @@ +/* Test truncating a file. + Copyright (C) 2011-2024 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 . */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (ftruncate, int, (int, off_t)); + +#include +#include + +#include "macros.h" + +int +main (_GL_UNUSED int argc, char *argv[]) +{ + const char *filename = argv[1]; + + /* Test behaviour for invalid file descriptors. */ + { + errno = 0; + ASSERT (ftruncate (-1, 0) == -1); + ASSERT (errno == EBADF); + } + { + close (99); + errno = 0; + ASSERT (ftruncate (99, 0) == -1); + ASSERT (errno == EBADF); + } + + /* Test behaviour for read-only file descriptors. */ + { + int fd = open (filename, O_RDONLY); + ASSERT (fd >= 0); + errno = 0; + ASSERT (ftruncate (fd, 0) == -1); + ASSERT (errno == EBADF || errno == EINVAL + || errno == EACCES /* seen on mingw */ + ); + close (fd); + } + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-ftruncate.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-ftruncate.sh new file mode 100755 index 00000000..203e07b6 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-ftruncate.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +exec ${CHECKER} ./test-ftruncate${EXEEXT} "$srcdir/test-ftruncate.sh" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fwrite.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fwrite.c new file mode 100644 index 00000000..f00f35ca --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-fwrite.c @@ -0,0 +1,98 @@ +/* Test of fwrite() function. + Copyright (C) 2011-2024 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 . */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (fwrite, size_t, (const void *, size_t, size_t, FILE *)); + +#include +#include +#include + +#if HAVE_MSVC_INVALID_PARAMETER_HANDLER +# include "msvc-inval.h" +#endif + +#include "macros.h" + +int +main () +{ + const char *filename = "test-fwrite.txt"; + + /* We don't have an fwrite() function that installs an invalid parameter + handler so far. So install that handler here, explicitly. */ +#if HAVE_MSVC_INVALID_PARAMETER_HANDLER \ + && MSVC_INVALID_PARAMETER_HANDLING == DEFAULT_HANDLING + gl_msvc_inval_ensure_handler (); +#endif + + /* Test that fwrite() on an unbuffered stream sets errno if someone else + closes the stream fd behind the back of stdio. */ + #if !defined __ANDROID__ /* fdsan */ + { + FILE *fp = fopen (filename, "w"); + char buf[5] = "world"; + ASSERT (fp != NULL); + setvbuf (fp, NULL, _IONBF, 0); + ASSERT (close (fileno (fp)) == 0); + errno = 0; + ASSERT (fwrite (buf, 1, sizeof (buf), fp) == 0); + ASSERT (errno == EBADF); + ASSERT (ferror (fp)); + fclose (fp); + } + #endif + + /* Test that fwrite() on an unbuffered stream sets errno if the stream + was constructed with an invalid file descriptor. */ + { + FILE *fp = fdopen (-1, "w"); + if (fp != NULL) + { + char buf[5] = "world"; + setvbuf (fp, NULL, _IONBF, 0); + errno = 0; + ASSERT (fwrite (buf, 1, sizeof (buf), fp) == 0); + ASSERT (errno == EBADF); + ASSERT (ferror (fp)); + fclose (fp); + } + } + { + FILE *fp; + close (99); + fp = fdopen (99, "w"); + if (fp != NULL) + { + char buf[5] = "world"; + setvbuf (fp, NULL, _IONBF, 0); + errno = 0; + ASSERT (fwrite (buf, 1, sizeof (buf), fp) == 0); + ASSERT (errno == EBADF); + ASSERT (ferror (fp)); + fclose (fp); + } + } + + /* Clean up. */ + unlink (filename); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-getcwd-lgpl.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-getcwd-lgpl.c new file mode 100644 index 00000000..1e7238a0 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-getcwd-lgpl.c @@ -0,0 +1,102 @@ +/* Test of getcwd() function. + Copyright (C) 2009-2024 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 . */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (getcwd, char *, (char *, size_t)); + +#include +#include +#include +#include + +#include "macros.h" + +int +main (int argc, char **argv) +{ + char *pwd1; + char *pwd2; + /* If the user provides an argument, attempt to chdir there first. */ + if (1 < argc) + { + if (chdir (argv[1]) == 0) + printf ("changed to directory %s\n", argv[1]); + } + + pwd1 = getcwd (NULL, 0); + ASSERT (pwd1 && *pwd1); + if (1 < argc) + printf ("cwd=%s\n", pwd1); + + /* Make sure the result is usable. */ + ASSERT (chdir (pwd1) == 0); + ASSERT (chdir (".//./.") == 0); + + /* Make sure that result is normalized. */ + pwd2 = getcwd (NULL, 0); + ASSERT (pwd2); + ASSERT (strcmp (pwd1, pwd2) == 0); + free (pwd2); + { + size_t len = strlen (pwd1); + ssize_t i = len - 10; + if (i < 1) + i = 1; + pwd2 = getcwd (NULL, len + 1); + ASSERT (pwd2); + free (pwd2); + pwd2 = malloc (len + 2); + for ( ; i <= len; i++) + { + char *tmp; + errno = 0; + ASSERT (getcwd (pwd2, i) == NULL); + ASSERT (errno == ERANGE); + /* Allow either glibc or BSD behavior, since POSIX allows both. */ + errno = 0; + tmp = getcwd (NULL, i); + if (tmp) + { + ASSERT (strcmp (pwd1, tmp) == 0); + free (tmp); + } + else + { + ASSERT (errno == ERANGE); + } + } + ASSERT (getcwd (pwd2, len + 1) == pwd2); + pwd2[len] = '/'; + pwd2[len + 1] = '\0'; + } + ASSERT (strstr (pwd2, "/./") == NULL); + ASSERT (strstr (pwd2, "/../") == NULL); + ASSERT (strstr (pwd2 + 1 + (pwd2[1] == '/'), "//") == NULL); + + /* Validate a POSIX requirement on size. */ + errno = 0; + ASSERT (getcwd (pwd2, 0) == NULL); + ASSERT (errno == EINVAL); + + free (pwd1); + free (pwd2); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-getdtablesize.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-getdtablesize.c new file mode 100644 index 00000000..401fe901 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-getdtablesize.c @@ -0,0 +1,41 @@ +/* Test of getdtablesize() function. + Copyright (C) 2008-2024 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 . */ + +/* Written by Bruno Haible , 2008. */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (getdtablesize, int, (void)); + +#include "macros.h" + +/* Tell GCC not to warn about the specific edge cases tested here. */ +#if __GNUC__ >= 13 +# pragma GCC diagnostic ignored "-Wanalyzer-fd-leak" +#endif + +int +main () +{ + ASSERT (getdtablesize () >= 3); + ASSERT (dup2 (0, getdtablesize() - 1) == getdtablesize () - 1); + ASSERT (dup2 (0, getdtablesize()) == -1); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-getopt-gnu.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-getopt-gnu.c new file mode 100644 index 00000000..617f3180 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-getopt-gnu.c @@ -0,0 +1,45 @@ +/* Test of command line argument processing. + Copyright (C) 2009-2024 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 . */ + +/* Written by Bruno Haible , 2009. */ + +#include + +/* None of the files accessed by this test are large, so disable the + ftell link warning if we are not using the gnulib ftell module. */ +#define _GL_NO_LARGE_FILES + +/* POSIX and glibc provide the getopt() function in , see + https://pubs.opengroup.org/onlinepubs/9699919799/functions/getopt.html + https://www.gnu.org/software/libc/manual/html_node/Using-Getopt.html + But gnulib provides the getopt() function in , not in . + This is what we are testing here. */ +#include + +#ifndef __getopt_argv_const +# define __getopt_argv_const const +#endif +#include "signature.h" +SIGNATURE_CHECK (getopt_long, int, (int, char *__getopt_argv_const *, + char const *, struct option const *, + int *)); +SIGNATURE_CHECK (getopt_long_only, int, (int, char *__getopt_argv_const *, + char const *, struct option const *, + int *)); + +#define TEST_GETOPT_GNU 1 +#define TEST_GETOPT_TMP_NAME "test-getopt-gnu.tmp" +#include "test-getopt-main.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-getopt-main.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-getopt-main.h new file mode 100644 index 00000000..82ad65df --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-getopt-main.h @@ -0,0 +1,76 @@ +/* Test of command line argument processing. + Copyright (C) 2009-2024 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 . */ + +/* Written by Bruno Haible , 2009. */ + +#include "signature.h" +SIGNATURE_CHECK (getopt, int, (int, char * const[], char const *)); + +#include +#include +#include +#include + +/* This test intentionally remaps stderr. So, we arrange to have fd 10 + (outside the range of interesting fd's during the test) set up to + duplicate the original stderr. */ + +#define BACKUP_STDERR_FILENO 10 +#define ASSERT_STREAM myerr +#include "macros.h" + +static FILE *myerr; + +#include "test-getopt.h" +#if TEST_GETOPT_GNU +# include "test-getopt_long.h" +#endif + +int +main (void) +{ + /* This test validates that stderr is used correctly, so move the + original into fd 10. */ + if (dup2 (STDERR_FILENO, BACKUP_STDERR_FILENO) != BACKUP_STDERR_FILENO + || (myerr = fdopen (BACKUP_STDERR_FILENO, "w")) == NULL) + return 2; + + ASSERT (freopen (TEST_GETOPT_TMP_NAME, "w", stderr) == stderr); + + /* These default values are required by POSIX. */ + ASSERT (optind == 1); + ASSERT (opterr != 0); + + setenv ("POSIXLY_CORRECT", "1", 1); + test_getopt (); + +#if TEST_GETOPT_GNU + test_getopt_long_posix (); +#endif + + unsetenv ("POSIXLY_CORRECT"); + test_getopt (); + +#if TEST_GETOPT_GNU + test_getopt_long (); + test_getopt_long_only (); +#endif + + ASSERT (fclose (stderr) == 0); + ASSERT (remove (TEST_GETOPT_TMP_NAME) == 0); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-getopt-posix.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-getopt-posix.c new file mode 100644 index 00000000..a0fbd69e --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-getopt-posix.c @@ -0,0 +1,34 @@ +/* Test of command line argument processing. + Copyright (C) 2009-2024 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 . */ + +/* Written by Bruno Haible , 2009. */ + +#include + +/* None of the files accessed by this test are large, so disable the + ftell link warning if we are not using the gnulib ftell module. */ +#define _GL_NO_LARGE_FILES + +/* POSIX and glibc provide the getopt() function in , see + https://pubs.opengroup.org/onlinepubs/9699919799/functions/getopt.html + https://www.gnu.org/software/libc/manual/html_node/Using-Getopt.html + But gnulib provides the getopt() function in , not in . + Nevertheless the getopt() function should also be found in . */ +#include + +#define TEST_GETOPT_GNU 0 +#define TEST_GETOPT_TMP_NAME "test-getopt-posix.tmp" +#include "test-getopt-main.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-getopt.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-getopt.h new file mode 100644 index 00000000..f13b5959 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-getopt.h @@ -0,0 +1,1390 @@ +/* Test of command line argument processing. + Copyright (C) 2009-2024 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 . */ + +/* Written by Bruno Haible , 2009. */ + + +/* The glibc/gnulib implementation of getopt supports setting optind = + 0, but not all other implementations do. This matters for getopt. + But for getopt_long, we require GNU compatibility. */ +#if defined __GETOPT_PREFIX || (__GLIBC__ >= 2 && !defined __UCLIBC__) +# define OPTIND_MIN 0 +#elif HAVE_DECL_OPTRESET +# define OPTIND_MIN (optreset = 1) +#else +# define OPTIND_MIN 1 +#endif + +static void +getopt_loop (int argc, const char **argv, + const char *options, + int *a_seen, int *b_seen, + const char **p_value, const char **q_value, + int *non_options_count, const char **non_options, + int *unrecognized, bool *message_issued) +{ + int c; + int pos = ftell (stderr); + + while ((c = getopt (argc, (char **) argv, options)) != -1) + { + switch (c) + { + case 'a': + (*a_seen)++; + break; + case 'b': + (*b_seen)++; + break; + case 'p': + *p_value = optarg; + break; + case 'q': + *q_value = optarg; + break; + case '\1': + /* Must only happen with option '-' at the beginning. */ + ASSERT (options[0] == '-'); + non_options[(*non_options_count)++] = optarg; + break; + case ':': + /* Must only happen with option ':' at the beginning. */ + ASSERT (options[0] == ':' + || ((options[0] == '-' || options[0] == '+') + && options[1] == ':')); + FALLTHROUGH; + case '?': + *unrecognized = optopt; + break; + default: + *unrecognized = c; + break; + } + } + + *message_issued = pos < ftell (stderr); +} + +static void +test_getopt (void) +{ + int start; + bool posixly = !!getenv ("POSIXLY_CORRECT"); + /* See comment in getopt.c: + glibc gets a LSB-compliant getopt. + Standalone applications get a POSIX-compliant getopt. */ +#if defined __GETOPT_PREFIX || !(__GLIBC__ >= 2 || defined __MINGW32__) + /* Using getopt from gnulib or from a non-glibc system. */ + posixly = true; +#endif + + /* Test processing of boolean options. */ + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[10]; + + argv[argc++] = "program"; + argv[argc++] = "-a"; + argv[argc++] = "foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + opterr = 1; + getopt_loop (argc, argv, "ab", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 2); + ASSERT (!output); + } + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[10]; + + argv[argc++] = "program"; + argv[argc++] = "-b"; + argv[argc++] = "-a"; + argv[argc++] = "foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + opterr = 1; + getopt_loop (argc, argv, "ab", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + ASSERT (a_seen == 1); + ASSERT (b_seen == 1); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 3); + ASSERT (!output); + } + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[10]; + + argv[argc++] = "program"; + argv[argc++] = "-ba"; + argv[argc++] = "foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + opterr = 1; + getopt_loop (argc, argv, "ab", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + ASSERT (a_seen == 1); + ASSERT (b_seen == 1); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 2); + ASSERT (!output); + } + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[10]; + + argv[argc++] = "program"; + argv[argc++] = "-ab"; + argv[argc++] = "-a"; + argv[argc++] = "foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + opterr = 1; + getopt_loop (argc, argv, "ab", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + ASSERT (a_seen == 2); + ASSERT (b_seen == 1); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 3); + ASSERT (!output); + } + + /* Test processing of options with arguments. */ + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[10]; + + argv[argc++] = "program"; + argv[argc++] = "-pfoo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + opterr = 1; + getopt_loop (argc, argv, "p:q:", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 2); + ASSERT (!output); + } + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[10]; + + argv[argc++] = "program"; + argv[argc++] = "-p"; + argv[argc++] = "foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + opterr = 1; + getopt_loop (argc, argv, "p:q:", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 3); + ASSERT (!output); + } + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[10]; + + argv[argc++] = "program"; + argv[argc++] = "-ab"; + argv[argc++] = "-q"; + argv[argc++] = "baz"; + argv[argc++] = "-pfoo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + opterr = 1; + getopt_loop (argc, argv, "abp:q:", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + ASSERT (a_seen == 1); + ASSERT (b_seen == 1); + ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0); + ASSERT (q_value != NULL && strcmp (q_value, "baz") == 0); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 5); + ASSERT (!output); + } + +#if GNULIB_TEST_GETOPT_GNU + /* Test processing of options with optional arguments. */ + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[10]; + + argv[argc++] = "program"; + argv[argc++] = "-pfoo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + opterr = 1; + getopt_loop (argc, argv, "p::q::", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 2); + ASSERT (!output); + } + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[10]; + + argv[argc++] = "program"; + argv[argc++] = "-p"; + argv[argc++] = "foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + opterr = 1; + getopt_loop (argc, argv, "p::q::", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 2); + ASSERT (!output); + } + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[10]; + + argv[argc++] = "program"; + argv[argc++] = "-p"; + argv[argc++] = "-a"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + opterr = 1; + getopt_loop (argc, argv, "abp::q::", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 3); + ASSERT (!output); + } +#endif /* GNULIB_TEST_GETOPT_GNU */ + + /* Check that invalid options are recognized; and that both opterr + and leading ':' can silence output. */ + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[10]; + + argv[argc++] = "program"; + argv[argc++] = "-p"; + argv[argc++] = "foo"; + argv[argc++] = "-x"; + argv[argc++] = "-a"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + opterr = 42; + getopt_loop (argc, argv, "abp:q:", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 'x'); + ASSERT (optind == 5); + ASSERT (output); + } + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[10]; + + argv[argc++] = "program"; + argv[argc++] = "-p"; + argv[argc++] = "foo"; + argv[argc++] = "-x"; + argv[argc++] = "-a"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + opterr = 0; + getopt_loop (argc, argv, "abp:q:", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 'x'); + ASSERT (optind == 5); + ASSERT (!output); + } + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[10]; + + argv[argc++] = "program"; + argv[argc++] = "-p"; + argv[argc++] = "foo"; + argv[argc++] = "-x"; + argv[argc++] = "-a"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + opterr = 1; + getopt_loop (argc, argv, ":abp:q:", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 'x'); + ASSERT (optind == 5); + ASSERT (!output); + } + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[10]; + + argv[argc++] = "program"; + argv[argc++] = "-p"; + argv[argc++] = "foo"; + argv[argc++] = "-:"; + argv[argc++] = "-a"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + opterr = 42; + getopt_loop (argc, argv, "abp:q:", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == ':'); + ASSERT (optind == 5); + ASSERT (output); + } + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[10]; + + argv[argc++] = "program"; + argv[argc++] = "-p"; + argv[argc++] = "foo"; + argv[argc++] = "-:"; + argv[argc++] = "-a"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + opterr = 0; + getopt_loop (argc, argv, "abp:q:", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == ':'); + ASSERT (optind == 5); + ASSERT (!output); + } + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[10]; + + argv[argc++] = "program"; + argv[argc++] = "-p"; + argv[argc++] = "foo"; + argv[argc++] = "-:"; + argv[argc++] = "-a"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + opterr = 1; + getopt_loop (argc, argv, ":abp:q:", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == ':'); + ASSERT (optind == 5); + ASSERT (!output); + } + + /* Check for missing argument behavior. */ + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[10]; + + argv[argc++] = "program"; + argv[argc++] = "-ap"; + argv[argc] = NULL; + optind = start; + opterr = 1; + getopt_loop (argc, argv, "abp:q:", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 'p'); + ASSERT (optind == 2); + ASSERT (output); + } + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[10]; + + argv[argc++] = "program"; + argv[argc++] = "-ap"; + argv[argc] = NULL; + optind = start; + opterr = 0; + getopt_loop (argc, argv, "abp:q:", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 'p'); + ASSERT (optind == 2); + ASSERT (!output); + } + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[10]; + + argv[argc++] = "program"; + argv[argc++] = "-ap"; + argv[argc] = NULL; + optind = start; + opterr = 1; + getopt_loop (argc, argv, ":abp:q:", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 'p'); + ASSERT (optind == 2); + ASSERT (!output); + } + + /* Check that by default, non-options arguments are moved to the end. */ + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[10]; + + argv[argc++] = "program"; + argv[argc++] = "donald"; + argv[argc++] = "-p"; + argv[argc++] = "billy"; + argv[argc++] = "duck"; + argv[argc++] = "-a"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + opterr = 1; + getopt_loop (argc, argv, "abp:q:", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + if (posixly) + { + ASSERT (strcmp (argv[0], "program") == 0); + ASSERT (strcmp (argv[1], "donald") == 0); + ASSERT (strcmp (argv[2], "-p") == 0); + ASSERT (strcmp (argv[3], "billy") == 0); + ASSERT (strcmp (argv[4], "duck") == 0); + ASSERT (strcmp (argv[5], "-a") == 0); + ASSERT (strcmp (argv[6], "bar") == 0); + ASSERT (argv[7] == NULL); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 1); + ASSERT (!output); + } + else + { + ASSERT (strcmp (argv[0], "program") == 0); + ASSERT (strcmp (argv[1], "-p") == 0); + ASSERT (strcmp (argv[2], "billy") == 0); + ASSERT (strcmp (argv[3], "-a") == 0); + ASSERT (strcmp (argv[4], "donald") == 0); + ASSERT (strcmp (argv[5], "duck") == 0); + ASSERT (strcmp (argv[6], "bar") == 0); + ASSERT (argv[7] == NULL); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "billy") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 4); + ASSERT (!output); + } + } + + /* Check that '--' ends the argument processing. */ + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[20]; + + argv[argc++] = "program"; + argv[argc++] = "donald"; + argv[argc++] = "-p"; + argv[argc++] = "billy"; + argv[argc++] = "duck"; + argv[argc++] = "-a"; + argv[argc++] = "--"; + argv[argc++] = "-b"; + argv[argc++] = "foo"; + argv[argc++] = "-q"; + argv[argc++] = "johnny"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + opterr = 1; + getopt_loop (argc, argv, "abp:q:", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + if (posixly) + { + ASSERT (strcmp (argv[0], "program") == 0); + ASSERT (strcmp (argv[1], "donald") == 0); + ASSERT (strcmp (argv[2], "-p") == 0); + ASSERT (strcmp (argv[3], "billy") == 0); + ASSERT (strcmp (argv[4], "duck") == 0); + ASSERT (strcmp (argv[5], "-a") == 0); + ASSERT (strcmp (argv[6], "--") == 0); + ASSERT (strcmp (argv[7], "-b") == 0); + ASSERT (strcmp (argv[8], "foo") == 0); + ASSERT (strcmp (argv[9], "-q") == 0); + ASSERT (strcmp (argv[10], "johnny") == 0); + ASSERT (strcmp (argv[11], "bar") == 0); + ASSERT (argv[12] == NULL); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 1); + ASSERT (!output); + } + else + { + ASSERT (strcmp (argv[0], "program") == 0); + ASSERT (strcmp (argv[1], "-p") == 0); + ASSERT (strcmp (argv[2], "billy") == 0); + ASSERT (strcmp (argv[3], "-a") == 0); + ASSERT (strcmp (argv[4], "--") == 0); + ASSERT (strcmp (argv[5], "donald") == 0); + ASSERT (strcmp (argv[6], "duck") == 0); + ASSERT (strcmp (argv[7], "-b") == 0); + ASSERT (strcmp (argv[8], "foo") == 0); + ASSERT (strcmp (argv[9], "-q") == 0); + ASSERT (strcmp (argv[10], "johnny") == 0); + ASSERT (strcmp (argv[11], "bar") == 0); + ASSERT (argv[12] == NULL); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "billy") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 5); + ASSERT (!output); + } + } + +#if GNULIB_TEST_GETOPT_GNU + /* Check that the '-' flag causes non-options to be returned in order. */ + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[10]; + + argv[argc++] = "program"; + argv[argc++] = "donald"; + argv[argc++] = "-p"; + argv[argc++] = "billy"; + argv[argc++] = "duck"; + argv[argc++] = "-a"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + opterr = 1; + getopt_loop (argc, argv, "-abp:q:", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + ASSERT (strcmp (argv[0], "program") == 0); + ASSERT (strcmp (argv[1], "donald") == 0); + ASSERT (strcmp (argv[2], "-p") == 0); + ASSERT (strcmp (argv[3], "billy") == 0); + ASSERT (strcmp (argv[4], "duck") == 0); + ASSERT (strcmp (argv[5], "-a") == 0); + ASSERT (strcmp (argv[6], "bar") == 0); + ASSERT (argv[7] == NULL); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "billy") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 3); + ASSERT (strcmp (non_options[0], "donald") == 0); + ASSERT (strcmp (non_options[1], "duck") == 0); + ASSERT (strcmp (non_options[2], "bar") == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 7); + ASSERT (!output); + } + + /* Check that '--' ends the argument processing. */ + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[20]; + + argv[argc++] = "program"; + argv[argc++] = "donald"; + argv[argc++] = "-p"; + argv[argc++] = "billy"; + argv[argc++] = "duck"; + argv[argc++] = "-a"; + argv[argc++] = "--"; + argv[argc++] = "-b"; + argv[argc++] = "foo"; + argv[argc++] = "-q"; + argv[argc++] = "johnny"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + opterr = 1; + getopt_loop (argc, argv, "-abp:q:", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + ASSERT (strcmp (argv[0], "program") == 0); + ASSERT (strcmp (argv[1], "donald") == 0); + ASSERT (strcmp (argv[2], "-p") == 0); + ASSERT (strcmp (argv[3], "billy") == 0); + ASSERT (strcmp (argv[4], "duck") == 0); + ASSERT (strcmp (argv[5], "-a") == 0); + ASSERT (strcmp (argv[6], "--") == 0); + ASSERT (strcmp (argv[7], "-b") == 0); + ASSERT (strcmp (argv[8], "foo") == 0); + ASSERT (strcmp (argv[9], "-q") == 0); + ASSERT (strcmp (argv[10], "johnny") == 0); + ASSERT (strcmp (argv[11], "bar") == 0); + ASSERT (argv[12] == NULL); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "billy") == 0); + ASSERT (q_value == NULL); + ASSERT (!output); + if (non_options_count == 2) + { + /* glibc behaviour. */ + ASSERT (non_options_count == 2); + ASSERT (strcmp (non_options[0], "donald") == 0); + ASSERT (strcmp (non_options[1], "duck") == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 7); + } + else + { + /* Another valid behaviour. */ + ASSERT (non_options_count == 7); + ASSERT (strcmp (non_options[0], "donald") == 0); + ASSERT (strcmp (non_options[1], "duck") == 0); + ASSERT (strcmp (non_options[2], "-b") == 0); + ASSERT (strcmp (non_options[3], "foo") == 0); + ASSERT (strcmp (non_options[4], "-q") == 0); + ASSERT (strcmp (non_options[5], "johnny") == 0); + ASSERT (strcmp (non_options[6], "bar") == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 12); + } + } + + /* Check that the '-' flag has to come first. */ + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[10]; + + argv[argc++] = "program"; + argv[argc++] = "donald"; + argv[argc++] = "-p"; + argv[argc++] = "billy"; + argv[argc++] = "duck"; + argv[argc++] = "-a"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + opterr = 1; + getopt_loop (argc, argv, "abp:q:-", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + if (posixly) + { + ASSERT (strcmp (argv[0], "program") == 0); + ASSERT (strcmp (argv[1], "donald") == 0); + ASSERT (strcmp (argv[2], "-p") == 0); + ASSERT (strcmp (argv[3], "billy") == 0); + ASSERT (strcmp (argv[4], "duck") == 0); + ASSERT (strcmp (argv[5], "-a") == 0); + ASSERT (strcmp (argv[6], "bar") == 0); + ASSERT (argv[7] == NULL); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 1); + ASSERT (!output); + } + else + { + ASSERT (strcmp (argv[0], "program") == 0); + ASSERT (strcmp (argv[1], "-p") == 0); + ASSERT (strcmp (argv[2], "billy") == 0); + ASSERT (strcmp (argv[3], "-a") == 0); + ASSERT (strcmp (argv[4], "donald") == 0); + ASSERT (strcmp (argv[5], "duck") == 0); + ASSERT (strcmp (argv[6], "bar") == 0); + ASSERT (argv[7] == NULL); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "billy") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 4); + ASSERT (!output); + } + } + + /* Check that the '+' flag causes the first non-option to terminate the + loop. */ + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[10]; + + argv[argc++] = "program"; + argv[argc++] = "donald"; + argv[argc++] = "-p"; + argv[argc++] = "billy"; + argv[argc++] = "duck"; + argv[argc++] = "-a"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + opterr = 1; + getopt_loop (argc, argv, "+abp:q:", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + ASSERT (strcmp (argv[0], "program") == 0); + ASSERT (strcmp (argv[1], "donald") == 0); + ASSERT (strcmp (argv[2], "-p") == 0); + ASSERT (strcmp (argv[3], "billy") == 0); + ASSERT (strcmp (argv[4], "duck") == 0); + ASSERT (strcmp (argv[5], "-a") == 0); + ASSERT (strcmp (argv[6], "bar") == 0); + ASSERT (argv[7] == NULL); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 1); + ASSERT (!output); + } + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[10]; + + argv[argc++] = "program"; + argv[argc++] = "-+"; + argv[argc] = NULL; + optind = start; + getopt_loop (argc, argv, "+abp:q:", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == '+'); + ASSERT (optind == 2); + ASSERT (output); + } + + /* Check that '--' ends the argument processing. */ + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[20]; + + argv[argc++] = "program"; + argv[argc++] = "donald"; + argv[argc++] = "-p"; + argv[argc++] = "billy"; + argv[argc++] = "duck"; + argv[argc++] = "-a"; + argv[argc++] = "--"; + argv[argc++] = "-b"; + argv[argc++] = "foo"; + argv[argc++] = "-q"; + argv[argc++] = "johnny"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + opterr = 1; + getopt_loop (argc, argv, "+abp:q:", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + ASSERT (strcmp (argv[0], "program") == 0); + ASSERT (strcmp (argv[1], "donald") == 0); + ASSERT (strcmp (argv[2], "-p") == 0); + ASSERT (strcmp (argv[3], "billy") == 0); + ASSERT (strcmp (argv[4], "duck") == 0); + ASSERT (strcmp (argv[5], "-a") == 0); + ASSERT (strcmp (argv[6], "--") == 0); + ASSERT (strcmp (argv[7], "-b") == 0); + ASSERT (strcmp (argv[8], "foo") == 0); + ASSERT (strcmp (argv[9], "-q") == 0); + ASSERT (strcmp (argv[10], "johnny") == 0); + ASSERT (strcmp (argv[11], "bar") == 0); + ASSERT (argv[12] == NULL); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 1); + ASSERT (!output); + } +#endif /* GNULIB_TEST_GETOPT_GNU */ + + /* Check that the '+' flag has to come first. */ + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[10]; + + argv[argc++] = "program"; + argv[argc++] = "donald"; + argv[argc++] = "-p"; + argv[argc++] = "billy"; + argv[argc++] = "duck"; + argv[argc++] = "-a"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + opterr = 1; + getopt_loop (argc, argv, "abp:q:+", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + if (posixly) + { + ASSERT (strcmp (argv[0], "program") == 0); + ASSERT (strcmp (argv[1], "donald") == 0); + ASSERT (strcmp (argv[2], "-p") == 0); + ASSERT (strcmp (argv[3], "billy") == 0); + ASSERT (strcmp (argv[4], "duck") == 0); + ASSERT (strcmp (argv[5], "-a") == 0); + ASSERT (strcmp (argv[6], "bar") == 0); + ASSERT (argv[7] == NULL); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 1); + ASSERT (!output); + } + else + { + ASSERT (strcmp (argv[0], "program") == 0); + ASSERT (strcmp (argv[1], "-p") == 0); + ASSERT (strcmp (argv[2], "billy") == 0); + ASSERT (strcmp (argv[3], "-a") == 0); + ASSERT (strcmp (argv[4], "donald") == 0); + ASSERT (strcmp (argv[5], "duck") == 0); + ASSERT (strcmp (argv[6], "bar") == 0); + ASSERT (argv[7] == NULL); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "billy") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 4); + ASSERT (!output); + } + } + +#if GNULIB_TEST_GETOPT_GNU + /* If GNU extensions are supported, require compliance with POSIX + interpretation on leading '+' behavior. + http://austingroupbugs.net/view.php?id=191 */ + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[10]; + + argv[argc++] = "program"; + argv[argc++] = "donald"; + argv[argc++] = "-p"; + argv[argc++] = "billy"; + argv[argc++] = "duck"; + argv[argc++] = "-a"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + opterr = 1; + getopt_loop (argc, argv, "+:abp:q:", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + ASSERT (strcmp (argv[0], "program") == 0); + ASSERT (strcmp (argv[1], "donald") == 0); + ASSERT (strcmp (argv[2], "-p") == 0); + ASSERT (strcmp (argv[3], "billy") == 0); + ASSERT (strcmp (argv[4], "duck") == 0); + ASSERT (strcmp (argv[5], "-a") == 0); + ASSERT (strcmp (argv[6], "bar") == 0); + ASSERT (argv[7] == NULL); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 1); + ASSERT (!output); + } + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[10]; + + argv[argc++] = "program"; + argv[argc++] = "-p"; + argv[argc] = NULL; + optind = start; + getopt_loop (argc, argv, "+:abp:q:", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 'p'); + ASSERT (optind == 2); + ASSERT (!output); + } + for (start = OPTIND_MIN; start <= 1; start++) + { + int a_seen = 0; + int b_seen = 0; + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + bool output; + int argc = 0; + const char *argv[10]; + + argv[argc++] = "program"; + argv[argc++] = "-b"; + argv[argc++] = "-p"; + argv[argc] = NULL; + optind = start; + getopt_loop (argc, argv, "+:abp:q:", + &a_seen, &b_seen, &p_value, &q_value, + &non_options_count, non_options, &unrecognized, &output); + ASSERT (a_seen == 0); + ASSERT (b_seen == 1); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 'p'); + ASSERT (optind == 3); + ASSERT (!output); + } + + /* Check that 'W' does not dump core: + https://sourceware.org/bugzilla/show_bug.cgi?id=12922 + Technically, POSIX says the presence of ';' in the opt-string + gives unspecified behavior, so we only test this when GNU compliance + is desired. */ + for (start = OPTIND_MIN; start <= 1; start++) + { + int argc = 0; + const char *argv[10]; + int pos = ftell (stderr); + + argv[argc++] = "program"; + argv[argc++] = "-W"; + argv[argc++] = "dummy"; + argv[argc] = NULL; + optind = start; + opterr = 1; + ASSERT (getopt (argc, (char **) argv, "W;") == 'W'); + ASSERT (ftell (stderr) == pos); + ASSERT (optind == 2); + } +#endif /* GNULIB_TEST_GETOPT_GNU */ +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-getopt_long.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-getopt_long.h new file mode 100644 index 00000000..07bc7196 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-getopt_long.h @@ -0,0 +1,2144 @@ +/* Test of command line argument processing. + Copyright (C) 2009-2024 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 . */ + +/* Written by Bruno Haible , 2009. */ + +static int a_seen; +static int b_seen; +static int q_seen; + +static const struct option long_options_required[] = + { + { "alpha", no_argument, NULL, 'a' }, + { "beta", no_argument, &b_seen, 1 }, + { "prune", required_argument, NULL, 'p' }, + { "quetsche", required_argument, &q_seen, 1 }, + { "xtremely-",no_argument, NULL, 1003 }, + { "xtra", no_argument, NULL, 1001 }, + { "xtreme", no_argument, NULL, 1002 }, + { "xtremely", no_argument, NULL, 1003 }, + { NULL, 0, NULL, 0 } + }; + +static const struct option long_options_optional[] = + { + { "alpha", no_argument, NULL, 'a' }, + { "beta", no_argument, &b_seen, 1 }, + { "prune", optional_argument, NULL, 'p' }, + { "quetsche", optional_argument, &q_seen, 1 }, + { NULL, 0, NULL, 0 } + }; + +static void +getopt_long_loop (int argc, const char **argv, + const char *options, const struct option *long_options, + const char **p_value, const char **q_value, + int *non_options_count, const char **non_options, + int *unrecognized) +{ + int option_index = -1; + int c; + + opterr = 0; + q_seen = 0; + while ((c = getopt_long (argc, (char **) argv, options, long_options, + &option_index)) + != -1) + { + switch (c) + { + case 0: + /* An option with a non-NULL flag pointer was processed. */ + if (q_seen) + *q_value = optarg; + break; + case 'a': + a_seen++; + break; + case 'b': + b_seen = 1; + break; + case 'p': + *p_value = optarg; + break; + case 'q': + *q_value = optarg; + break; + case '\1': + /* Must only happen with option '-' at the beginning. */ + ASSERT (options[0] == '-'); + non_options[(*non_options_count)++] = optarg; + break; + case ':': + /* Must only happen with option ':' at the beginning. */ + ASSERT (options[0] == ':' + || ((options[0] == '-' || options[0] == '+') + && options[1] == ':')); + FALLTHROUGH; + case '?': + *unrecognized = optopt; + break; + default: + *unrecognized = c; + break; + } + } +} + +/* Reduce casting, so we can use string literals elsewhere. + getopt_long takes an array of char*, but luckily does not modify + those elements, so we can pass const char*. */ +static int +do_getopt_long (int argc, const char **argv, const char *shortopts, + const struct option *longopts, int *longind) +{ + return getopt_long (argc, (char **) argv, shortopts, longopts, longind); +} + +static void +test_getopt_long (void) +{ + int start; + + /* Test disambiguation of options. */ + { + int argc = 0; + const char *argv[10]; + int option_index; + int c; + + argv[argc++] = "program"; + argv[argc++] = "--x"; + argv[argc] = NULL; + optind = 1; + opterr = 0; + c = do_getopt_long (argc, argv, "ab", long_options_required, &option_index); + ASSERT (c == '?'); + ASSERT (optopt == 0); + } + { + int argc = 0; + const char *argv[10]; + int option_index; + int c; + + argv[argc++] = "program"; + argv[argc++] = "--xt"; + argv[argc] = NULL; + optind = 1; + opterr = 0; + c = do_getopt_long (argc, argv, "ab", long_options_required, &option_index); + ASSERT (c == '?'); + ASSERT (optopt == 0); + } + { + int argc = 0; + const char *argv[10]; + int option_index; + int c; + + argv[argc++] = "program"; + argv[argc++] = "--xtr"; + argv[argc] = NULL; + optind = 1; + opterr = 0; + c = do_getopt_long (argc, argv, "ab", long_options_required, &option_index); + ASSERT (c == '?'); + ASSERT (optopt == 0); + } + { + int argc = 0; + const char *argv[10]; + int option_index; + int c; + + argv[argc++] = "program"; + argv[argc++] = "--xtra"; + argv[argc] = NULL; + optind = 1; + opterr = 0; + c = do_getopt_long (argc, argv, "ab", long_options_required, &option_index); + ASSERT (c == 1001); + } + { + int argc = 0; + const char *argv[10]; + int option_index; + int c; + + argv[argc++] = "program"; + argv[argc++] = "--xtre"; + argv[argc] = NULL; + optind = 1; + opterr = 0; + c = do_getopt_long (argc, argv, "ab", long_options_required, &option_index); + ASSERT (c == '?'); + ASSERT (optopt == 0); + } + { + int argc = 0; + const char *argv[10]; + int option_index; + int c; + + argv[argc++] = "program"; + argv[argc++] = "--xtrem"; + argv[argc] = NULL; + optind = 1; + opterr = 0; + c = do_getopt_long (argc, argv, "ab", long_options_required, &option_index); + ASSERT (c == '?'); + ASSERT (optopt == 0); + } + { + int argc = 0; + const char *argv[10]; + int option_index; + int c; + + argv[argc++] = "program"; + argv[argc++] = "--xtreme"; + argv[argc] = NULL; + optind = 1; + opterr = 0; + c = do_getopt_long (argc, argv, "ab", long_options_required, &option_index); + ASSERT (c == 1002); + } + { + int argc = 0; + const char *argv[10]; + int option_index; + int c; + + argv[argc++] = "program"; + argv[argc++] = "--xtremel"; + argv[argc] = NULL; + optind = 1; + opterr = 0; + c = do_getopt_long (argc, argv, "ab", long_options_required, &option_index); + ASSERT (c == 1003); + } + { + int argc = 0; + const char *argv[10]; + int option_index; + int c; + + argv[argc++] = "program"; + argv[argc++] = "--xtremely"; + argv[argc] = NULL; + optind = 1; + opterr = 0; + c = do_getopt_long (argc, argv, "ab", long_options_required, &option_index); + ASSERT (c == 1003); + } + + /* Check that -W handles unknown options. */ + { + int argc = 0; + const char *argv[10]; + int option_index; + int c; + + argv[argc++] = "program"; + argv[argc++] = "-W"; + argv[argc] = NULL; + optind = 1; + opterr = 0; + c = do_getopt_long (argc, argv, "W;", long_options_required, &option_index); + ASSERT (c == '?'); + ASSERT (optopt == 'W'); + } + { + int argc = 0; + const char *argv[10]; + int option_index; + int c; + + argv[argc++] = "program"; + argv[argc++] = "-Wunknown"; + argv[argc] = NULL; + optind = 1; + opterr = 0; + c = do_getopt_long (argc, argv, "W;", long_options_required, &option_index); + /* glibc and BSD behave differently here, but for now, we allow + both behaviors since W support is not frequently used. */ + if (c == '?') + { + ASSERT (optopt == 0); + ASSERT (optarg == NULL); + } + else + { + ASSERT (c == 'W'); + ASSERT (strcmp (optarg, "unknown") == 0); + } + } + { + int argc = 0; + const char *argv[10]; + int option_index; + int c; + + argv[argc++] = "program"; + argv[argc++] = "-W"; + argv[argc++] = "unknown"; + argv[argc] = NULL; + optind = 1; + opterr = 0; + c = do_getopt_long (argc, argv, "W;", long_options_required, &option_index); + /* glibc and BSD behave differently here, but for now, we allow + both behaviors since W support is not frequently used. */ + if (c == '?') + { + ASSERT (optopt == 0); + ASSERT (optarg == NULL); + } + else + { + ASSERT (c == 'W'); + ASSERT (strcmp (optarg, "unknown") == 0); + } + } + + /* Test that 'W' does not dump core: + https://sourceware.org/bugzilla/show_bug.cgi?id=12922 */ + { + int argc = 0; + const char *argv[10]; + int option_index; + int c; + + argv[argc++] = "program"; + argv[argc++] = "-W"; + argv[argc++] = "dummy"; + argv[argc] = NULL; + optind = 1; + opterr = 0; + c = do_getopt_long (argc, argv, "W;", NULL, &option_index); + ASSERT (c == 'W'); + ASSERT (optind == 2); + } + + /* Test processing of boolean short options. */ + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "-a"; + argv[argc++] = "foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "ab", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 2); + } + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "-b"; + argv[argc++] = "-a"; + argv[argc++] = "foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "ab", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 1); + ASSERT (b_seen == 1); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 3); + } + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "-ba"; + argv[argc++] = "foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "ab", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 1); + ASSERT (b_seen == 1); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 2); + } + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "-ab"; + argv[argc++] = "-a"; + argv[argc++] = "foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "ab", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 2); + ASSERT (b_seen == 1); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 3); + } + + /* Test processing of boolean long options. */ + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "--alpha"; + argv[argc++] = "foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "ab", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 2); + } + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "--beta"; + argv[argc++] = "--alpha"; + argv[argc++] = "foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "ab", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 1); + ASSERT (b_seen == 1); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 3); + } + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "--alpha"; + argv[argc++] = "--beta"; + argv[argc++] = "--alpha"; + argv[argc++] = "--beta"; + argv[argc++] = "foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "ab", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 2); + ASSERT (b_seen == 1); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 5); + } + + /* Test processing of boolean long options via -W. */ + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "-Walpha"; + argv[argc++] = "foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "abW;", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 2); + } + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "-W"; + argv[argc++] = "beta"; + argv[argc++] = "-W"; + argv[argc++] = "alpha"; + argv[argc++] = "foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "aW;b", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 1); + ASSERT (b_seen == 1); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 5); + } + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "-Walpha"; + argv[argc++] = "-Wbeta"; + argv[argc++] = "-Walpha"; + argv[argc++] = "-Wbeta"; + argv[argc++] = "foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "W;ab", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 2); + ASSERT (b_seen == 1); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 5); + } + + /* Test processing of short options with arguments. */ + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "-pfoo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "p:q:", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 2); + } + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "-p"; + argv[argc++] = "foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "p:q:", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 3); + } + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "-ab"; + argv[argc++] = "-q"; + argv[argc++] = "baz"; + argv[argc++] = "-pfoo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "abp:q:", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 1); + ASSERT (b_seen == 1); + ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0); + ASSERT (q_value != NULL && strcmp (q_value, "baz") == 0); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 5); + } + + /* Test processing of long options with arguments. */ + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "--p=foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "p:q:", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 2); + } + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "--p"; + argv[argc++] = "foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "p:q:", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 3); + } + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "-ab"; + argv[argc++] = "--q"; + argv[argc++] = "baz"; + argv[argc++] = "--p=foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "abp:q:", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 1); + ASSERT (b_seen == 1); + ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0); + ASSERT (q_value != NULL && strcmp (q_value, "baz") == 0); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 5); + } + + /* Test processing of long options with arguments via -W. */ + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "-Wp=foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "p:q:W;", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 2); + } + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "-W"; + argv[argc++] = "p"; + argv[argc++] = "foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "p:W;q:", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 4); + } + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "-ab"; + argv[argc++] = "-Wq"; + argv[argc++] = "baz"; + argv[argc++] = "-W"; + argv[argc++] = "p=foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "W;abp:q:", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 1); + ASSERT (b_seen == 1); + ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0); + ASSERT (q_value != NULL && strcmp (q_value, "baz") == 0); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 6); + } + + /* Test processing of short options with optional arguments. */ + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "-pfoo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "p::q::", long_options_optional, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 2); + } + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "-p"; + argv[argc++] = "foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "p::q::", long_options_optional, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 2); + } + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "-p"; + argv[argc++] = "-a"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "abp::q::", long_options_optional, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 3); + } + + /* Test processing of long options with optional arguments. */ + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "--p=foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "p::q::", long_options_optional, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 2); + } + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "--p"; + argv[argc++] = "foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "p::q::", long_options_optional, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 2); + } + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "--p="; + argv[argc++] = "foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "p::q::", long_options_optional, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && *p_value == '\0'); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 2); + } + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "--p"; + argv[argc++] = "-a"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "abp::q::", long_options_optional, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 3); + } + + /* Test processing of long options with optional arguments via -W. */ + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "-Wp=foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "p::q::W;", long_options_optional, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 2); + } + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "-Wp"; + argv[argc++] = "foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "p::q::W;", long_options_optional, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 2); + } + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "-Wp="; + argv[argc++] = "foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "W;p::q::", long_options_optional, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && *p_value == '\0'); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 2); + } + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "-W"; + argv[argc++] = "p="; + argv[argc++] = "foo"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "W;p::q::", long_options_optional, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && *p_value == '\0'); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 3); + } + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "-W"; + argv[argc++] = "p"; + argv[argc++] = "-a"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "W;abp::q::", long_options_optional, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + /* ASSERT (p_value == NULL); */ + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 4); + } + + /* Check that invalid options are recognized. */ + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "-p"; + argv[argc++] = "foo"; + argv[argc++] = "-x"; + argv[argc++] = "-a"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "abp:q:", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 'x'); + ASSERT (optind == 5); + } + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "-p"; + argv[argc++] = "foo"; + argv[argc++] = "-:"; + argv[argc++] = "-a"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "abp:q:", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == ':'); + ASSERT (optind == 5); + } + + /* Check that unexpected arguments are recognized. */ + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "-p"; + argv[argc++] = "foo"; + argv[argc++] = "--a="; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "abp:q:", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 'a'); + ASSERT (optind == 4); + } + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "-p"; + argv[argc++] = "foo"; + argv[argc++] = "--b="; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "abp:q:", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + /* When flag is non-zero, glibc sets optopt anyway, but BSD + leaves optopt unchanged. */ + ASSERT (unrecognized == 1 || unrecognized == 0); + ASSERT (optind == 4); + } + + /* Check that by default, non-options arguments are moved to the end. */ + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "donald"; + argv[argc++] = "-p"; + argv[argc++] = "billy"; + argv[argc++] = "duck"; + argv[argc++] = "-a"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "abp:q:", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (strcmp (argv[0], "program") == 0); + ASSERT (strcmp (argv[1], "-p") == 0); + ASSERT (strcmp (argv[2], "billy") == 0); + ASSERT (strcmp (argv[3], "-a") == 0); + ASSERT (strcmp (argv[4], "donald") == 0); + ASSERT (strcmp (argv[5], "duck") == 0); + ASSERT (strcmp (argv[6], "bar") == 0); + ASSERT (argv[7] == NULL); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "billy") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 4); + } + + /* Check that '--' ends the argument processing. */ + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[20]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "donald"; + argv[argc++] = "-p"; + argv[argc++] = "billy"; + argv[argc++] = "duck"; + argv[argc++] = "-a"; + argv[argc++] = "--"; + argv[argc++] = "-b"; + argv[argc++] = "foo"; + argv[argc++] = "-q"; + argv[argc++] = "johnny"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "abp:q:", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (strcmp (argv[0], "program") == 0); + ASSERT (strcmp (argv[1], "-p") == 0); + ASSERT (strcmp (argv[2], "billy") == 0); + ASSERT (strcmp (argv[3], "-a") == 0); + ASSERT (strcmp (argv[4], "--") == 0); + ASSERT (strcmp (argv[5], "donald") == 0); + ASSERT (strcmp (argv[6], "duck") == 0); + ASSERT (strcmp (argv[7], "-b") == 0); + ASSERT (strcmp (argv[8], "foo") == 0); + ASSERT (strcmp (argv[9], "-q") == 0); + ASSERT (strcmp (argv[10], "johnny") == 0); + ASSERT (strcmp (argv[11], "bar") == 0); + ASSERT (argv[12] == NULL); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "billy") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 5); + } + + /* Check that the '-' flag causes non-options to be returned in order. */ + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "donald"; + argv[argc++] = "-p"; + argv[argc++] = "billy"; + argv[argc++] = "duck"; + argv[argc++] = "-a"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "-abp:q:", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (strcmp (argv[0], "program") == 0); + ASSERT (strcmp (argv[1], "donald") == 0); + ASSERT (strcmp (argv[2], "-p") == 0); + ASSERT (strcmp (argv[3], "billy") == 0); + ASSERT (strcmp (argv[4], "duck") == 0); + ASSERT (strcmp (argv[5], "-a") == 0); + ASSERT (strcmp (argv[6], "bar") == 0); + ASSERT (argv[7] == NULL); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "billy") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 3); + ASSERT (strcmp (non_options[0], "donald") == 0); + ASSERT (strcmp (non_options[1], "duck") == 0); + ASSERT (strcmp (non_options[2], "bar") == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 7); + } + + /* Check that '--' ends the argument processing. */ + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[20]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "donald"; + argv[argc++] = "-p"; + argv[argc++] = "billy"; + argv[argc++] = "duck"; + argv[argc++] = "-a"; + argv[argc++] = "--"; + argv[argc++] = "-b"; + argv[argc++] = "foo"; + argv[argc++] = "-q"; + argv[argc++] = "johnny"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "-abp:q:", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (strcmp (argv[0], "program") == 0); + ASSERT (strcmp (argv[1], "donald") == 0); + ASSERT (strcmp (argv[2], "-p") == 0); + ASSERT (strcmp (argv[3], "billy") == 0); + ASSERT (strcmp (argv[4], "duck") == 0); + ASSERT (strcmp (argv[5], "-a") == 0); + ASSERT (strcmp (argv[6], "--") == 0); + ASSERT (strcmp (argv[7], "-b") == 0); + ASSERT (strcmp (argv[8], "foo") == 0); + ASSERT (strcmp (argv[9], "-q") == 0); + ASSERT (strcmp (argv[10], "johnny") == 0); + ASSERT (strcmp (argv[11], "bar") == 0); + ASSERT (argv[12] == NULL); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "billy") == 0); + ASSERT (q_value == NULL); + if (non_options_count == 2) + { + /* glibc behaviour. */ + ASSERT (non_options_count == 2); + ASSERT (strcmp (non_options[0], "donald") == 0); + ASSERT (strcmp (non_options[1], "duck") == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 7); + } + else + { + /* Another valid behaviour. */ + ASSERT (non_options_count == 7); + ASSERT (strcmp (non_options[0], "donald") == 0); + ASSERT (strcmp (non_options[1], "duck") == 0); + ASSERT (strcmp (non_options[2], "-b") == 0); + ASSERT (strcmp (non_options[3], "foo") == 0); + ASSERT (strcmp (non_options[4], "-q") == 0); + ASSERT (strcmp (non_options[5], "johnny") == 0); + ASSERT (strcmp (non_options[6], "bar") == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 12); + } + } + + /* Check that the '-' flag has to come first. */ + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "donald"; + argv[argc++] = "-p"; + argv[argc++] = "billy"; + argv[argc++] = "duck"; + argv[argc++] = "-a"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "abp:q:-", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (strcmp (argv[0], "program") == 0); + ASSERT (strcmp (argv[1], "-p") == 0); + ASSERT (strcmp (argv[2], "billy") == 0); + ASSERT (strcmp (argv[3], "-a") == 0); + ASSERT (strcmp (argv[4], "donald") == 0); + ASSERT (strcmp (argv[5], "duck") == 0); + ASSERT (strcmp (argv[6], "bar") == 0); + ASSERT (argv[7] == NULL); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "billy") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 4); + } + + /* Check that the '+' flag causes the first non-option to terminate the + loop. */ + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "donald"; + argv[argc++] = "-p"; + argv[argc++] = "billy"; + argv[argc++] = "duck"; + argv[argc++] = "-a"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "+abp:q:", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (strcmp (argv[0], "program") == 0); + ASSERT (strcmp (argv[1], "donald") == 0); + ASSERT (strcmp (argv[2], "-p") == 0); + ASSERT (strcmp (argv[3], "billy") == 0); + ASSERT (strcmp (argv[4], "duck") == 0); + ASSERT (strcmp (argv[5], "-a") == 0); + ASSERT (strcmp (argv[6], "bar") == 0); + ASSERT (argv[7] == NULL); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 1); + } + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "-+"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "+abp:q:", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == '+'); + ASSERT (optind == 2); + } + + /* Check that '--' ends the argument processing. */ + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[20]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "donald"; + argv[argc++] = "-p"; + argv[argc++] = "billy"; + argv[argc++] = "duck"; + argv[argc++] = "-a"; + argv[argc++] = "--"; + argv[argc++] = "-b"; + argv[argc++] = "foo"; + argv[argc++] = "-q"; + argv[argc++] = "johnny"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "+abp:q:", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (strcmp (argv[0], "program") == 0); + ASSERT (strcmp (argv[1], "donald") == 0); + ASSERT (strcmp (argv[2], "-p") == 0); + ASSERT (strcmp (argv[3], "billy") == 0); + ASSERT (strcmp (argv[4], "duck") == 0); + ASSERT (strcmp (argv[5], "-a") == 0); + ASSERT (strcmp (argv[6], "--") == 0); + ASSERT (strcmp (argv[7], "-b") == 0); + ASSERT (strcmp (argv[8], "foo") == 0); + ASSERT (strcmp (argv[9], "-q") == 0); + ASSERT (strcmp (argv[10], "johnny") == 0); + ASSERT (strcmp (argv[11], "bar") == 0); + ASSERT (argv[12] == NULL); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 1); + } + + /* Check that the '+' flag has to come first. */ + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "donald"; + argv[argc++] = "-p"; + argv[argc++] = "billy"; + argv[argc++] = "duck"; + argv[argc++] = "-a"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "abp:q:+", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (strcmp (argv[0], "program") == 0); + ASSERT (strcmp (argv[1], "-p") == 0); + ASSERT (strcmp (argv[2], "billy") == 0); + ASSERT (strcmp (argv[3], "-a") == 0); + ASSERT (strcmp (argv[4], "donald") == 0); + ASSERT (strcmp (argv[5], "duck") == 0); + ASSERT (strcmp (argv[6], "bar") == 0); + ASSERT (argv[7] == NULL); + ASSERT (a_seen == 1); + ASSERT (b_seen == 0); + ASSERT (p_value != NULL && strcmp (p_value, "billy") == 0); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 4); + } +} + +/* Test behavior of getopt_long when POSIXLY_CORRECT is set in the + environment. Options with optional arguments should not change + behavior just because of an environment variable. + https://lists.gnu.org/r/bug-m4/2006-09/msg00028.html */ +static void +test_getopt_long_posix (void) +{ + int start; + + /* Check that POSIXLY_CORRECT stops parsing the same as leading '+'. */ + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "donald"; + argv[argc++] = "-p"; + argv[argc++] = "billy"; + argv[argc++] = "duck"; + argv[argc++] = "-a"; + argv[argc++] = "bar"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "abp:q:", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (strcmp (argv[0], "program") == 0); + ASSERT (strcmp (argv[1], "donald") == 0); + ASSERT (strcmp (argv[2], "-p") == 0); + ASSERT (strcmp (argv[3], "billy") == 0); + ASSERT (strcmp (argv[4], "duck") == 0); + ASSERT (strcmp (argv[5], "-a") == 0); + ASSERT (strcmp (argv[6], "bar") == 0); + ASSERT (argv[7] == NULL); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 1); + } + + /* Check that POSIXLY_CORRECT doesn't change optional arguments. */ + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "-p"; + argv[argc++] = "billy"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "p::", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 0); + ASSERT (b_seen == 0); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 2); + } + + /* Check that leading - still sees options after non-options. */ + for (start = 0; start <= 1; start++) + { + const char *p_value = NULL; + const char *q_value = NULL; + int non_options_count = 0; + const char *non_options[10]; + int unrecognized = 0; + int argc = 0; + const char *argv[10]; + a_seen = 0; + b_seen = 0; + + argv[argc++] = "program"; + argv[argc++] = "-a"; + argv[argc++] = "billy"; + argv[argc++] = "-b"; + argv[argc] = NULL; + optind = start; + getopt_long_loop (argc, argv, "-ab", long_options_required, + &p_value, &q_value, + &non_options_count, non_options, &unrecognized); + ASSERT (a_seen == 1); + ASSERT (b_seen == 1); + ASSERT (p_value == NULL); + ASSERT (q_value == NULL); + ASSERT (non_options_count == 1); + ASSERT (strcmp (non_options[0], "billy") == 0); + ASSERT (unrecognized == 0); + ASSERT (optind == 4); + } +} + +/* Reduce casting, so we can use string literals elsewhere. + getopt_long_only takes an array of char*, but luckily does not + modify those elements, so we can pass const char*. */ +static int +do_getopt_long_only (int argc, const char **argv, const char *shortopts, + const struct option *longopts, int *longind) +{ + return getopt_long_only (argc, (char **) argv, shortopts, longopts, longind); +} + +static void +test_getopt_long_only (void) +{ + /* Test disambiguation of options. */ + { + int argc = 0; + const char *argv[10]; + int option_index; + int c; + + argv[argc++] = "program"; + argv[argc++] = "-x"; + argv[argc] = NULL; + optind = 1; + opterr = 0; + c = do_getopt_long_only (argc, argv, "ab", long_options_required, + &option_index); + ASSERT (c == '?'); + ASSERT (optopt == 0); + } + { + int argc = 0; + const char *argv[10]; + int option_index; + int c; + + argv[argc++] = "program"; + argv[argc++] = "-x"; + argv[argc] = NULL; + optind = 1; + opterr = 0; + c = do_getopt_long_only (argc, argv, "abx", long_options_required, + &option_index); + ASSERT (c == 'x'); + ASSERT (optopt == 0); + } + { + int argc = 0; + const char *argv[10]; + int option_index; + int c; + + argv[argc++] = "program"; + argv[argc++] = "--x"; + argv[argc] = NULL; + optind = 1; + opterr = 0; + c = do_getopt_long_only (argc, argv, "abx", long_options_required, + &option_index); + ASSERT (c == '?'); + ASSERT (optopt == 0); + } + { + int argc = 0; + const char *argv[10]; + int option_index; + int c; + + argv[argc++] = "program"; + argv[argc++] = "-b"; + argv[argc] = NULL; + optind = 1; + opterr = 0; + b_seen = 0; + c = do_getopt_long_only (argc, argv, "abx", long_options_required, + &option_index); + ASSERT (c == 'b'); + ASSERT (b_seen == 0); + } + { + int argc = 0; + const char *argv[10]; + int option_index; + int c; + + argv[argc++] = "program"; + argv[argc++] = "--b"; + argv[argc] = NULL; + optind = 1; + opterr = 0; + b_seen = 0; + c = do_getopt_long_only (argc, argv, "abx", long_options_required, + &option_index); + ASSERT (c == 0); + ASSERT (b_seen == 1); + } + { + int argc = 0; + const char *argv[10]; + int option_index; + int c; + + argv[argc++] = "program"; + argv[argc++] = "-xt"; + argv[argc] = NULL; + optind = 1; + opterr = 0; + c = do_getopt_long_only (argc, argv, "ab", long_options_required, + &option_index); + ASSERT (c == '?'); + ASSERT (optopt == 0); + } + { + int argc = 0; + const char *argv[10]; + int option_index; + int c; + + argv[argc++] = "program"; + argv[argc++] = "-xt"; + argv[argc] = NULL; + optind = 1; + opterr = 0; + c = do_getopt_long_only (argc, argv, "abx", long_options_required, + &option_index); + ASSERT (c == '?'); + ASSERT (optopt == 0); + } + { + int argc = 0; + const char *argv[10]; + int option_index; + int c; + + argv[argc++] = "program"; + argv[argc++] = "-xtra"; + argv[argc] = NULL; + optind = 1; + opterr = 0; + c = do_getopt_long_only (argc, argv, "ab", long_options_required, + &option_index); + ASSERT (c == 1001); + } + { + int argc = 0; + const char *argv[10]; + int option_index; + int c; + + argv[argc++] = "program"; + argv[argc++] = "-xtreme"; + argv[argc] = NULL; + optind = 1; + opterr = 0; + c = do_getopt_long_only (argc, argv, "abx:", long_options_required, + &option_index); + ASSERT (c == 1002); + } + { + int argc = 0; + const char *argv[10]; + int option_index; + int c; + + argv[argc++] = "program"; + argv[argc++] = "-xtremel"; + argv[argc] = NULL; + optind = 1; + opterr = 0; + c = do_getopt_long_only (argc, argv, "ab", long_options_required, + &option_index); + /* glibc getopt_long_only is intentionally different from + getopt_long when handling a prefix that is common to two + spellings, when both spellings have the same option directives. + BSD getopt_long_only treats both cases the same. */ + ASSERT (c == 1003 || c == '?'); + ASSERT (optind == 2); + } + { + int argc = 0; + const char *argv[10]; + int option_index; + int c; + + argv[argc++] = "program"; + argv[argc++] = "-xtremel"; + argv[argc] = NULL; + optind = 1; + opterr = 0; + c = do_getopt_long_only (argc, argv, "abx::", long_options_required, + &option_index); + /* glibc getopt_long_only is intentionally different from + getopt_long when handling a prefix that is common to two + spellings, when both spellings have the same option directives. + BSD getopt_long_only treats both cases the same. */ + ASSERT (c == 1003 || c == '?'); + ASSERT (optind == 2); + ASSERT (optarg == NULL); + } + { + int argc = 0; + const char *argv[10]; + int option_index; + int c; + + argv[argc++] = "program"; + argv[argc++] = "-xtras"; + argv[argc] = NULL; + optind = 1; + opterr = 0; + c = do_getopt_long_only (argc, argv, "abx::", long_options_required, + &option_index); + ASSERT (c == 'x'); + ASSERT (strcmp (optarg, "tras") == 0); + } +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-getprogname.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-getprogname.c new file mode 100644 index 00000000..f26696db --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-getprogname.c @@ -0,0 +1,59 @@ +/* Test the gnulib getprogname module. + Copyright (C) 2016-2024 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 . */ + +#include + +#include + +#include +#include + +#ifdef __hpux +# define STREQ(a, b) (strncmp (a, b, 14) == 0) +#else +# define STREQ(a, b) (strcmp (a, b) == 0) +#endif + +int +main (void) +{ + char const *p = getprogname (); + + /* libtool creates a temporary executable whose name is sometimes prefixed + with "lt-" (depends on the platform). But the name of the temporary + executable is a detail that should not be visible to the end user and to + the test suite. Remove this "lt-" prefix here. */ + if (strncmp (p, "lt-", 3) == 0) + p += 3; + + /* Note: You can make this test fail + a) by running it on a case-insensitive file system (such as on Windows, + Cygwin, or on Mac OS X with a case-insensitive HFS+ file system), + with an invocation that contains upper case characters, e.g. + test-GETPROGNAME, + b) by hardlinking or symlinking it to a different name (e.g. test-foo) + and invoking it through that name. + That's not the intended use. The Makefile always invokes it as + 'test-getprogname${EXEEXT}'. */ +#if defined __CYGWIN__ + /* The Cygwin getprogname() function strips the ".exe" suffix. */ + assert (STREQ (p, "test-getprogname")); +#else + assert (STREQ (p, "test-getprogname" EXEEXT)); +#endif + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-getrandom.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-getrandom.c new file mode 100644 index 00000000..68a3ae34 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-getrandom.c @@ -0,0 +1,92 @@ +/* Test of getting random bytes. + Copyright (C) 2020-2024 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 . */ + +/* Written by Bruno Haible. */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (getrandom, ssize_t, (void *, size_t, unsigned int)); + +#include +#include + +#include "macros.h" + +int +main (void) +{ + char buf1[8]; + char buf2[8]; + char large_buf[100000]; + ssize_t ret; + + /* Check that different calls produce different results (with a high + probability). */ + ret = getrandom (buf1, sizeof (buf1), 0); + if (ret < 0) + ASSERT (errno == ENOSYS); + else + { + ret = getrandom (buf2, sizeof (buf2), 0); + if (ret < 0) + ASSERT (errno == ENOSYS); + else + { + /* It is very unlikely that two calls to getrandom produce the + same results. */ + ASSERT (memcmp (buf1, buf2, sizeof (buf1)) != 0); + } + } + + /* Likewise with the "truly random" number generator. */ + ret = getrandom (buf1, sizeof (buf1), GRND_RANDOM); + if (ret < 0) + ASSERT (errno == ENOSYS); + else + { + ret = getrandom (buf2, sizeof (buf2), GRND_RANDOM); + if (ret < 0) + ASSERT (errno == ENOSYS); + else + { + /* It is very unlikely that two calls to getrandom produce the + same results. */ + ASSERT (memcmp (buf1, buf2, sizeof (buf1)) != 0); + } + } + + /* Check that GRND_NONBLOCK works. */ + ret = getrandom (large_buf, sizeof (large_buf), GRND_RANDOM | GRND_NONBLOCK); + ASSERT (ret <= (ssize_t) sizeof (large_buf)); + /* It is very unlikely that so many truly random bytes were ready. */ + if (ret < 0) + ASSERT (errno == ENOSYS || errno == EAGAIN + || errno == EINVAL /* Solaris */); + else + ASSERT (ret > 0); + + if (getrandom (buf1, 1, 0) < 1) + if (getrandom (buf1, 1, GRND_RANDOM) < 1) + { + fputs ("Skipping test: getrandom is ineffective\n", stderr); + return 77; + } + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-gettimeofday.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-gettimeofday.c new file mode 100644 index 00000000..ea810bd5 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-gettimeofday.c @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2005, 2007, 2009-2024 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 . */ + +/* Written by Jim Meyering and Bruno Haible. */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (gettimeofday, int, + (struct timeval *, GETTIMEOFDAY_TIMEZONE *)); + +#include + +#include +#include +#include + +#include "macros.h" + +static void +test_clobber () +{ + time_t t = 0; + struct tm *lt; + struct tm saved_lt; + struct timeval tv; + lt = localtime (&t); + saved_lt = *lt; + gettimeofday (&tv, NULL); + if (memcmp (lt, &saved_lt, sizeof (struct tm)) != 0) + { + fprintf (stderr, "gettimeofday still clobbers the localtime buffer!\n"); + exit (1); + } +} + +static void +test_consistency () +{ + struct timeval tv1; + time_t tt2; + struct timeval tv3; + time_t tt4; + + ASSERT (gettimeofday (&tv1, NULL) == 0); + tt2 = time (NULL); + ASSERT (gettimeofday (&tv3, NULL) == 0); + tt4 = time (NULL); + + /* Verify monotonicity of gettimeofday(). */ + ASSERT (tv1.tv_sec < tv3.tv_sec + || (tv1.tv_sec == tv3.tv_sec && tv1.tv_usec <= tv3.tv_usec)); + + /* Verify monotonicity of time(). */ + ASSERT (tt2 <= tt4); + + /* Verify that the tv_sec field of the result is the same as time(NULL). */ + /* Note: It's here that the dependency to the 'time' module is needed. + Without it, this assertion would sometimes fail on glibc systems, see + https://sourceware.org/bugzilla/show_bug.cgi?id=30200 */ + ASSERT (tv1.tv_sec <= tt2); + ASSERT (tt2 <= tv3.tv_sec); + ASSERT (tv3.tv_sec <= tt4); +} + +int +main (void) +{ + test_clobber (); + test_consistency (); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-hard-locale.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-hard-locale.c new file mode 100644 index 00000000..151843ca --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-hard-locale.c @@ -0,0 +1,116 @@ +/* Test of determination whether a locale is different from the "C" locale. + Copyright (C) 2019-2024 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 . */ + +/* Written by Bruno Haible , 2019. */ + +#include + +#include "hard-locale.h" + +#include +#include +#include + +/* True if all locale names are accepted and all locales are trivial. + This is the case e.g. on OpenBSD 3.8. */ +static bool all_trivial; + +static int +test_one (const char *name, int failure_bitmask) +{ + if (setlocale (LC_ALL, name) != NULL) + { + bool expected; + + /* musl libc has special code for the C.UTF-8 locale; other than that, + all locale names are accepted and all locales are trivial. + OpenBSD returns the locale name that was set, but we don't know how it + behaves under the hood. Likewise for Haiku. + On Android >= 5.0, the "C" locale may have UTF-8 encoding, and we don't + know how it will behave in the future. */ +#if defined MUSL_LIBC || defined __OpenBSD__ || defined __HAIKU__ || defined __ANDROID__ + expected = true; +#else + expected = !all_trivial; +#endif + if (hard_locale (LC_CTYPE) != expected) + { + if (expected) + fprintf (stderr, "Unexpected: The category LC_CTYPE of the locale '%s' is not equivalent to C or POSIX.\n", + name); + else + fprintf (stderr, "Unexpected: The category LC_CTYPE of the locale '%s' is equivalent to C or POSIX.\n", + name); + return failure_bitmask; + } + + /* On NetBSD 7.0, some locales such as de_DE.ISO8859-1 and de_DE.UTF-8 + have the LC_COLLATE category set to "C". + Similarly, on musl libc, with the C.UTF-8 locale. + On Android >= 5.0, the "C" locale may have UTF-8 encoding, and we don't + know how it will behave in the future. */ +#if defined __NetBSD__ + expected = false; +#elif defined MUSL_LIBC + expected = strcmp (name, "C.UTF-8") != 0; +#elif (defined __OpenBSD__ && HAVE_DUPLOCALE) || defined __HAIKU__ || defined __ANDROID__ /* OpenBSD >= 6.2, Haiku, Android */ + expected = true; +#else + expected = !all_trivial; +#endif + if (hard_locale (LC_COLLATE) != expected) + { + if (expected) + fprintf (stderr, "Unexpected: The category LC_COLLATE of the locale '%s' is not equivalent to C or POSIX.\n", + name); + else + fprintf (stderr, "Unexpected: The category LC_COLLATE of the locale '%s' is equivalent to C or POSIX.\n", + name); + return failure_bitmask; + } + } + return 0; +} + +int +main () +{ + int fail = 0; + + /* The initial locale is the "C" or "POSIX" locale. + On Android >= 5.0, it is equivalent to the "C.UTF-8" locale, cf. + . */ +#if ! defined __ANDROID__ + if (hard_locale (LC_CTYPE) || hard_locale (LC_COLLATE)) + { + fprintf (stderr, "The initial locale should not be hard!\n"); + fail |= 1; + } +#endif + + all_trivial = (setlocale (LC_ALL, "foobar") != NULL); + + fail |= test_one ("de", 2); + fail |= test_one ("de_DE", 4); + fail |= test_one ("de_DE.ISO8859-1", 8); + fail |= test_one ("de_DE.iso88591", 8); + fail |= test_one ("de_DE.UTF-8", 16); + fail |= test_one ("de_DE.utf8", 16); + fail |= test_one ("german", 32); + fail |= test_one ("C.UTF-8", 64); + + return fail; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-hash.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-hash.c new file mode 100644 index 00000000..12ce00cc --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-hash.c @@ -0,0 +1,262 @@ +/* + * Copyright (C) 2009-2024 Free Software Foundation, Inc. + * Written by Jim Meyering + * + * 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 . */ + +#include + +#include "hash.h" +#include "hash-pjw.h" +#include "inttostr.h" + +#include +#include +#include +#include + +#include "macros.h" + +#define STREQ(a, b) (strcmp (a, b) == 0) +#define ARRAY_CARDINALITY(Array) (sizeof (Array) / sizeof *(Array)) + +static bool +hash_compare_strings (void const *x, void const *y) +{ + ASSERT (x != y); + return STREQ (x, y) ? true : false; +} + +static void +hash_freer (void *x) +{ + free (x); +} + +static void +insert_new (Hash_table *ht, const void *ent) +{ + void *e = hash_insert (ht, ent); + ASSERT (e == ent); +} + +static bool +walk (void *ent, void *data) +{ + char *str = ent; + unsigned int *map = data; + switch (*str) + { + case 'a': *map |= 1; return true; + case 'b': *map |= 2; return true; + case 'c': *map |= 4; return true; + } + *map |= 8; + return false; +} + +static int +get_seed (char const *str, unsigned int *seed) +{ + size_t len = strlen (str); + if (len == 0 || strspn (str, "0123456789") != len || 10 < len) + return 1; + + *seed = atoi (str); + return 0; +} + +int +main (int argc, char **argv) +{ + unsigned int i; + unsigned int k; + unsigned int table_size[] = {1, 2, 3, 4, 5, 23, 53}; + Hash_table *ht; + Hash_tuning tuning; + + hash_reset_tuning (&tuning); + tuning.shrink_threshold = 0.3; + tuning.shrink_factor = 0.707; + tuning.growth_threshold = 1.5; + tuning.growth_factor = 2.0; + tuning.is_n_buckets = true; + + if (1 < argc) + { + unsigned int seed; + if (get_seed (argv[1], &seed) != 0) + { + fprintf (stderr, "invalid seed: %s\n", argv[1]); + exit (EXIT_FAILURE); + } + + srand (seed); + } + + for (i = 0; i < ARRAY_CARDINALITY (table_size); i++) + { + size_t sz = table_size[i]; + ht = hash_initialize (sz, NULL, hash_pjw, hash_compare_strings, NULL); + ASSERT (ht); + insert_new (ht, "a"); + { + char *str1 = strdup ("a"); + char *str2; + ASSERT (str1); + str2 = hash_insert (ht, str1); + ASSERT (str1 != str2); + ASSERT (STREQ (str1, str2)); + free (str1); + } + insert_new (ht, "b"); + insert_new (ht, "c"); + i = 0; + ASSERT (hash_do_for_each (ht, walk, &i) == 3); + ASSERT (i == 7); + { + void *buf[5] = { NULL }; + ASSERT (hash_get_entries (ht, NULL, 0) == 0); + ASSERT (hash_get_entries (ht, buf, 5) == 3); + ASSERT (STREQ (buf[0], "a") || STREQ (buf[0], "b") || STREQ (buf[0], "c")); + } + ASSERT (hash_remove (ht, "a")); + ASSERT (hash_remove (ht, "a") == NULL); + ASSERT (hash_remove (ht, "b")); + ASSERT (hash_remove (ht, "c")); + + ASSERT (hash_rehash (ht, 47)); + ASSERT (hash_rehash (ht, 467)); + + /* Free an empty table. */ + hash_clear (ht); + hash_free (ht); + + ht = hash_initialize (sz, NULL, hash_pjw, hash_compare_strings, NULL); + ASSERT (ht); + + insert_new (ht, "z"); + insert_new (ht, "y"); + insert_new (ht, "x"); + insert_new (ht, "w"); + insert_new (ht, "v"); + insert_new (ht, "u"); + + hash_clear (ht); + ASSERT (hash_get_n_entries (ht) == 0); + hash_free (ht); + + /* Test pointer hashing. */ + ht = hash_initialize (sz, NULL, NULL, NULL, NULL); + ASSERT (ht); + { + char *str = strdup ("a"); + ASSERT (str); + insert_new (ht, "a"); + insert_new (ht, str); + ASSERT (hash_lookup (ht, str) == str); + free (str); + } + hash_free (ht); + } + + hash_reset_tuning (&tuning); + tuning.shrink_threshold = 0.3; + tuning.shrink_factor = 0.707; + tuning.growth_threshold = 1.5; + tuning.growth_factor = 2.0; + tuning.is_n_buckets = true; + /* Invalid tuning. */ + ht = hash_initialize (4651, &tuning, hash_pjw, hash_compare_strings, + hash_freer); + ASSERT (!ht); + + /* Alternate tuning. */ + tuning.growth_threshold = 0.89; + + /* Run with default tuning, then with custom tuning settings. */ + for (k = 0; k < 2; k++) + { + Hash_tuning const *tune = (k == 0 ? NULL : &tuning); + /* Now, each entry is malloc'd. */ + ht = hash_initialize (4651, tune, hash_pjw, + hash_compare_strings, hash_freer); + ASSERT (ht); + for (i = 0; i < 10000; i++) + { + unsigned int op = rand () % 10; + switch (op) + { + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + { + char buf[50]; + char const *p = uinttostr (i, buf); + char *p_dup = strdup (p); + ASSERT (p_dup); + insert_new (ht, p_dup); + } + break; + + case 6: + { + size_t n = hash_get_n_entries (ht); + ASSERT (hash_rehash (ht, n + rand () % 20)); + } + break; + + case 7: + { + size_t n = hash_get_n_entries (ht); + size_t delta = rand () % 20; + if (delta < n) + ASSERT (hash_rehash (ht, n - delta)); + } + break; + + case 8: + case 9: + { + /* Delete a random entry. */ + size_t n = hash_get_n_entries (ht); + if (n) + { + size_t kk = rand () % n; + void const *p; + void *v; + for (p = hash_get_first (ht); kk; + --kk, p = hash_get_next (ht, p)) + { + /* empty */ + } + ASSERT (p); + v = hash_remove (ht, p); + ASSERT (v); + free (v); + } + break; + } + } + ASSERT (hash_table_ok (ht)); + } + + hash_free (ht); + } + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-ignore-value.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-ignore-value.c new file mode 100644 index 00000000..32edfb45 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-ignore-value.c @@ -0,0 +1,78 @@ +/* Test the "ignore-value" module. + + Copyright (C) 2011-2024 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 . */ + +/* Written by Eric Blake. */ + +#include + +#include "ignore-value.h" + +#include + +#include "attribute.h" + +struct s { int i; }; +NODISCARD static char doChar (void); +NODISCARD static int doInt (void); +NODISCARD static off_t doOff (void); +NODISCARD static void *doPtr (void); +NODISCARD static struct s doStruct (void); + +static char +doChar (void) +{ + return 0; +} + +static int +doInt (void) +{ + return 0; +} + +static off_t +doOff (void) +{ + return 0; +} + +static void * +doPtr (void) +{ + return NULL; +} + +static struct s +doStruct (void) +{ + static struct s s1; + return s1; +} + +int +main (void) +{ + /* If this test can compile with -Werror and the same warnings as + the rest of the project, then we are properly silencing warnings + about ignored return values. */ + ignore_value (doChar ()); + ignore_value (doInt ()); + ignore_value (doOff ()); + ignore_value (doPtr ()); + ignore_value (doStruct ()); + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-inet_pton.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-inet_pton.c new file mode 100644 index 00000000..6598d5a0 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-inet_pton.c @@ -0,0 +1,58 @@ +/* Test of inet_pton function. + Copyright (C) 2009-2024 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 . */ + +/* Written by Bruno Haible , 2009. */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (inet_pton, int, (int, const char *, void *)); + +#include +#include + +#include "macros.h" + +int +main (void) +{ +#if defined AF_INET /* HAVE_IPV4 */ + { + /* This machine was for a long time known as + ma2s2.mathematik.uni-karlsruhe.de. */ + const char printable[] = "129.13.115.2"; + struct in_addr internal; + int ret; + + ret = inet_pton (AF_INET, printable, &internal); + ASSERT (ret == 1); + /* Verify that internal is filled in network byte order. */ + ASSERT (((unsigned char *) &internal)[0] == 0x81); + ASSERT (((unsigned char *) &internal)[1] == 0x0D); + ASSERT (((unsigned char *) &internal)[2] == 0x73); + ASSERT (((unsigned char *) &internal)[3] == 0x02); +# ifdef WORDS_BIGENDIAN + ASSERT (internal.s_addr == 0x810D7302); +# else + ASSERT (internal.s_addr == 0x02730D81); +# endif + } +#endif + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-init.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-init.sh new file mode 100755 index 00000000..8f20fe61 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-init.sh @@ -0,0 +1,74 @@ +#!/bin/sh +# Unit tests for init.sh +# Copyright (C) 2011-2024 Free Software Foundation, Inc. +# This file is part of the GNUlib Library. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . */ + +: "${srcdir=.}" +. "$srcdir/init.sh"; path_prepend_ . + +fail=0 + +test_compare() +{ + touch empty || fail=1 + echo xyz > in || fail=1 + + compare /dev/null /dev/null >out 2>err || fail=1 + test -s out && fail_ "out not empty: $(cat out)" + # "err" should be empty, too, but has "set -x" output when VERBOSE=yes + case $- in *x*) ;; *) test -s err && fail_ "err not empty: $(cat err)";; esac + + compare /dev/null empty >out 2>err || fail=1 + test -s out && fail_ "out not empty: $(cat out)" + case $- in *x*) ;; *) test -s err && fail_ "err not empty: $(cat err)";; esac + + compare in in >out 2>err || fail=1 + test -s out && fail_ "out not empty: $(cat out)" + case $- in *x*) ;; *) test -s err && fail_ "err not empty: $(cat err)";; esac + + compare /dev/null in >out 2>err && fail=1 + cat <<\EOF > exp +diff -u /dev/null in +--- /dev/null 1970-01-01 ++++ in 1970-01-01 ++xyz +EOF + compare exp out || fail=1 + case $- in *x*) ;; *) test -s err && fail_ "err not empty: $(cat err)";; esac + + compare empty in >out 2>err && fail=1 + # Compare against expected output only if compare is using diff -u. + if grep @ out >/dev/null; then + # Remove the TAB-date suffix on each --- and +++ line, + # for both the expected and the actual output files. + # Also remove the @@ line, since Solaris 5.10 and GNU diff formats differ: + # -@@ -0,0 +1 @@ + # +@@ -1,0 +1,1 @@ + # Also, remove space after leading '+', since AIX 7.1 diff outputs a space. + sed 's/ .*//;/^@@/d;s/^+ /+/' out > k && mv k out + cat <<\EOF > exp +--- empty ++++ in ++xyz +EOF + compare exp out || fail=1 + fi + case $- in *x*) ;; *) test -s err && fail_ "err not empty: $(cat err)";; esac +} + +test_compare + +Exit $fail diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-intprops.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-intprops.c new file mode 100644 index 00000000..e0d63d47 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-intprops.c @@ -0,0 +1,448 @@ +/* Test intprops.h. + Copyright (C) 2011-2024 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 . */ + +/* Written by Paul Eggert. */ + +/* Tell gcc not to warn about the long expressions that the overflow + macros expand to, or about the (X < 0) expressions. */ +#if 4 < __GNUC__ + (3 <= __GNUC_MINOR__) +# pragma GCC diagnostic ignored "-Woverlength-strings" +# pragma GCC diagnostic ignored "-Wtype-limits" + +/* Work around a bug in GCC 6.1 and earlier; see: + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68971 */ +# pragma GCC diagnostic ignored "-Woverflow" + +#endif + +#include + +#ifdef TEST_STDCKDINT +# include +#else +# include "intprops.h" +#endif + +#include +#include + +#include "macros.h" + +/* Compile-time verification of expression X. + In this file, we need it as a statement, rather than as a declaration. */ +#define verify_stmt(x) do { static_assert (x); } while (0) + +/* VERIFY (X) uses a static assertion for compilers that are known to work, + and falls back on a dynamic assertion for other compilers. + But it ignores X if testing stdckdint.h. + These tests should be checkable via 'verify' rather than 'ASSERT', but + using 'verify' would run into a bug with HP-UX 11.23 cc; see + . */ +#ifdef TEST_STDCKDINT +# define VERIFY(x) ((void) 0) +#elif __GNUC__ || __clang__ || __SUNPRO_C +# define VERIFY(x) verify_stmt (x) +#else +# define VERIFY(x) ASSERT (x) +#endif + +#define DONTCARE __LINE__ + +int int_minus_2 = -2; +int int_1 = 1; + +int +main (void) +{ + /* Use VERIFY for tests that must be integer constant expressions, + ASSERT otherwise. */ + +#ifndef TEST_STDCKDINT + /* TYPE_IS_INTEGER. */ + ASSERT (TYPE_IS_INTEGER (bool)); + ASSERT (TYPE_IS_INTEGER (char)); + ASSERT (TYPE_IS_INTEGER (signed char)); + ASSERT (TYPE_IS_INTEGER (unsigned char)); + ASSERT (TYPE_IS_INTEGER (short int)); + ASSERT (TYPE_IS_INTEGER (unsigned short int)); + ASSERT (TYPE_IS_INTEGER (int)); + ASSERT (TYPE_IS_INTEGER (unsigned int)); + ASSERT (TYPE_IS_INTEGER (long int)); + ASSERT (TYPE_IS_INTEGER (unsigned long int)); + ASSERT (TYPE_IS_INTEGER (intmax_t)); + ASSERT (TYPE_IS_INTEGER (uintmax_t)); + ASSERT (! TYPE_IS_INTEGER (float)); + ASSERT (! TYPE_IS_INTEGER (double)); + ASSERT (! TYPE_IS_INTEGER (long double)); + + /* TYPE_SIGNED. */ + /* VERIFY (! TYPE_SIGNED (bool)); // not guaranteed by gnulib substitute */ + VERIFY (TYPE_SIGNED (signed char)); + VERIFY (! TYPE_SIGNED (unsigned char)); + VERIFY (TYPE_SIGNED (short int)); + VERIFY (! TYPE_SIGNED (unsigned short int)); + VERIFY (TYPE_SIGNED (int)); + VERIFY (! TYPE_SIGNED (unsigned int)); + VERIFY (TYPE_SIGNED (long int)); + VERIFY (! TYPE_SIGNED (unsigned long int)); + VERIFY (TYPE_SIGNED (intmax_t)); + VERIFY (! TYPE_SIGNED (uintmax_t)); + ASSERT (TYPE_SIGNED (float)); + ASSERT (TYPE_SIGNED (double)); + ASSERT (TYPE_SIGNED (long double)); + + /* Integer representation. Check that it is two's complement. */ + VERIFY (INT_MIN + INT_MAX < 0); + + /* TYPE_MINIMUM, TYPE_MAXIMUM. */ + VERIFY (TYPE_MINIMUM (char) == CHAR_MIN); + VERIFY (TYPE_MAXIMUM (char) == CHAR_MAX); + VERIFY (TYPE_MINIMUM (unsigned char) == 0); + VERIFY (TYPE_MAXIMUM (unsigned char) == UCHAR_MAX); + VERIFY (TYPE_MINIMUM (signed char) == SCHAR_MIN); + VERIFY (TYPE_MAXIMUM (signed char) == SCHAR_MAX); + VERIFY (TYPE_MINIMUM (short int) == SHRT_MIN); + VERIFY (TYPE_MAXIMUM (short int) == SHRT_MAX); + VERIFY (TYPE_MINIMUM (unsigned short int) == 0); + VERIFY (TYPE_MAXIMUM (unsigned short int) == USHRT_MAX); + VERIFY (TYPE_MINIMUM (int) == INT_MIN); + VERIFY (TYPE_MAXIMUM (int) == INT_MAX); + VERIFY (TYPE_MINIMUM (unsigned int) == 0); + VERIFY (TYPE_MAXIMUM (unsigned int) == UINT_MAX); + VERIFY (TYPE_MINIMUM (long int) == LONG_MIN); + VERIFY (TYPE_MAXIMUM (long int) == LONG_MAX); + VERIFY (TYPE_MINIMUM (unsigned long int) == 0); + VERIFY (TYPE_MAXIMUM (unsigned long int) == ULONG_MAX); + #ifdef LLONG_MAX + verify_stmt (TYPE_MINIMUM (long long int) == LLONG_MIN); + verify_stmt (TYPE_MAXIMUM (long long int) == LLONG_MAX); + verify_stmt (TYPE_MINIMUM (unsigned long long int) == 0); + verify_stmt (TYPE_MAXIMUM (unsigned long long int) == ULLONG_MAX); + #endif + VERIFY (TYPE_MINIMUM (intmax_t) == INTMAX_MIN); + VERIFY (TYPE_MAXIMUM (intmax_t) == INTMAX_MAX); + VERIFY (TYPE_MINIMUM (uintmax_t) == 0); + VERIFY (TYPE_MAXIMUM (uintmax_t) == UINTMAX_MAX); + + /* TYPE_WIDTH. */ + #ifdef CHAR_WIDTH + verify_stmt (TYPE_WIDTH (char) == CHAR_WIDTH); + verify_stmt (TYPE_WIDTH (signed char) == SCHAR_WIDTH); + verify_stmt (TYPE_WIDTH (unsigned char) == UCHAR_WIDTH); + verify_stmt (TYPE_WIDTH (short int) == SHRT_WIDTH); + verify_stmt (TYPE_WIDTH (unsigned short int) == USHRT_WIDTH); + verify_stmt (TYPE_WIDTH (int) == INT_WIDTH); + verify_stmt (TYPE_WIDTH (unsigned int) == UINT_WIDTH); + verify_stmt (TYPE_WIDTH (long int) == LONG_WIDTH); + verify_stmt (TYPE_WIDTH (unsigned long int) == ULONG_WIDTH); + #ifdef LLONG_WIDTH + verify_stmt (TYPE_WIDTH (long long int) == LLONG_WIDTH); + verify_stmt (TYPE_WIDTH (unsigned long long int) == ULLONG_WIDTH); + #endif + #endif + + /* INT_BITS_STRLEN_BOUND. */ + VERIFY (INT_BITS_STRLEN_BOUND (1) == 1); + VERIFY (INT_BITS_STRLEN_BOUND (2620) == 789); + + /* INT_STRLEN_BOUND, INT_BUFSIZE_BOUND. */ + #ifdef INT32_MAX /* POSIX guarantees int32_t; this ports to non-POSIX. */ + VERIFY (INT_STRLEN_BOUND (int32_t) == sizeof ("-2147483648") - 1); + VERIFY (INT_BUFSIZE_BOUND (int32_t) == sizeof ("-2147483648")); + #endif + #ifdef INT64_MAX + VERIFY (INT_STRLEN_BOUND (int64_t) == sizeof ("-9223372036854775808") - 1); + VERIFY (INT_BUFSIZE_BOUND (int64_t) == sizeof ("-9223372036854775808")); + #endif +#endif + + /* All the INT__RANGE_OVERFLOW tests are equally valid as + INT__OVERFLOW tests, so define macros to do both. OP is the + operation, OPNAME its symbolic name, A and B its operands, T the + result type, V the overflow flag, and VRES the result if V and if + two's complement. CHECK_BINOP is for most binary operations, + CHECK_SBINOP for binary +, -, * when the result type is signed, + and CHECK_UNOP for unary operations. */ + #define CHECK_BINOP(op, opname, a, b, t, v, vres) \ + VERIFY (INT_##opname##_RANGE_OVERFLOW (a, b, TYPE_MINIMUM (t), \ + TYPE_MAXIMUM (t)) \ + == (v)); \ + VERIFY (INT_##opname##_OVERFLOW (a, b) == (v)) + #define CHECK_SBINOP(op, opname, a, b, t, v, vres) \ + CHECK_BINOP(op, opname, a, b, t, v, vres); \ + { \ + t result; \ + ASSERT (INT_##opname##_WRAPV (a, b, &result) == (v)); \ + ASSERT (result == ((v) ? (vres) : ((a) op (b)))); \ + } + #define CHECK_UNOP(op, opname, a, t, v) \ + VERIFY (INT_##opname##_RANGE_OVERFLOW (a, TYPE_MINIMUM (t), \ + TYPE_MAXIMUM (t)) \ + == (v)); \ + VERIFY (INT_##opname##_OVERFLOW (a) == (v)) + + /* INT__RANGE_OVERFLOW, INT__OVERFLOW. */ + VERIFY (INT_ADD_RANGE_OVERFLOW (INT_MAX, 1, INT_MIN, INT_MAX)); + VERIFY (INT_ADD_OVERFLOW (INT_MAX, 1)); + + CHECK_SBINOP (+, ADD, INT_MAX, 1, int, true, INT_MIN); + CHECK_SBINOP (+, ADD, INT_MAX, -1, int, false, INT_MAX - 1); + CHECK_SBINOP (+, ADD, INT_MIN, 1, int, false, INT_MIN + 1); + CHECK_SBINOP (+, ADD, INT_MIN, -1, int, true, INT_MAX); + CHECK_BINOP (+, ADD, UINT_MAX, 1u, unsigned int, true, 0u); + CHECK_BINOP (+, ADD, 0u, 1u, unsigned int, false, 1u); + + CHECK_SBINOP (-, SUBTRACT, INT_MAX, 1, int, false, INT_MAX - 1); + CHECK_SBINOP (-, SUBTRACT, INT_MAX, -1, int, true, INT_MIN); + CHECK_SBINOP (-, SUBTRACT, INT_MIN, 1, int, true, INT_MAX); + CHECK_SBINOP (-, SUBTRACT, INT_MIN, -1, int, false, INT_MIN - -1); + CHECK_BINOP (-, SUBTRACT, UINT_MAX, 1u, unsigned int, false, UINT_MAX - 1u); + CHECK_BINOP (-, SUBTRACT, 0u, 1u, unsigned int, true, 0u - 1u); + + CHECK_UNOP (-, NEGATE, INT_MIN, int, true); + CHECK_UNOP (-, NEGATE, 0, int, false); + CHECK_UNOP (-, NEGATE, INT_MAX, int, false); + CHECK_UNOP (-, NEGATE, 0u, unsigned int, false); + CHECK_UNOP (-, NEGATE, 1u, unsigned int, true); + CHECK_UNOP (-, NEGATE, UINT_MAX, unsigned int, true); + + CHECK_SBINOP (*, MULTIPLY, INT_MAX, INT_MAX, int, true, 1); + CHECK_SBINOP (*, MULTIPLY, INT_MAX, INT_MIN, int, true, INT_MIN); + CHECK_SBINOP (*, MULTIPLY, INT_MIN, INT_MAX, int, true, INT_MIN); + CHECK_SBINOP (*, MULTIPLY, INT_MIN, INT_MIN, int, true, 0); + CHECK_SBINOP (*, MULTIPLY, -1, INT_MIN, int, + INT_NEGATE_OVERFLOW (INT_MIN), INT_MIN); +#if !defined __HP_cc + CHECK_SBINOP (*, MULTIPLY, LONG_MIN / INT_MAX, (long int) INT_MAX, + long int, false, LONG_MIN - LONG_MIN % INT_MAX); +#endif + + CHECK_BINOP (/, DIVIDE, INT_MIN, -1, int, + INT_NEGATE_OVERFLOW (INT_MIN), INT_MIN); + CHECK_BINOP (/, DIVIDE, INT_MAX, 1, int, false, INT_MAX); + CHECK_BINOP (/, DIVIDE, (unsigned int) INT_MIN, -1u, unsigned int, + false, INT_MIN / -1u); + + CHECK_BINOP (%, REMAINDER, INT_MIN, -1, int, INT_NEGATE_OVERFLOW (INT_MIN), 0); + CHECK_BINOP (%, REMAINDER, INT_MAX, 1, int, false, 0); + CHECK_BINOP (%, REMAINDER, (unsigned int) INT_MIN, -1u, unsigned int, + false, INT_MIN % -1u); + + CHECK_BINOP (<<, LEFT_SHIFT, UINT_MAX, 1, unsigned int, true, UINT_MAX << 1); + CHECK_BINOP (<<, LEFT_SHIFT, UINT_MAX / 2 + 1, 1, unsigned int, true, + (UINT_MAX / 2 + 1) << 1); + CHECK_BINOP (<<, LEFT_SHIFT, UINT_MAX / 2, 1, unsigned int, false, + (UINT_MAX / 2) << 1); + + /* INT__OVERFLOW and INT__WRAPV with mixed types. */ + #define CHECK_SUM(a, b, t, v, vres) \ + CHECK_SUM1 (a, b, t, v, vres); \ + CHECK_SUM1 (b, a, t, v, vres) + #define CHECK_SUM_WRAPV(a, b, t, v, vres, okres) \ + CHECK_SUM_WRAPV1 (a, b, t, v, vres, okres); \ + CHECK_SUM_WRAPV1 (b, a, t, v, vres, okres) + #define CHECK_SUM1(a, b, t, v, vres) \ + VERIFY (INT_ADD_OVERFLOW (a, b) == (v)); \ + CHECK_SUM_WRAPV1 (a, b, t, v, vres, (a) + (b)) + #define CHECK_SUM_WRAPV1(a, b, t, v, vres, okres) \ + { \ + t result; \ + ASSERT (INT_ADD_WRAPV (a, b, &result) == (v)); \ + ASSERT (result == ((v) ? (vres) : (okres))); \ + } + CHECK_SUM (-1, LONG_MIN, long int, true, LONG_MAX); + CHECK_SUM (-1, UINT_MAX, unsigned int, false, DONTCARE); + CHECK_SUM (-1L, INT_MIN, long int, INT_MIN == LONG_MIN, + INT_MIN == LONG_MIN ? INT_MAX : DONTCARE); + CHECK_SUM (0u, -1, unsigned int, true, 0u + -1); + CHECK_SUM (0u, 0, unsigned int, false, DONTCARE); + CHECK_SUM (0u, 1, unsigned int, false, DONTCARE); + CHECK_SUM (1, LONG_MAX, long int, true, LONG_MIN); + CHECK_SUM (1, UINT_MAX, unsigned int, true, 0u); + CHECK_SUM (1L, INT_MAX, long int, INT_MAX == LONG_MAX, + INT_MAX == LONG_MAX ? INT_MIN : DONTCARE); + CHECK_SUM (1u, INT_MAX, unsigned int, INT_MAX == UINT_MAX, 1u + INT_MAX); + CHECK_SUM (1u, INT_MIN, unsigned int, true, 1u + INT_MIN); + CHECK_SUM_WRAPV (-1, 1u, int, false, DONTCARE, 0); + CHECK_SUM_WRAPV (-1, 1ul, int, false, DONTCARE, 0); + CHECK_SUM_WRAPV (-1l, 1u, int, false, DONTCARE, 0); + CHECK_SUM_WRAPV (-100, 1000u, int, false, DONTCARE, 900); + CHECK_SUM_WRAPV (INT_MIN, UINT_MAX, int, false, DONTCARE, INT_MAX); + CHECK_SUM_WRAPV (1u, INT_MAX, int, true, INT_MIN, DONTCARE); + CHECK_SUM_WRAPV (INT_MAX, 1, long int, LONG_MAX <= INT_MAX, INT_MIN, + INT_MAX + 1L); + CHECK_SUM_WRAPV (UINT_MAX, 1, long int, LONG_MAX <= UINT_MAX, 0, + UINT_MAX + 1L); + CHECK_SUM_WRAPV (INT_MAX, 1, unsigned long int, ULONG_MAX <= INT_MAX, 0, + INT_MAX + 1uL); + CHECK_SUM_WRAPV (UINT_MAX, 1, unsigned long int, ULONG_MAX <= UINT_MAX, 0, + UINT_MAX + 1uL); + + { + long int result; + ASSERT (INT_ADD_WRAPV (1, INT_MAX, &result) == (INT_MAX == LONG_MAX)); + ASSERT (INT_ADD_WRAPV (-1, INT_MIN, &result) == (INT_MIN == LONG_MIN)); + } + + #define CHECK_DIFFERENCE(a, b, t, v, vres) \ + VERIFY (INT_SUBTRACT_OVERFLOW (a, b) == (v)) + #define CHECK_SDIFFERENCE(a, b, t, v, vres) \ + CHECK_DIFFERENCE (a, b, t, v, vres); \ + CHECK_SDIFFERENCE_WRAPV (a, b, t, v, vres) + #define CHECK_SDIFFERENCE_WRAPV(a, b, t, v, vres) \ + { \ + t result; \ + ASSERT (INT_SUBTRACT_WRAPV (a, b, &result) == (v)); \ + ASSERT (result == ((v) ? (vres) : ((a) - (b)))); \ + } + CHECK_DIFFERENCE (INT_MAX, 1u, unsigned int, UINT_MAX < INT_MAX - 1, + INT_MAX - 1u); + CHECK_DIFFERENCE (UINT_MAX, 1, unsigned int, false, UINT_MAX - 1); + CHECK_DIFFERENCE (0u, -1, unsigned int, false, 0u - -1); + CHECK_DIFFERENCE (UINT_MAX, -1, unsigned int, true, UINT_MAX - -1); + CHECK_DIFFERENCE (INT_MIN, 1u, unsigned int, true, INT_MIN - 1u); + CHECK_DIFFERENCE (-1, 0u, unsigned int, true, -1 - 0u); + CHECK_SDIFFERENCE (-1, INT_MIN, int, false, -1 - INT_MIN); + CHECK_SDIFFERENCE (-1, INT_MAX, int, false, -1 - INT_MAX); + CHECK_SDIFFERENCE (0, INT_MIN, int, INT_MIN < -INT_MAX, INT_MIN); + CHECK_SDIFFERENCE (0, INT_MAX, int, false, 0 - INT_MAX); + CHECK_SDIFFERENCE_WRAPV (-1, 1u, int, false, DONTCARE); + CHECK_SDIFFERENCE_WRAPV (-1, 1ul, int, false, DONTCARE); + CHECK_SDIFFERENCE_WRAPV (-1l, 1u, int, false, DONTCARE); + CHECK_SDIFFERENCE_WRAPV (0u, INT_MAX, int, false, DONTCARE); + CHECK_SDIFFERENCE_WRAPV (1u, INT_MIN, int, true, 1u - INT_MIN); + { + long int result; + ASSERT (INT_SUBTRACT_WRAPV (INT_MAX, -1, &result) == (INT_MAX == LONG_MAX)); + ASSERT (INT_SUBTRACT_WRAPV (INT_MIN, 1, &result) == (INT_MAX == LONG_MAX)); + } + + #define CHECK_PRODUCT(a, b, t, v, vres) \ + CHECK_PRODUCT1 (a, b, t, v, vres); \ + CHECK_PRODUCT1 (b, a, t, v, vres) + #define CHECK_SPRODUCT(a, b, t, v, vres) \ + CHECK_SPRODUCT1 (a, b, t, v, vres); \ + CHECK_SPRODUCT1 (b, a, t, v, vres) + #define CHECK_SPRODUCT_WRAPV(a, b, t, v, vres) \ + CHECK_SPRODUCT_WRAPV1 (a, b, t, v, vres); \ + CHECK_SPRODUCT_WRAPV1 (b, a, t, v, vres) + #define CHECK_PRODUCT1(a, b, t, v, vres) \ + VERIFY (INT_MULTIPLY_OVERFLOW (a, b) == (v)) + #define CHECK_SPRODUCT1(a, b, t, v, vres) \ + CHECK_PRODUCT1 (a, b, t, v, vres); \ + CHECK_SPRODUCT_WRAPV1 (a, b, t, v, vres) + #define CHECK_SPRODUCT_WRAPV1(a, b, t, v, vres) \ + { \ + t result; \ + ASSERT (INT_MULTIPLY_WRAPV (a, b, &result) == (v)); \ + ASSERT (result == ((v) ? (vres) : ((a) * (b)))); \ + } + CHECK_PRODUCT (-1, 1u, unsigned int, true, -1 * 1u); + CHECK_SPRODUCT (-1, INT_MIN, int, INT_NEGATE_OVERFLOW (INT_MIN), INT_MIN); + CHECK_PRODUCT (-1, UINT_MAX, unsigned int, true, -1 * UINT_MAX); + CHECK_SPRODUCT (-32768, LONG_MAX / -32768 - 1, long int, true, LONG_MIN); + CHECK_SPRODUCT (-12345, LONG_MAX / -12345, long int, false, DONTCARE); + CHECK_SPRODUCT (0, -1, int, false, DONTCARE); + CHECK_SPRODUCT (0, 0, int, false, DONTCARE); + CHECK_PRODUCT (0, 0u, unsigned int, false, DONTCARE); + CHECK_SPRODUCT (0, 1, int, false, DONTCARE); + CHECK_SPRODUCT (0, INT_MAX, int, false, DONTCARE); + CHECK_SPRODUCT (0, INT_MIN, int, false, DONTCARE); + CHECK_PRODUCT (0, UINT_MAX, unsigned int, false, DONTCARE); + CHECK_PRODUCT (0u, -1, unsigned int, false, DONTCARE); + CHECK_PRODUCT (0u, 0, unsigned int, false, DONTCARE); + CHECK_PRODUCT (0u, 0u, unsigned int, false, DONTCARE); + CHECK_PRODUCT (0u, 1, unsigned int, false, DONTCARE); + CHECK_PRODUCT (0u, INT_MAX, unsigned int, false, DONTCARE); + CHECK_PRODUCT (0u, INT_MIN, unsigned int, false, DONTCARE); + CHECK_PRODUCT (0u, UINT_MAX, unsigned int, false, DONTCARE); + CHECK_SPRODUCT (1, INT_MAX, int, false, DONTCARE); + CHECK_SPRODUCT (1, INT_MIN, int, false, DONTCARE); + CHECK_PRODUCT (1, UINT_MAX, unsigned int, false, DONTCARE); + CHECK_PRODUCT (1u, INT_MIN, unsigned int, true, 1u * INT_MIN); + CHECK_PRODUCT (1u, INT_MAX, unsigned int, UINT_MAX < INT_MAX, 1u * INT_MAX); + CHECK_PRODUCT (INT_MAX, UINT_MAX, unsigned int, true, INT_MAX * UINT_MAX); + CHECK_PRODUCT (INT_MAX, ULONG_MAX, unsigned long int, true, + INT_MAX * ULONG_MAX); +#if !defined __HP_cc + CHECK_SPRODUCT (INT_MIN, LONG_MAX / INT_MIN - 1, long int, true, LONG_MIN); + CHECK_SPRODUCT (INT_MIN, LONG_MAX / INT_MIN, long int, false, DONTCARE); +#endif + CHECK_PRODUCT (INT_MIN, UINT_MAX, unsigned int, true, INT_MIN * UINT_MAX); + CHECK_PRODUCT (INT_MIN, ULONG_MAX, unsigned long int, true, + INT_MIN * ULONG_MAX); + CHECK_SPRODUCT_WRAPV (-1, INT_MAX + 1u, int, false, DONTCARE); + CHECK_SPRODUCT_WRAPV (-1, 1u, int, false, DONTCARE); + CHECK_SPRODUCT (0, ULONG_MAX, int, false, DONTCARE); + CHECK_SPRODUCT (0u, LONG_MIN, int, false, DONTCARE); + { + long int result; + ASSERT (INT_MULTIPLY_WRAPV (INT_MAX, INT_MAX, &result) + == (LONG_MAX / INT_MAX < INT_MAX)); + ASSERT (INT_MULTIPLY_WRAPV (INT_MAX, INT_MAX, &result) + || result == INT_MAX * (long int) INT_MAX); + ASSERT (INT_MULTIPLY_WRAPV (INT_MIN, INT_MIN, &result) + || result == INT_MIN * (long int) INT_MIN); + } + +# ifdef LLONG_MAX + { + long long int result; + ASSERT (INT_MULTIPLY_WRAPV (LONG_MAX, LONG_MAX, &result) + == (LLONG_MAX / LONG_MAX < LONG_MAX)); + ASSERT (INT_MULTIPLY_WRAPV (LONG_MAX, LONG_MAX, &result) + || result == LONG_MAX * (long long int) LONG_MAX); + ASSERT (INT_MULTIPLY_WRAPV (LONG_MIN, LONG_MIN, &result) + || result == LONG_MIN * (long long int) LONG_MIN); + } +# endif + + /* Check for GCC bug 91450. */ + { + unsigned long long result; + ASSERT (INT_MULTIPLY_WRAPV (int_minus_2, int_1, &result) && result == -2); + } + + #define CHECK_QUOTIENT(a, b, v) VERIFY (INT_DIVIDE_OVERFLOW (a, b) == (v)) + + CHECK_QUOTIENT (INT_MIN, -1L, INT_MIN == LONG_MIN); + CHECK_QUOTIENT (INT_MIN, UINT_MAX, false); + CHECK_QUOTIENT (INTMAX_MIN, UINTMAX_MAX, false); + CHECK_QUOTIENT (INTMAX_MIN, UINT_MAX, false); + CHECK_QUOTIENT (-11, 10u, true); + CHECK_QUOTIENT (-10, 10u, true); + CHECK_QUOTIENT (-9, 10u, false); + CHECK_QUOTIENT (11u, -10, true); + CHECK_QUOTIENT (10u, -10, true); + CHECK_QUOTIENT (9u, -10, false); + + #define CHECK_REMAINDER(a, b, v) VERIFY (INT_REMAINDER_OVERFLOW (a, b) == (v)) + + CHECK_REMAINDER (INT_MIN, -1L, INT_MIN == LONG_MIN); + CHECK_REMAINDER (-1, UINT_MAX, true); + CHECK_REMAINDER ((intmax_t) -1, UINTMAX_MAX, true); + CHECK_REMAINDER (INTMAX_MIN, UINT_MAX, + (INTMAX_MAX < UINT_MAX + && - (unsigned int) INTMAX_MIN % UINT_MAX != 0)); + CHECK_REMAINDER (INT_MIN, ULONG_MAX, INT_MIN % ULONG_MAX != 1); + CHECK_REMAINDER (1u, -1, false); + CHECK_REMAINDER (37*39u, -39, false); + CHECK_REMAINDER (37*39u + 1, -39, true); + CHECK_REMAINDER (37*39u - 1, -39, true); + CHECK_REMAINDER (LONG_MAX, -INT_MAX, false); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-inttostr.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-inttostr.c new file mode 100644 index 00000000..be7b5d45 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-inttostr.c @@ -0,0 +1,94 @@ +/* Test inttostr functions, and incidentally, INT_BUFSIZE_BOUND + Copyright (C) 2010-2024 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 . */ + +/* Written by Jim Meyering. */ + +#include + +#include "inttostr.h" +#include "intprops.h" +#include +#include +#include +#include + +#include "macros.h" + +#define STREQ(a, b) (strcmp (a, b) == 0) +#define IS_TIGHT(T) (_GL_SIGNED_TYPE_OR_EXPR (T) == TYPE_SIGNED (T)) +#define ISDIGIT(c) ((unsigned int) (c) - '0' <= 9) + +/* Verify that an inttostr function works as advertised. + Convert maximum and minimum (per-type, T) values using both snprintf -- + with a cast to intmax_t or uintmax_t -- and FN, and compare the + resulting strings. Use malloc for the inttostr buffer, so that if + we ever exceed the usually-tight INT_BUFSIZE_BOUND, tools like + valgrind will detect the failure. */ +#define CK(T, Fn) \ + do \ + { \ + char ref[100]; \ + char *buf = malloc (INT_BUFSIZE_BOUND (T)); \ + char const *p; \ + ASSERT (buf); \ + *buf = '\0'; \ + ASSERT \ + ((TYPE_SIGNED (T) \ + ? snprintf (ref, sizeof ref, "%jd", (intmax_t) TYPE_MINIMUM (T)) \ + : snprintf (ref, sizeof ref, "%ju", (uintmax_t) TYPE_MINIMUM (T))) \ + < sizeof ref); \ + ASSERT (STREQ ((p = Fn (TYPE_MINIMUM (T), buf)), ref)); \ + /* Ensure that INT_BUFSIZE_BOUND is tight for signed types. */ \ + ASSERT (! TYPE_SIGNED (T) || (p == buf && *p == '-')); \ + ASSERT \ + ((TYPE_SIGNED (T) \ + ? snprintf (ref, sizeof ref, "%jd", (intmax_t) TYPE_MAXIMUM (T)) \ + : snprintf (ref, sizeof ref, "%ju", (uintmax_t) TYPE_MAXIMUM (T))) \ + < sizeof ref); \ + ASSERT (STREQ ((p = Fn (TYPE_MAXIMUM (T), buf)), ref)); \ + /* For unsigned types, the bound is not always tight. */ \ + ASSERT (! IS_TIGHT (T) || TYPE_SIGNED (T) \ + || (p == buf && ISDIGIT (*p))); \ + free (buf); \ + } \ + while (0) + +int +main (void) +{ + size_t b_size = 2; + char *b = malloc (b_size); + ASSERT (b); + + /* Ideally we would rely on the snprintf-posix module, in which case + this guard would not be required, but due to limitations in gnulib's + implementation (see modules/snprintf-posix), we cannot. */ + if (snprintf (b, b_size, "%ju", (uintmax_t) 3) == 1 + && b[0] == '3' && b[1] == '\0') + { + CK (int, inttostr); + CK (unsigned int, uinttostr); + CK (off_t, offtostr); + CK (uintmax_t, umaxtostr); + CK (intmax_t, imaxtostr); + free (b); + return 0; + } + + /* snprintf doesn't accept %ju; skip this test. */ + free (b); + return 77; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-inttypes.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-inttypes.c new file mode 100644 index 00000000..036ca510 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-inttypes.c @@ -0,0 +1,116 @@ +/* Test of substitute. + Copyright (C) 2006-2007, 2009-2024 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 . */ + +/* Written by Bruno Haible , 2007. */ + +#include + +#include + +/* Tests for macros supposed to be defined in inttypes.h. */ + +const char *k = /* implicit string concatenation */ +#ifdef INT8_MAX + PRId8 PRIi8 +#endif +#ifdef UINT8_MAX + PRIo8 PRIu8 PRIx8 PRIX8 +#endif +#ifdef INT16_MAX + PRId16 PRIi16 +#endif +#ifdef UINT16_MAX + PRIo16 PRIu16 PRIx16 PRIX16 +#endif +#ifdef INT32_MAX + PRId32 PRIi32 +#endif +#ifdef UINT32_MAX + PRIo32 PRIu32 PRIx32 PRIX32 +#endif +#ifdef INT64_MAX + PRId64 PRIi64 +#endif +#ifdef UINT64_MAX + PRIo64 PRIu64 PRIx64 PRIX64 +#endif + PRIdLEAST8 PRIiLEAST8 PRIoLEAST8 PRIuLEAST8 PRIxLEAST8 PRIXLEAST8 + PRIdLEAST16 PRIiLEAST16 PRIoLEAST16 PRIuLEAST16 PRIxLEAST16 PRIXLEAST16 + PRIdLEAST32 PRIiLEAST32 PRIoLEAST32 PRIuLEAST32 PRIxLEAST32 PRIXLEAST32 + PRIdLEAST64 PRIiLEAST64 + PRIoLEAST64 PRIuLEAST64 PRIxLEAST64 PRIXLEAST64 + PRIdFAST8 PRIiFAST8 PRIoFAST8 PRIuFAST8 PRIxFAST8 PRIXFAST8 + PRIdFAST16 PRIiFAST16 PRIoFAST16 PRIuFAST16 PRIxFAST16 PRIXFAST16 + PRIdFAST32 PRIiFAST32 PRIoFAST32 PRIuFAST32 PRIxFAST32 PRIXFAST32 + PRIdFAST64 PRIiFAST64 + PRIoFAST64 PRIuFAST64 PRIxFAST64 PRIXFAST64 + PRIdMAX PRIiMAX PRIoMAX PRIuMAX PRIxMAX PRIXMAX +#ifdef INTPTR_MAX + PRIdPTR PRIiPTR +#endif +#ifdef UINTPTR_MAX + PRIoPTR PRIuPTR PRIxPTR PRIXPTR +#endif + ; +const char *l = /* implicit string concatenation */ +#ifdef INT8_MAX + SCNd8 SCNi8 +#endif +#ifdef UINT8_MAX + SCNo8 SCNu8 SCNx8 +#endif +#ifdef INT16_MAX + SCNd16 SCNi16 +#endif +#ifdef UINT16_MAX + SCNo16 SCNu16 SCNx16 +#endif +#ifdef INT32_MAX + SCNd32 SCNi32 +#endif +#ifdef UINT32_MAX + SCNo32 SCNu32 SCNx32 +#endif +#ifdef INT64_MAX + SCNd64 SCNi64 +#endif +#ifdef UINT64_MAX + SCNo64 SCNu64 SCNx64 +#endif + SCNdLEAST8 SCNiLEAST8 SCNoLEAST8 SCNuLEAST8 SCNxLEAST8 + SCNdLEAST16 SCNiLEAST16 SCNoLEAST16 SCNuLEAST16 SCNxLEAST16 + SCNdLEAST32 SCNiLEAST32 SCNoLEAST32 SCNuLEAST32 SCNxLEAST32 + SCNdLEAST64 SCNiLEAST64 + SCNoLEAST64 SCNuLEAST64 SCNxLEAST64 + SCNdFAST8 SCNiFAST8 SCNoFAST8 SCNuFAST8 SCNxFAST8 + SCNdFAST16 SCNiFAST16 SCNoFAST16 SCNuFAST16 SCNxFAST16 + SCNdFAST32 SCNiFAST32 SCNoFAST32 SCNuFAST32 SCNxFAST32 + SCNdFAST64 SCNiFAST64 + SCNoFAST64 SCNuFAST64 SCNxFAST64 + SCNdMAX SCNiMAX SCNoMAX SCNuMAX SCNxMAX +#ifdef INTPTR_MAX + SCNdPTR SCNiPTR +#endif +#ifdef UINTPTR_MAX + SCNoPTR SCNuPTR SCNxPTR +#endif + ; + +int +main (void) +{ + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-ioctl.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-ioctl.c new file mode 100644 index 00000000..1fef85b4 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-ioctl.c @@ -0,0 +1,51 @@ +/* Test of ioctl() function. + Copyright (C) 2011-2024 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 . */ + +#include + +/* Specification. */ +#include + +#include "signature.h" +SIGNATURE_CHECK (ioctl, int, (int, int, ...)); + +#include +#include + +#include "macros.h" + +int +main (void) +{ +#ifdef FIONREAD + /* Test behaviour for invalid file descriptors. */ + { + int value; + errno = 0; + ASSERT (ioctl (-1, FIONREAD, &value) == -1); + ASSERT (errno == EBADF); + } + { + int value; + close (99); + errno = 0; + ASSERT (ioctl (99, FIONREAD, &value) == -1); + ASSERT (errno == EBADF); + } +#endif + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-isblank.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-isblank.c new file mode 100644 index 00000000..8e13bae1 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-isblank.c @@ -0,0 +1,50 @@ +/* Test of isblank() function. + Copyright (C) 2009-2024 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 . */ + +/* Written by Bruno Haible , 2009. */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (isblank, int, (int)); + +#include +#include + +#include "macros.h" + +int +main () +{ + unsigned int c; + + /* Verify the property in the "C" locale. + POSIX specifies in + + that + - in all locales, the blank characters include the and + characters, + - in the "POSIX" locale (which is usually the same as the "C" locale), + the blank characters include only the ASCII and + characters. */ + for (c = 0; c <= UCHAR_MAX; c++) + ASSERT (!isblank (c) == !(c == ' ' || c == '\t')); + ASSERT (!isblank (EOF)); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-isnand-nolibm.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-isnand-nolibm.c new file mode 100644 index 00000000..7b251aa9 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-isnand-nolibm.c @@ -0,0 +1,21 @@ +/* Test of isnand() substitute. + Copyright (C) 2007-2024 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 . */ + +#include + +#include "isnand-nolibm.h" + +#include "test-isnand.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-isnand.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-isnand.h new file mode 100644 index 00000000..5369e336 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-isnand.h @@ -0,0 +1,49 @@ +/* Test of isnand() substitute. + Copyright (C) 2007-2024 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 . */ + +/* Written by Bruno Haible , 2007. */ + +#include + +#include "minus-zero.h" +#include "infinity.h" +#include "nan.h" +#include "snan.h" +#include "macros.h" + +int +main () +{ + /* Finite values. */ + ASSERT (!isnand (3.141)); + ASSERT (!isnand (3.141e30)); + ASSERT (!isnand (3.141e-30)); + ASSERT (!isnand (-2.718)); + ASSERT (!isnand (-2.718e30)); + ASSERT (!isnand (-2.718e-30)); + ASSERT (!isnand (0.0)); + ASSERT (!isnand (minus_zerod)); + /* Infinite values. */ + ASSERT (!isnand (Infinityd ())); + ASSERT (!isnand (- Infinityd ())); + /* Quiet NaN. */ + ASSERT (isnand (NaNd ())); +#if HAVE_SNAND + /* Signalling NaN. */ + ASSERT (isnand (SNaNd ())); +#endif + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-isnanf-nolibm.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-isnanf-nolibm.c new file mode 100644 index 00000000..bd39f06f --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-isnanf-nolibm.c @@ -0,0 +1,21 @@ +/* Test of isnanf() substitute. + Copyright (C) 2007-2024 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 . */ + +#include + +#include "isnanf-nolibm.h" + +#include "test-isnanf.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-isnanf.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-isnanf.h new file mode 100644 index 00000000..6f138016 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-isnanf.h @@ -0,0 +1,49 @@ +/* Test of isnanf() substitute. + Copyright (C) 2007-2024 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 . */ + +/* Written by Bruno Haible , 2007. */ + +#include + +#include "minus-zero.h" +#include "infinity.h" +#include "nan.h" +#include "snan.h" +#include "macros.h" + +int +main () +{ + /* Finite values. */ + ASSERT (!isnanf (3.141f)); + ASSERT (!isnanf (3.141e30f)); + ASSERT (!isnanf (3.141e-30f)); + ASSERT (!isnanf (-2.718f)); + ASSERT (!isnanf (-2.718e30f)); + ASSERT (!isnanf (-2.718e-30f)); + ASSERT (!isnanf (0.0f)); + ASSERT (!isnanf (minus_zerof)); + /* Infinite values. */ + ASSERT (!isnanf (Infinityf ())); + ASSERT (!isnanf (- Infinityf ())); + /* Quiet NaN. */ + ASSERT (isnanf (NaNf ())); +#if HAVE_SNANF + /* Signalling NaN. */ + ASSERT (isnanf (SNaNf ())); +#endif + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-isnanl-nolibm.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-isnanl-nolibm.c new file mode 100644 index 00000000..caed43e0 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-isnanl-nolibm.c @@ -0,0 +1,23 @@ +/* Test of isnanl() substitute. + Copyright (C) 2007, 2009-2024 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 . */ + +/* Written by Bruno Haible , 2007. */ + +#include + +#include "isnanl-nolibm.h" + +#include "test-isnanl.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-isnanl.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-isnanl.h new file mode 100644 index 00000000..ff42ee54 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-isnanl.h @@ -0,0 +1,104 @@ +/* Test of isnanl() substitute. + Copyright (C) 2007-2024 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 . */ + +/* Written by Bruno Haible , 2007. */ + +#include +#include + +#include "minus-zero.h" +#include "infinity.h" +#include "nan.h" +#include "snan.h" +#include "macros.h" + +int +main () +{ + /* Finite values. */ + ASSERT (!isnanl (3.141L)); + ASSERT (!isnanl (3.141e30L)); + ASSERT (!isnanl (3.141e-30L)); + ASSERT (!isnanl (-2.718L)); + ASSERT (!isnanl (-2.718e30L)); + ASSERT (!isnanl (-2.718e-30L)); + ASSERT (!isnanl (0.0L)); + ASSERT (!isnanl (minus_zerol)); + /* Infinite values. */ + ASSERT (!isnanl (Infinityl ())); + ASSERT (!isnanl (- Infinityl ())); + /* Quiet NaN. */ + ASSERT (isnanl (NaNl ())); +#if HAVE_SNANL + /* Signalling NaN. */ + ASSERT (isnanl (SNaNl ())); +#endif + +#if ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_)) && !HAVE_SAME_LONG_DOUBLE_AS_DOUBLE +/* Representation of an 80-bit 'long double' as an initializer for a sequence + of 'unsigned int' words. */ +# ifdef WORDS_BIGENDIAN +# define LDBL80_WORDS(exponent,manthi,mantlo) \ + { ((unsigned int) (exponent) << 16) | ((unsigned int) (manthi) >> 16), \ + ((unsigned int) (manthi) << 16) | ((unsigned int) (mantlo) >> 16), \ + (unsigned int) (mantlo) << 16 \ + } +# else +# define LDBL80_WORDS(exponent,manthi,mantlo) \ + { mantlo, manthi, exponent } +# endif + { /* Quiet NaN. */ + static memory_long_double x = + { .word = LDBL80_WORDS (0xFFFF, 0xC3333333, 0x00000000) }; + ASSERT (isnanl (x.value)); + } + { + /* Signalling NaN. */ + static memory_long_double x = + { .word = LDBL80_WORDS (0xFFFF, 0x83333333, 0x00000000) }; + ASSERT (isnanl (x.value)); + } + /* isnanl should return something for noncanonical values. */ + { /* Pseudo-NaN. */ + static memory_long_double x = + { .word = LDBL80_WORDS (0xFFFF, 0x40000001, 0x00000000) }; + ASSERT (isnanl (x.value) || !isnanl (x.value)); + } + { /* Pseudo-Infinity. */ + static memory_long_double x = + { .word = LDBL80_WORDS (0xFFFF, 0x00000000, 0x00000000) }; + ASSERT (isnanl (x.value) || !isnanl (x.value)); + } + { /* Pseudo-Zero. */ + static memory_long_double x = + { .word = LDBL80_WORDS (0x4004, 0x00000000, 0x00000000) }; + ASSERT (isnanl (x.value) || !isnanl (x.value)); + } + { /* Unnormalized number. */ + static memory_long_double x = + { .word = LDBL80_WORDS (0x4000, 0x63333333, 0x00000000) }; + ASSERT (isnanl (x.value) || !isnanl (x.value)); + } + { /* Pseudo-Denormal. */ + static memory_long_double x = + { .word = LDBL80_WORDS (0x0000, 0x83333333, 0x00000000) }; + ASSERT (isnanl (x.value) || !isnanl (x.value)); + } + #undef NWORDS +#endif + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-iswblank.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-iswblank.c new file mode 100644 index 00000000..e5925179 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-iswblank.c @@ -0,0 +1,40 @@ +/* Test of iswblank() function. + Copyright (C) 2007-2024 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 . */ + +#include + +#include + +#include "macros.h" + +/* Check that WEOF is defined. */ +wint_t e = WEOF; + +int +main (void) +{ + /* Check that the function exist as a function or as a macro. */ + (void) iswblank (0); + /* Check that the isw* functions map WEOF to 0. */ + ASSERT (!iswblank (e)); + + /* Sanity check for the iswblank function. */ + ASSERT (iswblank (L' ')); + ASSERT (iswblank (L'\t')); + ASSERT (!iswblank (L'\n')); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-iswctype.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-iswctype.c new file mode 100644 index 00000000..e882bdbc --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-iswctype.c @@ -0,0 +1,198 @@ +/* Test of wide character properties. + Copyright (C) 2023-2024 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 . */ + +/* Written by Bruno Haible , 2023. */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (iswctype, int, (wint_t, wctype_t)); + +#include "macros.h" + +int +main (int argc, char *argv[]) +{ + wctype_t desc; + + desc = wctype ("any"); + ASSERT (desc == (wctype_t) 0); + + desc = wctype ("blank"); + ASSERT (desc != (wctype_t) 0); + ASSERT (iswctype (L' ', desc)); + ASSERT (iswctype (L'\t', desc)); + ASSERT (! iswctype (L'\n', desc)); + ASSERT (! iswctype (L'a', desc)); + ASSERT (! iswctype (L'_', desc)); + ASSERT (! iswctype (WEOF, desc)); + + desc = wctype ("space"); + ASSERT (desc != (wctype_t) 0); + ASSERT (iswctype (L' ', desc)); + ASSERT (iswctype (L'\t', desc)); + ASSERT (iswctype (L'\n', desc)); + ASSERT (! iswctype (L'a', desc)); + ASSERT (! iswctype (L'_', desc)); + ASSERT (! iswctype (WEOF, desc)); + + desc = wctype ("punct"); + ASSERT (desc != (wctype_t) 0); + ASSERT (iswctype (L'!', desc)); + ASSERT (iswctype (L'"', desc)); + ASSERT (iswctype (L'#', desc)); + ASSERT (iswctype (L'$', desc)); + ASSERT (iswctype (L'%', desc)); + ASSERT (iswctype (L'&', desc)); + ASSERT (iswctype (L'\'', desc)); + ASSERT (iswctype (L'(', desc)); + ASSERT (iswctype (L')', desc)); + ASSERT (iswctype (L'*', desc)); + ASSERT (iswctype (L'+', desc)); + ASSERT (iswctype (L',', desc)); + ASSERT (iswctype (L'-', desc)); + ASSERT (iswctype (L'.', desc)); + ASSERT (iswctype (L'/', desc)); + ASSERT (iswctype (L':', desc)); + ASSERT (iswctype (L';', desc)); + ASSERT (iswctype (L'<', desc)); + ASSERT (iswctype (L'=', desc)); + ASSERT (iswctype (L'>', desc)); + ASSERT (iswctype (L'?', desc)); + ASSERT (iswctype (L'@', desc)); + ASSERT (iswctype (L'[', desc)); + ASSERT (iswctype (L'\\', desc)); + ASSERT (iswctype (L']', desc)); + ASSERT (iswctype (L'^', desc)); + ASSERT (iswctype (L'_', desc)); + ASSERT (iswctype (L'`', desc)); + ASSERT (iswctype (L'{', desc)); + ASSERT (iswctype (L'|', desc)); + ASSERT (iswctype (L'}', desc)); + ASSERT (iswctype (L'~', desc)); + ASSERT (! iswctype (L' ', desc)); + ASSERT (! iswctype (L'a', desc)); + ASSERT (! iswctype (L'1', desc)); + ASSERT (! iswctype (WEOF, desc)); + + desc = wctype ("lower"); + ASSERT (desc != (wctype_t) 0); + ASSERT (iswctype (L'a', desc)); + ASSERT (iswctype (L'z', desc)); + ASSERT (! iswctype (L'A', desc)); + ASSERT (! iswctype (L'Z', desc)); + ASSERT (! iswctype (L'1', desc)); + ASSERT (! iswctype (L'_', desc)); + ASSERT (! iswctype (WEOF, desc)); + + desc = wctype ("upper"); + ASSERT (desc != (wctype_t) 0); + ASSERT (iswctype (L'A', desc)); + ASSERT (iswctype (L'Z', desc)); + ASSERT (! iswctype (L'a', desc)); + ASSERT (! iswctype (L'z', desc)); + ASSERT (! iswctype (L'1', desc)); + ASSERT (! iswctype (L'_', desc)); + ASSERT (! iswctype (WEOF, desc)); + + desc = wctype ("alpha"); + ASSERT (desc != (wctype_t) 0); + ASSERT (iswctype (L'a', desc)); + ASSERT (iswctype (L'z', desc)); + ASSERT (iswctype (L'A', desc)); + ASSERT (iswctype (L'Z', desc)); + ASSERT (! iswctype (L'1', desc)); + ASSERT (! iswctype (L'$', desc)); + ASSERT (! iswctype (WEOF, desc)); + + desc = wctype ("digit"); + ASSERT (desc != (wctype_t) 0); + ASSERT (iswctype (L'0', desc)); + ASSERT (iswctype (L'9', desc)); + ASSERT (! iswctype (L'a', desc)); + ASSERT (! iswctype (L'f', desc)); + ASSERT (! iswctype (L'A', desc)); + ASSERT (! iswctype (L'F', desc)); + ASSERT (! iswctype (WEOF, desc)); + + desc = wctype ("xdigit"); + ASSERT (desc != (wctype_t) 0); + ASSERT (iswctype (L'0', desc)); + ASSERT (iswctype (L'9', desc)); + ASSERT (iswctype (L'a', desc)); + ASSERT (iswctype (L'f', desc)); + ASSERT (iswctype (L'A', desc)); + ASSERT (iswctype (L'F', desc)); + ASSERT (! iswctype (L'g', desc)); + ASSERT (! iswctype (L'G', desc)); + ASSERT (! iswctype (WEOF, desc)); + + desc = wctype ("alnum"); + ASSERT (desc != (wctype_t) 0); + ASSERT (iswctype (L'a', desc)); + ASSERT (iswctype (L'z', desc)); + ASSERT (iswctype (L'A', desc)); + ASSERT (iswctype (L'Z', desc)); + ASSERT (iswctype (L'0', desc)); + ASSERT (iswctype (L'9', desc)); + ASSERT (! iswctype (L' ', desc)); + ASSERT (! iswctype (L'_', desc)); + ASSERT (! iswctype (WEOF, desc)); + + desc = wctype ("cntrl"); + ASSERT (desc != (wctype_t) 0); + ASSERT (iswctype (L'\0', desc)); + ASSERT (iswctype (L'\n', desc)); + ASSERT (iswctype (L'\t', desc)); + ASSERT (! iswctype (L' ', desc)); + ASSERT (! iswctype (L'a', desc)); + ASSERT (! iswctype (L'\\', desc)); + ASSERT (! iswctype (WEOF, desc)); + + desc = wctype ("graph"); + ASSERT (desc != (wctype_t) 0); + ASSERT (iswctype (L'a', desc)); + ASSERT (iswctype (L'z', desc)); + ASSERT (iswctype (L'A', desc)); + ASSERT (iswctype (L'Z', desc)); + ASSERT (iswctype (L'0', desc)); + ASSERT (iswctype (L'9', desc)); + ASSERT (iswctype (L'$', desc)); + ASSERT (! iswctype (L' ', desc)); + ASSERT (! iswctype (L'\t', desc)); + ASSERT (! iswctype (L'\n', desc)); + ASSERT (! iswctype (L'\0', desc)); + ASSERT (! iswctype (WEOF, desc)); + + desc = wctype ("print"); + ASSERT (desc != (wctype_t) 0); + ASSERT (iswctype (L'a', desc)); + ASSERT (iswctype (L'z', desc)); + ASSERT (iswctype (L'A', desc)); + ASSERT (iswctype (L'Z', desc)); + ASSERT (iswctype (L'0', desc)); + ASSERT (iswctype (L'9', desc)); + ASSERT (iswctype (L'$', desc)); + ASSERT (iswctype (L' ', desc)); + ASSERT (! iswctype (L'\t', desc)); + ASSERT (! iswctype (L'\n', desc)); + ASSERT (! iswctype (L'\0', desc)); + ASSERT (! iswctype (WEOF, desc)); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-iswdigit.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-iswdigit.c new file mode 100644 index 00000000..a5bcc4ff --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-iswdigit.c @@ -0,0 +1,233 @@ +/* Test of iswdigit() function. + Copyright (C) 2020-2024 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 . */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (iswdigit, int, (wint_t)); + +#include +#include +#include +#include + +#include "macros.h" + +/* Returns the value of iswdigit for the multibyte character s[0..n-1]. */ +static int +for_character (const char *s, size_t n) +{ + mbstate_t state; + wchar_t wc; + size_t ret; + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, s, n, &state); + if (ret == n) + return iswdigit (wc); + else + return 0; +} + +int +main (int argc, char *argv[]) +{ + int is; + char buf[4]; + + /* configure should already have checked that the locale is supported. */ + if (setlocale (LC_ALL, "") == NULL) + return 1; + + /* Test WEOF. */ + is = iswdigit (WEOF); + ASSERT (is == 0); + + /* Test single-byte characters. + ISO C 99 sections 7.25.2.1.5 and 5.2.1 specify that the decimal digits + include only the ASCII 0 ... 9 characters. */ + { + int c; + + for (c = 0; c < 0x100; c++) + switch (c) + { + case '\t': case '\v': case '\f': + case ' ': case '!': case '"': case '#': case '%': + case '&': case '\'': case '(': case ')': case '*': + case '+': case ',': case '-': case '.': case '/': + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + case ':': case ';': case '<': case '=': case '>': + case '?': + case 'A': case 'B': case 'C': case 'D': case 'E': + case 'F': case 'G': case 'H': case 'I': case 'J': + case 'K': case 'L': case 'M': case 'N': case 'O': + case 'P': case 'Q': case 'R': case 'S': case 'T': + case 'U': case 'V': case 'W': case 'X': case 'Y': + case 'Z': + case '[': case '\\': case ']': case '^': case '_': + case 'a': case 'b': case 'c': case 'd': case 'e': + case 'f': case 'g': case 'h': case 'i': case 'j': + case 'k': case 'l': case 'm': case 'n': case 'o': + case 'p': case 'q': case 'r': case 's': case 't': + case 'u': case 'v': case 'w': case 'x': case 'y': + case 'z': case '{': case '|': case '}': case '~': + /* c is in the ISO C "basic character set". */ + buf[0] = (unsigned char) c; + is = for_character (buf, 1); + switch (c) + { + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + ASSERT (is != 0); + break; + default: + ASSERT (is == 0); + break; + } + break; + } + } + + if (argc > 1) + switch (argv[1][0]) + { + case '0': + /* C locale; tested above. */ + return 0; + + case '1': + /* Locale encoding is ISO-8859-1 or ISO-8859-15. */ + { + /* U+00B2 SUPERSCRIPT TWO */ + is = for_character ("\262", 1); + ASSERT (is == 0); + /* U+00B3 SUPERSCRIPT THREE */ + is = for_character ("\263", 1); + ASSERT (is == 0); + /* U+00B9 SUPERSCRIPT ONE */ + is = for_character ("\271", 1); + ASSERT (is == 0); + } + return 0; + + case '2': + /* Locale encoding is EUC-JP. */ + { + /* U+FF11 FULLWIDTH DIGIT ONE */ + is = for_character ("\243\261", 2); + ASSERT (is == 0); + } + return 0; + + case '3': + /* Locale encoding is UTF-8. */ + { + /* U+00B2 SUPERSCRIPT TWO */ + is = for_character ("\302\262", 2); + ASSERT (is == 0); + /* U+00B3 SUPERSCRIPT THREE */ + is = for_character ("\302\263", 2); + ASSERT (is == 0); + /* U+00B9 SUPERSCRIPT ONE */ + is = for_character ("\302\271", 2); + ASSERT (is == 0); + /* U+0663 ARABIC-INDIC DIGIT THREE */ + is = for_character ("\331\243", 2); + ASSERT (is == 0); + /* U+2070 SUPERSCRIPT ZERO */ + is = for_character ("\342\201\260", 3); + ASSERT (is == 0); + /* U+2079 SUPERSCRIPT NINE */ + is = for_character ("\342\201\271", 3); + ASSERT (is == 0); + /* U+FF11 FULLWIDTH DIGIT ONE */ + is = for_character ("\357\274\221", 3); + ASSERT (is == 0); + /* U+1D7D1 MATHEMATICAL BOLD DIGIT THREE */ + is = for_character ("\360\235\237\221", 4); + ASSERT (is == 0); + /* U+1D7DB MATHEMATICAL DOUBLE-STRUCK DIGIT THREE */ + is = for_character ("\360\235\237\233", 4); + ASSERT (is == 0); + /* U+1D7E5 MATHEMATICAL SANS-SERIF DIGIT THREE */ + is = for_character ("\360\235\237\245", 4); + ASSERT (is == 0); + /* U+1D7EF MATHEMATICAL SANS-SERIF BOLD DIGIT THREE */ + is = for_character ("\360\235\237\257", 4); + ASSERT (is == 0); + /* U+1D7F9 MATHEMATICAL MONOSPACE DIGIT THREE */ + is = for_character ("\360\235\237\271", 4); + ASSERT (is == 0); + /* U+E0033 TAG DIGIT THREE */ + is = for_character ("\363\240\200\263", 4); + ASSERT (is == 0); + } + return 0; + + case '4': + /* Locale encoding is GB18030. */ + { + /* U+00B2 SUPERSCRIPT TWO */ + is = for_character ("\201\060\205\065", 4); + ASSERT (is == 0); + /* U+00B3 SUPERSCRIPT THREE */ + is = for_character ("\201\060\205\066", 4); + ASSERT (is == 0); + /* U+00B9 SUPERSCRIPT ONE */ + is = for_character ("\201\060\206\061", 4); + ASSERT (is == 0); + /* U+0663 ARABIC-INDIC DIGIT THREE */ + is = for_character ("\201\061\211\071", 4); + ASSERT (is == 0); + /* U+2070 SUPERSCRIPT ZERO */ + is = for_character ("\201\066\255\062", 4); + ASSERT (is == 0); + /* U+2079 SUPERSCRIPT NINE */ + is = for_character ("\201\066\256\061", 4); + ASSERT (is == 0); + /* U+FF11 FULLWIDTH DIGIT ONE */ + is = for_character ("\243\261", 2); + ASSERT (is == 0); + /* U+1D7D1 MATHEMATICAL BOLD DIGIT THREE */ + is = for_character ("\224\063\353\071", 4); + ASSERT (is == 0); + /* U+1D7DB MATHEMATICAL DOUBLE-STRUCK DIGIT THREE */ + is = for_character ("\224\063\354\071", 4); + ASSERT (is == 0); + /* U+1D7E5 MATHEMATICAL SANS-SERIF DIGIT THREE */ + is = for_character ("\224\063\355\071", 4); + ASSERT (is == 0); + /* U+1D7EF MATHEMATICAL SANS-SERIF BOLD DIGIT THREE */ + is = for_character ("\224\063\356\071", 4); + ASSERT (is == 0); + /* U+1D7F9 MATHEMATICAL MONOSPACE DIGIT THREE */ + is = for_character ("\224\063\357\071", 4); + ASSERT (is == 0); + /* U+E0033 TAG DIGIT THREE */ + is = for_character ("\323\066\232\071", 4); + ASSERT (is == 0); + } + return 0; + + } + + return 1; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-iswdigit.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-iswdigit.sh new file mode 100755 index 00000000..142a224f --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-iswdigit.sh @@ -0,0 +1,39 @@ +#!/bin/sh + +# Test in the POSIX locale. +LC_ALL=C ${CHECKER} ./test-iswdigit${EXEEXT} 0 || exit 1 +LC_ALL=POSIX ${CHECKER} ./test-iswdigit${EXEEXT} 0 || exit 1 + +# Test in an ISO-8859-1 or ISO-8859-15 locale. +: "${LOCALE_FR=fr_FR}" +if test $LOCALE_FR != none; then + LC_ALL=$LOCALE_FR \ + ${CHECKER} ./test-iswdigit${EXEEXT} 1 \ + || exit 1 +fi + +# Test whether a specific EUC-JP locale is installed. +: "${LOCALE_JA=ja_JP}" +if test $LOCALE_JA != none; then + LC_ALL=$LOCALE_JA \ + ${CHECKER} ./test-iswdigit${EXEEXT} 2 \ + || exit 1 +fi + +# Test whether a specific UTF-8 locale is installed. +: "${LOCALE_FR_UTF8=fr_FR.UTF-8}" +if test $LOCALE_FR_UTF8 != none; then + LC_ALL=$LOCALE_FR_UTF8 \ + ${CHECKER} ./test-iswdigit${EXEEXT} 3 \ + || exit 1 +fi + +# Test whether a specific GB18030 locale is installed. +: "${LOCALE_ZH_CN=zh_CN.GB18030}" +if test $LOCALE_ZH_CN != none; then + LC_ALL=$LOCALE_ZH_CN \ + ${CHECKER} ./test-iswdigit${EXEEXT} 4 \ + || exit 1 +fi + +exit 0 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-iswpunct.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-iswpunct.c new file mode 100644 index 00000000..c0bbd168 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-iswpunct.c @@ -0,0 +1,153 @@ +/* Test of iswpunct() function. + Copyright (C) 2020-2024 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 . */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (iswpunct, int, (wint_t)); + +#include +#include +#include +#include + +#include "macros.h" + +/* Returns the value of iswpunct for the multibyte character s[0..n-1]. */ +static int +for_character (const char *s, size_t n) +{ + mbstate_t state; + wchar_t wc; + size_t ret; + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, s, n, &state); + if (ret == n) + return iswpunct (wc); + else + return 0; +} + +int +main (int argc, char *argv[]) +{ + int is; + char buf[4]; + + /* configure should already have checked that the locale is supported. */ + if (setlocale (LC_ALL, "") == NULL) + return 1; + + /* Test WEOF. */ + is = iswpunct (WEOF); + ASSERT (is == 0); + + /* Test single-byte characters. + POSIX specifies in + + no explicit list of punctuation or symbol characters. */ + { + int c; + + for (c = 0; c < 0x100; c++) + switch (c) + { + case '\t': case '\v': case '\f': + case ' ': case '!': case '"': case '#': case '%': + case '&': case '\'': case '(': case ')': case '*': + case '+': case ',': case '-': case '.': case '/': + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + case ':': case ';': case '<': case '=': case '>': + case '?': + case 'A': case 'B': case 'C': case 'D': case 'E': + case 'F': case 'G': case 'H': case 'I': case 'J': + case 'K': case 'L': case 'M': case 'N': case 'O': + case 'P': case 'Q': case 'R': case 'S': case 'T': + case 'U': case 'V': case 'W': case 'X': case 'Y': + case 'Z': + case '[': case '\\': case ']': case '^': case '_': + case 'a': case 'b': case 'c': case 'd': case 'e': + case 'f': case 'g': case 'h': case 'i': case 'j': + case 'k': case 'l': case 'm': case 'n': case 'o': + case 'p': case 'q': case 'r': case 's': case 't': + case 'u': case 'v': case 'w': case 'x': case 'y': + case 'z': case '{': case '|': case '}': case '~': + /* c is in the ISO C "basic character set". */ + buf[0] = (unsigned char) c; + is = for_character (buf, 1); + switch (c) + { + case ' ': + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + case 'A': case 'B': case 'C': case 'D': case 'E': + case 'F': case 'G': case 'H': case 'I': case 'J': + case 'K': case 'L': case 'M': case 'N': case 'O': + case 'P': case 'Q': case 'R': case 'S': case 'T': + case 'U': case 'V': case 'W': case 'X': case 'Y': + case 'Z': + case 'a': case 'b': case 'c': case 'd': case 'e': + case 'f': case 'g': case 'h': case 'i': case 'j': + case 'k': case 'l': case 'm': case 'n': case 'o': + case 'p': case 'q': case 'r': case 's': case 't': + case 'u': case 'v': case 'w': case 'x': case 'y': + case 'z': + /* c is an alphanumeric or space character. */ + ASSERT (is == 0); + break; + case '!': case '"': case '#': case '%': + case '&': case '\'': case '(': case ')': case '*': + case '+': case ',': case '-': case '.': case '/': + case ':': case ';': case '<': case '=': case '>': + case '?': + case '[': case '\\': case ']': case '^': case '_': + case '{': case '|': case '}': case '~': + /* These characters are usually expected to be punctuation or + symbol characters. */ + ASSERT (is != 0); + break; + default: + ASSERT (is == 0); + break; + } + break; + } + } + + if (argc > 1) + switch (argv[1][0]) + { + case '0': + /* C locale; tested above. */ + /* These characters are not in the ISO C "basic character set", but + are nevertheless usually expected to be punctuation or symbol + characters. */ + is = for_character ("$", 1); + ASSERT (is != 0); + is = for_character ("@", 1); + ASSERT (is != 0); + is = for_character ("`", 1); + ASSERT (is != 0); + return 0; + } + + return 1; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-iswpunct.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-iswpunct.sh new file mode 100755 index 00000000..366e1859 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-iswpunct.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +# Test in the POSIX locale. +LC_ALL=C ${CHECKER} ./test-iswpunct${EXEEXT} 0 || exit 1 +LC_ALL=POSIX ${CHECKER} ./test-iswpunct${EXEEXT} 0 || exit 1 + +exit 0 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-iswxdigit.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-iswxdigit.c new file mode 100644 index 00000000..f4aeb493 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-iswxdigit.c @@ -0,0 +1,259 @@ +/* Test of iswxdigit() function. + Copyright (C) 2020-2024 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 . */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (iswxdigit, int, (wint_t)); + +#include +#include +#include +#include + +#include "macros.h" + +/* Returns the value of iswxdigit for the multibyte character s[0..n-1]. */ +static int +for_character (const char *s, size_t n) +{ + mbstate_t state; + wchar_t wc; + size_t ret; + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, s, n, &state); + if (ret == n) + return iswxdigit (wc); + else + return 0; +} + +int +main (int argc, char *argv[]) +{ + int is; + char buf[4]; + + /* configure should already have checked that the locale is supported. */ + if (setlocale (LC_ALL, "") == NULL) + return 1; + + /* Test WEOF. */ + is = iswxdigit (WEOF); + ASSERT (is == 0); + + /* Test single-byte characters. + ISO C 99 sections 7.25.2.1.12 and 6.4.4.1 specify that the hexadecimal + digits include only the ASCII 0 ... 9 A ... F a ... f characters. */ + { + int c; + + for (c = 0; c < 0x100; c++) + switch (c) + { + case '\t': case '\v': case '\f': + case ' ': case '!': case '"': case '#': case '%': + case '&': case '\'': case '(': case ')': case '*': + case '+': case ',': case '-': case '.': case '/': + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + case ':': case ';': case '<': case '=': case '>': + case '?': + case 'A': case 'B': case 'C': case 'D': case 'E': + case 'F': case 'G': case 'H': case 'I': case 'J': + case 'K': case 'L': case 'M': case 'N': case 'O': + case 'P': case 'Q': case 'R': case 'S': case 'T': + case 'U': case 'V': case 'W': case 'X': case 'Y': + case 'Z': + case '[': case '\\': case ']': case '^': case '_': + case 'a': case 'b': case 'c': case 'd': case 'e': + case 'f': case 'g': case 'h': case 'i': case 'j': + case 'k': case 'l': case 'm': case 'n': case 'o': + case 'p': case 'q': case 'r': case 's': case 't': + case 'u': case 'v': case 'w': case 'x': case 'y': + case 'z': case '{': case '|': case '}': case '~': + /* c is in the ISO C "basic character set". */ + buf[0] = (unsigned char) c; + is = for_character (buf, 1); + switch (c) + { + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': + case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': + ASSERT (is != 0); + break; + default: + ASSERT (is == 0); + break; + } + break; + } + } + + if (argc > 1) + switch (argv[1][0]) + { + case '0': + /* C locale; tested above. */ + return 0; + + case '1': + /* Locale encoding is ISO-8859-1 or ISO-8859-15. */ + { + /* U+00B2 SUPERSCRIPT TWO */ + is = for_character ("\262", 1); + ASSERT (is == 0); + /* U+00B3 SUPERSCRIPT THREE */ + is = for_character ("\263", 1); + ASSERT (is == 0); + /* U+00B9 SUPERSCRIPT ONE */ + is = for_character ("\271", 1); + ASSERT (is == 0); + } + return 0; + + case '2': + /* Locale encoding is EUC-JP. */ + { + /* U+FF11 FULLWIDTH DIGIT ONE */ + is = for_character ("\243\261", 2); + ASSERT (is == 0); + /* U+FF21 FULLWIDTH LATIN CAPITAL LETTER A */ + is = for_character ("\243\301", 2); + ASSERT (is == 0); + /* U+FF41 FULLWIDTH LATIN SMALL LETTER A */ + is = for_character ("\243\341", 2); + ASSERT (is == 0); + } + return 0; + + case '3': + /* Locale encoding is UTF-8. */ + { + /* U+00B2 SUPERSCRIPT TWO */ + is = for_character ("\302\262", 2); + ASSERT (is == 0); + /* U+00B3 SUPERSCRIPT THREE */ + is = for_character ("\302\263", 2); + ASSERT (is == 0); + /* U+00B9 SUPERSCRIPT ONE */ + is = for_character ("\302\271", 2); + ASSERT (is == 0); + /* U+0663 ARABIC-INDIC DIGIT THREE */ + is = for_character ("\331\243", 2); + ASSERT (is == 0); + /* U+2070 SUPERSCRIPT ZERO */ + is = for_character ("\342\201\260", 3); + ASSERT (is == 0); + /* U+2079 SUPERSCRIPT NINE */ + is = for_character ("\342\201\271", 3); + ASSERT (is == 0); + /* U+FF11 FULLWIDTH DIGIT ONE */ + is = for_character ("\357\274\221", 3); + ASSERT (is == 0); + /* U+FF21 FULLWIDTH LATIN CAPITAL LETTER A */ + is = for_character ("\357\274\241", 3); + ASSERT (is == 0); + /* U+FF41 FULLWIDTH LATIN SMALL LETTER A */ + is = for_character ("\357\275\201", 3); + ASSERT (is == 0); + /* U+1D7D1 MATHEMATICAL BOLD DIGIT THREE */ + is = for_character ("\360\235\237\221", 4); + ASSERT (is == 0); + /* U+1D7DB MATHEMATICAL DOUBLE-STRUCK DIGIT THREE */ + is = for_character ("\360\235\237\233", 4); + ASSERT (is == 0); + /* U+1D7E5 MATHEMATICAL SANS-SERIF DIGIT THREE */ + is = for_character ("\360\235\237\245", 4); + ASSERT (is == 0); + /* U+1D7EF MATHEMATICAL SANS-SERIF BOLD DIGIT THREE */ + is = for_character ("\360\235\237\257", 4); + ASSERT (is == 0); + /* U+1D7F9 MATHEMATICAL MONOSPACE DIGIT THREE */ + is = for_character ("\360\235\237\271", 4); + ASSERT (is == 0); + /* U+E0033 TAG DIGIT THREE */ + is = for_character ("\363\240\200\263", 4); + ASSERT (is == 0); + /* U+E0041 TAG LATIN CAPITAL LETTER A */ + is = for_character ("\363\240\201\201", 4); + ASSERT (is == 0); + } + return 0; + + case '4': + /* Locale encoding is GB18030. */ + { + /* U+00B2 SUPERSCRIPT TWO */ + is = for_character ("\201\060\205\065", 4); + ASSERT (is == 0); + /* U+00B3 SUPERSCRIPT THREE */ + is = for_character ("\201\060\205\066", 4); + ASSERT (is == 0); + /* U+00B9 SUPERSCRIPT ONE */ + is = for_character ("\201\060\206\061", 4); + ASSERT (is == 0); + /* U+0663 ARABIC-INDIC DIGIT THREE */ + is = for_character ("\201\061\211\071", 4); + ASSERT (is == 0); + /* U+2070 SUPERSCRIPT ZERO */ + is = for_character ("\201\066\255\062", 4); + ASSERT (is == 0); + /* U+2079 SUPERSCRIPT NINE */ + is = for_character ("\201\066\256\061", 4); + ASSERT (is == 0); + /* U+FF11 FULLWIDTH DIGIT ONE */ + is = for_character ("\243\261", 2); + ASSERT (is == 0); + /* U+FF21 FULLWIDTH LATIN CAPITAL LETTER A */ + is = for_character ("\243\301", 2); + ASSERT (is == 0); + /* U+FF41 FULLWIDTH LATIN SMALL LETTER A */ + is = for_character ("\243\341", 2); + ASSERT (is == 0); + /* U+1D7D1 MATHEMATICAL BOLD DIGIT THREE */ + is = for_character ("\224\063\353\071", 4); + ASSERT (is == 0); + /* U+1D7DB MATHEMATICAL DOUBLE-STRUCK DIGIT THREE */ + is = for_character ("\224\063\354\071", 4); + ASSERT (is == 0); + /* U+1D7E5 MATHEMATICAL SANS-SERIF DIGIT THREE */ + is = for_character ("\224\063\355\071", 4); + ASSERT (is == 0); + /* U+1D7EF MATHEMATICAL SANS-SERIF BOLD DIGIT THREE */ + is = for_character ("\224\063\356\071", 4); + ASSERT (is == 0); + /* U+1D7F9 MATHEMATICAL MONOSPACE DIGIT THREE */ + is = for_character ("\224\063\357\071", 4); + ASSERT (is == 0); + /* U+E0033 TAG DIGIT THREE */ + is = for_character ("\323\066\232\071", 4); + ASSERT (is == 0); + /* U+E0041 TAG LATIN CAPITAL LETTER A */ + is = for_character ("\323\066\234\063", 4); + ASSERT (is == 0); + } + return 0; + + } + + return 1; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-iswxdigit.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-iswxdigit.sh new file mode 100755 index 00000000..9bdaff4a --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-iswxdigit.sh @@ -0,0 +1,39 @@ +#!/bin/sh + +# Test in the POSIX locale. +LC_ALL=C ${CHECKER} ./test-iswxdigit${EXEEXT} 0 || exit 1 +LC_ALL=POSIX ${CHECKER} ./test-iswxdigit${EXEEXT} 0 || exit 1 + +# Test in an ISO-8859-1 or ISO-8859-15 locale. +: "${LOCALE_FR=fr_FR}" +if test $LOCALE_FR != none; then + LC_ALL=$LOCALE_FR \ + ${CHECKER} ./test-iswxdigit${EXEEXT} 1 \ + || exit 1 +fi + +# Test whether a specific EUC-JP locale is installed. +: "${LOCALE_JA=ja_JP}" +if test $LOCALE_JA != none; then + LC_ALL=$LOCALE_JA \ + ${CHECKER} ./test-iswxdigit${EXEEXT} 2 \ + || exit 1 +fi + +# Test whether a specific UTF-8 locale is installed. +: "${LOCALE_FR_UTF8=fr_FR.UTF-8}" +if test $LOCALE_FR_UTF8 != none; then + LC_ALL=$LOCALE_FR_UTF8 \ + ${CHECKER} ./test-iswxdigit${EXEEXT} 3 \ + || exit 1 +fi + +# Test whether a specific GB18030 locale is installed. +: "${LOCALE_ZH_CN=zh_CN.GB18030}" +if test $LOCALE_ZH_CN != none; then + LC_ALL=$LOCALE_ZH_CN \ + ${CHECKER} ./test-iswxdigit${EXEEXT} 4 \ + || exit 1 +fi + +exit 0 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-langinfo.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-langinfo.c new file mode 100644 index 00000000..9561793b --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-langinfo.c @@ -0,0 +1,92 @@ +/* Test of substitute. + Copyright (C) 2009-2024 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 . */ + +/* Written by Bruno Haible , 2009. */ + +#include + +#include + +/* Check that all the nl_item values are defined. */ +int items[] = + { + /* nl_langinfo items of the LC_CTYPE category */ + CODESET, + /* nl_langinfo items of the LC_NUMERIC category */ + RADIXCHAR, + THOUSEP, + /* nl_langinfo items of the LC_TIME category */ + D_T_FMT, + D_FMT, + T_FMT, + T_FMT_AMPM, + AM_STR, + PM_STR, + DAY_1, + DAY_2, + DAY_3, + DAY_4, + DAY_5, + DAY_6, + DAY_7, + ABDAY_1, + ABDAY_2, + ABDAY_3, + ABDAY_4, + ABDAY_5, + ABDAY_6, + ABDAY_7, + MON_1, + MON_2, + MON_3, + MON_4, + MON_5, + MON_6, + MON_7, + MON_8, + MON_9, + MON_10, + MON_11, + MON_12, + ABMON_1, + ABMON_2, + ABMON_3, + ABMON_4, + ABMON_5, + ABMON_6, + ABMON_7, + ABMON_8, + ABMON_9, + ABMON_10, + ABMON_11, + ABMON_12, + ERA, + ERA_D_FMT, + ERA_D_T_FMT, + ERA_T_FMT, + ALT_DIGITS, + /* nl_langinfo items of the LC_MONETARY category */ + CRNCYSTR, + /* nl_langinfo items of the LC_MESSAGES category */ + YESEXPR, + NOEXPR + }; + +int +main (void) +{ + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-largefile.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-largefile.c new file mode 100644 index 00000000..d2d6a157 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-largefile.c @@ -0,0 +1,51 @@ +/* Test of largefile module. + Copyright (C) 2023-2024 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 . */ + +/* Written by Bruno Haible , 2023. */ + +/* This test may fail if AC_SYS_LARGEFILE could not arrange for a 64-bit off_t. + This should be rare, though: only very old systems don't have support for + files larger than 2 GiB. */ + +#include + +#include +#include +#include "intprops.h" + +/* Although these tests could be done with static_assert, the test + harness prefers dynamic checking. */ + +int +main (void) +{ + int result = 0; + + /* Check the range of off_t. + With MSVC, this test succeeds only thanks to the 'sys_types' module. */ + if (TYPE_MAXIMUM (off_t) >> 31 >> 31 == 0) + result |= 1; + + /* Check the size of the 'struct stat' field 'st_size'. + With MSVC, this test succeeds only thanks to the 'sys_stat' module. */ + { + struct stat st; + if (sizeof st.st_size != sizeof (off_t)) + result |= 2; + } + + return result; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-limits-h.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-limits-h.c new file mode 100644 index 00000000..6f574c88 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-limits-h.c @@ -0,0 +1,133 @@ +/* Test of substitute. + Copyright 2016-2024 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 . */ + +/* Written by Paul Eggert. */ + +#include + +#include + +#if 4 < __GNUC__ + (3 <= __GNUC_MINOR__) +# pragma GCC diagnostic ignored "-Woverlength-strings" +#endif + +#define verify_width(width, min, max) \ + static_assert ((max) >> ((width) - 1 - ((min) < 0)) == 1) + +/* Macros borrowed from intprops.h. */ +#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1)) +#define TYPE_WIDTH(t) (sizeof (t) * CHAR_BIT) +#define TYPE_MINIMUM(t) ((t) ~ TYPE_MAXIMUM (t)) +#define TYPE_MAXIMUM(t) \ + ((t) (! TYPE_SIGNED (t) \ + ? (t) -1 \ + : ((((t) 1 << (TYPE_WIDTH (t) - 2)) - 1) * 2 + 1))) + +/* Type width macros. */ + +int type_bits[] = + { + CHAR_BIT, + WORD_BIT, + LONG_BIT + }; +verify_width (CHAR_BIT, CHAR_MIN, CHAR_MAX); +verify_width (WORD_BIT, INT_MIN, INT_MAX); +verify_width (LONG_BIT, LONG_MIN, LONG_MAX); + +/* Numerical limit macros. */ + +char limits1[] = { CHAR_MIN, CHAR_MAX }; +static_assert (TYPE_MINIMUM (char) == CHAR_MIN); +static_assert (TYPE_MAXIMUM (char) == CHAR_MAX); + +signed char limits2[] = { SCHAR_MIN, SCHAR_MAX }; +static_assert (TYPE_MINIMUM (signed char) == SCHAR_MIN); +static_assert (TYPE_MAXIMUM (signed char) == SCHAR_MAX); + +unsigned char limits3[] = { UCHAR_MAX }; +static_assert (TYPE_MINIMUM (unsigned char) == 0); +static_assert (TYPE_MAXIMUM (unsigned char) == UCHAR_MAX); + +short limits4[] = { SHRT_MIN, SHRT_MAX }; +static_assert (TYPE_MINIMUM (short int) == SHRT_MIN); +static_assert (TYPE_MAXIMUM (short int) == SHRT_MAX); + +unsigned short limits5[] = { USHRT_MAX }; +static_assert (TYPE_MINIMUM (unsigned short int) == 0); +static_assert (TYPE_MAXIMUM (unsigned short int) == USHRT_MAX); + +int limits6[] = { INT_MIN, INT_MAX }; +static_assert (TYPE_MINIMUM (int) == INT_MIN); +static_assert (TYPE_MAXIMUM (int) == INT_MAX); + +unsigned int limits7[] = { UINT_MAX }; +static_assert (TYPE_MINIMUM (unsigned int) == 0); +static_assert (TYPE_MAXIMUM (unsigned int) == UINT_MAX); + +long limits8[] = { LONG_MIN, LONG_MAX }; +static_assert (TYPE_MINIMUM (long int) == LONG_MIN); +static_assert (TYPE_MAXIMUM (long int) == LONG_MAX); + +unsigned long limits9[] = { ULONG_MAX }; +static_assert (TYPE_MINIMUM (unsigned long int) == 0); +static_assert (TYPE_MAXIMUM (unsigned long int) == ULONG_MAX); + +long long limits10[] = { LLONG_MIN, LLONG_MAX }; +static_assert (TYPE_MINIMUM (long long int) == LLONG_MIN); +static_assert (TYPE_MAXIMUM (long long int) == LLONG_MAX); + +unsigned long long limits11[] = { ULLONG_MAX }; +static_assert (TYPE_MINIMUM (unsigned long long int) == 0); +static_assert (TYPE_MAXIMUM (unsigned long long int) == ULLONG_MAX); + +/* Specified by POSIX, not by ISO C. */ + +long long limits12[] = { SSIZE_MAX }; + +/* Macros specified by C23 and by ISO/IEC TS 18661-1:2014. */ + +verify_width (CHAR_WIDTH, CHAR_MIN, CHAR_MAX); +verify_width (SCHAR_WIDTH, SCHAR_MIN, SCHAR_MAX); +verify_width (UCHAR_WIDTH, 0, UCHAR_MAX); +verify_width (SHRT_WIDTH, SHRT_MIN, SHRT_MAX); +verify_width (USHRT_WIDTH, 0, USHRT_MAX); +verify_width (INT_WIDTH, INT_MIN, INT_MAX); +verify_width (UINT_WIDTH, 0, UINT_MAX); +verify_width (LONG_WIDTH, LONG_MIN, LONG_MAX); +verify_width (ULONG_WIDTH, 0, ULONG_MAX); +verify_width (LLONG_WIDTH, LLONG_MIN, LLONG_MAX); +verify_width (ULLONG_WIDTH, 0, ULLONG_MAX); + +/* Macros specified by C23. */ + +int bool_attrs[] = { BOOL_MAX, BOOL_WIDTH }; +static_assert (BOOL_MAX == 1); + +static_assert (0 < MB_LEN_MAX); + +/* Get ssize_t, size_t. */ +#include + +static_assert (TYPE_MAXIMUM (ssize_t) == SSIZE_MAX); +/* Verify that ssize_t has the same width as size_t. */ +static_assert (TYPE_MAXIMUM (size_t) / 2 == SSIZE_MAX); + +int +main (void) +{ + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-listen.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-listen.c new file mode 100644 index 00000000..21fc7a2b --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-listen.c @@ -0,0 +1,54 @@ +/* Test listen() function. + Copyright (C) 2011-2024 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 . */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (listen, int, (int, int)); + +#include +#include + +#include "sockets.h" +#include "macros.h" + +/* Tell GCC not to warn about the specific edge cases tested here. */ +#if __GNUC__ >= 13 +# pragma GCC diagnostic ignored "-Wanalyzer-fd-use-without-check" +#endif + +int +main (void) +{ + (void) gl_sockets_startup (SOCKETS_1_1); + + /* Test behaviour for invalid file descriptors. */ + { + errno = 0; + ASSERT (listen (-1, 1) == -1); + ASSERT (errno == EBADF); + } + { + close (99); + errno = 0; + ASSERT (listen (99 ,1) == -1); + ASSERT (errno == EBADF); + } + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-localcharset.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-localcharset.c new file mode 100644 index 00000000..da6cbf6d --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-localcharset.c @@ -0,0 +1,39 @@ +/* Manual test of localcharset() function. + Copyright (C) 2018-2024 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 . */ + +/* This program prints the result of locale_charset in the current locale. + One way to use it is: + $ for l in `locale -a`; do + echo -n "$l "; LANG=$l ./test-localcharset; + done \ + | sort -k 2 + */ + +#include + +#include "localcharset.h" + +#include +#include + +int +main (void) +{ + setlocale (LC_ALL, ""); + printf ("%s\n", locale_charset ()); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-locale.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-locale.c new file mode 100644 index 00000000..e4e61aad --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-locale.c @@ -0,0 +1,78 @@ +/* Test of substitute. + Copyright (C) 2007, 2009-2024 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 . */ + +/* Written by Bruno Haible , 2007. */ + +#include + +#include + +int a[] = + { + LC_ALL, + LC_COLLATE, + LC_CTYPE, + LC_MESSAGES, + LC_MONETARY, + LC_NUMERIC, + LC_TIME + }; + +/* Check that the 'struct lconv' type is defined. */ +struct lconv l; +int ls; + +/* Check that NULL can be passed through varargs as a pointer type, + per POSIX 2008. */ +static_assert (sizeof NULL == sizeof (void *)); + +int +main () +{ +#if HAVE_WORKING_NEWLOCALE + /* Check that the locale_t type and the LC_GLOBAL_LOCALE macro are defined. */ + locale_t b = LC_GLOBAL_LOCALE; + (void) b; +#endif + + /* Check that 'struct lconv' has the ISO C and POSIX specified members. */ + ls += sizeof (*l.decimal_point); + ls += sizeof (*l.thousands_sep); + ls += sizeof (*l.grouping); + ls += sizeof (*l.mon_decimal_point); + ls += sizeof (*l.mon_thousands_sep); + ls += sizeof (*l.mon_grouping); + ls += sizeof (*l.positive_sign); + ls += sizeof (*l.negative_sign); + ls += sizeof (*l.currency_symbol); + ls += sizeof (l.frac_digits); + ls += sizeof (l.p_cs_precedes); + ls += sizeof (l.p_sign_posn); + ls += sizeof (l.p_sep_by_space); + ls += sizeof (l.n_cs_precedes); + ls += sizeof (l.n_sign_posn); + ls += sizeof (l.n_sep_by_space); + ls += sizeof (*l.int_curr_symbol); + ls += sizeof (l.int_frac_digits); + ls += sizeof (l.int_p_cs_precedes); + ls += sizeof (l.int_p_sign_posn); + ls += sizeof (l.int_p_sep_by_space); + ls += sizeof (l.int_n_cs_precedes); + ls += sizeof (l.int_n_sign_posn); + ls += sizeof (l.int_n_sep_by_space); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-localeconv.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-localeconv.c new file mode 100644 index 00000000..a4f0ecd8 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-localeconv.c @@ -0,0 +1,72 @@ +/* Test of localeconv() function. + Copyright (C) 2012-2024 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 . */ + +/* Written by Bruno Haible , 2012. */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (localeconv, struct lconv *, (void)); + +#include +#include + +#include "macros.h" + +int +main () +{ + /* Test localeconv() result in the "C" locale. */ + { + struct lconv *l = localeconv (); + + ASSERT (STREQ (l->decimal_point, ".")); + ASSERT (STREQ (l->thousands_sep, "")); +#if !((defined __FreeBSD__ || defined __DragonFly__) || defined __sun || defined __CYGWIN__) + ASSERT (STREQ (l->grouping, "")); +#endif + + ASSERT (STREQ (l->mon_decimal_point, "")); + ASSERT (STREQ (l->mon_thousands_sep, "")); +#if !((defined __FreeBSD__ || defined __DragonFly__) || defined __sun || defined __CYGWIN__) + ASSERT (STREQ (l->mon_grouping, "")); +#endif + ASSERT (STREQ (l->positive_sign, "")); + ASSERT (STREQ (l->negative_sign, "")); + + ASSERT (STREQ (l->currency_symbol, "")); + ASSERT (l->frac_digits == CHAR_MAX); + ASSERT (l->p_cs_precedes == CHAR_MAX); + ASSERT (l->p_sign_posn == CHAR_MAX); + ASSERT (l->p_sep_by_space == CHAR_MAX); + ASSERT (l->n_cs_precedes == CHAR_MAX); + ASSERT (l->n_sign_posn == CHAR_MAX); + ASSERT (l->n_sep_by_space == CHAR_MAX); + + ASSERT (STREQ (l->int_curr_symbol, "")); + ASSERT (l->int_frac_digits == CHAR_MAX); + ASSERT (l->int_p_cs_precedes == CHAR_MAX); + ASSERT (l->int_p_sign_posn == CHAR_MAX); + ASSERT (l->int_p_sep_by_space == CHAR_MAX); + ASSERT (l->int_n_cs_precedes == CHAR_MAX); + ASSERT (l->int_n_sign_posn == CHAR_MAX); + ASSERT (l->int_n_sep_by_space == CHAR_MAX); + } + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-lstat.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-lstat.c new file mode 100644 index 00000000..3a2d61ec --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-lstat.c @@ -0,0 +1,59 @@ +/* Test of lstat() function. + Copyright (C) 2008-2024 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 . */ + +/* Written by Simon Josefsson, 2008; and Eric Blake, 2009. */ + +#include + +#include + +/* Caution: lstat may be a function-like macro. Although this + signature check must pass, it may be the signature of the real (and + broken) lstat rather than rpl_lstat. Most code should not use the + address of lstat. */ +#include "signature.h" +SIGNATURE_CHECK (lstat, int, (char const *, struct stat *)); + +#include +#include +#include +#include +#include + +#include "same-inode.h" +#include "ignore-value.h" +#include "macros.h" + +#define BASE "test-lstat.t" + +#include "test-lstat.h" + +/* Wrapper around lstat, which works even if lstat is a function-like + macro, where test_lstat_func(lstat) would do the wrong thing. */ +static int +do_lstat (char const *name, struct stat *st) +{ + return lstat (name, st); +} + +int +main (void) +{ + /* Remove any leftovers from a previous partial run. */ + ignore_value (system ("rm -rf " BASE "*")); + + return test_lstat_func (do_lstat, true); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-lstat.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-lstat.h new file mode 100644 index 00000000..31476132 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-lstat.h @@ -0,0 +1,122 @@ +/* Test of lstat() function. + Copyright (C) 2008-2024 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 . */ + +/* Written by Simon Josefsson, 2008; and Eric Blake, 2009. */ + +/* This file is designed to test both lstat(n,buf) and + fstatat(AT_FDCWD,n,buf,AT_SYMLINK_NOFOLLOW). FUNC is the function + to test. Assumes that BASE and ASSERT are already defined, and + that appropriate headers are already included. If PRINT, warn + before skipping symlink tests with status 77. */ + +static int +test_lstat_func (int (*func) (char const *, struct stat *), bool print) +{ + struct stat st1; + struct stat st2; + + /* Test for common directories. */ + ASSERT (func (".", &st1) == 0); + ASSERT (func ("./", &st2) == 0); +#if !(defined _WIN32 && !defined __CYGWIN__ && !_GL_WINDOWS_STAT_INODES) + ASSERT (psame_inode (&st1, &st2)); +#endif + ASSERT (S_ISDIR (st1.st_mode)); + ASSERT (S_ISDIR (st2.st_mode)); + ASSERT (func ("/", &st1) == 0); + ASSERT (func ("///", &st2) == 0); +#if !(defined _WIN32 && !defined __CYGWIN__ && !_GL_WINDOWS_STAT_INODES) + ASSERT (psame_inode (&st1, &st2)); +#endif + ASSERT (S_ISDIR (st1.st_mode)); + ASSERT (S_ISDIR (st2.st_mode)); + ASSERT (func ("..", &st1) == 0); + ASSERT (S_ISDIR (st1.st_mode)); + + /* Test for error conditions. */ + errno = 0; + ASSERT (func ("", &st1) == -1); + ASSERT (errno == ENOENT); + errno = 0; + ASSERT (func ("nosuch", &st1) == -1); + ASSERT (errno == ENOENT); + errno = 0; + ASSERT (func ("nosuch/", &st1) == -1); + ASSERT (errno == ENOENT); + + ASSERT (close (creat (BASE "file", 0600)) == 0); + ASSERT (func (BASE "file", &st1) == 0); + ASSERT (S_ISREG (st1.st_mode)); + errno = 0; + ASSERT (func (BASE "file/", &st1) == -1); + ASSERT (errno == ENOTDIR); + + /* Now for some symlink tests, where supported. We set up: + link1 -> directory + link2 -> file + link3 -> dangling + link4 -> loop + then test behavior both with and without trailing slash. + */ + if (symlink (".", BASE "link1") != 0) + { + ASSERT (unlink (BASE "file") == 0); + if (print) + fputs ("skipping test: symlinks not supported on this file system\n", + stderr); + return 77; + } + ASSERT (symlink (BASE "file", BASE "link2") == 0); + ASSERT (symlink (BASE "nosuch", BASE "link3") == 0); + ASSERT (symlink (BASE "link4", BASE "link4") == 0); + + ASSERT (func (BASE "link1", &st1) == 0); + ASSERT (S_ISLNK (st1.st_mode)); + ASSERT (func (BASE "link1/", &st1) == 0); + ASSERT (stat (BASE "link1", &st2) == 0); + ASSERT (S_ISDIR (st1.st_mode)); + ASSERT (S_ISDIR (st2.st_mode)); +#if !(defined _WIN32 && !defined __CYGWIN__ && !_GL_WINDOWS_STAT_INODES) + ASSERT (psame_inode (&st1, &st2)); +#endif + + ASSERT (func (BASE "link2", &st1) == 0); + ASSERT (S_ISLNK (st1.st_mode)); + errno = 0; + ASSERT (func (BASE "link2/", &st1) == -1); + ASSERT (errno == ENOTDIR); + + ASSERT (func (BASE "link3", &st1) == 0); + ASSERT (S_ISLNK (st1.st_mode)); + errno = 0; + ASSERT (func (BASE "link3/", &st1) == -1); + ASSERT (errno == ENOENT); + + ASSERT (func (BASE "link4", &st1) == 0); + ASSERT (S_ISLNK (st1.st_mode)); + errno = 0; + ASSERT (func (BASE "link4/", &st1) == -1); + ASSERT (errno == ELOOP); + + /* Cleanup. */ + ASSERT (unlink (BASE "file") == 0); + ASSERT (unlink (BASE "link1") == 0); + ASSERT (unlink (BASE "link2") == 0); + ASSERT (unlink (BASE "link3") == 0); + ASSERT (unlink (BASE "link4") == 0); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-malloc-gnu.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-malloc-gnu.c new file mode 100644 index 00000000..490efb01 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-malloc-gnu.c @@ -0,0 +1,45 @@ +/* Test of malloc function. + Copyright (C) 2010-2024 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 . */ + +#include + +/* Specification. */ +#include + +#include +#include + +#include "macros.h" + +int +main (int argc, _GL_UNUSED char **argv) +{ + /* Check that malloc (0) is not a NULL pointer. */ + void *volatile p = malloc (0); + ASSERT (p != NULL); + free (p); + + /* Check that malloc (n) fails when n exceeds PTRDIFF_MAX. */ + if (PTRDIFF_MAX < SIZE_MAX) + { + size_t one = argc != 12345; + p = malloc (PTRDIFF_MAX + one); + ASSERT (p == NULL); + ASSERT (errno == ENOMEM); + } + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-malloca.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-malloca.c new file mode 100644 index 00000000..9d46cd42 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-malloca.c @@ -0,0 +1,62 @@ +/* Test of safe automatic memory allocation. + Copyright (C) 2005, 2007, 2009-2024 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 . */ + +/* Written by Bruno Haible , 2005. */ + +#include + +#include "malloca.h" + +#include + +static void +do_allocation (int n) +{ + void *volatile ptr = malloca (n); + freea (ptr); + safe_alloca (n); +} + +void (*func) (int) = do_allocation; + +int +main () +{ + int i; + + /* This slows down malloc a lot. */ + unsetenv ("MALLOC_PERTURB_"); + + /* Repeat a lot of times, to make sure there's no memory leak. */ + for (i = 0; i < 50000; i++) + { + /* Try various values. + n = 0 gave a crash on Alpha with gcc-2.5.8. + Some versions of Mac OS X have a stack size limit of 512 KB. */ + func (34); + func (134); + func (399); + func (510823); + func (129321); + func (0); + func (4070); + func (4095); + func (1); + func (16582); + } + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-math.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-math.c new file mode 100644 index 00000000..d853f2a8 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-math.c @@ -0,0 +1,104 @@ +/* Test of substitute. + Copyright (C) 2007-2024 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 . */ + +/* Written by Bruno Haible , 2007. */ + +#include + +#include + +#ifndef NAN +# error NAN should be defined +choke me +#endif + +#ifndef HUGE_VALF +# error HUGE_VALF should be defined +choke me +#endif + +#ifndef HUGE_VAL +# error HUGE_VAL should be defined +choke me +#endif + +#ifndef HUGE_VALL +# error HUGE_VALL should be defined +choke me +#endif + +#ifndef FP_ILOGB0 +# error FP_ILOGB0 should be defined +choke me +#endif + +#ifndef FP_ILOGBNAN +# error FP_ILOGBNAN should be defined +choke me +#endif + +#if 0 +/* Check that NAN expands into a constant expression. */ +static float n = NAN; +#endif + +#include + +#include "macros.h" + +/* Compare two numbers with ==. + This is a separate function because IRIX 6.5 "cc -O" miscompiles an + 'x == x' test. */ +static int +numeric_equalf (float x, float y) +{ + return x == y; +} +static int +numeric_equald (double x, double y) +{ + return x == y; +} +static int +numeric_equall (long double x, long double y) +{ + return x == y; +} + +int +main (void) +{ + double d = NAN; + double zero = 0.0; + ASSERT (!numeric_equald (d, d)); + + d = HUGE_VAL; + ASSERT (numeric_equald (d, 1.0 / zero)); + + ASSERT (numeric_equalf (HUGE_VALF, HUGE_VALF + HUGE_VALF)); + + ASSERT (numeric_equald (HUGE_VAL, HUGE_VAL + HUGE_VAL)); + + ASSERT (numeric_equall (HUGE_VALL, HUGE_VALL + HUGE_VALL)); + + /* Check the value of FP_ILOGB0. */ + ASSERT (FP_ILOGB0 == INT_MIN || FP_ILOGB0 == - INT_MAX); + + /* Check the value of FP_ILOGBNAN. */ + ASSERT (FP_ILOGBNAN == INT_MIN || FP_ILOGBNAN == INT_MAX); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtoc32-1.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtoc32-1.sh new file mode 100755 index 00000000..85abbdad --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtoc32-1.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +# Test whether the POSIX locale has encoding errors. +LC_ALL=C \ +${CHECKER} ./test-mbrtoc32${EXEEXT} 1 || exit 1 +LC_ALL=POSIX \ +${CHECKER} ./test-mbrtoc32${EXEEXT} 1 || exit 1 + +exit 0 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtoc32-2.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtoc32-2.sh new file mode 100755 index 00000000..1d44338a --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtoc32-2.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Test in an ISO-8859-1 or ISO-8859-15 locale. +: "${LOCALE_FR=fr_FR}" +if test $LOCALE_FR = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no traditional french locale is installed" + else + echo "Skipping test: no traditional french locale is supported" + fi + exit 77 +fi + +LC_ALL=$LOCALE_FR \ +${CHECKER} ./test-mbrtoc32${EXEEXT} 2 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtoc32-3.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtoc32-3.sh new file mode 100755 index 00000000..082bad84 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtoc32-3.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Test whether a specific UTF-8 locale is installed. +: "${LOCALE_FR_UTF8=fr_FR.UTF-8}" +if test $LOCALE_FR_UTF8 = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no french Unicode locale is installed" + else + echo "Skipping test: no french Unicode locale is supported" + fi + exit 77 +fi + +LC_ALL=$LOCALE_FR_UTF8 \ +${CHECKER} ./test-mbrtoc32${EXEEXT} 3 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtoc32-4.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtoc32-4.sh new file mode 100755 index 00000000..b23a3272 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtoc32-4.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Test whether a specific EUC-JP locale is installed. +: "${LOCALE_JA=ja_JP}" +if test $LOCALE_JA = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no traditional japanese locale is installed" + else + echo "Skipping test: no traditional japanese locale is supported" + fi + exit 77 +fi + +LC_ALL=$LOCALE_JA \ +${CHECKER} ./test-mbrtoc32${EXEEXT} 4 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtoc32-5.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtoc32-5.sh new file mode 100755 index 00000000..734a959e --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtoc32-5.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Test whether a specific GB18030 locale is installed. +: "${LOCALE_ZH_CN=zh_CN.GB18030}" +if test $LOCALE_ZH_CN = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no transitional chinese locale is installed" + else + echo "Skipping test: no transitional chinese locale is supported" + fi + exit 77 +fi + +LC_ALL=$LOCALE_ZH_CN \ +${CHECKER} ./test-mbrtoc32${EXEEXT} 5 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtoc32-w32-2.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtoc32-w32-2.sh new file mode 100755 index 00000000..bf6b61ce --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtoc32-w32-2.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Test a CP1252 locale. +${CHECKER} ./test-mbrtoc32-w32${EXEEXT} French_France 1252 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtoc32-w32-3.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtoc32-w32-3.sh new file mode 100755 index 00000000..dd96b17f --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtoc32-w32-3.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Test a CP1256 locale. +${CHECKER} ./test-mbrtoc32-w32${EXEEXT} "Arabic_Saudi Arabia" 1256 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtoc32-w32-4.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtoc32-w32-4.sh new file mode 100755 index 00000000..b2b889b6 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtoc32-w32-4.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Test some UTF-8 locales. +${CHECKER} ./test-mbrtoc32-w32${EXEEXT} French_France Japanese_Japan Chinese_Taiwan Chinese_China 65001 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtoc32-w32-5.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtoc32-w32-5.sh new file mode 100755 index 00000000..21a826b5 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtoc32-w32-5.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Test a CP932 locale. +${CHECKER} ./test-mbrtoc32-w32${EXEEXT} Japanese_Japan 932 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtoc32-w32-6.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtoc32-w32-6.sh new file mode 100755 index 00000000..4e261dbd --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtoc32-w32-6.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Test a CP950 locale. +${CHECKER} ./test-mbrtoc32-w32${EXEEXT} Chinese_Taiwan 950 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtoc32-w32-7.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtoc32-w32-7.sh new file mode 100755 index 00000000..200c248c --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtoc32-w32-7.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Test a CP936 locale. +${CHECKER} ./test-mbrtoc32-w32${EXEEXT} Chinese_China 936 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtoc32-w32-8.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtoc32-w32-8.sh new file mode 100755 index 00000000..a763e9fe --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtoc32-w32-8.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Test a GB18030 locale. +${CHECKER} ./test-mbrtoc32-w32${EXEEXT} Chinese_China 54936 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtoc32-w32.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtoc32-w32.c new file mode 100644 index 00000000..93196d48 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtoc32-w32.c @@ -0,0 +1,750 @@ +/* Test of conversion of multibyte character to 32-bit wide character. + Copyright (C) 2008-2024 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 . */ + +#include + +#include + +#include +#include +#include +#include +#include +#include + +#include "localcharset.h" +#include "macros.h" + +#if defined _WIN32 && !defined __CYGWIN__ + +static int +test_one_locale (const char *name, int codepage) +{ + mbstate_t state; + char32_t wc; + size_t ret; + +# if 1 + /* Portable code to set the locale. */ + { + char name_with_codepage[1024]; + + sprintf (name_with_codepage, "%s.%d", name, codepage); + + /* Set the locale. */ + if (setlocale (LC_ALL, name_with_codepage) == NULL) + return 77; + } +# else + /* Hacky way to set a locale.codepage combination that setlocale() refuses + to set. */ + { + /* Codepage of the current locale, set with setlocale(). + Not necessarily the same as GetACP(). */ + extern __declspec(dllimport) unsigned int __lc_codepage; + + /* Set the locale. */ + if (setlocale (LC_ALL, name) == NULL) + return 77; + + /* Clobber the codepage and MB_CUR_MAX, both set by setlocale(). */ + __lc_codepage = codepage; + switch (codepage) + { + case 1252: + case 1256: + MB_CUR_MAX = 1; + break; + case 932: + case 950: + case 936: + MB_CUR_MAX = 2; + break; + case 54936: + case 65001: + MB_CUR_MAX = 4; + break; + } + + /* Test whether the codepage is really available. */ + memset (&state, '\0', sizeof (mbstate_t)); + if (mbrtoc32 (&wc, " ", 1, &state) == (size_t)(-1)) + return 77; + } +# endif + + /* Test zero-length input. */ + { + memset (&state, '\0', sizeof (mbstate_t)); + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, "x", 0, &state); + ASSERT (ret == (size_t)(-2)); + ASSERT (mbsinit (&state)); + } + + /* Test NUL byte input. */ + { + memset (&state, '\0', sizeof (mbstate_t)); + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, "", 1, &state); + ASSERT (ret == 0); + ASSERT (wc == 0); + ASSERT (mbsinit (&state)); + ret = mbrtoc32 (NULL, "", 1, &state); + ASSERT (ret == 0); + ASSERT (mbsinit (&state)); + } + + /* Test single-byte input. */ + { + int c; + char buf[1]; + + memset (&state, '\0', sizeof (mbstate_t)); + for (c = 0; c < 0x100; c++) + switch (c) + { + case '\t': case '\v': case '\f': + case ' ': case '!': case '"': case '#': case '%': + case '&': case '\'': case '(': case ')': case '*': + case '+': case ',': case '-': case '.': case '/': + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + case ':': case ';': case '<': case '=': case '>': + case '?': + case 'A': case 'B': case 'C': case 'D': case 'E': + case 'F': case 'G': case 'H': case 'I': case 'J': + case 'K': case 'L': case 'M': case 'N': case 'O': + case 'P': case 'Q': case 'R': case 'S': case 'T': + case 'U': case 'V': case 'W': case 'X': case 'Y': + case 'Z': + case '[': case '\\': case ']': case '^': case '_': + case 'a': case 'b': case 'c': case 'd': case 'e': + case 'f': case 'g': case 'h': case 'i': case 'j': + case 'k': case 'l': case 'm': case 'n': case 'o': + case 'p': case 'q': case 'r': case 's': case 't': + case 'u': case 'v': case 'w': case 'x': case 'y': + case 'z': case '{': case '|': case '}': case '~': + /* c is in the ISO C "basic character set". */ + buf[0] = c; + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, buf, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == c); + ASSERT (mbsinit (&state)); + ret = mbrtoc32 (NULL, buf, 1, &state); + ASSERT (ret == 1); + ASSERT (mbsinit (&state)); + break; + } + } + + /* Test special calling convention, passing a NULL pointer. */ + { + memset (&state, '\0', sizeof (mbstate_t)); + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, NULL, 5, &state); + ASSERT (ret == 0); + ASSERT (wc == (char32_t) 0xBADFACE); + ASSERT (mbsinit (&state)); + } + + switch (codepage) + { + case 1252: + /* Locale encoding is CP1252, an extension of ISO-8859-1. */ + { + char input[] = "B\374\337er"; /* "Büßer" */ + memset (&state, '\0', sizeof (mbstate_t)); + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == 'B'); + ASSERT (mbsinit (&state)); + input[0] = '\0'; + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input + 1, 1, &state); + ASSERT (ret == 1); + ASSERT (c32tob (wc) == (unsigned char) '\374'); + ASSERT (wc == 0x00FC); /* expect Unicode encoding */ + ASSERT (mbsinit (&state)); + input[1] = '\0'; + + /* Test support of NULL first argument. */ + ret = mbrtoc32 (NULL, input + 2, 3, &state); + ASSERT (ret == 1); + ASSERT (mbsinit (&state)); + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input + 2, 3, &state); + ASSERT (ret == 1); + ASSERT (c32tob (wc) == (unsigned char) '\337'); + ASSERT (wc == 0x00DF); /* expect Unicode encoding */ + ASSERT (mbsinit (&state)); + input[2] = '\0'; + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input + 3, 2, &state); + ASSERT (ret == 1); + ASSERT (wc == 'e'); + ASSERT (mbsinit (&state)); + input[3] = '\0'; + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input + 4, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == 'r'); + ASSERT (mbsinit (&state)); + } + return 0; + + case 1256: + /* Locale encoding is CP1256, not the same as ISO-8859-6. */ + { + char input[] = "x\302\341\346y"; /* "xآلوy" */ + memset (&state, '\0', sizeof (mbstate_t)); + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == 'x'); + ASSERT (mbsinit (&state)); + input[0] = '\0'; + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input + 1, 1, &state); + ASSERT (ret == 1); + ASSERT (c32tob (wc) == (unsigned char) '\302'); + ASSERT (wc == 0x0622); /* expect Unicode encoding */ + ASSERT (mbsinit (&state)); + input[1] = '\0'; + + /* Test support of NULL first argument. */ + ret = mbrtoc32 (NULL, input + 2, 3, &state); + ASSERT (ret == 1); + ASSERT (mbsinit (&state)); + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input + 2, 3, &state); + ASSERT (ret == 1); + ASSERT (c32tob (wc) == (unsigned char) '\341'); + ASSERT (wc == 0x0644); /* expect Unicode encoding */ + ASSERT (mbsinit (&state)); + input[2] = '\0'; + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input + 3, 2, &state); + ASSERT (ret == 1); + ASSERT (c32tob (wc) == (unsigned char) '\346'); + ASSERT (wc == 0x0648); /* expect Unicode encoding */ + ASSERT (mbsinit (&state)); + input[3] = '\0'; + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input + 4, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == 'y'); + ASSERT (mbsinit (&state)); + } + return 0; + + case 65001: + /* Locale encoding is CP65001 = UTF-8. */ + if (strcmp (locale_charset (), "UTF-8") != 0) + return 77; + { + char input[] = "s\303\274\303\237\360\237\230\213!"; /* "süß😋!" */ + memset (&state, '\0', sizeof (mbstate_t)); + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == 's'); + ASSERT (mbsinit (&state)); + input[0] = '\0'; + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input + 1, 1, &state); + ASSERT (ret == (size_t)(-2)); + ASSERT (wc == (char32_t) 0xBADFACE); + ASSERT (!mbsinit (&state)); + input[1] = '\0'; + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input + 2, 7, &state); + ASSERT (ret == 1); + ASSERT (c32tob (wc) == EOF); + ASSERT (wc == 0x00FC); /* expect Unicode encoding */ + ASSERT (mbsinit (&state)); + input[2] = '\0'; + + /* Test support of NULL first argument. */ + ret = mbrtoc32 (NULL, input + 3, 6, &state); + ASSERT (ret == 2); + ASSERT (mbsinit (&state)); + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input + 3, 6, &state); + ASSERT (ret == 2); + ASSERT (c32tob (wc) == EOF); + ASSERT (wc == 0x00DF); /* expect Unicode encoding */ + ASSERT (mbsinit (&state)); + input[3] = '\0'; + input[4] = '\0'; + + /* Test support of NULL first argument. */ + ret = mbrtoc32 (NULL, input + 5, 4, &state); + ASSERT (ret == 4); + ASSERT (mbsinit (&state)); + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input + 5, 4, &state); + ASSERT (ret == 4); + ASSERT (c32tob (wc) == EOF); + ASSERT (wc == 0x1F60B); /* expect Unicode encoding */ + ASSERT (mbsinit (&state)); + input[5] = '\0'; + input[6] = '\0'; + input[7] = '\0'; + input[8] = '\0'; + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input + 9, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == '!'); + ASSERT (mbsinit (&state)); + + /* Test some invalid input. */ + memset (&state, '\0', sizeof (mbstate_t)); + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, "\377", 1, &state); /* 0xFF */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, "\303\300", 2, &state); /* 0xC3 0xC0 */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, "\343\300", 2, &state); /* 0xE3 0xC0 */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, "\343\300\200", 3, &state); /* 0xE3 0xC0 0x80 */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, "\343\200\300", 3, &state); /* 0xE3 0x80 0xC0 */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, "\363\300", 2, &state); /* 0xF3 0xC0 */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, "\363\300\200\200", 4, &state); /* 0xF3 0xC0 0x80 0x80 */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, "\363\200\300", 3, &state); /* 0xF3 0x80 0xC0 */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, "\363\200\300\200", 4, &state); /* 0xF3 0x80 0xC0 0x80 */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, "\363\200\200\300", 4, &state); /* 0xF3 0x80 0x80 0xC0 */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + } + return 0; + + case 932: + /* Locale encoding is CP932, similar to Shift_JIS. */ + { + char input[] = "<\223\372\226\173\214\352>"; /* "<日本語>" */ + memset (&state, '\0', sizeof (mbstate_t)); + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == '<'); + ASSERT (mbsinit (&state)); + input[0] = '\0'; + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input + 1, 2, &state); + ASSERT (ret == 2); + ASSERT (c32tob (wc) == EOF); + ASSERT (wc == 0x65E5); /* expect Unicode encoding */ + ASSERT (mbsinit (&state)); + input[1] = '\0'; + input[2] = '\0'; + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input + 3, 1, &state); + ASSERT (ret == (size_t)(-2)); + ASSERT (wc == (char32_t) 0xBADFACE); + ASSERT (!mbsinit (&state)); + input[3] = '\0'; + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input + 4, 4, &state); + ASSERT (ret == 1); + ASSERT (c32tob (wc) == EOF); + ASSERT (wc == 0x672C); /* expect Unicode encoding */ + ASSERT (mbsinit (&state)); + input[4] = '\0'; + + /* Test support of NULL first argument. */ + ret = mbrtoc32 (NULL, input + 5, 3, &state); + ASSERT (ret == 2); + ASSERT (mbsinit (&state)); + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input + 5, 3, &state); + ASSERT (ret == 2); + ASSERT (c32tob (wc) == EOF); + ASSERT (wc == 0x8A9E); /* expect Unicode encoding */ + ASSERT (mbsinit (&state)); + input[5] = '\0'; + input[6] = '\0'; + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input + 7, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == '>'); + ASSERT (mbsinit (&state)); + + /* Test some invalid input. */ + memset (&state, '\0', sizeof (mbstate_t)); + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, "\377", 1, &state); /* 0xFF */ + ASSERT ((ret == (size_t)-1 && errno == EILSEQ) || ret == (size_t)-2); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, "\225\377", 2, &state); /* 0x95 0xFF */ + ASSERT ((ret == (size_t)-1 && errno == EILSEQ) || (ret == 2 && wc == 0x30FB)); + } + return 0; + + case 950: + /* Locale encoding is CP950, similar to Big5. */ + { + char input[] = "<\244\351\245\273\273\171>"; /* "<日本語>" */ + memset (&state, '\0', sizeof (mbstate_t)); + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == '<'); + ASSERT (mbsinit (&state)); + input[0] = '\0'; + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input + 1, 2, &state); + ASSERT (ret == 2); + ASSERT (c32tob (wc) == EOF); + ASSERT (wc == 0x65E5); /* expect Unicode encoding */ + ASSERT (mbsinit (&state)); + input[1] = '\0'; + input[2] = '\0'; + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input + 3, 1, &state); + ASSERT (ret == (size_t)(-2)); + ASSERT (wc == (char32_t) 0xBADFACE); + ASSERT (!mbsinit (&state)); + input[3] = '\0'; + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input + 4, 4, &state); + ASSERT (ret == 1); + ASSERT (c32tob (wc) == EOF); + ASSERT (wc == 0x672C); /* expect Unicode encoding */ + ASSERT (mbsinit (&state)); + input[4] = '\0'; + + /* Test support of NULL first argument. */ + ret = mbrtoc32 (NULL, input + 5, 3, &state); + ASSERT (ret == 2); + ASSERT (mbsinit (&state)); + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input + 5, 3, &state); + ASSERT (ret == 2); + ASSERT (c32tob (wc) == EOF); + ASSERT (wc == 0x8A9E); /* expect Unicode encoding */ + ASSERT (mbsinit (&state)); + input[5] = '\0'; + input[6] = '\0'; + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input + 7, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == '>'); + ASSERT (mbsinit (&state)); + + /* Test some invalid input. */ + memset (&state, '\0', sizeof (mbstate_t)); + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, "\377", 1, &state); /* 0xFF */ + ASSERT ((ret == (size_t)-1 && errno == EILSEQ) || ret == (size_t)-2); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, "\225\377", 2, &state); /* 0x95 0xFF */ + ASSERT ((ret == (size_t)-1 && errno == EILSEQ) || (ret == 2 && wc == '?')); + } + return 0; + + case 936: + /* Locale encoding is CP936 = GBK, an extension of GB2312. */ + { + char input[] = "<\310\325\261\276\325\132>"; /* "<日本語>" */ + memset (&state, '\0', sizeof (mbstate_t)); + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == '<'); + ASSERT (mbsinit (&state)); + input[0] = '\0'; + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input + 1, 2, &state); + ASSERT (ret == 2); + ASSERT (c32tob (wc) == EOF); + ASSERT (wc == 0x65E5); /* expect Unicode encoding */ + ASSERT (mbsinit (&state)); + input[1] = '\0'; + input[2] = '\0'; + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input + 3, 1, &state); + ASSERT (ret == (size_t)(-2)); + ASSERT (wc == (char32_t) 0xBADFACE); + ASSERT (!mbsinit (&state)); + input[3] = '\0'; + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input + 4, 4, &state); + ASSERT (ret == 1); + ASSERT (c32tob (wc) == EOF); + ASSERT (wc == 0x672C); /* expect Unicode encoding */ + ASSERT (mbsinit (&state)); + input[4] = '\0'; + + /* Test support of NULL first argument. */ + ret = mbrtoc32 (NULL, input + 5, 3, &state); + ASSERT (ret == 2); + ASSERT (mbsinit (&state)); + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input + 5, 3, &state); + ASSERT (ret == 2); + ASSERT (c32tob (wc) == EOF); + ASSERT (wc == 0x8A9E); /* expect Unicode encoding */ + ASSERT (mbsinit (&state)); + input[5] = '\0'; + input[6] = '\0'; + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input + 7, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == '>'); + ASSERT (mbsinit (&state)); + + /* Test some invalid input. */ + memset (&state, '\0', sizeof (mbstate_t)); + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, "\377", 1, &state); /* 0xFF */ + ASSERT ((ret == (size_t)-1 && errno == EILSEQ) || ret == (size_t)-2); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, "\225\377", 2, &state); /* 0x95 0xFF */ + ASSERT ((ret == (size_t)-1 && errno == EILSEQ) || (ret == 2 && wc == '?')); + } + return 0; + + case 54936: + /* Locale encoding is CP54936 = GB18030. */ + if (strcmp (locale_charset (), "GB18030") != 0) + return 77; + { + char input[] = "s\250\271\201\060\211\070\224\071\375\067!"; /* "süß😋!" */ + memset (&state, '\0', sizeof (mbstate_t)); + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == 's'); + ASSERT (mbsinit (&state)); + input[0] = '\0'; + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input + 1, 1, &state); + ASSERT (ret == (size_t)(-2)); + ASSERT (wc == (char32_t) 0xBADFACE); + ASSERT (!mbsinit (&state)); + input[1] = '\0'; + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input + 2, 9, &state); + ASSERT (ret == 1); + ASSERT (c32tob (wc) == EOF); + ASSERT (wc == 0x00FC); /* expect Unicode encoding */ + ASSERT (mbsinit (&state)); + input[2] = '\0'; + + /* Test support of NULL first argument. */ + ret = mbrtoc32 (NULL, input + 3, 8, &state); + ASSERT (ret == 4); + ASSERT (mbsinit (&state)); + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input + 3, 8, &state); + ASSERT (ret == 4); + ASSERT (c32tob (wc) == EOF); + ASSERT (wc == 0x00DF); /* expect Unicode encoding */ + ASSERT (mbsinit (&state)); + input[3] = '\0'; + input[4] = '\0'; + input[5] = '\0'; + input[6] = '\0'; + + /* Test support of NULL first argument. */ + ret = mbrtoc32 (NULL, input + 7, 4, &state); + ASSERT (ret == 4); + ASSERT (mbsinit (&state)); + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input + 7, 4, &state); + ASSERT (ret == 4); + ASSERT (c32tob (wc) == EOF); + ASSERT (wc == 0x1F60B); /* expect Unicode encoding */ + ASSERT (mbsinit (&state)); + input[7] = '\0'; + input[8] = '\0'; + input[9] = '\0'; + input[10] = '\0'; + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input + 11, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == '!'); + ASSERT (mbsinit (&state)); + + /* Test some invalid input. */ + memset (&state, '\0', sizeof (mbstate_t)); + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, "\377", 1, &state); /* 0xFF */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, "\225\377", 2, &state); /* 0x95 0xFF */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, "\201\045", 2, &state); /* 0x81 0x25 */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, "\201\060\377", 3, &state); /* 0x81 0x30 0xFF */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, "\201\060\377\064", 4, &state); /* 0x81 0x30 0xFF 0x34 */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, "\201\060\211\072", 4, &state); /* 0x81 0x30 0x89 0x3A */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + } + return 0; + + default: + return 1; + } +} + +int +main (int argc, char *argv[]) +{ + int codepage = atoi (argv[argc - 1]); + int result; + int i; + + result = 77; + for (i = 1; i < argc - 1; i++) + { + int ret = test_one_locale (argv[i], codepage); + + if (ret != 77) + result = ret; + } + + if (result == 77) + { + fprintf (stderr, "Skipping test: found no locale with codepage %d\n", + codepage); + } + return result; +} + +#else + +int +main (int argc, char *argv[]) +{ + fputs ("Skipping test: not a native Windows system\n", stderr); + return 77; +} + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtoc32.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtoc32.c new file mode 100644 index 00000000..6fffb2a7 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtoc32.c @@ -0,0 +1,441 @@ +/* Test of conversion of multibyte character to 32-bit wide character. + Copyright (C) 2008-2024 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 . */ + +/* Written by Bruno Haible , 2008. */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (mbrtoc32, size_t, + (char32_t *, const char *, size_t, mbstate_t *)); + +#include +#include +#include +#include +#include + +#include "macros.h" + +int +main (int argc, char *argv[]) +{ + mbstate_t state; + char32_t wc; + size_t ret; + + /* configure should already have checked that the locale is supported. */ + if (setlocale (LC_ALL, "") == NULL) + return 1; + + /* Test zero-length input. */ + { + memset (&state, '\0', sizeof (mbstate_t)); + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, "x", 0, &state); + ASSERT (ret == (size_t)(-2)); + ASSERT (mbsinit (&state)); + } + + /* Test NUL byte input. */ + { + memset (&state, '\0', sizeof (mbstate_t)); + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, "", 1, &state); + ASSERT (ret == 0); + ASSERT (wc == 0); + ASSERT (mbsinit (&state)); + ret = mbrtoc32 (NULL, "", 1, &state); + ASSERT (ret == 0); + ASSERT (mbsinit (&state)); + } + + /* Test single-byte input. */ + { + int c; + char buf[1]; + + memset (&state, '\0', sizeof (mbstate_t)); + for (c = 0; c < 0x100; c++) + switch (c) + { + case '\t': case '\v': case '\f': + case ' ': case '!': case '"': case '#': case '%': + case '&': case '\'': case '(': case ')': case '*': + case '+': case ',': case '-': case '.': case '/': + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + case ':': case ';': case '<': case '=': case '>': + case '?': + case 'A': case 'B': case 'C': case 'D': case 'E': + case 'F': case 'G': case 'H': case 'I': case 'J': + case 'K': case 'L': case 'M': case 'N': case 'O': + case 'P': case 'Q': case 'R': case 'S': case 'T': + case 'U': case 'V': case 'W': case 'X': case 'Y': + case 'Z': + case '[': case '\\': case ']': case '^': case '_': + case 'a': case 'b': case 'c': case 'd': case 'e': + case 'f': case 'g': case 'h': case 'i': case 'j': + case 'k': case 'l': case 'm': case 'n': case 'o': + case 'p': case 'q': case 'r': case 's': case 't': + case 'u': case 'v': case 'w': case 'x': case 'y': + case 'z': case '{': case '|': case '}': case '~': + /* c is in the ISO C "basic character set". */ + ASSERT (c < 0x80); + /* c is an ASCII character. */ + buf[0] = c; + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, buf, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == c); + ASSERT (mbsinit (&state)); + + ret = mbrtoc32 (NULL, buf, 1, &state); + ASSERT (ret == 1); + ASSERT (mbsinit (&state)); + + break; + default: + break; + } + } + + /* Test special calling convention, passing a NULL pointer. */ + { + memset (&state, '\0', sizeof (mbstate_t)); + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, NULL, 5, &state); + ASSERT (ret == 0); + ASSERT (wc == (char32_t) 0xBADFACE); + ASSERT (mbsinit (&state)); + } + +#ifdef __ANDROID__ + /* On Android ≥ 5.0, the default locale is the "C.UTF-8" locale, not the + "C" locale. Furthermore, when you attempt to set the "C" or "POSIX" + locale via setlocale(), what you get is a "C" locale with UTF-8 encoding, + that is, effectively the "C.UTF-8" locale. */ + if (argc > 1 && strcmp (argv[1], "1") == 0 && MB_CUR_MAX > 1) + argv[1] = "3"; +#endif + + if (argc > 1) + switch (argv[1][0]) + { + case '1': + /* C or POSIX locale. */ + { + int c; + char buf[1]; + + memset (&state, '\0', sizeof (mbstate_t)); + for (c = 0; c < 0x100; c++) + if (c != 0) + { + /* We are testing all nonnull bytes. */ + buf[0] = c; + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, buf, 1, &state); + /* POSIX:2018 says regarding mbrtowc: "In the POSIX locale an + [EILSEQ] error cannot occur since all byte values are valid + characters." It is reasonable to expect mbrtoc32 to behave + in the same way. */ + ASSERT (ret == 1); + if (c < 0x80) + /* c is an ASCII character. */ + ASSERT (wc == c); + else + /* On most platforms, the bytes 0x80..0xFF map to U+0080..U+00FF. + But on musl libc, the bytes 0x80..0xFF map to U+DF80..U+DFFF. */ + ASSERT (wc == (btoc32 (c) == 0xDF00 + c ? btoc32 (c) : c)); + ASSERT (mbsinit (&state)); + + ret = mbrtoc32 (NULL, buf, 1, &state); + ASSERT (ret == 1); + ASSERT (mbsinit (&state)); + } + } + return 0; + + case '2': + /* Locale encoding is ISO-8859-1 or ISO-8859-15. */ + { + char input[] = "B\374\337er"; /* "Büßer" */ + memset (&state, '\0', sizeof (mbstate_t)); + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == 'B'); + ASSERT (mbsinit (&state)); + input[0] = '\0'; + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input + 1, 1, &state); + ASSERT (ret == 1); + ASSERT (c32tob (wc) == (unsigned char) '\374'); + #if GL_CHAR32_T_IS_UNICODE + ASSERT (wc == 0x00FC); /* expect Unicode encoding */ + #endif + ASSERT (mbsinit (&state)); + input[1] = '\0'; + + /* Test support of NULL first argument. */ + ret = mbrtoc32 (NULL, input + 2, 3, &state); + ASSERT (ret == 1); + ASSERT (mbsinit (&state)); + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input + 2, 3, &state); + ASSERT (ret == 1); + ASSERT (c32tob (wc) == (unsigned char) '\337'); + #if GL_CHAR32_T_IS_UNICODE + ASSERT (wc == 0x00DF); /* expect Unicode encoding */ + #endif + ASSERT (mbsinit (&state)); + input[2] = '\0'; + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input + 3, 2, &state); + ASSERT (ret == 1); + ASSERT (wc == 'e'); + ASSERT (mbsinit (&state)); + input[3] = '\0'; + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input + 4, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == 'r'); + ASSERT (mbsinit (&state)); + } + return 0; + + case '3': + /* Locale encoding is UTF-8. */ + { + char input[] = "s\303\274\303\237\360\237\230\213!"; /* "süß😋!" */ + memset (&state, '\0', sizeof (mbstate_t)); + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == 's'); + ASSERT (mbsinit (&state)); + input[0] = '\0'; + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input + 1, 1, &state); + ASSERT (ret == (size_t)(-2)); + ASSERT (wc == (char32_t) 0xBADFACE); + ASSERT (!mbsinit (&state)); + input[1] = '\0'; + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input + 2, 7, &state); + ASSERT (ret == 1); + ASSERT (c32tob (wc) == EOF); + ASSERT (wc == 0x00FC); /* expect Unicode encoding */ + ASSERT (mbsinit (&state)); + input[2] = '\0'; + + /* Test support of NULL first argument. */ + ret = mbrtoc32 (NULL, input + 3, 6, &state); + ASSERT (ret == 2); + ASSERT (mbsinit (&state)); + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input + 3, 6, &state); + ASSERT (ret == 2); + ASSERT (c32tob (wc) == EOF); + ASSERT (wc == 0x00DF); /* expect Unicode encoding */ + ASSERT (mbsinit (&state)); + input[3] = '\0'; + input[4] = '\0'; + + /* Test support of NULL first argument. */ + ret = mbrtoc32 (NULL, input + 5, 4, &state); + ASSERT (ret == 4); + ASSERT (mbsinit (&state)); + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input + 5, 4, &state); + ASSERT (ret == 4); + ASSERT (c32tob (wc) == EOF); + ASSERT (wc == 0x1F60B); /* expect Unicode encoding */ + ASSERT (mbsinit (&state)); + input[5] = '\0'; + input[6] = '\0'; + input[7] = '\0'; + input[8] = '\0'; + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input + 9, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == '!'); + ASSERT (mbsinit (&state)); + } + return 0; + + case '4': + /* Locale encoding is EUC-JP. */ + { + char input[] = "<\306\374\313\334\270\354>"; /* "<日本語>" */ + memset (&state, '\0', sizeof (mbstate_t)); + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == '<'); + ASSERT (mbsinit (&state)); + input[0] = '\0'; + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input + 1, 2, &state); + ASSERT (ret == 2); + ASSERT (c32tob (wc) == EOF); + #if GL_CHAR32_T_IS_UNICODE + ASSERT (wc == 0x65E5); /* expect Unicode encoding */ + #endif + ASSERT (mbsinit (&state)); + input[1] = '\0'; + input[2] = '\0'; + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input + 3, 1, &state); + ASSERT (ret == (size_t)(-2)); + ASSERT (wc == (char32_t) 0xBADFACE); + ASSERT (!mbsinit (&state)); + input[3] = '\0'; + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input + 4, 4, &state); + ASSERT (ret == 1); + ASSERT (c32tob (wc) == EOF); + #if GL_CHAR32_T_IS_UNICODE + ASSERT (wc == 0x672C); /* expect Unicode encoding */ + #endif + ASSERT (mbsinit (&state)); + input[4] = '\0'; + + /* Test support of NULL first argument. */ + ret = mbrtoc32 (NULL, input + 5, 3, &state); + ASSERT (ret == 2); + ASSERT (mbsinit (&state)); + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input + 5, 3, &state); + ASSERT (ret == 2); + ASSERT (c32tob (wc) == EOF); + #if GL_CHAR32_T_IS_UNICODE + ASSERT (wc == 0x8A9E); /* expect Unicode encoding */ + #endif + ASSERT (mbsinit (&state)); + input[5] = '\0'; + input[6] = '\0'; + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input + 7, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == '>'); + ASSERT (mbsinit (&state)); + } + return 0; + + case '5': + /* Locale encoding is GB18030. */ + #if (defined __GLIBC__ && __GLIBC__ == 2 && __GLIBC_MINOR__ >= 13 && __GLIBC_MINOR__ <= 15) || (GL_CHAR32_T_IS_UNICODE && (defined __FreeBSD__ || defined __NetBSD__ || defined __sun)) + fputs ("Skipping test: The GB18030 converter in this system's iconv is broken.\n", stderr); + return 77; + #endif + { + char input[] = "s\250\271\201\060\211\070\224\071\375\067!"; /* "süß😋!" */ + memset (&state, '\0', sizeof (mbstate_t)); + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == 's'); + ASSERT (mbsinit (&state)); + input[0] = '\0'; + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input + 1, 1, &state); + ASSERT (ret == (size_t)(-2)); + ASSERT (wc == (char32_t) 0xBADFACE); + ASSERT (!mbsinit (&state)); + input[1] = '\0'; + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input + 2, 9, &state); + ASSERT (ret == 1); + ASSERT (c32tob (wc) == EOF); + #if GL_CHAR32_T_IS_UNICODE + ASSERT (wc == 0x00FC); /* expect Unicode encoding */ + #endif + ASSERT (mbsinit (&state)); + input[2] = '\0'; + + /* Test support of NULL first argument. */ + ret = mbrtoc32 (NULL, input + 3, 8, &state); + ASSERT (ret == 4); + ASSERT (mbsinit (&state)); + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input + 3, 8, &state); + ASSERT (ret == 4); + ASSERT (c32tob (wc) == EOF); + #if GL_CHAR32_T_IS_UNICODE + ASSERT (wc == 0x00DF); /* expect Unicode encoding */ + #endif + ASSERT (mbsinit (&state)); + input[3] = '\0'; + input[4] = '\0'; + input[5] = '\0'; + input[6] = '\0'; + + /* Test support of NULL first argument. */ + ret = mbrtoc32 (NULL, input + 7, 4, &state); + ASSERT (ret == 4); + ASSERT (mbsinit (&state)); + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input + 7, 4, &state); + ASSERT (ret == 4); + ASSERT (c32tob (wc) == EOF); + #if GL_CHAR32_T_IS_UNICODE + ASSERT (wc == 0x1F60B); /* expect Unicode encoding */ + #endif + ASSERT (mbsinit (&state)); + input[7] = '\0'; + input[8] = '\0'; + input[9] = '\0'; + input[10] = '\0'; + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input + 11, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == '!'); + ASSERT (mbsinit (&state)); + } + return 0; + } + + return 1; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtowc-1.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtowc-1.sh new file mode 100755 index 00000000..f0a1feda --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtowc-1.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +# Test whether the POSIX locale has encoding errors. +LC_ALL=C \ +${CHECKER} ./test-mbrtowc${EXEEXT} 1 || exit 1 +LC_ALL=POSIX \ +${CHECKER} ./test-mbrtowc${EXEEXT} 1 || exit 1 + +exit 0 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtowc-2.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtowc-2.sh new file mode 100755 index 00000000..30662926 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtowc-2.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Test in an ISO-8859-1 or ISO-8859-15 locale. +: "${LOCALE_FR=fr_FR}" +if test $LOCALE_FR = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no traditional french locale is installed" + else + echo "Skipping test: no traditional french locale is supported" + fi + exit 77 +fi + +LC_ALL=$LOCALE_FR \ +${CHECKER} ./test-mbrtowc${EXEEXT} 2 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtowc-3.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtowc-3.sh new file mode 100755 index 00000000..36b0023c --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtowc-3.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Test whether a specific UTF-8 locale is installed. +: "${LOCALE_FR_UTF8=fr_FR.UTF-8}" +if test $LOCALE_FR_UTF8 = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no french Unicode locale is installed" + else + echo "Skipping test: no french Unicode locale is supported" + fi + exit 77 +fi + +LC_ALL=$LOCALE_FR_UTF8 \ +${CHECKER} ./test-mbrtowc${EXEEXT} 3 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtowc-4.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtowc-4.sh new file mode 100755 index 00000000..1c5943ea --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtowc-4.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Test whether a specific EUC-JP locale is installed. +: "${LOCALE_JA=ja_JP}" +if test $LOCALE_JA = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no traditional japanese locale is installed" + else + echo "Skipping test: no traditional japanese locale is supported" + fi + exit 77 +fi + +LC_ALL=$LOCALE_JA \ +${CHECKER} ./test-mbrtowc${EXEEXT} 4 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtowc-5.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtowc-5.sh new file mode 100755 index 00000000..8690bbef --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtowc-5.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Test whether a specific GB18030 locale is installed. +: "${LOCALE_ZH_CN=zh_CN.GB18030}" +if test $LOCALE_ZH_CN = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no transitional chinese locale is installed" + else + echo "Skipping test: no transitional chinese locale is supported" + fi + exit 77 +fi + +LC_ALL=$LOCALE_ZH_CN \ +${CHECKER} ./test-mbrtowc${EXEEXT} 5 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtowc-w32-2.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtowc-w32-2.sh new file mode 100755 index 00000000..fec9eadf --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtowc-w32-2.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Test a CP1252 locale. +${CHECKER} ./test-mbrtowc-w32${EXEEXT} French_France 1252 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtowc-w32-3.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtowc-w32-3.sh new file mode 100755 index 00000000..c55a0ec0 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtowc-w32-3.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Test a CP1256 locale. +${CHECKER} ./test-mbrtowc-w32${EXEEXT} "Arabic_Saudi Arabia" 1256 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtowc-w32-4.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtowc-w32-4.sh new file mode 100755 index 00000000..2c5d555f --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtowc-w32-4.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Test some UTF-8 locales. +${CHECKER} ./test-mbrtowc-w32${EXEEXT} French_France Japanese_Japan Chinese_Taiwan Chinese_China 65001 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtowc-w32-5.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtowc-w32-5.sh new file mode 100755 index 00000000..c49f4bdf --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtowc-w32-5.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Test a CP932 locale. +${CHECKER} ./test-mbrtowc-w32${EXEEXT} Japanese_Japan 932 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtowc-w32-6.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtowc-w32-6.sh new file mode 100755 index 00000000..3e786150 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtowc-w32-6.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Test a CP950 locale. +${CHECKER} ./test-mbrtowc-w32${EXEEXT} Chinese_Taiwan 950 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtowc-w32-7.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtowc-w32-7.sh new file mode 100755 index 00000000..c6ba2226 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtowc-w32-7.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Test a CP936 locale. +${CHECKER} ./test-mbrtowc-w32${EXEEXT} Chinese_China 936 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtowc-w32-8.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtowc-w32-8.sh new file mode 100755 index 00000000..c2e8dfe0 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtowc-w32-8.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Test a GB18030 locale. +${CHECKER} ./test-mbrtowc-w32${EXEEXT} Chinese_China 54936 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtowc-w32.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtowc-w32.c new file mode 100644 index 00000000..2071ddeb --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtowc-w32.c @@ -0,0 +1,734 @@ +/* Test of conversion of multibyte character to wide character. + Copyright (C) 2008-2024 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 . */ + +#include + +#include + +#include +#include +#include +#include +#include + +#include "localcharset.h" +#include "macros.h" + +#if defined _WIN32 && !defined __CYGWIN__ + +static int +test_one_locale (const char *name, int codepage) +{ + mbstate_t state; + wchar_t wc; + size_t ret; + +# if 1 + /* Portable code to set the locale. */ + { + char name_with_codepage[1024]; + + sprintf (name_with_codepage, "%s.%d", name, codepage); + + /* Set the locale. */ + if (setlocale (LC_ALL, name_with_codepage) == NULL) + return 77; + } +# else + /* Hacky way to set a locale.codepage combination that setlocale() refuses + to set. */ + { + /* Codepage of the current locale, set with setlocale(). + Not necessarily the same as GetACP(). */ + extern __declspec(dllimport) unsigned int __lc_codepage; + + /* Set the locale. */ + if (setlocale (LC_ALL, name) == NULL) + return 77; + + /* Clobber the codepage and MB_CUR_MAX, both set by setlocale(). */ + __lc_codepage = codepage; + switch (codepage) + { + case 1252: + case 1256: + MB_CUR_MAX = 1; + break; + case 932: + case 950: + case 936: + MB_CUR_MAX = 2; + break; + case 54936: + case 65001: + MB_CUR_MAX = 4; + break; + } + + /* Test whether the codepage is really available. */ + memset (&state, '\0', sizeof (mbstate_t)); + if (mbrtowc (&wc, " ", 1, &state) == (size_t)(-1)) + return 77; + } +# endif + + /* Test zero-length input. */ + { + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "x", 0, &state); + /* gnulib's implementation returns (size_t)(-2). + The AIX 5.1 implementation returns (size_t)(-1). + glibc's implementation returns 0. */ + ASSERT (ret == (size_t)(-2) || ret == (size_t)(-1) || ret == 0); + ASSERT (mbsinit (&state)); + } + + /* Test NUL byte input. */ + { + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "", 1, &state); + ASSERT (ret == 0); + ASSERT (wc == 0); + ASSERT (mbsinit (&state)); + ret = mbrtowc (NULL, "", 1, &state); + ASSERT (ret == 0); + ASSERT (mbsinit (&state)); + } + + /* Test single-byte input. */ + { + int c; + char buf[1]; + + memset (&state, '\0', sizeof (mbstate_t)); + for (c = 0; c < 0x100; c++) + switch (c) + { + case '\t': case '\v': case '\f': + case ' ': case '!': case '"': case '#': case '%': + case '&': case '\'': case '(': case ')': case '*': + case '+': case ',': case '-': case '.': case '/': + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + case ':': case ';': case '<': case '=': case '>': + case '?': + case 'A': case 'B': case 'C': case 'D': case 'E': + case 'F': case 'G': case 'H': case 'I': case 'J': + case 'K': case 'L': case 'M': case 'N': case 'O': + case 'P': case 'Q': case 'R': case 'S': case 'T': + case 'U': case 'V': case 'W': case 'X': case 'Y': + case 'Z': + case '[': case '\\': case ']': case '^': case '_': + case 'a': case 'b': case 'c': case 'd': case 'e': + case 'f': case 'g': case 'h': case 'i': case 'j': + case 'k': case 'l': case 'm': case 'n': case 'o': + case 'p': case 'q': case 'r': case 's': case 't': + case 'u': case 'v': case 'w': case 'x': case 'y': + case 'z': case '{': case '|': case '}': case '~': + /* c is in the ISO C "basic character set". */ + buf[0] = c; + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, buf, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == c); + ASSERT (mbsinit (&state)); + ret = mbrtowc (NULL, buf, 1, &state); + ASSERT (ret == 1); + ASSERT (mbsinit (&state)); + break; + } + } + + /* Test special calling convention, passing a NULL pointer. */ + { + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, NULL, 5, &state); + ASSERT (ret == 0); + ASSERT (wc == (wchar_t) 0xBADFACE); + ASSERT (mbsinit (&state)); + } + + switch (codepage) + { + case 1252: + /* Locale encoding is CP1252, an extension of ISO-8859-1. */ + { + char input[] = "B\374\337er"; /* "Büßer" */ + memset (&state, '\0', sizeof (mbstate_t)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == 'B'); + ASSERT (mbsinit (&state)); + input[0] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 1, 1, &state); + ASSERT (ret == 1); + ASSERT (wctob (wc) == (unsigned char) '\374'); + ASSERT (wc == 0x00FC); + ASSERT (mbsinit (&state)); + input[1] = '\0'; + + /* Test support of NULL first argument. */ + ret = mbrtowc (NULL, input + 2, 3, &state); + ASSERT (ret == 1); + ASSERT (mbsinit (&state)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 2, 3, &state); + ASSERT (ret == 1); + ASSERT (wctob (wc) == (unsigned char) '\337'); + ASSERT (wc == 0x00DF); + ASSERT (mbsinit (&state)); + input[2] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 3, 2, &state); + ASSERT (ret == 1); + ASSERT (wc == 'e'); + ASSERT (mbsinit (&state)); + input[3] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 4, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == 'r'); + ASSERT (mbsinit (&state)); + } + return 0; + + case 1256: + /* Locale encoding is CP1256, not the same as ISO-8859-6. */ + { + char input[] = "x\302\341\346y"; /* "xآلوy" */ + memset (&state, '\0', sizeof (mbstate_t)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == 'x'); + ASSERT (mbsinit (&state)); + input[0] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 1, 1, &state); + ASSERT (ret == 1); + ASSERT (wctob (wc) == (unsigned char) '\302'); + ASSERT (wc == 0x0622); + ASSERT (mbsinit (&state)); + input[1] = '\0'; + + /* Test support of NULL first argument. */ + ret = mbrtowc (NULL, input + 2, 3, &state); + ASSERT (ret == 1); + ASSERT (mbsinit (&state)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 2, 3, &state); + ASSERT (ret == 1); + ASSERT (wctob (wc) == (unsigned char) '\341'); + ASSERT (wc == 0x0644); + ASSERT (mbsinit (&state)); + input[2] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 3, 2, &state); + ASSERT (ret == 1); + ASSERT (wctob (wc) == (unsigned char) '\346'); + ASSERT (wc == 0x0648); + ASSERT (mbsinit (&state)); + input[3] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 4, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == 'y'); + ASSERT (mbsinit (&state)); + } + return 0; + + case 65001: + /* Locale encoding is CP65001 = UTF-8. */ + if (strcmp (locale_charset (), "UTF-8") != 0) + return 77; + { + char input[] = "B\303\274\303\237er"; /* "Büßer" */ + memset (&state, '\0', sizeof (mbstate_t)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == 'B'); + ASSERT (mbsinit (&state)); + input[0] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 1, 1, &state); + ASSERT (ret == (size_t)(-2)); + ASSERT (wc == (wchar_t) 0xBADFACE); + ASSERT (!mbsinit (&state)); + input[1] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 2, 5, &state); + ASSERT (ret == 1); + ASSERT (wctob (wc) == EOF); + ASSERT (wc == 0x00FC); + ASSERT (mbsinit (&state)); + input[2] = '\0'; + + /* Test support of NULL first argument. */ + ret = mbrtowc (NULL, input + 3, 4, &state); + ASSERT (ret == 2); + ASSERT (mbsinit (&state)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 3, 4, &state); + ASSERT (ret == 2); + ASSERT (wctob (wc) == EOF); + ASSERT (wc == 0x00DF); + ASSERT (mbsinit (&state)); + input[3] = '\0'; + input[4] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 5, 2, &state); + ASSERT (ret == 1); + ASSERT (wc == 'e'); + ASSERT (mbsinit (&state)); + input[5] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 6, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == 'r'); + ASSERT (mbsinit (&state)); + + /* Test some invalid input. */ + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\377", 1, &state); /* 0xFF */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\303\300", 2, &state); /* 0xC3 0xC0 */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\343\300", 2, &state); /* 0xE3 0xC0 */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\343\300\200", 3, &state); /* 0xE3 0xC0 0x80 */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\343\200\300", 3, &state); /* 0xE3 0x80 0xC0 */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\363\300", 2, &state); /* 0xF3 0xC0 */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\363\300\200\200", 4, &state); /* 0xF3 0xC0 0x80 0x80 */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\363\200\300", 3, &state); /* 0xF3 0x80 0xC0 */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\363\200\300\200", 4, &state); /* 0xF3 0x80 0xC0 0x80 */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\363\200\200\300", 4, &state); /* 0xF3 0x80 0x80 0xC0 */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + } + return 0; + + case 932: + /* Locale encoding is CP932, similar to Shift_JIS. */ + { + char input[] = "<\223\372\226\173\214\352>"; /* "<日本語>" */ + memset (&state, '\0', sizeof (mbstate_t)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == '<'); + ASSERT (mbsinit (&state)); + input[0] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 1, 2, &state); + ASSERT (ret == 2); + ASSERT (wctob (wc) == EOF); + ASSERT (wc == 0x65E5); + ASSERT (mbsinit (&state)); + input[1] = '\0'; + input[2] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 3, 1, &state); + ASSERT (ret == (size_t)(-2)); + ASSERT (wc == (wchar_t) 0xBADFACE); + ASSERT (!mbsinit (&state)); + input[3] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 4, 4, &state); + ASSERT (ret == 1); + ASSERT (wctob (wc) == EOF); + ASSERT (wc == 0x672C); + ASSERT (mbsinit (&state)); + input[4] = '\0'; + + /* Test support of NULL first argument. */ + ret = mbrtowc (NULL, input + 5, 3, &state); + ASSERT (ret == 2); + ASSERT (mbsinit (&state)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 5, 3, &state); + ASSERT (ret == 2); + ASSERT (wctob (wc) == EOF); + ASSERT (wc == 0x8A9E); + ASSERT (mbsinit (&state)); + input[5] = '\0'; + input[6] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 7, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == '>'); + ASSERT (mbsinit (&state)); + + /* Test some invalid input. */ + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\377", 1, &state); /* 0xFF */ + ASSERT ((ret == (size_t)-1 && errno == EILSEQ) || ret == (size_t)-2); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\225\377", 2, &state); /* 0x95 0xFF */ + ASSERT ((ret == (size_t)-1 && errno == EILSEQ) || (ret == 2 && wc == 0x30FB)); + } + return 0; + + case 950: + /* Locale encoding is CP950, similar to Big5. */ + { + char input[] = "<\244\351\245\273\273\171>"; /* "<日本語>" */ + memset (&state, '\0', sizeof (mbstate_t)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == '<'); + ASSERT (mbsinit (&state)); + input[0] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 1, 2, &state); + ASSERT (ret == 2); + ASSERT (wctob (wc) == EOF); + ASSERT (wc == 0x65E5); + ASSERT (mbsinit (&state)); + input[1] = '\0'; + input[2] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 3, 1, &state); + ASSERT (ret == (size_t)(-2)); + ASSERT (wc == (wchar_t) 0xBADFACE); + ASSERT (!mbsinit (&state)); + input[3] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 4, 4, &state); + ASSERT (ret == 1); + ASSERT (wctob (wc) == EOF); + ASSERT (wc == 0x672C); + ASSERT (mbsinit (&state)); + input[4] = '\0'; + + /* Test support of NULL first argument. */ + ret = mbrtowc (NULL, input + 5, 3, &state); + ASSERT (ret == 2); + ASSERT (mbsinit (&state)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 5, 3, &state); + ASSERT (ret == 2); + ASSERT (wctob (wc) == EOF); + ASSERT (wc == 0x8A9E); + ASSERT (mbsinit (&state)); + input[5] = '\0'; + input[6] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 7, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == '>'); + ASSERT (mbsinit (&state)); + + /* Test some invalid input. */ + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\377", 1, &state); /* 0xFF */ + ASSERT ((ret == (size_t)-1 && errno == EILSEQ) || ret == (size_t)-2); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\225\377", 2, &state); /* 0x95 0xFF */ + ASSERT ((ret == (size_t)-1 && errno == EILSEQ) || (ret == 2 && wc == '?')); + } + return 0; + + case 936: + /* Locale encoding is CP936 = GBK, an extension of GB2312. */ + { + char input[] = "<\310\325\261\276\325\132>"; /* "<日本語>" */ + memset (&state, '\0', sizeof (mbstate_t)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == '<'); + ASSERT (mbsinit (&state)); + input[0] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 1, 2, &state); + ASSERT (ret == 2); + ASSERT (wctob (wc) == EOF); + ASSERT (wc == 0x65E5); + ASSERT (mbsinit (&state)); + input[1] = '\0'; + input[2] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 3, 1, &state); + ASSERT (ret == (size_t)(-2)); + ASSERT (wc == (wchar_t) 0xBADFACE); + ASSERT (!mbsinit (&state)); + input[3] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 4, 4, &state); + ASSERT (ret == 1); + ASSERT (wctob (wc) == EOF); + ASSERT (wc == 0x672C); + ASSERT (mbsinit (&state)); + input[4] = '\0'; + + /* Test support of NULL first argument. */ + ret = mbrtowc (NULL, input + 5, 3, &state); + ASSERT (ret == 2); + ASSERT (mbsinit (&state)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 5, 3, &state); + ASSERT (ret == 2); + ASSERT (wctob (wc) == EOF); + ASSERT (wc == 0x8A9E); + ASSERT (mbsinit (&state)); + input[5] = '\0'; + input[6] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 7, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == '>'); + ASSERT (mbsinit (&state)); + + /* Test some invalid input. */ + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\377", 1, &state); /* 0xFF */ + ASSERT ((ret == (size_t)-1 && errno == EILSEQ) || ret == (size_t)-2); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\225\377", 2, &state); /* 0x95 0xFF */ + ASSERT ((ret == (size_t)-1 && errno == EILSEQ) || (ret == 2 && wc == '?')); + } + return 0; + + case 54936: + /* Locale encoding is CP54936 = GB18030. */ + if (strcmp (locale_charset (), "GB18030") != 0) + return 77; + { + char input[] = "B\250\271\201\060\211\070er"; /* "Büßer" */ + memset (&state, '\0', sizeof (mbstate_t)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == 'B'); + ASSERT (mbsinit (&state)); + input[0] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 1, 1, &state); + ASSERT (ret == (size_t)(-2)); + ASSERT (wc == (wchar_t) 0xBADFACE); + ASSERT (!mbsinit (&state)); + input[1] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 2, 7, &state); + ASSERT (ret == 1); + ASSERT (wctob (wc) == EOF); + ASSERT (wc == 0x00FC); + ASSERT (mbsinit (&state)); + input[2] = '\0'; + + /* Test support of NULL first argument. */ + ret = mbrtowc (NULL, input + 3, 6, &state); + ASSERT (ret == 4); + ASSERT (mbsinit (&state)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 3, 6, &state); + ASSERT (ret == 4); + ASSERT (wctob (wc) == EOF); + ASSERT (wc == 0x00DF); + ASSERT (mbsinit (&state)); + input[3] = '\0'; + input[4] = '\0'; + input[5] = '\0'; + input[6] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 7, 2, &state); + ASSERT (ret == 1); + ASSERT (wc == 'e'); + ASSERT (mbsinit (&state)); + input[7] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 8, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == 'r'); + ASSERT (mbsinit (&state)); + + /* Test some invalid input. */ + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\377", 1, &state); /* 0xFF */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\225\377", 2, &state); /* 0x95 0xFF */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\201\045", 2, &state); /* 0x81 0x25 */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\201\060\377", 3, &state); /* 0x81 0x30 0xFF */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\201\060\377\064", 4, &state); /* 0x81 0x30 0xFF 0x34 */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\201\060\211\072", 4, &state); /* 0x81 0x30 0x89 0x3A */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + } + return 0; + + default: + return 1; + } +} + +int +main (int argc, char *argv[]) +{ + int codepage = atoi (argv[argc - 1]); + int result; + int i; + + result = 77; + for (i = 1; i < argc - 1; i++) + { + int ret = test_one_locale (argv[i], codepage); + + if (ret != 77) + result = ret; + } + + if (result == 77) + { + fprintf (stderr, "Skipping test: found no locale with codepage %d\n", + codepage); + } + return result; +} + +#else + +int +main (int argc, char *argv[]) +{ + fputs ("Skipping test: not a native Windows system\n", stderr); + return 77; +} + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtowc.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtowc.c new file mode 100644 index 00000000..f45f90e4 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbrtowc.c @@ -0,0 +1,391 @@ +/* Test of conversion of multibyte character to wide character. + Copyright (C) 2008-2024 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 . */ + +/* Written by Bruno Haible , 2008. */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (mbrtowc, size_t, (wchar_t *, char const *, size_t, + mbstate_t *)); + +#include +#include +#include +#include + +#include "macros.h" + +int +main (int argc, char *argv[]) +{ + mbstate_t state; + wchar_t wc; + size_t ret; + + /* configure should already have checked that the locale is supported. */ + if (setlocale (LC_ALL, "") == NULL) + return 1; + + /* Test zero-length input. */ + { + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "x", 0, &state); + ASSERT (ret == (size_t)(-2)); + ASSERT (mbsinit (&state)); + } + + /* Test NUL byte input. */ + { + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "", 1, &state); + ASSERT (ret == 0); + ASSERT (wc == 0); + ASSERT (mbsinit (&state)); + ret = mbrtowc (NULL, "", 1, &state); + ASSERT (ret == 0); + ASSERT (mbsinit (&state)); + } + + /* Test single-byte input. */ + { + int c; + char buf[1]; + + memset (&state, '\0', sizeof (mbstate_t)); + for (c = 0; c < 0x100; c++) + switch (c) + { + case '\t': case '\v': case '\f': + case ' ': case '!': case '"': case '#': case '%': + case '&': case '\'': case '(': case ')': case '*': + case '+': case ',': case '-': case '.': case '/': + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + case ':': case ';': case '<': case '=': case '>': + case '?': + case 'A': case 'B': case 'C': case 'D': case 'E': + case 'F': case 'G': case 'H': case 'I': case 'J': + case 'K': case 'L': case 'M': case 'N': case 'O': + case 'P': case 'Q': case 'R': case 'S': case 'T': + case 'U': case 'V': case 'W': case 'X': case 'Y': + case 'Z': + case '[': case '\\': case ']': case '^': case '_': + case 'a': case 'b': case 'c': case 'd': case 'e': + case 'f': case 'g': case 'h': case 'i': case 'j': + case 'k': case 'l': case 'm': case 'n': case 'o': + case 'p': case 'q': case 'r': case 's': case 't': + case 'u': case 'v': case 'w': case 'x': case 'y': + case 'z': case '{': case '|': case '}': case '~': + /* c is in the ISO C "basic character set". */ + ASSERT (c < 0x80); + /* c is an ASCII character. */ + buf[0] = c; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, buf, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == c); + ASSERT (mbsinit (&state)); + + ret = mbrtowc (NULL, buf, 1, &state); + ASSERT (ret == 1); + ASSERT (mbsinit (&state)); + + break; + default: + break; + } + } + + /* Test special calling convention, passing a NULL pointer. */ + { + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, NULL, 5, &state); + ASSERT (ret == 0); + ASSERT (wc == (wchar_t) 0xBADFACE); + ASSERT (mbsinit (&state)); + } + +#ifdef __ANDROID__ + /* On Android ≥ 5.0, the default locale is the "C.UTF-8" locale, not the + "C" locale. Furthermore, when you attempt to set the "C" or "POSIX" + locale via setlocale(), what you get is a "C" locale with UTF-8 encoding, + that is, effectively the "C.UTF-8" locale. */ + if (argc > 1 && strcmp (argv[1], "1") == 0 && MB_CUR_MAX > 1) + argv[1] = "3"; +#endif + + if (argc > 1) + switch (argv[1][0]) + { + case '1': + /* C or POSIX locale. */ + { + int c; + char buf[1]; + + memset (&state, '\0', sizeof (mbstate_t)); + for (c = 0; c < 0x100; c++) + if (c != 0) + { + /* We are testing all nonnull bytes. */ + buf[0] = c; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, buf, 1, &state); + /* POSIX:2018 says: "In the POSIX locale an [EILSEQ] error + cannot occur since all byte values are valid characters." */ + ASSERT (ret == 1); + if (c < 0x80) + /* c is an ASCII character. */ + ASSERT (wc == c); + else + /* On most platforms, the bytes 0x80..0xFF map to U+0080..U+00FF. + But on musl libc, the bytes 0x80..0xFF map to U+DF80..U+DFFF. */ + ASSERT (wc == (btowc (c) == 0xDF00 + c ? btowc (c) : c)); + ASSERT (mbsinit (&state)); + + ret = mbrtowc (NULL, buf, 1, &state); + ASSERT (ret == 1); + ASSERT (mbsinit (&state)); + } + } + return 0; + + case '2': + /* Locale encoding is ISO-8859-1 or ISO-8859-15. */ + { + char input[] = "B\374\337er"; /* "Büßer" */ + memset (&state, '\0', sizeof (mbstate_t)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == 'B'); + ASSERT (mbsinit (&state)); + input[0] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 1, 1, &state); + ASSERT (ret == 1); + ASSERT (wctob (wc) == (unsigned char) '\374'); + ASSERT (mbsinit (&state)); + input[1] = '\0'; + + /* Test support of NULL first argument. */ + ret = mbrtowc (NULL, input + 2, 3, &state); + ASSERT (ret == 1); + ASSERT (mbsinit (&state)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 2, 3, &state); + ASSERT (ret == 1); + ASSERT (wctob (wc) == (unsigned char) '\337'); + ASSERT (mbsinit (&state)); + input[2] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 3, 2, &state); + ASSERT (ret == 1); + ASSERT (wc == 'e'); + ASSERT (mbsinit (&state)); + input[3] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 4, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == 'r'); + ASSERT (mbsinit (&state)); + } + return 0; + + case '3': + /* Locale encoding is UTF-8. */ + { + char input[] = "B\303\274\303\237er"; /* "Büßer" */ + memset (&state, '\0', sizeof (mbstate_t)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == 'B'); + ASSERT (mbsinit (&state)); + input[0] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 1, 1, &state); + ASSERT (ret == (size_t)(-2)); + ASSERT (wc == (wchar_t) 0xBADFACE); + ASSERT (!mbsinit (&state)); + input[1] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 2, 5, &state); + ASSERT (ret == 1); + ASSERT (wctob (wc) == EOF); + ASSERT (mbsinit (&state)); + input[2] = '\0'; + + /* Test support of NULL first argument. */ + ret = mbrtowc (NULL, input + 3, 4, &state); + ASSERT (ret == 2); + ASSERT (mbsinit (&state)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 3, 4, &state); + ASSERT (ret == 2); + ASSERT (wctob (wc) == EOF); + ASSERT (mbsinit (&state)); + input[3] = '\0'; + input[4] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 5, 2, &state); + ASSERT (ret == 1); + ASSERT (wc == 'e'); + ASSERT (mbsinit (&state)); + input[5] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 6, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == 'r'); + ASSERT (mbsinit (&state)); + } + return 0; + + case '4': + /* Locale encoding is EUC-JP. */ + { + char input[] = "<\306\374\313\334\270\354>"; /* "<日本語>" */ + memset (&state, '\0', sizeof (mbstate_t)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == '<'); + ASSERT (mbsinit (&state)); + input[0] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 1, 2, &state); + ASSERT (ret == 2); + ASSERT (wctob (wc) == EOF); + ASSERT (mbsinit (&state)); + input[1] = '\0'; + input[2] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 3, 1, &state); + ASSERT (ret == (size_t)(-2)); + ASSERT (wc == (wchar_t) 0xBADFACE); + ASSERT (!mbsinit (&state)); + input[3] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 4, 4, &state); + ASSERT (ret == 1); + ASSERT (wctob (wc) == EOF); + ASSERT (mbsinit (&state)); + input[4] = '\0'; + + /* Test support of NULL first argument. */ + ret = mbrtowc (NULL, input + 5, 3, &state); + ASSERT (ret == 2); + ASSERT (mbsinit (&state)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 5, 3, &state); + ASSERT (ret == 2); + ASSERT (wctob (wc) == EOF); + ASSERT (mbsinit (&state)); + input[5] = '\0'; + input[6] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 7, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == '>'); + ASSERT (mbsinit (&state)); + } + return 0; + + case '5': + /* Locale encoding is GB18030. */ + { + char input[] = "B\250\271\201\060\211\070er"; /* "Büßer" */ + memset (&state, '\0', sizeof (mbstate_t)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == 'B'); + ASSERT (mbsinit (&state)); + input[0] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 1, 1, &state); + ASSERT (ret == (size_t)(-2)); + ASSERT (wc == (wchar_t) 0xBADFACE); + ASSERT (!mbsinit (&state)); + input[1] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 2, 7, &state); + ASSERT (ret == 1); + ASSERT (wctob (wc) == EOF); + ASSERT (mbsinit (&state)); + input[2] = '\0'; + + /* Test support of NULL first argument. */ + ret = mbrtowc (NULL, input + 3, 6, &state); + ASSERT (ret == 4); + ASSERT (mbsinit (&state)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 3, 6, &state); + ASSERT (ret == 4); + ASSERT (wctob (wc) == EOF); + ASSERT (mbsinit (&state)); + input[3] = '\0'; + input[4] = '\0'; + input[5] = '\0'; + input[6] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 7, 2, &state); + ASSERT (ret == 1); + ASSERT (wc == 'e'); + ASSERT (mbsinit (&state)); + input[7] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 8, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == 'r'); + ASSERT (mbsinit (&state)); + } + return 0; + } + + return 1; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbscasecmp.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbscasecmp.c new file mode 100644 index 00000000..c097a982 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbscasecmp.c @@ -0,0 +1,55 @@ +/* Test of case-insensitive string comparison function. + Copyright (C) 2007-2024 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 . */ + +/* Written by Bruno Haible , 2007. */ + +#include + +#include + +#include + +#include "macros.h" + +int +main () +{ + /* configure should already have checked that the locale is supported. */ + if (setlocale (LC_ALL, "") == NULL) + return 1; + + ASSERT (mbscasecmp ("paragraph", "Paragraph") == 0); + + ASSERT (mbscasecmp ("paragrapH", "parAgRaph") == 0); + + ASSERT (mbscasecmp ("paragraph", "paraLyzed") < 0); + ASSERT (mbscasecmp ("paraLyzed", "paragraph") > 0); + + ASSERT (mbscasecmp ("para", "paragraph") < 0); + ASSERT (mbscasecmp ("paragraph", "para") > 0); + + /* The following tests shows how mbscasecmp() is different from + strcasecmp(). */ + + ASSERT (mbscasecmp ("\303\266zg\303\274r", "\303\226ZG\303\234R") == 0); /* özgür */ + ASSERT (mbscasecmp ("\303\226ZG\303\234R", "\303\266zg\303\274r") == 0); /* özgür */ + + /* This test shows how strings of different size can compare equal. */ + ASSERT (mbscasecmp ("turkish", "TURK\304\260SH") == 0); + ASSERT (mbscasecmp ("TURK\304\260SH", "turkish") == 0); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbscasecmp.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbscasecmp.sh new file mode 100755 index 00000000..73e62b5f --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbscasecmp.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Test whether a specific Turkish locale is installed. +: "${LOCALE_TR_UTF8=tr_TR.UTF-8}" +if test $LOCALE_TR_UTF8 = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no turkish Unicode locale is installed" + else + echo "Skipping test: no turkish Unicode locale is supported" + fi + exit 77 +fi + +LC_ALL=$LOCALE_TR_UTF8 \ +${CHECKER} ./test-mbscasecmp${EXEEXT} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbsinit.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbsinit.c new file mode 100644 index 00000000..0250894d --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbsinit.c @@ -0,0 +1,55 @@ +/* Test of test for initial conversion state. + Copyright (C) 2008-2024 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 . */ + +/* Written by Bruno Haible , 2008. */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (mbsinit, int, (const mbstate_t *)); + +#include + +#include "macros.h" + +int +main (int argc, char *argv[]) +{ + static mbstate_t state; + + ASSERT (mbsinit (NULL)); + + ASSERT (mbsinit (&state)); + + if (argc > 1) + { + static const char input[1] = "\303"; + wchar_t wc; + size_t ret; + + /* configure should already have checked that the locale is supported. */ + if (setlocale (LC_ALL, "") == NULL) + return 1; + + ret = mbrtowc (&wc, input, 1, &state); + ASSERT (ret == (size_t)(-2)); + ASSERT (!mbsinit (&state)); + } + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbsinit.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbsinit.sh new file mode 100755 index 00000000..25d4b2e4 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbsinit.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Test whether a specific UTF-8 locale is installed. +: "${LOCALE_FR_UTF8=fr_FR.UTF-8}" +if test $LOCALE_FR_UTF8 = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no french Unicode locale is installed" + else + echo "Skipping test: no french Unicode locale is supported" + fi + exit 77 +fi + +LC_ALL=$LOCALE_FR_UTF8 \ +${CHECKER} ./test-mbsinit${EXEEXT} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbsrtoc32s-1.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbsrtoc32s-1.sh new file mode 100755 index 00000000..3d5f89be --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbsrtoc32s-1.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +# Test whether the POSIX locale has encoding errors. +LC_ALL=C \ +${CHECKER} ./test-mbsrtoc32s${EXEEXT} 1 || exit 1 +LC_ALL=POSIX \ +${CHECKER} ./test-mbsrtoc32s${EXEEXT} 1 || exit 1 + +exit 0 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbsrtoc32s-2.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbsrtoc32s-2.sh new file mode 100755 index 00000000..1f084d46 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbsrtoc32s-2.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Test in an ISO-8859-1 or ISO-8859-15 locale. +: "${LOCALE_FR=fr_FR}" +if test $LOCALE_FR = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no traditional french locale is installed" + else + echo "Skipping test: no traditional french locale is supported" + fi + exit 77 +fi + +LC_ALL=$LOCALE_FR \ +${CHECKER} ./test-mbsrtoc32s${EXEEXT} 2 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbsrtoc32s-3.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbsrtoc32s-3.sh new file mode 100755 index 00000000..721e8df9 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbsrtoc32s-3.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Test whether a specific UTF-8 locale is installed. +: "${LOCALE_FR_UTF8=fr_FR.UTF-8}" +if test $LOCALE_FR_UTF8 = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no french Unicode locale is installed" + else + echo "Skipping test: no french Unicode locale is supported" + fi + exit 77 +fi + +LC_ALL=$LOCALE_FR_UTF8 \ +${CHECKER} ./test-mbsrtoc32s${EXEEXT} 3 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbsrtoc32s-4.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbsrtoc32s-4.sh new file mode 100755 index 00000000..553fde28 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbsrtoc32s-4.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Test whether a specific EUC-JP locale is installed. +: "${LOCALE_JA=ja_JP}" +if test $LOCALE_JA = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no traditional japanese locale is installed" + else + echo "Skipping test: no traditional japanese locale is supported" + fi + exit 77 +fi + +LC_ALL=$LOCALE_JA \ +${CHECKER} ./test-mbsrtoc32s${EXEEXT} 4 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbsrtoc32s-5.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbsrtoc32s-5.sh new file mode 100755 index 00000000..fa25beef --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbsrtoc32s-5.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Test whether a specific GB18030 locale is installed. +: "${LOCALE_ZH_CN=zh_CN.GB18030}" +if test $LOCALE_ZH_CN = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no transitional chinese locale is installed" + else + echo "Skipping test: no transitional chinese locale is supported" + fi + exit 77 +fi + +LC_ALL=$LOCALE_ZH_CN \ +${CHECKER} ./test-mbsrtoc32s${EXEEXT} 5 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbsrtoc32s.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbsrtoc32s.c new file mode 100644 index 00000000..fb6494a7 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbsrtoc32s.c @@ -0,0 +1,375 @@ +/* Test of conversion of string to 32-bit wide string. + Copyright (C) 2008-2024 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 . */ + +/* Written by Bruno Haible , 2008. */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (mbsrtoc32s, size_t, + (char32_t *, const char **, size_t, mbstate_t *)); + +#include +#include +#include +#include + +#include "macros.h" + +int +main (int argc, char *argv[]) +{ + mbstate_t state; + char32_t wc; + size_t ret; + + /* configure should already have checked that the locale is supported. */ + if (setlocale (LC_ALL, "") == NULL) + return 1; + + /* Test NUL byte input. */ + { + const char *src; + + memset (&state, '\0', sizeof (mbstate_t)); + + src = ""; + ret = mbsrtoc32s (NULL, &src, 0, &state); + ASSERT (ret == 0); + ASSERT (mbsinit (&state)); + + src = ""; + ret = mbsrtoc32s (NULL, &src, 1, &state); + ASSERT (ret == 0); + ASSERT (mbsinit (&state)); + + wc = (char32_t) 0xBADFACE; + src = ""; + ret = mbsrtoc32s (&wc, &src, 0, &state); + ASSERT (ret == 0); + ASSERT (wc == (char32_t) 0xBADFACE); + ASSERT (mbsinit (&state)); + + wc = (char32_t) 0xBADFACE; + src = ""; + ret = mbsrtoc32s (&wc, &src, 1, &state); + ASSERT (ret == 0); + ASSERT (wc == 0); + ASSERT (mbsinit (&state)); + } + +#ifdef __ANDROID__ + /* On Android ≥ 5.0, the default locale is the "C.UTF-8" locale, not the + "C" locale. Furthermore, when you attempt to set the "C" or "POSIX" + locale via setlocale(), what you get is a "C" locale with UTF-8 encoding, + that is, effectively the "C.UTF-8" locale. */ + if (argc > 1 && strcmp (argv[1], "1") == 0 && MB_CUR_MAX > 1) + argv[1] = "3"; +#endif + + if (argc > 1) + { + int unlimited; + + for (unlimited = 0; unlimited < 2; unlimited++) + { + #define BUFSIZE 10 + char32_t buf[BUFSIZE]; + const char *src; + mbstate_t temp_state; + + { + size_t i; + for (i = 0; i < BUFSIZE; i++) + buf[i] = (char32_t) 0xBADFACE; + } + + switch (argv[1][0]) + { + case '1': + /* C or POSIX locale. */ + { + char input[] = "n/a"; + memset (&state, '\0', sizeof (mbstate_t)); + + src = input; + temp_state = state; + ret = mbsrtoc32s (NULL, &src, unlimited ? BUFSIZE : 1, &temp_state); + ASSERT (ret == 3); + ASSERT (src == input); + ASSERT (mbsinit (&state)); + + src = input; + ret = mbsrtoc32s (buf, &src, unlimited ? BUFSIZE : 1, &state); + ASSERT (ret == (unlimited ? 3 : 1)); + ASSERT (src == (unlimited ? NULL : input + 1)); + ASSERT (buf[0] == 'n'); + if (unlimited) + { + ASSERT (buf[1] == '/'); + ASSERT (buf[2] == 'a'); + ASSERT (buf[3] == 0); + ASSERT (buf[4] == (char32_t) 0xBADFACE); + } + else + ASSERT (buf[1] == (char32_t) 0xBADFACE); + ASSERT (mbsinit (&state)); + } + { + int c; + char input[2]; + + memset (&state, '\0', sizeof (mbstate_t)); + for (c = 0; c < 0x100; c++) + if (c != 0) + { + /* We are testing all nonnull bytes. */ + input[0] = c; + input[1] = '\0'; + + src = input; + ret = mbsrtoc32s (NULL, &src, unlimited ? BUFSIZE : 1, &state); + ASSERT (ret == 1); + ASSERT (src == input); + ASSERT (mbsinit (&state)); + + buf[0] = buf[1] = (char32_t) 0xBADFACE; + src = input; + ret = mbsrtoc32s (buf, &src, unlimited ? BUFSIZE : 1, &state); + /* POSIX:2018 says regarding mbsrtowcs: "In the POSIX locale an + [EILSEQ] error cannot occur since all byte values are valid + characters." It is reasonable to expect mbsrtoc32s to behave + in the same way. */ + ASSERT (ret == 1); + ASSERT (src == (unlimited ? NULL : input + 1)); + if (c < 0x80) + /* c is an ASCII character. */ + ASSERT (buf[0] == c); + else + /* On most platforms, the bytes 0x80..0xFF map to U+0080..U+00FF. + But on musl libc, the bytes 0x80..0xFF map to U+DF80..U+DFFF. */ + ASSERT (buf[0] == (btoc32 (c) == 0xDF00 + c ? btoc32 (c) : c)); + ASSERT (mbsinit (&state)); + } + } + break; + + case '2': + /* Locale encoding is ISO-8859-1 or ISO-8859-15. */ + { + char input[] = "B\374\337er"; /* "Büßer" */ + memset (&state, '\0', sizeof (mbstate_t)); + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == 'B'); + ASSERT (mbsinit (&state)); + input[0] = '\0'; + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input + 1, 1, &state); + ASSERT (ret == 1); + ASSERT (c32tob (wc) == (unsigned char) '\374'); + ASSERT (mbsinit (&state)); + input[1] = '\0'; + + src = input + 2; + temp_state = state; + ret = mbsrtoc32s (NULL, &src, unlimited ? BUFSIZE : 1, &temp_state); + ASSERT (ret == 3); + ASSERT (src == input + 2); + ASSERT (mbsinit (&state)); + + src = input + 2; + ret = mbsrtoc32s (buf, &src, unlimited ? BUFSIZE : 1, &state); + ASSERT (ret == (unlimited ? 3 : 1)); + ASSERT (src == (unlimited ? NULL : input + 3)); + ASSERT (c32tob (buf[0]) == (unsigned char) '\337'); + if (unlimited) + { + ASSERT (buf[1] == 'e'); + ASSERT (buf[2] == 'r'); + ASSERT (buf[3] == 0); + ASSERT (buf[4] == (char32_t) 0xBADFACE); + } + else + ASSERT (buf[1] == (char32_t) 0xBADFACE); + ASSERT (mbsinit (&state)); + } + break; + + case '3': + /* Locale encoding is UTF-8. */ + { + char input[] = "s\303\274\303\237\360\237\230\213!"; /* "süß😋!" */ + memset (&state, '\0', sizeof (mbstate_t)); + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == 's'); + ASSERT (mbsinit (&state)); + input[0] = '\0'; + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input + 1, 1, &state); + ASSERT (ret == (size_t)(-2)); + ASSERT (wc == (char32_t) 0xBADFACE); + ASSERT (!mbsinit (&state)); + input[1] = '\0'; + + src = input + 2; + temp_state = state; + ret = mbsrtoc32s (NULL, &src, unlimited ? BUFSIZE : 2, &temp_state); + ASSERT (ret == 4); + ASSERT (src == input + 2); + ASSERT (!mbsinit (&state)); + + src = input + 2; + ret = mbsrtoc32s (buf, &src, unlimited ? BUFSIZE : 2, &state); + ASSERT (ret == (unlimited ? 4 : 2)); + ASSERT (src == (unlimited ? NULL : input + 5)); + ASSERT (c32tob (buf[0]) == EOF); + ASSERT (c32tob (buf[1]) == EOF); + if (unlimited) + { + ASSERT (buf[2] == 0x1F60B); /* expect Unicode encoding */ + ASSERT (buf[3] == '!'); + ASSERT (buf[4] == 0); + ASSERT (buf[5] == (char32_t) 0xBADFACE); + } + else + ASSERT (buf[2] == (char32_t) 0xBADFACE); + ASSERT (mbsinit (&state)); + } + break; + + case '4': + /* Locale encoding is EUC-JP. */ + { + char input[] = "<\306\374\313\334\270\354>"; /* "<日本語>" */ + memset (&state, '\0', sizeof (mbstate_t)); + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == '<'); + ASSERT (mbsinit (&state)); + input[0] = '\0'; + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input + 1, 2, &state); + ASSERT (ret == 2); + ASSERT (c32tob (wc) == EOF); + ASSERT (mbsinit (&state)); + input[1] = '\0'; + input[2] = '\0'; + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input + 3, 1, &state); + ASSERT (ret == (size_t)(-2)); + ASSERT (wc == (char32_t) 0xBADFACE); + ASSERT (!mbsinit (&state)); + input[3] = '\0'; + + src = input + 4; + temp_state = state; + ret = mbsrtoc32s (NULL, &src, unlimited ? BUFSIZE : 2, &temp_state); + ASSERT (ret == 3); + ASSERT (src == input + 4); + ASSERT (!mbsinit (&state)); + + src = input + 4; + ret = mbsrtoc32s (buf, &src, unlimited ? BUFSIZE : 2, &state); + ASSERT (ret == (unlimited ? 3 : 2)); + ASSERT (src == (unlimited ? NULL : input + 7)); + ASSERT (c32tob (buf[0]) == EOF); + ASSERT (c32tob (buf[1]) == EOF); + if (unlimited) + { + ASSERT (buf[2] == '>'); + ASSERT (buf[3] == 0); + ASSERT (buf[4] == (char32_t) 0xBADFACE); + } + else + ASSERT (buf[2] == (char32_t) 0xBADFACE); + ASSERT (mbsinit (&state)); + } + break; + + case '5': + /* Locale encoding is GB18030. */ + #if (defined __GLIBC__ && __GLIBC__ == 2 && __GLIBC_MINOR__ >= 13 && __GLIBC_MINOR__ <= 15) || (GL_CHAR32_T_IS_UNICODE && (defined __FreeBSD__ || defined __NetBSD__ || defined __sun)) + fputs ("Skipping test: The GB18030 converter in this system's iconv is broken.\n", stderr); + return 77; + #endif + { + char input[] = "s\250\271\201\060\211\070\224\071\375\067!"; /* "süß😋!" */ + memset (&state, '\0', sizeof (mbstate_t)); + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == 's'); + ASSERT (mbsinit (&state)); + input[0] = '\0'; + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, input + 1, 1, &state); + ASSERT (ret == (size_t)(-2)); + ASSERT (wc == (char32_t) 0xBADFACE); + ASSERT (!mbsinit (&state)); + input[1] = '\0'; + + src = input + 2; + temp_state = state; + ret = mbsrtoc32s (NULL, &src, unlimited ? BUFSIZE : 2, &temp_state); + ASSERT (ret == 4); + ASSERT (src == input + 2); + ASSERT (!mbsinit (&state)); + + src = input + 2; + ret = mbsrtoc32s (buf, &src, unlimited ? BUFSIZE : 2, &state); + ASSERT (ret == (unlimited ? 4 : 2)); + ASSERT (src == (unlimited ? NULL : input + 7)); + ASSERT (c32tob (buf[0]) == EOF); + ASSERT (c32tob (buf[1]) == EOF); + if (unlimited) + { + ASSERT (c32tob (buf[2]) == EOF); + ASSERT (buf[3] == '!'); + ASSERT (buf[4] == 0); + ASSERT (buf[5] == (char32_t) 0xBADFACE); + } + else + ASSERT (buf[2] == (char32_t) 0xBADFACE); + ASSERT (mbsinit (&state)); + } + break; + + default: + return 1; + } + } + + return 0; + } + + return 1; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbsrtowcs-1.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbsrtowcs-1.sh new file mode 100755 index 00000000..abac8d2e --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbsrtowcs-1.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +# Test whether the POSIX locale has encoding errors. +LC_ALL=C \ +${CHECKER} ./test-mbsrtowcs${EXEEXT} 1 || exit 1 +LC_ALL=POSIX \ +${CHECKER} ./test-mbsrtowcs${EXEEXT} 1 || exit 1 + +exit 0 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbsrtowcs-2.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbsrtowcs-2.sh new file mode 100755 index 00000000..508159e6 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbsrtowcs-2.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Test in an ISO-8859-1 or ISO-8859-15 locale. +: "${LOCALE_FR=fr_FR}" +if test $LOCALE_FR = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no traditional french locale is installed" + else + echo "Skipping test: no traditional french locale is supported" + fi + exit 77 +fi + +LC_ALL=$LOCALE_FR \ +${CHECKER} ./test-mbsrtowcs${EXEEXT} 2 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbsrtowcs-3.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbsrtowcs-3.sh new file mode 100755 index 00000000..9c7caee5 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbsrtowcs-3.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Test whether a specific UTF-8 locale is installed. +: "${LOCALE_FR_UTF8=fr_FR.UTF-8}" +if test $LOCALE_FR_UTF8 = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no french Unicode locale is installed" + else + echo "Skipping test: no french Unicode locale is supported" + fi + exit 77 +fi + +LC_ALL=$LOCALE_FR_UTF8 \ +${CHECKER} ./test-mbsrtowcs${EXEEXT} 3 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbsrtowcs-4.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbsrtowcs-4.sh new file mode 100755 index 00000000..87dc7e75 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbsrtowcs-4.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Test whether a specific EUC-JP locale is installed. +: "${LOCALE_JA=ja_JP}" +if test $LOCALE_JA = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no traditional japanese locale is installed" + else + echo "Skipping test: no traditional japanese locale is supported" + fi + exit 77 +fi + +LC_ALL=$LOCALE_JA \ +${CHECKER} ./test-mbsrtowcs${EXEEXT} 4 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbsrtowcs-5.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbsrtowcs-5.sh new file mode 100755 index 00000000..8e2de64c --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbsrtowcs-5.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Test whether a specific GB18030 locale is installed. +: "${LOCALE_ZH_CN=zh_CN.GB18030}" +if test $LOCALE_ZH_CN = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no transitional chinese locale is installed" + else + echo "Skipping test: no transitional chinese locale is supported" + fi + exit 77 +fi + +LC_ALL=$LOCALE_ZH_CN \ +${CHECKER} ./test-mbsrtowcs${EXEEXT} 5 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbsrtowcs.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbsrtowcs.c new file mode 100644 index 00000000..7e958a40 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mbsrtowcs.c @@ -0,0 +1,368 @@ +/* Test of conversion of string to wide string. + Copyright (C) 2008-2024 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 . */ + +/* Written by Bruno Haible , 2008. */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (mbsrtowcs, size_t, (wchar_t *, char const **, size_t, + mbstate_t *)); + +#include +#include +#include + +#include "macros.h" + +int +main (int argc, char *argv[]) +{ + mbstate_t state; + wchar_t wc; + size_t ret; + + /* configure should already have checked that the locale is supported. */ + if (setlocale (LC_ALL, "") == NULL) + return 1; + + /* Test NUL byte input. */ + { + const char *src; + + memset (&state, '\0', sizeof (mbstate_t)); + + src = ""; + ret = mbsrtowcs (NULL, &src, 0, &state); + ASSERT (ret == 0); + ASSERT (mbsinit (&state)); + + src = ""; + ret = mbsrtowcs (NULL, &src, 1, &state); + ASSERT (ret == 0); + ASSERT (mbsinit (&state)); + + wc = (wchar_t) 0xBADFACE; + src = ""; + ret = mbsrtowcs (&wc, &src, 0, &state); + ASSERT (ret == 0); + ASSERT (wc == (wchar_t) 0xBADFACE); + ASSERT (mbsinit (&state)); + + wc = (wchar_t) 0xBADFACE; + src = ""; + ret = mbsrtowcs (&wc, &src, 1, &state); + ASSERT (ret == 0); + ASSERT (wc == 0); + ASSERT (mbsinit (&state)); + } + +#ifdef __ANDROID__ + /* On Android ≥ 5.0, the default locale is the "C.UTF-8" locale, not the + "C" locale. Furthermore, when you attempt to set the "C" or "POSIX" + locale via setlocale(), what you get is a "C" locale with UTF-8 encoding, + that is, effectively the "C.UTF-8" locale. */ + if (argc > 1 && strcmp (argv[1], "1") == 0 && MB_CUR_MAX > 1) + argv[1] = "3"; +#endif + + if (argc > 1) + { + int unlimited; + + for (unlimited = 0; unlimited < 2; unlimited++) + { + #define BUFSIZE 10 + wchar_t buf[BUFSIZE]; + const char *src; + mbstate_t temp_state; + + { + size_t i; + for (i = 0; i < BUFSIZE; i++) + buf[i] = (wchar_t) 0xBADFACE; + } + + switch (argv[1][0]) + { + case '1': + /* C or POSIX locale. */ + { + char input[] = "n/a"; + memset (&state, '\0', sizeof (mbstate_t)); + + src = input; + temp_state = state; + ret = mbsrtowcs (NULL, &src, unlimited ? BUFSIZE : 1, &temp_state); + ASSERT (ret == 3); + ASSERT (src == input); + ASSERT (mbsinit (&state)); + + src = input; + ret = mbsrtowcs (buf, &src, unlimited ? BUFSIZE : 1, &state); + ASSERT (ret == (unlimited ? 3 : 1)); + ASSERT (src == (unlimited ? NULL : input + 1)); + ASSERT (buf[0] == 'n'); + if (unlimited) + { + ASSERT (buf[1] == '/'); + ASSERT (buf[2] == 'a'); + ASSERT (buf[3] == 0); + ASSERT (buf[4] == (wchar_t) 0xBADFACE); + } + else + ASSERT (buf[1] == (wchar_t) 0xBADFACE); + ASSERT (mbsinit (&state)); + } + { + int c; + char input[2]; + + memset (&state, '\0', sizeof (mbstate_t)); + for (c = 0; c < 0x100; c++) + if (c != 0) + { + /* We are testing all nonnull bytes. */ + input[0] = c; + input[1] = '\0'; + + src = input; + ret = mbsrtowcs (NULL, &src, unlimited ? BUFSIZE : 1, &state); + ASSERT (ret == 1); + ASSERT (src == input); + ASSERT (mbsinit (&state)); + + buf[0] = buf[1] = (wchar_t) 0xBADFACE; + src = input; + ret = mbsrtowcs (buf, &src, unlimited ? BUFSIZE : 1, &state); + /* POSIX:2018 says: "In the POSIX locale an [EILSEQ] error + cannot occur since all byte values are valid characters." */ + ASSERT (ret == 1); + ASSERT (src == (unlimited ? NULL : input + 1)); + if (c < 0x80) + /* c is an ASCII character. */ + ASSERT (buf[0] == c); + else + /* On most platforms, the bytes 0x80..0xFF map to U+0080..U+00FF. + But on musl libc, the bytes 0x80..0xFF map to U+DF80..U+DFFF. */ + ASSERT (buf[0] == (btowc (c) == 0xDF00 + c ? btowc (c) : c)); + ASSERT (mbsinit (&state)); + } + } + break; + + case '2': + /* Locale encoding is ISO-8859-1 or ISO-8859-15. */ + { + char input[] = "B\374\337er"; /* "Büßer" */ + memset (&state, '\0', sizeof (mbstate_t)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == 'B'); + ASSERT (mbsinit (&state)); + input[0] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 1, 1, &state); + ASSERT (ret == 1); + ASSERT (wctob (wc) == (unsigned char) '\374'); + ASSERT (mbsinit (&state)); + input[1] = '\0'; + + src = input + 2; + temp_state = state; + ret = mbsrtowcs (NULL, &src, unlimited ? BUFSIZE : 1, &temp_state); + ASSERT (ret == 3); + ASSERT (src == input + 2); + ASSERT (mbsinit (&state)); + + src = input + 2; + ret = mbsrtowcs (buf, &src, unlimited ? BUFSIZE : 1, &state); + ASSERT (ret == (unlimited ? 3 : 1)); + ASSERT (src == (unlimited ? NULL : input + 3)); + ASSERT (wctob (buf[0]) == (unsigned char) '\337'); + if (unlimited) + { + ASSERT (buf[1] == 'e'); + ASSERT (buf[2] == 'r'); + ASSERT (buf[3] == 0); + ASSERT (buf[4] == (wchar_t) 0xBADFACE); + } + else + ASSERT (buf[1] == (wchar_t) 0xBADFACE); + ASSERT (mbsinit (&state)); + } + break; + + case '3': + /* Locale encoding is UTF-8. */ + { + char input[] = "B\303\274\303\237er"; /* "Büßer" */ + memset (&state, '\0', sizeof (mbstate_t)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == 'B'); + ASSERT (mbsinit (&state)); + input[0] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 1, 1, &state); + ASSERT (ret == (size_t)(-2)); + ASSERT (wc == (wchar_t) 0xBADFACE); + ASSERT (!mbsinit (&state)); + input[1] = '\0'; + + src = input + 2; + temp_state = state; + ret = mbsrtowcs (NULL, &src, unlimited ? BUFSIZE : 2, &temp_state); + ASSERT (ret == 4); + ASSERT (src == input + 2); + ASSERT (!mbsinit (&state)); + + src = input + 2; + ret = mbsrtowcs (buf, &src, unlimited ? BUFSIZE : 2, &state); + ASSERT (ret == (unlimited ? 4 : 2)); + ASSERT (src == (unlimited ? NULL : input + 5)); + ASSERT (wctob (buf[0]) == EOF); + ASSERT (wctob (buf[1]) == EOF); + if (unlimited) + { + ASSERT (buf[2] == 'e'); + ASSERT (buf[3] == 'r'); + ASSERT (buf[4] == 0); + ASSERT (buf[5] == (wchar_t) 0xBADFACE); + } + else + ASSERT (buf[2] == (wchar_t) 0xBADFACE); + ASSERT (mbsinit (&state)); + } + break; + + case '4': + /* Locale encoding is EUC-JP. */ + { + char input[] = "<\306\374\313\334\270\354>"; /* "<日本語>" */ + memset (&state, '\0', sizeof (mbstate_t)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == '<'); + ASSERT (mbsinit (&state)); + input[0] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 1, 2, &state); + ASSERT (ret == 2); + ASSERT (wctob (wc) == EOF); + ASSERT (mbsinit (&state)); + input[1] = '\0'; + input[2] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 3, 1, &state); + ASSERT (ret == (size_t)(-2)); + ASSERT (wc == (wchar_t) 0xBADFACE); + ASSERT (!mbsinit (&state)); + input[3] = '\0'; + + src = input + 4; + temp_state = state; + ret = mbsrtowcs (NULL, &src, unlimited ? BUFSIZE : 2, &temp_state); + ASSERT (ret == 3); + ASSERT (src == input + 4); + ASSERT (!mbsinit (&state)); + + src = input + 4; + ret = mbsrtowcs (buf, &src, unlimited ? BUFSIZE : 2, &state); + ASSERT (ret == (unlimited ? 3 : 2)); + ASSERT (src == (unlimited ? NULL : input + 7)); + ASSERT (wctob (buf[0]) == EOF); + ASSERT (wctob (buf[1]) == EOF); + if (unlimited) + { + ASSERT (buf[2] == '>'); + ASSERT (buf[3] == 0); + ASSERT (buf[4] == (wchar_t) 0xBADFACE); + } + else + ASSERT (buf[2] == (wchar_t) 0xBADFACE); + ASSERT (mbsinit (&state)); + } + break; + + case '5': + /* Locale encoding is GB18030. */ + { + char input[] = "B\250\271\201\060\211\070er"; /* "Büßer" */ + memset (&state, '\0', sizeof (mbstate_t)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input, 1, &state); + ASSERT (ret == 1); + ASSERT (wc == 'B'); + ASSERT (mbsinit (&state)); + input[0] = '\0'; + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input + 1, 1, &state); + ASSERT (ret == (size_t)(-2)); + ASSERT (wc == (wchar_t) 0xBADFACE); + ASSERT (!mbsinit (&state)); + input[1] = '\0'; + + src = input + 2; + temp_state = state; + ret = mbsrtowcs (NULL, &src, unlimited ? BUFSIZE : 2, &temp_state); + ASSERT (ret == 4); + ASSERT (src == input + 2); + ASSERT (!mbsinit (&state)); + + src = input + 2; + ret = mbsrtowcs (buf, &src, unlimited ? BUFSIZE : 2, &state); + ASSERT (ret == (unlimited ? 4 : 2)); + ASSERT (src == (unlimited ? NULL : input + 7)); + ASSERT (wctob (buf[0]) == EOF); + ASSERT (wctob (buf[1]) == EOF); + if (unlimited) + { + ASSERT (buf[2] == 'e'); + ASSERT (buf[3] == 'r'); + ASSERT (buf[4] == 0); + ASSERT (buf[5] == (wchar_t) 0xBADFACE); + } + else + ASSERT (buf[2] == (wchar_t) 0xBADFACE); + ASSERT (mbsinit (&state)); + } + break; + + default: + return 1; + } + } + + return 0; + } + + return 1; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-memchr.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-memchr.c new file mode 100644 index 00000000..c43ce9ff --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-memchr.c @@ -0,0 +1,137 @@ +/* + * Copyright (C) 2008-2024 Free Software Foundation, Inc. + * Written by Eric Blake and Bruno Haible + * + * 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 . */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (memchr, void *, (void const *, int, size_t)); + +#include + +#include "zerosize-ptr.h" +#include "macros.h" + +/* Calculating void * + int is not portable, so this wrapper converts + to char * to make the tests easier to write. */ +#define MEMCHR (char *) memchr + +int +main (void) +{ + size_t n = 0x100000; + char *input = malloc (n); + ASSERT (input); + + input[0] = 'a'; + input[1] = 'b'; + memset (input + 2, 'c', 1024); + memset (input + 1026, 'd', n - 1028); + input[n - 2] = 'e'; + input[n - 1] = 'a'; + + /* Basic behavior tests. */ + ASSERT (MEMCHR (input, 'a', n) == input); + + ASSERT (MEMCHR (input, 'a', 0) == NULL); + + { + void *page_boundary = zerosize_ptr (); + if (page_boundary) + ASSERT (MEMCHR (page_boundary, 'a', 0) == NULL); + } + + ASSERT (MEMCHR (input, 'b', n) == input + 1); + ASSERT (MEMCHR (input, 'c', n) == input + 2); + ASSERT (MEMCHR (input, 'd', n) == input + 1026); + + ASSERT (MEMCHR (input + 1, 'a', n - 1) == input + n - 1); + ASSERT (MEMCHR (input + 1, 'e', n - 1) == input + n - 2); + ASSERT (MEMCHR (input + 1, 0x789abc00 | 'e', n - 1) == input + n - 2); + + ASSERT (MEMCHR (input, 'f', n) == NULL); + ASSERT (MEMCHR (input, '\0', n) == NULL); + + /* Check that a very long haystack is handled quickly if the byte is + found near the beginning. */ + { + size_t repeat = 10000; + for (; repeat > 0; repeat--) + { + ASSERT (MEMCHR (input, 'c', n) == input + 2); + } + } + + /* Alignment tests. */ + { + int i, j; + for (i = 0; i < 32; i++) + { + for (j = 0; j < 256; j++) + input[i + j] = j; + for (j = 0; j < 256; j++) + { + ASSERT (MEMCHR (input + i, j, 256) == input + i + j); + } + } + } + + /* Check that memchr() does not read past the first occurrence of the + byte being searched. See the Austin Group's clarification + . + Test both '\0' and something else, since some implementations + special-case searching for NUL. + */ + { + char *page_boundary = (char *) zerosize_ptr (); + /* Too small, and we miss cache line boundary tests; too large, + and the test takes cubically longer to complete. */ + int limit = 257; + + if (page_boundary != NULL) + { + for (n = 1; n <= limit; n++) + { + char *mem = page_boundary - n; + memset (mem, 'X', n); + ASSERT (MEMCHR (mem, 'U', n) == NULL); + ASSERT (MEMCHR (mem, 0, n) == NULL); + + { + size_t i; + size_t k; + + for (i = 0; i < n; i++) + { + mem[i] = 'U'; + for (k = i + 1; k < n + limit; k++) + ASSERT (MEMCHR (mem, 'U', k) == mem + i); + mem[i] = 0; + for (k = i + 1; k < n + limit; k++) + ASSERT (MEMCHR (mem, 0, k) == mem + i); + mem[i] = 'X'; + } + } + } + } + } + + free (input); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-memrchr.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-memrchr.c new file mode 100644 index 00000000..0dde27dd --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-memrchr.c @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2008-2024 Free Software Foundation, Inc. + * Written by Eric Blake and Bruno Haible + * + * 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 . */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (memrchr, void *, (void const *, int, size_t)); + +#include + +#include "zerosize-ptr.h" +#include "macros.h" + +/* Work around GCC bug 101494. */ +#if 4 < __GNUC__ + (7 <= __GNUC_MINOR__) && __GNUC__ < 12 +# pragma GCC diagnostic ignored "-Wmaybe-uninitialized" +#endif + +/* Calculating void * + int is not portable, so this wrapper converts + to char * to make the tests easier to write. */ +#define MEMRCHR (char *) memrchr + +int +main (void) +{ + size_t n = 0x100000; + char *input = malloc (n); + ASSERT (input); + + input[n - 1] = 'a'; + input[n - 2] = 'b'; + memset (input + n - 1026, 'c', 1024); + memset (input + 2, 'd', n - 1028); + input[1] = 'e'; + input[0] = 'a'; + + /* Basic behavior tests. */ + ASSERT (MEMRCHR (input, 'a', n) == input + n - 1); + + ASSERT (MEMRCHR (input, 'a', 0) == NULL); + void *page_boundary = zerosize_ptr (); + if (page_boundary) + ASSERT (MEMRCHR (page_boundary, 'a', 0) == NULL); + + ASSERT (MEMRCHR (input, 'b', n) == input + n - 2); + ASSERT (MEMRCHR (input, 'c', n) == input + n - 3); + ASSERT (MEMRCHR (input, 'd', n) == input + n - 1027); + + ASSERT (MEMRCHR (input, 'a', n - 1) == input); + ASSERT (MEMRCHR (input, 'e', n - 1) == input + 1); + + ASSERT (MEMRCHR (input, 'f', n) == NULL); + ASSERT (MEMRCHR (input, '\0', n) == NULL); + + /* Check that a very long haystack is handled quickly if the byte is + found near the end. */ + { + size_t repeat = 10000; + for (; repeat > 0; repeat--) + { + ASSERT (MEMRCHR (input, 'c', n) == input + n - 3); + } + } + + /* Alignment tests. */ + { + int i, j; + for (i = 0; i < 32; i++) + { + for (j = 0; j < 256; j++) + input[i + j] = j; + for (j = 0; j < 256; j++) + { + ASSERT (MEMRCHR (input + i, j, 256) == input + i + j); + } + } + } + + free (input); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mkdir.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mkdir.c new file mode 100644 index 00000000..ae0ed341 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mkdir.c @@ -0,0 +1,46 @@ +/* Tests of mkdir. + Copyright (C) 2009-2024 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 . */ + +/* Written by Eric Blake , 2009. */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (mkdir, int, (char const *, mode_t)); + +#include +#include +#include +#include +#include + +#include "ignore-value.h" +#include "macros.h" + +#define BASE "test-mkdir.t" + +#include "test-mkdir.h" + +int +main (void) +{ + /* Clean up any trash from prior testsuite runs. */ + ignore_value (system ("rm -rf " BASE "*")); + + return test_mkdir (mkdir, true); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mkdir.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mkdir.h new file mode 100644 index 00000000..e22d07ad --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-mkdir.h @@ -0,0 +1,98 @@ +/* Test of mkdir() function. + Copyright (C) 2009-2024 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 . */ + +/* This file is designed to test both mkdir(a,b) and + mkdirat(AT_FDCWD,a,b). FUNC is the function to test. Assumes that + BASE and ASSERT are already defined, and that appropriate headers + are already included. If PRINT, warn before skipping tests with + status 77 when symlinks are unsupported. */ + +static int +test_mkdir (int (*func) (char const *, mode_t), bool print) +{ + /* Test basic error handling. */ + ASSERT (close (creat (BASE "file", 0600)) == 0); + errno = 0; + ASSERT (func (BASE "file", 0700) == -1); + ASSERT (errno == EEXIST); + errno = 0; + ASSERT (func (BASE "file/", 0700) == -1); + ASSERT (errno == ENOTDIR || errno == EEXIST); + errno = 0; + ASSERT (func (BASE "file/dir", 0700) == -1); + ASSERT (errno == ENOTDIR || errno == ENOENT || errno == EOPNOTSUPP); + ASSERT (unlink (BASE "file") == 0); + errno = 0; + ASSERT (func ("", 0700) == -1); + ASSERT (errno == ENOENT); + errno = 0; + ASSERT (func (BASE "dir/sub", 0700) == -1); + ASSERT (errno == ENOENT); + errno = 0; + ASSERT (func (BASE "dir/.", 0700) == -1); + ASSERT (errno == ENOENT); + errno = 0; + ASSERT (func (BASE "dir/.//", 0700) == -1); + ASSERT (errno == ENOENT); + + /* Test trailing slash handling. */ + ASSERT (func (BASE "dir", 0700) == 0); + errno = 0; + ASSERT (func (BASE "dir", 0700) == -1); + ASSERT (errno == EEXIST); + ASSERT (rmdir (BASE "dir") == 0); + ASSERT (func (BASE "dir/", 0700) == 0); + errno = 0; + ASSERT (func (BASE "dir/", 0700) == -1); + ASSERT (errno == EEXIST); + ASSERT (rmdir (BASE "dir") == 0); + + /* Test symlink behavior. POSIX requires the creation of + directories through a dangling symlink with trailing slash, but + GNU does not yet implement that, so we support either behavior + for now. */ + if (symlink (BASE "dir", BASE "link")) + { + if (print) + fputs ("skipping test: symlinks not supported on this file system\n", + stderr); + return 77; + } + errno = 0; + ASSERT (func (BASE "link", 0700) == -1); + ASSERT (errno == EEXIST); + { + int result; + errno = 0; + result = func (BASE "link/", 0700); + if (!result) + ASSERT (rmdir (BASE "dir") == 0); + else + { + ASSERT (result == -1); + ASSERT (errno == EEXIST); + errno = 0; + ASSERT (rmdir (BASE "dir") == -1); + ASSERT (errno == ENOENT); + } + } + errno = 0; + ASSERT (func (BASE "link/.", 0700) == -1); + ASSERT (errno == ENOENT); + ASSERT (unlink (BASE "link") == 0); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-nanosleep.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-nanosleep.c new file mode 100644 index 00000000..c3953843 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-nanosleep.c @@ -0,0 +1,94 @@ +/* Test of nanosleep() function. + Copyright (C) 2009-2024 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 . */ + +/* Written by Eric Blake , 2009. */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (nanosleep, int, (struct timespec const *, struct timespec *)); + +#include +#include +#include + +#include "macros.h" + +#if HAVE_DECL_ALARM +static void +handle_alarm (int sig) +{ + if (sig != SIGALRM) + _exit (1); +} +#endif + +int +main (void) +{ + struct timespec ts; + + /* Check that negative nanosecond values cause failure. */ + ts.tv_sec = 1; + ts.tv_nsec = -1; + errno = 0; + ASSERT (nanosleep (&ts, NULL) == -1); + ASSERT (errno == EINVAL); + + ts.tv_sec = 1000; + ts.tv_nsec = -1; + errno = 0; + ASSERT (nanosleep (&ts, NULL) == -1); + ASSERT (errno == EINVAL); + + /* Check that too large nanosecond values cause failure. */ + ts.tv_sec = 1000; + ts.tv_nsec = 1000000000; + errno = 0; + ASSERT (nanosleep (&ts, NULL) == -1); + ASSERT (errno == EINVAL); + + /* Check successful call. */ + ts.tv_sec = 0; + ts.tv_nsec = 1; + ASSERT (nanosleep (&ts, &ts) == 0); + /* Remaining time is only defined on EINTR failure; but on success, + it is typically either 0 or unchanged from input. At any rate, + it shouldn't be randomly changed to unrelated values. */ + ASSERT (ts.tv_sec == 0); + ASSERT (ts.tv_nsec == 0 || ts.tv_nsec == 1); + ts.tv_nsec = 0; + ASSERT (nanosleep (&ts, NULL) == 0); + +#if HAVE_DECL_ALARM + { + const time_t pentecost = 50 * 24 * 60 * 60; /* 50 days. */ + signal (SIGALRM, handle_alarm); + alarm (1); + ts.tv_sec = pentecost; + ts.tv_nsec = 999999999; + errno = 0; + ASSERT (nanosleep (&ts, &ts) == -1); + ASSERT (errno == EINTR); + ASSERT (pentecost - 10 < ts.tv_sec && ts.tv_sec <= pentecost); + ASSERT (0 <= ts.tv_nsec && ts.tv_nsec <= 999999999); + } +#endif + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-netinet_in.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-netinet_in.c new file mode 100644 index 00000000..6842821e --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-netinet_in.c @@ -0,0 +1,27 @@ +/* Test of substitute. + Copyright (C) 2007, 2009-2024 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 . */ + +/* Written by Bruno Haible , 2007. */ + +#include + +#include + +int +main (void) +{ + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-nl_langinfo-mt.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-nl_langinfo-mt.c new file mode 100644 index 00000000..b7e16fcc --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-nl_langinfo-mt.c @@ -0,0 +1,253 @@ +/* Multithread-safety test for nl_langinfo(). + Copyright (C) 2019-2024 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 . */ + +/* Written by Bruno Haible , 2019. */ + +#include + +/* Work around GCC bug 44511. */ +#if 4 < __GNUC__ + (3 <= __GNUC_MINOR__) +# pragma GCC diagnostic ignored "-Wreturn-type" +#endif + +#if USE_ISOC_THREADS || USE_POSIX_THREADS || USE_ISOC_AND_POSIX_THREADS || USE_WINDOWS_THREADS + +/* Specification. */ +#include + +#include +#include +#include +#include +#include + +#include "glthread/thread.h" + + +/* Some common locale names. */ + +#if defined _WIN32 && !defined __CYGWIN__ +# define ENGLISH "English_United States" +# define FRENCH "French_France" +# define GERMAN "German_Germany" +# define ENCODING ".1252" +#else +# define ENGLISH "en_US" +# define FRENCH "fr_FR" +# define GERMAN "de_DE" +# if defined __sgi +# define ENCODING ".ISO8859-15" +# elif defined __hpux +# define ENCODING ".utf8" +# else +# define ENCODING ".UTF-8" +# endif +#endif + +static const char LOCALE1[] = ENGLISH ENCODING; +static const char LOCALE2[] = FRENCH ENCODING; +static const char LOCALE3[] = GERMAN ENCODING; + +static char *expected1; + +static void * +thread1_func (void *arg) +{ + for (;;) + { + const char *value = nl_langinfo (CODESET); + if (strcmp (expected1, value) != 0) + { + fprintf (stderr, "thread1 disturbed by threadN!\n"); fflush (stderr); + abort (); + } + } + + /*NOTREACHED*/ +} + +static char *expected2; + +static void * +thread2_func (void *arg) +{ + for (;;) + { + const char *value = nl_langinfo (PM_STR); + if (strcmp (expected2, value) != 0) + { + fprintf (stderr, "thread2 disturbed by threadN!\n"); fflush (stderr); + abort (); + } + } + + /*NOTREACHED*/ +} + +static char *expected3; + +static void * +thread3_func (void *arg) +{ + for (;;) + { + const char *value = nl_langinfo (DAY_2); + if (strcmp (expected3, value) != 0) + { + fprintf (stderr, "thread3 disturbed by threadN!\n"); fflush (stderr); + abort (); + } + } + + /*NOTREACHED*/ +} + +static char *expected4; + +static void * +thread4_func (void *arg) +{ + for (;;) + { + const char *value = nl_langinfo (ALTMON_2); + if (strcmp (expected4, value) != 0) + { + fprintf (stderr, "thread4 disturbed by threadN!\n"); fflush (stderr); + abort (); + } + } + + /*NOTREACHED*/ +} + +static char *expected5; + +static void * +thread5_func (void *arg) +{ + for (;;) + { + const char *value = nl_langinfo (CRNCYSTR); + if (strcmp (expected5, value) != 0) + { + fprintf (stderr, "thread5 disturbed by threadN!\n"); fflush (stderr); + abort (); + } + } + + /*NOTREACHED*/ +} + +static char *expected6; + +static void * +thread6_func (void *arg) +{ + for (;;) + { + const char *value = nl_langinfo (RADIXCHAR); + if (strcmp (expected6, value) != 0) + { + fprintf (stderr, "thread6 disturbed by threadN!\n"); fflush (stderr); + abort (); + } + } + + /*NOTREACHED*/ +} + +static void * +threadN_func (void *arg) +{ + for (;;) + { + nl_langinfo (CODESET); /* LC_CTYPE */ /* locale charmap */ + nl_langinfo (AM_STR); /* LC_TIME */ /* locale -k am_pm */ + nl_langinfo (PM_STR); /* LC_TIME */ /* locale -k am_pm */ + nl_langinfo (DAY_2); /* LC_TIME */ /* locale -k day */ + nl_langinfo (DAY_5); /* LC_TIME */ /* locale -k day */ + nl_langinfo (ALTMON_2); /* LC_TIME */ /* locale -k alt_mon */ + nl_langinfo (ALTMON_9); /* LC_TIME */ /* locale -k alt_mon */ + nl_langinfo (CRNCYSTR); /* LC_MONETARY */ /* locale -k currency_symbol */ + nl_langinfo (RADIXCHAR); /* LC_NUMERIC */ /* locale -k decimal_point */ + nl_langinfo (THOUSEP); /* LC_NUMERIC */ /* locale -k thousands_sep */ + } + + /*NOTREACHED*/ +} + +int +main (int argc, char *argv[]) +{ + if (setlocale (LC_ALL, LOCALE1) == NULL) + { + fprintf (stderr, "Skipping test: LOCALE1 not recognized\n"); + return 77; + } + if (setlocale (LC_MONETARY, LOCALE2) == NULL) + { + fprintf (stderr, "Skipping test: LOCALE2 not recognized\n"); + return 77; + } + if (setlocale (LC_NUMERIC, LOCALE3) == NULL) + { + fprintf (stderr, "Skipping test: LOCALE3 not recognized\n"); + return 77; + } + + expected1 = strdup (nl_langinfo (CODESET)); + expected2 = strdup (nl_langinfo (PM_STR)); + expected3 = strdup (nl_langinfo (DAY_2)); + expected4 = strdup (nl_langinfo (ALTMON_2)); + expected5 = strdup (nl_langinfo (CRNCYSTR)); + expected6 = strdup (nl_langinfo (RADIXCHAR)); + + /* Create the checker threads. */ + gl_thread_create (thread1_func, NULL); + gl_thread_create (thread2_func, NULL); + gl_thread_create (thread3_func, NULL); + gl_thread_create (thread4_func, NULL); + gl_thread_create (thread5_func, NULL); + gl_thread_create (thread6_func, NULL); + /* Create the disturber thread. */ + gl_thread_create (threadN_func, NULL); + + /* Let them run for 2 seconds. */ + { + struct timespec duration; + duration.tv_sec = (argc > 1 ? atoi (argv[1]) : 2); + duration.tv_nsec = 0; + + nanosleep (&duration, NULL); + } + + return 0; +} + +#else + +/* No multithreading available. */ + +#include + +int +main () +{ + fputs ("Skipping test: multithreading not enabled\n", stderr); + return 77; +} + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-nl_langinfo1.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-nl_langinfo1.c new file mode 100644 index 00000000..367e0c0c --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-nl_langinfo1.c @@ -0,0 +1,152 @@ +/* Test of nl_langinfo replacement. + Copyright (C) 2009-2024 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 . */ + +/* Written by Bruno Haible , 2009. */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (nl_langinfo, char *, (nl_item)); + +#include +#include +#include + +#include "c-strcase.h" +#include "macros.h" + +/* For GCC >= 4.3, silence the warnings + "comparison of unsigned expression >= 0 is always true" + in this file. */ +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) +# pragma GCC diagnostic ignored "-Wtype-limits" +#endif + +int +main (int argc, char *argv[]) +{ + int pass = atoi (argv[1]); + /* pass locale + 0 C + 1 traditional French locale + 2 French UTF-8 locale + */ + + setlocale (LC_ALL, ""); + + /* nl_langinfo items of the LC_CTYPE category */ + ASSERT (strlen (nl_langinfo (CODESET)) > 0); + if (pass == 2) + { + const char *codeset = nl_langinfo (CODESET); + ASSERT (c_strcasecmp (codeset, "UTF-8") == 0 || c_strcasecmp (codeset, "UTF8") == 0); + } + /* nl_langinfo items of the LC_NUMERIC category */ + ASSERT (strlen (nl_langinfo (RADIXCHAR)) > 0); + ASSERT (strlen (nl_langinfo (THOUSEP)) >= 0); + /* nl_langinfo items of the LC_TIME category */ + ASSERT (strlen (nl_langinfo (D_T_FMT)) > 0); + ASSERT (strlen (nl_langinfo (D_FMT)) > 0); + ASSERT (strlen (nl_langinfo (T_FMT)) > 0); + ASSERT (strlen (nl_langinfo (T_FMT_AMPM)) >= (pass == 0 ? 1 : 0)); + ASSERT (strlen (nl_langinfo (AM_STR)) >= (pass == 0 ? 1 : 0)); + ASSERT (strlen (nl_langinfo (PM_STR)) >= (pass == 0 ? 1 : 0)); + ASSERT (strlen (nl_langinfo (DAY_1)) > 0); + ASSERT (strlen (nl_langinfo (DAY_2)) > 0); + ASSERT (strlen (nl_langinfo (DAY_3)) > 0); + ASSERT (strlen (nl_langinfo (DAY_4)) > 0); + ASSERT (strlen (nl_langinfo (DAY_5)) > 0); + ASSERT (strlen (nl_langinfo (DAY_6)) > 0); + ASSERT (strlen (nl_langinfo (DAY_7)) > 0); + ASSERT (strlen (nl_langinfo (ABDAY_1)) > 0); + ASSERT (strlen (nl_langinfo (ABDAY_2)) > 0); + ASSERT (strlen (nl_langinfo (ABDAY_3)) > 0); + ASSERT (strlen (nl_langinfo (ABDAY_4)) > 0); + ASSERT (strlen (nl_langinfo (ABDAY_5)) > 0); + ASSERT (strlen (nl_langinfo (ABDAY_6)) > 0); + ASSERT (strlen (nl_langinfo (ABDAY_7)) > 0); + ASSERT (strlen (nl_langinfo (MON_1)) > 0); + ASSERT (strlen (nl_langinfo (MON_2)) > 0); + ASSERT (strlen (nl_langinfo (MON_3)) > 0); + ASSERT (strlen (nl_langinfo (MON_4)) > 0); + ASSERT (strlen (nl_langinfo (MON_5)) > 0); + ASSERT (strlen (nl_langinfo (MON_6)) > 0); + ASSERT (strlen (nl_langinfo (MON_7)) > 0); + ASSERT (strlen (nl_langinfo (MON_8)) > 0); + ASSERT (strlen (nl_langinfo (MON_9)) > 0); + ASSERT (strlen (nl_langinfo (MON_10)) > 0); + ASSERT (strlen (nl_langinfo (MON_11)) > 0); + ASSERT (strlen (nl_langinfo (MON_12)) > 0); + ASSERT (strlen (nl_langinfo (ALTMON_1)) > 0); + ASSERT (strlen (nl_langinfo (ALTMON_2)) > 0); + ASSERT (strlen (nl_langinfo (ALTMON_3)) > 0); + ASSERT (strlen (nl_langinfo (ALTMON_4)) > 0); + ASSERT (strlen (nl_langinfo (ALTMON_5)) > 0); + ASSERT (strlen (nl_langinfo (ALTMON_6)) > 0); + ASSERT (strlen (nl_langinfo (ALTMON_7)) > 0); + ASSERT (strlen (nl_langinfo (ALTMON_8)) > 0); + ASSERT (strlen (nl_langinfo (ALTMON_9)) > 0); + ASSERT (strlen (nl_langinfo (ALTMON_10)) > 0); + ASSERT (strlen (nl_langinfo (ALTMON_11)) > 0); + ASSERT (strlen (nl_langinfo (ALTMON_12)) > 0); + /* In the tested locales, alternate month names and month names ought to be + the same. */ + ASSERT (strcmp (nl_langinfo (ALTMON_1), nl_langinfo (MON_1)) == 0); + ASSERT (strcmp (nl_langinfo (ALTMON_2), nl_langinfo (MON_2)) == 0); + ASSERT (strcmp (nl_langinfo (ALTMON_3), nl_langinfo (MON_3)) == 0); + ASSERT (strcmp (nl_langinfo (ALTMON_4), nl_langinfo (MON_4)) == 0); + ASSERT (strcmp (nl_langinfo (ALTMON_5), nl_langinfo (MON_5)) == 0); + ASSERT (strcmp (nl_langinfo (ALTMON_6), nl_langinfo (MON_6)) == 0); + ASSERT (strcmp (nl_langinfo (ALTMON_7), nl_langinfo (MON_7)) == 0); + ASSERT (strcmp (nl_langinfo (ALTMON_8), nl_langinfo (MON_8)) == 0); + ASSERT (strcmp (nl_langinfo (ALTMON_9), nl_langinfo (MON_9)) == 0); + ASSERT (strcmp (nl_langinfo (ALTMON_10), nl_langinfo (MON_10)) == 0); + ASSERT (strcmp (nl_langinfo (ALTMON_11), nl_langinfo (MON_11)) == 0); + ASSERT (strcmp (nl_langinfo (ALTMON_12), nl_langinfo (MON_12)) == 0); + ASSERT (strlen (nl_langinfo (ABMON_1)) > 0); + ASSERT (strlen (nl_langinfo (ABMON_2)) > 0); + ASSERT (strlen (nl_langinfo (ABMON_3)) > 0); + ASSERT (strlen (nl_langinfo (ABMON_4)) > 0); + ASSERT (strlen (nl_langinfo (ABMON_5)) > 0); + ASSERT (strlen (nl_langinfo (ABMON_6)) > 0); + ASSERT (strlen (nl_langinfo (ABMON_7)) > 0); + ASSERT (strlen (nl_langinfo (ABMON_8)) > 0); + ASSERT (strlen (nl_langinfo (ABMON_9)) > 0); + ASSERT (strlen (nl_langinfo (ABMON_10)) > 0); + ASSERT (strlen (nl_langinfo (ABMON_11)) > 0); + ASSERT (strlen (nl_langinfo (ABMON_12)) > 0); + ASSERT (strlen (nl_langinfo (ERA)) >= 0); + ASSERT (strlen (nl_langinfo (ERA_D_FMT)) >= 0); + ASSERT (strlen (nl_langinfo (ERA_D_T_FMT)) >= 0); + ASSERT (strlen (nl_langinfo (ERA_T_FMT)) >= 0); + ASSERT (nl_langinfo (ALT_DIGITS) != NULL); + /* nl_langinfo items of the LC_MONETARY category */ + { + const char *currency = nl_langinfo (CRNCYSTR); + ASSERT (strlen (currency) >= 0); +#if !(defined MUSL_LIBC || defined __NetBSD__) + if (pass > 0) + ASSERT (strlen (currency) >= 1); +#endif + } + /* nl_langinfo items of the LC_MESSAGES category */ + ASSERT (strlen (nl_langinfo (YESEXPR)) > 0); + ASSERT (strlen (nl_langinfo (NOEXPR)) > 0); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-nl_langinfo1.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-nl_langinfo1.sh new file mode 100755 index 00000000..9acfcdd9 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-nl_langinfo1.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +LC_ALL=C ${CHECKER} ./test-nl_langinfo1${EXEEXT} 0 || exit 1 + +# Test whether a specific traditional locale is installed. +: "${LOCALE_FR=fr_FR}" +if test $LOCALE_FR != none; then + LC_ALL=$LOCALE_FR ${CHECKER} ./test-nl_langinfo1${EXEEXT} 1 || exit 1 +fi + +# Test whether a specific UTF-8 locale is installed. +: "${LOCALE_FR_UTF8=fr_FR.UTF-8}" +if test $LOCALE_FR_UTF8 != none; then + LC_ALL=$LOCALE_FR_UTF8 ${CHECKER} ./test-nl_langinfo1${EXEEXT} 2 || exit 1 +fi + +exit 0 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-nl_langinfo2.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-nl_langinfo2.c new file mode 100644 index 00000000..0b8688a6 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-nl_langinfo2.c @@ -0,0 +1,146 @@ +/* Test of nl_langinfo replacement. + Copyright (C) 2023-2024 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 . */ + +/* Written by Bruno Haible , 2023. */ + +#include + +#include + +#include +#include +#include + +#include "c-strcase.h" +#include "c-strcasestr.h" +#include "macros.h" + +int +main (int argc, char *argv[]) +{ +#if HAVE_WORKING_USELOCALE + /* Check that nl_langinfo() uses the per-thread locale. */ + int pass; + bool skipped_all = true; + + /* Extract a few items from the C locale. */ + /* nl_langinfo items of the LC_CTYPE category */ + const char *c_CODESET = nl_langinfo (CODESET); + /* nl_langinfo items of the LC_NUMERIC category */ + const char *c_RADIXCHAR = nl_langinfo (RADIXCHAR); + /* nl_langinfo items of the LC_TIME category */ + const char *c_T_FMT_AMPM = nl_langinfo (T_FMT_AMPM); + const char *c_AM_STR = nl_langinfo (AM_STR); + const char *c_PM_STR = nl_langinfo (PM_STR); + /* nl_langinfo items of the LC_MONETARY category */ + const char *c_CRNCYSTR = nl_langinfo (CRNCYSTR); + /* nl_langinfo items of the LC_MESSAGES category */ + const char *c_YESEXPR = nl_langinfo (YESEXPR); + + /* Sanity checks. */ + (void) c_CODESET; + ASSERT (strcmp (c_RADIXCHAR, ".") == 0); + ASSERT (strlen (c_T_FMT_AMPM) > 0); + ASSERT (strlen (c_AM_STR) > 0); + ASSERT (strlen (c_PM_STR) > 0); + ASSERT (strlen (c_CRNCYSTR) <= 1); /* "-", "+", ".", or "" */ + ASSERT (c_strcasestr (c_YESEXPR, "y" /* from "yes" */) != NULL); + + for (pass = 1; pass <= 2; pass++) + { + /* pass locale + 1 traditional French locale + 2 French UTF-8 locale + */ + const char *fr_locale_name = + getenv (pass == 1 ? "LOCALE_FR" : "LOCALE_FR_UTF8"); + if (strcmp (fr_locale_name, "none") != 0) + { + /* Use a per-thread locale. */ + locale_t fr_locale = newlocale (LC_ALL_MASK, fr_locale_name, NULL); + if (fr_locale != NULL) + { + uselocale (fr_locale); + + /* Extract a few items from the current locale, and check the + values. */ + + /* nl_langinfo items of the LC_CTYPE category */ + const char *fr_CODESET = nl_langinfo (CODESET); + if (pass == 1) + ASSERT (strstr (fr_CODESET, "8859") != NULL); + else if (pass == 2) + ASSERT (c_strcasecmp (fr_CODESET, "UTF-8") == 0 + || c_strcasecmp (fr_CODESET, "UTF8") == 0); + + /* In musl libc, locales differ at most in the LC_MESSAGES + category. */ + #if !defined MUSL_LIBC + + /* nl_langinfo items of the LC_NUMERIC category */ + const char *fr_RADIXCHAR = nl_langinfo (RADIXCHAR); + ASSERT (strcmp (fr_RADIXCHAR, ",") == 0); + + /* nl_langinfo items of the LC_TIME category */ + /* macOS and Solaris 11 don't get the LC_TIME values right. + Poor. */ + #if !((defined __APPLE__ && defined __MACH__) || defined __sun) + const char *fr_T_FMT_AMPM = nl_langinfo (T_FMT_AMPM); + const char *fr_AM_STR = nl_langinfo (AM_STR); + const char *fr_PM_STR = nl_langinfo (PM_STR); + ASSERT (strlen (fr_T_FMT_AMPM) == 0 + || strcmp (fr_T_FMT_AMPM, "%I:%M:%S") == 0); + ASSERT (strlen (fr_AM_STR) == 0); + ASSERT (strlen (fr_PM_STR) == 0); + #endif + + /* nl_langinfo items of the LC_MONETARY category */ + /* macOS doesn't get the EUR currency symbol or abbreviation + right. Very poor. */ + #if !(defined __APPLE__ && defined __MACH__) + const char *fr_CRNCYSTR = nl_langinfo (CRNCYSTR); + if (pass == 2) + ASSERT (strlen (fr_CRNCYSTR) >= 1 + && strcmp (fr_CRNCYSTR + 1, "€") == 0); + #endif + + #endif + + /* nl_langinfo items of the LC_MESSAGES category */ + /* In musl libc, this works only if the package 'musl-locales' is + installed. */ + #if !defined MUSL_LIBC + const char *fr_YESEXPR = nl_langinfo (YESEXPR); + ASSERT (c_strcasestr (fr_YESEXPR, "o" /* from "oui" */) != NULL); + #endif + + skipped_all = false; + } + } + } + + if (skipped_all) + { + fputs ("Skipping test: French locale is not installed\n", stderr); + return 77; + } + + return 0; +#else + fputs ("Skipping test: uselocale() not available\n", stderr); + return 77; +#endif +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-nl_langinfo2.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-nl_langinfo2.sh new file mode 100755 index 00000000..6333c900 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-nl_langinfo2.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +# The name of a specific traditional locale. +: "${LOCALE_FR=fr_FR}" + +# The name of a specific UTF-8 locale. +: "${LOCALE_FR_UTF8=fr_FR.UTF-8}" + +# Make them accessible as environment variables. +export LOCALE_FR LOCALE_FR_UTF8 + +${CHECKER} ./test-nl_langinfo2${EXEEXT} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-nstrftime.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-nstrftime.c new file mode 100644 index 00000000..87d6a351 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-nstrftime.c @@ -0,0 +1,349 @@ +/* Test that nstrftime works as required. + Copyright (C) 2011-2024 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 . */ + +/* Written by Jim Meyering. */ + +#include + +#include "strftime.h" + +#include "intprops.h" + +#include +#include +#include +#include +#include +#include + +#include "macros.h" +#define STREQ(a, b) (strcmp (a, b) == 0) + +/* Support for settings like TZ='<+00>0' was added in IEEE Std 1003.1-2001. */ +#define TZ_ANGLE_BRACKETS_SHOULD_WORK (200112 <= _POSIX_VERSION) + +struct posixtm_test +{ + time_t in; + int in_ns; + char const *fmt; + char const *exp; +}; + +static struct posixtm_test const T[] = + { + { 1300000000, 0, "%F", "2011-03-13" }, + { 0, 10, "%T.%N", "00:00:00.000000010" }, + { 56, 123456789, "%T.%12N", "00:00:56.123456789000" }, + { 0, 0, NULL, NULL } + }; + +static int +posixtm_test (void) +{ + int fail = 0; + unsigned int i; + + for (i = 0; T[i].fmt; i++) + { + char buf[1000]; + time_t t = T[i].in; + struct tm *tm = gmtime (&t); + size_t n; + + ASSERT (tm); + + n = nstrftime (buf, sizeof buf, T[i].fmt, tm, 0, T[i].in_ns); + if (n == 0) + { + fail = 1; + printf ("nstrftime failed with format %s\n", T[i].fmt); + } + + if (! STREQ (buf, T[i].exp)) + { + fail = 1; + printf ("%s: result mismatch: got %s, expected %s\n", + T[i].fmt, buf, T[i].exp); + } + } + + return fail; +} + +struct tzalloc_test +{ + timezone_t tz; + char const *setting; +}; + +static struct tzalloc_test TZ[] = + { +#define Pacific 0 + { 0, "PST8PDT,M3.2.0,M11.1.0" }, +#define Arizona 1 + { 0, "MST7" }, +#define UTC 2 + { 0, 0 }, +#define CentEur 3 + { 0, "CET-1CEST,M3.5.0,M10.5.0/3" }, +#define Japan 4 + { 0, "JST-9" }, +#define NZ 5 + { 0, "NZST-12NZDT,M9.5.0,M4.1.0/3" }, +#define Unknown 6 + { 0, "<-00>0" }, + { 0 } + }; + +struct localtime_rz_test +{ + /* Input parameters. */ + struct tzalloc_test *tza; + time_t t; + + /* Expected result. */ + char const *exp; + + /* Determines if an incorrectly unset tm_isdst + results in failure or just a warning. */ + int ahistorical; +}; + +static struct localtime_rz_test LT[] = + { +#if !(defined __DragonFly__ || defined __NetBSD__ || defined __ANDROID__) + { TZ+Pacific, 0, "1969-12-31 16:00:00 -0800 (PST)", 0 }, +#endif + { TZ+Arizona, 0, "1969-12-31 17:00:00 -0700 (MST)", 0 }, + { TZ+UTC , 0, "1970-01-01 00:00:00 +0000 (UTC)", 0 }, +#if !(defined __DragonFly__ || defined __NetBSD__ || defined __ANDROID__) + { TZ+CentEur, 0, "1970-01-01 01:00:00 +0100 (CET)", 0 }, +#endif + { TZ+Japan , 0, "1970-01-01 09:00:00 +0900 (JST)", 0 }, +#if !defined __FreeBSD__ + { TZ+NZ , 0, "1970-01-01 13:00:00 +1300 (NZDT)", 1 }, +#endif + { TZ+Pacific, 500000001, "1985-11-04 16:53:21 -0800 (PST)", 0 }, + { TZ+Arizona, 500000001, "1985-11-04 17:53:21 -0700 (MST)", 0 }, + { TZ+UTC , 500000001, "1985-11-05 00:53:21 +0000 (UTC)", 0 }, + { TZ+CentEur, 500000001, "1985-11-05 01:53:21 +0100 (CET)", 1 }, + { TZ+Japan , 500000001, "1985-11-05 09:53:21 +0900 (JST)", 0 }, + { TZ+NZ , 500000001, "1985-11-05 13:53:21 +1300 (NZDT)", 0 }, + { TZ+Pacific, 1000000002, "2001-09-08 18:46:42 -0700 (PDT)", 0 }, + { TZ+Arizona, 1000000002, "2001-09-08 18:46:42 -0700 (MST)", 0 }, + { TZ+UTC , 1000000002, "2001-09-09 01:46:42 +0000 (UTC)", 0 }, + { TZ+CentEur, 1000000002, "2001-09-09 03:46:42 +0200 (CEST)", 0 }, + { TZ+Japan , 1000000002, "2001-09-09 10:46:42 +0900 (JST)", 0 }, + { TZ+NZ , 1000000002, "2001-09-09 13:46:42 +1200 (NZST)", 0 }, +#if TZ_ANGLE_BRACKETS_SHOULD_WORK && !defined __FreeBSD__ + { TZ+Unknown, 0, "1970-01-01 00:00:00 -0000 (-00)", 0 }, + { TZ+Unknown, 500000001, "1985-11-05 00:53:21 -0000 (-00)", 0 }, + { TZ+Unknown, 1000000002, "2001-09-09 01:46:42 -0000 (-00)", 0 }, +#endif + { 0 } + }; + +static int +tzalloc_test (void) +{ + int fail = 0; + int i; + + for (i = 0; LT[i].tza; i++) + { + struct tzalloc_test *tza = LT[i].tza; + long lt = LT[i].t; + timezone_t tz = tza->tz; + char const *setting; + static char const format[] = "%Y-%m-%d %H:%M:%S %z (%Z)"; + char buf[1000]; + struct tm tm; + size_t n; + + if (!tz && tza->setting) + { + tz = tzalloc (tza->setting); + if (!tz) + { + fail = 1; + printf ("%s: tzalloc: %s\n", TZ[i].setting, strerror (errno)); + continue; + } + tza->tz = tz; + } + + setting = tza->setting ? tza->setting : "UTC0"; + + if (!localtime_rz (tz, <[i].t, &tm)) + { + fail = 1; + printf ("%s: %ld: localtime_rz: %s\n", setting, lt, + strerror (errno)); + continue; + } + + n = nstrftime (buf, sizeof buf, format, &tm, tz, 0); + if (n == 0) + { + fail = 1; + printf ("%s: %ld: nstrftime failed\n", setting, lt); + continue; + } + + if (! (STREQ (buf, LT[i].exp) + || (!tz && n == strlen (LT[i].exp) + && memcmp (buf, LT[i].exp, n - sizeof "(GMT)" + 1) == 0 + && STREQ (buf + n - sizeof "(GMT)" + 1, "(GMT)")))) + { + /* Don't fail for unhandled dst in ahistorical entries, + as gnulib doesn't currently fix that issue, seen on Darwin 14. */ + if (!LT[i].ahistorical || tm.tm_isdst) + fail = 1; + printf ("%s: expected \"%s\", got \"%s\"\n", + setting, LT[i].exp, buf); + } + } + + return fail; +} + + +static int +quarter_test (void) +{ + int result = 0; + size_t mon; + + /* Check %q. */ + for (mon = 1; mon <= 12; mon++) + { + char out[2]; + char exp[2] = {0,}; + struct tm qtm = { .tm_mon = mon - 1 }; + char fmt[3] = {'%','q','\0'}; + + size_t r = nstrftime (out, sizeof (out), fmt, &qtm, 0, 0); + if (r == 0) + { + puts ("nstrftime(\"%q\") failed"); + result = 1; + break; + } + + exp[0] = mon < 4 ? '1' : mon < 7 ? '2' : mon < 10 ? '3' : '4'; + if (strcmp (out, exp) != 0) + { + printf ("nstrftime %%q: expected \"%s\", got \"%s\"\n", exp, out); + result = 1; + break; + } + } + + return result; +} + +static int +errno_test (void) +{ + int fail = 0; + struct tm tm = { .tm_year = 2020 - 1900, .tm_mday = 1 }; + char buf[INT_BUFSIZE_BOUND (time_t)]; + size_t n; + int bigyear = LLONG_MAX - 1900 < INT_MAX ? LLONG_MAX - 1900 : INT_MAX; + + errno = 0; + n = nstrftime (buf, 0, "%m", &tm, 0, 0); + if (! (n == 0 && errno == ERANGE)) + { + fail = 1; + printf ("nstrftime failed to set errno = ERANGE\n"); + } + + errno = 0; + n = nstrftime (buf, sizeof buf, "", &tm, 0, 0); + if (! (n == 0 && errno == 0)) + { + fail = 1; + printf ("nstrftime failed to leave errno alone\n"); + } + + + tm.tm_year = bigyear; + errno = 0; + n = nstrftime (buf, sizeof buf, "%s", &tm, 0, 0); + if (n == 0) + { + if (errno != EOVERFLOW) + { + fail = 1; + printf ("nstrftime failed to set errno = EOVERFLOW\n"); + } + + if (mktime_z (0, &tm) != (time_t) -1) + { + fail = 1; + printf ("nstrftime %%s failed but mktime_z worked for tm_year=%d\n", + bigyear); + } + } + else + { + long long int text_seconds = atoll (buf); + if (text_seconds <= (LLONG_MAX - 1 < TYPE_MAXIMUM (time_t) + ? LLONG_MAX - 1 : TYPE_MAXIMUM (time_t))) + { + time_t bigtime = text_seconds; + struct tm *tmp = gmtime (&bigtime); + if (!tmp) + { + fail = 1; + printf ("gmtime failed on nstrftime result\n"); + } + else + { + char buf1[sizeof buf]; + size_t n1 = nstrftime (buf1, sizeof buf1, "%s", tmp, 0, 0); + buf1[n1] = '\0'; + if (! STREQ (buf, buf1)) + { + fail = 1; + printf ("nstrftime %%s first returned '%s', then '%s'\n", + buf, buf1); + } + } + } + } + + return fail; +} + +int +main (void) +{ + int fail = 0; + fail |= posixtm_test (); + fail |= tzalloc_test (); + fail |= quarter_test (); + fail |= errno_test (); + return fail; +} + +/* +Local Variables: +indent-tabs-mode: nil +End: +*/ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-nullptr.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-nullptr.c new file mode 100644 index 00000000..5c8f99e6 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-nullptr.c @@ -0,0 +1,69 @@ +/* Test nullptr. + Copyright 2023-2024 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 . */ + +/* Written by Bruno Haible. */ + +#include + +int *my_null = nullptr; + +#if 0 /* not yet */ +/* Header that is supposed to define nullptr_t. */ +# include +#endif + +#include + +#include "macros.h" + +#if 0 /* not yet */ + +static void +simple_callee (nullptr_t x) +{ + ASSERT (x == NULL); +} + +#endif + +static void +varargs_callee (const char *first, ...) +{ + va_list args; + const char *arg; + + ASSERT (first[0] == 't'); + va_start (args, first); + + arg = va_arg (args, const char *); + ASSERT (arg == NULL); + + arg = va_arg (args, const char *); + ASSERT (arg[0] == 'f'); + + arg = va_arg (args, const char *); + ASSERT (arg == NULL); + + va_end (args); +} + +int +main () +{ + varargs_callee ("type", nullptr, "foo", nullptr); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-open.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-open.c new file mode 100644 index 00000000..52e72be9 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-open.c @@ -0,0 +1,40 @@ +/* Test of opening a file descriptor. + Copyright (C) 2007-2024 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 . */ + +/* Written by Bruno Haible , 2007. */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (open, int, (char const *, int, ...)); + +#include +#include +#include + +#include "macros.h" + +#define BASE "test-open.t" + +#include "test-open.h" + +int +main (void) +{ + return test_open (open, true); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-open.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-open.h new file mode 100644 index 00000000..05764356 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-open.h @@ -0,0 +1,138 @@ +/* Test of opening a file descriptor. + Copyright (C) 2007-2024 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 . */ + +/* Written by Bruno Haible , 2007. */ + +/* Tell GCC not to warn about the specific edge cases tested here. */ +#if __GNUC__ >= 13 +# pragma GCC diagnostic ignored "-Wanalyzer-fd-leak" +#endif + +/* Make test_open always inline if we're using Fortify, which defines + __always_inline to do that. Do nothing otherwise. This works + around a glibc bug whereby 'open' cannot be used as a function + pointer when _FORTIFY_SOURCE is positive. */ + +#if __GLIBC__ && defined __always_inline +# define ALWAYS_INLINE __always_inline +#else +# define ALWAYS_INLINE +#endif + +/* This file is designed to test both open(n,buf[,mode]) and + openat(AT_FDCWD,n,buf[,mode]). FUNC is the function to test. + Assumes that BASE and ASSERT are already defined, and that + appropriate headers are already included. If PRINT, warn before + skipping symlink tests with status 77. */ + +static ALWAYS_INLINE int +test_open (int (*func) (char const *, int, ...), bool print) +{ + int fd; + + /* Remove anything from prior partial run. */ + unlink (BASE "file"); + unlink (BASE "e.exe"); + unlink (BASE "link"); + + /* Cannot create directory. */ + errno = 0; + ASSERT (func ("nonexist.ent/", O_CREAT | O_RDONLY, 0600) == -1); + ASSERT (errno == ENOTDIR || errno == EISDIR || errno == ENOENT + || errno == EINVAL); + + /* Create a regular file. */ + fd = func (BASE "file", O_CREAT | O_RDONLY, 0600); + ASSERT (0 <= fd); + ASSERT (close (fd) == 0); + + /* Create an executable regular file. */ + fd = func (BASE "e.exe", O_CREAT | O_RDONLY, 0700); + ASSERT (0 <= fd); + ASSERT (close (fd) == 0); + + /* Trailing slash handling. */ + errno = 0; + ASSERT (func (BASE "file/", O_RDONLY) == -1); + ASSERT (errno == ENOTDIR || errno == EISDIR || errno == EINVAL); + + /* Directories cannot be opened for writing. */ + errno = 0; + ASSERT (func (".", O_WRONLY) == -1); + ASSERT (errno == EISDIR || errno == EACCES); + + /* /dev/null must exist, and be writable. */ + fd = func ("/dev/null", O_RDONLY); + ASSERT (0 <= fd); + { + char c; + ASSERT (read (fd, &c, 1) == 0); + } + ASSERT (close (fd) == 0); + fd = func ("/dev/null", O_WRONLY); + ASSERT (0 <= fd); + ASSERT (write (fd, "c", 1) == 1); + ASSERT (close (fd) == 0); + + /* Although O_NONBLOCK on regular files can be ignored, it must not + cause a failure. */ + fd = func (BASE "file", O_NONBLOCK | O_RDONLY); + ASSERT (0 <= fd); + ASSERT (close (fd) == 0); + + /* O_CLOEXEC must be honoured. */ + if (O_CLOEXEC) + { + /* Since the O_CLOEXEC handling goes through a special code path at its + first invocation, test it twice. */ + int i; + + for (i = 0; i < 2; i++) + { + int flags; + + fd = func (BASE "file", O_CLOEXEC | O_RDONLY); + ASSERT (0 <= fd); + flags = fcntl (fd, F_GETFD); + ASSERT (flags >= 0); + ASSERT ((flags & FD_CLOEXEC) != 0); + ASSERT (close (fd) == 0); + } + } + + /* Symlink handling, where supported. */ + if (symlink (BASE "file", BASE "link") != 0) + { + ASSERT (unlink (BASE "file") == 0); + if (print) + fputs ("skipping test: symlinks not supported on this file system\n", + stderr); + return 77; + } + errno = 0; + ASSERT (func (BASE "link/", O_RDONLY) == -1); + ASSERT (errno == ENOTDIR); + fd = func (BASE "link", O_RDONLY); + ASSERT (0 <= fd); + ASSERT (close (fd) == 0); + + /* Cleanup. */ + ASSERT (unlink (BASE "file") == 0); + ASSERT (unlink (BASE "e.exe") == 0); + ASSERT (unlink (BASE "link") == 0); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-openat.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-openat.c new file mode 100644 index 00000000..6ae3e3e2 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-openat.c @@ -0,0 +1,98 @@ +/* Test that openat works. + Copyright (C) 2009-2024 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 . */ + +/* Written by Eric Blake , 2009. */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (openat, int, (int, char const *, int, ...)); + +#include +#include +#include +#include + +#include "macros.h" + +#define BASE "test-openat.t" + +#include "test-open.h" + +static int dfd = AT_FDCWD; + +/* Wrapper around openat to test open behavior. */ +static int +do_open (char const *name, int flags, ...) +{ + if (flags & O_CREAT) + { + mode_t mode = 0; + va_list arg; + va_start (arg, flags); + + /* We have to use PROMOTED_MODE_T instead of mode_t, otherwise GCC 4 + creates crashing code when 'mode_t' is smaller than 'int'. */ + mode = va_arg (arg, PROMOTED_MODE_T); + + va_end (arg); + return openat (dfd, name, flags, mode); + } + return openat (dfd, name, flags); +} + +int +main () +{ + int result; + + /* Test behaviour for invalid file descriptors. */ + { + errno = 0; + ASSERT (openat (-1, "foo", O_RDONLY) == -1); + ASSERT (errno == EBADF); + } + { + close (99); + errno = 0; + ASSERT (openat (99, "foo", O_RDONLY) == -1); + ASSERT (errno == EBADF); + } + + /* Basic checks. */ + result = test_open (do_open, false); + dfd = open (".", O_RDONLY); + ASSERT (0 <= dfd); + ASSERT (test_open (do_open, false) == result); + ASSERT (close (dfd) == 0); + + /* Check that even when *-safer modules are in use, plain openat can + land in fd 0. Do this test last, since it is destructive to + stdin. */ + ASSERT (close (STDIN_FILENO) == 0); + ASSERT (openat (AT_FDCWD, ".", O_RDONLY) == STDIN_FILENO); + { + dfd = open (".", O_RDONLY); + ASSERT (STDIN_FILENO < dfd); + ASSERT (chdir ("..") == 0); + ASSERT (close (STDIN_FILENO) == 0); + ASSERT (openat (dfd, ".", O_RDONLY) == STDIN_FILENO); + ASSERT (close (dfd) == 0); + } + return result; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-pathmax.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-pathmax.c new file mode 100644 index 00000000..a80ee065 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-pathmax.c @@ -0,0 +1,32 @@ +/* Test of "pathmax.h". + Copyright (C) 2011-2024 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 . */ + +/* Written by Bruno Haible , 2011. */ + +#include + +#include "pathmax.h" + +/* Check that PATH_MAX is a constant if it is defined. */ +#ifdef PATH_MAX +int a = PATH_MAX; +#endif + +int +main (void) +{ + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-perror.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-perror.c new file mode 100644 index 00000000..aba12fa1 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-perror.c @@ -0,0 +1,36 @@ +/* Test of perror() function. + Copyright (C) 2008-2024 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 . */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (perror, void, (char const *)); + +#include + +int +main (int argc, char **argv) +{ + const char *prefix = (argc > 1 ? argv[1] : NULL); + + errno = EACCES; perror (prefix); + errno = ETIMEDOUT; perror (prefix); + errno = EOVERFLOW; perror (prefix); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-perror.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-perror.sh new file mode 100755 index 00000000..e6244413 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-perror.sh @@ -0,0 +1,26 @@ +#!/bin/sh +: "${srcdir=.}" +. "$srcdir/init.sh"; path_prepend_ . + +# Test NULL prefix. Result should not contain a number, except in lines that +# start with 'EDC' (IBM z/OS libc produces an error identifier before the +# error message). +${CHECKER} test-perror 2>&1 >/dev/null | LC_ALL=C tr -d '\r' > t-perror.tmp +grep -v '^EDC' t-perror.tmp | grep '[0-9]' > /dev/null \ + && fail_ "result should not contain a number" + +# Test empty prefix. Result should be the same. +${CHECKER} test-perror '' 2>&1 >/dev/null | LC_ALL=C tr -d '\r' > t-perror1.tmp +diff t-perror.tmp t-perror1.tmp \ + || fail_ "empty prefix should behave like NULL argument" + +# Test non-empty prefix. +${CHECKER} test-perror foo 2>&1 >/dev/null | LC_ALL=C tr -d '\r' > t-perror3.tmp +sed -e 's/^/foo: /' < t-perror.tmp > t-perror2.tmp +diff t-perror2.tmp t-perror3.tmp || fail_ "prefix applied incorrectly" + +# Test exit status. +${CHECKER} test-perror >out 2>/dev/null || fail_ "unexpected exit status" +test -s out && fail_ "unexpected output" + +Exit 0 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-perror2.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-perror2.c new file mode 100644 index 00000000..edf1d15f --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-perror2.c @@ -0,0 +1,138 @@ +/* Test of perror() function. + Copyright (C) 2011-2024 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 . */ + +#include + +#include + +#include +#include +#include + +/* Tell GCC not to warn about myerr being leaked. */ +#if __GNUC__ >= 13 +# pragma GCC diagnostic ignored "-Wanalyzer-fd-leak" +#endif + +/* This test intentionally parses stderr. So, we arrange to have fd 10 + (outside the range of interesting fd's during the test) set up to + duplicate the original stderr. */ +#define BACKUP_STDERR_FILENO 10 +#define ASSERT_STREAM myerr +#include "macros.h" + +static FILE *myerr; + +#define BASE "test-perror2" + +int +main (void) +{ + /* We change fd 2 later, so save it in fd 10. */ + if (dup2 (STDERR_FILENO, BACKUP_STDERR_FILENO) != BACKUP_STDERR_FILENO + || (myerr = fdopen (BACKUP_STDERR_FILENO, "w")) == NULL) + return 2; + + ASSERT (freopen (BASE ".tmp", "w+", stderr) == stderr); + + /* Test that perror does not clobber strerror buffer. */ + { + const char *msg1; + const char *msg2; + const char *msg3; + const char *msg4; + char *str1; + char *str2; + char *str3; + char *str4; + + msg1 = strerror (ENOENT); + ASSERT (msg1); + str1 = strdup (msg1); + ASSERT (str1); + + msg2 = strerror (ERANGE); + ASSERT (msg2); + str2 = strdup (msg2); + ASSERT (str2); + + msg3 = strerror (-4); + ASSERT (msg3); + str3 = strdup (msg3); + ASSERT (str3); + + msg4 = strerror (1729576); + ASSERT (msg4); + str4 = strdup (msg4); + ASSERT (str4); + + errno = EACCES; + perror (""); + errno = -5; + perror (""); + ASSERT (!ferror (stderr)); + ASSERT (STREQ (msg4, str4)); + + free (str1); + free (str2); + free (str3); + free (str4); + } + + /* Test that perror uses the same message as strerror. */ + { + int errs[] = { EACCES, 0, -3, }; + int i; + for (i = 0; i < SIZEOF (errs); i++) + { + char buf[256]; + const char *err = strerror (errs[i]); + + ASSERT (err); + ASSERT (strlen (err) < sizeof buf); + rewind (stderr); + ASSERT (ftruncate (fileno (stderr), 0) == 0); + errno = errs[i]; + perror (NULL); + ASSERT (!ferror (stderr)); + rewind (stderr); + ASSERT (fgets (buf, sizeof buf, stderr) == buf); + ASSERT (strstr (buf, err)); + } + } + + /* Test that perror reports write failure. */ + { + ASSERT (freopen (BASE ".tmp", "r", stderr) == stderr); + ASSERT (setvbuf (stderr, NULL, _IONBF, BUFSIZ) == 0); + errno = -1; + ASSERT (!ferror (stderr)); + perror (NULL); +#if 0 + /* Commented out until cygwin behaves: + https://sourceware.org/ml/newlib/2011/msg00228.html */ + ASSERT (errno > 0); + /* Commented out until glibc behaves: + https://sourceware.org/bugzilla/show_bug.cgi?id=12792 */ + ASSERT (ferror (stderr)); +#endif + } + + ASSERT (fclose (stderr) == 0); + ASSERT (remove (BASE ".tmp") == 0); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-pipe.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-pipe.c new file mode 100644 index 00000000..e9ebe162 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-pipe.c @@ -0,0 +1,107 @@ +/* Test of pipe. + Copyright (C) 2009-2024 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 . */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (pipe, int, (int[2])); + +#include + +#if defined _WIN32 && ! defined __CYGWIN__ +/* Get declarations of the native Windows API functions. */ +# define WIN32_LEAN_AND_MEAN +# include +/* Get _get_osfhandle. */ +# if GNULIB_MSVC_NOTHROW +# include "msvc-nothrow.h" +# else +# include +# endif +#endif + +#include "binary-io.h" +#include "macros.h" + +/* Return true if FD is open. */ +static bool +is_open (int fd) +{ +#if defined _WIN32 && ! defined __CYGWIN__ + /* On native Windows, the initial state of unassigned standard file + descriptors is that they are open but point to an + INVALID_HANDLE_VALUE, and there is no fcntl. */ + return (HANDLE) _get_osfhandle (fd) != INVALID_HANDLE_VALUE; +#else +# ifndef F_GETFL +# error Please port fcntl to your platform +# endif + return 0 <= fcntl (fd, F_GETFL); +#endif +} + +/* Return true if FD is not inherited to child processes. */ +static bool +is_cloexec (int fd) +{ +#if defined _WIN32 && ! defined __CYGWIN__ + HANDLE h = (HANDLE) _get_osfhandle (fd); + DWORD flags; + ASSERT (GetHandleInformation (h, &flags)); + return (flags & HANDLE_FLAG_INHERIT) == 0; +#else + int flags; + ASSERT ((flags = fcntl (fd, F_GETFD)) >= 0); + return (flags & FD_CLOEXEC) != 0; +#endif +} + +/* Return true if FD is in non-blocking mode. */ +static bool +is_nonblocking (int fd) +{ +#if defined _WIN32 && ! defined __CYGWIN__ + /* We don't use the non-blocking mode for sockets here. */ + return 0; +#else + int flags; + ASSERT ((flags = fcntl (fd, F_GETFL)) >= 0); + return (flags & O_NONBLOCK) != 0; +#endif +} + +int +main () +{ + int fd[2]; + + fd[0] = -1; + fd[1] = -1; + ASSERT (pipe (fd) >= 0); + ASSERT (fd[0] >= 0); + ASSERT (fd[1] >= 0); + ASSERT (fd[0] != fd[1]); + ASSERT (is_open (fd[0])); + ASSERT (is_open (fd[1])); + ASSERT (!is_cloexec (fd[0])); + ASSERT (!is_cloexec (fd[1])); + ASSERT (!is_nonblocking (fd[0])); + ASSERT (!is_nonblocking (fd[1])); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-popen.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-popen.c new file mode 100644 index 00000000..31e823e2 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-popen.c @@ -0,0 +1,28 @@ +/* Test of opening a subcommand stream. + Copyright (C) 2009-2024 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 . */ + +/* Written by Eric Blake , 2009. */ + +#include + +/* Specification. */ +#include + +#include "signature.h" +SIGNATURE_CHECK (popen, FILE *, (char const *, char const *)); +SIGNATURE_CHECK (pclose, int, (FILE *)); + +#include "test-popen.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-popen.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-popen.h new file mode 100644 index 00000000..b7009bec --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-popen.h @@ -0,0 +1,93 @@ +/* Test of opening a subcommand stream. + Copyright (C) 2009-2024 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 . */ + +/* Written by Eric Blake , 2009. */ + +/* Include and a form of first. */ + +/* Helpers. */ +#include +#include +#include +#include + +#include "macros.h" + +int +main (int argc, char **argv) +{ + size_t len; + char *cmd; + int i; + + /* Children - use the pipe. */ + if (argc > 1) + { + if (*argv[1] == 'r') /* Parent is reading, so we write. */ + ASSERT (putchar ('c') == 'c'); + else /* Parent is writing, so we read. */ + ASSERT (getchar () == 'p'); + /* Test that parent can read non-zero status. */ + return 42; + } + + /* Parent - create read and write child, once under normal + circumstances and once with stdin and stdout closed. */ + len = strlen (argv[0]); + cmd = malloc (len + 3); /* Adding " r" and NUL. */ + ASSERT (cmd); + /* We count on argv[0] not containing any shell metacharacters. */ + strcpy (cmd, argv[0]); + cmd[len] = ' '; + cmd[len + 2] = '\0'; + for (i = 0; i < 2; i++) + { + FILE *child; + int status; + + if (i) + { + ASSERT (fclose (stdin) == 0); + ASSERT (fclose (stdout) == 0); + } + + cmd[len + 1] = 'r'; + ASSERT (child = popen (cmd, "r")); + ASSERT (fgetc (child) == 'c'); + status = pclose (child); + ASSERT (WIFEXITED (status)); + ASSERT (WEXITSTATUS (status) == 42); + if (i) + { + ASSERT (dup2 (STDIN_FILENO, STDIN_FILENO) == -1); + ASSERT (dup2 (STDOUT_FILENO, STDOUT_FILENO) == -1); + } + + cmd[len + 1] = 'w'; + ASSERT (child = popen (cmd, "w")); + ASSERT (fputc ('p', child) == 'p'); + status = pclose (child); + ASSERT (WIFEXITED (status)); + ASSERT (WEXITSTATUS (status) == 42); + if (i) + { + ASSERT (dup2 (STDIN_FILENO, STDIN_FILENO) == -1); + ASSERT (dup2 (STDOUT_FILENO, STDOUT_FILENO) == -1); + } + } + free (cmd); + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-priv-set.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-priv-set.c new file mode 100644 index 00000000..f7177d6e --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-priv-set.c @@ -0,0 +1,88 @@ +/* Test the priv-set module. + Copyright (C) 2009-2024 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 . */ + +/* Written by David Bartley , 2007. */ + +#include + +#include "priv-set.h" + +#if HAVE_GETPPRIV && HAVE_PRIV_H +# include +#endif +#include +#include +#include + +#include "macros.h" + +int +main (void) +{ +#if HAVE_GETPPRIV && HAVE_PRIV_H + priv_set_t *set; + + ASSERT (set = priv_allocset ()); + ASSERT (getppriv (PRIV_EFFECTIVE, set) == 0); + ASSERT (priv_ismember (set, PRIV_PROC_EXEC) == 1); + + /* Do a series of removes and restores making sure that the results are + consistent with our ismember function and solaris' priv_ismember. */ + ASSERT (priv_set_ismember (PRIV_PROC_EXEC) == 1); + ASSERT (getppriv (PRIV_EFFECTIVE, set) == 0); + ASSERT (priv_ismember (set, PRIV_PROC_EXEC) == 1); + ASSERT (priv_set_restore (PRIV_PROC_EXEC) == -1); + ASSERT (errno == EINVAL); + ASSERT (priv_set_ismember (PRIV_PROC_EXEC) == 1); + ASSERT (getppriv (PRIV_EFFECTIVE, set) == 0); + ASSERT (priv_ismember (set, PRIV_PROC_EXEC) == 1); + ASSERT (priv_set_remove (PRIV_PROC_EXEC) == 0); + ASSERT (priv_set_ismember (PRIV_PROC_EXEC) == 0); + ASSERT (getppriv (PRIV_EFFECTIVE, set) == 0); + ASSERT (priv_ismember (set, PRIV_PROC_EXEC) == 0); + ASSERT (priv_set_remove (PRIV_PROC_EXEC) == -1); + ASSERT (errno == EINVAL); + ASSERT (priv_set_ismember (PRIV_PROC_EXEC) == 0); + ASSERT (getppriv (PRIV_EFFECTIVE, set) == 0); + ASSERT (priv_ismember (set, PRIV_PROC_EXEC) == 0); + ASSERT (priv_set_restore (PRIV_PROC_EXEC) == 0); + ASSERT (priv_set_ismember (PRIV_PROC_EXEC) == 1); + ASSERT (getppriv (PRIV_EFFECTIVE, set) == 0); + ASSERT (priv_ismember (set, PRIV_PROC_EXEC) == 1); + ASSERT (priv_set_restore (PRIV_PROC_EXEC) == -1); + ASSERT (errno == EINVAL); + ASSERT (priv_set_ismember (PRIV_PROC_EXEC) == 1); + ASSERT (getppriv (PRIV_EFFECTIVE, set) == 0); + ASSERT (priv_ismember (set, PRIV_PROC_EXEC) == 1); + + /* Test the priv_set_linkdir wrappers. */ + ASSERT (getppriv (PRIV_EFFECTIVE, set) == 0); + if (priv_ismember (set, PRIV_SYS_LINKDIR)) + { + ASSERT (priv_set_restore_linkdir () == -1); + ASSERT (errno == EINVAL); + ASSERT (priv_set_remove_linkdir () == 0); + ASSERT (priv_set_remove_linkdir () == -1); + ASSERT (errno == EINVAL); + ASSERT (priv_set_restore_linkdir () == 0); + } +#else + ASSERT (priv_set_restore_linkdir () == -1); + ASSERT (priv_set_remove_linkdir () == -1); +#endif + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-pselect.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-pselect.c new file mode 100644 index 00000000..2f239ddf --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-pselect.c @@ -0,0 +1,49 @@ +/* Test of pselect() substitute. + Copyright (C) 2011-2024 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 . */ + +#include + +#include + +#include "signature.h" + +SIGNATURE_CHECK (pselect, int, + (int, fd_set *restrict, fd_set *restrict, fd_set *restrict, + struct timespec const *restrict, const sigset_t *restrict)); + +#define TEST_PORT 12347 +#include "test-select.h" + +static int +my_select (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, + struct timeval *timeout) +{ + struct timespec ts; + struct timespec *pts = NULL; + if (timeout) + { + ts.tv_sec = timeout->tv_sec; + ts.tv_nsec = timeout->tv_usec * 1000; + pts = &ts; + } + return pselect (nfds, readfds, writefds, exceptfds, pts, NULL); +} + +int +main (void) +{ + return test_function (my_select); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-pthread-thread.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-pthread-thread.c new file mode 100644 index 00000000..f0a19793 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-pthread-thread.c @@ -0,0 +1,73 @@ +/* Test of pthread_create () function. + Copyright (C) 2011-2024 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 . */ + +/* Written by Bruno Haible , 2011. */ + +#include + +#include + +#include +#include + +#include "macros.h" + +static pthread_t main_thread_before; +static pthread_t main_thread_after; +static pthread_t worker_thread; + +#define MAGIC ((void *) 1266074729) +static volatile int work_done; + +static void * +worker_thread_func (_GL_UNUSED void *arg) +{ + work_done = 1; + return MAGIC; +} + +int +main () +{ + main_thread_before = pthread_self (); + + if (pthread_create (&worker_thread, NULL, worker_thread_func, NULL) == 0) + { + void *ret; + + /* Check that pthread_self () has the same value before than after the + first call to pthread_create (). */ + main_thread_after = pthread_self (); + ASSERT (memcmp (&main_thread_before, &main_thread_after, + sizeof (pthread_t)) + == 0); + + ASSERT (pthread_join (worker_thread, &ret) == 0); + + /* Check the return value of the thread. */ + ASSERT (ret == MAGIC); + + /* Check that worker_thread_func () has finished executing. */ + ASSERT (work_done); + + return 0; + } + else + { + fputs ("pthread_create failed\n", stderr); + return 1; + } +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-pthread.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-pthread.c new file mode 100644 index 00000000..f7e89c66 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-pthread.c @@ -0,0 +1,88 @@ +/* Test of substitute. + Copyright (C) 2019-2024 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 . */ + +/* Written by Bruno Haible , 2019. */ + +#include + +#include + +/* Check that the types are all defined. */ + +pthread_t t1; +pthread_attr_t t2; + +pthread_once_t t3 = PTHREAD_ONCE_INIT; + +pthread_mutex_t t4 = PTHREAD_MUTEX_INITIALIZER; +pthread_mutexattr_t t5; + +pthread_rwlock_t t6 = PTHREAD_RWLOCK_INITIALIZER; +pthread_rwlockattr_t t7; + +pthread_cond_t t8 = PTHREAD_COND_INITIALIZER; +pthread_condattr_t t9; + +pthread_key_t t10; + +pthread_spinlock_t t11; + +#ifdef TODO /* Not implemented in gnulib yet */ +pthread_barrier_t t12; +pthread_barrierattr_t t13; +#endif + +/* Check that the various macros are defined. */ + +/* Constants for pthread_attr_setdetachstate(). */ +int ds[] = { PTHREAD_CREATE_JOINABLE, PTHREAD_CREATE_DETACHED }; + +/* Constants for pthread_exit(). */ +void *canceled = PTHREAD_CANCELED; + +/* Constants for pthread_mutexattr_settype(). */ +int mt[] = { + PTHREAD_MUTEX_DEFAULT, + PTHREAD_MUTEX_NORMAL, + PTHREAD_MUTEX_RECURSIVE, + PTHREAD_MUTEX_ERRORCHECK +}; + +#ifdef TODO /* Not implemented in gnulib yet */ + +/* Constants for pthread_mutexattr_setrobust(). */ +int mr[] = { PTHREAD_MUTEX_ROBUST, PTHREAD_MUTEX_STALLED }; + +/* Constants for pthread_barrierattr_setpshared(). */ +int bp[] = { PTHREAD_PROCESS_SHARED, PTHREAD_PROCESS_PRIVATE }; + +/* Constants for pthread_barrier_wait(). */ +int bw[] = { PTHREAD_BARRIER_SERIAL_THREAD }; + +/* Constants for pthread_setcancelstate(). */ +int cs[] = { PTHREAD_CANCEL_ENABLE, PTHREAD_CANCEL_DISABLE }; + +/* Constants for pthread_setcanceltype(). */ +int ct[] = { PTHREAD_CANCEL_DEFERRED, PTHREAD_CANCEL_ASYNCHRONOUS }; + +#endif + + +int +main (void) +{ + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-pthread_sigmask1.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-pthread_sigmask1.c new file mode 100644 index 00000000..a4f9ba6d --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-pthread_sigmask1.c @@ -0,0 +1,96 @@ +/* Test of pthread_sigmask in a single-threaded program. + Copyright (C) 2011-2024 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 . */ + +/* Written by Bruno Haible , 2011. */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (pthread_sigmask, int, (int, const sigset_t *, sigset_t *)); + +#include +#include +#include +#include +#include + +#include "macros.h" + +#if !(defined _WIN32 && !defined __CYGWIN__) + +static volatile int sigint_occurred; + +static void +sigint_handler (_GL_UNUSED int sig) +{ + sigint_occurred++; +} + +int +main () +{ + sigset_t set; + intmax_t pid = getpid (); + char command[80]; + + signal (SIGINT, sigint_handler); + + sigemptyset (&set); + sigaddset (&set, SIGINT); + + /* Check error handling. */ + ASSERT (pthread_sigmask (1729, &set, NULL) == EINVAL); + + /* Block SIGINT. */ + ASSERT (pthread_sigmask (SIG_BLOCK, &set, NULL) == 0); + + /* Request a SIGINT signal from outside. */ + sprintf (command, "sh -c 'sleep 1; kill -INT %"PRIdMAX"' &", pid); + ASSERT (system (command) == 0); + + /* Wait. */ + sleep (2); + + /* The signal should not have arrived yet, because it is blocked. */ + ASSERT (sigint_occurred == 0); + + /* Unblock SIGINT. */ + ASSERT (pthread_sigmask (SIG_UNBLOCK, &set, NULL) == 0); + + /* The signal should have arrived now, because POSIX says + "If there are any pending unblocked signals after the call to + pthread_sigmask(), at least one of those signals shall be delivered + before the call to pthread_sigmask() returns." */ + ASSERT (sigint_occurred == 1); + + return 0; +} + +#else + +/* On native Windows, getpid() values and the arguments that are passed to + the (Cygwin?) 'kill' program are not necessarily related. */ + +int +main () +{ + fputs ("Skipping test: native Windows platform\n", stderr); + return 77; +} + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-pthread_sigmask2.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-pthread_sigmask2.c new file mode 100644 index 00000000..d527eb8d --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-pthread_sigmask2.c @@ -0,0 +1,105 @@ +/* Test of pthread_sigmask in a multi-threaded program. + Copyright (C) 2011-2024 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 . */ + +/* Written by Bruno Haible , 2011. */ + +#include + +#include + +#include +#include +#include +#include + +#include "macros.h" + +#if USE_POSIX_THREADS || USE_ISOC_AND_POSIX_THREADS + +static pthread_t main_thread; +static pthread_t killer_thread; + +static void * +killer_thread_func (_GL_UNUSED void *arg) +{ + sleep (1); + pthread_kill (main_thread, SIGINT); + return NULL; +} + +static volatile int sigint_occurred; + +static void +sigint_handler (_GL_UNUSED int sig) +{ + sigint_occurred++; +} + +int +main () +{ + sigset_t set; + + signal (SIGINT, sigint_handler); + + sigemptyset (&set); + sigaddset (&set, SIGINT); + + /* Check error handling. */ + /* This call returns 0 on NetBSD 8.0. */ +#if !defined __NetBSD__ + ASSERT (pthread_sigmask (1729, &set, NULL) == EINVAL); +#endif + + /* Block SIGINT. */ + ASSERT (pthread_sigmask (SIG_BLOCK, &set, NULL) == 0); + + /* Request a SIGINT signal from another thread. */ + main_thread = pthread_self (); + ASSERT (pthread_create (&killer_thread, NULL, killer_thread_func, NULL) == 0); + + /* Wait. */ + sleep (2); + + /* The signal should not have arrived yet, because it is blocked. */ + ASSERT (sigint_occurred == 0); + + /* Unblock SIGINT. */ + ASSERT (pthread_sigmask (SIG_UNBLOCK, &set, NULL) == 0); + + /* The signal should have arrived now, because POSIX says + "If there are any pending unblocked signals after the call to + pthread_sigmask(), at least one of those signals shall be delivered + before the call to pthread_sigmask() returns." */ + ASSERT (sigint_occurred == 1); + + /* Clean up the thread. This avoid a "ThreadSanitizer: thread leak" warning + from "gcc -fsanitize=thread". */ + ASSERT (pthread_join (killer_thread, NULL) == 0); + + return 0; +} + +#else + +int +main () +{ + fputs ("Skipping test: POSIX threads not enabled\n", stderr); + return 77; +} + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-quotearg-simple.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-quotearg-simple.c new file mode 100644 index 00000000..5a9a7695 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-quotearg-simple.c @@ -0,0 +1,365 @@ +/* Test of quotearg family of functions. + Copyright (C) 2008-2024 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 . */ + +/* Written by Eric Blake , 2008. */ + +#include + +#include "quotearg.h" + +#include +#include +#include +#include + +#include "localcharset.h" +#include "macros.h" +#include "zerosize-ptr.h" + +#include "test-quotearg.h" + +static struct result_groups results_g[] = { + /* literal_quoting_style */ + { { "", "\0""1\0", 3, "simple", " \t\n'\"\033?""?/\\", "a:b", "a\\b", + "a' b", LQ RQ, LQ RQ }, + { "", "1", 1, "simple", " \t\n'\"\033?""?/\\", "a:b", "a\\b", + "a' b", LQ RQ, LQ RQ }, + { "", "1", 1, "simple", " \t\n'\"\033?""?/\\", "a:b", "a\\b", + "a' b", LQ RQ, LQ RQ } }, + + /* shell_quoting_style */ + { { "''", "\0""1\0", 3, "simple", "' \t\n'\\''\"\033?""?/\\'", "a:b", + "'a\\b'", "\"a' b\"", LQ RQ, LQ RQ }, + { "''", "1", 1, "simple", "' \t\n'\\''\"\033?""?/\\'", "a:b", + "'a\\b'", "\"a' b\"", LQ RQ, LQ RQ }, + { "''", "1", 1, "simple", "' \t\n'\\''\"\033?""?/\\'", "'a:b'", + "'a\\b'", "\"a' b\"", LQ RQ, LQ RQ } }, + + /* shell_always_quoting_style */ + { { "''", "'\0""1\0'", 5, "'simple'", "' \t\n'\\''\"\033?""?/\\'", "'a:b'", + "'a\\b'", "\"a' b\"", "'" LQ RQ "'", "'" LQ RQ "'" }, + { "''", "'1'", 3, "'simple'", "' \t\n'\\''\"\033?""?/\\'", "'a:b'", + "'a\\b'", "\"a' b\"", "'" LQ RQ "'", "'" LQ RQ "'" }, + { "''", "'1'", 3, "'simple'", "' \t\n'\\''\"\033?""?/\\'", "'a:b'", + "'a\\b'", "\"a' b\"", "'" LQ RQ "'", "'" LQ RQ "'" } }, + + /* shell_escape_quoting_style */ + { { "''", "''$'\\0''1'$'\\0'", 15, "simple", + "' '$'\\t\\n'\\''\"'$'\\033''?""?/\\'", "a:b", + "'a\\b'", "\"a' b\"", "''$'" LQ_ENC RQ_ENC "'", LQ RQ }, + { "''", "''$'\\0''1'$'\\0'", 15, "simple", + "' '$'\\t\\n'\\''\"'$'\\033''?""?/\\'", "a:b", + "'a\\b'", "\"a' b\"", "''$'" LQ_ENC RQ_ENC "'", LQ RQ }, + { "''", "''$'\\0''1'$'\\0'", 15, "simple", + "' '$'\\t\\n'\\''\"'$'\\033''?""?/\\'", "'a:b'", + "'a\\b'", "\"a' b\"", "''$'" LQ_ENC RQ_ENC "'", LQ RQ } }, + + /* shell_escape_always_quoting_style */ + { { "''", "''$'\\0''1'$'\\0'", 15, "'simple'", + "' '$'\\t\\n'\\''\"'$'\\033''?""?/\\'", "'a:b'", + "'a\\b'", "\"a' b\"", "''$'" LQ_ENC RQ_ENC "'", "'" LQ RQ "'" }, + { "''", "''$'\\0''1'$'\\0'", 15, "'simple'", + "' '$'\\t\\n'\\''\"'$'\\033''?""?/\\'", "'a:b'", + "'a\\b'", "\"a' b\"", "''$'" LQ_ENC RQ_ENC "'", "'" LQ RQ "'" }, + { "''", "''$'\\0''1'$'\\0'", 15, "'simple'", + "' '$'\\t\\n'\\''\"'$'\\033''?""?/\\'", "'a:b'", + "'a\\b'", "\"a' b\"", "''$'" LQ_ENC RQ_ENC "'", "'" LQ RQ "'" } }, + + /* c_quoting_style */ + { { "\"\"", "\"\\0001\\0\"", 9, "\"simple\"", + "\" \\t\\n'\\\"\\033?""?/\\\\\"", "\"a:b\"", "\"a\\\\b\"", + "\"a' b\"", "\"" LQ_ENC RQ_ENC "\"", "\"" LQ RQ "\"" }, + { "\"\"", "\"\\0001\\0\"", 9, "\"simple\"", + "\" \\t\\n'\\\"\\033?""?/\\\\\"", "\"a:b\"", "\"a\\\\b\"", + "\"a' b\"", "\"" LQ_ENC RQ_ENC "\"", "\"" LQ RQ "\"" }, + { "\"\"", "\"\\0001\\0\"", 9, "\"simple\"", + "\" \\t\\n'\\\"\\033?""?/\\\\\"", "\"a\\:b\"", "\"a\\\\b\"", + "\"a' b\"", "\"" LQ_ENC RQ_ENC "\"", "\"" LQ RQ "\"" } }, + + /* c_maybe_quoting_style */ + { { "", "\"\\0001\\0\"", 9, "simple", "\" \\t\\n'\\\"\\033?""?/\\\\\"", + "a:b", "a\\b", "a' b", "\"" LQ_ENC RQ_ENC "\"", LQ RQ }, + { "", "\"\\0001\\0\"", 9, "simple", "\" \\t\\n'\\\"\\033?""?/\\\\\"", + "a:b", "a\\b", "a' b", "\"" LQ_ENC RQ_ENC "\"", LQ RQ }, + { "", "\"\\0001\\0\"", 9, "simple", "\" \\t\\n'\\\"\\033?""?/\\\\\"", + "\"a:b\"", "a\\b", "a' b", "\"" LQ_ENC RQ_ENC "\"", LQ RQ } }, + + /* escape_quoting_style */ + { { "", "\\0001\\0", 7, "simple", " \\t\\n'\"\\033?""?/\\\\", "a:b", + "a\\\\b", "a' b", LQ_ENC RQ_ENC, LQ RQ }, + { "", "\\0001\\0", 7, "simple", " \\t\\n'\"\\033?""?/\\\\", "a:b", + "a\\\\b", "a' b", LQ_ENC RQ_ENC, LQ RQ }, + { "", "\\0001\\0", 7, "simple", " \\t\\n'\"\\033?""?/\\\\", "a\\:b", + "a\\\\b", "a' b", LQ_ENC RQ_ENC, LQ RQ } }, + + /* locale_quoting_style */ + { { "''", "'\\0001\\0'", 9, "'simple'", "' \\t\\n\\'\"\\033?""?/\\\\'", + "'a:b'", "'a\\\\b'", "'a\\' b'", "'" LQ_ENC RQ_ENC "'", "'" LQ RQ "'" }, + { "''", "'\\0001\\0'", 9, "'simple'", "' \\t\\n\\'\"\\033?""?/\\\\'", + "'a:b'", "'a\\\\b'", "'a\\' b'", "'" LQ_ENC RQ_ENC "'", "'" LQ RQ "'" }, + { "''", "'\\0001\\0'", 9, "'simple'", "' \\t\\n\\'\"\\033?""?/\\\\'", + "'a\\:b'", "'a\\\\b'", "'a\\' b'", + "'" LQ_ENC RQ_ENC "'", "'" LQ RQ "'" } }, + + /* clocale_quoting_style */ + { { "\"\"", "\"\\0001\\0\"", 9, "\"simple\"", + "\" \\t\\n'\\\"\\033?""?/\\\\\"", "\"a:b\"", "\"a\\\\b\"", + "\"a' b\"", "\"" LQ_ENC RQ_ENC "\"", "\"" LQ RQ "\"" }, + { "\"\"", "\"\\0001\\0\"", 9, "\"simple\"", + "\" \\t\\n'\\\"\\033?""?/\\\\\"", "\"a:b\"", "\"a\\\\b\"", + "\"a' b\"", "\"" LQ_ENC RQ_ENC "\"", "\"" LQ RQ "\"" }, + { "\"\"", "\"\\0001\\0\"", 9, "\"simple\"", + "\" \\t\\n'\\\"\\033?""?/\\\\\"", "\"a\\:b\"", "\"a\\\\b\"", + "\"a' b\"", "\"" LQ_ENC RQ_ENC "\"", "\"" LQ RQ "\"" } } +}; + +static struct result_groups flag_results[] = { + /* literal_quoting_style and QA_ELIDE_NULL_BYTES */ + { { "", "1", 1, "simple", " \t\n'\"\033?""?/\\", "a:b", "a\\b", "a' b", + LQ RQ, LQ RQ }, + { "", "1", 1, "simple", " \t\n'\"\033?""?/\\", "a:b", "a\\b", "a' b", + LQ RQ, LQ RQ }, + { "", "1", 1, "simple", " \t\n'\"\033?""?/\\", "a:b", "a\\b", "a' b", + LQ RQ, LQ RQ } }, + + /* c_quoting_style and QA_ELIDE_OUTER_QUOTES */ + { { "", "\"\\0001\\0\"", 9, "simple", "\" \\t\\n'\\\"\\033?""?/\\\\\"", + "a:b", "a\\b", "a' b", "\"" LQ_ENC RQ_ENC "\"", LQ RQ }, + { "", "\"\\0001\\0\"", 9, "simple", "\" \\t\\n'\\\"\\033?""?/\\\\\"", + "a:b", "a\\b", "a' b", "\"" LQ_ENC RQ_ENC "\"", LQ RQ }, + { "", "\"\\0001\\0\"", 9, "simple", "\" \\t\\n'\\\"\\033?""?/\\\\\"", + "\"a:b\"", "a\\b", "a' b", "\"" LQ_ENC RQ_ENC "\"", LQ RQ } }, + + /* c_quoting_style and QA_SPLIT_TRIGRAPHS */ + { { "\"\"", "\"\\0001\\0\"", 9, "\"simple\"", + "\" \\t\\n'\\\"\\033?\"\"?/\\\\\"", "\"a:b\"", "\"a\\\\b\"", + "\"a' b\"", "\"" LQ_ENC RQ_ENC "\"", "\"" LQ RQ "\"" }, + { "\"\"", "\"\\0001\\0\"", 9, "\"simple\"", + "\" \\t\\n'\\\"\\033?\"\"?/\\\\\"", "\"a:b\"", "\"a\\\\b\"", + "\"a' b\"", "\"" LQ_ENC RQ_ENC "\"", "\"" LQ RQ "\"" }, + { "\"\"", "\"\\0001\\0\"", 9, "\"simple\"", + "\" \\t\\n'\\\"\\033?\"\"?/\\\\\"", "\"a\\:b\"", "\"a\\\\b\"", + "\"a' b\"", "\"" LQ_ENC RQ_ENC "\"", "\"" LQ RQ "\"" } } +}; + +static char const *custom_quotes[][2] = { + { "", "" }, + { "'", "'" }, + { "(", ")" }, + { ":", " " }, + { " ", ":" }, + { "# ", "\n" }, + { "\"'", "'\"" } +}; + +static struct result_groups custom_results[] = { + /* left_quote = right_quote = "" */ + { { "", "\\0001\\0", 7, "simple", + " \\t\\n'\"\\033?""?/\\\\", "a:b", "a\\\\b", + "a' b", LQ_ENC RQ_ENC, LQ RQ }, + { "", "\\0001\\0", 7, "simple", + " \\t\\n'\"\\033?""?/\\\\", "a:b", "a\\\\b", + "a' b", LQ_ENC RQ_ENC, LQ RQ }, + { "", "\\0001\\0", 7, "simple", + " \\t\\n'\"\\033?""?/\\\\", "a\\:b", "a\\\\b", + "a' b", LQ_ENC RQ_ENC, LQ RQ } }, + + /* left_quote = right_quote = "'" */ + { { "''", "'\\0001\\0'", 9, "'simple'", + "' \\t\\n\\'\"\\033?""?/\\\\'", "'a:b'", "'a\\\\b'", + "'a\\' b'", "'" LQ_ENC RQ_ENC "'", "'" LQ RQ "'" }, + { "''", "'\\0001\\0'", 9, "'simple'", + "' \\t\\n\\'\"\\033?""?/\\\\'", "'a:b'", "'a\\\\b'", + "'a\\' b'", "'" LQ_ENC RQ_ENC "'", "'" LQ RQ "'" }, + { "''", "'\\0001\\0'", 9, "'simple'", + "' \\t\\n\\'\"\\033?""?/\\\\'", "'a\\:b'", "'a\\\\b'", + "'a\\' b'", "'" LQ_ENC RQ_ENC "'", "'" LQ RQ "'" } }, + + /* left_quote = "(" and right_quote = ")" */ + { { "()", "(\\0001\\0)", 9, "(simple)", + "( \\t\\n'\"\\033?""?/\\\\)", "(a:b)", "(a\\\\b)", + "(a' b)", "(" LQ_ENC RQ_ENC ")", "(" LQ RQ ")" }, + { "()", "(\\0001\\0)", 9, "(simple)", + "( \\t\\n'\"\\033?""?/\\\\)", "(a:b)", "(a\\\\b)", + "(a' b)", "(" LQ_ENC RQ_ENC ")", "(" LQ RQ ")" }, + { "()", "(\\0001\\0)", 9, "(simple)", + "( \\t\\n'\"\\033?""?/\\\\)", "(a\\:b)", "(a\\\\b)", + "(a' b)", "(" LQ_ENC RQ_ENC ")", "(" LQ RQ ")" } }, + + /* left_quote = ":" and right_quote = " " */ + { { ": ", ":\\0001\\0 ", 9, ":simple ", + ":\\ \\t\\n'\"\\033?""?/\\\\ ", ":a:b ", ":a\\\\b ", + ":a'\\ b ", ":" LQ_ENC RQ_ENC " ", ":" LQ RQ " " }, + { ": ", ":\\0001\\0 ", 9, ":simple ", + ":\\ \\t\\n'\"\\033?""?/\\\\ ", ":a:b ", ":a\\\\b ", + ":a'\\ b ", ":" LQ_ENC RQ_ENC " ", ":" LQ RQ " " }, + { ": ", ":\\0001\\0 ", 9, ":simple ", + ":\\ \\t\\n'\"\\033?""?/\\\\ ", ":a\\:b ", ":a\\\\b ", + ":a'\\ b ", ":" LQ_ENC RQ_ENC " ", ":" LQ RQ " " } }, + + /* left_quote = " " and right_quote = ":" */ + { { " :", " \\0001\\0:", 9, " simple:", + " \\t\\n'\"\\033?""?/\\\\:", " a\\:b:", " a\\\\b:", + " a' b:", " " LQ_ENC RQ_ENC ":", " " LQ RQ ":" }, + { " :", " \\0001\\0:", 9, " simple:", + " \\t\\n'\"\\033?""?/\\\\:", " a\\:b:", " a\\\\b:", + " a' b:", " " LQ_ENC RQ_ENC ":", " " LQ RQ ":" }, + { " :", " \\0001\\0:", 9, " simple:", + " \\t\\n'\"\\033?""?/\\\\:", " a\\:b:", " a\\\\b:", + " a' b:", " " LQ_ENC RQ_ENC ":", " " LQ RQ ":" } }, + + /* left_quote = "# " and right_quote = "\n" */ + { { "# \n", "# \\0001\\0\n", 10, "# simple\n", + "# \\t\\n'\"\\033?""?/\\\\\n", "# a:b\n", "# a\\\\b\n", + "# a' b\n", "# " LQ_ENC RQ_ENC "\n", "# " LQ RQ "\n" }, + { "# \n", "# \\0001\\0\n", 10, "# simple\n", + "# \\t\\n'\"\\033?""?/\\\\\n", "# a:b\n", "# a\\\\b\n", + "# a' b\n", "# " LQ_ENC RQ_ENC "\n", "# " LQ RQ "\n" }, + { "# \n", "# \\0001\\0\n", 10, "# simple\n", + "# \\t\\n'\"\\033?""?/\\\\\n", "# a\\:b\n", "# a\\\\b\n", + "# a' b\n", "# " LQ_ENC RQ_ENC "\n", "# " LQ RQ "\n" } }, + + /* left_quote = "\"'" and right_quote = "'\"" */ + { { "\"''\"", "\"'\\0001\\0'\"", 11, "\"'simple'\"", + "\"' \\t\\n\\'\"\\033?""?/\\\\'\"", "\"'a:b'\"", "\"'a\\\\b'\"", + "\"'a' b'\"", "\"'" LQ_ENC RQ_ENC "'\"", "\"'" LQ RQ "'\"" }, + { "\"''\"", "\"'\\0001\\0'\"", 11, "\"'simple'\"", + "\"' \\t\\n\\'\"\\033?""?/\\\\'\"", "\"'a:b'\"", "\"'a\\\\b'\"", + "\"'a' b'\"", "\"'" LQ_ENC RQ_ENC "'\"", "\"'" LQ RQ "'\"" }, + { "\"''\"", "\"'\\0001\\0'\"", 11, "\"'simple'\"", + "\"' \\t\\n\\'\"\\033?""?/\\\\'\"", "\"'a\\:b'\"", "\"'a\\\\b'\"", + "\"'a' b'\"", "\"'" LQ_ENC RQ_ENC "'\"", "\"'" LQ RQ "'\"" } } +}; + +static char * +use_quote_double_quotes (const char *str, size_t *len) +{ + char *p = *len == SIZE_MAX ? quotearg_char (str, '"') + : quotearg_char_mem (str, *len, '"'); + *len = strlen (p); + return p; +} + +int +main (_GL_UNUSED int argc, char *argv[]) +{ + int i; + bool ascii_only = MB_CUR_MAX == 1 && !isprint ((unsigned char) LQ[0]); + + /* This part of the program is hard-wired to the C locale since it + does not call setlocale. However, according to POSIX, the use of + 8-bit bytes in a character context in the C locale gives + unspecified results (that is, the C locale charset is allowed to + be unibyte with 8-bit bytes rejected [ASCII], unibyte with 8-bit + bytes being characters [often ISO-8859-1], or multibyte [often + UTF-8]). We assume that the latter two cases will be + indistinguishable in this test - that is, the LQ and RQ sequences + will pass through unchanged in either type of charset. So when + testing for quoting of str7, use the ascii_only flag to decide + what to expect for the 8-bit data being quoted. */ + ASSERT (!isprint ('\033')); + for (i = literal_quoting_style; i <= clocale_quoting_style; i++) + { + set_quoting_style (NULL, (enum quoting_style) i); + if (!(i == locale_quoting_style || i == clocale_quoting_style) + || (strcmp (locale_charset (), "ASCII") == 0 + || strcmp (locale_charset (), "ANSI_X3.4-1968") == 0)) + { + compare_strings (use_quotearg_buffer, &results_g[i].group1, + ascii_only); + compare_strings (use_quotearg, &results_g[i].group2, + ascii_only); + if (i == c_quoting_style) + compare_strings (use_quote_double_quotes, &results_g[i].group2, + ascii_only); + compare_strings (use_quotearg_colon, &results_g[i].group3, + ascii_only); + } + } + + set_quoting_style (NULL, literal_quoting_style); + ASSERT (set_quoting_flags (NULL, QA_ELIDE_NULL_BYTES) == 0); + compare_strings (use_quotearg_buffer, &flag_results[0].group1, ascii_only); + compare_strings (use_quotearg, &flag_results[0].group2, ascii_only); + compare_strings (use_quotearg_colon, &flag_results[0].group3, ascii_only); + + set_quoting_style (NULL, c_quoting_style); + ASSERT (set_quoting_flags (NULL, QA_ELIDE_OUTER_QUOTES) + == QA_ELIDE_NULL_BYTES); + compare_strings (use_quotearg_buffer, &flag_results[1].group1, ascii_only); + compare_strings (use_quotearg, &flag_results[1].group2, ascii_only); + compare_strings (use_quote_double_quotes, &flag_results[1].group2, + ascii_only); + compare_strings (use_quotearg_colon, &flag_results[1].group3, ascii_only); + + ASSERT (set_quoting_flags (NULL, QA_SPLIT_TRIGRAPHS) + == QA_ELIDE_OUTER_QUOTES); + compare_strings (use_quotearg_buffer, &flag_results[2].group1, ascii_only); + compare_strings (use_quotearg, &flag_results[2].group2, ascii_only); + compare_strings (use_quote_double_quotes, &flag_results[2].group2, + ascii_only); + compare_strings (use_quotearg_colon, &flag_results[2].group3, ascii_only); + + ASSERT (set_quoting_flags (NULL, 0) == QA_SPLIT_TRIGRAPHS); + + for (i = 0; i < sizeof custom_quotes / sizeof *custom_quotes; ++i) + { + set_custom_quoting (NULL, + custom_quotes[i][0], custom_quotes[i][1]); + compare_strings (use_quotearg_buffer, &custom_results[i].group1, + ascii_only); + compare_strings (use_quotearg, &custom_results[i].group2, ascii_only); + compare_strings (use_quotearg_colon, &custom_results[i].group3, + ascii_only); + } + + { + /* Trigger the bug whereby quotearg_buffer would read beyond the NUL + that defines the end of the string being quoted. Use an input + string whose NUL is the last byte before an unreadable page. */ + char *z = zerosize_ptr (); + + if (z) + { + size_t q_len = 1024; + char *q = malloc (q_len + 1); + char buf[10]; + memset (q, 'Q', q_len); + q[q_len] = 0; + + /* Z points to the boundary between a readable/writable page + and one that is neither readable nor writable. Position + our string so its NUL is at the end of the writable one. */ + char const *str = "____"; + size_t s_len = strlen (str); + z -= s_len + 1; + memcpy (z, str, s_len + 1); + + set_custom_quoting (NULL, q, q); + /* Whether this actually triggers a SEGV depends on the + implementation of memcmp: whether it compares only byte-at- + a-time, and from left to right (no SEGV) or some other way. */ + size_t n = quotearg_buffer (buf, sizeof buf, z, SIZE_MAX, NULL); + ASSERT (n == s_len + 2 * q_len); + ASSERT (memcmp (buf, q, sizeof buf) == 0); + free (q); + } + } + + quotearg_free (); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-quotearg.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-quotearg.h new file mode 100644 index 00000000..47de7fee --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-quotearg.h @@ -0,0 +1,128 @@ +/* Test of quotearg family of functions. + Copyright (C) 2008-2024 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 . */ + +/* Written by Eric Blake , 2008. */ + +struct result_strings { + char const *str1; /* Translation of "". */ + char const *str2; /* Translation of "\0""1\0". */ + size_t len2; /* Length of str2. */ + char const *str3; /* Translation of "simple". */ + char const *str4; /* Translation of " \t\n'\"\033?""?/\\". */ + char const *str5; /* Translation of "a:b". */ + char const *str6; /* Translation of "a\\b". */ + char const *str7; /* Translation of "a' b". */ + char const *str8a; /* Translation of LQ RQ, in ASCII charset. */ + char const *str8b; /* Translation of LQ RQ, in Latin1 or UTF-8 charset. */ +}; + +struct result_groups { + struct result_strings group1; /* Via quotearg_buffer. */ + struct result_strings group2; /* Via quotearg{,_mem}. */ + struct result_strings group3; /* Via quotearg_colon{,_mem}. */ +}; + +/* These quotes are borrowed from a pt_PT.utf8 translation. */ +# define LQ "\302\253" +# define RQ "\302\273" +# define LQ_ENC "\\302\\253" +# define RQ_ENC "\\302\\273" +# define RQ_ESC "\\\302\273" + +static struct result_strings inputs = { + "", "\0001\0", 3, "simple", " \t\n'\"\033?""?/\\", "a:b", "a\\b", + "a' b", LQ RQ, NULL +}; + +static void +compare (char const *a, size_t la, char const *b, size_t lb) +{ + ASSERT (la == lb); + ASSERT (memcmp (a, b, la) == 0); + ASSERT (b[lb] == '\0'); +} + +static void +compare_strings (char *(func) (char const *, size_t *), + struct result_strings *results, bool ascii_only) +{ + size_t len; + char *p; + + len = 0; + p = func (inputs.str1, &len); + compare (results->str1, strlen (results->str1), p, len); + + len = inputs.len2; + p = func (inputs.str2, &len); + compare (results->str2, results->len2, p, len); + + len = SIZE_MAX; + p = func (inputs.str3, &len); + compare (results->str3, strlen (results->str3), p, len); + + len = strlen (inputs.str4); + p = func (inputs.str4, &len); + compare (results->str4, strlen (results->str4), p, len); + + len = SIZE_MAX; + p = func (inputs.str5, &len); + compare (results->str5, strlen (results->str5), p, len); + + len = strlen (inputs.str6); + p = func (inputs.str6, &len); + compare (results->str6, strlen (results->str6), p, len); + + len = strlen (inputs.str7); + p = func (inputs.str7, &len); + compare (results->str7, strlen (results->str7), p, len); + + len = strlen (inputs.str8a); + p = func (inputs.str8a, &len); + if (ascii_only) + compare (results->str8a, strlen (results->str8a), p, len); + else + compare (results->str8b, strlen (results->str8b), p, len); +} + +static char * +use_quotearg_buffer (const char *str, size_t *len) +{ + static char buf[100]; + size_t size; + memset (buf, 0xa5, 100); + size = quotearg_buffer (buf, 100, str, *len, NULL); + *len = size; + ASSERT ((unsigned char) buf[size + 1] == 0xa5); + return buf; +} + +static char * +use_quotearg (const char *str, size_t *len) +{ + char *p = *len == SIZE_MAX ? quotearg (str) : quotearg_mem (str, *len); + *len = strlen (p); + return p; +} + +static char * +use_quotearg_colon (const char *str, size_t *len) +{ + char *p = (*len == SIZE_MAX ? quotearg_colon (str) + : quotearg_colon_mem (str, *len)); + *len = strlen (p); + return p; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-raise.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-raise.c new file mode 100644 index 00000000..39ffdc30 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-raise.c @@ -0,0 +1,51 @@ +/* Test raising a signal. + Copyright (C) 2011-2024 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 . */ + +#include + +#include +#include + +#include "signature.h" +SIGNATURE_CHECK (raise, int, (int)); + +#include + +#include "macros.h" + +/* It is safe to use _Noreturn here: _exit() never returns, and GCC knows that + _exit() is a non-returning function, even on platforms where its declaration + in does not have the 'noreturn' attribute. */ +static _Noreturn void +handler (_GL_UNUSED int sig) +{ + _exit (0); +} + +int +main (void) +{ + /* Test behaviour for invalid argument. */ + ASSERT (raise (-1) != 0); + + /* Test behaviour for SIGINT. */ + ASSERT (signal (SIGINT, handler) != SIG_ERR); + + raise (SIGINT); + + /* We should not get here, because the handler takes away the control. */ + exit (1); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-raise.c~ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-raise.c~ new file mode 100644 index 00000000..7574b2b4 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-raise.c~ @@ -0,0 +1,51 @@ +/* Test raising a signal. + Copyright (C) 2011-2023 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 . */ + +#include + +#include +#include + +#include "signature.h" +SIGNATURE_CHECK (raise, int, (int)); + +#include + +#include "macros.h" + +/* It is safe to use _Noreturn here: exit() never returns, and GCC knows that + exit() is a non-returning function, even on platforms where its declaration + in does not have the 'noreturn' attribute. */ +static _Noreturn void +handler (int sig) +{ + _exit (0); +} + +int +main (void) +{ + /* Test behaviour for invalid argument. */ + ASSERT (raise (-1) != 0); + + /* Test behaviour for SIGINT. */ + ASSERT (signal (SIGINT, handler) != SIG_ERR); + + raise (SIGINT); + + /* We should not get here, because the handler takes away the control. */ + exit (1); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-rawmemchr.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-rawmemchr.c new file mode 100644 index 00000000..23d411c7 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-rawmemchr.c @@ -0,0 +1,105 @@ +/* + * Copyright (C) 2008-2024 Free Software Foundation, Inc. + * Written by Eric Blake and Bruno Haible + * + * 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 . */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (rawmemchr, void *, (void const *, int)); + +#include + +#include "zerosize-ptr.h" +#include "macros.h" + +/* Calculating void * + int is not portable, so this wrapper converts + to char * to make the tests easier to write. */ +#define RAWMEMCHR (char *) rawmemchr + +int +main (void) +{ + size_t n = 0x100000; + char *input = malloc (n + 1); + ASSERT (input); + + input[0] = 'a'; + input[1] = 'b'; + memset (input + 2, 'c', 1024); + memset (input + 1026, 'd', n - 1028); + input[n - 2] = 'e'; + input[n - 1] = 'a'; + input[n] = '\0'; + + /* Basic behavior tests. */ + ASSERT (RAWMEMCHR (input, 'a') == input); + ASSERT (RAWMEMCHR (input, 'b') == input + 1); + ASSERT (RAWMEMCHR (input, 'c') == input + 2); + ASSERT (RAWMEMCHR (input, 'd') == input + 1026); + + ASSERT (RAWMEMCHR (input + 1, 'a') == input + n - 1); + ASSERT (RAWMEMCHR (input + 1, 'e') == input + n - 2); + ASSERT (RAWMEMCHR (input + 1, 0x789abc00 | 'e') == input + n - 2); + + ASSERT (RAWMEMCHR (input, '\0') == input + n); + + /* Alignment tests. */ + { + int i, j; + for (i = 0; i < 32; i++) + { + for (j = 0; j < 256; j++) + input[i + j] = j; + for (j = 0; j < 256; j++) + { + ASSERT (RAWMEMCHR (input + i, j) == input + i + j); + } + } + } + + /* Ensure that no unaligned oversized reads occur. */ + { + char *page_boundary = (char *) zerosize_ptr (); + size_t i; + + if (!page_boundary) + page_boundary = input + 4096; + memset (page_boundary - 512, '1', 511); + page_boundary[-1] = '2'; + for (i = 1; i <= 512; i++) + ASSERT (RAWMEMCHR (page_boundary - i, (i * 0x01010100) | '2') + == page_boundary - 1); + } + + free (input); + + /* Test aligned oversized reads, which are allowed on most architectures + but not on CHERI. */ + { + input = malloc (5); + memcpy (input, "abcde", 5); + ASSERT (RAWMEMCHR (input, 'e') == input + 4); + ASSERT (RAWMEMCHR (input + 1, 'e') == input + 4); + ASSERT (RAWMEMCHR (input + 2, 'e') == input + 4); + ASSERT (RAWMEMCHR (input + 3, 'e') == input + 4); + ASSERT (RAWMEMCHR (input + 4, 'e') == input + 4); + free (input); + } + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-readlink.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-readlink.c new file mode 100644 index 00000000..911b8a13 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-readlink.c @@ -0,0 +1,47 @@ +/* Tests of readlink. + Copyright (C) 2009-2024 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 . */ + +/* Written by Eric Blake , 2009. */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (readlink, ssize_t, (char const *, char *, size_t)); + +#include +#include +#include +#include +#include +#include + +#include "ignore-value.h" +#include "macros.h" + +#define BASE "test-readlink.t" + +#include "test-readlink.h" + +int +main (void) +{ + /* Remove any leftovers from a previous partial run. */ + ignore_value (system ("rm -rf " BASE "*")); + + return test_readlink (readlink, true); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-readlink.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-readlink.h new file mode 100644 index 00000000..3a21b60b --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-readlink.h @@ -0,0 +1,119 @@ +/* Tests of readlink. + Copyright (C) 2009-2024 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 . */ + +/* Written by Eric Blake , 2009. */ + +/* This file is designed to test both readlink(a,b,c) and + readlinkat(AT_FDCWD,a,b,c). FUNC is the function to test. Assumes + that BASE and ASSERT are already defined, and that appropriate + headers are already included. If PRINT, warn before skipping + symlink tests with status 77. */ + +static int +test_readlink (ssize_t (*func) (char const *, char *, size_t), bool print) +{ + char buf[80]; + + /* Sanity checks of failures. Mingw lacks symlink, but readlink can + still distinguish between various errors. */ + memset (buf, 0xff, sizeof buf); + errno = 0; + ASSERT (func ("no_such", buf, sizeof buf) == -1); + ASSERT (errno == ENOENT); + errno = 0; + ASSERT (func ("no_such/", buf, sizeof buf) == -1); + ASSERT (errno == ENOENT); + errno = 0; + ASSERT (func ("", buf, sizeof buf) == -1); + ASSERT (errno == ENOENT || errno == EINVAL); + errno = 0; + ASSERT (func (".", buf, sizeof buf) == -1); + ASSERT (errno == EINVAL); + errno = 0; + ASSERT (func ("./", buf, sizeof buf) == -1); + ASSERT (errno == EINVAL); + ASSERT (close (creat (BASE "file", 0600)) == 0); + errno = 0; + ASSERT (func (BASE "file", buf, sizeof buf) == -1); + ASSERT (errno == EINVAL); + errno = 0; + ASSERT (func (BASE "file/", buf, sizeof buf) == -1); + ASSERT (errno == ENOTDIR || errno == EINVAL); /* AIX yields EINVAL */ + + /* Now test actual symlinks. */ + if (symlink (BASE "dir", BASE "link")) + { + ASSERT (unlink (BASE "file") == 0); + if (print) + fputs ("skipping test: symlinks not supported on this file system\n", + stderr); + return 77; + } + ASSERT (mkdir (BASE "dir", 0700) == 0); + errno = 0; + ASSERT (func (BASE "link/", buf, sizeof buf) == -1); + ASSERT (errno == EINVAL); + ASSERT (symlink (BASE "link", BASE "link2") == 0); + errno = 0; + ASSERT (func (BASE "link2/", buf, sizeof buf) == -1); + ASSERT (errno == EINVAL); + ASSERT (unlink (BASE "link2") == 0); + ASSERT (symlink (BASE "file", BASE "link2") == 0); + errno = 0; + ASSERT (func (BASE "link2/", buf, sizeof buf) == -1); + ASSERT (errno == ENOTDIR || errno == EINVAL); /* AIX yields EINVAL */ + ASSERT (unlink (BASE "file") == 0); + ASSERT (unlink (BASE "link2") == 0); + { + /* Up till now, no readlink has been successful, so buf should be + unchanged. */ + int i; + for (i = 0; i < sizeof buf; i++) + ASSERT (buf[i] == (char) 0xff); + } + { + size_t len = strlen (BASE "dir"); + /* When passing too small of a buffer, expect the truncated + length, or an ERANGE failure. However, a size of 0 is not + portable enough to test. */ + ssize_t result; + errno = 0; + result = readlink (BASE "link", buf, 1); + if (result == -1) + { + ASSERT (errno == ERANGE); + ASSERT (buf[0] == (char) 0xff); + } + else + { + ASSERT (result == 1); + ASSERT (buf[0] == BASE[0]); + } + ASSERT (buf[1] == (char) 0xff); + ASSERT (func (BASE "link", buf, len) == len); + ASSERT (strncmp (buf, BASE "dir", len) == 0); + ASSERT (buf[len] == (char) 0xff); + ASSERT (func (BASE "link", buf, sizeof buf) == len); + ASSERT (strncmp (buf, BASE "dir", len) == 0); + /* POSIX says rest of buf is unspecified; but in practice, it is + either left alone, or NUL-terminated. */ + ASSERT (buf[len] == '\0' || buf[len] == (char) 0xff); + } + ASSERT (rmdir (BASE "dir") == 0); + ASSERT (unlink (BASE "link") == 0); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-readlinkat.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-readlinkat.c new file mode 100644 index 00000000..c36094f2 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-readlinkat.c @@ -0,0 +1,120 @@ +/* Tests of readlinkat. + Copyright (C) 2009-2024 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 . */ + +/* Written by Eric Blake , 2009. */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (readlinkat, ssize_t, (int, char const *, char *, size_t)); + +#include +#include +#include +#include +#include +#include + +#include "ignore-value.h" +#include "macros.h" + +#ifndef HAVE_SYMLINK +# define HAVE_SYMLINK 0 +#endif + +#define BASE "test-readlinkat.t" + +#include "test-readlink.h" + +static int dfd = AT_FDCWD; + +static ssize_t +do_readlink (char const *name, char *buf, size_t len) +{ + return readlinkat (dfd, name, buf, len); +} + +int +main (void) +{ + char buf[80]; + int result; + + /* Remove any leftovers from a previous partial run. */ + ignore_value (system ("rm -rf " BASE "*")); + + /* Test behaviour for invalid file descriptors. */ + { + errno = 0; + ASSERT (readlinkat (-1, "foo", buf, sizeof buf) == -1); + ASSERT (errno == EBADF); + } + { + close (99); + errno = 0; + ASSERT (readlinkat (99, "foo", buf, sizeof buf) == -1); + ASSERT (errno == EBADF); + } + + /* Perform same checks as counterpart functions. */ + result = test_readlink (do_readlink, false); + dfd = openat (AT_FDCWD, ".", O_RDONLY); + ASSERT (0 <= dfd); + ASSERT (test_readlink (do_readlink, false) == result); + + /* Now perform some cross-directory checks. Skip everything else on + mingw. */ + if (HAVE_SYMLINK) + { + const char *contents = "don't matter!"; + ssize_t exp = strlen (contents); + + /* Create link while cwd is '.', then read it in '..'. */ + ASSERT (symlinkat (contents, AT_FDCWD, BASE "link") == 0); + errno = 0; + ASSERT (symlinkat (contents, dfd, BASE "link") == -1); + ASSERT (errno == EEXIST); + ASSERT (chdir ("..") == 0); + errno = 0; + ASSERT (readlinkat (AT_FDCWD, BASE "link", buf, sizeof buf) == -1); + ASSERT (errno == ENOENT); + ASSERT (readlinkat (dfd, BASE "link", buf, sizeof buf) == exp); + ASSERT (strncmp (contents, buf, exp) == 0); + ASSERT (unlinkat (dfd, BASE "link", 0) == 0); + + /* Create link while cwd is '..', then read it in '.'. */ + ASSERT (symlinkat (contents, dfd, BASE "link") == 0); + ASSERT (fchdir (dfd) == 0); + errno = 0; + ASSERT (symlinkat (contents, AT_FDCWD, BASE "link") == -1); + ASSERT (errno == EEXIST); + buf[0] = '\0'; + ASSERT (readlinkat (AT_FDCWD, BASE "link", buf, sizeof buf) == exp); + ASSERT (strncmp (contents, buf, exp) == 0); + buf[0] = '\0'; + ASSERT (readlinkat (dfd, BASE "link", buf, sizeof buf) == exp); + ASSERT (strncmp (contents, buf, exp) == 0); + ASSERT (unlink (BASE "link") == 0); + } + + ASSERT (close (dfd) == 0); + if (result == 77) + fputs ("skipping test: symlinks not supported on this file system\n", + stderr); + return result; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-realloc-gnu.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-realloc-gnu.c new file mode 100644 index 00000000..54832ee8 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-realloc-gnu.c @@ -0,0 +1,49 @@ +/* Test of realloc function. + Copyright (C) 2010-2024 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 . */ + +#include + +/* Specification. */ +#include + +#include +#include + +#include "macros.h" + +int +main (int argc, _GL_UNUSED char **argv) +{ + /* Check that realloc (NULL, 0) is not a NULL pointer. */ + void *volatile p = realloc (NULL, 0); + ASSERT (p != NULL); + + /* Check that realloc (p, n) fails when p is non-null and n exceeds + PTRDIFF_MAX. */ + if (PTRDIFF_MAX < SIZE_MAX) + { + size_t one = argc != 12345; + p = realloc (p, PTRDIFF_MAX + one); + ASSERT (p == NULL); + /* Avoid a test failure due to glibc bug + . */ + if (!getenv ("MALLOC_CHECK_")) + ASSERT (errno == ENOMEM); + } + + free (p); + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-reallocarray.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-reallocarray.c new file mode 100644 index 00000000..fb9171ce --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-reallocarray.c @@ -0,0 +1,58 @@ +/* Test of reallocarray function. + Copyright (C) 2010-2024 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 . */ + +#include + +/* Specification. */ +#include + +#include +#include + +#include "signature.h" +SIGNATURE_CHECK (reallocarray, void *, (void *, size_t, size_t)); + +#include "macros.h" + +int +main () +{ + /* Check that reallocarray fails when requested to allocate a block + of memory larger than PTRDIFF_MAX or SIZE_MAX bytes. */ + for (size_t n = 2; n != 0; n <<= 1) + { + void *volatile p = NULL; + + if (PTRDIFF_MAX / n + 1 <= SIZE_MAX) + { + p = reallocarray (p, PTRDIFF_MAX / n + 1, n); + ASSERT (p == NULL); + ASSERT (errno == ENOMEM); + } + + p = reallocarray (p, SIZE_MAX / n + 1, n); + ASSERT (p == NULL); + ASSERT (errno == ENOMEM + || errno == EOVERFLOW /* NetBSD */); + + /* Reallocarray should not crash with zero sizes. */ + p = reallocarray (p, 0, n); + p = reallocarray (p, n, 0); + free (p); + } + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-regex.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-regex.c new file mode 100644 index 00000000..175cdf4f --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-regex.c @@ -0,0 +1,488 @@ +/* Test regular expressions + Copyright 1996-2001, 2003-2024 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 . */ + +#include + +#include "regex.h" + +#include +#include +#include +#include +#include +#include +#include +#if HAVE_DECL_ALARM +# include +# include +#endif + +#include "localcharset.h" + +static int exit_status; + +static void +report_error (char const *format, ...) +{ + va_list args; + va_start (args, format); + fprintf (stderr, "test-regex: "); + vfprintf (stderr, format, args); + fprintf (stderr, "\n"); + va_end (args); + exit_status = 1; +} + +/* Check whether it's really a UTF-8 locale. + On mingw, setlocale (LC_ALL, "en_US.UTF-8") succeeds but returns + "English_United States.1252", with locale_charset () returning "CP1252". */ +static int +really_utf8 (void) +{ + return strcmp (locale_charset (), "UTF-8") == 0; +} + +/* Tests supposed to match; copied from glibc posix/bug-regex11.c. */ +static struct +{ + const char *pattern; + const char *string; + int flags, nmatch; + regmatch_t rm[5]; +} const tests[] = { + /* Test for newline handling in regex. */ + { "[^~]*~", "\nx~y", 0, 2, { { 0, 3 }, { -1, -1 } } }, + /* Other tests. */ + { "a(.*)b", "a b", REG_EXTENDED, 2, { { 0, 3 }, { 1, 2 } } }, + { ".*|\\([KIO]\\)\\([^|]*\\).*|?[KIO]", "10~.~|P|K0|I10|O16|?KSb", 0, 3, + { { 0, 21 }, { 15, 16 }, { 16, 18 } } }, + { ".*|\\([KIO]\\)\\([^|]*\\).*|?\\1", "10~.~|P|K0|I10|O16|?KSb", 0, 3, + { { 0, 21 }, { 8, 9 }, { 9, 10 } } }, + { "^\\(a*\\)\\1\\{9\\}\\(a\\{0,9\\}\\)\\([0-9]*;.*[^a]\\2\\([0-9]\\)\\)", + "a1;;0a1aa2aaa3aaaa4aaaaa5aaaaaa6aaaaaaa7aaaaaaaa8aaaaaaaaa9aa2aa1a0", 0, + 5, { { 0, 67 }, { 0, 0 }, { 0, 1 }, { 1, 67 }, { 66, 67 } } }, + /* Test for BRE expression anchoring. POSIX says just that this may match; + in glibc regex it always matched, so avoid changing it. */ + { "\\(^\\|foo\\)bar", "bar", 0, 2, { { 0, 3 }, { -1, -1 } } }, + { "\\(foo\\|^\\)bar", "bar", 0, 2, { { 0, 3 }, { -1, -1 } } }, + /* In ERE this must be treated as an anchor. */ + { "(^|foo)bar", "bar", REG_EXTENDED, 2, { { 0, 3 }, { -1, -1 } } }, + { "(foo|^)bar", "bar", REG_EXTENDED, 2, { { 0, 3 }, { -1, -1 } } }, + /* Here ^ cannot be treated as an anchor according to POSIX. */ + { "(^|foo)bar", "(^|foo)bar", 0, 2, { { 0, 10 }, { -1, -1 } } }, + { "(foo|^)bar", "(foo|^)bar", 0, 2, { { 0, 10 }, { -1, -1 } } }, + /* More tests on backreferences. */ + { "()\\1", "x", REG_EXTENDED, 2, { { 0, 0 }, { 0, 0 } } }, + { "()x\\1", "x", REG_EXTENDED, 2, { { 0, 1 }, { 0, 0 } } }, + { "()\\1*\\1*", "", REG_EXTENDED, 2, { { 0, 0 }, { 0, 0 } } }, + { "([0-9]).*\\1(a*)", "7;7a6", REG_EXTENDED, 3, { { 0, 4 }, { 0, 1 }, { 3, 4 } } }, + { "([0-9]).*\\1(a*)", "7;7a", REG_EXTENDED, 3, { { 0, 4 }, { 0, 1 }, { 3, 4 } } }, + { "(b)()c\\1", "bcb", REG_EXTENDED, 3, { { 0, 3 }, { 0, 1 }, { 1, 1 } } }, + { "()(b)c\\2", "bcb", REG_EXTENDED, 3, { { 0, 3 }, { 0, 0 }, { 0, 1 } } }, + { "a(b)()c\\1", "abcb", REG_EXTENDED, 3, { { 0, 4 }, { 1, 2 }, { 2, 2 } } }, + { "a()(b)c\\2", "abcb", REG_EXTENDED, 3, { { 0, 4 }, { 1, 1 }, { 1, 2 } } }, + { "()(b)\\1c\\2", "bcb", REG_EXTENDED, 3, { { 0, 3 }, { 0, 0 }, { 0, 1 } } }, + { "(b())\\2\\1", "bbbb", REG_EXTENDED, 3, { { 0, 2 }, { 0, 1 }, { 1, 1 } } }, + { "a()(b)\\1c\\2", "abcb", REG_EXTENDED, 3, { { 0, 4 }, { 1, 1 }, { 1, 2 } } }, + { "a()d(b)\\1c\\2", "adbcb", REG_EXTENDED, 3, { { 0, 5 }, { 1, 1 }, { 2, 3 } } }, + { "a(b())\\2\\1", "abbbb", REG_EXTENDED, 3, { { 0, 3 }, { 1, 2 }, { 2, 2 } } }, + { "(bb())\\2\\1", "bbbb", REG_EXTENDED, 3, { { 0, 4 }, { 0, 2 }, { 2, 2 } } }, + { "^([^,]*),\\1,\\1$", "a,a,a", REG_EXTENDED, 2, { { 0, 5 }, { 0, 1 } } }, + { "^([^,]*),\\1,\\1$", "ab,ab,ab", REG_EXTENDED, 2, { { 0, 8 }, { 0, 2 } } }, + { "^([^,]*),\\1,\\1,\\1$", "abc,abc,abc,abc", REG_EXTENDED, 2, + { { 0, 15 }, { 0, 3 } } }, + { "^(.?)(.?)(.?)(.?)(.?).?\\5\\4\\3\\2\\1$", + "level", REG_NOSUB | REG_EXTENDED, 0, { { -1, -1 } } }, + { "^(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.).?\\9\\8\\7\\6\\5\\4\\3\\2\\1$|^.?$", + "level", REG_NOSUB | REG_EXTENDED, 0, { { -1, -1 } } }, + { "^(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.).?\\9\\8\\7\\6\\5\\4\\3\\2\\1$|^.?$", + "abcdedcba", REG_EXTENDED, 1, { { 0, 9 } } }, + { "^(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.).?\\9\\8\\7\\6\\5\\4\\3\\2\\1$|^.?$", + "ababababa", REG_EXTENDED, 1, { { 0, 9 } } }, + { "^(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.?).?\\9\\8\\7\\6\\5\\4\\3\\2\\1$", + "level", REG_NOSUB | REG_EXTENDED, 0, { { -1, -1 } } }, + { "^(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.?).?\\9\\8\\7\\6\\5\\4\\3\\2\\1$", + "ababababa", REG_EXTENDED, 1, { { 0, 9 } } }, + /* Test for *+ match. */ + { "^a*+(.)", "ab", REG_EXTENDED, 2, { { 0, 2 }, { 1, 2 } } }, + /* Test for ** match. */ + { "^(a*)*(.)", "ab", REG_EXTENDED, 3, { { 0, 2 }, { 0, 1 }, { 1, 2 } } }, +}; + +static void +bug_regex11 (void) +{ + regex_t re; + regmatch_t rm[5]; + size_t i; + int n; + + for (i = 0; i < sizeof (tests) / sizeof (tests[0]); ++i) + { + n = regcomp (&re, tests[i].pattern, tests[i].flags); + if (n != 0) + { + char buf[500]; + regerror (n, &re, buf, sizeof (buf)); + report_error ("%s: regcomp %zd failed: %s", tests[i].pattern, i, buf); + continue; + } + + if (regexec (&re, tests[i].string, tests[i].nmatch, rm, 0)) + { + report_error ("%s: regexec %zd failed", tests[i].pattern, i); + regfree (&re); + continue; + } + + for (n = 0; n < tests[i].nmatch; ++n) + if (rm[n].rm_so != tests[i].rm[n].rm_so + || rm[n].rm_eo != tests[i].rm[n].rm_eo) + { + if (tests[i].rm[n].rm_so == -1 && tests[i].rm[n].rm_eo == -1) + break; + report_error ("%s: regexec %zd match failure rm[%d] %d..%d", + tests[i].pattern, i, n, + (int) rm[n].rm_so, (int) rm[n].rm_eo); + break; + } + + regfree (&re); + } +} + +int +main (void) +{ + static struct re_pattern_buffer regex; + unsigned char folded_chars[UCHAR_MAX + 1]; + int i; + const char *s; + struct re_registers regs; + +#if HAVE_DECL_ALARM + /* In case a bug causes glibc to go into an infinite loop. + The tests should take less than 10 s on a reasonably modern CPU. */ + int alarm_value = 1000; + signal (SIGALRM, SIG_DFL); + alarm (alarm_value); +#endif + + bug_regex11 (); + + if (setlocale (LC_ALL, "en_US.UTF-8")) + { + { + /* https://sourceware.org/ml/libc-hacker/2006-09/msg00008.html + This test needs valgrind to catch the bug on Debian + GNU/Linux 3.1 x86, but it might catch the bug better + on other platforms and it shouldn't hurt to try the + test here. */ + static char const pat[] = "insert into"; + static char const data[] = + "\xFF\0\x12\xA2\xAA\xC4\xB1,K\x12\xC4\xB1*\xACK"; + re_set_syntax (RE_SYNTAX_GREP | RE_HAT_LISTS_NOT_NEWLINE + | RE_ICASE); + memset (®ex, 0, sizeof regex); + s = re_compile_pattern (pat, sizeof pat - 1, ®ex); + if (s) + report_error ("%s: %s", pat, s); + else + { + memset (®s, 0, sizeof regs); + i = re_search (®ex, data, sizeof data - 1, + 0, sizeof data - 1, ®s); + if (i != -1) + report_error ("re_search '%s' on '%s' returned %d", + pat, data, i); + regfree (®ex); + free (regs.start); + free (regs.end); + } + } + + if (really_utf8 ()) + { + /* This test is from glibc bug 15078. + The test case is from Andreas Schwab in + . + */ + static char const pat[] = "[^x]x"; + static char const data[] = + /* */ + "\xe1\x80\x80" + "\xe1\x80\xbb" + "\xe1\x80\xbd" + "\xe1\x80\x94" + "\xe1\x80\xba" + "\xe1\x80\xaf" + "\xe1\x80\x95" + "\xe1\x80\xba" + "x"; + re_set_syntax (0); + memset (®ex, 0, sizeof regex); + s = re_compile_pattern (pat, sizeof pat - 1, ®ex); + if (s) + report_error ("%s: %s", pat, s); + else + { + memset (®s, 0, sizeof regs); + i = re_search (®ex, data, sizeof data - 1, + 0, sizeof data - 1, 0); + if (i != 0 && i != 21) + report_error ("re_search '%s' on '%s' returned %d", + pat, data, i); + regfree (®ex); + free (regs.start); + free (regs.end); + } + } + + if (! setlocale (LC_ALL, "C")) + { + report_error ("setlocale \"C\" failed"); + return exit_status; + } + } + + if (setlocale (LC_ALL, "tr_TR.UTF-8")) + { + if (really_utf8 () && towupper (L'i') == 0x0130 /* U+0130; see below. */) + { + re_set_syntax (RE_SYNTAX_GREP | RE_ICASE); + memset (®ex, 0, sizeof regex); + static char const pat[] = "i"; + s = re_compile_pattern (pat, sizeof pat - 1, ®ex); + if (s) + report_error ("%s: %s", pat, s); + else + { + /* UTF-8 encoding of U+0130 LATIN CAPITAL LETTER I WITH DOT ABOVE. + In Turkish, this is the upper-case equivalent of ASCII "i". + Older versions of Gnulib failed to match "i" to U+0130 when + ignoring case in Turkish . */ + static char const data[] = "\xc4\xb0"; + + memset (®s, 0, sizeof regs); + i = re_search (®ex, data, sizeof data - 1, 0, sizeof data - 1, + ®s); + if (i != 0) + report_error ("re_search '%s' on '%s' returned %d", + pat, data, i); + regfree (®ex); + free (regs.start); + free (regs.end); + } + } + + if (! setlocale (LC_ALL, "C")) + { + report_error ("setlocale \"C\" failed"); + return exit_status; + } + } + + /* This test is from glibc bug 3957, reported by Andrew Mackey. */ + re_set_syntax (RE_SYNTAX_EGREP | RE_HAT_LISTS_NOT_NEWLINE); + memset (®ex, 0, sizeof regex); + static char const pat_3957[] = "a[^x]b"; + s = re_compile_pattern (pat_3957, sizeof pat_3957 - 1, ®ex); + if (s) + report_error ("%s: %s", pat_3957, s); + else + { + /* This should fail, but succeeds for glibc-2.5. */ + memset (®s, 0, sizeof regs); + static char const data[] = "a\nb"; + i = re_search (®ex, data, sizeof data - 1, 0, sizeof data - 1, ®s); + if (i != -1) + report_error ("re_search '%s' on '%s' returned %d", + pat_3957, data, i); + regfree (®ex); + free (regs.start); + free (regs.end); + } + + /* This regular expression is from Spencer ere test number 75 + in grep-2.3. */ + re_set_syntax (RE_SYNTAX_POSIX_EGREP); + memset (®ex, 0, sizeof regex); + for (i = 0; i <= UCHAR_MAX; i++) + folded_chars[i] = i; + regex.translate = folded_chars; + static char const pat75[] = "a[[:@:>@:]]b\n"; + s = re_compile_pattern (pat75, sizeof pat75 - 1, ®ex); + /* This should fail with _Invalid character class name_ error. */ + if (!s) + { + report_error ("re_compile_pattern: failed to reject '%s'", pat75); + regfree (®ex); + } + + /* Ensure that [b-a] is diagnosed as invalid, when + using RE_NO_EMPTY_RANGES. */ + re_set_syntax (RE_SYNTAX_POSIX_EGREP | RE_NO_EMPTY_RANGES); + memset (®ex, 0, sizeof regex); + static char const pat_b_a[] = "a[b-a]"; + s = re_compile_pattern (pat_b_a, sizeof pat_b_a - 1, ®ex); + if (s == 0) + { + report_error ("re_compile_pattern: failed to reject '%s'", pat_b_a); + regfree (®ex); + } + + /* This should succeed, but does not for glibc-2.1.3. */ + memset (®ex, 0, sizeof regex); + static char const pat_213[] = "{1"; + s = re_compile_pattern (pat_213, sizeof pat_213 - 1, ®ex); + if (s) + report_error ("%s: %s", pat_213, s); + else + regfree (®ex); + + /* The following example is derived from a problem report + against gawk from Jorge Stolfi . */ + memset (®ex, 0, sizeof regex); + static char const pat_stolfi[] = "[an\371]*n"; + s = re_compile_pattern (pat_stolfi, sizeof pat_stolfi - 1, ®ex); + if (s) + report_error ("%s: %s", pat_stolfi, s); + /* This should match, but does not for glibc-2.2.1. */ + else + { + memset (®s, 0, sizeof regs); + static char const data[] = "an"; + i = re_match (®ex, data, sizeof data - 1, 0, ®s); + if (i != 2) + report_error ("re_match '%s' on '%s' at 2 returned %d", + pat_stolfi, data, i); + regfree (®ex); + free (regs.start); + free (regs.end); + } + + memset (®ex, 0, sizeof regex); + static char const pat_x[] = "x"; + s = re_compile_pattern (pat_x, sizeof pat_x - 1, ®ex); + if (s) + report_error ("%s: %s", pat_x, s); + /* glibc-2.2.93 does not work with a negative RANGE argument. */ + else + { + memset (®s, 0, sizeof regs); + static char const data[] = "wxy"; + i = re_search (®ex, data, sizeof data - 1, 2, -2, ®s); + if (i != 1) + report_error ("re_search '%s' on '%s' returned %d", pat_x, data, i); + regfree (®ex); + free (regs.start); + free (regs.end); + } + + /* The version of regex.c in older versions of gnulib + ignored RE_ICASE. Detect that problem too. */ + re_set_syntax (RE_SYNTAX_EMACS | RE_ICASE); + memset (®ex, 0, sizeof regex); + s = re_compile_pattern (pat_x, 1, ®ex); + if (s) + report_error ("%s: %s", pat_x, s); + else + { + memset (®s, 0, sizeof regs); + static char const data[] = "WXY"; + i = re_search (®ex, data, sizeof data - 1, 0, 3, ®s); + if (i < 0) + report_error ("re_search '%s' on '%s' returned %d", pat_x, data, i); + regfree (®ex); + free (regs.start); + free (regs.end); + } + + /* glibc bug 11053. */ + re_set_syntax (RE_SYNTAX_POSIX_BASIC); + memset (®ex, 0, sizeof regex); + static char const pat_sub2[] = "\\(a*\\)*a*\\1"; + s = re_compile_pattern (pat_sub2, sizeof pat_sub2 - 1, ®ex); + if (s) + report_error ("%s: %s", pat_sub2, s); + else + { + memset (®s, 0, sizeof regs); + static char const data[] = "a"; + int datalen = sizeof data - 1; + i = re_search (®ex, data, datalen, 0, datalen, ®s); + if (i != 0) + report_error ("re_search '%s' on '%s' returned %d", pat_sub2, data, i); + else if (regs.num_regs < 2) + report_error ("re_search '%s' on '%s' returned only %d registers", + pat_sub2, data, (int) regs.num_regs); + else if (! (regs.start[0] == 0 && regs.end[0] == 1)) + report_error ("re_search '%s' on '%s' returned wrong match [%d,%d)", + pat_sub2, data, (int) regs.start[0], (int) regs.end[0]); + else if (! (regs.start[1] == 0 && regs.end[1] == 0)) + report_error ("re_search '%s' on '%s' returned wrong submatch [%d,%d)", + pat_sub2, data, (int) regs.start[1], (int) regs.end[1]); + regfree (®ex); + free (regs.start); + free (regs.end); + } + + /* Catch a bug reported by Vin Shelton in + https://lists.gnu.org/r/bug-coreutils/2007-06/msg00089.html + */ + re_set_syntax (RE_SYNTAX_POSIX_BASIC + & ~RE_CONTEXT_INVALID_DUP + & ~RE_NO_EMPTY_RANGES); + static char const pat_shelton[] = "[[:alnum:]_-]\\\\+$"; + s = re_compile_pattern (pat_shelton, sizeof pat_shelton - 1, ®ex); + if (s) + report_error ("%s: %s", pat_shelton, s); + else + regfree (®ex); + + /* REG_STARTEND was added to glibc on 2004-01-15. + Reject older versions. */ + if (REG_STARTEND == 0) + report_error ("REG_STARTEND is zero"); + + /* Matching with the compiled form of this regexp would provoke + an assertion failure prior to glibc-2.28: + regexec.c:1375: pop_fail_stack: Assertion 'num >= 0' failed + With glibc-2.28, compilation fails and reports the invalid + back reference. */ + re_set_syntax (RE_SYNTAX_POSIX_EGREP); + memset (®ex, 0, sizeof regex); + static char const pat_badback[] = "0|()0|\\1|0"; + s = re_compile_pattern (pat_badback, sizeof pat_badback, ®ex); + if (!s && re_search (®ex, "x", 1, 0, 1, ®s) != -1) + s = "mishandled invalid back reference"; + if (s && strcmp (s, "Invalid back reference") != 0) + report_error ("%s: %s", pat_badback, s); + +#if 0 + /* It would be nice to reject hosts whose regoff_t values are too + narrow (including glibc on hosts with 64-bit ptrdiff_t and + 32-bit int), but we should wait until glibc implements this + feature. Otherwise, support for equivalence classes and + multibyte collation symbols would always be broken except + when compiling --without-included-regex. */ + if (sizeof (regoff_t) < sizeof (ptrdiff_t) + || sizeof (regoff_t) < sizeof (ssize_t)) + report_error ("regoff_t values are too narrow"); +#endif + + return exit_status; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-rmdir.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-rmdir.c new file mode 100644 index 00000000..7f18663b --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-rmdir.c @@ -0,0 +1,46 @@ +/* Tests of rmdir. + Copyright (C) 2009-2024 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 . */ + +/* Written by Eric Blake , 2009. */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (rmdir, int, (char const *)); + +#include +#include +#include +#include +#include + +#include "ignore-value.h" +#include "macros.h" + +#define BASE "test-rmdir.t" + +#include "test-rmdir.h" + +int +main (void) +{ + /* Remove any leftovers from a previous partial run. */ + ignore_value (system ("rm -rf " BASE "*")); + + return test_rmdir_func (rmdir, true); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-rmdir.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-rmdir.h new file mode 100644 index 00000000..09e3600d --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-rmdir.h @@ -0,0 +1,102 @@ +/* Tests of rmdir. + Copyright (C) 2009-2024 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 . */ + +/* Written by Eric Blake , 2009. */ + +/* This file is designed to test both rmdir(n) and + unlinkat(AT_FDCWD,n,AT_REMOVEDIR). FUNC is the function to test. + Assumes that BASE and ASSERT are already defined, and that + appropriate headers are already included. If PRINT, then warn + before returning status 77 when symlinks are unsupported. */ + +static int +test_rmdir_func (int (*func) (char const *name), bool print) +{ + /* Setup. */ + ASSERT (mkdir (BASE "dir", 0700) == 0); + ASSERT (close (creat (BASE "dir/file", 0600)) == 0); + + /* Basic error conditions. */ + errno = 0; + ASSERT (func ("") == -1); + ASSERT (errno == ENOENT); + errno = 0; + ASSERT (func (BASE "nosuch") == -1); + ASSERT (errno == ENOENT); + errno = 0; + ASSERT (func (BASE "nosuch/") == -1); + ASSERT (errno == ENOENT); + errno = 0; + ASSERT (func (".") == -1); + ASSERT (errno == EINVAL || errno == EBUSY); + /* Resulting errno after ".." or "/" is too varied to test; it is + reasonable to see any of EINVAL, EBUSY, EEXIST, ENOTEMPTY, + EACCES, EPERM. */ + ASSERT (func ("..") == -1); + ASSERT (func ("/") == -1); + ASSERT (func ("///") == -1); + errno = 0; + ASSERT (func (BASE "dir/file/") == -1); + ASSERT (errno == ENOTDIR); + + /* Non-empty directory. */ + errno = 0; + ASSERT (func (BASE "dir") == -1); + ASSERT (errno == EEXIST || errno == ENOTEMPTY); + + /* Non-directory. */ + errno = 0; + ASSERT (func (BASE "dir/file") == -1); + ASSERT (errno == ENOTDIR); + + /* Empty directory. */ + ASSERT (unlink (BASE "dir/file") == 0); + errno = 0; + ASSERT (func (BASE "dir/.//") == -1); + ASSERT (errno == EINVAL || errno == EBUSY || errno == EEXIST + || errno == ENOTEMPTY); + ASSERT (func (BASE "dir") == 0); + + /* Test symlink behavior. Specifying trailing slash should remove + referent directory (POSIX), or cause ENOTDIR failure (Linux), but + not touch symlink. We prefer the Linux behavior for its + intuitiveness (especially compared to rmdir("symlink-to-file/")), + but not enough to penalize POSIX systems with an rpl_rmdir. */ + if (symlink (BASE "dir", BASE "link") != 0) + { + if (print) + fputs ("skipping test: symlinks not supported on this file system\n", + stderr); + return 77; + } + ASSERT (mkdir (BASE "dir", 0700) == 0); + errno = 0; + if (func (BASE "link/") == 0) + { + struct stat st; + errno = 0; + ASSERT (stat (BASE "link", &st) == -1); + ASSERT (errno == ENOENT); + } + else + { + ASSERT (errno == ENOTDIR); + ASSERT (func (BASE "dir") == 0); + } + ASSERT (unlink (BASE "link") == 0); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sched.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sched.c new file mode 100644 index 00000000..afefc7d5 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sched.c @@ -0,0 +1,41 @@ +/* Test of substitute. + Copyright (C) 2008-2024 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 . */ + +/* Written by Bruno Haible , 2008. */ + +#include + +#include + +/* Check that 'struct sched_param' is defined. */ +static struct sched_param a; + +/* Check that the SCHED_* macros are defined and compile-time constants. */ +int b[] = { SCHED_FIFO, SCHED_RR, SCHED_OTHER }; + +/* Check that the types are all defined. */ +pid_t t1; + +int f1; + +int +main () +{ + /* Check fields of 'struct sched_param'. */ + f1 = a.sched_priority; + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-select-fd.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-select-fd.c new file mode 100644 index 00000000..b94addd5 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-select-fd.c @@ -0,0 +1,72 @@ +/* Test of select() substitute, reading or writing from a given file descriptor. + Copyright (C) 2008-2024 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 . */ + +/* Written by Bruno Haible , 2008. */ + +#include + +#include +#include +#include + +int +main (int argc, char *argv[]) +{ + if (argc == 4) + { + char mode = argv[1][0]; + + if (mode == 'r' || mode == 'w') + { + int fd = atoi (argv[2]); + + if (fd >= 0) + { + const char *result_file_name = argv[3]; + FILE *result_file = fopen (result_file_name, "wb"); + + if (result_file != NULL) + { + fd_set fds; + struct timeval timeout; + int ret; + + FD_ZERO (&fds); + FD_SET (fd, &fds); + timeout.tv_sec = 0; + timeout.tv_usec = 10000; + ret = (mode == 'r' + ? select (fd + 1, &fds, NULL, NULL, &timeout) + : select (fd + 1, NULL, &fds, NULL, &timeout)); + if (ret < 0) + { + perror ("select failed"); + exit (1); + } + if ((ret == 0) != ! FD_ISSET (fd, &fds)) + { + fprintf (stderr, "incorrect return value\n"); + exit (1); + } + fprintf (result_file, "%d\n", ret); + exit (0); + } + } + } + } + fprintf (stderr, "Usage: test-select-fd mode fd result-file-name\n"); + exit (1); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-select-in.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-select-in.sh new file mode 100755 index 00000000..ad86ea25 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-select-in.sh @@ -0,0 +1,38 @@ +#!/bin/sh +# Test select() on file descriptors opened for reading. + +# This test is known to fail on Solaris 2.6 and older, due to its handling +# of /dev/null. + +tmpfiles="" +trap 'rm -fr $tmpfiles' HUP INT QUIT TERM + +tmpfiles="$tmpfiles t-select-in.tmp" + +# Regular files. + +rm -f t-select-in.tmp +${CHECKER} ./test-select-fd${EXEEXT} r 0 t-select-in.tmp < ./test-select-fd${EXEEXT} +test `cat t-select-in.tmp` = "1" || exit 1 + +# Pipes. + +rm -f t-select-in.tmp +{ sleep 1; echo abc; } | \ + { ${CHECKER} ./test-select-fd${EXEEXT} r 0 t-select-in.tmp; cat > /dev/null; } +test `cat t-select-in.tmp` = "0" || exit 1 + +rm -f t-select-in.tmp +echo abc | { sleep 1; ${CHECKER} ./test-select-fd${EXEEXT} r 0 t-select-in.tmp; } +test `cat t-select-in.tmp` = "1" || exit 1 + +# Special files. +# This part of the test is known to fail on Solaris 2.6 and older. + +rm -f t-select-in.tmp +${CHECKER} ./test-select-fd${EXEEXT} r 0 t-select-in.tmp < /dev/null +test `cat t-select-in.tmp` = "1" || exit 1 + +rm -fr $tmpfiles + +exit 0 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-select-out.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-select-out.sh new file mode 100755 index 00000000..cfa5e179 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-select-out.sh @@ -0,0 +1,35 @@ +#!/bin/sh +# Test select() on file descriptors opened for writing. + +tmpfiles="" +trap 'rm -fr $tmpfiles' HUP INT QUIT TERM + +tmpfiles="$tmpfiles t-select-out.out t-select-out.tmp" + +# Regular files. + +rm -f t-select-out.tmp +${CHECKER} ./test-select-fd${EXEEXT} w 1 t-select-out.tmp > t-select-out.out +test `cat t-select-out.tmp` = "1" || exit 1 + +# Pipes. + +if false; then # This test fails on some platforms. + rm -f t-select-out.tmp + ( { echo abc; ${CHECKER} ./test-select-fd${EXEEXT} w 1 t-select-out.tmp; } | { sleep 1; cat; } ) > /dev/null + test `cat t-select-out.tmp` = "0" || exit 1 +fi + +rm -f t-select-out.tmp +( { sleep 1; echo abc; ${CHECKER} ./test-select-fd${EXEEXT} w 1 t-select-out.tmp; } | cat) > /dev/null +test `cat t-select-out.tmp` = "1" || exit 1 + +# Special files. + +rm -f t-select-out.tmp +${CHECKER} ./test-select-fd${EXEEXT} w 1 t-select-out.tmp > /dev/null +test `cat t-select-out.tmp` = "1" || exit 1 + +rm -fr $tmpfiles + +exit 0 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-select-stdin.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-select-stdin.c new file mode 100644 index 00000000..2f8f08aa --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-select-stdin.c @@ -0,0 +1,83 @@ +/* Test of select() substitute, reading from stdin. + Copyright (C) 2008-2024 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 . */ + +/* Written by Bruno Haible , 2008. */ + +#include + +#include +#include +#include +#include +#include + +#include "macros.h" + +int +main (void) +{ + printf ("Applying select() from standard input. Press Ctrl-C to abort.\n"); + for (;;) + { + struct timeval before; + struct timeval after; + unsigned long spent_usec; + fd_set readfds; + struct timeval timeout; + int ret; + + gettimeofday (&before, NULL); + + FD_ZERO (&readfds); + FD_SET (0, &readfds); + timeout.tv_sec = 0; + timeout.tv_usec = 500000; + ret = select (1, &readfds, NULL, NULL, &timeout); + + gettimeofday (&after, NULL); + spent_usec = (after.tv_sec - before.tv_sec) * 1000000 + + after.tv_usec - before.tv_usec; + + if (ret < 0) + { + perror ("select failed"); + exit (1); + } + if ((ret == 0) != ! FD_ISSET (0, &readfds)) + { + fprintf (stderr, "incorrect return value\n"); + exit (1); + } + if (ret == 0) + { + if (spent_usec < 250000) + { + fprintf (stderr, "returned too early\n"); + exit (1); + } + /* Timeout */ + printf ("."); + ASSERT (fflush (stdout) == 0); + } + else + { + char c; + + printf ("Input available! Trying to read 1 byte...\n"); + ASSERT (read (0, &c, 1) == 1); + } + } +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-select.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-select.c new file mode 100644 index 00000000..a75c9244 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-select.c @@ -0,0 +1,35 @@ +/* Test of select() substitute. + Copyright (C) 2008-2024 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 . */ + +/* Written by Paolo Bonzini, 2008. */ + +#include + +#include + +#include "signature.h" + +SIGNATURE_CHECK (select, int, (int, fd_set *, fd_set *, fd_set *, + struct timeval *)); + +#define TEST_PORT 12346 +#include "test-select.h" + +int +main (void) +{ + return test_function (select); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-select.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-select.h new file mode 100644 index 00000000..4896b674 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-select.h @@ -0,0 +1,467 @@ +/* Test of select() substitute. + Copyright (C) 2008-2024 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 . */ + +/* Written by Paolo Bonzini, 2008. */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "macros.h" + +#if defined _WIN32 && ! defined __CYGWIN__ +# define WINDOWS_NATIVE +#endif + +#ifdef HAVE_SYS_WAIT_H +# include +#endif + +/* Tell GCC not to warn about the specific edge cases tested here. */ +#if __GNUC__ >= 13 +# pragma GCC diagnostic ignored "-Wanalyzer-fd-use-without-check" +#endif + +typedef int (*select_fn) (int, fd_set *, fd_set *, fd_set *, struct timeval *); + + +/* Minimal testing infrastructure. */ + +static int failures; + +static void +failed (const char *reason) +{ + if (++failures > 1) + printf (" "); + printf ("failed (%s)\n", reason); +} + +static int +test (void (*fn) (select_fn), select_fn my_select, const char *msg) +{ + failures = 0; + printf ("%s... ", msg); + fflush (stdout); + fn (my_select); + + if (!failures) + printf ("passed\n"); + + return failures; +} + + +/* Funny socket code. */ + +static int +open_server_socket (void) +{ + int s, x; + struct sockaddr_in ia; + + s = socket (AF_INET, SOCK_STREAM, 0); + + x = 1; + setsockopt (s, SOL_SOCKET, SO_REUSEPORT, &x, sizeof (x)); + + memset (&ia, 0, sizeof (ia)); + ia.sin_family = AF_INET; + inet_pton (AF_INET, "127.0.0.1", &ia.sin_addr); + ia.sin_port = htons (TEST_PORT); + if (bind (s, (struct sockaddr *) &ia, sizeof (ia)) < 0) + { + perror ("bind"); + exit (77); + } + + if (listen (s, 1) < 0) + { + perror ("listen"); + exit (77); + } + + return s; +} + +static int +connect_to_socket (bool blocking) +{ + int s; + struct sockaddr_in ia; + + s = socket (AF_INET, SOCK_STREAM, 0); + + memset (&ia, 0, sizeof (ia)); + ia.sin_family = AF_INET; + inet_pton (AF_INET, "127.0.0.1", &ia.sin_addr); + ia.sin_port = htons (TEST_PORT); + + if (!blocking) + { +#ifdef WINDOWS_NATIVE + unsigned long iMode = 1; + ioctl (s, FIONBIO, (char *) &iMode); + +#elif defined F_GETFL + int oldflags = fcntl (s, F_GETFL, NULL); + + if (!(oldflags & O_NONBLOCK)) + fcntl (s, F_SETFL, oldflags | O_NONBLOCK); +#endif + } + + if (connect (s, (struct sockaddr *) &ia, sizeof (ia)) < 0 + && (blocking || errno != EINPROGRESS)) + { + perror ("connect"); + exit (77); + } + + return s; +} + + +/* A slightly more convenient interface to select(2). + Waits until a specific event occurs on a file descriptor FD. + EV is a bit mask of events to look for: + SEL_IN - input can be polled without blocking, + SEL_OUT - output can be provided without blocking, + SEL_EXC - an exception occurred, + A maximum wait time is specified by TIMEOUT. + *TIMEOUT = { 0, 0 } means to return immediately, + TIMEOUT = NULL means to wait indefinitely. */ + +enum { SEL_IN = 1, SEL_OUT = 2, SEL_EXC = 4 }; + +static int +do_select (int fd, int ev, struct timeval *timeout, select_fn my_select) +{ + fd_set rfds, wfds, xfds; + int r, rev; + + FD_ZERO (&rfds); + FD_ZERO (&wfds); + FD_ZERO (&xfds); + if (ev & SEL_IN) + FD_SET (fd, &rfds); + if (ev & SEL_OUT) + FD_SET (fd, &wfds); + if (ev & SEL_EXC) + FD_SET (fd, &xfds); + r = my_select (fd + 1, &rfds, &wfds, &xfds, timeout); + if (r < 0) + return r; + + rev = 0; + if (FD_ISSET (fd, &rfds)) + rev |= SEL_IN; + if (FD_ISSET (fd, &wfds)) + rev |= SEL_OUT; + if (FD_ISSET (fd, &xfds)) + rev |= SEL_EXC; + if (rev && r == 0) + failed ("select returned 0"); + if (rev & ~ev) + failed ("select returned unrequested events"); + + return rev; +} + +static int +do_select_nowait (int fd, int ev, select_fn my_select) +{ + struct timeval tv0; + tv0.tv_sec = 0; + tv0.tv_usec = 0; + return do_select (fd, ev, &tv0, my_select); +} + +static int +do_select_wait (int fd, int ev, select_fn my_select) +{ + return do_select (fd, ev, NULL, my_select); +} + + +/* Test select(2) for TTYs. */ + +#ifdef INTERACTIVE +static void +test_tty (select_fn my_select) +{ + if (do_select_nowait (0, SEL_IN, my_select) != 0) + failed ("can read"); + if (do_select_nowait (0, SEL_OUT, my_select) == 0) + failed ("cannot write"); + + if (do_select_wait (0, SEL_IN, my_select) == 0) + failed ("return with infinite timeout"); + + getchar (); + if (do_select_nowait (0, SEL_IN, my_select) != 0) + failed ("can read after getc"); +} +#endif + + +static int +do_select_bad_nfd_nowait (int nfd, select_fn my_select) +{ + struct timeval tv0; + tv0.tv_sec = 0; + tv0.tv_usec = 0; + errno = 0; + return my_select (nfd, NULL, NULL, NULL, &tv0); +} + +static void +test_bad_nfd (select_fn my_select) +{ + if (do_select_bad_nfd_nowait (-1, my_select) != -1 || errno != EINVAL) + failed ("invalid errno after negative nfds"); + /* Can't test FD_SETSIZE + 1 for EINVAL, since some systems allow + dynamically larger set size by redefining FD_SETSIZE anywhere up + to the actual maximum fd. */ +#if 0 + if (do_select_bad_nfd_nowait (FD_SETSIZE + 1, my_select) != -1 + || errno != EINVAL) + failed ("invalid errno after bogus nfds"); +#endif +} + +/* Test select(2) on invalid file descriptors. */ + +static int +do_select_bad_fd (int fd, int ev, struct timeval *timeout, select_fn my_select) +{ + fd_set rfds, wfds, xfds; + + FD_ZERO (&rfds); + FD_ZERO (&wfds); + FD_ZERO (&xfds); + if (ev & SEL_IN) + FD_SET (fd, &rfds); + if (ev & SEL_OUT) + FD_SET (fd, &wfds); + if (ev & SEL_EXC) + FD_SET (fd, &xfds); + errno = 0; + return my_select (fd + 1, &rfds, &wfds, &xfds, timeout); + /* In this case, when fd is invalid, on some platforms, the bit for fd + is left alone in the fd_set, whereas on other platforms it is cleared. + So, don't check the bit for fd here. */ +} + +static int +do_select_bad_fd_nowait (int fd, int ev, select_fn my_select) +{ + struct timeval tv0; + tv0.tv_sec = 0; + tv0.tv_usec = 0; + return do_select_bad_fd (fd, ev, &tv0, my_select); +} + +static void +test_bad_fd (select_fn my_select) +{ + /* This tests fails on OSF/1 and native Windows, even with fd = 16. */ +#if !(defined __osf__ || defined WINDOWS_NATIVE) + int fd; + + /* On Linux, Mac OS X, *BSD, values of fd like 99 or 399 are discarded + by the kernel early and therefore do *not* lead to EBADF, as required + by POSIX. */ +# if defined __linux__ || (defined __APPLE__ && defined __MACH__) || (defined __FreeBSD__ || defined __DragonFly__) || defined __OpenBSD__ || defined __NetBSD__ + fd = 14; +# else + fd = 99; +# endif + /* Even on the best POSIX compliant platforms, values of fd >= FD_SETSIZE + require an nfds argument that is > FD_SETSIZE and thus may lead to EINVAL, + not EBADF. */ + if (fd >= FD_SETSIZE) + fd = FD_SETSIZE - 1; + close (fd); + + if (do_select_bad_fd_nowait (fd, SEL_IN, my_select) == 0 || errno != EBADF) + failed ("invalid fd among rfds"); + if (do_select_bad_fd_nowait (fd, SEL_OUT, my_select) == 0 || errno != EBADF) + failed ("invalid fd among wfds"); + if (do_select_bad_fd_nowait (fd, SEL_EXC, my_select) == 0 || errno != EBADF) + failed ("invalid fd among xfds"); +#endif +} + + +/* Test select(2) for unconnected nonblocking sockets. */ + +static void +test_connect_first (select_fn my_select) +{ + int s = open_server_socket (); + struct sockaddr_in ia; + socklen_t addrlen; + + int c1, c2; + + if (do_select_nowait (s, SEL_IN | SEL_EXC, my_select) != 0) + failed ("can read, socket not connected"); + + c1 = connect_to_socket (false); + + if (do_select_wait (s, SEL_IN | SEL_EXC, my_select) != SEL_IN) + failed ("expecting readability on passive socket"); + if (do_select_nowait (s, SEL_IN | SEL_EXC, my_select) != SEL_IN) + failed ("expecting readability on passive socket"); + + addrlen = sizeof (ia); + c2 = accept (s, (struct sockaddr *) &ia, &addrlen); + ASSERT (close (s) == 0); + ASSERT (close (c1) == 0); + ASSERT (close (c2) == 0); +} + + +/* Test select(2) for unconnected blocking sockets. */ + +static void +test_accept_first (select_fn my_select) +{ +#ifndef WINDOWS_NATIVE + int s = open_server_socket (); + struct sockaddr_in ia; + socklen_t addrlen; + char buf[3]; + int c, pid; + + pid = fork (); + if (pid < 0) + return; + + if (pid == 0) + { + addrlen = sizeof (ia); + c = accept (s, (struct sockaddr *) &ia, &addrlen); + ASSERT (close (s) == 0); + ASSERT (write (c, "foo", 3) == 3); + ASSERT (read (c, buf, 3) == 3); + shutdown (c, SHUT_RD); + ASSERT (close (c) == 0); + exit (0); + } + else + { + ASSERT (close (s) == 0); + c = connect_to_socket (true); + if (do_select_nowait (c, SEL_OUT, my_select) != SEL_OUT) + failed ("cannot write after blocking connect"); + ASSERT (write (c, "foo", 3) == 3); + wait (&pid); + if (do_select_wait (c, SEL_IN, my_select) != SEL_IN) + failed ("cannot read data left in the socket by closed process"); + ASSERT (read (c, buf, 3) == 3); + ASSERT (write (c, "foo", 3) == 3); + (void) close (c); /* may fail with errno = ECONNRESET */ + } +#endif +} + + +/* Common code for pipes and connected sockets. */ + +static void +test_pair (int rd, int wd, select_fn my_select) +{ + char buf[3]; + if (do_select_wait (wd, SEL_IN | SEL_OUT | SEL_EXC, my_select) != SEL_OUT) + failed ("expecting writability before writing"); + if (do_select_nowait (wd, SEL_IN | SEL_OUT | SEL_EXC, my_select) != SEL_OUT) + failed ("expecting writability before writing"); + + ASSERT (write (wd, "foo", 3) == 3); + if (do_select_wait (rd, SEL_IN, my_select) != SEL_IN) + failed ("expecting readability after writing"); + if (do_select_nowait (rd, SEL_IN, my_select) != SEL_IN) + failed ("expecting readability after writing"); + + ASSERT (read (rd, buf, 3) == 3); +} + + +/* Test select(2) on connected sockets. */ + +static void +test_socket_pair (select_fn my_select) +{ + struct sockaddr_in ia; + + socklen_t addrlen = sizeof (ia); + int s = open_server_socket (); + int c1 = connect_to_socket (false); + int c2 = accept (s, (struct sockaddr *) &ia, &addrlen); + + ASSERT (close (s) == 0); + + test_pair (c1, c2, my_select); + ASSERT (close (c1) == 0); + ASSERT (write (c2, "foo", 3) == 3); + (void) close (c2); /* may fail with errno = ECONNRESET */ +} + + +/* Test select(2) on pipes. */ + +static void +test_pipe (select_fn my_select) +{ + int fd[2]; + + ASSERT (pipe (fd) == 0); + test_pair (fd[0], fd[1], my_select); + ASSERT (close (fd[0]) == 0); + ASSERT (close (fd[1]) == 0); +} + + +/* Do them all. */ + +static int +test_function (select_fn my_select) +{ + int result = 0; + +#ifdef INTERACTIVE + printf ("Please press Enter\n"); + test (test_tty, "TTY", my_select); +#endif + + result += test (test_bad_nfd, my_select, "Invalid nfd test"); + result += test (test_bad_fd, my_select, "Invalid fd test"); + result += test (test_connect_first, my_select, "Unconnected socket test"); + result += test (test_socket_pair, my_select, "Connected sockets test"); + result += test (test_accept_first, my_select, "General socket test with fork"); + result += test (test_pipe, my_select, "Pipe test"); + + return result; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-setenv.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-setenv.c new file mode 100644 index 00000000..3b2850e4 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-setenv.c @@ -0,0 +1,56 @@ +/* Tests of setenv. + Copyright (C) 2009-2024 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 . */ + +/* Written by Eric Blake , 2009. */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (setenv, int, (char const *, char const *, int)); + +#include +#include +#include + +#include "macros.h" + +int +main (void) +{ + /* Test overwriting. */ + ASSERT (setenv ("a", "==", -1) == 0); + ASSERT (setenv ("a", "2", 0) == 0); + ASSERT (strcmp (getenv ("a"), "==") == 0); + + /* Required to fail with EINVAL. */ + errno = 0; + ASSERT (setenv ("", "", 1) == -1); + ASSERT (errno == EINVAL); + errno = 0; + ASSERT (setenv ("a=b", "", 0) == -1); + ASSERT (errno == EINVAL); +#if 0 + /* glibc and gnulib's implementation guarantee this, but POSIX no + longer requires it: http://austingroupbugs.net/view.php?id=185 */ + errno = 0; + ASSERT (setenv (NULL, "", 0) == -1); + ASSERT (errno == EINVAL); +#endif + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-setlocale_null-mt-all.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-setlocale_null-mt-all.c new file mode 100644 index 00000000..d565aa03 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-setlocale_null-mt-all.c @@ -0,0 +1,172 @@ +/* Multithread-safety test for setlocale_null_r (LC_ALL, ...). + Copyright (C) 2019-2024 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 . */ + +/* Written by Bruno Haible , 2019. */ + +#include + +/* Work around GCC bug 44511. */ +#if 4 < __GNUC__ + (3 <= __GNUC_MINOR__) +# pragma GCC diagnostic ignored "-Wreturn-type" +#endif + +#if USE_ISOC_THREADS || USE_POSIX_THREADS || USE_ISOC_AND_POSIX_THREADS || USE_WINDOWS_THREADS + +/* Specification. */ +#include + +#include +#include +#include +#include + +#include "glthread/thread.h" + +/* We want to use the system's setlocale() function here, not the gnulib + override. */ +#undef setlocale + + +/* Some common locale names. */ + +#if defined _WIN32 && !defined __CYGWIN__ +# define ENGLISH "English_United States" +# define GERMAN "German_Germany" +# define FRENCH "French_France" +# define ENCODING ".1252" +#else +# define ENGLISH "en_US" +# define GERMAN "de_DE" +# define FRENCH "fr_FR" +# if defined __sgi +# define ENCODING ".ISO8859-15" +# elif defined __hpux +# define ENCODING ".utf8" +# else +# define ENCODING ".UTF-8" +# endif +#endif + +static const char LOCALE1[] = ENGLISH ENCODING; +static const char LOCALE2[] = GERMAN ENCODING; +static const char LOCALE3[] = FRENCH ENCODING; + +static char *expected; + +static void * +thread1_func (void *arg) +{ + for (;;) + { + char buf[SETLOCALE_NULL_ALL_MAX]; + + if (setlocale_null_r (LC_ALL, buf, sizeof (buf))) + abort (); + if (strcmp (expected, buf) != 0) + { + fprintf (stderr, "thread1 disturbed by thread2!\n"); fflush (stderr); + abort (); + } + } + + /*NOTREACHED*/ +} + +static void * +thread2_func (void *arg) +{ + for (;;) + { + char buf[SETLOCALE_NULL_ALL_MAX]; + + setlocale_null_r (LC_NUMERIC, buf, sizeof (buf)); + setlocale_null_r (LC_ALL, buf, sizeof (buf)); + } + + /*NOTREACHED*/ +} + +int +main (int argc, char *argv[]) +{ + if (setlocale (LC_ALL, LOCALE1) == NULL) + { + fprintf (stderr, "Skipping test: LOCALE1 not recognized\n"); + return 77; + } + if (setlocale (LC_NUMERIC, LOCALE2) == NULL) + { + fprintf (stderr, "Skipping test: LOCALE2 not recognized\n"); + return 77; + } + if (setlocale (LC_TIME, LOCALE3) == NULL) + { + fprintf (stderr, "Skipping test: LOCALE3 not recognized\n"); + return 77; + } + + expected = strdup (setlocale (LC_ALL, NULL)); + + /* Create the two threads. */ + gl_thread_create (thread1_func, NULL); + gl_thread_create (thread2_func, NULL); + + /* Let them run for 5 seconds. */ + { + struct timespec duration; + duration.tv_sec = 5; + duration.tv_nsec = 0; + + nanosleep (&duration, NULL); + } + + return 0; +} + +#else + +/* No multithreading available. */ + +#include + +int +main () +{ + fputs ("Skipping test: multithreading not enabled\n", stderr); + return 77; +} + +#endif + +/* Without locking, the results of this test would be: +glibc OK +musl libc crash < 10 sec +macOS crash < 1 sec +FreeBSD crash < 1 sec +NetBSD crash < 2 sec +OpenBSD crash < 1 sec +AIX crash < 2 sec +HP-UX OK +IRIX OK +Solaris 10 OK +Solaris 11.0 OK +Solaris 11.4 OK +Solaris OpenIndiana OK +Haiku crash < 1 sec +Cygwin < 3.4.6 crash < 1 sec +mingw OK +MSVC OK (assuming compiler option /MD !) +*/ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-setlocale_null-mt-one.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-setlocale_null-mt-one.c new file mode 100644 index 00000000..cbd057f9 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-setlocale_null-mt-one.c @@ -0,0 +1,172 @@ +/* Multithread-safety test for setlocale_null_r (LC_xxx, ...). + Copyright (C) 2019-2024 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 . */ + +/* Written by Bruno Haible , 2019. */ + +#include + +/* Work around GCC bug 44511. */ +#if 4 < __GNUC__ + (3 <= __GNUC_MINOR__) +# pragma GCC diagnostic ignored "-Wreturn-type" +#endif + +#if USE_ISOC_THREADS || USE_POSIX_THREADS || USE_ISOC_AND_POSIX_THREADS || USE_WINDOWS_THREADS + +/* Specification. */ +#include + +#include +#include +#include +#include + +#include "glthread/thread.h" + +/* We want to use the system's setlocale() function here, not the gnulib + override. */ +#undef setlocale + + +/* Some common locale names. */ + +#if defined _WIN32 && !defined __CYGWIN__ +# define ENGLISH "English_United States" +# define GERMAN "German_Germany" +# define FRENCH "French_France" +# define ENCODING ".1252" +#else +# define ENGLISH "en_US" +# define GERMAN "de_DE" +# define FRENCH "fr_FR" +# if defined __sgi +# define ENCODING ".ISO8859-15" +# elif defined __hpux +# define ENCODING ".utf8" +# else +# define ENCODING ".UTF-8" +# endif +#endif + +static const char LOCALE1[] = ENGLISH ENCODING; +static const char LOCALE2[] = GERMAN ENCODING; +static const char LOCALE3[] = FRENCH ENCODING; + +static char *expected; + +static void * +thread1_func (void *arg) +{ + for (;;) + { + char buf[SETLOCALE_NULL_MAX]; + + if (setlocale_null_r (LC_NUMERIC, buf, sizeof (buf))) + abort (); + if (strcmp (expected, buf) != 0) + { + fprintf (stderr, "thread1 disturbed by thread2!\n"); fflush (stderr); + abort (); + } + } + + /*NOTREACHED*/ +} + +static void * +thread2_func (void *arg) +{ + for (;;) + { + char buf[SETLOCALE_NULL_MAX]; + + setlocale_null_r (LC_NUMERIC, buf, sizeof (buf)); + setlocale_null_r (LC_TIME, buf, sizeof (buf)); + } + + /*NOTREACHED*/ +} + +int +main (int argc, char *argv[]) +{ + if (setlocale (LC_ALL, LOCALE1) == NULL) + { + fprintf (stderr, "Skipping test: LOCALE1 not recognized\n"); + return 77; + } + if (setlocale (LC_NUMERIC, LOCALE2) == NULL) + { + fprintf (stderr, "Skipping test: LOCALE2 not recognized\n"); + return 77; + } + if (setlocale (LC_TIME, LOCALE3) == NULL) + { + fprintf (stderr, "Skipping test: LOCALE3 not recognized\n"); + return 77; + } + + expected = strdup (setlocale (LC_NUMERIC, NULL)); + + /* Create the two threads. */ + gl_thread_create (thread1_func, NULL); + gl_thread_create (thread2_func, NULL); + + /* Let them run for 2 seconds. */ + { + struct timespec duration; + duration.tv_sec = 2; + duration.tv_nsec = 0; + + nanosleep (&duration, NULL); + } + + return 0; +} + +#else + +/* No multithreading available. */ + +#include + +int +main () +{ + fputs ("Skipping test: multithreading not enabled\n", stderr); + return 77; +} + +#endif + +/* Without locking, the results of this test would be: +glibc OK +musl libc OK +macOS OK +FreeBSD OK +NetBSD OK +OpenBSD crash < 1 sec +AIX crash < 2 sec +HP-UX OK +IRIX OK +Solaris 10 OK +Solaris 11.0 OK +Solaris 11.4 OK +Solaris OpenIndiana OK +Haiku OK +Cygwin OK +mingw OK +MSVC OK (assuming compiler option /MD !) +*/ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-setlocale_null.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-setlocale_null.c new file mode 100644 index 00000000..72352348 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-setlocale_null.c @@ -0,0 +1,32 @@ +/* Test of setlocale_null_r function. + Copyright (C) 2019-2024 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 . */ + +/* Written by Bruno Haible , 2019. */ + +#include + +/* Specification. */ +#include + +/* Check that SETLOCALE_NULL_ALL_MAX is a constant expression. */ +static char buf[SETLOCALE_NULL_ALL_MAX]; + +int +main () +{ + /* Check that setlocale_null_r() can be used with $(SETLOCALE_NULL_LIB). */ + return setlocale_null_r (LC_ALL, buf, sizeof (buf)) != 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-setsockopt.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-setsockopt.c new file mode 100644 index 00000000..75493810 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-setsockopt.c @@ -0,0 +1,55 @@ +/* Test setsockopt() function. + Copyright (C) 2011-2024 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 . */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (setsockopt, int, (int, int, int, const void *, socklen_t)); + +#include +#include + +#include "sockets.h" +#include "macros.h" + +int +main (void) +{ + (void) gl_sockets_startup (SOCKETS_1_1); + + /* Test behaviour for invalid file descriptors. */ + { + int value = 1; + + errno = 0; + ASSERT (setsockopt (-1, SOL_SOCKET, SO_REUSEADDR, &value, sizeof (value)) + == -1); + ASSERT (errno == EBADF); + } + { + int value = 1; + + close (99); + errno = 0; + ASSERT (setsockopt (99, SOL_SOCKET, SO_REUSEADDR, &value, sizeof (value)) + == -1); + ASSERT (errno == EBADF); + } + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sh-quote.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sh-quote.c new file mode 100644 index 00000000..c7798128 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sh-quote.c @@ -0,0 +1,203 @@ +/* Test of sh-quote module. + Copyright (C) 2012-2024 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 . */ + +/* Written by Bruno Haible , 2012. */ + +#include + +/* Specification. */ +#include "sh-quote.h" + +#include +#include + +#include "macros.h" + +static void +check_one (const char *input, const char *expected) +{ + char buf[1000]; + size_t output_len; + char *output; + char *bufend; + + output_len = shell_quote_length (input); + + output = shell_quote (input); + ASSERT (strlen (output) == output_len); + + ASSERT (output_len <= sizeof (buf) - 2); + memset (buf, '\0', output_len + 1); + buf[output_len + 1] = '%'; + bufend = shell_quote_copy (buf, input); + ASSERT (bufend == buf + output_len); + ASSERT (memcmp (buf, output, output_len + 1) == 0); + ASSERT (buf[output_len + 1] == '%'); + + ASSERT (strcmp (output, expected) == 0); + + free (output); +} + +int +main (void) +{ + /* Check the shell_quote_length, shell_quote_copy, shell_quote functions. */ + { + int c; + + /* Empty argument. */ + check_one ("", "''"); + + /* Identifier or number. */ + check_one ("foo", "foo"); + check_one ("phr0ck", "phr0ck"); + + /* Whitespace would be interpreted as argument separator by the shell. */ + check_one ("foo\tbar", "'foo\tbar'"); + check_one ("foo\nbar", "'foo\nbar'"); + check_one ("foo\rbar", "'foo\rbar'"); + check_one ("foo bar", "'foo bar'"); + + /* '!' at the beginning of argv[0] would introduce a negated command. */ + check_one ("!foo", "'!foo'"); + + /* '"' would be interpreted as the start of a string. */ + check_one ("\"foo\"bar", "'\"foo\"bar'"); + + /* '#' at the beginning of an argument would be interpreted as the start + of a comment. */ + check_one ("#foo", "'#foo'"); + + /* '$' at the beginning of an argument would be interpreted as a variable + reference. */ + check_one ("$foo", "'$foo'"); + + /* '&' at the beginning of an argument would be interpreted as a background + task indicator. */ + check_one ("&", "'&'"); + + /* "'" would be interpreted as the start of a string. */ + check_one ("'foo'bar", "\"'foo'bar\""); + + /* '(' at the beginning of argv[0] would introduce a subshell command. */ + check_one ("(", "'('"); + + /* ')' at the beginning of an argument would be interpreted as the end of + the command. */ + check_one (")", "')'"); + + /* '*' would be interpreted as a wildcard character. */ + check_one ("*", "'*'"); + check_one ("*foo", "'*foo'"); + + /* ';' at the beginning of an argument would be interpreted as an empty + statement in argv[0] and as the end of the command otherwise. */ + check_one (";", "';'"); + check_one ("foo;", "'foo;'"); + + /* '<' would be interpreted as a redirection of stdin. */ + check_one ("<", "'<'"); + + /* '=' inside argv[0] would be interpreted as an environment variable + assignment. */ + check_one ("foo=bar", "'foo=bar'"); + + /* '>' would be interpreted as a redirection of stdout. */ + check_one (">", "'>'"); + + /* '?' would be interpreted as a wildcard character. */ + check_one ("?", "'?'"); + check_one ("foo?bar", "'foo?bar'"); + + /* '^' would be interpreted in old /bin/sh, e.g. SunOS 4.1.4. */ + check_one ("^", "'^'"); + + /* "[...]" would be interpreted as a wildcard pattern. */ + check_one ("[", "'['"); + check_one ("]", "]"); /* or "']'" */ + + /* '\' would be interpreted as an escape character. */ + check_one ("\\foo", "'\\foo'"); + + /* '`' would be interpreted as the start of a command substitution. */ + check_one ("`foo", "'`foo'"); + + /* '{' at the beginning of argv[0] would introduce a complex command. */ + check_one ("{", "'{'"); + + /* '|' at the beginning of an argument would be interpreted as a pipe + between commands. */ + check_one ("|", "'|'"); + + /* '}' at the beginning of an argument would be interpreted as the end of + the command. */ + check_one ("}", "'}'"); + + /* '~' at the beginning of an argument would be interpreted as a reference + to a user's home directory. */ + check_one ("~", "'~'"); + check_one ("~foo", "'~foo'"); + + /* A string that contains both ' and ". */ + check_one ("foo'bar\"baz", "'foo'\\''bar\"baz'"); /* or "\"foo'bar\\\"baz\"" */ + + /* All other characters don't need quoting. */ + for (c = 1; c <= UCHAR_MAX; c++) + if (strchr ("\t\n\r !\"#$&'()*;<=>?^[\\]`{|}~", c) == NULL) + { + char s[5]; + s[0] = 'a'; + s[1] = (char) c; + s[2] = 'z'; + s[3] = (char) c; + s[4] = '\0'; + + check_one (s, s); + } + } + + /* Check the shell_quote_argv function. */ + { + const char *argv[1]; + char *result; + argv[0] = NULL; + result = shell_quote_argv (argv); + ASSERT (strcmp (result, "") == 0); + free (result); + } + { + const char *argv[2]; + char *result; + argv[0] = "foo bar/baz"; + argv[1] = NULL; + result = shell_quote_argv (argv); + ASSERT (strcmp (result, "'foo bar/baz'") == 0); /* or "\"foo bar/baz\"" */ + free (result); + } + { + const char *argv[3]; + char *result; + argv[0] = "foo bar/baz"; + argv[1] = "$"; + argv[2] = NULL; + result = shell_quote_argv (argv); + ASSERT (strcmp (result, "'foo bar/baz' '$'") == 0); /* or "\"foo bar/baz\" \"\\$\"" */ + free (result); + } + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sigaction.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sigaction.c new file mode 100644 index 00000000..5d29854f --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sigaction.c @@ -0,0 +1,122 @@ +/* Test of sigaction() function. + Copyright (C) 2008-2024 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 . */ + +/* Written by Eric Blake , 2008. */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (sigaction, int, (int, struct sigaction const *, + struct sigaction *)); + +#include + +#include "macros.h" + +#ifndef SA_NOCLDSTOP +# define SA_NOCLDSTOP 0 +#endif +#ifndef SA_ONSTACK +# define SA_ONSTACK 0 +#endif +#ifndef SA_RESETHAND +# define SA_RESETHAND 0 +#endif +#ifndef SA_RESTART +# define SA_RESTART 0 +#endif +#ifndef SA_SIGINFO +# define SA_SIGINFO 0 +#endif +#ifndef SA_NOCLDWAIT +# define SA_NOCLDWAIT 0 +#endif + +/* Define a mask of flags required by POSIX. Some implementations + provide other flags as extensions, such as SA_RESTORER, that we + must ignore in this test. */ +#define MASK_SA_FLAGS (SA_NOCLDSTOP | SA_ONSTACK | SA_RESETHAND | SA_RESTART \ + | SA_SIGINFO | SA_NOCLDWAIT | SA_NODEFER) + +/* This test is unsafe in the presence of an asynchronous SIGABRT, + because we install a signal-handler that is intentionally not + async-safe. Hopefully, this does not lead to too many reports of + false failures, since people don't generally use 'kill -s SIGABRT' + to end a runaway program. */ + +static void +handler (int sig) +{ + static int entry_count; + struct sigaction sa; + ASSERT (sig == SIGABRT); + ASSERT (sigaction (SIGABRT, NULL, &sa) == 0); + ASSERT ((sa.sa_flags & SA_SIGINFO) == 0); + switch (entry_count++) + { + case 0: + ASSERT ((sa.sa_flags & SA_RESETHAND) == 0); + ASSERT (sa.sa_handler == handler); + break; + case 1: + /* This assertion fails on glibc-2.3.6 systems with LinuxThreads, + when this program is linked with -lpthread, due to the sigaction() + override in libpthread.so. */ +#if !(defined __GLIBC__ || defined __UCLIBC__) + ASSERT (sa.sa_handler == SIG_DFL); +#endif + break; + default: + ASSERT (0); + } +} + +int +main (void) +{ + struct sigaction sa; + struct sigaction old_sa; + sa.sa_handler = handler; + + sa.sa_flags = 0; + ASSERT (sigemptyset (&sa.sa_mask) == 0); + ASSERT (sigaction (SIGABRT, &sa, NULL) == 0); + ASSERT (raise (SIGABRT) == 0); + + sa.sa_flags = SA_RESETHAND | SA_NODEFER; + ASSERT (sigaction (SIGABRT, &sa, &old_sa) == 0); + ASSERT ((old_sa.sa_flags & MASK_SA_FLAGS) == 0); + ASSERT (old_sa.sa_handler == handler); + ASSERT (raise (SIGABRT) == 0); + + sa.sa_handler = SIG_DFL; + ASSERT (sigaction (SIGABRT, &sa, &old_sa) == 0); + ASSERT ((old_sa.sa_flags & SA_SIGINFO) == 0); +#if !(defined __GLIBC__ || defined __UCLIBC__) /* see above */ + ASSERT (old_sa.sa_handler == SIG_DFL); +#endif + + sa.sa_handler = SIG_IGN; + ASSERT (sigaction (SIGABRT, &sa, NULL) == 0); + ASSERT (raise (SIGABRT) == 0); + ASSERT (sigaction (SIGABRT, NULL, &old_sa) == 0); + ASSERT (old_sa.sa_handler == SIG_IGN); + ASSERT (raise (SIGABRT) == 0); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-signal-h.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-signal-h.c new file mode 100644 index 00000000..c4b32207 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-signal-h.c @@ -0,0 +1,129 @@ +/* Test of substitute. + Copyright (C) 2009-2024 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 . */ + +/* Written by Eric Blake , 2009. */ + +#include + +#include + +/* Check for required types. */ +struct +{ + size_t a; + uid_t b; + volatile sig_atomic_t c; + sigset_t d; + pid_t e; +#if 0 + /* Not guaranteed by gnulib. */ + pthread_t f; + struct timespec g; +#endif +} s; + +/* Check that NSIG is defined. */ +int nsig = NSIG; + +int +main (void) +{ + switch (0) + { + /* The following are guaranteed by C. */ + case 0: + case SIGABRT: + case SIGFPE: + case SIGILL: + case SIGINT: + case SIGSEGV: + case SIGTERM: + /* The following is guaranteed by gnulib. */ +#if GNULIB_SIGPIPE || defined SIGPIPE + case SIGPIPE: +#endif + /* Ensure no conflict with other standardized names. */ +#ifdef SIGALRM + case SIGALRM: +#endif + /* On Haiku, SIGBUS is mistakenly equal to SIGSEGV. */ +#if defined SIGBUS && SIGBUS != SIGSEGV + case SIGBUS: +#endif +#ifdef SIGCHLD + case SIGCHLD: +#endif +#ifdef SIGCONT + case SIGCONT: +#endif +#ifdef SIGHUP + case SIGHUP: +#endif +#ifdef SIGKILL + case SIGKILL: +#endif +#ifdef SIGQUIT + case SIGQUIT: +#endif +#ifdef SIGSTOP + case SIGSTOP: +#endif +#ifdef SIGTSTP + case SIGTSTP: +#endif +#ifdef SIGTTIN + case SIGTTIN: +#endif +#ifdef SIGTTOU + case SIGTTOU: +#endif +#ifdef SIGUSR1 + case SIGUSR1: +#endif +#ifdef SIGUSR2 + case SIGUSR2: +#endif +#ifdef SIGSYS + case SIGSYS: +#endif +#ifdef SIGTRAP + case SIGTRAP: +#endif +#ifdef SIGURG + case SIGURG: +#endif +#ifdef SIGVTALRM + case SIGVTALRM: +#endif +#ifdef SIGXCPU + case SIGXCPU: +#endif +#ifdef SIGXFSZ + case SIGXFSZ: +#endif + /* SIGRTMIN and SIGRTMAX need not be compile-time constants. */ +#if 0 +# ifdef SIGRTMIN + case SIGRTMIN: +# endif +# ifdef SIGRTMAX + case SIGRTMAX: +# endif +#endif + ; + } + return s.a + s.b + s.c + s.e; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-signbit.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-signbit.c new file mode 100644 index 00000000..da5b7981 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-signbit.c @@ -0,0 +1,135 @@ +/* Test of signbit() substitute. + Copyright (C) 2007-2024 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 . */ + +/* Written by Bruno Haible , 2007. */ + +#include + +#include + +/* signbit must be a macro. */ +#ifndef signbit +# error missing declaration +#endif + +#include +#include + +#include "minus-zero.h" +#include "infinity.h" +#include "signed-nan.h" +#include "signed-snan.h" +#include "macros.h" + +float zerof = 0.0f; +double zerod = 0.0; +long double zerol = 0.0L; + +static void +test_signbitf () +{ + /* Finite values. */ + ASSERT (!signbit (3.141f)); + ASSERT (!signbit (3.141e30f)); + ASSERT (!signbit (3.141e-30f)); + ASSERT (signbit (-2.718f)); + ASSERT (signbit (-2.718e30f)); + ASSERT (signbit (-2.718e-30f)); + /* Zeros. */ + ASSERT (!signbit (0.0f)); + if (1.0f / minus_zerof < 0) + ASSERT (signbit (minus_zerof)); + else + ASSERT (!signbit (minus_zerof)); + /* Infinite values. */ + ASSERT (!signbit (Infinityf ())); + ASSERT (signbit (- Infinityf ())); + /* Quiet NaN. */ + ASSERT (!signbit (positive_NaNf ())); + ASSERT (signbit (negative_NaNf ())); +#if HAVE_SNANF + /* Signalling NaN. */ + ASSERT (!signbit (positive_SNaNf ())); + ASSERT (signbit (negative_SNaNf ())); +#endif +} + +static void +test_signbitd () +{ + /* Finite values. */ + ASSERT (!signbit (3.141)); + ASSERT (!signbit (3.141e30)); + ASSERT (!signbit (3.141e-30)); + ASSERT (signbit (-2.718)); + ASSERT (signbit (-2.718e30)); + ASSERT (signbit (-2.718e-30)); + /* Zeros. */ + ASSERT (!signbit (0.0)); + if (1.0 / minus_zerod < 0) + ASSERT (signbit (minus_zerod)); + else + ASSERT (!signbit (minus_zerod)); + /* Infinite values. */ + ASSERT (!signbit (Infinityd ())); + ASSERT (signbit (- Infinityd ())); + /* Quiet NaN. */ + ASSERT (!signbit (positive_NaNd ())); + ASSERT (signbit (negative_NaNd ())); +#if HAVE_SNAND + /* Signalling NaN. */ + ASSERT (!signbit (positive_SNaNd ())); + ASSERT (signbit (negative_SNaNd ())); +#endif +} + +static void +test_signbitl () +{ + /* Finite values. */ + ASSERT (!signbit (3.141L)); + ASSERT (!signbit (3.141e30L)); + ASSERT (!signbit (3.141e-30L)); + ASSERT (signbit (-2.718L)); + ASSERT (signbit (-2.718e30L)); + ASSERT (signbit (-2.718e-30L)); + /* Zeros. */ + ASSERT (!signbit (0.0L)); + if (1.0L / minus_zerol < 0) + ASSERT (signbit (minus_zerol)); + else + ASSERT (!signbit (minus_zerol)); + /* Infinite values. */ + ASSERT (!signbit (Infinityl ())); + ASSERT (signbit (- Infinityl ())); + /* Quiet NaN. */ + ASSERT (!signbit (positive_NaNl ())); + ASSERT (signbit (negative_NaNl ())); +#if HAVE_SNANL + /* Signalling NaN. */ + ASSERT (!signbit (positive_SNaNl ())); + ASSERT (signbit (negative_SNaNl ())); +#endif +} + +int +main () +{ + test_signbitf (); + test_signbitd (); + test_signbitl (); + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sigprocmask.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sigprocmask.c new file mode 100644 index 00000000..c712d77d --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sigprocmask.c @@ -0,0 +1,97 @@ +/* Test of sigprocmask. + Copyright (C) 2011-2024 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 . */ + +/* Written by Bruno Haible , 2011. */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (sigprocmask, int, (int, const sigset_t *, sigset_t *)); + +#include +#include +#include +#include +#include + +#include "macros.h" + +#if !(defined _WIN32 && !defined __CYGWIN__) + +static volatile int sigint_occurred; + +static void +sigint_handler (_GL_UNUSED int sig) +{ + sigint_occurred++; +} + +int +main () +{ + sigset_t set; + intmax_t pid = getpid (); + char command[80]; + + signal (SIGINT, sigint_handler); + + sigemptyset (&set); + sigaddset (&set, SIGINT); + + /* Check error handling. */ + ASSERT (sigprocmask (1729, &set, NULL) == -1); + ASSERT (errno == EINVAL); + + /* Block SIGINT. */ + ASSERT (sigprocmask (SIG_BLOCK, &set, NULL) == 0); + + /* Request a SIGINT signal from outside. */ + sprintf (command, "sh -c 'sleep 1; kill -INT %"PRIdMAX"' &", pid); + ASSERT (system (command) == 0); + + /* Wait. */ + sleep (2); + + /* The signal should not have arrived yet, because it is blocked. */ + ASSERT (sigint_occurred == 0); + + /* Unblock SIGINT. */ + ASSERT (sigprocmask (SIG_UNBLOCK, &set, NULL) == 0); + + /* The signal should have arrived now, because POSIX says + "If there are any pending unblocked signals after the call to + sigprocmask(), at least one of those signals shall be delivered + before the call to sigprocmask() returns." */ + ASSERT (sigint_occurred == 1); + + return 0; +} + +#else + +/* On native Windows, getpid() values and the arguments that are passed to + the (Cygwin?) 'kill' program are not necessarily related. */ + +int +main () +{ + fputs ("Skipping test: native Windows platform\n", stderr); + return 77; +} + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sigsegv-catch-segv1.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sigsegv-catch-segv1.c new file mode 100644 index 00000000..8c04ef08 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sigsegv-catch-segv1.c @@ -0,0 +1,130 @@ +/* Test that the handler is called, with the right fault address. + Copyright (C) 2002-2024 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 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 . */ + +/* Written by Bruno Haible. */ + +#include + +/* Specification. */ +#include "sigsegv.h" + +#include +#include + +#if HAVE_SIGSEGV_RECOVERY + +# include "mmap-anon-util.h" +# include + +# if SIGSEGV_FAULT_ADDRESS_ALIGNMENT > 1UL +# include +# define SIGSEGV_FAULT_ADDRESS_ROUNDOFF_BITS (getpagesize () - 1) +# else +# define SIGSEGV_FAULT_ADDRESS_ROUNDOFF_BITS 0 +# endif + +uintptr_t page; + +volatile int handler_called = 0; + +static int +handler (void *fault_address, int serious) +{ + handler_called++; + if (handler_called > 10) + abort (); + if (fault_address + != (void *)((page + 0x678) & ~SIGSEGV_FAULT_ADDRESS_ROUNDOFF_BITS)) + abort (); + if (mprotect ((void *) page, 0x4000, PROT_READ_WRITE) == 0) + return 1; + return 0; +} + +static void +crasher (uintptr_t p) +{ + *(volatile int *) (p + 0x678) = 42; +} + +int +main () +{ + int prot_unwritable; + void *p; + + /* Preparations. */ +# if !HAVE_MAP_ANONYMOUS + zero_fd = open ("/dev/zero", O_RDONLY, 0644); +# endif + +# if defined __linux__ && defined __sparc__ + /* On Linux 2.6.26/SPARC64, PROT_READ has the same effect as + PROT_READ | PROT_WRITE. */ + prot_unwritable = PROT_NONE; +# else + prot_unwritable = PROT_READ; +# endif + + /* Setup some mmapped memory. */ + p = mmap_zeromap ((void *) 0x12340000, 0x4000); + if (p == (void *)(-1)) + { + fprintf (stderr, "mmap_zeromap failed.\n"); + exit (2); + } + page = (uintptr_t) p; + + /* Make it read-only. */ + if (mprotect ((void *) page, 0x4000, prot_unwritable) < 0) + { + fprintf (stderr, "mprotect failed.\n"); + exit (2); + } + /* Test whether it's possible to make it read-write after it was read-only. + This is not possible on Cygwin. */ + if (mprotect ((void *) page, 0x4000, PROT_READ_WRITE) < 0 + || mprotect ((void *) page, 0x4000, prot_unwritable) < 0) + { + fprintf (stderr, "mprotect failed.\n"); + exit (2); + } + + /* Install the SIGSEGV handler. */ + sigsegv_install_handler (&handler); + + /* The first write access should invoke the handler and then complete. */ + crasher (page); + /* The second write access should not invoke the handler. */ + crasher (page); + + /* Check that the handler was called only once. */ + if (handler_called != 1) + exit (1); + /* Test passed! */ + printf ("Test passed.\n"); + return 0; +} + +#else + +int +main () +{ + return 77; +} + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sigsegv-catch-segv2.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sigsegv-catch-segv2.c new file mode 100644 index 00000000..397359e3 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sigsegv-catch-segv2.c @@ -0,0 +1,153 @@ +/* Test that the handler can be exited multiple times. + Copyright (C) 2002-2024 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 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 . */ + +/* Written by Bruno Haible. */ + +#include + +/* Specification. */ +#include "sigsegv.h" + +#include +#include + +#if HAVE_SIGSEGV_RECOVERY + +# if defined _WIN32 && !defined __CYGWIN__ + /* Windows doesn't have sigset_t. */ + typedef int sigset_t; +# define sigemptyset(set) +# define sigprocmask(how,set,oldset) +# endif + +# include "mmap-anon-util.h" +# include /* for abort, exit */ +# include +# include + +# if SIGSEGV_FAULT_ADDRESS_ALIGNMENT > 1UL +# include +# define SIGSEGV_FAULT_ADDRESS_ROUNDOFF_BITS (getpagesize () - 1) +# else +# define SIGSEGV_FAULT_ADDRESS_ROUNDOFF_BITS 0 +# endif + +jmp_buf mainloop; +sigset_t mainsigset; + +volatile int pass = 0; +uintptr_t page; + +volatile int handler_called = 0; + +static void +handler_continuation (void *arg1, void *arg2, void *arg3) +{ + longjmp (mainloop, pass); +} + +int +handler (void *fault_address, int serious) +{ + handler_called++; + if (handler_called > 10) + abort (); + if (fault_address + != (void *)((page + 0x678 + 8 * pass) & ~SIGSEGV_FAULT_ADDRESS_ROUNDOFF_BITS)) + abort (); + pass++; + printf ("Fault %d caught.\n", pass); + sigprocmask (SIG_SETMASK, &mainsigset, NULL); + return sigsegv_leave_handler (handler_continuation, NULL, NULL, NULL); +} + +void +crasher (uintptr_t p) +{ + *(volatile int *) (p + 0x678 + 8 * pass) = 42; +} + +int +main () +{ + int prot_unwritable; + void *p; + sigset_t emptyset; + + /* Preparations. */ +# if !HAVE_MAP_ANONYMOUS + zero_fd = open ("/dev/zero", O_RDONLY, 0644); +# endif + +# if defined __linux__ && defined __sparc__ + /* On Linux 2.6.26/SPARC64, PROT_READ has the same effect as + PROT_READ | PROT_WRITE. */ + prot_unwritable = PROT_NONE; +# else + prot_unwritable = PROT_READ; +# endif + + /* Setup some mmapped memory. */ + p = mmap_zeromap ((void *) 0x12340000, 0x4000); + if (p == (void *)(-1)) + { + fprintf (stderr, "mmap_zeromap failed.\n"); + exit (2); + } + page = (uintptr_t) p; + + /* Make it read-only. */ + if (mprotect ((void *) page, 0x4000, prot_unwritable) < 0) + { + fprintf (stderr, "mprotect failed.\n"); + exit (2); + } + + /* Install the SIGSEGV handler. */ + if (sigsegv_install_handler (&handler) < 0) + exit (2); + + /* Save the current signal mask. */ + sigemptyset (&emptyset); + sigprocmask (SIG_BLOCK, &emptyset, &mainsigset); + + /* Provoke two SIGSEGVs in a row. */ + switch (setjmp (mainloop)) + { + case 0: case 1: + printf ("Doing SIGSEGV pass %d.\n", pass + 1); + crasher (page); + printf ("no SIGSEGV?!\n"); exit (1); + case 2: + break; + default: + abort (); + } + + /* Test passed! */ + printf ("Test passed.\n"); + return 0; +} + +#else + +int +main () +{ + return 77; +} + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sigsegv-catch-stackoverflow1.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sigsegv-catch-stackoverflow1.c new file mode 100644 index 00000000..20915adf --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sigsegv-catch-stackoverflow1.c @@ -0,0 +1,149 @@ +/* Test the stack overflow handler. + Copyright (C) 2002-2024 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 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 . */ + +/* Written by Bruno Haible and Eric Blake. */ + +#include + +/* Specification. */ +#include "sigsegv.h" + +#include +#include + +#if HAVE_STACK_OVERFLOW_RECOVERY + +# if defined _WIN32 && !defined __CYGWIN__ + /* Windows doesn't have sigset_t. */ + typedef int sigset_t; +# define sigemptyset(set) +# define sigprocmask(how,set,oldset) +# endif + +# include /* needed for NULL on SunOS4 */ +# include /* for abort, exit */ +# include +# include +# if HAVE_SETRLIMIT +# include +# include +# include +# endif +# include "altstack-util.h" + +static jmp_buf mainloop; +static sigset_t mainsigset; + +static volatile int pass = 0; + +static volatile char *stack_lower_bound; +static volatile char *stack_upper_bound; + +static void +stackoverflow_handler_continuation (void *arg1, void *arg2, void *arg3) +{ + int arg = (int) (long) arg1; + longjmp (mainloop, arg); +} + +static void +stackoverflow_handler (int emergency, stackoverflow_context_t scp) +{ + char dummy; + volatile char *addr = &dummy; + if (!(addr >= stack_lower_bound && addr <= stack_upper_bound)) + abort (); + pass++; + printf ("Stack overflow %d caught.\n", pass); + sigprocmask (SIG_SETMASK, &mainsigset, NULL); + sigsegv_leave_handler (stackoverflow_handler_continuation, + (void *) (long) (emergency ? -1 : pass), NULL, NULL); +} + +static volatile int * +recurse_1 (int n, volatile int *p) +{ + if (n < INT_MAX) + *recurse_1 (n + 1, p) += n; + return p; +} + +static int +recurse (volatile int n) +{ + return *recurse_1 (n, &n); +} + +int +main () +{ + sigset_t emptyset; + +# if HAVE_SETRLIMIT && defined RLIMIT_STACK + /* Before starting the endless recursion, try to be friendly to the user's + machine. On some Linux 2.2.x systems, there is no stack limit for user + processes at all. We don't want to kill such systems. */ + struct rlimit rl; + rl.rlim_cur = rl.rlim_max = 0x100000; /* 1 MB */ + setrlimit (RLIMIT_STACK, &rl); +# endif + + /* Prepare the storage for the alternate stack. */ + prepare_alternate_stack (); + + /* Install the stack overflow handler. */ + if (stackoverflow_install_handler (&stackoverflow_handler, + mystack, MYSTACK_SIZE) + < 0) + exit (2); + stack_lower_bound = mystack; + stack_upper_bound = mystack + MYSTACK_SIZE - 1; + + /* Save the current signal mask. */ + sigemptyset (&emptyset); + sigprocmask (SIG_BLOCK, &emptyset, &mainsigset); + + /* Provoke two stack overflows in a row. */ + switch (setjmp (mainloop)) + { + case -1: + printf ("emergency exit\n"); exit (1); + case 0: case 1: + printf ("Starting recursion pass %d.\n", pass + 1); + recurse (0); + printf ("no endless recursion?!\n"); exit (1); + case 2: + break; + default: + abort (); + } + + /* Validate that the alternate stack did not overflow. */ + check_alternate_stack_no_overflow (); + + printf ("Test passed.\n"); + exit (0); +} + +#else + +int +main () +{ + return 77; +} + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sigsegv-catch-stackoverflow2.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sigsegv-catch-stackoverflow2.c new file mode 100644 index 00000000..5113ba5f --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sigsegv-catch-stackoverflow2.c @@ -0,0 +1,211 @@ +/* Test that stack overflow and SIGSEGV are correctly distinguished. + Copyright (C) 2002-2024 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 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 . */ + +/* Written by Bruno Haible and Eric Blake. */ + +#include + +/* Specification. */ +#include "sigsegv.h" + +#include +#include +#include + +#if HAVE_STACK_OVERFLOW_RECOVERY && HAVE_SIGSEGV_RECOVERY + +# if defined _WIN32 && !defined __CYGWIN__ + /* Windows doesn't have sigset_t. */ + typedef int sigset_t; +# define sigemptyset(set) +# define sigprocmask(how,set,oldset) +# endif + +# include "mmap-anon-util.h" +# include /* needed for NULL on SunOS4 */ +# include /* for abort, exit */ +# include +# include +# if HAVE_SETRLIMIT +# include +# include +# include +# endif +# include "altstack-util.h" + +static jmp_buf mainloop; +static sigset_t mainsigset; + +static volatile int pass = 0; +static uintptr_t page; +static volatile int *null_pointer_to_volatile_int /* = NULL */; + +static void +stackoverflow_handler_continuation (void *arg1, void *arg2, void *arg3) +{ + int arg = (int) (long) arg1; + longjmp (mainloop, arg); +} + +static void +stackoverflow_handler (int emergency, stackoverflow_context_t scp) +{ + pass++; + if (pass <= 2) + printf ("Stack overflow %d caught.\n", pass); + else + { + printf ("Segmentation violation misdetected as stack overflow.\n"); + exit (1); + } + sigprocmask (SIG_SETMASK, &mainsigset, NULL); + sigsegv_leave_handler (stackoverflow_handler_continuation, + (void *) (long) (emergency ? -1 : pass), NULL, NULL); +} + +static int +sigsegv_handler (void *address, int emergency) +{ + /* This test is necessary to distinguish stack overflow and SIGSEGV. */ + if (!emergency) + return 0; + + pass++; + if (pass <= 2) + { + printf ("Stack overflow %d missed.\n", pass); + exit (1); + } + else + printf ("Segmentation violation correctly detected.\n"); + sigprocmask (SIG_SETMASK, &mainsigset, NULL); + return sigsegv_leave_handler (stackoverflow_handler_continuation, + (void *) (long) pass, NULL, NULL); +} + +static volatile int * +recurse_1 (int n, volatile int *p) +{ + if (n < INT_MAX) + *recurse_1 (n + 1, p) += n; + return p; +} + +static int +recurse (volatile int n) +{ + return *recurse_1 (n, &n); +} + +int +main () +{ + int prot_unwritable; + void *p; + sigset_t emptyset; + +# if HAVE_SETRLIMIT && defined RLIMIT_STACK + /* Before starting the endless recursion, try to be friendly to the user's + machine. On some Linux 2.2.x systems, there is no stack limit for user + processes at all. We don't want to kill such systems. */ + struct rlimit rl; + rl.rlim_cur = rl.rlim_max = 0x100000; /* 1 MB */ + setrlimit (RLIMIT_STACK, &rl); +# endif + + /* Prepare the storage for the alternate stack. */ + prepare_alternate_stack (); + + /* Install the stack overflow handler. */ + if (stackoverflow_install_handler (&stackoverflow_handler, + mystack, MYSTACK_SIZE) + < 0) + exit (2); + + /* Preparations. */ +# if !HAVE_MAP_ANONYMOUS + zero_fd = open ("/dev/zero", O_RDONLY, 0644); +# endif + +# if defined __linux__ && defined __sparc__ + /* On Linux 2.6.26/SPARC64, PROT_READ has the same effect as + PROT_READ | PROT_WRITE. */ + prot_unwritable = PROT_NONE; +# else + prot_unwritable = PROT_READ; +# endif + + /* Setup some mmapped memory. */ + p = mmap_zeromap ((void *) 0x12340000, 0x4000); + if (p == (void *)(-1)) + { + fprintf (stderr, "mmap_zeromap failed.\n"); + exit (2); + } + page = (uintptr_t) p; + + /* Make it read-only. */ + if (mprotect ((void *) page, 0x4000, prot_unwritable) < 0) + { + fprintf (stderr, "mprotect failed.\n"); + exit (2); + } + + /* Install the SIGSEGV handler. */ + if (sigsegv_install_handler (&sigsegv_handler) < 0) + exit (2); + + /* Save the current signal mask. */ + sigemptyset (&emptyset); + sigprocmask (SIG_BLOCK, &emptyset, &mainsigset); + + /* Provoke two stack overflows in a row. */ + switch (setjmp (mainloop)) + { + case -1: + printf ("emergency exit\n"); exit (1); + case 0: case 1: + printf ("Starting recursion pass %d.\n", pass + 1); + recurse (0); + printf ("no endless recursion?!\n"); exit (1); + case 2: + *(volatile int *) (page + 0x678) = 42; + break; + case 3: + *null_pointer_to_volatile_int = 42; + break; + case 4: + break; + default: + abort (); + } + + /* Validate that the alternate stack did not overflow. */ + check_alternate_stack_no_overflow (); + + printf ("Test passed.\n"); + exit (0); +} + +#else + +int +main () +{ + return 77; +} + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sleep.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sleep.c new file mode 100644 index 00000000..b0896f2e --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sleep.c @@ -0,0 +1,58 @@ +/* Test of sleep() function. + Copyright (C) 2007-2024 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 . */ + +/* Written by Bruno Haible , 2007. */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (sleep, unsigned int, (unsigned int)); + +#include + +#include "macros.h" + +#if HAVE_DECL_ALARM +static void +handle_alarm (int sig) +{ + if (sig != SIGALRM) + _exit (1); +} +#endif + +int +main (void) +{ + ASSERT (sleep (1) <= 1); + + ASSERT (sleep (0) == 0); + +#if HAVE_DECL_ALARM + { + const unsigned int pentecost = 50 * 24 * 60 * 60; /* 50 days. */ + unsigned int remaining; + signal (SIGALRM, handle_alarm); + alarm (1); + remaining = sleep (pentecost); + ASSERT (pentecost - 10 < remaining && remaining <= pentecost); + } +#endif + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-snprintf.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-snprintf.c new file mode 100644 index 00000000..98f1f1c2 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-snprintf.c @@ -0,0 +1,72 @@ +/* Test of snprintf() function. + Copyright (C) 2007-2024 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 . */ + +/* Written by Bruno Haible , 2007. */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (snprintf, int, (char *, size_t, char const *, ...)); + +#include + +#include "macros.h" + +int +main () +{ + char buf[8]; + int size; + int retval; + + retval = snprintf (NULL, 0, "%d", 12345); + ASSERT (retval == 5); + + for (size = 0; size <= 8; size++) + { + memcpy (buf, "DEADBEEF", 8); + retval = snprintf (buf, size, "%d", 12345); + ASSERT (retval == 5); + if (size < 6) + { + if (size > 0) + { + ASSERT (memcmp (buf, "12345", size - 1) == 0); + ASSERT (buf[size - 1] == '\0' || buf[size - 1] == '0' + size); + } +#if !CHECK_SNPRINTF_POSIX + if (size > 0) +#endif + ASSERT (memcmp (buf + size, &"DEADBEEF"[size], 8 - size) == 0); + } + else + { + ASSERT (memcmp (buf, "12345\0EF", 8) == 0); + } + } + + /* Test the support of the POSIX/XSI format strings with positions. */ + { + char result[100]; + retval = snprintf (result, sizeof (result), "%2$d %1$d", 33, 55); + ASSERT (strcmp (result, "55 33") == 0); + ASSERT (retval == strlen (result)); + } + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sockets.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sockets.c new file mode 100644 index 00000000..5917e4dd --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sockets.c @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2008-2024 Free Software Foundation, Inc. + * Written by Simon Josefsson. + * + * 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 . */ + +#include + +#include + +#include "sockets.h" + +int +main (void) +{ + int err; + + err = gl_sockets_startup (SOCKETS_1_1); + if (err != 0) + { + printf ("wsastartup failed %d\n", err); + return 1; + } + + err = gl_sockets_cleanup (); + if (err != 0) + { + printf ("wsacleanup failed %d\n", err); + return 1; + } + + (void) gl_fd_to_handle (0); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-stat-time.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-stat-time.c new file mode 100644 index 00000000..f28b6c46 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-stat-time.c @@ -0,0 +1,248 @@ +/* Test of . + Copyright (C) 2007-2024 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 . */ + +/* Written by James Youngman , 2007. */ + +#include + +#include "stat-time.h" + +#include +#include +#include +#include +#include +#include + +#include "macros.h" + +#define BASE "test-stat-time.t" +#include "nap.h" + +enum { NFILES = 4 }; + +static char filename_stamp1[50]; +static char filename_testfile[50]; +static char filename_stamp2[50]; +static char filename_stamp3[50]; + +/* Use file names that are different at each run. + This is necessary for test_birthtime() to pass on native Windows: + On this platform, the file system apparently remembers the creation time + of a file even after it is removed and created anew. See + "Windows NT Contains File System Tunneling Capabilities" + */ +static void +initialize_filenames (void) +{ + long t = (long) time (NULL); + sprintf (filename_stamp1, "t-stt-%ld-stamp1", t); + sprintf (filename_testfile, "t-stt-%ld-testfile", t); + sprintf (filename_stamp2, "t-stt-%ld-stamp2", t); + sprintf (filename_stamp3, "t-stt-%ld-stamp3", t); +} + +static int +force_unlink (const char *filename) +{ + /* This chmod is necessary on mingw, where unlink() of a read-only file + fails with EPERM. */ + chmod (filename, 0600); + return unlink (filename); +} + +static void +cleanup (int sig) +{ + /* Remove temporary files. */ + force_unlink (filename_stamp1); + force_unlink (filename_testfile); + force_unlink (filename_stamp2); + force_unlink (filename_stamp3); + + if (sig != 0) + _exit (1); +} + +static int +open_file (const char *filename, int flags) +{ + int fd = open (filename, flags | O_WRONLY, 0500); + if (fd >= 0) + { + close (fd); + return 1; + } + else + { + return 0; + } +} + +static void +create_file (const char *filename) +{ + ASSERT (open_file (filename, O_CREAT | O_EXCL)); +} + +static void +do_stat (const char *filename, struct stat *p) +{ + ASSERT (stat (filename, p) == 0); +} + +static void +prepare_test (struct stat *statinfo, struct timespec *modtimes) +{ + int i; + + create_file (filename_stamp1); + nap (); + create_file (filename_testfile); + nap (); + create_file (filename_stamp2); + nap (); + ASSERT (chmod (filename_testfile, 0400) == 0); + nap (); + create_file (filename_stamp3); + + do_stat (filename_stamp1, &statinfo[0]); + do_stat (filename_testfile, &statinfo[1]); + do_stat (filename_stamp2, &statinfo[2]); + do_stat (filename_stamp3, &statinfo[3]); + + /* Now use our access functions. */ + for (i = 0; i < NFILES; ++i) + { + modtimes[i] = get_stat_mtime (&statinfo[i]); + } +} + +static void +test_mtime (const struct stat *statinfo, struct timespec *modtimes) +{ + int i; + + /* Use the struct stat fields directly. */ + /* mtime(stamp1) < mtime(stamp2) */ + ASSERT (statinfo[0].st_mtime < statinfo[2].st_mtime + || (statinfo[0].st_mtime == statinfo[2].st_mtime + && (get_stat_mtime_ns (&statinfo[0]) + < get_stat_mtime_ns (&statinfo[2])))); + /* mtime(stamp2) < mtime(stamp3) */ + ASSERT (statinfo[2].st_mtime < statinfo[3].st_mtime + || (statinfo[2].st_mtime == statinfo[3].st_mtime + && (get_stat_mtime_ns (&statinfo[2]) + < get_stat_mtime_ns (&statinfo[3])))); + + /* Now check the result of the access functions. */ + /* mtime(stamp1) < mtime(stamp2) */ + ASSERT (modtimes[0].tv_sec < modtimes[2].tv_sec + || (modtimes[0].tv_sec == modtimes[2].tv_sec + && modtimes[0].tv_nsec < modtimes[2].tv_nsec)); + /* mtime(stamp2) < mtime(stamp3) */ + ASSERT (modtimes[2].tv_sec < modtimes[3].tv_sec + || (modtimes[2].tv_sec == modtimes[3].tv_sec + && modtimes[2].tv_nsec < modtimes[3].tv_nsec)); + + /* verify equivalence */ + for (i = 0; i < NFILES; ++i) + { + struct timespec ts; + ts = get_stat_mtime (&statinfo[i]); + ASSERT (ts.tv_sec == statinfo[i].st_mtime); + } +} + +#if defined _WIN32 && !defined __CYGWIN__ +/* Skip the ctime tests on native Windows platforms, because their + st_ctime is either the same as st_mtime (plus or minus an offset) + or set to the file _creation_ time, and is not influenced by rename + or chmod. */ +# define test_ctime(ignored) ((void) 0) +#else +static void +test_ctime (const struct stat *statinfo) +{ + /* On some buggy NFS clients, mtime and ctime are disproportionately + skewed from one another. Skip this test in that case. */ + if (statinfo[0].st_mtime != statinfo[0].st_ctime) + return; + + /* mtime(stamp2) < ctime(testfile) */ + ASSERT (statinfo[2].st_mtime < statinfo[1].st_ctime + || (statinfo[2].st_mtime == statinfo[1].st_ctime + && (get_stat_mtime_ns (&statinfo[2]) + < get_stat_ctime_ns (&statinfo[1])))); +} +#endif + +static void +test_birthtime (const struct stat *statinfo, + const struct timespec *modtimes, + struct timespec *birthtimes) +{ + int i; + + /* Collect the birth times. */ + for (i = 0; i < NFILES; ++i) + { + birthtimes[i] = get_stat_birthtime (&statinfo[i]); + if (birthtimes[i].tv_nsec < 0) + return; + } + + /* mtime(stamp1) < birthtime(testfile) */ + ASSERT (modtimes[0].tv_sec < birthtimes[1].tv_sec + || (modtimes[0].tv_sec == birthtimes[1].tv_sec + && modtimes[0].tv_nsec < birthtimes[1].tv_nsec)); + /* birthtime(testfile) < mtime(stamp2) */ + ASSERT (birthtimes[1].tv_sec < modtimes[2].tv_sec + || (birthtimes[1].tv_sec == modtimes[2].tv_sec + && birthtimes[1].tv_nsec < modtimes[2].tv_nsec)); +} + +int +main (void) +{ + struct stat statinfo[NFILES]; + struct timespec modtimes[NFILES]; + struct timespec birthtimes[NFILES]; + + initialize_filenames (); + +#ifdef SIGHUP + signal (SIGHUP, cleanup); +#endif +#ifdef SIGINT + signal (SIGINT, cleanup); +#endif +#ifdef SIGQUIT + signal (SIGQUIT, cleanup); +#endif +#ifdef SIGTERM + signal (SIGTERM, cleanup); +#endif + + cleanup (0); + prepare_test (statinfo, modtimes); + test_mtime (statinfo, modtimes); + test_ctime (statinfo); + test_birthtime (statinfo, modtimes, birthtimes); + + cleanup (0); + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-stat.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-stat.c new file mode 100644 index 00000000..53ff77d9 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-stat.c @@ -0,0 +1,55 @@ +/* Tests of stat. + Copyright (C) 2009-2024 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 . */ + +/* Written by Eric Blake , 2009. */ + +#include + +#include + +/* Caution: stat may be a function-like macro. Although this + signature check must pass, it may be the signature of the real (and + broken) stat rather than rpl_stat. Most code should not use the + address of stat. */ +#include "signature.h" +SIGNATURE_CHECK (stat, int, (char const *, struct stat *)); + +#include +#include +#include +#include +#include + +#include "same-inode.h" +#include "macros.h" + +#define BASE "test-stat.t" + +#include "test-stat.h" + +/* Wrapper around stat, which works even if stat is a function-like + macro, where test_stat_func(stat) would do the wrong thing. */ +static int +do_stat (char const *name, struct stat *st) +{ + return stat (name, st); +} + +int +main (void) +{ + return test_stat_func (do_stat, true); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-stat.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-stat.h new file mode 100644 index 00000000..a76f38f9 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-stat.h @@ -0,0 +1,107 @@ +/* Tests of stat. + Copyright (C) 2009-2024 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 . */ + +/* Written by Eric Blake , 2009. */ + +/* This file is designed to test both stat(n,buf) and + fstatat(AT_FDCWD,n,buf,0). FUNC is the function to test. Assumes + that BASE and ASSERT are already defined, and that appropriate + headers are already included. If PRINT, warn before skipping + symlink tests with status 77. */ + +static int +test_stat_func (int (*func) (char const *, struct stat *), bool print) +{ + struct stat st1; + struct stat st2; + char *cwd = getcwd (NULL, 0); + + ASSERT (cwd); + ASSERT (func (".", &st1) == 0); + ASSERT (func ("./", &st2) == 0); +#if !(defined _WIN32 && !defined __CYGWIN__ && !_GL_WINDOWS_STAT_INODES) + ASSERT (psame_inode (&st1, &st2)); +#endif + ASSERT (func (cwd, &st2) == 0); +#if !(defined _WIN32 && !defined __CYGWIN__ && !_GL_WINDOWS_STAT_INODES) + ASSERT (psame_inode (&st1, &st2)); +#endif + ASSERT (func ("/", &st1) == 0); + ASSERT (func ("///", &st2) == 0); +#if !(defined _WIN32 && !defined __CYGWIN__ && !_GL_WINDOWS_STAT_INODES) + ASSERT (psame_inode (&st1, &st2)); +#endif + + errno = 0; + ASSERT (func ("", &st1) == -1); + ASSERT (errno == ENOENT); + errno = 0; + ASSERT (func ("nosuch", &st1) == -1); + ASSERT (errno == ENOENT); + errno = 0; + ASSERT (func ("nosuch/", &st1) == -1); + ASSERT (errno == ENOENT); + + ASSERT (close (creat (BASE "file", 0600)) == 0); + ASSERT (func (BASE "file", &st1) == 0); + errno = 0; + ASSERT (func (BASE "file/", &st1) == -1); + ASSERT (errno == ENOTDIR); + + /* Now for some symlink tests, where supported. We set up: + link1 -> directory + link2 -> file + link3 -> dangling + link4 -> loop + then test behavior with trailing slash. + */ + if (symlink (".", BASE "link1") != 0) + { + ASSERT (unlink (BASE "file") == 0); + if (print) + fputs ("skipping test: symlinks not supported on this file system\n", + stderr); + return 77; + } + ASSERT (symlink (BASE "file", BASE "link2") == 0); + ASSERT (symlink (BASE "nosuch", BASE "link3") == 0); + ASSERT (symlink (BASE "link4", BASE "link4") == 0); + + ASSERT (func (BASE "link1/", &st1) == 0); + ASSERT (S_ISDIR (st1.st_mode)); + + errno = 0; + ASSERT (func (BASE "link2/", &st1) == -1); + ASSERT (errno == ENOTDIR); + + errno = 0; + ASSERT (func (BASE "link3/", &st1) == -1); + ASSERT (errno == ENOENT); + + errno = 0; + ASSERT (func (BASE "link4/", &st1) == -1); + ASSERT (errno == ELOOP); + + /* Cleanup. */ + ASSERT (unlink (BASE "file") == 0); + ASSERT (unlink (BASE "link1") == 0); + ASSERT (unlink (BASE "link2") == 0); + ASSERT (unlink (BASE "link3") == 0); + ASSERT (unlink (BASE "link4") == 0); + free (cwd); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-stdbool.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-stdbool.c new file mode 100644 index 00000000..9322b500 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-stdbool.c @@ -0,0 +1,119 @@ +/* Test bool. + Copyright (C) 2002-2007, 2009-2024 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 . */ + +/* Written by Bruno Haible , 2007. */ + +/* Define ADDRESS_CHECK_OKAY if it is OK to assign an address to a 'bool' + and this does not generate a warning (because we want this test to succeed + even when using gcc's -Werror). */ +#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) \ + || (__clang_major__ >= 4) +/* We can silence the warning. */ +# pragma GCC diagnostic ignored "-Waddress" +# define ADDRESS_CHECK_OKAY +#elif defined __GNUC__ || defined __clang__ +/* There may be a warning. */ +#else +/* Ignore warnings from other compilers. */ +# define ADDRESS_CHECK_OKAY +#endif + +#include + +#ifdef TEST_STDBOOL_H +# include +#endif + +#if false + "error: false is not 0" +#endif +#if true != 1 + "error: true is not 1" +#endif + +/* Several tests cannot be guaranteed with gnulib's , at + least, not for all compilers and compiler options. */ +#if ((HAVE_C_BOOL || defined __cplusplus \ + || HAVE_STDBOOL_H || 3 <= __GNUC__ || 4 <= __clang_major__) \ + && !(defined _MSC_VER || defined __SUNPRO_C)) +# define WORKING_BOOL 1 +#else +# define WORKING_BOOL 0 +#endif + +#if WORKING_BOOL +struct s { bool s: 1; bool t; } s; +#endif + +char a[true == 1 ? 1 : -1]; +char b[false == 0 ? 1 : -1]; +#if WORKING_BOOL +char d[(bool) 0.5 == true ? 1 : -1]; +# ifdef ADDRESS_CHECK_OKAY /* Avoid gcc warning. */ +/* C99 may plausibly be interpreted as not requiring support for a cast from + a variable's address to bool in a static initializer. So treat it like a + GCC extension. */ +# if defined __GNUC__ || defined __clang__ +bool e = &s; +# endif +# endif +char f[(bool) 0.0 == false ? 1 : -1]; +#endif +char g[true]; +char h[sizeof (bool)]; +#if WORKING_BOOL +char i[sizeof s.t]; +#endif +enum { j = false, k = true, l = false * true, m = true * 256 }; +bool n[m]; +char o[sizeof n == m * sizeof n[0] ? 1 : -1]; +char p[-1 - (bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1]; +/* Catch a bug in an HP-UX C compiler. See + https://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html + https://lists.gnu.org/r/bug-coreutils/2005-11/msg00161.html + */ +bool q = true; +bool *pq = &q; + +int +main () +{ + int error = 0; + +#if WORKING_BOOL +# ifdef ADDRESS_CHECK_OKAY /* Avoid gcc warning. */ + /* A cast from a variable's address to bool is valid in expressions. */ + { + bool e1 = &s; + if (!e1) + error = 1; + } +# endif +#endif + + /* Catch a bug in IBM AIX xlc compiler version 6.0.0.0 + reported by James Lemley on 2005-10-05; see + https://lists.gnu.org/r/bug-coreutils/2005-10/msg00086.html + This is a runtime test, since a corresponding compile-time + test would rely on initializer extensions. */ + { + char digs[] = "0123456789"; + if (&(digs + 5)[-2 + (bool) 1] != &digs[4]) + error = 1; + } + + return error; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-stdckdint.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-stdckdint.c new file mode 100644 index 00000000..f0a576f6 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-stdckdint.c @@ -0,0 +1,30 @@ +/* Test . + Copyright 2022-2024 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 . */ + +/* Written by Paul Eggert. */ + +/* Tell test-intprops.c to test instead of . */ + +#define TEST_STDCKDINT 1 + +#define INT_ADD_WRAPV(a, b, r) ckd_add (r, a, b) +#define INT_SUBTRACT_WRAPV(a, b, r) ckd_sub (r, a, b) +#define INT_MULTIPLY_WRAPV(a, b, r) ckd_mul (r, a, b) + +/* Luckily, test-intprops.c uses INT_NEGATE_OVERFLOW only on INT_MIN. */ +#define INT_NEGATE_OVERFLOW(a) ((a) < -INT_MAX) + +#include "test-intprops.c" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-stddef.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-stddef.c new file mode 100644 index 00000000..5bceb18a --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-stddef.c @@ -0,0 +1,100 @@ +/* Test of substitute. + Copyright (C) 2009-2024 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 . */ + +/* Written by Eric Blake , 2009. */ + +#include + +#include + +/* Check that appropriate types are defined. */ +wchar_t a = 'c'; +ptrdiff_t b = 1; +size_t c = 2; +max_align_t mat; + +/* Check that NULL can be passed through varargs as a pointer type, + per POSIX 2008. */ +static_assert (sizeof NULL == sizeof (void *)); + +/* Check that offsetof produces integer constants with correct type. */ +struct d +{ + char e; + char f; +}; +/* Solaris 10 has a bug where offsetof is under-parenthesized, and + cannot be used as an arbitrary expression. However, since it is + unlikely to bite real code, we ignore that short-coming. */ +/* static_assert (sizeof offsetof (struct d, e) == sizeof (size_t)); */ +static_assert (sizeof (offsetof (struct d, e)) == sizeof (size_t)); +static_assert (offsetof (struct d, f) == 1); + +/* Check max_align_t's alignment. */ +static_assert (alignof (double) <= alignof (max_align_t)); +static_assert (alignof (int) <= alignof (max_align_t)); +static_assert (alignof (long double) <= alignof (max_align_t)); +static_assert (alignof (long int) <= alignof (max_align_t)); +static_assert (alignof (ptrdiff_t) <= alignof (max_align_t)); +static_assert (alignof (size_t) <= alignof (max_align_t)); +static_assert (alignof (wchar_t) <= alignof (max_align_t)); +static_assert (alignof (struct d) <= alignof (max_align_t)); +#if defined __GNUC__ || defined __clang__ || defined __IBM__ALIGNOF__ +static_assert (__alignof__ (double) <= __alignof__ (max_align_t)); +static_assert (__alignof__ (int) <= __alignof__ (max_align_t)); +static_assert (__alignof__ (long double) <= __alignof__ (max_align_t)); +static_assert (__alignof__ (long int) <= __alignof__ (max_align_t)); +static_assert (__alignof__ (ptrdiff_t) <= __alignof__ (max_align_t)); +static_assert (__alignof__ (size_t) <= __alignof__ (max_align_t)); +static_assert (__alignof__ (wchar_t) <= __alignof__ (max_align_t)); +static_assert (__alignof__ (struct d) <= __alignof__ (max_align_t)); +#endif + +int test_unreachable_optimization (int x); +_Noreturn void test_unreachable_noreturn (void); + +int +test_unreachable_optimization (int x) +{ + /* Check that the compiler uses 'unreachable' for optimization. + This function, when compiled with optimization, should have code + equivalent to + return x + 3; + Use 'objdump --disassemble test-stddef.o' to verify this. */ + if (x < 4) + unreachable (); + return (x > 1 ? x + 3 : 2 * x + 10); +} + +_Noreturn void +test_unreachable_noreturn (void) +{ + /* Check that the compiler's data-flow analysis recognizes 'unreachable ()'. + This function should not elicit a warning. */ + unreachable (); +} + +#include /* INT_MAX */ + +/* offsetof promotes to an unsigned integer if and only if sizes do + not fit in int. */ +static_assert ((offsetof (struct d, e) < -1) == (INT_MAX < (size_t) -1)); + +int +main (void) +{ + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-stdint.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-stdint.c new file mode 100644 index 00000000..47bedc89 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-stdint.c @@ -0,0 +1,437 @@ +/* Test of substitute. + Copyright (C) 2006-2024 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 . */ + +/* Written by Bruno Haible , 2006. */ + +#include + +/* Whether to enable pedantic checks. */ +#define DO_PEDANTIC 0 + +#include + +#include "verify.h" +#include "intprops.h" + +#if ((__GNUC__ >= 2) || (__clang_major__ >= 4)) && DO_PEDANTIC +# define verify_same_types(expr1,expr2) \ + extern void _verify_func(__LINE__) (__typeof__ (expr1) *); \ + extern void _verify_func(__LINE__) (__typeof__ (expr2) *); +# define _verify_func(line) _verify_func2(line) +# define _verify_func2(line) verify_func_ ## line +#else +# define verify_same_types(expr1,expr2) extern void verify_func (int) +#endif + +/* 7.18.1.1. Exact-width integer types */ +/* 7.18.2.1. Limits of exact-width integer types */ + +int8_t a1[3] = { INT8_C (17), INT8_MIN, INT8_MAX }; +verify (TYPE_MINIMUM (int8_t) == INT8_MIN); +verify (TYPE_MAXIMUM (int8_t) == INT8_MAX); +verify_same_types (INT8_MIN, (int8_t) 0 + 0); +verify_same_types (INT8_MAX, (int8_t) 0 + 0); + +int16_t a2[3] = { INT16_C (17), INT16_MIN, INT16_MAX }; +verify (TYPE_MINIMUM (int16_t) == INT16_MIN); +verify (TYPE_MAXIMUM (int16_t) == INT16_MAX); +verify_same_types (INT16_MIN, (int16_t) 0 + 0); +verify_same_types (INT16_MAX, (int16_t) 0 + 0); + +int32_t a3[3] = { INT32_C (17), INT32_MIN, INT32_MAX }; +verify (TYPE_MINIMUM (int32_t) == INT32_MIN); +verify (TYPE_MAXIMUM (int32_t) == INT32_MAX); +verify_same_types (INT32_MIN, (int32_t) 0 + 0); +verify_same_types (INT32_MAX, (int32_t) 0 + 0); + +#ifdef INT64_MAX +int64_t a4[3] = { INT64_C (17), INT64_MIN, INT64_MAX }; +verify (TYPE_MINIMUM (int64_t) == INT64_MIN); +verify (TYPE_MAXIMUM (int64_t) == INT64_MAX); +verify_same_types (INT64_MIN, (int64_t) 0 + 0); +verify_same_types (INT64_MAX, (int64_t) 0 + 0); +#endif + +uint8_t b1[2] = { UINT8_C (17), UINT8_MAX }; +verify (TYPE_MAXIMUM (uint8_t) == UINT8_MAX); +verify_same_types (UINT8_MAX, (uint8_t) 0 + 0); + +uint16_t b2[2] = { UINT16_C (17), UINT16_MAX }; +verify (TYPE_MAXIMUM (uint16_t) == UINT16_MAX); +verify_same_types (UINT16_MAX, (uint16_t) 0 + 0); + +uint32_t b3[2] = { UINT32_C (17), UINT32_MAX }; +verify (TYPE_MAXIMUM (uint32_t) == UINT32_MAX); +verify_same_types (UINT32_MAX, (uint32_t) 0 + 0); + +#ifdef UINT64_MAX +uint64_t b4[2] = { UINT64_C (17), UINT64_MAX }; +verify (TYPE_MAXIMUM (uint64_t) == UINT64_MAX); +verify_same_types (UINT64_MAX, (uint64_t) 0 + 0); +#endif + +#if INT8_MIN && INT8_MAX && INT16_MIN && INT16_MAX && INT32_MIN && INT32_MAX +/* ok */ +#else +err or; +#endif + +#if UINT8_MAX && UINT16_MAX && UINT32_MAX +/* ok */ +#else +err or; +#endif + +/* 7.18.1.2. Minimum-width integer types */ +/* 7.18.2.2. Limits of minimum-width integer types */ + +int_least8_t c1[3] = { 17, INT_LEAST8_MIN, INT_LEAST8_MAX }; +verify (TYPE_MINIMUM (int_least8_t) == INT_LEAST8_MIN); +verify (TYPE_MAXIMUM (int_least8_t) == INT_LEAST8_MAX); +verify_same_types (INT_LEAST8_MIN, (int_least8_t) 0 + 0); +verify_same_types (INT_LEAST8_MAX, (int_least8_t) 0 + 0); + +int_least16_t c2[3] = { 17, INT_LEAST16_MIN, INT_LEAST16_MAX }; +verify (TYPE_MINIMUM (int_least16_t) == INT_LEAST16_MIN); +verify (TYPE_MAXIMUM (int_least16_t) == INT_LEAST16_MAX); +verify_same_types (INT_LEAST16_MIN, (int_least16_t) 0 + 0); +verify_same_types (INT_LEAST16_MAX, (int_least16_t) 0 + 0); + +int_least32_t c3[3] = { 17, INT_LEAST32_MIN, INT_LEAST32_MAX }; +verify (TYPE_MINIMUM (int_least32_t) == INT_LEAST32_MIN); +verify (TYPE_MAXIMUM (int_least32_t) == INT_LEAST32_MAX); +verify_same_types (INT_LEAST32_MIN, (int_least32_t) 0 + 0); +verify_same_types (INT_LEAST32_MAX, (int_least32_t) 0 + 0); + +#ifdef INT_LEAST64_MAX +int_least64_t c4[3] = { 17, INT_LEAST64_MIN, INT_LEAST64_MAX }; +verify (TYPE_MINIMUM (int_least64_t) == INT_LEAST64_MIN); +verify (TYPE_MAXIMUM (int_least64_t) == INT_LEAST64_MAX); +verify_same_types (INT_LEAST64_MIN, (int_least64_t) 0 + 0); +verify_same_types (INT_LEAST64_MAX, (int_least64_t) 0 + 0); +#endif + +uint_least8_t d1[2] = { 17, UINT_LEAST8_MAX }; +verify (TYPE_MAXIMUM (uint_least8_t) == UINT_LEAST8_MAX); +verify_same_types (UINT_LEAST8_MAX, (uint_least8_t) 0 + 0); + +uint_least16_t d2[2] = { 17, UINT_LEAST16_MAX }; +verify (TYPE_MAXIMUM (uint_least16_t) == UINT_LEAST16_MAX); +verify_same_types (UINT_LEAST16_MAX, (uint_least16_t) 0 + 0); + +uint_least32_t d3[2] = { 17, UINT_LEAST32_MAX }; +verify (TYPE_MAXIMUM (uint_least32_t) == UINT_LEAST32_MAX); +verify_same_types (UINT_LEAST32_MAX, (uint_least32_t) 0 + 0); + +#ifdef UINT_LEAST64_MAX +uint_least64_t d4[2] = { 17, UINT_LEAST64_MAX }; +verify (TYPE_MAXIMUM (uint_least64_t) == UINT_LEAST64_MAX); +verify_same_types (UINT_LEAST64_MAX, (uint_least64_t) 0 + 0); +#endif + +#if INT_LEAST8_MIN && INT_LEAST8_MAX && INT_LEAST16_MIN && INT_LEAST16_MAX && INT_LEAST32_MIN && INT_LEAST32_MAX +/* ok */ +#else +err or; +#endif + +#if UINT_LEAST8_MAX && UINT_LEAST16_MAX && UINT_LEAST32_MAX +/* ok */ +#else +err or; +#endif + +/* 7.18.1.3. Fastest minimum-width integer types */ +/* 7.18.2.3. Limits of fastest minimum-width integer types */ + +int_fast8_t e1[3] = { 17, INT_FAST8_MIN, INT_FAST8_MAX }; +verify (TYPE_MINIMUM (int_fast8_t) == INT_FAST8_MIN); +verify (TYPE_MAXIMUM (int_fast8_t) == INT_FAST8_MAX); +verify_same_types (INT_FAST8_MIN, (int_fast8_t) 0 + 0); +verify_same_types (INT_FAST8_MAX, (int_fast8_t) 0 + 0); + +int_fast16_t e2[3] = { 17, INT_FAST16_MIN, INT_FAST16_MAX }; +verify (TYPE_MINIMUM (int_fast16_t) == INT_FAST16_MIN); +verify (TYPE_MAXIMUM (int_fast16_t) == INT_FAST16_MAX); +verify_same_types (INT_FAST16_MIN, (int_fast16_t) 0 + 0); +verify_same_types (INT_FAST16_MAX, (int_fast16_t) 0 + 0); + +int_fast32_t e3[3] = { 17, INT_FAST32_MIN, INT_FAST32_MAX }; +verify (TYPE_MINIMUM (int_fast32_t) == INT_FAST32_MIN); +verify (TYPE_MAXIMUM (int_fast32_t) == INT_FAST32_MAX); +verify_same_types (INT_FAST32_MIN, (int_fast32_t) 0 + 0); +verify_same_types (INT_FAST32_MAX, (int_fast32_t) 0 + 0); + +#ifdef INT_FAST64_MAX +int_fast64_t e4[3] = { 17, INT_FAST64_MIN, INT_FAST64_MAX }; +verify (TYPE_MINIMUM (int_fast64_t) == INT_FAST64_MIN); +verify (TYPE_MAXIMUM (int_fast64_t) == INT_FAST64_MAX); +verify_same_types (INT_FAST64_MIN, (int_fast64_t) 0 + 0); +verify_same_types (INT_FAST64_MAX, (int_fast64_t) 0 + 0); +#endif + +uint_fast8_t f1[2] = { 17, UINT_FAST8_MAX }; +verify (TYPE_MAXIMUM (uint_fast8_t) == UINT_FAST8_MAX); +verify_same_types (UINT_FAST8_MAX, (uint_fast8_t) 0 + 0); + +uint_fast16_t f2[2] = { 17, UINT_FAST16_MAX }; +verify (TYPE_MAXIMUM (uint_fast16_t) == UINT_FAST16_MAX); +verify_same_types (UINT_FAST16_MAX, (uint_fast16_t) 0 + 0); + +uint_fast32_t f3[2] = { 17, UINT_FAST32_MAX }; +verify (TYPE_MAXIMUM (uint_fast32_t) == UINT_FAST32_MAX); +verify_same_types (UINT_FAST32_MAX, (uint_fast32_t) 0 + 0); + +#ifdef UINT_FAST64_MAX +uint_fast64_t f4[2] = { 17, UINT_FAST64_MAX }; +verify (TYPE_MAXIMUM (uint_fast64_t) == UINT_FAST64_MAX); +verify_same_types (UINT_FAST64_MAX, (uint_fast64_t) 0 + 0); +#endif + +#if INT_FAST8_MIN && INT_FAST8_MAX && INT_FAST16_MIN && INT_FAST16_MAX && INT_FAST32_MIN && INT_FAST32_MAX +/* ok */ +#else +err or; +#endif + +#if UINT_FAST8_MAX && UINT_FAST16_MAX && UINT_FAST32_MAX +/* ok */ +#else +err or; +#endif + +/* 7.18.1.4. Integer types capable of holding object pointers */ +/* 7.18.2.4. Limits of integer types capable of holding object pointers */ + +#ifdef INTPTR_MAX +intptr_t g[3] = { 17, INTPTR_MIN, INTPTR_MAX }; +verify (sizeof (void *) <= sizeof (intptr_t)); +# ifndef __CHERI_PURE_CAPABILITY__ +verify (TYPE_MINIMUM (intptr_t) == INTPTR_MIN); +verify (TYPE_MAXIMUM (intptr_t) == INTPTR_MAX); +# endif +verify_same_types (INTPTR_MIN, (intptr_t) 0 + 0); +verify_same_types (INTPTR_MAX, (intptr_t) 0 + 0); +#endif + +#ifdef UINTPTR_MAX +uintptr_t h[2] = { 17, UINTPTR_MAX }; +verify (sizeof (void *) <= sizeof (uintptr_t)); +# ifndef __CHERI_PURE_CAPABILITY__ +verify (TYPE_MAXIMUM (uintptr_t) == UINTPTR_MAX); +# endif +verify_same_types (UINTPTR_MAX, (uintptr_t) 0 + 0); +#endif + +/* 7.18.1.5. Greatest-width integer types */ +/* 7.18.2.5. Limits of greatest-width integer types */ + +intmax_t i[3] = { INTMAX_C (17), INTMAX_MIN, INTMAX_MAX }; +verify (TYPE_MINIMUM (intmax_t) == INTMAX_MIN); +verify (TYPE_MAXIMUM (intmax_t) == INTMAX_MAX); +verify_same_types (INTMAX_MIN, (intmax_t) 0 + 0); +verify_same_types (INTMAX_MAX, (intmax_t) 0 + 0); + +uintmax_t j[2] = { UINTMAX_C (17), UINTMAX_MAX }; +verify (TYPE_MAXIMUM (uintmax_t) == UINTMAX_MAX); +verify_same_types (UINTMAX_MAX, (uintmax_t) 0 + 0); + +/* Older Sun C and HP-UX 10.20 cc don't support 'long long' constants in + the preprocessor. */ +#if !((defined __SUNPRO_C && __SUNPRO_C < 0x5150) \ + || (defined __hpux && !defined __GNUC__)) +#if INTMAX_MIN && INTMAX_MAX && UINTMAX_MAX +/* ok */ +#else +err or; +#endif +#endif + +/* 7.18.3. Limits of other integer types */ + +#include + +verify (TYPE_MINIMUM (ptrdiff_t) == PTRDIFF_MIN); +verify (TYPE_MAXIMUM (ptrdiff_t) == PTRDIFF_MAX); +verify_same_types (PTRDIFF_MIN, (ptrdiff_t) 0 + 0); +verify_same_types (PTRDIFF_MAX, (ptrdiff_t) 0 + 0); + +#if PTRDIFF_MIN && PTRDIFF_MAX +/* ok */ +#else +err or; +#endif + +#include + +verify (TYPE_MINIMUM (sig_atomic_t) == SIG_ATOMIC_MIN); +verify (TYPE_MAXIMUM (sig_atomic_t) == SIG_ATOMIC_MAX); +verify_same_types (SIG_ATOMIC_MIN, (sig_atomic_t) 0 + 0); +verify_same_types (SIG_ATOMIC_MAX, (sig_atomic_t) 0 + 0); + +#if SIG_ATOMIC_MIN != 17 && SIG_ATOMIC_MAX +/* ok */ +#else +err or; +#endif + +verify (TYPE_MAXIMUM (size_t) == SIZE_MAX); +verify_same_types (SIZE_MAX, (size_t) 0 + 0); + +#if SIZE_MAX +/* ok */ +#else +err or; +#endif + +#if HAVE_WCHAR_T +verify (TYPE_MINIMUM (wchar_t) == WCHAR_MIN); +verify (TYPE_MAXIMUM (wchar_t) == WCHAR_MAX); +verify_same_types (WCHAR_MIN, (wchar_t) 0 + 0); +verify_same_types (WCHAR_MAX, (wchar_t) 0 + 0); + +# if WCHAR_MIN != 17 && WCHAR_MAX +/* ok */ +# else +err or; +# endif +#endif + +#if HAVE_WINT_T +# include + +verify (TYPE_MINIMUM (wint_t) == WINT_MIN); +verify (TYPE_MAXIMUM (wint_t) == WINT_MAX); +verify_same_types (WINT_MIN, (wint_t) 0 + 0); +verify_same_types (WINT_MAX, (wint_t) 0 + 0); + +# if WINT_MIN != 17 && WINT_MAX +/* ok */ +# else +err or; +# endif +#endif + +/* 7.18.4. Macros for integer constants */ + +verify (INT8_C (17) == 17); +verify_same_types (INT8_C (17), (int_least8_t)0 + 0); +verify (UINT8_C (17) == 17); +verify_same_types (UINT8_C (17), (uint_least8_t)0 + 0); + +verify (INT16_C (17) == 17); +verify_same_types (INT16_C (17), (int_least16_t)0 + 0); +verify (UINT16_C (17) == 17); +verify_same_types (UINT16_C (17), (uint_least16_t)0 + 0); + +verify (INT32_C (17) == 17); +verify_same_types (INT32_C (17), (int_least32_t)0 + 0); +verify (UINT32_C (17) == 17); +verify_same_types (UINT32_C (17), (uint_least32_t)0 + 0); + +#ifdef INT64_C +verify (INT64_C (17) == 17); +verify_same_types (INT64_C (17), (int_least64_t)0 + 0); +#endif +#ifdef UINT64_C +verify (UINT64_C (17) == 17); +verify_same_types (UINT64_C (17), (uint_least64_t)0 + 0); +#endif + +verify (INTMAX_C (17) == 17); +verify_same_types (INTMAX_C (17), (intmax_t)0 + 0); +verify (UINTMAX_C (17) == 17); +verify_same_types (UINTMAX_C (17), (uintmax_t)0 + 0); + +/* Use _GL_VERIFY (with a fixed-length diagnostic string) rather than verify, + because the latter would require forming each stringified expression, and + many of these would be so long as to trigger a warning/error like this: + + test-stdint.c:407:1: error: string length '6980' is greater than the \ + length '4095' ISO C99 compilers are required to support \ + [-Werror=overlength-strings] + */ +#define verify_width(width, min, max) \ + _GL_VERIFY ((max) >> ((width) - 1 - ((min) < 0)) == 1, \ + "verify_width check", -) + +/* Macros specified by ISO/IEC TS 18661-1:2014. */ + +#ifdef INT8_MAX +verify_width (INT8_WIDTH, INT8_MIN, INT8_MAX); +#endif +#ifdef UINT8_MAX +verify_width (UINT8_WIDTH, 0, UINT8_MAX); +#endif +#ifdef INT16_MAX +verify_width (INT16_WIDTH, INT16_MIN, INT16_MAX); +#endif +#ifdef UINT16_MAX +verify_width (UINT16_WIDTH, 0, UINT16_MAX); +#endif +#ifdef INT32_MAX +verify_width (INT32_WIDTH, INT32_MIN, INT32_MAX); +#endif +#ifdef UINT32_MAX +verify_width (UINT32_WIDTH, 0, UINT32_MAX); +#endif +#ifdef INT64_MAX +verify_width (INT64_WIDTH, INT64_MIN, INT64_MAX); +#endif +#ifdef UINT64_MAX +verify_width (UINT64_WIDTH, 0, UINT64_MAX); +#endif +verify_width (INT_LEAST8_WIDTH, INT_LEAST8_MIN, INT_LEAST8_MAX); +verify_width (UINT_LEAST8_WIDTH, 0, UINT_LEAST8_MAX); +verify_width (INT_LEAST16_WIDTH, INT_LEAST16_MIN, INT_LEAST16_MAX); +verify_width (UINT_LEAST16_WIDTH, 0, UINT_LEAST16_MAX); +verify_width (INT_LEAST32_WIDTH, INT_LEAST32_MIN, INT_LEAST32_MAX); +verify_width (UINT_LEAST32_WIDTH, 0, UINT_LEAST32_MAX); +verify_width (INT_LEAST64_WIDTH, INT_LEAST64_MIN, INT_LEAST64_MAX); +verify_width (UINT_LEAST64_WIDTH, 0, UINT_LEAST64_MAX); +verify_width (INT_FAST8_WIDTH, INT_FAST8_MIN, INT_FAST8_MAX); +verify_width (UINT_FAST8_WIDTH, 0, UINT_FAST8_MAX); +verify_width (INT_FAST16_WIDTH, INT_FAST16_MIN, INT_FAST16_MAX); +verify_width (UINT_FAST16_WIDTH, 0, UINT_FAST16_MAX); +verify_width (INT_FAST32_WIDTH, INT_FAST32_MIN, INT_FAST32_MAX); +verify_width (UINT_FAST32_WIDTH, 0, UINT_FAST32_MAX); +verify_width (INT_FAST64_WIDTH, INT_FAST64_MIN, INT_FAST64_MAX); +verify_width (UINT_FAST64_WIDTH, 0, UINT_FAST64_MAX); +#ifndef __CHERI_PURE_CAPABILITY__ +# ifdef INTPTR_WIDTH +verify_width (INTPTR_WIDTH, INTPTR_MIN, INTPTR_MAX); +# endif +# ifdef UINTPTR_WIDTH +verify_width (UINTPTR_WIDTH, 0, UINTPTR_MAX); +# endif +#endif +verify_width (INTMAX_WIDTH, INTMAX_MIN, INTMAX_MAX); +verify_width (UINTMAX_WIDTH, 0, UINTMAX_MAX); +verify_width (PTRDIFF_WIDTH, PTRDIFF_MIN, PTRDIFF_MAX); +verify_width (SIZE_WIDTH, 0, SIZE_MAX); +verify_width (WCHAR_WIDTH, WCHAR_MIN, WCHAR_MAX); +#ifdef WINT_MAX +verify_width (WINT_WIDTH, WINT_MIN, WINT_MAX); +#endif +#ifdef SIG_ATOMIC_MAX +verify_width (SIG_ATOMIC_WIDTH, SIG_ATOMIC_MIN, SIG_ATOMIC_MAX); +#endif + +int +main (void) +{ + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-stdio.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-stdio.c new file mode 100644 index 00000000..49969520 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-stdio.c @@ -0,0 +1,93 @@ +/* Test of substitute. + Copyright (C) 2007, 2009-2024 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 . */ + +/* Written by Bruno Haible , 2007. */ + +#include + +#include + +/* Check that the various SEEK_* macros are defined. */ +int sk[] = { SEEK_CUR, SEEK_END, SEEK_SET }; + +/* Check that the _PRINTF_NAN_LEN_MAX macro is defined. */ +int pnlm[] = { _PRINTF_NAN_LEN_MAX }; + +/* Check that NULL can be passed through varargs as a pointer type, + per POSIX 2008. */ +static_assert (sizeof NULL == sizeof (void *)); + +/* Check that the types are all defined. */ +fpos_t t1; +off_t t2; +size_t t3; +ssize_t t4; +va_list t5; + +#include + +#include "signed-nan.h" +#include "signed-snan.h" +#include "macros.h" + +int +main (void) +{ + { + double value1; + char buf[64]; + + value1 = positive_NaNd(); + sprintf (buf, "%g", value1); + ASSERT (strlen (buf) <= _PRINTF_NAN_LEN_MAX); + + value1 = negative_NaNd(); + sprintf (buf, "%g", value1); + ASSERT (strlen (buf) <= _PRINTF_NAN_LEN_MAX); + } +#if defined DBL_EXPBIT0_WORD && defined DBL_EXPBIT0_BIT + /* Check the value of _PRINTF_NAN_LEN_MAX. */ + { + double value1; + memory_double value2; + char buf[64]; + + value1 = positive_SNaNd(); + sprintf (buf, "%g", value1); + ASSERT (strlen (buf) <= _PRINTF_NAN_LEN_MAX); + + value1 = negative_SNaNd(); + sprintf (buf, "%g", value1); + ASSERT (strlen (buf) <= _PRINTF_NAN_LEN_MAX); + + value2.value = positive_NaNd (); + #if DBL_EXPBIT0_BIT == 20 + value2.word[DBL_EXPBIT0_WORD] ^= 0x54321; + #endif + sprintf (buf, "%g", value2.value); + ASSERT (strlen (buf) <= _PRINTF_NAN_LEN_MAX); + + value2.value = negative_NaNd (); + #if DBL_EXPBIT0_BIT == 20 + value2.word[DBL_EXPBIT0_WORD] ^= 0x54321; + #endif + sprintf (buf, "%g", value2.value); + ASSERT (strlen (buf) <= _PRINTF_NAN_LEN_MAX); + } +#endif + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-stdlib.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-stdlib.c new file mode 100644 index 00000000..cb6db802 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-stdlib.c @@ -0,0 +1,63 @@ +/* Test of substitute. + Copyright (C) 2007, 2009-2024 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 . */ + +/* Written by Bruno Haible , 2007. */ + +#include + +#include + +/* Check that EXIT_SUCCESS is 0, per POSIX. */ +static int exitcode = EXIT_SUCCESS; +#if EXIT_SUCCESS +"oops" +#endif + +/* Check for GNU value (not guaranteed by POSIX, but is guaranteed by + gnulib). */ +#if EXIT_FAILURE != 1 +"oops" +#endif + +/* Check that NULL can be passed through varargs as a pointer type, + per POSIX 2008. */ +static_assert (sizeof NULL == sizeof (void *)); + +#if GNULIB_TEST_SYSTEM_POSIX +# include "test-sys_wait.h" +#else +# define test_sys_wait_macros() 0 +#endif + +int +main (void) +{ + /* POSIX:2018 says: + "In the POSIX locale the value of MB_CUR_MAX shall be 1." */ + /* On Android ≥ 5.0, the default locale is the "C.UTF-8" locale, not the + "C" locale. Furthermore, when you attempt to set the "C" or "POSIX" + locale via setlocale(), what you get is a "C" locale with UTF-8 encoding, + that is, effectively the "C.UTF-8" locale. */ +#ifndef __ANDROID__ + if (MB_CUR_MAX != 1) + return 1; +#endif + + if (test_sys_wait_macros ()) + return 2; + + return exitcode; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-strerror.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-strerror.c new file mode 100644 index 00000000..3074b5cd --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-strerror.c @@ -0,0 +1,75 @@ +/* Test of strerror() function. + Copyright (C) 2007-2024 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 . */ + +/* Written by Eric Blake , 2007. */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (strerror, char *, (int)); + +#include + +#include "macros.h" + +int +main (void) +{ + char *str; + + errno = 0; + str = strerror (EACCES); + ASSERT (str); + ASSERT (*str); + ASSERT (errno == 0); + + errno = 0; + str = strerror (ETIMEDOUT); + ASSERT (str); + ASSERT (*str); + ASSERT (errno == 0); + + errno = 0; + str = strerror (EOVERFLOW); + ASSERT (str); + ASSERT (*str); + ASSERT (errno == 0); + + /* POSIX requires strerror (0) to succeed. Reject use of "Unknown + error", but allow "Success", "No error", or even Solaris' "Error + 0" which are distinct patterns from true out-of-range strings. + http://austingroupbugs.net/view.php?id=382 */ + errno = 0; + str = strerror (0); + ASSERT (str); + ASSERT (*str); + ASSERT (errno == 0); + ASSERT (strstr (str, "nknown") == NULL); + ASSERT (strstr (str, "ndefined") == NULL); + + /* POSIX requires strerror to produce a non-NULL result for all + inputs; as an extension, we also guarantee a non-empty result. + Reporting EINVAL is optional. */ + errno = 0; + str = strerror (-3); + ASSERT (str); + ASSERT (*str); + ASSERT (errno == 0 || errno == EINVAL); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-strerror_r.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-strerror_r.c new file mode 100644 index 00000000..4b4e27f4 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-strerror_r.c @@ -0,0 +1,178 @@ +/* Test of strerror_r() function. + Copyright (C) 2007-2024 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 . */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (strerror_r, int, (int, char *, size_t)); + +#include + +#include "macros.h" + +int +main (void) +{ + char buf[100]; + int ret; + + /* Test results with valid errnum and enough room. */ + + errno = 0; + buf[0] = '\0'; + ASSERT (strerror_r (EACCES, buf, sizeof buf) == 0); + ASSERT (buf[0] != '\0'); + ASSERT (errno == 0); + ASSERT (strlen (buf) < sizeof buf); + + errno = 0; + buf[0] = '\0'; + ASSERT (strerror_r (ETIMEDOUT, buf, sizeof buf) == 0); + ASSERT (buf[0] != '\0'); + ASSERT (errno == 0); + ASSERT (strlen (buf) < sizeof buf); + + errno = 0; + buf[0] = '\0'; + ASSERT (strerror_r (EOVERFLOW, buf, sizeof buf) == 0); + ASSERT (buf[0] != '\0'); + ASSERT (errno == 0); + ASSERT (strlen (buf) < sizeof buf); + + /* POSIX requires strerror (0) to succeed. Reject use of "Unknown + error", but allow "Success", "No error", or even Solaris' "Error + 0" which are distinct patterns from true out-of-range strings. + http://austingroupbugs.net/view.php?id=382 */ + errno = 0; + buf[0] = '\0'; + ret = strerror_r (0, buf, sizeof buf); + ASSERT (ret == 0); + ASSERT (buf[0]); + ASSERT (errno == 0); + ASSERT (strstr (buf, "nknown") == NULL); + ASSERT (strstr (buf, "ndefined") == NULL); + + /* Test results with out-of-range errnum and enough room. POSIX + allows an empty string on success, and allows an unchanged buf on + error, but these are not useful, so we guarantee contents. */ + errno = 0; + buf[0] = '^'; + ret = strerror_r (-3, buf, sizeof buf); + ASSERT (ret == 0 || ret == EINVAL); + ASSERT (buf[0] != '^'); + ASSERT (*buf); + ASSERT (errno == 0); + ASSERT (strlen (buf) < sizeof buf); + + /* Test results with a too small buffer. POSIX requires an error; + only ERANGE for 0 and valid errors, and a choice of ERANGE or + EINVAL for out-of-range values. On error, POSIX permits buf to + be empty, unchanged, or unterminated, but these are not useful, + so we guarantee NUL-terminated truncated contents for all but + size 0. http://austingroupbugs.net/view.php?id=398. Also ensure + that no out-of-bounds writes occur. */ + { + int errs[] = { EACCES, 0, -3, }; + int j; + + buf[sizeof buf - 1] = '\0'; + for (j = 0; j < SIZEOF (errs); j++) + { + int err = errs[j]; + char buf2[sizeof buf] = ""; + size_t len; + size_t i; + + strerror_r (err, buf2, sizeof buf2); + len = strlen (buf2); + ASSERT (len < sizeof buf); + + for (i = 0; i <= len; i++) + { + memset (buf, '^', sizeof buf - 1); + errno = 0; + ret = strerror_r (err, buf, i); + ASSERT (errno == 0); + if (j == 2) + ASSERT (ret == ERANGE || ret == EINVAL); + else + ASSERT (ret == ERANGE); + if (i) + { + ASSERT (strncmp (buf, buf2, i - 1) == 0); + ASSERT (buf[i - 1] == '\0'); + } + ASSERT (strspn (buf + i, "^") == sizeof buf - 1 - i); + } + + strcpy (buf, "BADFACE"); + errno = 0; + ret = strerror_r (err, buf, len + 1); + ASSERT (ret != ERANGE); + ASSERT (errno == 0); + ASSERT (strcmp (buf, buf2) == 0); + } + } + +#if GNULIB_STRERROR + /* Test that strerror_r does not clobber strerror buffer. On some + platforms, this test can only succeed if gnulib also replaces + strerror. */ + { + const char *msg1; + const char *msg2; + const char *msg3; + const char *msg4; + char *str1; + char *str2; + char *str3; + char *str4; + + msg1 = strerror (ENOENT); + ASSERT (msg1); + str1 = strdup (msg1); + ASSERT (str1); + + msg2 = strerror (ERANGE); + ASSERT (msg2); + str2 = strdup (msg2); + ASSERT (str2); + + msg3 = strerror (-4); + ASSERT (msg3); + str3 = strdup (msg3); + ASSERT (str3); + + msg4 = strerror (1729576); + ASSERT (msg4); + str4 = strdup (msg4); + ASSERT (str4); + + strerror_r (EACCES, buf, sizeof buf); + strerror_r (-5, buf, sizeof buf); + ASSERT (STREQ (msg4, str4)); + + free (str1); + free (str2); + free (str3); + free (str4); + } +#endif + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-string.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-string.c new file mode 100644 index 00000000..053c2e4a --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-string.c @@ -0,0 +1,31 @@ +/* Test of substitute. + Copyright (C) 2007, 2009-2024 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 . */ + +/* Written by Bruno Haible , 2007. */ + +#include + +#include + +/* Check that NULL can be passed through varargs as a pointer type, + per POSIX 2008. */ +static_assert (sizeof NULL == sizeof (void *)); + +int +main (void) +{ + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-strings.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-strings.c new file mode 100644 index 00000000..942e41c2 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-strings.c @@ -0,0 +1,27 @@ +/* Test of substitute. + Copyright (C) 2007, 2009-2024 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 . */ + +/* Written by Bruno Haible , 2007. */ + +#include + +#include + +int +main () +{ + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-strnlen.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-strnlen.c new file mode 100644 index 00000000..0c85b8fc --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-strnlen.c @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2010-2024 Free Software Foundation, Inc. + * Written by Eric Blake + * + * 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 . */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (strnlen, size_t, (char const *, size_t)); + +#include + +#include "zerosize-ptr.h" +#include "macros.h" + +int +main (void) +{ + size_t i; + char *page_boundary = (char *) zerosize_ptr (); + if (!page_boundary) + { + page_boundary = malloc (0x1000); + ASSERT (page_boundary); + page_boundary += 0x1000; + } + + /* Basic behavior tests. */ + ASSERT (strnlen ("a", 0) == 0); + ASSERT (strnlen ("a", 1) == 1); + ASSERT (strnlen ("a", 2) == 1); + ASSERT (strnlen ("", 0x100000) == 0); + + /* Memory fence and alignment testing. */ + for (i = 0; i < 512; i++) + { + char *start = page_boundary - i; + size_t j = i; + memset (start, 'x', i); + do + { + if (i != j) + { + start[j] = 0; + ASSERT (strnlen (start, i + j) == j); + } + ASSERT (strnlen (start, i) == j); + ASSERT (strnlen (start, j) == j); + } + while (j--); + } + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-strtoimax.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-strtoimax.c new file mode 100644 index 00000000..184da300 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-strtoimax.c @@ -0,0 +1,181 @@ +/* + * Copyright (C) 2011-2024 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 . */ + +#include + +#include + +#include "signature.h" +#ifndef strtoimax +SIGNATURE_CHECK (strtoimax, intmax_t, (const char *, char **, int)); +#endif + +#include + +#include "macros.h" + +int +main (void) +{ + /* Subject sequence empty or invalid. */ + { + const char input[] = ""; + char *ptr; + intmax_t result; + errno = 0; + result = strtoimax (input, &ptr, 10); + ASSERT (result == 0); + ASSERT (ptr == input); + ASSERT (errno == 0 || errno == EINVAL); + } + { + const char input[] = " "; + char *ptr; + intmax_t result; + errno = 0; + result = strtoimax (input, &ptr, 10); + ASSERT (result == 0); + ASSERT (ptr == input); + ASSERT (errno == 0 || errno == EINVAL); + } + { + const char input[] = " +"; + char *ptr; + intmax_t result; + errno = 0; + result = strtoimax (input, &ptr, 10); + ASSERT (result == 0); + ASSERT (ptr == input); + ASSERT (errno == 0 || errno == EINVAL); + } + { + const char input[] = " -"; + char *ptr; + intmax_t result; + errno = 0; + result = strtoimax (input, &ptr, 10); + ASSERT (result == 0); + ASSERT (ptr == input); + ASSERT (errno == 0 || errno == EINVAL); + } + + /* Simple integer values. */ + { + const char input[] = "0"; + char *ptr; + intmax_t result; + errno = 0; + result = strtoimax (input, &ptr, 10); + ASSERT (result == 0); + ASSERT (ptr == input + 1); + ASSERT (errno == 0); + } + { + const char input[] = "+0"; + char *ptr; + intmax_t result; + errno = 0; + result = strtoimax (input, &ptr, 10); + ASSERT (result == 0); + ASSERT (ptr == input + 2); + ASSERT (errno == 0); + } + { + const char input[] = "-0"; + char *ptr; + intmax_t result; + errno = 0; + result = strtoimax (input, &ptr, 10); + ASSERT (result == 0); + ASSERT (ptr == input + 2); + ASSERT (errno == 0); + } + { + const char input[] = "23"; + char *ptr; + intmax_t result; + errno = 0; + result = strtoimax (input, &ptr, 10); + ASSERT (result == 23); + ASSERT (ptr == input + 2); + ASSERT (errno == 0); + } + { + const char input[] = " 23"; + char *ptr; + intmax_t result; + errno = 0; + result = strtoimax (input, &ptr, 10); + ASSERT (result == 23); + ASSERT (ptr == input + 3); + ASSERT (errno == 0); + } + { + const char input[] = "+23"; + char *ptr; + intmax_t result; + errno = 0; + result = strtoimax (input, &ptr, 10); + ASSERT (result == 23); + ASSERT (ptr == input + 3); + ASSERT (errno == 0); + } + { + const char input[] = "-23"; + char *ptr; + intmax_t result; + errno = 0; + result = strtoimax (input, &ptr, 10); + ASSERT (result == -23); + ASSERT (ptr == input + 3); + ASSERT (errno == 0); + } + + /* Large integer values. */ + { + const char input[] = "2147483647"; + char *ptr; + intmax_t result; + errno = 0; + result = strtoimax (input, &ptr, 10); + ASSERT (result == 2147483647); + ASSERT (ptr == input + 10); + ASSERT (errno == 0); + } + { + const char input[] = "-2147483648"; + char *ptr; + intmax_t result; + errno = 0; + result = strtoimax (input, &ptr, 10); + ASSERT (result == -2147483647 - 1); + ASSERT (ptr == input + 11); + ASSERT (errno == 0); + } + if (sizeof (intmax_t) > sizeof (int)) + { + const char input[] = "4294967295"; + char *ptr; + intmax_t result; + errno = 0; + result = strtoimax (input, &ptr, 10); + ASSERT (result == (intmax_t) 65535 * (intmax_t) 65537); + ASSERT (ptr == input + 10); + ASSERT (errno == 0); + } + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-strtoll.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-strtoll.c new file mode 100644 index 00000000..b1507022 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-strtoll.c @@ -0,0 +1,305 @@ +/* + * Copyright (C) 2011-2024 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 . */ + +#include + +#include + +#include "signature.h" +#ifndef strtoll +SIGNATURE_CHECK (strtoll, long long, (const char *, char **, int)); +#endif + +#include + +#include "macros.h" + +int +main (void) +{ + /* Subject sequence empty or invalid. */ + { + const char input[] = ""; + char *ptr; + long long result; + errno = 0; + result = strtoll (input, &ptr, 10); + ASSERT (result == 0); + ASSERT (ptr == input); + ASSERT (errno == 0 || errno == EINVAL); + } + { + const char input[] = " "; + char *ptr; + long long result; + errno = 0; + result = strtoll (input, &ptr, 10); + ASSERT (result == 0); + ASSERT (ptr == input); + ASSERT (errno == 0 || errno == EINVAL); + } + { + const char input[] = " +"; + char *ptr; + long long result; + errno = 0; + result = strtoll (input, &ptr, 10); + ASSERT (result == 0); + ASSERT (ptr == input); + ASSERT (errno == 0 || errno == EINVAL); + } + { + const char input[] = " -"; + char *ptr; + long long result; + errno = 0; + result = strtoll (input, &ptr, 10); + ASSERT (result == 0); + ASSERT (ptr == input); + ASSERT (errno == 0 || errno == EINVAL); + } + + /* Simple integer values. */ + { + const char input[] = "0"; + char *ptr; + long long result; + errno = 0; + result = strtoll (input, &ptr, 10); + ASSERT (result == 0); + ASSERT (ptr == input + 1); + ASSERT (errno == 0); + } + { + const char input[] = "+0"; + char *ptr; + long long result; + errno = 0; + result = strtoll (input, &ptr, 10); + ASSERT (result == 0); + ASSERT (ptr == input + 2); + ASSERT (errno == 0); + } + { + const char input[] = "-0"; + char *ptr; + long long result; + errno = 0; + result = strtoll (input, &ptr, 10); + ASSERT (result == 0); + ASSERT (ptr == input + 2); + ASSERT (errno == 0); + } + { + const char input[] = "23"; + char *ptr; + long long result; + errno = 0; + result = strtoll (input, &ptr, 10); + ASSERT (result == 23); + ASSERT (ptr == input + 2); + ASSERT (errno == 0); + } + { + const char input[] = " 23"; + char *ptr; + long long result; + errno = 0; + result = strtoll (input, &ptr, 10); + ASSERT (result == 23); + ASSERT (ptr == input + 3); + ASSERT (errno == 0); + } + { + const char input[] = "+23"; + char *ptr; + long long result; + errno = 0; + result = strtoll (input, &ptr, 10); + ASSERT (result == 23); + ASSERT (ptr == input + 3); + ASSERT (errno == 0); + } + { + const char input[] = "-23"; + char *ptr; + long long result; + errno = 0; + result = strtoll (input, &ptr, 10); + ASSERT (result == -23); + ASSERT (ptr == input + 3); + ASSERT (errno == 0); + } + + /* Large integer values. */ + { + const char input[] = "2147483647"; + char *ptr; + long long result; + errno = 0; + result = strtoll (input, &ptr, 10); + ASSERT (result == 2147483647); + ASSERT (ptr == input + 10); + ASSERT (errno == 0); + } + { + const char input[] = "-2147483648"; + char *ptr; + long long result; + errno = 0; + result = strtoll (input, &ptr, 10); + ASSERT (result == -2147483647 - 1); + ASSERT (ptr == input + 11); + ASSERT (errno == 0); + } + if (sizeof (long long) > sizeof (int)) + { + const char input[] = "4294967295"; + char *ptr; + long long result; + errno = 0; + result = strtoll (input, &ptr, 10); + ASSERT (result == 65535LL * 65537LL); + ASSERT (ptr == input + 10); + ASSERT (errno == 0); + } + + /* Hexadecimal integer syntax. */ + { + const char input[] = "0x2A"; + char *ptr; + long long result; + errno = 0; + result = strtoll (input, &ptr, 10); + ASSERT (result == 0LL); + ASSERT (ptr == input + 1); + ASSERT (errno == 0); + } + { + const char input[] = "0x2A"; + char *ptr; + long long result; + errno = 0; + result = strtoll (input, &ptr, 16); + ASSERT (result == 42LL); + ASSERT (ptr == input + 4); + ASSERT (errno == 0); + } + { + const char input[] = "0x2A"; + char *ptr; + long long result; + errno = 0; + result = strtoll (input, &ptr, 0); + ASSERT (result == 42LL); + ASSERT (ptr == input + 4); + ASSERT (errno == 0); + } + { + const char input[] = "0x"; + char *ptr; + long long result; + errno = 0; + result = strtoll (input, &ptr, 10); + ASSERT (result == 0LL); + ASSERT (ptr == input + 1); + ASSERT (errno == 0); + } + { + const char input[] = "0x"; + char *ptr; + long long result; + errno = 0; + result = strtoll (input, &ptr, 16); + ASSERT (result == 0LL); + ASSERT (ptr == input + 1); + ASSERT (errno == 0); + } + { + const char input[] = "0x"; + char *ptr; + long long result; + errno = 0; + result = strtoll (input, &ptr, 0); + ASSERT (result == 0LL); + ASSERT (ptr == input + 1); + ASSERT (errno == 0); + } + + /* Binary integer syntax. */ + { + const char input[] = "0b111010"; + char *ptr; + long long result; + errno = 0; + result = strtoll (input, &ptr, 10); + ASSERT (result == 0LL); + ASSERT (ptr == input + 1); + ASSERT (errno == 0); + } + { + const char input[] = "0b111010"; + char *ptr; + long long result; + errno = 0; + result = strtoll (input, &ptr, 2); + ASSERT (result == 58LL); + ASSERT (ptr == input + 8); + ASSERT (errno == 0); + } + { + const char input[] = "0b111010"; + char *ptr; + long long result; + errno = 0; + result = strtoll (input, &ptr, 0); + ASSERT (result == 58LL); + ASSERT (ptr == input + 8); + ASSERT (errno == 0); + } + { + const char input[] = "0b"; + char *ptr; + long long result; + errno = 0; + result = strtoll (input, &ptr, 10); + ASSERT (result == 0LL); + ASSERT (ptr == input + 1); + ASSERT (errno == 0); + } + { + const char input[] = "0b"; + char *ptr; + long long result; + errno = 0; + result = strtoll (input, &ptr, 2); + ASSERT (result == 0LL); + ASSERT (ptr == input + 1); + ASSERT (errno == 0); + } + { + const char input[] = "0b"; + char *ptr; + long long result; + errno = 0; + result = strtoll (input, &ptr, 0); + ASSERT (result == 0LL); + ASSERT (ptr == input + 1); + ASSERT (errno == 0); + } + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-symlink.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-symlink.c new file mode 100644 index 00000000..04c3e7a8 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-symlink.c @@ -0,0 +1,46 @@ +/* Tests of symlink. + Copyright (C) 2009-2024 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 . */ + +/* Written by Eric Blake , 2009. */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (symlink, int, (char const *, char const *)); + +#include +#include +#include +#include +#include + +#include "ignore-value.h" +#include "macros.h" + +#define BASE "test-symlink.t" + +#include "test-symlink.h" + +int +main (void) +{ + /* Remove any leftovers from a previous partial run. */ + ignore_value (system ("rm -rf " BASE "*")); + + return test_symlink (symlink, true); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-symlink.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-symlink.h new file mode 100644 index 00000000..a63faed7 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-symlink.h @@ -0,0 +1,96 @@ +/* Tests of symlink. + Copyright (C) 2009-2024 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 . */ + +/* Written by Eric Blake , 2009. */ + +/* This file is designed to test both symlink(a,b) and + symlinkat(a,AT_FDCWD,b). FUNC is the function to test. Assumes + that BASE and ASSERT are already defined, and that appropriate + headers are already included. If PRINT, warn before skipping + symlink tests with status 77. */ + +static int +test_symlink (int (*func) (char const *, char const *), bool print) +{ + if (func ("nowhere", BASE "link1")) + { + if (print) + fputs ("skipping test: symlinks not supported on this file system\n", + stderr); + return 77; + } + + /* Some systems allow the creation of 0-length symlinks as a synonym + for "."; but most reject it. */ + { + int status; + errno = 0; + status = func ("", BASE "link2"); + if (status == -1) + ASSERT (errno == ENOENT || errno == EINVAL); + else + { + ASSERT (status == 0); + ASSERT (unlink (BASE "link2") == 0); + } + } + + /* Sanity checks of failures. */ + errno = 0; + ASSERT (func ("nowhere", "") == -1); + ASSERT (errno == ENOENT); + errno = 0; + ASSERT (func ("nowhere", ".") == -1); + ASSERT (errno == EEXIST || errno == EINVAL); + errno = 0; + ASSERT (func ("somewhere", BASE "link1") == -1); + ASSERT (errno == EEXIST); + errno = 0; + ASSERT (func ("nowhere", BASE "link2/") == -1); + ASSERT (errno == ENOTDIR || errno == ENOENT); + ASSERT (mkdir (BASE "dir", 0700) == 0); + errno = 0; + ASSERT (func ("nowhere", BASE "dir") == -1); + ASSERT (errno == EEXIST); + errno = 0; + ASSERT (func ("nowhere", BASE "dir/") == -1); + ASSERT (errno == EEXIST || errno == EINVAL + || errno == ENOENT /* Lustre FS on Linux */); + ASSERT (close (creat (BASE "file", 0600)) == 0); + errno = 0; + ASSERT (func ("nowhere", BASE "file") == -1); + ASSERT (errno == EEXIST); + errno = 0; + ASSERT (func ("nowhere", BASE "file/") == -1); + ASSERT (errno == EEXIST || errno == ENOTDIR || errno == ENOENT); + + /* Trailing slash must always be rejected. */ + ASSERT (unlink (BASE "link1") == 0); + ASSERT (func (BASE "link2", BASE "link1") == 0); + errno = 0; + ASSERT (func (BASE "nowhere", BASE "link1/") == -1); + ASSERT (errno == EEXIST || errno == ENOTDIR || errno == ENOENT); + errno = 0; + ASSERT (unlink (BASE "link2") == -1); + ASSERT (errno == ENOENT); + + /* Cleanup. */ + ASSERT (rmdir (BASE "dir") == 0); + ASSERT (unlink (BASE "file") == 0); + ASSERT (unlink (BASE "link1") == 0); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-symlinkat.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-symlinkat.c new file mode 100644 index 00000000..86d2558f --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-symlinkat.c @@ -0,0 +1,88 @@ +/* Tests of symlinkat. + Copyright (C) 2009-2024 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 . */ + +/* Written by Eric Blake , 2009. */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (symlinkat, int, (char const *, int, char const *)); + +#include +#include +#include +#include +#include +#include + +#include "ignore-value.h" +#include "macros.h" + +#ifndef HAVE_SYMLINK +# define HAVE_SYMLINK 0 +#endif + +#define BASE "test-symlinkat.t" + +#include "test-symlink.h" + +static int dfd = AT_FDCWD; + +static int +do_symlink (char const *contents, char const *name) +{ + return symlinkat (contents, dfd, name); +} + +int +main (void) +{ + int result; + + /* Remove any leftovers from a previous partial run. */ + ignore_value (system ("rm -rf " BASE "*")); + + /* Test behaviour for invalid file descriptors. */ + { + errno = 0; + ASSERT (symlinkat ("foo", -1, "bar") == -1); + ASSERT (errno == EBADF + || errno == ENOSYS /* seen on mingw */ + ); + } + { + close (99); + errno = 0; + ASSERT (symlinkat ("foo", 99, "bar") == -1); + ASSERT (errno == EBADF + || errno == ENOSYS /* seen on mingw */ + ); + } + + /* Perform same checks as counterpart functions. */ + result = test_symlink (do_symlink, false); + dfd = openat (AT_FDCWD, ".", O_RDONLY); + ASSERT (0 <= dfd); + ASSERT (test_symlink (do_symlink, false) == result); + + ASSERT (close (dfd) == 0); + if (result == 77) + fputs ("skipping test: symlinks not supported on this file system\n", + stderr); + return result; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sys_ioctl.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sys_ioctl.c new file mode 100644 index 00000000..4cecce18 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sys_ioctl.c @@ -0,0 +1,27 @@ +/* Test of substitute. + Copyright (C) 2009-2024 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 . */ + +/* Written by Eric Blake , 2009. */ + +#include + +#include + +int +main (void) +{ + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sys_random.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sys_random.c new file mode 100644 index 00000000..16cacd31 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sys_random.c @@ -0,0 +1,32 @@ +/* Test of substitute. + Copyright (C) 2020-2024 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 . */ + +#include + +#include + +/* Check that the necessary constants are defined. */ +int flags[] = + { + GRND_RANDOM, + GRND_NONBLOCK + }; + +int +main (void) +{ + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sys_select.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sys_select.c new file mode 100644 index 00000000..db791de1 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sys_select.c @@ -0,0 +1,59 @@ +/* Test of substitute. + Copyright (C) 2007-2024 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 . */ + +/* Written by Bruno Haible , 2007. */ + +#include + +#include + +/* Check that the 'struct timeval' type is defined. */ +struct timeval a; + +/* Check that a.tv_sec is wide enough to hold a time_t, ignoring + signedness issues. */ +typedef int verify_tv_sec_type[sizeof (time_t) <= sizeof (a.tv_sec) ? 1 : -1]; + +/* Check that sigset_t is defined. */ +sigset_t t2; + +#include "signature.h" + +/* The following may be macros without underlying functions, so only + check signature if they are not macros. */ +#ifndef FD_CLR +SIGNATURE_CHECK (FD_CLR, void, (int, fd_set *)); +#endif +#ifndef FD_ISSET +SIGNATURE_CHECK (FD_ISSET, void, (int, fd_set *)); +#endif +#ifndef FD_SET +SIGNATURE_CHECK (FD_SET, int, (int, fd_set *)); +#endif +#ifndef FD_ZERO +SIGNATURE_CHECK (FD_ZERO, void, (fd_set *)); +#endif + +int +main (void) +{ + /* Check that FD_ZERO can be used. This should not yield a warning + such as "warning: implicit declaration of function 'memset'". */ + fd_set fds; + FD_ZERO (&fds); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sys_socket.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sys_socket.c new file mode 100644 index 00000000..4e0f9ad4 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sys_socket.c @@ -0,0 +1,68 @@ +/* Test of substitute. + Copyright (C) 2007, 2009-2024 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 . */ + +/* Written by Bruno Haible , 2007. */ + +#include + +#include + +#if HAVE_SHUTDOWN +/* Check some integer constant expressions. */ +int a[] = { SHUT_RD, SHUT_WR, SHUT_RDWR }; +#endif + +/* Check that the 'socklen_t' type is defined. */ +socklen_t t1; + +/* Check that the 'size_t' and 'ssize_t' types are defined. */ +size_t t2; +ssize_t t3; + +/* Check that 'struct iovec' is defined. */ +struct iovec io; + +/* Check that a minimal set of 'struct msghdr' is defined. */ +struct msghdr msg; + +#include + +int +main (void) +{ + struct sockaddr_storage x; + sa_family_t i; + + /* Check some errno values. */ + switch (ENOTSOCK) + { + case ENOTSOCK: + case EADDRINUSE: + case ENETRESET: + case ECONNABORTED: + case ECONNRESET: + case ENOTCONN: + case ESHUTDOWN: + break; + } + + x.ss_family = 42; + i = 42; + msg.msg_iov = &io; + + return (x.ss_family - i + msg.msg_namelen + msg.msg_iov->iov_len + + msg.msg_iovlen); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sys_stat.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sys_stat.c new file mode 100644 index 00000000..7c4ec1fe --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sys_stat.c @@ -0,0 +1,338 @@ +/* Test of substitute. + Copyright (C) 2007-2024 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 . */ + +/* Written by Bruno Haible , 2007. */ + +#include + +#include + +/* Check the existence of some macros. */ +int a[] = + { + S_IFMT, +#ifdef S_IFBLK /* missing on MSVC */ + S_IFBLK, +#endif + S_IFCHR, S_IFDIR, S_IFIFO, S_IFREG, +#ifdef S_IFLNK /* missing on native Windows and DJGPP */ + S_IFLNK, +#endif +#ifdef S_IFSOCK /* missing on native Windows and DJGPP */ + S_IFSOCK, +#endif + S_IRWXU, S_IRUSR, S_IWUSR, S_IXUSR, + S_IRWXG, S_IRGRP, S_IWGRP, S_IXGRP, + S_IRWXO, S_IROTH, S_IWOTH, S_IXOTH, + S_ISUID, S_ISGID, S_ISVTX, + S_ISBLK (S_IFREG), + S_ISCHR (S_IFREG), + S_ISDIR (S_IFREG), + S_ISFIFO (S_IFREG), + S_ISREG (S_IFREG), + S_ISLNK (S_IFREG), + S_ISSOCK (S_IFREG), + S_ISDOOR (S_IFREG), + S_ISMPB (S_IFREG), + S_ISMPX (S_IFREG), + S_ISNAM (S_IFREG), + S_ISNWK (S_IFREG), + S_ISPORT (S_IFREG), + S_ISCTG (S_IFREG), + S_ISOFD (S_IFREG), + S_ISOFL (S_IFREG), + S_ISWHT (S_IFREG) + }; + +/* Sanity checks. */ + +static_assert (S_IRWXU == (S_IRUSR | S_IWUSR | S_IXUSR)); +static_assert (S_IRWXG == (S_IRGRP | S_IWGRP | S_IXGRP)); +static_assert (S_IRWXO == (S_IROTH | S_IWOTH | S_IXOTH)); + +#ifdef S_IFBLK +static_assert (S_ISBLK (S_IFBLK)); +#endif +static_assert (!S_ISBLK (S_IFCHR)); +static_assert (!S_ISBLK (S_IFDIR)); +static_assert (!S_ISBLK (S_IFIFO)); +static_assert (!S_ISBLK (S_IFREG)); +#ifdef S_IFLNK +static_assert (!S_ISBLK (S_IFLNK)); +#endif +#ifdef S_IFSOCK +static_assert (!S_ISBLK (S_IFSOCK)); +#endif + +#ifdef S_IFBLK +static_assert (!S_ISCHR (S_IFBLK)); +#endif +static_assert (S_ISCHR (S_IFCHR)); +static_assert (!S_ISCHR (S_IFDIR)); +static_assert (!S_ISCHR (S_IFIFO)); +static_assert (!S_ISCHR (S_IFREG)); +#ifdef S_IFLNK +static_assert (!S_ISCHR (S_IFLNK)); +#endif +#ifdef S_IFSOCK +static_assert (!S_ISCHR (S_IFSOCK)); +#endif + +#ifdef S_IFBLK +static_assert (!S_ISDIR (S_IFBLK)); +#endif +static_assert (!S_ISDIR (S_IFCHR)); +static_assert (S_ISDIR (S_IFDIR)); +static_assert (!S_ISDIR (S_IFIFO)); +static_assert (!S_ISDIR (S_IFREG)); +#ifdef S_IFLNK +static_assert (!S_ISDIR (S_IFLNK)); +#endif +#ifdef S_IFSOCK +static_assert (!S_ISDIR (S_IFSOCK)); +#endif + +#ifdef S_IFBLK +static_assert (!S_ISFIFO (S_IFBLK)); +#endif +static_assert (!S_ISFIFO (S_IFCHR)); +static_assert (!S_ISFIFO (S_IFDIR)); +static_assert (S_ISFIFO (S_IFIFO)); +static_assert (!S_ISFIFO (S_IFREG)); +#ifdef S_IFLNK +static_assert (!S_ISFIFO (S_IFLNK)); +#endif +#ifdef S_IFSOCK +static_assert (!S_ISFIFO (S_IFSOCK)); +#endif + +#ifdef S_IFBLK +static_assert (!S_ISREG (S_IFBLK)); +#endif +static_assert (!S_ISREG (S_IFCHR)); +static_assert (!S_ISREG (S_IFDIR)); +static_assert (!S_ISREG (S_IFIFO)); +static_assert (S_ISREG (S_IFREG)); +#ifdef S_IFLNK +static_assert (!S_ISREG (S_IFLNK)); +#endif +#ifdef S_IFSOCK +static_assert (!S_ISREG (S_IFSOCK)); +#endif + +#ifdef S_IFBLK +static_assert (!S_ISLNK (S_IFBLK)); +#endif +static_assert (!S_ISLNK (S_IFCHR)); +static_assert (!S_ISLNK (S_IFDIR)); +static_assert (!S_ISLNK (S_IFIFO)); +static_assert (!S_ISLNK (S_IFREG)); +#ifdef S_IFLNK +static_assert (S_ISLNK (S_IFLNK)); +#endif +#ifdef S_IFSOCK +static_assert (!S_ISLNK (S_IFSOCK)); +#endif + +#ifdef S_IFBLK +static_assert (!S_ISSOCK (S_IFBLK)); +#endif +static_assert (!S_ISSOCK (S_IFCHR)); +static_assert (!S_ISSOCK (S_IFDIR)); +static_assert (!S_ISSOCK (S_IFIFO)); +static_assert (!S_ISSOCK (S_IFREG)); +#ifdef S_IFLNK +static_assert (!S_ISSOCK (S_IFLNK)); +#endif +#ifdef S_IFSOCK +static_assert (S_ISSOCK (S_IFSOCK)); +#endif + +#ifdef S_IFBLK +static_assert (!S_ISDOOR (S_IFBLK)); +#endif +static_assert (!S_ISDOOR (S_IFCHR)); +static_assert (!S_ISDOOR (S_IFDIR)); +static_assert (!S_ISDOOR (S_IFIFO)); +static_assert (!S_ISDOOR (S_IFREG)); +#ifdef S_IFLNK +static_assert (!S_ISDOOR (S_IFLNK)); +#endif +#ifdef S_IFSOCK +static_assert (!S_ISDOOR (S_IFSOCK)); +#endif + +#ifdef S_IFBLK +static_assert (!S_ISMPB (S_IFBLK)); +#endif +static_assert (!S_ISMPB (S_IFCHR)); +static_assert (!S_ISMPB (S_IFDIR)); +static_assert (!S_ISMPB (S_IFIFO)); +static_assert (!S_ISMPB (S_IFREG)); +#ifdef S_IFLNK +static_assert (!S_ISMPB (S_IFLNK)); +#endif +#ifdef S_IFSOCK +static_assert (!S_ISMPB (S_IFSOCK)); +#endif + +#ifdef S_IFBLK +static_assert (!S_ISMPX (S_IFBLK)); +#endif +static_assert (!S_ISMPX (S_IFCHR)); +static_assert (!S_ISMPX (S_IFDIR)); +static_assert (!S_ISMPX (S_IFIFO)); +static_assert (!S_ISMPX (S_IFREG)); +#ifdef S_IFLNK +static_assert (!S_ISMPX (S_IFLNK)); +#endif +#ifdef S_IFSOCK +static_assert (!S_ISMPX (S_IFSOCK)); +#endif + +#ifdef S_IFBLK +static_assert (!S_ISNAM (S_IFBLK)); +#endif +static_assert (!S_ISNAM (S_IFCHR)); +static_assert (!S_ISNAM (S_IFDIR)); +static_assert (!S_ISNAM (S_IFIFO)); +static_assert (!S_ISNAM (S_IFREG)); +#ifdef S_IFLNK +static_assert (!S_ISNAM (S_IFLNK)); +#endif +#ifdef S_IFSOCK +static_assert (!S_ISNAM (S_IFSOCK)); +#endif + +#ifdef S_IFBLK +static_assert (!S_ISNWK (S_IFBLK)); +#endif +static_assert (!S_ISNWK (S_IFCHR)); +static_assert (!S_ISNWK (S_IFDIR)); +static_assert (!S_ISNWK (S_IFIFO)); +static_assert (!S_ISNWK (S_IFREG)); +#ifdef S_IFLNK +static_assert (!S_ISNWK (S_IFLNK)); +#endif +#ifdef S_IFSOCK +static_assert (!S_ISNWK (S_IFSOCK)); +#endif + +#ifdef S_IFBLK +static_assert (!S_ISPORT (S_IFBLK)); +#endif +static_assert (!S_ISPORT (S_IFCHR)); +static_assert (!S_ISPORT (S_IFDIR)); +static_assert (!S_ISPORT (S_IFIFO)); +static_assert (!S_ISPORT (S_IFREG)); +#ifdef S_IFLNK +static_assert (!S_ISPORT (S_IFLNK)); +#endif +#ifdef S_IFSOCK +static_assert (!S_ISPORT (S_IFSOCK)); +#endif + +#ifdef S_IFBLK +static_assert (!S_ISCTG (S_IFBLK)); +#endif +static_assert (!S_ISCTG (S_IFCHR)); +static_assert (!S_ISCTG (S_IFDIR)); +static_assert (!S_ISCTG (S_IFIFO)); +static_assert (!S_ISCTG (S_IFREG)); +#ifdef S_IFLNK +static_assert (!S_ISCTG (S_IFLNK)); +#endif +#ifdef S_IFSOCK +static_assert (!S_ISCTG (S_IFSOCK)); +#endif + +#ifdef S_IFBLK +static_assert (!S_ISOFD (S_IFBLK)); +#endif +static_assert (!S_ISOFD (S_IFCHR)); +static_assert (!S_ISOFD (S_IFDIR)); +static_assert (!S_ISOFD (S_IFIFO)); +static_assert (!S_ISOFD (S_IFREG)); +#ifdef S_IFLNK +static_assert (!S_ISOFD (S_IFLNK)); +#endif +#ifdef S_IFSOCK +static_assert (!S_ISOFD (S_IFSOCK)); +#endif + +#ifdef S_IFBLK +static_assert (!S_ISOFL (S_IFBLK)); +#endif +static_assert (!S_ISOFL (S_IFCHR)); +static_assert (!S_ISOFL (S_IFDIR)); +static_assert (!S_ISOFL (S_IFIFO)); +static_assert (!S_ISOFL (S_IFREG)); +#ifdef S_IFLNK +static_assert (!S_ISOFL (S_IFLNK)); +#endif +#ifdef S_IFSOCK +static_assert (!S_ISOFL (S_IFSOCK)); +#endif + +#ifdef S_IFBLK +static_assert (!S_ISWHT (S_IFBLK)); +#endif +static_assert (!S_ISWHT (S_IFCHR)); +static_assert (!S_ISWHT (S_IFDIR)); +static_assert (!S_ISWHT (S_IFIFO)); +static_assert (!S_ISWHT (S_IFREG)); +#ifdef S_IFLNK +static_assert (!S_ISWHT (S_IFLNK)); +#endif +#ifdef S_IFSOCK +static_assert (!S_ISWHT (S_IFSOCK)); +#endif + +/* POSIX 2008 requires traditional encoding of permission constants. */ +static_assert (S_IRWXU == 00700); +static_assert (S_IRUSR == 00400); +static_assert (S_IWUSR == 00200); +static_assert (S_IXUSR == 00100); +static_assert (S_IRWXG == 00070); +static_assert (S_IRGRP == 00040); +static_assert (S_IWGRP == 00020); +static_assert (S_IXGRP == 00010); +static_assert (S_IRWXO == 00007); +static_assert (S_IROTH == 00004); +static_assert (S_IWOTH == 00002); +static_assert (S_IXOTH == 00001); +static_assert (S_ISUID == 04000); +static_assert (S_ISGID == 02000); +static_assert (S_ISVTX == 01000); + +#if ((0 <= UTIME_NOW && UTIME_NOW < 1000000000) \ + || (0 <= UTIME_OMIT && UTIME_OMIT < 1000000000) \ + || UTIME_NOW == UTIME_OMIT) +invalid UTIME macros +#endif + +/* Check the existence of some types. */ +nlink_t t1; +off_t t2; +mode_t t3; + +struct timespec st; + +int +main (void) +{ + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sys_time.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sys_time.c new file mode 100644 index 00000000..5db5c2c0 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sys_time.c @@ -0,0 +1,34 @@ +/* Test of substitute. + Copyright (C) 2007, 2009-2024 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 . */ + +/* Written by Bruno Haible , 2007. */ + +#include + +#include + +/* Check that the 'struct timeval' type is defined. */ +struct timeval a; + +/* Check that a.tv_sec is wide enough to hold a time_t, ignoring + signedness issues. */ +typedef int verify_tv_sec_type[sizeof (time_t) <= sizeof (a.tv_sec) ? 1 : -1]; + +int +main (void) +{ + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sys_types.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sys_types.c new file mode 100644 index 00000000..f661a921 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sys_types.c @@ -0,0 +1,34 @@ +/* Test of substitute. + Copyright (C) 2011-2024 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 . */ + +/* Written by Bruno Haible , 2011. */ + +#include + +#include + +/* Check that the types are all defined. */ +pid_t t1; +size_t t2; +ssize_t t3; +off_t t4; +mode_t t5; + +int +main (void) +{ + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sys_uio.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sys_uio.c new file mode 100644 index 00000000..d371471f --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sys_uio.c @@ -0,0 +1,32 @@ +/* Test of substitute. + Copyright (C) 2011-2024 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 . */ + +/* Written by Eric Blake , 2011. */ + +#include + +#include + +/* Check that necessary types are defined. */ +size_t a; +ssize_t b; +struct iovec c; + +int +main (void) +{ + return a + b + !!c.iov_base + c.iov_len; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sys_wait.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sys_wait.c new file mode 100644 index 00000000..bdd64289 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sys_wait.c @@ -0,0 +1,47 @@ +/* Test of substitute. + Copyright (C) 2009-2024 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 . */ + +/* Written by Eric Blake , 2009. */ + +#include + +#include + +/* Check for existence of required types. */ +static pid_t a; + +#include "test-sys_wait.h" + +int +main (void) +{ + if (test_sys_wait_macros ()) + return 1; + +#if 0 + switch (WCONTINUED) + { + /* Gnulib doesn't guarantee these, yet. */ + case WCONTINUED: + case WEXITED: + case WNOWAIT: + case WSTOPPED: + break; + } +#endif + + return a ? 1 : 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sys_wait.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sys_wait.h new file mode 100644 index 00000000..5f2eec54 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-sys_wait.h @@ -0,0 +1,53 @@ +/* Test of macros shared between and . + Copyright (C) 2010-2024 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 . */ + +/* Written by Eric Blake , 2010. */ + +static int +test_sys_wait_macros (void) +{ + /* Check subset of macros that must be visible here. + Note that some of these macros are only portable when operating + on an lvalue. */ + int i; + for (i = 0; i < 0x8000; i = (i ? i << 1 : 1)) + { + /* POSIX requires that for all valid process statuses, that + exactly one of these three macros is true. But not all + possible 16-bit values map to valid process status. + Traditionally, 8 of the bits are for WIFEXITED, 7 of the bits + to tell between WIFSIGNALED and WIFSTOPPED, and either 0x80 + or 0x8000 to flag that core was also dumped. Since we don't + know which byte is WIFEXITED, we skip the both possible bits + that can signal core dump. */ + if (i == 0x80) + continue; + if (!!WIFSIGNALED (i) + !!WIFEXITED (i) + !!WIFSTOPPED (i) != 1) + return 1; + } + i = WEXITSTATUS (i) + WSTOPSIG (i) + WTERMSIG (i); + +#if 0 + switch (i) + { + /* Gnulib doesn't guarantee these, yet. */ + case WNOHANG: + case WUNTRACED: + break; + } +#endif + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-thread_create.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-thread_create.c new file mode 100644 index 00000000..89dc1c9e --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-thread_create.c @@ -0,0 +1,78 @@ +/* Test of gl_thread_create () macro. + Copyright (C) 2011-2024 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 . */ + +/* Written by Bruno Haible , 2011. */ + +#include + +#include "glthread/thread.h" + +#include +#include + +#include "macros.h" + +static gl_thread_t main_thread_before; +static gl_thread_t main_thread_after; +static gl_thread_t worker_thread; + +static int dummy; +static volatile int work_done; + +static void * +worker_thread_func (_GL_UNUSED void *arg) +{ + work_done = 1; + return &dummy; +} + +int +main () +{ + main_thread_before = gl_thread_self (); + + if (glthread_create (&worker_thread, worker_thread_func, NULL) == 0) + { + void *ret; + + /* Check that gl_thread_self () has the same value before than after the + first call to gl_thread_create (). */ + main_thread_after = gl_thread_self (); + ASSERT (memcmp (&main_thread_before, &main_thread_after, + sizeof (gl_thread_t)) + == 0); + + gl_thread_join (worker_thread, &ret); + + /* Check the return value of the thread. */ + ASSERT (ret == &dummy); + + /* Check that worker_thread_func () has finished executing. */ + ASSERT (work_done); + + return 0; + } + else + { +#if USE_ISOC_THREADS || USE_POSIX_THREADS || USE_ISOC_AND_POSIX_THREADS || USE_WINDOWS_THREADS + fputs ("glthread_create failed\n", stderr); + return 1; +#else + fputs ("Skipping test: multithreading not enabled\n", stderr); + return 77; +#endif + } +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-thread_self.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-thread_self.c new file mode 100644 index 00000000..e494613b --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-thread_self.c @@ -0,0 +1,39 @@ +/* Test of gl_thread_self () macro. + Copyright (C) 2011-2024 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 . */ + +/* Written by Bruno Haible , 2011. */ + +#include + +#include "glthread/thread.h" + +gl_thread_t main_thread; + +int +main () +{ + /* Check that gl_thread_self () can be used with just $(LIBTHREAD), not + $(LIBMULTITHREAD), i.e. in libraries that are multithread-safe but don't + create threads themselves. */ + /* This is not the case on AIX with --enable-threads=isoc+posix, because in + this case, $(LIBTHREAD) is empty whereas $(LIBMULTITHREAD) is '-lpthread'. + */ +#if !defined _AIX + main_thread = gl_thread_self (); +#endif + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-time-h.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-time-h.c new file mode 100644 index 00000000..01f9fff8 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-time-h.c @@ -0,0 +1,43 @@ +/* Test of substitute. + Copyright (C) 2007, 2009-2024 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 . */ + +/* Written by Bruno Haible , 2007. */ + +#include + +#include + +/* Check that the types are all defined. */ +struct timespec t1; +#if 0 +/* POSIX:2008 does not require pid_t in unconditionally, and indeed + it's missing on Mac OS X 10.5, FreeBSD 6.4, OpenBSD 4.9, mingw. */ +pid_t t2; +#endif + +/* Check that NULL can be passed through varargs as a pointer type, + per POSIX 2008. */ +static_assert (sizeof NULL == sizeof (void *)); + +/* Check that TIME_UTC is defined and a positive integer. */ +int t3 = TIME_UTC; +static_assert (TIME_UTC > 0); + +int +main (void) +{ + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-time.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-time.c new file mode 100644 index 00000000..752d4c0f --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-time.c @@ -0,0 +1,49 @@ +/* Test of time() function. + Copyright (C) 2023-2024 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 . */ + +/* Written by Bruno Haible. */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (time, time_t, (time_t *)); + +#include + +#include "macros.h" + +int +main (void) +{ + /* Check consistency of time() with gettimeofday().tv_sec. */ + struct timeval tv1; + struct timeval tv2; + time_t tt3; + + /* Wait until gettimeofday() reports an increase in tv_sec. */ + ASSERT (gettimeofday (&tv1, NULL) == 0); + do + ASSERT (gettimeofday (&tv2, NULL) == 0); + while (tv2.tv_sec == tv1.tv_sec); + /* We are now at the beginning of a second. Test whether time() reports + the new second or the previous one. */ + tt3 = time (NULL); + ASSERT (tt3 >= tv2.tv_sec); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-timespec.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-timespec.c new file mode 100644 index 00000000..2859ead6 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-timespec.c @@ -0,0 +1,166 @@ +/* Test timespec functions. + Copyright 2015-2024 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 . */ + +/* Written by Paul Eggert. */ + +#include + +#include "timespec.h" + +#include "intprops.h" +#include "macros.h" + +#include + +static struct { int s; int ns; } const prototype[] = + { + { INT_MIN, 0 }, + { INT_MIN, 1 }, + { INT_MIN, TIMESPEC_HZ - 1 }, + { INT_MIN + 1, 0 }, + { INT_MIN + 1, 1 }, + { INT_MIN + 1, TIMESPEC_HZ - 1 }, + { -1, 0 }, + { -1, 1 }, + { -1, TIMESPEC_HZ - 1 }, + { 0, 0 }, + { 0, 1 }, + { 0, TIMESPEC_HZ - 1 }, + { 1, 0 }, + { 1, 1 }, + { 1, TIMESPEC_HZ - 1 }, + { 1234567890, 0 }, + { 1234567890, 1 }, + { 1234567890, TIMESPEC_HZ - 1 }, + { INT_MAX - 1, 0 }, + { INT_MAX - 1, 1 }, + { INT_MAX - 1, TIMESPEC_HZ - 1 }, + { INT_MAX, 0 }, + { INT_MAX, 1 }, + { INT_MAX, TIMESPEC_HZ - 1 }, + { INT_MAX, 2 * TIMESPEC_HZ } + }; +enum { nprototypes = sizeof prototype / sizeof *prototype }; + +static bool +valid (struct timespec a) +{ + return 0 <= a.tv_nsec && a.tv_nsec < TIMESPEC_HZ; +} + +static int +sign (int i) +{ + return i < 0 ? -1 : 0 < i; +} + +static int +cmp (struct timespec a, struct timespec b) +{ + return sign (timespec_cmp (a, b)); +} + +static bool +eq (struct timespec a, struct timespec b) +{ + return timespec_cmp (a, b) == 0; +} + +static bool +extremal (struct timespec a) +{ + return ((a.tv_sec == TYPE_MINIMUM (time_t) && a.tv_nsec == 0) + || (a.tv_sec == TYPE_MAXIMUM (time_t) + && a.tv_nsec == TIMESPEC_HZ - 1)); +} + +int +main (void) +{ + int i, j, k; + struct timespec test[nprototypes + 1]; + int ntests; + int computed_hz = 1; + struct timespec prevroundtrip; + + test[0] = make_timespec (TYPE_MINIMUM (time_t), -1); + ntests = 1; + for (i = 0; i < nprototypes; i++) + { + int s = prototype[i].s; + if (TYPE_SIGNED (time_t) || 0 <= s) + { + time_t t = (s <= INT_MIN + 1 ? s - INT_MIN + TYPE_MINIMUM (time_t) + : INT_MAX - 1 <= s ? s - INT_MAX + TYPE_MAXIMUM (time_t) + : s); + test[ntests++] = make_timespec (t, prototype[i].ns); + } + } + + for (i = 0; i < LOG10_TIMESPEC_HZ; i++) + computed_hz *= 10; + ASSERT (computed_hz == TIMESPEC_HZ); + + for (i = 0; i < ntests; i++) + { + struct timespec a = test[i]; + + struct timespec roundtrip = dtotimespec (timespectod (a)); + if (i != 0) + ASSERT (cmp (prevroundtrip, roundtrip) <= 0); + prevroundtrip = roundtrip; + + ASSERT (sign (timespec_sign (a)) == cmp (a, make_timespec (0, 0))); + + if (valid (a)) + for (j = 0; j < ntests; j++) + { + struct timespec b = test[j]; + if (valid (b)) + { + struct timespec sum = timespec_add (a, b); + struct timespec diff = timespec_sub (a, b); + struct timespec rdiff = timespec_sub (b, a); + ASSERT (cmp (a, b) == sign (i - j)); + ASSERT (eq (sum, timespec_add (b, a))); + if (! extremal (sum)) + { + ASSERT (eq (a, timespec_sub (sum, b))); + ASSERT (eq (b, timespec_sub (sum, a))); + + for (k = 0; k < ntests; k++) + { + struct timespec c = test[k]; + if (valid (c)) + { + struct timespec sumbc = timespec_add (b, c); + if (! extremal (sumbc)) + ASSERT (eq (timespec_add (a, sumbc), + timespec_add (sum, c))); + } + } + } + if (! extremal (diff)) + ASSERT (eq (a, timespec_add (diff, b))); + if (! extremal (rdiff)) + ASSERT (eq (b, timespec_add (rdiff, a))); + + } + } + } + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-timespec_get.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-timespec_get.c new file mode 100644 index 00000000..765541a1 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-timespec_get.c @@ -0,0 +1,57 @@ +/* Test of timespec_get() function. + Copyright (C) 2021-2024 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 . */ + +/* Written by Bruno Haible. */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (timespec_get, int, (struct timespec *ts, int base)); + +#include "macros.h" + +int +main (void) +{ + struct timespec ts1; + time_t tt2; + struct timespec ts3; + time_t tt4; + + ASSERT (timespec_get (&ts1, TIME_UTC)); + tt2 = time (NULL); + ASSERT (timespec_get (&ts3, TIME_UTC)); + tt4 = time (NULL); + + /* Verify monotonicity of timespec_get(). */ + ASSERT (ts1.tv_sec < ts3.tv_sec + || (ts1.tv_sec == ts3.tv_sec && ts1.tv_nsec <= ts3.tv_nsec)); + + /* Verify monotonicity of time(). */ + ASSERT (tt2 <= tt4); + + /* Verify that the tv_sec field of the result is the same as time(NULL). */ + /* Note: It's here that the dependency to the 'time' module is needed. + Without it, this assertion would sometimes fail on glibc systems, see + https://sourceware.org/bugzilla/show_bug.cgi?id=30200 */ + ASSERT (ts1.tv_sec <= tt2); + ASSERT (tt2 <= ts3.tv_sec); + ASSERT (ts3.tv_sec <= tt4); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-uchar.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-uchar.c new file mode 100644 index 00000000..dfb368e0 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-uchar.c @@ -0,0 +1,57 @@ +/* Test of substitute. + Copyright (C) 2019-2024 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 . */ + +/* Written by Bruno Haible , 2019. */ + +#include + +#include + +/* Check that the types are defined. */ +mbstate_t a = { 0 }; +size_t b = 5; +char8_t c = 'x'; +char16_t d = 'y'; +char32_t e = 'z'; + +/* Check that char8_t, char16_t, and char32_t are unsigned types. */ +static_assert ((char8_t)(-1) >= 0); +static_assert ((char16_t)(-1) >= 0); +#if !defined __HP_cc +static_assert ((char32_t)(-1) >= 0); +#endif + +/* Check that char8_t is at least 8 bits wide. */ +static_assert ((char8_t)0xFF != (char8_t)0x7F); + +/* Check that char16_t is at least 16 bits wide. */ +static_assert ((char16_t)0xFFFF != (char16_t)0x7FFF); + +/* Check that char32_t is at least 31 bits wide. */ +static_assert ((char32_t)0x7FFFFFFF != (char32_t)0x3FFFFFFF); + +/* Check that _GL_SMALL_WCHAR_T is correctly defined. */ +#if _GL_SMALL_WCHAR_T +static_assert (sizeof (wchar_t) < sizeof (char32_t)); +#else +static_assert (sizeof (wchar_t) == sizeof (char32_t)); +#endif + +int +main (void) +{ + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-unistd.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-unistd.c new file mode 100644 index 00000000..931d65e4 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-unistd.c @@ -0,0 +1,54 @@ +/* Test of substitute. + Copyright (C) 2007, 2009-2024 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 . */ + +/* Written by Bruno Haible , 2007. */ + +#include + +#include + +/* Check that NULL can be passed through varargs as a pointer type, + per POSIX 2008. */ +static_assert (sizeof NULL == sizeof (void *)); + +/* Check that the various SEEK_* macros are defined. */ +int sk[] = { SEEK_CUR, SEEK_END, SEEK_SET }; + +/* Check that the various *_FILENO macros are defined. */ +#if ! (defined STDIN_FILENO \ + && (STDIN_FILENO + STDOUT_FILENO + STDERR_FILENO == 3)) +missing or broken *_FILENO macros +#endif + +/* Check that the types are all defined. */ +size_t t1; +ssize_t t2; +#ifdef TODO /* Not implemented in gnulib yet */ +uid_t t3; +gid_t t4; +#endif +off_t t5; +pid_t t6; +#ifdef TODO +useconds_t t7; +intptr_t t8; +#endif + +int +main (void) +{ + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-unlink.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-unlink.c new file mode 100644 index 00000000..f857acbf --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-unlink.c @@ -0,0 +1,48 @@ +/* Tests of unlink. + Copyright (C) 2009-2024 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 . */ + +/* Written by Eric Blake , 2009. */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (unlink, int, (char const *)); + +#include +#include +#include +#include +#include +#include + +#include "unlinkdir.h" +#include "ignore-value.h" +#include "macros.h" + +#define BASE "test-unlink.t" + +#include "test-unlink.h" + +int +main (void) +{ + /* Remove any leftovers from a previous partial run. */ + ignore_value (system ("rm -rf " BASE "*")); + + return test_unlink_func (unlink, true); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-unlink.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-unlink.h new file mode 100644 index 00000000..800537db --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-unlink.h @@ -0,0 +1,86 @@ +/* Tests of unlink. + Copyright (C) 2009-2024 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 . */ + +/* Written by Eric Blake , 2009. */ + +/* This file is designed to test both unlink(n) and + unlinkat(AT_FDCWD,n,0). FUNC is the function to test. Assumes + that BASE and ASSERT are already defined, and that appropriate + headers are already included. If PRINT, then warn before returning + status 77 when symlinks are unsupported. */ + +static int +test_unlink_func (int (*func) (char const *name), bool print) +{ + /* Setup. */ + ASSERT (mkdir (BASE "dir", 0700) == 0); + ASSERT (close (creat (BASE "dir/file", 0600)) == 0); + + /* Basic error conditions. */ + errno = 0; + ASSERT (func ("") == -1); + ASSERT (errno == ENOENT); + errno = 0; + ASSERT (func (BASE "nosuch") == -1); + ASSERT (errno == ENOENT); + errno = 0; + ASSERT (func (BASE "nosuch/") == -1); + ASSERT (errno == ENOENT); + /* Resulting errno after directories is rather varied across + implementations (EPERM, EINVAL, EACCES, EBUSY, EISDIR, ENOTSUP); + however, we must be careful to not attempt unlink on a directory + unless we know it must fail. */ + if (cannot_unlink_dir ()) + { + ASSERT (func (".") == -1); + ASSERT (func ("..") == -1); + ASSERT (func ("/") == -1); + ASSERT (func (BASE "dir") == -1); + ASSERT (mkdir (BASE "dir1", 0700) == 0); + ASSERT (func (BASE "dir1") == -1); + ASSERT (rmdir (BASE "dir1") == 0); + } + errno = 0; + ASSERT (func (BASE "dir/file/") == -1); + ASSERT (errno == ENOTDIR); + + /* Test symlink behavior. Specifying trailing slash will attempt + unlink of a directory, so only attempt it if we know it must + fail. */ + if (symlink (BASE "dir", BASE "link") != 0) + { + ASSERT (func (BASE "dir/file") == 0); + ASSERT (rmdir (BASE "dir") == 0); + if (print) + fputs ("skipping test: symlinks not supported on this file system\n", + stderr); + return 77; + } + if (cannot_unlink_dir ()) + ASSERT (func (BASE "link/") == -1); + ASSERT (func (BASE "link") == 0); + ASSERT (symlink (BASE "dir/file", BASE "link") == 0); + errno = 0; + ASSERT (func (BASE "link/") == -1); + ASSERT (errno == ENOTDIR); + /* Order here proves unlink of a symlink does not follow through to + the file. */ + ASSERT (func (BASE "link") == 0); + ASSERT (func (BASE "dir/file") == 0); + ASSERT (rmdir (BASE "dir") == 0); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-unlinkat.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-unlinkat.c new file mode 100644 index 00000000..4c4cf752 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-unlinkat.c @@ -0,0 +1,94 @@ +/* Tests of unlinkat. + Copyright (C) 2009-2024 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 . */ + +/* Written by Eric Blake , 2009. */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (unlinkat, int, (int, char const *, int)); + +#include +#include +#include +#include +#include + +#include "unlinkdir.h" +#include "ignore-value.h" +#include "macros.h" + +#define BASE "test-unlinkat.t" + +#include "test-rmdir.h" +#include "test-unlink.h" + +static int dfd = AT_FDCWD; + +/* Wrapper around unlinkat to test rmdir behavior. */ +static int +rmdirat (char const *name) +{ + return unlinkat (dfd, name, AT_REMOVEDIR); +} + +/* Wrapper around unlinkat to test unlink behavior. */ +static int +unlinker (char const *name) +{ + return unlinkat (dfd, name, 0); +} + +int +main () +{ + /* FIXME: Add tests of fd other than ".". */ + int result1; + int result2; + + /* Remove any leftovers from a previous partial run. */ + ignore_value (system ("rm -rf " BASE "*")); + + /* Test behaviour for invalid file descriptors. */ + { + errno = 0; + ASSERT (unlinkat (-1, "foo", 0) == -1); + ASSERT (errno == EBADF); + } + { + close (99); + errno = 0; + ASSERT (unlinkat (99, "foo", 0) == -1); + ASSERT (errno == EBADF); + } + + result1 = test_rmdir_func (rmdirat, false); + result2 = test_unlink_func (unlinker, false); + ASSERT (result1 == result2); + dfd = open (".", O_RDONLY); + ASSERT (0 <= dfd); + result2 = test_rmdir_func (rmdirat, false); + ASSERT (result1 == result2); + result2 = test_unlink_func (unlinker, false); + ASSERT (result1 == result2); + ASSERT (close (dfd) == 0); + if (result1 == 77) + fputs ("skipping test: symlinks not supported on this file system\n", + stderr); + return result1; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-unsetenv.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-unsetenv.c new file mode 100644 index 00000000..4e6a19ad --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-unsetenv.c @@ -0,0 +1,62 @@ +/* Tests of unsetenv. + Copyright (C) 2009-2024 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 . */ + +/* Written by Eric Blake , 2009. */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (unsetenv, int, (char const *)); + +#include +#include +#include + +#include "macros.h" + +int +main (void) +{ + /* Static to pacify gcc -Wanalyzer-putenv-of-auto-var. */ + static char entry[] = "b=2"; + + /* Test removal when multiple entries present. */ + ASSERT (putenv ((char *) "a=1") == 0); + ASSERT (putenv (entry) == 0); + entry[0] = 'a'; /* Unspecified what getenv("a") would be at this point. */ + ASSERT (unsetenv ("a") == 0); /* Both entries will be removed. */ + ASSERT (getenv ("a") == NULL); + ASSERT (unsetenv ("a") == 0); + + /* Required to fail with EINVAL. */ + errno = 0; + ASSERT (unsetenv ("") == -1); + ASSERT (errno == EINVAL); + errno = 0; + ASSERT (unsetenv ("a=b") == -1); + ASSERT (errno == EINVAL); +#if 0 + /* glibc and gnulib's implementation guarantee this, but POSIX no + longer requires it: http://austingroupbugs.net/view.php?id=185 */ + errno = 0; + ASSERT (unsetenv (NULL) == -1); + ASSERT (errno == EINVAL); +#endif + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-update-copyright.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-update-copyright.sh new file mode 100755 index 00000000..b2a7f2df --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-update-copyright.sh @@ -0,0 +1,611 @@ +#!/bin/sh +# Test suite for update-copyright. +# Copyright (C) 2009-2024 Free Software Foundation, Inc. +# This file is part of the GNUlib Library. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +diffout=`diff -u /dev/null /dev/null 2>&1` +if test x"$diffout" = x"" && test $? -eq 0; then + compare() { diff -u "$@"; } +else + compare() { cmp "$@"; } +fi + +# Ensure the update-copyright program gets found. +PATH=$abs_aux_dir:$PATH +export PATH + +TMP_BASE=update-copyright.test +trap 'rm -f $TMP_BASE*' EXIT HUP INT QUIT TERM + +## --------------------------------- ## +## Skip if user does not have perl. ## +## --------------------------------- ## + +TMP=$TMP_BASE +s=$TMP-script +cat <<\EOF > $s +#!/bin/sh +#! -*-perl-*- +# This is a prologue that allows to run a perl script as an executable +# on systems that are compliant to a POSIX version before POSIX:2017. +# On such systems, the usual invocation of an executable through execlp() +# or execvp() fails with ENOEXEC if it is a script that does not start +# with a #! line. The script interpreter mentioned in the #! line has +# to be /bin/sh, because on GuixSD systems that is the only program that +# has a fixed file name. The second line is essential for perl and is +# also useful for editing this file in Emacs. The next two lines below +# are valid code in both sh and perl. When executed by sh, they re-execute +# the script through the perl program found in $PATH. The '-x' option +# is essential as well; without it, perl would re-execute the script +# through /bin/sh. When executed by perl, the next two lines are a no-op. +eval 'exec perl -wSx -pi "$0" "$@"' + if 0; + +s/a/b/ +EOF +chmod a+x $s +echo a > $TMP-in +./$s $TMP-in 2>/dev/null && test b = "`cat $TMP-in 2>/dev/null`" || + { + printf '%s\n' "$0: skipping this test;" \ + 'your system has insufficient support for Perl' 1>&2 + exit 77 + } + +# Skip this test if Perl is too old. FIXME: 5.8.0 is just a guess. +# We have a report that 5.6.1 is inadequate and that 5.8.0 works. +perl -e 'require 5.8.0' || { + echo "$0: skipping this test; Perl version is too old" 1>&2 + exit 77 +} + +# Do not let a different envvar setting perturb results. +UPDATE_COPYRIGHT_MAX_LINE_LENGTH=72 +export UPDATE_COPYRIGHT_MAX_LINE_LENGTH + +# This assignment to 'ight' is so that data can contain strings +# like "Copy$ight 2024 Free Software Foundation, Inc." without being +# mistakenly updated by "cd .. && make update-copyright". +ight=right + +## ----------------------------- ## +## Examples from documentation. ## +## ----------------------------- ## + +TMP=$TMP_BASE-ex +cat > $TMP-1 < $TMP-2 < $TMP-3 < $TMP-4 < $TMP-5 < $TMP-6 < $TMP-7 < $TMP-8 < $TMP-stdout 2> $TMP-stderr +compare /dev/null $TMP-stdout || exit 1 +compare - $TMP-stderr < $TMP-stdout 2> $TMP-stderr +compare /dev/null $TMP-stdout || exit 1 +compare - $TMP-stderr < $TMP-stdout 2> $TMP-stderr +compare /dev/null $TMP-stdout || exit 1 +compare - $TMP-stderr < $TMP.1 < $TMP.2 < $TMP.3 < $TMP.4 < $TMP-stdout 2> $TMP-stderr +compare /dev/null $TMP-stdout || exit 1 +compare /dev/null $TMP-stderr || exit 1 +compare - $TMP.1 < $TMP < $TMP-stdout 2> $TMP-stderr +compare /dev/null $TMP-stdout || exit 1 +compare /dev/null $TMP-stderr || exit 1 +compare - $TMP < $TMP-stdout 2> $TMP-stderr +compare /dev/null $TMP-stdout || exit 1 +compare /dev/null $TMP-stderr || exit 1 +compare - $TMP < $TMP < $TMP-stdout 2> $TMP-stderr +compare /dev/null $TMP-stdout || exit 1 +compare /dev/null $TMP-stderr || exit 1 +compare - $TMP < $TMP < $TMP-stdout 2> $TMP-stderr +compare /dev/null $TMP-stdout || exit 1 +compare /dev/null $TMP-stderr || exit 1 +compare - $TMP < $TMP-stdout 2> $TMP-stderr +compare /dev/null $TMP-stdout || exit 1 +compare /dev/null $TMP-stderr || exit 1 +compare - $TMP < $TMP < $TMP-stdout 2> $TMP-stderr +compare /dev/null $TMP-stdout || exit 1 +compare - $TMP-stderr < $TMP < $TMP-stdout 2> $TMP-stderr +compare /dev/null $TMP-stdout || exit 1 +compare - $TMP-stderr < $TMP < $TMP-stdout 2> $TMP-stderr +compare /dev/null $TMP-stdout || exit 1 +compare /dev/null $TMP-stderr || exit 1 +compare - $TMP < $TMP-stdout 2> $TMP-stderr +compare /dev/null $TMP-stdout || exit 1 +compare /dev/null $TMP-stderr || exit 1 +compare - $TMP < $TMP < $TMP-stdout 2> $TMP-stderr +compare /dev/null $TMP-stdout || exit 1 +compare /dev/null $TMP-stderr || exit 1 +compare - $TMP < $TMP-stdout 2> $TMP-stderr +compare /dev/null $TMP-stdout || exit 1 +compare /dev/null $TMP-stderr || exit 1 +compare - $TMP < $TMP-stdout 2> $TMP-stderr +compare /dev/null $TMP-stdout || exit 1 +compare /dev/null $TMP-stderr || exit 1 +compare - $TMP < $TMP < $TMP-stdout 2> $TMP-stderr +compare /dev/null $TMP-stdout || exit 1 +compare /dev/null $TMP-stderr || exit 1 +tr @ '\015' > $TMP-exp < $TMP < $TMP-stdout 2> $TMP-stderr +compare /dev/null $TMP-stdout || exit 1 +compare /dev/null $TMP-stderr || exit 1 +compare - $TMP < $TMP.star < $TMP.space < $TMP.single-line < $TMP.single-line-wrapped < $TMP.extra-text-star < $TMP.extra-text-space < $TMP.two-digit-final-is-substr-of-first < $TMP-stdout 2> $TMP-stderr +compare /dev/null $TMP-stdout || exit 1 +compare /dev/null $TMP-stderr || exit 1 +compare - $TMP.star <. */ + +/* Written by Bruno Haible , 2007. */ + +#include + +#include "vasnprintf.h" + +#include +#include +#include + +#include "macros.h" + +static void +test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...)) +{ + char buf[8]; + int size; + + for (size = 0; size <= 8; size++) + { + size_t length = size; + char *result = my_asnprintf (NULL, &length, "%d", 12345); + ASSERT (result != NULL); + ASSERT (strcmp (result, "12345") == 0); + ASSERT (length == 5); + free (result); + } + + for (size = 0; size <= 8; size++) + { + size_t length; + char *result; + + memcpy (buf, "DEADBEEF", 8); + length = size; + result = my_asnprintf (buf, &length, "%d", 12345); + ASSERT (result != NULL); + ASSERT (strcmp (result, "12345") == 0); + ASSERT (length == 5); + if (size < 5 + 1) + ASSERT (result != buf); + ASSERT (memcmp (buf + size, &"DEADBEEF"[size], 8 - size) == 0); + if (result != buf) + free (result); + } + + /* Note: This test assumes IEEE 754 representation of 'double' floats. */ + for (size = 0; size <= 8; size++) + { + size_t length; + char *result; + + memcpy (buf, "DEADBEEF", 8); + length = size; + result = my_asnprintf (buf, &length, "%2.0f", 1.6314159265358979e+125); + ASSERT (result != NULL); + /* The exact result and the result on glibc systems is + 163141592653589790215729350939528493057529598899734151772468186268423257777068536614838678161083520756952076273094236944990208 + On Cygwin, the result is + 163141592653589790215729350939528493057529600000000000000000000000000000000000000000000000000000000000000000000000000000000000 + On HP-UX 11.31 / hppa and IRIX 6.5, the result is + 163141592653589790000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 + */ + ASSERT (strlen (result) == 126); + ASSERT (memcmp (result, "163141592653589790", 18) == 0); + ASSERT (length == 126); + if (size < 126 + 1) + ASSERT (result != buf); + ASSERT (memcmp (buf + size, &"DEADBEEF"[size], 8 - size) == 0); + if (result != buf) + free (result); + } +} + +static char * +my_asnprintf (char *resultbuf, size_t *lengthp, const char *format, ...) +{ + va_list args; + char *ret; + + va_start (args, format); + ret = vasnprintf (resultbuf, lengthp, format, args); + va_end (args); + return ret; +} + +static void +test_vasnprintf () +{ + test_function (my_asnprintf); +} + +static void +test_asnprintf () +{ + test_function (asnprintf); +} + +int +main () +{ + test_vasnprintf (); + test_asnprintf (); + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-vc-list-files-cvs.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-vc-list-files-cvs.sh new file mode 100755 index 00000000..64b54c0e --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-vc-list-files-cvs.sh @@ -0,0 +1,53 @@ +#!/bin/sh +# Unit tests for vc-list-files +# Copyright (C) 2008-2024 Free Software Foundation, Inc. +# This file is part of the GNUlib Library. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . */ + +: "${srcdir=.}" +. "$srcdir/init.sh"; path_prepend_ . + +tmpdir=vc-cvs +repo=`pwd`/$tmpdir/repo + +fail=0 +for i in with-cvsu without; do + # On the first iteration, test using cvsu, if it's in your path. + # On the second iteration, ensure that cvsu fails, so we'll + # exercise the awk-using code. + if test $i = without; then + printf '%s\n' '#!/bin/sh' 'exit 1' > cvsu + chmod a+x cvsu + PATH=`pwd`:$PATH + export PATH + fi + ok=0 + mkdir $tmpdir && cd $tmpdir && + # without cvs, skip the test + { ( cvs -Q -d "$repo" init ) > /dev/null 2>&1 \ + || skip_ "cvs not found in PATH"; } && + mkdir w && cd w && + mkdir d && + touch d/a b c && + cvs -Q -d "$repo" import -m imp m M M0 && + cvs -Q -d "$repo" co m && cd m && + printf '%s\n' b c d/a > expected && + $BOURNE_SHELL "$abs_aux_dir/vc-list-files" | sort > actual && + compare expected actual && + ok=1 + test $ok = 0 && fail=1 +done + +Exit $fail diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-vc-list-files-git.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-vc-list-files-git.sh new file mode 100755 index 00000000..7bee9bed --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-vc-list-files-git.sh @@ -0,0 +1,49 @@ +#!/bin/sh +# Unit tests for vc-list-files +# Copyright (C) 2008-2024 Free Software Foundation, Inc. +# This file is part of the GNUlib Library. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . */ + +: "${srcdir=.}" +. "$srcdir/init.sh"; path_prepend_ . + +tmpdir=vc-git-$$ +GIT_DIR= GIT_WORK_TREE=; unset GIT_DIR GIT_WORK_TREE + +# Ignore local git configurations that may interact badly with +# commands below. For example, if the user has set +# commit.gpgsign=true in ~/.gitconfig the 'git commit' below will +# require a OpenPGP private key operation which trigger PIN prompts +# and unwanted hardware access on the developer's machine. +GIT_CONFIG_GLOBAL=/dev/null; export GIT_CONFIG_GLOBAL + +fail=1 +mkdir $tmpdir && cd $tmpdir && + # without git, skip the test + # The double use of 'exit' is needed for the reference to $? inside the trap. + { ( git init -q ) > /dev/null 2>&1 \ + || skip_ "git not found in PATH"; } && + mkdir d && + touch d/a b c && + git config user.email "you@example.com" && + git config user.name "Your Name" && + git add . > /dev/null && + git commit -q -a -m log && + printf '%s\n' b c d/a > expected && + $BOURNE_SHELL "$abs_aux_dir/vc-list-files" > actual && + compare expected actual && + fail=0 + +Exit $fail diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-verify-try.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-verify-try.c new file mode 100644 index 00000000..d16fb938 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-verify-try.c @@ -0,0 +1,21 @@ +/* Test the "verify" module. + + Copyright (C) 2017-2024 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 . */ + +/* This is a separate source file, so that the execution of test-verify.sh + does not interfere with the building of the 'test-verify' program. */ + +#include "test-verify.c" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-verify.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-verify.c new file mode 100644 index 00000000..1d8f43c7 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-verify.c @@ -0,0 +1,119 @@ +/* Test the "verify" module. + + Copyright (C) 2005, 2009-2024 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 . */ + +/* Written by Bruno Haible. */ + +#include + +#include "verify.h" + +#ifndef EXP_FAIL +# define EXP_FAIL 0 +#endif + +/* ======================= Test verify, verify_expr ======================= */ + +int gx; +enum { A, B, C }; + +#if EXP_FAIL == 1 +verify (gx >= 0); /* should give ERROR: non-constant expression */ +#endif +verify (C == 2); /* should be ok */ +#if EXP_FAIL == 2 +verify (1 + 1 == 3); /* should give ERROR */ +#endif +verify (1 == 1); verify (1 == 1); /* should be ok */ + +enum +{ + item = verify_expr (1 == 1, 10 * 0 + 17) /* should be ok */ +}; + +static int +function (int n) +{ +#if EXP_FAIL == 3 + verify (n >= 0); /* should give ERROR: non-constant expression */ +#endif + verify (C == 2); /* should be ok */ +#if EXP_FAIL == 4 + verify (1 + 1 == 3); /* should give ERROR */ +#endif + verify (1 == 1); verify (1 == 1); /* should be ok */ + + if (n) + return ((void) verify_expr (1 == 1, 1), verify_expr (1 == 1, 8)); /* should be ok */ +#if EXP_FAIL == 5 + return verify_expr (1 == 2, 5); /* should give ERROR */ +#endif + return 0; +} + +/* ============================== Test assume ============================== */ + +static int +f (int a) +{ + return a; +} + +typedef struct { unsigned int context : 4; unsigned int halt : 1; } state; + +void test_assume_expressions (state *s); +int test_assume_optimization (int x); +_Noreturn void test_assume_noreturn (void); + +void +test_assume_expressions (state *s) +{ + /* Check that 'assume' accepts a function call, even of a non-const + function. */ + assume (f (1)); + /* Check that 'assume' accepts a bit-field expression. */ + assume (s->halt); +} + +int +test_assume_optimization (int x) +{ + /* Check that the compiler uses 'assume' for optimization. + This function, when compiled with optimization, should have code + equivalent to + return x + 3; + Use 'objdump --disassemble test-verify.o' to verify this. */ + assume (x >= 4); + return (x > 1 ? x + 3 : 2 * x + 10); +} + +_Noreturn void +test_assume_noreturn (void) +{ + /* Check that the compiler's data-flow analysis recognizes 'assume (0)'. + This function should not elicit a warning. */ + assume (0); +} + +/* ============================== Main ===================================== */ +int +main (void) +{ + state s = { 0, 1 }; + test_assume_expressions (&s); + test_assume_optimization (5); + return !(function (0) == 0 && function (1) == 8); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-verify.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-verify.sh new file mode 100755 index 00000000..1e75d55a --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-verify.sh @@ -0,0 +1,25 @@ +#!/bin/sh +. "${srcdir=.}/init.sh" + +# We are not interested in triggering bugs in the compilers and tools +# (such as gcc 4.3.1 on openSUSE 11.0). +unset MALLOC_PERTURB_ + +# Rather than figure out how to invoke the compiler with the right +# include path ourselves, we let make do it: +(cd "$initial_cwd_" \ + && rm -f test-verify-try.o \ + && $MAKE test-verify-try.o >/dev/null 2>&1) \ + || skip_ "cannot compile error-free" + +# Now, prove that we encounter all expected compilation failures: +: >out +: >err +for i in 1 2 3 4 5; do + (cd "$initial_cwd_" + rm -f test-verify-try.o + $MAKE CFLAGS=-DEXP_FAIL=$i test-verify-try.o) >>out 2>>err \ + && { warn_ "compiler didn't detect verification failure $i"; fail=1; } +done + +Exit $fail diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-version-etc.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-version-etc.c new file mode 100644 index 00000000..8662d24d --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-version-etc.c @@ -0,0 +1,31 @@ +/* Test suite for version-etc. + Copyright (C) 2009-2024 Free Software Foundation, Inc. + This file is part of the GNUlib Library. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include + +#include "version-etc.h" + + +#define AUTHORS "Sergey Poznyakoff", "Eric Blake" + +int +main (_GL_UNUSED int argc, char **argv) +{ + version_etc (stdout, "test-version-etc", "dummy", "0", AUTHORS, + (const char *) NULL); + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-version-etc.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-version-etc.sh new file mode 100755 index 00000000..9b4b631a --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-version-etc.sh @@ -0,0 +1,45 @@ +#! /bin/sh +# Test suite for version-etc. +# Copyright (C) 2009-2024 Free Software Foundation, Inc. +# This file is part of the GNUlib Library. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ . + +TMP=ve-expected.tmp +LC_ALL=C +export LC_ALL +ERR=0 + +cat > $TMP <. +This is free software: you are free to change and redistribute it. +There is NO WARRANTY, to the extent permitted by law. + +Written by Sergey Poznyakoff and Eric Blake. +EOT + +${CHECKER} test-version-etc${EXEEXT} --version | + sed '1s/test-version-etc (.*) .*/test-version-etc (PROJECT) VERSION/ + /^Packaged by/d + 2,3 s/Copyright (C) [0-9]\{4,4\}/COPYRIGHT/' | + tr -d '\015' | + compare $TMP - || ERR=1 + +rm $TMP + +exit $ERR diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-wchar.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-wchar.c new file mode 100644 index 00000000..663a5a4e --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-wchar.c @@ -0,0 +1,35 @@ +/* Test of substitute. + Copyright (C) 2007-2024 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 . */ + +/* Written by Bruno Haible , 2007. */ + +#include + +#include + +/* Check that the types wchar_t and wint_t are defined. */ +wchar_t a = 'c'; +wint_t b = 'x'; + +/* Check that NULL can be passed through varargs as a pointer type, + per POSIX 2008. */ +static_assert (sizeof NULL == sizeof (void *)); + +int +main (void) +{ + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-wcrtomb-w32-2.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-wcrtomb-w32-2.sh new file mode 100755 index 00000000..b01c5436 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-wcrtomb-w32-2.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Test a CP1252 locale. +${CHECKER} ./test-wcrtomb-w32${EXEEXT} French_France 1252 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-wcrtomb-w32-3.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-wcrtomb-w32-3.sh new file mode 100755 index 00000000..5481634d --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-wcrtomb-w32-3.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Test a CP1256 locale. +${CHECKER} ./test-wcrtomb-w32${EXEEXT} "Arabic_Saudi Arabia" 1256 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-wcrtomb-w32-4.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-wcrtomb-w32-4.sh new file mode 100755 index 00000000..fb04e583 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-wcrtomb-w32-4.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Test some UTF-8 locales. +${CHECKER} ./test-wcrtomb-w32${EXEEXT} French_France Japanese_Japan Chinese_Taiwan Chinese_China 65001 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-wcrtomb-w32-5.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-wcrtomb-w32-5.sh new file mode 100755 index 00000000..f35879da --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-wcrtomb-w32-5.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Test a CP932 locale. +${CHECKER} ./test-wcrtomb-w32${EXEEXT} Japanese_Japan 932 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-wcrtomb-w32-6.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-wcrtomb-w32-6.sh new file mode 100755 index 00000000..8eec6cbc --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-wcrtomb-w32-6.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Test a CP950 locale. +${CHECKER} ./test-wcrtomb-w32${EXEEXT} Chinese_Taiwan 950 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-wcrtomb-w32-7.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-wcrtomb-w32-7.sh new file mode 100755 index 00000000..fd47d6fa --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-wcrtomb-w32-7.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Test a CP936 locale. +${CHECKER} ./test-wcrtomb-w32${EXEEXT} Chinese_China 936 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-wcrtomb-w32-8.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-wcrtomb-w32-8.sh new file mode 100755 index 00000000..802237d1 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-wcrtomb-w32-8.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Test a GB18030 locale. +${CHECKER} ./test-wcrtomb-w32${EXEEXT} Chinese_China 54936 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-wcrtomb-w32.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-wcrtomb-w32.c new file mode 100644 index 00000000..4be9a0df --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-wcrtomb-w32.c @@ -0,0 +1,337 @@ +/* Test of conversion of wide character to multibyte character. + Copyright (C) 2008-2024 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 . */ + +#include + +#include + +#include +#include +#include +#include + +#include "localcharset.h" +#include "macros.h" + +#if defined _WIN32 && !defined __CYGWIN__ + +static int +test_one_locale (const char *name, int codepage) +{ + char buf[64]; + size_t ret; + +# if 1 + /* Portable code to set the locale. */ + { + char name_with_codepage[1024]; + + sprintf (name_with_codepage, "%s.%d", name, codepage); + + /* Set the locale. */ + if (setlocale (LC_ALL, name_with_codepage) == NULL) + return 77; + } +# else + /* Hacky way to set a locale.codepage combination that setlocale() refuses + to set. */ + { + /* Codepage of the current locale, set with setlocale(). + Not necessarily the same as GetACP(). */ + extern __declspec(dllimport) unsigned int __lc_codepage; + + /* Set the locale. */ + if (setlocale (LC_ALL, name) == NULL) + return 77; + + /* Clobber the codepage and MB_CUR_MAX, both set by setlocale(). */ + __lc_codepage = codepage; + switch (codepage) + { + case 1252: + case 1256: + MB_CUR_MAX = 1; + break; + case 932: + case 950: + case 936: + MB_CUR_MAX = 2; + break; + case 54936: + case 65001: + MB_CUR_MAX = 4; + break; + } + + /* Test whether the codepage is really available. */ + { + mbstate_t state; + wchar_t wc; + + memset (&state, '\0', sizeof (mbstate_t)); + if (mbrtowc (&wc, " ", 1, &state) == (size_t)(-1)) + return 77; + } + } +# endif + + /* Test NUL character. */ + { + buf[0] = 'x'; + ret = wcrtomb (buf, 0, NULL); + ASSERT (ret == 1); + ASSERT (buf[0] == '\0'); + } + + /* Test single bytes. */ + { + int c; + + for (c = 0; c < 0x100; c++) + switch (c) + { + case '\t': case '\v': case '\f': + case ' ': case '!': case '"': case '#': case '%': + case '&': case '\'': case '(': case ')': case '*': + case '+': case ',': case '-': case '.': case '/': + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + case ':': case ';': case '<': case '=': case '>': + case '?': + case 'A': case 'B': case 'C': case 'D': case 'E': + case 'F': case 'G': case 'H': case 'I': case 'J': + case 'K': case 'L': case 'M': case 'N': case 'O': + case 'P': case 'Q': case 'R': case 'S': case 'T': + case 'U': case 'V': case 'W': case 'X': case 'Y': + case 'Z': + case '[': case '\\': case ']': case '^': case '_': + case 'a': case 'b': case 'c': case 'd': case 'e': + case 'f': case 'g': case 'h': case 'i': case 'j': + case 'k': case 'l': case 'm': case 'n': case 'o': + case 'p': case 'q': case 'r': case 's': case 't': + case 'u': case 'v': case 'w': case 'x': case 'y': + case 'z': case '{': case '|': case '}': case '~': + /* c is in the ISO C "basic character set". */ + ret = wcrtomb (buf, btowc (c), NULL); + ASSERT (ret == 1); + ASSERT (buf[0] == (char) c); + break; + } + } + + /* Test special calling convention, passing a NULL pointer. */ + { + ret = wcrtomb (NULL, '\0', NULL); + ASSERT (ret == 1); + ret = wcrtomb (NULL, btowc ('x'), NULL); + ASSERT (ret == 1); + } + + switch (codepage) + { + case 1252: + /* Locale encoding is CP1252, an extension of ISO-8859-1. */ + { + /* Convert "B\374\337er": "Büßer" */ + memset (buf, 'x', 8); + ret = wcrtomb (buf, 0x00FC, NULL); + ASSERT (ret == 1); + ASSERT (memcmp (buf, "\374", 1) == 0); + ASSERT (buf[1] == 'x'); + + memset (buf, 'x', 8); + ret = wcrtomb (buf, 0x00DF, NULL); + ASSERT (ret == 1); + ASSERT (memcmp (buf, "\337", 1) == 0); + ASSERT (buf[1] == 'x'); + } + return 0; + + case 1256: + /* Locale encoding is CP1256, not the same as ISO-8859-6. */ + { + /* Convert "x\302\341\346y": "xآلوy" */ + memset (buf, 'x', 8); + ret = wcrtomb (buf, 0x0622, NULL); + ASSERT (ret == 1); + ASSERT (memcmp (buf, "\302", 1) == 0); + ASSERT (buf[1] == 'x'); + + memset (buf, 'x', 8); + ret = wcrtomb (buf, 0x0644, NULL); + ASSERT (ret == 1); + ASSERT (memcmp (buf, "\341", 1) == 0); + ASSERT (buf[1] == 'x'); + + memset (buf, 'x', 8); + ret = wcrtomb (buf, 0x0648, NULL); + ASSERT (ret == 1); + ASSERT (memcmp (buf, "\346", 1) == 0); + ASSERT (buf[1] == 'x'); + } + return 0; + + case 65001: + /* Locale encoding is CP65001 = UTF-8. */ + if (strcmp (locale_charset (), "UTF-8") != 0) + return 77; + { + /* Convert "B\303\274\303\237er": "Büßer" */ + memset (buf, 'x', 8); + ret = wcrtomb (buf, 0x00FC, NULL); + ASSERT (ret == 2); + ASSERT (memcmp (buf, "\303\274", 2) == 0); + ASSERT (buf[2] == 'x'); + + memset (buf, 'x', 8); + ret = wcrtomb (buf, 0x00DF, NULL); + ASSERT (ret == 2); + ASSERT (memcmp (buf, "\303\237", 2) == 0); + ASSERT (buf[2] == 'x'); + } + return 0; + + case 932: + /* Locale encoding is CP932, similar to Shift_JIS. */ + { + /* Convert "<\223\372\226\173\214\352>": "<日本語>" */ + memset (buf, 'x', 8); + ret = wcrtomb (buf, 0x65E5, NULL); + ASSERT (ret == 2); + ASSERT (memcmp (buf, "\223\372", 2) == 0); + ASSERT (buf[2] == 'x'); + + memset (buf, 'x', 8); + ret = wcrtomb (buf, 0x672C, NULL); + ASSERT (ret == 2); + ASSERT (memcmp (buf, "\226\173", 2) == 0); + ASSERT (buf[2] == 'x'); + + memset (buf, 'x', 8); + ret = wcrtomb (buf, 0x8A9E, NULL); + ASSERT (ret == 2); + ASSERT (memcmp (buf, "\214\352", 2) == 0); + ASSERT (buf[2] == 'x'); + } + return 0; + + case 950: + /* Locale encoding is CP950, similar to Big5. */ + { + /* Convert "<\244\351\245\273\273\171>": "<日本語>" */ + memset (buf, 'x', 8); + ret = wcrtomb (buf, 0x65E5, NULL); + ASSERT (ret == 2); + ASSERT (memcmp (buf, "\244\351", 2) == 0); + ASSERT (buf[2] == 'x'); + + memset (buf, 'x', 8); + ret = wcrtomb (buf, 0x672C, NULL); + ASSERT (ret == 2); + ASSERT (memcmp (buf, "\245\273", 2) == 0); + ASSERT (buf[2] == 'x'); + + memset (buf, 'x', 8); + ret = wcrtomb (buf, 0x8A9E, NULL); + ASSERT (ret == 2); + ASSERT (memcmp (buf, "\273\171", 2) == 0); + ASSERT (buf[2] == 'x'); + } + return 0; + + case 936: + /* Locale encoding is CP936 = GBK, an extension of GB2312. */ + { + /* Convert "<\310\325\261\276\325\132>": "<日本語>" */ + memset (buf, 'x', 8); + ret = wcrtomb (buf, 0x65E5, NULL); + ASSERT (ret == 2); + ASSERT (memcmp (buf, "\310\325", 2) == 0); + ASSERT (buf[2] == 'x'); + + memset (buf, 'x', 8); + ret = wcrtomb (buf, 0x672C, NULL); + ASSERT (ret == 2); + ASSERT (memcmp (buf, "\261\276", 2) == 0); + ASSERT (buf[2] == 'x'); + + memset (buf, 'x', 8); + ret = wcrtomb (buf, 0x8A9E, NULL); + ASSERT (ret == 2); + ASSERT (memcmp (buf, "\325\132", 2) == 0); + ASSERT (buf[2] == 'x'); + } + return 0; + + case 54936: + /* Locale encoding is CP54936 = GB18030. */ + if (strcmp (locale_charset (), "GB18030") != 0) + return 77; + { + /* Convert "B\250\271\201\060\211\070er": "Büßer" */ + memset (buf, 'x', 8); + ret = wcrtomb (buf, 0x00FC, NULL); + ASSERT (ret == 2); + ASSERT (memcmp (buf, "\250\271", 2) == 0); + ASSERT (buf[2] == 'x'); + + memset (buf, 'x', 8); + ret = wcrtomb (buf, 0x00DF, NULL); + ASSERT (ret == 4); + ASSERT (memcmp (buf, "\201\060\211\070", 4) == 0); + ASSERT (buf[4] == 'x'); + } + return 0; + + default: + return 1; + } +} + +int +main (int argc, char *argv[]) +{ + int codepage = atoi (argv[argc - 1]); + int result; + int i; + + result = 77; + for (i = 1; i < argc - 1; i++) + { + int ret = test_one_locale (argv[i], codepage); + + if (ret != 77) + result = ret; + } + + if (result == 77) + { + fprintf (stderr, "Skipping test: found no locale with codepage %d\n", + codepage); + } + return result; +} + +#else + +int +main (int argc, char *argv[]) +{ + fputs ("Skipping test: not a native Windows system\n", stderr); + return 77; +} + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-wcrtomb.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-wcrtomb.c new file mode 100644 index 00000000..640d6d9c --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-wcrtomb.c @@ -0,0 +1,166 @@ +/* Test of conversion of wide character to multibyte character. + Copyright (C) 2008-2024 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 . */ + +/* Written by Bruno Haible , 2008. */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (wcrtomb, size_t, (char *, wchar_t, mbstate_t *)); + +#include +#include +#include + +#include "macros.h" + +/* Check the multibyte character s[0..n-1]. */ +static void +check_character (const char *s, size_t n) +{ + wchar_t wc; + char buf[64]; + int iret; + size_t ret; + + wc = (wchar_t) 0xBADFACE; + iret = mbtowc (&wc, s, n); + ASSERT (iret == n); + + ret = wcrtomb (buf, wc, NULL); + ASSERT (ret == n); + ASSERT (memcmp (buf, s, n) == 0); + + /* Test special calling convention, passing a NULL pointer. */ + ret = wcrtomb (NULL, wc, NULL); + ASSERT (ret == 1); +} + +int +main (int argc, char *argv[]) +{ + char buf[64]; + size_t ret; + + /* configure should already have checked that the locale is supported. */ + if (setlocale (LC_ALL, "") == NULL) + return 1; + + /* Test NUL character. */ + { + buf[0] = 'x'; + ret = wcrtomb (buf, 0, NULL); + ASSERT (ret == 1); + ASSERT (buf[0] == '\0'); + } + + /* Test single bytes. */ + { + int c; + + for (c = 0; c < 0x100; c++) + switch (c) + { + case '\t': case '\v': case '\f': + case ' ': case '!': case '"': case '#': case '%': + case '&': case '\'': case '(': case ')': case '*': + case '+': case ',': case '-': case '.': case '/': + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + case ':': case ';': case '<': case '=': case '>': + case '?': + case 'A': case 'B': case 'C': case 'D': case 'E': + case 'F': case 'G': case 'H': case 'I': case 'J': + case 'K': case 'L': case 'M': case 'N': case 'O': + case 'P': case 'Q': case 'R': case 'S': case 'T': + case 'U': case 'V': case 'W': case 'X': case 'Y': + case 'Z': + case '[': case '\\': case ']': case '^': case '_': + case 'a': case 'b': case 'c': case 'd': case 'e': + case 'f': case 'g': case 'h': case 'i': case 'j': + case 'k': case 'l': case 'm': case 'n': case 'o': + case 'p': case 'q': case 'r': case 's': case 't': + case 'u': case 'v': case 'w': case 'x': case 'y': + case 'z': case '{': case '|': case '}': case '~': + /* c is in the ISO C "basic character set". */ + ret = wcrtomb (buf, btowc (c), NULL); + ASSERT (ret == 1); + ASSERT (buf[0] == (char) c); + break; + } + } + + /* Test special calling convention, passing a NULL pointer. */ + { + ret = wcrtomb (NULL, '\0', NULL); + ASSERT (ret == 1); + ret = wcrtomb (NULL, btowc ('x'), NULL); + ASSERT (ret == 1); + } + + if (argc > 1) + switch (argv[1][0]) + { + case '1': + /* C locale; tested above. */ + return 0; + + case '2': + /* Locale encoding is ISO-8859-1 or ISO-8859-15. */ + { + const char input[] = "B\374\337er"; /* "Büßer" */ + + check_character (input + 1, 1); + check_character (input + 2, 1); + } + return 0; + + case '3': + /* Locale encoding is UTF-8. */ + { + const char input[] = "B\303\274\303\237er"; /* "Büßer" */ + + check_character (input + 1, 2); + check_character (input + 3, 2); + } + return 0; + + case '4': + /* Locale encoding is EUC-JP. */ + { + const char input[] = "<\306\374\313\334\270\354>"; /* "<日本語>" */ + + check_character (input + 1, 2); + check_character (input + 3, 2); + check_character (input + 5, 2); + } + return 0; + + case '5': + /* Locale encoding is GB18030. */ + { + const char input[] = "B\250\271\201\060\211\070er"; /* "Büßer" */ + + check_character (input + 1, 2); + check_character (input + 3, 4); + } + return 0; + } + + return 1; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-wcrtomb.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-wcrtomb.sh new file mode 100755 index 00000000..b4604612 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-wcrtomb.sh @@ -0,0 +1,39 @@ +#!/bin/sh + +# Test in the POSIX locale. +LC_ALL=C ${CHECKER} ./test-wcrtomb${EXEEXT} 1 || exit 1 +LC_ALL=POSIX ${CHECKER} ./test-wcrtomb${EXEEXT} 1 || exit 1 + +# Test in an ISO-8859-1 or ISO-8859-15 locale. +: "${LOCALE_FR=fr_FR}" +if test $LOCALE_FR != none; then + LC_ALL=$LOCALE_FR \ + ${CHECKER} ./test-wcrtomb${EXEEXT} 2 \ + || exit 1 +fi + +# Test whether a specific UTF-8 locale is installed. +: "${LOCALE_FR_UTF8=fr_FR.UTF-8}" +if test $LOCALE_FR_UTF8 != none; then + LC_ALL=$LOCALE_FR_UTF8 \ + ${CHECKER} ./test-wcrtomb${EXEEXT} 3 \ + || exit 1 +fi + +# Test whether a specific EUC-JP locale is installed. +: "${LOCALE_JA=ja_JP}" +if test $LOCALE_JA != none; then + LC_ALL=$LOCALE_JA \ + ${CHECKER} ./test-wcrtomb${EXEEXT} 4 \ + || exit 1 +fi + +# Test whether a specific GB18030 locale is installed. +: "${LOCALE_ZH_CN=zh_CN.GB18030}" +if test $LOCALE_ZH_CN != none; then + LC_ALL=$LOCALE_ZH_CN \ + ${CHECKER} ./test-wcrtomb${EXEEXT} 5 \ + || exit 1 +fi + +exit 0 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-wctype-h.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-wctype-h.c new file mode 100644 index 00000000..016fd8fc --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-wctype-h.c @@ -0,0 +1,111 @@ +/* Test of substitute. + Copyright (C) 2007-2024 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 . */ + +/* Written by Bruno Haible , 2007. */ + +#include + +#include + +/* Check that the type wint_t is defined. */ +wint_t a = 'x'; +/* Check that WEOF is defined. */ +wint_t e = WEOF; + +/* Check that the type wctype_t is defined. */ +wctype_t p; + +/* Check that the type wctrans_t is defined. */ +wctrans_t q; + +#include "macros.h" + +int +main (void) +{ + /* Check that the isw* functions exist as functions or as macros. */ + (void) iswalnum (0); + (void) iswalpha (0); + (void) iswcntrl (0); + (void) iswdigit (0); + (void) iswgraph (0); + (void) iswlower (0); + (void) iswprint (0); + (void) iswpunct (0); + (void) iswspace (0); + (void) iswupper (0); + (void) iswxdigit (0); + + /* Check that the isw* functions map WEOF to 0. */ + ASSERT (!iswalnum (e)); + ASSERT (!iswalpha (e)); + ASSERT (!iswcntrl (e)); + ASSERT (!iswdigit (e)); + ASSERT (!iswgraph (e)); + ASSERT (!iswlower (e)); + ASSERT (!iswprint (e)); + ASSERT (!iswpunct (e)); + ASSERT (!iswspace (e)); + ASSERT (!iswupper (e)); + ASSERT (!iswxdigit (e)); + + /* Sanity check for the iswprint function. */ + ASSERT (iswprint (L' ')); + ASSERT (!iswprint (L'\t')); + ASSERT (!iswprint (L'\n')); + + /* Sanity check for the iswpunct function. + These characters are usually expected to be punctuation or symbol + characters. */ + ASSERT (iswpunct (L'!')); + ASSERT (iswpunct (L'"')); + ASSERT (iswpunct (L'#')); + ASSERT (iswpunct (L'%')); + ASSERT (iswpunct (L'&')); + ASSERT (iswpunct (L'\'')); + ASSERT (iswpunct (L'(')); + ASSERT (iswpunct (L')')); + ASSERT (iswpunct (L'*')); + ASSERT (iswpunct (L',')); + ASSERT (iswpunct (L'-')); + ASSERT (iswpunct (L'.')); + ASSERT (iswpunct (L'/')); + ASSERT (iswpunct (L':')); + ASSERT (iswpunct (L';')); + ASSERT (iswpunct (L'?')); + ASSERT (iswpunct (L'@')); + ASSERT (iswpunct (L'[')); + ASSERT (iswpunct (L'\\')); + ASSERT (iswpunct (L']')); + ASSERT (iswpunct (L'_')); + ASSERT (iswpunct (L'{')); + ASSERT (iswpunct (L'}')); + ASSERT (!iswpunct (L'5')); + ASSERT (!iswpunct (L'F')); + ASSERT (!iswpunct (L' ')); + ASSERT (!iswpunct (L'\t')); + ASSERT (!iswpunct (L'\n')); + + /* Check that the tow* functions exist as functions or as macros. */ + (void) towlower (0); + (void) towupper (0); + + /* Check that the tow* functions map WEOF to WEOF. */ + ASSERT (towlower (e) == e); + ASSERT (towupper (e) == e); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-wctype.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-wctype.c new file mode 100644 index 00000000..62d0a78c --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-wctype.c @@ -0,0 +1,73 @@ +/* Test of getting descriptor for a wide character property. + Copyright (C) 2023-2024 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 . */ + +/* Written by Bruno Haible , 2023. */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (wctype, wctype_t, (const char *)); + +#include "macros.h" + +int +main (int argc, char *argv[]) +{ + wctype_t desc; + + desc = wctype ("any"); + ASSERT (desc == (wctype_t) 0); + + desc = wctype ("blank"); + ASSERT (desc != (wctype_t) 0); + + desc = wctype ("space"); + ASSERT (desc != (wctype_t) 0); + + desc = wctype ("punct"); + ASSERT (desc != (wctype_t) 0); + + desc = wctype ("lower"); + ASSERT (desc != (wctype_t) 0); + + desc = wctype ("upper"); + ASSERT (desc != (wctype_t) 0); + + desc = wctype ("alpha"); + ASSERT (desc != (wctype_t) 0); + + desc = wctype ("digit"); + ASSERT (desc != (wctype_t) 0); + + desc = wctype ("xdigit"); + ASSERT (desc != (wctype_t) 0); + + desc = wctype ("alnum"); + ASSERT (desc != (wctype_t) 0); + + desc = wctype ("cntrl"); + ASSERT (desc != (wctype_t) 0); + + desc = wctype ("graph"); + ASSERT (desc != (wctype_t) 0); + + desc = wctype ("print"); + ASSERT (desc != (wctype_t) 0); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-wcwidth.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-wcwidth.c new file mode 100644 index 00000000..79556a24 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-wcwidth.c @@ -0,0 +1,106 @@ +/* Test of wcwidth() function. + Copyright (C) 2007-2024 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 . */ + +/* Written by Bruno Haible , 2007. */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (wcwidth, int, (wchar_t)); + +#include +#include + +#include "c-ctype.h" +#include "localcharset.h" +#include "macros.h" + +int +main () +{ + wchar_t wc; + +#if !GNULIB_WCHAR_SINGLE_LOCALE +# ifdef C_CTYPE_ASCII + /* Test width of ASCII characters. */ + for (wc = 0x20; wc < 0x7F; wc++) + ASSERT (wcwidth (wc) == 1); +# endif +#endif + + /* Switch to an UTF-8 locale. */ + if (setlocale (LC_ALL, "fr_FR.UTF-8") != NULL + /* Check whether it's really an UTF-8 locale. + On OpenBSD 4.0, the setlocale call succeeds only for the LC_CTYPE + category and therefore returns "C/fr_FR.UTF-8/C/C/C/C", but the + LC_CTYPE category is effectively set to an ASCII LC_CTYPE category; + in particular, locale_charset() returns "ASCII". */ + && strcmp (locale_charset (), "UTF-8") == 0) + { + /* Test width of ASCII characters. */ + for (wc = 0x20; wc < 0x7F; wc++) + ASSERT (wcwidth (wc) == 1); + + /* Test width of some non-spacing characters. */ + ASSERT (wcwidth (0x0301) == 0); + ASSERT (wcwidth (0x05B0) == 0); + + /* Test width of some format control characters. */ + ASSERT (wcwidth (0x200E) <= 0); + ASSERT (wcwidth (0x2060) <= 0); +#if 0 /* wchar_t may be only 16 bits. */ + ASSERT (wcwidth (0xE0001) <= 0); + ASSERT (wcwidth (0xE0044) <= 0); +#endif + + /* Test width of some zero width characters. */ + /* While it is desirable that U+200B, U+200C, U+200D have width 0, + because this makes wcswidth work better on strings that contain these + characters, it is acceptable if an implementation treats these + characters like control characters. */ + ASSERT (wcwidth (0x200B) <= 0); + ASSERT (wcwidth (0xFEFF) <= 0); + + /* Test width of some math symbols. + U+2202 is marked as having ambiguous width (A) in EastAsianWidth.txt + (see ). + The Unicode Standard Annex 11 + + says + "Ambiguous characters behave like wide or narrow characters + depending on the context (language tag, script identification, + associated font, source of data, or explicit markup; all can + provide the context). If the context cannot be established + reliably, they should be treated as narrow characters by default." + For wcwidth(), the only available context information is the locale. + "fr_FR.UTF-8" is a Western locale, not an East Asian locale, therefore + U+2202 should be treated like a narrow character. */ + ASSERT (wcwidth (0x2202) == 1); + + /* Test width of some CJK characters. */ + ASSERT (wcwidth (0x3000) == 2); + ASSERT (wcwidth (0xB250) == 2); + ASSERT (wcwidth (0xFF1A) == 2); +#if 0 /* wchar_t may be only 16 bits. */ + ASSERT (wcwidth (0x20369) == 2); + ASSERT (wcwidth (0x2F876) == 2); +#endif + } + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-xalloc-die.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-xalloc-die.c new file mode 100644 index 00000000..d4565434 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-xalloc-die.c @@ -0,0 +1,28 @@ +/* Test of xalloc_die() function. + Copyright (C) 2009-2024 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 . */ + +/* Written by Simon Josefsson , 2009. */ + +#include + +#include "xalloc.h" + +int +main () +{ + xalloc_die (); + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-xalloc-die.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-xalloc-die.sh new file mode 100755 index 00000000..dedc132c --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-xalloc-die.sh @@ -0,0 +1,36 @@ +#!/bin/sh +# Test suite for xalloc_die. +# Copyright (C) 2009-2024 Free Software Foundation, Inc. +# This file is part of the GNUlib Library. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ . + +${CHECKER} test-xalloc-die${EXEEXT} > out 2> err +case $? in + 1) ;; + *) Exit 1;; +esac + +tr -d '\015' < err \ + | sed 's,.*test-xalloc-die[.ex]*:,test-xalloc-die:,' > err2 || Exit 1 + +compare - err2 <<\EOF || Exit 1 +test-xalloc-die: memory exhausted +EOF + +test -s out && Exit 1 + +Exit $fail diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-xstdopen.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-xstdopen.c new file mode 100644 index 00000000..da27840c --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-xstdopen.c @@ -0,0 +1,32 @@ +/* Test of xstdopen() function. + Copyright (C) 2019-2024 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 . */ + +#include + +#include "xstdopen.h" + +#include + +#include "macros.h" + +int +main (void) +{ + xstdopen (); + ASSERT (open ("Makefile", O_RDONLY) >= 3); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-xstdopen.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-xstdopen.sh new file mode 100755 index 00000000..44201671 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-xstdopen.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +# Test with all of stdin, stdout, stderr open. +${CHECKER} ./test-xstdopen${EXEEXT} || exit 1 + +# The syntax for closed file descriptors in sh scripts is specified by POSIX in +# section 2.7.5 of +# https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html + +# Test with stdin closed. +${CHECKER} ./test-xstdopen${EXEEXT} <&- || exit 1 + +# Test with stdout closed. +${CHECKER} ./test-xstdopen${EXEEXT} >&- || exit 1 + +# Test with stderr closed. +${CHECKER} ./test-xstdopen${EXEEXT} 2>&- || exit 1 + +# Test with all of stdin, stdout, stderr closed. +${CHECKER} ./test-xstdopen${EXEEXT} <&- >&- 2>&- || exit 1 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-xstrtoimax.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-xstrtoimax.c new file mode 100644 index 00000000..cc2f6ae8 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-xstrtoimax.c @@ -0,0 +1,4 @@ +#define __xstrtol xstrtoimax +#define __strtol_t intmax_t +#define __spec PRIdMAX +#include "test-xstrtol.c" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-xstrtoimax.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-xstrtoimax.sh new file mode 100755 index 00000000..f41e52ea --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-xstrtoimax.sh @@ -0,0 +1,46 @@ +#!/bin/sh +: "${srcdir=.}" +. "$srcdir/init.sh"; path_prepend_ . + +too_big=99999999999999999999999999999999999999999999999999999999999999999999 +result=0 + +# test xstrtoimax +${CHECKER} test-xstrtoimax 1 >> out 2>&1 || result=1 +${CHECKER} test-xstrtoimax -1 >> out 2>&1 || result=1 +${CHECKER} test-xstrtoimax 1k >> out 2>&1 || result=1 +${CHECKER} test-xstrtoimax ${too_big}h >> out 2>&1 && result=1 +${CHECKER} test-xstrtoimax $too_big >> out 2>&1 && result=1 +${CHECKER} test-xstrtoimax x >> out 2>&1 && result=1 +${CHECKER} test-xstrtoimax 9x >> out 2>&1 && result=1 +${CHECKER} test-xstrtoimax 010 >> out 2>&1 || result=1 +${CHECKER} test-xstrtoimax MiB >> out 2>&1 || result=1 + +# Find out how to remove carriage returns from output. Solaris /usr/ucb/tr +# does not understand '\r'. +if echo solaris | tr -d '\r' | grep solais > /dev/null; then + cr='\015' +else + cr='\r' +fi + +# normalize output +LC_ALL=C tr -d "$cr" < out > k +mv k out + +# compare expected output +cat > exp <1 () +-1->-1 () +1k->1024 () +invalid suffix in X argument '${too_big}h' +X argument '$too_big' too large +invalid X argument 'x' +invalid suffix in X argument '9x' +010->8 () +MiB->1048576 () +EOF + +compare exp out || result=1 + +Exit $result diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-xstrtol.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-xstrtol.c new file mode 100644 index 00000000..c9568379 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-xstrtol.c @@ -0,0 +1,62 @@ +/* Test of xstrtol module. + Copyright (C) 1995-1996, 1998-2001, 2003-2024 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 . */ + +#include + +#include +#include +#include + +#include +#include "xstrtol-error.h" + +#ifndef __xstrtol +# define __xstrtol xstrtol +# define __strtol_t long int +# define __spec "ld" +#endif + +/* Don't show the program name in error messages. */ +static void +print_no_progname (void) +{ +} + +int +main (int argc, char **argv) +{ + strtol_error s_err; + int i; + + error_print_progname = print_no_progname; + + for (i = 1; i < argc; i++) + { + char *p; + __strtol_t val; + + s_err = __xstrtol (argv[i], &p, 0, &val, "bckMw0"); + if (s_err == LONGINT_OK) + { + printf ("%s->%" __spec " (%s)\n", argv[i], val, p); + } + else + { + xstrtol_fatal (s_err, -2, 'X', NULL, argv[i]); + } + } + exit (0); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-xstrtol.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-xstrtol.sh new file mode 100755 index 00000000..e82b585b --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-xstrtol.sh @@ -0,0 +1,71 @@ +#!/bin/sh +: "${srcdir=.}" +. "$srcdir/init.sh"; path_prepend_ . + +too_big=99999999999999999999999999999999999999999999999999999999999999999999 +result=0 + +# test xstrtol +${CHECKER} test-xstrtol 1 >> out 2>&1 || result=1 +${CHECKER} test-xstrtol -1 >> out 2>&1 || result=1 +${CHECKER} test-xstrtol 1k >> out 2>&1 || result=1 +${CHECKER} test-xstrtol ${too_big}h >> out 2>&1 && result=1 +${CHECKER} test-xstrtol $too_big >> out 2>&1 && result=1 +${CHECKER} test-xstrtol x >> out 2>&1 && result=1 +${CHECKER} test-xstrtol 9x >> out 2>&1 && result=1 +${CHECKER} test-xstrtol 010 >> out 2>&1 || result=1 +# suffix without integer is valid +${CHECKER} test-xstrtol MiB >> out 2>&1 || result=1 +${CHECKER} test-xstrtol 1bB >> out 2>&1 && result=1 + +# test xstrtoul +${CHECKER} test-xstrtoul 1 >> out 2>&1 || result=1 +${CHECKER} test-xstrtoul -1 >> out 2>&1 && result=1 +${CHECKER} test-xstrtoul 1k >> out 2>&1 || result=1 +${CHECKER} test-xstrtoul ${too_big}h >> out 2>&1 && result=1 +${CHECKER} test-xstrtoul $too_big >> out 2>&1 && result=1 +${CHECKER} test-xstrtoul x >> out 2>&1 && result=1 +${CHECKER} test-xstrtoul 9x >> out 2>&1 && result=1 +${CHECKER} test-xstrtoul 010 >> out 2>&1 || result=1 +${CHECKER} test-xstrtoul MiB >> out 2>&1 || result=1 +${CHECKER} test-xstrtoul 1bB >> out 2>&1 && result=1 + +# Find out how to remove carriage returns from output. Solaris /usr/ucb/tr +# does not understand '\r'. +if echo solaris | tr -d '\r' | grep solais > /dev/null; then + cr='\015' +else + cr='\r' +fi + +# normalize output +LC_ALL=C tr -d "$cr" < out > k +mv k out + +# compare expected output +cat > expected <1 () +-1->-1 () +1k->1024 () +invalid suffix in X argument '${too_big}h' +X argument '$too_big' too large +invalid X argument 'x' +invalid suffix in X argument '9x' +010->8 () +MiB->1048576 () +invalid suffix in X argument '1bB' +1->1 () +invalid X argument '-1' +1k->1024 () +invalid suffix in X argument '${too_big}h' +X argument '$too_big' too large +invalid X argument 'x' +invalid suffix in X argument '9x' +010->8 () +MiB->1048576 () +invalid suffix in X argument '1bB' +EOF + +compare expected out || result=1 + +Exit $result diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-xstrtoul.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-xstrtoul.c new file mode 100644 index 00000000..9dda9ee6 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-xstrtoul.c @@ -0,0 +1,4 @@ +#define __xstrtol xstrtoul +#define __strtol_t unsigned long int +#define __spec "lu" +#include "test-xstrtol.c" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-year2038.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-year2038.c new file mode 100644 index 00000000..3e80d930 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/test-year2038.c @@ -0,0 +1,39 @@ +/* Test of year2038 module. + Copyright (C) 2023-2024 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 . */ + +/* Written by Bruno Haible , 2023. */ + +/* This test fails if AC_SYS_YEAR2038 could not arrange for a time_t + that supports values > 2147483647. + This can happen + - on systems that are not year 2038 safe, or + - if the user specified --disable-year2038 at configure time. + It is intended that this test fails in these circumstances. */ + +#include + +#include +#include "intprops.h" + +/* Although this test could be done with static_assert, the test + harness prefers dynamic checking. */ + +int +main (void) +{ + /* Check the range of time_t. */ + return TYPE_MAXIMUM (time_t) >> 31 == 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/time.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/time.c new file mode 100644 index 00000000..573199c2 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/time.c @@ -0,0 +1,41 @@ +/* Provide time() for systems for which it's broken. + Copyright (C) 2023-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible. */ + +#include + +/* Specification. */ +#include + +#include +#include + +time_t +time (time_t *tp) +{ + struct timeval tv; + time_t tt; + + if (gettimeofday (&tv, NULL) < 0) + abort (); + tt = tv.tv_sec; + + if (tp) + *tp = tt; + + return tt; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/timespec-add.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/timespec-add.c new file mode 100644 index 00000000..e10c1984 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/timespec-add.c @@ -0,0 +1,66 @@ +/* Add two struct timespec values. + + Copyright (C) 2011-2024 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 . */ + +/* Written by Paul Eggert. */ + +/* Return the sum of two timespec values A and B. On overflow, return + an extremal value. This assumes 0 <= tv_nsec < TIMESPEC_HZ. */ + +#include +#include "timespec.h" + +#include +#include "intprops.h" + +struct timespec +timespec_add (struct timespec a, struct timespec b) +{ + time_t rs = a.tv_sec; + time_t bs = b.tv_sec; + int ns = a.tv_nsec + b.tv_nsec; + int nsd = ns - TIMESPEC_HZ; + int rns = ns; + + if (0 <= nsd) + { + rns = nsd; + time_t bs1; + if (!ckd_add (&bs1, bs, 1)) + bs = bs1; + else if (rs < 0) + rs++; + else + goto high_overflow; + } + + if (ckd_add (&rs, rs, bs)) + { + if (bs < 0) + { + rs = TYPE_MINIMUM (time_t); + rns = 0; + } + else + { + high_overflow: + rs = TYPE_MAXIMUM (time_t); + rns = TIMESPEC_HZ - 1; + } + } + + return make_timespec (rs, rns); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/timespec-sub.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/timespec-sub.c new file mode 100644 index 00000000..315cc638 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/timespec-sub.c @@ -0,0 +1,66 @@ +/* Subtract two struct timespec values. + + Copyright (C) 2011-2024 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 . */ + +/* Written by Paul Eggert. */ + +/* Return the difference between two timespec values A and B. On + overflow, return an extremal value. This assumes 0 <= tv_nsec < + TIMESPEC_HZ. */ + +#include +#include "timespec.h" + +#include +#include "intprops.h" + +struct timespec +timespec_sub (struct timespec a, struct timespec b) +{ + time_t rs = a.tv_sec; + time_t bs = b.tv_sec; + int ns = a.tv_nsec - b.tv_nsec; + int rns = ns; + + if (ns < 0) + { + rns = ns + TIMESPEC_HZ; + time_t bs1; + if (!ckd_add (&bs1, bs, 1)) + bs = bs1; + else if (- TYPE_SIGNED (time_t) < rs) + rs--; + else + goto low_overflow; + } + + if (ckd_sub (&rs, rs, bs)) + { + if (0 < bs) + { + low_overflow: + rs = TYPE_MINIMUM (time_t); + rns = 0; + } + else + { + rs = TYPE_MAXIMUM (time_t); + rns = TIMESPEC_HZ - 1; + } + } + + return make_timespec (rs, rns); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/uinttostr.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/uinttostr.c new file mode 100644 index 00000000..be56c85b --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/uinttostr.c @@ -0,0 +1,20 @@ +/* Convert 'unsigned int' integer to printable string. + + Copyright (C) 2006-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#define anytostr uinttostr +#define inttype unsigned int +#include "anytostr.c" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/umaxtostr.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/umaxtostr.c new file mode 100644 index 00000000..0458b4af --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/umaxtostr.c @@ -0,0 +1,20 @@ +/* Convert 'uintmax_t' integer to printable string. + + Copyright (C) 2004-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#define anytostr umaxtostr +#define inttype uintmax_t +#include "anytostr.c" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unicase/.gitignore b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unicase/.gitignore new file mode 100644 index 00000000..19cfffea --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unicase/.gitignore @@ -0,0 +1,3 @@ +/test-mapping-part1.h +/test-mapping-part2.h +/test-uc_tolower.c diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unicase/test-mapping-part1.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unicase/test-mapping-part1.h new file mode 100644 index 00000000..562195a5 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unicase/test-mapping-part1.h @@ -0,0 +1,31 @@ +/* Test of single character case mapping functions. + Copyright (C) 2007-2024 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 . */ + +#include + +#include "unicase.h" + +#include + +#include "macros.h" + +/* Pair of Unicode characters. */ +typedef struct { ucs4_t ch; ucs4_t value; } pair_t; + +/* Characters and their mapping values, ignoring no-op mappings, in increasing + order. */ +static const pair_t mapping[] = + { diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unicase/test-mapping-part2.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unicase/test-mapping-part2.h new file mode 100644 index 00000000..ed489482 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unicase/test-mapping-part2.h @@ -0,0 +1,37 @@ +/* Test of single character case mapping functions. + Copyright (C) 2007-2024 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 . */ + + }; + +int +main () +{ + unsigned int c; + size_t i; + + c = 0; + for (i = 0; i < SIZEOF (mapping); i++) + { + for (; c < mapping[i].ch; c++) + ASSERT (MAP (c) == c); + ASSERT (MAP (c) == mapping[i].value); + c++; + } + for (; c < 0x110000; c++) + ASSERT (MAP (c) == c); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unicase/test-uc_tolower.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unicase/test-uc_tolower.c new file mode 100644 index 00000000..83942037 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unicase/test-uc_tolower.c @@ -0,0 +1,1457 @@ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +/* Test the Unicode character mapping functions. + Copyright (C) 2009-2022 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 the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + This file 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 . */ + +/* Generated automatically by gen-uni-tables.c for Unicode 15.0.0. */ + +#include "test-mapping-part1.h" + + { 0x0041, 0x0061 }, + { 0x0042, 0x0062 }, + { 0x0043, 0x0063 }, + { 0x0044, 0x0064 }, + { 0x0045, 0x0065 }, + { 0x0046, 0x0066 }, + { 0x0047, 0x0067 }, + { 0x0048, 0x0068 }, + { 0x0049, 0x0069 }, + { 0x004A, 0x006A }, + { 0x004B, 0x006B }, + { 0x004C, 0x006C }, + { 0x004D, 0x006D }, + { 0x004E, 0x006E }, + { 0x004F, 0x006F }, + { 0x0050, 0x0070 }, + { 0x0051, 0x0071 }, + { 0x0052, 0x0072 }, + { 0x0053, 0x0073 }, + { 0x0054, 0x0074 }, + { 0x0055, 0x0075 }, + { 0x0056, 0x0076 }, + { 0x0057, 0x0077 }, + { 0x0058, 0x0078 }, + { 0x0059, 0x0079 }, + { 0x005A, 0x007A }, + { 0x00C0, 0x00E0 }, + { 0x00C1, 0x00E1 }, + { 0x00C2, 0x00E2 }, + { 0x00C3, 0x00E3 }, + { 0x00C4, 0x00E4 }, + { 0x00C5, 0x00E5 }, + { 0x00C6, 0x00E6 }, + { 0x00C7, 0x00E7 }, + { 0x00C8, 0x00E8 }, + { 0x00C9, 0x00E9 }, + { 0x00CA, 0x00EA }, + { 0x00CB, 0x00EB }, + { 0x00CC, 0x00EC }, + { 0x00CD, 0x00ED }, + { 0x00CE, 0x00EE }, + { 0x00CF, 0x00EF }, + { 0x00D0, 0x00F0 }, + { 0x00D1, 0x00F1 }, + { 0x00D2, 0x00F2 }, + { 0x00D3, 0x00F3 }, + { 0x00D4, 0x00F4 }, + { 0x00D5, 0x00F5 }, + { 0x00D6, 0x00F6 }, + { 0x00D8, 0x00F8 }, + { 0x00D9, 0x00F9 }, + { 0x00DA, 0x00FA }, + { 0x00DB, 0x00FB }, + { 0x00DC, 0x00FC }, + { 0x00DD, 0x00FD }, + { 0x00DE, 0x00FE }, + { 0x0100, 0x0101 }, + { 0x0102, 0x0103 }, + { 0x0104, 0x0105 }, + { 0x0106, 0x0107 }, + { 0x0108, 0x0109 }, + { 0x010A, 0x010B }, + { 0x010C, 0x010D }, + { 0x010E, 0x010F }, + { 0x0110, 0x0111 }, + { 0x0112, 0x0113 }, + { 0x0114, 0x0115 }, + { 0x0116, 0x0117 }, + { 0x0118, 0x0119 }, + { 0x011A, 0x011B }, + { 0x011C, 0x011D }, + { 0x011E, 0x011F }, + { 0x0120, 0x0121 }, + { 0x0122, 0x0123 }, + { 0x0124, 0x0125 }, + { 0x0126, 0x0127 }, + { 0x0128, 0x0129 }, + { 0x012A, 0x012B }, + { 0x012C, 0x012D }, + { 0x012E, 0x012F }, + { 0x0130, 0x0069 }, + { 0x0132, 0x0133 }, + { 0x0134, 0x0135 }, + { 0x0136, 0x0137 }, + { 0x0139, 0x013A }, + { 0x013B, 0x013C }, + { 0x013D, 0x013E }, + { 0x013F, 0x0140 }, + { 0x0141, 0x0142 }, + { 0x0143, 0x0144 }, + { 0x0145, 0x0146 }, + { 0x0147, 0x0148 }, + { 0x014A, 0x014B }, + { 0x014C, 0x014D }, + { 0x014E, 0x014F }, + { 0x0150, 0x0151 }, + { 0x0152, 0x0153 }, + { 0x0154, 0x0155 }, + { 0x0156, 0x0157 }, + { 0x0158, 0x0159 }, + { 0x015A, 0x015B }, + { 0x015C, 0x015D }, + { 0x015E, 0x015F }, + { 0x0160, 0x0161 }, + { 0x0162, 0x0163 }, + { 0x0164, 0x0165 }, + { 0x0166, 0x0167 }, + { 0x0168, 0x0169 }, + { 0x016A, 0x016B }, + { 0x016C, 0x016D }, + { 0x016E, 0x016F }, + { 0x0170, 0x0171 }, + { 0x0172, 0x0173 }, + { 0x0174, 0x0175 }, + { 0x0176, 0x0177 }, + { 0x0178, 0x00FF }, + { 0x0179, 0x017A }, + { 0x017B, 0x017C }, + { 0x017D, 0x017E }, + { 0x0181, 0x0253 }, + { 0x0182, 0x0183 }, + { 0x0184, 0x0185 }, + { 0x0186, 0x0254 }, + { 0x0187, 0x0188 }, + { 0x0189, 0x0256 }, + { 0x018A, 0x0257 }, + { 0x018B, 0x018C }, + { 0x018E, 0x01DD }, + { 0x018F, 0x0259 }, + { 0x0190, 0x025B }, + { 0x0191, 0x0192 }, + { 0x0193, 0x0260 }, + { 0x0194, 0x0263 }, + { 0x0196, 0x0269 }, + { 0x0197, 0x0268 }, + { 0x0198, 0x0199 }, + { 0x019C, 0x026F }, + { 0x019D, 0x0272 }, + { 0x019F, 0x0275 }, + { 0x01A0, 0x01A1 }, + { 0x01A2, 0x01A3 }, + { 0x01A4, 0x01A5 }, + { 0x01A6, 0x0280 }, + { 0x01A7, 0x01A8 }, + { 0x01A9, 0x0283 }, + { 0x01AC, 0x01AD }, + { 0x01AE, 0x0288 }, + { 0x01AF, 0x01B0 }, + { 0x01B1, 0x028A }, + { 0x01B2, 0x028B }, + { 0x01B3, 0x01B4 }, + { 0x01B5, 0x01B6 }, + { 0x01B7, 0x0292 }, + { 0x01B8, 0x01B9 }, + { 0x01BC, 0x01BD }, + { 0x01C4, 0x01C6 }, + { 0x01C5, 0x01C6 }, + { 0x01C7, 0x01C9 }, + { 0x01C8, 0x01C9 }, + { 0x01CA, 0x01CC }, + { 0x01CB, 0x01CC }, + { 0x01CD, 0x01CE }, + { 0x01CF, 0x01D0 }, + { 0x01D1, 0x01D2 }, + { 0x01D3, 0x01D4 }, + { 0x01D5, 0x01D6 }, + { 0x01D7, 0x01D8 }, + { 0x01D9, 0x01DA }, + { 0x01DB, 0x01DC }, + { 0x01DE, 0x01DF }, + { 0x01E0, 0x01E1 }, + { 0x01E2, 0x01E3 }, + { 0x01E4, 0x01E5 }, + { 0x01E6, 0x01E7 }, + { 0x01E8, 0x01E9 }, + { 0x01EA, 0x01EB }, + { 0x01EC, 0x01ED }, + { 0x01EE, 0x01EF }, + { 0x01F1, 0x01F3 }, + { 0x01F2, 0x01F3 }, + { 0x01F4, 0x01F5 }, + { 0x01F6, 0x0195 }, + { 0x01F7, 0x01BF }, + { 0x01F8, 0x01F9 }, + { 0x01FA, 0x01FB }, + { 0x01FC, 0x01FD }, + { 0x01FE, 0x01FF }, + { 0x0200, 0x0201 }, + { 0x0202, 0x0203 }, + { 0x0204, 0x0205 }, + { 0x0206, 0x0207 }, + { 0x0208, 0x0209 }, + { 0x020A, 0x020B }, + { 0x020C, 0x020D }, + { 0x020E, 0x020F }, + { 0x0210, 0x0211 }, + { 0x0212, 0x0213 }, + { 0x0214, 0x0215 }, + { 0x0216, 0x0217 }, + { 0x0218, 0x0219 }, + { 0x021A, 0x021B }, + { 0x021C, 0x021D }, + { 0x021E, 0x021F }, + { 0x0220, 0x019E }, + { 0x0222, 0x0223 }, + { 0x0224, 0x0225 }, + { 0x0226, 0x0227 }, + { 0x0228, 0x0229 }, + { 0x022A, 0x022B }, + { 0x022C, 0x022D }, + { 0x022E, 0x022F }, + { 0x0230, 0x0231 }, + { 0x0232, 0x0233 }, + { 0x023A, 0x2C65 }, + { 0x023B, 0x023C }, + { 0x023D, 0x019A }, + { 0x023E, 0x2C66 }, + { 0x0241, 0x0242 }, + { 0x0243, 0x0180 }, + { 0x0244, 0x0289 }, + { 0x0245, 0x028C }, + { 0x0246, 0x0247 }, + { 0x0248, 0x0249 }, + { 0x024A, 0x024B }, + { 0x024C, 0x024D }, + { 0x024E, 0x024F }, + { 0x0370, 0x0371 }, + { 0x0372, 0x0373 }, + { 0x0376, 0x0377 }, + { 0x037F, 0x03F3 }, + { 0x0386, 0x03AC }, + { 0x0388, 0x03AD }, + { 0x0389, 0x03AE }, + { 0x038A, 0x03AF }, + { 0x038C, 0x03CC }, + { 0x038E, 0x03CD }, + { 0x038F, 0x03CE }, + { 0x0391, 0x03B1 }, + { 0x0392, 0x03B2 }, + { 0x0393, 0x03B3 }, + { 0x0394, 0x03B4 }, + { 0x0395, 0x03B5 }, + { 0x0396, 0x03B6 }, + { 0x0397, 0x03B7 }, + { 0x0398, 0x03B8 }, + { 0x0399, 0x03B9 }, + { 0x039A, 0x03BA }, + { 0x039B, 0x03BB }, + { 0x039C, 0x03BC }, + { 0x039D, 0x03BD }, + { 0x039E, 0x03BE }, + { 0x039F, 0x03BF }, + { 0x03A0, 0x03C0 }, + { 0x03A1, 0x03C1 }, + { 0x03A3, 0x03C3 }, + { 0x03A4, 0x03C4 }, + { 0x03A5, 0x03C5 }, + { 0x03A6, 0x03C6 }, + { 0x03A7, 0x03C7 }, + { 0x03A8, 0x03C8 }, + { 0x03A9, 0x03C9 }, + { 0x03AA, 0x03CA }, + { 0x03AB, 0x03CB }, + { 0x03CF, 0x03D7 }, + { 0x03D8, 0x03D9 }, + { 0x03DA, 0x03DB }, + { 0x03DC, 0x03DD }, + { 0x03DE, 0x03DF }, + { 0x03E0, 0x03E1 }, + { 0x03E2, 0x03E3 }, + { 0x03E4, 0x03E5 }, + { 0x03E6, 0x03E7 }, + { 0x03E8, 0x03E9 }, + { 0x03EA, 0x03EB }, + { 0x03EC, 0x03ED }, + { 0x03EE, 0x03EF }, + { 0x03F4, 0x03B8 }, + { 0x03F7, 0x03F8 }, + { 0x03F9, 0x03F2 }, + { 0x03FA, 0x03FB }, + { 0x03FD, 0x037B }, + { 0x03FE, 0x037C }, + { 0x03FF, 0x037D }, + { 0x0400, 0x0450 }, + { 0x0401, 0x0451 }, + { 0x0402, 0x0452 }, + { 0x0403, 0x0453 }, + { 0x0404, 0x0454 }, + { 0x0405, 0x0455 }, + { 0x0406, 0x0456 }, + { 0x0407, 0x0457 }, + { 0x0408, 0x0458 }, + { 0x0409, 0x0459 }, + { 0x040A, 0x045A }, + { 0x040B, 0x045B }, + { 0x040C, 0x045C }, + { 0x040D, 0x045D }, + { 0x040E, 0x045E }, + { 0x040F, 0x045F }, + { 0x0410, 0x0430 }, + { 0x0411, 0x0431 }, + { 0x0412, 0x0432 }, + { 0x0413, 0x0433 }, + { 0x0414, 0x0434 }, + { 0x0415, 0x0435 }, + { 0x0416, 0x0436 }, + { 0x0417, 0x0437 }, + { 0x0418, 0x0438 }, + { 0x0419, 0x0439 }, + { 0x041A, 0x043A }, + { 0x041B, 0x043B }, + { 0x041C, 0x043C }, + { 0x041D, 0x043D }, + { 0x041E, 0x043E }, + { 0x041F, 0x043F }, + { 0x0420, 0x0440 }, + { 0x0421, 0x0441 }, + { 0x0422, 0x0442 }, + { 0x0423, 0x0443 }, + { 0x0424, 0x0444 }, + { 0x0425, 0x0445 }, + { 0x0426, 0x0446 }, + { 0x0427, 0x0447 }, + { 0x0428, 0x0448 }, + { 0x0429, 0x0449 }, + { 0x042A, 0x044A }, + { 0x042B, 0x044B }, + { 0x042C, 0x044C }, + { 0x042D, 0x044D }, + { 0x042E, 0x044E }, + { 0x042F, 0x044F }, + { 0x0460, 0x0461 }, + { 0x0462, 0x0463 }, + { 0x0464, 0x0465 }, + { 0x0466, 0x0467 }, + { 0x0468, 0x0469 }, + { 0x046A, 0x046B }, + { 0x046C, 0x046D }, + { 0x046E, 0x046F }, + { 0x0470, 0x0471 }, + { 0x0472, 0x0473 }, + { 0x0474, 0x0475 }, + { 0x0476, 0x0477 }, + { 0x0478, 0x0479 }, + { 0x047A, 0x047B }, + { 0x047C, 0x047D }, + { 0x047E, 0x047F }, + { 0x0480, 0x0481 }, + { 0x048A, 0x048B }, + { 0x048C, 0x048D }, + { 0x048E, 0x048F }, + { 0x0490, 0x0491 }, + { 0x0492, 0x0493 }, + { 0x0494, 0x0495 }, + { 0x0496, 0x0497 }, + { 0x0498, 0x0499 }, + { 0x049A, 0x049B }, + { 0x049C, 0x049D }, + { 0x049E, 0x049F }, + { 0x04A0, 0x04A1 }, + { 0x04A2, 0x04A3 }, + { 0x04A4, 0x04A5 }, + { 0x04A6, 0x04A7 }, + { 0x04A8, 0x04A9 }, + { 0x04AA, 0x04AB }, + { 0x04AC, 0x04AD }, + { 0x04AE, 0x04AF }, + { 0x04B0, 0x04B1 }, + { 0x04B2, 0x04B3 }, + { 0x04B4, 0x04B5 }, + { 0x04B6, 0x04B7 }, + { 0x04B8, 0x04B9 }, + { 0x04BA, 0x04BB }, + { 0x04BC, 0x04BD }, + { 0x04BE, 0x04BF }, + { 0x04C0, 0x04CF }, + { 0x04C1, 0x04C2 }, + { 0x04C3, 0x04C4 }, + { 0x04C5, 0x04C6 }, + { 0x04C7, 0x04C8 }, + { 0x04C9, 0x04CA }, + { 0x04CB, 0x04CC }, + { 0x04CD, 0x04CE }, + { 0x04D0, 0x04D1 }, + { 0x04D2, 0x04D3 }, + { 0x04D4, 0x04D5 }, + { 0x04D6, 0x04D7 }, + { 0x04D8, 0x04D9 }, + { 0x04DA, 0x04DB }, + { 0x04DC, 0x04DD }, + { 0x04DE, 0x04DF }, + { 0x04E0, 0x04E1 }, + { 0x04E2, 0x04E3 }, + { 0x04E4, 0x04E5 }, + { 0x04E6, 0x04E7 }, + { 0x04E8, 0x04E9 }, + { 0x04EA, 0x04EB }, + { 0x04EC, 0x04ED }, + { 0x04EE, 0x04EF }, + { 0x04F0, 0x04F1 }, + { 0x04F2, 0x04F3 }, + { 0x04F4, 0x04F5 }, + { 0x04F6, 0x04F7 }, + { 0x04F8, 0x04F9 }, + { 0x04FA, 0x04FB }, + { 0x04FC, 0x04FD }, + { 0x04FE, 0x04FF }, + { 0x0500, 0x0501 }, + { 0x0502, 0x0503 }, + { 0x0504, 0x0505 }, + { 0x0506, 0x0507 }, + { 0x0508, 0x0509 }, + { 0x050A, 0x050B }, + { 0x050C, 0x050D }, + { 0x050E, 0x050F }, + { 0x0510, 0x0511 }, + { 0x0512, 0x0513 }, + { 0x0514, 0x0515 }, + { 0x0516, 0x0517 }, + { 0x0518, 0x0519 }, + { 0x051A, 0x051B }, + { 0x051C, 0x051D }, + { 0x051E, 0x051F }, + { 0x0520, 0x0521 }, + { 0x0522, 0x0523 }, + { 0x0524, 0x0525 }, + { 0x0526, 0x0527 }, + { 0x0528, 0x0529 }, + { 0x052A, 0x052B }, + { 0x052C, 0x052D }, + { 0x052E, 0x052F }, + { 0x0531, 0x0561 }, + { 0x0532, 0x0562 }, + { 0x0533, 0x0563 }, + { 0x0534, 0x0564 }, + { 0x0535, 0x0565 }, + { 0x0536, 0x0566 }, + { 0x0537, 0x0567 }, + { 0x0538, 0x0568 }, + { 0x0539, 0x0569 }, + { 0x053A, 0x056A }, + { 0x053B, 0x056B }, + { 0x053C, 0x056C }, + { 0x053D, 0x056D }, + { 0x053E, 0x056E }, + { 0x053F, 0x056F }, + { 0x0540, 0x0570 }, + { 0x0541, 0x0571 }, + { 0x0542, 0x0572 }, + { 0x0543, 0x0573 }, + { 0x0544, 0x0574 }, + { 0x0545, 0x0575 }, + { 0x0546, 0x0576 }, + { 0x0547, 0x0577 }, + { 0x0548, 0x0578 }, + { 0x0549, 0x0579 }, + { 0x054A, 0x057A }, + { 0x054B, 0x057B }, + { 0x054C, 0x057C }, + { 0x054D, 0x057D }, + { 0x054E, 0x057E }, + { 0x054F, 0x057F }, + { 0x0550, 0x0580 }, + { 0x0551, 0x0581 }, + { 0x0552, 0x0582 }, + { 0x0553, 0x0583 }, + { 0x0554, 0x0584 }, + { 0x0555, 0x0585 }, + { 0x0556, 0x0586 }, + { 0x10A0, 0x2D00 }, + { 0x10A1, 0x2D01 }, + { 0x10A2, 0x2D02 }, + { 0x10A3, 0x2D03 }, + { 0x10A4, 0x2D04 }, + { 0x10A5, 0x2D05 }, + { 0x10A6, 0x2D06 }, + { 0x10A7, 0x2D07 }, + { 0x10A8, 0x2D08 }, + { 0x10A9, 0x2D09 }, + { 0x10AA, 0x2D0A }, + { 0x10AB, 0x2D0B }, + { 0x10AC, 0x2D0C }, + { 0x10AD, 0x2D0D }, + { 0x10AE, 0x2D0E }, + { 0x10AF, 0x2D0F }, + { 0x10B0, 0x2D10 }, + { 0x10B1, 0x2D11 }, + { 0x10B2, 0x2D12 }, + { 0x10B3, 0x2D13 }, + { 0x10B4, 0x2D14 }, + { 0x10B5, 0x2D15 }, + { 0x10B6, 0x2D16 }, + { 0x10B7, 0x2D17 }, + { 0x10B8, 0x2D18 }, + { 0x10B9, 0x2D19 }, + { 0x10BA, 0x2D1A }, + { 0x10BB, 0x2D1B }, + { 0x10BC, 0x2D1C }, + { 0x10BD, 0x2D1D }, + { 0x10BE, 0x2D1E }, + { 0x10BF, 0x2D1F }, + { 0x10C0, 0x2D20 }, + { 0x10C1, 0x2D21 }, + { 0x10C2, 0x2D22 }, + { 0x10C3, 0x2D23 }, + { 0x10C4, 0x2D24 }, + { 0x10C5, 0x2D25 }, + { 0x10C7, 0x2D27 }, + { 0x10CD, 0x2D2D }, + { 0x13A0, 0xAB70 }, + { 0x13A1, 0xAB71 }, + { 0x13A2, 0xAB72 }, + { 0x13A3, 0xAB73 }, + { 0x13A4, 0xAB74 }, + { 0x13A5, 0xAB75 }, + { 0x13A6, 0xAB76 }, + { 0x13A7, 0xAB77 }, + { 0x13A8, 0xAB78 }, + { 0x13A9, 0xAB79 }, + { 0x13AA, 0xAB7A }, + { 0x13AB, 0xAB7B }, + { 0x13AC, 0xAB7C }, + { 0x13AD, 0xAB7D }, + { 0x13AE, 0xAB7E }, + { 0x13AF, 0xAB7F }, + { 0x13B0, 0xAB80 }, + { 0x13B1, 0xAB81 }, + { 0x13B2, 0xAB82 }, + { 0x13B3, 0xAB83 }, + { 0x13B4, 0xAB84 }, + { 0x13B5, 0xAB85 }, + { 0x13B6, 0xAB86 }, + { 0x13B7, 0xAB87 }, + { 0x13B8, 0xAB88 }, + { 0x13B9, 0xAB89 }, + { 0x13BA, 0xAB8A }, + { 0x13BB, 0xAB8B }, + { 0x13BC, 0xAB8C }, + { 0x13BD, 0xAB8D }, + { 0x13BE, 0xAB8E }, + { 0x13BF, 0xAB8F }, + { 0x13C0, 0xAB90 }, + { 0x13C1, 0xAB91 }, + { 0x13C2, 0xAB92 }, + { 0x13C3, 0xAB93 }, + { 0x13C4, 0xAB94 }, + { 0x13C5, 0xAB95 }, + { 0x13C6, 0xAB96 }, + { 0x13C7, 0xAB97 }, + { 0x13C8, 0xAB98 }, + { 0x13C9, 0xAB99 }, + { 0x13CA, 0xAB9A }, + { 0x13CB, 0xAB9B }, + { 0x13CC, 0xAB9C }, + { 0x13CD, 0xAB9D }, + { 0x13CE, 0xAB9E }, + { 0x13CF, 0xAB9F }, + { 0x13D0, 0xABA0 }, + { 0x13D1, 0xABA1 }, + { 0x13D2, 0xABA2 }, + { 0x13D3, 0xABA3 }, + { 0x13D4, 0xABA4 }, + { 0x13D5, 0xABA5 }, + { 0x13D6, 0xABA6 }, + { 0x13D7, 0xABA7 }, + { 0x13D8, 0xABA8 }, + { 0x13D9, 0xABA9 }, + { 0x13DA, 0xABAA }, + { 0x13DB, 0xABAB }, + { 0x13DC, 0xABAC }, + { 0x13DD, 0xABAD }, + { 0x13DE, 0xABAE }, + { 0x13DF, 0xABAF }, + { 0x13E0, 0xABB0 }, + { 0x13E1, 0xABB1 }, + { 0x13E2, 0xABB2 }, + { 0x13E3, 0xABB3 }, + { 0x13E4, 0xABB4 }, + { 0x13E5, 0xABB5 }, + { 0x13E6, 0xABB6 }, + { 0x13E7, 0xABB7 }, + { 0x13E8, 0xABB8 }, + { 0x13E9, 0xABB9 }, + { 0x13EA, 0xABBA }, + { 0x13EB, 0xABBB }, + { 0x13EC, 0xABBC }, + { 0x13ED, 0xABBD }, + { 0x13EE, 0xABBE }, + { 0x13EF, 0xABBF }, + { 0x13F0, 0x13F8 }, + { 0x13F1, 0x13F9 }, + { 0x13F2, 0x13FA }, + { 0x13F3, 0x13FB }, + { 0x13F4, 0x13FC }, + { 0x13F5, 0x13FD }, + { 0x1C90, 0x10D0 }, + { 0x1C91, 0x10D1 }, + { 0x1C92, 0x10D2 }, + { 0x1C93, 0x10D3 }, + { 0x1C94, 0x10D4 }, + { 0x1C95, 0x10D5 }, + { 0x1C96, 0x10D6 }, + { 0x1C97, 0x10D7 }, + { 0x1C98, 0x10D8 }, + { 0x1C99, 0x10D9 }, + { 0x1C9A, 0x10DA }, + { 0x1C9B, 0x10DB }, + { 0x1C9C, 0x10DC }, + { 0x1C9D, 0x10DD }, + { 0x1C9E, 0x10DE }, + { 0x1C9F, 0x10DF }, + { 0x1CA0, 0x10E0 }, + { 0x1CA1, 0x10E1 }, + { 0x1CA2, 0x10E2 }, + { 0x1CA3, 0x10E3 }, + { 0x1CA4, 0x10E4 }, + { 0x1CA5, 0x10E5 }, + { 0x1CA6, 0x10E6 }, + { 0x1CA7, 0x10E7 }, + { 0x1CA8, 0x10E8 }, + { 0x1CA9, 0x10E9 }, + { 0x1CAA, 0x10EA }, + { 0x1CAB, 0x10EB }, + { 0x1CAC, 0x10EC }, + { 0x1CAD, 0x10ED }, + { 0x1CAE, 0x10EE }, + { 0x1CAF, 0x10EF }, + { 0x1CB0, 0x10F0 }, + { 0x1CB1, 0x10F1 }, + { 0x1CB2, 0x10F2 }, + { 0x1CB3, 0x10F3 }, + { 0x1CB4, 0x10F4 }, + { 0x1CB5, 0x10F5 }, + { 0x1CB6, 0x10F6 }, + { 0x1CB7, 0x10F7 }, + { 0x1CB8, 0x10F8 }, + { 0x1CB9, 0x10F9 }, + { 0x1CBA, 0x10FA }, + { 0x1CBD, 0x10FD }, + { 0x1CBE, 0x10FE }, + { 0x1CBF, 0x10FF }, + { 0x1E00, 0x1E01 }, + { 0x1E02, 0x1E03 }, + { 0x1E04, 0x1E05 }, + { 0x1E06, 0x1E07 }, + { 0x1E08, 0x1E09 }, + { 0x1E0A, 0x1E0B }, + { 0x1E0C, 0x1E0D }, + { 0x1E0E, 0x1E0F }, + { 0x1E10, 0x1E11 }, + { 0x1E12, 0x1E13 }, + { 0x1E14, 0x1E15 }, + { 0x1E16, 0x1E17 }, + { 0x1E18, 0x1E19 }, + { 0x1E1A, 0x1E1B }, + { 0x1E1C, 0x1E1D }, + { 0x1E1E, 0x1E1F }, + { 0x1E20, 0x1E21 }, + { 0x1E22, 0x1E23 }, + { 0x1E24, 0x1E25 }, + { 0x1E26, 0x1E27 }, + { 0x1E28, 0x1E29 }, + { 0x1E2A, 0x1E2B }, + { 0x1E2C, 0x1E2D }, + { 0x1E2E, 0x1E2F }, + { 0x1E30, 0x1E31 }, + { 0x1E32, 0x1E33 }, + { 0x1E34, 0x1E35 }, + { 0x1E36, 0x1E37 }, + { 0x1E38, 0x1E39 }, + { 0x1E3A, 0x1E3B }, + { 0x1E3C, 0x1E3D }, + { 0x1E3E, 0x1E3F }, + { 0x1E40, 0x1E41 }, + { 0x1E42, 0x1E43 }, + { 0x1E44, 0x1E45 }, + { 0x1E46, 0x1E47 }, + { 0x1E48, 0x1E49 }, + { 0x1E4A, 0x1E4B }, + { 0x1E4C, 0x1E4D }, + { 0x1E4E, 0x1E4F }, + { 0x1E50, 0x1E51 }, + { 0x1E52, 0x1E53 }, + { 0x1E54, 0x1E55 }, + { 0x1E56, 0x1E57 }, + { 0x1E58, 0x1E59 }, + { 0x1E5A, 0x1E5B }, + { 0x1E5C, 0x1E5D }, + { 0x1E5E, 0x1E5F }, + { 0x1E60, 0x1E61 }, + { 0x1E62, 0x1E63 }, + { 0x1E64, 0x1E65 }, + { 0x1E66, 0x1E67 }, + { 0x1E68, 0x1E69 }, + { 0x1E6A, 0x1E6B }, + { 0x1E6C, 0x1E6D }, + { 0x1E6E, 0x1E6F }, + { 0x1E70, 0x1E71 }, + { 0x1E72, 0x1E73 }, + { 0x1E74, 0x1E75 }, + { 0x1E76, 0x1E77 }, + { 0x1E78, 0x1E79 }, + { 0x1E7A, 0x1E7B }, + { 0x1E7C, 0x1E7D }, + { 0x1E7E, 0x1E7F }, + { 0x1E80, 0x1E81 }, + { 0x1E82, 0x1E83 }, + { 0x1E84, 0x1E85 }, + { 0x1E86, 0x1E87 }, + { 0x1E88, 0x1E89 }, + { 0x1E8A, 0x1E8B }, + { 0x1E8C, 0x1E8D }, + { 0x1E8E, 0x1E8F }, + { 0x1E90, 0x1E91 }, + { 0x1E92, 0x1E93 }, + { 0x1E94, 0x1E95 }, + { 0x1E9E, 0x00DF }, + { 0x1EA0, 0x1EA1 }, + { 0x1EA2, 0x1EA3 }, + { 0x1EA4, 0x1EA5 }, + { 0x1EA6, 0x1EA7 }, + { 0x1EA8, 0x1EA9 }, + { 0x1EAA, 0x1EAB }, + { 0x1EAC, 0x1EAD }, + { 0x1EAE, 0x1EAF }, + { 0x1EB0, 0x1EB1 }, + { 0x1EB2, 0x1EB3 }, + { 0x1EB4, 0x1EB5 }, + { 0x1EB6, 0x1EB7 }, + { 0x1EB8, 0x1EB9 }, + { 0x1EBA, 0x1EBB }, + { 0x1EBC, 0x1EBD }, + { 0x1EBE, 0x1EBF }, + { 0x1EC0, 0x1EC1 }, + { 0x1EC2, 0x1EC3 }, + { 0x1EC4, 0x1EC5 }, + { 0x1EC6, 0x1EC7 }, + { 0x1EC8, 0x1EC9 }, + { 0x1ECA, 0x1ECB }, + { 0x1ECC, 0x1ECD }, + { 0x1ECE, 0x1ECF }, + { 0x1ED0, 0x1ED1 }, + { 0x1ED2, 0x1ED3 }, + { 0x1ED4, 0x1ED5 }, + { 0x1ED6, 0x1ED7 }, + { 0x1ED8, 0x1ED9 }, + { 0x1EDA, 0x1EDB }, + { 0x1EDC, 0x1EDD }, + { 0x1EDE, 0x1EDF }, + { 0x1EE0, 0x1EE1 }, + { 0x1EE2, 0x1EE3 }, + { 0x1EE4, 0x1EE5 }, + { 0x1EE6, 0x1EE7 }, + { 0x1EE8, 0x1EE9 }, + { 0x1EEA, 0x1EEB }, + { 0x1EEC, 0x1EED }, + { 0x1EEE, 0x1EEF }, + { 0x1EF0, 0x1EF1 }, + { 0x1EF2, 0x1EF3 }, + { 0x1EF4, 0x1EF5 }, + { 0x1EF6, 0x1EF7 }, + { 0x1EF8, 0x1EF9 }, + { 0x1EFA, 0x1EFB }, + { 0x1EFC, 0x1EFD }, + { 0x1EFE, 0x1EFF }, + { 0x1F08, 0x1F00 }, + { 0x1F09, 0x1F01 }, + { 0x1F0A, 0x1F02 }, + { 0x1F0B, 0x1F03 }, + { 0x1F0C, 0x1F04 }, + { 0x1F0D, 0x1F05 }, + { 0x1F0E, 0x1F06 }, + { 0x1F0F, 0x1F07 }, + { 0x1F18, 0x1F10 }, + { 0x1F19, 0x1F11 }, + { 0x1F1A, 0x1F12 }, + { 0x1F1B, 0x1F13 }, + { 0x1F1C, 0x1F14 }, + { 0x1F1D, 0x1F15 }, + { 0x1F28, 0x1F20 }, + { 0x1F29, 0x1F21 }, + { 0x1F2A, 0x1F22 }, + { 0x1F2B, 0x1F23 }, + { 0x1F2C, 0x1F24 }, + { 0x1F2D, 0x1F25 }, + { 0x1F2E, 0x1F26 }, + { 0x1F2F, 0x1F27 }, + { 0x1F38, 0x1F30 }, + { 0x1F39, 0x1F31 }, + { 0x1F3A, 0x1F32 }, + { 0x1F3B, 0x1F33 }, + { 0x1F3C, 0x1F34 }, + { 0x1F3D, 0x1F35 }, + { 0x1F3E, 0x1F36 }, + { 0x1F3F, 0x1F37 }, + { 0x1F48, 0x1F40 }, + { 0x1F49, 0x1F41 }, + { 0x1F4A, 0x1F42 }, + { 0x1F4B, 0x1F43 }, + { 0x1F4C, 0x1F44 }, + { 0x1F4D, 0x1F45 }, + { 0x1F59, 0x1F51 }, + { 0x1F5B, 0x1F53 }, + { 0x1F5D, 0x1F55 }, + { 0x1F5F, 0x1F57 }, + { 0x1F68, 0x1F60 }, + { 0x1F69, 0x1F61 }, + { 0x1F6A, 0x1F62 }, + { 0x1F6B, 0x1F63 }, + { 0x1F6C, 0x1F64 }, + { 0x1F6D, 0x1F65 }, + { 0x1F6E, 0x1F66 }, + { 0x1F6F, 0x1F67 }, + { 0x1F88, 0x1F80 }, + { 0x1F89, 0x1F81 }, + { 0x1F8A, 0x1F82 }, + { 0x1F8B, 0x1F83 }, + { 0x1F8C, 0x1F84 }, + { 0x1F8D, 0x1F85 }, + { 0x1F8E, 0x1F86 }, + { 0x1F8F, 0x1F87 }, + { 0x1F98, 0x1F90 }, + { 0x1F99, 0x1F91 }, + { 0x1F9A, 0x1F92 }, + { 0x1F9B, 0x1F93 }, + { 0x1F9C, 0x1F94 }, + { 0x1F9D, 0x1F95 }, + { 0x1F9E, 0x1F96 }, + { 0x1F9F, 0x1F97 }, + { 0x1FA8, 0x1FA0 }, + { 0x1FA9, 0x1FA1 }, + { 0x1FAA, 0x1FA2 }, + { 0x1FAB, 0x1FA3 }, + { 0x1FAC, 0x1FA4 }, + { 0x1FAD, 0x1FA5 }, + { 0x1FAE, 0x1FA6 }, + { 0x1FAF, 0x1FA7 }, + { 0x1FB8, 0x1FB0 }, + { 0x1FB9, 0x1FB1 }, + { 0x1FBA, 0x1F70 }, + { 0x1FBB, 0x1F71 }, + { 0x1FBC, 0x1FB3 }, + { 0x1FC8, 0x1F72 }, + { 0x1FC9, 0x1F73 }, + { 0x1FCA, 0x1F74 }, + { 0x1FCB, 0x1F75 }, + { 0x1FCC, 0x1FC3 }, + { 0x1FD8, 0x1FD0 }, + { 0x1FD9, 0x1FD1 }, + { 0x1FDA, 0x1F76 }, + { 0x1FDB, 0x1F77 }, + { 0x1FE8, 0x1FE0 }, + { 0x1FE9, 0x1FE1 }, + { 0x1FEA, 0x1F7A }, + { 0x1FEB, 0x1F7B }, + { 0x1FEC, 0x1FE5 }, + { 0x1FF8, 0x1F78 }, + { 0x1FF9, 0x1F79 }, + { 0x1FFA, 0x1F7C }, + { 0x1FFB, 0x1F7D }, + { 0x1FFC, 0x1FF3 }, + { 0x2126, 0x03C9 }, + { 0x212A, 0x006B }, + { 0x212B, 0x00E5 }, + { 0x2132, 0x214E }, + { 0x2160, 0x2170 }, + { 0x2161, 0x2171 }, + { 0x2162, 0x2172 }, + { 0x2163, 0x2173 }, + { 0x2164, 0x2174 }, + { 0x2165, 0x2175 }, + { 0x2166, 0x2176 }, + { 0x2167, 0x2177 }, + { 0x2168, 0x2178 }, + { 0x2169, 0x2179 }, + { 0x216A, 0x217A }, + { 0x216B, 0x217B }, + { 0x216C, 0x217C }, + { 0x216D, 0x217D }, + { 0x216E, 0x217E }, + { 0x216F, 0x217F }, + { 0x2183, 0x2184 }, + { 0x24B6, 0x24D0 }, + { 0x24B7, 0x24D1 }, + { 0x24B8, 0x24D2 }, + { 0x24B9, 0x24D3 }, + { 0x24BA, 0x24D4 }, + { 0x24BB, 0x24D5 }, + { 0x24BC, 0x24D6 }, + { 0x24BD, 0x24D7 }, + { 0x24BE, 0x24D8 }, + { 0x24BF, 0x24D9 }, + { 0x24C0, 0x24DA }, + { 0x24C1, 0x24DB }, + { 0x24C2, 0x24DC }, + { 0x24C3, 0x24DD }, + { 0x24C4, 0x24DE }, + { 0x24C5, 0x24DF }, + { 0x24C6, 0x24E0 }, + { 0x24C7, 0x24E1 }, + { 0x24C8, 0x24E2 }, + { 0x24C9, 0x24E3 }, + { 0x24CA, 0x24E4 }, + { 0x24CB, 0x24E5 }, + { 0x24CC, 0x24E6 }, + { 0x24CD, 0x24E7 }, + { 0x24CE, 0x24E8 }, + { 0x24CF, 0x24E9 }, + { 0x2C00, 0x2C30 }, + { 0x2C01, 0x2C31 }, + { 0x2C02, 0x2C32 }, + { 0x2C03, 0x2C33 }, + { 0x2C04, 0x2C34 }, + { 0x2C05, 0x2C35 }, + { 0x2C06, 0x2C36 }, + { 0x2C07, 0x2C37 }, + { 0x2C08, 0x2C38 }, + { 0x2C09, 0x2C39 }, + { 0x2C0A, 0x2C3A }, + { 0x2C0B, 0x2C3B }, + { 0x2C0C, 0x2C3C }, + { 0x2C0D, 0x2C3D }, + { 0x2C0E, 0x2C3E }, + { 0x2C0F, 0x2C3F }, + { 0x2C10, 0x2C40 }, + { 0x2C11, 0x2C41 }, + { 0x2C12, 0x2C42 }, + { 0x2C13, 0x2C43 }, + { 0x2C14, 0x2C44 }, + { 0x2C15, 0x2C45 }, + { 0x2C16, 0x2C46 }, + { 0x2C17, 0x2C47 }, + { 0x2C18, 0x2C48 }, + { 0x2C19, 0x2C49 }, + { 0x2C1A, 0x2C4A }, + { 0x2C1B, 0x2C4B }, + { 0x2C1C, 0x2C4C }, + { 0x2C1D, 0x2C4D }, + { 0x2C1E, 0x2C4E }, + { 0x2C1F, 0x2C4F }, + { 0x2C20, 0x2C50 }, + { 0x2C21, 0x2C51 }, + { 0x2C22, 0x2C52 }, + { 0x2C23, 0x2C53 }, + { 0x2C24, 0x2C54 }, + { 0x2C25, 0x2C55 }, + { 0x2C26, 0x2C56 }, + { 0x2C27, 0x2C57 }, + { 0x2C28, 0x2C58 }, + { 0x2C29, 0x2C59 }, + { 0x2C2A, 0x2C5A }, + { 0x2C2B, 0x2C5B }, + { 0x2C2C, 0x2C5C }, + { 0x2C2D, 0x2C5D }, + { 0x2C2E, 0x2C5E }, + { 0x2C2F, 0x2C5F }, + { 0x2C60, 0x2C61 }, + { 0x2C62, 0x026B }, + { 0x2C63, 0x1D7D }, + { 0x2C64, 0x027D }, + { 0x2C67, 0x2C68 }, + { 0x2C69, 0x2C6A }, + { 0x2C6B, 0x2C6C }, + { 0x2C6D, 0x0251 }, + { 0x2C6E, 0x0271 }, + { 0x2C6F, 0x0250 }, + { 0x2C70, 0x0252 }, + { 0x2C72, 0x2C73 }, + { 0x2C75, 0x2C76 }, + { 0x2C7E, 0x023F }, + { 0x2C7F, 0x0240 }, + { 0x2C80, 0x2C81 }, + { 0x2C82, 0x2C83 }, + { 0x2C84, 0x2C85 }, + { 0x2C86, 0x2C87 }, + { 0x2C88, 0x2C89 }, + { 0x2C8A, 0x2C8B }, + { 0x2C8C, 0x2C8D }, + { 0x2C8E, 0x2C8F }, + { 0x2C90, 0x2C91 }, + { 0x2C92, 0x2C93 }, + { 0x2C94, 0x2C95 }, + { 0x2C96, 0x2C97 }, + { 0x2C98, 0x2C99 }, + { 0x2C9A, 0x2C9B }, + { 0x2C9C, 0x2C9D }, + { 0x2C9E, 0x2C9F }, + { 0x2CA0, 0x2CA1 }, + { 0x2CA2, 0x2CA3 }, + { 0x2CA4, 0x2CA5 }, + { 0x2CA6, 0x2CA7 }, + { 0x2CA8, 0x2CA9 }, + { 0x2CAA, 0x2CAB }, + { 0x2CAC, 0x2CAD }, + { 0x2CAE, 0x2CAF }, + { 0x2CB0, 0x2CB1 }, + { 0x2CB2, 0x2CB3 }, + { 0x2CB4, 0x2CB5 }, + { 0x2CB6, 0x2CB7 }, + { 0x2CB8, 0x2CB9 }, + { 0x2CBA, 0x2CBB }, + { 0x2CBC, 0x2CBD }, + { 0x2CBE, 0x2CBF }, + { 0x2CC0, 0x2CC1 }, + { 0x2CC2, 0x2CC3 }, + { 0x2CC4, 0x2CC5 }, + { 0x2CC6, 0x2CC7 }, + { 0x2CC8, 0x2CC9 }, + { 0x2CCA, 0x2CCB }, + { 0x2CCC, 0x2CCD }, + { 0x2CCE, 0x2CCF }, + { 0x2CD0, 0x2CD1 }, + { 0x2CD2, 0x2CD3 }, + { 0x2CD4, 0x2CD5 }, + { 0x2CD6, 0x2CD7 }, + { 0x2CD8, 0x2CD9 }, + { 0x2CDA, 0x2CDB }, + { 0x2CDC, 0x2CDD }, + { 0x2CDE, 0x2CDF }, + { 0x2CE0, 0x2CE1 }, + { 0x2CE2, 0x2CE3 }, + { 0x2CEB, 0x2CEC }, + { 0x2CED, 0x2CEE }, + { 0x2CF2, 0x2CF3 }, + { 0xA640, 0xA641 }, + { 0xA642, 0xA643 }, + { 0xA644, 0xA645 }, + { 0xA646, 0xA647 }, + { 0xA648, 0xA649 }, + { 0xA64A, 0xA64B }, + { 0xA64C, 0xA64D }, + { 0xA64E, 0xA64F }, + { 0xA650, 0xA651 }, + { 0xA652, 0xA653 }, + { 0xA654, 0xA655 }, + { 0xA656, 0xA657 }, + { 0xA658, 0xA659 }, + { 0xA65A, 0xA65B }, + { 0xA65C, 0xA65D }, + { 0xA65E, 0xA65F }, + { 0xA660, 0xA661 }, + { 0xA662, 0xA663 }, + { 0xA664, 0xA665 }, + { 0xA666, 0xA667 }, + { 0xA668, 0xA669 }, + { 0xA66A, 0xA66B }, + { 0xA66C, 0xA66D }, + { 0xA680, 0xA681 }, + { 0xA682, 0xA683 }, + { 0xA684, 0xA685 }, + { 0xA686, 0xA687 }, + { 0xA688, 0xA689 }, + { 0xA68A, 0xA68B }, + { 0xA68C, 0xA68D }, + { 0xA68E, 0xA68F }, + { 0xA690, 0xA691 }, + { 0xA692, 0xA693 }, + { 0xA694, 0xA695 }, + { 0xA696, 0xA697 }, + { 0xA698, 0xA699 }, + { 0xA69A, 0xA69B }, + { 0xA722, 0xA723 }, + { 0xA724, 0xA725 }, + { 0xA726, 0xA727 }, + { 0xA728, 0xA729 }, + { 0xA72A, 0xA72B }, + { 0xA72C, 0xA72D }, + { 0xA72E, 0xA72F }, + { 0xA732, 0xA733 }, + { 0xA734, 0xA735 }, + { 0xA736, 0xA737 }, + { 0xA738, 0xA739 }, + { 0xA73A, 0xA73B }, + { 0xA73C, 0xA73D }, + { 0xA73E, 0xA73F }, + { 0xA740, 0xA741 }, + { 0xA742, 0xA743 }, + { 0xA744, 0xA745 }, + { 0xA746, 0xA747 }, + { 0xA748, 0xA749 }, + { 0xA74A, 0xA74B }, + { 0xA74C, 0xA74D }, + { 0xA74E, 0xA74F }, + { 0xA750, 0xA751 }, + { 0xA752, 0xA753 }, + { 0xA754, 0xA755 }, + { 0xA756, 0xA757 }, + { 0xA758, 0xA759 }, + { 0xA75A, 0xA75B }, + { 0xA75C, 0xA75D }, + { 0xA75E, 0xA75F }, + { 0xA760, 0xA761 }, + { 0xA762, 0xA763 }, + { 0xA764, 0xA765 }, + { 0xA766, 0xA767 }, + { 0xA768, 0xA769 }, + { 0xA76A, 0xA76B }, + { 0xA76C, 0xA76D }, + { 0xA76E, 0xA76F }, + { 0xA779, 0xA77A }, + { 0xA77B, 0xA77C }, + { 0xA77D, 0x1D79 }, + { 0xA77E, 0xA77F }, + { 0xA780, 0xA781 }, + { 0xA782, 0xA783 }, + { 0xA784, 0xA785 }, + { 0xA786, 0xA787 }, + { 0xA78B, 0xA78C }, + { 0xA78D, 0x0265 }, + { 0xA790, 0xA791 }, + { 0xA792, 0xA793 }, + { 0xA796, 0xA797 }, + { 0xA798, 0xA799 }, + { 0xA79A, 0xA79B }, + { 0xA79C, 0xA79D }, + { 0xA79E, 0xA79F }, + { 0xA7A0, 0xA7A1 }, + { 0xA7A2, 0xA7A3 }, + { 0xA7A4, 0xA7A5 }, + { 0xA7A6, 0xA7A7 }, + { 0xA7A8, 0xA7A9 }, + { 0xA7AA, 0x0266 }, + { 0xA7AB, 0x025C }, + { 0xA7AC, 0x0261 }, + { 0xA7AD, 0x026C }, + { 0xA7AE, 0x026A }, + { 0xA7B0, 0x029E }, + { 0xA7B1, 0x0287 }, + { 0xA7B2, 0x029D }, + { 0xA7B3, 0xAB53 }, + { 0xA7B4, 0xA7B5 }, + { 0xA7B6, 0xA7B7 }, + { 0xA7B8, 0xA7B9 }, + { 0xA7BA, 0xA7BB }, + { 0xA7BC, 0xA7BD }, + { 0xA7BE, 0xA7BF }, + { 0xA7C0, 0xA7C1 }, + { 0xA7C2, 0xA7C3 }, + { 0xA7C4, 0xA794 }, + { 0xA7C5, 0x0282 }, + { 0xA7C6, 0x1D8E }, + { 0xA7C7, 0xA7C8 }, + { 0xA7C9, 0xA7CA }, + { 0xA7D0, 0xA7D1 }, + { 0xA7D6, 0xA7D7 }, + { 0xA7D8, 0xA7D9 }, + { 0xA7F5, 0xA7F6 }, + { 0xFF21, 0xFF41 }, + { 0xFF22, 0xFF42 }, + { 0xFF23, 0xFF43 }, + { 0xFF24, 0xFF44 }, + { 0xFF25, 0xFF45 }, + { 0xFF26, 0xFF46 }, + { 0xFF27, 0xFF47 }, + { 0xFF28, 0xFF48 }, + { 0xFF29, 0xFF49 }, + { 0xFF2A, 0xFF4A }, + { 0xFF2B, 0xFF4B }, + { 0xFF2C, 0xFF4C }, + { 0xFF2D, 0xFF4D }, + { 0xFF2E, 0xFF4E }, + { 0xFF2F, 0xFF4F }, + { 0xFF30, 0xFF50 }, + { 0xFF31, 0xFF51 }, + { 0xFF32, 0xFF52 }, + { 0xFF33, 0xFF53 }, + { 0xFF34, 0xFF54 }, + { 0xFF35, 0xFF55 }, + { 0xFF36, 0xFF56 }, + { 0xFF37, 0xFF57 }, + { 0xFF38, 0xFF58 }, + { 0xFF39, 0xFF59 }, + { 0xFF3A, 0xFF5A }, + { 0x10400, 0x10428 }, + { 0x10401, 0x10429 }, + { 0x10402, 0x1042A }, + { 0x10403, 0x1042B }, + { 0x10404, 0x1042C }, + { 0x10405, 0x1042D }, + { 0x10406, 0x1042E }, + { 0x10407, 0x1042F }, + { 0x10408, 0x10430 }, + { 0x10409, 0x10431 }, + { 0x1040A, 0x10432 }, + { 0x1040B, 0x10433 }, + { 0x1040C, 0x10434 }, + { 0x1040D, 0x10435 }, + { 0x1040E, 0x10436 }, + { 0x1040F, 0x10437 }, + { 0x10410, 0x10438 }, + { 0x10411, 0x10439 }, + { 0x10412, 0x1043A }, + { 0x10413, 0x1043B }, + { 0x10414, 0x1043C }, + { 0x10415, 0x1043D }, + { 0x10416, 0x1043E }, + { 0x10417, 0x1043F }, + { 0x10418, 0x10440 }, + { 0x10419, 0x10441 }, + { 0x1041A, 0x10442 }, + { 0x1041B, 0x10443 }, + { 0x1041C, 0x10444 }, + { 0x1041D, 0x10445 }, + { 0x1041E, 0x10446 }, + { 0x1041F, 0x10447 }, + { 0x10420, 0x10448 }, + { 0x10421, 0x10449 }, + { 0x10422, 0x1044A }, + { 0x10423, 0x1044B }, + { 0x10424, 0x1044C }, + { 0x10425, 0x1044D }, + { 0x10426, 0x1044E }, + { 0x10427, 0x1044F }, + { 0x104B0, 0x104D8 }, + { 0x104B1, 0x104D9 }, + { 0x104B2, 0x104DA }, + { 0x104B3, 0x104DB }, + { 0x104B4, 0x104DC }, + { 0x104B5, 0x104DD }, + { 0x104B6, 0x104DE }, + { 0x104B7, 0x104DF }, + { 0x104B8, 0x104E0 }, + { 0x104B9, 0x104E1 }, + { 0x104BA, 0x104E2 }, + { 0x104BB, 0x104E3 }, + { 0x104BC, 0x104E4 }, + { 0x104BD, 0x104E5 }, + { 0x104BE, 0x104E6 }, + { 0x104BF, 0x104E7 }, + { 0x104C0, 0x104E8 }, + { 0x104C1, 0x104E9 }, + { 0x104C2, 0x104EA }, + { 0x104C3, 0x104EB }, + { 0x104C4, 0x104EC }, + { 0x104C5, 0x104ED }, + { 0x104C6, 0x104EE }, + { 0x104C7, 0x104EF }, + { 0x104C8, 0x104F0 }, + { 0x104C9, 0x104F1 }, + { 0x104CA, 0x104F2 }, + { 0x104CB, 0x104F3 }, + { 0x104CC, 0x104F4 }, + { 0x104CD, 0x104F5 }, + { 0x104CE, 0x104F6 }, + { 0x104CF, 0x104F7 }, + { 0x104D0, 0x104F8 }, + { 0x104D1, 0x104F9 }, + { 0x104D2, 0x104FA }, + { 0x104D3, 0x104FB }, + { 0x10570, 0x10597 }, + { 0x10571, 0x10598 }, + { 0x10572, 0x10599 }, + { 0x10573, 0x1059A }, + { 0x10574, 0x1059B }, + { 0x10575, 0x1059C }, + { 0x10576, 0x1059D }, + { 0x10577, 0x1059E }, + { 0x10578, 0x1059F }, + { 0x10579, 0x105A0 }, + { 0x1057A, 0x105A1 }, + { 0x1057C, 0x105A3 }, + { 0x1057D, 0x105A4 }, + { 0x1057E, 0x105A5 }, + { 0x1057F, 0x105A6 }, + { 0x10580, 0x105A7 }, + { 0x10581, 0x105A8 }, + { 0x10582, 0x105A9 }, + { 0x10583, 0x105AA }, + { 0x10584, 0x105AB }, + { 0x10585, 0x105AC }, + { 0x10586, 0x105AD }, + { 0x10587, 0x105AE }, + { 0x10588, 0x105AF }, + { 0x10589, 0x105B0 }, + { 0x1058A, 0x105B1 }, + { 0x1058C, 0x105B3 }, + { 0x1058D, 0x105B4 }, + { 0x1058E, 0x105B5 }, + { 0x1058F, 0x105B6 }, + { 0x10590, 0x105B7 }, + { 0x10591, 0x105B8 }, + { 0x10592, 0x105B9 }, + { 0x10594, 0x105BB }, + { 0x10595, 0x105BC }, + { 0x10C80, 0x10CC0 }, + { 0x10C81, 0x10CC1 }, + { 0x10C82, 0x10CC2 }, + { 0x10C83, 0x10CC3 }, + { 0x10C84, 0x10CC4 }, + { 0x10C85, 0x10CC5 }, + { 0x10C86, 0x10CC6 }, + { 0x10C87, 0x10CC7 }, + { 0x10C88, 0x10CC8 }, + { 0x10C89, 0x10CC9 }, + { 0x10C8A, 0x10CCA }, + { 0x10C8B, 0x10CCB }, + { 0x10C8C, 0x10CCC }, + { 0x10C8D, 0x10CCD }, + { 0x10C8E, 0x10CCE }, + { 0x10C8F, 0x10CCF }, + { 0x10C90, 0x10CD0 }, + { 0x10C91, 0x10CD1 }, + { 0x10C92, 0x10CD2 }, + { 0x10C93, 0x10CD3 }, + { 0x10C94, 0x10CD4 }, + { 0x10C95, 0x10CD5 }, + { 0x10C96, 0x10CD6 }, + { 0x10C97, 0x10CD7 }, + { 0x10C98, 0x10CD8 }, + { 0x10C99, 0x10CD9 }, + { 0x10C9A, 0x10CDA }, + { 0x10C9B, 0x10CDB }, + { 0x10C9C, 0x10CDC }, + { 0x10C9D, 0x10CDD }, + { 0x10C9E, 0x10CDE }, + { 0x10C9F, 0x10CDF }, + { 0x10CA0, 0x10CE0 }, + { 0x10CA1, 0x10CE1 }, + { 0x10CA2, 0x10CE2 }, + { 0x10CA3, 0x10CE3 }, + { 0x10CA4, 0x10CE4 }, + { 0x10CA5, 0x10CE5 }, + { 0x10CA6, 0x10CE6 }, + { 0x10CA7, 0x10CE7 }, + { 0x10CA8, 0x10CE8 }, + { 0x10CA9, 0x10CE9 }, + { 0x10CAA, 0x10CEA }, + { 0x10CAB, 0x10CEB }, + { 0x10CAC, 0x10CEC }, + { 0x10CAD, 0x10CED }, + { 0x10CAE, 0x10CEE }, + { 0x10CAF, 0x10CEF }, + { 0x10CB0, 0x10CF0 }, + { 0x10CB1, 0x10CF1 }, + { 0x10CB2, 0x10CF2 }, + { 0x118A0, 0x118C0 }, + { 0x118A1, 0x118C1 }, + { 0x118A2, 0x118C2 }, + { 0x118A3, 0x118C3 }, + { 0x118A4, 0x118C4 }, + { 0x118A5, 0x118C5 }, + { 0x118A6, 0x118C6 }, + { 0x118A7, 0x118C7 }, + { 0x118A8, 0x118C8 }, + { 0x118A9, 0x118C9 }, + { 0x118AA, 0x118CA }, + { 0x118AB, 0x118CB }, + { 0x118AC, 0x118CC }, + { 0x118AD, 0x118CD }, + { 0x118AE, 0x118CE }, + { 0x118AF, 0x118CF }, + { 0x118B0, 0x118D0 }, + { 0x118B1, 0x118D1 }, + { 0x118B2, 0x118D2 }, + { 0x118B3, 0x118D3 }, + { 0x118B4, 0x118D4 }, + { 0x118B5, 0x118D5 }, + { 0x118B6, 0x118D6 }, + { 0x118B7, 0x118D7 }, + { 0x118B8, 0x118D8 }, + { 0x118B9, 0x118D9 }, + { 0x118BA, 0x118DA }, + { 0x118BB, 0x118DB }, + { 0x118BC, 0x118DC }, + { 0x118BD, 0x118DD }, + { 0x118BE, 0x118DE }, + { 0x118BF, 0x118DF }, + { 0x16E40, 0x16E60 }, + { 0x16E41, 0x16E61 }, + { 0x16E42, 0x16E62 }, + { 0x16E43, 0x16E63 }, + { 0x16E44, 0x16E64 }, + { 0x16E45, 0x16E65 }, + { 0x16E46, 0x16E66 }, + { 0x16E47, 0x16E67 }, + { 0x16E48, 0x16E68 }, + { 0x16E49, 0x16E69 }, + { 0x16E4A, 0x16E6A }, + { 0x16E4B, 0x16E6B }, + { 0x16E4C, 0x16E6C }, + { 0x16E4D, 0x16E6D }, + { 0x16E4E, 0x16E6E }, + { 0x16E4F, 0x16E6F }, + { 0x16E50, 0x16E70 }, + { 0x16E51, 0x16E71 }, + { 0x16E52, 0x16E72 }, + { 0x16E53, 0x16E73 }, + { 0x16E54, 0x16E74 }, + { 0x16E55, 0x16E75 }, + { 0x16E56, 0x16E76 }, + { 0x16E57, 0x16E77 }, + { 0x16E58, 0x16E78 }, + { 0x16E59, 0x16E79 }, + { 0x16E5A, 0x16E7A }, + { 0x16E5B, 0x16E7B }, + { 0x16E5C, 0x16E7C }, + { 0x16E5D, 0x16E7D }, + { 0x16E5E, 0x16E7E }, + { 0x16E5F, 0x16E7F }, + { 0x1E900, 0x1E922 }, + { 0x1E901, 0x1E923 }, + { 0x1E902, 0x1E924 }, + { 0x1E903, 0x1E925 }, + { 0x1E904, 0x1E926 }, + { 0x1E905, 0x1E927 }, + { 0x1E906, 0x1E928 }, + { 0x1E907, 0x1E929 }, + { 0x1E908, 0x1E92A }, + { 0x1E909, 0x1E92B }, + { 0x1E90A, 0x1E92C }, + { 0x1E90B, 0x1E92D }, + { 0x1E90C, 0x1E92E }, + { 0x1E90D, 0x1E92F }, + { 0x1E90E, 0x1E930 }, + { 0x1E90F, 0x1E931 }, + { 0x1E910, 0x1E932 }, + { 0x1E911, 0x1E933 }, + { 0x1E912, 0x1E934 }, + { 0x1E913, 0x1E935 }, + { 0x1E914, 0x1E936 }, + { 0x1E915, 0x1E937 }, + { 0x1E916, 0x1E938 }, + { 0x1E917, 0x1E939 }, + { 0x1E918, 0x1E93A }, + { 0x1E919, 0x1E93B }, + { 0x1E91A, 0x1E93C }, + { 0x1E91B, 0x1E93D }, + { 0x1E91C, 0x1E93E }, + { 0x1E91D, 0x1E93F }, + { 0x1E91E, 0x1E940 }, + { 0x1E91F, 0x1E941 }, + { 0x1E920, 0x1E942 }, + { 0x1E921, 0x1E943 } + +#define MAP(c) uc_tolower (c) +#include "test-mapping-part2.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/.gitignore b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/.gitignore new file mode 100644 index 00000000..e77e0507 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/.gitignore @@ -0,0 +1,14 @@ +/test-ctype_alnum.c +/test-ctype_alpha.c +/test-ctype_blank.c +/test-ctype_cntrl.c +/test-ctype_digit.c +/test-ctype_graph.c +/test-ctype_lower.c +/test-ctype_print.c +/test-ctype_punct.c +/test-ctype_space.c +/test-ctype_upper.c +/test-ctype_xdigit.c +/test-predicate-part1.h +/test-predicate-part2.h diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/test-ctype_alnum.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/test-ctype_alnum.c new file mode 100644 index 00000000..7947a92b --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/test-ctype_alnum.c @@ -0,0 +1,738 @@ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +/* Test the Unicode character type functions. + Copyright (C) 2007-2022 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 the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + This file 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 . */ + +#include "test-predicate-part1.h" + + { 0x0030, 0x0039 }, + { 0x0041, 0x005A }, + { 0x0061, 0x007A }, + { 0x00AA, 0x00AA }, + { 0x00B5, 0x00B5 }, + { 0x00BA, 0x00BA }, + { 0x00C0, 0x00D6 }, + { 0x00D8, 0x00F6 }, + { 0x00F8, 0x02C1 }, + { 0x02C6, 0x02D1 }, + { 0x02E0, 0x02E4 }, + { 0x02EC, 0x02EC }, + { 0x02EE, 0x02EE }, + { 0x0345, 0x0345 }, + { 0x0370, 0x0374 }, + { 0x0376, 0x0377 }, + { 0x037A, 0x037D }, + { 0x037F, 0x037F }, + { 0x0386, 0x0386 }, + { 0x0388, 0x038A }, + { 0x038C, 0x038C }, + { 0x038E, 0x03A1 }, + { 0x03A3, 0x03F5 }, + { 0x03F7, 0x0481 }, + { 0x048A, 0x052F }, + { 0x0531, 0x0556 }, + { 0x0559, 0x0559 }, + { 0x0560, 0x0588 }, + { 0x05D0, 0x05EA }, + { 0x05EF, 0x05F2 }, + { 0x0620, 0x064A }, + { 0x0660, 0x0669 }, + { 0x066E, 0x066F }, + { 0x0671, 0x06D3 }, + { 0x06D5, 0x06D5 }, + { 0x06E5, 0x06E6 }, + { 0x06EE, 0x06FC }, + { 0x06FF, 0x06FF }, + { 0x0710, 0x0710 }, + { 0x0712, 0x072F }, + { 0x074D, 0x07A5 }, + { 0x07B1, 0x07B1 }, + { 0x07C0, 0x07EA }, + { 0x07F4, 0x07F5 }, + { 0x07FA, 0x07FA }, + { 0x0800, 0x0815 }, + { 0x081A, 0x081A }, + { 0x0824, 0x0824 }, + { 0x0828, 0x0828 }, + { 0x0840, 0x0858 }, + { 0x0860, 0x086A }, + { 0x0870, 0x0887 }, + { 0x0889, 0x088E }, + { 0x08A0, 0x08C9 }, + { 0x0904, 0x0939 }, + { 0x093D, 0x093D }, + { 0x0950, 0x0950 }, + { 0x0958, 0x0961 }, + { 0x0966, 0x096F }, + { 0x0971, 0x0980 }, + { 0x0985, 0x098C }, + { 0x098F, 0x0990 }, + { 0x0993, 0x09A8 }, + { 0x09AA, 0x09B0 }, + { 0x09B2, 0x09B2 }, + { 0x09B6, 0x09B9 }, + { 0x09BD, 0x09BD }, + { 0x09CE, 0x09CE }, + { 0x09DC, 0x09DD }, + { 0x09DF, 0x09E1 }, + { 0x09E6, 0x09F1 }, + { 0x09FC, 0x09FC }, + { 0x0A05, 0x0A0A }, + { 0x0A0F, 0x0A10 }, + { 0x0A13, 0x0A28 }, + { 0x0A2A, 0x0A30 }, + { 0x0A32, 0x0A33 }, + { 0x0A35, 0x0A36 }, + { 0x0A38, 0x0A39 }, + { 0x0A59, 0x0A5C }, + { 0x0A5E, 0x0A5E }, + { 0x0A66, 0x0A6F }, + { 0x0A72, 0x0A74 }, + { 0x0A85, 0x0A8D }, + { 0x0A8F, 0x0A91 }, + { 0x0A93, 0x0AA8 }, + { 0x0AAA, 0x0AB0 }, + { 0x0AB2, 0x0AB3 }, + { 0x0AB5, 0x0AB9 }, + { 0x0ABD, 0x0ABD }, + { 0x0AD0, 0x0AD0 }, + { 0x0AE0, 0x0AE1 }, + { 0x0AE6, 0x0AEF }, + { 0x0AF9, 0x0AF9 }, + { 0x0B05, 0x0B0C }, + { 0x0B0F, 0x0B10 }, + { 0x0B13, 0x0B28 }, + { 0x0B2A, 0x0B30 }, + { 0x0B32, 0x0B33 }, + { 0x0B35, 0x0B39 }, + { 0x0B3D, 0x0B3D }, + { 0x0B5C, 0x0B5D }, + { 0x0B5F, 0x0B61 }, + { 0x0B66, 0x0B6F }, + { 0x0B71, 0x0B71 }, + { 0x0B83, 0x0B83 }, + { 0x0B85, 0x0B8A }, + { 0x0B8E, 0x0B90 }, + { 0x0B92, 0x0B95 }, + { 0x0B99, 0x0B9A }, + { 0x0B9C, 0x0B9C }, + { 0x0B9E, 0x0B9F }, + { 0x0BA3, 0x0BA4 }, + { 0x0BA8, 0x0BAA }, + { 0x0BAE, 0x0BB9 }, + { 0x0BD0, 0x0BD0 }, + { 0x0BE6, 0x0BEF }, + { 0x0C05, 0x0C0C }, + { 0x0C0E, 0x0C10 }, + { 0x0C12, 0x0C28 }, + { 0x0C2A, 0x0C39 }, + { 0x0C3D, 0x0C3D }, + { 0x0C58, 0x0C5A }, + { 0x0C5D, 0x0C5D }, + { 0x0C60, 0x0C61 }, + { 0x0C66, 0x0C6F }, + { 0x0C80, 0x0C80 }, + { 0x0C85, 0x0C8C }, + { 0x0C8E, 0x0C90 }, + { 0x0C92, 0x0CA8 }, + { 0x0CAA, 0x0CB3 }, + { 0x0CB5, 0x0CB9 }, + { 0x0CBD, 0x0CBD }, + { 0x0CDD, 0x0CDE }, + { 0x0CE0, 0x0CE1 }, + { 0x0CE6, 0x0CEF }, + { 0x0CF1, 0x0CF2 }, + { 0x0D04, 0x0D0C }, + { 0x0D0E, 0x0D10 }, + { 0x0D12, 0x0D3A }, + { 0x0D3D, 0x0D3D }, + { 0x0D4E, 0x0D4E }, + { 0x0D54, 0x0D56 }, + { 0x0D5F, 0x0D61 }, + { 0x0D66, 0x0D6F }, + { 0x0D7A, 0x0D7F }, + { 0x0D85, 0x0D96 }, + { 0x0D9A, 0x0DB1 }, + { 0x0DB3, 0x0DBB }, + { 0x0DBD, 0x0DBD }, + { 0x0DC0, 0x0DC6 }, + { 0x0DE6, 0x0DEF }, + { 0x0E01, 0x0E2E }, + { 0x0E30, 0x0E3A }, + { 0x0E40, 0x0E45 }, + { 0x0E47, 0x0E4E }, + { 0x0E50, 0x0E59 }, + { 0x0E81, 0x0E82 }, + { 0x0E84, 0x0E84 }, + { 0x0E86, 0x0E8A }, + { 0x0E8C, 0x0EA3 }, + { 0x0EA5, 0x0EA5 }, + { 0x0EA7, 0x0EB0 }, + { 0x0EB2, 0x0EB3 }, + { 0x0EBD, 0x0EBD }, + { 0x0EC0, 0x0EC4 }, + { 0x0EC6, 0x0EC6 }, + { 0x0ED0, 0x0ED9 }, + { 0x0EDC, 0x0EDF }, + { 0x0F00, 0x0F00 }, + { 0x0F20, 0x0F29 }, + { 0x0F40, 0x0F47 }, + { 0x0F49, 0x0F6C }, + { 0x0F88, 0x0F8C }, + { 0x1000, 0x102A }, + { 0x103F, 0x1049 }, + { 0x1050, 0x1055 }, + { 0x105A, 0x105D }, + { 0x1061, 0x1061 }, + { 0x1065, 0x1066 }, + { 0x106E, 0x1070 }, + { 0x1075, 0x1081 }, + { 0x108E, 0x108E }, + { 0x1090, 0x1099 }, + { 0x10A0, 0x10C5 }, + { 0x10C7, 0x10C7 }, + { 0x10CD, 0x10CD }, + { 0x10D0, 0x10FA }, + { 0x10FC, 0x1248 }, + { 0x124A, 0x124D }, + { 0x1250, 0x1256 }, + { 0x1258, 0x1258 }, + { 0x125A, 0x125D }, + { 0x1260, 0x1288 }, + { 0x128A, 0x128D }, + { 0x1290, 0x12B0 }, + { 0x12B2, 0x12B5 }, + { 0x12B8, 0x12BE }, + { 0x12C0, 0x12C0 }, + { 0x12C2, 0x12C5 }, + { 0x12C8, 0x12D6 }, + { 0x12D8, 0x1310 }, + { 0x1312, 0x1315 }, + { 0x1318, 0x135A }, + { 0x1380, 0x138F }, + { 0x13A0, 0x13F5 }, + { 0x13F8, 0x13FD }, + { 0x1401, 0x166C }, + { 0x166F, 0x167F }, + { 0x1681, 0x169A }, + { 0x16A0, 0x16EA }, + { 0x16EE, 0x16F8 }, + { 0x1700, 0x1711 }, + { 0x171F, 0x1731 }, + { 0x1740, 0x1751 }, + { 0x1760, 0x176C }, + { 0x176E, 0x1770 }, + { 0x1780, 0x17B3 }, + { 0x17D7, 0x17D7 }, + { 0x17DC, 0x17DC }, + { 0x17E0, 0x17E9 }, + { 0x1810, 0x1819 }, + { 0x1820, 0x1878 }, + { 0x1880, 0x1884 }, + { 0x1887, 0x18A8 }, + { 0x18AA, 0x18AA }, + { 0x18B0, 0x18F5 }, + { 0x1900, 0x191E }, + { 0x1946, 0x196D }, + { 0x1970, 0x1974 }, + { 0x1980, 0x19AB }, + { 0x19B0, 0x19C9 }, + { 0x19D0, 0x19D9 }, + { 0x1A00, 0x1A16 }, + { 0x1A20, 0x1A54 }, + { 0x1A80, 0x1A89 }, + { 0x1A90, 0x1A99 }, + { 0x1AA7, 0x1AA7 }, + { 0x1B05, 0x1B33 }, + { 0x1B45, 0x1B4C }, + { 0x1B50, 0x1B59 }, + { 0x1B83, 0x1BA0 }, + { 0x1BAE, 0x1BE5 }, + { 0x1C00, 0x1C23 }, + { 0x1C40, 0x1C49 }, + { 0x1C4D, 0x1C7D }, + { 0x1C80, 0x1C88 }, + { 0x1C90, 0x1CBA }, + { 0x1CBD, 0x1CBF }, + { 0x1CE9, 0x1CEC }, + { 0x1CEE, 0x1CF3 }, + { 0x1CF5, 0x1CF6 }, + { 0x1CFA, 0x1CFA }, + { 0x1D00, 0x1DBF }, + { 0x1E00, 0x1F15 }, + { 0x1F18, 0x1F1D }, + { 0x1F20, 0x1F45 }, + { 0x1F48, 0x1F4D }, + { 0x1F50, 0x1F57 }, + { 0x1F59, 0x1F59 }, + { 0x1F5B, 0x1F5B }, + { 0x1F5D, 0x1F5D }, + { 0x1F5F, 0x1F7D }, + { 0x1F80, 0x1FB4 }, + { 0x1FB6, 0x1FBC }, + { 0x1FBE, 0x1FBE }, + { 0x1FC2, 0x1FC4 }, + { 0x1FC6, 0x1FCC }, + { 0x1FD0, 0x1FD3 }, + { 0x1FD6, 0x1FDB }, + { 0x1FE0, 0x1FEC }, + { 0x1FF2, 0x1FF4 }, + { 0x1FF6, 0x1FFC }, + { 0x2071, 0x2071 }, + { 0x207F, 0x207F }, + { 0x2090, 0x209C }, + { 0x2102, 0x2102 }, + { 0x2107, 0x2107 }, + { 0x210A, 0x2113 }, + { 0x2115, 0x2115 }, + { 0x2119, 0x211D }, + { 0x2124, 0x2124 }, + { 0x2126, 0x2126 }, + { 0x2128, 0x212D }, + { 0x212F, 0x2139 }, + { 0x213C, 0x213F }, + { 0x2145, 0x2149 }, + { 0x214E, 0x214E }, + { 0x2160, 0x2188 }, + { 0x249C, 0x24E9 }, + { 0x2C00, 0x2CE4 }, + { 0x2CEB, 0x2CEE }, + { 0x2CF2, 0x2CF3 }, + { 0x2D00, 0x2D25 }, + { 0x2D27, 0x2D27 }, + { 0x2D2D, 0x2D2D }, + { 0x2D30, 0x2D67 }, + { 0x2D6F, 0x2D6F }, + { 0x2D80, 0x2D96 }, + { 0x2DA0, 0x2DA6 }, + { 0x2DA8, 0x2DAE }, + { 0x2DB0, 0x2DB6 }, + { 0x2DB8, 0x2DBE }, + { 0x2DC0, 0x2DC6 }, + { 0x2DC8, 0x2DCE }, + { 0x2DD0, 0x2DD6 }, + { 0x2DD8, 0x2DDE }, + { 0x2E2F, 0x2E2F }, + { 0x3005, 0x3007 }, + { 0x3021, 0x3029 }, + { 0x3031, 0x3035 }, + { 0x3038, 0x303C }, + { 0x3041, 0x3096 }, + { 0x309D, 0x309F }, + { 0x30A1, 0x30FA }, + { 0x30FC, 0x30FF }, + { 0x3105, 0x312F }, + { 0x3131, 0x318E }, + { 0x31A0, 0x31BF }, + { 0x31F0, 0x31FF }, + { 0x3400, 0x4DBF }, + { 0x4E00, 0xA48C }, + { 0xA4D0, 0xA4FD }, + { 0xA500, 0xA60C }, + { 0xA610, 0xA62B }, + { 0xA640, 0xA66E }, + { 0xA67F, 0xA69D }, + { 0xA6A0, 0xA6EF }, + { 0xA717, 0xA71F }, + { 0xA722, 0xA788 }, + { 0xA78B, 0xA7CA }, + { 0xA7D0, 0xA7D1 }, + { 0xA7D3, 0xA7D3 }, + { 0xA7D5, 0xA7D9 }, + { 0xA7F2, 0xA801 }, + { 0xA803, 0xA805 }, + { 0xA807, 0xA80A }, + { 0xA80C, 0xA822 }, + { 0xA840, 0xA873 }, + { 0xA882, 0xA8B3 }, + { 0xA8D0, 0xA8D9 }, + { 0xA8F2, 0xA8F7 }, + { 0xA8FB, 0xA8FB }, + { 0xA8FD, 0xA8FE }, + { 0xA900, 0xA925 }, + { 0xA930, 0xA946 }, + { 0xA960, 0xA97C }, + { 0xA984, 0xA9B2 }, + { 0xA9CF, 0xA9D9 }, + { 0xA9E0, 0xA9E4 }, + { 0xA9E6, 0xA9FE }, + { 0xAA00, 0xAA28 }, + { 0xAA40, 0xAA42 }, + { 0xAA44, 0xAA4B }, + { 0xAA50, 0xAA59 }, + { 0xAA60, 0xAA76 }, + { 0xAA7A, 0xAA7A }, + { 0xAA7E, 0xAAAF }, + { 0xAAB1, 0xAAB1 }, + { 0xAAB5, 0xAAB6 }, + { 0xAAB9, 0xAABD }, + { 0xAAC0, 0xAAC0 }, + { 0xAAC2, 0xAAC2 }, + { 0xAADB, 0xAADD }, + { 0xAAE0, 0xAAEA }, + { 0xAAF2, 0xAAF4 }, + { 0xAB01, 0xAB06 }, + { 0xAB09, 0xAB0E }, + { 0xAB11, 0xAB16 }, + { 0xAB20, 0xAB26 }, + { 0xAB28, 0xAB2E }, + { 0xAB30, 0xAB5A }, + { 0xAB5C, 0xAB69 }, + { 0xAB70, 0xABE2 }, + { 0xABF0, 0xABF9 }, + { 0xAC00, 0xD7A3 }, + { 0xD7B0, 0xD7C6 }, + { 0xD7CB, 0xD7FB }, + { 0xF900, 0xFA6D }, + { 0xFA70, 0xFAD9 }, + { 0xFB00, 0xFB06 }, + { 0xFB13, 0xFB17 }, + { 0xFB1D, 0xFB1D }, + { 0xFB1F, 0xFB28 }, + { 0xFB2A, 0xFB36 }, + { 0xFB38, 0xFB3C }, + { 0xFB3E, 0xFB3E }, + { 0xFB40, 0xFB41 }, + { 0xFB43, 0xFB44 }, + { 0xFB46, 0xFBB1 }, + { 0xFBD3, 0xFD3D }, + { 0xFD50, 0xFD8F }, + { 0xFD92, 0xFDC7 }, + { 0xFDF0, 0xFDFB }, + { 0xFE70, 0xFE74 }, + { 0xFE76, 0xFEFC }, + { 0xFF10, 0xFF19 }, + { 0xFF21, 0xFF3A }, + { 0xFF41, 0xFF5A }, + { 0xFF66, 0xFFBE }, + { 0xFFC2, 0xFFC7 }, + { 0xFFCA, 0xFFCF }, + { 0xFFD2, 0xFFD7 }, + { 0xFFDA, 0xFFDC }, + { 0x10000, 0x1000B }, + { 0x1000D, 0x10026 }, + { 0x10028, 0x1003A }, + { 0x1003C, 0x1003D }, + { 0x1003F, 0x1004D }, + { 0x10050, 0x1005D }, + { 0x10080, 0x100FA }, + { 0x10140, 0x10174 }, + { 0x10280, 0x1029C }, + { 0x102A0, 0x102D0 }, + { 0x10300, 0x1031F }, + { 0x1032D, 0x1034A }, + { 0x10350, 0x10375 }, + { 0x10380, 0x1039D }, + { 0x103A0, 0x103C3 }, + { 0x103C8, 0x103CF }, + { 0x103D1, 0x103D5 }, + { 0x10400, 0x1049D }, + { 0x104A0, 0x104A9 }, + { 0x104B0, 0x104D3 }, + { 0x104D8, 0x104FB }, + { 0x10500, 0x10527 }, + { 0x10530, 0x10563 }, + { 0x10570, 0x1057A }, + { 0x1057C, 0x1058A }, + { 0x1058C, 0x10592 }, + { 0x10594, 0x10595 }, + { 0x10597, 0x105A1 }, + { 0x105A3, 0x105B1 }, + { 0x105B3, 0x105B9 }, + { 0x105BB, 0x105BC }, + { 0x10600, 0x10736 }, + { 0x10740, 0x10755 }, + { 0x10760, 0x10767 }, + { 0x10780, 0x10785 }, + { 0x10787, 0x107B0 }, + { 0x107B2, 0x107BA }, + { 0x10800, 0x10805 }, + { 0x10808, 0x10808 }, + { 0x1080A, 0x10835 }, + { 0x10837, 0x10838 }, + { 0x1083C, 0x1083C }, + { 0x1083F, 0x10855 }, + { 0x10860, 0x10876 }, + { 0x10880, 0x1089E }, + { 0x108E0, 0x108F2 }, + { 0x108F4, 0x108F5 }, + { 0x10900, 0x10915 }, + { 0x10920, 0x10939 }, + { 0x10980, 0x109B7 }, + { 0x109BE, 0x109BF }, + { 0x10A00, 0x10A00 }, + { 0x10A10, 0x10A13 }, + { 0x10A15, 0x10A17 }, + { 0x10A19, 0x10A35 }, + { 0x10A60, 0x10A7C }, + { 0x10A80, 0x10A9C }, + { 0x10AC0, 0x10AC7 }, + { 0x10AC9, 0x10AE4 }, + { 0x10B00, 0x10B35 }, + { 0x10B40, 0x10B55 }, + { 0x10B60, 0x10B72 }, + { 0x10B80, 0x10B91 }, + { 0x10C00, 0x10C48 }, + { 0x10C80, 0x10CB2 }, + { 0x10CC0, 0x10CF2 }, + { 0x10D00, 0x10D23 }, + { 0x10D30, 0x10D39 }, + { 0x10E80, 0x10EA9 }, + { 0x10EB0, 0x10EB1 }, + { 0x10F00, 0x10F1C }, + { 0x10F27, 0x10F27 }, + { 0x10F30, 0x10F45 }, + { 0x10F70, 0x10F81 }, + { 0x10FB0, 0x10FC4 }, + { 0x10FE0, 0x10FF6 }, + { 0x11003, 0x11037 }, + { 0x11066, 0x1106F }, + { 0x11071, 0x11072 }, + { 0x11075, 0x11075 }, + { 0x11083, 0x110AF }, + { 0x110D0, 0x110E8 }, + { 0x110F0, 0x110F9 }, + { 0x11103, 0x11126 }, + { 0x11136, 0x1113F }, + { 0x11144, 0x11144 }, + { 0x11147, 0x11147 }, + { 0x11150, 0x11172 }, + { 0x11176, 0x11176 }, + { 0x11183, 0x111B2 }, + { 0x111C1, 0x111C4 }, + { 0x111D0, 0x111DA }, + { 0x111DC, 0x111DC }, + { 0x11200, 0x11211 }, + { 0x11213, 0x1122B }, + { 0x1123F, 0x11240 }, + { 0x11280, 0x11286 }, + { 0x11288, 0x11288 }, + { 0x1128A, 0x1128D }, + { 0x1128F, 0x1129D }, + { 0x1129F, 0x112A8 }, + { 0x112B0, 0x112DE }, + { 0x112F0, 0x112F9 }, + { 0x11305, 0x1130C }, + { 0x1130F, 0x11310 }, + { 0x11313, 0x11328 }, + { 0x1132A, 0x11330 }, + { 0x11332, 0x11333 }, + { 0x11335, 0x11339 }, + { 0x1133D, 0x1133D }, + { 0x11350, 0x11350 }, + { 0x1135D, 0x11361 }, + { 0x11400, 0x11434 }, + { 0x11447, 0x1144A }, + { 0x11450, 0x11459 }, + { 0x1145F, 0x11461 }, + { 0x11480, 0x114AF }, + { 0x114C4, 0x114C5 }, + { 0x114C7, 0x114C7 }, + { 0x114D0, 0x114D9 }, + { 0x11580, 0x115AE }, + { 0x115D8, 0x115DB }, + { 0x11600, 0x1162F }, + { 0x11644, 0x11644 }, + { 0x11650, 0x11659 }, + { 0x11680, 0x116AA }, + { 0x116B8, 0x116B8 }, + { 0x116C0, 0x116C9 }, + { 0x11700, 0x1171A }, + { 0x11730, 0x11739 }, + { 0x11740, 0x11746 }, + { 0x11800, 0x1182B }, + { 0x118A0, 0x118E9 }, + { 0x118FF, 0x11906 }, + { 0x11909, 0x11909 }, + { 0x1190C, 0x11913 }, + { 0x11915, 0x11916 }, + { 0x11918, 0x1192F }, + { 0x1193F, 0x1193F }, + { 0x11941, 0x11941 }, + { 0x11950, 0x11959 }, + { 0x119A0, 0x119A7 }, + { 0x119AA, 0x119D0 }, + { 0x119E1, 0x119E1 }, + { 0x119E3, 0x119E3 }, + { 0x11A00, 0x11A00 }, + { 0x11A0B, 0x11A32 }, + { 0x11A3A, 0x11A3A }, + { 0x11A50, 0x11A50 }, + { 0x11A5C, 0x11A89 }, + { 0x11A9D, 0x11A9D }, + { 0x11AB0, 0x11AF8 }, + { 0x11C00, 0x11C08 }, + { 0x11C0A, 0x11C2E }, + { 0x11C40, 0x11C40 }, + { 0x11C50, 0x11C59 }, + { 0x11C72, 0x11C8F }, + { 0x11D00, 0x11D06 }, + { 0x11D08, 0x11D09 }, + { 0x11D0B, 0x11D30 }, + { 0x11D46, 0x11D46 }, + { 0x11D50, 0x11D59 }, + { 0x11D60, 0x11D65 }, + { 0x11D67, 0x11D68 }, + { 0x11D6A, 0x11D89 }, + { 0x11D98, 0x11D98 }, + { 0x11DA0, 0x11DA9 }, + { 0x11EE0, 0x11EF2 }, + { 0x11F02, 0x11F02 }, + { 0x11F04, 0x11F10 }, + { 0x11F12, 0x11F33 }, + { 0x11F50, 0x11F59 }, + { 0x11FB0, 0x11FB0 }, + { 0x12000, 0x12399 }, + { 0x12400, 0x1246E }, + { 0x12480, 0x12543 }, + { 0x12F90, 0x12FF0 }, + { 0x13000, 0x1342F }, + { 0x13441, 0x13446 }, + { 0x14400, 0x14646 }, + { 0x16800, 0x16A38 }, + { 0x16A40, 0x16A5E }, + { 0x16A60, 0x16A69 }, + { 0x16A70, 0x16ABE }, + { 0x16AC0, 0x16AC9 }, + { 0x16AD0, 0x16AED }, + { 0x16B00, 0x16B2F }, + { 0x16B40, 0x16B43 }, + { 0x16B50, 0x16B59 }, + { 0x16B63, 0x16B77 }, + { 0x16B7D, 0x16B8F }, + { 0x16E40, 0x16E7F }, + { 0x16F00, 0x16F4A }, + { 0x16F50, 0x16F50 }, + { 0x16F93, 0x16F9F }, + { 0x16FE0, 0x16FE1 }, + { 0x16FE3, 0x16FE3 }, + { 0x17000, 0x187F7 }, + { 0x18800, 0x18CD5 }, + { 0x18D00, 0x18D08 }, + { 0x1AFF0, 0x1AFF3 }, + { 0x1AFF5, 0x1AFFB }, + { 0x1AFFD, 0x1AFFE }, + { 0x1B000, 0x1B122 }, + { 0x1B132, 0x1B132 }, + { 0x1B150, 0x1B152 }, + { 0x1B155, 0x1B155 }, + { 0x1B164, 0x1B167 }, + { 0x1B170, 0x1B2FB }, + { 0x1BC00, 0x1BC6A }, + { 0x1BC70, 0x1BC7C }, + { 0x1BC80, 0x1BC88 }, + { 0x1BC90, 0x1BC99 }, + { 0x1D400, 0x1D454 }, + { 0x1D456, 0x1D49C }, + { 0x1D49E, 0x1D49F }, + { 0x1D4A2, 0x1D4A2 }, + { 0x1D4A5, 0x1D4A6 }, + { 0x1D4A9, 0x1D4AC }, + { 0x1D4AE, 0x1D4B9 }, + { 0x1D4BB, 0x1D4BB }, + { 0x1D4BD, 0x1D4C3 }, + { 0x1D4C5, 0x1D505 }, + { 0x1D507, 0x1D50A }, + { 0x1D50D, 0x1D514 }, + { 0x1D516, 0x1D51C }, + { 0x1D51E, 0x1D539 }, + { 0x1D53B, 0x1D53E }, + { 0x1D540, 0x1D544 }, + { 0x1D546, 0x1D546 }, + { 0x1D54A, 0x1D550 }, + { 0x1D552, 0x1D6A5 }, + { 0x1D6A8, 0x1D6C0 }, + { 0x1D6C2, 0x1D6DA }, + { 0x1D6DC, 0x1D6FA }, + { 0x1D6FC, 0x1D714 }, + { 0x1D716, 0x1D734 }, + { 0x1D736, 0x1D74E }, + { 0x1D750, 0x1D76E }, + { 0x1D770, 0x1D788 }, + { 0x1D78A, 0x1D7A8 }, + { 0x1D7AA, 0x1D7C2 }, + { 0x1D7C4, 0x1D7CB }, + { 0x1D7CE, 0x1D7FF }, + { 0x1DF00, 0x1DF1E }, + { 0x1DF25, 0x1DF2A }, + { 0x1E030, 0x1E06D }, + { 0x1E100, 0x1E12C }, + { 0x1E137, 0x1E13D }, + { 0x1E140, 0x1E149 }, + { 0x1E14E, 0x1E14E }, + { 0x1E290, 0x1E2AD }, + { 0x1E2C0, 0x1E2EB }, + { 0x1E2F0, 0x1E2F9 }, + { 0x1E4D0, 0x1E4EB }, + { 0x1E4F0, 0x1E4F9 }, + { 0x1E7E0, 0x1E7E6 }, + { 0x1E7E8, 0x1E7EB }, + { 0x1E7ED, 0x1E7EE }, + { 0x1E7F0, 0x1E7FE }, + { 0x1E800, 0x1E8C4 }, + { 0x1E900, 0x1E943 }, + { 0x1E94B, 0x1E94B }, + { 0x1E950, 0x1E959 }, + { 0x1EE00, 0x1EE03 }, + { 0x1EE05, 0x1EE1F }, + { 0x1EE21, 0x1EE22 }, + { 0x1EE24, 0x1EE24 }, + { 0x1EE27, 0x1EE27 }, + { 0x1EE29, 0x1EE32 }, + { 0x1EE34, 0x1EE37 }, + { 0x1EE39, 0x1EE39 }, + { 0x1EE3B, 0x1EE3B }, + { 0x1EE42, 0x1EE42 }, + { 0x1EE47, 0x1EE47 }, + { 0x1EE49, 0x1EE49 }, + { 0x1EE4B, 0x1EE4B }, + { 0x1EE4D, 0x1EE4F }, + { 0x1EE51, 0x1EE52 }, + { 0x1EE54, 0x1EE54 }, + { 0x1EE57, 0x1EE57 }, + { 0x1EE59, 0x1EE59 }, + { 0x1EE5B, 0x1EE5B }, + { 0x1EE5D, 0x1EE5D }, + { 0x1EE5F, 0x1EE5F }, + { 0x1EE61, 0x1EE62 }, + { 0x1EE64, 0x1EE64 }, + { 0x1EE67, 0x1EE6A }, + { 0x1EE6C, 0x1EE72 }, + { 0x1EE74, 0x1EE77 }, + { 0x1EE79, 0x1EE7C }, + { 0x1EE7E, 0x1EE7E }, + { 0x1EE80, 0x1EE89 }, + { 0x1EE8B, 0x1EE9B }, + { 0x1EEA1, 0x1EEA3 }, + { 0x1EEA5, 0x1EEA9 }, + { 0x1EEAB, 0x1EEBB }, + { 0x1F110, 0x1F12C }, + { 0x1F130, 0x1F149 }, + { 0x1F150, 0x1F169 }, + { 0x1F170, 0x1F18A }, + { 0x1F1A5, 0x1F1A5 }, + { 0x1F1E6, 0x1F1FF }, + { 0x1FBF0, 0x1FBF9 }, + { 0x20000, 0x2A6DF }, + { 0x2A700, 0x2B739 }, + { 0x2B740, 0x2B81D }, + { 0x2B820, 0x2CEA1 }, + { 0x2CEB0, 0x2EBE0 }, + { 0x2F800, 0x2FA1D }, + { 0x30000, 0x3134A }, + { 0x31350, 0x323AF } + +#define PREDICATE(c) uc_is_alnum (c) +#include "test-predicate-part2.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/test-ctype_alpha.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/test-ctype_alpha.c new file mode 100644 index 00000000..284d964e --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/test-ctype_alpha.c @@ -0,0 +1,737 @@ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +/* Test the Unicode character type functions. + Copyright (C) 2007-2022 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 the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + This file 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 . */ + +#include "test-predicate-part1.h" + + { 0x0041, 0x005A }, + { 0x0061, 0x007A }, + { 0x00AA, 0x00AA }, + { 0x00B5, 0x00B5 }, + { 0x00BA, 0x00BA }, + { 0x00C0, 0x00D6 }, + { 0x00D8, 0x00F6 }, + { 0x00F8, 0x02C1 }, + { 0x02C6, 0x02D1 }, + { 0x02E0, 0x02E4 }, + { 0x02EC, 0x02EC }, + { 0x02EE, 0x02EE }, + { 0x0345, 0x0345 }, + { 0x0370, 0x0374 }, + { 0x0376, 0x0377 }, + { 0x037A, 0x037D }, + { 0x037F, 0x037F }, + { 0x0386, 0x0386 }, + { 0x0388, 0x038A }, + { 0x038C, 0x038C }, + { 0x038E, 0x03A1 }, + { 0x03A3, 0x03F5 }, + { 0x03F7, 0x0481 }, + { 0x048A, 0x052F }, + { 0x0531, 0x0556 }, + { 0x0559, 0x0559 }, + { 0x0560, 0x0588 }, + { 0x05D0, 0x05EA }, + { 0x05EF, 0x05F2 }, + { 0x0620, 0x064A }, + { 0x0660, 0x0669 }, + { 0x066E, 0x066F }, + { 0x0671, 0x06D3 }, + { 0x06D5, 0x06D5 }, + { 0x06E5, 0x06E6 }, + { 0x06EE, 0x06FC }, + { 0x06FF, 0x06FF }, + { 0x0710, 0x0710 }, + { 0x0712, 0x072F }, + { 0x074D, 0x07A5 }, + { 0x07B1, 0x07B1 }, + { 0x07C0, 0x07EA }, + { 0x07F4, 0x07F5 }, + { 0x07FA, 0x07FA }, + { 0x0800, 0x0815 }, + { 0x081A, 0x081A }, + { 0x0824, 0x0824 }, + { 0x0828, 0x0828 }, + { 0x0840, 0x0858 }, + { 0x0860, 0x086A }, + { 0x0870, 0x0887 }, + { 0x0889, 0x088E }, + { 0x08A0, 0x08C9 }, + { 0x0904, 0x0939 }, + { 0x093D, 0x093D }, + { 0x0950, 0x0950 }, + { 0x0958, 0x0961 }, + { 0x0966, 0x096F }, + { 0x0971, 0x0980 }, + { 0x0985, 0x098C }, + { 0x098F, 0x0990 }, + { 0x0993, 0x09A8 }, + { 0x09AA, 0x09B0 }, + { 0x09B2, 0x09B2 }, + { 0x09B6, 0x09B9 }, + { 0x09BD, 0x09BD }, + { 0x09CE, 0x09CE }, + { 0x09DC, 0x09DD }, + { 0x09DF, 0x09E1 }, + { 0x09E6, 0x09F1 }, + { 0x09FC, 0x09FC }, + { 0x0A05, 0x0A0A }, + { 0x0A0F, 0x0A10 }, + { 0x0A13, 0x0A28 }, + { 0x0A2A, 0x0A30 }, + { 0x0A32, 0x0A33 }, + { 0x0A35, 0x0A36 }, + { 0x0A38, 0x0A39 }, + { 0x0A59, 0x0A5C }, + { 0x0A5E, 0x0A5E }, + { 0x0A66, 0x0A6F }, + { 0x0A72, 0x0A74 }, + { 0x0A85, 0x0A8D }, + { 0x0A8F, 0x0A91 }, + { 0x0A93, 0x0AA8 }, + { 0x0AAA, 0x0AB0 }, + { 0x0AB2, 0x0AB3 }, + { 0x0AB5, 0x0AB9 }, + { 0x0ABD, 0x0ABD }, + { 0x0AD0, 0x0AD0 }, + { 0x0AE0, 0x0AE1 }, + { 0x0AE6, 0x0AEF }, + { 0x0AF9, 0x0AF9 }, + { 0x0B05, 0x0B0C }, + { 0x0B0F, 0x0B10 }, + { 0x0B13, 0x0B28 }, + { 0x0B2A, 0x0B30 }, + { 0x0B32, 0x0B33 }, + { 0x0B35, 0x0B39 }, + { 0x0B3D, 0x0B3D }, + { 0x0B5C, 0x0B5D }, + { 0x0B5F, 0x0B61 }, + { 0x0B66, 0x0B6F }, + { 0x0B71, 0x0B71 }, + { 0x0B83, 0x0B83 }, + { 0x0B85, 0x0B8A }, + { 0x0B8E, 0x0B90 }, + { 0x0B92, 0x0B95 }, + { 0x0B99, 0x0B9A }, + { 0x0B9C, 0x0B9C }, + { 0x0B9E, 0x0B9F }, + { 0x0BA3, 0x0BA4 }, + { 0x0BA8, 0x0BAA }, + { 0x0BAE, 0x0BB9 }, + { 0x0BD0, 0x0BD0 }, + { 0x0BE6, 0x0BEF }, + { 0x0C05, 0x0C0C }, + { 0x0C0E, 0x0C10 }, + { 0x0C12, 0x0C28 }, + { 0x0C2A, 0x0C39 }, + { 0x0C3D, 0x0C3D }, + { 0x0C58, 0x0C5A }, + { 0x0C5D, 0x0C5D }, + { 0x0C60, 0x0C61 }, + { 0x0C66, 0x0C6F }, + { 0x0C80, 0x0C80 }, + { 0x0C85, 0x0C8C }, + { 0x0C8E, 0x0C90 }, + { 0x0C92, 0x0CA8 }, + { 0x0CAA, 0x0CB3 }, + { 0x0CB5, 0x0CB9 }, + { 0x0CBD, 0x0CBD }, + { 0x0CDD, 0x0CDE }, + { 0x0CE0, 0x0CE1 }, + { 0x0CE6, 0x0CEF }, + { 0x0CF1, 0x0CF2 }, + { 0x0D04, 0x0D0C }, + { 0x0D0E, 0x0D10 }, + { 0x0D12, 0x0D3A }, + { 0x0D3D, 0x0D3D }, + { 0x0D4E, 0x0D4E }, + { 0x0D54, 0x0D56 }, + { 0x0D5F, 0x0D61 }, + { 0x0D66, 0x0D6F }, + { 0x0D7A, 0x0D7F }, + { 0x0D85, 0x0D96 }, + { 0x0D9A, 0x0DB1 }, + { 0x0DB3, 0x0DBB }, + { 0x0DBD, 0x0DBD }, + { 0x0DC0, 0x0DC6 }, + { 0x0DE6, 0x0DEF }, + { 0x0E01, 0x0E2E }, + { 0x0E30, 0x0E3A }, + { 0x0E40, 0x0E45 }, + { 0x0E47, 0x0E4E }, + { 0x0E50, 0x0E59 }, + { 0x0E81, 0x0E82 }, + { 0x0E84, 0x0E84 }, + { 0x0E86, 0x0E8A }, + { 0x0E8C, 0x0EA3 }, + { 0x0EA5, 0x0EA5 }, + { 0x0EA7, 0x0EB0 }, + { 0x0EB2, 0x0EB3 }, + { 0x0EBD, 0x0EBD }, + { 0x0EC0, 0x0EC4 }, + { 0x0EC6, 0x0EC6 }, + { 0x0ED0, 0x0ED9 }, + { 0x0EDC, 0x0EDF }, + { 0x0F00, 0x0F00 }, + { 0x0F20, 0x0F29 }, + { 0x0F40, 0x0F47 }, + { 0x0F49, 0x0F6C }, + { 0x0F88, 0x0F8C }, + { 0x1000, 0x102A }, + { 0x103F, 0x1049 }, + { 0x1050, 0x1055 }, + { 0x105A, 0x105D }, + { 0x1061, 0x1061 }, + { 0x1065, 0x1066 }, + { 0x106E, 0x1070 }, + { 0x1075, 0x1081 }, + { 0x108E, 0x108E }, + { 0x1090, 0x1099 }, + { 0x10A0, 0x10C5 }, + { 0x10C7, 0x10C7 }, + { 0x10CD, 0x10CD }, + { 0x10D0, 0x10FA }, + { 0x10FC, 0x1248 }, + { 0x124A, 0x124D }, + { 0x1250, 0x1256 }, + { 0x1258, 0x1258 }, + { 0x125A, 0x125D }, + { 0x1260, 0x1288 }, + { 0x128A, 0x128D }, + { 0x1290, 0x12B0 }, + { 0x12B2, 0x12B5 }, + { 0x12B8, 0x12BE }, + { 0x12C0, 0x12C0 }, + { 0x12C2, 0x12C5 }, + { 0x12C8, 0x12D6 }, + { 0x12D8, 0x1310 }, + { 0x1312, 0x1315 }, + { 0x1318, 0x135A }, + { 0x1380, 0x138F }, + { 0x13A0, 0x13F5 }, + { 0x13F8, 0x13FD }, + { 0x1401, 0x166C }, + { 0x166F, 0x167F }, + { 0x1681, 0x169A }, + { 0x16A0, 0x16EA }, + { 0x16EE, 0x16F8 }, + { 0x1700, 0x1711 }, + { 0x171F, 0x1731 }, + { 0x1740, 0x1751 }, + { 0x1760, 0x176C }, + { 0x176E, 0x1770 }, + { 0x1780, 0x17B3 }, + { 0x17D7, 0x17D7 }, + { 0x17DC, 0x17DC }, + { 0x17E0, 0x17E9 }, + { 0x1810, 0x1819 }, + { 0x1820, 0x1878 }, + { 0x1880, 0x1884 }, + { 0x1887, 0x18A8 }, + { 0x18AA, 0x18AA }, + { 0x18B0, 0x18F5 }, + { 0x1900, 0x191E }, + { 0x1946, 0x196D }, + { 0x1970, 0x1974 }, + { 0x1980, 0x19AB }, + { 0x19B0, 0x19C9 }, + { 0x19D0, 0x19D9 }, + { 0x1A00, 0x1A16 }, + { 0x1A20, 0x1A54 }, + { 0x1A80, 0x1A89 }, + { 0x1A90, 0x1A99 }, + { 0x1AA7, 0x1AA7 }, + { 0x1B05, 0x1B33 }, + { 0x1B45, 0x1B4C }, + { 0x1B50, 0x1B59 }, + { 0x1B83, 0x1BA0 }, + { 0x1BAE, 0x1BE5 }, + { 0x1C00, 0x1C23 }, + { 0x1C40, 0x1C49 }, + { 0x1C4D, 0x1C7D }, + { 0x1C80, 0x1C88 }, + { 0x1C90, 0x1CBA }, + { 0x1CBD, 0x1CBF }, + { 0x1CE9, 0x1CEC }, + { 0x1CEE, 0x1CF3 }, + { 0x1CF5, 0x1CF6 }, + { 0x1CFA, 0x1CFA }, + { 0x1D00, 0x1DBF }, + { 0x1E00, 0x1F15 }, + { 0x1F18, 0x1F1D }, + { 0x1F20, 0x1F45 }, + { 0x1F48, 0x1F4D }, + { 0x1F50, 0x1F57 }, + { 0x1F59, 0x1F59 }, + { 0x1F5B, 0x1F5B }, + { 0x1F5D, 0x1F5D }, + { 0x1F5F, 0x1F7D }, + { 0x1F80, 0x1FB4 }, + { 0x1FB6, 0x1FBC }, + { 0x1FBE, 0x1FBE }, + { 0x1FC2, 0x1FC4 }, + { 0x1FC6, 0x1FCC }, + { 0x1FD0, 0x1FD3 }, + { 0x1FD6, 0x1FDB }, + { 0x1FE0, 0x1FEC }, + { 0x1FF2, 0x1FF4 }, + { 0x1FF6, 0x1FFC }, + { 0x2071, 0x2071 }, + { 0x207F, 0x207F }, + { 0x2090, 0x209C }, + { 0x2102, 0x2102 }, + { 0x2107, 0x2107 }, + { 0x210A, 0x2113 }, + { 0x2115, 0x2115 }, + { 0x2119, 0x211D }, + { 0x2124, 0x2124 }, + { 0x2126, 0x2126 }, + { 0x2128, 0x212D }, + { 0x212F, 0x2139 }, + { 0x213C, 0x213F }, + { 0x2145, 0x2149 }, + { 0x214E, 0x214E }, + { 0x2160, 0x2188 }, + { 0x249C, 0x24E9 }, + { 0x2C00, 0x2CE4 }, + { 0x2CEB, 0x2CEE }, + { 0x2CF2, 0x2CF3 }, + { 0x2D00, 0x2D25 }, + { 0x2D27, 0x2D27 }, + { 0x2D2D, 0x2D2D }, + { 0x2D30, 0x2D67 }, + { 0x2D6F, 0x2D6F }, + { 0x2D80, 0x2D96 }, + { 0x2DA0, 0x2DA6 }, + { 0x2DA8, 0x2DAE }, + { 0x2DB0, 0x2DB6 }, + { 0x2DB8, 0x2DBE }, + { 0x2DC0, 0x2DC6 }, + { 0x2DC8, 0x2DCE }, + { 0x2DD0, 0x2DD6 }, + { 0x2DD8, 0x2DDE }, + { 0x2E2F, 0x2E2F }, + { 0x3005, 0x3007 }, + { 0x3021, 0x3029 }, + { 0x3031, 0x3035 }, + { 0x3038, 0x303C }, + { 0x3041, 0x3096 }, + { 0x309D, 0x309F }, + { 0x30A1, 0x30FA }, + { 0x30FC, 0x30FF }, + { 0x3105, 0x312F }, + { 0x3131, 0x318E }, + { 0x31A0, 0x31BF }, + { 0x31F0, 0x31FF }, + { 0x3400, 0x4DBF }, + { 0x4E00, 0xA48C }, + { 0xA4D0, 0xA4FD }, + { 0xA500, 0xA60C }, + { 0xA610, 0xA62B }, + { 0xA640, 0xA66E }, + { 0xA67F, 0xA69D }, + { 0xA6A0, 0xA6EF }, + { 0xA717, 0xA71F }, + { 0xA722, 0xA788 }, + { 0xA78B, 0xA7CA }, + { 0xA7D0, 0xA7D1 }, + { 0xA7D3, 0xA7D3 }, + { 0xA7D5, 0xA7D9 }, + { 0xA7F2, 0xA801 }, + { 0xA803, 0xA805 }, + { 0xA807, 0xA80A }, + { 0xA80C, 0xA822 }, + { 0xA840, 0xA873 }, + { 0xA882, 0xA8B3 }, + { 0xA8D0, 0xA8D9 }, + { 0xA8F2, 0xA8F7 }, + { 0xA8FB, 0xA8FB }, + { 0xA8FD, 0xA8FE }, + { 0xA900, 0xA925 }, + { 0xA930, 0xA946 }, + { 0xA960, 0xA97C }, + { 0xA984, 0xA9B2 }, + { 0xA9CF, 0xA9D9 }, + { 0xA9E0, 0xA9E4 }, + { 0xA9E6, 0xA9FE }, + { 0xAA00, 0xAA28 }, + { 0xAA40, 0xAA42 }, + { 0xAA44, 0xAA4B }, + { 0xAA50, 0xAA59 }, + { 0xAA60, 0xAA76 }, + { 0xAA7A, 0xAA7A }, + { 0xAA7E, 0xAAAF }, + { 0xAAB1, 0xAAB1 }, + { 0xAAB5, 0xAAB6 }, + { 0xAAB9, 0xAABD }, + { 0xAAC0, 0xAAC0 }, + { 0xAAC2, 0xAAC2 }, + { 0xAADB, 0xAADD }, + { 0xAAE0, 0xAAEA }, + { 0xAAF2, 0xAAF4 }, + { 0xAB01, 0xAB06 }, + { 0xAB09, 0xAB0E }, + { 0xAB11, 0xAB16 }, + { 0xAB20, 0xAB26 }, + { 0xAB28, 0xAB2E }, + { 0xAB30, 0xAB5A }, + { 0xAB5C, 0xAB69 }, + { 0xAB70, 0xABE2 }, + { 0xABF0, 0xABF9 }, + { 0xAC00, 0xD7A3 }, + { 0xD7B0, 0xD7C6 }, + { 0xD7CB, 0xD7FB }, + { 0xF900, 0xFA6D }, + { 0xFA70, 0xFAD9 }, + { 0xFB00, 0xFB06 }, + { 0xFB13, 0xFB17 }, + { 0xFB1D, 0xFB1D }, + { 0xFB1F, 0xFB28 }, + { 0xFB2A, 0xFB36 }, + { 0xFB38, 0xFB3C }, + { 0xFB3E, 0xFB3E }, + { 0xFB40, 0xFB41 }, + { 0xFB43, 0xFB44 }, + { 0xFB46, 0xFBB1 }, + { 0xFBD3, 0xFD3D }, + { 0xFD50, 0xFD8F }, + { 0xFD92, 0xFDC7 }, + { 0xFDF0, 0xFDFB }, + { 0xFE70, 0xFE74 }, + { 0xFE76, 0xFEFC }, + { 0xFF10, 0xFF19 }, + { 0xFF21, 0xFF3A }, + { 0xFF41, 0xFF5A }, + { 0xFF66, 0xFFBE }, + { 0xFFC2, 0xFFC7 }, + { 0xFFCA, 0xFFCF }, + { 0xFFD2, 0xFFD7 }, + { 0xFFDA, 0xFFDC }, + { 0x10000, 0x1000B }, + { 0x1000D, 0x10026 }, + { 0x10028, 0x1003A }, + { 0x1003C, 0x1003D }, + { 0x1003F, 0x1004D }, + { 0x10050, 0x1005D }, + { 0x10080, 0x100FA }, + { 0x10140, 0x10174 }, + { 0x10280, 0x1029C }, + { 0x102A0, 0x102D0 }, + { 0x10300, 0x1031F }, + { 0x1032D, 0x1034A }, + { 0x10350, 0x10375 }, + { 0x10380, 0x1039D }, + { 0x103A0, 0x103C3 }, + { 0x103C8, 0x103CF }, + { 0x103D1, 0x103D5 }, + { 0x10400, 0x1049D }, + { 0x104A0, 0x104A9 }, + { 0x104B0, 0x104D3 }, + { 0x104D8, 0x104FB }, + { 0x10500, 0x10527 }, + { 0x10530, 0x10563 }, + { 0x10570, 0x1057A }, + { 0x1057C, 0x1058A }, + { 0x1058C, 0x10592 }, + { 0x10594, 0x10595 }, + { 0x10597, 0x105A1 }, + { 0x105A3, 0x105B1 }, + { 0x105B3, 0x105B9 }, + { 0x105BB, 0x105BC }, + { 0x10600, 0x10736 }, + { 0x10740, 0x10755 }, + { 0x10760, 0x10767 }, + { 0x10780, 0x10785 }, + { 0x10787, 0x107B0 }, + { 0x107B2, 0x107BA }, + { 0x10800, 0x10805 }, + { 0x10808, 0x10808 }, + { 0x1080A, 0x10835 }, + { 0x10837, 0x10838 }, + { 0x1083C, 0x1083C }, + { 0x1083F, 0x10855 }, + { 0x10860, 0x10876 }, + { 0x10880, 0x1089E }, + { 0x108E0, 0x108F2 }, + { 0x108F4, 0x108F5 }, + { 0x10900, 0x10915 }, + { 0x10920, 0x10939 }, + { 0x10980, 0x109B7 }, + { 0x109BE, 0x109BF }, + { 0x10A00, 0x10A00 }, + { 0x10A10, 0x10A13 }, + { 0x10A15, 0x10A17 }, + { 0x10A19, 0x10A35 }, + { 0x10A60, 0x10A7C }, + { 0x10A80, 0x10A9C }, + { 0x10AC0, 0x10AC7 }, + { 0x10AC9, 0x10AE4 }, + { 0x10B00, 0x10B35 }, + { 0x10B40, 0x10B55 }, + { 0x10B60, 0x10B72 }, + { 0x10B80, 0x10B91 }, + { 0x10C00, 0x10C48 }, + { 0x10C80, 0x10CB2 }, + { 0x10CC0, 0x10CF2 }, + { 0x10D00, 0x10D23 }, + { 0x10D30, 0x10D39 }, + { 0x10E80, 0x10EA9 }, + { 0x10EB0, 0x10EB1 }, + { 0x10F00, 0x10F1C }, + { 0x10F27, 0x10F27 }, + { 0x10F30, 0x10F45 }, + { 0x10F70, 0x10F81 }, + { 0x10FB0, 0x10FC4 }, + { 0x10FE0, 0x10FF6 }, + { 0x11003, 0x11037 }, + { 0x11066, 0x1106F }, + { 0x11071, 0x11072 }, + { 0x11075, 0x11075 }, + { 0x11083, 0x110AF }, + { 0x110D0, 0x110E8 }, + { 0x110F0, 0x110F9 }, + { 0x11103, 0x11126 }, + { 0x11136, 0x1113F }, + { 0x11144, 0x11144 }, + { 0x11147, 0x11147 }, + { 0x11150, 0x11172 }, + { 0x11176, 0x11176 }, + { 0x11183, 0x111B2 }, + { 0x111C1, 0x111C4 }, + { 0x111D0, 0x111DA }, + { 0x111DC, 0x111DC }, + { 0x11200, 0x11211 }, + { 0x11213, 0x1122B }, + { 0x1123F, 0x11240 }, + { 0x11280, 0x11286 }, + { 0x11288, 0x11288 }, + { 0x1128A, 0x1128D }, + { 0x1128F, 0x1129D }, + { 0x1129F, 0x112A8 }, + { 0x112B0, 0x112DE }, + { 0x112F0, 0x112F9 }, + { 0x11305, 0x1130C }, + { 0x1130F, 0x11310 }, + { 0x11313, 0x11328 }, + { 0x1132A, 0x11330 }, + { 0x11332, 0x11333 }, + { 0x11335, 0x11339 }, + { 0x1133D, 0x1133D }, + { 0x11350, 0x11350 }, + { 0x1135D, 0x11361 }, + { 0x11400, 0x11434 }, + { 0x11447, 0x1144A }, + { 0x11450, 0x11459 }, + { 0x1145F, 0x11461 }, + { 0x11480, 0x114AF }, + { 0x114C4, 0x114C5 }, + { 0x114C7, 0x114C7 }, + { 0x114D0, 0x114D9 }, + { 0x11580, 0x115AE }, + { 0x115D8, 0x115DB }, + { 0x11600, 0x1162F }, + { 0x11644, 0x11644 }, + { 0x11650, 0x11659 }, + { 0x11680, 0x116AA }, + { 0x116B8, 0x116B8 }, + { 0x116C0, 0x116C9 }, + { 0x11700, 0x1171A }, + { 0x11730, 0x11739 }, + { 0x11740, 0x11746 }, + { 0x11800, 0x1182B }, + { 0x118A0, 0x118E9 }, + { 0x118FF, 0x11906 }, + { 0x11909, 0x11909 }, + { 0x1190C, 0x11913 }, + { 0x11915, 0x11916 }, + { 0x11918, 0x1192F }, + { 0x1193F, 0x1193F }, + { 0x11941, 0x11941 }, + { 0x11950, 0x11959 }, + { 0x119A0, 0x119A7 }, + { 0x119AA, 0x119D0 }, + { 0x119E1, 0x119E1 }, + { 0x119E3, 0x119E3 }, + { 0x11A00, 0x11A00 }, + { 0x11A0B, 0x11A32 }, + { 0x11A3A, 0x11A3A }, + { 0x11A50, 0x11A50 }, + { 0x11A5C, 0x11A89 }, + { 0x11A9D, 0x11A9D }, + { 0x11AB0, 0x11AF8 }, + { 0x11C00, 0x11C08 }, + { 0x11C0A, 0x11C2E }, + { 0x11C40, 0x11C40 }, + { 0x11C50, 0x11C59 }, + { 0x11C72, 0x11C8F }, + { 0x11D00, 0x11D06 }, + { 0x11D08, 0x11D09 }, + { 0x11D0B, 0x11D30 }, + { 0x11D46, 0x11D46 }, + { 0x11D50, 0x11D59 }, + { 0x11D60, 0x11D65 }, + { 0x11D67, 0x11D68 }, + { 0x11D6A, 0x11D89 }, + { 0x11D98, 0x11D98 }, + { 0x11DA0, 0x11DA9 }, + { 0x11EE0, 0x11EF2 }, + { 0x11F02, 0x11F02 }, + { 0x11F04, 0x11F10 }, + { 0x11F12, 0x11F33 }, + { 0x11F50, 0x11F59 }, + { 0x11FB0, 0x11FB0 }, + { 0x12000, 0x12399 }, + { 0x12400, 0x1246E }, + { 0x12480, 0x12543 }, + { 0x12F90, 0x12FF0 }, + { 0x13000, 0x1342F }, + { 0x13441, 0x13446 }, + { 0x14400, 0x14646 }, + { 0x16800, 0x16A38 }, + { 0x16A40, 0x16A5E }, + { 0x16A60, 0x16A69 }, + { 0x16A70, 0x16ABE }, + { 0x16AC0, 0x16AC9 }, + { 0x16AD0, 0x16AED }, + { 0x16B00, 0x16B2F }, + { 0x16B40, 0x16B43 }, + { 0x16B50, 0x16B59 }, + { 0x16B63, 0x16B77 }, + { 0x16B7D, 0x16B8F }, + { 0x16E40, 0x16E7F }, + { 0x16F00, 0x16F4A }, + { 0x16F50, 0x16F50 }, + { 0x16F93, 0x16F9F }, + { 0x16FE0, 0x16FE1 }, + { 0x16FE3, 0x16FE3 }, + { 0x17000, 0x187F7 }, + { 0x18800, 0x18CD5 }, + { 0x18D00, 0x18D08 }, + { 0x1AFF0, 0x1AFF3 }, + { 0x1AFF5, 0x1AFFB }, + { 0x1AFFD, 0x1AFFE }, + { 0x1B000, 0x1B122 }, + { 0x1B132, 0x1B132 }, + { 0x1B150, 0x1B152 }, + { 0x1B155, 0x1B155 }, + { 0x1B164, 0x1B167 }, + { 0x1B170, 0x1B2FB }, + { 0x1BC00, 0x1BC6A }, + { 0x1BC70, 0x1BC7C }, + { 0x1BC80, 0x1BC88 }, + { 0x1BC90, 0x1BC99 }, + { 0x1D400, 0x1D454 }, + { 0x1D456, 0x1D49C }, + { 0x1D49E, 0x1D49F }, + { 0x1D4A2, 0x1D4A2 }, + { 0x1D4A5, 0x1D4A6 }, + { 0x1D4A9, 0x1D4AC }, + { 0x1D4AE, 0x1D4B9 }, + { 0x1D4BB, 0x1D4BB }, + { 0x1D4BD, 0x1D4C3 }, + { 0x1D4C5, 0x1D505 }, + { 0x1D507, 0x1D50A }, + { 0x1D50D, 0x1D514 }, + { 0x1D516, 0x1D51C }, + { 0x1D51E, 0x1D539 }, + { 0x1D53B, 0x1D53E }, + { 0x1D540, 0x1D544 }, + { 0x1D546, 0x1D546 }, + { 0x1D54A, 0x1D550 }, + { 0x1D552, 0x1D6A5 }, + { 0x1D6A8, 0x1D6C0 }, + { 0x1D6C2, 0x1D6DA }, + { 0x1D6DC, 0x1D6FA }, + { 0x1D6FC, 0x1D714 }, + { 0x1D716, 0x1D734 }, + { 0x1D736, 0x1D74E }, + { 0x1D750, 0x1D76E }, + { 0x1D770, 0x1D788 }, + { 0x1D78A, 0x1D7A8 }, + { 0x1D7AA, 0x1D7C2 }, + { 0x1D7C4, 0x1D7CB }, + { 0x1D7CE, 0x1D7FF }, + { 0x1DF00, 0x1DF1E }, + { 0x1DF25, 0x1DF2A }, + { 0x1E030, 0x1E06D }, + { 0x1E100, 0x1E12C }, + { 0x1E137, 0x1E13D }, + { 0x1E140, 0x1E149 }, + { 0x1E14E, 0x1E14E }, + { 0x1E290, 0x1E2AD }, + { 0x1E2C0, 0x1E2EB }, + { 0x1E2F0, 0x1E2F9 }, + { 0x1E4D0, 0x1E4EB }, + { 0x1E4F0, 0x1E4F9 }, + { 0x1E7E0, 0x1E7E6 }, + { 0x1E7E8, 0x1E7EB }, + { 0x1E7ED, 0x1E7EE }, + { 0x1E7F0, 0x1E7FE }, + { 0x1E800, 0x1E8C4 }, + { 0x1E900, 0x1E943 }, + { 0x1E94B, 0x1E94B }, + { 0x1E950, 0x1E959 }, + { 0x1EE00, 0x1EE03 }, + { 0x1EE05, 0x1EE1F }, + { 0x1EE21, 0x1EE22 }, + { 0x1EE24, 0x1EE24 }, + { 0x1EE27, 0x1EE27 }, + { 0x1EE29, 0x1EE32 }, + { 0x1EE34, 0x1EE37 }, + { 0x1EE39, 0x1EE39 }, + { 0x1EE3B, 0x1EE3B }, + { 0x1EE42, 0x1EE42 }, + { 0x1EE47, 0x1EE47 }, + { 0x1EE49, 0x1EE49 }, + { 0x1EE4B, 0x1EE4B }, + { 0x1EE4D, 0x1EE4F }, + { 0x1EE51, 0x1EE52 }, + { 0x1EE54, 0x1EE54 }, + { 0x1EE57, 0x1EE57 }, + { 0x1EE59, 0x1EE59 }, + { 0x1EE5B, 0x1EE5B }, + { 0x1EE5D, 0x1EE5D }, + { 0x1EE5F, 0x1EE5F }, + { 0x1EE61, 0x1EE62 }, + { 0x1EE64, 0x1EE64 }, + { 0x1EE67, 0x1EE6A }, + { 0x1EE6C, 0x1EE72 }, + { 0x1EE74, 0x1EE77 }, + { 0x1EE79, 0x1EE7C }, + { 0x1EE7E, 0x1EE7E }, + { 0x1EE80, 0x1EE89 }, + { 0x1EE8B, 0x1EE9B }, + { 0x1EEA1, 0x1EEA3 }, + { 0x1EEA5, 0x1EEA9 }, + { 0x1EEAB, 0x1EEBB }, + { 0x1F110, 0x1F12C }, + { 0x1F130, 0x1F149 }, + { 0x1F150, 0x1F169 }, + { 0x1F170, 0x1F18A }, + { 0x1F1A5, 0x1F1A5 }, + { 0x1F1E6, 0x1F1FF }, + { 0x1FBF0, 0x1FBF9 }, + { 0x20000, 0x2A6DF }, + { 0x2A700, 0x2B739 }, + { 0x2B740, 0x2B81D }, + { 0x2B820, 0x2CEA1 }, + { 0x2CEB0, 0x2EBE0 }, + { 0x2F800, 0x2FA1D }, + { 0x30000, 0x3134A }, + { 0x31350, 0x323AF } + +#define PREDICATE(c) uc_is_alpha (c) +#include "test-predicate-part2.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/test-ctype_blank.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/test-ctype_blank.c new file mode 100644 index 00000000..4824fe73 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/test-ctype_blank.c @@ -0,0 +1,29 @@ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +/* Test the Unicode character type functions. + Copyright (C) 2007-2022 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 the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + This file 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 . */ + +#include "test-predicate-part1.h" + + { 0x0009, 0x0009 }, + { 0x0020, 0x0020 }, + { 0x1680, 0x1680 }, + { 0x2000, 0x2006 }, + { 0x2008, 0x200A }, + { 0x205F, 0x205F }, + { 0x3000, 0x3000 } + +#define PREDICATE(c) uc_is_blank (c) +#include "test-predicate-part2.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/test-ctype_cntrl.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/test-ctype_cntrl.c new file mode 100644 index 00000000..d32c701d --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/test-ctype_cntrl.c @@ -0,0 +1,25 @@ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +/* Test the Unicode character type functions. + Copyright (C) 2007-2022 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 the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + This file 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 . */ + +#include "test-predicate-part1.h" + + { 0x0000, 0x001F }, + { 0x007F, 0x009F }, + { 0x2028, 0x2029 } + +#define PREDICATE(c) uc_is_cntrl (c) +#include "test-predicate-part2.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/test-ctype_digit.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/test-ctype_digit.c new file mode 100644 index 00000000..ccda557f --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/test-ctype_digit.c @@ -0,0 +1,23 @@ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +/* Test the Unicode character type functions. + Copyright (C) 2007-2022 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 the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + This file 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 . */ + +#include "test-predicate-part1.h" + + { 0x0030, 0x0039 } + +#define PREDICATE(c) uc_is_digit (c) +#include "test-predicate-part2.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/test-ctype_graph.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/test-ctype_graph.c new file mode 100644 index 00000000..16ab878a --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/test-ctype_graph.c @@ -0,0 +1,734 @@ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +/* Test the Unicode character type functions. + Copyright (C) 2007-2022 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 the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + This file 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 . */ + +#include "test-predicate-part1.h" + + { 0x0021, 0x007E }, + { 0x00A0, 0x0377 }, + { 0x037A, 0x037F }, + { 0x0384, 0x038A }, + { 0x038C, 0x038C }, + { 0x038E, 0x03A1 }, + { 0x03A3, 0x052F }, + { 0x0531, 0x0556 }, + { 0x0559, 0x058A }, + { 0x058D, 0x058F }, + { 0x0591, 0x05C7 }, + { 0x05D0, 0x05EA }, + { 0x05EF, 0x05F4 }, + { 0x0600, 0x070D }, + { 0x070F, 0x074A }, + { 0x074D, 0x07B1 }, + { 0x07C0, 0x07FA }, + { 0x07FD, 0x082D }, + { 0x0830, 0x083E }, + { 0x0840, 0x085B }, + { 0x085E, 0x085E }, + { 0x0860, 0x086A }, + { 0x0870, 0x088E }, + { 0x0890, 0x0891 }, + { 0x0898, 0x0983 }, + { 0x0985, 0x098C }, + { 0x098F, 0x0990 }, + { 0x0993, 0x09A8 }, + { 0x09AA, 0x09B0 }, + { 0x09B2, 0x09B2 }, + { 0x09B6, 0x09B9 }, + { 0x09BC, 0x09C4 }, + { 0x09C7, 0x09C8 }, + { 0x09CB, 0x09CE }, + { 0x09D7, 0x09D7 }, + { 0x09DC, 0x09DD }, + { 0x09DF, 0x09E3 }, + { 0x09E6, 0x09FE }, + { 0x0A01, 0x0A03 }, + { 0x0A05, 0x0A0A }, + { 0x0A0F, 0x0A10 }, + { 0x0A13, 0x0A28 }, + { 0x0A2A, 0x0A30 }, + { 0x0A32, 0x0A33 }, + { 0x0A35, 0x0A36 }, + { 0x0A38, 0x0A39 }, + { 0x0A3C, 0x0A3C }, + { 0x0A3E, 0x0A42 }, + { 0x0A47, 0x0A48 }, + { 0x0A4B, 0x0A4D }, + { 0x0A51, 0x0A51 }, + { 0x0A59, 0x0A5C }, + { 0x0A5E, 0x0A5E }, + { 0x0A66, 0x0A76 }, + { 0x0A81, 0x0A83 }, + { 0x0A85, 0x0A8D }, + { 0x0A8F, 0x0A91 }, + { 0x0A93, 0x0AA8 }, + { 0x0AAA, 0x0AB0 }, + { 0x0AB2, 0x0AB3 }, + { 0x0AB5, 0x0AB9 }, + { 0x0ABC, 0x0AC5 }, + { 0x0AC7, 0x0AC9 }, + { 0x0ACB, 0x0ACD }, + { 0x0AD0, 0x0AD0 }, + { 0x0AE0, 0x0AE3 }, + { 0x0AE6, 0x0AF1 }, + { 0x0AF9, 0x0AFF }, + { 0x0B01, 0x0B03 }, + { 0x0B05, 0x0B0C }, + { 0x0B0F, 0x0B10 }, + { 0x0B13, 0x0B28 }, + { 0x0B2A, 0x0B30 }, + { 0x0B32, 0x0B33 }, + { 0x0B35, 0x0B39 }, + { 0x0B3C, 0x0B44 }, + { 0x0B47, 0x0B48 }, + { 0x0B4B, 0x0B4D }, + { 0x0B55, 0x0B57 }, + { 0x0B5C, 0x0B5D }, + { 0x0B5F, 0x0B63 }, + { 0x0B66, 0x0B77 }, + { 0x0B82, 0x0B83 }, + { 0x0B85, 0x0B8A }, + { 0x0B8E, 0x0B90 }, + { 0x0B92, 0x0B95 }, + { 0x0B99, 0x0B9A }, + { 0x0B9C, 0x0B9C }, + { 0x0B9E, 0x0B9F }, + { 0x0BA3, 0x0BA4 }, + { 0x0BA8, 0x0BAA }, + { 0x0BAE, 0x0BB9 }, + { 0x0BBE, 0x0BC2 }, + { 0x0BC6, 0x0BC8 }, + { 0x0BCA, 0x0BCD }, + { 0x0BD0, 0x0BD0 }, + { 0x0BD7, 0x0BD7 }, + { 0x0BE6, 0x0BFA }, + { 0x0C00, 0x0C0C }, + { 0x0C0E, 0x0C10 }, + { 0x0C12, 0x0C28 }, + { 0x0C2A, 0x0C39 }, + { 0x0C3C, 0x0C44 }, + { 0x0C46, 0x0C48 }, + { 0x0C4A, 0x0C4D }, + { 0x0C55, 0x0C56 }, + { 0x0C58, 0x0C5A }, + { 0x0C5D, 0x0C5D }, + { 0x0C60, 0x0C63 }, + { 0x0C66, 0x0C6F }, + { 0x0C77, 0x0C8C }, + { 0x0C8E, 0x0C90 }, + { 0x0C92, 0x0CA8 }, + { 0x0CAA, 0x0CB3 }, + { 0x0CB5, 0x0CB9 }, + { 0x0CBC, 0x0CC4 }, + { 0x0CC6, 0x0CC8 }, + { 0x0CCA, 0x0CCD }, + { 0x0CD5, 0x0CD6 }, + { 0x0CDD, 0x0CDE }, + { 0x0CE0, 0x0CE3 }, + { 0x0CE6, 0x0CEF }, + { 0x0CF1, 0x0CF3 }, + { 0x0D00, 0x0D0C }, + { 0x0D0E, 0x0D10 }, + { 0x0D12, 0x0D44 }, + { 0x0D46, 0x0D48 }, + { 0x0D4A, 0x0D4F }, + { 0x0D54, 0x0D63 }, + { 0x0D66, 0x0D7F }, + { 0x0D81, 0x0D83 }, + { 0x0D85, 0x0D96 }, + { 0x0D9A, 0x0DB1 }, + { 0x0DB3, 0x0DBB }, + { 0x0DBD, 0x0DBD }, + { 0x0DC0, 0x0DC6 }, + { 0x0DCA, 0x0DCA }, + { 0x0DCF, 0x0DD4 }, + { 0x0DD6, 0x0DD6 }, + { 0x0DD8, 0x0DDF }, + { 0x0DE6, 0x0DEF }, + { 0x0DF2, 0x0DF4 }, + { 0x0E01, 0x0E3A }, + { 0x0E3F, 0x0E5B }, + { 0x0E81, 0x0E82 }, + { 0x0E84, 0x0E84 }, + { 0x0E86, 0x0E8A }, + { 0x0E8C, 0x0EA3 }, + { 0x0EA5, 0x0EA5 }, + { 0x0EA7, 0x0EBD }, + { 0x0EC0, 0x0EC4 }, + { 0x0EC6, 0x0EC6 }, + { 0x0EC8, 0x0ECE }, + { 0x0ED0, 0x0ED9 }, + { 0x0EDC, 0x0EDF }, + { 0x0F00, 0x0F47 }, + { 0x0F49, 0x0F6C }, + { 0x0F71, 0x0F97 }, + { 0x0F99, 0x0FBC }, + { 0x0FBE, 0x0FCC }, + { 0x0FCE, 0x0FDA }, + { 0x1000, 0x10C5 }, + { 0x10C7, 0x10C7 }, + { 0x10CD, 0x10CD }, + { 0x10D0, 0x1248 }, + { 0x124A, 0x124D }, + { 0x1250, 0x1256 }, + { 0x1258, 0x1258 }, + { 0x125A, 0x125D }, + { 0x1260, 0x1288 }, + { 0x128A, 0x128D }, + { 0x1290, 0x12B0 }, + { 0x12B2, 0x12B5 }, + { 0x12B8, 0x12BE }, + { 0x12C0, 0x12C0 }, + { 0x12C2, 0x12C5 }, + { 0x12C8, 0x12D6 }, + { 0x12D8, 0x1310 }, + { 0x1312, 0x1315 }, + { 0x1318, 0x135A }, + { 0x135D, 0x137C }, + { 0x1380, 0x1399 }, + { 0x13A0, 0x13F5 }, + { 0x13F8, 0x13FD }, + { 0x1400, 0x167F }, + { 0x1681, 0x169C }, + { 0x16A0, 0x16F8 }, + { 0x1700, 0x1715 }, + { 0x171F, 0x1736 }, + { 0x1740, 0x1753 }, + { 0x1760, 0x176C }, + { 0x176E, 0x1770 }, + { 0x1772, 0x1773 }, + { 0x1780, 0x17DD }, + { 0x17E0, 0x17E9 }, + { 0x17F0, 0x17F9 }, + { 0x1800, 0x1819 }, + { 0x1820, 0x1878 }, + { 0x1880, 0x18AA }, + { 0x18B0, 0x18F5 }, + { 0x1900, 0x191E }, + { 0x1920, 0x192B }, + { 0x1930, 0x193B }, + { 0x1940, 0x1940 }, + { 0x1944, 0x196D }, + { 0x1970, 0x1974 }, + { 0x1980, 0x19AB }, + { 0x19B0, 0x19C9 }, + { 0x19D0, 0x19DA }, + { 0x19DE, 0x1A1B }, + { 0x1A1E, 0x1A5E }, + { 0x1A60, 0x1A7C }, + { 0x1A7F, 0x1A89 }, + { 0x1A90, 0x1A99 }, + { 0x1AA0, 0x1AAD }, + { 0x1AB0, 0x1ACE }, + { 0x1B00, 0x1B4C }, + { 0x1B50, 0x1B7E }, + { 0x1B80, 0x1BF3 }, + { 0x1BFC, 0x1C37 }, + { 0x1C3B, 0x1C49 }, + { 0x1C4D, 0x1C88 }, + { 0x1C90, 0x1CBA }, + { 0x1CBD, 0x1CC7 }, + { 0x1CD0, 0x1CFA }, + { 0x1D00, 0x1F15 }, + { 0x1F18, 0x1F1D }, + { 0x1F20, 0x1F45 }, + { 0x1F48, 0x1F4D }, + { 0x1F50, 0x1F57 }, + { 0x1F59, 0x1F59 }, + { 0x1F5B, 0x1F5B }, + { 0x1F5D, 0x1F5D }, + { 0x1F5F, 0x1F7D }, + { 0x1F80, 0x1FB4 }, + { 0x1FB6, 0x1FC4 }, + { 0x1FC6, 0x1FD3 }, + { 0x1FD6, 0x1FDB }, + { 0x1FDD, 0x1FEF }, + { 0x1FF2, 0x1FF4 }, + { 0x1FF6, 0x1FFE }, + { 0x2007, 0x2007 }, + { 0x200B, 0x2027 }, + { 0x202A, 0x205E }, + { 0x2060, 0x2064 }, + { 0x2066, 0x2071 }, + { 0x2074, 0x208E }, + { 0x2090, 0x209C }, + { 0x20A0, 0x20C0 }, + { 0x20D0, 0x20F0 }, + { 0x2100, 0x218B }, + { 0x2190, 0x2426 }, + { 0x2440, 0x244A }, + { 0x2460, 0x2B73 }, + { 0x2B76, 0x2B95 }, + { 0x2B97, 0x2CF3 }, + { 0x2CF9, 0x2D25 }, + { 0x2D27, 0x2D27 }, + { 0x2D2D, 0x2D2D }, + { 0x2D30, 0x2D67 }, + { 0x2D6F, 0x2D70 }, + { 0x2D7F, 0x2D96 }, + { 0x2DA0, 0x2DA6 }, + { 0x2DA8, 0x2DAE }, + { 0x2DB0, 0x2DB6 }, + { 0x2DB8, 0x2DBE }, + { 0x2DC0, 0x2DC6 }, + { 0x2DC8, 0x2DCE }, + { 0x2DD0, 0x2DD6 }, + { 0x2DD8, 0x2DDE }, + { 0x2DE0, 0x2E5D }, + { 0x2E80, 0x2E99 }, + { 0x2E9B, 0x2EF3 }, + { 0x2F00, 0x2FD5 }, + { 0x2FF0, 0x2FFB }, + { 0x3001, 0x303F }, + { 0x3041, 0x3096 }, + { 0x3099, 0x30FF }, + { 0x3105, 0x312F }, + { 0x3131, 0x318E }, + { 0x3190, 0x31E3 }, + { 0x31F0, 0x321E }, + { 0x3220, 0xA48C }, + { 0xA490, 0xA4C6 }, + { 0xA4D0, 0xA62B }, + { 0xA640, 0xA6F7 }, + { 0xA700, 0xA7CA }, + { 0xA7D0, 0xA7D1 }, + { 0xA7D3, 0xA7D3 }, + { 0xA7D5, 0xA7D9 }, + { 0xA7F2, 0xA82C }, + { 0xA830, 0xA839 }, + { 0xA840, 0xA877 }, + { 0xA880, 0xA8C5 }, + { 0xA8CE, 0xA8D9 }, + { 0xA8E0, 0xA953 }, + { 0xA95F, 0xA97C }, + { 0xA980, 0xA9CD }, + { 0xA9CF, 0xA9D9 }, + { 0xA9DE, 0xA9FE }, + { 0xAA00, 0xAA36 }, + { 0xAA40, 0xAA4D }, + { 0xAA50, 0xAA59 }, + { 0xAA5C, 0xAAC2 }, + { 0xAADB, 0xAAF6 }, + { 0xAB01, 0xAB06 }, + { 0xAB09, 0xAB0E }, + { 0xAB11, 0xAB16 }, + { 0xAB20, 0xAB26 }, + { 0xAB28, 0xAB2E }, + { 0xAB30, 0xAB6B }, + { 0xAB70, 0xABED }, + { 0xABF0, 0xABF9 }, + { 0xAC00, 0xD7A3 }, + { 0xD7B0, 0xD7C6 }, + { 0xD7CB, 0xD7FB }, + { 0xE000, 0xFA6D }, + { 0xFA70, 0xFAD9 }, + { 0xFB00, 0xFB06 }, + { 0xFB13, 0xFB17 }, + { 0xFB1D, 0xFB36 }, + { 0xFB38, 0xFB3C }, + { 0xFB3E, 0xFB3E }, + { 0xFB40, 0xFB41 }, + { 0xFB43, 0xFB44 }, + { 0xFB46, 0xFBC2 }, + { 0xFBD3, 0xFD8F }, + { 0xFD92, 0xFDC7 }, + { 0xFDCF, 0xFDCF }, + { 0xFDF0, 0xFE19 }, + { 0xFE20, 0xFE52 }, + { 0xFE54, 0xFE66 }, + { 0xFE68, 0xFE6B }, + { 0xFE70, 0xFE74 }, + { 0xFE76, 0xFEFC }, + { 0xFEFF, 0xFEFF }, + { 0xFF01, 0xFFBE }, + { 0xFFC2, 0xFFC7 }, + { 0xFFCA, 0xFFCF }, + { 0xFFD2, 0xFFD7 }, + { 0xFFDA, 0xFFDC }, + { 0xFFE0, 0xFFE6 }, + { 0xFFE8, 0xFFEE }, + { 0xFFF9, 0xFFFD }, + { 0x10000, 0x1000B }, + { 0x1000D, 0x10026 }, + { 0x10028, 0x1003A }, + { 0x1003C, 0x1003D }, + { 0x1003F, 0x1004D }, + { 0x10050, 0x1005D }, + { 0x10080, 0x100FA }, + { 0x10100, 0x10102 }, + { 0x10107, 0x10133 }, + { 0x10137, 0x1018E }, + { 0x10190, 0x1019C }, + { 0x101A0, 0x101A0 }, + { 0x101D0, 0x101FD }, + { 0x10280, 0x1029C }, + { 0x102A0, 0x102D0 }, + { 0x102E0, 0x102FB }, + { 0x10300, 0x10323 }, + { 0x1032D, 0x1034A }, + { 0x10350, 0x1037A }, + { 0x10380, 0x1039D }, + { 0x1039F, 0x103C3 }, + { 0x103C8, 0x103D5 }, + { 0x10400, 0x1049D }, + { 0x104A0, 0x104A9 }, + { 0x104B0, 0x104D3 }, + { 0x104D8, 0x104FB }, + { 0x10500, 0x10527 }, + { 0x10530, 0x10563 }, + { 0x1056F, 0x1057A }, + { 0x1057C, 0x1058A }, + { 0x1058C, 0x10592 }, + { 0x10594, 0x10595 }, + { 0x10597, 0x105A1 }, + { 0x105A3, 0x105B1 }, + { 0x105B3, 0x105B9 }, + { 0x105BB, 0x105BC }, + { 0x10600, 0x10736 }, + { 0x10740, 0x10755 }, + { 0x10760, 0x10767 }, + { 0x10780, 0x10785 }, + { 0x10787, 0x107B0 }, + { 0x107B2, 0x107BA }, + { 0x10800, 0x10805 }, + { 0x10808, 0x10808 }, + { 0x1080A, 0x10835 }, + { 0x10837, 0x10838 }, + { 0x1083C, 0x1083C }, + { 0x1083F, 0x10855 }, + { 0x10857, 0x1089E }, + { 0x108A7, 0x108AF }, + { 0x108E0, 0x108F2 }, + { 0x108F4, 0x108F5 }, + { 0x108FB, 0x1091B }, + { 0x1091F, 0x10939 }, + { 0x1093F, 0x1093F }, + { 0x10980, 0x109B7 }, + { 0x109BC, 0x109CF }, + { 0x109D2, 0x10A03 }, + { 0x10A05, 0x10A06 }, + { 0x10A0C, 0x10A13 }, + { 0x10A15, 0x10A17 }, + { 0x10A19, 0x10A35 }, + { 0x10A38, 0x10A3A }, + { 0x10A3F, 0x10A48 }, + { 0x10A50, 0x10A58 }, + { 0x10A60, 0x10A9F }, + { 0x10AC0, 0x10AE6 }, + { 0x10AEB, 0x10AF6 }, + { 0x10B00, 0x10B35 }, + { 0x10B39, 0x10B55 }, + { 0x10B58, 0x10B72 }, + { 0x10B78, 0x10B91 }, + { 0x10B99, 0x10B9C }, + { 0x10BA9, 0x10BAF }, + { 0x10C00, 0x10C48 }, + { 0x10C80, 0x10CB2 }, + { 0x10CC0, 0x10CF2 }, + { 0x10CFA, 0x10D27 }, + { 0x10D30, 0x10D39 }, + { 0x10E60, 0x10E7E }, + { 0x10E80, 0x10EA9 }, + { 0x10EAB, 0x10EAD }, + { 0x10EB0, 0x10EB1 }, + { 0x10EFD, 0x10F27 }, + { 0x10F30, 0x10F59 }, + { 0x10F70, 0x10F89 }, + { 0x10FB0, 0x10FCB }, + { 0x10FE0, 0x10FF6 }, + { 0x11000, 0x1104D }, + { 0x11052, 0x11075 }, + { 0x1107F, 0x110C2 }, + { 0x110CD, 0x110CD }, + { 0x110D0, 0x110E8 }, + { 0x110F0, 0x110F9 }, + { 0x11100, 0x11134 }, + { 0x11136, 0x11147 }, + { 0x11150, 0x11176 }, + { 0x11180, 0x111DF }, + { 0x111E1, 0x111F4 }, + { 0x11200, 0x11211 }, + { 0x11213, 0x11241 }, + { 0x11280, 0x11286 }, + { 0x11288, 0x11288 }, + { 0x1128A, 0x1128D }, + { 0x1128F, 0x1129D }, + { 0x1129F, 0x112A9 }, + { 0x112B0, 0x112EA }, + { 0x112F0, 0x112F9 }, + { 0x11300, 0x11303 }, + { 0x11305, 0x1130C }, + { 0x1130F, 0x11310 }, + { 0x11313, 0x11328 }, + { 0x1132A, 0x11330 }, + { 0x11332, 0x11333 }, + { 0x11335, 0x11339 }, + { 0x1133B, 0x11344 }, + { 0x11347, 0x11348 }, + { 0x1134B, 0x1134D }, + { 0x11350, 0x11350 }, + { 0x11357, 0x11357 }, + { 0x1135D, 0x11363 }, + { 0x11366, 0x1136C }, + { 0x11370, 0x11374 }, + { 0x11400, 0x1145B }, + { 0x1145D, 0x11461 }, + { 0x11480, 0x114C7 }, + { 0x114D0, 0x114D9 }, + { 0x11580, 0x115B5 }, + { 0x115B8, 0x115DD }, + { 0x11600, 0x11644 }, + { 0x11650, 0x11659 }, + { 0x11660, 0x1166C }, + { 0x11680, 0x116B9 }, + { 0x116C0, 0x116C9 }, + { 0x11700, 0x1171A }, + { 0x1171D, 0x1172B }, + { 0x11730, 0x11746 }, + { 0x11800, 0x1183B }, + { 0x118A0, 0x118F2 }, + { 0x118FF, 0x11906 }, + { 0x11909, 0x11909 }, + { 0x1190C, 0x11913 }, + { 0x11915, 0x11916 }, + { 0x11918, 0x11935 }, + { 0x11937, 0x11938 }, + { 0x1193B, 0x11946 }, + { 0x11950, 0x11959 }, + { 0x119A0, 0x119A7 }, + { 0x119AA, 0x119D7 }, + { 0x119DA, 0x119E4 }, + { 0x11A00, 0x11A47 }, + { 0x11A50, 0x11AA2 }, + { 0x11AB0, 0x11AF8 }, + { 0x11B00, 0x11B09 }, + { 0x11C00, 0x11C08 }, + { 0x11C0A, 0x11C36 }, + { 0x11C38, 0x11C45 }, + { 0x11C50, 0x11C6C }, + { 0x11C70, 0x11C8F }, + { 0x11C92, 0x11CA7 }, + { 0x11CA9, 0x11CB6 }, + { 0x11D00, 0x11D06 }, + { 0x11D08, 0x11D09 }, + { 0x11D0B, 0x11D36 }, + { 0x11D3A, 0x11D3A }, + { 0x11D3C, 0x11D3D }, + { 0x11D3F, 0x11D47 }, + { 0x11D50, 0x11D59 }, + { 0x11D60, 0x11D65 }, + { 0x11D67, 0x11D68 }, + { 0x11D6A, 0x11D8E }, + { 0x11D90, 0x11D91 }, + { 0x11D93, 0x11D98 }, + { 0x11DA0, 0x11DA9 }, + { 0x11EE0, 0x11EF8 }, + { 0x11F00, 0x11F10 }, + { 0x11F12, 0x11F3A }, + { 0x11F3E, 0x11F59 }, + { 0x11FB0, 0x11FB0 }, + { 0x11FC0, 0x11FF1 }, + { 0x11FFF, 0x12399 }, + { 0x12400, 0x1246E }, + { 0x12470, 0x12474 }, + { 0x12480, 0x12543 }, + { 0x12F90, 0x12FF2 }, + { 0x13000, 0x13455 }, + { 0x14400, 0x14646 }, + { 0x16800, 0x16A38 }, + { 0x16A40, 0x16A5E }, + { 0x16A60, 0x16A69 }, + { 0x16A6E, 0x16ABE }, + { 0x16AC0, 0x16AC9 }, + { 0x16AD0, 0x16AED }, + { 0x16AF0, 0x16AF5 }, + { 0x16B00, 0x16B45 }, + { 0x16B50, 0x16B59 }, + { 0x16B5B, 0x16B61 }, + { 0x16B63, 0x16B77 }, + { 0x16B7D, 0x16B8F }, + { 0x16E40, 0x16E9A }, + { 0x16F00, 0x16F4A }, + { 0x16F4F, 0x16F87 }, + { 0x16F8F, 0x16F9F }, + { 0x16FE0, 0x16FE4 }, + { 0x16FF0, 0x16FF1 }, + { 0x17000, 0x187F7 }, + { 0x18800, 0x18CD5 }, + { 0x18D00, 0x18D08 }, + { 0x1AFF0, 0x1AFF3 }, + { 0x1AFF5, 0x1AFFB }, + { 0x1AFFD, 0x1AFFE }, + { 0x1B000, 0x1B122 }, + { 0x1B132, 0x1B132 }, + { 0x1B150, 0x1B152 }, + { 0x1B155, 0x1B155 }, + { 0x1B164, 0x1B167 }, + { 0x1B170, 0x1B2FB }, + { 0x1BC00, 0x1BC6A }, + { 0x1BC70, 0x1BC7C }, + { 0x1BC80, 0x1BC88 }, + { 0x1BC90, 0x1BC99 }, + { 0x1BC9C, 0x1BCA3 }, + { 0x1CF00, 0x1CF2D }, + { 0x1CF30, 0x1CF46 }, + { 0x1CF50, 0x1CFC3 }, + { 0x1D000, 0x1D0F5 }, + { 0x1D100, 0x1D126 }, + { 0x1D129, 0x1D1EA }, + { 0x1D200, 0x1D245 }, + { 0x1D2C0, 0x1D2D3 }, + { 0x1D2E0, 0x1D2F3 }, + { 0x1D300, 0x1D356 }, + { 0x1D360, 0x1D378 }, + { 0x1D400, 0x1D454 }, + { 0x1D456, 0x1D49C }, + { 0x1D49E, 0x1D49F }, + { 0x1D4A2, 0x1D4A2 }, + { 0x1D4A5, 0x1D4A6 }, + { 0x1D4A9, 0x1D4AC }, + { 0x1D4AE, 0x1D4B9 }, + { 0x1D4BB, 0x1D4BB }, + { 0x1D4BD, 0x1D4C3 }, + { 0x1D4C5, 0x1D505 }, + { 0x1D507, 0x1D50A }, + { 0x1D50D, 0x1D514 }, + { 0x1D516, 0x1D51C }, + { 0x1D51E, 0x1D539 }, + { 0x1D53B, 0x1D53E }, + { 0x1D540, 0x1D544 }, + { 0x1D546, 0x1D546 }, + { 0x1D54A, 0x1D550 }, + { 0x1D552, 0x1D6A5 }, + { 0x1D6A8, 0x1D7CB }, + { 0x1D7CE, 0x1DA8B }, + { 0x1DA9B, 0x1DA9F }, + { 0x1DAA1, 0x1DAAF }, + { 0x1DF00, 0x1DF1E }, + { 0x1DF25, 0x1DF2A }, + { 0x1E000, 0x1E006 }, + { 0x1E008, 0x1E018 }, + { 0x1E01B, 0x1E021 }, + { 0x1E023, 0x1E024 }, + { 0x1E026, 0x1E02A }, + { 0x1E030, 0x1E06D }, + { 0x1E08F, 0x1E08F }, + { 0x1E100, 0x1E12C }, + { 0x1E130, 0x1E13D }, + { 0x1E140, 0x1E149 }, + { 0x1E14E, 0x1E14F }, + { 0x1E290, 0x1E2AE }, + { 0x1E2C0, 0x1E2F9 }, + { 0x1E2FF, 0x1E2FF }, + { 0x1E4D0, 0x1E4F9 }, + { 0x1E7E0, 0x1E7E6 }, + { 0x1E7E8, 0x1E7EB }, + { 0x1E7ED, 0x1E7EE }, + { 0x1E7F0, 0x1E7FE }, + { 0x1E800, 0x1E8C4 }, + { 0x1E8C7, 0x1E8D6 }, + { 0x1E900, 0x1E94B }, + { 0x1E950, 0x1E959 }, + { 0x1E95E, 0x1E95F }, + { 0x1EC71, 0x1ECB4 }, + { 0x1ED01, 0x1ED3D }, + { 0x1EE00, 0x1EE03 }, + { 0x1EE05, 0x1EE1F }, + { 0x1EE21, 0x1EE22 }, + { 0x1EE24, 0x1EE24 }, + { 0x1EE27, 0x1EE27 }, + { 0x1EE29, 0x1EE32 }, + { 0x1EE34, 0x1EE37 }, + { 0x1EE39, 0x1EE39 }, + { 0x1EE3B, 0x1EE3B }, + { 0x1EE42, 0x1EE42 }, + { 0x1EE47, 0x1EE47 }, + { 0x1EE49, 0x1EE49 }, + { 0x1EE4B, 0x1EE4B }, + { 0x1EE4D, 0x1EE4F }, + { 0x1EE51, 0x1EE52 }, + { 0x1EE54, 0x1EE54 }, + { 0x1EE57, 0x1EE57 }, + { 0x1EE59, 0x1EE59 }, + { 0x1EE5B, 0x1EE5B }, + { 0x1EE5D, 0x1EE5D }, + { 0x1EE5F, 0x1EE5F }, + { 0x1EE61, 0x1EE62 }, + { 0x1EE64, 0x1EE64 }, + { 0x1EE67, 0x1EE6A }, + { 0x1EE6C, 0x1EE72 }, + { 0x1EE74, 0x1EE77 }, + { 0x1EE79, 0x1EE7C }, + { 0x1EE7E, 0x1EE7E }, + { 0x1EE80, 0x1EE89 }, + { 0x1EE8B, 0x1EE9B }, + { 0x1EEA1, 0x1EEA3 }, + { 0x1EEA5, 0x1EEA9 }, + { 0x1EEAB, 0x1EEBB }, + { 0x1EEF0, 0x1EEF1 }, + { 0x1F000, 0x1F02B }, + { 0x1F030, 0x1F093 }, + { 0x1F0A0, 0x1F0AE }, + { 0x1F0B1, 0x1F0BF }, + { 0x1F0C1, 0x1F0CF }, + { 0x1F0D1, 0x1F0F5 }, + { 0x1F100, 0x1F1AD }, + { 0x1F1E6, 0x1F202 }, + { 0x1F210, 0x1F23B }, + { 0x1F240, 0x1F248 }, + { 0x1F250, 0x1F251 }, + { 0x1F260, 0x1F265 }, + { 0x1F300, 0x1F6D7 }, + { 0x1F6DC, 0x1F6EC }, + { 0x1F6F0, 0x1F6FC }, + { 0x1F700, 0x1F776 }, + { 0x1F77B, 0x1F7D9 }, + { 0x1F7E0, 0x1F7EB }, + { 0x1F7F0, 0x1F7F0 }, + { 0x1F800, 0x1F80B }, + { 0x1F810, 0x1F847 }, + { 0x1F850, 0x1F859 }, + { 0x1F860, 0x1F887 }, + { 0x1F890, 0x1F8AD }, + { 0x1F8B0, 0x1F8B1 }, + { 0x1F900, 0x1FA53 }, + { 0x1FA60, 0x1FA6D }, + { 0x1FA70, 0x1FA7C }, + { 0x1FA80, 0x1FA88 }, + { 0x1FA90, 0x1FABD }, + { 0x1FABF, 0x1FAC5 }, + { 0x1FACE, 0x1FADB }, + { 0x1FAE0, 0x1FAE8 }, + { 0x1FAF0, 0x1FAF8 }, + { 0x1FB00, 0x1FB92 }, + { 0x1FB94, 0x1FBCA }, + { 0x1FBF0, 0x1FBF9 }, + { 0x20000, 0x2A6DF }, + { 0x2A700, 0x2B739 }, + { 0x2B740, 0x2B81D }, + { 0x2B820, 0x2CEA1 }, + { 0x2CEB0, 0x2EBE0 }, + { 0x2F800, 0x2FA1D }, + { 0x30000, 0x3134A }, + { 0x31350, 0x323AF }, + { 0xE0001, 0xE0001 }, + { 0xE0020, 0xE007F }, + { 0xE0100, 0xE01EF }, + { 0xF0000, 0xFFFFD }, + { 0x100000, 0x10FFFD } + +#define PREDICATE(c) uc_is_graph (c) +#include "test-predicate-part2.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/test-ctype_lower.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/test-ctype_lower.c new file mode 100644 index 00000000..f8fceb33 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/test-ctype_lower.c @@ -0,0 +1,649 @@ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +/* Test the Unicode character type functions. + Copyright (C) 2007-2022 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 the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + This file 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 . */ + +#include "test-predicate-part1.h" + + { 0x0061, 0x007A }, + { 0x00B5, 0x00B5 }, + { 0x00DF, 0x00F6 }, + { 0x00F8, 0x00FF }, + { 0x0101, 0x0101 }, + { 0x0103, 0x0103 }, + { 0x0105, 0x0105 }, + { 0x0107, 0x0107 }, + { 0x0109, 0x0109 }, + { 0x010B, 0x010B }, + { 0x010D, 0x010D }, + { 0x010F, 0x010F }, + { 0x0111, 0x0111 }, + { 0x0113, 0x0113 }, + { 0x0115, 0x0115 }, + { 0x0117, 0x0117 }, + { 0x0119, 0x0119 }, + { 0x011B, 0x011B }, + { 0x011D, 0x011D }, + { 0x011F, 0x011F }, + { 0x0121, 0x0121 }, + { 0x0123, 0x0123 }, + { 0x0125, 0x0125 }, + { 0x0127, 0x0127 }, + { 0x0129, 0x0129 }, + { 0x012B, 0x012B }, + { 0x012D, 0x012D }, + { 0x012F, 0x012F }, + { 0x0131, 0x0131 }, + { 0x0133, 0x0133 }, + { 0x0135, 0x0135 }, + { 0x0137, 0x0137 }, + { 0x013A, 0x013A }, + { 0x013C, 0x013C }, + { 0x013E, 0x013E }, + { 0x0140, 0x0140 }, + { 0x0142, 0x0142 }, + { 0x0144, 0x0144 }, + { 0x0146, 0x0146 }, + { 0x0148, 0x0148 }, + { 0x014B, 0x014B }, + { 0x014D, 0x014D }, + { 0x014F, 0x014F }, + { 0x0151, 0x0151 }, + { 0x0153, 0x0153 }, + { 0x0155, 0x0155 }, + { 0x0157, 0x0157 }, + { 0x0159, 0x0159 }, + { 0x015B, 0x015B }, + { 0x015D, 0x015D }, + { 0x015F, 0x015F }, + { 0x0161, 0x0161 }, + { 0x0163, 0x0163 }, + { 0x0165, 0x0165 }, + { 0x0167, 0x0167 }, + { 0x0169, 0x0169 }, + { 0x016B, 0x016B }, + { 0x016D, 0x016D }, + { 0x016F, 0x016F }, + { 0x0171, 0x0171 }, + { 0x0173, 0x0173 }, + { 0x0175, 0x0175 }, + { 0x0177, 0x0177 }, + { 0x017A, 0x017A }, + { 0x017C, 0x017C }, + { 0x017E, 0x0180 }, + { 0x0183, 0x0183 }, + { 0x0185, 0x0185 }, + { 0x0188, 0x0188 }, + { 0x018C, 0x018C }, + { 0x0192, 0x0192 }, + { 0x0195, 0x0195 }, + { 0x0199, 0x019A }, + { 0x019E, 0x019E }, + { 0x01A1, 0x01A1 }, + { 0x01A3, 0x01A3 }, + { 0x01A5, 0x01A5 }, + { 0x01A8, 0x01A8 }, + { 0x01AD, 0x01AD }, + { 0x01B0, 0x01B0 }, + { 0x01B4, 0x01B4 }, + { 0x01B6, 0x01B6 }, + { 0x01B9, 0x01B9 }, + { 0x01BD, 0x01BD }, + { 0x01BF, 0x01BF }, + { 0x01C5, 0x01C6 }, + { 0x01C8, 0x01C9 }, + { 0x01CB, 0x01CC }, + { 0x01CE, 0x01CE }, + { 0x01D0, 0x01D0 }, + { 0x01D2, 0x01D2 }, + { 0x01D4, 0x01D4 }, + { 0x01D6, 0x01D6 }, + { 0x01D8, 0x01D8 }, + { 0x01DA, 0x01DA }, + { 0x01DC, 0x01DD }, + { 0x01DF, 0x01DF }, + { 0x01E1, 0x01E1 }, + { 0x01E3, 0x01E3 }, + { 0x01E5, 0x01E5 }, + { 0x01E7, 0x01E7 }, + { 0x01E9, 0x01E9 }, + { 0x01EB, 0x01EB }, + { 0x01ED, 0x01ED }, + { 0x01EF, 0x01EF }, + { 0x01F2, 0x01F3 }, + { 0x01F5, 0x01F5 }, + { 0x01F9, 0x01F9 }, + { 0x01FB, 0x01FB }, + { 0x01FD, 0x01FD }, + { 0x01FF, 0x01FF }, + { 0x0201, 0x0201 }, + { 0x0203, 0x0203 }, + { 0x0205, 0x0205 }, + { 0x0207, 0x0207 }, + { 0x0209, 0x0209 }, + { 0x020B, 0x020B }, + { 0x020D, 0x020D }, + { 0x020F, 0x020F }, + { 0x0211, 0x0211 }, + { 0x0213, 0x0213 }, + { 0x0215, 0x0215 }, + { 0x0217, 0x0217 }, + { 0x0219, 0x0219 }, + { 0x021B, 0x021B }, + { 0x021D, 0x021D }, + { 0x021F, 0x021F }, + { 0x0223, 0x0223 }, + { 0x0225, 0x0225 }, + { 0x0227, 0x0227 }, + { 0x0229, 0x0229 }, + { 0x022B, 0x022B }, + { 0x022D, 0x022D }, + { 0x022F, 0x022F }, + { 0x0231, 0x0231 }, + { 0x0233, 0x0233 }, + { 0x023C, 0x023C }, + { 0x023F, 0x0240 }, + { 0x0242, 0x0242 }, + { 0x0247, 0x0247 }, + { 0x0249, 0x0249 }, + { 0x024B, 0x024B }, + { 0x024D, 0x024D }, + { 0x024F, 0x0254 }, + { 0x0256, 0x0257 }, + { 0x0259, 0x0259 }, + { 0x025B, 0x025C }, + { 0x0260, 0x0261 }, + { 0x0263, 0x0263 }, + { 0x0265, 0x0266 }, + { 0x0268, 0x026C }, + { 0x026F, 0x026F }, + { 0x0271, 0x0272 }, + { 0x0275, 0x0275 }, + { 0x027D, 0x027D }, + { 0x0280, 0x0280 }, + { 0x0282, 0x0283 }, + { 0x0287, 0x028C }, + { 0x0292, 0x0292 }, + { 0x029D, 0x029E }, + { 0x0345, 0x0345 }, + { 0x0371, 0x0371 }, + { 0x0373, 0x0373 }, + { 0x0377, 0x0377 }, + { 0x037B, 0x037D }, + { 0x03AC, 0x03AF }, + { 0x03B1, 0x03CE }, + { 0x03D0, 0x03D1 }, + { 0x03D5, 0x03D7 }, + { 0x03D9, 0x03D9 }, + { 0x03DB, 0x03DB }, + { 0x03DD, 0x03DD }, + { 0x03DF, 0x03DF }, + { 0x03E1, 0x03E1 }, + { 0x03E3, 0x03E3 }, + { 0x03E5, 0x03E5 }, + { 0x03E7, 0x03E7 }, + { 0x03E9, 0x03E9 }, + { 0x03EB, 0x03EB }, + { 0x03ED, 0x03ED }, + { 0x03EF, 0x03F3 }, + { 0x03F5, 0x03F5 }, + { 0x03F8, 0x03F8 }, + { 0x03FB, 0x03FB }, + { 0x0430, 0x045F }, + { 0x0461, 0x0461 }, + { 0x0463, 0x0463 }, + { 0x0465, 0x0465 }, + { 0x0467, 0x0467 }, + { 0x0469, 0x0469 }, + { 0x046B, 0x046B }, + { 0x046D, 0x046D }, + { 0x046F, 0x046F }, + { 0x0471, 0x0471 }, + { 0x0473, 0x0473 }, + { 0x0475, 0x0475 }, + { 0x0477, 0x0477 }, + { 0x0479, 0x0479 }, + { 0x047B, 0x047B }, + { 0x047D, 0x047D }, + { 0x047F, 0x047F }, + { 0x0481, 0x0481 }, + { 0x048B, 0x048B }, + { 0x048D, 0x048D }, + { 0x048F, 0x048F }, + { 0x0491, 0x0491 }, + { 0x0493, 0x0493 }, + { 0x0495, 0x0495 }, + { 0x0497, 0x0497 }, + { 0x0499, 0x0499 }, + { 0x049B, 0x049B }, + { 0x049D, 0x049D }, + { 0x049F, 0x049F }, + { 0x04A1, 0x04A1 }, + { 0x04A3, 0x04A3 }, + { 0x04A5, 0x04A5 }, + { 0x04A7, 0x04A7 }, + { 0x04A9, 0x04A9 }, + { 0x04AB, 0x04AB }, + { 0x04AD, 0x04AD }, + { 0x04AF, 0x04AF }, + { 0x04B1, 0x04B1 }, + { 0x04B3, 0x04B3 }, + { 0x04B5, 0x04B5 }, + { 0x04B7, 0x04B7 }, + { 0x04B9, 0x04B9 }, + { 0x04BB, 0x04BB }, + { 0x04BD, 0x04BD }, + { 0x04BF, 0x04BF }, + { 0x04C2, 0x04C2 }, + { 0x04C4, 0x04C4 }, + { 0x04C6, 0x04C6 }, + { 0x04C8, 0x04C8 }, + { 0x04CA, 0x04CA }, + { 0x04CC, 0x04CC }, + { 0x04CE, 0x04CF }, + { 0x04D1, 0x04D1 }, + { 0x04D3, 0x04D3 }, + { 0x04D5, 0x04D5 }, + { 0x04D7, 0x04D7 }, + { 0x04D9, 0x04D9 }, + { 0x04DB, 0x04DB }, + { 0x04DD, 0x04DD }, + { 0x04DF, 0x04DF }, + { 0x04E1, 0x04E1 }, + { 0x04E3, 0x04E3 }, + { 0x04E5, 0x04E5 }, + { 0x04E7, 0x04E7 }, + { 0x04E9, 0x04E9 }, + { 0x04EB, 0x04EB }, + { 0x04ED, 0x04ED }, + { 0x04EF, 0x04EF }, + { 0x04F1, 0x04F1 }, + { 0x04F3, 0x04F3 }, + { 0x04F5, 0x04F5 }, + { 0x04F7, 0x04F7 }, + { 0x04F9, 0x04F9 }, + { 0x04FB, 0x04FB }, + { 0x04FD, 0x04FD }, + { 0x04FF, 0x04FF }, + { 0x0501, 0x0501 }, + { 0x0503, 0x0503 }, + { 0x0505, 0x0505 }, + { 0x0507, 0x0507 }, + { 0x0509, 0x0509 }, + { 0x050B, 0x050B }, + { 0x050D, 0x050D }, + { 0x050F, 0x050F }, + { 0x0511, 0x0511 }, + { 0x0513, 0x0513 }, + { 0x0515, 0x0515 }, + { 0x0517, 0x0517 }, + { 0x0519, 0x0519 }, + { 0x051B, 0x051B }, + { 0x051D, 0x051D }, + { 0x051F, 0x051F }, + { 0x0521, 0x0521 }, + { 0x0523, 0x0523 }, + { 0x0525, 0x0525 }, + { 0x0527, 0x0527 }, + { 0x0529, 0x0529 }, + { 0x052B, 0x052B }, + { 0x052D, 0x052D }, + { 0x052F, 0x052F }, + { 0x0561, 0x0586 }, + { 0x10D0, 0x10FA }, + { 0x10FD, 0x10FF }, + { 0x13F8, 0x13FD }, + { 0x1C80, 0x1C88 }, + { 0x1D79, 0x1D79 }, + { 0x1D7D, 0x1D7D }, + { 0x1D8E, 0x1D8E }, + { 0x1E01, 0x1E01 }, + { 0x1E03, 0x1E03 }, + { 0x1E05, 0x1E05 }, + { 0x1E07, 0x1E07 }, + { 0x1E09, 0x1E09 }, + { 0x1E0B, 0x1E0B }, + { 0x1E0D, 0x1E0D }, + { 0x1E0F, 0x1E0F }, + { 0x1E11, 0x1E11 }, + { 0x1E13, 0x1E13 }, + { 0x1E15, 0x1E15 }, + { 0x1E17, 0x1E17 }, + { 0x1E19, 0x1E19 }, + { 0x1E1B, 0x1E1B }, + { 0x1E1D, 0x1E1D }, + { 0x1E1F, 0x1E1F }, + { 0x1E21, 0x1E21 }, + { 0x1E23, 0x1E23 }, + { 0x1E25, 0x1E25 }, + { 0x1E27, 0x1E27 }, + { 0x1E29, 0x1E29 }, + { 0x1E2B, 0x1E2B }, + { 0x1E2D, 0x1E2D }, + { 0x1E2F, 0x1E2F }, + { 0x1E31, 0x1E31 }, + { 0x1E33, 0x1E33 }, + { 0x1E35, 0x1E35 }, + { 0x1E37, 0x1E37 }, + { 0x1E39, 0x1E39 }, + { 0x1E3B, 0x1E3B }, + { 0x1E3D, 0x1E3D }, + { 0x1E3F, 0x1E3F }, + { 0x1E41, 0x1E41 }, + { 0x1E43, 0x1E43 }, + { 0x1E45, 0x1E45 }, + { 0x1E47, 0x1E47 }, + { 0x1E49, 0x1E49 }, + { 0x1E4B, 0x1E4B }, + { 0x1E4D, 0x1E4D }, + { 0x1E4F, 0x1E4F }, + { 0x1E51, 0x1E51 }, + { 0x1E53, 0x1E53 }, + { 0x1E55, 0x1E55 }, + { 0x1E57, 0x1E57 }, + { 0x1E59, 0x1E59 }, + { 0x1E5B, 0x1E5B }, + { 0x1E5D, 0x1E5D }, + { 0x1E5F, 0x1E5F }, + { 0x1E61, 0x1E61 }, + { 0x1E63, 0x1E63 }, + { 0x1E65, 0x1E65 }, + { 0x1E67, 0x1E67 }, + { 0x1E69, 0x1E69 }, + { 0x1E6B, 0x1E6B }, + { 0x1E6D, 0x1E6D }, + { 0x1E6F, 0x1E6F }, + { 0x1E71, 0x1E71 }, + { 0x1E73, 0x1E73 }, + { 0x1E75, 0x1E75 }, + { 0x1E77, 0x1E77 }, + { 0x1E79, 0x1E79 }, + { 0x1E7B, 0x1E7B }, + { 0x1E7D, 0x1E7D }, + { 0x1E7F, 0x1E7F }, + { 0x1E81, 0x1E81 }, + { 0x1E83, 0x1E83 }, + { 0x1E85, 0x1E85 }, + { 0x1E87, 0x1E87 }, + { 0x1E89, 0x1E89 }, + { 0x1E8B, 0x1E8B }, + { 0x1E8D, 0x1E8D }, + { 0x1E8F, 0x1E8F }, + { 0x1E91, 0x1E91 }, + { 0x1E93, 0x1E93 }, + { 0x1E95, 0x1E95 }, + { 0x1E9B, 0x1E9B }, + { 0x1EA1, 0x1EA1 }, + { 0x1EA3, 0x1EA3 }, + { 0x1EA5, 0x1EA5 }, + { 0x1EA7, 0x1EA7 }, + { 0x1EA9, 0x1EA9 }, + { 0x1EAB, 0x1EAB }, + { 0x1EAD, 0x1EAD }, + { 0x1EAF, 0x1EAF }, + { 0x1EB1, 0x1EB1 }, + { 0x1EB3, 0x1EB3 }, + { 0x1EB5, 0x1EB5 }, + { 0x1EB7, 0x1EB7 }, + { 0x1EB9, 0x1EB9 }, + { 0x1EBB, 0x1EBB }, + { 0x1EBD, 0x1EBD }, + { 0x1EBF, 0x1EBF }, + { 0x1EC1, 0x1EC1 }, + { 0x1EC3, 0x1EC3 }, + { 0x1EC5, 0x1EC5 }, + { 0x1EC7, 0x1EC7 }, + { 0x1EC9, 0x1EC9 }, + { 0x1ECB, 0x1ECB }, + { 0x1ECD, 0x1ECD }, + { 0x1ECF, 0x1ECF }, + { 0x1ED1, 0x1ED1 }, + { 0x1ED3, 0x1ED3 }, + { 0x1ED5, 0x1ED5 }, + { 0x1ED7, 0x1ED7 }, + { 0x1ED9, 0x1ED9 }, + { 0x1EDB, 0x1EDB }, + { 0x1EDD, 0x1EDD }, + { 0x1EDF, 0x1EDF }, + { 0x1EE1, 0x1EE1 }, + { 0x1EE3, 0x1EE3 }, + { 0x1EE5, 0x1EE5 }, + { 0x1EE7, 0x1EE7 }, + { 0x1EE9, 0x1EE9 }, + { 0x1EEB, 0x1EEB }, + { 0x1EED, 0x1EED }, + { 0x1EEF, 0x1EEF }, + { 0x1EF1, 0x1EF1 }, + { 0x1EF3, 0x1EF3 }, + { 0x1EF5, 0x1EF5 }, + { 0x1EF7, 0x1EF7 }, + { 0x1EF9, 0x1EF9 }, + { 0x1EFB, 0x1EFB }, + { 0x1EFD, 0x1EFD }, + { 0x1EFF, 0x1F07 }, + { 0x1F10, 0x1F15 }, + { 0x1F20, 0x1F27 }, + { 0x1F30, 0x1F37 }, + { 0x1F40, 0x1F45 }, + { 0x1F51, 0x1F51 }, + { 0x1F53, 0x1F53 }, + { 0x1F55, 0x1F55 }, + { 0x1F57, 0x1F57 }, + { 0x1F60, 0x1F67 }, + { 0x1F70, 0x1F7D }, + { 0x1F80, 0x1F87 }, + { 0x1F90, 0x1F97 }, + { 0x1FA0, 0x1FA7 }, + { 0x1FB0, 0x1FB1 }, + { 0x1FB3, 0x1FB3 }, + { 0x1FBE, 0x1FBE }, + { 0x1FC3, 0x1FC3 }, + { 0x1FD0, 0x1FD1 }, + { 0x1FE0, 0x1FE1 }, + { 0x1FE5, 0x1FE5 }, + { 0x1FF3, 0x1FF3 }, + { 0x214E, 0x214E }, + { 0x2170, 0x217F }, + { 0x2184, 0x2184 }, + { 0x24D0, 0x24E9 }, + { 0x2C30, 0x2C5F }, + { 0x2C61, 0x2C61 }, + { 0x2C65, 0x2C66 }, + { 0x2C68, 0x2C68 }, + { 0x2C6A, 0x2C6A }, + { 0x2C6C, 0x2C6C }, + { 0x2C73, 0x2C73 }, + { 0x2C76, 0x2C76 }, + { 0x2C81, 0x2C81 }, + { 0x2C83, 0x2C83 }, + { 0x2C85, 0x2C85 }, + { 0x2C87, 0x2C87 }, + { 0x2C89, 0x2C89 }, + { 0x2C8B, 0x2C8B }, + { 0x2C8D, 0x2C8D }, + { 0x2C8F, 0x2C8F }, + { 0x2C91, 0x2C91 }, + { 0x2C93, 0x2C93 }, + { 0x2C95, 0x2C95 }, + { 0x2C97, 0x2C97 }, + { 0x2C99, 0x2C99 }, + { 0x2C9B, 0x2C9B }, + { 0x2C9D, 0x2C9D }, + { 0x2C9F, 0x2C9F }, + { 0x2CA1, 0x2CA1 }, + { 0x2CA3, 0x2CA3 }, + { 0x2CA5, 0x2CA5 }, + { 0x2CA7, 0x2CA7 }, + { 0x2CA9, 0x2CA9 }, + { 0x2CAB, 0x2CAB }, + { 0x2CAD, 0x2CAD }, + { 0x2CAF, 0x2CAF }, + { 0x2CB1, 0x2CB1 }, + { 0x2CB3, 0x2CB3 }, + { 0x2CB5, 0x2CB5 }, + { 0x2CB7, 0x2CB7 }, + { 0x2CB9, 0x2CB9 }, + { 0x2CBB, 0x2CBB }, + { 0x2CBD, 0x2CBD }, + { 0x2CBF, 0x2CBF }, + { 0x2CC1, 0x2CC1 }, + { 0x2CC3, 0x2CC3 }, + { 0x2CC5, 0x2CC5 }, + { 0x2CC7, 0x2CC7 }, + { 0x2CC9, 0x2CC9 }, + { 0x2CCB, 0x2CCB }, + { 0x2CCD, 0x2CCD }, + { 0x2CCF, 0x2CCF }, + { 0x2CD1, 0x2CD1 }, + { 0x2CD3, 0x2CD3 }, + { 0x2CD5, 0x2CD5 }, + { 0x2CD7, 0x2CD7 }, + { 0x2CD9, 0x2CD9 }, + { 0x2CDB, 0x2CDB }, + { 0x2CDD, 0x2CDD }, + { 0x2CDF, 0x2CDF }, + { 0x2CE1, 0x2CE1 }, + { 0x2CE3, 0x2CE3 }, + { 0x2CEC, 0x2CEC }, + { 0x2CEE, 0x2CEE }, + { 0x2CF3, 0x2CF3 }, + { 0x2D00, 0x2D25 }, + { 0x2D27, 0x2D27 }, + { 0x2D2D, 0x2D2D }, + { 0xA641, 0xA641 }, + { 0xA643, 0xA643 }, + { 0xA645, 0xA645 }, + { 0xA647, 0xA647 }, + { 0xA649, 0xA649 }, + { 0xA64B, 0xA64B }, + { 0xA64D, 0xA64D }, + { 0xA64F, 0xA64F }, + { 0xA651, 0xA651 }, + { 0xA653, 0xA653 }, + { 0xA655, 0xA655 }, + { 0xA657, 0xA657 }, + { 0xA659, 0xA659 }, + { 0xA65B, 0xA65B }, + { 0xA65D, 0xA65D }, + { 0xA65F, 0xA65F }, + { 0xA661, 0xA661 }, + { 0xA663, 0xA663 }, + { 0xA665, 0xA665 }, + { 0xA667, 0xA667 }, + { 0xA669, 0xA669 }, + { 0xA66B, 0xA66B }, + { 0xA66D, 0xA66D }, + { 0xA681, 0xA681 }, + { 0xA683, 0xA683 }, + { 0xA685, 0xA685 }, + { 0xA687, 0xA687 }, + { 0xA689, 0xA689 }, + { 0xA68B, 0xA68B }, + { 0xA68D, 0xA68D }, + { 0xA68F, 0xA68F }, + { 0xA691, 0xA691 }, + { 0xA693, 0xA693 }, + { 0xA695, 0xA695 }, + { 0xA697, 0xA697 }, + { 0xA699, 0xA699 }, + { 0xA69B, 0xA69B }, + { 0xA723, 0xA723 }, + { 0xA725, 0xA725 }, + { 0xA727, 0xA727 }, + { 0xA729, 0xA729 }, + { 0xA72B, 0xA72B }, + { 0xA72D, 0xA72D }, + { 0xA72F, 0xA72F }, + { 0xA733, 0xA733 }, + { 0xA735, 0xA735 }, + { 0xA737, 0xA737 }, + { 0xA739, 0xA739 }, + { 0xA73B, 0xA73B }, + { 0xA73D, 0xA73D }, + { 0xA73F, 0xA73F }, + { 0xA741, 0xA741 }, + { 0xA743, 0xA743 }, + { 0xA745, 0xA745 }, + { 0xA747, 0xA747 }, + { 0xA749, 0xA749 }, + { 0xA74B, 0xA74B }, + { 0xA74D, 0xA74D }, + { 0xA74F, 0xA74F }, + { 0xA751, 0xA751 }, + { 0xA753, 0xA753 }, + { 0xA755, 0xA755 }, + { 0xA757, 0xA757 }, + { 0xA759, 0xA759 }, + { 0xA75B, 0xA75B }, + { 0xA75D, 0xA75D }, + { 0xA75F, 0xA75F }, + { 0xA761, 0xA761 }, + { 0xA763, 0xA763 }, + { 0xA765, 0xA765 }, + { 0xA767, 0xA767 }, + { 0xA769, 0xA769 }, + { 0xA76B, 0xA76B }, + { 0xA76D, 0xA76D }, + { 0xA76F, 0xA76F }, + { 0xA77A, 0xA77A }, + { 0xA77C, 0xA77C }, + { 0xA77F, 0xA77F }, + { 0xA781, 0xA781 }, + { 0xA783, 0xA783 }, + { 0xA785, 0xA785 }, + { 0xA787, 0xA787 }, + { 0xA78C, 0xA78C }, + { 0xA791, 0xA791 }, + { 0xA793, 0xA794 }, + { 0xA797, 0xA797 }, + { 0xA799, 0xA799 }, + { 0xA79B, 0xA79B }, + { 0xA79D, 0xA79D }, + { 0xA79F, 0xA79F }, + { 0xA7A1, 0xA7A1 }, + { 0xA7A3, 0xA7A3 }, + { 0xA7A5, 0xA7A5 }, + { 0xA7A7, 0xA7A7 }, + { 0xA7A9, 0xA7A9 }, + { 0xA7B5, 0xA7B5 }, + { 0xA7B7, 0xA7B7 }, + { 0xA7B9, 0xA7B9 }, + { 0xA7BB, 0xA7BB }, + { 0xA7BD, 0xA7BD }, + { 0xA7BF, 0xA7BF }, + { 0xA7C1, 0xA7C1 }, + { 0xA7C3, 0xA7C3 }, + { 0xA7C8, 0xA7C8 }, + { 0xA7CA, 0xA7CA }, + { 0xA7D1, 0xA7D1 }, + { 0xA7D7, 0xA7D7 }, + { 0xA7D9, 0xA7D9 }, + { 0xA7F6, 0xA7F6 }, + { 0xAB53, 0xAB53 }, + { 0xAB70, 0xABBF }, + { 0xFF41, 0xFF5A }, + { 0x10428, 0x1044F }, + { 0x104D8, 0x104FB }, + { 0x10597, 0x105A1 }, + { 0x105A3, 0x105B1 }, + { 0x105B3, 0x105B9 }, + { 0x105BB, 0x105BC }, + { 0x10CC0, 0x10CF2 }, + { 0x118C0, 0x118DF }, + { 0x16E60, 0x16E7F }, + { 0x1E922, 0x1E943 } + +#define PREDICATE(c) uc_is_lower (c) +#include "test-predicate-part2.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/test-ctype_print.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/test-ctype_print.c new file mode 100644 index 00000000..dad6b07b --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/test-ctype_print.c @@ -0,0 +1,731 @@ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +/* Test the Unicode character type functions. + Copyright (C) 2007-2022 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 the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + This file 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 . */ + +#include "test-predicate-part1.h" + + { 0x0020, 0x007E }, + { 0x00A0, 0x0377 }, + { 0x037A, 0x037F }, + { 0x0384, 0x038A }, + { 0x038C, 0x038C }, + { 0x038E, 0x03A1 }, + { 0x03A3, 0x052F }, + { 0x0531, 0x0556 }, + { 0x0559, 0x058A }, + { 0x058D, 0x058F }, + { 0x0591, 0x05C7 }, + { 0x05D0, 0x05EA }, + { 0x05EF, 0x05F4 }, + { 0x0600, 0x070D }, + { 0x070F, 0x074A }, + { 0x074D, 0x07B1 }, + { 0x07C0, 0x07FA }, + { 0x07FD, 0x082D }, + { 0x0830, 0x083E }, + { 0x0840, 0x085B }, + { 0x085E, 0x085E }, + { 0x0860, 0x086A }, + { 0x0870, 0x088E }, + { 0x0890, 0x0891 }, + { 0x0898, 0x0983 }, + { 0x0985, 0x098C }, + { 0x098F, 0x0990 }, + { 0x0993, 0x09A8 }, + { 0x09AA, 0x09B0 }, + { 0x09B2, 0x09B2 }, + { 0x09B6, 0x09B9 }, + { 0x09BC, 0x09C4 }, + { 0x09C7, 0x09C8 }, + { 0x09CB, 0x09CE }, + { 0x09D7, 0x09D7 }, + { 0x09DC, 0x09DD }, + { 0x09DF, 0x09E3 }, + { 0x09E6, 0x09FE }, + { 0x0A01, 0x0A03 }, + { 0x0A05, 0x0A0A }, + { 0x0A0F, 0x0A10 }, + { 0x0A13, 0x0A28 }, + { 0x0A2A, 0x0A30 }, + { 0x0A32, 0x0A33 }, + { 0x0A35, 0x0A36 }, + { 0x0A38, 0x0A39 }, + { 0x0A3C, 0x0A3C }, + { 0x0A3E, 0x0A42 }, + { 0x0A47, 0x0A48 }, + { 0x0A4B, 0x0A4D }, + { 0x0A51, 0x0A51 }, + { 0x0A59, 0x0A5C }, + { 0x0A5E, 0x0A5E }, + { 0x0A66, 0x0A76 }, + { 0x0A81, 0x0A83 }, + { 0x0A85, 0x0A8D }, + { 0x0A8F, 0x0A91 }, + { 0x0A93, 0x0AA8 }, + { 0x0AAA, 0x0AB0 }, + { 0x0AB2, 0x0AB3 }, + { 0x0AB5, 0x0AB9 }, + { 0x0ABC, 0x0AC5 }, + { 0x0AC7, 0x0AC9 }, + { 0x0ACB, 0x0ACD }, + { 0x0AD0, 0x0AD0 }, + { 0x0AE0, 0x0AE3 }, + { 0x0AE6, 0x0AF1 }, + { 0x0AF9, 0x0AFF }, + { 0x0B01, 0x0B03 }, + { 0x0B05, 0x0B0C }, + { 0x0B0F, 0x0B10 }, + { 0x0B13, 0x0B28 }, + { 0x0B2A, 0x0B30 }, + { 0x0B32, 0x0B33 }, + { 0x0B35, 0x0B39 }, + { 0x0B3C, 0x0B44 }, + { 0x0B47, 0x0B48 }, + { 0x0B4B, 0x0B4D }, + { 0x0B55, 0x0B57 }, + { 0x0B5C, 0x0B5D }, + { 0x0B5F, 0x0B63 }, + { 0x0B66, 0x0B77 }, + { 0x0B82, 0x0B83 }, + { 0x0B85, 0x0B8A }, + { 0x0B8E, 0x0B90 }, + { 0x0B92, 0x0B95 }, + { 0x0B99, 0x0B9A }, + { 0x0B9C, 0x0B9C }, + { 0x0B9E, 0x0B9F }, + { 0x0BA3, 0x0BA4 }, + { 0x0BA8, 0x0BAA }, + { 0x0BAE, 0x0BB9 }, + { 0x0BBE, 0x0BC2 }, + { 0x0BC6, 0x0BC8 }, + { 0x0BCA, 0x0BCD }, + { 0x0BD0, 0x0BD0 }, + { 0x0BD7, 0x0BD7 }, + { 0x0BE6, 0x0BFA }, + { 0x0C00, 0x0C0C }, + { 0x0C0E, 0x0C10 }, + { 0x0C12, 0x0C28 }, + { 0x0C2A, 0x0C39 }, + { 0x0C3C, 0x0C44 }, + { 0x0C46, 0x0C48 }, + { 0x0C4A, 0x0C4D }, + { 0x0C55, 0x0C56 }, + { 0x0C58, 0x0C5A }, + { 0x0C5D, 0x0C5D }, + { 0x0C60, 0x0C63 }, + { 0x0C66, 0x0C6F }, + { 0x0C77, 0x0C8C }, + { 0x0C8E, 0x0C90 }, + { 0x0C92, 0x0CA8 }, + { 0x0CAA, 0x0CB3 }, + { 0x0CB5, 0x0CB9 }, + { 0x0CBC, 0x0CC4 }, + { 0x0CC6, 0x0CC8 }, + { 0x0CCA, 0x0CCD }, + { 0x0CD5, 0x0CD6 }, + { 0x0CDD, 0x0CDE }, + { 0x0CE0, 0x0CE3 }, + { 0x0CE6, 0x0CEF }, + { 0x0CF1, 0x0CF3 }, + { 0x0D00, 0x0D0C }, + { 0x0D0E, 0x0D10 }, + { 0x0D12, 0x0D44 }, + { 0x0D46, 0x0D48 }, + { 0x0D4A, 0x0D4F }, + { 0x0D54, 0x0D63 }, + { 0x0D66, 0x0D7F }, + { 0x0D81, 0x0D83 }, + { 0x0D85, 0x0D96 }, + { 0x0D9A, 0x0DB1 }, + { 0x0DB3, 0x0DBB }, + { 0x0DBD, 0x0DBD }, + { 0x0DC0, 0x0DC6 }, + { 0x0DCA, 0x0DCA }, + { 0x0DCF, 0x0DD4 }, + { 0x0DD6, 0x0DD6 }, + { 0x0DD8, 0x0DDF }, + { 0x0DE6, 0x0DEF }, + { 0x0DF2, 0x0DF4 }, + { 0x0E01, 0x0E3A }, + { 0x0E3F, 0x0E5B }, + { 0x0E81, 0x0E82 }, + { 0x0E84, 0x0E84 }, + { 0x0E86, 0x0E8A }, + { 0x0E8C, 0x0EA3 }, + { 0x0EA5, 0x0EA5 }, + { 0x0EA7, 0x0EBD }, + { 0x0EC0, 0x0EC4 }, + { 0x0EC6, 0x0EC6 }, + { 0x0EC8, 0x0ECE }, + { 0x0ED0, 0x0ED9 }, + { 0x0EDC, 0x0EDF }, + { 0x0F00, 0x0F47 }, + { 0x0F49, 0x0F6C }, + { 0x0F71, 0x0F97 }, + { 0x0F99, 0x0FBC }, + { 0x0FBE, 0x0FCC }, + { 0x0FCE, 0x0FDA }, + { 0x1000, 0x10C5 }, + { 0x10C7, 0x10C7 }, + { 0x10CD, 0x10CD }, + { 0x10D0, 0x1248 }, + { 0x124A, 0x124D }, + { 0x1250, 0x1256 }, + { 0x1258, 0x1258 }, + { 0x125A, 0x125D }, + { 0x1260, 0x1288 }, + { 0x128A, 0x128D }, + { 0x1290, 0x12B0 }, + { 0x12B2, 0x12B5 }, + { 0x12B8, 0x12BE }, + { 0x12C0, 0x12C0 }, + { 0x12C2, 0x12C5 }, + { 0x12C8, 0x12D6 }, + { 0x12D8, 0x1310 }, + { 0x1312, 0x1315 }, + { 0x1318, 0x135A }, + { 0x135D, 0x137C }, + { 0x1380, 0x1399 }, + { 0x13A0, 0x13F5 }, + { 0x13F8, 0x13FD }, + { 0x1400, 0x169C }, + { 0x16A0, 0x16F8 }, + { 0x1700, 0x1715 }, + { 0x171F, 0x1736 }, + { 0x1740, 0x1753 }, + { 0x1760, 0x176C }, + { 0x176E, 0x1770 }, + { 0x1772, 0x1773 }, + { 0x1780, 0x17DD }, + { 0x17E0, 0x17E9 }, + { 0x17F0, 0x17F9 }, + { 0x1800, 0x1819 }, + { 0x1820, 0x1878 }, + { 0x1880, 0x18AA }, + { 0x18B0, 0x18F5 }, + { 0x1900, 0x191E }, + { 0x1920, 0x192B }, + { 0x1930, 0x193B }, + { 0x1940, 0x1940 }, + { 0x1944, 0x196D }, + { 0x1970, 0x1974 }, + { 0x1980, 0x19AB }, + { 0x19B0, 0x19C9 }, + { 0x19D0, 0x19DA }, + { 0x19DE, 0x1A1B }, + { 0x1A1E, 0x1A5E }, + { 0x1A60, 0x1A7C }, + { 0x1A7F, 0x1A89 }, + { 0x1A90, 0x1A99 }, + { 0x1AA0, 0x1AAD }, + { 0x1AB0, 0x1ACE }, + { 0x1B00, 0x1B4C }, + { 0x1B50, 0x1B7E }, + { 0x1B80, 0x1BF3 }, + { 0x1BFC, 0x1C37 }, + { 0x1C3B, 0x1C49 }, + { 0x1C4D, 0x1C88 }, + { 0x1C90, 0x1CBA }, + { 0x1CBD, 0x1CC7 }, + { 0x1CD0, 0x1CFA }, + { 0x1D00, 0x1F15 }, + { 0x1F18, 0x1F1D }, + { 0x1F20, 0x1F45 }, + { 0x1F48, 0x1F4D }, + { 0x1F50, 0x1F57 }, + { 0x1F59, 0x1F59 }, + { 0x1F5B, 0x1F5B }, + { 0x1F5D, 0x1F5D }, + { 0x1F5F, 0x1F7D }, + { 0x1F80, 0x1FB4 }, + { 0x1FB6, 0x1FC4 }, + { 0x1FC6, 0x1FD3 }, + { 0x1FD6, 0x1FDB }, + { 0x1FDD, 0x1FEF }, + { 0x1FF2, 0x1FF4 }, + { 0x1FF6, 0x1FFE }, + { 0x2000, 0x2027 }, + { 0x202A, 0x2064 }, + { 0x2066, 0x2071 }, + { 0x2074, 0x208E }, + { 0x2090, 0x209C }, + { 0x20A0, 0x20C0 }, + { 0x20D0, 0x20F0 }, + { 0x2100, 0x218B }, + { 0x2190, 0x2426 }, + { 0x2440, 0x244A }, + { 0x2460, 0x2B73 }, + { 0x2B76, 0x2B95 }, + { 0x2B97, 0x2CF3 }, + { 0x2CF9, 0x2D25 }, + { 0x2D27, 0x2D27 }, + { 0x2D2D, 0x2D2D }, + { 0x2D30, 0x2D67 }, + { 0x2D6F, 0x2D70 }, + { 0x2D7F, 0x2D96 }, + { 0x2DA0, 0x2DA6 }, + { 0x2DA8, 0x2DAE }, + { 0x2DB0, 0x2DB6 }, + { 0x2DB8, 0x2DBE }, + { 0x2DC0, 0x2DC6 }, + { 0x2DC8, 0x2DCE }, + { 0x2DD0, 0x2DD6 }, + { 0x2DD8, 0x2DDE }, + { 0x2DE0, 0x2E5D }, + { 0x2E80, 0x2E99 }, + { 0x2E9B, 0x2EF3 }, + { 0x2F00, 0x2FD5 }, + { 0x2FF0, 0x2FFB }, + { 0x3000, 0x303F }, + { 0x3041, 0x3096 }, + { 0x3099, 0x30FF }, + { 0x3105, 0x312F }, + { 0x3131, 0x318E }, + { 0x3190, 0x31E3 }, + { 0x31F0, 0x321E }, + { 0x3220, 0xA48C }, + { 0xA490, 0xA4C6 }, + { 0xA4D0, 0xA62B }, + { 0xA640, 0xA6F7 }, + { 0xA700, 0xA7CA }, + { 0xA7D0, 0xA7D1 }, + { 0xA7D3, 0xA7D3 }, + { 0xA7D5, 0xA7D9 }, + { 0xA7F2, 0xA82C }, + { 0xA830, 0xA839 }, + { 0xA840, 0xA877 }, + { 0xA880, 0xA8C5 }, + { 0xA8CE, 0xA8D9 }, + { 0xA8E0, 0xA953 }, + { 0xA95F, 0xA97C }, + { 0xA980, 0xA9CD }, + { 0xA9CF, 0xA9D9 }, + { 0xA9DE, 0xA9FE }, + { 0xAA00, 0xAA36 }, + { 0xAA40, 0xAA4D }, + { 0xAA50, 0xAA59 }, + { 0xAA5C, 0xAAC2 }, + { 0xAADB, 0xAAF6 }, + { 0xAB01, 0xAB06 }, + { 0xAB09, 0xAB0E }, + { 0xAB11, 0xAB16 }, + { 0xAB20, 0xAB26 }, + { 0xAB28, 0xAB2E }, + { 0xAB30, 0xAB6B }, + { 0xAB70, 0xABED }, + { 0xABF0, 0xABF9 }, + { 0xAC00, 0xD7A3 }, + { 0xD7B0, 0xD7C6 }, + { 0xD7CB, 0xD7FB }, + { 0xE000, 0xFA6D }, + { 0xFA70, 0xFAD9 }, + { 0xFB00, 0xFB06 }, + { 0xFB13, 0xFB17 }, + { 0xFB1D, 0xFB36 }, + { 0xFB38, 0xFB3C }, + { 0xFB3E, 0xFB3E }, + { 0xFB40, 0xFB41 }, + { 0xFB43, 0xFB44 }, + { 0xFB46, 0xFBC2 }, + { 0xFBD3, 0xFD8F }, + { 0xFD92, 0xFDC7 }, + { 0xFDCF, 0xFDCF }, + { 0xFDF0, 0xFE19 }, + { 0xFE20, 0xFE52 }, + { 0xFE54, 0xFE66 }, + { 0xFE68, 0xFE6B }, + { 0xFE70, 0xFE74 }, + { 0xFE76, 0xFEFC }, + { 0xFEFF, 0xFEFF }, + { 0xFF01, 0xFFBE }, + { 0xFFC2, 0xFFC7 }, + { 0xFFCA, 0xFFCF }, + { 0xFFD2, 0xFFD7 }, + { 0xFFDA, 0xFFDC }, + { 0xFFE0, 0xFFE6 }, + { 0xFFE8, 0xFFEE }, + { 0xFFF9, 0xFFFD }, + { 0x10000, 0x1000B }, + { 0x1000D, 0x10026 }, + { 0x10028, 0x1003A }, + { 0x1003C, 0x1003D }, + { 0x1003F, 0x1004D }, + { 0x10050, 0x1005D }, + { 0x10080, 0x100FA }, + { 0x10100, 0x10102 }, + { 0x10107, 0x10133 }, + { 0x10137, 0x1018E }, + { 0x10190, 0x1019C }, + { 0x101A0, 0x101A0 }, + { 0x101D0, 0x101FD }, + { 0x10280, 0x1029C }, + { 0x102A0, 0x102D0 }, + { 0x102E0, 0x102FB }, + { 0x10300, 0x10323 }, + { 0x1032D, 0x1034A }, + { 0x10350, 0x1037A }, + { 0x10380, 0x1039D }, + { 0x1039F, 0x103C3 }, + { 0x103C8, 0x103D5 }, + { 0x10400, 0x1049D }, + { 0x104A0, 0x104A9 }, + { 0x104B0, 0x104D3 }, + { 0x104D8, 0x104FB }, + { 0x10500, 0x10527 }, + { 0x10530, 0x10563 }, + { 0x1056F, 0x1057A }, + { 0x1057C, 0x1058A }, + { 0x1058C, 0x10592 }, + { 0x10594, 0x10595 }, + { 0x10597, 0x105A1 }, + { 0x105A3, 0x105B1 }, + { 0x105B3, 0x105B9 }, + { 0x105BB, 0x105BC }, + { 0x10600, 0x10736 }, + { 0x10740, 0x10755 }, + { 0x10760, 0x10767 }, + { 0x10780, 0x10785 }, + { 0x10787, 0x107B0 }, + { 0x107B2, 0x107BA }, + { 0x10800, 0x10805 }, + { 0x10808, 0x10808 }, + { 0x1080A, 0x10835 }, + { 0x10837, 0x10838 }, + { 0x1083C, 0x1083C }, + { 0x1083F, 0x10855 }, + { 0x10857, 0x1089E }, + { 0x108A7, 0x108AF }, + { 0x108E0, 0x108F2 }, + { 0x108F4, 0x108F5 }, + { 0x108FB, 0x1091B }, + { 0x1091F, 0x10939 }, + { 0x1093F, 0x1093F }, + { 0x10980, 0x109B7 }, + { 0x109BC, 0x109CF }, + { 0x109D2, 0x10A03 }, + { 0x10A05, 0x10A06 }, + { 0x10A0C, 0x10A13 }, + { 0x10A15, 0x10A17 }, + { 0x10A19, 0x10A35 }, + { 0x10A38, 0x10A3A }, + { 0x10A3F, 0x10A48 }, + { 0x10A50, 0x10A58 }, + { 0x10A60, 0x10A9F }, + { 0x10AC0, 0x10AE6 }, + { 0x10AEB, 0x10AF6 }, + { 0x10B00, 0x10B35 }, + { 0x10B39, 0x10B55 }, + { 0x10B58, 0x10B72 }, + { 0x10B78, 0x10B91 }, + { 0x10B99, 0x10B9C }, + { 0x10BA9, 0x10BAF }, + { 0x10C00, 0x10C48 }, + { 0x10C80, 0x10CB2 }, + { 0x10CC0, 0x10CF2 }, + { 0x10CFA, 0x10D27 }, + { 0x10D30, 0x10D39 }, + { 0x10E60, 0x10E7E }, + { 0x10E80, 0x10EA9 }, + { 0x10EAB, 0x10EAD }, + { 0x10EB0, 0x10EB1 }, + { 0x10EFD, 0x10F27 }, + { 0x10F30, 0x10F59 }, + { 0x10F70, 0x10F89 }, + { 0x10FB0, 0x10FCB }, + { 0x10FE0, 0x10FF6 }, + { 0x11000, 0x1104D }, + { 0x11052, 0x11075 }, + { 0x1107F, 0x110C2 }, + { 0x110CD, 0x110CD }, + { 0x110D0, 0x110E8 }, + { 0x110F0, 0x110F9 }, + { 0x11100, 0x11134 }, + { 0x11136, 0x11147 }, + { 0x11150, 0x11176 }, + { 0x11180, 0x111DF }, + { 0x111E1, 0x111F4 }, + { 0x11200, 0x11211 }, + { 0x11213, 0x11241 }, + { 0x11280, 0x11286 }, + { 0x11288, 0x11288 }, + { 0x1128A, 0x1128D }, + { 0x1128F, 0x1129D }, + { 0x1129F, 0x112A9 }, + { 0x112B0, 0x112EA }, + { 0x112F0, 0x112F9 }, + { 0x11300, 0x11303 }, + { 0x11305, 0x1130C }, + { 0x1130F, 0x11310 }, + { 0x11313, 0x11328 }, + { 0x1132A, 0x11330 }, + { 0x11332, 0x11333 }, + { 0x11335, 0x11339 }, + { 0x1133B, 0x11344 }, + { 0x11347, 0x11348 }, + { 0x1134B, 0x1134D }, + { 0x11350, 0x11350 }, + { 0x11357, 0x11357 }, + { 0x1135D, 0x11363 }, + { 0x11366, 0x1136C }, + { 0x11370, 0x11374 }, + { 0x11400, 0x1145B }, + { 0x1145D, 0x11461 }, + { 0x11480, 0x114C7 }, + { 0x114D0, 0x114D9 }, + { 0x11580, 0x115B5 }, + { 0x115B8, 0x115DD }, + { 0x11600, 0x11644 }, + { 0x11650, 0x11659 }, + { 0x11660, 0x1166C }, + { 0x11680, 0x116B9 }, + { 0x116C0, 0x116C9 }, + { 0x11700, 0x1171A }, + { 0x1171D, 0x1172B }, + { 0x11730, 0x11746 }, + { 0x11800, 0x1183B }, + { 0x118A0, 0x118F2 }, + { 0x118FF, 0x11906 }, + { 0x11909, 0x11909 }, + { 0x1190C, 0x11913 }, + { 0x11915, 0x11916 }, + { 0x11918, 0x11935 }, + { 0x11937, 0x11938 }, + { 0x1193B, 0x11946 }, + { 0x11950, 0x11959 }, + { 0x119A0, 0x119A7 }, + { 0x119AA, 0x119D7 }, + { 0x119DA, 0x119E4 }, + { 0x11A00, 0x11A47 }, + { 0x11A50, 0x11AA2 }, + { 0x11AB0, 0x11AF8 }, + { 0x11B00, 0x11B09 }, + { 0x11C00, 0x11C08 }, + { 0x11C0A, 0x11C36 }, + { 0x11C38, 0x11C45 }, + { 0x11C50, 0x11C6C }, + { 0x11C70, 0x11C8F }, + { 0x11C92, 0x11CA7 }, + { 0x11CA9, 0x11CB6 }, + { 0x11D00, 0x11D06 }, + { 0x11D08, 0x11D09 }, + { 0x11D0B, 0x11D36 }, + { 0x11D3A, 0x11D3A }, + { 0x11D3C, 0x11D3D }, + { 0x11D3F, 0x11D47 }, + { 0x11D50, 0x11D59 }, + { 0x11D60, 0x11D65 }, + { 0x11D67, 0x11D68 }, + { 0x11D6A, 0x11D8E }, + { 0x11D90, 0x11D91 }, + { 0x11D93, 0x11D98 }, + { 0x11DA0, 0x11DA9 }, + { 0x11EE0, 0x11EF8 }, + { 0x11F00, 0x11F10 }, + { 0x11F12, 0x11F3A }, + { 0x11F3E, 0x11F59 }, + { 0x11FB0, 0x11FB0 }, + { 0x11FC0, 0x11FF1 }, + { 0x11FFF, 0x12399 }, + { 0x12400, 0x1246E }, + { 0x12470, 0x12474 }, + { 0x12480, 0x12543 }, + { 0x12F90, 0x12FF2 }, + { 0x13000, 0x13455 }, + { 0x14400, 0x14646 }, + { 0x16800, 0x16A38 }, + { 0x16A40, 0x16A5E }, + { 0x16A60, 0x16A69 }, + { 0x16A6E, 0x16ABE }, + { 0x16AC0, 0x16AC9 }, + { 0x16AD0, 0x16AED }, + { 0x16AF0, 0x16AF5 }, + { 0x16B00, 0x16B45 }, + { 0x16B50, 0x16B59 }, + { 0x16B5B, 0x16B61 }, + { 0x16B63, 0x16B77 }, + { 0x16B7D, 0x16B8F }, + { 0x16E40, 0x16E9A }, + { 0x16F00, 0x16F4A }, + { 0x16F4F, 0x16F87 }, + { 0x16F8F, 0x16F9F }, + { 0x16FE0, 0x16FE4 }, + { 0x16FF0, 0x16FF1 }, + { 0x17000, 0x187F7 }, + { 0x18800, 0x18CD5 }, + { 0x18D00, 0x18D08 }, + { 0x1AFF0, 0x1AFF3 }, + { 0x1AFF5, 0x1AFFB }, + { 0x1AFFD, 0x1AFFE }, + { 0x1B000, 0x1B122 }, + { 0x1B132, 0x1B132 }, + { 0x1B150, 0x1B152 }, + { 0x1B155, 0x1B155 }, + { 0x1B164, 0x1B167 }, + { 0x1B170, 0x1B2FB }, + { 0x1BC00, 0x1BC6A }, + { 0x1BC70, 0x1BC7C }, + { 0x1BC80, 0x1BC88 }, + { 0x1BC90, 0x1BC99 }, + { 0x1BC9C, 0x1BCA3 }, + { 0x1CF00, 0x1CF2D }, + { 0x1CF30, 0x1CF46 }, + { 0x1CF50, 0x1CFC3 }, + { 0x1D000, 0x1D0F5 }, + { 0x1D100, 0x1D126 }, + { 0x1D129, 0x1D1EA }, + { 0x1D200, 0x1D245 }, + { 0x1D2C0, 0x1D2D3 }, + { 0x1D2E0, 0x1D2F3 }, + { 0x1D300, 0x1D356 }, + { 0x1D360, 0x1D378 }, + { 0x1D400, 0x1D454 }, + { 0x1D456, 0x1D49C }, + { 0x1D49E, 0x1D49F }, + { 0x1D4A2, 0x1D4A2 }, + { 0x1D4A5, 0x1D4A6 }, + { 0x1D4A9, 0x1D4AC }, + { 0x1D4AE, 0x1D4B9 }, + { 0x1D4BB, 0x1D4BB }, + { 0x1D4BD, 0x1D4C3 }, + { 0x1D4C5, 0x1D505 }, + { 0x1D507, 0x1D50A }, + { 0x1D50D, 0x1D514 }, + { 0x1D516, 0x1D51C }, + { 0x1D51E, 0x1D539 }, + { 0x1D53B, 0x1D53E }, + { 0x1D540, 0x1D544 }, + { 0x1D546, 0x1D546 }, + { 0x1D54A, 0x1D550 }, + { 0x1D552, 0x1D6A5 }, + { 0x1D6A8, 0x1D7CB }, + { 0x1D7CE, 0x1DA8B }, + { 0x1DA9B, 0x1DA9F }, + { 0x1DAA1, 0x1DAAF }, + { 0x1DF00, 0x1DF1E }, + { 0x1DF25, 0x1DF2A }, + { 0x1E000, 0x1E006 }, + { 0x1E008, 0x1E018 }, + { 0x1E01B, 0x1E021 }, + { 0x1E023, 0x1E024 }, + { 0x1E026, 0x1E02A }, + { 0x1E030, 0x1E06D }, + { 0x1E08F, 0x1E08F }, + { 0x1E100, 0x1E12C }, + { 0x1E130, 0x1E13D }, + { 0x1E140, 0x1E149 }, + { 0x1E14E, 0x1E14F }, + { 0x1E290, 0x1E2AE }, + { 0x1E2C0, 0x1E2F9 }, + { 0x1E2FF, 0x1E2FF }, + { 0x1E4D0, 0x1E4F9 }, + { 0x1E7E0, 0x1E7E6 }, + { 0x1E7E8, 0x1E7EB }, + { 0x1E7ED, 0x1E7EE }, + { 0x1E7F0, 0x1E7FE }, + { 0x1E800, 0x1E8C4 }, + { 0x1E8C7, 0x1E8D6 }, + { 0x1E900, 0x1E94B }, + { 0x1E950, 0x1E959 }, + { 0x1E95E, 0x1E95F }, + { 0x1EC71, 0x1ECB4 }, + { 0x1ED01, 0x1ED3D }, + { 0x1EE00, 0x1EE03 }, + { 0x1EE05, 0x1EE1F }, + { 0x1EE21, 0x1EE22 }, + { 0x1EE24, 0x1EE24 }, + { 0x1EE27, 0x1EE27 }, + { 0x1EE29, 0x1EE32 }, + { 0x1EE34, 0x1EE37 }, + { 0x1EE39, 0x1EE39 }, + { 0x1EE3B, 0x1EE3B }, + { 0x1EE42, 0x1EE42 }, + { 0x1EE47, 0x1EE47 }, + { 0x1EE49, 0x1EE49 }, + { 0x1EE4B, 0x1EE4B }, + { 0x1EE4D, 0x1EE4F }, + { 0x1EE51, 0x1EE52 }, + { 0x1EE54, 0x1EE54 }, + { 0x1EE57, 0x1EE57 }, + { 0x1EE59, 0x1EE59 }, + { 0x1EE5B, 0x1EE5B }, + { 0x1EE5D, 0x1EE5D }, + { 0x1EE5F, 0x1EE5F }, + { 0x1EE61, 0x1EE62 }, + { 0x1EE64, 0x1EE64 }, + { 0x1EE67, 0x1EE6A }, + { 0x1EE6C, 0x1EE72 }, + { 0x1EE74, 0x1EE77 }, + { 0x1EE79, 0x1EE7C }, + { 0x1EE7E, 0x1EE7E }, + { 0x1EE80, 0x1EE89 }, + { 0x1EE8B, 0x1EE9B }, + { 0x1EEA1, 0x1EEA3 }, + { 0x1EEA5, 0x1EEA9 }, + { 0x1EEAB, 0x1EEBB }, + { 0x1EEF0, 0x1EEF1 }, + { 0x1F000, 0x1F02B }, + { 0x1F030, 0x1F093 }, + { 0x1F0A0, 0x1F0AE }, + { 0x1F0B1, 0x1F0BF }, + { 0x1F0C1, 0x1F0CF }, + { 0x1F0D1, 0x1F0F5 }, + { 0x1F100, 0x1F1AD }, + { 0x1F1E6, 0x1F202 }, + { 0x1F210, 0x1F23B }, + { 0x1F240, 0x1F248 }, + { 0x1F250, 0x1F251 }, + { 0x1F260, 0x1F265 }, + { 0x1F300, 0x1F6D7 }, + { 0x1F6DC, 0x1F6EC }, + { 0x1F6F0, 0x1F6FC }, + { 0x1F700, 0x1F776 }, + { 0x1F77B, 0x1F7D9 }, + { 0x1F7E0, 0x1F7EB }, + { 0x1F7F0, 0x1F7F0 }, + { 0x1F800, 0x1F80B }, + { 0x1F810, 0x1F847 }, + { 0x1F850, 0x1F859 }, + { 0x1F860, 0x1F887 }, + { 0x1F890, 0x1F8AD }, + { 0x1F8B0, 0x1F8B1 }, + { 0x1F900, 0x1FA53 }, + { 0x1FA60, 0x1FA6D }, + { 0x1FA70, 0x1FA7C }, + { 0x1FA80, 0x1FA88 }, + { 0x1FA90, 0x1FABD }, + { 0x1FABF, 0x1FAC5 }, + { 0x1FACE, 0x1FADB }, + { 0x1FAE0, 0x1FAE8 }, + { 0x1FAF0, 0x1FAF8 }, + { 0x1FB00, 0x1FB92 }, + { 0x1FB94, 0x1FBCA }, + { 0x1FBF0, 0x1FBF9 }, + { 0x20000, 0x2A6DF }, + { 0x2A700, 0x2B739 }, + { 0x2B740, 0x2B81D }, + { 0x2B820, 0x2CEA1 }, + { 0x2CEB0, 0x2EBE0 }, + { 0x2F800, 0x2FA1D }, + { 0x30000, 0x3134A }, + { 0x31350, 0x323AF }, + { 0xE0001, 0xE0001 }, + { 0xE0020, 0xE007F }, + { 0xE0100, 0xE01EF }, + { 0xF0000, 0xFFFFD }, + { 0x100000, 0x10FFFD } + +#define PREDICATE(c) uc_is_print (c) +#include "test-predicate-part2.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/test-ctype_punct.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/test-ctype_punct.c new file mode 100644 index 00000000..1cd20e2a --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/test-ctype_punct.c @@ -0,0 +1,588 @@ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +/* Test the Unicode character type functions. + Copyright (C) 2007-2022 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 the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + This file 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 . */ + +#include "test-predicate-part1.h" + + { 0x0021, 0x002F }, + { 0x003A, 0x0040 }, + { 0x005B, 0x0060 }, + { 0x007B, 0x007E }, + { 0x00A0, 0x00A9 }, + { 0x00AB, 0x00B4 }, + { 0x00B6, 0x00B9 }, + { 0x00BB, 0x00BF }, + { 0x00D7, 0x00D7 }, + { 0x00F7, 0x00F7 }, + { 0x02C2, 0x02C5 }, + { 0x02D2, 0x02DF }, + { 0x02E5, 0x02EB }, + { 0x02ED, 0x02ED }, + { 0x02EF, 0x0344 }, + { 0x0346, 0x036F }, + { 0x0375, 0x0375 }, + { 0x037E, 0x037E }, + { 0x0384, 0x0385 }, + { 0x0387, 0x0387 }, + { 0x03F6, 0x03F6 }, + { 0x0482, 0x0489 }, + { 0x055A, 0x055F }, + { 0x0589, 0x058A }, + { 0x058D, 0x058F }, + { 0x0591, 0x05C7 }, + { 0x05F3, 0x05F4 }, + { 0x0600, 0x061F }, + { 0x064B, 0x065F }, + { 0x066A, 0x066D }, + { 0x0670, 0x0670 }, + { 0x06D4, 0x06D4 }, + { 0x06D6, 0x06E4 }, + { 0x06E7, 0x06ED }, + { 0x06FD, 0x06FE }, + { 0x0700, 0x070D }, + { 0x070F, 0x070F }, + { 0x0711, 0x0711 }, + { 0x0730, 0x074A }, + { 0x07A6, 0x07B0 }, + { 0x07EB, 0x07F3 }, + { 0x07F6, 0x07F9 }, + { 0x07FD, 0x07FF }, + { 0x0816, 0x0819 }, + { 0x081B, 0x0823 }, + { 0x0825, 0x0827 }, + { 0x0829, 0x082D }, + { 0x0830, 0x083E }, + { 0x0859, 0x085B }, + { 0x085E, 0x085E }, + { 0x0888, 0x0888 }, + { 0x0890, 0x0891 }, + { 0x0898, 0x089F }, + { 0x08CA, 0x0903 }, + { 0x093A, 0x093C }, + { 0x093E, 0x094F }, + { 0x0951, 0x0957 }, + { 0x0962, 0x0965 }, + { 0x0970, 0x0970 }, + { 0x0981, 0x0983 }, + { 0x09BC, 0x09BC }, + { 0x09BE, 0x09C4 }, + { 0x09C7, 0x09C8 }, + { 0x09CB, 0x09CD }, + { 0x09D7, 0x09D7 }, + { 0x09E2, 0x09E3 }, + { 0x09F2, 0x09FB }, + { 0x09FD, 0x09FE }, + { 0x0A01, 0x0A03 }, + { 0x0A3C, 0x0A3C }, + { 0x0A3E, 0x0A42 }, + { 0x0A47, 0x0A48 }, + { 0x0A4B, 0x0A4D }, + { 0x0A51, 0x0A51 }, + { 0x0A70, 0x0A71 }, + { 0x0A75, 0x0A76 }, + { 0x0A81, 0x0A83 }, + { 0x0ABC, 0x0ABC }, + { 0x0ABE, 0x0AC5 }, + { 0x0AC7, 0x0AC9 }, + { 0x0ACB, 0x0ACD }, + { 0x0AE2, 0x0AE3 }, + { 0x0AF0, 0x0AF1 }, + { 0x0AFA, 0x0AFF }, + { 0x0B01, 0x0B03 }, + { 0x0B3C, 0x0B3C }, + { 0x0B3E, 0x0B44 }, + { 0x0B47, 0x0B48 }, + { 0x0B4B, 0x0B4D }, + { 0x0B55, 0x0B57 }, + { 0x0B62, 0x0B63 }, + { 0x0B70, 0x0B70 }, + { 0x0B72, 0x0B77 }, + { 0x0B82, 0x0B82 }, + { 0x0BBE, 0x0BC2 }, + { 0x0BC6, 0x0BC8 }, + { 0x0BCA, 0x0BCD }, + { 0x0BD7, 0x0BD7 }, + { 0x0BF0, 0x0BFA }, + { 0x0C00, 0x0C04 }, + { 0x0C3C, 0x0C3C }, + { 0x0C3E, 0x0C44 }, + { 0x0C46, 0x0C48 }, + { 0x0C4A, 0x0C4D }, + { 0x0C55, 0x0C56 }, + { 0x0C62, 0x0C63 }, + { 0x0C77, 0x0C7F }, + { 0x0C81, 0x0C84 }, + { 0x0CBC, 0x0CBC }, + { 0x0CBE, 0x0CC4 }, + { 0x0CC6, 0x0CC8 }, + { 0x0CCA, 0x0CCD }, + { 0x0CD5, 0x0CD6 }, + { 0x0CE2, 0x0CE3 }, + { 0x0CF3, 0x0CF3 }, + { 0x0D00, 0x0D03 }, + { 0x0D3B, 0x0D3C }, + { 0x0D3E, 0x0D44 }, + { 0x0D46, 0x0D48 }, + { 0x0D4A, 0x0D4D }, + { 0x0D4F, 0x0D4F }, + { 0x0D57, 0x0D5E }, + { 0x0D62, 0x0D63 }, + { 0x0D70, 0x0D79 }, + { 0x0D81, 0x0D83 }, + { 0x0DCA, 0x0DCA }, + { 0x0DCF, 0x0DD4 }, + { 0x0DD6, 0x0DD6 }, + { 0x0DD8, 0x0DDF }, + { 0x0DF2, 0x0DF4 }, + { 0x0E2F, 0x0E2F }, + { 0x0E3F, 0x0E3F }, + { 0x0E46, 0x0E46 }, + { 0x0E4F, 0x0E4F }, + { 0x0E5A, 0x0E5B }, + { 0x0EB1, 0x0EB1 }, + { 0x0EB4, 0x0EBC }, + { 0x0EC8, 0x0ECE }, + { 0x0F01, 0x0F1F }, + { 0x0F2A, 0x0F3F }, + { 0x0F71, 0x0F87 }, + { 0x0F8D, 0x0F97 }, + { 0x0F99, 0x0FBC }, + { 0x0FBE, 0x0FCC }, + { 0x0FCE, 0x0FDA }, + { 0x102B, 0x103E }, + { 0x104A, 0x104F }, + { 0x1056, 0x1059 }, + { 0x105E, 0x1060 }, + { 0x1062, 0x1064 }, + { 0x1067, 0x106D }, + { 0x1071, 0x1074 }, + { 0x1082, 0x108D }, + { 0x108F, 0x108F }, + { 0x109A, 0x109F }, + { 0x10FB, 0x10FB }, + { 0x135D, 0x137C }, + { 0x1390, 0x1399 }, + { 0x1400, 0x1400 }, + { 0x166D, 0x166E }, + { 0x169B, 0x169C }, + { 0x16EB, 0x16ED }, + { 0x1712, 0x1715 }, + { 0x1732, 0x1736 }, + { 0x1752, 0x1753 }, + { 0x1772, 0x1773 }, + { 0x17B4, 0x17D6 }, + { 0x17D8, 0x17DB }, + { 0x17DD, 0x17DD }, + { 0x17F0, 0x17F9 }, + { 0x1800, 0x180F }, + { 0x1885, 0x1886 }, + { 0x18A9, 0x18A9 }, + { 0x1920, 0x192B }, + { 0x1930, 0x193B }, + { 0x1940, 0x1940 }, + { 0x1944, 0x1945 }, + { 0x19DA, 0x19DA }, + { 0x19DE, 0x19FF }, + { 0x1A17, 0x1A1B }, + { 0x1A1E, 0x1A1F }, + { 0x1A55, 0x1A5E }, + { 0x1A60, 0x1A7C }, + { 0x1A7F, 0x1A7F }, + { 0x1AA0, 0x1AA6 }, + { 0x1AA8, 0x1AAD }, + { 0x1AB0, 0x1ACE }, + { 0x1B00, 0x1B04 }, + { 0x1B34, 0x1B44 }, + { 0x1B5A, 0x1B7E }, + { 0x1B80, 0x1B82 }, + { 0x1BA1, 0x1BAD }, + { 0x1BE6, 0x1BF3 }, + { 0x1BFC, 0x1BFF }, + { 0x1C24, 0x1C37 }, + { 0x1C3B, 0x1C3F }, + { 0x1C7E, 0x1C7F }, + { 0x1CC0, 0x1CC7 }, + { 0x1CD0, 0x1CE8 }, + { 0x1CED, 0x1CED }, + { 0x1CF4, 0x1CF4 }, + { 0x1CF7, 0x1CF9 }, + { 0x1DC0, 0x1DFF }, + { 0x1FBD, 0x1FBD }, + { 0x1FBF, 0x1FC1 }, + { 0x1FCD, 0x1FCF }, + { 0x1FDD, 0x1FDF }, + { 0x1FED, 0x1FEF }, + { 0x1FFD, 0x1FFE }, + { 0x2007, 0x2007 }, + { 0x200B, 0x2027 }, + { 0x202A, 0x205E }, + { 0x2060, 0x2064 }, + { 0x2066, 0x2070 }, + { 0x2074, 0x207E }, + { 0x2080, 0x208E }, + { 0x20A0, 0x20C0 }, + { 0x20D0, 0x20F0 }, + { 0x2100, 0x2101 }, + { 0x2103, 0x2106 }, + { 0x2108, 0x2109 }, + { 0x2114, 0x2114 }, + { 0x2116, 0x2118 }, + { 0x211E, 0x2123 }, + { 0x2125, 0x2125 }, + { 0x2127, 0x2127 }, + { 0x212E, 0x212E }, + { 0x213A, 0x213B }, + { 0x2140, 0x2144 }, + { 0x214A, 0x214D }, + { 0x214F, 0x215F }, + { 0x2189, 0x218B }, + { 0x2190, 0x2426 }, + { 0x2440, 0x244A }, + { 0x2460, 0x249B }, + { 0x24EA, 0x2B73 }, + { 0x2B76, 0x2B95 }, + { 0x2B97, 0x2BFF }, + { 0x2CE5, 0x2CEA }, + { 0x2CEF, 0x2CF1 }, + { 0x2CF9, 0x2CFF }, + { 0x2D70, 0x2D70 }, + { 0x2D7F, 0x2D7F }, + { 0x2DE0, 0x2E2E }, + { 0x2E30, 0x2E5D }, + { 0x2E80, 0x2E99 }, + { 0x2E9B, 0x2EF3 }, + { 0x2F00, 0x2FD5 }, + { 0x2FF0, 0x2FFB }, + { 0x3001, 0x3004 }, + { 0x3008, 0x3020 }, + { 0x302A, 0x3030 }, + { 0x3036, 0x3037 }, + { 0x303D, 0x303F }, + { 0x3099, 0x309C }, + { 0x30A0, 0x30A0 }, + { 0x30FB, 0x30FB }, + { 0x3190, 0x319F }, + { 0x31C0, 0x31E3 }, + { 0x3200, 0x321E }, + { 0x3220, 0x33FF }, + { 0x4DC0, 0x4DFF }, + { 0xA490, 0xA4C6 }, + { 0xA4FE, 0xA4FF }, + { 0xA60D, 0xA60F }, + { 0xA66F, 0xA67E }, + { 0xA69E, 0xA69F }, + { 0xA6F0, 0xA6F7 }, + { 0xA700, 0xA716 }, + { 0xA720, 0xA721 }, + { 0xA789, 0xA78A }, + { 0xA802, 0xA802 }, + { 0xA806, 0xA806 }, + { 0xA80B, 0xA80B }, + { 0xA823, 0xA82C }, + { 0xA830, 0xA839 }, + { 0xA874, 0xA877 }, + { 0xA880, 0xA881 }, + { 0xA8B4, 0xA8C5 }, + { 0xA8CE, 0xA8CF }, + { 0xA8E0, 0xA8F1 }, + { 0xA8F8, 0xA8FA }, + { 0xA8FC, 0xA8FC }, + { 0xA8FF, 0xA8FF }, + { 0xA926, 0xA92F }, + { 0xA947, 0xA953 }, + { 0xA95F, 0xA95F }, + { 0xA980, 0xA983 }, + { 0xA9B3, 0xA9CD }, + { 0xA9DE, 0xA9DF }, + { 0xA9E5, 0xA9E5 }, + { 0xAA29, 0xAA36 }, + { 0xAA43, 0xAA43 }, + { 0xAA4C, 0xAA4D }, + { 0xAA5C, 0xAA5F }, + { 0xAA77, 0xAA79 }, + { 0xAA7B, 0xAA7D }, + { 0xAAB0, 0xAAB0 }, + { 0xAAB2, 0xAAB4 }, + { 0xAAB7, 0xAAB8 }, + { 0xAABE, 0xAABF }, + { 0xAAC1, 0xAAC1 }, + { 0xAADE, 0xAADF }, + { 0xAAEB, 0xAAF1 }, + { 0xAAF5, 0xAAF6 }, + { 0xAB5B, 0xAB5B }, + { 0xAB6A, 0xAB6B }, + { 0xABE3, 0xABED }, + { 0xE000, 0xF8FF }, + { 0xFB1E, 0xFB1E }, + { 0xFB29, 0xFB29 }, + { 0xFBB2, 0xFBC2 }, + { 0xFD3E, 0xFD4F }, + { 0xFDCF, 0xFDCF }, + { 0xFDFC, 0xFE19 }, + { 0xFE20, 0xFE52 }, + { 0xFE54, 0xFE66 }, + { 0xFE68, 0xFE6B }, + { 0xFEFF, 0xFEFF }, + { 0xFF01, 0xFF0F }, + { 0xFF1A, 0xFF20 }, + { 0xFF3B, 0xFF40 }, + { 0xFF5B, 0xFF65 }, + { 0xFFE0, 0xFFE6 }, + { 0xFFE8, 0xFFEE }, + { 0xFFF9, 0xFFFD }, + { 0x10100, 0x10102 }, + { 0x10107, 0x10133 }, + { 0x10137, 0x1013F }, + { 0x10175, 0x1018E }, + { 0x10190, 0x1019C }, + { 0x101A0, 0x101A0 }, + { 0x101D0, 0x101FD }, + { 0x102E0, 0x102FB }, + { 0x10320, 0x10323 }, + { 0x10376, 0x1037A }, + { 0x1039F, 0x1039F }, + { 0x103D0, 0x103D0 }, + { 0x1056F, 0x1056F }, + { 0x10857, 0x1085F }, + { 0x10877, 0x1087F }, + { 0x108A7, 0x108AF }, + { 0x108FB, 0x108FF }, + { 0x10916, 0x1091B }, + { 0x1091F, 0x1091F }, + { 0x1093F, 0x1093F }, + { 0x109BC, 0x109BD }, + { 0x109C0, 0x109CF }, + { 0x109D2, 0x109FF }, + { 0x10A01, 0x10A03 }, + { 0x10A05, 0x10A06 }, + { 0x10A0C, 0x10A0F }, + { 0x10A38, 0x10A3A }, + { 0x10A3F, 0x10A48 }, + { 0x10A50, 0x10A58 }, + { 0x10A7D, 0x10A7F }, + { 0x10A9D, 0x10A9F }, + { 0x10AC8, 0x10AC8 }, + { 0x10AE5, 0x10AE6 }, + { 0x10AEB, 0x10AF6 }, + { 0x10B39, 0x10B3F }, + { 0x10B58, 0x10B5F }, + { 0x10B78, 0x10B7F }, + { 0x10B99, 0x10B9C }, + { 0x10BA9, 0x10BAF }, + { 0x10CFA, 0x10CFF }, + { 0x10D24, 0x10D27 }, + { 0x10E60, 0x10E7E }, + { 0x10EAB, 0x10EAD }, + { 0x10EFD, 0x10EFF }, + { 0x10F1D, 0x10F26 }, + { 0x10F46, 0x10F59 }, + { 0x10F82, 0x10F89 }, + { 0x10FC5, 0x10FCB }, + { 0x11000, 0x11002 }, + { 0x11038, 0x1104D }, + { 0x11052, 0x11065 }, + { 0x11070, 0x11070 }, + { 0x11073, 0x11074 }, + { 0x1107F, 0x11082 }, + { 0x110B0, 0x110C2 }, + { 0x110CD, 0x110CD }, + { 0x11100, 0x11102 }, + { 0x11127, 0x11134 }, + { 0x11140, 0x11143 }, + { 0x11145, 0x11146 }, + { 0x11173, 0x11175 }, + { 0x11180, 0x11182 }, + { 0x111B3, 0x111C0 }, + { 0x111C5, 0x111CF }, + { 0x111DB, 0x111DB }, + { 0x111DD, 0x111DF }, + { 0x111E1, 0x111F4 }, + { 0x1122C, 0x1123E }, + { 0x11241, 0x11241 }, + { 0x112A9, 0x112A9 }, + { 0x112DF, 0x112EA }, + { 0x11300, 0x11303 }, + { 0x1133B, 0x1133C }, + { 0x1133E, 0x11344 }, + { 0x11347, 0x11348 }, + { 0x1134B, 0x1134D }, + { 0x11357, 0x11357 }, + { 0x11362, 0x11363 }, + { 0x11366, 0x1136C }, + { 0x11370, 0x11374 }, + { 0x11435, 0x11446 }, + { 0x1144B, 0x1144F }, + { 0x1145A, 0x1145B }, + { 0x1145D, 0x1145E }, + { 0x114B0, 0x114C3 }, + { 0x114C6, 0x114C6 }, + { 0x115AF, 0x115B5 }, + { 0x115B8, 0x115D7 }, + { 0x115DC, 0x115DD }, + { 0x11630, 0x11643 }, + { 0x11660, 0x1166C }, + { 0x116AB, 0x116B7 }, + { 0x116B9, 0x116B9 }, + { 0x1171D, 0x1172B }, + { 0x1173A, 0x1173F }, + { 0x1182C, 0x1183B }, + { 0x118EA, 0x118F2 }, + { 0x11930, 0x11935 }, + { 0x11937, 0x11938 }, + { 0x1193B, 0x1193E }, + { 0x11940, 0x11940 }, + { 0x11942, 0x11946 }, + { 0x119D1, 0x119D7 }, + { 0x119DA, 0x119E0 }, + { 0x119E2, 0x119E2 }, + { 0x119E4, 0x119E4 }, + { 0x11A01, 0x11A0A }, + { 0x11A33, 0x11A39 }, + { 0x11A3B, 0x11A47 }, + { 0x11A51, 0x11A5B }, + { 0x11A8A, 0x11A9C }, + { 0x11A9E, 0x11AA2 }, + { 0x11B00, 0x11B09 }, + { 0x11C2F, 0x11C36 }, + { 0x11C38, 0x11C3F }, + { 0x11C41, 0x11C45 }, + { 0x11C5A, 0x11C6C }, + { 0x11C70, 0x11C71 }, + { 0x11C92, 0x11CA7 }, + { 0x11CA9, 0x11CB6 }, + { 0x11D31, 0x11D36 }, + { 0x11D3A, 0x11D3A }, + { 0x11D3C, 0x11D3D }, + { 0x11D3F, 0x11D45 }, + { 0x11D47, 0x11D47 }, + { 0x11D8A, 0x11D8E }, + { 0x11D90, 0x11D91 }, + { 0x11D93, 0x11D97 }, + { 0x11EF3, 0x11EF8 }, + { 0x11F00, 0x11F01 }, + { 0x11F03, 0x11F03 }, + { 0x11F34, 0x11F3A }, + { 0x11F3E, 0x11F4F }, + { 0x11FC0, 0x11FF1 }, + { 0x11FFF, 0x11FFF }, + { 0x12470, 0x12474 }, + { 0x12FF1, 0x12FF2 }, + { 0x13430, 0x13440 }, + { 0x13447, 0x13455 }, + { 0x16A6E, 0x16A6F }, + { 0x16AF0, 0x16AF5 }, + { 0x16B30, 0x16B3F }, + { 0x16B44, 0x16B45 }, + { 0x16B5B, 0x16B61 }, + { 0x16E80, 0x16E9A }, + { 0x16F4F, 0x16F4F }, + { 0x16F51, 0x16F87 }, + { 0x16F8F, 0x16F92 }, + { 0x16FE2, 0x16FE2 }, + { 0x16FE4, 0x16FE4 }, + { 0x16FF0, 0x16FF1 }, + { 0x1BC9C, 0x1BCA3 }, + { 0x1CF00, 0x1CF2D }, + { 0x1CF30, 0x1CF46 }, + { 0x1CF50, 0x1CFC3 }, + { 0x1D000, 0x1D0F5 }, + { 0x1D100, 0x1D126 }, + { 0x1D129, 0x1D1EA }, + { 0x1D200, 0x1D245 }, + { 0x1D2C0, 0x1D2D3 }, + { 0x1D2E0, 0x1D2F3 }, + { 0x1D300, 0x1D356 }, + { 0x1D360, 0x1D378 }, + { 0x1D6C1, 0x1D6C1 }, + { 0x1D6DB, 0x1D6DB }, + { 0x1D6FB, 0x1D6FB }, + { 0x1D715, 0x1D715 }, + { 0x1D735, 0x1D735 }, + { 0x1D74F, 0x1D74F }, + { 0x1D76F, 0x1D76F }, + { 0x1D789, 0x1D789 }, + { 0x1D7A9, 0x1D7A9 }, + { 0x1D7C3, 0x1D7C3 }, + { 0x1D800, 0x1DA8B }, + { 0x1DA9B, 0x1DA9F }, + { 0x1DAA1, 0x1DAAF }, + { 0x1E000, 0x1E006 }, + { 0x1E008, 0x1E018 }, + { 0x1E01B, 0x1E021 }, + { 0x1E023, 0x1E024 }, + { 0x1E026, 0x1E02A }, + { 0x1E08F, 0x1E08F }, + { 0x1E130, 0x1E136 }, + { 0x1E14F, 0x1E14F }, + { 0x1E2AE, 0x1E2AE }, + { 0x1E2EC, 0x1E2EF }, + { 0x1E2FF, 0x1E2FF }, + { 0x1E4EC, 0x1E4EF }, + { 0x1E8C7, 0x1E8D6 }, + { 0x1E944, 0x1E94A }, + { 0x1E95E, 0x1E95F }, + { 0x1EC71, 0x1ECB4 }, + { 0x1ED01, 0x1ED3D }, + { 0x1EEF0, 0x1EEF1 }, + { 0x1F000, 0x1F02B }, + { 0x1F030, 0x1F093 }, + { 0x1F0A0, 0x1F0AE }, + { 0x1F0B1, 0x1F0BF }, + { 0x1F0C1, 0x1F0CF }, + { 0x1F0D1, 0x1F0F5 }, + { 0x1F100, 0x1F10F }, + { 0x1F12D, 0x1F12F }, + { 0x1F14A, 0x1F14F }, + { 0x1F16A, 0x1F16F }, + { 0x1F18B, 0x1F1A4 }, + { 0x1F1A6, 0x1F1AD }, + { 0x1F200, 0x1F202 }, + { 0x1F210, 0x1F23B }, + { 0x1F240, 0x1F248 }, + { 0x1F250, 0x1F251 }, + { 0x1F260, 0x1F265 }, + { 0x1F300, 0x1F6D7 }, + { 0x1F6DC, 0x1F6EC }, + { 0x1F6F0, 0x1F6FC }, + { 0x1F700, 0x1F776 }, + { 0x1F77B, 0x1F7D9 }, + { 0x1F7E0, 0x1F7EB }, + { 0x1F7F0, 0x1F7F0 }, + { 0x1F800, 0x1F80B }, + { 0x1F810, 0x1F847 }, + { 0x1F850, 0x1F859 }, + { 0x1F860, 0x1F887 }, + { 0x1F890, 0x1F8AD }, + { 0x1F8B0, 0x1F8B1 }, + { 0x1F900, 0x1FA53 }, + { 0x1FA60, 0x1FA6D }, + { 0x1FA70, 0x1FA7C }, + { 0x1FA80, 0x1FA88 }, + { 0x1FA90, 0x1FABD }, + { 0x1FABF, 0x1FAC5 }, + { 0x1FACE, 0x1FADB }, + { 0x1FAE0, 0x1FAE8 }, + { 0x1FAF0, 0x1FAF8 }, + { 0x1FB00, 0x1FB92 }, + { 0x1FB94, 0x1FBCA }, + { 0xE0001, 0xE0001 }, + { 0xE0020, 0xE007F }, + { 0xE0100, 0xE01EF }, + { 0xF0000, 0xFFFFD }, + { 0x100000, 0x10FFFD } + +#define PREDICATE(c) uc_is_punct (c) +#include "test-predicate-part2.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/test-ctype_space.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/test-ctype_space.c new file mode 100644 index 00000000..da37cf74 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/test-ctype_space.c @@ -0,0 +1,30 @@ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +/* Test the Unicode character type functions. + Copyright (C) 2007-2022 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 the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + This file 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 . */ + +#include "test-predicate-part1.h" + + { 0x0009, 0x000D }, + { 0x0020, 0x0020 }, + { 0x1680, 0x1680 }, + { 0x2000, 0x2006 }, + { 0x2008, 0x200A }, + { 0x2028, 0x2029 }, + { 0x205F, 0x205F }, + { 0x3000, 0x3000 } + +#define PREDICATE(c) uc_is_space (c) +#include "test-predicate-part2.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/test-ctype_upper.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/test-ctype_upper.c new file mode 100644 index 00000000..724d4c7c --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/test-ctype_upper.c @@ -0,0 +1,631 @@ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +/* Test the Unicode character type functions. + Copyright (C) 2007-2022 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 the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + This file 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 . */ + +#include "test-predicate-part1.h" + + { 0x0041, 0x005A }, + { 0x00C0, 0x00D6 }, + { 0x00D8, 0x00DE }, + { 0x0100, 0x0100 }, + { 0x0102, 0x0102 }, + { 0x0104, 0x0104 }, + { 0x0106, 0x0106 }, + { 0x0108, 0x0108 }, + { 0x010A, 0x010A }, + { 0x010C, 0x010C }, + { 0x010E, 0x010E }, + { 0x0110, 0x0110 }, + { 0x0112, 0x0112 }, + { 0x0114, 0x0114 }, + { 0x0116, 0x0116 }, + { 0x0118, 0x0118 }, + { 0x011A, 0x011A }, + { 0x011C, 0x011C }, + { 0x011E, 0x011E }, + { 0x0120, 0x0120 }, + { 0x0122, 0x0122 }, + { 0x0124, 0x0124 }, + { 0x0126, 0x0126 }, + { 0x0128, 0x0128 }, + { 0x012A, 0x012A }, + { 0x012C, 0x012C }, + { 0x012E, 0x012E }, + { 0x0130, 0x0130 }, + { 0x0132, 0x0132 }, + { 0x0134, 0x0134 }, + { 0x0136, 0x0136 }, + { 0x0139, 0x0139 }, + { 0x013B, 0x013B }, + { 0x013D, 0x013D }, + { 0x013F, 0x013F }, + { 0x0141, 0x0141 }, + { 0x0143, 0x0143 }, + { 0x0145, 0x0145 }, + { 0x0147, 0x0147 }, + { 0x014A, 0x014A }, + { 0x014C, 0x014C }, + { 0x014E, 0x014E }, + { 0x0150, 0x0150 }, + { 0x0152, 0x0152 }, + { 0x0154, 0x0154 }, + { 0x0156, 0x0156 }, + { 0x0158, 0x0158 }, + { 0x015A, 0x015A }, + { 0x015C, 0x015C }, + { 0x015E, 0x015E }, + { 0x0160, 0x0160 }, + { 0x0162, 0x0162 }, + { 0x0164, 0x0164 }, + { 0x0166, 0x0166 }, + { 0x0168, 0x0168 }, + { 0x016A, 0x016A }, + { 0x016C, 0x016C }, + { 0x016E, 0x016E }, + { 0x0170, 0x0170 }, + { 0x0172, 0x0172 }, + { 0x0174, 0x0174 }, + { 0x0176, 0x0176 }, + { 0x0178, 0x0179 }, + { 0x017B, 0x017B }, + { 0x017D, 0x017D }, + { 0x0181, 0x0182 }, + { 0x0184, 0x0184 }, + { 0x0186, 0x0187 }, + { 0x0189, 0x018B }, + { 0x018E, 0x0191 }, + { 0x0193, 0x0194 }, + { 0x0196, 0x0198 }, + { 0x019C, 0x019D }, + { 0x019F, 0x01A0 }, + { 0x01A2, 0x01A2 }, + { 0x01A4, 0x01A4 }, + { 0x01A6, 0x01A7 }, + { 0x01A9, 0x01A9 }, + { 0x01AC, 0x01AC }, + { 0x01AE, 0x01AF }, + { 0x01B1, 0x01B3 }, + { 0x01B5, 0x01B5 }, + { 0x01B7, 0x01B8 }, + { 0x01BC, 0x01BC }, + { 0x01C4, 0x01C5 }, + { 0x01C7, 0x01C8 }, + { 0x01CA, 0x01CB }, + { 0x01CD, 0x01CD }, + { 0x01CF, 0x01CF }, + { 0x01D1, 0x01D1 }, + { 0x01D3, 0x01D3 }, + { 0x01D5, 0x01D5 }, + { 0x01D7, 0x01D7 }, + { 0x01D9, 0x01D9 }, + { 0x01DB, 0x01DB }, + { 0x01DE, 0x01DE }, + { 0x01E0, 0x01E0 }, + { 0x01E2, 0x01E2 }, + { 0x01E4, 0x01E4 }, + { 0x01E6, 0x01E6 }, + { 0x01E8, 0x01E8 }, + { 0x01EA, 0x01EA }, + { 0x01EC, 0x01EC }, + { 0x01EE, 0x01EE }, + { 0x01F1, 0x01F2 }, + { 0x01F4, 0x01F4 }, + { 0x01F6, 0x01F8 }, + { 0x01FA, 0x01FA }, + { 0x01FC, 0x01FC }, + { 0x01FE, 0x01FE }, + { 0x0200, 0x0200 }, + { 0x0202, 0x0202 }, + { 0x0204, 0x0204 }, + { 0x0206, 0x0206 }, + { 0x0208, 0x0208 }, + { 0x020A, 0x020A }, + { 0x020C, 0x020C }, + { 0x020E, 0x020E }, + { 0x0210, 0x0210 }, + { 0x0212, 0x0212 }, + { 0x0214, 0x0214 }, + { 0x0216, 0x0216 }, + { 0x0218, 0x0218 }, + { 0x021A, 0x021A }, + { 0x021C, 0x021C }, + { 0x021E, 0x021E }, + { 0x0220, 0x0220 }, + { 0x0222, 0x0222 }, + { 0x0224, 0x0224 }, + { 0x0226, 0x0226 }, + { 0x0228, 0x0228 }, + { 0x022A, 0x022A }, + { 0x022C, 0x022C }, + { 0x022E, 0x022E }, + { 0x0230, 0x0230 }, + { 0x0232, 0x0232 }, + { 0x023A, 0x023B }, + { 0x023D, 0x023E }, + { 0x0241, 0x0241 }, + { 0x0243, 0x0246 }, + { 0x0248, 0x0248 }, + { 0x024A, 0x024A }, + { 0x024C, 0x024C }, + { 0x024E, 0x024E }, + { 0x0370, 0x0370 }, + { 0x0372, 0x0372 }, + { 0x0376, 0x0376 }, + { 0x037F, 0x037F }, + { 0x0386, 0x0386 }, + { 0x0388, 0x038A }, + { 0x038C, 0x038C }, + { 0x038E, 0x038F }, + { 0x0391, 0x03A1 }, + { 0x03A3, 0x03AB }, + { 0x03CF, 0x03CF }, + { 0x03D8, 0x03D8 }, + { 0x03DA, 0x03DA }, + { 0x03DC, 0x03DC }, + { 0x03DE, 0x03DE }, + { 0x03E0, 0x03E0 }, + { 0x03E2, 0x03E2 }, + { 0x03E4, 0x03E4 }, + { 0x03E6, 0x03E6 }, + { 0x03E8, 0x03E8 }, + { 0x03EA, 0x03EA }, + { 0x03EC, 0x03EC }, + { 0x03EE, 0x03EE }, + { 0x03F4, 0x03F4 }, + { 0x03F7, 0x03F7 }, + { 0x03F9, 0x03FA }, + { 0x03FD, 0x042F }, + { 0x0460, 0x0460 }, + { 0x0462, 0x0462 }, + { 0x0464, 0x0464 }, + { 0x0466, 0x0466 }, + { 0x0468, 0x0468 }, + { 0x046A, 0x046A }, + { 0x046C, 0x046C }, + { 0x046E, 0x046E }, + { 0x0470, 0x0470 }, + { 0x0472, 0x0472 }, + { 0x0474, 0x0474 }, + { 0x0476, 0x0476 }, + { 0x0478, 0x0478 }, + { 0x047A, 0x047A }, + { 0x047C, 0x047C }, + { 0x047E, 0x047E }, + { 0x0480, 0x0480 }, + { 0x048A, 0x048A }, + { 0x048C, 0x048C }, + { 0x048E, 0x048E }, + { 0x0490, 0x0490 }, + { 0x0492, 0x0492 }, + { 0x0494, 0x0494 }, + { 0x0496, 0x0496 }, + { 0x0498, 0x0498 }, + { 0x049A, 0x049A }, + { 0x049C, 0x049C }, + { 0x049E, 0x049E }, + { 0x04A0, 0x04A0 }, + { 0x04A2, 0x04A2 }, + { 0x04A4, 0x04A4 }, + { 0x04A6, 0x04A6 }, + { 0x04A8, 0x04A8 }, + { 0x04AA, 0x04AA }, + { 0x04AC, 0x04AC }, + { 0x04AE, 0x04AE }, + { 0x04B0, 0x04B0 }, + { 0x04B2, 0x04B2 }, + { 0x04B4, 0x04B4 }, + { 0x04B6, 0x04B6 }, + { 0x04B8, 0x04B8 }, + { 0x04BA, 0x04BA }, + { 0x04BC, 0x04BC }, + { 0x04BE, 0x04BE }, + { 0x04C0, 0x04C1 }, + { 0x04C3, 0x04C3 }, + { 0x04C5, 0x04C5 }, + { 0x04C7, 0x04C7 }, + { 0x04C9, 0x04C9 }, + { 0x04CB, 0x04CB }, + { 0x04CD, 0x04CD }, + { 0x04D0, 0x04D0 }, + { 0x04D2, 0x04D2 }, + { 0x04D4, 0x04D4 }, + { 0x04D6, 0x04D6 }, + { 0x04D8, 0x04D8 }, + { 0x04DA, 0x04DA }, + { 0x04DC, 0x04DC }, + { 0x04DE, 0x04DE }, + { 0x04E0, 0x04E0 }, + { 0x04E2, 0x04E2 }, + { 0x04E4, 0x04E4 }, + { 0x04E6, 0x04E6 }, + { 0x04E8, 0x04E8 }, + { 0x04EA, 0x04EA }, + { 0x04EC, 0x04EC }, + { 0x04EE, 0x04EE }, + { 0x04F0, 0x04F0 }, + { 0x04F2, 0x04F2 }, + { 0x04F4, 0x04F4 }, + { 0x04F6, 0x04F6 }, + { 0x04F8, 0x04F8 }, + { 0x04FA, 0x04FA }, + { 0x04FC, 0x04FC }, + { 0x04FE, 0x04FE }, + { 0x0500, 0x0500 }, + { 0x0502, 0x0502 }, + { 0x0504, 0x0504 }, + { 0x0506, 0x0506 }, + { 0x0508, 0x0508 }, + { 0x050A, 0x050A }, + { 0x050C, 0x050C }, + { 0x050E, 0x050E }, + { 0x0510, 0x0510 }, + { 0x0512, 0x0512 }, + { 0x0514, 0x0514 }, + { 0x0516, 0x0516 }, + { 0x0518, 0x0518 }, + { 0x051A, 0x051A }, + { 0x051C, 0x051C }, + { 0x051E, 0x051E }, + { 0x0520, 0x0520 }, + { 0x0522, 0x0522 }, + { 0x0524, 0x0524 }, + { 0x0526, 0x0526 }, + { 0x0528, 0x0528 }, + { 0x052A, 0x052A }, + { 0x052C, 0x052C }, + { 0x052E, 0x052E }, + { 0x0531, 0x0556 }, + { 0x10A0, 0x10C5 }, + { 0x10C7, 0x10C7 }, + { 0x10CD, 0x10CD }, + { 0x13A0, 0x13F5 }, + { 0x1C90, 0x1CBA }, + { 0x1CBD, 0x1CBF }, + { 0x1E00, 0x1E00 }, + { 0x1E02, 0x1E02 }, + { 0x1E04, 0x1E04 }, + { 0x1E06, 0x1E06 }, + { 0x1E08, 0x1E08 }, + { 0x1E0A, 0x1E0A }, + { 0x1E0C, 0x1E0C }, + { 0x1E0E, 0x1E0E }, + { 0x1E10, 0x1E10 }, + { 0x1E12, 0x1E12 }, + { 0x1E14, 0x1E14 }, + { 0x1E16, 0x1E16 }, + { 0x1E18, 0x1E18 }, + { 0x1E1A, 0x1E1A }, + { 0x1E1C, 0x1E1C }, + { 0x1E1E, 0x1E1E }, + { 0x1E20, 0x1E20 }, + { 0x1E22, 0x1E22 }, + { 0x1E24, 0x1E24 }, + { 0x1E26, 0x1E26 }, + { 0x1E28, 0x1E28 }, + { 0x1E2A, 0x1E2A }, + { 0x1E2C, 0x1E2C }, + { 0x1E2E, 0x1E2E }, + { 0x1E30, 0x1E30 }, + { 0x1E32, 0x1E32 }, + { 0x1E34, 0x1E34 }, + { 0x1E36, 0x1E36 }, + { 0x1E38, 0x1E38 }, + { 0x1E3A, 0x1E3A }, + { 0x1E3C, 0x1E3C }, + { 0x1E3E, 0x1E3E }, + { 0x1E40, 0x1E40 }, + { 0x1E42, 0x1E42 }, + { 0x1E44, 0x1E44 }, + { 0x1E46, 0x1E46 }, + { 0x1E48, 0x1E48 }, + { 0x1E4A, 0x1E4A }, + { 0x1E4C, 0x1E4C }, + { 0x1E4E, 0x1E4E }, + { 0x1E50, 0x1E50 }, + { 0x1E52, 0x1E52 }, + { 0x1E54, 0x1E54 }, + { 0x1E56, 0x1E56 }, + { 0x1E58, 0x1E58 }, + { 0x1E5A, 0x1E5A }, + { 0x1E5C, 0x1E5C }, + { 0x1E5E, 0x1E5E }, + { 0x1E60, 0x1E60 }, + { 0x1E62, 0x1E62 }, + { 0x1E64, 0x1E64 }, + { 0x1E66, 0x1E66 }, + { 0x1E68, 0x1E68 }, + { 0x1E6A, 0x1E6A }, + { 0x1E6C, 0x1E6C }, + { 0x1E6E, 0x1E6E }, + { 0x1E70, 0x1E70 }, + { 0x1E72, 0x1E72 }, + { 0x1E74, 0x1E74 }, + { 0x1E76, 0x1E76 }, + { 0x1E78, 0x1E78 }, + { 0x1E7A, 0x1E7A }, + { 0x1E7C, 0x1E7C }, + { 0x1E7E, 0x1E7E }, + { 0x1E80, 0x1E80 }, + { 0x1E82, 0x1E82 }, + { 0x1E84, 0x1E84 }, + { 0x1E86, 0x1E86 }, + { 0x1E88, 0x1E88 }, + { 0x1E8A, 0x1E8A }, + { 0x1E8C, 0x1E8C }, + { 0x1E8E, 0x1E8E }, + { 0x1E90, 0x1E90 }, + { 0x1E92, 0x1E92 }, + { 0x1E94, 0x1E94 }, + { 0x1E9E, 0x1E9E }, + { 0x1EA0, 0x1EA0 }, + { 0x1EA2, 0x1EA2 }, + { 0x1EA4, 0x1EA4 }, + { 0x1EA6, 0x1EA6 }, + { 0x1EA8, 0x1EA8 }, + { 0x1EAA, 0x1EAA }, + { 0x1EAC, 0x1EAC }, + { 0x1EAE, 0x1EAE }, + { 0x1EB0, 0x1EB0 }, + { 0x1EB2, 0x1EB2 }, + { 0x1EB4, 0x1EB4 }, + { 0x1EB6, 0x1EB6 }, + { 0x1EB8, 0x1EB8 }, + { 0x1EBA, 0x1EBA }, + { 0x1EBC, 0x1EBC }, + { 0x1EBE, 0x1EBE }, + { 0x1EC0, 0x1EC0 }, + { 0x1EC2, 0x1EC2 }, + { 0x1EC4, 0x1EC4 }, + { 0x1EC6, 0x1EC6 }, + { 0x1EC8, 0x1EC8 }, + { 0x1ECA, 0x1ECA }, + { 0x1ECC, 0x1ECC }, + { 0x1ECE, 0x1ECE }, + { 0x1ED0, 0x1ED0 }, + { 0x1ED2, 0x1ED2 }, + { 0x1ED4, 0x1ED4 }, + { 0x1ED6, 0x1ED6 }, + { 0x1ED8, 0x1ED8 }, + { 0x1EDA, 0x1EDA }, + { 0x1EDC, 0x1EDC }, + { 0x1EDE, 0x1EDE }, + { 0x1EE0, 0x1EE0 }, + { 0x1EE2, 0x1EE2 }, + { 0x1EE4, 0x1EE4 }, + { 0x1EE6, 0x1EE6 }, + { 0x1EE8, 0x1EE8 }, + { 0x1EEA, 0x1EEA }, + { 0x1EEC, 0x1EEC }, + { 0x1EEE, 0x1EEE }, + { 0x1EF0, 0x1EF0 }, + { 0x1EF2, 0x1EF2 }, + { 0x1EF4, 0x1EF4 }, + { 0x1EF6, 0x1EF6 }, + { 0x1EF8, 0x1EF8 }, + { 0x1EFA, 0x1EFA }, + { 0x1EFC, 0x1EFC }, + { 0x1EFE, 0x1EFE }, + { 0x1F08, 0x1F0F }, + { 0x1F18, 0x1F1D }, + { 0x1F28, 0x1F2F }, + { 0x1F38, 0x1F3F }, + { 0x1F48, 0x1F4D }, + { 0x1F59, 0x1F59 }, + { 0x1F5B, 0x1F5B }, + { 0x1F5D, 0x1F5D }, + { 0x1F5F, 0x1F5F }, + { 0x1F68, 0x1F6F }, + { 0x1F88, 0x1F8F }, + { 0x1F98, 0x1F9F }, + { 0x1FA8, 0x1FAF }, + { 0x1FB8, 0x1FBC }, + { 0x1FC8, 0x1FCC }, + { 0x1FD8, 0x1FDB }, + { 0x1FE8, 0x1FEC }, + { 0x1FF8, 0x1FFC }, + { 0x2126, 0x2126 }, + { 0x212A, 0x212B }, + { 0x2132, 0x2132 }, + { 0x2160, 0x216F }, + { 0x2183, 0x2183 }, + { 0x24B6, 0x24CF }, + { 0x2C00, 0x2C2F }, + { 0x2C60, 0x2C60 }, + { 0x2C62, 0x2C64 }, + { 0x2C67, 0x2C67 }, + { 0x2C69, 0x2C69 }, + { 0x2C6B, 0x2C6B }, + { 0x2C6D, 0x2C70 }, + { 0x2C72, 0x2C72 }, + { 0x2C75, 0x2C75 }, + { 0x2C7E, 0x2C80 }, + { 0x2C82, 0x2C82 }, + { 0x2C84, 0x2C84 }, + { 0x2C86, 0x2C86 }, + { 0x2C88, 0x2C88 }, + { 0x2C8A, 0x2C8A }, + { 0x2C8C, 0x2C8C }, + { 0x2C8E, 0x2C8E }, + { 0x2C90, 0x2C90 }, + { 0x2C92, 0x2C92 }, + { 0x2C94, 0x2C94 }, + { 0x2C96, 0x2C96 }, + { 0x2C98, 0x2C98 }, + { 0x2C9A, 0x2C9A }, + { 0x2C9C, 0x2C9C }, + { 0x2C9E, 0x2C9E }, + { 0x2CA0, 0x2CA0 }, + { 0x2CA2, 0x2CA2 }, + { 0x2CA4, 0x2CA4 }, + { 0x2CA6, 0x2CA6 }, + { 0x2CA8, 0x2CA8 }, + { 0x2CAA, 0x2CAA }, + { 0x2CAC, 0x2CAC }, + { 0x2CAE, 0x2CAE }, + { 0x2CB0, 0x2CB0 }, + { 0x2CB2, 0x2CB2 }, + { 0x2CB4, 0x2CB4 }, + { 0x2CB6, 0x2CB6 }, + { 0x2CB8, 0x2CB8 }, + { 0x2CBA, 0x2CBA }, + { 0x2CBC, 0x2CBC }, + { 0x2CBE, 0x2CBE }, + { 0x2CC0, 0x2CC0 }, + { 0x2CC2, 0x2CC2 }, + { 0x2CC4, 0x2CC4 }, + { 0x2CC6, 0x2CC6 }, + { 0x2CC8, 0x2CC8 }, + { 0x2CCA, 0x2CCA }, + { 0x2CCC, 0x2CCC }, + { 0x2CCE, 0x2CCE }, + { 0x2CD0, 0x2CD0 }, + { 0x2CD2, 0x2CD2 }, + { 0x2CD4, 0x2CD4 }, + { 0x2CD6, 0x2CD6 }, + { 0x2CD8, 0x2CD8 }, + { 0x2CDA, 0x2CDA }, + { 0x2CDC, 0x2CDC }, + { 0x2CDE, 0x2CDE }, + { 0x2CE0, 0x2CE0 }, + { 0x2CE2, 0x2CE2 }, + { 0x2CEB, 0x2CEB }, + { 0x2CED, 0x2CED }, + { 0x2CF2, 0x2CF2 }, + { 0xA640, 0xA640 }, + { 0xA642, 0xA642 }, + { 0xA644, 0xA644 }, + { 0xA646, 0xA646 }, + { 0xA648, 0xA648 }, + { 0xA64A, 0xA64A }, + { 0xA64C, 0xA64C }, + { 0xA64E, 0xA64E }, + { 0xA650, 0xA650 }, + { 0xA652, 0xA652 }, + { 0xA654, 0xA654 }, + { 0xA656, 0xA656 }, + { 0xA658, 0xA658 }, + { 0xA65A, 0xA65A }, + { 0xA65C, 0xA65C }, + { 0xA65E, 0xA65E }, + { 0xA660, 0xA660 }, + { 0xA662, 0xA662 }, + { 0xA664, 0xA664 }, + { 0xA666, 0xA666 }, + { 0xA668, 0xA668 }, + { 0xA66A, 0xA66A }, + { 0xA66C, 0xA66C }, + { 0xA680, 0xA680 }, + { 0xA682, 0xA682 }, + { 0xA684, 0xA684 }, + { 0xA686, 0xA686 }, + { 0xA688, 0xA688 }, + { 0xA68A, 0xA68A }, + { 0xA68C, 0xA68C }, + { 0xA68E, 0xA68E }, + { 0xA690, 0xA690 }, + { 0xA692, 0xA692 }, + { 0xA694, 0xA694 }, + { 0xA696, 0xA696 }, + { 0xA698, 0xA698 }, + { 0xA69A, 0xA69A }, + { 0xA722, 0xA722 }, + { 0xA724, 0xA724 }, + { 0xA726, 0xA726 }, + { 0xA728, 0xA728 }, + { 0xA72A, 0xA72A }, + { 0xA72C, 0xA72C }, + { 0xA72E, 0xA72E }, + { 0xA732, 0xA732 }, + { 0xA734, 0xA734 }, + { 0xA736, 0xA736 }, + { 0xA738, 0xA738 }, + { 0xA73A, 0xA73A }, + { 0xA73C, 0xA73C }, + { 0xA73E, 0xA73E }, + { 0xA740, 0xA740 }, + { 0xA742, 0xA742 }, + { 0xA744, 0xA744 }, + { 0xA746, 0xA746 }, + { 0xA748, 0xA748 }, + { 0xA74A, 0xA74A }, + { 0xA74C, 0xA74C }, + { 0xA74E, 0xA74E }, + { 0xA750, 0xA750 }, + { 0xA752, 0xA752 }, + { 0xA754, 0xA754 }, + { 0xA756, 0xA756 }, + { 0xA758, 0xA758 }, + { 0xA75A, 0xA75A }, + { 0xA75C, 0xA75C }, + { 0xA75E, 0xA75E }, + { 0xA760, 0xA760 }, + { 0xA762, 0xA762 }, + { 0xA764, 0xA764 }, + { 0xA766, 0xA766 }, + { 0xA768, 0xA768 }, + { 0xA76A, 0xA76A }, + { 0xA76C, 0xA76C }, + { 0xA76E, 0xA76E }, + { 0xA779, 0xA779 }, + { 0xA77B, 0xA77B }, + { 0xA77D, 0xA77E }, + { 0xA780, 0xA780 }, + { 0xA782, 0xA782 }, + { 0xA784, 0xA784 }, + { 0xA786, 0xA786 }, + { 0xA78B, 0xA78B }, + { 0xA78D, 0xA78D }, + { 0xA790, 0xA790 }, + { 0xA792, 0xA792 }, + { 0xA796, 0xA796 }, + { 0xA798, 0xA798 }, + { 0xA79A, 0xA79A }, + { 0xA79C, 0xA79C }, + { 0xA79E, 0xA79E }, + { 0xA7A0, 0xA7A0 }, + { 0xA7A2, 0xA7A2 }, + { 0xA7A4, 0xA7A4 }, + { 0xA7A6, 0xA7A6 }, + { 0xA7A8, 0xA7A8 }, + { 0xA7AA, 0xA7AE }, + { 0xA7B0, 0xA7B4 }, + { 0xA7B6, 0xA7B6 }, + { 0xA7B8, 0xA7B8 }, + { 0xA7BA, 0xA7BA }, + { 0xA7BC, 0xA7BC }, + { 0xA7BE, 0xA7BE }, + { 0xA7C0, 0xA7C0 }, + { 0xA7C2, 0xA7C2 }, + { 0xA7C4, 0xA7C7 }, + { 0xA7C9, 0xA7C9 }, + { 0xA7D0, 0xA7D0 }, + { 0xA7D6, 0xA7D6 }, + { 0xA7D8, 0xA7D8 }, + { 0xA7F5, 0xA7F5 }, + { 0xFF21, 0xFF3A }, + { 0x10400, 0x10427 }, + { 0x104B0, 0x104D3 }, + { 0x10570, 0x1057A }, + { 0x1057C, 0x1058A }, + { 0x1058C, 0x10592 }, + { 0x10594, 0x10595 }, + { 0x10C80, 0x10CB2 }, + { 0x118A0, 0x118BF }, + { 0x16E40, 0x16E5F }, + { 0x1E900, 0x1E921 } + +#define PREDICATE(c) uc_is_upper (c) +#include "test-predicate-part2.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/test-ctype_xdigit.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/test-ctype_xdigit.c new file mode 100644 index 00000000..3de8ce98 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/test-ctype_xdigit.c @@ -0,0 +1,25 @@ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +/* Test the Unicode character type functions. + Copyright (C) 2007-2022 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 the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + This file 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 . */ + +#include "test-predicate-part1.h" + + { 0x0030, 0x0039 }, + { 0x0041, 0x0046 }, + { 0x0061, 0x0066 } + +#define PREDICATE(c) uc_is_xdigit (c) +#include "test-predicate-part2.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/test-predicate-part1.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/test-predicate-part1.h new file mode 100644 index 00000000..10eb668b --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/test-predicate-part1.h @@ -0,0 +1,31 @@ +/* Test the Unicode character type functions. + Copyright (C) 2007-2024 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 . */ + +#include + +#include "unictype.h" + +#include + +#include "macros.h" + +/* Interval of Unicode characters. */ +typedef struct { ucs4_t start; ucs4_t end; } interval_t; + +/* Set of Unicode characters, described as list of intervals, in increasing + order. */ +static const interval_t set[] = + { diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/test-predicate-part2.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/test-predicate-part2.h new file mode 100644 index 00000000..aecd5f5a --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unictype/test-predicate-part2.h @@ -0,0 +1,37 @@ +/* Test the Unicode character type functions. + Copyright (C) 2007-2024 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 . */ + + }; + +int +main () +{ + unsigned int c; + size_t i; + + c = 0; + for (i = 0; i < SIZEOF (set); i++) + { + for (; c < set[i].start; c++) + ASSERT (!PREDICATE (c)); + for (; c <= set[i].end; c++) + ASSERT (PREDICATE (c)); + } + for (; c < 0x110000; c++) + ASSERT (!PREDICATE (c)); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unistr/.gitignore b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unistr/.gitignore new file mode 100644 index 00000000..57f6b56e --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unistr/.gitignore @@ -0,0 +1,13 @@ +/test-chr.h +/test-cpy.h +/test-pcpy.h +/test-set.h +/test-strcat.h +/test-u32-chr.c +/test-u32-cpy.c +/test-u32-pcpy.c +/test-u32-set.c +/test-u32-strcat.c +/test-u32-strlen.c +/u-set.h +/u32-set.c diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unistr/test-chr.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unistr/test-chr.h new file mode 100644 index 00000000..f7bfc2ba --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unistr/test-chr.h @@ -0,0 +1,142 @@ +/* Test of uN_chr() functions. + Copyright (C) 2008-2024 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 . */ + +/* Written by Eric Blake and Bruno Haible , 2010. */ + +int +main (void) +{ + size_t size = 0x100000; + size_t length; + UNIT *input; + uint32_t *input32 = (uint32_t *) malloc (size * sizeof (uint32_t)); + ASSERT (input32); + + input32[0] = 'a'; + input32[1] = 'b'; + u32_set (input32 + 2, 'c', 1024); + for (size_t i = 1026; i < size - 2; i += 63) + { + size_t last = i + 63 < size - 2 ? i + 63 : size - 2; + ucs4_t uc = 'd' | (i - 1026); + if (uc >= 0xd800 && uc <= 0xdfff) + uc |= 0x100000; + u32_set (input32 + i, uc, last - i); + } + + input32[size - 2] = 'e'; + input32[size - 1] = 'a'; + + input = U32_TO_U (input32, size, NULL, &length); + ASSERT (input); + + /* Basic behavior tests. */ + ASSERT (U_CHR (input, length, 'a') == input); + + ASSERT (U_CHR (input, 0, 'a') == NULL); + { + void *page_boundary = zerosize_ptr (); + if (page_boundary != NULL) + ASSERT (U_CHR (page_boundary, 0, 'a') == NULL); + } + + ASSERT (U_CHR (input, length, 'b') == input + 1); + ASSERT (U_CHR (input, length, 'c') == input + 2); + ASSERT (U_CHR (input, length, 'd') == input + 1026); + + { + UNIT *exp = input + 1026; + UNIT *prev = input + 1; + for (size_t i = 1026; i < size - 2; i += 63) + { + UNIT c[6]; + size_t n; + ucs4_t uc = 'd' | (i - 1026); + if (uc >= 0xd800 && uc <= 0xdfff) + uc |= 0x100000; + n = U_UCTOMB (c, uc, 6); + ASSERT (exp < input + length - 1); + ASSERT (U_CHR (prev, (length - 1) - (prev - input), uc) == exp); + ASSERT (memcmp (exp, c, n * sizeof (UNIT)) == 0); + prev = exp; + exp += n * 63; + } + } + + ASSERT (U_CHR (input + 1, length - 1, 'a') == input + length - 1); + ASSERT (U_CHR (input + 1, length - 1, 'e') == input + length - 2); + + ASSERT (U_CHR (input, length, 'f') == NULL); + ASSERT (U_CHR (input, length, '\0') == NULL); + + /* Check that a very long haystack is handled quickly if the byte is + found near the beginning. */ + { + size_t repeat = 10000; + for (; repeat > 0; repeat--) + { + ASSERT (U_CHR (input, length, 'c') == input + 2); + } + } + + /* Alignment tests. */ + { + int i, j; + for (i = 0; i < 32; i++) + { + for (j = 0; j < 128; j++) + input[i + j] = j; + for (j = 0; j < 128; j++) + { + ASSERT (U_CHR (input + i, 128, j) == input + i + j); + } + } + } + + /* Check that uN_chr() does not read past the first occurrence of the + byte being searched. */ + { + UNIT *page_boundary = zerosize_ptr (); + size_t n; + + if (page_boundary != NULL) + { + for (n = 1; n <= 500 / sizeof (UNIT); n++) + { + UNIT *mem = page_boundary - n; + U_SET (mem, 'X', n); + ASSERT (U_CHR (mem, n, 'U') == NULL); + + { + size_t i; + + for (i = 0; i < n; i++) + { + mem[i] = 'U'; + ASSERT (U_CHR (mem, 4000, 'U') == mem + i); + mem[i] = 'X'; + } + } + } + } + } + + free (input); + if (sizeof (UNIT) != sizeof (uint32_t)) + free (input32); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unistr/test-cpy.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unistr/test-cpy.h new file mode 100644 index 00000000..05f1f5a8 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unistr/test-cpy.h @@ -0,0 +1,44 @@ +/* Test of uN_cpy() functions. + Copyright (C) 2010-2024 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 . */ + +/* Written by Bruno Haible , 2010. */ + +int +main () +{ + /* Test small copying operations. */ + { + static const UNIT src[] = { 'c', 'l', 'i', 'm', 'a', 't', 'e' }; + size_t n; + + for (n = 0; n <= SIZEOF (src); n++) + { + UNIT dest[1 + SIZEOF (src) + 1] = + { MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC }; + UNIT *ret; + size_t i; + + ret = U_CPY (dest + 1, src, n); + ASSERT (ret == dest + 1); + ASSERT (dest[0] == MAGIC); + for (i = 0; i < n; i++) + ASSERT (dest[1 + i] == src[i]); + ASSERT (dest[1 + n] == MAGIC); + } + } + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unistr/test-pcpy.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unistr/test-pcpy.h new file mode 100644 index 00000000..92ae0d0e --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unistr/test-pcpy.h @@ -0,0 +1,44 @@ +/* Test of uN_pcpy() functions. + Copyright (C) 2010-2024 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 . */ + +/* Written by Bruno Haible , 2023. */ + +int +main () +{ + /* Test small copying operations. */ + { + static const UNIT src[] = { 'c', 'l', 'i', 'm', 'a', 't', 'e' }; + size_t n; + + for (n = 0; n <= SIZEOF (src); n++) + { + UNIT dest[1 + SIZEOF (src) + 1] = + { MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC }; + UNIT *ret; + size_t i; + + ret = U_PCPY (dest + 1, src, n); + ASSERT (ret == dest + 1 + n); + ASSERT (dest[0] == MAGIC); + for (i = 0; i < n; i++) + ASSERT (dest[1 + i] == src[i]); + ASSERT (dest[1 + n] == MAGIC); + } + } + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unistr/test-set.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unistr/test-set.h new file mode 100644 index 00000000..c1966675 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unistr/test-set.h @@ -0,0 +1,44 @@ +/* Test of uN_set() functions. + Copyright (C) 2010-2024 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 . */ + +/* Written by Bruno Haible , 2010. */ + +int +main () +{ + { +#define NMAX 7 + size_t n; + + for (n = 0; n <= NMAX; n++) + { + UNIT dest[1 + NMAX + 1] = + { MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC }; + UNIT *ret; + size_t i; + + ret = U_SET (dest + 1, VALUE, n); + ASSERT (ret == dest + 1); + ASSERT (dest[0] == MAGIC); + for (i = 0; i < n; i++) + ASSERT (dest[1 + i] == VALUE); + ASSERT (dest[1 + n] == MAGIC); + } +#undef NMAX + } + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unistr/test-strcat.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unistr/test-strcat.h new file mode 100644 index 00000000..12440c43 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unistr/test-strcat.h @@ -0,0 +1,56 @@ +/* Test of uN_strcat() functions. + Copyright (C) 2010-2024 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 . */ + +/* Written by Bruno Haible , 2010. */ + +int +main () +{ + /* Test small copying operations. */ + { + static const UNIT base[] = { 'C', 'h', 'a', 'n', 'g', 'i', 'n', 'g', 0 }; + static const UNIT src[] = { 'c', 'l', 'i', 'm', 'a', 't', 'e', 0 }; + size_t m; + size_t n; + + for (m = 0; m < SIZEOF (base); m++) + for (n = 1; n <= SIZEOF (src); n++) + { + UNIT dest[1 + (SIZEOF (base) - 1) + SIZEOF (src) + 1] = + { MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, + MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC + }; + UNIT *result; + size_t i; + + for (i = 0; i < m; i++) + dest[1 + i] = base[i]; + dest[1 + m] = 0; + + result = U_STRCAT (dest + 1, src + SIZEOF (src) - n); + ASSERT (result == dest + 1); + + ASSERT (dest[0] == MAGIC); + for (i = 0; i < m; i++) + ASSERT (dest[1 + i] == base[i]); + for (i = 0; i < n; i++) + ASSERT (dest[1 + m + i] == src[SIZEOF (src) - n + i]); + ASSERT (dest[1 + m + n] == MAGIC); + } + } + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unistr/test-u32-chr.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unistr/test-u32-chr.c new file mode 100644 index 00000000..474681ff --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unistr/test-u32-chr.c @@ -0,0 +1,34 @@ +/* Test of u32_chr() function. + Copyright (C) 2010-2024 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 . */ + +/* Written by Bruno Haible , 2010. */ + +#include + +#include "unistr.h" + +#include +#include + +#include "zerosize-ptr.h" +#include "macros.h" + +#define UNIT uint32_t +#define U_UCTOMB(s, uc, n) (*(s) = (uc), 1) +#define U32_TO_U(s, n, result, length) (*(length) = (n), (s)) +#define U_CHR u32_chr +#define U_SET u32_set +#include "test-chr.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unistr/test-u32-cpy.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unistr/test-u32-cpy.c new file mode 100644 index 00000000..0ba5f8b4 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unistr/test-u32-cpy.c @@ -0,0 +1,28 @@ +/* Test of u32_cpy() function. + Copyright (C) 2010-2024 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 . */ + +/* Written by Bruno Haible , 2010. */ + +#include + +#include "unistr.h" + +#include "macros.h" + +#define UNIT uint32_t +#define U_CPY u32_cpy +#define MAGIC 0xBADFACE +#include "test-cpy.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unistr/test-u32-pcpy.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unistr/test-u32-pcpy.c new file mode 100644 index 00000000..af77cc25 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unistr/test-u32-pcpy.c @@ -0,0 +1,28 @@ +/* Test of u32_pcpy() function. + Copyright (C) 2010-2024 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 . */ + +/* Written by Bruno Haible , 2023. */ + +#include + +#include "unistr.h" + +#include "macros.h" + +#define UNIT uint32_t +#define U_PCPY u32_pcpy +#define MAGIC 0xBADFACE +#include "test-pcpy.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unistr/test-u32-set.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unistr/test-u32-set.c new file mode 100644 index 00000000..99e644dc --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unistr/test-u32-set.c @@ -0,0 +1,29 @@ +/* Test of u32_set() function. + Copyright (C) 2010-2024 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 . */ + +/* Written by Bruno Haible , 2010. */ + +#include + +#include "unistr.h" + +#include "macros.h" + +#define UNIT uint32_t +#define U_SET u32_set +#define MAGIC 0xBADFACE +#define VALUE 0x1D51E +#include "test-set.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unistr/test-u32-strcat.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unistr/test-u32-strcat.c new file mode 100644 index 00000000..64e1b5cc --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unistr/test-u32-strcat.c @@ -0,0 +1,28 @@ +/* Test of u32_strcat() function. + Copyright (C) 2010-2024 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 . */ + +/* Written by Bruno Haible , 2010. */ + +#include + +#include "unistr.h" + +#include "macros.h" + +#define UNIT uint32_t +#define U_STRCAT u32_strcat +#define MAGIC 0xBADFACE +#include "test-strcat.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unistr/test-u32-strlen.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unistr/test-u32-strlen.c new file mode 100644 index 00000000..6186fbdb --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unistr/test-u32-strlen.c @@ -0,0 +1,57 @@ +/* Test of u32_strlen() function. + Copyright (C) 2010-2024 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 . */ + +/* Written by Bruno Haible , 2010. */ + +#include + +#include "unistr.h" + +#include "macros.h" + +int +main () +{ + /* Empty string. */ + { + static const uint32_t input[] = { 0 }; + ASSERT (u32_strlen (input) == 0); + } + + /* Simple string. */ + { /* "Grüß Gott. Здравствуйте! x=(-b±sqrt(b²-4ac))/(2a) 日本語,中文,한글" */ + static const uint32_t input[] = + { 'G', 'r', 0x00FC, 0x00DF, ' ', 'G', 'o', 't', 't', '.', ' ', + 0x0417, 0x0434, 0x0440, 0x0430, 0x0432, 0x0441, 0x0442, 0x0432, 0x0443, + 0x0439, 0x0442, 0x0435, '!', ' ', + 'x', '=', '(', '-', 'b', 0x00B1, 's', 'q', 'r', 't', '(', 'b', 0x00B2, + '-', '4', 'a', 'c', ')', ')', '/', '(', '2', 'a', ')', ' ', ' ', + 0x65E5, 0x672C, 0x8A9E, ',', 0x4E2D, 0x6587, ',', 0xD55C, 0xAE00, 0 + }; + ASSERT (u32_strlen (input) == SIZEOF (input) - 1); + } + + /* String with characters outside the BMP. */ + { + static const uint32_t input[] = + { '-', '(', 0x1D51E, 0x00D7, 0x1D51F, ')', '=', + 0x1D51F, 0x00D7, 0x1D51E, 0 + }; + ASSERT (u32_strlen (input) == SIZEOF (input) - 1); + } + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unistr/u-set.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unistr/u-set.h new file mode 100644 index 00000000..088cabef --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unistr/u-set.h @@ -0,0 +1,47 @@ +/* Fill UTF-8/UTF-16/UTF-32 string. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2002. + + This file is free software. + It is dual-licensed under "the GNU LGPLv3+ or the GNU GPLv2+". + You can redistribute it and/or modify it under either + - the terms of the GNU Lesser General Public License as published + by the Free Software Foundation, either version 3, or (at your + option) any later version, or + - the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2, or (at your option) + any later version, or + - the same dual license "the GNU LGPLv3+ or the GNU GPLv2+". + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License and the GNU General Public License + for more details. + + You should have received a copy of the GNU Lesser General Public + License and of the GNU General Public License along with this + program. If not, see . */ + +#include + +UNIT * +FUNC (UNIT *s, ucs4_t uc, size_t n) +{ + if (n > 0) + { + if (IS_SINGLE_UNIT (uc)) + { + UNIT *ptr = s; + + for (; n > 0; n--) + *ptr++ = uc; + } + else + { + errno = EILSEQ; + return NULL; + } + } + return s; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unistr/u32-set.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unistr/u32-set.c new file mode 100644 index 00000000..51cf3d63 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unistr/u32-set.c @@ -0,0 +1,34 @@ +/* Fill UTF-32 string. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2002. + + This file is free software. + It is dual-licensed under "the GNU LGPLv3+ or the GNU GPLv2+". + You can redistribute it and/or modify it under either + - the terms of the GNU Lesser General Public License as published + by the Free Software Foundation, either version 3, or (at your + option) any later version, or + - the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2, or (at your option) + any later version, or + - the same dual license "the GNU LGPLv3+ or the GNU GPLv2+". + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License and the GNU General Public License + for more details. + + You should have received a copy of the GNU Lesser General Public + License and of the GNU General Public License along with this + program. If not, see . */ + +#include + +/* Specification. */ +#include "unistr.h" + +#define FUNC u32_set +#define UNIT uint32_t +#define IS_SINGLE_UNIT(uc) (uc < 0xd800 || (uc >= 0xe000 && uc < 0x110000)) +#include "u-set.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/uniwidth/.gitignore b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/uniwidth/.gitignore new file mode 100644 index 00000000..2cd813bd --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/uniwidth/.gitignore @@ -0,0 +1,3 @@ +/test-uc_width.c +/test-uc_width2.c +/test-uc_width2.sh diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/uniwidth/test-uc_width.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/uniwidth/test-uc_width.c new file mode 100644 index 00000000..5f0e793f --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/uniwidth/test-uc_width.c @@ -0,0 +1,56 @@ +/* Test of uc_width() function. + Copyright (C) 2007-2024 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 . */ + +/* Written by Bruno Haible , 2007. */ + +#include + +#include "uniwidth.h" + +#include "macros.h" + +int +main () +{ + ucs4_t uc; + + /* Test width of ASCII characters. */ + for (uc = 0x0020; uc < 0x007F; uc++) + ASSERT (uc_width (uc, "ISO-8859-2") == 1); + + /* Test width of some non-spacing characters. */ + ASSERT (uc_width (0x0301, "UTF-8") == 0); + ASSERT (uc_width (0x05B0, "UTF-8") == 0); + + /* Test width of some format control characters. */ + ASSERT (uc_width (0x200E, "UTF-8") == 0); + ASSERT (uc_width (0x2060, "UTF-8") == 0); + ASSERT (uc_width (0xE0001, "UTF-8") == 0); + ASSERT (uc_width (0xE0044, "UTF-8") == 0); + + /* Test width of some zero width characters. */ + ASSERT (uc_width (0x200B, "UTF-8") == 0); + ASSERT (uc_width (0xFEFF, "UTF-8") == 0); + + /* Test width of some CJK characters. */ + ASSERT (uc_width (0x3000, "UTF-8") == 2); + ASSERT (uc_width (0xB250, "UTF-8") == 2); + ASSERT (uc_width (0xFF1A, "UTF-8") == 2); + ASSERT (uc_width (0x20369, "UTF-8") == 2); + ASSERT (uc_width (0x2F876, "UTF-8") == 2); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/uniwidth/test-uc_width2.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/uniwidth/test-uc_width2.c new file mode 100644 index 00000000..a07a11f8 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/uniwidth/test-uc_width2.c @@ -0,0 +1,86 @@ +/* Test of uc_width() function. + Copyright (C) 2007-2024 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 . */ + +/* Written by Bruno Haible , 2008. */ + +#include + +#include "uniwidth.h" + +#include + +#include "macros.h" + +/* One of 0, '0', '1', 'A', '2'. */ +static char current_width; +/* The interval for which the current_width holds. */ +static ucs4_t current_start; +static ucs4_t current_end; + +static void +finish_interval (void) +{ + if (current_width != 0) + { + if (current_start == current_end) + printf ("%04X\t\t%c\n", (unsigned) current_start, current_width); + else + printf ("%04X..%04X\t%c\n", (unsigned) current_start, + (unsigned) current_end, current_width); + current_width = 0; + } +} + +static void +add_to_interval (ucs4_t uc, char width) +{ + if (current_width == width && uc == current_end + 1) + current_end = uc; + else + { + finish_interval (); + current_width = width; + current_start = current_end = uc; + } +} + +int +main () +{ + ucs4_t uc; + + for (uc = 0; uc < 0x110000; uc++) + { + int w1 = uc_width (uc, "UTF-8"); + int w2 = uc_width (uc, "GBK"); + char width = + (w1 == 0 && w2 == 0 ? '0' : + w1 == 1 && w2 == 1 ? '1' : + w1 == 1 && w2 == 2 ? 'A' : + w1 == 2 && w2 == 2 ? '2' : + 0); + if (width == 0) + { + /* uc must be a control character. */ + ASSERT (w1 < 0 && w2 < 0); + } + else + add_to_interval (uc, width); + } + finish_interval (); + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/uniwidth/test-uc_width2.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/uniwidth/test-uc_width2.sh new file mode 100755 index 00000000..ae6f8f45 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/uniwidth/test-uc_width2.sh @@ -0,0 +1,939 @@ +#!/bin/sh + +tmpfiles="" +trap 'rm -fr $tmpfiles' HUP INT QUIT TERM + +tmpfiles="$tmpfiles uc_width.out" +${CHECKER} ./test-uc_width2${EXEEXT} | LC_ALL=C tr -d '\r' > uc_width.out + +tmpfiles="$tmpfiles uc_width.ok" +cat > uc_width.ok <<\EOF +0000 0 +0020..007E 1 +00A0 1 +00A1..00AC A +00AD 0 +00AE..02FF A +0300..036F 0 +0370..0482 A +0483..0489 0 +048A..0590 A +0591..05BD 0 +05BE A +05BF 0 +05C0 A +05C1..05C2 0 +05C3 A +05C4..05C5 0 +05C6 A +05C7 0 +05C8..05FF A +0600..0605 0 +0606..060F A +0610..061A 0 +061B A +061C 0 +061D..064A A +064B..065F 0 +0660..066F A +0670 0 +0671..06D5 A +06D6..06DD 0 +06DE A +06DF..06E4 0 +06E5..06E6 A +06E7..06E8 0 +06E9 A +06EA..06ED 0 +06EE..070E A +070F 0 +0710 A +0711 0 +0712..072F A +0730..074A 0 +074B..07A5 A +07A6..07B0 0 +07B1..07EA A +07EB..07F3 0 +07F4..07FC A +07FD 0 +07FE..0815 A +0816..0819 0 +081A A +081B..0823 0 +0824 A +0825..0827 0 +0828 A +0829..082D 0 +082E..0858 A +0859..085B 0 +085C..088F A +0890..0891 0 +0892..0897 A +0898..089F 0 +08A0..08C9 A +08CA..0902 0 +0903..0939 A +093A 0 +093B A +093C 0 +093D..0940 A +0941..0948 0 +0949..094C A +094D 0 +094E..0950 A +0951..0957 0 +0958..0961 A +0962..0963 0 +0964..0980 A +0981 0 +0982..09BB A +09BC 0 +09BD..09C0 A +09C1..09C4 0 +09C5..09CC A +09CD 0 +09CE..09E1 A +09E2..09E3 0 +09E4..09FD A +09FE 0 +09FF..0A00 A +0A01..0A02 0 +0A03..0A3B A +0A3C 0 +0A3D..0A40 A +0A41..0A42 0 +0A43..0A46 A +0A47..0A48 0 +0A49..0A4A A +0A4B..0A4D 0 +0A4E..0A50 A +0A51 0 +0A52..0A6F A +0A70..0A71 0 +0A72..0A74 A +0A75 0 +0A76..0A80 A +0A81..0A82 0 +0A83..0ABB A +0ABC 0 +0ABD..0AC0 A +0AC1..0AC5 0 +0AC6 A +0AC7..0AC8 0 +0AC9..0ACC A +0ACD 0 +0ACE..0AE1 A +0AE2..0AE3 0 +0AE4..0AF9 A +0AFA..0AFF 0 +0B00 A +0B01 0 +0B02..0B3B A +0B3C 0 +0B3D..0B3E A +0B3F 0 +0B40 A +0B41..0B44 0 +0B45..0B4C A +0B4D 0 +0B4E..0B54 A +0B55..0B56 0 +0B57..0B61 A +0B62..0B63 0 +0B64..0B81 A +0B82 0 +0B83..0BBF A +0BC0 0 +0BC1..0BCC A +0BCD 0 +0BCE..0BFF A +0C00 0 +0C01..0C03 A +0C04 0 +0C05..0C3B A +0C3C 0 +0C3D A +0C3E..0C40 0 +0C41..0C45 A +0C46..0C48 0 +0C49 A +0C4A..0C4D 0 +0C4E..0C54 A +0C55..0C56 0 +0C57..0C61 A +0C62..0C63 0 +0C64..0C80 A +0C81 0 +0C82..0CBB A +0CBC 0 +0CBD..0CCB A +0CCC..0CCD 0 +0CCE..0CE1 A +0CE2..0CE3 0 +0CE4..0CFF A +0D00..0D01 0 +0D02..0D3A A +0D3B..0D3C 0 +0D3D..0D40 A +0D41..0D44 0 +0D45..0D4C A +0D4D 0 +0D4E..0D61 A +0D62..0D63 0 +0D64..0D80 A +0D81 0 +0D82..0DC9 A +0DCA 0 +0DCB..0DD1 A +0DD2..0DD4 0 +0DD5 A +0DD6 0 +0DD7..0E30 A +0E31 0 +0E32..0E33 A +0E34..0E3A 0 +0E3B..0E46 A +0E47..0E4E 0 +0E4F..0EB0 A +0EB1 0 +0EB2..0EB3 A +0EB4..0EBC 0 +0EBD..0EC7 A +0EC8..0ECE 0 +0ECF..0F17 A +0F18..0F19 0 +0F1A..0F34 A +0F35 0 +0F36 A +0F37 0 +0F38 A +0F39 0 +0F3A..0F70 A +0F71..0F7E 0 +0F7F A +0F80..0F84 0 +0F85 A +0F86..0F87 0 +0F88..0F8C A +0F8D..0F97 0 +0F98 A +0F99..0FBC 0 +0FBD..0FC5 A +0FC6 0 +0FC7..102C A +102D..1030 0 +1031 A +1032..1037 0 +1038 A +1039..103A 0 +103B..103C A +103D..103E 0 +103F..1057 A +1058..1059 0 +105A..105D A +105E..1060 0 +1061..1070 A +1071..1074 0 +1075..1081 A +1082 0 +1083..1084 A +1085..1086 0 +1087..108C A +108D 0 +108E..109C A +109D 0 +109E..10FF A +1100..115F 2 +1160..11FF 0 +1200..135C A +135D..135F 0 +1360..1711 A +1712..1714 0 +1715..1731 A +1732..1733 0 +1734..1751 A +1752..1753 0 +1754..1771 A +1772..1773 0 +1774..17B3 A +17B4..17B5 0 +17B6 A +17B7..17BD 0 +17BE..17C5 A +17C6 0 +17C7..17C8 A +17C9..17D3 0 +17D4..17DC A +17DD 0 +17DE..180A A +180B..180F 0 +1810..1884 A +1885..1886 0 +1887..18A8 A +18A9 0 +18AA..191F A +1920..1922 0 +1923..1926 A +1927..1928 0 +1929..1931 A +1932 0 +1933..1938 A +1939..193B 0 +193C..1A16 A +1A17..1A18 0 +1A19..1A1A A +1A1B 0 +1A1C..1A55 A +1A56 0 +1A57 A +1A58..1A5E 0 +1A5F A +1A60 0 +1A61 A +1A62 0 +1A63..1A64 A +1A65..1A6C 0 +1A6D..1A72 A +1A73..1A7C 0 +1A7D..1A7E A +1A7F 0 +1A80..1AAF A +1AB0..1ACE 0 +1ACF..1AFF A +1B00..1B03 0 +1B04..1B33 A +1B34 0 +1B35 A +1B36..1B3A 0 +1B3B A +1B3C 0 +1B3D..1B41 A +1B42 0 +1B43..1B6A A +1B6B..1B73 0 +1B74..1B7F A +1B80..1B81 0 +1B82..1BA1 A +1BA2..1BA5 0 +1BA6..1BA7 A +1BA8..1BA9 0 +1BAA A +1BAB..1BAD 0 +1BAE..1BE5 A +1BE6 0 +1BE7 A +1BE8..1BE9 0 +1BEA..1BEC A +1BED 0 +1BEE A +1BEF..1BF1 0 +1BF2..1C2B A +1C2C..1C33 0 +1C34..1C35 A +1C36..1C37 0 +1C38..1CCF A +1CD0..1CD2 0 +1CD3 A +1CD4..1CE0 0 +1CE1 A +1CE2..1CE8 0 +1CE9..1CEC A +1CED 0 +1CEE..1CF3 A +1CF4 0 +1CF5..1CF7 A +1CF8..1CF9 0 +1CFA..1DBF A +1DC0..1DFF 0 +1E00..200A A +200B..200F 0 +2010..2029 A +202A..202E 0 +202F..205F A +2060..2064 0 +2065 A +2066..206F 0 +2070..20A8 A +20A9 1 +20AA..20CF A +20D0..20F0 0 +20F1..2319 A +231A..231B 2 +231C..2328 A +2329..232A 2 +232B..23E8 A +23E9..23EC 2 +23ED..23EF A +23F0 2 +23F1..23F2 A +23F3 2 +23F4..25FC A +25FD..25FE 2 +25FF..2613 A +2614..2615 2 +2616..2647 A +2648..2653 2 +2654..267E A +267F 2 +2680..2692 A +2693 2 +2694..26A0 A +26A1 2 +26A2..26A9 A +26AA..26AB 2 +26AC..26BC A +26BD..26BE 2 +26BF..26C3 A +26C4..26C5 2 +26C6..26CD A +26CE 2 +26CF..26D3 A +26D4 2 +26D5..26E9 A +26EA 2 +26EB..26F1 A +26F2..26F3 2 +26F4 A +26F5 2 +26F6..26F9 A +26FA 2 +26FB..26FC A +26FD 2 +26FE..2704 A +2705 2 +2706..2709 A +270A..270B 2 +270C..2727 A +2728 2 +2729..274B A +274C 2 +274D A +274E 2 +274F..2752 A +2753..2755 2 +2756 A +2757 2 +2758..2794 A +2795..2797 2 +2798..27AF A +27B0 2 +27B1..27BE A +27BF 2 +27C0..2B1A A +2B1B..2B1C 2 +2B1D..2B4F A +2B50 2 +2B51..2B54 A +2B55 2 +2B56..2CEE A +2CEF..2CF1 0 +2CF2..2D7E A +2D7F 0 +2D80..2DDF A +2DE0..2DFF 0 +2E00..2E7F A +2E80..3029 2 +302A..302D 0 +302E..303E 2 +303F A +3040..3098 2 +3099..309A 0 +309B..3247 2 +3248..324F A +3250..4DBF 2 +4DC0..4DFF A +4E00..A4CF 2 +A4D0..A66E A +A66F..A672 0 +A673 A +A674..A67D 0 +A67E..A69D A +A69E..A69F 0 +A6A0..A6EF A +A6F0..A6F1 0 +A6F2..A801 A +A802 0 +A803..A805 A +A806 0 +A807..A80A A +A80B 0 +A80C..A824 A +A825..A826 0 +A827..A82B A +A82C 0 +A82D..A8C3 A +A8C4..A8C5 0 +A8C6..A8DF A +A8E0..A8F1 0 +A8F2..A8FE A +A8FF 0 +A900..A925 A +A926..A92D 0 +A92E..A946 A +A947..A951 0 +A952..A95F A +A960..A97C 2 +A97D..A97F A +A980..A982 0 +A983..A9B2 A +A9B3 0 +A9B4..A9B5 A +A9B6..A9B9 0 +A9BA..A9BB A +A9BC..A9BD 0 +A9BE..A9E4 A +A9E5 0 +A9E6..AA28 A +AA29..AA2E 0 +AA2F..AA30 A +AA31..AA32 0 +AA33..AA34 A +AA35..AA36 0 +AA37..AA42 A +AA43 0 +AA44..AA4B A +AA4C 0 +AA4D..AA7B A +AA7C 0 +AA7D..AAAF A +AAB0 0 +AAB1 A +AAB2..AAB4 0 +AAB5..AAB6 A +AAB7..AAB8 0 +AAB9..AABD A +AABE..AABF 0 +AAC0 A +AAC1 0 +AAC2..AAEB A +AAEC..AAED 0 +AAEE..AAF5 A +AAF6 0 +AAF7..ABE4 A +ABE5 0 +ABE6..ABE7 A +ABE8 0 +ABE9..ABEC A +ABED 0 +ABEE..ABFF A +AC00..D7A3 2 +D7A4..D7AF A +D7B0..D7C6 0 +D7C7..D7CA A +D7CB..D7FB 0 +D7FC..F8FF A +F900..FAFF 2 +FB00..FB1D A +FB1E 0 +FB1F..FDFF A +FE00..FE0F 0 +FE10..FE1F 2 +FE20..FE2F 0 +FE30..FE6F 2 +FE70..FEFE A +FEFF 0 +FF00..FF60 2 +FF61..FFDF 1 +FFE0..FFE6 2 +FFE7..FFF8 1 +FFF9..FFFB 0 +FFFC..101FC 1 +101FD 0 +101FE..102DF 1 +102E0 0 +102E1..10375 1 +10376..1037A 0 +1037B..10A00 1 +10A01..10A03 0 +10A04 1 +10A05..10A06 0 +10A07..10A0B 1 +10A0C..10A0F 0 +10A10..10A37 1 +10A38..10A3A 0 +10A3B..10A3E 1 +10A3F 0 +10A40..10AE4 1 +10AE5..10AE6 0 +10AE7..10D23 1 +10D24..10D27 0 +10D28..10EAA 1 +10EAB..10EAC 0 +10EAD..10EFC 1 +10EFD..10EFF 0 +10F00..10F45 1 +10F46..10F50 0 +10F51..10F81 1 +10F82..10F85 0 +10F86..11000 1 +11001 0 +11002..11037 1 +11038..11046 0 +11047..1106F 1 +11070 0 +11071..11072 1 +11073..11074 0 +11075..1107E 1 +1107F..11081 0 +11082..110B2 1 +110B3..110B6 0 +110B7..110B8 1 +110B9..110BA 0 +110BB..110BC 1 +110BD 0 +110BE..110C1 1 +110C2 0 +110C3..110CC 1 +110CD 0 +110CE..110FF 1 +11100..11102 0 +11103..11126 1 +11127..1112B 0 +1112C 1 +1112D..11134 0 +11135..11172 1 +11173 0 +11174..1117F 1 +11180..11181 0 +11182..111B5 1 +111B6..111BE 0 +111BF..111C8 1 +111C9..111CC 0 +111CD..111CE 1 +111CF 0 +111D0..1122E 1 +1122F..11231 0 +11232..11233 1 +11234 0 +11235 1 +11236..11237 0 +11238..1123D 1 +1123E 0 +1123F..11240 1 +11241 0 +11242..112DE 1 +112DF 0 +112E0..112E2 1 +112E3..112EA 0 +112EB..112FF 1 +11300..11301 0 +11302..1133A 1 +1133B..1133C 0 +1133D..1133F 1 +11340 0 +11341..11365 1 +11366..1136C 0 +1136D..1136F 1 +11370..11374 0 +11375..11437 1 +11438..1143F 0 +11440..11441 1 +11442..11444 0 +11445 1 +11446 0 +11447..1145D 1 +1145E 0 +1145F..114B2 1 +114B3..114B8 0 +114B9 1 +114BA 0 +114BB..114BE 1 +114BF..114C0 0 +114C1 1 +114C2..114C3 0 +114C4..115B1 1 +115B2..115B5 0 +115B6..115BB 1 +115BC..115BD 0 +115BE 1 +115BF..115C0 0 +115C1..115DB 1 +115DC..115DD 0 +115DE..11632 1 +11633..1163A 0 +1163B..1163C 1 +1163D 0 +1163E 1 +1163F..11640 0 +11641..116AA 1 +116AB 0 +116AC 1 +116AD 0 +116AE..116AF 1 +116B0..116B5 0 +116B6 1 +116B7 0 +116B8..1171C 1 +1171D..1171F 0 +11720..11721 1 +11722..11725 0 +11726 1 +11727..1172B 0 +1172C..1182E 1 +1182F..11837 0 +11838 1 +11839..1183A 0 +1183B..1193A 1 +1193B..1193C 0 +1193D 1 +1193E 0 +1193F..11942 1 +11943 0 +11944..119D3 1 +119D4..119D7 0 +119D8..119D9 1 +119DA..119DB 0 +119DC..119DF 1 +119E0 0 +119E1..11A00 1 +11A01..11A06 0 +11A07..11A08 1 +11A09..11A0A 0 +11A0B..11A32 1 +11A33..11A38 0 +11A39..11A3A 1 +11A3B..11A3E 0 +11A3F..11A46 1 +11A47 0 +11A48..11A50 1 +11A51..11A56 0 +11A57..11A58 1 +11A59..11A5B 0 +11A5C..11A89 1 +11A8A..11A96 0 +11A97 1 +11A98..11A99 0 +11A9A..11C2F 1 +11C30..11C36 0 +11C37 1 +11C38..11C3D 0 +11C3E..11C91 1 +11C92..11CA7 0 +11CA8..11CA9 1 +11CAA..11CB0 0 +11CB1 1 +11CB2..11CB3 0 +11CB4 1 +11CB5..11CB6 0 +11CB7..11D30 1 +11D31..11D36 0 +11D37..11D39 1 +11D3A 0 +11D3B 1 +11D3C..11D3D 0 +11D3E 1 +11D3F..11D45 0 +11D46 1 +11D47 0 +11D48..11D8F 1 +11D90..11D91 0 +11D92..11D94 1 +11D95 0 +11D96 1 +11D97 0 +11D98..11EF2 1 +11EF3..11EF4 0 +11EF5..11EFF 1 +11F00..11F01 0 +11F02..11F35 1 +11F36..11F3A 0 +11F3B..11F3F 1 +11F40 0 +11F41 1 +11F42 0 +11F43..1342F 1 +13430..13440 0 +13441..13446 1 +13447..13455 0 +13456..16AEF 1 +16AF0..16AF4 0 +16AF5..16B2F 1 +16B30..16B36 0 +16B37..16F4E 1 +16F4F 0 +16F50..16F8E 1 +16F8F..16F92 0 +16F93..16FDF 1 +16FE0..16FE3 2 +16FE4 0 +16FE5..16FEF 1 +16FF0..16FF1 2 +16FF2..16FFF 1 +17000..187F7 2 +187F8..187FF 1 +18800..18CD5 2 +18CD6..18CFF 1 +18D00..18D08 2 +18D09..1AFEF 1 +1AFF0..1AFF3 2 +1AFF4 1 +1AFF5..1AFFB 2 +1AFFC 1 +1AFFD..1AFFE 2 +1AFFF 1 +1B000..1B122 2 +1B123..1B14F 1 +1B150..1B152 2 +1B153..1B163 1 +1B164..1B167 2 +1B168..1B16F 1 +1B170..1B2FB 2 +1B2FC..1BC9C 1 +1BC9D..1BC9E 0 +1BC9F 1 +1BCA0..1BCA3 0 +1BCA4..1CEFF 1 +1CF00..1CF2D 0 +1CF2E..1CF2F 1 +1CF30..1CF46 0 +1CF47..1D166 1 +1D167..1D169 0 +1D16A..1D172 1 +1D173..1D182 0 +1D183..1D184 1 +1D185..1D18B 0 +1D18C..1D1A9 1 +1D1AA..1D1AD 0 +1D1AE..1D241 1 +1D242..1D244 0 +1D245..1D9FF 1 +1DA00..1DA36 0 +1DA37..1DA3A 1 +1DA3B..1DA6C 0 +1DA6D..1DA74 1 +1DA75 0 +1DA76..1DA83 1 +1DA84 0 +1DA85..1DA9A 1 +1DA9B..1DA9F 0 +1DAA0 1 +1DAA1..1DAAF 0 +1DAB0..1DFFF 1 +1E000..1E006 0 +1E007 1 +1E008..1E018 0 +1E019..1E01A 1 +1E01B..1E021 0 +1E022 1 +1E023..1E024 0 +1E025 1 +1E026..1E02A 0 +1E02B..1E08E 1 +1E08F 0 +1E090..1E12F 1 +1E130..1E136 0 +1E137..1E2AD 1 +1E2AE 0 +1E2AF..1E2EB 1 +1E2EC..1E2EF 0 +1E2F0..1E4EB 1 +1E4EC..1E4EF 0 +1E4F0..1E8CF 1 +1E8D0..1E8D6 0 +1E8D7..1E943 1 +1E944..1E94A 0 +1E94B..1F003 1 +1F004 2 +1F005..1F0CE 1 +1F0CF 2 +1F0D0..1F18D 1 +1F18E 2 +1F18F..1F190 1 +1F191..1F19A 2 +1F19B..1F1FF 1 +1F200..1F320 2 +1F321..1F32C 1 +1F32D..1F335 2 +1F336 1 +1F337..1F37C 2 +1F37D 1 +1F37E..1F393 2 +1F394..1F39F 1 +1F3A0..1F3CA 2 +1F3CB..1F3CE 1 +1F3CF..1F3D3 2 +1F3D4..1F3DF 1 +1F3E0..1F3F0 2 +1F3F1..1F3F3 1 +1F3F4 2 +1F3F5..1F3F7 1 +1F3F8..1F43E 2 +1F43F 1 +1F440 2 +1F441 1 +1F442..1F4FC 2 +1F4FD..1F4FE 1 +1F4FF..1F53D 2 +1F53E..1F54A 1 +1F54B..1F54E 2 +1F54F 1 +1F550..1F567 2 +1F568..1F579 1 +1F57A 2 +1F57B..1F594 1 +1F595..1F596 2 +1F597..1F5A3 1 +1F5A4 2 +1F5A5..1F5FA 1 +1F5FB..1F64F 2 +1F650..1F67F 1 +1F680..1F6C5 2 +1F6C6..1F6CB 1 +1F6CC 2 +1F6CD..1F6CF 1 +1F6D0..1F6D2 2 +1F6D3..1F6D4 1 +1F6D5..1F6D7 2 +1F6D8..1F6DC 1 +1F6DD..1F6DF 2 +1F6E0..1F6EA 1 +1F6EB..1F6EC 2 +1F6ED..1F6F3 1 +1F6F4..1F6FC 2 +1F6FD..1F7DF 1 +1F7E0..1F7EB 2 +1F7EC..1F7EF 1 +1F7F0 2 +1F7F1..1F90B 1 +1F90C..1F93A 2 +1F93B 1 +1F93C..1F945 2 +1F946 1 +1F947..1F9FF 2 +1FA00..1FA6F 1 +1FA70..1FA74 2 +1FA75..1FA77 1 +1FA78..1FA7C 2 +1FA7D..1FA7F 1 +1FA80..1FA86 2 +1FA87..1FA8F 1 +1FA90..1FAAC 2 +1FAAD..1FAAF 1 +1FAB0..1FABA 2 +1FABB..1FABF 1 +1FAC0..1FAC5 2 +1FAC6..1FACF 1 +1FAD0..1FAD9 2 +1FADA..1FADF 1 +1FAE0..1FAE7 2 +1FAE8..1FAEF 1 +1FAF0..1FAF6 2 +1FAF7..1FFFF 1 +20000..3FFFF 2 +40000..E0000 1 +E0001 0 +E0002..E001F 1 +E0020..E007F 0 +E0080..E00FF 1 +E0100..E01EF 0 +E01F0..10FFFF 1 +EOF + +: "${DIFF=diff}" +${DIFF} uc_width.ok uc_width.out +result=$? + +rm -fr $tmpfiles + +exit $result diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unlink.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unlink.c new file mode 100644 index 00000000..ca656e39 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unlink.c @@ -0,0 +1,98 @@ +/* Work around unlink bugs. + + Copyright (C) 2009-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +#include + +#include +#include +#include +#include + +#include "filename.h" + +#undef unlink +#if defined _WIN32 && !defined __CYGWIN__ +# define unlink _unlink +#endif + +/* Remove file NAME. + Return 0 if successful, -1 if not. */ + +int +rpl_unlink (char const *name) +{ + /* Work around Solaris 9 bug where unlink("file/") succeeds. */ + size_t len = strlen (name); + int result = 0; + if (len && ISSLASH (name[len - 1])) + { + /* We can't unlink(2) something if it doesn't exist. If it does + exist, then it resolved to a directory, due to the trailing + slash, and POSIX requires that the unlink attempt to remove + that directory (which would leave the symlink dangling). + Unfortunately, Solaris 9 is one of the platforms where the + root user can unlink directories, and we don't want to + cripple this behavior on real directories, even if it is + seldom needed (at any rate, it's nicer to let coreutils' + unlink(1) give the correct errno for non-root users). But we + don't know whether name was an actual directory, or a symlink + to a directory; and due to the bug of ignoring trailing + slash, Solaris 9 would end up successfully unlinking the + symlink instead of the directory. Technically, we could use + realpath to find the canonical directory name to attempt + deletion on. But that is a lot of work for a corner case; so + we instead just use an lstat on the shortened name, and + reject symlinks with trailing slashes. The root user of + unlink(1) will just have to live with the rule that they + can't delete a directory via a symlink. */ + struct stat st; + result = lstat (name, &st); + if (result == 0 || errno == EOVERFLOW) + { + /* Trailing NUL will overwrite the trailing slash. */ + char *short_name = malloc (len); + if (!short_name) + return -1; + memcpy (short_name, name, len); + while (len && ISSLASH (short_name[len - 1])) + short_name[--len] = '\0'; + if (len && (lstat (short_name, &st) || S_ISLNK (st.st_mode))) + { + free (short_name); + errno = EPERM; + return -1; + } + free (short_name); + result = 0; + } + } + if (!result) + { +#if UNLINK_PARENT_BUG + if (len >= 2 && name[len - 1] == '.' && name[len - 2] == '.' + && (len == 2 || ISSLASH (name[len - 3]))) + { + errno = EISDIR; /* could also use EPERM */ + return -1; + } +#endif + result = unlink (name); + } + return result; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unlinkat.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unlinkat.c new file mode 100644 index 00000000..f797f152 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unlinkat.c @@ -0,0 +1,124 @@ +/* Work around unlinkat bugs on Solaris 9 and Hurd. + + Copyright (C) 2009-2024 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 . */ + +/* Written by Eric Blake. */ + +#include + +#include + +#include +#include +#include +#include + +#include + +#include "filename.h" +#include "openat.h" + +#if HAVE_UNLINKAT + +# undef unlinkat + +/* unlinkat without AT_REMOVEDIR does not honor trailing / on Solaris 9. + Hurd has the same issue. + + unlinkat without AT_REMOVEDIR erroneously ignores ".." on Darwin 14. + + Solve these in a similar manner to unlink. */ + +int +rpl_unlinkat (int fd, char const *name, int flag) +{ + size_t len; + int result = 0; + /* rmdir behavior has no problems with trailing slash. */ + if (flag & AT_REMOVEDIR) + return unlinkat (fd, name, flag); + + len = strlen (name); + if (len && ISSLASH (name[len - 1])) + { + /* See the lengthy comment in unlink.c why we disobey the POSIX + rule of letting unlink("link-to-dir/") attempt to unlink a + directory. */ + struct stat st; + result = fstatat (fd, name, &st, AT_SYMLINK_NOFOLLOW); + if (result == 0 || errno == EOVERFLOW) + { + /* Trailing NUL will overwrite the trailing slash. */ + char *short_name = malloc (len); + if (!short_name) + { + errno = EPERM; + return -1; + } + memcpy (short_name, name, len); + while (len && ISSLASH (short_name[len - 1])) + short_name[--len] = '\0'; + if (len && (fstatat (fd, short_name, &st, AT_SYMLINK_NOFOLLOW) + || S_ISLNK (st.st_mode))) + { + free (short_name); + errno = EPERM; + return -1; + } + free (short_name); + result = 0; + } + } + if (!result) + { +# if UNLINK_PARENT_BUG + if (len >= 2 && name[len - 1] == '.' && name[len - 2] == '.' + && (len == 2 || ISSLASH (name[len - 3]))) + { + errno = EISDIR; /* could also use EPERM */ + return -1; + } +# endif + result = unlinkat (fd, name, flag); + } + return result; +} + +#else /* !HAVE_UNLINKAT */ + +/* Replacement for Solaris' function by the same name. + + First, try to simulate it via (unlink|rmdir) ("/proc/self/fd/FD/FILE"). + Failing that, simulate it via save_cwd/fchdir/(unlink|rmdir)/restore_cwd. + If either the save_cwd or the restore_cwd fails (relatively unlikely), + then give a diagnostic and exit nonzero. + Otherwise, this function works just like Solaris' unlinkat. */ + +# define AT_FUNC_NAME unlinkat +# define AT_FUNC_F1 rmdir +# define AT_FUNC_F2 unlink +# define AT_FUNC_USE_F1_COND AT_REMOVEDIR +# define AT_FUNC_POST_FILE_PARAM_DECLS , int flag +# define AT_FUNC_POST_FILE_ARGS /* empty */ +# include "at-func.c" +# undef AT_FUNC_NAME +# undef AT_FUNC_F1 +# undef AT_FUNC_F2 +# undef AT_FUNC_USE_F1_COND +# undef AT_FUNC_POST_FILE_PARAM_DECLS +# undef AT_FUNC_POST_FILE_ARGS + +#endif /* !HAVE_UNLINKAT */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unlinkdir.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unlinkdir.c new file mode 100644 index 00000000..bb71cb88 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unlinkdir.c @@ -0,0 +1,55 @@ +/* unlinkdir.c - determine whether we can unlink directories + + Copyright (C) 2005-2006, 2009-2024 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 . */ + +/* Written by Paul Eggert, Jim Meyering, and David Bartley. */ + +#include + +#include "unlinkdir.h" +#include "priv-set.h" +#include "root-uid.h" +#include + +#if ! UNLINK_CANNOT_UNLINK_DIR + +/* Return true if we cannot unlink directories, false if we might be + able to unlink directories. */ + +bool +cannot_unlink_dir (void) +{ + static bool initialized; + static bool cannot; + + if (! initialized) + { +# if defined PRIV_SYS_LINKDIR + /* We might be able to unlink directories if we cannot + determine our privileges, or if we have the + PRIV_SYS_LINKDIR privilege. */ + cannot = (priv_set_ismember (PRIV_SYS_LINKDIR) == 0); +# else + /* In traditional Unix, only root can unlink directories. */ + cannot = (geteuid () != ROOT_UID); +# endif + initialized = true; + } + + return cannot; +} + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unlinkdir.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unlinkdir.h new file mode 100644 index 00000000..955ea48b --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/unlinkdir.h @@ -0,0 +1,24 @@ +/* unlinkdir.h - determine (and maybe change) whether we can unlink directories + + Copyright (C) 2005, 2009-2024 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 . */ + +/* Written by Paul Eggert and Jim Meyering. */ + +#if UNLINK_CANNOT_UNLINK_DIR +# define cannot_unlink_dir() true +#else +bool cannot_unlink_dir (void); +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/vasnprintf.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/vasnprintf.c new file mode 100644 index 00000000..544ae62d --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/vasnprintf.c @@ -0,0 +1,6979 @@ +/* vsprintf with automatic memory allocation. + Copyright (C) 1999, 2002-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* This file can be parametrized with the following macros: + VASNPRINTF The name of the function being defined. + FCHAR_T The element type of the format string. + DCHAR_T The element type of the destination (result) string. + FCHAR_T_ONLY_ASCII Set to 1 to enable verification that all characters + in the format string are ASCII. MUST be set if + FCHAR_T and DCHAR_T are not the same type. + DIRECTIVE Structure denoting a format directive. + Depends on FCHAR_T. + DIRECTIVES Structure denoting the set of format directives of a + format string. Depends on FCHAR_T. + PRINTF_PARSE Function that parses a format string. + Depends on FCHAR_T. + DCHAR_CPY memcpy like function for DCHAR_T[] arrays. + DCHAR_SET memset like function for DCHAR_T[] arrays. + DCHAR_MBSNLEN mbsnlen like function for DCHAR_T[] arrays. + SNPRINTF The system's snprintf (or similar) function. + This may be either snprintf or swprintf. + TCHAR_T The element type of the argument and result string + of the said SNPRINTF function. This may be either + char or wchar_t. The code exploits that + sizeof (TCHAR_T) | sizeof (DCHAR_T) and + alignof (TCHAR_T) <= alignof (DCHAR_T). + DCHAR_IS_TCHAR Set to 1 if DCHAR_T and TCHAR_T are the same type. + DCHAR_CONV_FROM_ENCODING A function to convert from char[] to DCHAR[]. + DCHAR_IS_UINT8_T Set to 1 if DCHAR_T is uint8_t. + DCHAR_IS_UINT16_T Set to 1 if DCHAR_T is uint16_t. + DCHAR_IS_UINT32_T Set to 1 if DCHAR_T is uint32_t. + ENABLE_UNISTDIO Set to 1 to enable the unistdio extensions. + ENABLE_WCHAR_FALLBACK Set to 1 to avoid EILSEQ during conversion of wide + characters (wchar_t) and wide character strings + (wchar_t[]) to multibyte sequences. The fallback is the + hexadecimal escape syntax (\unnnn or \Unnnnnnnn) or, + if wchar_t is not Unicode encoded, \wnnnn or \Wnnnnnnnn. + */ + +/* Tell glibc's to provide a prototype for snprintf(). + This must come before because may include + , and once has been included, it's too late. */ +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +#endif + +#ifndef VASNPRINTF +# include +#endif + +/* As of GCC 11.2.1, gcc -Wanalyzer-too-complex reports that main's + use of CHECK macros expands to code that is too complicated for gcc + -fanalyzer. Suppress the resulting bogus warnings. */ +#if 10 <= __GNUC__ +# pragma GCC diagnostic ignored "-Wanalyzer-null-argument" +#endif + +#include + +/* Specification. */ +#ifndef VASNPRINTF +# if WIDE_CHAR_VERSION +# include "vasnwprintf.h" +# else +# include "vasnprintf.h" +# endif +#endif + +#include /* localeconv() */ +#include /* snprintf(), sprintf() */ +#include /* abort(), malloc(), realloc(), free() */ +#include /* memcpy(), strlen() */ +#include /* mbstate_t, mbrtowc(), mbrlen(), wcrtomb(), mbszero() */ +#include /* errno */ +#include /* CHAR_BIT, INT_WIDTH, LONG_WIDTH */ +#include /* DBL_MAX_EXP, LDBL_MAX_EXP */ +#if HAVE_NL_LANGINFO +# include +#endif +#ifndef VASNPRINTF +# if WIDE_CHAR_VERSION +# include "wprintf-parse.h" +# else +# include "printf-parse.h" +# endif +#endif + +/* Checked size_t computations. */ +#include "xsize.h" + +#include "attribute.h" + +#if NEED_PRINTF_DOUBLE || NEED_PRINTF_LONG_DOUBLE || (NEED_WPRINTF_DIRECTIVE_LA && WIDE_CHAR_VERSION) +# include +# include "float+.h" +#endif + +#if NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE +# include +# include "isnand-nolibm.h" +#endif + +#if NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE || (NEED_WPRINTF_DIRECTIVE_LA && WIDE_CHAR_VERSION) +# include +# include "isnanl-nolibm.h" +# include "fpucw.h" +#endif + +#if NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_DOUBLE +# include +# include "isnand-nolibm.h" +# include "printf-frexp.h" +#endif + +#if NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE || (NEED_WPRINTF_DIRECTIVE_LA && WIDE_CHAR_VERSION) +# include +# include "isnanl-nolibm.h" +# include "printf-frexpl.h" +# include "fpucw.h" +#endif + +/* Default parameters. */ +#ifndef VASNPRINTF +# if WIDE_CHAR_VERSION +# define VASNPRINTF vasnwprintf +# define FCHAR_T wchar_t +# define DCHAR_T wchar_t +# define DIRECTIVE wchar_t_directive +# define DIRECTIVES wchar_t_directives +# define PRINTF_PARSE wprintf_parse +# define DCHAR_CPY wmemcpy +# define DCHAR_SET wmemset +# else +# define VASNPRINTF vasnprintf +# define FCHAR_T char +# define DCHAR_T char +# define TCHAR_T char +# define DCHAR_IS_TCHAR 1 +# define DIRECTIVE char_directive +# define DIRECTIVES char_directives +# define PRINTF_PARSE printf_parse +# define DCHAR_CPY memcpy +# define DCHAR_SET memset +# endif +#endif +#if WIDE_CHAR_VERSION + /* DCHAR_T is wchar_t. */ +# if HAVE_DECL__SNWPRINTF || (HAVE_SWPRINTF && HAVE_WORKING_SWPRINTF) +# define TCHAR_T wchar_t +# define DCHAR_IS_TCHAR 1 +# define USE_SNPRINTF 1 +# if HAVE_DECL__SNWPRINTF + /* On Windows, the function swprintf() has a different signature than + on Unix; we use the function _snwprintf() or - on mingw - snwprintf() + instead. The mingw function snwprintf() has fewer bugs than the + MSVCRT function _snwprintf(), so prefer that. */ +# if defined __MINGW32__ +# define SNPRINTF snwprintf +# else +# define SNPRINTF _snwprintf +# define USE_MSVC__SNPRINTF 1 +# endif +# else + /* Unix. */ +# define SNPRINTF swprintf +# endif +# else + /* Old platforms such as NetBSD 3.0, OpenBSD 3.8, HP-UX 11.00, IRIX 6.5. */ +# define TCHAR_T char +# endif +#endif +#if !WIDE_CHAR_VERSION || !DCHAR_IS_TCHAR + /* TCHAR_T is char. */ + /* Use snprintf if it exists under the name 'snprintf' or '_snprintf'. + But don't use it on BeOS, since BeOS snprintf produces no output if the + size argument is >= 0x3000000. + Also don't use it on Linux libc5, since there snprintf with size = 1 + writes any output without bounds, like sprintf. */ +# if (HAVE_DECL__SNPRINTF || HAVE_SNPRINTF) && !defined __BEOS__ && !(__GNU_LIBRARY__ == 1) +# define USE_SNPRINTF 1 +# else +# define USE_SNPRINTF 0 +# endif +# if HAVE_DECL__SNPRINTF + /* Windows. The mingw function snprintf() has fewer bugs than the MSVCRT + function _snprintf(), so prefer that. */ +# if defined __MINGW32__ +# define SNPRINTF snprintf + /* Here we need to call the native snprintf, not rpl_snprintf. */ +# undef snprintf +# else + /* MSVC versions < 14 did not have snprintf, only _snprintf. */ +# define SNPRINTF _snprintf +# define USE_MSVC__SNPRINTF 1 +# endif +# else + /* Unix. */ +# define SNPRINTF snprintf + /* Here we need to call the native snprintf, not rpl_snprintf. */ +# undef snprintf +# endif +#endif +/* Here we need to call the native sprintf, not rpl_sprintf. */ +#undef sprintf + +/* GCC >= 4.0 with -Wall emits unjustified "... may be used uninitialized" + warnings in this file. Use -Dlint to suppress them. */ +#if defined GCC_LINT || defined lint +# define IF_LINT(Code) Code +#else +# define IF_LINT(Code) /* empty */ +#endif + +/* Avoid some warnings from "gcc -Wshadow". + This file doesn't use the exp() and remainder() functions. */ +#undef exp +#define exp expo +#undef remainder +#define remainder rem + +#if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF) && !WIDE_CHAR_VERSION +# if (HAVE_STRNLEN && !defined _AIX) +# define local_strnlen strnlen +# else +# ifndef local_strnlen_defined +# define local_strnlen_defined 1 +static size_t +local_strnlen (const char *string, size_t maxlen) +{ + const char *end = memchr (string, '\0', maxlen); + return end ? (size_t) (end - string) : maxlen; +} +# endif +# endif +#endif + +#if (((!USE_SNPRINTF || WIDE_CHAR_VERSION || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || NEED_WPRINTF_DIRECTIVE_LC) && WIDE_CHAR_VERSION) || ((!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || NEED_PRINTF_DIRECTIVE_LS) && !WIDE_CHAR_VERSION && DCHAR_IS_TCHAR)) && HAVE_WCHAR_T +# if HAVE_WCSLEN +# define local_wcslen wcslen +# else + /* Solaris 2.5.1 has wcslen() in a separate library libw.so. To avoid + a dependency towards this library, here is a local substitute. + Define this substitute only once, even if this file is included + twice in the same compilation unit. */ +# ifndef local_wcslen_defined +# define local_wcslen_defined 1 +static size_t +local_wcslen (const wchar_t *s) +{ + const wchar_t *ptr; + + for (ptr = s; *ptr != (wchar_t) 0; ptr++) + ; + return ptr - s; +} +# endif +# endif +#endif + +#if (!USE_SNPRINTF || (WIDE_CHAR_VERSION && DCHAR_IS_TCHAR) || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF) && HAVE_WCHAR_T && WIDE_CHAR_VERSION +# if HAVE_WCSNLEN && HAVE_DECL_WCSNLEN +# define local_wcsnlen wcsnlen +# else +# ifndef local_wcsnlen_defined +# define local_wcsnlen_defined 1 +static size_t +local_wcsnlen (const wchar_t *s, size_t maxlen) +{ + const wchar_t *ptr; + + for (ptr = s; maxlen > 0 && *ptr != (wchar_t) 0; ptr++, maxlen--) + ; + return ptr - s; +} +# endif +# endif +#endif + +#if (((!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || NEED_PRINTF_DIRECTIVE_LS || ENABLE_WCHAR_FALLBACK) && HAVE_WCHAR_T) || ((NEED_PRINTF_DIRECTIVE_LC || ENABLE_WCHAR_FALLBACK) && HAVE_WINT_T)) && !WIDE_CHAR_VERSION +# if ENABLE_WCHAR_FALLBACK +static size_t +wctomb_fallback (char *s, wchar_t wc) +{ + static char const hex[16] = "0123456789ABCDEF"; + + s[0] = '\\'; + if (sizeof (wchar_t) > 2 && wc > 0xffff) + { +# if __STDC_ISO_10646__ || (__GLIBC__ >= 2) || (defined _WIN32 || defined __CYGWIN__) + s[1] = 'U'; +# else + s[1] = 'W'; +# endif + s[2] = hex[(wc & 0xf0000000U) >> 28]; + s[3] = hex[(wc & 0xf000000U) >> 24]; + s[4] = hex[(wc & 0xf00000U) >> 20]; + s[5] = hex[(wc & 0xf0000U) >> 16]; + s[6] = hex[(wc & 0xf000U) >> 12]; + s[7] = hex[(wc & 0xf00U) >> 8]; + s[8] = hex[(wc & 0xf0U) >> 4]; + s[9] = hex[wc & 0xfU]; + return 10; + } + else + { +# if __STDC_ISO_10646__ || (__GLIBC__ >= 2) || (defined _WIN32 || defined __CYGWIN__) + s[1] = 'u'; +# else + s[1] = 'w'; +# endif + s[2] = hex[(wc & 0xf000U) >> 12]; + s[3] = hex[(wc & 0xf00U) >> 8]; + s[4] = hex[(wc & 0xf0U) >> 4]; + s[5] = hex[wc & 0xfU]; + return 6; + } +} +# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t +static size_t +local_wcrtomb (char *s, wchar_t wc, mbstate_t *ps) +{ + size_t count = wcrtomb (s, wc, ps); + if (count == (size_t)(-1)) + count = wctomb_fallback (s, wc); + return count; +} +# else +static int +local_wctomb (char *s, wchar_t wc) +{ + int count = wctomb (s, wc); + if (count < 0) + count = wctomb_fallback (s, wc); + return count; +} +# define local_wcrtomb(S, WC, PS) local_wctomb ((S), (WC)) +# endif +# else +# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t +# define local_wcrtomb(S, WC, PS) wcrtomb ((S), (WC), (PS)) +# else +# define local_wcrtomb(S, WC, PS) wctomb ((S), (WC)) +# endif +# endif +#endif + +#if NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE || NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE || (NEED_WPRINTF_DIRECTIVE_LA && WIDE_CHAR_VERSION) +/* Determine the decimal-point character according to the current locale. */ +# ifndef decimal_point_char_defined +# define decimal_point_char_defined 1 +static char +decimal_point_char (void) +{ + const char *point; + /* Determine it in a multithread-safe way. We know nl_langinfo is + multithread-safe on glibc systems and Mac OS X systems, but is not required + to be multithread-safe by POSIX. sprintf(), however, is multithread-safe. + localeconv() is rarely multithread-safe. */ +# if HAVE_NL_LANGINFO && (__GLIBC__ || defined __UCLIBC__ || (defined __APPLE__ && defined __MACH__)) + point = nl_langinfo (RADIXCHAR); +# elif 1 + char pointbuf[5]; + sprintf (pointbuf, "%#.0f", 1.0); + point = &pointbuf[1]; +# else + point = localeconv () -> decimal_point; +# endif + /* The decimal point is always a single byte: either '.' or ','. */ + return (point[0] != '\0' ? point[0] : '.'); +} +# endif +#endif + +#if NEED_PRINTF_INFINITE_DOUBLE && !NEED_PRINTF_DOUBLE + +/* Equivalent to !isfinite(x) || x == 0, but does not require libm. */ +static int +is_infinite_or_zero (double x) +{ + return isnand (x) || x + x == x; +} + +#endif + +#if NEED_PRINTF_INFINITE_LONG_DOUBLE && !NEED_PRINTF_LONG_DOUBLE + +/* Equivalent to !isfinite(x) || x == 0, but does not require libm. */ +static int +is_infinite_or_zerol (long double x) +{ + return isnanl (x) || x + x == x; +} + +#endif + +#if NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_DOUBLE + +/* Converting 'long double' to decimal without rare rounding bugs requires + real bignums. We use the naming conventions of GNU gmp, but vastly simpler + (and slower) algorithms. */ + +typedef unsigned int mp_limb_t; +# define GMP_LIMB_BITS 32 +static_assert (sizeof (mp_limb_t) * CHAR_BIT == GMP_LIMB_BITS); + +typedef unsigned long long mp_twolimb_t; +# define GMP_TWOLIMB_BITS 64 +static_assert (sizeof (mp_twolimb_t) * CHAR_BIT == GMP_TWOLIMB_BITS); + +/* Representation of a bignum >= 0. */ +typedef struct +{ + size_t nlimbs; + mp_limb_t *limbs; /* Bits in little-endian order, allocated with malloc(). */ +} mpn_t; + +/* Compute the product of two bignums >= 0. + Return the allocated memory in case of success, NULL in case of memory + allocation failure. */ +static void * +multiply (mpn_t src1, mpn_t src2, mpn_t *dest) +{ + const mp_limb_t *p1; + const mp_limb_t *p2; + size_t len1; + size_t len2; + + if (src1.nlimbs <= src2.nlimbs) + { + len1 = src1.nlimbs; + p1 = src1.limbs; + len2 = src2.nlimbs; + p2 = src2.limbs; + } + else + { + len1 = src2.nlimbs; + p1 = src2.limbs; + len2 = src1.nlimbs; + p2 = src1.limbs; + } + /* Now 0 <= len1 <= len2. */ + if (len1 == 0) + { + /* src1 or src2 is zero. */ + dest->nlimbs = 0; + dest->limbs = (mp_limb_t *) malloc (1); + } + else + { + /* Here 1 <= len1 <= len2. */ + size_t dlen; + mp_limb_t *dp; + size_t k, i, j; + + dlen = len1 + len2; + dp = (mp_limb_t *) malloc (dlen * sizeof (mp_limb_t)); + if (dp == NULL) + return NULL; + for (k = len2; k > 0; ) + dp[--k] = 0; + for (i = 0; i < len1; i++) + { + mp_limb_t digit1 = p1[i]; + mp_twolimb_t carry = 0; + for (j = 0; j < len2; j++) + { + mp_limb_t digit2 = p2[j]; + carry += (mp_twolimb_t) digit1 * (mp_twolimb_t) digit2; + carry += dp[i + j]; + dp[i + j] = (mp_limb_t) carry; + carry = carry >> GMP_LIMB_BITS; + } + dp[i + len2] = (mp_limb_t) carry; + } + /* Normalise. */ + while (dlen > 0 && dp[dlen - 1] == 0) + dlen--; + dest->nlimbs = dlen; + dest->limbs = dp; + } + return dest->limbs; +} + +/* Compute the quotient of a bignum a >= 0 and a bignum b > 0. + a is written as a = q * b + r with 0 <= r < b. q is the quotient, r + the remainder. + Finally, round-to-even is performed: If r > b/2 or if r = b/2 and q is odd, + q is incremented. + Return the allocated memory in case of success, NULL in case of memory + allocation failure. */ +static void * +divide (mpn_t a, mpn_t b, mpn_t *q) +{ + /* Algorithm: + First normalise a and b: a=[a[m-1],...,a[0]], b=[b[n-1],...,b[0]] + with m>=0 and n>0 (in base beta = 2^GMP_LIMB_BITS). + If m=n=1, perform a single-precision division: + r:=0, j:=m, + while j>0 do + {Here (q[m-1]*beta^(m-1)+...+q[j]*beta^j) * b[0] + r*beta^j = + = a[m-1]*beta^(m-1)+...+a[j]*beta^j und 0<=r=n>1, perform a multiple-precision division: + We have a/b < beta^(m-n+1). + s:=intDsize-1-(highest bit in b[n-1]), 0<=s=beta/2. + For j=m-n,...,0: {Here 0 <= r < b*beta^(j+1).} + Compute q* : + q* := floor((r[j+n]*beta+r[j+n-1])/b[n-1]). + In case of overflow (q* >= beta) set q* := beta-1. + Compute c2 := ((r[j+n]*beta+r[j+n-1]) - q* * b[n-1])*beta + r[j+n-2] + and c3 := b[n-2] * q*. + {We have 0 <= c2 < 2*beta^2, even 0 <= c2 < beta^2 if no overflow + occurred. Furthermore 0 <= c3 < beta^2. + If there was overflow and + r[j+n]*beta+r[j+n-1] - q* * b[n-1] >= beta, i.e. c2 >= beta^2, + the next test can be skipped.} + While c3 > c2, {Here 0 <= c2 < c3 < beta^2} + Put q* := q* - 1, c2 := c2 + b[n-1]*beta, c3 := c3 - b[n-2]. + If q* > 0: + Put r := r - b * q* * beta^j. In detail: + [r[n+j],...,r[j]] := [r[n+j],...,r[j]] - q* * [b[n-1],...,b[0]]. + hence: u:=0, for i:=0 to n-1 do + u := u + q* * b[i], + r[j+i]:=r[j+i]-(u mod beta) (+ beta, if carry), + u:=u div beta (+ 1, if carry in subtraction) + r[n+j]:=r[n+j]-u. + {Since always u = (q* * [b[i-1],...,b[0]] div beta^i) + 1 + < q* + 1 <= beta, + the carry u does not overflow.} + If a negative carry occurs, put q* := q* - 1 + and [r[n+j],...,r[j]] := [r[n+j],...,r[j]] + [0,b[n-1],...,b[0]]. + Set q[j] := q*. + Normalise [q[m-n],..,q[0]]; this yields the quotient q. + Shift [r[n-1],...,r[0]] right by s bits and normalise; this yields the + rest r. + The room for q[j] can be allocated at the memory location of r[n+j]. + Finally, round-to-even: + Shift r left by 1 bit. + If r > b or if r = b and q[0] is odd, q := q+1. + */ + const mp_limb_t *a_ptr = a.limbs; + size_t a_len = a.nlimbs; + const mp_limb_t *b_ptr = b.limbs; + size_t b_len = b.nlimbs; + mp_limb_t *roomptr; + mp_limb_t *tmp_roomptr = NULL; + mp_limb_t *q_ptr; + size_t q_len; + mp_limb_t *r_ptr; + size_t r_len; + + /* Allocate room for a_len+2 digits. + (Need a_len+1 digits for the real division and 1 more digit for the + final rounding of q.) */ + roomptr = (mp_limb_t *) malloc ((a_len + 2) * sizeof (mp_limb_t)); + if (roomptr == NULL) + return NULL; + + /* Normalise a. */ + while (a_len > 0 && a_ptr[a_len - 1] == 0) + a_len--; + + /* Normalise b. */ + for (;;) + { + if (b_len == 0) + /* Division by zero. */ + abort (); + if (b_ptr[b_len - 1] == 0) + b_len--; + else + break; + } + + /* Here m = a_len >= 0 and n = b_len > 0. */ + + if (a_len < b_len) + { + /* m beta^(m-2) <= a/b < beta^m */ + r_ptr = roomptr; + q_ptr = roomptr + 1; + { + mp_limb_t den = b_ptr[0]; + mp_limb_t remainder = 0; + const mp_limb_t *sourceptr = a_ptr + a_len; + mp_limb_t *destptr = q_ptr + a_len; + size_t count; + for (count = a_len; count > 0; count--) + { + mp_twolimb_t num = + ((mp_twolimb_t) remainder << GMP_LIMB_BITS) | *--sourceptr; + *--destptr = num / den; + remainder = num % den; + } + /* Normalise and store r. */ + if (remainder > 0) + { + r_ptr[0] = remainder; + r_len = 1; + } + else + r_len = 0; + /* Normalise q. */ + q_len = a_len; + if (q_ptr[q_len - 1] == 0) + q_len--; + } + } + else + { + /* n>1: multiple precision division. + beta^(m-1) <= a < beta^m, beta^(n-1) <= b < beta^n ==> + beta^(m-n-1) <= a/b < beta^(m-n+1). */ + /* Determine s. */ + size_t s; + { + mp_limb_t msd = b_ptr[b_len - 1]; /* = b[n-1], > 0 */ + /* Determine s = GMP_LIMB_BITS - integer_length (msd). + Code copied from gnulib's integer_length.c. */ +# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) \ + || (__clang_major__ >= 4) + s = __builtin_clz (msd); +# else +# if defined DBL_EXPBIT0_WORD && defined DBL_EXPBIT0_BIT + if (GMP_LIMB_BITS <= DBL_MANT_BIT) + { + /* Use 'double' operations. + Assumes an IEEE 754 'double' implementation. */ +# define DBL_EXP_MASK ((DBL_MAX_EXP - DBL_MIN_EXP) | 7) +# define DBL_EXP_BIAS (DBL_EXP_MASK / 2 - 1) +# define NWORDS \ + ((sizeof (double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) + union { double value; unsigned int word[NWORDS]; } m; + + /* Use a single integer to floating-point conversion. */ + m.value = msd; + + s = GMP_LIMB_BITS + - (((m.word[DBL_EXPBIT0_WORD] >> DBL_EXPBIT0_BIT) & DBL_EXP_MASK) + - DBL_EXP_BIAS); + } + else +# undef NWORDS +# endif + { + s = 31; + if (msd >= 0x10000) + { + msd = msd >> 16; + s -= 16; + } + if (msd >= 0x100) + { + msd = msd >> 8; + s -= 8; + } + if (msd >= 0x10) + { + msd = msd >> 4; + s -= 4; + } + if (msd >= 0x4) + { + msd = msd >> 2; + s -= 2; + } + if (msd >= 0x2) + { + msd = msd >> 1; + s -= 1; + } + } +# endif + } + /* 0 <= s < GMP_LIMB_BITS. + Copy b, shifting it left by s bits. */ + if (s > 0) + { + tmp_roomptr = (mp_limb_t *) malloc (b_len * sizeof (mp_limb_t)); + if (tmp_roomptr == NULL) + { + free (roomptr); + return NULL; + } + { + const mp_limb_t *sourceptr = b_ptr; + mp_limb_t *destptr = tmp_roomptr; + mp_twolimb_t accu = 0; + size_t count; + for (count = b_len; count > 0; count--) + { + accu += (mp_twolimb_t) *sourceptr++ << s; + *destptr++ = (mp_limb_t) accu; + accu = accu >> GMP_LIMB_BITS; + } + /* accu must be zero, since that was how s was determined. */ + if (accu != 0) + abort (); + } + b_ptr = tmp_roomptr; + } + /* Copy a, shifting it left by s bits, yields r. + Memory layout: + At the beginning: r = roomptr[0..a_len], + at the end: r = roomptr[0..b_len-1], q = roomptr[b_len..a_len] */ + r_ptr = roomptr; + if (s == 0) + { + memcpy (r_ptr, a_ptr, a_len * sizeof (mp_limb_t)); + r_ptr[a_len] = 0; + } + else + { + const mp_limb_t *sourceptr = a_ptr; + mp_limb_t *destptr = r_ptr; + mp_twolimb_t accu = 0; + size_t count; + for (count = a_len; count > 0; count--) + { + accu += (mp_twolimb_t) *sourceptr++ << s; + *destptr++ = (mp_limb_t) accu; + accu = accu >> GMP_LIMB_BITS; + } + *destptr++ = (mp_limb_t) accu; + } + q_ptr = roomptr + b_len; + q_len = a_len - b_len + 1; /* q will have m-n+1 limbs */ + { + size_t j = a_len - b_len; /* m-n */ + mp_limb_t b_msd = b_ptr[b_len - 1]; /* b[n-1] */ + mp_limb_t b_2msd = b_ptr[b_len - 2]; /* b[n-2] */ + mp_twolimb_t b_msdd = /* b[n-1]*beta+b[n-2] */ + ((mp_twolimb_t) b_msd << GMP_LIMB_BITS) | b_2msd; + /* Division loop, traversed m-n+1 times. + j counts down, b is unchanged, beta/2 <= b[n-1] < beta. */ + for (;;) + { + mp_limb_t q_star; + mp_limb_t c1; + if (r_ptr[j + b_len] < b_msd) /* r[j+n] < b[n-1] ? */ + { + /* Divide r[j+n]*beta+r[j+n-1] by b[n-1], no overflow. */ + mp_twolimb_t num = + ((mp_twolimb_t) r_ptr[j + b_len] << GMP_LIMB_BITS) + | r_ptr[j + b_len - 1]; + q_star = num / b_msd; + c1 = num % b_msd; + } + else + { + /* Overflow, hence r[j+n]*beta+r[j+n-1] >= beta*b[n-1]. */ + q_star = (mp_limb_t)~(mp_limb_t)0; /* q* = beta-1 */ + /* Test whether r[j+n]*beta+r[j+n-1] - (beta-1)*b[n-1] >= beta + <==> r[j+n]*beta+r[j+n-1] + b[n-1] >= beta*b[n-1]+beta + <==> b[n-1] < floor((r[j+n]*beta+r[j+n-1]+b[n-1])/beta) + {<= beta !}. + If yes, jump directly to the subtraction loop. + (Otherwise, r[j+n]*beta+r[j+n-1] - (beta-1)*b[n-1] < beta + <==> floor((r[j+n]*beta+r[j+n-1]+b[n-1])/beta) = b[n-1] ) */ + if (r_ptr[j + b_len] > b_msd + || (c1 = r_ptr[j + b_len - 1] + b_msd) < b_msd) + /* r[j+n] >= b[n-1]+1 or + r[j+n] = b[n-1] and the addition r[j+n-1]+b[n-1] gives a + carry. */ + goto subtract; + } + /* q_star = q*, + c1 = (r[j+n]*beta+r[j+n-1]) - q* * b[n-1] (>=0, 0, decrease it by + b[n-1]*beta+b[n-2]. Because of b[n-1]*beta+b[n-2] >= beta^2/2 + this can happen only twice. */ + if (c3 > c2) + { + q_star = q_star - 1; /* q* := q* - 1 */ + if (c3 - c2 > b_msdd) + q_star = q_star - 1; /* q* := q* - 1 */ + } + } + if (q_star > 0) + subtract: + { + /* Subtract r := r - b * q* * beta^j. */ + mp_limb_t cr; + { + const mp_limb_t *sourceptr = b_ptr; + mp_limb_t *destptr = r_ptr + j; + mp_twolimb_t carry = 0; + size_t count; + for (count = b_len; count > 0; count--) + { + /* Here 0 <= carry <= q*. */ + carry = + carry + + (mp_twolimb_t) q_star * (mp_twolimb_t) *sourceptr++ + + (mp_limb_t) ~(*destptr); + /* Here 0 <= carry <= beta*q* + beta-1. */ + *destptr++ = ~(mp_limb_t) carry; + carry = carry >> GMP_LIMB_BITS; /* <= q* */ + } + cr = (mp_limb_t) carry; + } + /* Subtract cr from r_ptr[j + b_len], then forget about + r_ptr[j + b_len]. */ + if (cr > r_ptr[j + b_len]) + { + /* Subtraction gave a carry. */ + q_star = q_star - 1; /* q* := q* - 1 */ + /* Add b back. */ + { + const mp_limb_t *sourceptr = b_ptr; + mp_limb_t *destptr = r_ptr + j; + mp_limb_t carry = 0; + size_t count; + for (count = b_len; count > 0; count--) + { + mp_limb_t source1 = *sourceptr++; + mp_limb_t source2 = *destptr; + *destptr++ = source1 + source2 + carry; + carry = + (carry + ? source1 >= (mp_limb_t) ~source2 + : source1 > (mp_limb_t) ~source2); + } + } + /* Forget about the carry and about r[j+n]. */ + } + } + /* q* is determined. Store it as q[j]. */ + q_ptr[j] = q_star; + if (j == 0) + break; + j--; + } + } + r_len = b_len; + /* Normalise q. */ + if (q_ptr[q_len - 1] == 0) + q_len--; +# if 0 /* Not needed here, since we need r only to compare it with b/2, and + b is shifted left by s bits. */ + /* Shift r right by s bits. */ + if (s > 0) + { + mp_limb_t ptr = r_ptr + r_len; + mp_twolimb_t accu = 0; + size_t count; + for (count = r_len; count > 0; count--) + { + accu = (mp_twolimb_t) (mp_limb_t) accu << GMP_LIMB_BITS; + accu += (mp_twolimb_t) *--ptr << (GMP_LIMB_BITS - s); + *ptr = (mp_limb_t) (accu >> GMP_LIMB_BITS); + } + } +# endif + /* Normalise r. */ + while (r_len > 0 && r_ptr[r_len - 1] == 0) + r_len--; + } + /* Compare r << 1 with b. */ + if (r_len > b_len) + goto increment_q; + { + size_t i; + for (i = b_len;;) + { + mp_limb_t r_i = + (i <= r_len && i > 0 ? r_ptr[i - 1] >> (GMP_LIMB_BITS - 1) : 0) + | (i < r_len ? r_ptr[i] << 1 : 0); + mp_limb_t b_i = (i < b_len ? b_ptr[i] : 0); + if (r_i > b_i) + goto increment_q; + if (r_i < b_i) + goto keep_q; + if (i == 0) + break; + i--; + } + } + if (q_len > 0 && ((q_ptr[0] & 1) != 0)) + /* q is odd. */ + increment_q: + { + size_t i; + for (i = 0; i < q_len; i++) + if (++(q_ptr[i]) != 0) + goto keep_q; + q_ptr[q_len++] = 1; + } + keep_q: + free (tmp_roomptr); + q->limbs = q_ptr; + q->nlimbs = q_len; + return roomptr; +} + +/* Avoid pointless GCC warning "argument 1 value '18446744073709551615' exceeds + maximum object size 9223372036854775807", triggered by the use of xsum as + argument of malloc. */ +# if __GNUC__ >= 7 +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Walloc-size-larger-than=" +# endif + +/* Convert a bignum a >= 0, multiplied with 10^extra_zeroes, to decimal + representation. + Destroys the contents of a. + Return the allocated memory - containing the decimal digits in low-to-high + order, terminated with a NUL character - in case of success, NULL in case + of memory allocation failure. */ +static char * +convert_to_decimal (mpn_t a, size_t extra_zeroes) +{ + mp_limb_t *a_ptr = a.limbs; + size_t a_len = a.nlimbs; + /* 0.03345 is slightly larger than log(2)/(9*log(10)). */ + size_t c_len = 9 * ((size_t)(a_len * (GMP_LIMB_BITS * 0.03345f)) + 1); + /* We need extra_zeroes bytes for zeroes, followed by c_len bytes for the + digits of a, followed by 1 byte for the terminating NUL. */ + char *c_ptr = (char *) malloc (xsum (xsum (extra_zeroes, c_len), 1)); + if (c_ptr != NULL) + { + char *d_ptr = c_ptr; + for (; extra_zeroes > 0; extra_zeroes--) + *d_ptr++ = '0'; + while (a_len > 0) + { + /* Divide a by 10^9, in-place. */ + mp_limb_t remainder = 0; + mp_limb_t *ptr = a_ptr + a_len; + size_t count; + for (count = a_len; count > 0; count--) + { + mp_twolimb_t num = + ((mp_twolimb_t) remainder << GMP_LIMB_BITS) | *--ptr; + *ptr = num / 1000000000; + remainder = num % 1000000000; + } + /* Store the remainder as 9 decimal digits. */ + for (count = 9; count > 0; count--) + { + *d_ptr++ = '0' + (remainder % 10); + remainder = remainder / 10; + } + /* Normalize a. */ + if (a_ptr[a_len - 1] == 0) + a_len--; + } + /* Remove leading zeroes. */ + while (d_ptr > c_ptr && d_ptr[-1] == '0') + d_ptr--; + /* But keep at least one zero. */ + if (d_ptr == c_ptr) + *d_ptr++ = '0'; + /* Terminate the string. */ + *d_ptr = '\0'; + } + return c_ptr; +} + +# if __GNUC__ >= 7 +# pragma GCC diagnostic pop +# endif + +# if NEED_PRINTF_LONG_DOUBLE + +/* Assuming x is finite and >= 0: + write x as x = 2^e * m, where m is a bignum. + Return the allocated memory in case of success, NULL in case of memory + allocation failure. */ +static void * +decode_long_double (long double x, int *ep, mpn_t *mp) +{ + mpn_t m; + int exp; + long double y; + size_t i; + + /* Allocate memory for result. */ + m.nlimbs = (LDBL_MANT_BIT + GMP_LIMB_BITS - 1) / GMP_LIMB_BITS; + m.limbs = (mp_limb_t *) malloc (m.nlimbs * sizeof (mp_limb_t)); + if (m.limbs == NULL) + return NULL; + /* Split into exponential part and mantissa. */ + y = frexpl (x, &exp); + if (!(y >= 0.0L && y < 1.0L)) + abort (); + /* x = 2^exp * y = 2^(exp - LDBL_MANT_BIT) * (y * 2^LDBL_MANT_BIT), and the + latter is an integer. */ + /* Convert the mantissa (y * 2^LDBL_MANT_BIT) to a sequence of limbs. + I'm not sure whether it's safe to cast a 'long double' value between + 2^31 and 2^32 to 'unsigned int', therefore play safe and cast only + 'long double' values between 0 and 2^16 (to 'unsigned int' or 'int', + doesn't matter). */ +# if (LDBL_MANT_BIT % GMP_LIMB_BITS) != 0 +# if (LDBL_MANT_BIT % GMP_LIMB_BITS) > GMP_LIMB_BITS / 2 + { + mp_limb_t hi, lo; + y *= (mp_limb_t) 1 << (LDBL_MANT_BIT % (GMP_LIMB_BITS / 2)); + hi = (int) y; + y -= hi; + if (!(y >= 0.0L && y < 1.0L)) + abort (); + y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2); + lo = (int) y; + y -= lo; + if (!(y >= 0.0L && y < 1.0L)) + abort (); + m.limbs[LDBL_MANT_BIT / GMP_LIMB_BITS] = (hi << (GMP_LIMB_BITS / 2)) | lo; + } +# else + { + mp_limb_t d; + y *= (mp_limb_t) 1 << (LDBL_MANT_BIT % GMP_LIMB_BITS); + d = (int) y; + y -= d; + if (!(y >= 0.0L && y < 1.0L)) + abort (); + m.limbs[LDBL_MANT_BIT / GMP_LIMB_BITS] = d; + } +# endif +# endif + for (i = LDBL_MANT_BIT / GMP_LIMB_BITS; i > 0; ) + { + mp_limb_t hi, lo; + y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2); + hi = (int) y; + y -= hi; + if (!(y >= 0.0L && y < 1.0L)) + abort (); + y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2); + lo = (int) y; + y -= lo; + if (!(y >= 0.0L && y < 1.0L)) + abort (); + m.limbs[--i] = (hi << (GMP_LIMB_BITS / 2)) | lo; + } +# if 0 /* On FreeBSD 6.1/x86, 'long double' numbers sometimes have excess + precision. */ + if (!(y == 0.0L)) + abort (); +# endif + /* Normalise. */ + while (m.nlimbs > 0 && m.limbs[m.nlimbs - 1] == 0) + m.nlimbs--; + *mp = m; + *ep = exp - LDBL_MANT_BIT; + return m.limbs; +} + +# endif + +# if NEED_PRINTF_DOUBLE + +/* Assuming x is finite and >= 0: + write x as x = 2^e * m, where m is a bignum. + Return the allocated memory in case of success, NULL in case of memory + allocation failure. */ +static void * +decode_double (double x, int *ep, mpn_t *mp) +{ + mpn_t m; + int exp; + double y; + size_t i; + + /* Allocate memory for result. */ + m.nlimbs = (DBL_MANT_BIT + GMP_LIMB_BITS - 1) / GMP_LIMB_BITS; + m.limbs = (mp_limb_t *) malloc (m.nlimbs * sizeof (mp_limb_t)); + if (m.limbs == NULL) + return NULL; + /* Split into exponential part and mantissa. */ + y = frexp (x, &exp); + if (!(y >= 0.0 && y < 1.0)) + abort (); + /* x = 2^exp * y = 2^(exp - DBL_MANT_BIT) * (y * 2^DBL_MANT_BIT), and the + latter is an integer. */ + /* Convert the mantissa (y * 2^DBL_MANT_BIT) to a sequence of limbs. + I'm not sure whether it's safe to cast a 'double' value between + 2^31 and 2^32 to 'unsigned int', therefore play safe and cast only + 'double' values between 0 and 2^16 (to 'unsigned int' or 'int', + doesn't matter). */ +# if (DBL_MANT_BIT % GMP_LIMB_BITS) != 0 +# if (DBL_MANT_BIT % GMP_LIMB_BITS) > GMP_LIMB_BITS / 2 + { + mp_limb_t hi, lo; + y *= (mp_limb_t) 1 << (DBL_MANT_BIT % (GMP_LIMB_BITS / 2)); + hi = (int) y; + y -= hi; + if (!(y >= 0.0 && y < 1.0)) + abort (); + y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2); + lo = (int) y; + y -= lo; + if (!(y >= 0.0 && y < 1.0)) + abort (); + m.limbs[DBL_MANT_BIT / GMP_LIMB_BITS] = (hi << (GMP_LIMB_BITS / 2)) | lo; + } +# else + { + mp_limb_t d; + y *= (mp_limb_t) 1 << (DBL_MANT_BIT % GMP_LIMB_BITS); + d = (int) y; + y -= d; + if (!(y >= 0.0 && y < 1.0)) + abort (); + m.limbs[DBL_MANT_BIT / GMP_LIMB_BITS] = d; + } +# endif +# endif + for (i = DBL_MANT_BIT / GMP_LIMB_BITS; i > 0; ) + { + mp_limb_t hi, lo; + y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2); + hi = (int) y; + y -= hi; + if (!(y >= 0.0 && y < 1.0)) + abort (); + y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2); + lo = (int) y; + y -= lo; + if (!(y >= 0.0 && y < 1.0)) + abort (); + m.limbs[--i] = (hi << (GMP_LIMB_BITS / 2)) | lo; + } + if (!(y == 0.0)) + abort (); + /* Normalise. */ + while (m.nlimbs > 0 && m.limbs[m.nlimbs - 1] == 0) + m.nlimbs--; + *mp = m; + *ep = exp - DBL_MANT_BIT; + return m.limbs; +} + +# endif + +/* Assuming x = 2^e * m is finite and >= 0, and n is an integer: + Returns the decimal representation of round (x * 10^n). + Return the allocated memory - containing the decimal digits in low-to-high + order, terminated with a NUL character - in case of success, NULL in case + of memory allocation failure. */ +static char * +scale10_round_decimal_decoded (int e, mpn_t m, void *memory, int n) +{ + int s; + size_t extra_zeroes; + unsigned int abs_n; + unsigned int abs_s; + mp_limb_t *pow5_ptr; + size_t pow5_len; + unsigned int s_limbs; + unsigned int s_bits; + mpn_t pow5; + mpn_t z; + void *z_memory; + char *digits; + + /* x = 2^e * m, hence + y = round (2^e * 10^n * m) = round (2^(e+n) * 5^n * m) + = round (2^s * 5^n * m). */ + s = e + n; + extra_zeroes = 0; + /* Factor out a common power of 10 if possible. */ + if (s > 0 && n > 0) + { + extra_zeroes = (s < n ? s : n); + s -= extra_zeroes; + n -= extra_zeroes; + } + /* Here y = round (2^s * 5^n * m) * 10^extra_zeroes. + Before converting to decimal, we need to compute + z = round (2^s * 5^n * m). */ + /* Compute 5^|n|, possibly shifted by |s| bits if n and s have the same + sign. 2.322 is slightly larger than log(5)/log(2). */ + abs_n = (n >= 0 ? n : -n); + abs_s = (s >= 0 ? s : -s); + pow5_ptr = (mp_limb_t *) malloc (((int)(abs_n * (2.322f / GMP_LIMB_BITS)) + 1 + + abs_s / GMP_LIMB_BITS + 1) + * sizeof (mp_limb_t)); + if (pow5_ptr == NULL) + { + free (memory); + return NULL; + } + /* Initialize with 1. */ + pow5_ptr[0] = 1; + pow5_len = 1; + /* Multiply with 5^|n|. */ + if (abs_n > 0) + { + static mp_limb_t const small_pow5[13 + 1] = + { + 1, 5, 25, 125, 625, 3125, 15625, 78125, 390625, 1953125, 9765625, + 48828125, 244140625, 1220703125 + }; + unsigned int n13; + for (n13 = 0; n13 <= abs_n; n13 += 13) + { + mp_limb_t digit1 = small_pow5[n13 + 13 <= abs_n ? 13 : abs_n - n13]; + size_t j; + mp_twolimb_t carry = 0; + for (j = 0; j < pow5_len; j++) + { + mp_limb_t digit2 = pow5_ptr[j]; + carry += (mp_twolimb_t) digit1 * (mp_twolimb_t) digit2; + pow5_ptr[j] = (mp_limb_t) carry; + carry = carry >> GMP_LIMB_BITS; + } + if (carry > 0) + pow5_ptr[pow5_len++] = (mp_limb_t) carry; + } + } + s_limbs = abs_s / GMP_LIMB_BITS; + s_bits = abs_s % GMP_LIMB_BITS; + if (n >= 0 ? s >= 0 : s <= 0) + { + /* Multiply with 2^|s|. */ + if (s_bits > 0) + { + mp_limb_t *ptr = pow5_ptr; + mp_twolimb_t accu = 0; + size_t count; + for (count = pow5_len; count > 0; count--) + { + accu += (mp_twolimb_t) *ptr << s_bits; + *ptr++ = (mp_limb_t) accu; + accu = accu >> GMP_LIMB_BITS; + } + if (accu > 0) + { + *ptr = (mp_limb_t) accu; + pow5_len++; + } + } + if (s_limbs > 0) + { + size_t count; + for (count = pow5_len; count > 0;) + { + count--; + pow5_ptr[s_limbs + count] = pow5_ptr[count]; + } + for (count = s_limbs; count > 0;) + { + count--; + pow5_ptr[count] = 0; + } + pow5_len += s_limbs; + } + pow5.limbs = pow5_ptr; + pow5.nlimbs = pow5_len; + if (n >= 0) + { + /* Multiply m with pow5. No division needed. */ + z_memory = multiply (m, pow5, &z); + } + else + { + /* Divide m by pow5 and round. */ + z_memory = divide (m, pow5, &z); + } + } + else + { + pow5.limbs = pow5_ptr; + pow5.nlimbs = pow5_len; + if (n >= 0) + { + /* n >= 0, s < 0. + Multiply m with pow5, then divide by 2^|s|. */ + mpn_t numerator; + mpn_t denominator; + void *tmp_memory; + tmp_memory = multiply (m, pow5, &numerator); + if (tmp_memory == NULL) + { + free (pow5_ptr); + free (memory); + return NULL; + } + /* Construct 2^|s|. */ + { + mp_limb_t *ptr = pow5_ptr + pow5_len; + size_t i; + for (i = 0; i < s_limbs; i++) + ptr[i] = 0; + ptr[s_limbs] = (mp_limb_t) 1 << s_bits; + denominator.limbs = ptr; + denominator.nlimbs = s_limbs + 1; + } + z_memory = divide (numerator, denominator, &z); + free (tmp_memory); + } + else + { + /* n < 0, s > 0. + Multiply m with 2^s, then divide by pow5. */ + mpn_t numerator; + mp_limb_t *num_ptr; + num_ptr = (mp_limb_t *) malloc ((m.nlimbs + s_limbs + 1) + * sizeof (mp_limb_t)); + if (num_ptr == NULL) + { + free (pow5_ptr); + free (memory); + return NULL; + } + { + mp_limb_t *destptr = num_ptr; + { + size_t i; + for (i = 0; i < s_limbs; i++) + *destptr++ = 0; + } + if (s_bits > 0) + { + const mp_limb_t *sourceptr = m.limbs; + mp_twolimb_t accu = 0; + size_t count; + for (count = m.nlimbs; count > 0; count--) + { + accu += (mp_twolimb_t) *sourceptr++ << s_bits; + *destptr++ = (mp_limb_t) accu; + accu = accu >> GMP_LIMB_BITS; + } + if (accu > 0) + *destptr++ = (mp_limb_t) accu; + } + else + { + const mp_limb_t *sourceptr = m.limbs; + size_t count; + for (count = m.nlimbs; count > 0; count--) + *destptr++ = *sourceptr++; + } + numerator.limbs = num_ptr; + numerator.nlimbs = destptr - num_ptr; + } + z_memory = divide (numerator, pow5, &z); + free (num_ptr); + } + } + free (pow5_ptr); + free (memory); + + /* Here y = round (x * 10^n) = z * 10^extra_zeroes. */ + + if (z_memory == NULL) + return NULL; + digits = convert_to_decimal (z, extra_zeroes); + free (z_memory); + return digits; +} + +# if NEED_PRINTF_LONG_DOUBLE + +/* Assuming x is finite and >= 0, and n is an integer: + Returns the decimal representation of round (x * 10^n). + Return the allocated memory - containing the decimal digits in low-to-high + order, terminated with a NUL character - in case of success, NULL in case + of memory allocation failure. */ +static char * +scale10_round_decimal_long_double (long double x, int n) +{ + int e; + mpn_t m; + void *memory = decode_long_double (x, &e, &m); + if (memory != NULL) + return scale10_round_decimal_decoded (e, m, memory, n); + else + return NULL; +} + +# endif + +# if NEED_PRINTF_DOUBLE + +/* Assuming x is finite and >= 0, and n is an integer: + Returns the decimal representation of round (x * 10^n). + Return the allocated memory - containing the decimal digits in low-to-high + order, terminated with a NUL character - in case of success, NULL in case + of memory allocation failure. */ +static char * +scale10_round_decimal_double (double x, int n) +{ + int e; + mpn_t m; + void *memory = decode_double (x, &e, &m); + if (memory != NULL) + return scale10_round_decimal_decoded (e, m, memory, n); + else + return NULL; +} + +# endif + +# if NEED_PRINTF_LONG_DOUBLE + +/* Assuming x is finite and > 0: + Return an approximation for n with 10^n <= x < 10^(n+1). + The approximation is usually the right n, but may be off by 1 sometimes. */ +static int +floorlog10l (long double x) +{ + int exp; + long double y; + double z; + double l; + + /* Split into exponential part and mantissa. */ + y = frexpl (x, &exp); + if (!(y >= 0.0L && y < 1.0L)) + abort (); + if (y == 0.0L) + return INT_MIN; + if (y < 0.5L) + { + while (y < (1.0L / (1 << (GMP_LIMB_BITS / 2)) / (1 << (GMP_LIMB_BITS / 2)))) + { + y *= 1.0L * (1 << (GMP_LIMB_BITS / 2)) * (1 << (GMP_LIMB_BITS / 2)); + exp -= GMP_LIMB_BITS; + } + if (y < (1.0L / (1 << 16))) + { + y *= 1.0L * (1 << 16); + exp -= 16; + } + if (y < (1.0L / (1 << 8))) + { + y *= 1.0L * (1 << 8); + exp -= 8; + } + if (y < (1.0L / (1 << 4))) + { + y *= 1.0L * (1 << 4); + exp -= 4; + } + if (y < (1.0L / (1 << 2))) + { + y *= 1.0L * (1 << 2); + exp -= 2; + } + if (y < (1.0L / (1 << 1))) + { + y *= 1.0L * (1 << 1); + exp -= 1; + } + } + if (!(y >= 0.5L && y < 1.0L)) + abort (); + /* Compute an approximation for l = log2(x) = exp + log2(y). */ + l = exp; + z = y; + if (z < 0.70710678118654752444) + { + z *= 1.4142135623730950488; + l -= 0.5; + } + if (z < 0.8408964152537145431) + { + z *= 1.1892071150027210667; + l -= 0.25; + } + if (z < 0.91700404320467123175) + { + z *= 1.0905077326652576592; + l -= 0.125; + } + if (z < 0.9576032806985736469) + { + z *= 1.0442737824274138403; + l -= 0.0625; + } + /* Now 0.95 <= z <= 1.01. */ + z = 1 - z; + /* log2(1-z) = 1/log(2) * (- z - z^2/2 - z^3/3 - z^4/4 - ...) + Four terms are enough to get an approximation with error < 10^-7. */ + l -= 1.4426950408889634074 * z * (1.0 + z * (0.5 + z * ((1.0 / 3) + z * 0.25))); + /* Finally multiply with log(2)/log(10), yields an approximation for + log10(x). */ + l *= 0.30102999566398119523; + /* Round down to the next integer. */ + return (int) l + (l < 0 ? -1 : 0); +} + +# endif + +# if NEED_PRINTF_DOUBLE + +/* Assuming x is finite and > 0: + Return an approximation for n with 10^n <= x < 10^(n+1). + The approximation is usually the right n, but may be off by 1 sometimes. */ +static int +floorlog10 (double x) +{ + int exp; + double y; + double z; + double l; + + /* Split into exponential part and mantissa. */ + y = frexp (x, &exp); + if (!(y >= 0.0 && y < 1.0)) + abort (); + if (y == 0.0) + return INT_MIN; + if (y < 0.5) + { + while (y < (1.0 / (1 << (GMP_LIMB_BITS / 2)) / (1 << (GMP_LIMB_BITS / 2)))) + { + y *= 1.0 * (1 << (GMP_LIMB_BITS / 2)) * (1 << (GMP_LIMB_BITS / 2)); + exp -= GMP_LIMB_BITS; + } + if (y < (1.0 / (1 << 16))) + { + y *= 1.0 * (1 << 16); + exp -= 16; + } + if (y < (1.0 / (1 << 8))) + { + y *= 1.0 * (1 << 8); + exp -= 8; + } + if (y < (1.0 / (1 << 4))) + { + y *= 1.0 * (1 << 4); + exp -= 4; + } + if (y < (1.0 / (1 << 2))) + { + y *= 1.0 * (1 << 2); + exp -= 2; + } + if (y < (1.0 / (1 << 1))) + { + y *= 1.0 * (1 << 1); + exp -= 1; + } + } + if (!(y >= 0.5 && y < 1.0)) + abort (); + /* Compute an approximation for l = log2(x) = exp + log2(y). */ + l = exp; + z = y; + if (z < 0.70710678118654752444) + { + z *= 1.4142135623730950488; + l -= 0.5; + } + if (z < 0.8408964152537145431) + { + z *= 1.1892071150027210667; + l -= 0.25; + } + if (z < 0.91700404320467123175) + { + z *= 1.0905077326652576592; + l -= 0.125; + } + if (z < 0.9576032806985736469) + { + z *= 1.0442737824274138403; + l -= 0.0625; + } + /* Now 0.95 <= z <= 1.01. */ + z = 1 - z; + /* log2(1-z) = 1/log(2) * (- z - z^2/2 - z^3/3 - z^4/4 - ...) + Four terms are enough to get an approximation with error < 10^-7. */ + l -= 1.4426950408889634074 * z * (1.0 + z * (0.5 + z * ((1.0 / 3) + z * 0.25))); + /* Finally multiply with log(2)/log(10), yields an approximation for + log10(x). */ + l *= 0.30102999566398119523; + /* Round down to the next integer. */ + return (int) l + (l < 0 ? -1 : 0); +} + +# endif + +/* Tests whether a string of digits consists of exactly PRECISION zeroes and + a single '1' digit. */ +static int +is_borderline (const char *digits, size_t precision) +{ + for (; precision > 0; precision--, digits++) + if (*digits != '0') + return 0; + if (*digits != '1') + return 0; + digits++; + return *digits == '\0'; +} + +#endif + +#if !USE_SNPRINTF || (WIDE_CHAR_VERSION && DCHAR_IS_TCHAR) || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF + +/* Use a different function name, to make it possible that the 'wchar_t' + parametrization and the 'char' parametrization get compiled in the same + translation unit. */ +# if WIDE_CHAR_VERSION +# define MAX_ROOM_NEEDED wmax_room_needed +# else +# define MAX_ROOM_NEEDED max_room_needed +# endif + +/* Returns the number of TCHAR_T units needed as temporary space for the result + of sprintf or SNPRINTF of a single conversion directive. */ +static size_t +MAX_ROOM_NEEDED (const arguments *ap, size_t arg_index, FCHAR_T conversion, + arg_type type, int flags, size_t width, int has_precision, + size_t precision, int pad_ourselves) +{ + size_t tmp_length; + + switch (conversion) + { + case 'd': case 'i': case 'u': + switch (type) + { + default: + tmp_length = + (unsigned int) (sizeof (unsigned int) * CHAR_BIT + * 0.30103 /* binary -> decimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_LONGINT: + tmp_length = + (unsigned int) (sizeof (long int) * CHAR_BIT + * 0.30103 /* binary -> decimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_ULONGINT: + tmp_length = + (unsigned int) (sizeof (unsigned long int) * CHAR_BIT + * 0.30103 /* binary -> decimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_LONGLONGINT: + tmp_length = + (unsigned int) (sizeof (long long int) * CHAR_BIT + * 0.30103 /* binary -> decimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_ULONGLONGINT: + tmp_length = + (unsigned int) (sizeof (unsigned long long int) * CHAR_BIT + * 0.30103 /* binary -> decimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_INT8_T: + tmp_length = + (unsigned int) (sizeof (int8_t) * CHAR_BIT + * 0.30103 /* binary -> decimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT8_T: + tmp_length = + (unsigned int) (sizeof (uint8_t) * CHAR_BIT + * 0.30103 /* binary -> decimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_INT16_T: + tmp_length = + (unsigned int) (sizeof (int16_t) * CHAR_BIT + * 0.30103 /* binary -> decimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT16_T: + tmp_length = + (unsigned int) (sizeof (uint16_t) * CHAR_BIT + * 0.30103 /* binary -> decimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_INT32_T: + tmp_length = + (unsigned int) (sizeof (int32_t) * CHAR_BIT + * 0.30103 /* binary -> decimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT32_T: + tmp_length = + (unsigned int) (sizeof (uint32_t) * CHAR_BIT + * 0.30103 /* binary -> decimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_INT64_T: + tmp_length = + (unsigned int) (sizeof (int64_t) * CHAR_BIT + * 0.30103 /* binary -> decimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT64_T: + tmp_length = + (unsigned int) (sizeof (uint64_t) * CHAR_BIT + * 0.30103 /* binary -> decimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_INT_FAST8_T: + tmp_length = + (unsigned int) (sizeof (int_fast8_t) * CHAR_BIT + * 0.30103 /* binary -> decimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT_FAST8_T: + tmp_length = + (unsigned int) (sizeof (uint_fast8_t) * CHAR_BIT + * 0.30103 /* binary -> decimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_INT_FAST16_T: + tmp_length = + (unsigned int) (sizeof (int_fast16_t) * CHAR_BIT + * 0.30103 /* binary -> decimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT_FAST16_T: + tmp_length = + (unsigned int) (sizeof (uint_fast16_t) * CHAR_BIT + * 0.30103 /* binary -> decimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_INT_FAST32_T: + tmp_length = + (unsigned int) (sizeof (int_fast32_t) * CHAR_BIT + * 0.30103 /* binary -> decimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT_FAST32_T: + tmp_length = + (unsigned int) (sizeof (uint_fast32_t) * CHAR_BIT + * 0.30103 /* binary -> decimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_INT_FAST64_T: + tmp_length = + (unsigned int) (sizeof (int_fast64_t) * CHAR_BIT + * 0.30103 /* binary -> decimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT_FAST64_T: + tmp_length = + (unsigned int) (sizeof (uint_fast64_t) * CHAR_BIT + * 0.30103 /* binary -> decimal */ + ) + + 1; /* turn floor into ceil */ + break; + } + if (tmp_length < precision) + tmp_length = precision; + /* Multiply by 2, as an estimate for FLAG_GROUP. */ + tmp_length = xsum (tmp_length, tmp_length); + /* Add 1, to account for a leading sign. */ + tmp_length = xsum (tmp_length, 1); + break; + + case 'b': + #if SUPPORT_GNU_PRINTF_DIRECTIVES \ + || (__GLIBC__ + (__GLIBC_MINOR__ >= 35) > 2) + case 'B': + #endif + switch (type) + { + default: + tmp_length = + (unsigned int) (sizeof (unsigned int) * CHAR_BIT) + + 1; /* turn floor into ceil */ + break; + case TYPE_ULONGINT: + tmp_length = + (unsigned int) (sizeof (unsigned long int) * CHAR_BIT) + + 1; /* turn floor into ceil */ + break; + case TYPE_ULONGLONGINT: + tmp_length = + (unsigned int) (sizeof (unsigned long long int) * CHAR_BIT) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT8_T: + tmp_length = + (unsigned int) (sizeof (uint8_t) * CHAR_BIT) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT16_T: + tmp_length = + (unsigned int) (sizeof (uint16_t) * CHAR_BIT) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT32_T: + tmp_length = + (unsigned int) (sizeof (uint32_t) * CHAR_BIT) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT64_T: + tmp_length = + (unsigned int) (sizeof (uint64_t) * CHAR_BIT) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT_FAST8_T: + tmp_length = + (unsigned int) (sizeof (uint_fast8_t) * CHAR_BIT) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT_FAST16_T: + tmp_length = + (unsigned int) (sizeof (uint_fast16_t) * CHAR_BIT) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT_FAST32_T: + tmp_length = + (unsigned int) (sizeof (uint_fast32_t) * CHAR_BIT) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT_FAST64_T: + tmp_length = + (unsigned int) (sizeof (uint_fast64_t) * CHAR_BIT) + + 1; /* turn floor into ceil */ + break; + } + if (tmp_length < precision) + tmp_length = precision; + /* Add 2, to account for a prefix from the alternate form. */ + tmp_length = xsum (tmp_length, 2); + break; + + case 'o': + switch (type) + { + default: + tmp_length = + (unsigned int) (sizeof (unsigned int) * CHAR_BIT + * 0.333334 /* binary -> octal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_ULONGINT: + tmp_length = + (unsigned int) (sizeof (unsigned long int) * CHAR_BIT + * 0.333334 /* binary -> octal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_ULONGLONGINT: + tmp_length = + (unsigned int) (sizeof (unsigned long long int) * CHAR_BIT + * 0.333334 /* binary -> octal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT8_T: + tmp_length = + (unsigned int) (sizeof (uint8_t) * CHAR_BIT + * 0.333334 /* binary -> octal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT16_T: + tmp_length = + (unsigned int) (sizeof (uint16_t) * CHAR_BIT + * 0.333334 /* binary -> octal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT32_T: + tmp_length = + (unsigned int) (sizeof (uint32_t) * CHAR_BIT + * 0.333334 /* binary -> octal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT64_T: + tmp_length = + (unsigned int) (sizeof (uint64_t) * CHAR_BIT + * 0.333334 /* binary -> octal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT_FAST8_T: + tmp_length = + (unsigned int) (sizeof (uint_fast8_t) * CHAR_BIT + * 0.333334 /* binary -> octal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT_FAST16_T: + tmp_length = + (unsigned int) (sizeof (uint_fast16_t) * CHAR_BIT + * 0.333334 /* binary -> octal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT_FAST32_T: + tmp_length = + (unsigned int) (sizeof (uint_fast32_t) * CHAR_BIT + * 0.333334 /* binary -> octal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT_FAST64_T: + tmp_length = + (unsigned int) (sizeof (uint_fast64_t) * CHAR_BIT + * 0.333334 /* binary -> octal */ + ) + + 1; /* turn floor into ceil */ + break; + } + if (tmp_length < precision) + tmp_length = precision; + /* Add 1, to account for a leading sign. */ + tmp_length = xsum (tmp_length, 1); + break; + + case 'x': case 'X': + switch (type) + { + default: + tmp_length = + (unsigned int) (sizeof (unsigned int) * CHAR_BIT + * 0.25 /* binary -> hexadecimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_ULONGINT: + tmp_length = + (unsigned int) (sizeof (unsigned long int) * CHAR_BIT + * 0.25 /* binary -> hexadecimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_ULONGLONGINT: + tmp_length = + (unsigned int) (sizeof (unsigned long long int) * CHAR_BIT + * 0.25 /* binary -> hexadecimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT8_T: + tmp_length = + (unsigned int) (sizeof (uint8_t) * CHAR_BIT + * 0.25 /* binary -> hexadecimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT16_T: + tmp_length = + (unsigned int) (sizeof (uint16_t) * CHAR_BIT + * 0.25 /* binary -> hexadecimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT32_T: + tmp_length = + (unsigned int) (sizeof (uint32_t) * CHAR_BIT + * 0.25 /* binary -> hexadecimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT64_T: + tmp_length = + (unsigned int) (sizeof (uint64_t) * CHAR_BIT + * 0.25 /* binary -> hexadecimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT_FAST8_T: + tmp_length = + (unsigned int) (sizeof (uint_fast8_t) * CHAR_BIT + * 0.25 /* binary -> hexadecimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT_FAST16_T: + tmp_length = + (unsigned int) (sizeof (uint_fast16_t) * CHAR_BIT + * 0.25 /* binary -> hexadecimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT_FAST32_T: + tmp_length = + (unsigned int) (sizeof (uint_fast32_t) * CHAR_BIT + * 0.25 /* binary -> hexadecimal */ + ) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT_FAST64_T: + tmp_length = + (unsigned int) (sizeof (uint_fast64_t) * CHAR_BIT + * 0.25 /* binary -> hexadecimal */ + ) + + 1; /* turn floor into ceil */ + break; + } + if (tmp_length < precision) + tmp_length = precision; + /* Add 2, to account for a prefix from the alternate form. */ + tmp_length = xsum (tmp_length, 2); + break; + + case 'f': case 'F': + if (type == TYPE_LONGDOUBLE) + tmp_length = + (unsigned int) (LDBL_MAX_EXP + * 0.30103 /* binary -> decimal */ + * 2 /* estimate for FLAG_GROUP */ + ) + + 1 /* turn floor into ceil */ + + 10; /* sign, decimal point etc. */ + else + tmp_length = + (unsigned int) (DBL_MAX_EXP + * 0.30103 /* binary -> decimal */ + * 2 /* estimate for FLAG_GROUP */ + ) + + 1 /* turn floor into ceil */ + + 10; /* sign, decimal point etc. */ + tmp_length = xsum (tmp_length, precision); + break; + + case 'e': case 'E': case 'g': case 'G': + tmp_length = + 12; /* sign, decimal point, exponent etc. */ + tmp_length = xsum (tmp_length, precision); + break; + + case 'a': case 'A': + if (type == TYPE_LONGDOUBLE) + tmp_length = + (unsigned int) (LDBL_DIG + * 0.831 /* decimal -> hexadecimal */ + ) + + 1; /* turn floor into ceil */ + else + tmp_length = + (unsigned int) (DBL_DIG + * 0.831 /* decimal -> hexadecimal */ + ) + + 1; /* turn floor into ceil */ + if (tmp_length < precision) + tmp_length = precision; + /* Account for sign, decimal point etc. */ + tmp_length = xsum (tmp_length, 12); + break; + + case 'c': +# if HAVE_WINT_T && !WIDE_CHAR_VERSION + if (type == TYPE_WIDE_CHAR) + { + tmp_length = MB_CUR_MAX; +# if ENABLE_WCHAR_FALLBACK + if (tmp_length < (sizeof (wchar_t) > 2 ? 10 : 6)) + tmp_length = (sizeof (wchar_t) > 2 ? 10 : 6); +# endif + } + else +# endif + tmp_length = 1; + break; + + case 's': +# if HAVE_WCHAR_T + if (type == TYPE_WIDE_STRING) + { +# if WIDE_CHAR_VERSION + /* ISO C says about %ls in fwprintf: + "If the precision is not specified or is greater than the size + of the array, the array shall contain a null wide character." + So if there is a precision, we must not use wcslen. */ + const wchar_t *arg = ap->arg[arg_index].a.a_wide_string; + + if (has_precision) + tmp_length = local_wcsnlen (arg, precision); + else + tmp_length = local_wcslen (arg); +# else + /* ISO C says about %ls in fprintf: + "If a precision is specified, no more than that many bytes are + written (including shift sequences, if any), and the array + shall contain a null wide character if, to equal the multibyte + character sequence length given by the precision, the function + would need to access a wide character one past the end of the + array." + So if there is a precision, we must not use wcslen. */ + /* This case has already been handled separately in VASNPRINTF. */ + abort (); +# endif + } + else +# endif + { +# if WIDE_CHAR_VERSION + /* ISO C says about %s in fwprintf: + "If the precision is not specified or is greater than the size + of the converted array, the converted array shall contain a + null wide character." + So if there is a precision, we must not use strlen. */ + /* This case has already been handled separately in VASNPRINTF. */ + abort (); +# else + /* ISO C says about %s in fprintf: + "If the precision is not specified or greater than the size of + the array, the array shall contain a null character." + So if there is a precision, we must not use strlen. */ + const char *arg = ap->arg[arg_index].a.a_string; + + if (has_precision) + tmp_length = local_strnlen (arg, precision); + else + tmp_length = strlen (arg); +# endif + } + break; + + case 'p': + tmp_length = + (unsigned int) (sizeof (void *) * CHAR_BIT + * 0.25 /* binary -> hexadecimal */ + ) + + 1 /* turn floor into ceil */ + + 2; /* account for leading 0x */ + break; + + default: + abort (); + } + + if (!pad_ourselves) + { +# if ENABLE_UNISTDIO + /* Padding considers the number of characters, therefore the number of + elements after padding may be + > max (tmp_length, width) + but is certainly + <= tmp_length + width. */ + tmp_length = xsum (tmp_length, width); +# else + /* Padding considers the number of elements, says POSIX. */ + if (tmp_length < width) + tmp_length = width; +# endif + } + + tmp_length = xsum (tmp_length, 1); /* account for trailing NUL */ + + return tmp_length; +} + +#endif + +DCHAR_T * +VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, + const FCHAR_T *format, va_list args) +{ + DIRECTIVES d; + arguments a; + + if (PRINTF_PARSE (format, &d, &a) < 0) + /* errno is already set. */ + return NULL; + + /* Frees the memory allocated by this function. Preserves errno. */ +#define CLEANUP() \ + if (d.dir != d.direct_alloc_dir) \ + free (d.dir); \ + if (a.arg != a.direct_alloc_arg) \ + free (a.arg); + + if (PRINTF_FETCHARGS (args, &a) < 0) + goto fail_1_with_EINVAL; + + { + size_t buf_neededlength; + TCHAR_T *buf; + TCHAR_T *buf_malloced; + const FCHAR_T *cp; + size_t i; + DIRECTIVE *dp; + /* Output string accumulator. */ + DCHAR_T *result; + size_t allocated; + size_t length; + + /* Allocate a small buffer that will hold a directive passed to + sprintf or snprintf. */ + buf_neededlength = + xsum4 (7, d.max_width_length, d.max_precision_length, 6); +#if HAVE_ALLOCA + if (buf_neededlength < 4000 / sizeof (TCHAR_T)) + { + buf = (TCHAR_T *) alloca (buf_neededlength * sizeof (TCHAR_T)); + buf_malloced = NULL; + } + else +#endif + { + size_t buf_memsize = xtimes (buf_neededlength, sizeof (TCHAR_T)); + if (size_overflow_p (buf_memsize)) + goto out_of_memory_1; + buf = (TCHAR_T *) malloc (buf_memsize); + if (buf == NULL) + goto out_of_memory_1; + buf_malloced = buf; + } + + result = resultbuf; + allocated = (resultbuf != NULL ? *lengthp : 0); + length = 0; + /* Invariants: + result is either == resultbuf or malloc-allocated. + If result == NULL, resultbuf is == NULL as well. + If length > 0, then result != NULL. */ + + /* Ensures that allocated >= needed. Aborts through a jump to + out_of_memory if needed is SIZE_MAX or otherwise too big. */ +#define ENSURE_ALLOCATION_ELSE(needed, oom_statement) \ + if ((needed) > allocated) \ + { \ + size_t memory_size; \ + DCHAR_T *memory; \ + \ + allocated = (allocated > 0 ? xtimes (allocated, 2) : 12); \ + if ((needed) > allocated) \ + allocated = (needed); \ + memory_size = xtimes (allocated, sizeof (DCHAR_T)); \ + if (size_overflow_p (memory_size)) \ + oom_statement \ + if (result == resultbuf) \ + memory = (DCHAR_T *) malloc (memory_size); \ + else \ + memory = (DCHAR_T *) realloc (result, memory_size); \ + if (memory == NULL) \ + oom_statement \ + if (result == resultbuf && length > 0) \ + DCHAR_CPY (memory, result, length); \ + result = memory; \ + } +#define ENSURE_ALLOCATION(needed) \ + ENSURE_ALLOCATION_ELSE((needed), goto out_of_memory; ) + + for (cp = format, i = 0, dp = &d.dir[0]; ; cp = dp->dir_end, i++, dp++) + { + if (cp != dp->dir_start) + { + size_t n = dp->dir_start - cp; + size_t augmented_length = xsum (length, n); + + ENSURE_ALLOCATION (augmented_length); + /* This copies a piece of FCHAR_T[] into a DCHAR_T[]. Here we + need that the format string contains only ASCII characters + if FCHAR_T and DCHAR_T are not the same type. */ + if (sizeof (FCHAR_T) == sizeof (DCHAR_T)) + { + DCHAR_CPY (result + length, (const DCHAR_T *) cp, n); + length = augmented_length; + } + else + { + do + result[length++] = *cp++; + while (--n > 0); + } + } + if (i == d.count) + break; + + /* Execute a single directive. */ + if (dp->conversion == '%') + { + size_t augmented_length; + + if (!(dp->arg_index == ARG_NONE)) + abort (); + augmented_length = xsum (length, 1); + ENSURE_ALLOCATION (augmented_length); + result[length] = '%'; + length = augmented_length; + } + else + { + if (!(dp->arg_index != ARG_NONE)) + abort (); + + if (dp->conversion == 'n') + { + switch (a.arg[dp->arg_index].type) + { + case TYPE_COUNT_SCHAR_POINTER: + *a.arg[dp->arg_index].a.a_count_schar_pointer = length; + break; + case TYPE_COUNT_SHORT_POINTER: + *a.arg[dp->arg_index].a.a_count_short_pointer = length; + break; + case TYPE_COUNT_INT_POINTER: + *a.arg[dp->arg_index].a.a_count_int_pointer = length; + break; + case TYPE_COUNT_LONGINT_POINTER: + *a.arg[dp->arg_index].a.a_count_longint_pointer = length; + break; + case TYPE_COUNT_LONGLONGINT_POINTER: + *a.arg[dp->arg_index].a.a_count_longlongint_pointer = length; + break; + case TYPE_COUNT_INT8_T_POINTER: + *a.arg[dp->arg_index].a.a_count_int8_t_pointer = length; + break; + case TYPE_COUNT_INT16_T_POINTER: + *a.arg[dp->arg_index].a.a_count_int16_t_pointer = length; + break; + case TYPE_COUNT_INT32_T_POINTER: + *a.arg[dp->arg_index].a.a_count_int32_t_pointer = length; + break; + case TYPE_COUNT_INT64_T_POINTER: + *a.arg[dp->arg_index].a.a_count_int64_t_pointer = length; + break; + case TYPE_COUNT_INT_FAST8_T_POINTER: + *a.arg[dp->arg_index].a.a_count_int_fast8_t_pointer = length; + break; + case TYPE_COUNT_INT_FAST16_T_POINTER: + *a.arg[dp->arg_index].a.a_count_int_fast16_t_pointer = length; + break; + case TYPE_COUNT_INT_FAST32_T_POINTER: + *a.arg[dp->arg_index].a.a_count_int_fast32_t_pointer = length; + break; + case TYPE_COUNT_INT_FAST64_T_POINTER: + *a.arg[dp->arg_index].a.a_count_int_fast64_t_pointer = length; + break; + default: + abort (); + } + } +#if ENABLE_UNISTDIO + /* The unistdio extensions. */ + else if (dp->conversion == 'U') + { + arg_type type = a.arg[dp->arg_index].type; + int flags = dp->flags; + int has_width; + size_t width; + int has_precision; + size_t precision; + + has_width = 0; + width = 0; + if (dp->width_start != dp->width_end) + { + if (dp->width_arg_index != ARG_NONE) + { + int arg; + + if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) + abort (); + arg = a.arg[dp->width_arg_index].a.a_int; + width = arg; + if (arg < 0) + { + /* "A negative field width is taken as a '-' flag + followed by a positive field width." */ + flags |= FLAG_LEFT; + width = -width; + } + } + else + { + const FCHAR_T *digitp = dp->width_start; + + do + width = xsum (xtimes (width, 10), *digitp++ - '0'); + while (digitp != dp->width_end); + } + has_width = 1; + } + + has_precision = 0; + precision = 0; + if (dp->precision_start != dp->precision_end) + { + if (dp->precision_arg_index != ARG_NONE) + { + int arg; + + if (!(a.arg[dp->precision_arg_index].type == TYPE_INT)) + abort (); + arg = a.arg[dp->precision_arg_index].a.a_int; + /* "A negative precision is taken as if the precision + were omitted." */ + if (arg >= 0) + { + precision = arg; + has_precision = 1; + } + } + else + { + const FCHAR_T *digitp = dp->precision_start + 1; + + precision = 0; + while (digitp != dp->precision_end) + precision = xsum (xtimes (precision, 10), *digitp++ - '0'); + has_precision = 1; + } + } + + switch (type) + { + case TYPE_U8_STRING: + { + const uint8_t *arg = a.arg[dp->arg_index].a.a_u8_string; + const uint8_t *arg_end; + size_t characters; + + if (has_precision) + { + /* Use only PRECISION characters, from the left. */ + arg_end = arg; + characters = 0; + for (; precision > 0; precision--) + { + int count = u8_strmblen (arg_end); + if (count == 0) + break; + if (count < 0) + goto fail_with_EILSEQ; + arg_end += count; + characters++; + } + } + else if (has_width) + { + /* Use the entire string, and count the number of + characters. */ + arg_end = arg; + characters = 0; + for (;;) + { + int count = u8_strmblen (arg_end); + if (count == 0) + break; + if (count < 0) + goto fail_with_EILSEQ; + arg_end += count; + characters++; + } + } + else + { + /* Use the entire string. */ + arg_end = arg + u8_strlen (arg); + /* The number of characters doesn't matter. */ + characters = 0; + } + + if (characters < width && !(flags & FLAG_LEFT)) + { + size_t n = width - characters; + ENSURE_ALLOCATION (xsum (length, n)); + DCHAR_SET (result + length, ' ', n); + length += n; + } + +# if DCHAR_IS_UINT8_T + { + size_t n = arg_end - arg; + ENSURE_ALLOCATION (xsum (length, n)); + DCHAR_CPY (result + length, arg, n); + length += n; + } +# else + { /* Convert. */ + DCHAR_T *converted = result + length; + size_t converted_len = allocated - length; +# if DCHAR_IS_TCHAR + /* Convert from UTF-8 to locale encoding. */ + converted = + u8_conv_to_encoding (locale_charset (), + iconveh_question_mark, + arg, arg_end - arg, NULL, + converted, &converted_len); +# else + /* Convert from UTF-8 to UTF-16/UTF-32. */ + converted = + U8_TO_DCHAR (arg, arg_end - arg, + converted, &converted_len); +# endif + if (converted == NULL) + goto fail_with_errno; + if (converted != result + length) + { + ENSURE_ALLOCATION_ELSE (xsum (length, converted_len), + { free (converted); goto out_of_memory; }); + DCHAR_CPY (result + length, converted, converted_len); + free (converted); + } + length += converted_len; + } +# endif + + if (characters < width && (flags & FLAG_LEFT)) + { + size_t n = width - characters; + ENSURE_ALLOCATION (xsum (length, n)); + DCHAR_SET (result + length, ' ', n); + length += n; + } + } + break; + + case TYPE_U16_STRING: + { + const uint16_t *arg = a.arg[dp->arg_index].a.a_u16_string; + const uint16_t *arg_end; + size_t characters; + + if (has_precision) + { + /* Use only PRECISION characters, from the left. */ + arg_end = arg; + characters = 0; + for (; precision > 0; precision--) + { + int count = u16_strmblen (arg_end); + if (count == 0) + break; + if (count < 0) + goto fail_with_EILSEQ; + arg_end += count; + characters++; + } + } + else if (has_width) + { + /* Use the entire string, and count the number of + characters. */ + arg_end = arg; + characters = 0; + for (;;) + { + int count = u16_strmblen (arg_end); + if (count == 0) + break; + if (count < 0) + goto fail_with_EILSEQ; + arg_end += count; + characters++; + } + } + else + { + /* Use the entire string. */ + arg_end = arg + u16_strlen (arg); + /* The number of characters doesn't matter. */ + characters = 0; + } + + if (characters < width && !(flags & FLAG_LEFT)) + { + size_t n = width - characters; + ENSURE_ALLOCATION (xsum (length, n)); + DCHAR_SET (result + length, ' ', n); + length += n; + } + +# if DCHAR_IS_UINT16_T + { + size_t n = arg_end - arg; + ENSURE_ALLOCATION (xsum (length, n)); + DCHAR_CPY (result + length, arg, n); + length += n; + } +# else + { /* Convert. */ + DCHAR_T *converted = result + length; + size_t converted_len = allocated - length; +# if DCHAR_IS_TCHAR + /* Convert from UTF-16 to locale encoding. */ + converted = + u16_conv_to_encoding (locale_charset (), + iconveh_question_mark, + arg, arg_end - arg, NULL, + converted, &converted_len); +# else + /* Convert from UTF-16 to UTF-8/UTF-32. */ + converted = + U16_TO_DCHAR (arg, arg_end - arg, + converted, &converted_len); +# endif + if (converted == NULL) + goto fail_with_errno; + if (converted != result + length) + { + ENSURE_ALLOCATION_ELSE (xsum (length, converted_len), + { free (converted); goto out_of_memory; }); + DCHAR_CPY (result + length, converted, converted_len); + free (converted); + } + length += converted_len; + } +# endif + + if (characters < width && (flags & FLAG_LEFT)) + { + size_t n = width - characters; + ENSURE_ALLOCATION (xsum (length, n)); + DCHAR_SET (result + length, ' ', n); + length += n; + } + } + break; + + case TYPE_U32_STRING: + { + const uint32_t *arg = a.arg[dp->arg_index].a.a_u32_string; + const uint32_t *arg_end; + size_t characters; + + if (has_precision) + { + /* Use only PRECISION characters, from the left. */ + arg_end = arg; + characters = 0; + for (; precision > 0; precision--) + { + int count = u32_strmblen (arg_end); + if (count == 0) + break; + if (count < 0) + goto fail_with_EILSEQ; + arg_end += count; + characters++; + } + } + else if (has_width) + { + /* Use the entire string, and count the number of + characters. */ + arg_end = arg; + characters = 0; + for (;;) + { + int count = u32_strmblen (arg_end); + if (count == 0) + break; + if (count < 0) + goto fail_with_EILSEQ; + arg_end += count; + characters++; + } + } + else + { + /* Use the entire string. */ + arg_end = arg + u32_strlen (arg); + /* The number of characters doesn't matter. */ + characters = 0; + } + + if (characters < width && !(flags & FLAG_LEFT)) + { + size_t n = width - characters; + ENSURE_ALLOCATION (xsum (length, n)); + DCHAR_SET (result + length, ' ', n); + length += n; + } + +# if DCHAR_IS_UINT32_T + { + size_t n = arg_end - arg; + ENSURE_ALLOCATION (xsum (length, n)); + DCHAR_CPY (result + length, arg, n); + length += n; + } +# else + { /* Convert. */ + DCHAR_T *converted = result + length; + size_t converted_len = allocated - length; +# if DCHAR_IS_TCHAR + /* Convert from UTF-32 to locale encoding. */ + converted = + u32_conv_to_encoding (locale_charset (), + iconveh_question_mark, + arg, arg_end - arg, NULL, + converted, &converted_len); +# else + /* Convert from UTF-32 to UTF-8/UTF-16. */ + converted = + U32_TO_DCHAR (arg, arg_end - arg, + converted, &converted_len); +# endif + if (converted == NULL) + goto fail_with_errno; + if (converted != result + length) + { + ENSURE_ALLOCATION_ELSE (xsum (length, converted_len), + { free (converted); goto out_of_memory; }); + DCHAR_CPY (result + length, converted, converted_len); + free (converted); + } + length += converted_len; + } +# endif + + if (characters < width && (flags & FLAG_LEFT)) + { + size_t n = width - characters; + ENSURE_ALLOCATION (xsum (length, n)); + DCHAR_SET (result + length, ' ', n); + length += n; + } + } + break; + + default: + abort (); + } + } +#endif +#if WIDE_CHAR_VERSION && (!DCHAR_IS_TCHAR || NEED_WPRINTF_DIRECTIVE_LC) + else if ((dp->conversion == 's' + && a.arg[dp->arg_index].type == TYPE_WIDE_STRING) + || (dp->conversion == 'c' + && a.arg[dp->arg_index].type == TYPE_WIDE_CHAR)) + { + /* %ls or %lc in vasnwprintf. See the specification of + fwprintf. */ + /* It would be silly to use snprintf ("%ls", ...) and then + convert back the result from a char[] to a wchar_t[]. + Instead, just copy the argument wchar_t[] to the result. */ + int flags = dp->flags; + size_t width; + + width = 0; + if (dp->width_start != dp->width_end) + { + if (dp->width_arg_index != ARG_NONE) + { + int arg; + + if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) + abort (); + arg = a.arg[dp->width_arg_index].a.a_int; + width = arg; + if (arg < 0) + { + /* "A negative field width is taken as a '-' flag + followed by a positive field width." */ + flags |= FLAG_LEFT; + width = -width; + } + } + else + { + const FCHAR_T *digitp = dp->width_start; + + do + width = xsum (xtimes (width, 10), *digitp++ - '0'); + while (digitp != dp->width_end); + } + } + + { + const wchar_t *ls_arg; + wchar_t lc_arg[1]; + size_t characters; + + if (dp->conversion == 's') + { + int has_precision; + size_t precision; + + has_precision = 0; + precision = 6; + if (dp->precision_start != dp->precision_end) + { + if (dp->precision_arg_index != ARG_NONE) + { + int arg; + + if (!(a.arg[dp->precision_arg_index].type == TYPE_INT)) + abort (); + arg = a.arg[dp->precision_arg_index].a.a_int; + /* "A negative precision is taken as if the precision + were omitted." */ + if (arg >= 0) + { + precision = arg; + has_precision = 1; + } + } + else + { + const FCHAR_T *digitp = dp->precision_start + 1; + + precision = 0; + while (digitp != dp->precision_end) + precision = xsum (xtimes (precision, 10), *digitp++ - '0'); + has_precision = 1; + } + } + + ls_arg = a.arg[dp->arg_index].a.a_wide_string; + + if (has_precision) + { + /* Use only at most PRECISION wide characters, from + the left. */ + const wchar_t *ls_arg_end; + + ls_arg_end = ls_arg; + characters = 0; + for (; precision > 0; precision--) + { + if (*ls_arg_end == 0) + /* Found the terminating null wide character. */ + break; + ls_arg_end++; + characters++; + } + } + else + { + /* Use the entire string, and count the number of wide + characters. */ + characters = local_wcslen (ls_arg); + } + } + else /* dp->conversion == 'c' */ + { + lc_arg[0] = (wchar_t) a.arg[dp->arg_index].a.a_wide_char; + ls_arg = lc_arg; + characters = 1; + } + + { + size_t total = (characters < width ? width : characters); + ENSURE_ALLOCATION (xsum (length, total)); + + if (characters < width && !(flags & FLAG_LEFT)) + { + size_t n = width - characters; + DCHAR_SET (result + length, ' ', n); + length += n; + } + + if (characters > 0) + { + DCHAR_CPY (result + length, ls_arg, characters); + length += characters; + } + + if (characters < width && (flags & FLAG_LEFT)) + { + size_t n = width - characters; + DCHAR_SET (result + length, ' ', n); + length += n; + } + } + } + } +#endif +#if (!USE_SNPRINTF || WIDE_CHAR_VERSION || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || NEED_PRINTF_DIRECTIVE_LS || ENABLE_WCHAR_FALLBACK) && HAVE_WCHAR_T + else if (dp->conversion == 's' +# if WIDE_CHAR_VERSION + && a.arg[dp->arg_index].type != TYPE_WIDE_STRING +# else + && a.arg[dp->arg_index].type == TYPE_WIDE_STRING +# endif + ) + { + /* The normal handling of the 's' directive below requires + allocating a temporary buffer. The determination of its + length (tmp_length), in the case when a precision is + specified, below requires a conversion between a char[] + string and a wchar_t[] wide string. It could be done, but + we have no guarantee that the implementation of sprintf will + use the exactly same algorithm. Without this guarantee, it + is possible to have buffer overrun bugs. In order to avoid + such bugs, we implement the entire processing of the 's' + directive ourselves. */ + int flags = dp->flags; + int has_width; + size_t width; + int has_precision; + size_t precision; + + has_width = 0; + width = 0; + if (dp->width_start != dp->width_end) + { + if (dp->width_arg_index != ARG_NONE) + { + int arg; + + if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) + abort (); + arg = a.arg[dp->width_arg_index].a.a_int; + width = arg; + if (arg < 0) + { + /* "A negative field width is taken as a '-' flag + followed by a positive field width." */ + flags |= FLAG_LEFT; + width = -width; + } + } + else + { + const FCHAR_T *digitp = dp->width_start; + + do + width = xsum (xtimes (width, 10), *digitp++ - '0'); + while (digitp != dp->width_end); + } + has_width = 1; + } + + has_precision = 0; + precision = 6; + if (dp->precision_start != dp->precision_end) + { + if (dp->precision_arg_index != ARG_NONE) + { + int arg; + + if (!(a.arg[dp->precision_arg_index].type == TYPE_INT)) + abort (); + arg = a.arg[dp->precision_arg_index].a.a_int; + /* "A negative precision is taken as if the precision + were omitted." */ + if (arg >= 0) + { + precision = arg; + has_precision = 1; + } + } + else + { + const FCHAR_T *digitp = dp->precision_start + 1; + + precision = 0; + while (digitp != dp->precision_end) + precision = xsum (xtimes (precision, 10), *digitp++ - '0'); + has_precision = 1; + } + } + +# if WIDE_CHAR_VERSION + /* %s in vasnwprintf. See the specification of fwprintf. */ + { + const char *arg = a.arg[dp->arg_index].a.a_string; + const char *arg_end; + size_t characters; + + if (has_precision) + { + /* Use only as many bytes as needed to produce PRECISION + wide characters, from the left. */ +# if HAVE_MBRTOWC + mbstate_t state; + mbszero (&state); +# endif + arg_end = arg; + characters = 0; + for (; precision > 0; precision--) + { + int count; +# if HAVE_MBRTOWC + count = mbrlen (arg_end, MB_CUR_MAX, &state); +# else + count = mblen (arg_end, MB_CUR_MAX); +# endif + if (count == 0) + /* Found the terminating NUL. */ + break; + if (count < 0) + /* Invalid or incomplete multibyte character. */ + goto fail_with_EILSEQ; + arg_end += count; + characters++; + } + } + else if (has_width) + { + /* Use the entire string, and count the number of wide + characters. */ +# if HAVE_MBRTOWC + mbstate_t state; + mbszero (&state); +# endif + arg_end = arg; + characters = 0; + for (;;) + { + int count; +# if HAVE_MBRTOWC + count = mbrlen (arg_end, MB_CUR_MAX, &state); +# else + count = mblen (arg_end, MB_CUR_MAX); +# endif + if (count == 0) + /* Found the terminating NUL. */ + break; + if (count < 0) + /* Invalid or incomplete multibyte character. */ + goto fail_with_EILSEQ; + arg_end += count; + characters++; + } + } + else + { + /* Use the entire string. */ + arg_end = arg + strlen (arg); + /* The number of characters doesn't matter. */ + characters = 0; + } + + if (characters < width && !(flags & FLAG_LEFT)) + { + size_t n = width - characters; + ENSURE_ALLOCATION (xsum (length, n)); + DCHAR_SET (result + length, ' ', n); + length += n; + } + + if (has_precision || has_width) + { + /* We know the number of wide characters in advance. */ + size_t remaining; +# if HAVE_MBRTOWC + mbstate_t state; + mbszero (&state); +# endif + ENSURE_ALLOCATION (xsum (length, characters)); + for (remaining = characters; remaining > 0; remaining--) + { + wchar_t wc; + int count; +# if HAVE_MBRTOWC + count = mbrtowc (&wc, arg, arg_end - arg, &state); +# else + count = mbtowc (&wc, arg, arg_end - arg); +# endif + if (count <= 0) + /* mbrtowc not consistent with mbrlen, or mbtowc + not consistent with mblen. */ + abort (); + result[length++] = wc; + arg += count; + } + if (!(arg == arg_end)) + abort (); + } + else + { +# if HAVE_MBRTOWC + mbstate_t state; + mbszero (&state); +# endif + while (arg < arg_end) + { + wchar_t wc; + int count; +# if HAVE_MBRTOWC + count = mbrtowc (&wc, arg, arg_end - arg, &state); +# else + count = mbtowc (&wc, arg, arg_end - arg); +# endif + if (count == 0) + /* mbrtowc not consistent with strlen. */ + abort (); + if (count < 0) + /* Invalid or incomplete multibyte character. */ + goto fail_with_EILSEQ; + ENSURE_ALLOCATION (xsum (length, 1)); + result[length++] = wc; + arg += count; + } + } + + if (characters < width && (flags & FLAG_LEFT)) + { + size_t n = width - characters; + ENSURE_ALLOCATION (xsum (length, n)); + DCHAR_SET (result + length, ' ', n); + length += n; + } + } +# else + /* %ls in vasnprintf. See the specification of fprintf. */ + { + const wchar_t *arg = a.arg[dp->arg_index].a.a_wide_string; + const wchar_t *arg_end; + size_t characters; +# if !DCHAR_IS_TCHAR + /* This code assumes that TCHAR_T is 'char'. */ + static_assert (sizeof (TCHAR_T) == 1); + TCHAR_T *tmpsrc; + DCHAR_T *tmpdst; + size_t tmpdst_len; +# endif + size_t w; + + if (has_precision) + { + /* Use only as many wide characters as needed to produce + at most PRECISION bytes, from the left. */ +# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t + mbstate_t state; + mbszero (&state); +# endif + arg_end = arg; + characters = 0; + while (precision > 0) + { + char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */ + int count; + + if (*arg_end == 0) + /* Found the terminating null wide character. */ + break; + count = local_wcrtomb (cbuf, *arg_end, &state); + if (count < 0) + /* Cannot convert. */ + goto fail_with_EILSEQ; + if (precision < (unsigned int) count) + break; + arg_end++; + characters += count; + precision -= count; + } + } +# if DCHAR_IS_TCHAR + else if (has_width) +# else + else +# endif + { + /* Use the entire string, and count the number of + bytes. */ +# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t + mbstate_t state; + mbszero (&state); +# endif + arg_end = arg; + characters = 0; + for (;;) + { + char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */ + int count; + + if (*arg_end == 0) + /* Found the terminating null wide character. */ + break; + count = local_wcrtomb (cbuf, *arg_end, &state); + if (count < 0) + /* Cannot convert. */ + goto fail_with_EILSEQ; + arg_end++; + characters += count; + } + } +# if DCHAR_IS_TCHAR + else + { + /* Use the entire string. */ + arg_end = arg + local_wcslen (arg); + /* The number of bytes doesn't matter. */ + characters = 0; + } +# endif + +# if !DCHAR_IS_TCHAR + /* Convert the string into a piece of temporary memory. */ + tmpsrc = (TCHAR_T *) malloc (characters * sizeof (TCHAR_T)); + if (tmpsrc == NULL) + goto out_of_memory; + { + TCHAR_T *tmpptr = tmpsrc; + size_t remaining; +# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t + mbstate_t state; + mbszero (&state); +# endif + for (remaining = characters; remaining > 0; ) + { + char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */ + int count; + + if (*arg == 0) + abort (); + count = local_wcrtomb (cbuf, *arg, &state); + if (count <= 0) + /* Inconsistency. */ + abort (); + memcpy (tmpptr, cbuf, count); + tmpptr += count; + arg++; + remaining -= count; + } + if (!(arg == arg_end)) + abort (); + } + + /* Convert from TCHAR_T[] to DCHAR_T[]. */ + tmpdst = + DCHAR_CONV_FROM_ENCODING (locale_charset (), + iconveh_question_mark, + tmpsrc, characters, + NULL, + NULL, &tmpdst_len); + if (tmpdst == NULL) + { + free (tmpsrc); + goto fail_with_errno; + } + free (tmpsrc); +# endif + + if (has_width) + { +# if ENABLE_UNISTDIO + /* Outside POSIX, it's preferable to compare the width + against the number of _characters_ of the converted + value. */ + w = DCHAR_MBSNLEN (result + length, characters); +# else + /* The width is compared against the number of _bytes_ + of the converted value, says POSIX. */ + w = characters; +# endif + } + else + /* w doesn't matter. */ + w = 0; + + if (w < width && !(flags & FLAG_LEFT)) + { + size_t n = width - w; + ENSURE_ALLOCATION (xsum (length, n)); + DCHAR_SET (result + length, ' ', n); + length += n; + } + +# if DCHAR_IS_TCHAR + if (has_precision || has_width) + { + /* We know the number of bytes in advance. */ + size_t remaining; +# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t + mbstate_t state; + mbszero (&state); +# endif + ENSURE_ALLOCATION (xsum (length, characters)); + for (remaining = characters; remaining > 0; ) + { + char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */ + int count; + + if (*arg == 0) + abort (); + count = local_wcrtomb (cbuf, *arg, &state); + if (count <= 0) + /* Inconsistency. */ + abort (); + memcpy (result + length, cbuf, count); + length += count; + arg++; + remaining -= count; + } + if (!(arg == arg_end)) + abort (); + } + else + { +# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t + mbstate_t state; + mbszero (&state); +# endif + while (arg < arg_end) + { + char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */ + int count; + + if (*arg == 0) + abort (); + count = local_wcrtomb (cbuf, *arg, &state); + if (count <= 0) + /* Cannot convert. */ + goto fail_with_EILSEQ; + ENSURE_ALLOCATION (xsum (length, count)); + memcpy (result + length, cbuf, count); + length += count; + arg++; + } + } +# else + ENSURE_ALLOCATION_ELSE (xsum (length, tmpdst_len), + { free (tmpdst); goto out_of_memory; }); + DCHAR_CPY (result + length, tmpdst, tmpdst_len); + free (tmpdst); + length += tmpdst_len; +# endif + + if (w < width && (flags & FLAG_LEFT)) + { + size_t n = width - w; + ENSURE_ALLOCATION (xsum (length, n)); + DCHAR_SET (result + length, ' ', n); + length += n; + } + } +# endif + } +#endif +#if (NEED_PRINTF_DIRECTIVE_LC || ENABLE_WCHAR_FALLBACK) && HAVE_WINT_T && !WIDE_CHAR_VERSION + else if (dp->conversion == 'c' + && a.arg[dp->arg_index].type == TYPE_WIDE_CHAR) + { + /* Implement the 'lc' directive ourselves, in order to provide + a correct behaviour for the null wint_t argument and/or the + fallback that avoids EILSEQ. */ + int flags = dp->flags; + int has_width; + size_t width; + + has_width = 0; + width = 0; + if (dp->width_start != dp->width_end) + { + if (dp->width_arg_index != ARG_NONE) + { + int arg; + + if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) + abort (); + arg = a.arg[dp->width_arg_index].a.a_int; + width = arg; + if (arg < 0) + { + /* "A negative field width is taken as a '-' flag + followed by a positive field width." */ + flags |= FLAG_LEFT; + width = -width; + } + } + else + { + const FCHAR_T *digitp = dp->width_start; + + do + width = xsum (xtimes (width, 10), *digitp++ - '0'); + while (digitp != dp->width_end); + } + has_width = 1; + } + + /* %lc in vasnprintf. See the specification of fprintf. */ + { + wchar_t arg = (wchar_t) a.arg[dp->arg_index].a.a_wide_char; + size_t characters; +# if !DCHAR_IS_TCHAR + /* This code assumes that TCHAR_T is 'char'. */ + static_assert (sizeof (TCHAR_T) == 1); + TCHAR_T tmpsrc[64]; /* Assume MB_CUR_MAX <= 64. */ + DCHAR_T *tmpdst; + size_t tmpdst_len; +# endif + size_t w; + +# if DCHAR_IS_TCHAR + if (has_width) +# endif + { + /* Count the number of bytes. */ + characters = 0; + char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */ + int count; +# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t + mbstate_t state; + mbszero (&state); +# endif + + count = local_wcrtomb (cbuf, arg, &state); + if (count < 0) + /* Cannot convert. */ + goto fail_with_EILSEQ; + characters = count; + } +# if DCHAR_IS_TCHAR + else + { + /* The number of bytes doesn't matter. */ + characters = 0; + } +# endif + +# if !DCHAR_IS_TCHAR + /* Convert the string into a piece of temporary memory. */ + if (characters > 0) + { + char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */ + int count; +# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t + mbstate_t state; + mbszero (&state); +# endif + + count = local_wcrtomb (cbuf, arg, &state); + if (count <= 0) + /* Inconsistency. */ + abort (); + memcpy (tmpsrc, cbuf, count); + } + + /* Convert from TCHAR_T[] to DCHAR_T[]. */ + tmpdst = + DCHAR_CONV_FROM_ENCODING (locale_charset (), + iconveh_question_mark, + tmpsrc, characters, + NULL, + NULL, &tmpdst_len); + if (tmpdst == NULL) + goto fail_with_errno; +# endif + + if (has_width) + { +# if ENABLE_UNISTDIO + /* Outside POSIX, it's preferable to compare the width + against the number of _characters_ of the converted + value. */ + w = DCHAR_MBSNLEN (result + length, characters); +# else + /* The width is compared against the number of _bytes_ + of the converted value, says POSIX. */ + w = characters; +# endif + } + else + /* w doesn't matter. */ + w = 0; + + if (w < width && !(flags & FLAG_LEFT)) + { + size_t n = width - w; + ENSURE_ALLOCATION (xsum (length, n)); + DCHAR_SET (result + length, ' ', n); + length += n; + } + +# if DCHAR_IS_TCHAR + if (has_width) + { + /* We know the number of bytes in advance. */ + ENSURE_ALLOCATION (xsum (length, characters)); + if (characters > 0) + { + int count; +# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t + mbstate_t state; + mbszero (&state); +# endif + + count = local_wcrtomb (result + length, arg, &state); + if (count <= 0) + /* Inconsistency. */ + abort (); + length += count; + } + } + else + { + char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */ + int count; +# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t + mbstate_t state; + mbszero (&state); +# endif + + count = local_wcrtomb (cbuf, arg, &state); + if (count < 0) + /* Cannot convert. */ + goto fail_with_EILSEQ; + ENSURE_ALLOCATION (xsum (length, count)); + memcpy (result + length, cbuf, count); + length += count; + } +# else + ENSURE_ALLOCATION_ELSE (xsum (length, tmpdst_len), + { free (tmpdst); goto out_of_memory; }); + DCHAR_CPY (result + length, tmpdst, tmpdst_len); + free (tmpdst); + length += tmpdst_len; +# endif + + if (w < width && (flags & FLAG_LEFT)) + { + size_t n = width - w; + ENSURE_ALLOCATION (xsum (length, n)); + DCHAR_SET (result + length, ' ', n); + length += n; + } + } + } +#endif +#if NEED_WPRINTF_DIRECTIVE_C && WIDE_CHAR_VERSION + else if (dp->conversion == 'c' + && a.arg[dp->arg_index].type != TYPE_WIDE_CHAR) + { + /* Implement the 'c' directive ourselves, in order to avoid + EILSEQ in the "C" locale. */ + int flags = dp->flags; + size_t width; + + width = 0; + if (dp->width_start != dp->width_end) + { + if (dp->width_arg_index != ARG_NONE) + { + int arg; + + if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) + abort (); + arg = a.arg[dp->width_arg_index].a.a_int; + width = arg; + if (arg < 0) + { + /* "A negative field width is taken as a '-' flag + followed by a positive field width." */ + flags |= FLAG_LEFT; + width = -width; + } + } + else + { + const FCHAR_T *digitp = dp->width_start; + + do + width = xsum (xtimes (width, 10), *digitp++ - '0'); + while (digitp != dp->width_end); + } + } + + /* %c in vasnwprintf. See the specification of fwprintf. */ + { + char arg = (char) a.arg[dp->arg_index].a.a_char; + mbstate_t state; + wchar_t wc; + + mbszero (&state); + int count = mbrtowc (&wc, &arg, 1, &state); + if (count < 0) + /* Invalid or incomplete multibyte character. */ + goto fail_with_EILSEQ; + + if (1 < width && !(flags & FLAG_LEFT)) + { + size_t n = width - 1; + ENSURE_ALLOCATION (xsum (length, n)); + DCHAR_SET (result + length, ' ', n); + length += n; + } + + ENSURE_ALLOCATION (xsum (length, 1)); + result[length++] = wc; + + if (1 < width && (flags & FLAG_LEFT)) + { + size_t n = width - 1; + ENSURE_ALLOCATION (xsum (length, n)); + DCHAR_SET (result + length, ' ', n); + length += n; + } + } + } +#endif +#if NEED_PRINTF_DIRECTIVE_B || NEED_PRINTF_DIRECTIVE_UPPERCASE_B + else if (0 +# if NEED_PRINTF_DIRECTIVE_B + || (dp->conversion == 'b') +# endif +# if NEED_PRINTF_DIRECTIVE_UPPERCASE_B + || (dp->conversion == 'B') +# endif + ) + { + arg_type type = a.arg[dp->arg_index].type; + int flags = dp->flags; + int has_width; + size_t width; + int has_precision; + size_t precision; + size_t tmp_length; + size_t count; + DCHAR_T tmpbuf[700]; + DCHAR_T *tmp; + DCHAR_T *tmp_end; + DCHAR_T *tmp_start; + DCHAR_T *pad_ptr; + DCHAR_T *p; + + has_width = 0; + width = 0; + if (dp->width_start != dp->width_end) + { + if (dp->width_arg_index != ARG_NONE) + { + int arg; + + if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) + abort (); + arg = a.arg[dp->width_arg_index].a.a_int; + width = arg; + if (arg < 0) + { + /* "A negative field width is taken as a '-' flag + followed by a positive field width." */ + flags |= FLAG_LEFT; + width = -width; + } + } + else + { + const FCHAR_T *digitp = dp->width_start; + + do + width = xsum (xtimes (width, 10), *digitp++ - '0'); + while (digitp != dp->width_end); + } + has_width = 1; + } + + has_precision = 0; + precision = 1; + if (dp->precision_start != dp->precision_end) + { + if (dp->precision_arg_index != ARG_NONE) + { + int arg; + + if (!(a.arg[dp->precision_arg_index].type == TYPE_INT)) + abort (); + arg = a.arg[dp->precision_arg_index].a.a_int; + /* "A negative precision is taken as if the precision + were omitted." */ + if (arg >= 0) + { + precision = arg; + has_precision = 1; + } + } + else + { + const FCHAR_T *digitp = dp->precision_start + 1; + + precision = 0; + while (digitp != dp->precision_end) + precision = xsum (xtimes (precision, 10), *digitp++ - '0'); + has_precision = 1; + } + } + + /* Allocate a temporary buffer of sufficient size. */ + switch (type) + { + default: + tmp_length = + (unsigned int) (sizeof (unsigned int) * CHAR_BIT) + + 1; /* turn floor into ceil */ + break; + case TYPE_ULONGINT: + tmp_length = + (unsigned int) (sizeof (unsigned long int) * CHAR_BIT) + + 1; /* turn floor into ceil */ + break; + case TYPE_ULONGLONGINT: + tmp_length = + (unsigned int) (sizeof (unsigned long long int) * CHAR_BIT) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT8_T: + tmp_length = + (unsigned int) (sizeof (uint8_t) * CHAR_BIT) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT16_T: + tmp_length = + (unsigned int) (sizeof (uint16_t) * CHAR_BIT) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT32_T: + tmp_length = + (unsigned int) (sizeof (uint32_t) * CHAR_BIT) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT64_T: + tmp_length = + (unsigned int) (sizeof (uint64_t) * CHAR_BIT) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT_FAST8_T: + tmp_length = + (unsigned int) (sizeof (uint_fast8_t) * CHAR_BIT) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT_FAST16_T: + tmp_length = + (unsigned int) (sizeof (uint_fast16_t) * CHAR_BIT) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT_FAST32_T: + tmp_length = + (unsigned int) (sizeof (uint_fast32_t) * CHAR_BIT) + + 1; /* turn floor into ceil */ + break; + case TYPE_UINT_FAST64_T: + tmp_length = + (unsigned int) (sizeof (uint_fast64_t) * CHAR_BIT) + + 1; /* turn floor into ceil */ + break; + } + if (tmp_length < precision) + tmp_length = precision; + /* Add 2, to account for a prefix from the alternate form. */ + tmp_length = xsum (tmp_length, 2); + + if (tmp_length < width) + tmp_length = width; + + if (tmp_length <= sizeof (tmpbuf) / sizeof (DCHAR_T)) + tmp = tmpbuf; + else + { + size_t tmp_memsize = xtimes (tmp_length, sizeof (DCHAR_T)); + + if (size_overflow_p (tmp_memsize)) + /* Overflow, would lead to out of memory. */ + goto out_of_memory; + tmp = (DCHAR_T *) malloc (tmp_memsize); + if (tmp == NULL) + /* Out of memory. */ + goto out_of_memory; + } + + tmp_end = tmp + tmp_length; + + unsigned long long arg; + switch (type) + { + case TYPE_UCHAR: + arg = a.arg[dp->arg_index].a.a_uchar; + break; + case TYPE_USHORT: + arg = a.arg[dp->arg_index].a.a_ushort; + break; + case TYPE_UINT: + arg = a.arg[dp->arg_index].a.a_uint; + break; + case TYPE_ULONGINT: + arg = a.arg[dp->arg_index].a.a_ulongint; + break; + case TYPE_ULONGLONGINT: + arg = a.arg[dp->arg_index].a.a_ulonglongint; + break; + case TYPE_UINT8_T: + arg = a.arg[dp->arg_index].a.a_uint8_t; + break; + case TYPE_UINT16_T: + arg = a.arg[dp->arg_index].a.a_uint16_t; + break; + case TYPE_UINT32_T: + arg = a.arg[dp->arg_index].a.a_uint32_t; + break; + case TYPE_UINT64_T: + arg = a.arg[dp->arg_index].a.a_uint64_t; + break; + case TYPE_UINT_FAST8_T: + arg = a.arg[dp->arg_index].a.a_uint_fast8_t; + break; + case TYPE_UINT_FAST16_T: + arg = a.arg[dp->arg_index].a.a_uint_fast16_t; + break; + case TYPE_UINT_FAST32_T: + arg = a.arg[dp->arg_index].a.a_uint_fast32_t; + break; + case TYPE_UINT_FAST64_T: + arg = a.arg[dp->arg_index].a.a_uint_fast64_t; + break; + default: + abort (); + } + int need_prefix = ((flags & FLAG_ALT) && arg != 0); + + p = tmp_end; + /* "The result of converting a zero value with a precision + of zero is no characters." */ + if (!(has_precision && precision == 0 && arg == 0)) + { + do + { + *--p = '0' + (arg & 1); + arg = arg >> 1; + } + while (arg != 0); + } + + if (has_precision) + { + DCHAR_T *digits_start = tmp_end - precision; + while (p > digits_start) + *--p = '0'; + } + + pad_ptr = p; + + if (need_prefix) + { +# if NEED_PRINTF_DIRECTIVE_B && !NEED_PRINTF_DIRECTIVE_UPPERCASE_B + *--p = 'b'; +# elif NEED_PRINTF_DIRECTIVE_UPPERCASE_B && !NEED_PRINTF_DIRECTIVE_B + *--p = 'B'; +# else + *--p = dp->conversion; +# endif + *--p = '0'; + } + tmp_start = p; + + /* The generated string now extends from tmp_start to tmp_end, + with the zero padding insertion point being at pad_ptr, + tmp_start <= pad_ptr <= tmp_end. */ + count = tmp_end - tmp_start; + + if (count < width) + { + size_t pad = width - count; + + if (flags & FLAG_LEFT) + { + /* Pad with spaces on the right. */ + for (p = tmp_start; p < tmp_end; p++) + *(p - pad) = *p; + for (p = tmp_end - pad; p < tmp_end; p++) + *p = ' '; + } + else if ((flags & FLAG_ZERO) + /* Neither ISO C nor POSIX specify that the '0' + flag is ignored when a width and a precision + are both present. But most implementations + do so. */ + && !(has_width && has_precision)) + { + /* Pad with zeroes. */ + for (p = tmp_start; p < pad_ptr; p++) + *(p - pad) = *p; + for (p = pad_ptr - pad; p < pad_ptr; p++) + *p = '0'; + } + else + { + /* Pad with spaces on the left. */ + for (p = tmp_start - pad; p < tmp_start; p++) + *p = ' '; + } + + tmp_start = tmp_start - pad; + } + + count = tmp_end - tmp_start; + + if (count > tmp_length) + /* tmp_length was incorrectly calculated - fix the + code above! */ + abort (); + + /* Make room for the result. */ + if (count >= allocated - length) + { + size_t n = xsum (length, count); + + ENSURE_ALLOCATION (n); + } + + /* Append the result. */ + memcpy (result + length, tmp_start, count * sizeof (DCHAR_T)); + if (tmp != tmpbuf) + free (tmp); + length += count; + } +#endif +#if NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_DOUBLE || (NEED_WPRINTF_DIRECTIVE_LA && WIDE_CHAR_VERSION) + else if ((dp->conversion == 'a' || dp->conversion == 'A') +# if !(NEED_PRINTF_DIRECTIVE_A || (NEED_PRINTF_LONG_DOUBLE && NEED_PRINTF_DOUBLE)) + && (0 +# if NEED_PRINTF_DOUBLE + || a.arg[dp->arg_index].type == TYPE_DOUBLE +# endif +# if NEED_PRINTF_LONG_DOUBLE || (NEED_WPRINTF_DIRECTIVE_LA && WIDE_CHAR_VERSION) + || a.arg[dp->arg_index].type == TYPE_LONGDOUBLE +# endif + ) +# endif + ) + { + arg_type type = a.arg[dp->arg_index].type; + int flags = dp->flags; + size_t width; + int has_precision; + size_t precision; + size_t tmp_length; + size_t count; + DCHAR_T tmpbuf[700]; + DCHAR_T *tmp; + DCHAR_T *pad_ptr; + DCHAR_T *p; + + width = 0; + if (dp->width_start != dp->width_end) + { + if (dp->width_arg_index != ARG_NONE) + { + int arg; + + if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) + abort (); + arg = a.arg[dp->width_arg_index].a.a_int; + width = arg; + if (arg < 0) + { + /* "A negative field width is taken as a '-' flag + followed by a positive field width." */ + flags |= FLAG_LEFT; + width = -width; + } + } + else + { + const FCHAR_T *digitp = dp->width_start; + + do + width = xsum (xtimes (width, 10), *digitp++ - '0'); + while (digitp != dp->width_end); + } + } + + has_precision = 0; + precision = 0; + if (dp->precision_start != dp->precision_end) + { + if (dp->precision_arg_index != ARG_NONE) + { + int arg; + + if (!(a.arg[dp->precision_arg_index].type == TYPE_INT)) + abort (); + arg = a.arg[dp->precision_arg_index].a.a_int; + /* "A negative precision is taken as if the precision + were omitted." */ + if (arg >= 0) + { + precision = arg; + has_precision = 1; + } + } + else + { + const FCHAR_T *digitp = dp->precision_start + 1; + + precision = 0; + while (digitp != dp->precision_end) + precision = xsum (xtimes (precision, 10), *digitp++ - '0'); + has_precision = 1; + } + } + + /* Allocate a temporary buffer of sufficient size. */ + if (type == TYPE_LONGDOUBLE) + tmp_length = + (unsigned int) ((LDBL_DIG + 1) + * 0.831 /* decimal -> hexadecimal */ + ) + + 1; /* turn floor into ceil */ + else + tmp_length = + (unsigned int) ((DBL_DIG + 1) + * 0.831 /* decimal -> hexadecimal */ + ) + + 1; /* turn floor into ceil */ + if (tmp_length < precision) + tmp_length = precision; + /* Account for sign, decimal point etc. */ + tmp_length = xsum (tmp_length, 12); + + if (tmp_length < width) + tmp_length = width; + + tmp_length = xsum (tmp_length, 1); /* account for trailing NUL */ + + if (tmp_length <= sizeof (tmpbuf) / sizeof (DCHAR_T)) + tmp = tmpbuf; + else + { + size_t tmp_memsize = xtimes (tmp_length, sizeof (DCHAR_T)); + + if (size_overflow_p (tmp_memsize)) + /* Overflow, would lead to out of memory. */ + goto out_of_memory; + tmp = (DCHAR_T *) malloc (tmp_memsize); + if (tmp == NULL) + /* Out of memory. */ + goto out_of_memory; + } + + pad_ptr = NULL; + p = tmp; + if (type == TYPE_LONGDOUBLE) + { +# if NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE || (NEED_WPRINTF_DIRECTIVE_LA && WIDE_CHAR_VERSION) + long double arg = a.arg[dp->arg_index].a.a_longdouble; + + if (isnanl (arg)) + { + if (dp->conversion == 'A') + { + *p++ = 'N'; *p++ = 'A'; *p++ = 'N'; + } + else + { + *p++ = 'n'; *p++ = 'a'; *p++ = 'n'; + } + } + else + { + int sign = 0; + DECL_LONG_DOUBLE_ROUNDING + + BEGIN_LONG_DOUBLE_ROUNDING (); + + if (signbit (arg)) /* arg < 0.0L or negative zero */ + { + sign = -1; + arg = -arg; + } + + if (sign < 0) + *p++ = '-'; + else if (flags & FLAG_SHOWSIGN) + *p++ = '+'; + else if (flags & FLAG_SPACE) + *p++ = ' '; + + if (arg > 0.0L && arg + arg == arg) + { + if (dp->conversion == 'A') + { + *p++ = 'I'; *p++ = 'N'; *p++ = 'F'; + } + else + { + *p++ = 'i'; *p++ = 'n'; *p++ = 'f'; + } + } + else + { + int exponent; + long double mantissa; + + if (arg > 0.0L) + mantissa = printf_frexpl (arg, &exponent); + else + { + exponent = 0; + mantissa = 0.0L; + } + + if (has_precision + && precision < (unsigned int) ((LDBL_DIG + 1) * 0.831) + 1) + { + /* Round the mantissa. */ + long double tail = mantissa; + size_t q; + + for (q = precision; ; q--) + { + int digit = (int) tail; + tail -= digit; + if (q == 0) + { + if (digit & 1 ? tail >= 0.5L : tail > 0.5L) + tail = 1 - tail; + else + tail = - tail; + break; + } + tail *= 16.0L; + } + if (tail != 0.0L) + for (q = precision; q > 0; q--) + tail *= 0.0625L; + mantissa += tail; + } + + *p++ = '0'; + *p++ = dp->conversion - 'A' + 'X'; + pad_ptr = p; + { + int digit; + + digit = (int) mantissa; + mantissa -= digit; + *p++ = '0' + digit; + if ((flags & FLAG_ALT) + || mantissa > 0.0L || precision > 0) + { + *p++ = decimal_point_char (); + /* This loop terminates because we assume + that FLT_RADIX is a power of 2. */ + while (mantissa > 0.0L) + { + mantissa *= 16.0L; + digit = (int) mantissa; + mantissa -= digit; + *p++ = digit + + (digit < 10 + ? '0' + : dp->conversion - 10); + if (precision > 0) + precision--; + } + while (precision > 0) + { + *p++ = '0'; + precision--; + } + } + } + *p++ = dp->conversion - 'A' + 'P'; +# if WIDE_CHAR_VERSION && DCHAR_IS_TCHAR + { + static const wchar_t decimal_format[] = + { '%', '+', 'd', '\0' }; + SNPRINTF (p, 6 + 1, decimal_format, exponent); + } + while (*p != '\0') + p++; +# else + if (sizeof (DCHAR_T) == 1) + { + sprintf ((char *) p, "%+d", exponent); + while (*p != '\0') + p++; + } + else + { + char expbuf[6 + 1]; + const char *ep; + sprintf (expbuf, "%+d", exponent); + for (ep = expbuf; (*p = *ep) != '\0'; ep++) + p++; + } +# endif + } + + END_LONG_DOUBLE_ROUNDING (); + } +# else + abort (); +# endif + } + else + { +# if NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_DOUBLE + double arg = a.arg[dp->arg_index].a.a_double; + + if (isnand (arg)) + { + if (dp->conversion == 'A') + { + *p++ = 'N'; *p++ = 'A'; *p++ = 'N'; + } + else + { + *p++ = 'n'; *p++ = 'a'; *p++ = 'n'; + } + } + else + { + int sign = 0; + + if (signbit (arg)) /* arg < 0.0 or negative zero */ + { + sign = -1; + arg = -arg; + } + + if (sign < 0) + *p++ = '-'; + else if (flags & FLAG_SHOWSIGN) + *p++ = '+'; + else if (flags & FLAG_SPACE) + *p++ = ' '; + + if (arg > 0.0 && arg + arg == arg) + { + if (dp->conversion == 'A') + { + *p++ = 'I'; *p++ = 'N'; *p++ = 'F'; + } + else + { + *p++ = 'i'; *p++ = 'n'; *p++ = 'f'; + } + } + else + { + int exponent; + double mantissa; + + if (arg > 0.0) + mantissa = printf_frexp (arg, &exponent); + else + { + exponent = 0; + mantissa = 0.0; + } + + if (has_precision + && precision < (unsigned int) ((DBL_DIG + 1) * 0.831) + 1) + { + /* Round the mantissa. */ + double tail = mantissa; + size_t q; + + for (q = precision; ; q--) + { + int digit = (int) tail; + tail -= digit; + if (q == 0) + { + if (digit & 1 ? tail >= 0.5 : tail > 0.5) + tail = 1 - tail; + else + tail = - tail; + break; + } + tail *= 16.0; + } + if (tail != 0.0) + for (q = precision; q > 0; q--) + tail *= 0.0625; + mantissa += tail; + } + + *p++ = '0'; + *p++ = dp->conversion - 'A' + 'X'; + pad_ptr = p; + { + int digit; + + digit = (int) mantissa; + mantissa -= digit; + *p++ = '0' + digit; + if ((flags & FLAG_ALT) + || mantissa > 0.0 || precision > 0) + { + *p++ = decimal_point_char (); + /* This loop terminates because we assume + that FLT_RADIX is a power of 2. */ + while (mantissa > 0.0) + { + mantissa *= 16.0; + digit = (int) mantissa; + mantissa -= digit; + *p++ = digit + + (digit < 10 + ? '0' + : dp->conversion - 10); + if (precision > 0) + precision--; + } + while (precision > 0) + { + *p++ = '0'; + precision--; + } + } + } + *p++ = dp->conversion - 'A' + 'P'; +# if WIDE_CHAR_VERSION && DCHAR_IS_TCHAR + { + static const wchar_t decimal_format[] = + { '%', '+', 'd', '\0' }; + SNPRINTF (p, 6 + 1, decimal_format, exponent); + } + while (*p != '\0') + p++; +# else + if (sizeof (DCHAR_T) == 1) + { + sprintf ((char *) p, "%+d", exponent); + while (*p != '\0') + p++; + } + else + { + char expbuf[6 + 1]; + const char *ep; + sprintf (expbuf, "%+d", exponent); + for (ep = expbuf; (*p = *ep) != '\0'; ep++) + p++; + } +# endif + } + } +# else + abort (); +# endif + } + + /* The generated string now extends from tmp to p, with the + zero padding insertion point being at pad_ptr. */ + count = p - tmp; + + if (count < width) + { + size_t pad = width - count; + DCHAR_T *end = p + pad; + + if (flags & FLAG_LEFT) + { + /* Pad with spaces on the right. */ + for (; pad > 0; pad--) + *p++ = ' '; + } + else if ((flags & FLAG_ZERO) && pad_ptr != NULL) + { + /* Pad with zeroes. */ + DCHAR_T *q = end; + + while (p > pad_ptr) + *--q = *--p; + for (; pad > 0; pad--) + *p++ = '0'; + } + else + { + /* Pad with spaces on the left. */ + DCHAR_T *q = end; + + while (p > tmp) + *--q = *--p; + for (; pad > 0; pad--) + *p++ = ' '; + } + + p = end; + } + + count = p - tmp; + + if (count >= tmp_length) + /* tmp_length was incorrectly calculated - fix the + code above! */ + abort (); + + /* Make room for the result. */ + if (count >= allocated - length) + { + size_t n = xsum (length, count); + + ENSURE_ALLOCATION (n); + } + + /* Append the result. */ + memcpy (result + length, tmp, count * sizeof (DCHAR_T)); + if (tmp != tmpbuf) + free (tmp); + length += count; + } +#endif +#if NEED_PRINTF_INFINITE_DOUBLE || NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE || NEED_PRINTF_LONG_DOUBLE + else if ((dp->conversion == 'f' || dp->conversion == 'F' + || dp->conversion == 'e' || dp->conversion == 'E' + || dp->conversion == 'g' || dp->conversion == 'G' + || dp->conversion == 'a' || dp->conversion == 'A') + && (0 +# if NEED_PRINTF_DOUBLE + || a.arg[dp->arg_index].type == TYPE_DOUBLE +# elif NEED_PRINTF_INFINITE_DOUBLE + || (a.arg[dp->arg_index].type == TYPE_DOUBLE + /* The systems (mingw) which produce wrong output + for Inf, -Inf, and NaN also do so for -0.0. + Therefore we treat this case here as well. */ + && is_infinite_or_zero (a.arg[dp->arg_index].a.a_double)) +# endif +# if NEED_PRINTF_LONG_DOUBLE + || a.arg[dp->arg_index].type == TYPE_LONGDOUBLE +# elif NEED_PRINTF_INFINITE_LONG_DOUBLE + || (a.arg[dp->arg_index].type == TYPE_LONGDOUBLE + /* Some systems produce wrong output for Inf, + -Inf, and NaN. Some systems in this category + (IRIX 5.3) also do so for -0.0. Therefore we + treat this case here as well. */ + && is_infinite_or_zerol (a.arg[dp->arg_index].a.a_longdouble)) +# endif + )) + { +# if (NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE) && (NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE) + arg_type type = a.arg[dp->arg_index].type; +# endif + int flags = dp->flags; + size_t width; + size_t count; + int has_precision; + size_t precision; + size_t tmp_length; + DCHAR_T tmpbuf[700]; + DCHAR_T *tmp; + DCHAR_T *pad_ptr; + DCHAR_T *p; + + width = 0; + if (dp->width_start != dp->width_end) + { + if (dp->width_arg_index != ARG_NONE) + { + int arg; + + if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) + abort (); + arg = a.arg[dp->width_arg_index].a.a_int; + width = arg; + if (arg < 0) + { + /* "A negative field width is taken as a '-' flag + followed by a positive field width." */ + flags |= FLAG_LEFT; + width = -width; + } + } + else + { + const FCHAR_T *digitp = dp->width_start; + + do + width = xsum (xtimes (width, 10), *digitp++ - '0'); + while (digitp != dp->width_end); + } + } + + has_precision = 0; + precision = 0; + if (dp->precision_start != dp->precision_end) + { + if (dp->precision_arg_index != ARG_NONE) + { + int arg; + + if (!(a.arg[dp->precision_arg_index].type == TYPE_INT)) + abort (); + arg = a.arg[dp->precision_arg_index].a.a_int; + /* "A negative precision is taken as if the precision + were omitted." */ + if (arg >= 0) + { + precision = arg; + has_precision = 1; + } + } + else + { + const FCHAR_T *digitp = dp->precision_start + 1; + + precision = 0; + while (digitp != dp->precision_end) + precision = xsum (xtimes (precision, 10), *digitp++ - '0'); + has_precision = 1; + } + } + + /* POSIX specifies the default precision to be 6 for %f, %F, + %e, %E, but not for %g, %G. Implementations appear to use + the same default precision also for %g, %G. But for %a, %A, + the default precision is 0. */ + if (!has_precision) + if (!(dp->conversion == 'a' || dp->conversion == 'A')) + precision = 6; + + /* Allocate a temporary buffer of sufficient size. */ +# if NEED_PRINTF_DOUBLE && NEED_PRINTF_LONG_DOUBLE + tmp_length = (type == TYPE_LONGDOUBLE ? LDBL_DIG + 1 : DBL_DIG + 1); +# elif NEED_PRINTF_INFINITE_DOUBLE && NEED_PRINTF_LONG_DOUBLE + tmp_length = (type == TYPE_LONGDOUBLE ? LDBL_DIG + 1 : 0); +# elif NEED_PRINTF_LONG_DOUBLE + tmp_length = LDBL_DIG + 1; +# elif NEED_PRINTF_DOUBLE + tmp_length = DBL_DIG + 1; +# else + tmp_length = 0; +# endif + if (tmp_length < precision) + tmp_length = precision; +# if NEED_PRINTF_LONG_DOUBLE +# if NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE + if (type == TYPE_LONGDOUBLE) +# endif + if (dp->conversion == 'f' || dp->conversion == 'F') + { + long double arg = a.arg[dp->arg_index].a.a_longdouble; + if (!(isnanl (arg) || arg + arg == arg)) + { + /* arg is finite and nonzero. */ + int exponent = floorlog10l (arg < 0 ? -arg : arg); + if (exponent >= 0 && tmp_length < exponent + precision) + tmp_length = exponent + precision; + } + } +# endif +# if NEED_PRINTF_DOUBLE +# if NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE + if (type == TYPE_DOUBLE) +# endif + if (dp->conversion == 'f' || dp->conversion == 'F') + { + double arg = a.arg[dp->arg_index].a.a_double; + if (!(isnand (arg) || arg + arg == arg)) + { + /* arg is finite and nonzero. */ + int exponent = floorlog10 (arg < 0 ? -arg : arg); + if (exponent >= 0 && tmp_length < exponent + precision) + tmp_length = exponent + precision; + } + } +# endif + /* Account for sign, decimal point etc. */ + tmp_length = xsum (tmp_length, 12); + + if (tmp_length < width) + tmp_length = width; + + tmp_length = xsum (tmp_length, 1); /* account for trailing NUL */ + + if (tmp_length <= sizeof (tmpbuf) / sizeof (DCHAR_T)) + tmp = tmpbuf; + else + { + size_t tmp_memsize = xtimes (tmp_length, sizeof (DCHAR_T)); + + if (size_overflow_p (tmp_memsize)) + /* Overflow, would lead to out of memory. */ + goto out_of_memory; + tmp = (DCHAR_T *) malloc (tmp_memsize); + if (tmp == NULL) + /* Out of memory. */ + goto out_of_memory; + } + + pad_ptr = NULL; + p = tmp; + +# if NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE +# if NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE + if (type == TYPE_LONGDOUBLE) +# endif + { + long double arg = a.arg[dp->arg_index].a.a_longdouble; + + if (isnanl (arg)) + { + if (dp->conversion >= 'A' && dp->conversion <= 'Z') + { + *p++ = 'N'; *p++ = 'A'; *p++ = 'N'; + } + else + { + *p++ = 'n'; *p++ = 'a'; *p++ = 'n'; + } + } + else + { + int sign = 0; + DECL_LONG_DOUBLE_ROUNDING + + BEGIN_LONG_DOUBLE_ROUNDING (); + + if (signbit (arg)) /* arg < 0.0L or negative zero */ + { + sign = -1; + arg = -arg; + } + + if (sign < 0) + *p++ = '-'; + else if (flags & FLAG_SHOWSIGN) + *p++ = '+'; + else if (flags & FLAG_SPACE) + *p++ = ' '; + + if (arg > 0.0L && arg + arg == arg) + { + if (dp->conversion >= 'A' && dp->conversion <= 'Z') + { + *p++ = 'I'; *p++ = 'N'; *p++ = 'F'; + } + else + { + *p++ = 'i'; *p++ = 'n'; *p++ = 'f'; + } + } + else + { +# if NEED_PRINTF_LONG_DOUBLE + pad_ptr = p; + + if (dp->conversion == 'f' || dp->conversion == 'F') + { + char *digits; + size_t ndigits; + + digits = + scale10_round_decimal_long_double (arg, precision); + if (digits == NULL) + { + END_LONG_DOUBLE_ROUNDING (); + goto out_of_memory; + } + ndigits = strlen (digits); + + if (ndigits > precision) + do + { + --ndigits; + *p++ = digits[ndigits]; + } + while (ndigits > precision); + else + *p++ = '0'; + /* Here ndigits <= precision. */ + if ((flags & FLAG_ALT) || precision > 0) + { + *p++ = decimal_point_char (); + for (; precision > ndigits; precision--) + *p++ = '0'; + while (ndigits > 0) + { + --ndigits; + *p++ = digits[ndigits]; + } + } + + free (digits); + } + else if (dp->conversion == 'e' || dp->conversion == 'E') + { + int exponent; + + if (arg == 0.0L) + { + exponent = 0; + *p++ = '0'; + if ((flags & FLAG_ALT) || precision > 0) + { + *p++ = decimal_point_char (); + for (; precision > 0; precision--) + *p++ = '0'; + } + } + else + { + /* arg > 0.0L. */ + int adjusted; + char *digits; + size_t ndigits; + + exponent = floorlog10l (arg); + adjusted = 0; + for (;;) + { + digits = + scale10_round_decimal_long_double (arg, + (int)precision - exponent); + if (digits == NULL) + { + END_LONG_DOUBLE_ROUNDING (); + goto out_of_memory; + } + ndigits = strlen (digits); + + if (ndigits == precision + 1) + break; + if (ndigits < precision + || ndigits > precision + 2) + /* The exponent was not guessed + precisely enough. */ + abort (); + if (adjusted) + /* None of two values of exponent is + the right one. Prevent an endless + loop. */ + abort (); + free (digits); + if (ndigits == precision) + exponent -= 1; + else + exponent += 1; + adjusted = 1; + } + /* Here ndigits = precision+1. */ + if (is_borderline (digits, precision)) + { + /* Maybe the exponent guess was too high + and a smaller exponent can be reached + by turning a 10...0 into 9...9x. */ + char *digits2 = + scale10_round_decimal_long_double (arg, + (int)precision - exponent + 1); + if (digits2 == NULL) + { + free (digits); + END_LONG_DOUBLE_ROUNDING (); + goto out_of_memory; + } + if (strlen (digits2) == precision + 1) + { + free (digits); + digits = digits2; + exponent -= 1; + } + else + free (digits2); + } + /* Here ndigits = precision+1. */ + + *p++ = digits[--ndigits]; + if ((flags & FLAG_ALT) || precision > 0) + { + *p++ = decimal_point_char (); + while (ndigits > 0) + { + --ndigits; + *p++ = digits[ndigits]; + } + } + + free (digits); + } + + *p++ = dp->conversion; /* 'e' or 'E' */ +# if WIDE_CHAR_VERSION && DCHAR_IS_TCHAR + { + static const wchar_t decimal_format[] = + { '%', '+', '.', '2', 'd', '\0' }; + SNPRINTF (p, 6 + 1, decimal_format, exponent); + } + while (*p != '\0') + p++; +# else + if (sizeof (DCHAR_T) == 1) + { + sprintf ((char *) p, "%+.2d", exponent); + while (*p != '\0') + p++; + } + else + { + char expbuf[6 + 1]; + const char *ep; + sprintf (expbuf, "%+.2d", exponent); + for (ep = expbuf; (*p = *ep) != '\0'; ep++) + p++; + } +# endif + } + else if (dp->conversion == 'g' || dp->conversion == 'G') + { + if (precision == 0) + precision = 1; + /* precision >= 1. */ + + if (arg == 0.0L) + /* The exponent is 0, >= -4, < precision. + Use fixed-point notation. */ + { + size_t ndigits = precision; + /* Number of trailing zeroes that have to be + dropped. */ + size_t nzeroes = + (flags & FLAG_ALT ? 0 : precision - 1); + + --ndigits; + *p++ = '0'; + if ((flags & FLAG_ALT) || ndigits > nzeroes) + { + *p++ = decimal_point_char (); + while (ndigits > nzeroes) + { + --ndigits; + *p++ = '0'; + } + } + } + else + { + /* arg > 0.0L. */ + int exponent; + int adjusted; + char *digits; + size_t ndigits; + size_t nzeroes; + + exponent = floorlog10l (arg); + adjusted = 0; + for (;;) + { + digits = + scale10_round_decimal_long_double (arg, + (int)(precision - 1) - exponent); + if (digits == NULL) + { + END_LONG_DOUBLE_ROUNDING (); + goto out_of_memory; + } + ndigits = strlen (digits); + + if (ndigits == precision) + break; + if (ndigits < precision - 1 + || ndigits > precision + 1) + /* The exponent was not guessed + precisely enough. */ + abort (); + if (adjusted) + /* None of two values of exponent is + the right one. Prevent an endless + loop. */ + abort (); + free (digits); + if (ndigits < precision) + exponent -= 1; + else + exponent += 1; + adjusted = 1; + } + /* Here ndigits = precision. */ + if (is_borderline (digits, precision - 1)) + { + /* Maybe the exponent guess was too high + and a smaller exponent can be reached + by turning a 10...0 into 9...9x. */ + char *digits2 = + scale10_round_decimal_long_double (arg, + (int)(precision - 1) - exponent + 1); + if (digits2 == NULL) + { + free (digits); + END_LONG_DOUBLE_ROUNDING (); + goto out_of_memory; + } + if (strlen (digits2) == precision) + { + free (digits); + digits = digits2; + exponent -= 1; + } + else + free (digits2); + } + /* Here ndigits = precision. */ + + /* Determine the number of trailing zeroes + that have to be dropped. */ + nzeroes = 0; + if ((flags & FLAG_ALT) == 0) + while (nzeroes < ndigits + && digits[nzeroes] == '0') + nzeroes++; + + /* The exponent is now determined. */ + if (exponent >= -4 + && exponent < (long)precision) + { + /* Fixed-point notation: + max(exponent,0)+1 digits, then the + decimal point, then the remaining + digits without trailing zeroes. */ + if (exponent >= 0) + { + size_t ecount = exponent + 1; + /* Note: count <= precision = ndigits. */ + for (; ecount > 0; ecount--) + *p++ = digits[--ndigits]; + if ((flags & FLAG_ALT) || ndigits > nzeroes) + { + *p++ = decimal_point_char (); + while (ndigits > nzeroes) + { + --ndigits; + *p++ = digits[ndigits]; + } + } + } + else + { + size_t ecount = -exponent - 1; + *p++ = '0'; + *p++ = decimal_point_char (); + for (; ecount > 0; ecount--) + *p++ = '0'; + while (ndigits > nzeroes) + { + --ndigits; + *p++ = digits[ndigits]; + } + } + } + else + { + /* Exponential notation. */ + *p++ = digits[--ndigits]; + if ((flags & FLAG_ALT) || ndigits > nzeroes) + { + *p++ = decimal_point_char (); + while (ndigits > nzeroes) + { + --ndigits; + *p++ = digits[ndigits]; + } + } + *p++ = dp->conversion - 'G' + 'E'; /* 'e' or 'E' */ +# if WIDE_CHAR_VERSION && DCHAR_IS_TCHAR + { + static const wchar_t decimal_format[] = + { '%', '+', '.', '2', 'd', '\0' }; + SNPRINTF (p, 6 + 1, decimal_format, exponent); + } + while (*p != '\0') + p++; +# else + if (sizeof (DCHAR_T) == 1) + { + sprintf ((char *) p, "%+.2d", exponent); + while (*p != '\0') + p++; + } + else + { + char expbuf[6 + 1]; + const char *ep; + sprintf (expbuf, "%+.2d", exponent); + for (ep = expbuf; (*p = *ep) != '\0'; ep++) + p++; + } +# endif + } + + free (digits); + } + } + else + abort (); +# else + /* arg is finite. */ + if (!(arg == 0.0L)) + abort (); + + pad_ptr = p; + + if (dp->conversion == 'f' || dp->conversion == 'F') + { + *p++ = '0'; + if ((flags & FLAG_ALT) || precision > 0) + { + *p++ = decimal_point_char (); + for (; precision > 0; precision--) + *p++ = '0'; + } + } + else if (dp->conversion == 'e' || dp->conversion == 'E') + { + *p++ = '0'; + if ((flags & FLAG_ALT) || precision > 0) + { + *p++ = decimal_point_char (); + for (; precision > 0; precision--) + *p++ = '0'; + } + *p++ = dp->conversion; /* 'e' or 'E' */ + *p++ = '+'; + *p++ = '0'; + *p++ = '0'; + } + else if (dp->conversion == 'g' || dp->conversion == 'G') + { + *p++ = '0'; + if (flags & FLAG_ALT) + { + size_t ndigits = + (precision > 0 ? precision - 1 : 0); + *p++ = decimal_point_char (); + for (; ndigits > 0; --ndigits) + *p++ = '0'; + } + } + else if (dp->conversion == 'a' || dp->conversion == 'A') + { + *p++ = '0'; + *p++ = dp->conversion - 'A' + 'X'; + pad_ptr = p; + *p++ = '0'; + if ((flags & FLAG_ALT) || precision > 0) + { + *p++ = decimal_point_char (); + for (; precision > 0; precision--) + *p++ = '0'; + } + *p++ = dp->conversion - 'A' + 'P'; + *p++ = '+'; + *p++ = '0'; + } + else + abort (); +# endif + } + + END_LONG_DOUBLE_ROUNDING (); + } + } +# if NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE + else +# endif +# endif +# if NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE + { + double arg = a.arg[dp->arg_index].a.a_double; + + if (isnand (arg)) + { + if (dp->conversion >= 'A' && dp->conversion <= 'Z') + { + *p++ = 'N'; *p++ = 'A'; *p++ = 'N'; + } + else + { + *p++ = 'n'; *p++ = 'a'; *p++ = 'n'; + } + } + else + { + int sign = 0; + + if (signbit (arg)) /* arg < 0.0 or negative zero */ + { + sign = -1; + arg = -arg; + } + + if (sign < 0) + *p++ = '-'; + else if (flags & FLAG_SHOWSIGN) + *p++ = '+'; + else if (flags & FLAG_SPACE) + *p++ = ' '; + + if (arg > 0.0 && arg + arg == arg) + { + if (dp->conversion >= 'A' && dp->conversion <= 'Z') + { + *p++ = 'I'; *p++ = 'N'; *p++ = 'F'; + } + else + { + *p++ = 'i'; *p++ = 'n'; *p++ = 'f'; + } + } + else + { +# if NEED_PRINTF_DOUBLE + pad_ptr = p; + + if (dp->conversion == 'f' || dp->conversion == 'F') + { + char *digits; + size_t ndigits; + + digits = + scale10_round_decimal_double (arg, precision); + if (digits == NULL) + goto out_of_memory; + ndigits = strlen (digits); + + if (ndigits > precision) + do + { + --ndigits; + *p++ = digits[ndigits]; + } + while (ndigits > precision); + else + *p++ = '0'; + /* Here ndigits <= precision. */ + if ((flags & FLAG_ALT) || precision > 0) + { + *p++ = decimal_point_char (); + for (; precision > ndigits; precision--) + *p++ = '0'; + while (ndigits > 0) + { + --ndigits; + *p++ = digits[ndigits]; + } + } + + free (digits); + } + else if (dp->conversion == 'e' || dp->conversion == 'E') + { + int exponent; + + if (arg == 0.0) + { + exponent = 0; + *p++ = '0'; + if ((flags & FLAG_ALT) || precision > 0) + { + *p++ = decimal_point_char (); + for (; precision > 0; precision--) + *p++ = '0'; + } + } + else + { + /* arg > 0.0. */ + int adjusted; + char *digits; + size_t ndigits; + + exponent = floorlog10 (arg); + adjusted = 0; + for (;;) + { + digits = + scale10_round_decimal_double (arg, + (int)precision - exponent); + if (digits == NULL) + goto out_of_memory; + ndigits = strlen (digits); + + if (ndigits == precision + 1) + break; + if (ndigits < precision + || ndigits > precision + 2) + /* The exponent was not guessed + precisely enough. */ + abort (); + if (adjusted) + /* None of two values of exponent is + the right one. Prevent an endless + loop. */ + abort (); + free (digits); + if (ndigits == precision) + exponent -= 1; + else + exponent += 1; + adjusted = 1; + } + /* Here ndigits = precision+1. */ + if (is_borderline (digits, precision)) + { + /* Maybe the exponent guess was too high + and a smaller exponent can be reached + by turning a 10...0 into 9...9x. */ + char *digits2 = + scale10_round_decimal_double (arg, + (int)precision - exponent + 1); + if (digits2 == NULL) + { + free (digits); + goto out_of_memory; + } + if (strlen (digits2) == precision + 1) + { + free (digits); + digits = digits2; + exponent -= 1; + } + else + free (digits2); + } + /* Here ndigits = precision+1. */ + + *p++ = digits[--ndigits]; + if ((flags & FLAG_ALT) || precision > 0) + { + *p++ = decimal_point_char (); + while (ndigits > 0) + { + --ndigits; + *p++ = digits[ndigits]; + } + } + + free (digits); + } + + *p++ = dp->conversion; /* 'e' or 'E' */ +# if WIDE_CHAR_VERSION && DCHAR_IS_TCHAR + { + static const wchar_t decimal_format[] = + /* Produce the same number of exponent digits + as the native printf implementation. */ +# if defined _WIN32 && ! defined __CYGWIN__ + { '%', '+', '.', '3', 'd', '\0' }; +# else + { '%', '+', '.', '2', 'd', '\0' }; +# endif + SNPRINTF (p, 6 + 1, decimal_format, exponent); + } + while (*p != '\0') + p++; +# else + { + static const char decimal_format[] = + /* Produce the same number of exponent digits + as the native printf implementation. */ +# if defined _WIN32 && ! defined __CYGWIN__ + "%+.3d"; +# else + "%+.2d"; +# endif + if (sizeof (DCHAR_T) == 1) + { + sprintf ((char *) p, decimal_format, exponent); + while (*p != '\0') + p++; + } + else + { + char expbuf[6 + 1]; + const char *ep; + sprintf (expbuf, decimal_format, exponent); + for (ep = expbuf; (*p = *ep) != '\0'; ep++) + p++; + } + } +# endif + } + else if (dp->conversion == 'g' || dp->conversion == 'G') + { + if (precision == 0) + precision = 1; + /* precision >= 1. */ + + if (arg == 0.0) + /* The exponent is 0, >= -4, < precision. + Use fixed-point notation. */ + { + size_t ndigits = precision; + /* Number of trailing zeroes that have to be + dropped. */ + size_t nzeroes = + (flags & FLAG_ALT ? 0 : precision - 1); + + --ndigits; + *p++ = '0'; + if ((flags & FLAG_ALT) || ndigits > nzeroes) + { + *p++ = decimal_point_char (); + while (ndigits > nzeroes) + { + --ndigits; + *p++ = '0'; + } + } + } + else + { + /* arg > 0.0. */ + int exponent; + int adjusted; + char *digits; + size_t ndigits; + size_t nzeroes; + + exponent = floorlog10 (arg); + adjusted = 0; + for (;;) + { + digits = + scale10_round_decimal_double (arg, + (int)(precision - 1) - exponent); + if (digits == NULL) + goto out_of_memory; + ndigits = strlen (digits); + + if (ndigits == precision) + break; + if (ndigits < precision - 1 + || ndigits > precision + 1) + /* The exponent was not guessed + precisely enough. */ + abort (); + if (adjusted) + /* None of two values of exponent is + the right one. Prevent an endless + loop. */ + abort (); + free (digits); + if (ndigits < precision) + exponent -= 1; + else + exponent += 1; + adjusted = 1; + } + /* Here ndigits = precision. */ + if (is_borderline (digits, precision - 1)) + { + /* Maybe the exponent guess was too high + and a smaller exponent can be reached + by turning a 10...0 into 9...9x. */ + char *digits2 = + scale10_round_decimal_double (arg, + (int)(precision - 1) - exponent + 1); + if (digits2 == NULL) + { + free (digits); + goto out_of_memory; + } + if (strlen (digits2) == precision) + { + free (digits); + digits = digits2; + exponent -= 1; + } + else + free (digits2); + } + /* Here ndigits = precision. */ + + /* Determine the number of trailing zeroes + that have to be dropped. */ + nzeroes = 0; + if ((flags & FLAG_ALT) == 0) + while (nzeroes < ndigits + && digits[nzeroes] == '0') + nzeroes++; + + /* The exponent is now determined. */ + if (exponent >= -4 + && exponent < (long)precision) + { + /* Fixed-point notation: + max(exponent,0)+1 digits, then the + decimal point, then the remaining + digits without trailing zeroes. */ + if (exponent >= 0) + { + size_t ecount = exponent + 1; + /* Note: ecount <= precision = ndigits. */ + for (; ecount > 0; ecount--) + *p++ = digits[--ndigits]; + if ((flags & FLAG_ALT) || ndigits > nzeroes) + { + *p++ = decimal_point_char (); + while (ndigits > nzeroes) + { + --ndigits; + *p++ = digits[ndigits]; + } + } + } + else + { + size_t ecount = -exponent - 1; + *p++ = '0'; + *p++ = decimal_point_char (); + for (; ecount > 0; ecount--) + *p++ = '0'; + while (ndigits > nzeroes) + { + --ndigits; + *p++ = digits[ndigits]; + } + } + } + else + { + /* Exponential notation. */ + *p++ = digits[--ndigits]; + if ((flags & FLAG_ALT) || ndigits > nzeroes) + { + *p++ = decimal_point_char (); + while (ndigits > nzeroes) + { + --ndigits; + *p++ = digits[ndigits]; + } + } + *p++ = dp->conversion - 'G' + 'E'; /* 'e' or 'E' */ +# if WIDE_CHAR_VERSION && DCHAR_IS_TCHAR + { + static const wchar_t decimal_format[] = + /* Produce the same number of exponent digits + as the native printf implementation. */ +# if defined _WIN32 && ! defined __CYGWIN__ + { '%', '+', '.', '3', 'd', '\0' }; +# else + { '%', '+', '.', '2', 'd', '\0' }; +# endif + SNPRINTF (p, 6 + 1, decimal_format, exponent); + } + while (*p != '\0') + p++; +# else + { + static const char decimal_format[] = + /* Produce the same number of exponent digits + as the native printf implementation. */ +# if defined _WIN32 && ! defined __CYGWIN__ + "%+.3d"; +# else + "%+.2d"; +# endif + if (sizeof (DCHAR_T) == 1) + { + sprintf ((char *) p, decimal_format, exponent); + while (*p != '\0') + p++; + } + else + { + char expbuf[6 + 1]; + const char *ep; + sprintf (expbuf, decimal_format, exponent); + for (ep = expbuf; (*p = *ep) != '\0'; ep++) + p++; + } + } +# endif + } + + free (digits); + } + } + else + abort (); +# else + /* arg is finite. */ + if (!(arg == 0.0)) + abort (); + + pad_ptr = p; + + if (dp->conversion == 'f' || dp->conversion == 'F') + { + *p++ = '0'; + if ((flags & FLAG_ALT) || precision > 0) + { + *p++ = decimal_point_char (); + for (; precision > 0; precision--) + *p++ = '0'; + } + } + else if (dp->conversion == 'e' || dp->conversion == 'E') + { + *p++ = '0'; + if ((flags & FLAG_ALT) || precision > 0) + { + *p++ = decimal_point_char (); + for (; precision > 0; precision--) + *p++ = '0'; + } + *p++ = dp->conversion; /* 'e' or 'E' */ + *p++ = '+'; + /* Produce the same number of exponent digits as + the native printf implementation. */ +# if defined _WIN32 && ! defined __CYGWIN__ + *p++ = '0'; +# endif + *p++ = '0'; + *p++ = '0'; + } + else if (dp->conversion == 'g' || dp->conversion == 'G') + { + *p++ = '0'; + if (flags & FLAG_ALT) + { + size_t ndigits = + (precision > 0 ? precision - 1 : 0); + *p++ = decimal_point_char (); + for (; ndigits > 0; --ndigits) + *p++ = '0'; + } + } + else + abort (); +# endif + } + } + } +# endif + + /* The generated string now extends from tmp to p, with the + zero padding insertion point being at pad_ptr. */ + count = p - tmp; + + if (count < width) + { + size_t pad = width - count; + DCHAR_T *end = p + pad; + + if (flags & FLAG_LEFT) + { + /* Pad with spaces on the right. */ + for (; pad > 0; pad--) + *p++ = ' '; + } + else if ((flags & FLAG_ZERO) && pad_ptr != NULL) + { + /* Pad with zeroes. */ + DCHAR_T *q = end; + + while (p > pad_ptr) + *--q = *--p; + for (; pad > 0; pad--) + *p++ = '0'; + } + else + { + /* Pad with spaces on the left. */ + DCHAR_T *q = end; + + while (p > tmp) + *--q = *--p; + for (; pad > 0; pad--) + *p++ = ' '; + } + + p = end; + } + + count = p - tmp; + + if (count >= tmp_length) + /* tmp_length was incorrectly calculated - fix the + code above! */ + abort (); + + /* Make room for the result. */ + if (count >= allocated - length) + { + size_t n = xsum (length, count); + + ENSURE_ALLOCATION (n); + } + + /* Append the result. */ + memcpy (result + length, tmp, count * sizeof (DCHAR_T)); + if (tmp != tmpbuf) + free (tmp); + length += count; + } +#endif + else + { + arg_type type = a.arg[dp->arg_index].type; + int flags = dp->flags; +#if (WIDE_CHAR_VERSION && MUSL_LIBC) || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_FLAG_ALT_PRECISION_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION + int has_width; +#endif +#if !USE_SNPRINTF || WIDE_CHAR_VERSION || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_FLAG_ALT_PRECISION_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION + size_t width; +#endif +#if !USE_SNPRINTF || (WIDE_CHAR_VERSION && DCHAR_IS_TCHAR) || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || (WIDE_CHAR_VERSION && MUSL_LIBC) || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_FLAG_ALT_PRECISION_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION + int has_precision; + size_t precision; +#endif +#if NEED_PRINTF_FLAG_ALT_PRECISION_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION + int prec_ourselves; +#else +# define prec_ourselves 0 +#endif +#if (WIDE_CHAR_VERSION && MUSL_LIBC) || NEED_PRINTF_FLAG_LEFTADJUST +# define pad_ourselves 1 +#elif !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_FLAG_ALT_PRECISION_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION + int pad_ourselves; +#else +# define pad_ourselves 0 +#endif + TCHAR_T *fbp; + unsigned int prefix_count; + int prefixes[2] IF_LINT (= { 0 }); + int orig_errno; +#if !USE_SNPRINTF + size_t tmp_length; + TCHAR_T tmpbuf[700]; + TCHAR_T *tmp; +#endif + +#if (WIDE_CHAR_VERSION && MUSL_LIBC) || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_FLAG_ALT_PRECISION_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION + has_width = 0; +#endif +#if !USE_SNPRINTF || WIDE_CHAR_VERSION || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_FLAG_ALT_PRECISION_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION + width = 0; + if (dp->width_start != dp->width_end) + { + if (dp->width_arg_index != ARG_NONE) + { + int arg; + + if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) + abort (); + arg = a.arg[dp->width_arg_index].a.a_int; + width = arg; + if (arg < 0) + { + /* "A negative field width is taken as a '-' flag + followed by a positive field width." */ + flags |= FLAG_LEFT; + width = -width; + } + } + else + { + const FCHAR_T *digitp = dp->width_start; + + do + width = xsum (xtimes (width, 10), *digitp++ - '0'); + while (digitp != dp->width_end); + } +# if (WIDE_CHAR_VERSION && MUSL_LIBC) || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_FLAG_ALT_PRECISION_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION + has_width = 1; +# endif + } +#endif + +#if !USE_SNPRINTF || (WIDE_CHAR_VERSION && DCHAR_IS_TCHAR) || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || (WIDE_CHAR_VERSION && MUSL_LIBC) || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_FLAG_ALT_PRECISION_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION + has_precision = 0; + precision = 6; + if (dp->precision_start != dp->precision_end) + { + if (dp->precision_arg_index != ARG_NONE) + { + int arg; + + if (!(a.arg[dp->precision_arg_index].type == TYPE_INT)) + abort (); + arg = a.arg[dp->precision_arg_index].a.a_int; + /* "A negative precision is taken as if the precision + were omitted." */ + if (arg >= 0) + { + precision = arg; + has_precision = 1; + } + } + else + { + const FCHAR_T *digitp = dp->precision_start + 1; + + precision = 0; + while (digitp != dp->precision_end) + precision = xsum (xtimes (precision, 10), *digitp++ - '0'); + has_precision = 1; + } + } +#endif + + /* Decide whether to handle the precision ourselves. */ +#if NEED_PRINTF_FLAG_ALT_PRECISION_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION + switch (dp->conversion) + { +# if NEED_PRINTF_UNBOUNDED_PRECISION + case 'd': case 'i': case 'u': + case 'b': + #if SUPPORT_GNU_PRINTF_DIRECTIVES \ + || (__GLIBC__ + (__GLIBC_MINOR__ >= 35) > 2) + case 'B': + #endif + case 'o': + prec_ourselves = has_precision && (precision > 0); + break; +# endif + case 'x': case 'X': case 'p': + prec_ourselves = + has_precision + && (0 +# if NEED_PRINTF_FLAG_ALT_PRECISION_ZERO + || (precision == 0) +# endif +# if NEED_PRINTF_UNBOUNDED_PRECISION + || (precision > 0) +# endif + ); + break; + default: + prec_ourselves = 0; + break; + } +#endif + + /* Decide whether to perform the padding ourselves. */ +#if !((WIDE_CHAR_VERSION && MUSL_LIBC) || NEED_PRINTF_FLAG_LEFTADJUST) && (!DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_FLAG_ALT_PRECISION_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION) + switch (dp->conversion) + { +# if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO + /* If we need conversion from TCHAR_T[] to DCHAR_T[], we need + to perform the padding after this conversion. Functions + with unistdio extensions perform the padding based on + character count rather than element count. */ + case 'c': case 's': +# endif +# if NEED_PRINTF_FLAG_ZERO + case 'f': case 'F': case 'e': case 'E': case 'g': case 'G': + case 'a': case 'A': +# endif + pad_ourselves = 1; + break; + default: + pad_ourselves = prec_ourselves; + break; + } +#endif + +#if !USE_SNPRINTF + /* Allocate a temporary buffer of sufficient size for calling + sprintf. */ + tmp_length = + MAX_ROOM_NEEDED (&a, dp->arg_index, dp->conversion, type, + flags, width, has_precision, precision, + pad_ourselves); + + if (tmp_length <= sizeof (tmpbuf) / sizeof (TCHAR_T)) + tmp = tmpbuf; + else + { + size_t tmp_memsize = xtimes (tmp_length, sizeof (TCHAR_T)); + + if (size_overflow_p (tmp_memsize)) + /* Overflow, would lead to out of memory. */ + goto out_of_memory; + tmp = (TCHAR_T *) malloc (tmp_memsize); + if (tmp == NULL) + /* Out of memory. */ + goto out_of_memory; + } +#endif + + /* Construct the format string for calling snprintf or + sprintf. */ + fbp = buf; + *fbp++ = '%'; +#if NEED_PRINTF_FLAG_GROUPING + /* The underlying implementation doesn't support the ' flag. + Produce no grouping characters in this case; this is + acceptable because the grouping is locale dependent. */ +#else + if (flags & FLAG_GROUP) + *fbp++ = '\''; +#endif + if (flags & FLAG_LEFT) + *fbp++ = '-'; + if (flags & FLAG_SHOWSIGN) + *fbp++ = '+'; + if (flags & FLAG_SPACE) + *fbp++ = ' '; + if (flags & FLAG_ALT) + *fbp++ = '#'; +#if __GLIBC__ >= 2 && !defined __UCLIBC__ + if (flags & FLAG_LOCALIZED) + *fbp++ = 'I'; +#endif + if (!pad_ourselves) + { + if (flags & FLAG_ZERO) + *fbp++ = '0'; + if (dp->width_start != dp->width_end) + { + size_t n = dp->width_end - dp->width_start; + /* The width specification is known to consist only + of standard ASCII characters. */ + if (sizeof (FCHAR_T) == sizeof (TCHAR_T)) + { + memcpy (fbp, dp->width_start, n * sizeof (TCHAR_T)); + fbp += n; + } + else + { + const FCHAR_T *mp = dp->width_start; + do + *fbp++ = *mp++; + while (--n > 0); + } + } + } + if (!prec_ourselves) + { + if (dp->precision_start != dp->precision_end) + { + size_t n = dp->precision_end - dp->precision_start; + /* The precision specification is known to consist only + of standard ASCII characters. */ + if (sizeof (FCHAR_T) == sizeof (TCHAR_T)) + { + memcpy (fbp, dp->precision_start, n * sizeof (TCHAR_T)); + fbp += n; + } + else + { + const FCHAR_T *mp = dp->precision_start; + do + *fbp++ = *mp++; + while (--n > 0); + } + } + } + + switch (type) + { + case TYPE_LONGLONGINT: + case TYPE_ULONGLONGINT: + #if INT8_WIDTH > LONG_WIDTH + case TYPE_INT8_T: + #endif + #if UINT8_WIDTH > LONG_WIDTH + case TYPE_UINT8_T: + #endif + #if INT16_WIDTH > LONG_WIDTH + case TYPE_INT16_T: + #endif + #if UINT16_WIDTH > LONG_WIDTH + case TYPE_UINT16_T: + #endif + #if INT32_WIDTH > LONG_WIDTH + case TYPE_INT32_T: + #endif + #if UINT32_WIDTH > LONG_WIDTH + case TYPE_UINT32_T: + #endif + #if INT64_WIDTH > LONG_WIDTH + case TYPE_INT64_T: + #endif + #if UINT64_WIDTH > LONG_WIDTH + case TYPE_UINT64_T: + #endif + #if INT_FAST8_WIDTH > LONG_WIDTH + case TYPE_INT_FAST8_T: + #endif + #if UINT_FAST8_WIDTH > LONG_WIDTH + case TYPE_UINT_FAST8_T: + #endif + #if INT_FAST16_WIDTH > LONG_WIDTH + case TYPE_INT_FAST16_T: + #endif + #if UINT_FAST16_WIDTH > LONG_WIDTH + case TYPE_UINT_FAST16_T: + #endif + #if INT_FAST32_WIDTH > LONG_WIDTH + case TYPE_INT3_FAST2_T: + #endif + #if UINT_FAST32_WIDTH > LONG_WIDTH + case TYPE_UINT_FAST32_T: + #endif + #if INT_FAST64_WIDTH > LONG_WIDTH + case TYPE_INT_FAST64_T: + #endif + #if UINT_FAST64_WIDTH > LONG_WIDTH + case TYPE_UINT_FAST64_T: + #endif +#if defined _WIN32 && ! defined __CYGWIN__ + *fbp++ = 'I'; + *fbp++ = '6'; + *fbp++ = '4'; + break; +#else + *fbp++ = 'l'; +#endif + FALLTHROUGH; + case TYPE_LONGINT: + case TYPE_ULONGINT: + #if INT8_WIDTH > INT_WIDTH && INT8_WIDTH <= LONG_WIDTH + case TYPE_INT8_T: + #endif + #if UINT8_WIDTH > INT_WIDTH && UINT8_WIDTH <= LONG_WIDTH + case TYPE_UINT8_T: + #endif + #if INT16_WIDTH > INT_WIDTH && INT16_WIDTH <= LONG_WIDTH + case TYPE_INT16_T: + #endif + #if UINT16_WIDTH > INT_WIDTH && UINT16_WIDTH <= LONG_WIDTH + case TYPE_UINT16_T: + #endif + #if INT32_WIDTH > INT_WIDTH && INT32_WIDTH <= LONG_WIDTH + case TYPE_INT32_T: + #endif + #if UINT32_WIDTH > INT_WIDTH && UINT32_WIDTH <= LONG_WIDTH + case TYPE_UINT32_T: + #endif + #if INT64_WIDTH > INT_WIDTH && INT64_WIDTH <= LONG_WIDTH + case TYPE_INT64_T: + #endif + #if UINT64_WIDTH > INT_WIDTH && UINT64_WIDTH <= LONG_WIDTH + case TYPE_UINT64_T: + #endif + #if INT_FAST8_WIDTH > INT_WIDTH && INT_FAST8_WIDTH <= LONG_WIDTH + case TYPE_INT_FAST8_T: + #endif + #if UINT_FAST8_WIDTH > INT_WIDTH && UINT_FAST8_WIDTH <= LONG_WIDTH + case TYPE_UINT_FAST8_T: + #endif + #if INT_FAST16_WIDTH > INT_WIDTH && INT_FAST16_WIDTH <= LONG_WIDTH + case TYPE_INT_FAST16_T: + #endif + #if UINT_FAST16_WIDTH > INT_WIDTH && UINT_FAST16_WIDTH <= LONG_WIDTH + case TYPE_UINT_FAST16_T: + #endif + #if INT_FAST32_WIDTH > INT_WIDTH && INT_FAST32_WIDTH <= LONG_WIDTH + case TYPE_INT_FAST32_T: + #endif + #if UINT_FAST32_WIDTH > INT_WIDTH && UINT_FAST32_WIDTH <= LONG_WIDTH + case TYPE_UINT_FAST32_T: + #endif + #if INT_FAST64_WIDTH > INT_WIDTH && INT_FAST64_WIDTH <= LONG_WIDTH + case TYPE_INT_FAST64_T: + #endif + #if UINT_FAST64_WIDTH > INT_WIDTH && UINT_FAST64_WIDTH <= LONG_WIDTH + case TYPE_UINT_FAST64_T: + #endif + #if HAVE_WINT_T + case TYPE_WIDE_CHAR: + #endif + #if HAVE_WCHAR_T + case TYPE_WIDE_STRING: + #endif + *fbp++ = 'l'; + break; + case TYPE_LONGDOUBLE: + *fbp++ = 'L'; + break; + default: + break; + } +#if NEED_PRINTF_DIRECTIVE_F + if (dp->conversion == 'F') + *fbp = 'f'; + else +#endif + *fbp = dp->conversion; +#if USE_SNPRINTF + /* Decide whether to pass %n in the format string + to SNPRINTF. */ +# if (((!WIDE_CHAR_VERSION || !DCHAR_IS_TCHAR) \ + && (HAVE_SNPRINTF_RETVAL_C99 && HAVE_SNPRINTF_TRUNCATION_C99)) \ + || ((__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) \ + && !defined __UCLIBC__) \ + || (defined __APPLE__ && defined __MACH__) \ + || defined __OpenBSD__ \ + || defined __ANDROID__ \ + || (defined _WIN32 && ! defined __CYGWIN__)) \ + || (WIDE_CHAR_VERSION && MUSL_LIBC) + /* We can avoid passing %n and instead rely on SNPRINTF's + return value if + - !WIDE_CHAR_VERSION || !DCHAR_IS_TCHAR, because otherwise, + when WIDE_CHAR_VERSION && DCHAR_IS_TCHAR, + snwprintf()/_snwprintf() (Windows) and swprintf() (Unix) + don't return the needed buffer size, + and + - we're compiling for a system where we know + - that snprintf's return value conforms to ISO C 99 + (HAVE_SNPRINTF_RETVAL_C99) and + - that snprintf always produces NUL-terminated strings + (HAVE_SNPRINTF_TRUNCATION_C99). + And it is desirable to do so, because more and more platforms + no longer support %n, for "security reasons". */ + /* On specific platforms, listed below, we *must* avoid %n. + In the case + !WIDE_CHAR_VERSION && HAVE_SNPRINTF_RETVAL_C99 && !USE_MSVC__SNPRINTF + we can rely on the return value of snprintf instead. Whereas + in the opposite case + WIDE_CHAR_VERSION || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF + we need to make room based on an estimation, computed by + MAX_ROOM_NEEDED. */ + /* The following platforms forbid %n: + - On glibc2 systems from 2004-10-18 or newer, the use of + %n in format strings in writable memory may crash the + program (if compiled with _FORTIFY_SOURCE=2). + - On macOS 10.13 or newer, the use of %n in format + strings in writable memory by default crashes the + program. + - On OpenBSD, since 2021-08-30, the use of %n in format + strings produces an abort (see + , + ). + - On Android, starting on 2018-03-07, the use of %n in + format strings produces a fatal error (see + ). + - On native Windows systems (such as mingw) where the OS is + Windows Vista, the use of %n in format strings by default + crashes the program. See + and + + On the first four of these platforms, if !WIDE_CHAR_VERSION, + it is not a big deal to avoid %n, because on these platforms, + HAVE_SNPRINTF_RETVAL_C99 and HAVE_SNPRINTF_TRUNCATION_C99 are + 1. + On native Windows, if !WIDE_CHAR_VERSION, it's not a big deal + either because: + - Although the gl_SNPRINTF_TRUNCATION_C99 test fails, + snprintf does not write more than the specified number + of bytes. (snprintf (buf, 3, "%d %d", 4567, 89) writes + '4', '5', '6' into buf, not '4', '5', '\0'.) + - Although the gl_SNPRINTF_RETVAL_C99 test fails, snprintf + allows us to recognize the case of an insufficient + buffer size: it returns -1 in this case. */ + /* Additionally, in the WIDE_CHAR_VERSION case, we cannot use %n + on musl libc because we would run into an swprintf() bug. + See . */ + fbp[1] = '\0'; +# else /* AIX <= 5.1, HP-UX, IRIX, OSF/1, Solaris <= 9, BeOS */ + fbp[1] = '%'; + fbp[2] = 'n'; + fbp[3] = '\0'; +# endif +#else + fbp[1] = '\0'; +#endif + + /* Construct the arguments for calling snprintf or sprintf. */ + prefix_count = 0; + if (!pad_ourselves && dp->width_arg_index != ARG_NONE) + { + if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) + abort (); + prefixes[prefix_count++] = a.arg[dp->width_arg_index].a.a_int; + } + if (!prec_ourselves && dp->precision_arg_index != ARG_NONE) + { + if (!(a.arg[dp->precision_arg_index].type == TYPE_INT)) + abort (); + prefixes[prefix_count++] = a.arg[dp->precision_arg_index].a.a_int; + } + +#if USE_SNPRINTF + /* The SNPRINTF result is appended after result[0..length]. + The latter is an array of DCHAR_T; SNPRINTF appends an + array of TCHAR_T to it. This is possible because + sizeof (TCHAR_T) divides sizeof (DCHAR_T) and + alignof (TCHAR_T) <= alignof (DCHAR_T). */ +# define TCHARS_PER_DCHAR (sizeof (DCHAR_T) / sizeof (TCHAR_T)) + /* Ensure that maxlen below will be >= 2. Needed on BeOS, + where an snprintf() with maxlen==1 acts like sprintf(). */ + ENSURE_ALLOCATION (xsum (length, + (2 + TCHARS_PER_DCHAR - 1) + / TCHARS_PER_DCHAR)); + /* Prepare checking whether snprintf returns the count + via %n. */ + *(TCHAR_T *) (result + length) = '\0'; +#endif + + orig_errno = errno; + + for (;;) + { + int count = -1; + +#if USE_SNPRINTF + int retcount = 0; + size_t maxlen = allocated - length; + /* SNPRINTF can fail if its second argument is + > INT_MAX. */ + if (maxlen > INT_MAX / TCHARS_PER_DCHAR) + maxlen = INT_MAX / TCHARS_PER_DCHAR; + maxlen = maxlen * TCHARS_PER_DCHAR; +# define SNPRINTF_BUF(arg) \ + switch (prefix_count) \ + { \ + case 0: \ + retcount = SNPRINTF ((TCHAR_T *) (result + length), \ + maxlen, buf, \ + arg, &count); \ + break; \ + case 1: \ + retcount = SNPRINTF ((TCHAR_T *) (result + length), \ + maxlen, buf, \ + prefixes[0], arg, &count); \ + break; \ + case 2: \ + retcount = SNPRINTF ((TCHAR_T *) (result + length), \ + maxlen, buf, \ + prefixes[0], prefixes[1], arg, \ + &count); \ + break; \ + default: \ + abort (); \ + } +#else +# define SNPRINTF_BUF(arg) \ + switch (prefix_count) \ + { \ + case 0: \ + count = sprintf (tmp, buf, arg); \ + break; \ + case 1: \ + count = sprintf (tmp, buf, prefixes[0], arg); \ + break; \ + case 2: \ + count = sprintf (tmp, buf, prefixes[0], prefixes[1],\ + arg); \ + break; \ + default: \ + abort (); \ + } +#endif + + errno = 0; + switch (type) + { + case TYPE_SCHAR: + { + int arg = a.arg[dp->arg_index].a.a_schar; + SNPRINTF_BUF (arg); + } + break; + case TYPE_UCHAR: + { + unsigned int arg = a.arg[dp->arg_index].a.a_uchar; + SNPRINTF_BUF (arg); + } + break; + case TYPE_SHORT: + { + int arg = a.arg[dp->arg_index].a.a_short; + SNPRINTF_BUF (arg); + } + break; + case TYPE_USHORT: + { + unsigned int arg = a.arg[dp->arg_index].a.a_ushort; + SNPRINTF_BUF (arg); + } + break; + case TYPE_INT: + { + int arg = a.arg[dp->arg_index].a.a_int; + SNPRINTF_BUF (arg); + } + break; + case TYPE_UINT: + { + unsigned int arg = a.arg[dp->arg_index].a.a_uint; + SNPRINTF_BUF (arg); + } + break; + case TYPE_LONGINT: + { + long int arg = a.arg[dp->arg_index].a.a_longint; + SNPRINTF_BUF (arg); + } + break; + case TYPE_ULONGINT: + { + unsigned long int arg = a.arg[dp->arg_index].a.a_ulongint; + SNPRINTF_BUF (arg); + } + break; + case TYPE_LONGLONGINT: + { + long long int arg = a.arg[dp->arg_index].a.a_longlongint; + SNPRINTF_BUF (arg); + } + break; + case TYPE_ULONGLONGINT: + { + unsigned long long int arg = a.arg[dp->arg_index].a.a_ulonglongint; + SNPRINTF_BUF (arg); + } + break; + case TYPE_INT8_T: + { + int8_t arg = a.arg[dp->arg_index].a.a_int8_t; + SNPRINTF_BUF (arg); + } + break; + case TYPE_UINT8_T: + { + uint8_t arg = a.arg[dp->arg_index].a.a_uint8_t; + SNPRINTF_BUF (arg); + } + break; + case TYPE_INT16_T: + { + int16_t arg = a.arg[dp->arg_index].a.a_int16_t; + SNPRINTF_BUF (arg); + } + break; + case TYPE_UINT16_T: + { + uint16_t arg = a.arg[dp->arg_index].a.a_uint16_t; + SNPRINTF_BUF (arg); + } + break; + case TYPE_INT32_T: + { + int32_t arg = a.arg[dp->arg_index].a.a_int32_t; + SNPRINTF_BUF (arg); + } + break; + case TYPE_UINT32_T: + { + uint32_t arg = a.arg[dp->arg_index].a.a_uint32_t; + SNPRINTF_BUF (arg); + } + break; + case TYPE_INT64_T: + { + int64_t arg = a.arg[dp->arg_index].a.a_int64_t; + SNPRINTF_BUF (arg); + } + break; + case TYPE_UINT64_T: + { + uint64_t arg = a.arg[dp->arg_index].a.a_uint64_t; + SNPRINTF_BUF (arg); + } + break; + case TYPE_INT_FAST8_T: + { + int_fast8_t arg = a.arg[dp->arg_index].a.a_int_fast8_t; + SNPRINTF_BUF (arg); + } + break; + case TYPE_UINT_FAST8_T: + { + uint_fast8_t arg = a.arg[dp->arg_index].a.a_uint_fast8_t; + SNPRINTF_BUF (arg); + } + break; + case TYPE_INT_FAST16_T: + { + int_fast16_t arg = a.arg[dp->arg_index].a.a_int_fast16_t; + SNPRINTF_BUF (arg); + } + break; + case TYPE_UINT_FAST16_T: + { + uint_fast16_t arg = a.arg[dp->arg_index].a.a_uint_fast16_t; + SNPRINTF_BUF (arg); + } + break; + case TYPE_INT_FAST32_T: + { + int_fast32_t arg = a.arg[dp->arg_index].a.a_int_fast32_t; + SNPRINTF_BUF (arg); + } + break; + case TYPE_UINT_FAST32_T: + { + uint_fast32_t arg = a.arg[dp->arg_index].a.a_uint_fast32_t; + SNPRINTF_BUF (arg); + } + break; + case TYPE_INT_FAST64_T: + { + int_fast64_t arg = a.arg[dp->arg_index].a.a_int_fast64_t; + SNPRINTF_BUF (arg); + } + break; + case TYPE_UINT_FAST64_T: + { + uint_fast64_t arg = a.arg[dp->arg_index].a.a_uint_fast64_t; + SNPRINTF_BUF (arg); + } + break; + case TYPE_DOUBLE: + { + double arg = a.arg[dp->arg_index].a.a_double; + SNPRINTF_BUF (arg); + } + break; + case TYPE_LONGDOUBLE: + { + long double arg = a.arg[dp->arg_index].a.a_longdouble; + SNPRINTF_BUF (arg); + } + break; + case TYPE_CHAR: + { + int arg = a.arg[dp->arg_index].a.a_char; + SNPRINTF_BUF (arg); + } + break; +#if HAVE_WINT_T + case TYPE_WIDE_CHAR: + { + wint_t arg = a.arg[dp->arg_index].a.a_wide_char; + SNPRINTF_BUF (arg); + } + break; +#endif + case TYPE_STRING: + { + const char *arg = a.arg[dp->arg_index].a.a_string; + SNPRINTF_BUF (arg); + } + break; +#if HAVE_WCHAR_T + case TYPE_WIDE_STRING: + { + const wchar_t *arg = a.arg[dp->arg_index].a.a_wide_string; + SNPRINTF_BUF (arg); + } + break; +#endif + case TYPE_POINTER: + { + void *arg = a.arg[dp->arg_index].a.a_pointer; + SNPRINTF_BUF (arg); + } + break; + default: + abort (); + } + +#if USE_SNPRINTF + /* Portability: Not all implementations of snprintf() + are ISO C 99 compliant. Determine the number of + bytes that snprintf() has produced or would have + produced. */ + if (count >= 0) + { + /* Verify that snprintf() has NUL-terminated its + result. */ + if ((unsigned int) count < maxlen + && ((TCHAR_T *) (result + length)) [count] != '\0') + abort (); + /* Portability hack. */ + if (retcount > count) + count = retcount; + } + else + { + /* snprintf() doesn't understand the '%n' + directive. */ + if (fbp[1] != '\0') + { + /* Don't use the '%n' directive; instead, look + at the snprintf() return value. */ + fbp[1] = '\0'; + continue; + } + else + { + /* Look at the snprintf() return value. */ + if (retcount < 0) + { +# if (WIDE_CHAR_VERSION && DCHAR_IS_TCHAR) || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF + /* HP-UX 10.20 snprintf() is doubly deficient: + It doesn't understand the '%n' directive, + *and* it returns -1 (rather than the length + that would have been required) when the + buffer is too small. + Likewise, in case of + WIDE_CHAR_VERSION && DCHAR_IS_TCHAR, the + functions snwprintf()/_snwprintf() (Windows) + or swprintf() (Unix). + But a failure at this point can also come + from other reasons than a too small buffer, + such as an invalid wide string argument to + the %ls directive, or possibly an invalid + floating-point argument. */ + size_t tmp_length = + MAX_ROOM_NEEDED (&a, dp->arg_index, + dp->conversion, type, flags, + width, + has_precision, + precision, pad_ourselves); + + if (maxlen < tmp_length) + { + /* Make more room. But try to do through + this reallocation only once. */ + size_t bigger_need = + xsum (length, + xsum (tmp_length, + TCHARS_PER_DCHAR - 1) + / TCHARS_PER_DCHAR); + /* And always grow proportionally. + (There may be several arguments, each + needing a little more room than the + previous one.) */ + size_t bigger_need2 = + xsum (xtimes (allocated, 2), 12); + if (bigger_need < bigger_need2) + bigger_need = bigger_need2; + ENSURE_ALLOCATION (bigger_need); + continue; + } +# endif + } + else + { + count = retcount; +# if WIDE_CHAR_VERSION && defined __MINGW32__ + if (count == 0 && dp->conversion == 'c') + /* snwprintf returned 0 instead of 1. But it + wrote a null wide character. */ + count = 1; +# endif + } + } + } +#endif + + /* Attempt to handle failure. */ + if (count < 0) + { + /* SNPRINTF or sprintf failed. Use the errno that it + has set, if any. */ + if (errno == 0) + { + if (dp->conversion == 'c' || dp->conversion == 's') + errno = EILSEQ; + else + errno = EINVAL; + } + + goto fail_with_errno; + } + +#if USE_SNPRINTF + /* Handle overflow of the allocated buffer. + If such an overflow occurs, a C99 compliant snprintf() + returns a count >= maxlen. However, a non-compliant + snprintf() function returns only count = maxlen - 1. To + cover both cases, test whether count >= maxlen - 1. */ + if ((unsigned int) count + 1 >= maxlen) + { + /* If maxlen already has attained its allowed maximum, + allocating more memory will not increase maxlen. + Instead of looping, bail out. */ + if (maxlen == INT_MAX / TCHARS_PER_DCHAR) + goto overflow; + else + { + /* Need at least (count + 1) * sizeof (TCHAR_T) + bytes. (The +1 is for the trailing NUL.) + But ask for (count + 2) * sizeof (TCHAR_T) + bytes, so that in the next round, we likely get + maxlen > (unsigned int) count + 1 + and so we don't get here again. + And allocate proportionally, to avoid looping + eternally if snprintf() reports a too small + count. */ + size_t n = + xmax (xsum (length, + ((unsigned int) count + 2 + + TCHARS_PER_DCHAR - 1) + / TCHARS_PER_DCHAR), + xtimes (allocated, 2)); + + ENSURE_ALLOCATION (n); + continue; + } + } +#endif + +#if NEED_PRINTF_FLAG_ALT_PRECISION_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION + if (prec_ourselves) + { + /* Handle the precision. */ + TCHAR_T *prec_ptr = +# if USE_SNPRINTF + (TCHAR_T *) (result + length); +# else + tmp; +# endif + size_t prefix_count; + size_t move; + + prefix_count = 0; + /* Put the additional zeroes after the sign. */ + if (count >= 1 + && (*prec_ptr == '-' || *prec_ptr == '+' + || *prec_ptr == ' ')) + prefix_count = 1; + /* Put the additional zeroes after the 0x prefix if + (flags & FLAG_ALT) || (dp->conversion == 'p'). */ + else if (count >= 2 + && prec_ptr[0] == '0' + && (prec_ptr[1] == 'x' || prec_ptr[1] == 'X')) + prefix_count = 2; + + move = count - prefix_count; + if (precision > move) + { + /* Insert zeroes. */ + size_t insert = precision - move; + TCHAR_T *prec_end; + +# if USE_SNPRINTF + size_t n = + xsum (length, + (count + insert + TCHARS_PER_DCHAR - 1) + / TCHARS_PER_DCHAR); + length += (count + TCHARS_PER_DCHAR - 1) / TCHARS_PER_DCHAR; + ENSURE_ALLOCATION (n); + length -= (count + TCHARS_PER_DCHAR - 1) / TCHARS_PER_DCHAR; + prec_ptr = (TCHAR_T *) (result + length); +# endif + + prec_end = prec_ptr + count; + prec_ptr += prefix_count; + + while (prec_end > prec_ptr) + { + prec_end--; + prec_end[insert] = prec_end[0]; + } + + prec_end += insert; + do + *--prec_end = '0'; + while (prec_end > prec_ptr); + + count += insert; + } +# if NEED_PRINTF_FLAG_ALT_PRECISION_ZERO + else if (precision == 0 + && move == 1 + && prec_ptr[prefix_count] == '0') + { + /* Replace the "0" result with an empty string. */ + count = prefix_count; + } +# endif + } +#endif + +#if !USE_SNPRINTF + if (count >= tmp_length) + /* tmp_length was incorrectly calculated - fix the + code above! */ + abort (); +#endif + +#if !DCHAR_IS_TCHAR + /* Convert from TCHAR_T[] to DCHAR_T[]. */ + if (dp->conversion == 'c' || dp->conversion == 's' +# if __GLIBC__ >= 2 && !defined __UCLIBC__ + || (flags & FLAG_LOCALIZED) +# endif + ) + { + /* The result string is not guaranteed to be ASCII. */ + const TCHAR_T *tmpsrc; + DCHAR_T *tmpdst; + size_t tmpdst_len; + /* This code assumes that TCHAR_T is 'char'. */ + static_assert (sizeof (TCHAR_T) == 1); +# if USE_SNPRINTF + tmpsrc = (TCHAR_T *) (result + length); +# else + tmpsrc = tmp; +# endif +# if WIDE_CHAR_VERSION + /* Convert tmpsrc[0..count-1] to a freshly allocated + wide character array. */ + mbstate_t state; + + mbszero (&state); + tmpdst_len = 0; + { + const TCHAR_T *src = tmpsrc; + size_t srclen = count; + + for (; srclen > 0; tmpdst_len++) + { + /* Parse the next multibyte character. */ + size_t ret = mbrtowc (NULL, src, srclen, &state); + if (ret == (size_t)(-2) || ret == (size_t)(-1)) + goto fail_with_EILSEQ; + if (ret == 0) + ret = 1; + src += ret; + srclen -= ret; + } + } + + tmpdst = + (wchar_t *) malloc ((tmpdst_len + 1) * sizeof (wchar_t)); + if (tmpdst == NULL) + goto out_of_memory; + + mbszero (&state); + { + DCHAR_T *destptr = tmpdst; + const TCHAR_T *src = tmpsrc; + size_t srclen = count; + + for (; srclen > 0; destptr++) + { + /* Parse the next multibyte character. */ + size_t ret = mbrtowc (destptr, src, srclen, &state); + if (ret == (size_t)(-2) || ret == (size_t)(-1)) + /* Should already have been caught in the first + loop, above. */ + abort (); + if (ret == 0) + ret = 1; + src += ret; + srclen -= ret; + } + } +# else + tmpdst = + DCHAR_CONV_FROM_ENCODING (locale_charset (), + iconveh_question_mark, + tmpsrc, count, + NULL, + NULL, &tmpdst_len); + if (tmpdst == NULL) + goto fail_with_errno; +# endif + ENSURE_ALLOCATION_ELSE (xsum (length, tmpdst_len), + { free (tmpdst); goto out_of_memory; }); + DCHAR_CPY (result + length, tmpdst, tmpdst_len); + free (tmpdst); + count = tmpdst_len; + } + else + { + /* The result string is ASCII. + Simple 1:1 conversion. */ +# if USE_SNPRINTF + /* If sizeof (DCHAR_T) == sizeof (TCHAR_T), it's a + no-op conversion, in-place on the array starting + at (result + length). */ + if (sizeof (DCHAR_T) != sizeof (TCHAR_T)) +# endif + { + const TCHAR_T *tmpsrc; + DCHAR_T *tmpdst; + size_t n; + +# if USE_SNPRINTF + if (result == resultbuf) + { + tmpsrc = (TCHAR_T *) (result + length); + /* ENSURE_ALLOCATION will not move tmpsrc + (because it's part of resultbuf). */ + ENSURE_ALLOCATION (xsum (length, count)); + } + else + { + /* ENSURE_ALLOCATION will move the array + (because it uses realloc(). */ + ENSURE_ALLOCATION (xsum (length, count)); + tmpsrc = (TCHAR_T *) (result + length); + } +# else + tmpsrc = tmp; + ENSURE_ALLOCATION (xsum (length, count)); +# endif + tmpdst = result + length; + /* Copy backwards, because of overlapping. */ + tmpsrc += count; + tmpdst += count; + for (n = count; n > 0; n--) + *--tmpdst = *--tmpsrc; + } + } +#endif + +#if DCHAR_IS_TCHAR && !USE_SNPRINTF + /* Make room for the result. */ + if (count > allocated - length) + { + /* Need at least count elements. But allocate + proportionally. */ + size_t n = + xmax (xsum (length, count), xtimes (allocated, 2)); + + ENSURE_ALLOCATION (n); + } +#endif + + /* Here count <= allocated - length. */ + + /* Perform padding. */ +#if (WIDE_CHAR_VERSION && MUSL_LIBC) || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_FLAG_ALT_PRECISION_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION + if (pad_ourselves && has_width) + { + size_t w; +# if ENABLE_UNISTDIO + /* Outside POSIX, it's preferable to compare the width + against the number of _characters_ of the converted + value. */ + w = DCHAR_MBSNLEN (result + length, count); +# else + /* The width is compared against the number of _bytes_ + of the converted value, says POSIX. */ + w = count; +# endif + if (w < width) + { + size_t pad = width - w; + + /* Make room for the result. */ + if (xsum (count, pad) > allocated - length) + { + /* Need at least count + pad elements. But + allocate proportionally. */ + size_t n = + xmax (xsum3 (length, count, pad), + xtimes (allocated, 2)); + +# if USE_SNPRINTF + length += count; + ENSURE_ALLOCATION (n); + length -= count; +# else + ENSURE_ALLOCATION (n); +# endif + } + /* Here count + pad <= allocated - length. */ + + { +# if !DCHAR_IS_TCHAR || USE_SNPRINTF + DCHAR_T * const rp = result + length; +# else + DCHAR_T * const rp = tmp; +# endif + DCHAR_T *p = rp + count; + DCHAR_T *end = p + pad; + DCHAR_T *pad_ptr; +# if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO + if (dp->conversion == 'c' + || dp->conversion == 's') + /* No zero-padding for string directives. */ + pad_ptr = NULL; + else +# endif + { + pad_ptr = (*rp == '-' ? rp + 1 : rp); + /* No zero-padding of "inf" and "nan". */ + if ((*pad_ptr >= 'A' && *pad_ptr <= 'Z') + || (*pad_ptr >= 'a' && *pad_ptr <= 'z')) + pad_ptr = NULL; + else + /* Do the zero-padding after the "0x" or + "0b" prefix, not before. */ + if (p - rp >= 2 + && *rp == '0' + && (((dp->conversion == 'a' + || dp->conversion == 'x') + && rp[1] == 'x') + || ((dp->conversion == 'A' + || dp->conversion == 'X') + && rp[1] == 'X') + || (dp->conversion == 'b' + && rp[1] == 'b') + || (dp->conversion == 'B' + && rp[1] == 'B'))) + pad_ptr += 2; + } + /* The generated string now extends from rp to p, + with the zero padding insertion point being at + pad_ptr. */ + + count = count + pad; /* = end - rp */ + + if (flags & FLAG_LEFT) + { + /* Pad with spaces on the right. */ + for (; pad > 0; pad--) + *p++ = ' '; + } + else if ((flags & FLAG_ZERO) && pad_ptr != NULL + /* ISO C says: "For d, i, o, u, x, and X + conversions, if a precision is + specified, the 0 flag is ignored. */ + && !(has_precision + && (dp->conversion == 'd' + || dp->conversion == 'i' + || dp->conversion == 'o' + || dp->conversion == 'u' + || dp->conversion == 'x' + || dp->conversion == 'X' + /* Although ISO C does not + require it, treat 'b' and 'B' + like 'x' and 'X'. */ + || dp->conversion == 'b' + || dp->conversion == 'B'))) + { + /* Pad with zeroes. */ + DCHAR_T *q = end; + + while (p > pad_ptr) + *--q = *--p; + for (; pad > 0; pad--) + *p++ = '0'; + } + else + { + /* Pad with spaces on the left. */ + DCHAR_T *q = end; + + while (p > rp) + *--q = *--p; + for (; pad > 0; pad--) + *p++ = ' '; + } + } + } + } +#endif + + /* Here still count <= allocated - length. */ + +#if !DCHAR_IS_TCHAR || USE_SNPRINTF + /* The snprintf() result did fit. */ +#else + /* Append the sprintf() result. */ + memcpy (result + length, tmp, count * sizeof (DCHAR_T)); +#endif +#if !USE_SNPRINTF + if (tmp != tmpbuf) + free (tmp); +#endif + +#if NEED_PRINTF_DIRECTIVE_F + if (dp->conversion == 'F') + { + /* Convert the %f result to upper case for %F. */ + DCHAR_T *rp = result + length; + size_t rc; + for (rc = count; rc > 0; rc--, rp++) + if (*rp >= 'a' && *rp <= 'z') + *rp = *rp - 'a' + 'A'; + } +#endif + + length += count; + break; + } + errno = orig_errno; +#undef pad_ourselves +#undef prec_ourselves + } + } + } + + /* Add the final NUL. */ + ENSURE_ALLOCATION (xsum (length, 1)); + result[length] = '\0'; + + if (result != resultbuf && length + 1 < allocated) + { + /* Shrink the allocated memory if possible. */ + DCHAR_T *memory; + + memory = (DCHAR_T *) realloc (result, (length + 1) * sizeof (DCHAR_T)); + if (memory != NULL) + result = memory; + } + + if (buf_malloced != NULL) + free (buf_malloced); + CLEANUP (); + *lengthp = length; + /* Note that we can produce a big string of a length > INT_MAX. POSIX + says that snprintf() fails with errno = EOVERFLOW in this case, but + that's only because snprintf() returns an 'int'. This function does + not have this limitation. */ + return result; + +#if USE_SNPRINTF + overflow: + errno = EOVERFLOW; + goto fail_with_errno; +#endif + + out_of_memory: + errno = ENOMEM; + goto fail_with_errno; + +#if ENABLE_UNISTDIO || ((!USE_SNPRINTF || WIDE_CHAR_VERSION || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || NEED_PRINTF_DIRECTIVE_LS || ENABLE_WCHAR_FALLBACK) && HAVE_WCHAR_T) || ((NEED_PRINTF_DIRECTIVE_LC || ENABLE_WCHAR_FALLBACK) && HAVE_WINT_T && !WIDE_CHAR_VERSION) || (NEED_WPRINTF_DIRECTIVE_C && WIDE_CHAR_VERSION) + fail_with_EILSEQ: + errno = EILSEQ; + goto fail_with_errno; +#endif + + fail_with_errno: + if (result != resultbuf) + free (result); + if (buf_malloced != NULL) + free (buf_malloced); + CLEANUP (); + return NULL; + } + + out_of_memory_1: + errno = ENOMEM; + goto fail_1_with_errno; + + fail_1_with_EINVAL: + errno = EINVAL; + goto fail_1_with_errno; + + fail_1_with_errno: + CLEANUP (); + return NULL; +} + +#undef MAX_ROOM_NEEDED +#undef TCHARS_PER_DCHAR +#undef SNPRINTF +#undef USE_SNPRINTF +#undef DCHAR_SET +#undef DCHAR_CPY +#undef PRINTF_PARSE +#undef DIRECTIVES +#undef DIRECTIVE +#undef DCHAR_IS_TCHAR +#undef TCHAR_T +#undef DCHAR_T +#undef FCHAR_T +#undef VASNPRINTF diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/vasnprintf.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/vasnprintf.h new file mode 100644 index 00000000..7ed9145c --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/vasnprintf.h @@ -0,0 +1,77 @@ +/* vsprintf with automatic memory allocation. + Copyright (C) 2002-2004, 2007-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef _VASNPRINTF_H +#define _VASNPRINTF_H + +/* This file uses _GL_ATTRIBUTE_FORMAT. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +/* Get va_list. */ +#include + +/* Get size_t. */ +#include + +/* Get _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD. */ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Write formatted output to a string dynamically allocated with malloc(). + You can pass a preallocated buffer for the result in RESULTBUF and its + size in *LENGTHP; otherwise you pass RESULTBUF = NULL. + If successful, return the address of the string (this may be = RESULTBUF + if no dynamic memory allocation was necessary) and set *LENGTHP to the + number of resulting bytes, excluding the trailing NUL. Upon error, set + errno and return NULL. + + When dynamic memory allocation occurs, the preallocated buffer is left + alone (with possibly modified contents). This makes it possible to use + a statically allocated or stack-allocated buffer, like this: + + char buf[100]; + size_t len = sizeof (buf); + char *output = vasnprintf (buf, &len, format, args); + if (output == NULL) + ... error handling ...; + else + { + ... use the output string ...; + if (output != buf) + free (output); + } + */ +#if REPLACE_VASNPRINTF +# define asnprintf rpl_asnprintf +# define vasnprintf rpl_vasnprintf +#endif +extern char * asnprintf (char *restrict resultbuf, size_t *lengthp, + const char *format, ...) + _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, 3, 4)); +extern char * vasnprintf (char *restrict resultbuf, size_t *lengthp, + const char *format, va_list args) + _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, 3, 0)); + +#ifdef __cplusplus +} +#endif + +#endif /* _VASNPRINTF_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/w32sock.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/w32sock.h new file mode 100644 index 00000000..166a5f77 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/w32sock.h @@ -0,0 +1,140 @@ +/* w32sock.h --- internal auxiliary functions for Windows socket functions + + Copyright (C) 2008-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Paolo Bonzini */ + +#include + +/* Get O_RDWR and O_BINARY. */ +#include + +/* Get _open_osfhandle(). */ +#include + +/* Get _get_osfhandle(). */ +#if GNULIB_MSVC_NOTHROW +# include "msvc-nothrow.h" +#else +# include +#endif + +#define FD_TO_SOCKET(fd) ((SOCKET) _get_osfhandle ((fd))) +#define SOCKET_TO_FD(fh) (_open_osfhandle ((intptr_t) (fh), O_RDWR | O_BINARY)) + +static inline void +set_winsock_errno (void) +{ + int err = WSAGetLastError (); + + /* Map some WSAE* errors to the runtime library's error codes. */ + switch (err) + { + case WSA_INVALID_HANDLE: + errno = EBADF; + break; + case WSA_NOT_ENOUGH_MEMORY: + errno = ENOMEM; + break; + case WSA_INVALID_PARAMETER: + errno = EINVAL; + break; + case WSAENAMETOOLONG: + errno = ENAMETOOLONG; + break; + case WSAENOTEMPTY: + errno = ENOTEMPTY; + break; + case WSAEWOULDBLOCK: + errno = EWOULDBLOCK; + break; + case WSAEINPROGRESS: + errno = EINPROGRESS; + break; + case WSAEALREADY: + errno = EALREADY; + break; + case WSAENOTSOCK: + errno = ENOTSOCK; + break; + case WSAEDESTADDRREQ: + errno = EDESTADDRREQ; + break; + case WSAEMSGSIZE: + errno = EMSGSIZE; + break; + case WSAEPROTOTYPE: + errno = EPROTOTYPE; + break; + case WSAENOPROTOOPT: + errno = ENOPROTOOPT; + break; + case WSAEPROTONOSUPPORT: + errno = EPROTONOSUPPORT; + break; + case WSAEOPNOTSUPP: + errno = EOPNOTSUPP; + break; + case WSAEAFNOSUPPORT: + errno = EAFNOSUPPORT; + break; + case WSAEADDRINUSE: + errno = EADDRINUSE; + break; + case WSAEADDRNOTAVAIL: + errno = EADDRNOTAVAIL; + break; + case WSAENETDOWN: + errno = ENETDOWN; + break; + case WSAENETUNREACH: + errno = ENETUNREACH; + break; + case WSAENETRESET: + errno = ENETRESET; + break; + case WSAECONNABORTED: + errno = ECONNABORTED; + break; + case WSAECONNRESET: + errno = ECONNRESET; + break; + case WSAENOBUFS: + errno = ENOBUFS; + break; + case WSAEISCONN: + errno = EISCONN; + break; + case WSAENOTCONN: + errno = ENOTCONN; + break; + case WSAETIMEDOUT: + errno = ETIMEDOUT; + break; + case WSAECONNREFUSED: + errno = ECONNREFUSED; + break; + case WSAELOOP: + errno = ELOOP; + break; + case WSAEHOSTUNREACH: + errno = EHOSTUNREACH; + break; + default: + errno = (err > 10000 && err < 10025) ? err - 10000 : err; + break; + } +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/warn-on-use.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/warn-on-use.h new file mode 100644 index 00000000..8f4d40dc --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/warn-on-use.h @@ -0,0 +1,149 @@ +/* A C macro for emitting warnings if a function is used. + Copyright (C) 2010-2024 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* _GL_WARN_ON_USE (function, "literal string") issues a declaration + for FUNCTION which will then trigger a compiler warning containing + the text of "literal string" anywhere that function is called, if + supported by the compiler. If the compiler does not support this + feature, the macro expands to an unused extern declaration. + + _GL_WARN_ON_USE_ATTRIBUTE ("literal string") expands to the + attribute used in _GL_WARN_ON_USE. If the compiler does not support + this feature, it expands to empty. + + These macros are useful for marking a function as a potential + portability trap, with the intent that "literal string" include + instructions on the replacement function that should be used + instead. + _GL_WARN_ON_USE is for functions with 'extern' linkage. + _GL_WARN_ON_USE_ATTRIBUTE is for functions with 'static' or 'inline' + linkage. + + However, one of the reasons that a function is a portability trap is + if it has the wrong signature. Declaring FUNCTION with a different + signature in C is a compilation error, so this macro must use the + same type as any existing declaration so that programs that avoid + the problematic FUNCTION do not fail to compile merely because they + included a header that poisoned the function. But this implies that + _GL_WARN_ON_USE is only safe to use if FUNCTION is known to already + have a declaration. Use of this macro implies that there must not + be any other macro hiding the declaration of FUNCTION; but + undefining FUNCTION first is part of the poisoning process anyway + (although for symbols that are provided only via a macro, the result + is a compilation error rather than a warning containing + "literal string"). Also note that in C++, it is only safe to use if + FUNCTION has no overloads. + + For an example, it is possible to poison 'getline' by: + - adding a call to gl_WARN_ON_USE_PREPARE([[#include ]], + [getline]) in configure.ac, which potentially defines + HAVE_RAW_DECL_GETLINE + - adding this code to a header that wraps the system : + #undef getline + #if HAVE_RAW_DECL_GETLINE + _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but" + "not universally present; use the gnulib module getline"); + #endif + + It is not possible to directly poison global variables. But it is + possible to write a wrapper accessor function, and poison that + (less common usage, like &environ, will cause a compilation error + rather than issue the nice warning, but the end result of informing + the developer about their portability problem is still achieved): + #if HAVE_RAW_DECL_ENVIRON + static char *** + rpl_environ (void) { return &environ; } + _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared"); + # undef environ + # define environ (*rpl_environ ()) + #endif + or better (avoiding contradictory use of 'static' and 'extern'): + #if HAVE_RAW_DECL_ENVIRON + static char *** + _GL_WARN_ON_USE_ATTRIBUTE ("environ is not always properly declared") + rpl_environ (void) { return &environ; } + # undef environ + # define environ (*rpl_environ ()) + #endif + */ +#ifndef _GL_WARN_ON_USE + +# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) +/* A compiler attribute is available in gcc versions 4.3.0 and later. */ +# define _GL_WARN_ON_USE(function, message) \ +_GL_WARN_EXTERN_C __typeof__ (function) function __attribute__ ((__warning__ (message))) +# define _GL_WARN_ON_USE_ATTRIBUTE(message) \ + __attribute__ ((__warning__ (message))) +# elif __clang_major__ >= 4 +/* Another compiler attribute is available in clang. */ +# define _GL_WARN_ON_USE(function, message) \ +_GL_WARN_EXTERN_C __typeof__ (function) function \ + __attribute__ ((__diagnose_if__ (1, message, "warning"))) +# define _GL_WARN_ON_USE_ATTRIBUTE(message) \ + __attribute__ ((__diagnose_if__ (1, message, "warning"))) +# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING +/* Verify the existence of the function. */ +# define _GL_WARN_ON_USE(function, message) \ +_GL_WARN_EXTERN_C __typeof__ (function) function +# define _GL_WARN_ON_USE_ATTRIBUTE(message) +# else /* Unsupported. */ +# define _GL_WARN_ON_USE(function, message) \ +_GL_WARN_EXTERN_C int _gl_warn_on_use +# define _GL_WARN_ON_USE_ATTRIBUTE(message) +# endif +#endif + +/* _GL_WARN_ON_USE_CXX (function, rettype_gcc, rettype_clang, parameters_and_attributes, "message") + is like _GL_WARN_ON_USE (function, "message"), except that in C++ mode the + function is declared with the given prototype, consisting of return type, + parameters, and attributes. + This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does + not work in this case. */ +#ifndef _GL_WARN_ON_USE_CXX +# if !defined __cplusplus +# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \ + _GL_WARN_ON_USE (function, msg) +# else +# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) +/* A compiler attribute is available in gcc versions 4.3.0 and later. */ +# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \ +extern rettype_gcc function parameters_and_attributes \ + __attribute__ ((__warning__ (msg))) +# elif __clang_major__ >= 4 +/* Another compiler attribute is available in clang. */ +# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \ +extern rettype_clang function parameters_and_attributes \ + __attribute__ ((__diagnose_if__ (1, msg, "warning"))) +# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING +/* Verify the existence of the function. */ +# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \ +extern rettype_gcc function parameters_and_attributes +# else /* Unsupported. */ +# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \ +_GL_WARN_EXTERN_C int _gl_warn_on_use +# endif +# endif +#endif + +/* _GL_WARN_EXTERN_C declaration; + performs the declaration with C linkage. */ +#ifndef _GL_WARN_EXTERN_C +# if defined __cplusplus +# define _GL_WARN_EXTERN_C extern "C" +# else +# define _GL_WARN_EXTERN_C extern +# endif +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/wctob.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/wctob.c new file mode 100644 index 00000000..e1f27404 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/wctob.c @@ -0,0 +1,38 @@ +/* Convert wide character to unibyte character. + Copyright (C) 2008, 2010-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2008. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +#include +#include + +int +wctob (wint_t wc) +{ + char buf[64]; + + if (!(MB_CUR_MAX <= sizeof (buf))) + abort (); + /* Handle the case where WEOF is a value that does not fit in a wchar_t. */ + if (wc == (wchar_t)wc) + if (wctomb (buf, (wchar_t)wc) == 1) + return (unsigned char) buf[0]; + return EOF; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/wctomb-impl.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/wctomb-impl.h new file mode 100644 index 00000000..ccec9ce0 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/wctomb-impl.h @@ -0,0 +1,34 @@ +/* Convert wide character to multibyte character. + Copyright (C) 2011-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2011. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +int +wctomb (char *s, wchar_t wc) +{ + if (s == NULL) + return 0; + else + { + mbstate_t state; + size_t result; + + mbszero (&state); + result = wcrtomb (s, wc, &state); + if (result == (size_t)-1) + return -1; + return result; + } +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/wctomb.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/wctomb.c new file mode 100644 index 00000000..694c95ca --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/wctomb.c @@ -0,0 +1,25 @@ +/* Convert wide character to multibyte character. + Copyright (C) 2011-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2011. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +#include + +#include +#include + +#include "wctomb-impl.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/windows-thread.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/windows-thread.c new file mode 100644 index 00000000..6a47a31f --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/windows-thread.c @@ -0,0 +1,243 @@ +/* Creating and controlling threads (native Windows implementation). + Copyright (C) 2005-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 2005. + Based on GCC's gthr-win32.h. */ + +#include + +/* Specification. */ +#include "windows-thread.h" + +#include +#include +#include + +#include "windows-once.h" +#include "windows-tls.h" + +/* The Thread-Local Storage (TLS) key that allows to access each thread's + 'struct glwthread_thread_struct *' pointer. */ +static DWORD self_key = (DWORD)-1; + +/* Initializes self_key. This function must only be called once. */ +static void +do_init_self_key (void) +{ + self_key = TlsAlloc (); + /* If this fails, we're hosed. */ + if (self_key == (DWORD)-1) + abort (); +} + +/* Initializes self_key. */ +static void +init_self_key (void) +{ + static glwthread_once_t once = GLWTHREAD_ONCE_INIT; + glwthread_once (&once, do_init_self_key); +} + +/* This structure contains information about a thread. + It is stored in TLS under key self_key. */ +struct glwthread_thread_struct +{ + /* Fields for managing the handle. */ + HANDLE volatile handle; + CRITICAL_SECTION handle_lock; + /* Fields for managing the exit value. */ + BOOL volatile detached; + void * volatile result; + /* Fields for managing the thread start. */ + void * (*func) (void *); + void *arg; +}; + +/* Return a real HANDLE object for the current thread. */ +static HANDLE +get_current_thread_handle (void) +{ + HANDLE this_handle; + + /* GetCurrentThread() returns a pseudo-handle, i.e. only a symbolic + identifier, not a real handle. */ + if (!DuplicateHandle (GetCurrentProcess (), GetCurrentThread (), + GetCurrentProcess (), &this_handle, + 0, FALSE, DUPLICATE_SAME_ACCESS)) + abort (); + return this_handle; +} + +glwthread_thread_t +glwthread_thread_self (void) +{ + glwthread_thread_t thread; + + if (self_key == (DWORD)-1) + init_self_key (); + thread = TlsGetValue (self_key); + if (thread == NULL) + { + /* This happens only in threads that have not been created through + glthread_create(), such as the main thread. */ + for (;;) + { + thread = + (struct glwthread_thread_struct *) + malloc (sizeof (struct glwthread_thread_struct)); + if (thread != NULL) + break; + /* Memory allocation failed. There is not much we can do. Have to + busy-loop, waiting for the availability of memory. */ + Sleep (1); + } + + thread->handle = get_current_thread_handle (); + InitializeCriticalSection (&thread->handle_lock); + thread->detached = FALSE; /* This can lead to a memory leak. */ + thread->result = NULL; /* just to be deterministic */ + TlsSetValue (self_key, thread); + } + return thread; +} + +/* The main function of a freshly creating thread. It's a wrapper around + the FUNC and ARG arguments passed to glthread_create_func. */ +static unsigned int WINAPI +wrapper_func (void *varg) +{ + struct glwthread_thread_struct *thread = + (struct glwthread_thread_struct *) varg; + + EnterCriticalSection (&thread->handle_lock); + /* Create a new handle for the thread only if the parent thread did not yet + fill in the handle. */ + if (thread->handle == NULL) + thread->handle = get_current_thread_handle (); + LeaveCriticalSection (&thread->handle_lock); + + if (self_key == (DWORD)-1) + init_self_key (); + TlsSetValue (self_key, thread); + + /* Run the thread. Store the exit value if the thread was not terminated + otherwise. */ + thread->result = thread->func (thread->arg); + + /* Process the TLS destructors. */ + glwthread_tls_process_destructors (); + + if (thread->detached) + { + /* Clean up the thread, like thrd_join would do. */ + DeleteCriticalSection (&thread->handle_lock); + CloseHandle (thread->handle); + free (thread); + } + + return 0; +} + +int +glwthread_thread_create (glwthread_thread_t *threadp, unsigned int attr, + void * (*func) (void *), void *arg) +{ + struct glwthread_thread_struct *thread = + (struct glwthread_thread_struct *) + malloc (sizeof (struct glwthread_thread_struct)); + if (thread == NULL) + return ENOMEM; + thread->handle = NULL; + InitializeCriticalSection (&thread->handle_lock); + thread->detached = (attr & GLWTHREAD_ATTR_DETACHED ? TRUE : FALSE); + thread->result = NULL; /* just to be deterministic */ + thread->func = func; + thread->arg = arg; + + { + unsigned int thread_id; + HANDLE thread_handle; + + thread_handle = (HANDLE) + _beginthreadex (NULL, 100000, wrapper_func, thread, 0, &thread_id); + /* calls CreateThread with the same arguments */ + if (thread_handle == NULL) + { + DeleteCriticalSection (&thread->handle_lock); + free (thread); + return EAGAIN; + } + + EnterCriticalSection (&thread->handle_lock); + if (thread->handle == NULL) + thread->handle = thread_handle; + else + /* thread->handle was already set by the thread itself. */ + CloseHandle (thread_handle); + LeaveCriticalSection (&thread->handle_lock); + + *threadp = thread; + return 0; + } +} + +int +glwthread_thread_join (glwthread_thread_t thread, void **retvalp) +{ + if (thread == NULL) + return EINVAL; + + if (thread == glwthread_thread_self ()) + return EDEADLK; + + if (thread->detached) + return EINVAL; + + if (WaitForSingleObject (thread->handle, INFINITE) == WAIT_FAILED) + return EINVAL; + + if (retvalp != NULL) + *retvalp = thread->result; + + DeleteCriticalSection (&thread->handle_lock); + CloseHandle (thread->handle); + free (thread); + + return 0; +} + +int +glwthread_thread_detach (glwthread_thread_t thread) +{ + if (thread == NULL) + return EINVAL; + + if (thread->detached) + return EINVAL; + + thread->detached = TRUE; + return 0; +} + +void +glwthread_thread_exit (void *retval) +{ + glwthread_thread_t thread = glwthread_thread_self (); + thread->result = retval; + glwthread_tls_process_destructors (); + _endthreadex (0); /* calls ExitThread (0) */ + abort (); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/windows-thread.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/windows-thread.h new file mode 100644 index 00000000..154bdfae --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/windows-thread.h @@ -0,0 +1,60 @@ +/* Creating and controlling threads (native Windows implementation). + Copyright (C) 2005-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 2005. + Based on GCC's gthr-win32.h. */ + +#ifndef _WINDOWS_THREAD_H +#define _WINDOWS_THREAD_H + +/* This file uses _Noreturn. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +#define WIN32_LEAN_AND_MEAN /* avoid including junk */ +#include + +/* The glwthread_thread_t is a pointer to a structure in memory. + Why not the thread handle? If it were the thread handle, it would be hard + to implement glwthread_thread_self() (since GetCurrentThread () returns a + pseudo-handle, DuplicateHandle (GetCurrentThread ()) returns a handle that + must be closed afterwards, and there is no function for quickly retrieving + a thread handle from its id). + Why not the thread id? I tried it. It did not work: Sometimes ids appeared + that did not belong to running threads, and glthread_join failed with ESRCH. + */ +typedef struct glwthread_thread_struct *glwthread_thread_t; + +#ifdef __cplusplus +extern "C" { +#endif + +/* attr is a bit mask, consisting of the following bits: */ +#define GLWTHREAD_ATTR_DETACHED 1 +extern int glwthread_thread_create (glwthread_thread_t *threadp, + unsigned int attr, + void * (*func) (void *), void *arg); +extern int glwthread_thread_join (glwthread_thread_t thread, void **retvalp); +extern int glwthread_thread_detach (glwthread_thread_t thread); +extern glwthread_thread_t glwthread_thread_self (void); +extern _Noreturn void glwthread_thread_exit (void *retval); + +#ifdef __cplusplus +} +#endif + +#endif /* _WINDOWS_THREAD_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/windows-tls.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/windows-tls.c new file mode 100644 index 00000000..6b73074d --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/windows-tls.c @@ -0,0 +1,339 @@ +/* Thread-local storage (native Windows implementation). + Copyright (C) 2005-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 2005. */ + +#include + +/* Specification. */ +#include "windows-tls.h" + +#include +#include +#include + +#include "windows-once.h" + +void * +glwthread_tls_get (glwthread_tls_key_t key) +{ + return TlsGetValue (key); +} + +int +glwthread_tls_set (glwthread_tls_key_t key, void *value) +{ + if (!TlsSetValue (key, value)) + return EINVAL; + return 0; +} + +/* The following variables keep track of TLS keys with non-NULL destructor. */ + +static glwthread_once_t dtor_table_init_once = GLWTHREAD_ONCE_INIT; + +static CRITICAL_SECTION dtor_table_lock; + +struct dtor { glwthread_tls_key_t key; void (*destructor) (void *); }; + +/* The table of dtors. */ +static struct dtor *dtor_table; +/* Number of active entries in the dtor_table. */ +static unsigned int dtors_count; +/* Valid indices into dtor_table are 0..dtors_used-1. */ +static unsigned int dtors_used; +/* Allocation size of dtor_table. */ +static unsigned int dtors_allocated; +/* Invariant: 0 <= dtors_count <= dtors_used <= dtors_allocated. */ + +/* Number of threads that are currently processing destructors. */ +static unsigned int dtor_processing_threads; + +static void +dtor_table_initialize (void) +{ + InitializeCriticalSection (&dtor_table_lock); + /* The other variables are already initialized to NULL or 0, respectively. */ +} + +static void +dtor_table_ensure_initialized (void) +{ + glwthread_once (&dtor_table_init_once, dtor_table_initialize); +} + +/* Shrinks dtors_used down to dtors_count, by replacing inactive entries + with active ones. */ +static void +dtor_table_shrink_used (void) +{ + unsigned int i = 0; + unsigned int j = dtors_used; + + for (;;) + { + BOOL i_found = FALSE; + BOOL j_found = FALSE; + /* Find the next inactive entry, from the left. */ + for (; i < dtors_count;) + { + if (dtor_table[i].destructor == NULL) + { + i_found = TRUE; + break; + } + i++; + } + + /* Find the next active entry, from the right. */ + for (; j > dtors_count;) + { + j--; + if (dtor_table[j].destructor != NULL) + { + j_found = TRUE; + break; + } + } + + if (i_found != j_found) + /* dtors_count was apparently wrong. */ + abort (); + + if (!i_found) + break; + + /* i_found and j_found are TRUE. Swap the two entries. */ + dtor_table[i] = dtor_table[j]; + + i++; + } + + dtors_used = dtors_count; +} + +void +glwthread_tls_process_destructors (void) +{ + unsigned int repeat; + + dtor_table_ensure_initialized (); + + EnterCriticalSection (&dtor_table_lock); + if (dtor_processing_threads == 0) + { + /* Now it's the appropriate time for shrinking dtors_used. */ + if (dtors_used > dtors_count) + dtor_table_shrink_used (); + } + dtor_processing_threads++; + + for (repeat = GLWTHREAD_DESTRUCTOR_ITERATIONS; repeat > 0; repeat--) + { + unsigned int destructors_run = 0; + + /* Iterate across dtor_table. We don't need to make a copy of dtor_table, + because + * When another thread calls glwthread_tls_key_create with a non-NULL + destructor argument, this will possibly reallocate the dtor_table + array and increase dtors_allocated as well as dtors_used and + dtors_count, but it will not change dtors_used nor the contents of + the first dtors_used entries of dtor_table. + * When another thread calls glwthread_tls_key_delete, this will + possibly set some 'destructor' member to NULL, thus marking an + entry as inactive, but it will not otherwise change dtors_used nor + the contents of the first dtors_used entries of dtor_table. */ + unsigned int i_limit = dtors_used; + unsigned int i; + + for (i = 0; i < i_limit; i++) + { + struct dtor current = dtor_table[i]; + if (current.destructor != NULL) + { + /* The current dtor has not been deleted yet. */ + void *current_value = glwthread_tls_get (current.key); + if (current_value != NULL) + { + /* The current value is non-NULL. Run the destructor. */ + glwthread_tls_set (current.key, NULL); + LeaveCriticalSection (&dtor_table_lock); + current.destructor (current_value); + EnterCriticalSection (&dtor_table_lock); + destructors_run++; + } + } + } + + /* When all TLS values were already NULL, no further iterations are + needed. */ + if (destructors_run == 0) + break; + } + + dtor_processing_threads--; + LeaveCriticalSection (&dtor_table_lock); +} + +int +glwthread_tls_key_create (glwthread_tls_key_t *keyp, void (*destructor) (void *)) +{ + if (destructor != NULL) + { + dtor_table_ensure_initialized (); + + EnterCriticalSection (&dtor_table_lock); + if (dtor_processing_threads == 0) + { + /* Now it's the appropriate time for shrinking dtors_used. */ + if (dtors_used > dtors_count) + dtor_table_shrink_used (); + } + + while (dtors_used == dtors_allocated) + { + /* Need to grow the dtor_table. */ + unsigned int new_allocated = 2 * dtors_allocated + 1; + if (new_allocated < 7) + new_allocated = 7; + if (new_allocated <= dtors_allocated) /* overflow? */ + new_allocated = UINT_MAX; + + LeaveCriticalSection (&dtor_table_lock); + { + struct dtor *new_table = + (struct dtor *) malloc (new_allocated * sizeof (struct dtor)); + if (new_table == NULL) + return ENOMEM; + EnterCriticalSection (&dtor_table_lock); + /* Attention! dtors_used, dtors_allocated may have changed! */ + if (dtors_used < new_allocated) + { + if (dtors_allocated < new_allocated) + { + /* The new_table is useful. */ + memcpy (new_table, dtor_table, + dtors_used * sizeof (struct dtor)); + dtor_table = new_table; + dtors_allocated = new_allocated; + } + else + { + /* The new_table is not useful, since another thread + meanwhile allocated a drop_table that is at least + as large. */ + free (new_table); + } + break; + } + /* The new_table is not useful, since other threads increased + dtors_used. Free it any retry. */ + free (new_table); + } + } + /* Here dtors_used < dtors_allocated. */ + { + /* Allocate a new key. */ + glwthread_tls_key_t key = TlsAlloc (); + if (key == (DWORD)-1) + { + LeaveCriticalSection (&dtor_table_lock); + return EAGAIN; + } + /* Store the new dtor in the dtor_table, after all used entries. + Do not overwrite inactive entries with indices < dtors_used, in order + not to disturb glwthread_tls_process_destructors invocations that may + be executing in other threads. */ + dtor_table[dtors_used].key = key; + dtor_table[dtors_used].destructor = destructor; + dtors_used++; + dtors_count++; + LeaveCriticalSection (&dtor_table_lock); + *keyp = key; + } + } + else + { + /* Allocate a new key. */ + glwthread_tls_key_t key = TlsAlloc (); + if (key == (DWORD)-1) + return EAGAIN; + *keyp = key; + } + return 0; +} + +int +glwthread_tls_key_delete (glwthread_tls_key_t key) +{ + /* Should the destructor be called for all threads that are currently running? + Probably not, because + - ISO C does not specify when the destructor is to be invoked at all. + - In POSIX, the destructor functions specified with pthread_key_create() + are invoked at thread exit. + - It would be hard to implement, because there are no primitives for + accessing thread-specific values from a different thread. */ + dtor_table_ensure_initialized (); + + EnterCriticalSection (&dtor_table_lock); + if (dtor_processing_threads == 0) + { + /* Now it's the appropriate time for shrinking dtors_used. */ + if (dtors_used > dtors_count) + dtor_table_shrink_used (); + /* Here dtors_used == dtors_count. */ + + /* Find the key in dtor_table. */ + { + unsigned int i_limit = dtors_used; + unsigned int i; + + for (i = 0; i < i_limit; i++) + if (dtor_table[i].key == key) + { + if (i < dtors_used - 1) + /* Swap the entries i and dtors_used - 1. */ + dtor_table[i] = dtor_table[dtors_used - 1]; + dtors_count = dtors_used = dtors_used - 1; + break; + } + } + } + else + { + /* Be careful not to disturb the glwthread_tls_process_destructors + invocations that are executing in other threads. */ + unsigned int i_limit = dtors_used; + unsigned int i; + + for (i = 0; i < i_limit; i++) + if (dtor_table[i].destructor != NULL /* skip inactive entries */ + && dtor_table[i].key == key) + { + /* Mark this entry as inactive. */ + dtor_table[i].destructor = NULL; + dtors_count = dtors_count - 1; + break; + } + } + LeaveCriticalSection (&dtor_table_lock); + /* Now we have ensured that glwthread_tls_process_destructors will no longer + use this key. */ + + if (!TlsFree (key)) + return EINVAL; + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/windows-tls.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/windows-tls.h new file mode 100644 index 00000000..d9393fe9 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/windows-tls.h @@ -0,0 +1,42 @@ +/* Thread-local storage (native Windows implementation). + Copyright (C) 2005-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 2005. */ + +#ifndef _WINDOWS_TLS_H +#define _WINDOWS_TLS_H + +#define WIN32_LEAN_AND_MEAN /* avoid including junk */ +#include + +typedef DWORD glwthread_tls_key_t; + +#ifdef __cplusplus +extern "C" { +#endif + +extern int glwthread_tls_key_create (glwthread_tls_key_t *keyp, void (*destructor) (void *)); +extern void *glwthread_tls_get (glwthread_tls_key_t key); +extern int glwthread_tls_set (glwthread_tls_key_t key, void *value); +extern int glwthread_tls_key_delete (glwthread_tls_key_t key); +extern void glwthread_tls_process_destructors (void); +#define GLWTHREAD_DESTRUCTOR_ITERATIONS 4 + +#ifdef __cplusplus +} +#endif + +#endif /* _WINDOWS_TLS_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/xsize.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/xsize.c new file mode 100644 index 00000000..87744675 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/xsize.c @@ -0,0 +1,21 @@ +/* Checked size_t computations. + + Copyright (C) 2012-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +#define XSIZE_INLINE _GL_EXTERN_INLINE +#include "xsize.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/xsize.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/xsize.h new file mode 100644 index 00000000..71c9c073 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/xsize.h @@ -0,0 +1,110 @@ +/* xsize.h -- Checked size_t computations. + + Copyright (C) 2003, 2008-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef _XSIZE_H +#define _XSIZE_H + +/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, HAVE_STDINT_H. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +/* Get size_t. */ +#include + +/* Get SIZE_MAX. */ +#include +#if HAVE_STDINT_H +# include +#endif + +/* Get ATTRIBUTE_PURE. */ +#include "attribute.h" + +_GL_INLINE_HEADER_BEGIN +#ifndef XSIZE_INLINE +# define XSIZE_INLINE _GL_INLINE +#endif + +/* The size of memory objects is often computed through expressions of + type size_t. Example: + void* p = malloc (header_size + n * element_size). + These computations can lead to overflow. When this happens, malloc() + returns a piece of memory that is way too small, and the program then + crashes while attempting to fill the memory. + To avoid this, the functions and macros in this file check for overflow. + The convention is that SIZE_MAX represents overflow. + malloc (SIZE_MAX) is not guaranteed to fail -- think of a malloc + implementation that uses mmap --, it's recommended to use size_overflow_p() + or size_in_bounds_p() before invoking malloc(). + The example thus becomes: + size_t size = xsum (header_size, xtimes (n, element_size)); + void *p = (size_in_bounds_p (size) ? malloc (size) : NULL); +*/ + +/* Convert an arbitrary value >= 0 to type size_t. */ +#define xcast_size_t(N) \ + ((N) <= SIZE_MAX ? (size_t) (N) : SIZE_MAX) + +/* Sum of two sizes, with overflow check. */ +XSIZE_INLINE size_t ATTRIBUTE_PURE +xsum (size_t size1, size_t size2) +{ + size_t sum = size1 + size2; + return (sum >= size1 ? sum : SIZE_MAX); +} + +/* Sum of three sizes, with overflow check. */ +XSIZE_INLINE size_t ATTRIBUTE_PURE +xsum3 (size_t size1, size_t size2, size_t size3) +{ + return xsum (xsum (size1, size2), size3); +} + +/* Sum of four sizes, with overflow check. */ +XSIZE_INLINE size_t ATTRIBUTE_PURE +xsum4 (size_t size1, size_t size2, size_t size3, size_t size4) +{ + return xsum (xsum (xsum (size1, size2), size3), size4); +} + +/* Maximum of two sizes, with overflow check. */ +XSIZE_INLINE size_t ATTRIBUTE_PURE +xmax (size_t size1, size_t size2) +{ + /* No explicit check is needed here, because for any n: + max (SIZE_MAX, n) == SIZE_MAX and max (n, SIZE_MAX) == SIZE_MAX. */ + return (size1 >= size2 ? size1 : size2); +} + +/* Multiplication of a count with an element size, with overflow check. + The count must be >= 0 and the element size must be > 0. + This is a macro, not a function, so that it works correctly even + when N is of a wider type and N > SIZE_MAX. */ +#define xtimes(N, ELSIZE) \ + ((N) <= SIZE_MAX / (ELSIZE) ? (size_t) (N) * (ELSIZE) : SIZE_MAX) + +/* Check for overflow. */ +#define size_overflow_p(SIZE) \ + ((SIZE) == SIZE_MAX) +/* Check against overflow. */ +#define size_in_bounds_p(SIZE) \ + ((SIZE) != SIZE_MAX) + +_GL_INLINE_HEADER_END + +#endif /* _XSIZE_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/xstrtol-error.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/xstrtol-error.c new file mode 100644 index 00000000..16d817a4 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/xstrtol-error.c @@ -0,0 +1,98 @@ +/* A more useful interface to strtol. + + Copyright (C) 1995-1996, 1998-1999, 2001-2004, 2006-2024 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 . */ + +#include +#include "xstrtol-error.h" + +#include + +#include +#include "exitfail.h" +#include "gettext.h" + +#define N_(msgid) msgid + +/* Report an error for an invalid integer in an option argument. + + ERR is the error code returned by one of the xstrto* functions. + + Use OPT_IDX to decide whether to print the short option string "C" + or "-C" or a long option string derived from LONG_OPTION. OPT_IDX + is -2 if the short option "C" was used, without any leading "-"; it + is -1 if the short option "-C" was used; otherwise it is an index + into LONG_OPTIONS, which should have a name preceded by two '-' + characters. + + ARG is the option-argument containing the integer. + + After reporting an error, exit with status EXIT_STATUS if it is + nonzero. */ + +static void +xstrtol_error (enum strtol_error err, + int opt_idx, char c, struct option const *long_options, + char const *arg, + int exit_status) +{ + char const *hyphens = "--"; + char const *msgid; + char const *option; + char option_buffer[2]; + + switch (err) + { + default: + abort (); + + case LONGINT_INVALID: + msgid = N_("invalid %s%s argument '%s'"); + break; + + case LONGINT_INVALID_SUFFIX_CHAR: + case LONGINT_INVALID_SUFFIX_CHAR_WITH_OVERFLOW: + msgid = N_("invalid suffix in %s%s argument '%s'"); + break; + + case LONGINT_OVERFLOW: + msgid = N_("%s%s argument '%s' too large"); + break; + } + + if (opt_idx < 0) + { + hyphens -= opt_idx; + option_buffer[0] = c; + option_buffer[1] = '\0'; + option = option_buffer; + } + else + option = long_options[opt_idx].name; + + error (exit_status, 0, gettext (msgid), hyphens, option, arg); +} + +/* Like xstrtol_error, except exit with a failure status. */ + +void +xstrtol_fatal (enum strtol_error err, + int opt_idx, char c, struct option const *long_options, + char const *arg) +{ + xstrtol_error (err, opt_idx, c, long_options, arg, exit_failure); + abort (); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/xstrtol-error.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/xstrtol-error.h new file mode 100644 index 00000000..ace787b9 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/xstrtol-error.h @@ -0,0 +1,51 @@ +/* Error reporting interface for xstrto* functions. + + Copyright (C) 1995-1996, 1998-1999, 2001-2004, 2006-2024 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 . */ + +#ifndef XSTRTOL_ERROR_H_ +# define XSTRTOL_ERROR_H_ 1 + +/* This file uses _Noreturn. */ +# if !_GL_CONFIG_H_INCLUDED +# error "Please include config.h first." +# endif + +# include "xstrtol.h" + +# include + +/* Report an error for an invalid integer in an option argument. + + ERR is the error code returned by one of the xstrto* functions. + + Use OPT_IDX to decide whether to print the short option string "C" + or "-C" or a long option string derived from LONG_OPTIONS. OPT_IDX + is -2 if the short option "C" was used, without any leading "-"; it + is -1 if the short option "-C" was used; otherwise it is an index + into LONG_OPTIONS, which should have a name preceded by two '-' + characters. + + ARG is the option-argument containing the integer. + + After reporting an error, exit with a failure status. */ + +_Noreturn void xstrtol_fatal (enum strtol_error /* err */, + int /* opt_idx */, char /* c */, + struct option const * /* long_options */, + char const * /* arg */); + +#endif /* not XSTRTOL_ERROR_H_ */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/zerosize-ptr.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/zerosize-ptr.h new file mode 100644 index 00000000..90ab26f9 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/gnulib-tests/zerosize-ptr.h @@ -0,0 +1,82 @@ +/* Return a pointer to a zero-size object in memory. + Copyright (C) 2009-2024 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 . */ + +/* ISO C 99 does not allow memcmp(), memchr() etc. to be invoked with a NULL + argument. Therefore this file produces a non-NULL pointer which cannot + be dereferenced, if possible. */ + +/* On Android, when targeting Android 4.4 or older with a GCC toolchain, + prevent a compilation error + "error: call to 'mmap' declared with attribute error: mmap is not + available with _FILE_OFFSET_BITS=64 when using GCC until android-21. + Either raise your minSdkVersion, disable _FILE_OFFSET_BITS=64, or + switch to Clang." + The files that we access in this compilation unit are less than 2 GB + large. */ +#if defined __ANDROID__ +# undef _FILE_OFFSET_BITS +# undef __USE_FILE_OFFSET64 +#endif + +#include + +/* Test whether mmap() and mprotect() are available. + We don't use HAVE_MMAP, because AC_FUNC_MMAP would not define it on HP-UX. + HAVE_MPROTECT is not enough, because mingw does not have mmap() but has an + mprotect() function in libgcc.a. + And OS/2 kLIBC has and mprotect(), but not mmap(). */ +#if HAVE_SYS_MMAN_H && HAVE_MPROTECT && !defined __KLIBC__ +# include +# include +# include +# include +/* Define MAP_FILE when it isn't otherwise. */ +# ifndef MAP_FILE +# define MAP_FILE 0 +# endif +#endif + +/* Return a pointer to a zero-size object in memory (that is, actually, a + pointer to a page boundary where the previous page is readable and writable + and the next page is neither readable not writable), if possible. + Return NULL otherwise. */ + +static void * +zerosize_ptr (void) +{ +/* Use mmap and mprotect when they exist. Don't test HAVE_MMAP, because it is + not defined on HP-UX 11 (since it does not support MAP_FIXED). */ +#if HAVE_SYS_MMAN_H && HAVE_MPROTECT && !defined __KLIBC__ +# if HAVE_MAP_ANONYMOUS + const int flags = MAP_ANONYMOUS | MAP_PRIVATE; + const int fd = -1; +# else /* !HAVE_MAP_ANONYMOUS */ + const int flags = MAP_FILE | MAP_PRIVATE; + int fd = open ("/dev/zero", O_RDONLY, 0666); + if (fd >= 0) +# endif + { + int pagesize = getpagesize (); + char *two_pages = + (char *) mmap (NULL, 2 * pagesize, PROT_READ | PROT_WRITE, + flags, fd, 0); + if (two_pages != (char *)(-1) + && mprotect (two_pages + pagesize, pagesize, PROT_NONE) == 0) + return two_pages + pagesize; + } +#endif + return NULL; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/.gitignore b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/.gitignore new file mode 100644 index 00000000..665c4f87 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/.gitignore @@ -0,0 +1,351 @@ +/_Noreturn.h +/alloca.in.h +/allocator.c +/allocator.h +/arg-nonnull.h +/argmatch.c +/argmatch.h +/assert.in.h +/assure.h +/attribute.h +/basename-lgpl.c +/basename-lgpl.h +/basename.c +/binary-io.c +/binary-io.h +/bitrotate.c +/bitrotate.h +/btowc.c +/c++defs.h +/c-ctype.c +/c-ctype.h +/c-stack.c +/c-stack.h +/c-strcase.h +/c-strcasecmp.c +/c-strcaseeq.h +/c-strncasecmp.c +/calloc.c +/careadlinkat.c +/careadlinkat.h +/cdefs.h +/cloexec.c +/cloexec.h +/close.c +/ctype.in.h +/diffseq.h +/dirname-lgpl.c +/dirname.c +/dirname.h +/dup2.c +/dynarray.h +/errno.in.h +/error.c +/error.in.h +/exclude.c +/exclude.h +/exitfail.c +/exitfail.h +/fcntl.c +/fcntl.in.h +/fd-hook.c +/fd-hook.h +/file-type.c +/file-type.h +/filename.h +/filenamecat-lgpl.c +/filenamecat.c +/filenamecat.h +/flexmember.h +/fnmatch.c +/fnmatch.in.h +/fnmatch_loop.c +/fopen.c +/free.c +/freopen.c +/fstat.c +/getdtablesize.c +/getopt-cdefs.in.h +/getopt-core.h +/getopt-ext.h +/getopt-pfx-core.h +/getopt-pfx-ext.h +/getopt.c +/getopt.in.h +/getopt1.c +/getopt_int.h +/getpagesize.c +/getprogname.c +/getprogname.h +/getrandom.c +/gettext.h +/gettime.c +/gettimeofday.c +/gnulib.mk +/hard-locale.c +/hard-locale.h +/hash.c +/hash.h +/ialloc.c +/ialloc.h +/idx.h +/ignore-value.h +/intprops-internal.h +/intprops.h +/inttypes.in.h +/isblank.c +/iswblank.c +/iswdigit.c +/iswxdigit.c +/langinfo.in.h +/lc-charset-dispatch.c +/lc-charset-dispatch.h +/libc-config.h +/limits.in.h +/localcharset.c +/localcharset.h +/locale.in.h +/localeconv.c +/lstat.c +/malloc.c +/malloca.c +/malloca.h +/mbchar.c +/mbchar.h +/mbrtowc-impl-utf8.h +/mbrtowc-impl.h +/mbrtowc.c +/mbscasecmp.c +/mbsinit.c +/mbsrtowcs-impl.h +/mbsrtowcs-state.c +/mbsrtowcs.c +/mbtowc-impl.h +/mbtowc-lock.c +/mbtowc-lock.h +/mbtowc.c +/mbuiter.c +/mbuiter.h +/memchr.c +/memchr.valgrind +/mempcpy.c +/minmax.h +/mkdir.c +/mkstemp.c +/mktime-internal.h +/mktime.c +/msvc-inval.c +/msvc-inval.h +/msvc-nothrow.c +/msvc-nothrow.h +/nl_langinfo-lock.c +/nl_langinfo.c +/nstrftime.c +/open.c +/pathmax.h +/progname.c +/progname.h +/propername.h +/quote.h +/quotearg.c +/quotearg.h +/raise.c +/rawmemchr.c +/rawmemchr.valgrind +/realloc.c +/reallocarray.c +/regcomp.c +/regex.c +/regex.h +/regex_internal.c +/regex_internal.h +/regexec.c +/setenv.c +/setlocale-lock.c +/setlocale_null.c +/setlocale_null.h +/sh-quote.c +/sh-quote.h +/signal.in.h +/sigprocmask.c +/sigsegv.c +/sigsegv.in.h +/stackvma.c +/stackvma.h +/stat-macros.h +/stat-time.c +/stat-time.h +/stat-w32.c +/stat-w32.h +/stat.c +/stdarg.in.h +/stdckdint.in.h +/stddef.in.h +/stdint.in.h +/stdio-read.c +/stdio-write.c +/stdio.in.h +/stdlib.in.h +/stdopen.c +/stdopen.h +/stpcpy.c +/strcasecmp.c +/streq.h +/strerror-override.c +/strerror-override.h +/strerror.c +/strftime.h +/string.in.h +/strings.in.h +/stripslash.c +/strncasecmp.c +/strnlen.c +/strnlen1.c +/strnlen1.h +/strptime.c +/strtoimax.c +/strtol.c +/strtoll.c +/sys_random.in.h +/sys_stat.in.h +/sys_time.in.h +/sys_types.in.h +/sys_wait.in.h +/system-quote.c +/system-quote.h +/tempname.c +/tempname.h +/time-internal.h +/time.in.h +/time_r.c +/time_rz.c +/timegm.c +/timespec.c +/timespec.h +/tzset.c +/unistd.c +/unistd.in.h +/unitypes.in.h +/uniwidth.in.h +/unlocked-io.h +/unsetenv.c +/verify.h +/version-etc-fsf.c +/version-etc.c +/version-etc.h +/warn-on-use.h +/wchar.in.h +/wcrtomb.c +/wctype-h.c +/wctype.in.h +/wcwidth.c +/windows-initguard.h +/windows-mutex.c +/windows-mutex.h +/windows-once.c +/windows-once.h +/windows-recmutex.c +/windows-recmutex.h +/windows-rwlock.c +/windows-rwlock.h +/wmemchr-impl.h +/wmemchr.c +/wmempcpy.c +/xalloc-die.c +/xalloc-oversized.h +/xalloc.h +/xfreopen.c +/xfreopen.h +/xmalloc.c +/xmalloca.c +/xmalloca.h +/xstdopen.c +/xstdopen.h +/xstrtoimax.c +/xstrtol.c +/xstrtol.h +/xstrtoul.c +/c32width.c +/count-leading-zeros.c +/count-leading-zeros.h +/mbrtoc32.c +/propername-lite.c +/same-inode.h +/uchar.in.h +/at-func.c +/btoc32.c +/c32_apply_type_test.c +/c32_get_type_test.c +/c32is-impl.h +/c32isalnum.c +/c32isalpha.c +/c32isblank.c +/c32iscntrl.c +/c32isdigit.c +/c32isgraph.c +/c32islower.c +/c32isprint.c +/c32ispunct.c +/c32isspace.c +/c32isupper.c +/c32isxdigit.c +/c32to-impl.h +/c32tolower.c +/chdir-long.c +/chdir-long.h +/closedir.c +/dirent-private.h +/dirent.in.h +/dirfd.c +/dup-safer-flag.c +/dup-safer.c +/dup.c +/fchdir.c +/fd-safer-flag.c +/fd-safer.c +/fdopendir.c +/fstatat.c +/getcwd-lgpl.c +/mbsrtoc32s-state.c +/mbsrtoc32s.c +/mbszero.c +/mbuiterf.c +/mbuiterf.h +/memrchr.c +/openat-die.c +/openat-priv.h +/openat-proc.c +/openat.c +/openat.h +/opendir.c +/pipe-safer.c +/pipe.c +/save-cwd.c +/save-cwd.h +/strdup.c +/timespec_get.c +/unicase.in.h +/unictype.in.h +/uninorm.in.h +/unistd--.h +/unistd-safer.h +/unistr.in.h +/readlink.c +/readlinkat.c +/sig-handler.c +/sig-handler.h +/sigaction.c +/popen.c +/pclose.c +/readdir.c +/areadlink.c +/areadlink.h +/xreadlink.c +/xreadlink.h +/c-file-type.c +/iswctype-impl.h +/iswctype.c +/iswpunct.c +/same-inode.c +/wctype-impl.h +/wctype.c diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/.gitignore~ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/.gitignore~ new file mode 100644 index 00000000..ab3d6f6f --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/.gitignore~ @@ -0,0 +1,344 @@ +/_Noreturn.h +/alloca.in.h +/allocator.c +/allocator.h +/arg-nonnull.h +/argmatch.c +/argmatch.h +/assert.in.h +/assure.h +/attribute.h +/basename-lgpl.c +/basename-lgpl.h +/basename.c +/binary-io.c +/binary-io.h +/bitrotate.c +/bitrotate.h +/btowc.c +/c++defs.h +/c-ctype.c +/c-ctype.h +/c-stack.c +/c-stack.h +/c-strcase.h +/c-strcasecmp.c +/c-strcaseeq.h +/c-strncasecmp.c +/calloc.c +/careadlinkat.c +/careadlinkat.h +/cdefs.h +/cloexec.c +/cloexec.h +/close.c +/ctype.in.h +/diffseq.h +/dirname-lgpl.c +/dirname.c +/dirname.h +/dup2.c +/dynarray.h +/errno.in.h +/error.c +/error.in.h +/exclude.c +/exclude.h +/exitfail.c +/exitfail.h +/fcntl.c +/fcntl.in.h +/fd-hook.c +/fd-hook.h +/file-type.c +/file-type.h +/filename.h +/filenamecat-lgpl.c +/filenamecat.c +/filenamecat.h +/flexmember.h +/fnmatch.c +/fnmatch.in.h +/fnmatch_loop.c +/fopen.c +/free.c +/freopen.c +/fstat.c +/getdtablesize.c +/getopt-cdefs.in.h +/getopt-core.h +/getopt-ext.h +/getopt-pfx-core.h +/getopt-pfx-ext.h +/getopt.c +/getopt.in.h +/getopt1.c +/getopt_int.h +/getpagesize.c +/getprogname.c +/getprogname.h +/getrandom.c +/gettext.h +/gettime.c +/gettimeofday.c +/gnulib.mk +/hard-locale.c +/hard-locale.h +/hash.c +/hash.h +/ialloc.c +/ialloc.h +/idx.h +/ignore-value.h +/intprops-internal.h +/intprops.h +/inttypes.in.h +/isblank.c +/iswblank.c +/iswdigit.c +/iswxdigit.c +/langinfo.in.h +/lc-charset-dispatch.c +/lc-charset-dispatch.h +/libc-config.h +/limits.in.h +/localcharset.c +/localcharset.h +/locale.in.h +/localeconv.c +/lstat.c +/malloc.c +/malloca.c +/malloca.h +/mbchar.c +/mbchar.h +/mbrtowc-impl-utf8.h +/mbrtowc-impl.h +/mbrtowc.c +/mbscasecmp.c +/mbsinit.c +/mbsrtowcs-impl.h +/mbsrtowcs-state.c +/mbsrtowcs.c +/mbtowc-impl.h +/mbtowc-lock.c +/mbtowc-lock.h +/mbtowc.c +/mbuiter.c +/mbuiter.h +/memchr.c +/memchr.valgrind +/mempcpy.c +/minmax.h +/mkdir.c +/mkstemp.c +/mktime-internal.h +/mktime.c +/msvc-inval.c +/msvc-inval.h +/msvc-nothrow.c +/msvc-nothrow.h +/nl_langinfo-lock.c +/nl_langinfo.c +/nstrftime.c +/open.c +/pathmax.h +/progname.c +/progname.h +/propername.h +/quote.h +/quotearg.c +/quotearg.h +/raise.c +/rawmemchr.c +/rawmemchr.valgrind +/realloc.c +/reallocarray.c +/regcomp.c +/regex.c +/regex.h +/regex_internal.c +/regex_internal.h +/regexec.c +/setenv.c +/setlocale-lock.c +/setlocale_null.c +/setlocale_null.h +/sh-quote.c +/sh-quote.h +/signal.in.h +/sigprocmask.c +/sigsegv.c +/sigsegv.in.h +/stackvma.c +/stackvma.h +/stat-macros.h +/stat-time.c +/stat-time.h +/stat-w32.c +/stat-w32.h +/stat.c +/stdarg.in.h +/stdckdint.in.h +/stddef.in.h +/stdint.in.h +/stdio-read.c +/stdio-write.c +/stdio.in.h +/stdlib.in.h +/stdopen.c +/stdopen.h +/stpcpy.c +/strcasecmp.c +/streq.h +/strerror-override.c +/strerror-override.h +/strerror.c +/strftime.h +/string.in.h +/strings.in.h +/stripslash.c +/strncasecmp.c +/strnlen.c +/strnlen1.c +/strnlen1.h +/strptime.c +/strtoimax.c +/strtol.c +/strtoll.c +/sys_random.in.h +/sys_stat.in.h +/sys_time.in.h +/sys_types.in.h +/sys_wait.in.h +/system-quote.c +/system-quote.h +/tempname.c +/tempname.h +/time-internal.h +/time.in.h +/time_r.c +/time_rz.c +/timegm.c +/timespec.c +/timespec.h +/tzset.c +/unistd.c +/unistd.in.h +/unitypes.in.h +/uniwidth.in.h +/unlocked-io.h +/unsetenv.c +/verify.h +/version-etc-fsf.c +/version-etc.c +/version-etc.h +/warn-on-use.h +/wchar.in.h +/wcrtomb.c +/wctype-h.c +/wctype.in.h +/wcwidth.c +/windows-initguard.h +/windows-mutex.c +/windows-mutex.h +/windows-once.c +/windows-once.h +/windows-recmutex.c +/windows-recmutex.h +/windows-rwlock.c +/windows-rwlock.h +/wmemchr-impl.h +/wmemchr.c +/wmempcpy.c +/xalloc-die.c +/xalloc-oversized.h +/xalloc.h +/xfreopen.c +/xfreopen.h +/xmalloc.c +/xmalloca.c +/xmalloca.h +/xstdopen.c +/xstdopen.h +/xstrtoimax.c +/xstrtol.c +/xstrtol.h +/xstrtoul.c +/c32width.c +/count-leading-zeros.c +/count-leading-zeros.h +/mbrtoc32.c +/propername-lite.c +/same-inode.h +/uchar.in.h +/at-func.c +/btoc32.c +/c32_apply_type_test.c +/c32_get_type_test.c +/c32is-impl.h +/c32isalnum.c +/c32isalpha.c +/c32isblank.c +/c32iscntrl.c +/c32isdigit.c +/c32isgraph.c +/c32islower.c +/c32isprint.c +/c32ispunct.c +/c32isspace.c +/c32isupper.c +/c32isxdigit.c +/c32to-impl.h +/c32tolower.c +/chdir-long.c +/chdir-long.h +/closedir.c +/dirent-private.h +/dirent.in.h +/dirfd.c +/dup-safer-flag.c +/dup-safer.c +/dup.c +/fchdir.c +/fd-safer-flag.c +/fd-safer.c +/fdopendir.c +/fstatat.c +/getcwd-lgpl.c +/mbsrtoc32s-state.c +/mbsrtoc32s.c +/mbszero.c +/mbuiterf.c +/mbuiterf.h +/memrchr.c +/openat-die.c +/openat-priv.h +/openat-proc.c +/openat.c +/openat.h +/opendir.c +/pipe-safer.c +/pipe.c +/save-cwd.c +/save-cwd.h +/strdup.c +/timespec_get.c +/unicase.in.h +/unictype.in.h +/uninorm.in.h +/unistd--.h +/unistd-safer.h +/unistr.in.h +/readlink.c +/readlinkat.c +/sig-handler.c +/sig-handler.h +/sigaction.c +/popen.c +/pclose.c +/readdir.c +/areadlink.c +/areadlink.h +/xreadlink.c +/xreadlink.h diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/_Noreturn.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/_Noreturn.h new file mode 100644 index 00000000..7326bd47 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/_Noreturn.h @@ -0,0 +1,50 @@ +/* A C macro for declaring that a function does not return. + Copyright (C) 2011-2024 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef _Noreturn +# if (defined __cplusplus \ + && ((201103 <= __cplusplus && !(__GNUC__ == 4 && __GNUC_MINOR__ == 7)) \ + || (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 __clang__ && __clang_major__ < 16 \ + && defined _GL_WORK_AROUND_LLVM_BUG_59792) + /* Compile with -D_GL_WORK_AROUND_LLVM_BUG_59792 to work around + that rare LLVM bug, though you may get many false-alarm warnings. */ +# define _Noreturn +# elif ((!defined __cplusplus || defined __clang__) \ + && (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \ + || (!defined __STRICT_ANSI__ \ + && (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__) || defined __clang__ \ + || 0x5110 <= __SUNPRO_C) +# define _Noreturn __attribute__ ((__noreturn__)) +# elif 1200 <= (defined _MSC_VER ? _MSC_VER : 0) +# define _Noreturn __declspec (noreturn) +# else +# define _Noreturn +# endif +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/alloca.in.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/alloca.in.h new file mode 100644 index 00000000..6aa47df8 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/alloca.in.h @@ -0,0 +1,72 @@ +/* Memory allocation on the stack. + + Copyright (C) 1995, 1999, 2001-2004, 2006-2024 Free Software Foundation, + Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Avoid using the symbol _ALLOCA_H here, as Bison assumes _ALLOCA_H + means there is a real alloca function. */ +#ifndef _GL_ALLOCA_H +#define _GL_ALLOCA_H + +/* alloca (N) returns a pointer to N bytes of memory + allocated on the stack, which will last until the function returns. + Use of alloca should be avoided: + - inside arguments of function calls - undefined behaviour, + - in inline functions - the allocation may actually last until the + calling function returns, + - for huge N (say, N >= 65536) - you never know how large (or small) + the stack is, and when the stack cannot fulfill the memory allocation + request, the program just crashes. + */ + +#ifndef alloca + /* Some version of mingw have an that causes trouble when + included after 'alloca' gets defined as a macro. As a workaround, + include this first and define 'alloca' as a macro afterwards + if needed. */ +# if defined __GNUC__ && (defined _WIN32 && ! defined __CYGWIN__) && @HAVE_ALLOCA_H@ +# include_next +# endif +#endif +#ifndef alloca +# if defined __GNUC__ || (__clang_major__ >= 4) +# define alloca __builtin_alloca +# elif defined _AIX +# define alloca __alloca +# elif defined _MSC_VER +# include +# define alloca _alloca +# elif defined __DECC && defined __VMS +# define alloca __ALLOCA +# elif defined __TANDEM && defined _TNS_E_TARGET +# ifdef __cplusplus +extern "C" +# endif +void *_alloca (unsigned short); +# pragma intrinsic (_alloca) +# define alloca _alloca +# elif defined __MVS__ +# include +# else +# include +# ifdef __cplusplus +extern "C" +# endif +void *alloca (size_t); +# endif +#endif + +#endif /* _GL_ALLOCA_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/allocator.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/allocator.c new file mode 100644 index 00000000..79fffbed --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/allocator.c @@ -0,0 +1,22 @@ +/* Memory allocators such as malloc+free. + + Copyright (C) 2011-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#define _GL_USE_STDLIB_ALLOC 1 +#include +#include "allocator.h" +#include +struct allocator const stdlib_allocator = { malloc, realloc, free, NULL }; diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/allocator.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/allocator.h new file mode 100644 index 00000000..bb30a344 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/allocator.h @@ -0,0 +1,58 @@ +/* Memory allocators such as malloc+free. + + Copyright (C) 2011-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Paul Eggert. */ + +#ifndef _GL_ALLOCATOR_H +#define _GL_ALLOCATOR_H + +#include + +/* An object describing a memory allocator family. */ + +struct allocator +{ + /* Do not use GCC attributes such as __attribute__ ((malloc)) with + the function types pointed at by these members, because these + attributes do not work with pointers to functions. See + . */ + + /* Call ALLOCATE to allocate memory, like 'malloc'. On failure ALLOCATE + should return NULL, though not necessarily set errno. When given + a zero size it may return NULL even if successful. */ + void *(*allocate) (size_t); + + /* If nonnull, call REALLOCATE to reallocate memory, like 'realloc'. + On failure REALLOCATE should return NULL, though not necessarily set + errno. When given a zero size it may return NULL even if + successful. */ + void *(*reallocate) (void *, size_t); + + /* Call FREE to free memory, like 'free'. */ + void (*free) (void *); + + /* If nonnull, call DIE (SIZE) if MALLOC (SIZE) or REALLOC (..., + SIZE) fails. DIE should not return. SIZE should equal SIZE_MAX + if size_t overflow was detected while calculating sizes to be + passed to MALLOC or REALLOC. */ + void (*die) (size_t); +}; + +/* An allocator using the stdlib functions and a null DIE function. */ +extern struct allocator const stdlib_allocator; + +#endif /* _GL_ALLOCATOR_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/arg-nonnull.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/arg-nonnull.h new file mode 100644 index 00000000..46c711ca --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/arg-nonnull.h @@ -0,0 +1,26 @@ +/* A C macro for declaring that specific arguments must not be NULL. + Copyright (C) 2009-2024 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools + that the values passed as arguments n, ..., m must be non-NULL pointers. + n = 1 stands for the first argument, n = 2 for the second argument etc. */ +#ifndef _GL_ARG_NONNULL +# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || defined __clang__ +# define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params)) +# else +# define _GL_ARG_NONNULL(params) +# endif +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/argmatch.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/argmatch.c new file mode 100644 index 00000000..c9d727c8 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/argmatch.c @@ -0,0 +1,293 @@ +/* argmatch.c -- find a match for a string in an array + + Copyright (C) 1990, 1998-1999, 2001-2007, 2009-2024 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 . */ + +/* Written by David MacKenzie + Modified by Akim Demaille */ + +#include + +/* Specification. */ +#include "argmatch.h" + +#include +#include +#include + +#define _(msgid) gettext (msgid) + +#include +#include "quotearg.h" + +#if USE_UNLOCKED_IO +# include "unlocked-io.h" +#endif + +/* When reporting an invalid argument, show nonprinting characters + by using the quoting style ARGMATCH_QUOTING_STYLE. Do not use + literal_quoting_style. */ +#ifndef ARGMATCH_QUOTING_STYLE +# define ARGMATCH_QUOTING_STYLE locale_quoting_style +#endif + +/* Non failing version of argmatch call this function after failing. */ +#ifndef ARGMATCH_DIE +# include "exitfail.h" +# define ARGMATCH_DIE exit (exit_failure) +#endif + +#ifdef ARGMATCH_DIE_DECL +ARGMATCH_DIE_DECL; +#endif + +static void +__argmatch_die (void) +{ + ARGMATCH_DIE; +} + +/* Used by XARGMATCH. See description in argmatch.h. + Default to __argmatch_die, but allow caller to change this at run-time. */ +argmatch_exit_fn argmatch_die = __argmatch_die; + + +/* If ARG is an unambiguous match for an element of the + NULL-terminated array ARGLIST, return the index in ARGLIST + of the matched element, else -1 if it does not match any element + or -2 if it is ambiguous (is a prefix of more than one element). + + If VALLIST is none null, use it to resolve ambiguities limited to + synonyms, i.e., for + "yes", "yop" -> 0 + "no", "nope" -> 1 + "y" is a valid argument, for 0, and "n" for 1. */ + +ptrdiff_t +argmatch (const char *arg, const char *const *arglist, + const void *vallist, size_t valsize) +{ + size_t i; /* Temporary index in ARGLIST. */ + size_t arglen; /* Length of ARG. */ + ptrdiff_t matchind = -1; /* Index of first nonexact match. */ + bool ambiguous = false; /* If true, multiple nonexact match(es). */ + + arglen = strlen (arg); + + /* Test all elements for either exact match or abbreviated matches. */ + for (i = 0; arglist[i]; i++) + { + if (!strncmp (arglist[i], arg, arglen)) + { + if (strlen (arglist[i]) == arglen) + /* Exact match found. */ + return i; + else if (matchind == -1) + /* First nonexact match found. */ + matchind = i; + else + { + /* Second nonexact match found. */ + if (vallist == NULL + || memcmp ((char const *) vallist + valsize * matchind, + (char const *) vallist + valsize * i, valsize)) + { + /* There is a real ambiguity, or we could not + disambiguate. */ + ambiguous = true; + } + } + } + } + if (ambiguous) + return -2; + else + return matchind; +} + +ptrdiff_t +argmatch_exact (const char *arg, const char *const *arglist) +{ + size_t i; + + /* Test elements for exact match. */ + for (i = 0; arglist[i]; i++) + { + if (!strcmp (arglist[i], arg)) + return i; + } + + return -1; +} + +/* Error reporting for argmatch. + CONTEXT is a description of the type of entity that was being matched. + VALUE is the invalid value that was given. + PROBLEM is the return value from argmatch. */ + +void +argmatch_invalid (const char *context, const char *value, ptrdiff_t problem) +{ + char const *format = (problem == -1 + ? _("invalid argument %s for %s") + : _("ambiguous argument %s for %s")); + + error (0, 0, format, quotearg_n_style (0, ARGMATCH_QUOTING_STYLE, value), + quote_n (1, context)); +} + +/* List the valid arguments for argmatch. + ARGLIST is the same as in argmatch. + VALLIST is a pointer to an array of values. + VALSIZE is the size of the elements of VALLIST */ +void +argmatch_valid (const char *const *arglist, + const void *vallist, size_t valsize) +{ + size_t i; + const char *last_val = NULL; + + /* We try to put synonyms on the same line. The assumption is that + synonyms follow each other */ + fputs (_("Valid arguments are:"), stderr); + for (i = 0; arglist[i]; i++) + if ((i == 0) + || memcmp (last_val, (char const *) vallist + valsize * i, valsize)) + { + fprintf (stderr, "\n - %s", quote (arglist[i])); + last_val = (char const *) vallist + valsize * i; + } + else + { + fprintf (stderr, ", %s", quote (arglist[i])); + } + putc ('\n', stderr); +} + +/* Never failing versions of the previous functions. + + CONTEXT is the context for which argmatch is called (e.g., + "--version-control", or "$VERSION_CONTROL" etc.). Upon failure, + calls the (supposed never to return) function EXIT_FN. */ + +ptrdiff_t +__xargmatch_internal (const char *context, + const char *arg, const char *const *arglist, + const void *vallist, size_t valsize, + argmatch_exit_fn exit_fn, + bool allow_abbreviation) +{ + ptrdiff_t res; + + if (allow_abbreviation) + res = argmatch (arg, arglist, vallist, valsize); + else + res = argmatch_exact (arg, arglist); + + if (res >= 0) + /* Success. */ + return res; + + /* We failed. Explain why. */ + argmatch_invalid (context, arg, res); + argmatch_valid (arglist, vallist, valsize); + (*exit_fn) (); + + return -1; /* To please the compilers. */ +} + +/* Look for VALUE in VALLIST, an array of objects of size VALSIZE and + return the first corresponding argument in ARGLIST */ +const char * +argmatch_to_argument (const void *value, + const char *const *arglist, + const void *vallist, size_t valsize) +{ + size_t i; + + for (i = 0; arglist[i]; i++) + if (!memcmp (value, (char const *) vallist + valsize * i, valsize)) + return arglist[i]; + return NULL; +} + +#ifdef TEST +/* + * Based on "getversion.c" by David MacKenzie + */ + +/* When to make backup files. */ +enum backup_type +{ + /* Never make backups. */ + no_backups, + + /* Make simple backups of every file. */ + simple_backups, + + /* Make numbered backups of files that already have numbered backups, + and simple backups of the others. */ + numbered_existing_backups, + + /* Make numbered backups of every file. */ + numbered_backups +}; + +/* Two tables describing arguments (keys) and their corresponding + values */ +static const char *const backup_args[] = +{ + "no", "none", "off", + "simple", "never", + "existing", "nil", + "numbered", "t", + 0 +}; + +static const enum backup_type backup_vals[] = +{ + no_backups, no_backups, no_backups, + simple_backups, simple_backups, + numbered_existing_backups, numbered_existing_backups, + numbered_backups, numbered_backups +}; + +int +main (int argc, const char *const *argv) +{ + const char *cp; + enum backup_type backup_type = no_backups; + + if (argc > 2) + { + fprintf (stderr, "Usage: %s [VERSION_CONTROL]\n", getprogname ()); + exit (1); + } + + if ((cp = getenv ("VERSION_CONTROL"))) + backup_type = XARGMATCH ("$VERSION_CONTROL", cp, + backup_args, backup_vals); + + if (argc == 2) + backup_type = XARGMATCH (getprogname (), argv[1], + backup_args, backup_vals); + + printf ("The version control is '%s'\n", + ARGMATCH_TO_ARGUMENT (&backup_type, backup_args, backup_vals)); + + return 0; +} +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/argmatch.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/argmatch.h new file mode 100644 index 00000000..ca60dfe1 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/argmatch.h @@ -0,0 +1,350 @@ +/* argmatch.h -- definitions and prototypes for argmatch.c + + Copyright (C) 1990, 1998-1999, 2001-2002, 2004-2005, 2009-2024 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 . */ + +/* Written by David MacKenzie + Modified by Akim Demaille */ + +#ifndef ARGMATCH_H_ +# define ARGMATCH_H_ 1 + +/* This file uses _GL_ATTRIBUTE_PURE. */ +# if !_GL_CONFIG_H_INCLUDED +# error "Please include config.h first." +# endif + +# include +# include +# include +# include /* memcmp */ + +# include "gettext.h" +# include "quote.h" + +# ifdef __cplusplus +extern "C" { +# endif + +# define ARRAY_CARDINALITY(Array) (sizeof (Array) / sizeof *(Array)) + +/* Assert there are as many real arguments as there are values + (argument list ends with a NULL guard). */ + +# define ARGMATCH_VERIFY(Arglist, Vallist) \ + static_assert (ARRAY_CARDINALITY (Arglist) \ + == ARRAY_CARDINALITY (Vallist) + 1) + +/* Return the index of the element of ARGLIST (NULL terminated) that + matches with ARG. If VALLIST is not NULL, then use it to resolve + false ambiguities (i.e., different matches of ARG but corresponding + to the same values in VALLIST). */ + +ptrdiff_t argmatch (char const *arg, char const *const *arglist, + void const *vallist, size_t valsize) _GL_ATTRIBUTE_PURE; + +ptrdiff_t argmatch_exact (char const *arg, char const *const *arglist) + _GL_ATTRIBUTE_PURE; + +# define ARGMATCH(Arg, Arglist, Vallist) \ + argmatch (Arg, Arglist, (void const *) (Vallist), sizeof *(Vallist)) + +# define ARGMATCH_EXACT(Arg, Arglist) \ + argmatch_exact (Arg, Arglist) + +/* xargmatch calls this function when it fails. This function should not + return. By default, this is a function that calls ARGMATCH_DIE which + in turn defaults to 'exit (exit_failure)'. */ +typedef void (*argmatch_exit_fn) (void); +extern argmatch_exit_fn argmatch_die; + +/* Report on stderr why argmatch failed. Report correct values. */ + +void argmatch_invalid (char const *context, char const *value, + ptrdiff_t problem); + +/* Left for compatibility with the old name invalid_arg */ + +# define invalid_arg(Context, Value, Problem) \ + argmatch_invalid (Context, Value, Problem) + + + +/* Report on stderr the list of possible arguments. */ + +void argmatch_valid (char const *const *arglist, + void const *vallist, size_t valsize); + +# define ARGMATCH_VALID(Arglist, Vallist) \ + argmatch_valid (Arglist, (void const *) (Vallist), sizeof *(Vallist)) + + + +/* Like argmatch/argmatch_exact, but upon failure, report an explanation + of the failure, and exit using the function EXIT_FN. */ + +ptrdiff_t __xargmatch_internal (char const *context, + char const *arg, char const *const *arglist, + void const *vallist, size_t valsize, + argmatch_exit_fn exit_fn, + bool allow_abbreviation); + +/* Programmer friendly interface to __xargmatch_internal. */ + +# define XARGMATCH(Context, Arg, Arglist, Vallist) \ + ((Vallist) [__xargmatch_internal (Context, Arg, Arglist, \ + (void const *) (Vallist), \ + sizeof *(Vallist), \ + argmatch_die, \ + true)]) + +# define XARGMATCH_EXACT(Context, Arg, Arglist, Vallist) \ + ((Vallist) [__xargmatch_internal (Context, Arg, Arglist, \ + (void const *) (Vallist), \ + sizeof *(Vallist), \ + argmatch_die, \ + false)]) + +/* Convert a value into a corresponding argument. */ + +char const *argmatch_to_argument (void const *value, + char const *const *arglist, + void const *vallist, size_t valsize) + _GL_ATTRIBUTE_PURE; + +# define ARGMATCH_TO_ARGUMENT(Value, Arglist, Vallist) \ + argmatch_to_argument (Value, Arglist, \ + (void const *) (Vallist), sizeof *(Vallist)) + +# define ARGMATCH_DEFINE_GROUP(Name, Type) \ + /* The type of the values of this group. */ \ + typedef Type argmatch_##Name##_type; \ + \ + /* The size of the type of the values of this group. */ \ + enum argmatch_##Name##_size_enum \ + { \ + argmatch_##Name##_size = sizeof (argmatch_##Name##_type) \ + }; \ + \ + /* Argument mapping of this group. */ \ + typedef struct \ + { \ + /* Argument (e.g., "simple"). */ \ + const char *arg; \ + /* Value (e.g., simple_backups). */ \ + const argmatch_##Name##_type val; \ + } argmatch_##Name##_arg; \ + \ + /* Documentation of this group. */ \ + typedef struct \ + { \ + /* Argument (e.g., "simple"). */ \ + const char *arg; \ + /* Documentation (e.g., N_("always make simple backups")). */ \ + const char *doc; \ + } argmatch_##Name##_doc; \ + \ + /* All the features of an argmatch group. */ \ + typedef struct \ + { \ + const argmatch_##Name##_arg* args; \ + const argmatch_##Name##_doc* docs; \ + \ + /* Printed before the usage message. */ \ + const char *doc_pre; \ + /* Printed after the usage message. */ \ + const char *doc_post; \ + } argmatch_##Name##_group_type; \ + \ + /* The structure the user must build. */ \ + extern const argmatch_##Name##_group_type argmatch_##Name##_group; \ + \ + /* Print the documentation of this group. */ \ + void argmatch_##Name##_usage (FILE *out); \ + \ + /* If nonnegative, the index I of ARG in ARGS, i.e, \ + ARGS[I] == ARG. \ + Return -1 for invalid argument, -2 for ambiguous argument. */ \ + ptrdiff_t argmatch_##Name##_choice (const char *arg); \ + \ + /* A pointer to the corresponding value if it exists, or \ + report an error and exit with failure if the argument was \ + not recognized. */ \ + const argmatch_##Name##_type* \ + argmatch_##Name##_value (const char *context, const char *arg); \ + \ + /* The first argument in ARGS that matches this value, or NULL. */ \ + const char * \ + argmatch_##Name##_argument (const argmatch_##Name##_type *val); \ + \ + ptrdiff_t \ + argmatch_##Name##_choice (const char *arg) \ + { \ + const argmatch_##Name##_group_type *g = &argmatch_##Name##_group; \ + size_t size = argmatch_##Name##_size; \ + ptrdiff_t res = -1; /* Index of first nonexact match. */ \ + bool ambiguous = false; /* Whether multiple nonexact match(es). */ \ + size_t arglen = strlen (arg); \ + \ + /* Test all elements for either exact match or abbreviated \ + matches. */ \ + for (size_t i = 0; g->args[i].arg; i++) \ + if (!strncmp (g->args[i].arg, arg, arglen)) \ + { \ + if (strlen (g->args[i].arg) == arglen) \ + /* Exact match found. */ \ + return i; \ + else if (res == -1) \ + /* First nonexact match found. */ \ + res = i; \ + else if (memcmp (&g->args[res].val, &g->args[i].val, size)) \ + /* Second nonexact match found. */ \ + /* There is a real ambiguity, or we could not \ + disambiguate. */ \ + ambiguous = true; \ + } \ + return ambiguous ? -2 : res; \ + } \ + \ + const char * \ + argmatch_##Name##_argument (const argmatch_##Name##_type *val) \ + { \ + const argmatch_##Name##_group_type *g = &argmatch_##Name##_group; \ + size_t size = argmatch_##Name##_size; \ + for (size_t i = 0; g->args[i].arg; i++) \ + if (!memcmp (val, &g->args[i].val, size)) \ + return g->args[i].arg; \ + return NULL; \ + } \ + \ + /* List the valid values of this group. */ \ + static void \ + argmatch_##Name##_valid (FILE *out) \ + { \ + const argmatch_##Name##_group_type *g = &argmatch_##Name##_group; \ + size_t size = argmatch_##Name##_size; \ + \ + /* Try to put synonyms on the same line. Synonyms are expected \ + to follow each other. */ \ + fputs (gettext ("Valid arguments are:"), out); \ + for (int i = 0; g->args[i].arg; i++) \ + if (i == 0 \ + || memcmp (&g->args[i-1].val, &g->args[i].val, size)) \ + fprintf (out, "\n - %s", quote (g->args[i].arg)); \ + else \ + fprintf (out, ", %s", quote (g->args[i].arg)); \ + putc ('\n', out); \ + } \ + \ + const argmatch_##Name##_type* \ + argmatch_##Name##_value (const char *context, const char *arg) \ + { \ + const argmatch_##Name##_group_type *g = &argmatch_##Name##_group; \ + ptrdiff_t res = argmatch_##Name##_choice (arg); \ + if (res < 0) \ + { \ + argmatch_invalid (context, arg, res); \ + argmatch_##Name##_valid (stderr); \ + argmatch_die (); \ + } \ + return &g->args[res].val; \ + } \ + \ + /* The column in which the documentation is displayed. \ + The leftmost possible, but no more than 20. */ \ + static int \ + argmatch_##Name##_doc_col (void) \ + { \ + const argmatch_##Name##_group_type *g = &argmatch_##Name##_group; \ + size_t size = argmatch_##Name##_size; \ + int res = 0; \ + for (int i = 0; g->docs[i].arg; ++i) \ + { \ + int col = 4; \ + int ival = argmatch_##Name##_choice (g->docs[i].arg); \ + if (ival < 0) \ + /* Pseudo argument, display it. */ \ + col += strlen (g->docs[i].arg); \ + else \ + /* Genuine argument, display it with its synonyms. */ \ + for (int j = 0; g->args[j].arg; ++j) \ + if (! memcmp (&g->args[ival].val, &g->args[j].val, size)) \ + col += (col == 4 ? 0 : 2) + strlen (g->args[j].arg); \ + if (res <= col) \ + res = col <= 20 ? col : 20; \ + } \ + return res ? res : 20; \ + } \ + \ + void \ + argmatch_##Name##_usage (FILE *out) \ + { \ + const argmatch_##Name##_group_type *g = &argmatch_##Name##_group; \ + size_t size = argmatch_##Name##_size; \ + /* Width of the screen. Help2man does not seem to support \ + arguments on several lines, so in that case pretend a very \ + large width. */ \ + const int screen_width = getenv ("HELP2MAN") ? INT_MAX : 80; \ + if (g->doc_pre) \ + fprintf (out, "%s\n", gettext (g->doc_pre)); \ + int doc_col = argmatch_##Name##_doc_col (); \ + for (int i = 0; g->docs[i].arg; ++i) \ + { \ + int col = 0; \ + bool first = true; \ + int ival = argmatch_##Name##_choice (g->docs[i].arg); \ + if (ival < 0) \ + /* Pseudo argument, display it. */ \ + col += fprintf (out, " %s", g->docs[i].arg); \ + else \ + /* Genuine argument, display it with its synonyms. */ \ + for (int j = 0; g->args[j].arg; ++j) \ + if (! memcmp (&g->args[ival].val, &g->args[j].val, size)) \ + { \ + if (!first \ + && screen_width < col + 2 + strlen (g->args[j].arg)) \ + { \ + fprintf (out, ",\n"); \ + col = 0; \ + first = true; \ + } \ + if (first) \ + { \ + col += fprintf (out, " "); \ + first = false; \ + } \ + else \ + col += fprintf (out, ","); \ + col += fprintf (out, " %s", g->args[j].arg); \ + } \ + /* The doc. Separated by at least two spaces. */ \ + if (doc_col < col + 2) \ + { \ + fprintf (out, "\n"); \ + col = 0; \ + } \ + fprintf (out, "%*s%s\n", \ + doc_col - col, "", gettext (g->docs[i].doc)); \ + } \ + if (g->doc_post) \ + fprintf (out, "%s\n", gettext (g->doc_post)); \ + } + +# ifdef __cplusplus +} +# endif + +#endif /* ARGMATCH_H_ */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/assert.in.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/assert.in.h new file mode 100644 index 00000000..6e4995e1 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/assert.in.h @@ -0,0 +1,27 @@ +/* Substitute for and wrapper around + Copyright (C) 2011-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Do not guard the include, since is supposed to define + the assert macro each time it is included. */ + +#if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +#endif +@PRAGMA_COLUMNS@ + +#@INCLUDE_NEXT@ @NEXT_ASSERT_H@ + +/* The definition of static_assert is copied here. */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/assure.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/assure.h new file mode 100644 index 00000000..d650ca15 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/assure.h @@ -0,0 +1,57 @@ +/* Run-time assert-like macros. + + Copyright (C) 2014-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Paul Eggert. */ + +#ifndef _GL_ASSURE_H +#define _GL_ASSURE_H + +#include +#include "verify.h" + +/* Evaluate an assertion E that is guaranteed to be true. + If NDEBUG is not defined, abort the program if E is false. + If NDEBUG is defined, the compiler can assume E and behavior is + undefined if E is false, fails to evaluate, or has side effects. + + Unlike standard 'assert', this macro evaluates E even when NDEBUG + is defined, so as to catch typos, avoid some GCC warnings, and + improve performance when E is simple enough. + + Also see the documentation for 'assume' in verify.h. */ + +#ifdef NDEBUG +# define affirm(E) assume (E) +#else +# define affirm(E) assert (E) +#endif + +/* Check E's value at runtime, and report an error and abort if not. + However, do nothing if NDEBUG is defined. + + Unlike standard 'assert', this macro compiles E even when NDEBUG + is defined, so as to catch typos and avoid some GCC warnings. + Unlike 'affirm', it is OK for E to use hard-to-optimize features, + since E is not executed if NDEBUG is defined. */ + +#ifdef NDEBUG +# define assure(E) ((void) (0 && (E))) +#else +# define assure(E) assert (E) +#endif + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/at-func.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/at-func.c new file mode 100644 index 00000000..56b313f4 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/at-func.c @@ -0,0 +1,146 @@ +/* Define at-style functions like fstatat, unlinkat, fchownat, etc. + Copyright (C) 2006, 2009-2024 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 . */ + +/* written by Jim Meyering */ + +#include "filename.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */ + +#ifdef GNULIB_SUPPORT_ONLY_AT_FDCWD +# include +# ifndef ENOTSUP +# define ENOTSUP EINVAL +# endif +#else +# include "openat.h" +# include "openat-priv.h" +# include "save-cwd.h" +#endif + +#ifdef AT_FUNC_USE_F1_COND +# define CALL_FUNC(F) \ + (flag == AT_FUNC_USE_F1_COND \ + ? AT_FUNC_F1 (F AT_FUNC_POST_FILE_ARGS) \ + : AT_FUNC_F2 (F AT_FUNC_POST_FILE_ARGS)) +# define VALIDATE_FLAG(F) \ + if (flag & ~AT_FUNC_USE_F1_COND) \ + { \ + errno = EINVAL; \ + return FUNC_FAIL; \ + } +#else +# define CALL_FUNC(F) (AT_FUNC_F1 (F AT_FUNC_POST_FILE_ARGS)) +# define VALIDATE_FLAG(F) /* empty */ +#endif + +#ifdef AT_FUNC_RESULT +# define FUNC_RESULT AT_FUNC_RESULT +#else +# define FUNC_RESULT int +#endif + +#ifdef AT_FUNC_FAIL +# define FUNC_FAIL AT_FUNC_FAIL +#else +# define FUNC_FAIL -1 +#endif + +/* Call AT_FUNC_F1 to operate on FILE, which is in the directory + open on descriptor FD. If AT_FUNC_USE_F1_COND is defined to a value, + AT_FUNC_POST_FILE_PARAM_DECLS must include a parameter named flag; + call AT_FUNC_F2 if FLAG is 0 or fail if FLAG contains more bits than + AT_FUNC_USE_F1_COND. Return int and fail with -1 unless AT_FUNC_RESULT + or AT_FUNC_FAIL are defined. If possible, do it without changing the + working directory. Otherwise, resort to using save_cwd/fchdir, + then AT_FUNC_F?/restore_cwd. If either the save_cwd or the restore_cwd + fails, then give a diagnostic and exit nonzero. */ +FUNC_RESULT +AT_FUNC_NAME (int fd, char const *file AT_FUNC_POST_FILE_PARAM_DECLS) +{ + VALIDATE_FLAG (flag); + + if (fd == AT_FDCWD || IS_ABSOLUTE_FILE_NAME (file)) + return CALL_FUNC (file); + +#ifdef GNULIB_SUPPORT_ONLY_AT_FDCWD + errno = ENOTSUP; + return FUNC_FAIL; +#else + { + /* Be careful to choose names unlikely to conflict with + AT_FUNC_POST_FILE_PARAM_DECLS. */ + struct saved_cwd saved_cwd; + int saved_errno; + FUNC_RESULT err; + + { + char proc_buf[OPENAT_BUFFER_SIZE]; + char *proc_file = openat_proc_name (proc_buf, fd, file); + if (proc_file) + { + FUNC_RESULT proc_result = CALL_FUNC (proc_file); + int proc_errno = errno; + if (proc_file != proc_buf) + free (proc_file); + /* If the syscall succeeds, or if it fails with an unexpected + errno value, then return right away. Otherwise, fall through + and resort to using save_cwd/restore_cwd. */ + if (FUNC_FAIL != proc_result) + return proc_result; + if (! EXPECTED_ERRNO (proc_errno)) + { + errno = proc_errno; + return proc_result; + } + } + } + + if (save_cwd (&saved_cwd) != 0) + openat_save_fail (errno); + if (0 <= fd && fd == saved_cwd.desc) + { + /* If saving the working directory collides with the user's + requested fd, then the user's fd must have been closed to + begin with. */ + free_cwd (&saved_cwd); + errno = EBADF; + return FUNC_FAIL; + } + + if (fchdir (fd) != 0) + { + saved_errno = errno; + free_cwd (&saved_cwd); + errno = saved_errno; + return FUNC_FAIL; + } + + err = CALL_FUNC (file); + saved_errno = (err == FUNC_FAIL ? errno : 0); + + if (restore_cwd (&saved_cwd) != 0) + openat_restore_fail (errno); + + free_cwd (&saved_cwd); + + if (saved_errno) + errno = saved_errno; + return err; + } +#endif +} +#undef CALL_FUNC +#undef FUNC_RESULT +#undef FUNC_FAIL diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/attribute.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/attribute.h new file mode 100644 index 00000000..710341ba --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/attribute.h @@ -0,0 +1,243 @@ +/* ATTRIBUTE_* macros for using attributes in GCC and similar compilers + + Copyright 2020-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Paul Eggert. */ + +/* Provide public ATTRIBUTE_* names for the private _GL_ATTRIBUTE_* + macros used within Gnulib. */ + +/* These attributes can be placed in two ways: + - At the start of a declaration (i.e. even before storage-class + specifiers!); then they apply to all entities that are declared + by the declaration. + - Immediately after the name of an entity being declared by the + declaration; then they apply to that entity only. */ + +#ifndef _GL_ATTRIBUTE_H +#define _GL_ATTRIBUTE_H + + +/* This file defines two types of attributes: + * C23 standard attributes. These have macro names that do not begin with + 'ATTRIBUTE_'. + * Selected GCC attributes; see: + https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html + https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html + https://gcc.gnu.org/onlinedocs/gcc/Common-Type-Attributes.html + These names begin with 'ATTRIBUTE_' to avoid name clashes. */ + + +/* This file uses _GL_ATTRIBUTE_ALLOC_SIZE, _GL_ATTRIBUTE_ALWAYS_INLINE, + _GL_ATTRIBUTE_ARTIFICIAL, _GL_ATTRIBUTE_COLD, _GL_ATTRIBUTE_CONST, + _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_DEPRECATED, _GL_ATTRIBUTE_ERROR, + _GL_ATTRIBUTE_WARNING, _GL_ATTRIBUTE_EXTERNALLY_VISIBLE, + _GL_ATTRIBUTE_FALLTHROUGH, _GL_ATTRIBUTE_FORMAT, _GL_ATTRIBUTE_LEAF, + _GL_ATTRIBUTE_MALLOC, _GL_ATTRIBUTE_MAY_ALIAS, _GL_ATTRIBUTE_MAYBE_UNUSED, + _GL_ATTRIBUTE_NODISCARD, _GL_ATTRIBUTE_NOINLINE, _GL_ATTRIBUTE_NONNULL, + _GL_ATTRIBUTE_NONSTRING, _GL_ATTRIBUTE_NOTHROW, _GL_ATTRIBUTE_PACKED, + _GL_ATTRIBUTE_PURE, _GL_ATTRIBUTE_RETURNS_NONNULL, + _GL_ATTRIBUTE_SENTINEL. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + + +/* =============== Attributes for specific kinds of functions =============== */ + +/* Attributes for functions that should not be used. */ + +/* Warn if the entity is used. */ +/* Applies to: + - function, variable, + - struct, union, struct/union member, + - enumeration, enumeration item, + - typedef, + in C++ also: namespace, class, template specialization. */ +#define DEPRECATED _GL_ATTRIBUTE_DEPRECATED + +/* If a function call is not optimized way, warn with MSG. */ +/* Applies to: functions. */ +#define ATTRIBUTE_WARNING(msg) _GL_ATTRIBUTE_WARNING (msg) + +/* If a function call is not optimized way, report an error with MSG. */ +/* Applies to: functions. */ +#define ATTRIBUTE_ERROR(msg) _GL_ATTRIBUTE_ERROR (msg) + + +/* Attributes for memory-allocating functions. */ + +/* The function returns a pointer to freshly allocated memory. */ +/* Applies to: functions. */ +#define ATTRIBUTE_MALLOC _GL_ATTRIBUTE_MALLOC + +/* ATTRIBUTE_ALLOC_SIZE ((N)) - The Nth argument of the function + is the size of the returned memory block. + ATTRIBUTE_ALLOC_SIZE ((M, N)) - Multiply the Mth and Nth arguments + to determine the size of the returned memory block. */ +/* Applies to: function, pointer to function, function types. */ +#define ATTRIBUTE_ALLOC_SIZE(args) _GL_ATTRIBUTE_ALLOC_SIZE (args) + +/* ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers + that can be freed by passing them as the Ith argument to the + function F. + ATTRIBUTE_DEALLOC_FREE declares that the function returns pointers that + can be freed via 'free'; it can be used only after declaring 'free'. */ +/* Applies to: functions. Cannot be used on inline functions. */ +#define ATTRIBUTE_DEALLOC(f, i) _GL_ATTRIBUTE_DEALLOC(f, i) +#define ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC_FREE + +/* Attributes for variadic functions. */ + +/* The variadic function expects a trailing NULL argument. + ATTRIBUTE_SENTINEL () - The last argument is NULL (requires C99). + ATTRIBUTE_SENTINEL ((N)) - The (N+1)st argument from the end is NULL. */ +/* Applies to: functions. */ +#define ATTRIBUTE_SENTINEL(pos) _GL_ATTRIBUTE_SENTINEL (pos) + + +/* ================== Attributes for compiler diagnostics ================== */ + +/* Attributes that help the compiler diagnose programmer mistakes. + Some of them may also help for some compiler optimizations. */ + +/* ATTRIBUTE_FORMAT ((ARCHETYPE, STRING-INDEX, FIRST-TO-CHECK)) - + The STRING-INDEXth function argument is a format string of style + ARCHETYPE, which is one of: + printf, gnu_printf + scanf, gnu_scanf, + strftime, gnu_strftime, + strfmon, + or the same thing prefixed and suffixed with '__'. + If FIRST-TO-CHECK is not 0, arguments starting at FIRST-TO_CHECK + are suitable for the format string. */ +/* Applies to: functions. */ +#define ATTRIBUTE_FORMAT(spec) _GL_ATTRIBUTE_FORMAT (spec) + +/* ATTRIBUTE_NONNULL ((N1, N2,...)) - Arguments N1, N2,... must not be NULL. + ATTRIBUTE_NONNULL () - All pointer arguments must not be null. */ +/* Applies to: functions. */ +#define ATTRIBUTE_NONNULL(args) _GL_ATTRIBUTE_NONNULL (args) + +/* The function's return value is a non-NULL pointer. */ +/* Applies to: functions. */ +#define ATTRIBUTE_RETURNS_NONNULL _GL_ATTRIBUTE_RETURNS_NONNULL + +/* Warn if the caller does not use the return value, + unless the caller uses something like ignore_value. */ +/* Applies to: function, enumeration, class. */ +#define NODISCARD _GL_ATTRIBUTE_NODISCARD + + +/* Attributes that disable false alarms when the compiler diagnoses + programmer "mistakes". */ + +/* Do not warn if the entity is not used. */ +/* Applies to: + - function, variable, + - struct, union, struct/union member, + - enumeration, enumeration item, + - typedef, + in C++ also: class. */ +#define MAYBE_UNUSED _GL_ATTRIBUTE_MAYBE_UNUSED + +/* The contents of a character array is not meant to be NUL-terminated. */ +/* Applies to: struct/union members and variables that are arrays of element + type '[[un]signed] char'. */ +#define ATTRIBUTE_NONSTRING _GL_ATTRIBUTE_NONSTRING + +/* Do not warn if control flow falls through to the immediately + following 'case' or 'default' label. */ +/* Applies to: Empty statement (;), inside a 'switch' statement. */ +#define FALLTHROUGH _GL_ATTRIBUTE_FALLTHROUGH + + +/* ================== Attributes for debugging information ================== */ + +/* Attributes regarding debugging information emitted by the compiler. */ + +/* Omit the function from stack traces when debugging. */ +/* Applies to: function. */ +#define ATTRIBUTE_ARTIFICIAL _GL_ATTRIBUTE_ARTIFICIAL + +/* Make the entity visible to debuggers etc., even with '-fwhole-program'. */ +/* Applies to: functions, variables. */ +#define ATTRIBUTE_EXTERNALLY_VISIBLE _GL_ATTRIBUTE_EXTERNALLY_VISIBLE + + +/* ========== Attributes that mainly direct compiler optimizations ========== */ + +/* The function does not throw exceptions. */ +/* Applies to: functions. */ +/* After a function's parameter list, this attribute must come first, before + other attributes. */ +#define ATTRIBUTE_NOTHROW _GL_ATTRIBUTE_NOTHROW + +/* Do not inline the function. */ +/* Applies to: functions. */ +#define ATTRIBUTE_NOINLINE _GL_ATTRIBUTE_NOINLINE + +/* Always inline the function, and report an error if the compiler + cannot inline. */ +/* Applies to: function. */ +#define ATTRIBUTE_ALWAYS_INLINE _GL_ATTRIBUTE_ALWAYS_INLINE + +/* It is OK for a compiler to omit duplicate calls with the same arguments. + This attribute is safe for a function that neither depends on + nor affects observable state, and always returns exactly once - + e.g., does not loop forever, and does not call longjmp. + (This attribute is stricter than ATTRIBUTE_PURE.) */ +/* Applies to: functions. */ +#define ATTRIBUTE_CONST _GL_ATTRIBUTE_CONST + +/* It is OK for a compiler to omit duplicate calls with the same + arguments if observable state is not changed between calls. + This attribute is safe for a function that does not affect + observable state, and always returns exactly once. + (This attribute is looser than ATTRIBUTE_CONST.) */ +/* Applies to: functions. */ +#define ATTRIBUTE_PURE _GL_ATTRIBUTE_PURE + +/* The function is rarely executed. */ +/* Applies to: functions. */ +#define ATTRIBUTE_COLD _GL_ATTRIBUTE_COLD + +/* If called from some other compilation unit, the function executes + code from that unit only by return or by exception handling, + letting the compiler optimize that unit more aggressively. */ +/* Applies to: functions. */ +#define ATTRIBUTE_LEAF _GL_ATTRIBUTE_LEAF + +/* For struct members: The member has the smallest possible alignment. + For struct, union, class: All members have the smallest possible alignment, + minimizing the memory required. */ +/* Applies to: struct members, struct, union, + in C++ also: class. */ +#define ATTRIBUTE_PACKED _GL_ATTRIBUTE_PACKED + + +/* ================ Attributes that make invalid code valid ================ */ + +/* Attributes that prevent fatal compiler optimizations for code that is not + fully ISO C compliant. */ + +/* Pointers to the type may point to the same storage as pointers to + other types, thus disabling strict aliasing optimization. */ +/* Applies to: types. */ +#define ATTRIBUTE_MAY_ALIAS _GL_ATTRIBUTE_MAY_ALIAS + + +#endif /* _GL_ATTRIBUTE_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/basename-lgpl.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/basename-lgpl.c new file mode 100644 index 00000000..256f8460 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/basename-lgpl.c @@ -0,0 +1,70 @@ +/* basename.c -- return the last element in a file name + + Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2024 Free Software + Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "basename-lgpl.h" + +#include + +#include "filename.h" + +char * +last_component (char const *name) +{ + char const *base = name + FILE_SYSTEM_PREFIX_LEN (name); + char const *p; + bool last_was_slash = false; + + while (ISSLASH (*base)) + base++; + + for (p = base; *p; p++) + { + if (ISSLASH (*p)) + last_was_slash = true; + else if (last_was_slash) + { + base = p; + last_was_slash = false; + } + } + + return (char *) base; +} + +size_t +base_len (char const *name) +{ + size_t len; + size_t prefix_len = FILE_SYSTEM_PREFIX_LEN (name); + + for (len = strlen (name); 1 < len && ISSLASH (name[len - 1]); len--) + continue; + + if (DOUBLE_SLASH_IS_DISTINCT_ROOT && len == 1 + && ISSLASH (name[0]) && ISSLASH (name[1]) && ! name[2]) + return 2; + + if (FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE && prefix_len + && len == prefix_len && ISSLASH (name[prefix_len])) + return prefix_len + 1; + + return len; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/basename-lgpl.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/basename-lgpl.h new file mode 100644 index 00000000..2a56be98 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/basename-lgpl.h @@ -0,0 +1,83 @@ +/* Extract the last component (base name) of a file name. + + Copyright (C) 1998, 2001, 2003-2006, 2009-2024 Free Software Foundation, + Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef _BASENAME_LGPL_H +#define _BASENAME_LGPL_H + +/* This file uses _GL_ATTRIBUTE_PURE. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +#include + +#ifndef DOUBLE_SLASH_IS_DISTINCT_ROOT +# define DOUBLE_SLASH_IS_DISTINCT_ROOT 0 +#endif + +#ifdef __cplusplus +extern "C" { +#endif + + +/* Return the address of the last file name component of FILENAME. + If FILENAME has some trailing slash(es), they are considered to be + part of the last component. + If FILENAME has no relative file name components because it is a file + system root, return the empty string. + Examples: + FILENAME RESULT + "foo.c" "foo.c" + "foo/bar.c" "bar.c" + "/foo/bar.c" "bar.c" + "foo/bar/" "bar/" + "foo/bar//" "bar//" + "/" "" + "//" "" + "" "" + The return value is a tail of the given FILENAME; do NOT free() it! */ + +/* This function was traditionally called 'basename', but we avoid this + function name because + * Various platforms have different functions in their libc. + In particular, the glibc basename(), defined in , does + not consider trailing slashes to be part of the component: + FILENAME RESULT + "foo/bar/" "" + "foo/bar//" "" + * The 'basename' command eliminates trailing slashes and for a root + produces a non-empty result: + FILENAME RESULT + "foo/bar/" "bar" + "foo/bar//" "bar" + "/" "/" + "//" "/" + */ +extern char *last_component (char const *filename) _GL_ATTRIBUTE_PURE; + +/* Return the length of the basename FILENAME. + Typically FILENAME is the value returned by base_name or last_component. + Act like strlen (FILENAME), except omit all trailing slashes. */ +extern size_t base_len (char const *filename) _GL_ATTRIBUTE_PURE; + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* _BASENAME_LGPL_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/basename.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/basename.c new file mode 100644 index 00000000..c5a6bdc9 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/basename.c @@ -0,0 +1,64 @@ +/* basename.c -- return the last element in a file name + + Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2024 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 . */ + +#include + +#include "dirname.h" + +#include +#include "xalloc.h" + +char * +base_name (char const *name) +{ + char const *base = last_component (name); + idx_t length; + int dotslash_len; + if (*base) + { + length = base_len (base); + + /* Collapse a sequence of trailing slashes into one. */ + length += ISSLASH (base[length]); + + /* On systems with drive letters, "a/b:c" must return "./b:c" rather + than "b:c" to avoid confusion with a drive letter. On systems + with pure POSIX semantics, this is not an issue. */ + dotslash_len = FILE_SYSTEM_PREFIX_LEN (base) != 0 ? 2 : 0; + } + else + { + /* There is no last component, so NAME is a file system root or + the empty string. */ + base = name; + length = base_len (base); + dotslash_len = 0; + } + + char *p = ximalloc (dotslash_len + length + 1); + if (dotslash_len) + { + p[0] = '.'; + p[1] = '/'; + } + + /* Finally, copy the basename. */ + memcpy (p + dotslash_len, base, length); + p[dotslash_len + length] = '\0'; + return p; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/binary-io.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/binary-io.c new file mode 100644 index 00000000..40f01d67 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/binary-io.c @@ -0,0 +1,39 @@ +/* Binary mode I/O. + Copyright 2017-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +#define BINARY_IO_INLINE _GL_EXTERN_INLINE +#include "binary-io.h" + +#if defined __DJGPP__ || defined __EMX__ +# include + +int +set_binary_mode (int fd, int mode) +{ + if (isatty (fd)) + /* If FD refers to a console (not a pipe, not a regular file), + O_TEXT is the only reasonable mode, both on input and on output. + Silently ignore the request. If we were to return -1 here, + all programs that use xset_binary_mode would fail when run + with console input or console output. */ + return O_TEXT; + else + return __gl_setmode (fd, mode); +} + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/binary-io.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/binary-io.h new file mode 100644 index 00000000..0cc5c117 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/binary-io.h @@ -0,0 +1,79 @@ +/* Binary mode I/O. + Copyright (C) 2001, 2003, 2005, 2008-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef _BINARY_H +#define _BINARY_H + +/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, _GL_UNUSED. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +/* For systems that distinguish between text and binary I/O. + O_BINARY is guaranteed by the gnulib . */ +#include + +/* The MSVC7 doesn't like to be included after '#define fileno ...', + so we include it here first. */ +#include + +_GL_INLINE_HEADER_BEGIN +#ifndef BINARY_IO_INLINE +# define BINARY_IO_INLINE _GL_INLINE +#endif + +#if O_BINARY +# if defined __EMX__ || defined __DJGPP__ || defined __CYGWIN__ +# include /* declares setmode() */ +# define __gl_setmode setmode +# else +# define __gl_setmode _setmode +# undef fileno +# define fileno _fileno +# endif +#else + /* On reasonable systems, binary I/O is the only choice. */ + /* Use a function rather than a macro, to avoid gcc warnings + "warning: statement with no effect". */ +BINARY_IO_INLINE int +__gl_setmode (_GL_UNUSED int fd, _GL_UNUSED int mode) +{ + return O_BINARY; +} +#endif + +/* Set FD's mode to MODE, which should be either O_TEXT or O_BINARY. + Return the old mode if successful, -1 (setting errno) on failure. + Ordinarily this function would be called 'setmode', since that is + its old name on MS-Windows, but it is called 'set_binary_mode' here + to avoid colliding with a BSD function of another name. */ + +#if defined __DJGPP__ || defined __EMX__ +extern int set_binary_mode (int fd, int mode); +#else +BINARY_IO_INLINE int +set_binary_mode (int fd, int mode) +{ + return __gl_setmode (fd, mode); +} +#endif + +/* This macro is obsolescent. */ +#define SET_BINARY(fd) ((void) set_binary_mode (fd, O_BINARY)) + +_GL_INLINE_HEADER_END + +#endif /* _BINARY_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/bitrotate.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/bitrotate.c new file mode 100644 index 00000000..bbf94d8b --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/bitrotate.c @@ -0,0 +1,21 @@ +/* Rotate bits in integers. + + Copyright (C) 2012-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +#define BITROTATE_INLINE _GL_EXTERN_INLINE +#include "bitrotate.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/bitrotate.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/bitrotate.h new file mode 100644 index 00000000..91744cc5 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/bitrotate.h @@ -0,0 +1,140 @@ +/* bitrotate.h - Rotate bits in integers + Copyright (C) 2008-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Simon Josefsson , 2008. */ + +#ifndef _GL_BITROTATE_H +#define _GL_BITROTATE_H + +/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +#include +#include +#include + +_GL_INLINE_HEADER_BEGIN +#ifndef BITROTATE_INLINE +# define BITROTATE_INLINE _GL_INLINE +#endif + +#ifdef UINT64_MAX +/* Given an unsigned 64-bit argument X, return the value corresponding + to rotating the bits N steps to the left. N must be between 1 and + 63 inclusive. */ +BITROTATE_INLINE uint64_t +rotl64 (uint64_t x, int n) +{ + return ((x << n) | (x >> (64 - n))) & UINT64_MAX; +} + +/* Given an unsigned 64-bit argument X, return the value corresponding + to rotating the bits N steps to the right. N must be between 1 to + 63 inclusive.*/ +BITROTATE_INLINE uint64_t +rotr64 (uint64_t x, int n) +{ + return ((x >> n) | (x << (64 - n))) & UINT64_MAX; +} +#endif + +/* Given an unsigned 32-bit argument X, return the value corresponding + to rotating the bits N steps to the left. N must be between 1 and + 31 inclusive. */ +BITROTATE_INLINE uint32_t +rotl32 (uint32_t x, int n) +{ + return ((x << n) | (x >> (32 - n))) & UINT32_MAX; +} + +/* Given an unsigned 32-bit argument X, return the value corresponding + to rotating the bits N steps to the right. N must be between 1 to + 31 inclusive.*/ +BITROTATE_INLINE uint32_t +rotr32 (uint32_t x, int n) +{ + return ((x >> n) | (x << (32 - n))) & UINT32_MAX; +} + +/* Given a size_t argument X, return the value corresponding + to rotating the bits N steps to the left. N must be between 1 and + (CHAR_BIT * sizeof (size_t) - 1) inclusive. */ +BITROTATE_INLINE size_t +rotl_sz (size_t x, int n) +{ + return ((x << n) | (x >> ((CHAR_BIT * sizeof x) - n))) & SIZE_MAX; +} + +/* Given a size_t argument X, return the value corresponding + to rotating the bits N steps to the right. N must be between 1 to + (CHAR_BIT * sizeof (size_t) - 1) inclusive. */ +BITROTATE_INLINE size_t +rotr_sz (size_t x, int n) +{ + return ((x >> n) | (x << ((CHAR_BIT * sizeof x) - n))) & SIZE_MAX; +} + +/* Given an unsigned 16-bit argument X, return the value corresponding + to rotating the bits N steps to the left. N must be between 1 to + 15 inclusive, but on most relevant targets N can also be 0 and 16 + because 'int' is at least 32 bits and the arguments must widen + before shifting. */ +BITROTATE_INLINE uint16_t +rotl16 (uint16_t x, int n) +{ + return (((unsigned int) x << n) | ((unsigned int) x >> (16 - n))) + & UINT16_MAX; +} + +/* Given an unsigned 16-bit argument X, return the value corresponding + to rotating the bits N steps to the right. N must be in 1 to 15 + inclusive, but on most relevant targets N can also be 0 and 16 + because 'int' is at least 32 bits and the arguments must widen + before shifting. */ +BITROTATE_INLINE uint16_t +rotr16 (uint16_t x, int n) +{ + return (((unsigned int) x >> n) | ((unsigned int) x << (16 - n))) + & UINT16_MAX; +} + +/* Given an unsigned 8-bit argument X, return the value corresponding + to rotating the bits N steps to the left. N must be between 1 to 7 + inclusive, but on most relevant targets N can also be 0 and 8 + because 'int' is at least 32 bits and the arguments must widen + before shifting. */ +BITROTATE_INLINE uint8_t +rotl8 (uint8_t x, int n) +{ + return (((unsigned int) x << n) | ((unsigned int) x >> (8 - n))) & UINT8_MAX; +} + +/* Given an unsigned 8-bit argument X, return the value corresponding + to rotating the bits N steps to the right. N must be in 1 to 7 + inclusive, but on most relevant targets N can also be 0 and 8 + because 'int' is at least 32 bits and the arguments must widen + before shifting. */ +BITROTATE_INLINE uint8_t +rotr8 (uint8_t x, int n) +{ + return (((unsigned int) x >> n) | ((unsigned int) x << (8 - n))) & UINT8_MAX; +} + +_GL_INLINE_HEADER_END + +#endif /* _GL_BITROTATE_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/btoc32.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/btoc32.c new file mode 100644 index 00000000..4f223059 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/btoc32.c @@ -0,0 +1,68 @@ +/* Convert unibyte character to 32-bit wide character. + Copyright (C) 2020-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 2020. */ + +#include + +#define IN_BTOC32 +/* Specification. */ +#include + +#include +#include +#include + +#if GL_CHAR32_T_IS_UNICODE +# include "lc-charset-unicode.h" +#endif + +#if _GL_WCHAR_T_IS_UCS4 +_GL_EXTERN_INLINE +#endif +wint_t +btoc32 (int c) +{ +#if HAVE_WORKING_MBRTOC32 && !_GL_WCHAR_T_IS_UCS4 + /* The char32_t encoding of a multibyte character may be different than its + wchar_t encoding. */ + if (c != EOF) + { + mbstate_t state; + char s[1]; + char32_t wc; + + mbszero (&state); + s[0] = (unsigned char) c; + if (mbrtoc32 (&wc, s, 1, &state) <= 1) + return wc; + } + return WEOF; +#else + /* In all known locale encodings, unibyte characters correspond only to + characters in the BMP. */ + wint_t wc = btowc (c); +# if GL_CHAR32_T_IS_UNICODE && GL_CHAR32_T_VS_WCHAR_T_NEEDS_CONVERSION + if (wc != WEOF && wc != 0) + { + wc = locale_encoding_to_unicode (wc); + if (wc == 0) + return WEOF; + } +# endif + return wc; +#endif +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/btowc.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/btowc.c new file mode 100644 index 00000000..8bf21aa6 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/btowc.c @@ -0,0 +1,47 @@ +/* Convert unibyte character to wide character. + Copyright (C) 2008, 2010-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2008. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +#include +#include +#include + +wint_t +btowc (int c) +{ + if (c != EOF) + { + char buf[1]; + wchar_t wc; + + buf[0] = c; +#if HAVE_MBRTOWC + mbstate_t state; + mbszero (&state); + size_t ret = mbrtowc (&wc, buf, 1, &state); + if (!(ret == (size_t)(-1) || ret == (size_t)(-2))) +#else + if (mbtowc (&wc, buf, 1) >= 0) +#endif + return wc; + } + return WEOF; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c++defs.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c++defs.h new file mode 100644 index 00000000..eb66967b --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c++defs.h @@ -0,0 +1,337 @@ +/* C++ compatible function declaration macros. + Copyright (C) 2010-2024 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef _GL_CXXDEFS_H +#define _GL_CXXDEFS_H + +/* Begin/end the GNULIB_NAMESPACE namespace. */ +#if defined __cplusplus && defined GNULIB_NAMESPACE +# define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE { +# define _GL_END_NAMESPACE } +#else +# define _GL_BEGIN_NAMESPACE +# define _GL_END_NAMESPACE +#endif + +/* The three most frequent use cases of these macros are: + + * For providing a substitute for a function that is missing on some + platforms, but is declared and works fine on the platforms on which + it exists: + + #if @GNULIB_FOO@ + # if !@HAVE_FOO@ + _GL_FUNCDECL_SYS (foo, ...); + # endif + _GL_CXXALIAS_SYS (foo, ...); + _GL_CXXALIASWARN (foo); + #elif defined GNULIB_POSIXCHECK + ... + #endif + + * For providing a replacement for a function that exists on all platforms, + but is broken/insufficient and needs to be replaced on some platforms: + + #if @GNULIB_FOO@ + # if @REPLACE_FOO@ + # if !(defined __cplusplus && defined GNULIB_NAMESPACE) + # undef foo + # define foo rpl_foo + # endif + _GL_FUNCDECL_RPL (foo, ...); + _GL_CXXALIAS_RPL (foo, ...); + # else + _GL_CXXALIAS_SYS (foo, ...); + # endif + _GL_CXXALIASWARN (foo); + #elif defined GNULIB_POSIXCHECK + ... + #endif + + * For providing a replacement for a function that exists on some platforms + but is broken/insufficient and needs to be replaced on some of them and + is additionally either missing or undeclared on some other platforms: + + #if @GNULIB_FOO@ + # if @REPLACE_FOO@ + # if !(defined __cplusplus && defined GNULIB_NAMESPACE) + # undef foo + # define foo rpl_foo + # endif + _GL_FUNCDECL_RPL (foo, ...); + _GL_CXXALIAS_RPL (foo, ...); + # else + # if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@ + _GL_FUNCDECL_SYS (foo, ...); + # endif + _GL_CXXALIAS_SYS (foo, ...); + # endif + _GL_CXXALIASWARN (foo); + #elif defined GNULIB_POSIXCHECK + ... + #endif +*/ + +/* _GL_EXTERN_C declaration; + performs the declaration with C linkage. */ +#if defined __cplusplus +# define _GL_EXTERN_C extern "C" +#else +# define _GL_EXTERN_C extern +#endif + +/* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes); + declares a replacement function, named rpl_func, with the given prototype, + consisting of return type, parameters, and attributes. + Example: + _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...) + _GL_ARG_NONNULL ((1))); + + Note: Attributes, such as _GL_ATTRIBUTE_DEPRECATED, are supported in front + of a _GL_FUNCDECL_RPL invocation only in C mode, not in C++ mode. (That's + because + [[...]] extern "C" ; + is invalid syntax in C++.) + */ +#define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \ + _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes) +#define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \ + _GL_EXTERN_C rettype rpl_func parameters_and_attributes + +/* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes); + declares the system function, named func, with the given prototype, + consisting of return type, parameters, and attributes. + Example: + _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...) + _GL_ARG_NONNULL ((1))); + */ +#define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \ + _GL_EXTERN_C rettype func parameters_and_attributes + +/* _GL_CXXALIAS_RPL (func, rettype, parameters); + declares a C++ alias called GNULIB_NAMESPACE::func + that redirects to rpl_func, if GNULIB_NAMESPACE is defined. + Example: + _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...)); + + Wrapping rpl_func in an object with an inline conversion operator + avoids a reference to rpl_func unless GNULIB_NAMESPACE::func is + actually used in the program. */ +#define _GL_CXXALIAS_RPL(func,rettype,parameters) \ + _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters) +#if defined __cplusplus && defined GNULIB_NAMESPACE +# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ + namespace GNULIB_NAMESPACE \ + { \ + static const struct _gl_ ## func ## _wrapper \ + { \ + typedef rettype (*type) parameters; \ + \ + inline operator type () const \ + { \ + return ::rpl_func; \ + } \ + } func = {}; \ + } \ + _GL_EXTERN_C int _gl_cxxalias_dummy +#else +# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ + _GL_EXTERN_C int _gl_cxxalias_dummy +#endif + +/* _GL_CXXALIAS_MDA (func, rettype, parameters); + is to be used when func is a Microsoft deprecated alias, on native Windows. + It declares a C++ alias called GNULIB_NAMESPACE::func + that redirects to _func, if GNULIB_NAMESPACE is defined. + Example: + _GL_CXXALIAS_MDA (open, int, (const char *filename, int flags, ...)); + */ +#define _GL_CXXALIAS_MDA(func,rettype,parameters) \ + _GL_CXXALIAS_RPL_1 (func, _##func, rettype, parameters) + +/* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters); + is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters); + except that the C function rpl_func may have a slightly different + declaration. A cast is used to silence the "invalid conversion" error + that would otherwise occur. */ +#if defined __cplusplus && defined GNULIB_NAMESPACE +# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ + namespace GNULIB_NAMESPACE \ + { \ + static const struct _gl_ ## func ## _wrapper \ + { \ + typedef rettype (*type) parameters; \ + \ + inline operator type () const \ + { \ + return reinterpret_cast(::rpl_func); \ + } \ + } func = {}; \ + } \ + _GL_EXTERN_C int _gl_cxxalias_dummy +#else +# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ + _GL_EXTERN_C int _gl_cxxalias_dummy +#endif + +/* _GL_CXXALIAS_MDA_CAST (func, rettype, parameters); + is like _GL_CXXALIAS_MDA (func, rettype, parameters); + except that the C function func may have a slightly different declaration. + A cast is used to silence the "invalid conversion" error that would + otherwise occur. */ +#define _GL_CXXALIAS_MDA_CAST(func,rettype,parameters) \ + _GL_CXXALIAS_RPL_CAST_1 (func, _##func, rettype, parameters) + +/* _GL_CXXALIAS_SYS (func, rettype, parameters); + declares a C++ alias called GNULIB_NAMESPACE::func + that redirects to the system provided function func, if GNULIB_NAMESPACE + is defined. + Example: + _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...)); + + Wrapping func in an object with an inline conversion operator + avoids a reference to func unless GNULIB_NAMESPACE::func is + actually used in the program. */ +#if defined __cplusplus && defined GNULIB_NAMESPACE +# define _GL_CXXALIAS_SYS(func,rettype,parameters) \ + namespace GNULIB_NAMESPACE \ + { \ + static const struct _gl_ ## func ## _wrapper \ + { \ + typedef rettype (*type) parameters; \ + \ + inline operator type () const \ + { \ + return ::func; \ + } \ + } func = {}; \ + } \ + _GL_EXTERN_C int _gl_cxxalias_dummy +#else +# define _GL_CXXALIAS_SYS(func,rettype,parameters) \ + _GL_EXTERN_C int _gl_cxxalias_dummy +#endif + +/* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters); + is like _GL_CXXALIAS_SYS (func, rettype, parameters); + except that the C function func may have a slightly different declaration. + A cast is used to silence the "invalid conversion" error that would + otherwise occur. */ +#if defined __cplusplus && defined GNULIB_NAMESPACE +# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ + namespace GNULIB_NAMESPACE \ + { \ + static const struct _gl_ ## func ## _wrapper \ + { \ + typedef rettype (*type) parameters; \ + \ + inline operator type () const \ + { \ + return reinterpret_cast(::func); \ + } \ + } func = {}; \ + } \ + _GL_EXTERN_C int _gl_cxxalias_dummy +#else +# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ + _GL_EXTERN_C int _gl_cxxalias_dummy +#endif + +/* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2); + is like _GL_CXXALIAS_SYS (func, rettype, parameters); + except that the C function is picked among a set of overloaded functions, + namely the one with rettype2 and parameters2. Two consecutive casts + are used to silence the "cannot find a match" and "invalid conversion" + errors that would otherwise occur. */ +#if defined __cplusplus && defined GNULIB_NAMESPACE + /* The outer cast must be a reinterpret_cast. + The inner cast: When the function is defined as a set of overloaded + functions, it works as a static_cast<>, choosing the designated variant. + When the function is defined as a single variant, it works as a + reinterpret_cast<>. The parenthesized cast syntax works both ways. */ +# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ + namespace GNULIB_NAMESPACE \ + { \ + static const struct _gl_ ## func ## _wrapper \ + { \ + typedef rettype (*type) parameters; \ + \ + inline operator type () const \ + { \ + return reinterpret_cast((rettype2 (*) parameters2)(::func)); \ + } \ + } func = {}; \ + } \ + _GL_EXTERN_C int _gl_cxxalias_dummy +#else +# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ + _GL_EXTERN_C int _gl_cxxalias_dummy +#endif + +/* _GL_CXXALIASWARN (func); + causes a warning to be emitted when ::func is used but not when + GNULIB_NAMESPACE::func is used. func must be defined without overloaded + variants. */ +#if defined __cplusplus && defined GNULIB_NAMESPACE +# define _GL_CXXALIASWARN(func) \ + _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE) +# define _GL_CXXALIASWARN_1(func,namespace) \ + _GL_CXXALIASWARN_2 (func, namespace) +/* To work around GCC bug , + we enable the warning only when not optimizing. */ +# if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__) +# define _GL_CXXALIASWARN_2(func,namespace) \ + _GL_WARN_ON_USE (func, \ + "The symbol ::" #func " refers to the system function. " \ + "Use " #namespace "::" #func " instead.") +# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING +# define _GL_CXXALIASWARN_2(func,namespace) \ + extern __typeof__ (func) func +# else +# define _GL_CXXALIASWARN_2(func,namespace) \ + _GL_EXTERN_C int _gl_cxxalias_dummy +# endif +#else +# define _GL_CXXALIASWARN(func) \ + _GL_EXTERN_C int _gl_cxxalias_dummy +#endif + +/* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes); + causes a warning to be emitted when the given overloaded variant of ::func + is used but not when GNULIB_NAMESPACE::func is used. */ +#if defined __cplusplus && defined GNULIB_NAMESPACE +# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ + _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \ + GNULIB_NAMESPACE) +# define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \ + _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace) +/* To work around GCC bug , + we enable the warning only when not optimizing. */ +# if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__) +# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ + _GL_WARN_ON_USE_CXX (func, rettype, rettype, parameters_and_attributes, \ + "The symbol ::" #func " refers to the system function. " \ + "Use " #namespace "::" #func " instead.") +# else +# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ + _GL_EXTERN_C int _gl_cxxalias_dummy +# endif +#else +# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ + _GL_EXTERN_C int _gl_cxxalias_dummy +#endif + +#endif /* _GL_CXXDEFS_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c-ctype.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c-ctype.c new file mode 100644 index 00000000..d3f1b12d --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c-ctype.c @@ -0,0 +1,21 @@ +/* Character handling in C locale. + + Copyright (C) 2003-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +#define C_CTYPE_INLINE _GL_EXTERN_INLINE +#include "c-ctype.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c-ctype.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c-ctype.h new file mode 100644 index 00000000..b582de4a --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c-ctype.h @@ -0,0 +1,366 @@ +/* Character handling in C locale. + + These functions work like the corresponding functions in , + except that they have the C (POSIX) locale hardwired, whereas the + functions' behaviour depends on the current locale set via + setlocale. + + Copyright (C) 2000-2003, 2006, 2008-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef C_CTYPE_H +#define C_CTYPE_H + +/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +_GL_INLINE_HEADER_BEGIN +#ifndef C_CTYPE_INLINE +# define C_CTYPE_INLINE _GL_INLINE +#endif + +#ifdef __cplusplus +extern "C" { +#endif + + +/* The functions defined in this file assume the "C" locale and a character + set without diacritics (ASCII-US or EBCDIC-US or something like that). + Even if the "C" locale on a particular system is an extension of the ASCII + character set (like on BeOS, where it is UTF-8, or on AmigaOS, where it + is ISO-8859-1), the functions in this file recognize only the ASCII + characters. */ + + +#if (' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ + && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \ + && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \ + && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \ + && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \ + && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \ + && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \ + && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \ + && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \ + && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \ + && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \ + && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \ + && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \ + && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \ + && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \ + && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \ + && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \ + && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \ + && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \ + && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \ + && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \ + && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \ + && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126) +/* The character set is ASCII or one of its variants or extensions, not EBCDIC. + Testing the value of '\n' and '\r' is not relevant. */ +# define C_CTYPE_ASCII 1 +#elif ! (' ' == '\x40' && '0' == '\xf0' \ + && 'A' == '\xc1' && 'J' == '\xd1' && 'S' == '\xe2' \ + && 'a' == '\x81' && 'j' == '\x91' && 's' == '\xa2') +# error "Only ASCII and EBCDIC are supported" +#endif + +#if 'A' < 0 +# error "EBCDIC and char is signed -- not supported" +#endif + +/* Cases for control characters. */ + +#define _C_CTYPE_CNTRL \ + case '\a': case '\b': case '\f': case '\n': \ + case '\r': case '\t': case '\v': \ + _C_CTYPE_OTHER_CNTRL + +/* ASCII control characters other than those with \-letter escapes. */ + +#if C_CTYPE_ASCII +# define _C_CTYPE_OTHER_CNTRL \ + case '\x00': case '\x01': case '\x02': case '\x03': \ + case '\x04': case '\x05': case '\x06': case '\x0e': \ + case '\x0f': case '\x10': case '\x11': case '\x12': \ + case '\x13': case '\x14': case '\x15': case '\x16': \ + case '\x17': case '\x18': case '\x19': case '\x1a': \ + case '\x1b': case '\x1c': case '\x1d': case '\x1e': \ + case '\x1f': case '\x7f' +#else + /* Use EBCDIC code page 1047's assignments for ASCII control chars; + assume all EBCDIC code pages agree about these assignments. */ +# define _C_CTYPE_OTHER_CNTRL \ + case '\x00': case '\x01': case '\x02': case '\x03': \ + case '\x07': case '\x0e': case '\x0f': case '\x10': \ + case '\x11': case '\x12': case '\x13': case '\x18': \ + case '\x19': case '\x1c': case '\x1d': case '\x1e': \ + case '\x1f': case '\x26': case '\x27': case '\x2d': \ + case '\x2e': case '\x32': case '\x37': case '\x3c': \ + case '\x3d': case '\x3f' +#endif + +/* Cases for lowercase hex letters, and lowercase letters, all offset by N. */ + +#define _C_CTYPE_LOWER_A_THRU_F_N(N) \ + case 'a' + (N): case 'b' + (N): case 'c' + (N): case 'd' + (N): \ + case 'e' + (N): case 'f' + (N) +#define _C_CTYPE_LOWER_N(N) \ + _C_CTYPE_LOWER_A_THRU_F_N(N): \ + case 'g' + (N): case 'h' + (N): case 'i' + (N): case 'j' + (N): \ + case 'k' + (N): case 'l' + (N): case 'm' + (N): case 'n' + (N): \ + case 'o' + (N): case 'p' + (N): case 'q' + (N): case 'r' + (N): \ + case 's' + (N): case 't' + (N): case 'u' + (N): case 'v' + (N): \ + case 'w' + (N): case 'x' + (N): case 'y' + (N): case 'z' + (N) + +/* Cases for hex letters, digits, lower, punct, and upper. */ + +#define _C_CTYPE_A_THRU_F \ + _C_CTYPE_LOWER_A_THRU_F_N (0): \ + _C_CTYPE_LOWER_A_THRU_F_N ('A' - 'a') +#define _C_CTYPE_DIGIT \ + case '0': case '1': case '2': case '3': \ + case '4': case '5': case '6': case '7': \ + case '8': case '9' +#define _C_CTYPE_LOWER _C_CTYPE_LOWER_N (0) +#define _C_CTYPE_PUNCT \ + case '!': case '"': case '#': case '$': \ + case '%': case '&': case '\'': case '(': \ + case ')': case '*': case '+': case ',': \ + case '-': case '.': case '/': case ':': \ + case ';': case '<': case '=': case '>': \ + case '?': case '@': case '[': case '\\': \ + case ']': case '^': case '_': case '`': \ + case '{': case '|': case '}': case '~' +#define _C_CTYPE_UPPER _C_CTYPE_LOWER_N ('A' - 'a') + + +/* Function definitions. */ + +/* Unlike the functions in , which require an argument in the range + of the 'unsigned char' type, the functions here operate on values that are + in the 'unsigned char' range or in the 'char' range. In other words, + when you have a 'char' value, you need to cast it before using it as + argument to a function: + + const char *s = ...; + if (isalpha ((unsigned char) *s)) ... + + but you don't need to cast it for the functions defined in this file: + + const char *s = ...; + if (c_isalpha (*s)) ... + */ + +C_CTYPE_INLINE bool +c_isalnum (int c) +{ + switch (c) + { + _C_CTYPE_DIGIT: + _C_CTYPE_LOWER: + _C_CTYPE_UPPER: + return true; + default: + return false; + } +} + +C_CTYPE_INLINE bool +c_isalpha (int c) +{ + switch (c) + { + _C_CTYPE_LOWER: + _C_CTYPE_UPPER: + return true; + default: + return false; + } +} + +/* The function isascii is not locale dependent. + Its use in EBCDIC is questionable. */ +C_CTYPE_INLINE bool +c_isascii (int c) +{ + switch (c) + { + case ' ': + _C_CTYPE_CNTRL: + _C_CTYPE_DIGIT: + _C_CTYPE_LOWER: + _C_CTYPE_PUNCT: + _C_CTYPE_UPPER: + return true; + default: + return false; + } +} + +C_CTYPE_INLINE bool +c_isblank (int c) +{ + return c == ' ' || c == '\t'; +} + +C_CTYPE_INLINE bool +c_iscntrl (int c) +{ + switch (c) + { + _C_CTYPE_CNTRL: + return true; + default: + return false; + } +} + +C_CTYPE_INLINE bool +c_isdigit (int c) +{ + switch (c) + { + _C_CTYPE_DIGIT: + return true; + default: + return false; + } +} + +C_CTYPE_INLINE bool +c_isgraph (int c) +{ + switch (c) + { + _C_CTYPE_DIGIT: + _C_CTYPE_LOWER: + _C_CTYPE_PUNCT: + _C_CTYPE_UPPER: + return true; + default: + return false; + } +} + +C_CTYPE_INLINE bool +c_islower (int c) +{ + switch (c) + { + _C_CTYPE_LOWER: + return true; + default: + return false; + } +} + +C_CTYPE_INLINE bool +c_isprint (int c) +{ + switch (c) + { + case ' ': + _C_CTYPE_DIGIT: + _C_CTYPE_LOWER: + _C_CTYPE_PUNCT: + _C_CTYPE_UPPER: + return true; + default: + return false; + } +} + +C_CTYPE_INLINE bool +c_ispunct (int c) +{ + switch (c) + { + _C_CTYPE_PUNCT: + return true; + default: + return false; + } +} + +C_CTYPE_INLINE bool +c_isspace (int c) +{ + switch (c) + { + case ' ': case '\t': case '\n': case '\v': case '\f': case '\r': + return true; + default: + return false; + } +} + +C_CTYPE_INLINE bool +c_isupper (int c) +{ + switch (c) + { + _C_CTYPE_UPPER: + return true; + default: + return false; + } +} + +C_CTYPE_INLINE bool +c_isxdigit (int c) +{ + switch (c) + { + _C_CTYPE_DIGIT: + _C_CTYPE_A_THRU_F: + return true; + default: + return false; + } +} + +C_CTYPE_INLINE int +c_tolower (int c) +{ + switch (c) + { + _C_CTYPE_UPPER: + return c - 'A' + 'a'; + default: + return c; + } +} + +C_CTYPE_INLINE int +c_toupper (int c) +{ + switch (c) + { + _C_CTYPE_LOWER: + return c - 'a' + 'A'; + default: + return c; + } +} + +#ifdef __cplusplus +} +#endif + +_GL_INLINE_HEADER_END + +#endif /* C_CTYPE_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c-file-type.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c-file-type.c new file mode 100644 index 00000000..1c558796 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c-file-type.c @@ -0,0 +1,111 @@ +/* Return a string describing the type of a file. + + Copyright (C) 1993-1994, 2001-2002, 2004-2006, 2009-2024 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 . */ + +/* Written by Paul Eggert. */ + +#include + +#include "file-type.h" + +#define N_(msgid) (msgid) + +char const * +c_file_type (struct stat const *st) +{ + /* For some of these formats, see POSIX 1003.1-2017 "file" command, + STDOUT section, Table: File Utility Output Strings + . + + To keep diagnostics grammatical in English, the returned string + must start with a consonant. */ + + /* Do these three first, as they're the most common. */ + + if (S_ISREG (st->st_mode)) + return st->st_size == 0 ? N_("regular empty file") : N_("regular file"); + + if (S_ISDIR (st->st_mode)) + return N_("directory"); + + if (S_ISLNK (st->st_mode)) + return N_("symbolic link"); + + /* Do the S_TYPEIS* macros next, as they may be implemented in terms + of S_ISNAM, and we want the more-specialized interpretation. */ + + if (S_TYPEISMQ (st)) + return N_("message queue"); + + if (S_TYPEISSEM (st)) + return N_("semaphore"); + + if (S_TYPEISSHM (st)) + return N_("shared memory object"); + + if (S_TYPEISTMO (st)) + return N_("typed memory object"); + + /* The remaining are in alphabetical order. */ + + if (S_ISBLK (st->st_mode)) + return N_("block special file"); + + if (S_ISCHR (st->st_mode)) + return N_("character special file"); + + if (S_ISCTG (st->st_mode)) + return N_("contiguous data"); + + if (S_ISFIFO (st->st_mode)) + return N_("fifo"); + + if (S_ISDOOR (st->st_mode)) + return N_("door"); + + if (S_ISMPB (st->st_mode)) + return N_("multiplexed block special file"); + + if (S_ISMPC (st->st_mode)) + return N_("multiplexed character special file"); + + if (S_ISMPX (st->st_mode)) + return N_("multiplexed file"); + + if (S_ISNAM (st->st_mode)) + return N_("named file"); + + if (S_ISNWK (st->st_mode)) + return N_("network special file"); + + if (S_ISOFD (st->st_mode)) + return N_("migrated file with data"); + + if (S_ISOFL (st->st_mode)) + return N_("migrated file without data"); + + if (S_ISPORT (st->st_mode)) + return N_("port"); + + if (S_ISSOCK (st->st_mode)) + return N_("socket"); + + if (S_ISWHT (st->st_mode)) + return N_("whiteout"); + + return N_("weird file"); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c-stack.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c-stack.c new file mode 100644 index 00000000..b8974d34 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c-stack.c @@ -0,0 +1,213 @@ +/* Stack overflow handling. + + Copyright (C) 2002, 2004, 2006, 2008-2024 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 . */ + +/* Written by Paul Eggert. */ + +/* NOTES: + + A program that uses alloca, dynamic arrays, or large local + variables may extend the stack by more than a page at a time. If + so, when the stack overflows the operating system may not detect + the overflow until the program uses the array, and this module may + incorrectly report a program error instead of a stack overflow. + + To avoid this problem, allocate only small objects on the stack; a + program should be OK if it limits single allocations to a page or + less. Allocate larger arrays in static storage, or on the heap + (e.g., with malloc). Yes, this is a pain, but we don't know of any + better solution that is portable. + + No attempt has been made to deal with multithreaded applications. */ + +#include + +#include "c-stack.h" + +#include +#include +#include +#include +#include +#include +#include + +#if DEBUG +# include +#endif + +#include + +#include "exitfail.h" +#include "idx.h" +#include "ignore-value.h" + +#include "gettext.h" +#define _(msgid) gettext (msgid) + +#if HAVE_STACK_OVERFLOW_RECOVERY + +/* Storage for the alternate signal stack. + 64 KiB is not too large for Gnulib-using apps, and is large enough + for all known platforms. Smaller sizes may run into trouble. + For example, libsigsegv 2.6 through 2.8 have a bug where some + architectures use more than the Linux default of an 8 KiB alternate + stack when deciding if a fault was caused by stack overflow. */ +static max_align_t alternate_signal_stack[(64 * 1024 + + sizeof (max_align_t) - 1) + / sizeof (max_align_t)]; + +/* The user-specified action to take when a SEGV-related program error + or stack overflow occurs. */ +static _GL_ASYNC_SAFE void (* volatile segv_action) (int); + +/* Translated messages for program errors and stack overflow. Do not + translate them in the signal handler, since gettext is not + async-signal-safe. */ +static char const * volatile program_error_message; +static char const * volatile stack_overflow_message; + +/* Output an error message, then exit with status EXIT_FAILURE if it + appears to have been a stack overflow, or with a core dump + otherwise. This function is async-signal-safe. */ + +static char const * volatile progname; + +static _GL_ASYNC_SAFE _Noreturn void +die (int signo) +{ + segv_action (signo); + char const *message = signo ? program_error_message : stack_overflow_message; + + /* If the message is short, write it all at once to avoid + interleaving with other messages. Avoid writev as it is not + documented to be async-signal-safe. */ + size_t prognamelen = strlen (progname); + size_t messagelen = strlen (message); + static char const separator[] = {':', ' '}; + char buf[sizeof alternate_signal_stack / 16 + sizeof separator]; + idx_t buflen; + if (prognamelen + messagelen < sizeof buf - sizeof separator) + { + char *p = mempcpy (buf, progname, prognamelen); + p = mempcpy (p, separator, sizeof separator); + p = mempcpy (p, message, messagelen); + *p++ = '\n'; + buflen = p - buf; + } + else + { + ignore_value (write (STDERR_FILENO, progname, prognamelen)); + ignore_value (write (STDERR_FILENO, separator, sizeof separator)); + ignore_value (write (STDERR_FILENO, message, messagelen)); + buf[0] = '\n'; + buflen = 1; + } + ignore_value (write (STDERR_FILENO, buf, buflen)); + + if (! signo) + _exit (exit_failure); + raise (signo); + abort (); +} + +static _GL_ASYNC_SAFE void +null_action (_GL_UNUSED int signo) +{ +} + +/* Pacify GCC 9.3.1, which otherwise would complain about segv_handler. */ +# if 4 < __GNUC__ + (6 <= __GNUC_MINOR__) +# pragma GCC diagnostic ignored "-Wsuggest-attribute=pure" +# endif + +/* Nonzero if general segv handler could not be installed. */ +static volatile int segv_handler_missing; + +/* Handle a segmentation violation and exit if it cannot be stack + overflow. This function is async-signal-safe. */ + +static _GL_ASYNC_SAFE int +segv_handler (_GL_UNUSED void *address, int serious) +{ +# if DEBUG + { + char buf[1024]; + int saved_errno = errno; + ignore_value (write (STDERR_FILENO, buf, + sprintf (buf, "segv_handler serious=%d\n", serious))); + errno = saved_errno; + } +# endif + + /* If this fault is not serious, return 0 to let the stack overflow + handler take a shot at it. */ + if (!serious) + return 0; + die (SIGSEGV); +} + +/* Handle a segmentation violation that is likely to be a stack + overflow and exit. This function is async-signal-safe. */ + +static _GL_ASYNC_SAFE _Noreturn void +overflow_handler (int emergency, _GL_UNUSED stackoverflow_context_t context) +{ +# if DEBUG + { + char buf[1024]; + ignore_value (write (STDERR_FILENO, buf, + sprintf (buf, ("overflow_handler emergency=%d" + " segv_handler_missing=%d\n"), + emergency, segv_handler_missing))); + } +# endif + + die ((!emergency || segv_handler_missing) ? 0 : SIGSEGV); +} + +int +c_stack_action (_GL_ASYNC_SAFE void (*action) (int)) +{ + segv_action = action ? action : null_action; + program_error_message = _("program error"); + stack_overflow_message = _("stack overflow"); + progname = getprogname (); + + /* Always install the overflow handler. */ + if (stackoverflow_install_handler (overflow_handler, + alternate_signal_stack, + sizeof alternate_signal_stack)) + { + errno = ENOTSUP; + return -1; + } + /* Try installing a general handler; if it fails, then treat all + segv as stack overflow. */ + segv_handler_missing = sigsegv_install_handler (segv_handler); + return 0; +} + +#else /* !HAVE_STACK_OVERFLOW_RECOVERY */ + +int +c_stack_action (_GL_ASYNC_SAFE void (*action) (_GL_UNUSED int) ) +{ + errno = ENOTSUP; + return -1; +} + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c-stack.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c-stack.h new file mode 100644 index 00000000..4db45193 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c-stack.h @@ -0,0 +1,62 @@ +/* Stack overflow handling. + + Copyright (C) 2002, 2004, 2008-2024 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 . */ + +/* This file uses _GL_ASYNC_SAFE. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +#ifdef __cplusplus +extern "C" +{ +#endif + +/* Set up ACTION so that it is invoked on C stack overflow and on other, + stack-unrelated, segmentation violation. + Return -1 (setting errno) if this cannot be done. + + When a stack overflow or segmentation violation occurs: + 1) ACTION is called. It is passed an argument equal to + - 0, for a stack overflow, + - SIGSEGV, for a segmentation violation that does not appear related + to stack overflow. + On many platforms the two cases are hard to distinguish; when in doubt, + zero is passed. + 2) If ACTION returns, a message is written to standard error, and the + program is terminated: in the case of stack overflow, with exit code + exit_failure (see "exitfail.h"), otherwise through a signal SIGSEGV. + + A null ACTION acts like an action that does nothing. + + Restrictions: + - ACTION must be async-signal-safe. + - ACTION together with its callees must not require more than 64 KiB of + stack space. + - ACTION must not create and then invoke nested functions + , because + this implementation does not guarantee an executable stack. + - ACTION should not call longjmp, because this implementation does not + guarantee that it is safe to return to the original stack. + + This function may install a handler for the SIGSEGV signal or for the SIGBUS + signal or exercise other system dependent exception handling APIs. */ + +extern int c_stack_action (_GL_ASYNC_SAFE void (* /*action*/) (int)); + +#ifdef __cplusplus +} +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c-strcase.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c-strcase.h new file mode 100644 index 00000000..b75e8dd1 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c-strcase.h @@ -0,0 +1,61 @@ +/* Case-insensitive string comparison functions in C locale. + Copyright (C) 1995-1996, 2001, 2003, 2005, 2009-2024 Free Software + Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef C_STRCASE_H +#define C_STRCASE_H + +/* This file uses _GL_ATTRIBUTE_PURE. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +#include + + +/* The functions defined in this file assume the "C" locale and a character + set without diacritics (ASCII-US or EBCDIC-US or something like that). + Even if the "C" locale on a particular system is an extension of the ASCII + character set (like on BeOS, where it is UTF-8, or on AmigaOS, where it + is ISO-8859-1), the functions in this file recognize only the ASCII + characters. More precisely, one of the string arguments must be an ASCII + string; the other one can also contain non-ASCII characters (but then + the comparison result will be nonzero). */ + + +#ifdef __cplusplus +extern "C" { +#endif + + +/* Compare strings S1 and S2, ignoring case, returning less than, equal to or + greater than zero if S1 is lexicographically less than, equal to or greater + than S2. */ +extern int c_strcasecmp (const char *s1, const char *s2) _GL_ATTRIBUTE_PURE; + +/* Compare no more than N characters of strings S1 and S2, ignoring case, + returning less than, equal to or greater than zero if S1 is + lexicographically less than, equal to or greater than S2. */ +extern int c_strncasecmp (const char *s1, const char *s2, size_t n) + _GL_ATTRIBUTE_PURE; + + +#ifdef __cplusplus +} +#endif + + +#endif /* C_STRCASE_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c-strcasecmp.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c-strcasecmp.c new file mode 100644 index 00000000..1fa575a8 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c-strcasecmp.c @@ -0,0 +1,56 @@ +/* c-strcasecmp.c -- case insensitive string comparator in C locale + Copyright (C) 1998-1999, 2005-2006, 2009-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "c-strcase.h" + +#include + +#include "c-ctype.h" + +int +c_strcasecmp (const char *s1, const char *s2) +{ + register const unsigned char *p1 = (const unsigned char *) s1; + register const unsigned char *p2 = (const unsigned char *) s2; + unsigned char c1, c2; + + if (p1 == p2) + return 0; + + do + { + c1 = c_tolower (*p1); + c2 = c_tolower (*p2); + + if (c1 == '\0') + break; + + ++p1; + ++p2; + } + while (c1 == c2); + + if (UCHAR_MAX <= INT_MAX) + return c1 - c2; + else + /* On machines where 'char' and 'int' are types of the same size, the + difference of two 'unsigned char' values - including the sign bit - + doesn't fit in an 'int'. */ + return _GL_CMP (c1, c2); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c-strcaseeq.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c-strcaseeq.h new file mode 100644 index 00000000..26e05c93 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c-strcaseeq.h @@ -0,0 +1,181 @@ +/* Optimized case-insensitive string comparison in C locale. + Copyright (C) 2001-2002, 2007, 2009-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible . */ + +#include "c-strcase.h" +#include "c-ctype.h" + +/* STRCASEEQ allows to optimize string comparison with a small literal string. + STRCASEEQ (s, "UTF-8", 'U','T','F','-','8',0,0,0,0) + is semantically equivalent to + c_strcasecmp (s, "UTF-8") == 0 + just faster. */ + +/* Help GCC to generate good code for string comparisons with + immediate strings. */ +#if (defined __GNUC__ || defined __clang__) && defined __OPTIMIZE__ + +/* Case insensitive comparison of ASCII characters. */ +# if C_CTYPE_ASCII +# define CASEEQ(other,upper) \ + (c_isupper (upper) ? ((other) & ~0x20) == (upper) : (other) == (upper)) +# else +# define CASEEQ(other,upper) \ + (c_toupper (other) == (upper)) +# endif + +static inline int +strcaseeq9 (const char *s1, const char *s2) +{ + return c_strcasecmp (s1 + 9, s2 + 9) == 0; +} + +static inline int +strcaseeq8 (const char *s1, const char *s2, char s28) +{ + if (CASEEQ (s1[8], s28)) + { + if (s28 == 0) + return 1; + else + return strcaseeq9 (s1, s2); + } + else + return 0; +} + +static inline int +strcaseeq7 (const char *s1, const char *s2, char s27, char s28) +{ + if (CASEEQ (s1[7], s27)) + { + if (s27 == 0) + return 1; + else + return strcaseeq8 (s1, s2, s28); + } + else + return 0; +} + +static inline int +strcaseeq6 (const char *s1, const char *s2, char s26, char s27, char s28) +{ + if (CASEEQ (s1[6], s26)) + { + if (s26 == 0) + return 1; + else + return strcaseeq7 (s1, s2, s27, s28); + } + else + return 0; +} + +static inline int +strcaseeq5 (const char *s1, const char *s2, char s25, char s26, char s27, char s28) +{ + if (CASEEQ (s1[5], s25)) + { + if (s25 == 0) + return 1; + else + return strcaseeq6 (s1, s2, s26, s27, s28); + } + else + return 0; +} + +static inline int +strcaseeq4 (const char *s1, const char *s2, char s24, char s25, char s26, char s27, char s28) +{ + if (CASEEQ (s1[4], s24)) + { + if (s24 == 0) + return 1; + else + return strcaseeq5 (s1, s2, s25, s26, s27, s28); + } + else + return 0; +} + +static inline int +strcaseeq3 (const char *s1, const char *s2, char s23, char s24, char s25, char s26, char s27, char s28) +{ + if (CASEEQ (s1[3], s23)) + { + if (s23 == 0) + return 1; + else + return strcaseeq4 (s1, s2, s24, s25, s26, s27, s28); + } + else + return 0; +} + +static inline int +strcaseeq2 (const char *s1, const char *s2, char s22, char s23, char s24, char s25, char s26, char s27, char s28) +{ + if (CASEEQ (s1[2], s22)) + { + if (s22 == 0) + return 1; + else + return strcaseeq3 (s1, s2, s23, s24, s25, s26, s27, s28); + } + else + return 0; +} + +static inline int +strcaseeq1 (const char *s1, const char *s2, char s21, char s22, char s23, char s24, char s25, char s26, char s27, char s28) +{ + if (CASEEQ (s1[1], s21)) + { + if (s21 == 0) + return 1; + else + return strcaseeq2 (s1, s2, s22, s23, s24, s25, s26, s27, s28); + } + else + return 0; +} + +static inline int +strcaseeq0 (const char *s1, const char *s2, char s20, char s21, char s22, char s23, char s24, char s25, char s26, char s27, char s28) +{ + if (CASEEQ (s1[0], s20)) + { + if (s20 == 0) + return 1; + else + return strcaseeq1 (s1, s2, s21, s22, s23, s24, s25, s26, s27, s28); + } + else + return 0; +} + +#define STRCASEEQ(s1,s2,s20,s21,s22,s23,s24,s25,s26,s27,s28) \ + strcaseeq0 (s1, s2, s20, s21, s22, s23, s24, s25, s26, s27, s28) + +#else + +#define STRCASEEQ(s1,s2,s20,s21,s22,s23,s24,s25,s26,s27,s28) \ + (c_strcasecmp (s1, s2) == 0) + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c-strncasecmp.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c-strncasecmp.c new file mode 100644 index 00000000..4c8b0b6b --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c-strncasecmp.c @@ -0,0 +1,56 @@ +/* c-strncasecmp.c -- case insensitive string comparator in C locale + Copyright (C) 1998-1999, 2005-2006, 2009-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "c-strcase.h" + +#include + +#include "c-ctype.h" + +int +c_strncasecmp (const char *s1, const char *s2, size_t n) +{ + register const unsigned char *p1 = (const unsigned char *) s1; + register const unsigned char *p2 = (const unsigned char *) s2; + unsigned char c1, c2; + + if (p1 == p2 || n == 0) + return 0; + + do + { + c1 = c_tolower (*p1); + c2 = c_tolower (*p2); + + if (--n == 0 || c1 == '\0') + break; + + ++p1; + ++p2; + } + while (c1 == c2); + + if (UCHAR_MAX <= INT_MAX) + return c1 - c2; + else + /* On machines where 'char' and 'int' are types of the same size, the + difference of two 'unsigned char' values - including the sign bit - + doesn't fit in an 'int'. */ + return _GL_CMP (c1, c2); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32_apply_type_test.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32_apply_type_test.c new file mode 100644 index 00000000..4d3ee908 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32_apply_type_test.c @@ -0,0 +1,39 @@ +/* Apply a 32-bit wide character property test. + Copyright (C) 2011-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 2023. */ + +#include + +#define IN_C32_APPLY_TYPE_TEST +/* Specification. */ +#include + +#include +#include + +#if _GL_WCHAR_T_IS_UCS4 +_GL_EXTERN_INLINE +#endif +int +c32_apply_type_test (wint_t wc, c32_type_test_t property) +{ +#if _GL_WCHAR_T_IS_UCS4 + return iswctype (wc, property); +#else + return property (wc); +#endif +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32_get_type_test.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32_get_type_test.c new file mode 100644 index 00000000..90bee394 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32_get_type_test.c @@ -0,0 +1,113 @@ +/* Get descriptor for a 32-bit wide character property. + Copyright (C) 2011-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 2023. */ + +#include + +#define IN_C32_GET_TYPE_TEST +/* Specification. */ +#include + +#include +#include + +#if _GL_WCHAR_T_IS_UCS4 +_GL_EXTERN_INLINE +#endif +c32_type_test_t +c32_get_type_test (const char *name) +{ +#if _GL_WCHAR_T_IS_UCS4 + return wctype (name); +#else + switch (name[0]) + { + case 'a': + switch (name[1]) + { + case 'l': + switch (name[2]) + { + case 'n': + if (strcmp (name + 3, "um") == 0) + return c32isalnum; + break; + case 'p': + if (strcmp (name + 3, "ha") == 0) + return c32isalpha; + break; + default: + break; + } + break; + default: + break; + } + break; + case 'b': + if (strcmp (name + 1, "lank") == 0) + return c32isblank; + break; + case 'c': + if (strcmp (name + 1, "ntrl") == 0) + return c32iscntrl; + break; + case 'd': + if (strcmp (name + 1, "igit") == 0) + return c32isdigit; + break; + case 'g': + if (strcmp (name + 1, "raph") == 0) + return c32isgraph; + break; + case 'l': + if (strcmp (name + 1, "ower") == 0) + return c32islower; + break; + case 'p': + switch (name[1]) + { + case 'r': + if (strcmp (name + 2, "int") == 0) + return c32isprint; + break; + case 'u': + if (strcmp (name + 2, "nct") == 0) + return c32ispunct; + break; + default: + break; + } + break; + case 's': + if (strcmp (name + 1, "pace") == 0) + return c32isspace; + break; + case 'u': + if (strcmp (name + 1, "pper") == 0) + return c32isupper; + break; + case 'x': + if (strcmp (name + 1, "digit") == 0) + return c32isxdigit; + break; + default: + break; + } + return (c32_type_test_t) 0; +#endif +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32is-impl.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32is-impl.h new file mode 100644 index 00000000..084b3a02 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32is-impl.h @@ -0,0 +1,105 @@ +/* Test whether a 32-bit wide character belongs to a specific character class. + Copyright (C) 2020-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 2020. */ + +#include +#include + +#ifdef __CYGWIN__ +# include +#endif + +#if GNULIB_defined_mbstate_t +# include "localcharset.h" +# include "streq.h" +#endif + +#if GL_CHAR32_T_IS_UNICODE +# include "lc-charset-unicode.h" +#endif + +#include "unictype.h" + +#if _GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t +_GL_EXTERN_INLINE +#endif +int +FUNC (wint_t wc) +{ + /* The char32_t encoding of a multibyte character is defined by the way + mbrtoc32() is defined. */ + +#if GNULIB_defined_mbstate_t /* AIX, IRIX */ + /* mbrtoc32() is defined on top of mbtowc() for the non-UTF-8 locales + and directly for the UTF-8 locales. */ + if (wc != WEOF) + { + const char *encoding = locale_charset (); + if (STREQ_OPT (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0, 0)) + return UCS_FUNC (wc); + else + return WCHAR_FUNC (wc); + } + else + return 0; + +#elif HAVE_WORKING_MBRTOC32 /* glibc, Android */ + /* mbrtoc32() is essentially defined by the system libc. */ + +# if _GL_WCHAR_T_IS_UCS4 + /* The char32_t encoding of a multibyte character is known to be the same as + the wchar_t encoding. */ + return WCHAR_FUNC (wc); +# else + /* The char32_t encoding of a multibyte character is known to be UCS-4, + different from the wchar_t encoding. */ + if (wc != WEOF) + return UCS_FUNC (wc); + else + return 0; +# endif + +#elif _GL_SMALL_WCHAR_T /* Cygwin, mingw, MSVC */ + /* The wchar_t encoding is UTF-16. + The char32_t encoding is UCS-4. */ + +# if defined __CYGWIN__ && CYGWIN_VERSION_DLL_MAJOR >= 1007 + /* As an extension to POSIX, the iswalnum() function of Cygwin >= 1.7 + supports also wc arguments outside the Unicode BMP, that is, outside + the 'wchar_t' range. See + + = . */ + return WCHAR_FUNC (wc); +# else + if (wc == WEOF || wc == (wchar_t) wc) + /* wc is in the range for the isw* functions. */ + return WCHAR_FUNC (wc); + else + return UCS_FUNC (wc); +# endif + +#else /* macOS, FreeBSD, NetBSD, OpenBSD, HP-UX, Solaris, Minix, Android */ + /* char32_t and wchar_t are equivalent. */ + static_assert (sizeof (char32_t) == sizeof (wchar_t)); + +# if GL_CHAR32_T_IS_UNICODE && GL_CHAR32_T_VS_WCHAR_T_NEEDS_CONVERSION + return UCS_FUNC (wc); +# else + return WCHAR_FUNC (wc); +# endif +#endif +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32isalnum.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32isalnum.c new file mode 100644 index 00000000..6335af6d --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32isalnum.c @@ -0,0 +1,26 @@ +/* Test 32-bit wide character for being alphanumeric. + Copyright (C) 2020-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +#define IN_C32ISALNUM +/* Specification. */ +#include + +#define FUNC c32isalnum +#define WCHAR_FUNC iswalnum +#define UCS_FUNC uc_is_alnum +#include "c32is-impl.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32isalpha.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32isalpha.c new file mode 100644 index 00000000..ea43be56 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32isalpha.c @@ -0,0 +1,26 @@ +/* Test 32-bit wide character for being alphabetic. + Copyright (C) 2020-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +#define IN_C32ISALPHA +/* Specification. */ +#include + +#define FUNC c32isalpha +#define WCHAR_FUNC iswalpha +#define UCS_FUNC uc_is_alpha +#include "c32is-impl.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32isblank.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32isblank.c new file mode 100644 index 00000000..ee06d3d0 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32isblank.c @@ -0,0 +1,26 @@ +/* Test 32-bit wide character for being blank. + Copyright (C) 2020-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +#define IN_C32ISBLANK +/* Specification. */ +#include + +#define FUNC c32isblank +#define WCHAR_FUNC iswblank +#define UCS_FUNC uc_is_blank +#include "c32is-impl.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32iscntrl.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32iscntrl.c new file mode 100644 index 00000000..1f50527b --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32iscntrl.c @@ -0,0 +1,26 @@ +/* Test 32-bit wide character for being a control character. + Copyright (C) 2020-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +#define IN_C32ISCNTRL +/* Specification. */ +#include + +#define FUNC c32iscntrl +#define WCHAR_FUNC iswcntrl +#define UCS_FUNC uc_is_cntrl +#include "c32is-impl.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32isdigit.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32isdigit.c new file mode 100644 index 00000000..4cb99c2a --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32isdigit.c @@ -0,0 +1,26 @@ +/* Test 32-bit wide character for being a digit. + Copyright (C) 2020-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +#define IN_C32ISDIGIT +/* Specification. */ +#include + +#define FUNC c32isdigit +#define WCHAR_FUNC iswdigit +#define UCS_FUNC uc_is_digit +#include "c32is-impl.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32isgraph.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32isgraph.c new file mode 100644 index 00000000..407d6d1a --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32isgraph.c @@ -0,0 +1,26 @@ +/* Test 32-bit wide character for being graphic. + Copyright (C) 2020-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +#define IN_C32ISGRAPH +/* Specification. */ +#include + +#define FUNC c32isgraph +#define WCHAR_FUNC iswgraph +#define UCS_FUNC uc_is_graph +#include "c32is-impl.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32islower.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32islower.c new file mode 100644 index 00000000..f2bfda7c --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32islower.c @@ -0,0 +1,26 @@ +/* Test 32-bit wide character for being lowercase. + Copyright (C) 2020-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +#define IN_C32ISLOWER +/* Specification. */ +#include + +#define FUNC c32islower +#define WCHAR_FUNC iswlower +#define UCS_FUNC uc_is_lower +#include "c32is-impl.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32isprint.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32isprint.c new file mode 100644 index 00000000..fd8d7a63 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32isprint.c @@ -0,0 +1,26 @@ +/* Test 32-bit wide character for being printable. + Copyright (C) 2020-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +#define IN_C32ISPRINT +/* Specification. */ +#include + +#define FUNC c32isprint +#define WCHAR_FUNC iswprint +#define UCS_FUNC uc_is_print +#include "c32is-impl.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32ispunct.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32ispunct.c new file mode 100644 index 00000000..03d64699 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32ispunct.c @@ -0,0 +1,26 @@ +/* Test 32-bit wide character for being a punctuation or symbol character. + Copyright (C) 2020-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +#define IN_C32ISPUNCT +/* Specification. */ +#include + +#define FUNC c32ispunct +#define WCHAR_FUNC iswpunct +#define UCS_FUNC uc_is_punct +#include "c32is-impl.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32isspace.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32isspace.c new file mode 100644 index 00000000..1449fc4e --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32isspace.c @@ -0,0 +1,26 @@ +/* Test 32-bit wide character for being white-space. + Copyright (C) 2020-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +#define IN_C32ISSPACE +/* Specification. */ +#include + +#define FUNC c32isspace +#define WCHAR_FUNC iswspace +#define UCS_FUNC uc_is_space +#include "c32is-impl.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32isupper.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32isupper.c new file mode 100644 index 00000000..4b218603 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32isupper.c @@ -0,0 +1,26 @@ +/* Test 32-bit wide character for being uppercase. + Copyright (C) 2020-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +#define IN_C32ISUPPER +/* Specification. */ +#include + +#define FUNC c32isupper +#define WCHAR_FUNC iswupper +#define UCS_FUNC uc_is_upper +#include "c32is-impl.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32isxdigit.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32isxdigit.c new file mode 100644 index 00000000..133d0103 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32isxdigit.c @@ -0,0 +1,26 @@ +/* Test 32-bit wide character for being a hexadecimal digit. + Copyright (C) 2020-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +#define IN_C32ISXDIGIT +/* Specification. */ +#include + +#define FUNC c32isxdigit +#define WCHAR_FUNC iswxdigit +#define UCS_FUNC uc_is_xdigit +#include "c32is-impl.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32to-impl.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32to-impl.h new file mode 100644 index 00000000..e94fa7dc --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32to-impl.h @@ -0,0 +1,92 @@ +/* Case mapping of a 32-bit wide character. + Copyright (C) 2020-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 2023. */ + +#include +#include + +#if GNULIB_defined_mbstate_t +# include "localcharset.h" +# include "streq.h" +#endif + +#if GL_CHAR32_T_IS_UNICODE +# include "lc-charset-unicode.h" +#endif + +#include "unicase.h" + +#if _GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t +_GL_EXTERN_INLINE +#endif +wint_t +FUNC (wint_t wc) +{ + /* The char32_t encoding of a multibyte character is defined by the way + mbrtoc32() is defined. */ + +#if GNULIB_defined_mbstate_t /* AIX, IRIX */ + /* mbrtoc32() is defined on top of mbtowc() for the non-UTF-8 locales + and directly for the UTF-8 locales. */ + if (wc != WEOF) + { + const char *encoding = locale_charset (); + if (STREQ_OPT (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0, 0)) + return UCS_FUNC (wc); + else + return WCHAR_FUNC (wc); + } + else + return wc; + +#elif HAVE_WORKING_MBRTOC32 /* glibc, Android */ + /* mbrtoc32() is essentially defined by the system libc. */ + +# if _GL_WCHAR_T_IS_UCS4 + /* The char32_t encoding of a multibyte character is known to be the same as + the wchar_t encoding. */ + return WCHAR_FUNC (wc); +# else + /* The char32_t encoding of a multibyte character is known to be UCS-4, + different from the wchar_t encoding. */ + if (wc != WEOF) + return UCS_FUNC (wc); + else + return wc; +# endif + +#elif _GL_SMALL_WCHAR_T /* Cygwin, mingw, MSVC */ + /* The wchar_t encoding is UTF-16. + The char32_t encoding is UCS-4. */ + + if (wc == WEOF || wc == (wchar_t) wc) + /* wc is in the range for the tow* functions. */ + return WCHAR_FUNC (wc); + else + return UCS_FUNC (wc); + +#else /* macOS, FreeBSD, NetBSD, OpenBSD, HP-UX, Solaris, Minix, Android */ + /* char32_t and wchar_t are equivalent. */ + static_assert (sizeof (char32_t) == sizeof (wchar_t)); + +# if GL_CHAR32_T_IS_UNICODE && GL_CHAR32_T_VS_WCHAR_T_NEEDS_CONVERSION + return UCS_FUNC (wc); +# else + return WCHAR_FUNC (wc); +# endif +#endif +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32tolower.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32tolower.c new file mode 100644 index 00000000..52b149b1 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32tolower.c @@ -0,0 +1,26 @@ +/* Map a 32-bit wide character to lowercase. + Copyright (C) 2023-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +#define IN_C32TOLOWER +/* Specification. */ +#include + +#define FUNC c32tolower +#define WCHAR_FUNC towlower +#define UCS_FUNC uc_tolower +#include "c32to-impl.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32width.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32width.c new file mode 100644 index 00000000..7edf0088 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/c32width.c @@ -0,0 +1,102 @@ +/* Determine the number of screen columns needed for a 32-bit wide character. + Copyright (C) 2020-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 2023. */ + +#include + +#define IN_C32WIDTH +/* Specification. */ +#include + +#include + +#ifdef __CYGWIN__ +# include +#endif + +#if GNULIB_defined_mbstate_t +# include "streq.h" +#endif + +#include "localcharset.h" + +#if GL_CHAR32_T_IS_UNICODE +# include "lc-charset-unicode.h" +#endif + +#include "uniwidth.h" + +#if _GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t +_GL_EXTERN_INLINE +#endif +int +c32width (char32_t wc) +{ + /* The char32_t encoding of a multibyte character is defined by the way + mbrtoc32() is defined. */ + +#if GNULIB_defined_mbstate_t /* AIX, IRIX */ + /* mbrtoc32() is defined on top of mbtowc() for the non-UTF-8 locales + and directly for the UTF-8 locales. */ + const char *encoding = locale_charset (); + if (STREQ_OPT (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0, 0)) + return uc_width (wc, encoding); + else + return wcwidth (wc); + +#elif HAVE_WORKING_MBRTOC32 /* glibc, Android */ + /* mbrtoc32() is essentially defined by the system libc. */ + +# if _GL_WCHAR_T_IS_UCS4 + /* The char32_t encoding of a multibyte character is known to be the same as + the wchar_t encoding. */ + return wcwidth (wc); +# else + /* The char32_t encoding of a multibyte character is known to be UCS-4, + different from the wchar_t encoding. */ + return uc_width (wc, locale_charset ()); +# endif + +#elif _GL_SMALL_WCHAR_T /* Cygwin, mingw, MSVC */ + /* The wchar_t encoding is UTF-16. + The char32_t encoding is UCS-4. */ + +# if defined __CYGWIN__ && CYGWIN_VERSION_DLL_MAJOR >= 1007 && 0 + /* As an extension to POSIX, the wcwidth() function of Cygwin >= 1.7 + supports also wc arguments outside the Unicode BMP, that is, outside + the 'wchar_t' range. See + . + But the resulting values for these characters are not of good quality. */ + return wcwidth (wc); +# else + if (wc == (wchar_t) wc) + /* wc is in the range for the wcwidth function. */ + return wcwidth (wc); + else + return uc_width (wc, locale_charset ()); +# endif + +#else /* macOS, FreeBSD, NetBSD, OpenBSD, HP-UX, Solaris, Minix, Android */ + /* char32_t and wchar_t are equivalent. */ + static_assert (sizeof (char32_t) == sizeof (wchar_t)); + +# if GL_CHAR32_T_IS_UNICODE && GL_CHAR32_T_VS_WCHAR_T_NEEDS_CONVERSION + return uc_width (wc, locale_charset ()); +# endif + return wcwidth (wc); +#endif +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/calloc.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/calloc.c new file mode 100644 index 00000000..81dfd3ef --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/calloc.c @@ -0,0 +1,55 @@ +/* calloc() function that is glibc compatible. + This wrapper function is required at least on Tru64 UNIX 5.1 and mingw. + Copyright (C) 2004-2007, 2009-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* written by Jim Meyering and Bruno Haible */ + +#include + +/* Specification. */ +#include + +#include + +#include "xalloc-oversized.h" + +/* Call the system's calloc below. */ +#undef calloc + +/* Allocate and zero-fill an NxS-byte block of memory from the heap, + even if N or S is zero. */ + +void * +rpl_calloc (size_t n, size_t s) +{ + if (n == 0 || s == 0) + n = s = 1; + + if (xalloc_oversized (n, s)) + { + errno = ENOMEM; + return NULL; + } + + void *result = calloc (n, s); + +#if !HAVE_MALLOC_POSIX + if (result == NULL) + errno = ENOMEM; +#endif + + return result; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/careadlinkat.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/careadlinkat.c new file mode 100644 index 00000000..f308b696 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/careadlinkat.c @@ -0,0 +1,182 @@ +/* Read symbolic links into a buffer without size limitation, relative to fd. + + Copyright (C) 2001, 2003-2004, 2007, 2009-2024 Free Software Foundation, + Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Paul Eggert, Bruno Haible, and Jim Meyering. */ + +#include + +#include "careadlinkat.h" + +#include "idx.h" +#include "minmax.h" + +#include +#include +#include +#include + +/* Define this independently so that stdint.h is not a prerequisite. */ +#ifndef SIZE_MAX +# define SIZE_MAX ((size_t) -1) +#endif + +#include "allocator.h" + +enum { STACK_BUF_SIZE = 1024 }; + +/* Act like careadlinkat (see below), with an additional argument + STACK_BUF that can be used as temporary storage. + + If GCC_LINT is defined, do not inline this function with GCC 10.1 + and later, to avoid creating a pointer to the stack that GCC + -Wreturn-local-addr incorrectly complains about. See: + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93644 + Although the noinline attribute can hurt performance a bit, no better way + to pacify GCC is known; even an explicit #pragma does not pacify GCC. + When the GCC bug is fixed this workaround should be limited to the + broken GCC versions. */ +#if _GL_GNUC_PREREQ (10, 1) +# if _GL_GNUC_PREREQ (12, 1) +# pragma GCC diagnostic ignored "-Wreturn-local-addr" +# elif defined GCC_LINT || defined lint +__attribute__ ((__noinline__)) +# elif __OPTIMIZE__ && !__NO_INLINE__ +# define GCC_BOGUS_WRETURN_LOCAL_ADDR +# endif +#endif +static char * +readlink_stk (int fd, char const *filename, + char *buffer, size_t buffer_size, + struct allocator const *alloc, + ssize_t (*preadlinkat) (int, char const *, char *, size_t), + char stack_buf[STACK_BUF_SIZE]) +{ + if (! alloc) + alloc = &stdlib_allocator; + + if (!buffer) + { + buffer = stack_buf; + buffer_size = STACK_BUF_SIZE; + } + + char *buf = buffer; + idx_t buf_size_max = MIN (IDX_MAX, MIN (SSIZE_MAX, SIZE_MAX)); + idx_t buf_size = MIN (buffer_size, buf_size_max); + + while (buf) + { + /* Attempt to read the link into the current buffer. */ + idx_t link_length = preadlinkat (fd, filename, buf, buf_size); + if (link_length < 0) + { + if (buf != buffer) + { + int readlinkat_errno = errno; + alloc->free (buf); + errno = readlinkat_errno; + } + return NULL; + } + + idx_t link_size = link_length; + + if (link_size < buf_size) + { + buf[link_size++] = '\0'; + + if (buf == stack_buf) + { + char *b = alloc->allocate (link_size); + buf_size = link_size; + if (! b) + break; + return memcpy (b, buf, link_size); + } + + if (link_size < buf_size && buf != buffer && alloc->reallocate) + { + /* Shrink BUF before returning it. */ + char *b = alloc->reallocate (buf, link_size); + if (b) + return b; + } + + return buf; + } + + if (buf != buffer) + alloc->free (buf); + + if (buf_size_max / 2 <= buf_size) + { + errno = ENAMETOOLONG; + return NULL; + } + + buf_size = 2 * buf_size + 1; + buf = alloc->allocate (buf_size); + } + + if (alloc->die) + alloc->die (buf_size); + errno = ENOMEM; + return NULL; +} + + +/* Assuming the current directory is FD, get the symbolic link value + of FILENAME as a null-terminated string and put it into a buffer. + If FD is AT_FDCWD, FILENAME is interpreted relative to the current + working directory, as in openat. + + If the link is small enough to fit into BUFFER put it there. + BUFFER's size is BUFFER_SIZE, and BUFFER can be null + if BUFFER_SIZE is zero. + + If the link is not small, put it into a dynamically allocated + buffer managed by ALLOC. It is the caller's responsibility to free + the returned value if it is nonnull and is not BUFFER. A null + ALLOC stands for the standard allocator. + + The PREADLINKAT function specifies how to read links. It operates + like POSIX readlinkat() + + but can assume that its first argument is the same as FD. + + If successful, return the buffer address; otherwise return NULL and + set errno. */ + +char * +careadlinkat (int fd, char const *filename, + char *buffer, size_t buffer_size, + struct allocator const *alloc, + ssize_t (*preadlinkat) (int, char const *, char *, size_t)) +{ + /* Allocate the initial buffer on the stack. This way, in the + common case of a symlink of small size, we get away with a + single small malloc instead of a big malloc followed by a + shrinking realloc. */ + #ifdef GCC_BOGUS_WRETURN_LOCAL_ADDR + #warning "GCC might issue a bogus -Wreturn-local-addr warning here." + #warning "See ." + #endif + char stack_buf[STACK_BUF_SIZE]; + return readlink_stk (fd, filename, buffer, buffer_size, alloc, + preadlinkat, stack_buf); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/careadlinkat.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/careadlinkat.h new file mode 100644 index 00000000..473e6531 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/careadlinkat.h @@ -0,0 +1,72 @@ +/* Read symbolic links into a buffer without size limitation, relative to fd. + + Copyright (C) 2011-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Paul Eggert, Bruno Haible, and Jim Meyering. */ + +#ifndef _GL_CAREADLINKAT_H +#define _GL_CAREADLINKAT_H + +/* This file uses HAVE_READLINKAT. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +#include +#include + +struct allocator; + +/* Assuming the current directory is FD, get the symbolic link value + of FILENAME as a null-terminated string and put it into a buffer. + If FD is AT_FDCWD, FILENAME is interpreted relative to the current + working directory, as in openat. + + If the link is small enough to fit into BUFFER put it there. + BUFFER's size is BUFFER_SIZE, and BUFFER can be null + if BUFFER_SIZE is zero. + + If the link is not small, put it into a dynamically allocated + buffer managed by ALLOC. It is the caller's responsibility to free + the returned value if it is nonnull and is not BUFFER. + + The PREADLINKAT function specifies how to read links. It operates + like POSIX readlinkat() + + but can assume that its first argument is the same as FD. + + If successful, return the buffer address; otherwise return NULL and + set errno. */ + +char *careadlinkat (int fd, char const *filename, + char *restrict buffer, size_t buffer_size, + struct allocator const *alloc, + ssize_t (*preadlinkat) (int, char const *, + char *, size_t)); + +/* Suitable value for careadlinkat's FD argument. */ +#if HAVE_READLINKAT +/* AT_FDCWD is declared in . */ +#else +/* Define AT_FDCWD independently, so that the careadlinkat module does + not depend on the fcntl-h module. We might as well use the same value + as fcntl-h. */ +# ifndef AT_FDCWD +# define AT_FDCWD (-3041965) +# endif +#endif + +#endif /* _GL_CAREADLINKAT_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/cdefs.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/cdefs.h new file mode 100644 index 00000000..6cc5581c --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/cdefs.h @@ -0,0 +1,715 @@ +/* Copyright (C) 1992-2024 Free Software Foundation, Inc. + Copyright The GNU Toolchain Authors. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _SYS_CDEFS_H +#define _SYS_CDEFS_H 1 + +/* We are almost always included from features.h. */ +#ifndef _FEATURES_H +# include +#endif + +/* The GNU libc does not support any K&R compilers or the traditional mode + of ISO C compilers anymore. Check for some of the combinations not + supported anymore. */ +#if defined __GNUC__ && !defined __STDC__ +# error "You need a ISO C conforming compiler to use the glibc headers" +#endif + +/* Some user header file might have defined this before. */ +#undef __P +#undef __PMT + +/* Compilers that lack __has_attribute may object to + #if defined __has_attribute && __has_attribute (...) + even though they do not need to evaluate the right-hand side of the &&. + Similarly for __has_builtin, etc. */ +#if (defined __has_attribute \ + && (!defined __clang_minor__ \ + || (defined __apple_build_version__ \ + ? 7000000 <= __apple_build_version__ \ + : 3 < __clang_major__ + (5 <= __clang_minor__)))) +# define __glibc_has_attribute(attr) __has_attribute (attr) +#else +# define __glibc_has_attribute(attr) 0 +#endif +#ifdef __has_builtin +# define __glibc_has_builtin(name) __has_builtin (name) +#else +# define __glibc_has_builtin(name) 0 +#endif +#ifdef __has_extension +# define __glibc_has_extension(ext) __has_extension (ext) +#else +# define __glibc_has_extension(ext) 0 +#endif + +#if defined __GNUC__ || defined __clang__ + +/* All functions, except those with callbacks or those that + synchronize memory, are leaf functions. */ +# if __GNUC_PREREQ (4, 6) && !defined _LIBC +# define __LEAF , __leaf__ +# define __LEAF_ATTR __attribute__ ((__leaf__)) +# else +# define __LEAF +# define __LEAF_ATTR +# endif + +/* GCC can always grok prototypes. For C++ programs we add throw() + to help it optimize the function calls. But this only works with + gcc 2.8.x and egcs. For gcc 3.4 and up we even mark C functions + as non-throwing using a function attribute since programs can use + the -fexceptions options for C code as well. */ +# if !defined __cplusplus \ + && (__GNUC_PREREQ (3, 4) || __glibc_has_attribute (__nothrow__)) +# define __THROW __attribute__ ((__nothrow__ __LEAF)) +# define __THROWNL __attribute__ ((__nothrow__)) +# define __NTH(fct) __attribute__ ((__nothrow__ __LEAF)) fct +# define __NTHNL(fct) __attribute__ ((__nothrow__)) fct +# else +# if defined __cplusplus && (__GNUC_PREREQ (2,8) || __clang_major >= 4) +# if __cplusplus >= 201103L +# define __THROW noexcept (true) +# else +# define __THROW throw () +# endif +# define __THROWNL __THROW +# define __NTH(fct) __LEAF_ATTR fct __THROW +# define __NTHNL(fct) fct __THROW +# else +# define __THROW +# define __THROWNL +# define __NTH(fct) fct +# define __NTHNL(fct) fct +# endif +# endif + +#else /* Not GCC or clang. */ + +# if (defined __cplusplus \ + || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)) +# define __inline inline +# else +# define __inline /* No inline functions. */ +# endif + +# define __THROW +# define __THROWNL +# define __NTH(fct) fct + +#endif /* GCC || clang. */ + +/* These two macros are not used in glibc anymore. They are kept here + only because some other projects expect the macros to be defined. */ +#define __P(args) args +#define __PMT(args) args + +/* For these things, GCC behaves the ANSI way normally, + and the non-ANSI way under -traditional. */ + +#define __CONCAT(x,y) x ## y +#define __STRING(x) #x + +/* This is not a typedef so `const __ptr_t' does the right thing. */ +#define __ptr_t void * + + +/* C++ needs to know that types and declarations are C, not C++. */ +#ifdef __cplusplus +# define __BEGIN_DECLS extern "C" { +# define __END_DECLS } +#else +# define __BEGIN_DECLS +# define __END_DECLS +#endif + + +/* Gnulib avoids these definitions, as they don't work on non-glibc platforms. + In particular, __bos and __bos0 are defined differently in the Android libc. + */ +#ifndef __GNULIB_CDEFS + +/* Fortify support. */ +# define __bos(ptr) __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1) +# define __bos0(ptr) __builtin_object_size (ptr, 0) + +/* Use __builtin_dynamic_object_size at _FORTIFY_SOURCE=3 when available. */ +# if __USE_FORTIFY_LEVEL == 3 && (__glibc_clang_prereq (9, 0) \ + || __GNUC_PREREQ (12, 0)) +# define __glibc_objsize0(__o) __builtin_dynamic_object_size (__o, 0) +# define __glibc_objsize(__o) __builtin_dynamic_object_size (__o, 1) +# else +# define __glibc_objsize0(__o) __bos0 (__o) +# define __glibc_objsize(__o) __bos (__o) +# endif + +/* Compile time conditions to choose between the regular, _chk and _chk_warn + variants. These conditions should get evaluated to constant and optimized + away. */ + +# define __glibc_safe_len_cond(__l, __s, __osz) ((__l) <= (__osz) / (__s)) +# define __glibc_unsigned_or_positive(__l) \ + ((__typeof (__l)) 0 < (__typeof (__l)) -1 \ + || (__builtin_constant_p (__l) && (__l) > 0)) + +/* Length is known to be safe at compile time if the __L * __S <= __OBJSZ + condition can be folded to a constant and if it is true, or unknown (-1) */ +# define __glibc_safe_or_unknown_len(__l, __s, __osz) \ + ((__osz) == (__SIZE_TYPE__) -1 \ + || (__glibc_unsigned_or_positive (__l) \ + && __builtin_constant_p (__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), \ + (__s), (__osz))) \ + && __glibc_safe_len_cond ((__SIZE_TYPE__) (__l), (__s), (__osz)))) + +/* Conversely, we know at compile time that the length is unsafe if the + __L * __S <= __OBJSZ condition can be folded to a constant and if it is + false. */ +# define __glibc_unsafe_len(__l, __s, __osz) \ + (__glibc_unsigned_or_positive (__l) \ + && __builtin_constant_p (__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), \ + __s, __osz)) \ + && !__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), __s, __osz)) + +/* Fortify function f. __f_alias, __f_chk and __f_chk_warn must be + declared. */ + +# define __glibc_fortify(f, __l, __s, __osz, ...) \ + (__glibc_safe_or_unknown_len (__l, __s, __osz) \ + ? __ ## f ## _alias (__VA_ARGS__) \ + : (__glibc_unsafe_len (__l, __s, __osz) \ + ? __ ## f ## _chk_warn (__VA_ARGS__, __osz) \ + : __ ## f ## _chk (__VA_ARGS__, __osz))) \ + +/* Fortify function f, where object size argument passed to f is the number of + elements and not total size. */ + +# define __glibc_fortify_n(f, __l, __s, __osz, ...) \ + (__glibc_safe_or_unknown_len (__l, __s, __osz) \ + ? __ ## f ## _alias (__VA_ARGS__) \ + : (__glibc_unsafe_len (__l, __s, __osz) \ + ? __ ## f ## _chk_warn (__VA_ARGS__, (__osz) / (__s)) \ + : __ ## f ## _chk (__VA_ARGS__, (__osz) / (__s)))) \ + +#endif + + +#if __GNUC_PREREQ (4,3) +# define __warnattr(msg) __attribute__((__warning__ (msg))) +# define __errordecl(name, msg) \ + extern void name (void) __attribute__((__error__ (msg))) +#else +# define __warnattr(msg) +# define __errordecl(name, msg) extern void name (void) +#endif + +/* Support for flexible arrays. + Headers that should use flexible arrays only if they're "real" + (e.g. only if they won't affect sizeof()) should test + #if __glibc_c99_flexarr_available. */ +#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L && !defined __HP_cc +# define __flexarr [] +# define __glibc_c99_flexarr_available 1 +#elif __GNUC_PREREQ (2,97) || defined __clang__ +/* GCC 2.97 and clang support C99 flexible array members as an extension, + even when in C89 mode or compiling C++ (any version). */ +# define __flexarr [] +# define __glibc_c99_flexarr_available 1 +#elif defined __GNUC__ +/* Pre-2.97 GCC did not support C99 flexible arrays but did have + an equivalent extension with slightly different notation. */ +# define __flexarr [0] +# define __glibc_c99_flexarr_available 1 +#else +/* Some other non-C99 compiler. Approximate with [1]. */ +# define __flexarr [1] +# define __glibc_c99_flexarr_available 0 +#endif + + +/* __asm__ ("xyz") is used throughout the headers to rename functions + at the assembly language level. This is wrapped by the __REDIRECT + macro, in order to support compilers that can do this some other + way. When compilers don't support asm-names at all, we have to do + preprocessor tricks instead (which don't have exactly the right + semantics, but it's the best we can do). + + Example: + int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); */ + +#if (defined __GNUC__ && __GNUC__ >= 2) || (__clang_major__ >= 4) + +# define __REDIRECT(name, proto, alias) name proto __asm__ (__ASMNAME (#alias)) +# ifdef __cplusplus +# define __REDIRECT_NTH(name, proto, alias) \ + name proto __THROW __asm__ (__ASMNAME (#alias)) +# define __REDIRECT_NTHNL(name, proto, alias) \ + name proto __THROWNL __asm__ (__ASMNAME (#alias)) +# else +# define __REDIRECT_NTH(name, proto, alias) \ + name proto __asm__ (__ASMNAME (#alias)) __THROW +# define __REDIRECT_NTHNL(name, proto, alias) \ + name proto __asm__ (__ASMNAME (#alias)) __THROWNL +# endif +# define __ASMNAME(cname) __ASMNAME2 (__USER_LABEL_PREFIX__, cname) +# define __ASMNAME2(prefix, cname) __STRING (prefix) cname + +/* +#elif __SOME_OTHER_COMPILER__ + +# define __REDIRECT(name, proto, alias) name proto; \ + _Pragma("let " #name " = " #alias) +*/ +#endif + +/* GCC and clang have various useful declarations that can be made with + the '__attribute__' syntax. All of the ways we use this do fine if + they are omitted for compilers that don't understand it. */ +#if !(defined __GNUC__ || defined __clang__) +# define __attribute__(xyz) /* Ignore */ +#endif + +/* At some point during the gcc 2.96 development the `malloc' attribute + for functions was introduced. We don't want to use it unconditionally + (although this would be possible) since it generates warnings. */ +#if __GNUC_PREREQ (2,96) || __glibc_has_attribute (__malloc__) +# define __attribute_malloc__ __attribute__ ((__malloc__)) +#else +# define __attribute_malloc__ /* Ignore */ +#endif + +/* Tell the compiler which arguments to an allocation function + indicate the size of the allocation. */ +#if __GNUC_PREREQ (4, 3) +# define __attribute_alloc_size__(params) \ + __attribute__ ((__alloc_size__ params)) +#else +# define __attribute_alloc_size__(params) /* Ignore. */ +#endif + +/* Tell the compiler which argument to an allocation function + indicates the alignment of the allocation. */ +#if __GNUC_PREREQ (4, 9) || __glibc_has_attribute (__alloc_align__) +# define __attribute_alloc_align__(param) \ + __attribute__ ((__alloc_align__ param)) +#else +# define __attribute_alloc_align__(param) /* Ignore. */ +#endif + +/* At some point during the gcc 2.96 development the `pure' attribute + for functions was introduced. We don't want to use it unconditionally + (although this would be possible) since it generates warnings. */ +#if __GNUC_PREREQ (2,96) || __glibc_has_attribute (__pure__) +# define __attribute_pure__ __attribute__ ((__pure__)) +#else +# define __attribute_pure__ /* Ignore */ +#endif + +/* This declaration tells the compiler that the value is constant. */ +#if __GNUC_PREREQ (2,5) || __glibc_has_attribute (__const__) +# define __attribute_const__ __attribute__ ((__const__)) +#else +# define __attribute_const__ /* Ignore */ +#endif + +#if __GNUC_PREREQ (2,7) || __glibc_has_attribute (__unused__) +# define __attribute_maybe_unused__ __attribute__ ((__unused__)) +#else +# define __attribute_maybe_unused__ /* Ignore */ +#endif + +/* At some point during the gcc 3.1 development the `used' attribute + for functions was introduced. We don't want to use it unconditionally + (although this would be possible) since it generates warnings. */ +#if __GNUC_PREREQ (3,1) || __glibc_has_attribute (__used__) +# define __attribute_used__ __attribute__ ((__used__)) +# define __attribute_noinline__ __attribute__ ((__noinline__)) +#else +# define __attribute_used__ __attribute__ ((__unused__)) +# define __attribute_noinline__ /* Ignore */ +#endif + +/* Since version 3.2, gcc allows marking deprecated functions. */ +#if __GNUC_PREREQ (3,2) || __glibc_has_attribute (__deprecated__) +# define __attribute_deprecated__ __attribute__ ((__deprecated__)) +#else +# define __attribute_deprecated__ /* Ignore */ +#endif + +/* Since version 4.5, gcc also allows one to specify the message printed + when a deprecated function is used. clang claims to be gcc 4.2, but + may also support this feature. */ +#if __GNUC_PREREQ (4,5) \ + || __glibc_has_extension (__attribute_deprecated_with_message__) +# define __attribute_deprecated_msg__(msg) \ + __attribute__ ((__deprecated__ (msg))) +#else +# define __attribute_deprecated_msg__(msg) __attribute_deprecated__ +#endif + +/* At some point during the gcc 2.8 development the `format_arg' attribute + for functions was introduced. We don't want to use it unconditionally + (although this would be possible) since it generates warnings. + If several `format_arg' attributes are given for the same function, in + gcc-3.0 and older, all but the last one are ignored. In newer gccs, + all designated arguments are considered. */ +#if __GNUC_PREREQ (2,8) || __glibc_has_attribute (__format_arg__) +# define __attribute_format_arg__(x) __attribute__ ((__format_arg__ (x))) +#else +# define __attribute_format_arg__(x) /* Ignore */ +#endif + +/* At some point during the gcc 2.97 development the `strfmon' format + attribute for functions was introduced. We don't want to use it + unconditionally (although this would be possible) since it + generates warnings. */ +#if __GNUC_PREREQ (2,97) || __glibc_has_attribute (__format__) +# define __attribute_format_strfmon__(a,b) \ + __attribute__ ((__format__ (__strfmon__, a, b))) +#else +# define __attribute_format_strfmon__(a,b) /* Ignore */ +#endif + +/* The nonnull function attribute marks pointer parameters that + must not be NULL. This has the name __nonnull in glibc, + and __attribute_nonnull__ in files shared with Gnulib to avoid + collision with a different __nonnull in DragonFlyBSD 5.9. */ +#ifndef __attribute_nonnull__ +# if __GNUC_PREREQ (3,3) || __glibc_has_attribute (__nonnull__) +# define __attribute_nonnull__(params) __attribute__ ((__nonnull__ params)) +# else +# define __attribute_nonnull__(params) +# endif +#endif +#ifndef __nonnull +# define __nonnull(params) __attribute_nonnull__ (params) +#endif + +/* The returns_nonnull function attribute marks the return type of the function + as always being non-null. */ +#ifndef __returns_nonnull +# if __GNUC_PREREQ (4, 9) || __glibc_has_attribute (__returns_nonnull__) +# define __returns_nonnull __attribute__ ((__returns_nonnull__)) +# else +# define __returns_nonnull +# endif +#endif + +/* If fortification mode, we warn about unused results of certain + function calls which can lead to problems. */ +#if __GNUC_PREREQ (3,4) || __glibc_has_attribute (__warn_unused_result__) +# define __attribute_warn_unused_result__ \ + __attribute__ ((__warn_unused_result__)) +# if defined __USE_FORTIFY_LEVEL && __USE_FORTIFY_LEVEL > 0 +# define __wur __attribute_warn_unused_result__ +# endif +#else +# define __attribute_warn_unused_result__ /* empty */ +#endif +#ifndef __wur +# define __wur /* Ignore */ +#endif + +/* Forces a function to be always inlined. */ +#if __GNUC_PREREQ (3,2) || __glibc_has_attribute (__always_inline__) +/* The Linux kernel defines __always_inline in stddef.h (283d7573), and + it conflicts with this definition. Therefore undefine it first to + allow either header to be included first. */ +# undef __always_inline +# define __always_inline __inline __attribute__ ((__always_inline__)) +#else +# undef __always_inline +# define __always_inline __inline +#endif + +/* Associate error messages with the source location of the call site rather + than with the source location inside the function. */ +#if __GNUC_PREREQ (4,3) || __glibc_has_attribute (__artificial__) +# define __attribute_artificial__ __attribute__ ((__artificial__)) +#else +# define __attribute_artificial__ /* Ignore */ +#endif + +/* GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99 + inline semantics, unless -fgnu89-inline is used. Using __GNUC_STDC_INLINE__ + or __GNUC_GNU_INLINE is not a good enough check for gcc because gcc versions + older than 4.3 may define these macros and still not guarantee GNU inlining + semantics. + + clang++ identifies itself as gcc-4.2, but has support for GNU inlining + semantics, that can be checked for by using the __GNUC_STDC_INLINE_ and + __GNUC_GNU_INLINE__ macro definitions. */ +#if (!defined __cplusplus || __GNUC_PREREQ (4,3) \ + || (defined __clang__ && (defined __GNUC_STDC_INLINE__ \ + || defined __GNUC_GNU_INLINE__))) +# if defined __GNUC_STDC_INLINE__ || defined __cplusplus +# define __extern_inline extern __inline __attribute__ ((__gnu_inline__)) +# define __extern_always_inline \ + extern __always_inline __attribute__ ((__gnu_inline__)) +# else +# define __extern_inline extern __inline +# define __extern_always_inline extern __always_inline +# endif +#endif + +#ifdef __extern_always_inline +# define __fortify_function __extern_always_inline __attribute_artificial__ +#endif + +/* GCC 4.3 and above allow passing all anonymous arguments of an + __extern_always_inline function to some other vararg function. */ +#if __GNUC_PREREQ (4,3) +# define __va_arg_pack() __builtin_va_arg_pack () +# define __va_arg_pack_len() __builtin_va_arg_pack_len () +#endif + +/* It is possible to compile containing GCC extensions even if GCC is + run in pedantic mode if the uses are carefully marked using the + `__extension__' keyword. But this is not generally available before + version 2.8. */ +#if !(__GNUC_PREREQ (2,8) || defined __clang__) +# define __extension__ /* Ignore */ +#endif + +/* __restrict is known in EGCS 1.2 and above, and in clang. + It works also in C++ mode (outside of arrays), but only when spelled + as '__restrict', not 'restrict'. */ +#if !(__GNUC_PREREQ (2,92) || __clang_major__ >= 3) +# if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L +# define __restrict restrict +# else +# define __restrict /* Ignore */ +# endif +#endif + +/* ISO C99 also allows to declare arrays as non-overlapping. The syntax is + array_name[restrict] + GCC 3.1 and clang support this. + This syntax is not usable in C++ mode. */ +#if (__GNUC_PREREQ (3,1) || __clang_major__ >= 3) && !defined __cplusplus +# define __restrict_arr __restrict +#else +# ifdef __GNUC__ +# define __restrict_arr /* Not supported in old GCC. */ +# else +# if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L +# define __restrict_arr restrict +# else +/* Some other non-C99 compiler. */ +# define __restrict_arr /* Not supported. */ +# endif +# endif +#endif + +#if (__GNUC__ >= 3) || __glibc_has_builtin (__builtin_expect) +# define __glibc_unlikely(cond) __builtin_expect ((cond), 0) +# define __glibc_likely(cond) __builtin_expect ((cond), 1) +#else +# define __glibc_unlikely(cond) (cond) +# define __glibc_likely(cond) (cond) +#endif + +#if (!defined _Noreturn \ + && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \ + && !(__GNUC_PREREQ (4,7) \ + || (3 < __clang_major__ + (5 <= __clang_minor__)))) +# if __GNUC_PREREQ (2,8) +# define _Noreturn __attribute__ ((__noreturn__)) +# else +# define _Noreturn +# endif +#endif + +#if __GNUC_PREREQ (8, 0) +/* Describes a char array whose address can safely be passed as the first + argument to strncpy and strncat, as the char array is not necessarily + a NUL-terminated string. */ +# define __attribute_nonstring__ __attribute__ ((__nonstring__)) +#else +# define __attribute_nonstring__ +#endif + +/* Undefine (also defined in libc-symbols.h). */ +#undef __attribute_copy__ +#if __GNUC_PREREQ (9, 0) +/* Copies attributes from the declaration or type referenced by + the argument. */ +# define __attribute_copy__(arg) __attribute__ ((__copy__ (arg))) +#else +# define __attribute_copy__(arg) +#endif + +#if (!defined _Static_assert && !defined __cplusplus \ + && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \ + && (!(__GNUC_PREREQ (4, 6) || __clang_major__ >= 4) \ + || defined __STRICT_ANSI__)) +# define _Static_assert(expr, diagnostic) \ + extern int (*__Static_assert_function (void)) \ + [!!sizeof (struct { int __error_if_negative: (expr) ? 2 : -1; })] +#endif + +/* Gnulib avoids including these, as they don't work on non-glibc or + older glibc platforms. */ +#ifndef __GNULIB_CDEFS +# include +# include +#endif + +#if __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1 +# ifdef __REDIRECT + +/* Alias name defined automatically. */ +# define __LDBL_REDIR(name, proto) ... unused__ldbl_redir +# define __LDBL_REDIR_DECL(name) \ + extern __typeof (name) name __asm (__ASMNAME ("__" #name "ieee128")); + +/* Alias name defined automatically, with leading underscores. */ +# define __LDBL_REDIR2_DECL(name) \ + extern __typeof (__##name) __##name \ + __asm (__ASMNAME ("__" #name "ieee128")); + +/* Alias name defined manually. */ +# define __LDBL_REDIR1(name, proto, alias) ... unused__ldbl_redir1 +# define __LDBL_REDIR1_DECL(name, alias) \ + extern __typeof (name) name __asm (__ASMNAME (#alias)); + +# define __LDBL_REDIR1_NTH(name, proto, alias) \ + __REDIRECT_NTH (name, proto, alias) +# define __REDIRECT_NTH_LDBL(name, proto, alias) \ + __LDBL_REDIR1_NTH (name, proto, __##alias##ieee128) + +/* Unused. */ +# define __REDIRECT_LDBL(name, proto, alias) ... unused__redirect_ldbl +# define __LDBL_REDIR_NTH(name, proto) ... unused__ldbl_redir_nth + +# else +_Static_assert (0, "IEEE 128-bits long double requires redirection on this platform"); +# endif +#elif defined __LONG_DOUBLE_MATH_OPTIONAL && defined __NO_LONG_DOUBLE_MATH +# define __LDBL_COMPAT 1 +# ifdef __REDIRECT +# define __LDBL_REDIR1(name, proto, alias) __REDIRECT (name, proto, alias) +# define __LDBL_REDIR(name, proto) \ + __LDBL_REDIR1 (name, proto, __nldbl_##name) +# define __LDBL_REDIR1_NTH(name, proto, alias) __REDIRECT_NTH (name, proto, alias) +# define __LDBL_REDIR_NTH(name, proto) \ + __LDBL_REDIR1_NTH (name, proto, __nldbl_##name) +# define __LDBL_REDIR2_DECL(name) \ + extern __typeof (__##name) __##name __asm (__ASMNAME ("__nldbl___" #name)); +# define __LDBL_REDIR1_DECL(name, alias) \ + extern __typeof (name) name __asm (__ASMNAME (#alias)); +# define __LDBL_REDIR_DECL(name) \ + extern __typeof (name) name __asm (__ASMNAME ("__nldbl_" #name)); +# define __REDIRECT_LDBL(name, proto, alias) \ + __LDBL_REDIR1 (name, proto, __nldbl_##alias) +# define __REDIRECT_NTH_LDBL(name, proto, alias) \ + __LDBL_REDIR1_NTH (name, proto, __nldbl_##alias) +# endif +#endif +#if (!defined __LDBL_COMPAT && __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 0) \ + || !defined __REDIRECT +# define __LDBL_REDIR1(name, proto, alias) name proto +# define __LDBL_REDIR(name, proto) name proto +# define __LDBL_REDIR1_NTH(name, proto, alias) name proto __THROW +# define __LDBL_REDIR_NTH(name, proto) name proto __THROW +# define __LDBL_REDIR2_DECL(name) +# define __LDBL_REDIR_DECL(name) +# ifdef __REDIRECT +# define __REDIRECT_LDBL(name, proto, alias) __REDIRECT (name, proto, alias) +# define __REDIRECT_NTH_LDBL(name, proto, alias) \ + __REDIRECT_NTH (name, proto, alias) +# endif +#endif + +/* __glibc_macro_warning (MESSAGE) issues warning MESSAGE. This is + intended for use in preprocessor macros. + + Note: MESSAGE must be a _single_ string; concatenation of string + literals is not supported. */ +#if __GNUC_PREREQ (4,8) || __glibc_clang_prereq (3,5) +# define __glibc_macro_warning1(message) _Pragma (#message) +# define __glibc_macro_warning(message) \ + __glibc_macro_warning1 (GCC warning message) +#else +# define __glibc_macro_warning(msg) +#endif + +/* Generic selection (ISO C11) is a C-only feature, available in GCC + since version 4.9. Previous versions do not provide generic + selection, even though they might set __STDC_VERSION__ to 201112L, + when in -std=c11 mode. Thus, we must check for !defined __GNUC__ + when testing __STDC_VERSION__ for generic selection support. + On the other hand, Clang also defines __GNUC__, so a clang-specific + check is required to enable the use of generic selection. */ +#if !defined __cplusplus \ + && (__GNUC_PREREQ (4, 9) \ + || __glibc_has_extension (c_generic_selections) \ + || (!defined __GNUC__ && defined __STDC_VERSION__ \ + && __STDC_VERSION__ >= 201112L)) +# define __HAVE_GENERIC_SELECTION 1 +#else +# define __HAVE_GENERIC_SELECTION 0 +#endif + +#if __GNUC_PREREQ (10, 0) +/* Designates a 1-based positional argument ref-index of pointer type + that can be used to access size-index elements of the pointed-to + array according to access mode, or at least one element when + size-index is not provided: + access (access-mode, [, ]) */ +# define __attr_access(x) __attribute__ ((__access__ x)) +/* For _FORTIFY_SOURCE == 3 we use __builtin_dynamic_object_size, which may + use the access attribute to get object sizes from function definition + arguments, so we can't use them on functions we fortify. Drop the object + size hints for such functions. */ +# if __USE_FORTIFY_LEVEL == 3 +# define __fortified_attr_access(a, o, s) __attribute__ ((__access__ (a, o))) +# else +# define __fortified_attr_access(a, o, s) __attr_access ((a, o, s)) +# endif +# if __GNUC_PREREQ (11, 0) +# define __attr_access_none(argno) __attribute__ ((__access__ (__none__, argno))) +# else +# define __attr_access_none(argno) +# endif +#else +# define __fortified_attr_access(a, o, s) +# define __attr_access(x) +# define __attr_access_none(argno) +#endif + +#if __GNUC_PREREQ (11, 0) +/* Designates dealloc as a function to call to deallocate objects + allocated by the declared function. */ +# define __attr_dealloc(dealloc, argno) \ + __attribute__ ((__malloc__ (dealloc, argno))) +# define __attr_dealloc_free __attr_dealloc (__builtin_free, 1) +#else +# define __attr_dealloc(dealloc, argno) +# define __attr_dealloc_free +#endif + +/* Specify that a function such as setjmp or vfork may return + twice. */ +#if __GNUC_PREREQ (4, 1) +# define __attribute_returns_twice__ __attribute__ ((__returns_twice__)) +#else +# define __attribute_returns_twice__ /* Ignore. */ +#endif + +#endif /* sys/cdefs.h */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/chdir-long.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/chdir-long.c new file mode 100644 index 00000000..61600251 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/chdir-long.c @@ -0,0 +1,263 @@ +/* provide a chdir function that tries not to fail due to ENAMETOOLONG + Copyright (C) 2004-2024 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 . */ + +/* written by Jim Meyering */ + +#include + +#include "chdir-long.h" + +#include +#include +#include +#include +#include + +#include "assure.h" + +#ifndef PATH_MAX +# error "compile this file only if your system defines PATH_MAX" +#endif + +/* The results of openat() in this file are not leaked to any + single-threaded code that could use stdio. + FIXME - if the kernel ever adds support for multi-thread safety for + avoiding standard fds, then we should use openat_safer. */ + +struct cd_buf +{ + int fd; +}; + +static void +cdb_init (struct cd_buf *cdb) +{ + cdb->fd = AT_FDCWD; +} + +static int +cdb_fchdir (struct cd_buf const *cdb) +{ + return fchdir (cdb->fd); +} + +static void +cdb_free (struct cd_buf const *cdb) +{ + if (0 <= cdb->fd) + { + bool close_fail = close (cdb->fd); + assure (! close_fail); + } +} + +/* Given a file descriptor of an open directory (or AT_FDCWD), CDB->fd, + try to open the CDB->fd-relative directory, DIR. If the open succeeds, + update CDB->fd with the resulting descriptor, close the incoming file + descriptor, and return zero. Upon failure, return -1 and set errno. */ +static int +cdb_advance_fd (struct cd_buf *cdb, char const *dir) +{ + int new_fd = openat (cdb->fd, dir, + O_SEARCH | O_DIRECTORY | O_NOCTTY | O_NONBLOCK); + if (new_fd < 0) + return -1; + + cdb_free (cdb); + cdb->fd = new_fd; + + return 0; +} + +/* Return a pointer to the first non-slash in S. */ +static char * _GL_ATTRIBUTE_PURE +find_non_slash (char const *s) +{ + size_t n_slash = strspn (s, "/"); + return (char *) s + n_slash; +} + +/* This is a function much like chdir, but without the PATH_MAX limitation + on the length of the directory name. A significant difference is that + it must be able to modify (albeit only temporarily) the directory + name. It handles an arbitrarily long directory name by operating + on manageable portions of the name. On systems without the openat + syscall, this means changing the working directory to more and more + "distant" points along the long directory name and then restoring + the working directory. If any of those attempts to save or restore + the working directory fails, this function exits nonzero. + + Note that this function may still fail with errno == ENAMETOOLONG, but + only if the specified directory name contains a component that is long + enough to provoke such a failure all by itself (e.g. if the component + has length PATH_MAX or greater on systems that define PATH_MAX). */ + +int +chdir_long (char *dir) +{ + int e = chdir (dir); + if (e == 0 || errno != ENAMETOOLONG) + return e; + + { + size_t len = strlen (dir); + char *dir_end = dir + len; + struct cd_buf cdb; + size_t n_leading_slash; + + cdb_init (&cdb); + + /* If DIR is the empty string, then the chdir above + must have failed and set errno to ENOENT. */ + assure (0 < len); + assure (PATH_MAX <= len); + + /* Count leading slashes. */ + n_leading_slash = strspn (dir, "/"); + + /* Handle any leading slashes as well as any name that matches + the regular expression, m!^//hostname[/]*! . Handling this + prefix separately usually results in a single additional + cdb_advance_fd call, but it's worthwhile, since it makes the + code in the following loop cleaner. */ + if (n_leading_slash == 2) + { + int err; + /* Find next slash. + We already know that dir[2] is neither a slash nor '\0'. */ + char *slash = memchr (dir + 3, '/', dir_end - (dir + 3)); + if (slash == NULL) + { + errno = ENAMETOOLONG; + return -1; + } + *slash = '\0'; + err = cdb_advance_fd (&cdb, dir); + *slash = '/'; + if (err != 0) + goto Fail; + dir = find_non_slash (slash + 1); + } + else if (n_leading_slash) + { + if (cdb_advance_fd (&cdb, "/") != 0) + goto Fail; + dir += n_leading_slash; + } + + assure (*dir != '/'); + assure (dir <= dir_end); + + while (PATH_MAX <= dir_end - dir) + { + int err; + /* Find a slash that is PATH_MAX or fewer bytes away from dir. + I.e. see if there is a slash that will give us a name of + length PATH_MAX-1 or less. */ + char *slash = memrchr (dir, '/', PATH_MAX); + if (slash == NULL) + { + errno = ENAMETOOLONG; + return -1; + } + + *slash = '\0'; + assure (slash - dir < PATH_MAX); + err = cdb_advance_fd (&cdb, dir); + *slash = '/'; + if (err != 0) + goto Fail; + + dir = find_non_slash (slash + 1); + } + + if (dir < dir_end) + { + if (cdb_advance_fd (&cdb, dir) != 0) + goto Fail; + } + + if (cdb_fchdir (&cdb) != 0) + goto Fail; + + cdb_free (&cdb); + return 0; + + Fail: + { + int saved_errno = errno; + cdb_free (&cdb); + errno = saved_errno; + return -1; + } + } +} + +#if TEST_CHDIR + +# include "closeout.h" +# include + +int +main (int argc, char *argv[]) +{ + char *line = NULL; + size_t n = 0; + int len; + + atexit (close_stdout); + + len = getline (&line, &n, stdin); + if (len < 0) + { + int saved_errno = errno; + if (feof (stdin)) + exit (0); + + error (EXIT_FAILURE, saved_errno, + "reading standard input"); + } + else if (len == 0) + exit (0); + + if (line[len-1] == '\n') + line[len-1] = '\0'; + + if (chdir_long (line) != 0) + error (EXIT_FAILURE, errno, + "chdir_long failed: %s", line); + + if (argc <= 1) + { + /* Using 'pwd' here makes sense only if it is a robust implementation, + like the one in coreutils after the 2004-04-19 changes. */ + char const *cmd = "pwd"; + execlp (cmd, (char *) NULL); + error (EXIT_FAILURE, errno, "%s", cmd); + } + + fclose (stdin); + fclose (stderr); + + exit (EXIT_SUCCESS); +} +#endif + +/* +Local Variables: +compile-command: "gcc -DTEST_CHDIR=1 -g -O -W -Wall chdir-long.c libcoreutils.a" +End: +*/ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/chdir-long.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/chdir-long.h new file mode 100644 index 00000000..2f24fa08 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/chdir-long.h @@ -0,0 +1,30 @@ +/* provide a chdir function that tries not to fail due to ENAMETOOLONG + Copyright (C) 2004-2005, 2009-2024 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 . */ + +/* Written by Jim Meyering. */ + +#include +#include + +#include "pathmax.h" + +/* On systems without PATH_MAX, presume that chdir accepts + arbitrarily long directory names. */ +#ifndef PATH_MAX +# define chdir_long(Dir) chdir (Dir) +#else +int chdir_long (char *dir); +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/cloexec.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/cloexec.c new file mode 100644 index 00000000..cdb0d740 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/cloexec.c @@ -0,0 +1,83 @@ +/* cloexec.c - set or clear the close-on-exec descriptor flag + + Copyright (C) 1991, 2004-2006, 2009-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* The code is taken from glibc/manual/llio.texi */ + +#include + +#include "cloexec.h" + +#include +#include +#include + +/* Set the 'FD_CLOEXEC' flag of DESC if VALUE is true, + or clear the flag if VALUE is false. + Return 0 on success, or -1 on error with 'errno' set. + + Note that on MingW, this function does NOT protect DESC from being + inherited into spawned children. Instead, either use dup_cloexec + followed by closing the original DESC, or use interfaces such as + open or pipe2 that accept flags like O_CLOEXEC to create DESC + non-inheritable in the first place. */ + +int +set_cloexec_flag (int desc, bool value) +{ +#ifdef F_SETFD + + int flags = fcntl (desc, F_GETFD, 0); + + if (0 <= flags) + { + int newflags = (value ? flags | FD_CLOEXEC : flags & ~FD_CLOEXEC); + + if (flags == newflags + || fcntl (desc, F_SETFD, newflags) != -1) + return 0; + } + + return -1; + +#else /* !F_SETFD */ + + /* Use dup2 to reject invalid file descriptors; the cloexec flag + will be unaffected. */ + if (desc < 0) + { + errno = EBADF; + return -1; + } + if (dup2 (desc, desc) < 0) + /* errno is EBADF here. */ + return -1; + + /* There is nothing we can do on this kind of platform. Punt. */ + return 0; +#endif /* !F_SETFD */ +} + + +/* Duplicates a file handle FD, while marking the copy to be closed + prior to exec or spawn. Returns -1 and sets errno if FD could not + be duplicated. */ + +int +dup_cloexec (int fd) +{ + return fcntl (fd, F_DUPFD_CLOEXEC, 0); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/cloexec.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/cloexec.h new file mode 100644 index 00000000..f52e5f2e --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/cloexec.h @@ -0,0 +1,34 @@ +/* cloexec.c - set or clear the close-on-exec descriptor flag + + Copyright (C) 2004, 2009-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Set the 'FD_CLOEXEC' flag of DESC if VALUE is true, + or clear the flag if VALUE is false. + Return 0 on success, or -1 on error with 'errno' set. + + Note that on MingW, this function does NOT protect DESC from being + inherited into spawned children. Instead, either use dup_cloexec + followed by closing the original DESC, or use interfaces such as + open or pipe2 that accept flags like O_CLOEXEC to create DESC + non-inheritable in the first place. */ + +int set_cloexec_flag (int desc, bool value); + +/* Duplicates a file handle FD, while marking the copy to be closed + prior to exec or spawn. Returns -1 and sets errno if FD could not + be duplicated. */ + +int dup_cloexec (int fd); diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/close.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/close.c new file mode 100644 index 00000000..830fd820 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/close.c @@ -0,0 +1,75 @@ +/* close replacement. + Copyright (C) 2008-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +#include + +#include "fd-hook.h" +#if HAVE_MSVC_INVALID_PARAMETER_HANDLER +# include "msvc-inval.h" +#endif + +#undef close + +#if defined _WIN32 && !defined __CYGWIN__ +# if HAVE_MSVC_INVALID_PARAMETER_HANDLER +static int +close_nothrow (int fd) +{ + int result; + + TRY_MSVC_INVAL + { + result = _close (fd); + } + CATCH_MSVC_INVAL + { + result = -1; + errno = EBADF; + } + DONE_MSVC_INVAL; + + return result; +} +# else +# define close_nothrow _close +# endif +#else +# define close_nothrow close +#endif + +/* Override close() to call into other gnulib modules. */ + +int +rpl_close (int fd) +{ +#if WINDOWS_SOCKETS + int retval = execute_all_close_hooks (close_nothrow, fd); +#else + int retval = close_nothrow (fd); +#endif + +#if REPLACE_FCHDIR + if (retval >= 0) + _gl_unregister_fd (fd); +#endif + + return retval; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/closedir.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/closedir.c new file mode 100644 index 00000000..24b6bdac --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/closedir.c @@ -0,0 +1,77 @@ +/* Stop reading the entries of a directory. + Copyright (C) 2006-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +#if REPLACE_FCHDIR +# include +#endif + +#include + +#if HAVE_CLOSEDIR + +/* Override closedir(), to keep track of the open file descriptors. + Needed because there is a function dirfd(). */ + +#endif + +#if GNULIB_defined_DIR +# include "dirent-private.h" +#endif + +int +closedir (DIR *dirp) +#undef closedir +{ +#if GNULIB_defined_DIR || REPLACE_FCHDIR + int fd = dirfd (dirp); +#endif + int retval; + +#if HAVE_DIRENT_H /* equivalent to HAVE_CLOSEDIR */ + +# if GNULIB_defined_DIR + retval = closedir (dirp->real_dirp); + if (retval >= 0) + free (dirp); +# else + retval = closedir (dirp); +# endif + +#else + + if (dirp->current != INVALID_HANDLE_VALUE) + FindClose (dirp->current); + free (dirp); + + retval = 0; + +#endif + +#if GNULIB_defined_DIR + if (retval >= 0) + close (fd); +#elif REPLACE_FCHDIR + if (retval >= 0) + _gl_unregister_fd (fd); +#endif + + return retval; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/count-leading-zeros.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/count-leading-zeros.c new file mode 100644 index 00000000..2bbfd674 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/count-leading-zeros.c @@ -0,0 +1,21 @@ +/* Count the number of leading 0 bits in a word. + + Copyright (C) 2012-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +#define COUNT_LEADING_ZEROS_INLINE _GL_EXTERN_INLINE +#include "count-leading-zeros.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/count-leading-zeros.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/count-leading-zeros.h new file mode 100644 index 00000000..545749d6 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/count-leading-zeros.h @@ -0,0 +1,138 @@ +/* count-leading-zeros.h -- counts the number of leading 0 bits in a word. + Copyright (C) 2012-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Eric Blake. */ + +#ifndef COUNT_LEADING_ZEROS_H +#define COUNT_LEADING_ZEROS_H 1 + +/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +#include +#include + +_GL_INLINE_HEADER_BEGIN +#ifndef COUNT_LEADING_ZEROS_INLINE +# define COUNT_LEADING_ZEROS_INLINE _GL_INLINE +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* Assuming the GCC builtin is BUILTIN and the MSC builtin is MSC_BUILTIN, + expand to code that computes the number of leading zeros of the local + variable 'x' of type TYPE (an unsigned integer type) and return it + from the current function. */ +#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) \ + || (__clang_major__ >= 4) +# define COUNT_LEADING_ZEROS(BUILTIN, MSC_BUILTIN, TYPE) \ + return x ? BUILTIN (x) : CHAR_BIT * sizeof x; +#elif _MSC_VER +# pragma intrinsic (_BitScanReverse) +# if defined _M_X64 +# pragma intrinsic (_BitScanReverse64) +# endif +# define COUNT_LEADING_ZEROS(BUILTIN, MSC_BUILTIN, TYPE) \ + do \ + { \ + unsigned long result; \ + if (MSC_BUILTIN (&result, x)) \ + return CHAR_BIT * sizeof x - 1 - result; \ + return CHAR_BIT * sizeof x; \ + } \ + while (0) +#else +# define COUNT_LEADING_ZEROS(BUILTIN, MSC_BUILTIN, TYPE) \ + do \ + { \ + int count; \ + unsigned int leading_32; \ + if (! x) \ + return CHAR_BIT * sizeof x; \ + for (count = 0; \ + (leading_32 = ((x >> (sizeof (TYPE) * CHAR_BIT - 32)) \ + & 0xffffffffU), \ + count < CHAR_BIT * sizeof x - 32 && !leading_32); \ + count += 32) \ + x = x << 31 << 1; \ + return count + count_leading_zeros_32 (leading_32); \ + } \ + while (0) + +/* Compute and return the number of leading zeros in X, + where 0 < X < 2**32. */ +COUNT_LEADING_ZEROS_INLINE int +count_leading_zeros_32 (unsigned int x) +{ + /* + */ + static const char de_Bruijn_lookup[32] = { + 31, 22, 30, 21, 18, 10, 29, 2, 20, 17, 15, 13, 9, 6, 28, 1, + 23, 19, 11, 3, 16, 14, 7, 24, 12, 4, 8, 25, 5, 26, 27, 0 + }; + + x |= x >> 1; + x |= x >> 2; + x |= x >> 4; + x |= x >> 8; + x |= x >> 16; + return de_Bruijn_lookup[((x * 0x07c4acddU) & 0xffffffffU) >> 27]; +} +#endif + +/* Compute and return the number of leading zeros in X. */ +COUNT_LEADING_ZEROS_INLINE int +count_leading_zeros (unsigned int x) +{ + COUNT_LEADING_ZEROS (__builtin_clz, _BitScanReverse, unsigned int); +} + +/* Compute and return the number of leading zeros in X. */ +COUNT_LEADING_ZEROS_INLINE int +count_leading_zeros_l (unsigned long int x) +{ + COUNT_LEADING_ZEROS (__builtin_clzl, _BitScanReverse, unsigned long int); +} + +/* Compute and return the number of leading zeros in X. */ +COUNT_LEADING_ZEROS_INLINE int +count_leading_zeros_ll (unsigned long long int x) +{ +#if (defined _MSC_VER && !defined __clang__) && !defined _M_X64 + /* 32-bit MSVC does not have _BitScanReverse64, only _BitScanReverse. */ + unsigned long result; + if (_BitScanReverse (&result, (unsigned long) (x >> 32))) + return CHAR_BIT * sizeof x - 1 - 32 - result; + if (_BitScanReverse (&result, (unsigned long) x)) + return CHAR_BIT * sizeof x - 1 - result; + return CHAR_BIT * sizeof x; +#else + COUNT_LEADING_ZEROS (__builtin_clzll, _BitScanReverse64, + unsigned long long int); +#endif +} + +#ifdef __cplusplus +} +#endif + +_GL_INLINE_HEADER_END + +#endif /* COUNT_LEADING_ZEROS_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/ctype.in.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/ctype.in.h new file mode 100644 index 00000000..61bcbf16 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/ctype.in.h @@ -0,0 +1,62 @@ +/* A substitute for ISO C99 , for platforms on which it is incomplete. + + Copyright (C) 2009-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible. */ + +/* + * ISO C 99 for platforms on which it is incomplete. + * + */ + +#ifndef _@GUARD_PREFIX@_CTYPE_H + +#if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +#endif +@PRAGMA_COLUMNS@ + +/* Include the original . */ +/* The include_next requires a split double-inclusion guard. */ +#@INCLUDE_NEXT@ @NEXT_CTYPE_H@ + +#ifndef _@GUARD_PREFIX@_CTYPE_H +#define _@GUARD_PREFIX@_CTYPE_H + +/* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ + +/* The definition of _GL_WARN_ON_USE is copied here. */ + +/* Return non-zero if c is a blank, i.e. a space or tab character. */ +#if @GNULIB_ISBLANK@ +# if !@HAVE_ISBLANK@ +_GL_EXTERN_C int isblank (int c); +# endif +#elif defined GNULIB_POSIXCHECK +# undef isblank +# if HAVE_RAW_DECL_ISBLANK +_GL_WARN_ON_USE (isblank, "isblank is unportable - " + "use gnulib module isblank for portability"); +# endif +#endif + +#endif /* _@GUARD_PREFIX@_CTYPE_H */ +#endif /* _@GUARD_PREFIX@_CTYPE_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/diffseq.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/diffseq.h new file mode 100644 index 00000000..0c5bc9cb --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/diffseq.h @@ -0,0 +1,570 @@ +/* Analyze differences between two vectors. + + Copyright (C) 1988-1989, 1992-1995, 2001-2004, 2006-2024 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 . */ + + +/* The basic idea is to consider two vectors as similar if, when + transforming the first vector into the second vector through a + sequence of edits (inserts and deletes of one element each), + this sequence is short - or equivalently, if the ordered list + of elements that are untouched by these edits is long. For a + good introduction to the subject, read about the "Levenshtein + distance" in Wikipedia. + + The basic algorithm is described in: + "An O(ND) Difference Algorithm and its Variations", Eugene W. Myers, + Algorithmica Vol. 1, 1986, pp. 251-266, + . + See especially section 4.2, which describes the variation used below. + + The basic algorithm was independently discovered as described in: + "Algorithms for Approximate String Matching", Esko Ukkonen, + Information and Control Vol. 64, 1985, pp. 100-118, + . + + Unless the 'find_minimal' flag is set, this code uses the TOO_EXPENSIVE + heuristic, by Paul Eggert, to limit the cost to O(N**1.5 log N) + at the price of producing suboptimal output for large inputs with + many differences. */ + +/* Before including this file, you need to define: + ELEMENT The element type of the vectors being compared. + EQUAL A two-argument macro that tests two elements for + equality. + OFFSET A signed integer type sufficient to hold the + difference between two indices. Usually + something like ptrdiff_t. + OFFSET_MAX (Optional) The maximum value of OFFSET (e.g., + PTRDIFF_MAX). If omitted, it is inferred in a + way portable to the vast majority of C platforms, + as they lack padding bits. + EXTRA_CONTEXT_FIELDS Declarations of fields for 'struct context'. + NOTE_DELETE(ctxt, xoff) Record the removal of the object xvec[xoff]. + NOTE_INSERT(ctxt, yoff) Record the insertion of the object yvec[yoff]. + NOTE_ORDERED (Optional) A boolean expression saying that + NOTE_DELETE and NOTE_INSERT calls must be + issued in offset order. + EARLY_ABORT(ctxt) (Optional) A boolean expression that triggers an + early abort of the computation. + USE_HEURISTIC (Optional) Define if you want to support the + heuristic for large vectors. + + It is also possible to use this file with abstract arrays. In this case, + xvec and yvec are not represented in memory. They only exist conceptually. + In this case, the list of defines above is amended as follows: + ELEMENT Undefined. + EQUAL Undefined. + XVECREF_YVECREF_EQUAL(ctxt, xoff, yoff) + A three-argument macro: References xvec[xoff] and + yvec[yoff] and tests these elements for equality. + + Before including this file, you also need to include: + #include + #include "minmax.h" + */ + +/* Maximum value of type OFFSET. */ +#ifndef OFFSET_MAX +# define OFFSET_MAX \ + ((((OFFSET) 1 << (sizeof (OFFSET) * CHAR_BIT - 2)) - 1) * 2 + 1) +#endif + +/* Default to no early abort. */ +#ifndef EARLY_ABORT +# define EARLY_ABORT(ctxt) false +#endif + +#ifndef NOTE_ORDERED +# define NOTE_ORDERED false +#endif + +/* Suppress gcc's "...may be used before initialized" warnings, + generated by GCC versions up to at least GCC 13.2. */ +#if __GNUC__ + (__GNUC_MINOR__ >= 7) > 4 +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wmaybe-uninitialized" +#endif + +/* + * Context of comparison operation. + */ +struct context +{ + #ifdef ELEMENT + /* Vectors being compared. */ + ELEMENT const *xvec; + ELEMENT const *yvec; + #endif + + /* Extra fields. */ + EXTRA_CONTEXT_FIELDS + + /* Vector, indexed by diagonal, containing 1 + the X coordinate of the point + furthest along the given diagonal in the forward search of the edit + matrix. */ + OFFSET *fdiag; + + /* Vector, indexed by diagonal, containing the X coordinate of the point + furthest along the given diagonal in the backward search of the edit + matrix. */ + OFFSET *bdiag; + + #ifdef USE_HEURISTIC + /* This corresponds to the diff --speed-large-files flag. With this + heuristic, for vectors with a constant small density of changes, + the algorithm is linear in the vector size. */ + bool heuristic; + #endif + + /* Edit scripts longer than this are too expensive to compute. */ + OFFSET too_expensive; + + /* Snakes bigger than this are considered "big". */ + #define SNAKE_LIMIT 20 +}; + +struct partition +{ + /* Midpoints of this partition. */ + OFFSET xmid; + OFFSET ymid; + + /* True if low half will be analyzed minimally. */ + bool lo_minimal; + + /* Likewise for high half. */ + bool hi_minimal; +}; + + +/* Find the midpoint of the shortest edit script for a specified portion + of the two vectors. + + Scan from the beginnings of the vectors, and simultaneously from the ends, + doing a breadth-first search through the space of edit-sequence. + When the two searches meet, we have found the midpoint of the shortest + edit sequence. + + If FIND_MINIMAL is true, find the minimal edit script regardless of + expense. Otherwise, if the search is too expensive, use heuristics to + stop the search and report a suboptimal answer. + + Set PART->(xmid,ymid) to the midpoint (XMID,YMID). The diagonal number + XMID - YMID equals the number of inserted elements minus the number + of deleted elements (counting only elements before the midpoint). + + Set PART->lo_minimal to true iff the minimal edit script for the + left half of the partition is known; similarly for PART->hi_minimal. + + This function assumes that the first elements of the specified portions + of the two vectors do not match, and likewise that the last elements do not + match. The caller must trim matching elements from the beginning and end + of the portions it is going to specify. + + If we return the "wrong" partitions, the worst this can do is cause + suboptimal diff output. It cannot cause incorrect diff output. */ + +static void +diag (OFFSET xoff, OFFSET xlim, OFFSET yoff, OFFSET ylim, bool find_minimal, + struct partition *part, struct context *ctxt) +{ + OFFSET *const fd = ctxt->fdiag; /* Give the compiler a chance. */ + OFFSET *const bd = ctxt->bdiag; /* Additional help for the compiler. */ +#ifdef ELEMENT + ELEMENT const *const xv = ctxt->xvec; /* Still more help for the compiler. */ + ELEMENT const *const yv = ctxt->yvec; /* And more and more . . . */ + #define XREF_YREF_EQUAL(x,y) EQUAL (xv[x], yv[y]) +#else + #define XREF_YREF_EQUAL(x,y) XVECREF_YVECREF_EQUAL (ctxt, x, y) +#endif + const OFFSET dmin = xoff - ylim; /* Minimum valid diagonal. */ + const OFFSET dmax = xlim - yoff; /* Maximum valid diagonal. */ + const OFFSET fmid = xoff - yoff; /* Center diagonal of top-down search. */ + const OFFSET bmid = xlim - ylim; /* Center diagonal of bottom-up search. */ + OFFSET fmin = fmid; + OFFSET fmax = fmid; /* Limits of top-down search. */ + OFFSET bmin = bmid; + OFFSET bmax = bmid; /* Limits of bottom-up search. */ + OFFSET c; /* Cost. */ + bool odd = (fmid - bmid) & 1; /* True if southeast corner is on an odd + diagonal with respect to the northwest. */ + + fd[fmid] = xoff; + bd[bmid] = xlim; + + for (c = 1;; ++c) + { + OFFSET d; /* Active diagonal. */ + bool big_snake = false; + + /* Extend the top-down search by an edit step in each diagonal. */ + if (fmin > dmin) + fd[--fmin - 1] = -1; + else + ++fmin; + if (fmax < dmax) + fd[++fmax + 1] = -1; + else + --fmax; + for (d = fmax; d >= fmin; d -= 2) + { + OFFSET x; + OFFSET y; + OFFSET tlo = fd[d - 1]; + OFFSET thi = fd[d + 1]; + OFFSET x0 = tlo < thi ? thi : tlo + 1; + + for (x = x0, y = x0 - d; + x < xlim && y < ylim && XREF_YREF_EQUAL (x, y); + x++, y++) + continue; + if (x - x0 > SNAKE_LIMIT) + big_snake = true; + fd[d] = x; + if (odd && bmin <= d && d <= bmax && bd[d] <= x) + { + part->xmid = x; + part->ymid = y; + part->lo_minimal = part->hi_minimal = true; + return; + } + } + + /* Similarly extend the bottom-up search. */ + if (bmin > dmin) + bd[--bmin - 1] = OFFSET_MAX; + else + ++bmin; + if (bmax < dmax) + bd[++bmax + 1] = OFFSET_MAX; + else + --bmax; + for (d = bmax; d >= bmin; d -= 2) + { + OFFSET x; + OFFSET y; + OFFSET tlo = bd[d - 1]; + OFFSET thi = bd[d + 1]; + OFFSET x0 = tlo < thi ? tlo : thi - 1; + + for (x = x0, y = x0 - d; + xoff < x && yoff < y && XREF_YREF_EQUAL (x - 1, y - 1); + x--, y--) + continue; + if (x0 - x > SNAKE_LIMIT) + big_snake = true; + bd[d] = x; + if (!odd && fmin <= d && d <= fmax && x <= fd[d]) + { + part->xmid = x; + part->ymid = y; + part->lo_minimal = part->hi_minimal = true; + return; + } + } + + if (find_minimal) + continue; + +#ifdef USE_HEURISTIC + bool heuristic = ctxt->heuristic; +#else + bool heuristic = false; +#endif + + /* Heuristic: check occasionally for a diagonal that has made lots + of progress compared with the edit distance. If we have any + such, find the one that has made the most progress and return it + as if it had succeeded. + + With this heuristic, for vectors with a constant small density + of changes, the algorithm is linear in the vector size. */ + + if (200 < c && big_snake && heuristic) + { + { + OFFSET best = 0; + + for (d = fmax; d >= fmin; d -= 2) + { + OFFSET dd = d - fmid; + OFFSET x = fd[d]; + OFFSET y = x - d; + OFFSET v = (x - xoff) * 2 - dd; + + if (v > 12 * (c + (dd < 0 ? -dd : dd))) + { + if (v > best + && xoff + SNAKE_LIMIT <= x && x < xlim + && yoff + SNAKE_LIMIT <= y && y < ylim) + { + /* We have a good enough best diagonal; now insist + that it end with a significant snake. */ + int k; + + for (k = 1; XREF_YREF_EQUAL (x - k, y - k); k++) + if (k == SNAKE_LIMIT) + { + best = v; + part->xmid = x; + part->ymid = y; + break; + } + } + } + } + if (best > 0) + { + part->lo_minimal = true; + part->hi_minimal = false; + return; + } + } + + { + OFFSET best = 0; + + for (d = bmax; d >= bmin; d -= 2) + { + OFFSET dd = d - bmid; + OFFSET x = bd[d]; + OFFSET y = x - d; + OFFSET v = (xlim - x) * 2 + dd; + + if (v > 12 * (c + (dd < 0 ? -dd : dd))) + { + if (v > best + && xoff < x && x <= xlim - SNAKE_LIMIT + && yoff < y && y <= ylim - SNAKE_LIMIT) + { + /* We have a good enough best diagonal; now insist + that it end with a significant snake. */ + int k; + + for (k = 0; XREF_YREF_EQUAL (x + k, y + k); k++) + if (k == SNAKE_LIMIT - 1) + { + best = v; + part->xmid = x; + part->ymid = y; + break; + } + } + } + } + if (best > 0) + { + part->lo_minimal = false; + part->hi_minimal = true; + return; + } + } + } + + /* Heuristic: if we've gone well beyond the call of duty, give up + and report halfway between our best results so far. */ + if (c >= ctxt->too_expensive) + { + /* Find forward diagonal that maximizes X + Y. */ + OFFSET fxybest = -1, fxbest; + for (d = fmax; d >= fmin; d -= 2) + { + OFFSET x = MIN (fd[d], xlim); + OFFSET y = x - d; + if (ylim < y) + { + x = ylim + d; + y = ylim; + } + if (fxybest < x + y) + { + fxybest = x + y; + fxbest = x; + } + } + + /* Find backward diagonal that minimizes X + Y. */ + OFFSET bxybest = OFFSET_MAX, bxbest; + for (d = bmax; d >= bmin; d -= 2) + { + OFFSET x = MAX (xoff, bd[d]); + OFFSET y = x - d; + if (y < yoff) + { + x = yoff + d; + y = yoff; + } + if (x + y < bxybest) + { + bxybest = x + y; + bxbest = x; + } + } + + /* Use the better of the two diagonals. */ + if ((xlim + ylim) - bxybest < fxybest - (xoff + yoff)) + { + part->xmid = fxbest; + part->ymid = fxybest - fxbest; + part->lo_minimal = true; + part->hi_minimal = false; + } + else + { + part->xmid = bxbest; + part->ymid = bxybest - bxbest; + part->lo_minimal = false; + part->hi_minimal = true; + } + return; + } + } + #undef XREF_YREF_EQUAL +} + + +/* Compare in detail contiguous subsequences of the two vectors + which are known, as a whole, to match each other. + + The subsequence of vector 0 is [XOFF, XLIM) and likewise for vector 1. + + Note that XLIM, YLIM are exclusive bounds. All indices into the vectors + are origin-0. + + If FIND_MINIMAL, find a minimal difference no matter how + expensive it is. + + The results are recorded by invoking NOTE_DELETE and NOTE_INSERT. + + Return false if terminated normally, or true if terminated through early + abort. */ + +static bool +compareseq (OFFSET xoff, OFFSET xlim, OFFSET yoff, OFFSET ylim, + bool find_minimal, struct context *ctxt) +{ +#ifdef ELEMENT + ELEMENT const *xv = ctxt->xvec; /* Help the compiler. */ + ELEMENT const *yv = ctxt->yvec; + #define XREF_YREF_EQUAL(x,y) EQUAL (xv[x], yv[y]) +#else + #define XREF_YREF_EQUAL(x,y) XVECREF_YVECREF_EQUAL (ctxt, x, y) +#endif + + while (true) + { + /* Slide down the bottom initial diagonal. */ + while (xoff < xlim && yoff < ylim && XREF_YREF_EQUAL (xoff, yoff)) + { + xoff++; + yoff++; + } + + /* Slide up the top initial diagonal. */ + while (xoff < xlim && yoff < ylim && XREF_YREF_EQUAL (xlim - 1, ylim - 1)) + { + xlim--; + ylim--; + } + + /* Handle simple cases. */ + if (xoff == xlim) + { + while (yoff < ylim) + { + NOTE_INSERT (ctxt, yoff); + if (EARLY_ABORT (ctxt)) + return true; + yoff++; + } + break; + } + if (yoff == ylim) + { + while (xoff < xlim) + { + NOTE_DELETE (ctxt, xoff); + if (EARLY_ABORT (ctxt)) + return true; + xoff++; + } + break; + } + + struct partition part; + + /* Find a point of correspondence in the middle of the vectors. */ + diag (xoff, xlim, yoff, ylim, find_minimal, &part, ctxt); + + /* Use the partitions to split this problem into subproblems. */ + OFFSET xoff1, xlim1, yoff1, ylim1, xoff2, xlim2, yoff2, ylim2; + bool find_minimal1, find_minimal2; + if (!NOTE_ORDERED + && ((xlim + ylim) - (part.xmid + part.ymid) + < (part.xmid + part.ymid) - (xoff + yoff))) + { + /* The second problem is smaller and the caller doesn't + care about order, so do the second problem first to + lessen recursion. */ + xoff1 = part.xmid; xlim1 = xlim; + yoff1 = part.ymid; ylim1 = ylim; + find_minimal1 = part.hi_minimal; + + xoff2 = xoff; xlim2 = part.xmid; + yoff2 = yoff; ylim2 = part.ymid; + find_minimal2 = part.lo_minimal; + } + else + { + xoff1 = xoff; xlim1 = part.xmid; + yoff1 = yoff; ylim1 = part.ymid; + find_minimal1 = part.lo_minimal; + + xoff2 = part.xmid; xlim2 = xlim; + yoff2 = part.ymid; ylim2 = ylim; + find_minimal2 = part.hi_minimal; + } + + /* Recurse to do one subproblem. */ + bool early = compareseq (xoff1, xlim1, yoff1, ylim1, find_minimal1, ctxt); + if (early) + return early; + + /* Iterate to do the other subproblem. */ + xoff = xoff2; xlim = xlim2; + yoff = yoff2; ylim = ylim2; + find_minimal = find_minimal2; + } + + return false; + #undef XREF_YREF_EQUAL +} + +#if __GNUC__ + (__GNUC_MINOR__ >= 7) > 4 +# pragma GCC diagnostic pop +#endif + +#undef ELEMENT +#undef EQUAL +#undef OFFSET +#undef EXTRA_CONTEXT_FIELDS +#undef NOTE_DELETE +#undef NOTE_INSERT +#undef EARLY_ABORT +#undef USE_HEURISTIC +#undef XVECREF_YVECREF_EQUAL +#undef OFFSET_MAX diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/dirent-private.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/dirent-private.h new file mode 100644 index 00000000..335fbc35 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/dirent-private.h @@ -0,0 +1,67 @@ +/* Private details of the DIR type. + Copyright (C) 2011-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef _DIRENT_PRIVATE_H +#define _DIRENT_PRIVATE_H 1 + +#if HAVE_DIRENT_H /* mingw */ + +# undef DIR + +struct gl_directory +{ + /* File descriptor to close during closedir(). + Needed for implementing fdopendir(). */ + int fd_to_close; + /* Pointer to the real DIR. */ + DIR *real_dirp; +}; + +/* Restore definition from dirent.h. */ +# define DIR struct gl_directory + +#else /* MSVC */ + +# define WIN32_LEAN_AND_MEAN +# include + +/* Don't assume that UNICODE is not defined. */ +# undef WIN32_FIND_DATA +# define WIN32_FIND_DATA WIN32_FIND_DATAA + +struct gl_directory +{ + /* File descriptor to close during closedir(). + Needed for implementing fdopendir(). */ + int fd_to_close; + /* Status, or error code to produce in next readdir() call. + -2 means the end of the directory is already reached, + -1 means the entry was already filled by FindFirstFile, + 0 means the entry needs to be filled using FindNextFile. + A positive value is an error code. */ + int status; + /* Handle, reading the directory, at current position. */ + HANDLE current; + /* Found directory entry. */ + WIN32_FIND_DATA entry; + /* Argument to pass to FindFirstFile. It consists of the absolutized + directory name, followed by a directory separator and the wildcards. */ + char dir_name_mask[1]; +}; + +#endif + +#endif /* _DIRENT_PRIVATE_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/dirent.in.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/dirent.in.h new file mode 100644 index 00000000..f05b8800 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/dirent.in.h @@ -0,0 +1,352 @@ +/* A GNU-like . + Copyright (C) 2006-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef _@GUARD_PREFIX@_DIRENT_H + +#if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +#endif +@PRAGMA_COLUMNS@ + +/* The include_next requires a split double-inclusion guard. */ +#if @HAVE_DIRENT_H@ +# @INCLUDE_NEXT@ @NEXT_DIRENT_H@ +#endif + +#ifndef _@GUARD_PREFIX@_DIRENT_H +#define _@GUARD_PREFIX@_DIRENT_H + +/* This file uses _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_MALLOC, + _GL_ATTRIBUTE_PURE, GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +/* Get ino_t. Needed on some systems, including glibc 2.8. */ +#include + +#if !@HAVE_DIRENT_H@ +/* Define types DIR and 'struct dirent'. */ +# if !GNULIB_defined_struct_dirent +struct dirent +{ + char d_type; + char d_name[1]; +}; +/* Possible values for 'd_type'. */ +# define DT_UNKNOWN 0 +# define DT_FIFO 1 /* FIFO */ +# define DT_CHR 2 /* character device */ +# define DT_DIR 4 /* directory */ +# define DT_BLK 6 /* block device */ +# define DT_REG 8 /* regular file */ +# define DT_LNK 10 /* symbolic link */ +# define DT_SOCK 12 /* socket */ +# define DT_WHT 14 /* whiteout */ +# define GNULIB_defined_struct_dirent 1 +# endif +#endif + +#if !@DIR_HAS_FD_MEMBER@ +# if !GNULIB_defined_DIR +/* struct gl_directory is a type with a field 'int fd_to_close'. + It is needed for implementing fdopendir(). */ +struct gl_directory; +# if @HAVE_DIRENT_H@ +# define DIR struct gl_directory +# else +typedef struct gl_directory DIR; +# endif +# define GNULIB_defined_DIR 1 +# endif +#endif + +/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers + that can be freed by passing them as the Ith argument to the + function F. */ +#ifndef _GL_ATTRIBUTE_DEALLOC +# if __GNUC__ >= 11 +# define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i))) +# else +# define _GL_ATTRIBUTE_DEALLOC(f, i) +# endif +#endif + +/* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly + allocated memory. */ +/* Applies to: functions. */ +#ifndef _GL_ATTRIBUTE_MALLOC +# if __GNUC__ >= 3 || defined __clang__ +# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__)) +# else +# define _GL_ATTRIBUTE_MALLOC +# endif +#endif + +/* The __attribute__ feature is available in gcc versions 2.5 and later. + The attribute __pure__ was added in gcc 2.96. */ +#ifndef _GL_ATTRIBUTE_PURE +# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined __clang__ +# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) +# else +# define _GL_ATTRIBUTE_PURE /* empty */ +# endif +#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. */ + + +/* Declare overridden functions. */ + +#if @GNULIB_CLOSEDIR@ +# if @REPLACE_CLOSEDIR@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef closedir +# define closedir rpl_closedir +# define GNULIB_defined_closedir 1 +# endif +_GL_FUNCDECL_RPL (closedir, int, (DIR *dirp) _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (closedir, int, (DIR *dirp)); +# else +# if !@HAVE_CLOSEDIR@ +_GL_FUNCDECL_SYS (closedir, int, (DIR *dirp) _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (closedir, int, (DIR *dirp)); +# endif +_GL_CXXALIASWARN (closedir); +#elif defined GNULIB_POSIXCHECK +# undef closedir +# if HAVE_RAW_DECL_CLOSEDIR +_GL_WARN_ON_USE (closedir, "closedir is not portable - " + "use gnulib module closedir for portability"); +# endif +#endif + +#if @GNULIB_OPENDIR@ +# if @REPLACE_OPENDIR@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef opendir +# define opendir rpl_opendir +# define GNULIB_defined_opendir 1 +# endif +_GL_FUNCDECL_RPL (opendir, DIR *, + (const char *dir_name) + _GL_ARG_NONNULL ((1)) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC (closedir, 1)); +_GL_CXXALIAS_RPL (opendir, DIR *, (const char *dir_name)); +# else +# if !@HAVE_OPENDIR@ || __GNUC__ >= 11 +_GL_FUNCDECL_SYS (opendir, DIR *, + (const char *dir_name) + _GL_ARG_NONNULL ((1)) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC (closedir, 1)); +# endif +_GL_CXXALIAS_SYS (opendir, DIR *, (const char *dir_name)); +# endif +_GL_CXXALIASWARN (opendir); +#else +# if @GNULIB_CLOSEDIR@ && !GNULIB_defined_DIR && __GNUC__ >= 11 && !defined opendir +/* For -Wmismatched-dealloc: Associate opendir with closedir or + rpl_closedir. */ +_GL_FUNCDECL_SYS (opendir, DIR *, + (const char *dir_name) + _GL_ARG_NONNULL ((1)) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC (closedir, 1)); +# endif +# if defined GNULIB_POSIXCHECK +# undef opendir +# if HAVE_RAW_DECL_OPENDIR +_GL_WARN_ON_USE (opendir, "opendir is not portable - " + "use gnulib module opendir for portability"); +# endif +# endif +#endif + +#if @GNULIB_READDIR@ +# if @REPLACE_READDIR@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef readdir +# define readdir rpl_readdir +# endif +_GL_FUNCDECL_RPL (readdir, struct dirent *, (DIR *dirp) _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (readdir, struct dirent *, (DIR *dirp)); +# else +# if !@HAVE_READDIR@ +_GL_FUNCDECL_SYS (readdir, struct dirent *, (DIR *dirp) _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (readdir, struct dirent *, (DIR *dirp)); +# endif +_GL_CXXALIASWARN (readdir); +#elif defined GNULIB_POSIXCHECK +# undef readdir +# if HAVE_RAW_DECL_READDIR +_GL_WARN_ON_USE (readdir, "readdir is not portable - " + "use gnulib module readdir for portability"); +# endif +#endif + +#if @GNULIB_REWINDDIR@ +# if @REPLACE_REWINDDIR@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef rewinddir +# define rewinddir rpl_rewinddir +# endif +_GL_FUNCDECL_RPL (rewinddir, void, (DIR *dirp) _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (rewinddir, void, (DIR *dirp)); +# else +# if !@HAVE_REWINDDIR@ +_GL_FUNCDECL_SYS (rewinddir, void, (DIR *dirp) _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (rewinddir, void, (DIR *dirp)); +# endif +_GL_CXXALIASWARN (rewinddir); +#elif defined GNULIB_POSIXCHECK +# undef rewinddir +# if HAVE_RAW_DECL_REWINDDIR +_GL_WARN_ON_USE (rewinddir, "rewinddir is not portable - " + "use gnulib module rewinddir for portability"); +# endif +#endif + +#if @GNULIB_DIRFD@ +/* Return the file descriptor associated with the given directory stream, + or -1 if none exists. */ +# if @REPLACE_DIRFD@ +/* On kLIBC, dirfd() is a macro that does not work. Undefine it. */ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) || defined dirfd +# undef dirfd +# define dirfd rpl_dirfd +# endif +_GL_FUNCDECL_RPL (dirfd, int, (DIR *) _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (dirfd, int, (DIR *)); + +# else +# if defined __cplusplus && defined GNULIB_NAMESPACE && defined dirfd + /* dirfd is defined as a macro and not as a function. + Turn it into a function and get rid of the macro. */ +static inline int (dirfd) (DIR *dp) { return dirfd (dp); } +# undef dirfd +# endif +# if !(@HAVE_DECL_DIRFD@ || defined dirfd) +_GL_FUNCDECL_SYS (dirfd, int, (DIR *) _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (dirfd, int, (DIR *)); +# endif +_GL_CXXALIASWARN (dirfd); +#elif defined GNULIB_POSIXCHECK +# undef dirfd +# if HAVE_RAW_DECL_DIRFD +_GL_WARN_ON_USE (dirfd, "dirfd is unportable - " + "use gnulib module dirfd for portability"); +# endif +#endif + +#if @GNULIB_FDOPENDIR@ +/* Open a directory stream visiting the given directory file + descriptor. Return NULL and set errno if fd is not visiting a + directory. On success, this function consumes fd (it will be + implicitly closed either by this function or by a subsequent + closedir). */ +# if @REPLACE_FDOPENDIR@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef fdopendir +# define fdopendir rpl_fdopendir +# endif +_GL_FUNCDECL_RPL (fdopendir, DIR *, + (int fd) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC (closedir, 1)); +_GL_CXXALIAS_RPL (fdopendir, DIR *, (int fd)); +# else +# if !@HAVE_FDOPENDIR@ || !@HAVE_DECL_FDOPENDIR@ || __GNUC__ >= 11 +_GL_FUNCDECL_SYS (fdopendir, DIR *, + (int fd) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC (closedir, 1)); +# endif +_GL_CXXALIAS_SYS (fdopendir, DIR *, (int fd)); +# endif +_GL_CXXALIASWARN (fdopendir); +#else +# if @GNULIB_CLOSEDIR@ && __GNUC__ >= 11 && !defined fdopendir +/* For -Wmismatched-dealloc: Associate fdopendir with closedir or + rpl_closedir. */ +_GL_FUNCDECL_SYS (fdopendir, DIR *, + (int fd) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC (closedir, 1)); +# endif +# if defined GNULIB_POSIXCHECK +# undef fdopendir +# if HAVE_RAW_DECL_FDOPENDIR +_GL_WARN_ON_USE (fdopendir, "fdopendir is unportable - " + "use gnulib module fdopendir for portability"); +# endif +# endif +#endif + +#if @GNULIB_SCANDIR@ +/* Scan the directory DIR, calling FILTER on each directory entry. + Entries for which FILTER returns nonzero are individually malloc'd, + sorted using qsort with CMP, and collected in a malloc'd array in + *NAMELIST. Returns the number of entries selected, or -1 on error. */ +# if !@HAVE_SCANDIR@ +_GL_FUNCDECL_SYS (scandir, int, + (const char *dir, struct dirent ***namelist, + int (*filter) (const struct dirent *), + int (*cmp) (const struct dirent **, const struct dirent **)) + _GL_ARG_NONNULL ((1, 2, 4))); +# endif +/* Need to cast, because on glibc systems, the fourth parameter is + int (*cmp) (const void *, const void *). */ +_GL_CXXALIAS_SYS_CAST (scandir, int, + (const char *dir, struct dirent ***namelist, + int (*filter) (const struct dirent *), + int (*cmp) (const struct dirent **, const struct dirent **))); +_GL_CXXALIASWARN (scandir); +#elif defined GNULIB_POSIXCHECK +# undef scandir +# if HAVE_RAW_DECL_SCANDIR +_GL_WARN_ON_USE (scandir, "scandir is unportable - " + "use gnulib module scandir for portability"); +# endif +#endif + +#if @GNULIB_ALPHASORT@ +/* Compare two 'struct dirent' entries alphabetically. */ +# if !@HAVE_ALPHASORT@ +_GL_FUNCDECL_SYS (alphasort, int, + (const struct dirent **, const struct dirent **) + _GL_ATTRIBUTE_PURE + _GL_ARG_NONNULL ((1, 2))); +# endif +/* Need to cast, because on glibc systems, the parameters are + (const void *, const void *). */ +_GL_CXXALIAS_SYS_CAST (alphasort, int, + (const struct dirent **, const struct dirent **)); +_GL_CXXALIASWARN (alphasort); +#elif defined GNULIB_POSIXCHECK +# undef alphasort +# if HAVE_RAW_DECL_ALPHASORT +_GL_WARN_ON_USE (alphasort, "alphasort is unportable - " + "use gnulib module alphasort for portability"); +# endif +#endif + + +#endif /* _@GUARD_PREFIX@_DIRENT_H */ +#endif /* _@GUARD_PREFIX@_DIRENT_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/dirfd.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/dirfd.c new file mode 100644 index 00000000..afcf382e --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/dirfd.c @@ -0,0 +1,44 @@ +/* dirfd.c -- return the file descriptor associated with an open DIR* + + Copyright (C) 2001, 2006, 2008-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Jim Meyering. */ + +#include + +#include +#include + +#if GNULIB_defined_DIR +# include "dirent-private.h" +#endif + +int +dirfd (DIR *dir_p) +{ +#if GNULIB_defined_DIR + int fd = dir_p->fd_to_close; + if (fd == -1) + errno = EINVAL; + return fd; +#else + int fd = DIR_TO_FD (dir_p); + if (fd == -1) + errno = ENOTSUP; + + return fd; +#endif +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/dirname-lgpl.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/dirname-lgpl.c new file mode 100644 index 00000000..8333c0eb --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/dirname-lgpl.c @@ -0,0 +1,86 @@ +/* dirname.c -- return all but the last element in a file name + + Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2024 Free Software + Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +#include "dirname.h" + +#include +#include + +/* Return the length of the prefix of FILE that will be used by + dir_name. If FILE is in the working directory, this returns zero + even though 'dir_name (FILE)' will return ".". Works properly even + if there are trailing slashes (by effectively ignoring them). */ + +size_t +dir_len (char const *file) +{ + size_t prefix_length = FILE_SYSTEM_PREFIX_LEN (file); + size_t length; + + /* Advance prefix_length beyond important leading slashes. */ + prefix_length += (prefix_length != 0 + ? (FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE + && ISSLASH (file[prefix_length])) + : (ISSLASH (file[0]) + ? ((DOUBLE_SLASH_IS_DISTINCT_ROOT + && ISSLASH (file[1]) && ! ISSLASH (file[2]) + ? 2 : 1)) + : 0)); + + /* Strip the basename and any redundant slashes before it. */ + for (length = last_component (file) - file; + prefix_length < length; length--) + if (! ISSLASH (file[length - 1])) + break; + return length; +} + + +/* In general, we can't use the builtin 'dirname' function if available, + since it has different meanings in different environments. + In some environments the builtin 'dirname' modifies its argument. + + Return the leading directories part of FILE, allocated with malloc. + Works properly even if there are trailing slashes (by effectively + ignoring them). Return NULL on failure. + + If lstat (FILE) would succeed, then { chdir (dir_name (FILE)); + lstat (base_name (FILE)); } will access the same file. Likewise, + if the sequence { chdir (dir_name (FILE)); + rename (base_name (FILE), "foo"); } succeeds, you have renamed FILE + to "foo" in the same directory FILE was in. */ + +char * +mdir_name (char const *file) +{ + size_t length = dir_len (file); + bool append_dot = (length == 0 + || (FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE + && length == FILE_SYSTEM_PREFIX_LEN (file) + && file[2] != '\0' && ! ISSLASH (file[2]))); + char *dir = malloc (length + append_dot + 1); + if (!dir) + return NULL; + memcpy (dir, file, length); + if (append_dot) + dir[length++] = '.'; + dir[length] = '\0'; + return dir; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/dirname.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/dirname.c new file mode 100644 index 00000000..393ec1b4 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/dirname.c @@ -0,0 +1,38 @@ +/* dirname.c -- return all but the last element in a file name + + Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2024 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 . */ + +#include + +#include "dirname.h" + +#include +#include +#include "xalloc.h" + +/* Just like mdir_name (dirname-lgpl.c), except, rather than + returning NULL upon malloc failure, here, we report the + "memory exhausted" condition and exit. */ + +char * +dir_name (char const *file) +{ + char *result = mdir_name (file); + if (!result) + xalloc_die (); + return result; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/dirname.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/dirname.h new file mode 100644 index 00000000..33935ba9 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/dirname.h @@ -0,0 +1,59 @@ +/* Take file names apart into directory and base names. + + Copyright (C) 1998, 2001, 2003-2006, 2009-2024 Free Software Foundation, + Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef DIRNAME_H_ +# define DIRNAME_H_ 1 + +/* This file uses _GL_ATTRIBUTE_MALLOC, _GL_ATTRIBUTE_PURE, + _GL_ATTRIBUTE_RETURNS_NONNULL. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +# include +# include "filename.h" +# include "basename-lgpl.h" + +# ifndef DIRECTORY_SEPARATOR +# define DIRECTORY_SEPARATOR '/' +# endif + +#ifdef __cplusplus +extern "C" { +#endif + +# if GNULIB_DIRNAME +char *base_name (char const *file) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE + _GL_ATTRIBUTE_RETURNS_NONNULL; +char *dir_name (char const *file) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE + _GL_ATTRIBUTE_RETURNS_NONNULL; +# endif + +char *mdir_name (char const *file) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE; +size_t dir_len (char const *file) _GL_ATTRIBUTE_PURE; + +bool strip_trailing_slashes (char *file); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* not DIRNAME_H_ */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/dup-safer-flag.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/dup-safer-flag.c new file mode 100644 index 00000000..ec2e311e --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/dup-safer-flag.c @@ -0,0 +1,38 @@ +/* Duplicate a file descriptor result, avoiding clobbering + STD{IN,OUT,ERR}_FILENO, with specific flags. + + Copyright (C) 2001, 2004-2006, 2009-2024 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 . */ + +/* Written by Paul Eggert and Eric Blake. */ + +#include + +/* Specification. */ +#include "unistd-safer.h" + +#include +#include + +/* Like dup, but do not return STDIN_FILENO, STDOUT_FILENO, or + STDERR_FILENO. If FLAG contains O_CLOEXEC, behave like + fcntl(F_DUPFD_CLOEXEC) rather than fcntl(F_DUPFD). */ + +int +dup_safer_flag (int fd, int flag) +{ + return fcntl (fd, (flag & O_CLOEXEC) ? F_DUPFD_CLOEXEC : F_DUPFD, + STDERR_FILENO + 1); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/dup-safer.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/dup-safer.c new file mode 100644 index 00000000..b0df2278 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/dup-safer.c @@ -0,0 +1,34 @@ +/* Invoke dup, but avoid some glitches. + + Copyright (C) 2001, 2004-2006, 2009-2024 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 . */ + +/* Written by Paul Eggert. */ + +#include + +#include "unistd-safer.h" + +#include +#include + +/* Like dup, but do not return STDIN_FILENO, STDOUT_FILENO, or + STDERR_FILENO. */ + +int +dup_safer (int fd) +{ + return fcntl (fd, F_DUPFD, STDERR_FILENO + 1); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/dup.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/dup.c new file mode 100644 index 00000000..db268036 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/dup.c @@ -0,0 +1,92 @@ +/* Duplicate an open file descriptor. + + Copyright (C) 2011-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +#include + +#if HAVE_MSVC_INVALID_PARAMETER_HANDLER +# include "msvc-inval.h" +#endif + +#undef dup + +#if defined _WIN32 && !defined __CYGWIN__ +# if HAVE_MSVC_INVALID_PARAMETER_HANDLER +static int +dup_nothrow (int fd) +{ + int result; + + TRY_MSVC_INVAL + { + result = _dup (fd); + } + CATCH_MSVC_INVAL + { + result = -1; + errno = EBADF; + } + DONE_MSVC_INVAL; + + return result; +} +# else +# define dup_nothrow _dup +# endif +#elif defined __KLIBC__ +# include +# include + +# include + +static int +dup_nothrow (int fd) +{ + int dupfd; + struct stat sbuf; + + dupfd = dup (fd); + if (dupfd == -1 && errno == ENOTSUP \ + && !fstat (fd, &sbuf) && S_ISDIR (sbuf.st_mode)) + { + char path[_MAX_PATH]; + + /* Get a path from fd */ + if (!__libc_Back_ioFHToPath (fd, path, sizeof (path))) + dupfd = open (path, O_RDONLY); + } + + return dupfd; +} +#else +# define dup_nothrow dup +#endif + +int +rpl_dup (int fd) +{ + int result = dup_nothrow (fd); +#if REPLACE_FCHDIR + if (result >= 0) + result = _gl_register_dup (fd, result); +#endif + return result; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/dup2.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/dup2.c new file mode 100644 index 00000000..916e113d --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/dup2.c @@ -0,0 +1,189 @@ +/* Duplicate an open file descriptor to a specified file descriptor. + + Copyright (C) 1999, 2004-2007, 2009-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* written by Paul Eggert */ + +#include + +/* Specification. */ +#include + +#include +#include + +#undef dup2 + +#if defined _WIN32 && ! defined __CYGWIN__ + +/* Get declarations of the native Windows API functions. */ +# define WIN32_LEAN_AND_MEAN +# include + +# if HAVE_MSVC_INVALID_PARAMETER_HANDLER +# include "msvc-inval.h" +# endif + +/* Get _get_osfhandle. */ +# if GNULIB_MSVC_NOTHROW +# include "msvc-nothrow.h" +# else +# include +# endif + +# if HAVE_MSVC_INVALID_PARAMETER_HANDLER +static int +dup2_nothrow (int fd, int desired_fd) +{ + int result; + + TRY_MSVC_INVAL + { + result = _dup2 (fd, desired_fd); + } + CATCH_MSVC_INVAL + { + errno = EBADF; + result = -1; + } + DONE_MSVC_INVAL; + + return result; +} +# else +# define dup2_nothrow _dup2 +# endif + +static int +ms_windows_dup2 (int fd, int desired_fd) +{ + int result; + + /* If fd is closed, mingw hangs on dup2 (fd, fd). If fd is open, + dup2 (fd, fd) returns 0, but all further attempts to use fd in + future dup2 calls will hang. */ + if (fd == desired_fd) + { + if ((HANDLE) _get_osfhandle (fd) == INVALID_HANDLE_VALUE) + { + errno = EBADF; + return -1; + } + return fd; + } + + /* Wine 1.0.1 return 0 when desired_fd is negative but not -1: + https://bugs.winehq.org/show_bug.cgi?id=21289 */ + if (desired_fd < 0) + { + errno = EBADF; + return -1; + } + + result = dup2_nothrow (fd, desired_fd); + + if (result == 0) + result = desired_fd; + + return result; +} + +# define dup2 ms_windows_dup2 + +#elif defined __KLIBC__ + +# include + +static int +klibc_dup2dirfd (int fd, int desired_fd) +{ + int tempfd; + int dupfd; + + tempfd = open ("NUL", O_RDONLY); + if (tempfd == -1) + return -1; + + if (tempfd == desired_fd) + { + close (tempfd); + + char path[_MAX_PATH]; + if (__libc_Back_ioFHToPath (fd, path, sizeof (path))) + return -1; + + return open(path, O_RDONLY); + } + + dupfd = klibc_dup2dirfd (fd, desired_fd); + + close (tempfd); + + return dupfd; +} + +static int +klibc_dup2 (int fd, int desired_fd) +{ + int dupfd; + struct stat sbuf; + + dupfd = dup2 (fd, desired_fd); + if (dupfd == -1 && errno == ENOTSUP \ + && !fstat (fd, &sbuf) && S_ISDIR (sbuf.st_mode)) + { + close (desired_fd); + + return klibc_dup2dirfd (fd, desired_fd); + } + + return dupfd; +} + +# define dup2 klibc_dup2 +#endif + +int +rpl_dup2 (int fd, int desired_fd) +{ + int result; + +#ifdef F_GETFL + /* On Linux kernels 2.6.26-2.6.29, dup2 (fd, fd) returns -EBADF. + On Cygwin 1.5.x, dup2 (1, 1) returns 0. + On Cygwin 1.7.17, dup2 (1, -1) dumps core. + On Cygwin 1.7.25, dup2 (1, 256) can dump core. + On Haiku, dup2 (fd, fd) mistakenly clears FD_CLOEXEC. */ +# if HAVE_SETDTABLESIZE + setdtablesize (desired_fd + 1); +# endif + if (desired_fd < 0) + fd = desired_fd; + if (fd == desired_fd) + return fcntl (fd, F_GETFL) == -1 ? -1 : fd; +#endif + + result = dup2 (fd, desired_fd); + + /* Correct an errno value on FreeBSD 6.1 and Cygwin 1.5.x. */ + if (result == -1 && errno == EMFILE) + errno = EBADF; +#if REPLACE_FCHDIR + if (fd != desired_fd && result != -1) + result = _gl_register_dup (fd, result); +#endif + return result; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/dynarray.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/dynarray.h new file mode 100644 index 00000000..8940e81b --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/dynarray.h @@ -0,0 +1,284 @@ +/* Type-safe arrays which grow dynamically. + Copyright 2021-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Paul Eggert and Bruno Haible, 2021. */ + +#ifndef _GL_DYNARRAY_H +#define _GL_DYNARRAY_H + +/* Before including this file, you need to define: + + DYNARRAY_STRUCT + The struct tag of dynamic array to be defined. + + DYNARRAY_ELEMENT + The type name of the element type. Elements are copied + as if by memcpy, and can change address as the dynamic + array grows. + + DYNARRAY_PREFIX + The prefix of the functions which are defined. + + The following parameters are optional: + + DYNARRAY_ELEMENT_FREE + DYNARRAY_ELEMENT_FREE (E) is evaluated to deallocate the + contents of elements. E is of type DYNARRAY_ELEMENT *. + + DYNARRAY_ELEMENT_INIT + DYNARRAY_ELEMENT_INIT (E) is evaluated to initialize a new + element. E is of type DYNARRAY_ELEMENT *. + If DYNARRAY_ELEMENT_FREE but not DYNARRAY_ELEMENT_INIT is + defined, new elements are automatically zero-initialized. + Otherwise, new elements have undefined contents. + + DYNARRAY_INITIAL_SIZE + The size of the statically allocated array (default: + at least 2, more elements if they fit into 128 bytes). + Must be a preprocessor constant. If DYNARRAY_INITIAL_SIZE is 0, + there is no statically allocated array at, and all non-empty + arrays are heap-allocated. + + DYNARRAY_FINAL_TYPE + The name of the type which holds the final array. If not + defined, is PREFIX##finalize not provided. DYNARRAY_FINAL_TYPE + must be a struct type, with members of type DYNARRAY_ELEMENT and + size_t at the start (in this order). + + These macros are undefined after this header file has been + included. + + The following types are provided (their members are private to the + dynarray implementation): + + struct DYNARRAY_STRUCT + + The following functions are provided: + */ + +/* Initialize a dynamic array object. This must be called before any + use of the object. */ +#if 0 +static void + DYNARRAY_PREFIX##init (struct DYNARRAY_STRUCT *list); +#endif + +/* Deallocate the dynamic array and its elements. */ +#if 0 +static void + DYNARRAY_PREFIX##free (struct DYNARRAY_STRUCT *list); +#endif + +/* Return true if the dynamic array is in an error state. */ +#if 0 +static bool + DYNARRAY_PREFIX##has_failed (const struct DYNARRAY_STRUCT *list); +#endif + +/* Mark the dynamic array as failed. All elements are deallocated as + a side effect. */ +#if 0 +static void + DYNARRAY_PREFIX##mark_failed (struct DYNARRAY_STRUCT *list); +#endif + +/* Return the number of elements which have been added to the dynamic + array. */ +#if 0 +static size_t + DYNARRAY_PREFIX##size (const struct DYNARRAY_STRUCT *list); +#endif + +/* Return a pointer to the first array element, if any. For a + zero-length array, the pointer can be NULL even though the dynamic + array has not entered the failure state. */ +#if 0 +static DYNARRAY_ELEMENT * + DYNARRAY_PREFIX##begin (const struct DYNARRAY_STRUCT *list); +#endif + +/* Return a pointer one element past the last array element. For a + zero-length array, the pointer can be NULL even though the dynamic + array has not entered the failure state. */ +#if 0 +static DYNARRAY_ELEMENT * + DYNARRAY_PREFIX##end (const struct DYNARRAY_STRUCT *list); +#endif + +/* Return a pointer to the array element at INDEX. Terminate the + process if INDEX is out of bounds. */ +#if 0 +static DYNARRAY_ELEMENT * + DYNARRAY_PREFIX##at (struct DYNARRAY_STRUCT *list, size_t index); +#endif + +/* Add ITEM at the end of the array, enlarging it by one element. + Mark *LIST as failed if the dynamic array allocation size cannot be + increased. */ +#if 0 +static void + DYNARRAY_PREFIX##add (struct DYNARRAY_STRUCT *list, + DYNARRAY_ELEMENT item); +#endif + +/* Allocate a place for a new element in *LIST and return a pointer to + it. The pointer can be NULL if the dynamic array cannot be + enlarged due to a memory allocation failure. */ +#if 0 +static DYNARRAY_ELEMENT * + DYNARRAY_PREFIX##emplace (struct DYNARRAY_STRUCT *list); +#endif + +/* Change the size of *LIST to SIZE. If SIZE is larger than the + existing size, new elements are added (which can be initialized). + Otherwise, the list is truncated, and elements are freed. Return + false on memory allocation failure (and mark *LIST as failed). */ +#if 0 +static bool + DYNARRAY_PREFIX##resize (struct DYNARRAY_STRUCT *list, size_t size); +#endif + +/* Remove the last element of LIST if it is present. */ +#if 0 +static void + DYNARRAY_PREFIX##remove_last (struct DYNARRAY_STRUCT *list); +#endif + +/* Remove all elements from the list. The elements are freed, but the + list itself is not. */ +#if 0 +static void + DYNARRAY_PREFIX##clear (struct DYNARRAY_STRUCT *list); +#endif + +#if defined DYNARRAY_FINAL_TYPE +/* Transfer the dynamic array to a permanent location at *RESULT. + Returns true on success on false on allocation failure. In either + case, *LIST is re-initialized and can be reused. A NULL pointer is + stored in *RESULT if LIST refers to an empty list. On success, the + pointer in *RESULT is heap-allocated and must be deallocated using + free. */ +#if 0 +static bool + DYNARRAY_PREFIX##finalize (struct DYNARRAY_STRUCT *list, + DYNARRAY_FINAL_TYPE *result); +#endif +#else /* !defined DYNARRAY_FINAL_TYPE */ +/* Transfer the dynamic array to a heap-allocated array and return a + pointer to it. The pointer is NULL if memory allocation fails, or + if the array is empty, so this function should be used only for + arrays which are known not be empty (usually because they always + have a sentinel at the end). If LENGTHP is not NULL, the array + length is written to *LENGTHP. *LIST is re-initialized and can be + reused. */ +#if 0 +static DYNARRAY_ELEMENT * + DYNARRAY_PREFIX##finalize (struct DYNARRAY_STRUCT *list, + size_t *lengthp); +#endif +#endif + +/* A minimal example which provides a growing list of integers can be + defined like this: + + struct int_array + { + // Pointer to result array followed by its length, + // as required by DYNARRAY_FINAL_TYPE. + int *array; + size_t length; + }; + + #define DYNARRAY_STRUCT dynarray_int + #define DYNARRAY_ELEMENT int + #define DYNARRAY_PREFIX dynarray_int_ + #define DYNARRAY_FINAL_TYPE struct int_array + #include + + To create a three-element array with elements 1, 2, 3, use this + code: + + struct dynarray_int dyn; + dynarray_int_init (&dyn); + for (int i = 1; i <= 3; ++i) + { + int *place = dynarray_int_emplace (&dyn); + assert (place != NULL); + *place = i; + } + struct int_array result; + bool ok = dynarray_int_finalize (&dyn, &result); + assert (ok); + assert (result.length == 3); + assert (result.array[0] == 1); + assert (result.array[1] == 2); + assert (result.array[2] == 3); + free (result.array); + + If the elements contain resources which must be freed, define + DYNARRAY_ELEMENT_FREE appropriately, like this: + + struct str_array + { + char **array; + size_t length; + }; + + #define DYNARRAY_STRUCT dynarray_str + #define DYNARRAY_ELEMENT char * + #define DYNARRAY_ELEMENT_FREE(ptr) free (*ptr) + #define DYNARRAY_PREFIX dynarray_str_ + #define DYNARRAY_FINAL_TYPE struct str_array + #include + */ + + +/* The implementation is imported from glibc. */ + +/* Avoid possible conflicts with symbols exported by the GNU libc. */ +#define __libc_dynarray_at_failure gl_dynarray_at_failure +#define __libc_dynarray_emplace_enlarge gl_dynarray_emplace_enlarge +#define __libc_dynarray_finalize gl_dynarray_finalize +#define __libc_dynarray_resize_clear gl_dynarray_resize_clear +#define __libc_dynarray_resize gl_dynarray_resize + +#if defined DYNARRAY_STRUCT || defined DYNARRAY_ELEMENT || defined DYNARRAY_PREFIX + +# ifndef _GL_LIKELY +/* Rely on __builtin_expect, as provided by the module 'builtin-expect'. */ +# define _GL_LIKELY(cond) __builtin_expect ((cond), 1) +# define _GL_UNLIKELY(cond) __builtin_expect ((cond), 0) +# endif + +/* Define auxiliary structs and declare auxiliary functions, common to all + instantiations of dynarray. */ +# include + +/* Define the instantiation, specified through + DYNARRAY_STRUCT + DYNARRAY_ELEMENT + DYNARRAY_PREFIX + etc. */ +# include + +#else + +/* This file is being included from one of the malloc/dynarray_*.c files. */ +# include + +#endif + +#endif /* _GL_DYNARRAY_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/errno.in.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/errno.in.h new file mode 100644 index 00000000..aa658e62 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/errno.in.h @@ -0,0 +1,279 @@ +/* A POSIX-like . + + Copyright (C) 2008-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef _@GUARD_PREFIX@_ERRNO_H + +#if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +#endif +@PRAGMA_COLUMNS@ + +/* The include_next requires a split double-inclusion guard. */ +#@INCLUDE_NEXT@ @NEXT_ERRNO_H@ + +#ifndef _@GUARD_PREFIX@_ERRNO_H +#define _@GUARD_PREFIX@_ERRNO_H + + +/* On native Windows platforms, many macros are not defined. */ +# if defined _WIN32 && ! defined __CYGWIN__ + +/* These are the same values as defined by MSVC 10, for interoperability. */ + +# ifndef ENOMSG +# define ENOMSG 122 +# define GNULIB_defined_ENOMSG 1 +# endif + +# ifndef EIDRM +# define EIDRM 111 +# define GNULIB_defined_EIDRM 1 +# endif + +# ifndef ENOLINK +# define ENOLINK 121 +# define GNULIB_defined_ENOLINK 1 +# endif + +# ifndef EPROTO +# define EPROTO 134 +# define GNULIB_defined_EPROTO 1 +# endif + +# ifndef EBADMSG +# define EBADMSG 104 +# define GNULIB_defined_EBADMSG 1 +# endif + +# ifndef EOVERFLOW +# define EOVERFLOW 132 +# define GNULIB_defined_EOVERFLOW 1 +# endif + +# ifndef ENOTSUP +# define ENOTSUP 129 +# define GNULIB_defined_ENOTSUP 1 +# endif + +# ifndef ENETRESET +# define ENETRESET 117 +# define GNULIB_defined_ENETRESET 1 +# endif + +# ifndef ECONNABORTED +# define ECONNABORTED 106 +# define GNULIB_defined_ECONNABORTED 1 +# endif + +# ifndef ECANCELED +# define ECANCELED 105 +# define GNULIB_defined_ECANCELED 1 +# endif + +# ifndef EOWNERDEAD +# define EOWNERDEAD 133 +# define GNULIB_defined_EOWNERDEAD 1 +# endif + +# ifndef ENOTRECOVERABLE +# define ENOTRECOVERABLE 127 +# define GNULIB_defined_ENOTRECOVERABLE 1 +# endif + +# ifndef EINPROGRESS +# define EINPROGRESS 112 +# define EALREADY 103 +# define ENOTSOCK 128 +# define EDESTADDRREQ 109 +# define EMSGSIZE 115 +# define EPROTOTYPE 136 +# define ENOPROTOOPT 123 +# define EPROTONOSUPPORT 135 +# define EOPNOTSUPP 130 +# define EAFNOSUPPORT 102 +# define EADDRINUSE 100 +# define EADDRNOTAVAIL 101 +# define ENETDOWN 116 +# define ENETUNREACH 118 +# define ECONNRESET 108 +# define ENOBUFS 119 +# define EISCONN 113 +# define ENOTCONN 126 +# define ETIMEDOUT 138 +# define ECONNREFUSED 107 +# define ELOOP 114 +# define EHOSTUNREACH 110 +# define EWOULDBLOCK 140 +# define GNULIB_defined_ESOCK 1 +# endif + +# ifndef ETXTBSY +# define ETXTBSY 139 +# define ENODATA 120 /* not required by POSIX */ +# define ENOSR 124 /* not required by POSIX */ +# define ENOSTR 125 /* not required by POSIX */ +# define ETIME 137 /* not required by POSIX */ +# define EOTHER 131 /* not required by POSIX */ +# define GNULIB_defined_ESTREAMS 1 +# endif + +/* These are intentionally the same values as the WSA* error numbers, defined + in . */ +# define ESOCKTNOSUPPORT 10044 /* not required by POSIX */ +# define EPFNOSUPPORT 10046 /* not required by POSIX */ +# define ESHUTDOWN 10058 /* not required by POSIX */ +# define ETOOMANYREFS 10059 /* not required by POSIX */ +# define EHOSTDOWN 10064 /* not required by POSIX */ +# define EPROCLIM 10067 /* not required by POSIX */ +# define EUSERS 10068 /* not required by POSIX */ +# define EDQUOT 10069 +# define ESTALE 10070 +# define EREMOTE 10071 /* not required by POSIX */ +# define GNULIB_defined_EWINSOCK 1 + +# endif + + +/* On OSF/1 5.1, when _XOPEN_SOURCE_EXTENDED is not defined, the macros + EMULTIHOP, ENOLINK, EOVERFLOW are not defined. */ +# if @EMULTIHOP_HIDDEN@ +# define EMULTIHOP @EMULTIHOP_VALUE@ +# define GNULIB_defined_EMULTIHOP 1 +# endif +# if @ENOLINK_HIDDEN@ +# define ENOLINK @ENOLINK_VALUE@ +# define GNULIB_defined_ENOLINK 1 +# endif +# if @EOVERFLOW_HIDDEN@ +# define EOVERFLOW @EOVERFLOW_VALUE@ +# define GNULIB_defined_EOVERFLOW 1 +# endif + + +/* On OpenBSD 4.0 and on native Windows, the macros ENOMSG, EIDRM, ENOLINK, + EPROTO, EMULTIHOP, EBADMSG, EOVERFLOW, ENOTSUP, ECANCELED are not defined. + Likewise, on NonStop Kernel, EDQUOT is not defined. + Define them here. Values >= 2000 seem safe to use: Solaris ESTALE = 151, + HP-UX EWOULDBLOCK = 246, IRIX EDQUOT = 1133. + + Note: When one of these systems defines some of these macros some day, + binaries will have to be recompiled so that they recognizes the new + errno values from the system. */ + +# ifndef ENOMSG +# define ENOMSG 2000 +# define GNULIB_defined_ENOMSG 1 +# endif + +# ifndef EIDRM +# define EIDRM 2001 +# define GNULIB_defined_EIDRM 1 +# endif + +# ifndef ENOLINK +# define ENOLINK 2002 +# define GNULIB_defined_ENOLINK 1 +# endif + +# ifndef EPROTO +# define EPROTO 2003 +# define GNULIB_defined_EPROTO 1 +# endif + +# ifndef EMULTIHOP +# define EMULTIHOP 2004 +# define GNULIB_defined_EMULTIHOP 1 +# endif + +# ifndef EBADMSG +# define EBADMSG 2005 +# define GNULIB_defined_EBADMSG 1 +# endif + +# ifndef EOVERFLOW +# define EOVERFLOW 2006 +# define GNULIB_defined_EOVERFLOW 1 +# endif + +# ifndef ENOTSUP +# define ENOTSUP 2007 +# define GNULIB_defined_ENOTSUP 1 +# endif + +# ifndef ENETRESET +# define ENETRESET 2011 +# define GNULIB_defined_ENETRESET 1 +# endif + +# ifndef ECONNABORTED +# define ECONNABORTED 2012 +# define GNULIB_defined_ECONNABORTED 1 +# endif + +# ifndef ESTALE +# define ESTALE 2009 +# define GNULIB_defined_ESTALE 1 +# endif + +# ifndef EDQUOT +# define EDQUOT 2010 +# define GNULIB_defined_EDQUOT 1 +# endif + +# ifndef ECANCELED +# define ECANCELED 2008 +# define GNULIB_defined_ECANCELED 1 +# endif + +/* On many platforms, the macros EOWNERDEAD and ENOTRECOVERABLE are not + defined. */ + +# ifndef EOWNERDEAD +# if defined __sun + /* Use the same values as defined for Solaris >= 8, for + interoperability. */ +# define EOWNERDEAD 58 +# define ENOTRECOVERABLE 59 +# elif defined _WIN32 && ! defined __CYGWIN__ + /* We have a conflict here: pthreads-win32 defines these values + differently than MSVC 10. It's hairy to decide which one to use. */ +# if defined __MINGW32__ && !defined USE_WINDOWS_THREADS + /* Use the same values as defined by pthreads-win32, for + interoperability. */ +# define EOWNERDEAD 43 +# define ENOTRECOVERABLE 44 +# else + /* Use the same values as defined by MSVC 10, for + interoperability. */ +# define EOWNERDEAD 133 +# define ENOTRECOVERABLE 127 +# endif +# else +# define EOWNERDEAD 2013 +# define ENOTRECOVERABLE 2014 +# endif +# define GNULIB_defined_EOWNERDEAD 1 +# define GNULIB_defined_ENOTRECOVERABLE 1 +# endif + +# ifndef EILSEQ +# define EILSEQ 2015 +# define GNULIB_defined_EILSEQ 1 +# endif + +#endif /* _@GUARD_PREFIX@_ERRNO_H */ +#endif /* _@GUARD_PREFIX@_ERRNO_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/error.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/error.c new file mode 100644 index 00000000..c53dfeb6 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/error.c @@ -0,0 +1,410 @@ +/* Error handler for noninteractive utilities + Copyright (C) 1990-1998, 2000-2007, 2009-2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by David MacKenzie . */ + +#if !_LIBC +# include +# define _GL_NO_INLINE_ERROR +#endif + +#include + +#include +#include +#include +#include + +#if !_LIBC && ENABLE_NLS +# include "gettext.h" +# define _(msgid) gettext (msgid) +#endif + +#ifdef _LIBC +# include +# include +# include +# include +# define mbsrtowcs __mbsrtowcs +# define USE_UNLOCKED_IO 0 +# define _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD(a, b) +# define _GL_ARG_NONNULL(a) +#endif + +#if USE_UNLOCKED_IO +# include "unlocked-io.h" +#endif + +#ifndef _ +# define _(String) String +#endif + +/* If NULL, error will flush stdout, then print on stderr the program + name, a colon and a space. Otherwise, error will call this + function without parameters instead. */ +void (*error_print_progname) (void); + +/* This variable is incremented each time 'error' is called. */ +unsigned int error_message_count; + +#ifdef _LIBC +/* In the GNU C library, there is a predefined variable for this. */ + +# define program_name program_invocation_name +# include +# include +# include + +/* In GNU libc we want do not want to use the common name 'error' directly. + Instead make it a weak alias. */ +extern void __error (int status, int errnum, const char *message, ...) + __attribute__ ((__format__ (__printf__, 3, 4))); +extern void __error_at_line (int status, int errnum, const char *file_name, + unsigned int line_number, const char *message, + ...) + __attribute__ ((__format__ (__printf__, 5, 6))); +# define error __error +# define error_at_line __error_at_line + +# include +# define fflush(s) _IO_fflush (s) +# undef putc +# define putc(c, fp) _IO_putc (c, fp) + +# include + +#else /* not _LIBC */ + +# include +# include + +# if defined _WIN32 && ! defined __CYGWIN__ +/* Get declarations of the native Windows API functions. */ +# define WIN32_LEAN_AND_MEAN +# include +/* Get _get_osfhandle. */ +# if GNULIB_MSVC_NOTHROW +# include "msvc-nothrow.h" +# else +# include +# endif +# endif + +/* The gnulib override of fcntl is not needed in this file. */ +# undef fcntl + +# if !(GNULIB_STRERROR_R_POSIX || HAVE_DECL_STRERROR_R) +# ifndef HAVE_DECL_STRERROR_R +"this configure-time declaration test was not run" +# endif +# if STRERROR_R_CHAR_P +char *strerror_r (int errnum, char *buf, size_t buflen); +# else +int strerror_r (int errnum, char *buf, size_t buflen); +# endif +# endif + +# define program_name getprogname () + +# if GNULIB_STRERROR_R_POSIX || HAVE_STRERROR_R || defined strerror_r +# define __strerror_r strerror_r +# endif /* GNULIB_STRERROR_R_POSIX || HAVE_STRERROR_R || defined strerror_r */ +#endif /* not _LIBC */ + +#if !_LIBC +/* Return non-zero if FD is open. */ +static int +is_open (int fd) +{ +# if defined _WIN32 && ! defined __CYGWIN__ + /* On native Windows: The initial state of unassigned standard file + descriptors is that they are open but point to an INVALID_HANDLE_VALUE. + There is no fcntl, and the gnulib replacement fcntl does not support + F_GETFL. */ + return (HANDLE) _get_osfhandle (fd) != INVALID_HANDLE_VALUE; +# else +# ifndef F_GETFL +# error Please port fcntl to your platform +# endif + return 0 <= fcntl (fd, F_GETFL); +# endif +} +#endif + +static void +flush_stdout (void) +{ +#if !_LIBC + int stdout_fd; + +# if GNULIB_FREOPEN_SAFER + /* Use of gnulib's freopen-safer module normally ensures that + fileno (stdout) == 1 + whenever stdout is open. */ + stdout_fd = STDOUT_FILENO; +# else + /* POSIX states that fileno (stdout) after fclose is unspecified. But in + practice it is not a problem, because stdout is statically allocated and + the fd of a FILE stream is stored as a field in its allocated memory. */ + stdout_fd = fileno (stdout); +# endif + /* POSIX states that fflush (stdout) after fclose is unspecified; it + is safe in glibc, but not on all other platforms. fflush (NULL) + is always defined, but too draconian. */ + if (0 <= stdout_fd && is_open (stdout_fd)) +#endif + fflush (stdout); +} + +static void +print_errno_message (int errnum) +{ + char const *s; + +#if _LIBC || GNULIB_STRERROR_R_POSIX || defined HAVE_STRERROR_R + char errbuf[1024]; +# if _LIBC || (!GNULIB_STRERROR_R_POSIX && STRERROR_R_CHAR_P) + s = __strerror_r (errnum, errbuf, sizeof errbuf); +# else + if (__strerror_r (errnum, errbuf, sizeof errbuf) == 0) + s = errbuf; + else + s = 0; +# endif +#else + s = strerror (errnum); +#endif + +#if !_LIBC + if (! s) + s = _("Unknown system error"); +#endif + +#if _LIBC + __fxprintf (NULL, ": %s", s); +#else + fprintf (stderr, ": %s", s); +#endif +} + +static void _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 0) _GL_ARG_NONNULL ((3)) +error_tail (int status, int errnum, const char *message, va_list args) +{ +#if _LIBC + if (_IO_fwide (stderr, 0) > 0) + { + size_t len = strlen (message) + 1; + wchar_t *wmessage = NULL; + mbstate_t st; + size_t res; + const char *tmp; + bool use_malloc = false; + + while (1) + { + if (__libc_use_alloca (len * sizeof (wchar_t))) + wmessage = (wchar_t *) alloca (len * sizeof (wchar_t)); + else + { + if (!use_malloc) + wmessage = NULL; + + wchar_t *p = (wchar_t *) realloc (wmessage, + len * sizeof (wchar_t)); + if (p == NULL) + { + free (wmessage); + fputws_unlocked (L"out of memory\n", stderr); + return; + } + wmessage = p; + use_malloc = true; + } + + memset (&st, '\0', sizeof (st)); + tmp = message; + + res = mbsrtowcs (wmessage, &tmp, len, &st); + if (res != len) + break; + + if (__builtin_expect (len >= SIZE_MAX / sizeof (wchar_t) / 2, 0)) + { + /* This really should not happen if everything is fine. */ + res = (size_t) -1; + break; + } + + len *= 2; + } + + if (res == (size_t) -1) + { + /* The string cannot be converted. */ + if (use_malloc) + { + free (wmessage); + use_malloc = false; + } + wmessage = (wchar_t *) L"???"; + } + + __vfwprintf (stderr, wmessage, args); + + if (use_malloc) + free (wmessage); + } + else +#endif + vfprintf (stderr, message, args); + + ++error_message_count; + if (errnum) + print_errno_message (errnum); +#if _LIBC + __fxprintf (NULL, "\n"); +#else + putc ('\n', stderr); +#endif + fflush (stderr); + if (status) + exit (status); +} + + +/* Print the program name and error message MESSAGE, which is a printf-style + format string with optional args. + If ERRNUM is nonzero, print its corresponding system error message. + Exit with status STATUS if it is nonzero. */ +void +error (int status, int errnum, const char *message, ...) +{ + va_list args; + +#if defined _LIBC && defined __libc_ptf_call + /* We do not want this call to be cut short by a thread + cancellation. Therefore disable cancellation for now. */ + int state = PTHREAD_CANCEL_ENABLE; + __libc_ptf_call (pthread_setcancelstate, (PTHREAD_CANCEL_DISABLE, &state), + 0); +#endif + + flush_stdout (); +#ifdef _LIBC + _IO_flockfile (stderr); +#endif + if (error_print_progname) + (*error_print_progname) (); + else + { +#if _LIBC + __fxprintf (NULL, "%s: ", program_name); +#else + fprintf (stderr, "%s: ", program_name); +#endif + } + + va_start (args, message); + error_tail (status, errnum, message, args); + va_end (args); + +#ifdef _LIBC + _IO_funlockfile (stderr); +# ifdef __libc_ptf_call + __libc_ptf_call (pthread_setcancelstate, (state, NULL), 0); +# endif +#endif +} + +/* Sometimes we want to have at most one error per line. This + variable controls whether this mode is selected or not. */ +int error_one_per_line; + +void +error_at_line (int status, int errnum, const char *file_name, + unsigned int line_number, const char *message, ...) +{ + va_list args; + + if (error_one_per_line) + { + static const char *old_file_name; + static unsigned int old_line_number; + + if (old_line_number == line_number + && (file_name == old_file_name + || (old_file_name != NULL + && file_name != NULL + && strcmp (old_file_name, file_name) == 0))) + + /* Simply return and print nothing. */ + return; + + old_file_name = file_name; + old_line_number = line_number; + } + +#if defined _LIBC && defined __libc_ptf_call + /* We do not want this call to be cut short by a thread + cancellation. Therefore disable cancellation for now. */ + int state = PTHREAD_CANCEL_ENABLE; + __libc_ptf_call (pthread_setcancelstate, (PTHREAD_CANCEL_DISABLE, &state), + 0); +#endif + + flush_stdout (); +#ifdef _LIBC + _IO_flockfile (stderr); +#endif + if (error_print_progname) + (*error_print_progname) (); + else + { +#if _LIBC + __fxprintf (NULL, "%s:", program_name); +#else + fprintf (stderr, "%s:", program_name); +#endif + } + +#if _LIBC + __fxprintf (NULL, file_name != NULL ? "%s:%u: " : " ", + file_name, line_number); +#else + fprintf (stderr, file_name != NULL ? "%s:%u: " : " ", + file_name, line_number); +#endif + + va_start (args, message); + error_tail (status, errnum, message, args); + va_end (args); + +#ifdef _LIBC + _IO_funlockfile (stderr); +# ifdef __libc_ptf_call + __libc_ptf_call (pthread_setcancelstate, (state, NULL), 0); +# endif +#endif +} + +#ifdef _LIBC +/* Make the weak alias. */ +# undef error +# undef error_at_line +weak_alias (__error, error) +weak_alias (__error_at_line, error_at_line) +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/error.in.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/error.in.h new file mode 100644 index 00000000..51f8cafd --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/error.in.h @@ -0,0 +1,216 @@ +/* Declarations for error-reporting functions. + Copyright (C) 1995-1997, 2003, 2006, 2008-2024 Free Software Foundation, + Inc. + This file is part of the GNU C Library. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef _@GUARD_PREFIX@_ERROR_H + +/* No @PRAGMA_SYSTEM_HEADER@ here, because it would prevent + -Wimplicit-fallthrough warnings for missing FALLTHROUGH after error(...) + or error_at_line(...) invocations. */ + +/* The include_next requires a split double-inclusion guard. */ +#if @HAVE_ERROR_H@ +# @INCLUDE_NEXT@ @NEXT_ERROR_H@ +#endif + +#ifndef _@GUARD_PREFIX@_ERROR_H +#define _@GUARD_PREFIX@_ERROR_H + +/* This file uses _GL_ATTRIBUTE_ALWAYS_INLINE, _GL_ATTRIBUTE_FORMAT, + _GL_ATTRIBUTE_MAYBE_UNUSED. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +/* Get 'unreachable'. */ +#include + +/* Get _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, _GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM. */ +#include + +/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ + +#if GNULIB_VFPRINTF_POSIX +# define _GL_ATTRIBUTE_SPEC_PRINTF_ERROR _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD +#else +# define _GL_ATTRIBUTE_SPEC_PRINTF_ERROR _GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM +#endif + +/* Helper macro for supporting the compiler's control flow analysis better. + It evaluates its arguments only once. + Test case: Compile copy-file.c with "gcc -Wimplicit-fallthrough". */ +#if defined __GNUC__ || defined __clang__ +/* Use 'unreachable' to tell the compiler when the function call does not + return. */ +# define __gl_error_call1(function, status, ...) \ + ((function) (status, __VA_ARGS__), \ + (status) != 0 ? unreachable () : (void) 0) +/* If STATUS is a not a constant, the function call may or may not return; + therefore -Wimplicit-fallthrough will produce a warning. Use a compound + statement in order to evaluate STATUS only once. + If STATUS is a constant, we don't use a compound statement, because that + would trigger a -Wimplicit-fallthrough warning even when STATUS is != 0, + when not optimizing. This causes STATUS to be evaluated twice, but + that's OK since it does not have side effects. */ +# define __gl_error_call(function, status, ...) \ + (__builtin_constant_p (status) \ + ? __gl_error_call1 (function, status, __VA_ARGS__) \ + : __extension__ \ + ({ \ + int const __errstatus = status; \ + __gl_error_call1 (function, __errstatus, __VA_ARGS__); \ + })) +#else +# define __gl_error_call(function, status, ...) \ + (function) (status, __VA_ARGS__) +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* Print a message with 'fprintf (stderr, FORMAT, ...)'; + if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM). + If STATUS is nonzero, terminate the program with 'exit (STATUS)'. */ +#if @REPLACE_ERROR@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef error +# define error rpl_error +# endif +_GL_FUNCDECL_RPL (error, void, + (int __status, int __errnum, const char *__format, ...) + _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_ERROR, 3, 4))); +_GL_CXXALIAS_RPL (error, void, + (int __status, int __errnum, const char *__format, ...)); +# ifndef _GL_NO_INLINE_ERROR +# undef error +# define error(status, ...) \ + __gl_error_call (rpl_error, status, __VA_ARGS__) +# endif +#else +# if ! @HAVE_ERROR@ +_GL_FUNCDECL_SYS (error, void, + (int __status, int __errnum, const char *__format, ...) + _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_ERROR, 3, 4))); +# endif +_GL_CXXALIAS_SYS (error, void, + (int __status, int __errnum, const char *__format, ...)); +# ifndef _GL_NO_INLINE_ERROR +# ifdef error +/* Only gcc ≥ 4.7 has __builtin_va_arg_pack. */ +# if _GL_GNUC_PREREQ (4, 7) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wattributes" +_GL_ATTRIBUTE_MAYBE_UNUSED +static void +_GL_ATTRIBUTE_ALWAYS_INLINE +_GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_ERROR, 3, 4)) +_gl_inline_error (int __status, int __errnum, const char *__format, ...) +{ + return error (__status, __errnum, __format, __builtin_va_arg_pack ()); +} +# pragma GCC diagnostic pop +# undef error +# define error(status, ...) \ + __gl_error_call (_gl_inline_error, status, __VA_ARGS__) +# endif +# else +# define error(status, ...) \ + __gl_error_call (error, status, __VA_ARGS__) +# endif +# endif +#endif +#if __GLIBC__ >= 2 +_GL_CXXALIASWARN (error); +#endif + +/* Likewise. If FILENAME is non-NULL, include FILENAME:LINENO: in the + message. */ +#if @REPLACE_ERROR_AT_LINE@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef error_at_line +# define error_at_line rpl_error_at_line +# endif +_GL_FUNCDECL_RPL (error_at_line, void, + (int __status, int __errnum, const char *__filename, + unsigned int __lineno, const char *__format, ...) + _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_ERROR, 5, 6))); +_GL_CXXALIAS_RPL (error_at_line, void, + (int __status, int __errnum, const char *__filename, + unsigned int __lineno, const char *__format, ...)); +# ifndef _GL_NO_INLINE_ERROR +# undef error_at_line +# define error_at_line(status, ...) \ + __gl_error_call (rpl_error_at_line, status, __VA_ARGS__) +# endif +#else +# if ! @HAVE_ERROR_AT_LINE@ +_GL_FUNCDECL_SYS (error_at_line, void, + (int __status, int __errnum, const char *__filename, + unsigned int __lineno, const char *__format, ...) + _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_ERROR, 5, 6))); +# endif +_GL_CXXALIAS_SYS (error_at_line, void, + (int __status, int __errnum, const char *__filename, + unsigned int __lineno, const char *__format, ...)); +# ifndef _GL_NO_INLINE_ERROR +# ifdef error_at_line +/* Only gcc ≥ 4.7 has __builtin_va_arg_pack. */ +# if _GL_GNUC_PREREQ (4, 7) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wattributes" +_GL_ATTRIBUTE_MAYBE_UNUSED +static void +_GL_ATTRIBUTE_ALWAYS_INLINE +_GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_ERROR, 5, 6)) +_gl_inline_error_at_line (int __status, int __errnum, const char *__filename, + unsigned int __lineno, const char *__format, ...) +{ + return error_at_line (__status, __errnum, __filename, __lineno, __format, + __builtin_va_arg_pack ()); +} +# pragma GCC diagnostic pop +# undef error_at_line +# define error_at_line(status, ...) \ + __gl_error_call (_gl_inline_error_at_line, status, __VA_ARGS__) +# endif +# else +# define error_at_line(status, ...) \ + __gl_error_call (error_at_line, status, __VA_ARGS__) +# endif +# endif +#endif +_GL_CXXALIASWARN (error_at_line); + +/* If NULL, error will flush stdout, then print on stderr the program + name, a colon and a space. Otherwise, error will call this + function without parameters instead. */ +extern void (*error_print_progname) (void); + +/* This variable is incremented each time 'error' is called. */ +extern unsigned int error_message_count; + +/* Sometimes we want to have at most one error per line. This + variable controls whether this mode is selected or not. */ +extern int error_one_per_line; + +#ifdef __cplusplus +} +#endif + +#endif /* _@GUARD_PREFIX@_ERROR_H */ +#endif /* _@GUARD_PREFIX@_ERROR_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/exclude.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/exclude.c new file mode 100644 index 00000000..568d1ec1 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/exclude.c @@ -0,0 +1,673 @@ +/* exclude.c -- exclude file names + + Copyright (C) 1992-1994, 1997, 1999-2007, 2009-2024 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 . */ + +/* Written by Paul Eggert + and Sergey Poznyakoff . + Thanks to Phil Proudman + for improvement suggestions. */ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "exclude.h" +#include "filename.h" +#include +#include "hash.h" +#if GNULIB_MCEL_PREFER +# include "mcel.h" +#else +# include "mbuiter.h" +#endif +#include "xalloc.h" + +#if GNULIB_EXCLUDE_SINGLE_THREAD +# include "unlocked-io.h" +#endif + +/* Non-GNU systems lack these options, so we don't need to check them. */ +#ifndef FNM_CASEFOLD +# define FNM_CASEFOLD 0 +#endif +#ifndef FNM_EXTMATCH +# define FNM_EXTMATCH 0 +#endif +#ifndef FNM_LEADING_DIR +# define FNM_LEADING_DIR 0 +#endif + +static_assert (((EXCLUDE_ANCHORED | EXCLUDE_INCLUDE | EXCLUDE_WILDCARDS) + & (FNM_PATHNAME | FNM_NOESCAPE | FNM_PERIOD | FNM_LEADING_DIR + | FNM_CASEFOLD | FNM_EXTMATCH)) + == 0); + + +/* Exclusion patterns are grouped into a singly-linked list of + "exclusion segments". Each segment represents a set of patterns + that can be matches using the same algorithm. Non-wildcard + patterns are kept in hash tables, to speed up searches. Wildcard + patterns are stored as arrays of patterns. */ + + +/* An exclude pattern-options pair. The options are fnmatch options + ORed with EXCLUDE_* options. */ + +struct patopts + { + int options; + union + { + char const *pattern; + regex_t re; + } v; + }; + +/* An array of pattern-options pairs. */ + +struct exclude_pattern + { + struct patopts *exclude; + idx_t exclude_alloc; + idx_t exclude_count; + }; + +enum exclude_type + { + exclude_hash, /* a hash table of excluded names */ + exclude_pattern /* an array of exclude patterns */ + }; + +struct exclude_segment + { + struct exclude_segment *next; /* next segment in list */ + enum exclude_type type; /* type of this segment */ + int options; /* common options for this segment */ + union + { + Hash_table *table; /* for type == exclude_hash */ + struct exclude_pattern pat; /* for type == exclude_pattern */ + } v; + }; + +struct pattern_buffer + { + struct pattern_buffer *next; + char *base; + }; + +/* The exclude structure keeps a singly-linked list of exclude segments, + maintained in reverse order. */ +struct exclude + { + struct exclude_segment *head; + struct pattern_buffer *patbuf; + }; + +/* Register BUF in the pattern buffer list of EX. ADD_FUNC (see + add_exclude_file and add_exclude_fp below) can use this function + if it modifies the pattern, to ensure the allocated memory will be + properly reclaimed upon calling free_exclude. */ +void +exclude_add_pattern_buffer (struct exclude *ex, char *buf) +{ + struct pattern_buffer *pbuf = xmalloc (sizeof *pbuf); + pbuf->base = buf; + pbuf->next = ex->patbuf; + ex->patbuf = pbuf; +} + +/* Return true if STR has or may have wildcards, when matched with OPTIONS. + Return false if STR definitely does not have wildcards. */ +bool +fnmatch_pattern_has_wildcards (const char *str, int options) +{ + while (true) + { + switch (*str++) + { + case '.': + case '{': + case '}': + case '(': + case ')': + if (options & EXCLUDE_REGEX) + return true; + break; + + case '\\': + if (options & EXCLUDE_REGEX) + continue; + else + str += ! (options & FNM_NOESCAPE) && *str; + break; + + case '+': case '@': case '!': + if (options & FNM_EXTMATCH && *str == '(') + return true; + break; + + case '?': case '*': case '[': + return true; + + case '\0': + return false; + } + } +} + +static void +unescape_pattern (char *str) +{ + char const *q = str; + do + q += *q == '\\' && q[1]; + while ((*str++ = *q++)); +} + +/* Return a newly allocated and empty exclude list. */ + +struct exclude * +new_exclude (void) +{ + return xzalloc (sizeof *new_exclude ()); +} + +/* Calculate the hash of string. */ +static size_t +string_hasher (void const *data, size_t n_buckets) +{ + return hash_string (data, n_buckets); +} + +/* Ditto, for case-insensitive hashes */ +static size_t +string_hasher_ci (void const *data, size_t n_buckets) +{ + char const *p = data; + size_t value = 0; + +#if GNULIB_MCEL_PREFER + while (*p) + { + mcel_t g = mcel_scanz (p); + value = value * 31 + (c32tolower (g.ch) - g.err); + p += g.len; + } +#else + mbui_iterator_t iter; + + for (mbui_init (iter, p); mbui_avail (iter); mbui_advance (iter)) + { + mbchar_t m = mbui_cur (iter); + char32_t wc; + + if (m.wc_valid) + wc = c32tolower (m.wc); + else + wc = *m.ptr; + + value = value * 31 + wc; + } +#endif + + return value % n_buckets; +} + +/* compare two strings for equality */ +static bool +string_compare (void const *data1, void const *data2) +{ + return strcmp (data1, data2) == 0; +} + +/* compare two strings for equality, case-insensitive */ +static bool +string_compare_ci (void const *data1, void const *data2) +{ + return mbscasecmp (data1, data2) == 0; +} + +/* Create new exclude segment of given TYPE and OPTIONS, and attach it + to the head of EX. */ +static void +new_exclude_segment (struct exclude *ex, enum exclude_type type, int options) +{ + struct exclude_segment *sp = xmalloc (sizeof (struct exclude_segment)); + sp->type = type; + sp->options = options; + switch (type) + { + case exclude_pattern: + sp->v.pat = (struct exclude_pattern) {0}; + break; + + case exclude_hash: + sp->v.table = hash_initialize (0, nullptr, + (options & FNM_CASEFOLD + ? string_hasher_ci + : string_hasher), + (options & FNM_CASEFOLD + ? string_compare_ci + : string_compare), + free); + break; + } + sp->next = ex->head; + ex->head = sp; +} + +/* Free a single exclude segment */ +static void +free_exclude_segment (struct exclude_segment *seg) +{ + switch (seg->type) + { + case exclude_pattern: + for (idx_t i = 0; i < seg->v.pat.exclude_count; i++) + if (seg->v.pat.exclude[i].options & EXCLUDE_REGEX) + regfree (&seg->v.pat.exclude[i].v.re); + free (seg->v.pat.exclude); + break; + + case exclude_hash: + hash_free (seg->v.table); + break; + } + free (seg); +} + +/* Free the storage associated with an exclude list. */ +void +free_exclude (struct exclude *ex) +{ + for (struct exclude_segment *seg = ex->head; seg; ) + { + struct exclude_segment *next = seg->next; + free_exclude_segment (seg); + seg = next; + } + + for (struct pattern_buffer *pbuf = ex->patbuf; pbuf; ) + { + struct pattern_buffer *next = pbuf->next; + free (pbuf->base); + free (pbuf); + pbuf = next; + } + + free (ex); +} + +/* Return zero if PATTERN matches F, obeying OPTIONS, except that + (unlike fnmatch) wildcards are disabled in PATTERN. */ + +static int +fnmatch_no_wildcards (char const *pattern, char const *f, int options) +{ + if (! (options & FNM_LEADING_DIR)) + return ((options & FNM_CASEFOLD) + ? mbscasecmp (pattern, f) + : strcmp (pattern, f)); + else if (! (options & FNM_CASEFOLD)) + { + idx_t patlen = strlen (pattern); + int r = strncmp (pattern, f, patlen); + if (! r) + { + r = f[patlen]; + if (r == '/') + r = 0; + } + return r; + } + else + { + /* Walk through a copy of F, seeing whether P matches any prefix + of F. + + FIXME: This is an O(N**2) algorithm; it should be O(N). + Also, the copy should not be necessary. However, fixing this + will probably involve a change to the mbs* API. */ + + char *fcopy = xstrdup (f); + int r; + for (char *p = fcopy; ; *p++ = '/') + { + p = strchr (p, '/'); + if (p) + *p = '\0'; + r = mbscasecmp (pattern, fcopy); + if (!p || r <= 0) + break; + } + free (fcopy); + return r; + } +} + +bool +exclude_fnmatch (char const *pattern, char const *f, int options) +{ + int (*matcher) (char const *, char const *, int) = + (options & EXCLUDE_WILDCARDS + ? fnmatch + : fnmatch_no_wildcards); + bool matched = matcher (pattern, f, options) == 0; + + if (! (options & EXCLUDE_ANCHORED)) + for (char const *p = f; *p && ! matched; p++) + if (*p == '/' && p[1] != '/') + matched = matcher (pattern, p + 1, options) == 0; + + return matched; +} + +static bool +exclude_patopts (struct patopts const *opts, char const *f) +{ + int options = opts->options; + + return (options & EXCLUDE_REGEX + ? regexec (&opts->v.re, f, 0, nullptr, 0) == 0 + : exclude_fnmatch (opts->v.pattern, f, options)); +} + +/* Return true if the exclude_pattern segment SEG matches F. */ + +static bool +file_pattern_matches (struct exclude_segment const *seg, char const *f) +{ + idx_t exclude_count = seg->v.pat.exclude_count; + struct patopts const *exclude = seg->v.pat.exclude; + + for (idx_t i = 0; i < exclude_count; i++) + if (exclude_patopts (exclude + i, f)) + return true; + return false; +} + +/* Return true if the exclude_hash segment SEG matches F. + BUFFER is an auxiliary storage of the same length as F (with nul + terminator included) */ +static bool +file_name_matches (struct exclude_segment const *seg, char const *f, + char *buffer) +{ + int options = seg->options; + Hash_table *table = seg->v.table; + + do + { + /* initialize the pattern */ + strcpy (buffer, f); + + while (true) + { + if (hash_lookup (table, buffer)) + return true; + if (options & FNM_LEADING_DIR) + { + char *p = strrchr (buffer, '/'); + if (p) + { + *p = '\0'; + continue; + } + } + break; + } + + if (!(options & EXCLUDE_ANCHORED)) + { + f = strchr (f, '/'); + if (f) + f++; + } + else + break; + } + while (f); + + return false; +} + +/* Return true if EX excludes F. */ + +bool +excluded_file_name (struct exclude const *ex, char const *f) +{ + /* If no patterns are given, the default is to include. */ + if (!ex->head) + return false; + + bool invert = false; + char *filename = nullptr; + + /* Scan through the segments, reporting the status of the first match. + The segments are in reverse order, so this reports the status of + the last match in the original option list. */ + struct exclude_segment *seg; + for (seg = ex->head; ; seg = seg->next) + { + if (seg->type == exclude_hash) + { + if (!filename) + filename = xmalloc (strlen (f) + 1); + if (file_name_matches (seg, f, filename)) + break; + } + else + { + if (file_pattern_matches (seg, f)) + break; + } + + if (! seg->next) + { + /* If patterns are given but none match, the default is the + opposite of the last segment (i.e., the first in the + original option list). For example, in the command + 'grep -r --exclude="a*" --include="*b" pat dir', the + first option is --exclude so any file name matching + neither a* nor *b is included. */ + invert = true; + break; + } + } + + free (filename); + return invert ^ ! (seg->options & EXCLUDE_INCLUDE); +} + +/* Append to EX the exclusion PATTERN with OPTIONS. */ + +void +add_exclude (struct exclude *ex, char const *pattern, int options) +{ + if ((options & (EXCLUDE_REGEX|EXCLUDE_WILDCARDS)) + && fnmatch_pattern_has_wildcards (pattern, options)) + { + if (! (ex->head && ex->head->type == exclude_pattern + && ((ex->head->options & EXCLUDE_INCLUDE) + == (options & EXCLUDE_INCLUDE)))) + new_exclude_segment (ex, exclude_pattern, options); + + struct exclude_pattern *pat = &ex->head->v.pat; + if (pat->exclude_count == pat->exclude_alloc) + pat->exclude = xpalloc (pat->exclude, &pat->exclude_alloc, 1, -1, + sizeof *pat->exclude); + struct patopts *patopts = &pat->exclude[pat->exclude_count++]; + + patopts->options = options; + if (options & EXCLUDE_REGEX) + { + int rc; + int cflags = (REG_NOSUB | REG_EXTENDED + | (options & FNM_CASEFOLD ? REG_ICASE : 0)); + + if (! (options & FNM_LEADING_DIR)) + rc = regcomp (&patopts->v.re, pattern, cflags); + else + for (idx_t len = strlen (pattern); ; len--) + { + if (len == 0) + { + rc = 1; + break; + } + if (!ISSLASH (pattern[len - 1])) + { + static char const patsuffix[] = "(/.*)?"; + char *tmp = ximalloc (len + sizeof patsuffix); + memcpy (tmp, pattern, len); + strcpy (tmp + len, patsuffix); + rc = regcomp (&patopts->v.re, tmp, cflags); + free (tmp); + break; + } + } + + if (rc) + { + pat->exclude_count--; + return; + } + } + else + { + if (options & EXCLUDE_ALLOC) + { + char *dup = xstrdup (pattern); + pattern = dup; + exclude_add_pattern_buffer (ex, dup); + } + patopts->v.pattern = pattern; + } + } + else + { + int exclude_hash_flags = (EXCLUDE_INCLUDE | EXCLUDE_ANCHORED + | FNM_LEADING_DIR | FNM_CASEFOLD); + if (! (ex->head && ex->head->type == exclude_hash + && ((ex->head->options & exclude_hash_flags) + == (options & exclude_hash_flags)))) + new_exclude_segment (ex, exclude_hash, options); + + char *str = xstrdup (pattern); + if ((options & (EXCLUDE_WILDCARDS | FNM_NOESCAPE)) == EXCLUDE_WILDCARDS) + unescape_pattern (str); + if (hash_insert (ex->head->v.table, str) != str) + free (str); + } +} + +/* Use ADD_FUNC to append to EX the patterns in FILE_NAME, each with + OPTIONS. LINE_END terminates each pattern in the file. If + LINE_END is a space character, ignore trailing spaces and empty + lines in FP. Return -1 (setting errno) on failure, 0 on success. */ + +int +add_exclude_fp (void (*add_func) (struct exclude *, char const *, int, void *), + struct exclude *ex, FILE *fp, int options, + char line_end, void *data) +{ + char *buf = nullptr; + idx_t buf_alloc = 0; + idx_t buf_count = 0; + + for (int c; (c = getc (fp)) != EOF; ) + { + if (buf_count == buf_alloc) + buf = xpalloc (buf, &buf_alloc, 1, -1, 1); + buf[buf_count++] = c; + } + + int e = ferror (fp) ? errno : 0; + + buf = xirealloc (buf, buf_count + 1); + buf[buf_count] = line_end; + char const *lim = (buf + buf_count + + ! (buf_count == 0 || buf[buf_count - 1] == line_end)); + + exclude_add_pattern_buffer (ex, buf); + + char *pattern = buf; + + for (char *p = buf; p < lim; p++) + if (*p == line_end) + { + char *pattern_end = p; + + if (isspace ((unsigned char) line_end)) + { + /* Assume that no multi-byte character has a trailing byte + that satisfies isspace, and that nobody cares about + trailing white space containing non-single-byte characters. + If either assumption turns out to be false, presumably + the code should be changed to scan forward through the + entire pattern, one multi-byte character at a time. */ + for (; ; pattern_end--) + if (pattern_end == pattern) + goto next_pattern; + else if (! isspace ((unsigned char) pattern_end[-1])) + break; + } + + *pattern_end = '\0'; + add_func (ex, pattern, options, data); + + next_pattern: + pattern = p + 1; + } + + errno = e; + return e ? -1 : 0; +} + +static void +call_addfn (struct exclude *ex, char const *pattern, int options, void *data) +{ + void (**addfnptr) (struct exclude *, char const *, int) = data; + (*addfnptr) (ex, pattern, options); +} + +int +add_exclude_file (void (*add_func) (struct exclude *, char const *, int), + struct exclude *ex, char const *file_name, int options, + char line_end) +{ + if (strcmp (file_name, "-") == 0) + return add_exclude_fp (call_addfn, ex, stdin, options, line_end, &add_func); + + FILE *in = fopen (file_name, "re"); + if (!in) + return -1; + int rc = add_exclude_fp (call_addfn, ex, in, options, line_end, &add_func); + int e = errno; + if (fclose (in) < 0) + return -1; + errno = e; + return rc; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/exclude.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/exclude.h new file mode 100644 index 00000000..0783b087 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/exclude.h @@ -0,0 +1,70 @@ +/* exclude.h -- declarations for excluding file names + + Copyright (C) 1992-1994, 1997, 1999, 2001-2003, 2005-2006, 2009-2024 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 . */ + +#ifndef _GL_EXCLUDE_H +#define _GL_EXCLUDE_H 1 + +/* This file uses _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_MALLOC, + _GL_ATTRIBUTE_NONNULL, _GL_ATTRIBUTE_PURE, _GL_ATTRIBUTE_RETURNS_NONNULL. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +#include + +/* Written by Paul Eggert + and Sergey Poznyakoff */ + +/* Exclude options, which can be ORed with fnmatch options. */ + +/* Patterns must match the start of file names, instead of matching + anywhere after a '/'. */ +#define EXCLUDE_ANCHORED (1 << 30) + +/* Include instead of exclude. */ +#define EXCLUDE_INCLUDE (1 << 29) + +/* '?', '*', '[', and '\\' are special in patterns. Without this + option, these characters are ordinary and fnmatch is not used. */ +#define EXCLUDE_WILDCARDS (1 << 28) + +/* Patterns are POSIX extended regular expressions */ +#define EXCLUDE_REGEX (1 << 27) + +/* Allocate storage for the pattern */ +#define EXCLUDE_ALLOC (1 << 26) + +struct exclude; + +bool fnmatch_pattern_has_wildcards (const char *, int) _GL_ATTRIBUTE_PURE; + +void free_exclude (struct exclude *) + _GL_ATTRIBUTE_NONNULL ((1)); +struct exclude *new_exclude (void) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_RETURNS_NONNULL + _GL_ATTRIBUTE_DEALLOC (free_exclude, 1); +void add_exclude (struct exclude *, char const *, int); +int add_exclude_file (void (*) (struct exclude *, char const *, int), + struct exclude *, char const *, int, char); +int add_exclude_fp (void (*) (struct exclude *, char const *, int, void *), + struct exclude *, FILE *, int, char, void *); +bool excluded_file_name (struct exclude const *, char const *); +void exclude_add_pattern_buffer (struct exclude *ex, char *buf); +bool exclude_fnmatch (char const *, char const *, int); + +#endif /* _GL_EXCLUDE_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/exitfail.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/exitfail.c new file mode 100644 index 00000000..8a5962e8 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/exitfail.c @@ -0,0 +1,24 @@ +/* Failure exit status + + Copyright (C) 2002-2003, 2005-2007, 2009-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +#include "exitfail.h" + +#include + +int volatile exit_failure = EXIT_FAILURE; diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/exitfail.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/exitfail.h new file mode 100644 index 00000000..20ac506b --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/exitfail.h @@ -0,0 +1,18 @@ +/* Failure exit status + + Copyright (C) 2002, 2009-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +extern int volatile exit_failure; diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/fchdir.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/fchdir.c new file mode 100644 index 00000000..5ac2f096 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/fchdir.c @@ -0,0 +1,204 @@ +/* fchdir replacement. + Copyright (C) 2006-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "assure.h" +#include "filename.h" +#include "filenamecat.h" + +#ifndef REPLACE_OPEN_DIRECTORY +# define REPLACE_OPEN_DIRECTORY 0 +#endif + +/* This replacement assumes that a directory is not renamed while opened + through a file descriptor. + + FIXME: On mingw, this would be possible to enforce if we were to + also open a HANDLE to each directory currently visited by a file + descriptor, since mingw refuses to rename any in-use file system + object. */ + +/* Array of file descriptors opened. If REPLACE_OPEN_DIRECTORY or if it points + to a directory, it stores info about this directory. */ +typedef struct +{ + char *name; /* Absolute name of the directory, or NULL. */ +} dir_info_t; +static dir_info_t *dirs; +static size_t dirs_allocated; + +/* Try to ensure dirs has enough room for a slot at index fd; free any + contents already in that slot. Return false and set errno to + ENOMEM on allocation failure. */ +static bool +ensure_dirs_slot (size_t fd) +{ + if (fd < dirs_allocated) + free (dirs[fd].name); + else + { + size_t new_allocated; + dir_info_t *new_dirs; + + new_allocated = 2 * dirs_allocated + 1; + if (new_allocated <= fd) + new_allocated = fd + 1; + new_dirs = + (dirs != NULL + ? (dir_info_t *) realloc (dirs, new_allocated * sizeof *dirs) + : (dir_info_t *) malloc (new_allocated * sizeof *dirs)); + if (new_dirs == NULL) + return false; + memset (new_dirs + dirs_allocated, 0, + (new_allocated - dirs_allocated) * sizeof *dirs); + dirs = new_dirs; + dirs_allocated = new_allocated; + } + return true; +} + +/* Return an absolute name of DIR in malloc'd storage. + Upon failure, return NULL with errno set. */ +static char * +get_name (char const *dir) +{ + char *cwd; + char *result; + + if (IS_ABSOLUTE_FILE_NAME (dir)) + return strdup (dir); + + /* We often encounter "."; treat it as a special case. */ + cwd = getcwd (NULL, 0); + if (!cwd || (dir[0] == '.' && dir[1] == '\0')) + return cwd; + + result = mfile_name_concat (cwd, dir, NULL); + free (cwd); + return result; +} + +/* Hook into the gnulib replacements for open() and close() to keep track + of the open file descriptors. */ + +/* Close FD, cleaning up any fd to name mapping if fd was visiting a + directory. */ +void +_gl_unregister_fd (int fd) +{ + if (fd >= 0 && fd < dirs_allocated) + { + free (dirs[fd].name); + dirs[fd].name = NULL; + } +} + +/* Mark FD as visiting FILENAME. FD must be non-negative, and refer + to an open file descriptor. If REPLACE_OPEN_DIRECTORY is non-zero, + this should only be called if FD is visiting a directory. Close FD + and return -1 with errno set if there is insufficient memory to track + the directory name; otherwise return FD. */ +int +_gl_register_fd (int fd, const char *filename) +{ + struct stat statbuf; + + assure (0 <= fd); + if (REPLACE_OPEN_DIRECTORY + || (fstat (fd, &statbuf) == 0 && S_ISDIR (statbuf.st_mode))) + { + if (!ensure_dirs_slot (fd) + || (dirs[fd].name = get_name (filename)) == NULL) + { + int saved_errno = errno; + close (fd); + errno = saved_errno; + return -1; + } + } + return fd; +} + +/* Mark NEWFD as a duplicate of OLDFD; useful from dup, dup2, dup3, + and fcntl. Both arguments must be valid and distinct file + descriptors. Close NEWFD and return -1 if OLDFD is tracking a + directory, but there is insufficient memory to track the same + directory in NEWFD; otherwise return NEWFD. */ +int +_gl_register_dup (int oldfd, int newfd) +{ + assure (0 <= oldfd && 0 <= newfd && oldfd != newfd); + if (oldfd < dirs_allocated && dirs[oldfd].name) + { + /* Duplicated a directory; must ensure newfd is allocated. */ + if (!ensure_dirs_slot (newfd) + || (dirs[newfd].name = strdup (dirs[oldfd].name)) == NULL) + { + int saved_errno = errno; + close (newfd); + errno = saved_errno; + newfd = -1; + } + } + else if (newfd < dirs_allocated) + { + /* Duplicated a non-directory; ensure newfd is cleared. */ + free (dirs[newfd].name); + dirs[newfd].name = NULL; + } + return newfd; +} + +/* If FD is currently visiting a directory, then return the name of + that directory. Otherwise, return NULL and set errno. */ +const char * +_gl_directory_name (int fd) +{ + if (0 <= fd && fd < dirs_allocated && dirs[fd].name != NULL) + return dirs[fd].name; + /* At this point, fd is either invalid, or open but not a directory. + If dup2 fails, errno is correctly EBADF. */ + if (0 <= fd) + { + if (dup2 (fd, fd) == fd) + errno = ENOTDIR; + } + else + errno = EBADF; + return NULL; +} + + +/* Implement fchdir() in terms of chdir(). */ + +int +fchdir (int fd) +{ + const char *name = _gl_directory_name (fd); + return name ? chdir (name) : -1; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/fcntl.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/fcntl.c new file mode 100644 index 00000000..7cd3a0f9 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/fcntl.c @@ -0,0 +1,629 @@ +/* Provide file descriptor control. + + Copyright (C) 2009-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Eric Blake . */ + +#include + +/* Specification. */ +#include + +#include +#include +#include +#include +#include + +#ifdef __KLIBC__ +# define INCL_DOS +# include +#endif + +#if defined _WIN32 && ! defined __CYGWIN__ +/* Get declarations of the native Windows API functions. */ +# define WIN32_LEAN_AND_MEAN +# include + +/* Get _get_osfhandle. */ +# if GNULIB_MSVC_NOTHROW +# include "msvc-nothrow.h" +# else +# include +# endif + +/* Upper bound on getdtablesize(). See lib/getdtablesize.c. */ +# define OPEN_MAX_MAX 0x10000 + +/* Duplicate OLDFD into the first available slot of at least NEWFD, + which must be positive, with FLAGS determining whether the duplicate + will be inheritable. */ +static int +dupfd (int oldfd, int newfd, int flags) +{ + /* Mingw has no way to create an arbitrary fd. Iterate until all + file descriptors less than newfd are filled up. */ + HANDLE curr_process = GetCurrentProcess (); + HANDLE old_handle = (HANDLE) _get_osfhandle (oldfd); + unsigned char fds_to_close[OPEN_MAX_MAX / CHAR_BIT]; + unsigned int fds_to_close_bound = 0; + int result; + BOOL inherit = flags & O_CLOEXEC ? FALSE : TRUE; + int mode; + + if (newfd < 0 || getdtablesize () <= newfd) + { + errno = EINVAL; + return -1; + } + if (old_handle == INVALID_HANDLE_VALUE + || (mode = _setmode (oldfd, O_BINARY)) == -1) + { + /* oldfd is not open, or is an unassigned standard file + descriptor. */ + errno = EBADF; + return -1; + } + _setmode (oldfd, mode); + flags |= mode; + + for (;;) + { + HANDLE new_handle; + int duplicated_fd; + unsigned int index; + + if (!DuplicateHandle (curr_process, /* SourceProcessHandle */ + old_handle, /* SourceHandle */ + curr_process, /* TargetProcessHandle */ + (PHANDLE) &new_handle, /* TargetHandle */ + (DWORD) 0, /* DesiredAccess */ + inherit, /* InheritHandle */ + DUPLICATE_SAME_ACCESS)) /* Options */ + { + switch (GetLastError ()) + { + case ERROR_TOO_MANY_OPEN_FILES: + errno = EMFILE; + break; + case ERROR_INVALID_HANDLE: + case ERROR_INVALID_TARGET_HANDLE: + case ERROR_DIRECT_ACCESS_HANDLE: + errno = EBADF; + break; + case ERROR_INVALID_PARAMETER: + case ERROR_INVALID_FUNCTION: + case ERROR_INVALID_ACCESS: + errno = EINVAL; + break; + default: + errno = EACCES; + break; + } + result = -1; + break; + } + duplicated_fd = _open_osfhandle ((intptr_t) new_handle, flags); + if (duplicated_fd < 0) + { + CloseHandle (new_handle); + result = -1; + break; + } + if (newfd <= duplicated_fd) + { + result = duplicated_fd; + break; + } + + /* Set the bit duplicated_fd in fds_to_close[]. */ + index = (unsigned int) duplicated_fd / CHAR_BIT; + if (fds_to_close_bound <= index) + { + if (sizeof fds_to_close <= index) + /* Need to increase OPEN_MAX_MAX. */ + abort (); + memset (fds_to_close + fds_to_close_bound, '\0', + index + 1 - fds_to_close_bound); + fds_to_close_bound = index + 1; + } + fds_to_close[index] |= 1 << ((unsigned int) duplicated_fd % CHAR_BIT); + } + + /* Close the previous fds that turned out to be too small. */ + { + int saved_errno = errno; + unsigned int duplicated_fd; + + for (duplicated_fd = 0; + duplicated_fd < fds_to_close_bound * CHAR_BIT; + duplicated_fd++) + if ((fds_to_close[duplicated_fd / CHAR_BIT] + >> (duplicated_fd % CHAR_BIT)) + & 1) + close (duplicated_fd); + + errno = saved_errno; + } + +# if REPLACE_FCHDIR + if (0 <= result) + result = _gl_register_dup (oldfd, result); +# endif + return result; +} +#endif /* W32 */ + +/* Forward declarations, because we '#undef fcntl' in the middle of this + compilation unit. */ +/* Our implementation of fcntl (fd, F_DUPFD, target). */ +static int rpl_fcntl_DUPFD (int fd, int target); +/* Our implementation of fcntl (fd, F_DUPFD_CLOEXEC, target). */ +static int rpl_fcntl_DUPFD_CLOEXEC (int fd, int target); +#ifdef __KLIBC__ +/* Adds support for fcntl on directories. */ +static int klibc_fcntl (int fd, int action, /* arg */...); +#endif + + +/* Perform the specified ACTION on the file descriptor FD, possibly + using the argument ARG further described below. This replacement + handles the following actions, and forwards all others on to the + native fcntl. An unrecognized ACTION returns -1 with errno set to + EINVAL. + + F_DUPFD - duplicate FD, with int ARG being the minimum target fd. + If successful, return the duplicate, which will be inheritable; + otherwise return -1 and set errno. + + F_DUPFD_CLOEXEC - duplicate FD, with int ARG being the minimum + target fd. If successful, return the duplicate, which will not be + inheritable; otherwise return -1 and set errno. + + F_GETFD - ARG need not be present. If successful, return a + non-negative value containing the descriptor flags of FD (only + FD_CLOEXEC is portable, but other flags may be present); otherwise + return -1 and set errno. */ + +int +fcntl (int fd, int action, /* arg */...) +#undef fcntl +#ifdef __KLIBC__ +# define fcntl klibc_fcntl +#endif +{ + va_list arg; + int result = -1; + va_start (arg, action); + switch (action) + { + case F_DUPFD: + { + int target = va_arg (arg, int); + result = rpl_fcntl_DUPFD (fd, target); + break; + } + + case F_DUPFD_CLOEXEC: + { + int target = va_arg (arg, int); + result = rpl_fcntl_DUPFD_CLOEXEC (fd, target); + break; + } + +#if !HAVE_FCNTL + case F_GETFD: + { +# if defined _WIN32 && ! defined __CYGWIN__ + HANDLE handle = (HANDLE) _get_osfhandle (fd); + DWORD flags; + if (handle == INVALID_HANDLE_VALUE + || GetHandleInformation (handle, &flags) == 0) + errno = EBADF; + else + result = (flags & HANDLE_FLAG_INHERIT) ? 0 : FD_CLOEXEC; +# else /* !W32 */ + /* Use dup2 to reject invalid file descriptors. No way to + access this information, so punt. */ + if (0 <= dup2 (fd, fd)) + result = 0; +# endif /* !W32 */ + break; + } /* F_GETFD */ +#endif /* !HAVE_FCNTL */ + + /* Implementing F_SETFD on mingw is not trivial - there is no + API for changing the O_NOINHERIT bit on an fd, and merely + changing the HANDLE_FLAG_INHERIT bit on the underlying handle + can lead to odd state. It may be possible by duplicating the + handle, using _open_osfhandle with the right flags, then + using dup2 to move the duplicate onto the original, but that + is not supported for now. */ + + default: + { +#if HAVE_FCNTL + switch (action) + { + #ifdef F_BARRIERFSYNC /* macOS */ + case F_BARRIERFSYNC: + #endif + #ifdef F_CHKCLEAN /* macOS */ + case F_CHKCLEAN: + #endif + #ifdef F_CLOSEM /* NetBSD, HP-UX */ + case F_CLOSEM: + #endif + #ifdef F_FLUSH_DATA /* macOS */ + case F_FLUSH_DATA: + #endif + #ifdef F_FREEZE_FS /* macOS */ + case F_FREEZE_FS: + #endif + #ifdef F_FULLFSYNC /* macOS */ + case F_FULLFSYNC: + #endif + #ifdef F_GETCONFINED /* macOS */ + case F_GETCONFINED: + #endif + #ifdef F_GETDEFAULTPROTLEVEL /* macOS */ + case F_GETDEFAULTPROTLEVEL: + #endif + #ifdef F_GETFD /* POSIX */ + case F_GETFD: + #endif + #ifdef F_GETFL /* POSIX */ + case F_GETFL: + #endif + #ifdef F_GETLEASE /* Linux */ + case F_GETLEASE: + #endif + #ifdef F_GETNOSIGPIPE /* macOS */ + case F_GETNOSIGPIPE: + #endif + #ifdef F_GETOWN /* POSIX */ + case F_GETOWN: + #endif + #ifdef F_GETPIPE_SZ /* Linux */ + case F_GETPIPE_SZ: + #endif + #ifdef F_GETPROTECTIONCLASS /* macOS */ + case F_GETPROTECTIONCLASS: + #endif + #ifdef F_GETPROTECTIONLEVEL /* macOS */ + case F_GETPROTECTIONLEVEL: + #endif + #ifdef F_GET_SEALS /* Linux */ + case F_GET_SEALS: + #endif + #ifdef F_GETSIG /* Linux */ + case F_GETSIG: + #endif + #ifdef F_MAXFD /* NetBSD */ + case F_MAXFD: + #endif + #ifdef F_RECYCLE /* macOS */ + case F_RECYCLE: + #endif + #ifdef F_SETFIFOENH /* HP-UX */ + case F_SETFIFOENH: + #endif + #ifdef F_THAW_FS /* macOS */ + case F_THAW_FS: + #endif + /* These actions take no argument. */ + result = fcntl (fd, action); + break; + + #ifdef F_ADD_SEALS /* Linux */ + case F_ADD_SEALS: + #endif + #ifdef F_BADFD /* Solaris */ + case F_BADFD: + #endif + #ifdef F_CHECK_OPENEVT /* macOS */ + case F_CHECK_OPENEVT: + #endif + #ifdef F_DUP2FD /* FreeBSD, AIX, Solaris */ + case F_DUP2FD: + #endif + #ifdef F_DUP2FD_CLOEXEC /* FreeBSD, Solaris */ + case F_DUP2FD_CLOEXEC: + #endif + #ifdef F_DUP2FD_CLOFORK /* Solaris */ + case F_DUP2FD_CLOFORK: + #endif + #ifdef F_DUPFD /* POSIX */ + case F_DUPFD: + #endif + #ifdef F_DUPFD_CLOEXEC /* POSIX */ + case F_DUPFD_CLOEXEC: + #endif + #ifdef F_DUPFD_CLOFORK /* Solaris */ + case F_DUPFD_CLOFORK: + #endif + #ifdef F_GETXFL /* Solaris */ + case F_GETXFL: + #endif + #ifdef F_GLOBAL_NOCACHE /* macOS */ + case F_GLOBAL_NOCACHE: + #endif + #ifdef F_MAKECOMPRESSED /* macOS */ + case F_MAKECOMPRESSED: + #endif + #ifdef F_MOVEDATAEXTENTS /* macOS */ + case F_MOVEDATAEXTENTS: + #endif + #ifdef F_NOCACHE /* macOS */ + case F_NOCACHE: + #endif + #ifdef F_NODIRECT /* macOS */ + case F_NODIRECT: + #endif + #ifdef F_NOTIFY /* Linux */ + case F_NOTIFY: + #endif + #ifdef F_OPLKACK /* IRIX */ + case F_OPLKACK: + #endif + #ifdef F_OPLKREG /* IRIX */ + case F_OPLKREG: + #endif + #ifdef F_RDAHEAD /* macOS */ + case F_RDAHEAD: + #endif + #ifdef F_SETBACKINGSTORE /* macOS */ + case F_SETBACKINGSTORE: + #endif + #ifdef F_SETCONFINED /* macOS */ + case F_SETCONFINED: + #endif + #ifdef F_SETFD /* POSIX */ + case F_SETFD: + #endif + #ifdef F_SETFL /* POSIX */ + case F_SETFL: + #endif + #ifdef F_SETLEASE /* Linux */ + case F_SETLEASE: + #endif + #ifdef F_SETNOSIGPIPE /* macOS */ + case F_SETNOSIGPIPE: + #endif + #ifdef F_SETOWN /* POSIX */ + case F_SETOWN: + #endif + #ifdef F_SETPIPE_SZ /* Linux */ + case F_SETPIPE_SZ: + #endif + #ifdef F_SETPROTECTIONCLASS /* macOS */ + case F_SETPROTECTIONCLASS: + #endif + #ifdef F_SETSIG /* Linux */ + case F_SETSIG: + #endif + #ifdef F_SINGLE_WRITER /* macOS */ + case F_SINGLE_WRITER: + #endif + /* These actions take an 'int' argument. */ + { + int x = va_arg (arg, int); + result = fcntl (fd, action, x); + } + break; + + default: + /* Other actions take a pointer argument. */ + { + void *p = va_arg (arg, void *); + result = fcntl (fd, action, p); + } + break; + } +#else + errno = EINVAL; +#endif + break; + } + } + va_end (arg); + return result; +} + +static int +rpl_fcntl_DUPFD (int fd, int target) +{ + int result; +#if !HAVE_FCNTL + result = dupfd (fd, target, 0); +#elif FCNTL_DUPFD_BUGGY || REPLACE_FCHDIR + /* Detect invalid target; needed for cygwin 1.5.x. */ + if (target < 0 || getdtablesize () <= target) + { + result = -1; + errno = EINVAL; + } + else + { + /* Haiku alpha 2 loses fd flags on original. */ + int flags = fcntl (fd, F_GETFD); + if (flags < 0) + result = -1; + else + { + result = fcntl (fd, F_DUPFD, target); + if (0 <= result && fcntl (fd, F_SETFD, flags) == -1) + { + int saved_errno = errno; + close (result); + result = -1; + errno = saved_errno; + } +# if REPLACE_FCHDIR + if (0 <= result) + result = _gl_register_dup (fd, result); +# endif + } + } +#else + result = fcntl (fd, F_DUPFD, target); +#endif + return result; +} + +static int +rpl_fcntl_DUPFD_CLOEXEC (int fd, int target) +{ + int result; +#if !HAVE_FCNTL + result = dupfd (fd, target, O_CLOEXEC); +#else /* HAVE_FCNTL */ +# if defined __NetBSD__ || defined __HAIKU__ + /* On NetBSD 9.0, the system fcntl (fd, F_DUPFD_CLOEXEC, target) + has only the same effect as fcntl (fd, F_DUPFD, target). */ + /* On Haiku, the system fcntl (fd, F_DUPFD_CLOEXEC, target) sets + the FD_CLOEXEC flag on fd, not on target. Therefore avoid the + system fcntl in this case. */ +# define have_dupfd_cloexec -1 +# else + /* Try the system call first, if the headers claim it exists + (that is, if GNULIB_defined_F_DUPFD_CLOEXEC is 0), since we + may be running with a glibc that has the macro but with an + older kernel that does not support it. Cache the + information on whether the system call really works, but + avoid caching failure if the corresponding F_DUPFD fails + for any reason. 0 = unknown, 1 = yes, -1 = no. */ + static int have_dupfd_cloexec = GNULIB_defined_F_DUPFD_CLOEXEC ? -1 : 0; + if (0 <= have_dupfd_cloexec) + { + result = fcntl (fd, F_DUPFD_CLOEXEC, target); + if (0 <= result || errno != EINVAL) + { + have_dupfd_cloexec = 1; +# if REPLACE_FCHDIR + if (0 <= result) + result = _gl_register_dup (fd, result); +# endif + } + else + { + result = rpl_fcntl_DUPFD (fd, target); + if (result >= 0) + have_dupfd_cloexec = -1; + } + } + else +# endif + result = rpl_fcntl_DUPFD (fd, target); + if (0 <= result && have_dupfd_cloexec == -1) + { + int flags = fcntl (result, F_GETFD); + if (flags < 0 || fcntl (result, F_SETFD, flags | FD_CLOEXEC) == -1) + { + int saved_errno = errno; + close (result); + errno = saved_errno; + result = -1; + } + } +#endif /* HAVE_FCNTL */ + return result; +} + +#undef fcntl + +#ifdef __KLIBC__ + +static int +klibc_fcntl (int fd, int action, /* arg */...) +{ + va_list arg_ptr; + int arg; + struct stat sbuf; + int result; + + va_start (arg_ptr, action); + arg = va_arg (arg_ptr, int); + result = fcntl (fd, action, arg); + /* EPERM for F_DUPFD, ENOTSUP for others */ + if (result == -1 && (errno == EPERM || errno == ENOTSUP) + && !fstat (fd, &sbuf) && S_ISDIR (sbuf.st_mode)) + { + ULONG ulMode; + + switch (action) + { + case F_DUPFD: + /* Find available fd */ + while (fcntl (arg, F_GETFL) != -1 || errno != EBADF) + arg++; + + result = dup2 (fd, arg); + break; + + /* Using underlying APIs is right ? */ + case F_GETFD: + if (DosQueryFHState (fd, &ulMode)) + break; + + result = (ulMode & OPEN_FLAGS_NOINHERIT) ? FD_CLOEXEC : 0; + break; + + case F_SETFD: + if (arg & ~FD_CLOEXEC) + break; + + if (DosQueryFHState (fd, &ulMode)) + break; + + if (arg & FD_CLOEXEC) + ulMode |= OPEN_FLAGS_NOINHERIT; + else + ulMode &= ~OPEN_FLAGS_NOINHERIT; + + /* Filter supported flags. */ + ulMode &= (OPEN_FLAGS_WRITE_THROUGH | OPEN_FLAGS_FAIL_ON_ERROR + | OPEN_FLAGS_NO_CACHE | OPEN_FLAGS_NOINHERIT); + + if (DosSetFHState (fd, ulMode)) + break; + + result = 0; + break; + + case F_GETFL: + result = 0; + break; + + case F_SETFL: + if (arg != 0) + break; + + result = 0; + break; + + default: + errno = EINVAL; + break; + } + } + + va_end (arg_ptr); + + return result; +} + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/fcntl.in.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/fcntl.in.h new file mode 100644 index 00000000..eea3b954 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/fcntl.in.h @@ -0,0 +1,450 @@ +/* Like , but with non-working flags defined to 0. + + Copyright (C) 2006-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* written by Paul Eggert */ + +#if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +#endif +@PRAGMA_COLUMNS@ + +#if defined __need_system_fcntl_h +/* Special invocation convention. */ + +/* Needed before . + May also define off_t to a 64-bit type on native Windows. */ +#include +/* On some systems other than glibc, is a prerequisite of + . On glibc systems, we would like to avoid namespace pollution. + But on glibc systems, includes inside an + extern "C" { ... } block, which leads to errors in C++ mode with the + overridden from gnulib. These errors are known to be gone + with g++ version >= 4.3. */ +#if !(defined __GLIBC__ || defined __UCLIBC__) || (defined __cplusplus && defined GNULIB_NAMESPACE && (defined __ICC || !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)))) +# include +#endif +#@INCLUDE_NEXT@ @NEXT_FCNTL_H@ + +/* Native Windows platforms declare open(), creat() in . */ +#if (@GNULIB_CREAT@ || @GNULIB_OPEN@ || defined GNULIB_POSIXCHECK) \ + && (defined _WIN32 && ! defined __CYGWIN__) +# include +#endif + +#else +/* Normal invocation convention. */ + +#ifndef _@GUARD_PREFIX@_FCNTL_H + +/* Needed before . + May also define off_t to a 64-bit type on native Windows. */ +#include +/* On some systems other than glibc, is a prerequisite of + . On glibc systems, we would like to avoid namespace pollution. + But on glibc systems, includes inside an + extern "C" { ... } block, which leads to errors in C++ mode with the + overridden from gnulib. These errors are known to be gone + with g++ version >= 4.3. */ +#if !(defined __GLIBC__ || defined __UCLIBC__) || (defined __cplusplus && defined GNULIB_NAMESPACE && (defined __ICC || !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)))) +# include +#endif +/* The include_next requires a split double-inclusion guard. */ +#@INCLUDE_NEXT@ @NEXT_FCNTL_H@ + +/* Native Windows platforms declare open(), creat() in . */ +#if (@GNULIB_CREAT@ || @GNULIB_OPEN@ || defined GNULIB_POSIXCHECK) \ + && (defined _WIN32 && ! defined __CYGWIN__) +# include +#endif + +#ifndef _@GUARD_PREFIX@_FCNTL_H +#define _@GUARD_PREFIX@_FCNTL_H + +/* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +#ifndef __GLIBC__ /* Avoid namespace pollution on glibc systems. */ +# include +#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. */ + + +/* 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)); +# elif defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef creat +# define creat _creat +# endif +_GL_CXXALIAS_MDA (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"); +#elif @GNULIB_MDA_CREAT@ +/* On native Windows, map 'creat' to '_creat', so that -loldnames is not + required. In C++ with GNULIB_NAMESPACE, avoid differences between + platforms by defining GNULIB_NAMESPACE::creat always. */ +# if defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef creat +# define creat _creat +# endif +/* Need to cast, because in mingw the last argument is 'int mode'. */ +_GL_CXXALIAS_MDA_CAST (creat, int, (const char *filename, mode_t mode)); +# else +_GL_CXXALIAS_SYS (creat, int, (const char *filename, mode_t mode)); +# endif +_GL_CXXALIASWARN (creat); +#endif + +#if @GNULIB_FCNTL@ +# if @REPLACE_FCNTL@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef fcntl +# define fcntl rpl_fcntl +# 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 +_GL_CXXALIASWARN (fcntl); +#elif defined GNULIB_POSIXCHECK +# undef fcntl +# if HAVE_RAW_DECL_FCNTL +_GL_WARN_ON_USE (fcntl, "fcntl is not always POSIX compliant - " + "use gnulib module fcntl for portability"); +# endif +#endif + +#if @GNULIB_OPEN@ +# if @REPLACE_OPEN@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef open +# define open rpl_open +# endif +_GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...)); +# elif defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef open +# define open _open +# endif +_GL_CXXALIAS_MDA (open, int, (const char *filename, int flags, ...)); +# else +_GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...)); +# endif +/* On HP-UX 11, in C++ mode, open() is defined as an inline function with a + default argument. _GL_CXXALIASWARN does not work in this case. */ +# if !defined __hpux +_GL_CXXALIASWARN (open); +# endif +#elif defined GNULIB_POSIXCHECK +# undef open +/* Assume open is always declared. */ +_GL_WARN_ON_USE (open, "open is not always POSIX compliant - " + "use gnulib module open for portability"); +#elif @GNULIB_MDA_OPEN@ +/* On native Windows, map 'open' to '_open', so that -loldnames is not + required. In C++ with GNULIB_NAMESPACE, avoid differences between + platforms by defining GNULIB_NAMESPACE::open always. */ +# if defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef open +# define open _open +# endif +_GL_CXXALIAS_MDA (open, int, (const char *filename, int flags, ...)); +# else +_GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...)); +# endif +# if !defined __hpux +_GL_CXXALIASWARN (open); +# endif +#endif + +#if @GNULIB_OPENAT@ +# if @REPLACE_OPENAT@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef openat +# define openat rpl_openat +# endif +_GL_FUNCDECL_RPL (openat, int, + (int fd, char const *file, int flags, /* mode_t mode */ ...) + _GL_ARG_NONNULL ((2))); +_GL_CXXALIAS_RPL (openat, int, + (int fd, char const *file, int flags, /* mode_t mode */ ...)); +# else +# if !@HAVE_OPENAT@ +_GL_FUNCDECL_SYS (openat, int, + (int fd, char const *file, int flags, /* mode_t mode */ ...) + _GL_ARG_NONNULL ((2))); +# endif +_GL_CXXALIAS_SYS (openat, int, + (int fd, char const *file, int flags, /* mode_t mode */ ...)); +# endif +_GL_CXXALIASWARN (openat); +#elif defined GNULIB_POSIXCHECK +# undef openat +# if HAVE_RAW_DECL_OPENAT +_GL_WARN_ON_USE (openat, "openat is not portable - " + "use gnulib module openat for portability"); +# endif +#endif + + +/* Fix up the FD_* macros, only known to be missing on mingw. */ + +#ifndef FD_CLOEXEC +# define FD_CLOEXEC 1 +#endif + +/* Fix up the supported F_* macros. Intentionally leave other F_* + macros undefined. Only known to be missing on mingw. */ + +#ifndef F_DUPFD_CLOEXEC +# define F_DUPFD_CLOEXEC 0x40000000 +/* Witness variable: 1 if gnulib defined F_DUPFD_CLOEXEC, 0 otherwise. */ +# define GNULIB_defined_F_DUPFD_CLOEXEC 1 +#else +# define GNULIB_defined_F_DUPFD_CLOEXEC 0 +#endif + +#ifndef F_DUPFD +# define F_DUPFD 1 +#endif + +#ifndef F_GETFD +# define F_GETFD 2 +#endif + +/* Fix up the O_* macros. */ + +/* AIX 7.1 with XL C 12.1 defines O_CLOEXEC, O_NOFOLLOW, and O_TTY_INIT + to values outside 'int' range, so omit these misdefinitions. + But avoid namespace pollution on non-AIX systems. */ +#ifdef _AIX +# include +# if defined O_CLOEXEC && ! (INT_MIN <= O_CLOEXEC && O_CLOEXEC <= INT_MAX) +# undef O_CLOEXEC +# endif +# if defined O_NOFOLLOW && ! (INT_MIN <= O_NOFOLLOW && O_NOFOLLOW <= INT_MAX) +# undef O_NOFOLLOW +# endif +# if defined O_TTY_INIT && ! (INT_MIN <= O_TTY_INIT && O_TTY_INIT <= INT_MAX) +# undef O_TTY_INIT +# endif +#endif + +#if !defined O_DIRECT && defined O_DIRECTIO +/* Tru64 spells it 'O_DIRECTIO'. */ +# define O_DIRECT O_DIRECTIO +#endif + +#if !defined O_CLOEXEC && defined O_NOINHERIT +/* Mingw spells it 'O_NOINHERIT'. */ +# define O_CLOEXEC O_NOINHERIT +#endif + +#ifndef O_CLOEXEC +# define O_CLOEXEC 0x40000000 /* Try to not collide with system O_* flags. */ +# define GNULIB_defined_O_CLOEXEC 1 +#else +# define GNULIB_defined_O_CLOEXEC 0 +#endif + +#ifndef O_DIRECT +# define O_DIRECT 0 +#endif + +#ifndef O_DIRECTORY +# define O_DIRECTORY 0 +#endif + +#ifndef O_DSYNC +# define O_DSYNC 0 +#endif + +#ifndef O_EXEC +# define O_EXEC O_RDONLY /* This is often close enough in older systems. */ +#endif + +#ifndef O_IGNORE_CTTY +# define O_IGNORE_CTTY 0 +#endif + +#ifndef O_NDELAY +# define O_NDELAY 0 +#endif + +#ifndef O_NOATIME +# define O_NOATIME 0 +#endif + +#ifndef O_NONBLOCK +# define O_NONBLOCK O_NDELAY +#endif + +/* If the gnulib module 'nonblocking' is in use, guarantee a working non-zero + value of O_NONBLOCK. Otherwise, O_NONBLOCK is defined (above) to O_NDELAY + or to 0 as fallback. */ +#if @GNULIB_NONBLOCKING@ +# if O_NONBLOCK +# define GNULIB_defined_O_NONBLOCK 0 +# else +# define GNULIB_defined_O_NONBLOCK 1 +# undef O_NONBLOCK +# define O_NONBLOCK 0x40000000 +# endif +#endif + +#ifndef O_NOCTTY +# define O_NOCTTY 0 +#endif + +#ifndef O_NOFOLLOW +# define O_NOFOLLOW 0 +#endif + +#ifndef O_NOLINK +# define O_NOLINK 0 +#endif + +#ifndef O_NOLINKS +# define O_NOLINKS 0 +#endif + +#ifndef O_NOTRANS +# define O_NOTRANS 0 +#endif + +#ifndef O_RSYNC +# define O_RSYNC 0 +#endif + +#ifndef O_SEARCH +# define O_SEARCH O_RDONLY /* This is often close enough in older systems. */ +#endif + +#ifndef O_SYNC +# define O_SYNC 0 +#endif + +#ifndef O_TTY_INIT +# define O_TTY_INIT 0 +#endif + +#if ~O_ACCMODE & (O_RDONLY | O_WRONLY | O_RDWR | O_EXEC | O_SEARCH) +# undef O_ACCMODE +# define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR | O_EXEC | O_SEARCH) +#endif + +/* For systems that distinguish between text and binary I/O. + O_BINARY is usually declared in fcntl.h */ +#if !defined O_BINARY && defined _O_BINARY + /* For MSC-compatible compilers. */ +# define O_BINARY _O_BINARY +# define O_TEXT _O_TEXT +#endif + +#if defined __BEOS__ || defined __HAIKU__ + /* BeOS 5 and Haiku have O_BINARY and O_TEXT, but they have no effect. */ +# undef O_BINARY +# undef O_TEXT +#endif + +#ifndef O_BINARY +# define O_BINARY 0 +# define O_TEXT 0 +#endif + +/* Fix up the AT_* macros. */ + +/* Work around a bug in Solaris 9 and 10: AT_FDCWD is positive. Its + value exceeds INT_MAX, so its use as an int doesn't conform to the + C standard, and GCC and Sun C complain in some cases. If the bug + is present, undef AT_FDCWD here, so it can be redefined below. */ +#if 0 < AT_FDCWD && AT_FDCWD == 0xffd19553 +# undef AT_FDCWD +#endif + +/* Use the same bit pattern as Solaris 9, but with the proper + signedness. The bit pattern is important, in case this actually is + Solaris with the above workaround. */ +#ifndef AT_FDCWD +# define AT_FDCWD (-3041965) +#endif + +/* Use the same values as Solaris 9. This shouldn't matter, but + there's no real reason to differ. */ +#ifndef AT_SYMLINK_NOFOLLOW +# define AT_SYMLINK_NOFOLLOW 4096 +#endif + +#ifndef AT_REMOVEDIR +# define AT_REMOVEDIR 1 +#endif + +/* Solaris 9 lacks these two, so just pick unique values. */ +#ifndef AT_SYMLINK_FOLLOW +# define AT_SYMLINK_FOLLOW 2 +#endif + +#ifndef AT_EACCESS +# define AT_EACCESS 4 +#endif + +/* Ignore this flag if not supported. */ +#ifndef AT_NO_AUTOMOUNT +# define AT_NO_AUTOMOUNT 0 +#endif + +#endif /* _@GUARD_PREFIX@_FCNTL_H */ +#endif /* _@GUARD_PREFIX@_FCNTL_H */ +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/fd-hook.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/fd-hook.c new file mode 100644 index 00000000..75bbe49c --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/fd-hook.c @@ -0,0 +1,116 @@ +/* Hook for making file descriptor functions close(), ioctl() extensible. + Copyright (C) 2009-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2009. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "fd-hook.h" + +#include + +/* Currently, this entire code is only needed for the handling of sockets + on native Windows platforms. */ +#if WINDOWS_SOCKETS + +/* The first and last link in the doubly linked list. + Initially the list is empty. */ +static struct fd_hook anchor = { &anchor, &anchor, NULL, NULL }; + +int +execute_close_hooks (const struct fd_hook *remaining_list, gl_close_fn primary, + int fd) +{ + if (remaining_list == &anchor) + /* End of list reached. */ + return primary (fd); + else + return remaining_list->private_close_fn (remaining_list->private_next, + primary, fd); +} + +int +execute_all_close_hooks (gl_close_fn primary, int fd) +{ + return execute_close_hooks (anchor.private_next, primary, fd); +} + +int +execute_ioctl_hooks (const struct fd_hook *remaining_list, gl_ioctl_fn primary, + int fd, int request, void *arg) +{ + if (remaining_list == &anchor) + /* End of list reached. */ + return primary (fd, request, arg); + else + return remaining_list->private_ioctl_fn (remaining_list->private_next, + primary, fd, request, arg); +} + +int +execute_all_ioctl_hooks (gl_ioctl_fn primary, + int fd, int request, void *arg) +{ + return execute_ioctl_hooks (anchor.private_next, primary, fd, request, arg); +} + +void +register_fd_hook (close_hook_fn close_hook, ioctl_hook_fn ioctl_hook, struct fd_hook *link) +{ + if (close_hook == NULL) + close_hook = execute_close_hooks; + if (ioctl_hook == NULL) + ioctl_hook = execute_ioctl_hooks; + + if (link->private_next == NULL && link->private_prev == NULL) + { + /* Add the link to the doubly linked list. */ + link->private_next = anchor.private_next; + link->private_prev = &anchor; + link->private_close_fn = close_hook; + link->private_ioctl_fn = ioctl_hook; + anchor.private_next->private_prev = link; + anchor.private_next = link; + } + else + { + /* The link is already in use. */ + if (link->private_close_fn != close_hook + || link->private_ioctl_fn != ioctl_hook) + abort (); + } +} + +void +unregister_fd_hook (struct fd_hook *link) +{ + struct fd_hook *next = link->private_next; + struct fd_hook *prev = link->private_prev; + + if (next != NULL && prev != NULL) + { + /* The link is in use. Remove it from the doubly linked list. */ + prev->private_next = next; + next->private_prev = prev; + /* Clear the link, to mark it unused. */ + link->private_next = NULL; + link->private_prev = NULL; + link->private_close_fn = NULL; + link->private_ioctl_fn = NULL; + } +} + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/fd-hook.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/fd-hook.h new file mode 100644 index 00000000..2150460b --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/fd-hook.h @@ -0,0 +1,119 @@ +/* Hook for making file descriptor functions close(), ioctl() extensible. + Copyright (C) 2009-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + + +#ifndef FD_HOOK_H +#define FD_HOOK_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/* Currently, this entire code is only needed for the handling of sockets + on native Windows platforms. */ +#if WINDOWS_SOCKETS + + +/* Type of function that closes FD. */ +typedef int (*gl_close_fn) (int fd); + +/* Type of function that applies a control request to FD. */ +typedef int (*gl_ioctl_fn) (int fd, int request, void *arg); + +/* An element of the list of file descriptor hooks. + In CLOS (Common Lisp Object System) speak, it consists of an "around" + method for the close() function and an "around" method for the ioctl() + function. + The fields of this structure are considered private. */ +struct fd_hook +{ + /* Doubly linked list. */ + struct fd_hook *private_next; + struct fd_hook *private_prev; + /* Function that treats the types of FD that it knows about and calls + execute_close_hooks (REMAINING_LIST, PRIMARY, FD) as a fallback. */ + int (*private_close_fn) (const struct fd_hook *remaining_list, + gl_close_fn primary, + int fd); + /* Function that treats the types of FD that it knows about and calls + execute_ioctl_hooks (REMAINING_LIST, PRIMARY, FD, REQUEST, ARG) as a + fallback. */ + int (*private_ioctl_fn) (const struct fd_hook *remaining_list, + gl_ioctl_fn primary, + int fd, int request, void *arg); +}; + +/* This type of function closes FD, applying special knowledge for the FD + types it knows about, and calls + execute_close_hooks (REMAINING_LIST, PRIMARY, FD) + for the other FD types. + In CLOS speak, REMAINING_LIST is the remaining list of "around" methods, + and PRIMARY is the "primary" method for close(). */ +typedef int (*close_hook_fn) (const struct fd_hook *remaining_list, + gl_close_fn primary, + int fd); + +/* Execute the close hooks in REMAINING_LIST, with PRIMARY as "primary" method. + Return 0 or -1, like close() would do. */ +extern int execute_close_hooks (const struct fd_hook *remaining_list, + gl_close_fn primary, + int fd); + +/* Execute all close hooks, with PRIMARY as "primary" method. + Return 0 or -1, like close() would do. */ +extern int execute_all_close_hooks (gl_close_fn primary, int fd); + +/* This type of function applies a control request to FD, applying special + knowledge for the FD types it knows about, and calls + execute_ioctl_hooks (REMAINING_LIST, PRIMARY, FD, REQUEST, ARG) + for the other FD types. + In CLOS speak, REMAINING_LIST is the remaining list of "around" methods, + and PRIMARY is the "primary" method for ioctl(). */ +typedef int (*ioctl_hook_fn) (const struct fd_hook *remaining_list, + gl_ioctl_fn primary, + int fd, int request, void *arg); + +/* Execute the ioctl hooks in REMAINING_LIST, with PRIMARY as "primary" method. + Return 0 or -1, like ioctl() would do. */ +extern int execute_ioctl_hooks (const struct fd_hook *remaining_list, + gl_ioctl_fn primary, + int fd, int request, void *arg); + +/* Execute all ioctl hooks, with PRIMARY as "primary" method. + Return 0 or -1, like ioctl() would do. */ +extern int execute_all_ioctl_hooks (gl_ioctl_fn primary, + int fd, int request, void *arg); + +/* Add a function pair to the list of file descriptor hooks. + CLOSE_HOOK and IOCTL_HOOK may be NULL, indicating no change. + The LINK variable points to a piece of memory which is guaranteed to be + accessible until the corresponding call to unregister_fd_hook. */ +extern void register_fd_hook (close_hook_fn close_hook, ioctl_hook_fn ioctl_hook, + struct fd_hook *link); + +/* Removes a hook from the list of file descriptor hooks. */ +extern void unregister_fd_hook (struct fd_hook *link); + + +#endif + + +#ifdef __cplusplus +} +#endif + +#endif /* FD_HOOK_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/fd-safer-flag.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/fd-safer-flag.c new file mode 100644 index 00000000..4cd1b148 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/fd-safer-flag.c @@ -0,0 +1,52 @@ +/* Adjust a file descriptor result so that it avoids clobbering + STD{IN,OUT,ERR}_FILENO, with specific flags. + + Copyright (C) 2005-2006, 2009-2024 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 . */ + +/* Written by Paul Eggert and Eric Blake. */ + +#include + +/* Specification. */ +#include "unistd-safer.h" + +#include +#include + +/* Return FD, unless FD would be a copy of standard input, output, or + error; in that case, return a duplicate of FD, closing FD. If FLAG + contains O_CLOEXEC, the returned FD will have close-on-exec + semantics. On failure to duplicate, close FD, set errno, and + return -1. Preserve errno if FD is negative, so that the caller + can always inspect errno when the returned value is negative. + + This function is usefully wrapped around functions that return file + descriptors, e.g., fd_safer_flag (open ("file", O_RDONLY | flag), flag). */ + +int +fd_safer_flag (int fd, int flag) +{ + if (STDIN_FILENO <= fd && fd <= STDERR_FILENO) + { + int f = dup_safer_flag (fd, flag); + int e = errno; + close (fd); + errno = e; + fd = f; + } + + return fd; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/fd-safer.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/fd-safer.c new file mode 100644 index 00000000..8d624337 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/fd-safer.c @@ -0,0 +1,49 @@ +/* Return a safer copy of a file descriptor. + + Copyright (C) 2005-2006, 2009-2024 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 . */ + +/* Written by Paul Eggert. */ + +#include + +#include "unistd-safer.h" + +#include +#include + +/* Return FD, unless FD would be a copy of standard input, output, or + error; in that case, return a duplicate of FD, closing FD. On + failure to duplicate, close FD, set errno, and return -1. Preserve + errno if FD is negative, so that the caller can always inspect + errno when the returned value is negative. + + This function is usefully wrapped around functions that return file + descriptors, e.g., fd_safer (open ("file", O_RDONLY)). */ + +int +fd_safer (int fd) +{ + if (STDIN_FILENO <= fd && fd <= STDERR_FILENO) + { + int f = dup_safer (fd); + int e = errno; + close (fd); + errno = e; + fd = f; + } + + return fd; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/fdopendir.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/fdopendir.c new file mode 100644 index 00000000..bdbb2ea9 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/fdopendir.c @@ -0,0 +1,238 @@ +/* provide a replacement fdopendir function + Copyright (C) 2004-2024 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 . */ + +/* written by Jim Meyering */ + +#include + +#include + +#include +#include + +#if !HAVE_FDOPENDIR + +# if GNULIB_defined_DIR +/* We are in control of the file descriptor of a DIR. */ + +# include "dirent-private.h" + +# if !REPLACE_FCHDIR +# error "unexpected configuration: GNULIB_defined_DIR but fchdir not replaced" +# endif + +DIR * +fdopendir (int fd) +{ + char const *name = _gl_directory_name (fd); + DIR *dirp = name ? opendir (name) : NULL; + if (dirp != NULL) + dirp->fd_to_close = fd; + return dirp; +} + +# else +/* We are not in control of the file descriptor of a DIR, and therefore have to + play tricks with file descriptors before and after a call to opendir(). */ + +# include "openat.h" +# include "openat-priv.h" +# include "save-cwd.h" + +# if GNULIB_DIRENT_SAFER +# include "dirent--.h" +# endif + +# ifndef REPLACE_FCHDIR +# define REPLACE_FCHDIR 0 +# endif + +static DIR *fdopendir_with_dup (int, int, struct saved_cwd const *); +static DIR *fd_clone_opendir (int, struct saved_cwd const *); + +/* Replacement for POSIX fdopendir. + + First, try to simulate it via opendir ("/proc/self/fd/..."). Failing + that, simulate it by using fchdir metadata, or by doing + save_cwd/fchdir/opendir(".")/restore_cwd. + If either the save_cwd or the restore_cwd fails (relatively unlikely), + then give a diagnostic and exit nonzero. + + If successful, the resulting stream is based on FD in + implementations where streams are based on file descriptors and in + applications where no other thread or signal handler allocates or + frees file descriptors. In other cases, consult dirfd on the result + to find out whether FD is still being used. + + Otherwise, this function works just like POSIX fdopendir. + + W A R N I N G: + + Unlike other fd-related functions, this one places constraints on FD. + If this function returns successfully, FD is under control of the + dirent.h system, and the caller should not close or modify the state of + FD other than by the dirent.h functions. */ +DIR * +fdopendir (int fd) +{ + DIR *dir = fdopendir_with_dup (fd, -1, NULL); + + if (! REPLACE_FCHDIR && ! dir) + { + int saved_errno = errno; + if (EXPECTED_ERRNO (saved_errno)) + { + struct saved_cwd cwd; + if (save_cwd (&cwd) != 0) + openat_save_fail (errno); + dir = fdopendir_with_dup (fd, -1, &cwd); + saved_errno = errno; + free_cwd (&cwd); + errno = saved_errno; + } + } + + return dir; +} + +/* Like fdopendir, except that if OLDER_DUPFD is not -1, it is known + to be a dup of FD which is less than FD - 1 and which will be + closed by the caller and not otherwise used by the caller. This + function makes sure that FD is closed and all file descriptors less + than FD are open, and then calls fd_clone_opendir on a dup of FD. + That way, barring race conditions, fd_clone_opendir returns a + stream whose file descriptor is FD. + + If REPLACE_FCHDIR or CWD is null, use opendir ("/proc/self/fd/...", + falling back on fchdir metadata. Otherwise, CWD is a saved version + of the working directory; use fchdir/opendir(".")/restore_cwd(CWD). */ +static DIR * +fdopendir_with_dup (int fd, int older_dupfd, struct saved_cwd const *cwd) +{ + int dupfd = dup (fd); + if (dupfd < 0 && errno == EMFILE) + dupfd = older_dupfd; + if (dupfd < 0) + return NULL; + else + { + DIR *dir; + int saved_errno; + if (dupfd < fd - 1 && dupfd != older_dupfd) + { + dir = fdopendir_with_dup (fd, dupfd, cwd); + saved_errno = errno; + } + else + { + close (fd); + dir = fd_clone_opendir (dupfd, cwd); + saved_errno = errno; + if (! dir) + { + int fd1 = dup (dupfd); + if (fd1 != fd) + openat_save_fail (fd1 < 0 ? errno : EBADF); + } + } + + if (dupfd != older_dupfd) + close (dupfd); + errno = saved_errno; + return dir; + } +} + +/* Like fdopendir, except the result controls a clone of FD. It is + the caller's responsibility both to close FD and (if the result is + not null) to closedir the result. */ +static DIR * +fd_clone_opendir (int fd, struct saved_cwd const *cwd) +{ + if (REPLACE_FCHDIR || ! cwd) + { + DIR *dir = NULL; + int saved_errno = EOPNOTSUPP; + char buf[OPENAT_BUFFER_SIZE]; + char *proc_file = openat_proc_name (buf, fd, "."); + if (proc_file) + { + dir = opendir (proc_file); + saved_errno = errno; + if (proc_file != buf) + free (proc_file); + } +# if REPLACE_FCHDIR + if (! dir && EXPECTED_ERRNO (saved_errno)) + { + char const *name = _gl_directory_name (fd); + DIR *dp = name ? opendir (name) : NULL; + + /* The caller has done an elaborate dance to arrange for opendir to + consume just the right file descriptor. If dirfd returns -1, + though, we're on a system like mingw where opendir does not + consume a file descriptor. Consume it via 'dup' instead. */ + if (dp && dirfd (dp) < 0) + dup (fd); + + return dp; + } +# endif + errno = saved_errno; + return dir; + } + else + { + if (fchdir (fd) != 0) + return NULL; + else + { + DIR *dir = opendir ("."); + int saved_errno = errno; + if (restore_cwd (cwd) != 0) + openat_restore_fail (errno); + errno = saved_errno; + return dir; + } + } +} + +# endif + +#else /* HAVE_FDOPENDIR */ + +# include +# include + +# undef fdopendir + +/* Like fdopendir, but work around GNU/Hurd bug by validating FD. */ + +DIR * +rpl_fdopendir (int fd) +{ + struct stat st; + if (fstat (fd, &st)) + return NULL; + if (!S_ISDIR (st.st_mode)) + { + errno = ENOTDIR; + return NULL; + } + return fdopendir (fd); +} + +#endif /* HAVE_FDOPENDIR */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/file-type.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/file-type.c new file mode 100644 index 00000000..657ca5c7 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/file-type.c @@ -0,0 +1,31 @@ +/* Return a string describing the type of a file. + + Copyright (C) 1993-1994, 2001-2002, 2004-2006, 2009-2024 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 . */ + +/* Written by Paul Eggert. */ + +#include + +#include "file-type.h" + +#include + +char const * +file_type (struct stat const *st) +{ + return gettext (c_file_type (st)); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/file-type.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/file-type.h new file mode 100644 index 00000000..7ca0357a --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/file-type.h @@ -0,0 +1,35 @@ +/* Return a string describing the type of a file. + + Copyright (C) 1993-1994, 2001-2002, 2004-2005, 2009-2024 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 . */ + +/* Written by Paul Eggert and Jim Meyering. */ + +#ifndef FILE_TYPE_H +# define FILE_TYPE_H 1 + +/* This file uses _GL_ATTRIBUTE_PURE. */ +# if !_GL_CONFIG_H_INCLUDED +# error "Please include config.h first." +# endif + +# include +# include + +char const *c_file_type (struct stat const *) _GL_ATTRIBUTE_PURE; +char const *file_type (struct stat const *) _GL_ATTRIBUTE_PURE; + +#endif /* FILE_TYPE_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/filename.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/filename.h new file mode 100644 index 00000000..a2400a9d --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/filename.h @@ -0,0 +1,112 @@ +/* Basic filename support macros. + Copyright (C) 2001-2023 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* From Paul Eggert and Jim Meyering. */ + +#ifndef _FILENAME_H +#define _FILENAME_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +/* 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 __MSDOS__ || defined __DJGPP__ + /* Native Windows, Cygwin, OS/2, DOS */ +# define ISSLASH(C) ((C) == '/' || (C) == '\\') + /* 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 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 +} +#endif + +#endif /* _FILENAME_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/filenamecat-lgpl.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/filenamecat-lgpl.c new file mode 100644 index 00000000..dc6d3468 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/filenamecat-lgpl.c @@ -0,0 +1,90 @@ +/* Concatenate two arbitrary file names. + + Copyright (C) 1996-2007, 2009-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Jim Meyering. */ + +#include + +/* Specification. */ +#include "filenamecat.h" + +#include +#include + +#include "basename-lgpl.h" +#include "filename.h" + +#if ! HAVE_MEMPCPY && ! defined mempcpy +# define mempcpy(D, S, N) ((void *) ((char *) memcpy (D, S, N) + (N))) +#endif + +/* Concatenate two file name components, DIR and BASE, in + newly-allocated storage and return the result. + The resulting file name F is such that the commands "ls F" and "(cd + DIR; ls ./BASE)" refer to the same file. If necessary, put + a separator between DIR and BASE in the result. Typically this + separator is "/", but in rare cases it might be ".". + In any case, if BASE_IN_RESULT is non-NULL, set + *BASE_IN_RESULT to point to the copy of BASE at the end of the + returned concatenation. + + If malloc fails, return NULL with errno set. */ + +char * +mfile_name_concat (char const *dir, char const *base, char **base_in_result) +{ + char const *dirbase = last_component (dir); + size_t dirbaselen = base_len (dirbase); + size_t dirlen = dirbase - dir + dirbaselen; + size_t baselen = strlen (base); + char sep = '\0'; + if (dirbaselen) + { + /* DIR is not a file system root, so separate with / if needed. */ + if (! ISSLASH (dir[dirlen - 1]) && ! ISSLASH (*base)) + sep = '/'; + } + else if (ISSLASH (*base)) + { + /* DIR is a file system root and BASE begins with a slash, so + separate with ".". For example, if DIR is "/" and BASE is + "/foo" then return "/./foo", as "//foo" would be wrong on + some POSIX systems. A fancier algorithm could omit "." in + some cases but is not worth the trouble. */ + sep = '.'; + } + + char *p_concat = malloc (dirlen + (sep != '\0') + baselen + 1); + if (p_concat == NULL) + return NULL; + + { + char *p; + + p = mempcpy (p_concat, dir, dirlen); + *p = sep; + p += sep != '\0'; + + if (base_in_result) + *base_in_result = p; + + p = mempcpy (p, base, baselen); + *p = '\0'; + } + + return p_concat; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/filenamecat.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/filenamecat.c new file mode 100644 index 00000000..b0d0fe72 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/filenamecat.c @@ -0,0 +1,41 @@ +/* Concatenate two arbitrary file names. + + Copyright (C) 1996-2007, 2009-2024 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 . */ + +/* Written by Jim Meyering. */ + +#include + +/* Specification. */ +#include "filenamecat.h" + +#include +#include + +#include "xalloc.h" + +/* Just like mfile_name_concat (filenamecat-lgpl.c), except, rather than + returning NULL upon malloc failure, here, we report the + "memory exhausted" condition and exit. */ + +char * +file_name_concat (char const *dir, char const *base, char **base_in_result) +{ + char *p = mfile_name_concat (dir, base, base_in_result); + if (p == NULL) + xalloc_die (); + return p; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/filenamecat.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/filenamecat.h new file mode 100644 index 00000000..8c8cf441 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/filenamecat.h @@ -0,0 +1,37 @@ +/* Concatenate two arbitrary file names. + + Copyright (C) 1996-1997, 2003, 2005, 2007, 2009-2024 Free Software + Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Jim Meyering. */ + +/* This file uses _GL_ATTRIBUTE_MALLOC, _GL_ATTRIBUTE_RETURNS_NONNULL. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +#include + +#if GNULIB_FILENAMECAT +char *file_name_concat (char const *dir, char const *base, + char **base_in_result) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE + _GL_ATTRIBUTE_RETURNS_NONNULL; +#endif + +char *mfile_name_concat (char const *dir, char const *base, + char **base_in_result) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE; diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/flexmember.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/flexmember.h new file mode 100644 index 00000000..6ef66a32 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/flexmember.h @@ -0,0 +1,76 @@ +/* Sizes of structs with flexible array members. + + Copyright 2016-2024 Free Software Foundation, Inc. + + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . + + Written by Paul Eggert. */ + +/* This file uses _Alignof. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +#include + +/* Nonzero multiple of alignment of TYPE, suitable for FLEXSIZEOF below. + On older platforms without _Alignof, use a pessimistic bound that is + safe in practice even if FLEXIBLE_ARRAY_MEMBER is 1. + On newer platforms, use _Alignof to get a tighter bound. */ + +#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 +# define FLEXALIGNOF(type) (sizeof (type) & ~ (sizeof (type) - 1)) +#else +# define FLEXALIGNOF(type) _Alignof (type) +#endif + +/* Yield a properly aligned upper bound on the size of a struct of + type TYPE with a flexible array member named MEMBER that is + followed by N bytes of other data. The result is suitable as an + argument to malloc. For example: + + struct s { int a; char d[FLEXIBLE_ARRAY_MEMBER]; }; + struct s *p = malloc (FLEXSIZEOF (struct s, d, n * sizeof (char))); + + FLEXSIZEOF (TYPE, MEMBER, N) is not simply (sizeof (TYPE) + N), + since FLEXIBLE_ARRAY_MEMBER may be 1 on pre-C11 platforms. Nor is + it simply (offsetof (TYPE, MEMBER) + N), as that might yield a size + that causes malloc to yield a pointer that is not properly aligned + for TYPE; for example, if sizeof (int) == alignof (int) == 4, + malloc (offsetof (struct s, d) + 3 * sizeof (char)) is equivalent + to malloc (7) and might yield a pointer that is not a multiple of 4 + (which means the pointer is not properly aligned for struct s), + whereas malloc (FLEXSIZEOF (struct s, d, 3 * sizeof (char))) is + equivalent to malloc (8) and must yield a pointer that is a + multiple of 4. + + Yield a value less than N if and only if arithmetic overflow occurs. */ + +#define FLEXSIZEOF(type, member, n) \ + ((offsetof (type, member) + FLEXALIGNOF (type) - 1 + (n)) \ + & ~ (FLEXALIGNOF (type) - 1)) + +/* Yield a properly aligned upper bound on the size of a struct of + type TYPE with a flexible array member named MEMBER that has N + elements. The result is suitable as an argument to malloc. + For example: + + struct s { int a; double d[FLEXIBLE_ARRAY_MEMBER]; }; + struct s *p = malloc (FLEXNSIZEOF (struct s, d, n)); + */ +#define FLEXNSIZEOF(type, member, n) \ + FLEXSIZEOF (type, member, (n) * sizeof (((type *) 0)->member[0])) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/fnmatch.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/fnmatch.c new file mode 100644 index 00000000..832b5a1e --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/fnmatch.c @@ -0,0 +1,391 @@ +/* Copyright (C) 1991-2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _LIBC +# include +#endif + +/* Enable GNU extensions in fnmatch.h. */ +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +#endif + +#include + +#include +#include +#include +#include +#include +#include +#if defined _LIBC || HAVE_ALLOCA +# include +#endif +#include +#include +#if defined _LIBC || !_GL_SMALL_WCHAR_T +/* It's OK to use wchar_t, since it's wide enough. */ +# include +# include +# define WCHAR_T wchar_t +# define WINT_T wint_t +# define BTOWC btowc +# define MBSRTOWCS mbsrtowcs +# define WCSLEN wcslen +# define WCSCAT wcscat +# define WMEMPCPY wmempcpy +# define WMEMCHR wmemchr +# define TOWLOWER towlower +# define WCTYPE_T wctype_t +# define WCTYPE wctype +# define ISWCTYPE iswctype +#else +/* wchar_t is too small, use char32_t instead. */ +# include "unistr.h" +# define WCHAR_T char32_t +# define WINT_T char32_t +# define BTOWC btoc32 +# define MBSRTOWCS mbsrtoc32s +# define WCSLEN u32_strlen +# define WCSCAT u32_strcat +# define WMEMPCPY u32_pcpy +# define WMEMCHR(S, C, N) u32_chr (S, N, C) +# define TOWLOWER c32tolower +# define WCTYPE_T c32_type_test_t +# define WCTYPE c32_get_type_test +# define ISWCTYPE c32_apply_type_test +#endif + +/* We need some of the locale data (the collation sequence information) + but there is no interface to get this information in general. Therefore + we support a correct implementation only in glibc. */ +#ifdef _LIBC +# include "../locale/localeinfo.h" +# include "../locale/coll-lookup.h" +# include + +# define CONCAT(a,b) __CONCAT(a,b) +# define btowc __btowc +# define iswctype __iswctype +# define mbsrtowcs __mbsrtowcs +# define mempcpy __mempcpy +# define strnlen __strnlen +# define towlower __towlower +# define wcscat __wcscat +# define wcslen __wcslen +# define wctype __wctype +# define wmemchr __wmemchr +# define wmempcpy __wmempcpy +# define fnmatch __fnmatch +extern int fnmatch (const char *pattern, const char *string, int flags); +#endif + +#ifdef _LIBC +# if __glibc_has_attribute (__fallthrough__) +# define FALLTHROUGH __attribute__ ((__fallthrough__)) +# else +# define FALLTHROUGH ((void) 0) +# endif +#else +# include "attribute.h" +#endif + +#include + +#ifdef _LIBC +typedef ptrdiff_t idx_t; +#else +# include "idx.h" +#endif + +/* We often have to test for FNM_FILE_NAME and FNM_PERIOD being both set. */ +#define NO_LEADING_PERIOD(flags) \ + ((flags & (FNM_FILE_NAME | FNM_PERIOD)) == (FNM_FILE_NAME | FNM_PERIOD)) + +#ifndef _LIBC +# if HAVE_ALLOCA +/* The OS usually guarantees only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + allocate anything larger than 4096 bytes. Also care for the possibility + of a few compiler-allocated temporary stack slots. */ +# define __libc_use_alloca(n) ((n) < 4032) +# else +/* Just use malloc. */ +# define __libc_use_alloca(n) false +# undef alloca +# define alloca(n) malloc (n) +# endif +# define alloca_account(size, avar) ((avar) += (size), alloca (size)) +#endif + +/* Provide support for user-defined character classes, based on the functions + from ISO C 90 amendment 1. */ +#ifdef CHARCLASS_NAME_MAX +# define CHAR_CLASS_MAX_LENGTH CHARCLASS_NAME_MAX +#else +/* This shouldn't happen but some implementation might still have this + problem. Use a reasonable default value. */ +# define CHAR_CLASS_MAX_LENGTH 256 +#endif + +#define IS_CHAR_CLASS(string) WCTYPE (string) + +/* Avoid depending on library functions or files + whose names are inconsistent. */ + +/* Global variable. */ +static int posixly_correct; + +/* Note that this evaluates C many times. */ +#define FOLD(c) ((flags & FNM_CASEFOLD) ? tolower (c) : (c)) +#define CHAR char +#define UCHAR unsigned char +#define INT int +#define FCT internal_fnmatch +#define EXT ext_match +#define END end_pattern +#define STRUCT fnmatch_struct +#define L_(CS) CS +#define UCHAR_TO_WCHAR(C) BTOWC (C) +#define STRLEN(S) strlen (S) +#define STRCAT(D, S) strcat (D, S) +#define MEMPCPY(D, S, N) mempcpy (D, S, N) +#define MEMCHR(S, C, N) memchr (S, C, N) +#define WIDE_CHAR_VERSION 0 +#ifdef _LIBC +# include +# define FINDIDX findidx +#endif +#include "fnmatch_loop.c" + + +#define FOLD(c) ((flags & FNM_CASEFOLD) ? TOWLOWER (c) : (c)) +#define CHAR WCHAR_T +#define UCHAR WINT_T +#define INT WINT_T +#define FCT internal_fnwmatch +#define EXT ext_wmatch +#define END end_wpattern +#define L_(CS) L##CS +#define UCHAR_TO_WCHAR(C) (C) +#define STRLEN(S) WCSLEN (S) +#define STRCAT(D, S) WCSCAT (D, S) +#define MEMPCPY(D, S, N) WMEMPCPY (D, S, N) +#define MEMCHR(S, C, N) WMEMCHR (S, C, N) +#define WIDE_CHAR_VERSION 1 +#ifdef _LIBC +/* Change the name the header defines so it doesn't conflict with + the version included above. */ +# define findidx findidxwc +# include +# undef findidx +# define FINDIDX findidxwc +#endif + +#undef IS_CHAR_CLASS +/* We have to convert the wide character string in a multibyte string. But + we know that the character class names consist of alphanumeric characters + from the portable character set, and since the wide character encoding + for a member of the portable character set is the same code point as + its single-byte encoding, we can use a simplified method to convert the + string to a multibyte character string. */ +static WCTYPE_T +is_char_class (const WCHAR_T *wcs) +{ + char s[CHAR_CLASS_MAX_LENGTH + 1]; + char *cp = s; + + do + { + /* Test for a printable character from the portable character set. */ +#ifdef _LIBC + if (*wcs < 0x20 || *wcs > 0x7e + || *wcs == 0x24 || *wcs == 0x40 || *wcs == 0x60) + return (WCTYPE_T) 0; +#else + switch (*wcs) + { + case L' ': case L'!': case L'"': case L'#': case L'%': + case L'&': case L'\'': case L'(': case L')': case L'*': + case L'+': case L',': case L'-': case L'.': case L'/': + case L'0': case L'1': case L'2': case L'3': case L'4': + case L'5': case L'6': case L'7': case L'8': case L'9': + case L':': case L';': case L'<': case L'=': case L'>': + case L'?': + case L'A': case L'B': case L'C': case L'D': case L'E': + case L'F': case L'G': case L'H': case L'I': case L'J': + case L'K': case L'L': case L'M': case L'N': case L'O': + case L'P': case L'Q': case L'R': case L'S': case L'T': + case L'U': case L'V': case L'W': case L'X': case L'Y': + case L'Z': + case L'[': case L'\\': case L']': case L'^': case L'_': + case L'a': case L'b': case L'c': case L'd': case L'e': + case L'f': case L'g': case L'h': case L'i': case L'j': + case L'k': case L'l': case L'm': case L'n': case L'o': + case L'p': case L'q': case L'r': case L's': case L't': + case L'u': case L'v': case L'w': case L'x': case L'y': + case L'z': case L'{': case L'|': case L'}': case L'~': + break; + default: + return (WCTYPE_T) 0; + } +#endif + + /* Avoid overrunning the buffer. */ + if (cp == s + CHAR_CLASS_MAX_LENGTH) + return (WCTYPE_T) 0; + + *cp++ = (char) *wcs++; + } + while (*wcs != L'\0'); + + *cp = '\0'; + + return WCTYPE (s); +} +#define IS_CHAR_CLASS(string) is_char_class (string) + +#include "fnmatch_loop.c" + + +int +fnmatch (const char *pattern, const char *string, int flags) +{ + if (__glibc_unlikely (MB_CUR_MAX != 1)) + { + mbstate_t ps; + size_t n; + const char *p; + WCHAR_T *wpattern_malloc = NULL; + WCHAR_T *wpattern; + WCHAR_T *wstring_malloc = NULL; + WCHAR_T *wstring; + size_t alloca_used = 0; + + /* Convert the strings into wide characters. */ + memset (&ps, '\0', sizeof (ps)); + p = pattern; + n = strnlen (pattern, 1024); + if (__glibc_likely (n < 1024)) + { + wpattern = (WCHAR_T *) alloca_account ((n + 1) * sizeof (WCHAR_T), + alloca_used); + n = MBSRTOWCS (wpattern, &p, n + 1, &ps); + if (__glibc_unlikely (n == (size_t) -1)) + /* Something wrong. + XXX Do we have to set 'errno' to something which mbsrtows hasn't + already done? */ + return -1; + if (p) + { + memset (&ps, '\0', sizeof (ps)); + goto prepare_wpattern; + } + } + else + { + prepare_wpattern: + n = MBSRTOWCS (NULL, &pattern, 0, &ps); + if (__glibc_unlikely (n == (size_t) -1)) + /* Something wrong. + XXX Do we have to set 'errno' to something which mbsrtows hasn't + already done? */ + return -1; + if (__glibc_unlikely (n >= (size_t) -1 / sizeof (WCHAR_T))) + { + __set_errno (ENOMEM); + return -2; + } + wpattern_malloc = wpattern + = (WCHAR_T *) malloc ((n + 1) * sizeof (WCHAR_T)); + assert (mbsinit (&ps)); + if (wpattern == NULL) + return -2; + (void) MBSRTOWCS (wpattern, &pattern, n + 1, &ps); + } + + assert (mbsinit (&ps)); + n = strnlen (string, 1024); + p = string; + if (__glibc_likely (n < 1024)) + { + wstring = (WCHAR_T *) alloca_account ((n + 1) * sizeof (WCHAR_T), + alloca_used); + n = MBSRTOWCS (wstring, &p, n + 1, &ps); + if (__glibc_unlikely (n == (size_t) -1)) + { + /* Something wrong. + XXX Do we have to set 'errno' to something which + mbsrtows hasn't already done? */ + free_return: + free (wpattern_malloc); + return -1; + } + if (p) + { + memset (&ps, '\0', sizeof (ps)); + goto prepare_wstring; + } + } + else + { + prepare_wstring: + n = MBSRTOWCS (NULL, &string, 0, &ps); + if (__glibc_unlikely (n == (size_t) -1)) + /* Something wrong. + XXX Do we have to set 'errno' to something which mbsrtows hasn't + already done? */ + goto free_return; + if (__glibc_unlikely (n >= (size_t) -1 / sizeof (WCHAR_T))) + { + free (wpattern_malloc); + __set_errno (ENOMEM); + return -2; + } + + wstring_malloc = wstring + = (WCHAR_T *) malloc ((n + 1) * sizeof (WCHAR_T)); + if (wstring == NULL) + { + free (wpattern_malloc); + return -2; + } + assert (mbsinit (&ps)); + (void) MBSRTOWCS (wstring, &string, n + 1, &ps); + } + + int res = internal_fnwmatch (wpattern, wstring, wstring + n, + flags & FNM_PERIOD, flags, NULL, + alloca_used); + + free (wstring_malloc); + free (wpattern_malloc); + + return res; + } + + return internal_fnmatch (pattern, string, string + strlen (string), + flags & FNM_PERIOD, flags, NULL, 0); +} + +#undef fnmatch +versioned_symbol (libc, __fnmatch, fnmatch, GLIBC_2_2_3); +#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_2_3) +strong_alias (__fnmatch, __fnmatch_old) +compat_symbol (libc, __fnmatch_old, fnmatch, GLIBC_2_0); +#endif +libc_hidden_ver (__fnmatch, fnmatch) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/fnmatch.in.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/fnmatch.in.h new file mode 100644 index 00000000..974bbffd --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/fnmatch.in.h @@ -0,0 +1,117 @@ +/* Substitute for and wrapper around . + Copyright (C) 1991-1993, 1996-1999, 2001-2003, 2005, 2007, 2009-2024 Free + Software Foundation, Inc. + + This file is part of the GNU C Library. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef _@GUARD_PREFIX@_FNMATCH_H + +#if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +#endif +@PRAGMA_COLUMNS@ + +/* The include_next requires a split double-inclusion guard. */ +#if @HAVE_FNMATCH_H@ && !@REPLACE_FNMATCH@ +# @INCLUDE_NEXT@ @NEXT_FNMATCH_H@ +#endif + +#ifndef _@GUARD_PREFIX@_FNMATCH_H +#define _@GUARD_PREFIX@_FNMATCH_H + +/* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#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. */ + +#if !@HAVE_FNMATCH_H@ || @REPLACE_FNMATCH@ + +/* We #undef these before defining them because some losing systems + (HP-UX A.08.07 for example) define these in . */ +#undef FNM_PATHNAME +#undef FNM_NOESCAPE +#undef FNM_PERIOD + +/* Bits set in the FLAGS argument to 'fnmatch'. */ +#define FNM_PATHNAME (1 << 0) /* No wildcard can ever match '/'. */ +#define FNM_NOESCAPE (1 << 1) /* Backslashes don't quote special chars. */ +#define FNM_PERIOD (1 << 2) /* Leading '.' is matched only explicitly. */ + +#if !defined _POSIX_C_SOURCE || _POSIX_C_SOURCE < 2 || defined _GNU_SOURCE +# define FNM_FILE_NAME FNM_PATHNAME /* Preferred GNU name. */ +# define FNM_LEADING_DIR (1 << 3) /* Ignore '/...' after a match. */ +# define FNM_CASEFOLD (1 << 4) /* Compare without regard to case. */ +# define FNM_EXTMATCH (1 << 5) /* Use ksh-like extended matching. */ +#endif + +/* Value returned by 'fnmatch' if STRING does not match PATTERN. */ +#define FNM_NOMATCH 1 + +/* This value is returned if the implementation does not support + 'fnmatch'. Since this is not the case here it will never be + returned but the conformance test suites still require the symbol + to be defined. */ +#ifdef _XOPEN_SOURCE +# define FNM_NOSYS (-1) +#endif + +#endif + + +#if @GNULIB_FNMATCH@ +/* Match NAME against the file name pattern PATTERN, + returning zero if it matches, FNM_NOMATCH if not. */ +# if @REPLACE_FNMATCH@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define fnmatch rpl_fnmatch +# endif +# define GNULIB_defined_fnmatch_function 1 +_GL_FUNCDECL_RPL (fnmatch, int, + (const char *pattern, const char *name, int flags) + _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (fnmatch, int, + (const char *pattern, const char *name, int flags)); +# else +# if !@HAVE_FNMATCH@ +# define GNULIB_defined_fnmatch_function 1 +_GL_FUNCDECL_SYS (fnmatch, int, + (const char *pattern, const char *name, int flags) + _GL_ARG_NONNULL ((1, 2))); +# endif +_GL_CXXALIAS_SYS (fnmatch, int, + (const char *pattern, const char *name, int flags)); +# endif +# if !GNULIB_FNMATCH_GNU && __GLIBC__ >= 2 +_GL_CXXALIASWARN (fnmatch); +# endif +#elif defined GNULIB_POSIXCHECK +# undef fnmatch +# if HAVE_RAW_DECL_FNMATCH +_GL_WARN_ON_USE (fnmatch, + "fnmatch does not portably work - " + "use gnulib module fnmatch for portability or gnulib module fnmatch-gnu for a glibc compatible implementation"); +# endif +#endif + + +#endif /* _@GUARD_PREFIX@_FNMATCH_H */ +#endif /* _@GUARD_PREFIX@_FNMATCH_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/fnmatch_loop.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/fnmatch_loop.c new file mode 100644 index 00000000..4e6e0865 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/fnmatch_loop.c @@ -0,0 +1,1211 @@ +/* Copyright (C) 1991-2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifdef _LIBC +# include +#endif + +struct STRUCT +{ + const CHAR *pattern; + const CHAR *string; + bool no_leading_period; +}; + +/* Match STRING against the file name pattern PATTERN, returning zero if + it matches, nonzero if not. */ +static int FCT (const CHAR *pattern, const CHAR *string, + const CHAR *string_end, bool no_leading_period, int flags, + struct STRUCT *ends, size_t alloca_used); +static int EXT (INT opt, const CHAR *pattern, const CHAR *string, + const CHAR *string_end, bool no_leading_period, int flags, + size_t alloca_used); +static const CHAR *END (const CHAR *patternp); + +static int +FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end, + bool no_leading_period, int flags, struct STRUCT *ends, size_t alloca_used) +{ + const CHAR *p = pattern, *n = string; + UCHAR c; +#ifdef _LIBC +# if WIDE_CHAR_VERSION + const char *collseq = (const char *) + _NL_CURRENT(LC_COLLATE, _NL_COLLATE_COLLSEQWC); +# else + const UCHAR *collseq = (const UCHAR *) + _NL_CURRENT(LC_COLLATE, _NL_COLLATE_COLLSEQMB); +# endif +#endif + + while ((c = *p++) != L_('\0')) + { + bool new_no_leading_period = false; + c = FOLD (c); + + switch (c) + { + case L_('?'): + if (__glibc_unlikely (flags & FNM_EXTMATCH) && *p == '(') + { + int res = EXT (c, p, n, string_end, no_leading_period, + flags, alloca_used); + if (res != -1) + return res; + } + + if (n == string_end) + return FNM_NOMATCH; + else if (*n == L_('/') && (flags & FNM_FILE_NAME)) + return FNM_NOMATCH; + else if (*n == L_('.') && no_leading_period) + return FNM_NOMATCH; + break; + + case L_('\\'): + if (!(flags & FNM_NOESCAPE)) + { + c = *p++; + if (c == L_('\0')) + /* Trailing \ loses. */ + return FNM_NOMATCH; + c = FOLD (c); + } + if (n == string_end || FOLD ((UCHAR) *n) != c) + return FNM_NOMATCH; + break; + + case L_('*'): + if (__glibc_unlikely (flags & FNM_EXTMATCH) && *p == '(') + { + int res = EXT (c, p, n, string_end, no_leading_period, + flags, alloca_used); + if (res != -1) + return res; + } + else if (ends != NULL) + { + ends->pattern = p - 1; + ends->string = n; + ends->no_leading_period = no_leading_period; + return 0; + } + + if (n != string_end && *n == L_('.') && no_leading_period) + return FNM_NOMATCH; + + for (c = *p++; c == L_('?') || c == L_('*'); c = *p++) + { + if (*p == L_('(') && (flags & FNM_EXTMATCH) != 0) + { + const CHAR *endp = END (p); + if (endp != p) + { + /* This is a pattern. Skip over it. */ + p = endp; + continue; + } + } + + if (c == L_('?')) + { + /* A ? needs to match one character. */ + if (n == string_end) + /* There isn't another character; no match. */ + return FNM_NOMATCH; + else if (*n == L_('/') + && __glibc_unlikely (flags & FNM_FILE_NAME)) + /* A slash does not match a wildcard under + FNM_FILE_NAME. */ + return FNM_NOMATCH; + else + /* One character of the string is consumed in matching + this ? wildcard, so *??? won't match if there are + less than three characters. */ + ++n; + } + } + + if (c == L_('\0')) + /* The wildcard(s) is/are the last element of the pattern. + If the name is a file name and contains another slash + this means it cannot match, unless the FNM_LEADING_DIR + flag is set. */ + { + int result = (flags & FNM_FILE_NAME) == 0 ? 0 : FNM_NOMATCH; + + if (flags & FNM_FILE_NAME) + { + if (flags & FNM_LEADING_DIR) + result = 0; + else + { + if (MEMCHR (n, L_('/'), string_end - n) == NULL) + result = 0; + } + } + + return result; + } + else + { + const CHAR *endp; + struct STRUCT end; + + end.pattern = NULL; + endp = MEMCHR (n, (flags & FNM_FILE_NAME) ? L_('/') : L_('\0'), + string_end - n); + if (endp == NULL) + endp = string_end; + + if (c == L_('[') + || (__glibc_unlikely (flags & FNM_EXTMATCH) + && (c == L_('@') || c == L_('+') || c == L_('!')) + && *p == L_('('))) + { + int flags2 = ((flags & FNM_FILE_NAME) + ? flags : (flags & ~FNM_PERIOD)); + + for (--p; n < endp; ++n, no_leading_period = false) + if (FCT (p, n, string_end, no_leading_period, flags2, + &end, alloca_used) == 0) + goto found; + } + else if (c == L_('/') && (flags & FNM_FILE_NAME)) + { + while (n < string_end && *n != L_('/')) + ++n; + if (n < string_end && *n == L_('/') + && (FCT (p, n + 1, string_end, flags & FNM_PERIOD, flags, + NULL, alloca_used) == 0)) + return 0; + } + else + { + int flags2 = ((flags & FNM_FILE_NAME) + ? flags : (flags & ~FNM_PERIOD)); + + if (c == L_('\\') && !(flags & FNM_NOESCAPE)) + c = *p; + c = FOLD (c); + for (--p; n < endp; ++n, no_leading_period = false) + if (FOLD ((UCHAR) *n) == c + && (FCT (p, n, string_end, no_leading_period, flags2, + &end, alloca_used) == 0)) + { + found: + if (end.pattern == NULL) + return 0; + break; + } + if (end.pattern != NULL) + { + p = end.pattern; + n = end.string; + no_leading_period = end.no_leading_period; + continue; + } + } + } + + /* If we come here no match is possible with the wildcard. */ + return FNM_NOMATCH; + + case L_('['): + { + /* Nonzero if the sense of the character class is inverted. */ + const CHAR *p_init = p; + const CHAR *n_init = n; + bool not; + CHAR cold; + UCHAR fn; + + if (posixly_correct == 0) + posixly_correct = getenv ("POSIXLY_CORRECT") != NULL ? 1 : -1; + + if (n == string_end) + return FNM_NOMATCH; + + if (*n == L_('.') && no_leading_period) + return FNM_NOMATCH; + + if (*n == L_('/') && (flags & FNM_FILE_NAME)) + /* '/' cannot be matched. */ + return FNM_NOMATCH; + + not = (*p == L_('!') || (posixly_correct < 0 && *p == L_('^'))); + if (not) + ++p; + + fn = FOLD ((UCHAR) *n); + + c = *p++; + for (;;) + { + if (!(flags & FNM_NOESCAPE) && c == L_('\\')) + { + if (*p == L_('\0')) + return FNM_NOMATCH; + c = FOLD ((UCHAR) *p); + ++p; + + goto normal_bracket; + } + else if (c == L_('[') && *p == L_(':')) + { + /* Leave room for the null. */ + CHAR str[CHAR_CLASS_MAX_LENGTH + 1]; + size_t c1 = 0; + WCTYPE_T wt; + const CHAR *startp = p; + + for (;;) + { + if (c1 == CHAR_CLASS_MAX_LENGTH) + /* The name is too long and therefore the pattern + is ill-formed. */ + return FNM_NOMATCH; + + c = *++p; + if (c == L_(':') && p[1] == L_(']')) + { + p += 2; + break; + } + if (c < L_('a') || c >= L_('z')) + { + /* This cannot possibly be a character class name. + Match it as a normal range. */ + p = startp; + c = L_('['); + goto normal_bracket; + } + str[c1++] = c; + } + str[c1] = L_('\0'); + + wt = IS_CHAR_CLASS (str); + if (wt == 0) + /* Invalid character class name. */ + return FNM_NOMATCH; + +#if defined _LIBC && ! WIDE_CHAR_VERSION + /* The following code is glibc specific but does + there a good job in speeding up the code since + we can avoid the btowc() call. */ + if (_ISCTYPE ((UCHAR) *n, wt)) + goto matched; +#else + if (ISWCTYPE (UCHAR_TO_WCHAR ((UCHAR) *n), wt)) + goto matched; +#endif + c = *p++; + } +#ifdef _LIBC + else if (c == L_('[') && *p == L_('=')) + { + /* It's important that STR be a scalar variable rather + than a one-element array, because GCC (at least 4.9.2 + -O2 on x86-64) can be confused by the array and + diagnose a "used initialized" in a dead branch in the + findidx function. */ + UCHAR str; + uint32_t nrules = + _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES); + const CHAR *startp = p; + + c = *++p; + if (c == L_('\0')) + { + p = startp; + c = L_('['); + goto normal_bracket; + } + str = c; + + c = *++p; + if (c != L_('=') || p[1] != L_(']')) + { + p = startp; + c = L_('['); + goto normal_bracket; + } + p += 2; + + if (nrules == 0) + { + if ((UCHAR) *n == str) + goto matched; + } + else + { + const int32_t *table; +# if WIDE_CHAR_VERSION + const int32_t *weights; + const wint_t *extra; +# else + const unsigned char *weights; + const unsigned char *extra; +# endif + const int32_t *indirect; + int32_t idx; + const UCHAR *cp = (const UCHAR *) &str; + +# if WIDE_CHAR_VERSION + table = (const int32_t *) + _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEWC); + weights = (const int32_t *) + _NL_CURRENT (LC_COLLATE, _NL_COLLATE_WEIGHTWC); + extra = (const wint_t *) + _NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAWC); + indirect = (const int32_t *) + _NL_CURRENT (LC_COLLATE, _NL_COLLATE_INDIRECTWC); +# else + table = (const int32_t *) + _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB); + weights = (const unsigned char *) + _NL_CURRENT (LC_COLLATE, _NL_COLLATE_WEIGHTMB); + extra = (const unsigned char *) + _NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAMB); + indirect = (const int32_t *) + _NL_CURRENT (LC_COLLATE, _NL_COLLATE_INDIRECTMB); +# endif + + idx = FINDIDX (table, indirect, extra, &cp, 1); + if (idx != 0) + { + /* We found a table entry. Now see whether the + character we are currently at has the same + equivalence class value. */ + int len = weights[idx & 0xffffff]; + int32_t idx2; + const UCHAR *np = (const UCHAR *) n; + + idx2 = FINDIDX (table, indirect, extra, + &np, string_end - n); + if (idx2 != 0 + && (idx >> 24) == (idx2 >> 24) + && len == weights[idx2 & 0xffffff]) + { + int cnt = 0; + + idx &= 0xffffff; + idx2 &= 0xffffff; + + while (cnt < len + && (weights[idx + 1 + cnt] + == weights[idx2 + 1 + cnt])) + ++cnt; + + if (cnt == len) + goto matched; + } + } + } + + c = *p++; + } +#endif + else if (c == L_('\0')) + { + /* [ unterminated, treat as normal character. */ + p = p_init; + n = n_init; + c = L_('['); + goto normal_match; + } + else + { + bool is_range = false; + +#ifdef _LIBC + bool is_seqval = false; + + if (c == L_('[') && *p == L_('.')) + { + uint32_t nrules = + _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES); + const CHAR *startp = p; + size_t c1 = 0; + + while (1) + { + c = *++p; + if (c == L_('.') && p[1] == L_(']')) + { + p += 2; + break; + } + if (c == '\0') + return FNM_NOMATCH; + ++c1; + } + + /* We have to handling the symbols differently in + ranges since then the collation sequence is + important. */ + is_range = *p == L_('-') && p[1] != L_('\0'); + + if (nrules == 0) + { + /* There are no names defined in the collation + data. Therefore we only accept the trivial + names consisting of the character itself. */ + if (c1 != 1) + return FNM_NOMATCH; + + if (!is_range && *n == startp[1]) + goto matched; + + cold = startp[1]; + c = *p++; + } + else + { + int32_t table_size; + const int32_t *symb_table; + const unsigned char *extra; + int32_t idx; + int32_t elem; +# if WIDE_CHAR_VERSION + CHAR *wextra; +# endif + + table_size = + _NL_CURRENT_WORD (LC_COLLATE, + _NL_COLLATE_SYMB_HASH_SIZEMB); + symb_table = (const int32_t *) + _NL_CURRENT (LC_COLLATE, + _NL_COLLATE_SYMB_TABLEMB); + extra = (const unsigned char *) + _NL_CURRENT (LC_COLLATE, + _NL_COLLATE_SYMB_EXTRAMB); + + for (elem = 0; elem < table_size; elem++) + if (symb_table[2 * elem] != 0) + { + idx = symb_table[2 * elem + 1]; + /* Skip the name of collating element. */ + idx += 1 + extra[idx]; +# if WIDE_CHAR_VERSION + /* Skip the byte sequence of the + collating element. */ + idx += 1 + extra[idx]; + /* Adjust for the alignment. */ + idx = (idx + 3) & ~3; + + wextra = (CHAR *) &extra[idx + 4]; + + if (/* Compare the length of the sequence. */ + c1 == wextra[0] + /* Compare the wide char sequence. */ + && (__wmemcmp (startp + 1, &wextra[1], + c1) + == 0)) + /* Yep, this is the entry. */ + break; +# else + if (/* Compare the length of the sequence. */ + c1 == extra[idx] + /* Compare the byte sequence. */ + && memcmp (startp + 1, + &extra[idx + 1], c1) == 0) + /* Yep, this is the entry. */ + break; +# endif + } + + if (elem < table_size) + { + /* Compare the byte sequence but only if + this is not part of a range. */ + if (! is_range + +# if WIDE_CHAR_VERSION + && __wmemcmp (n, &wextra[1], c1) == 0 +# else + && memcmp (n, &extra[idx + 1], c1) == 0 +# endif + ) + { + n += c1 - 1; + goto matched; + } + + /* Get the collation sequence value. */ + is_seqval = true; +# if WIDE_CHAR_VERSION + cold = wextra[1 + wextra[0]]; +# else + idx += 1 + extra[idx]; + /* Adjust for the alignment. */ + idx = (idx + 3) & ~3; + cold = *((int32_t *) &extra[idx]); +# endif + + c = *p++; + } + else if (c1 == 1) + { + /* No valid character. Match it as a + single byte. */ + if (!is_range && *n == startp[1]) + goto matched; + + cold = startp[1]; + c = *p++; + } + else + return FNM_NOMATCH; + } + } + else +#endif + { + c = FOLD (c); + normal_bracket: + + /* We have to handling the symbols differently in + ranges since then the collation sequence is + important. */ + is_range = (*p == L_('-') && p[1] != L_('\0') + && p[1] != L_(']')); + + if (!is_range && c == fn) + goto matched; + +#if _LIBC + /* This is needed if we goto normal_bracket; from + outside of is_seqval's scope. */ + is_seqval = false; +#endif + cold = c; + c = *p++; + } + + if (c == L_('-') && *p != L_(']')) + { +#if _LIBC + /* We have to find the collation sequence + value for C. Collation sequence is nothing + we can regularly access. The sequence + value is defined by the order in which the + definitions of the collation values for the + various characters appear in the source + file. A strange concept, nowhere + documented. */ + uint32_t fcollseq; + uint32_t lcollseq; + UCHAR cend = *p++; + +# if WIDE_CHAR_VERSION + /* Search in the 'names' array for the characters. */ + fcollseq = __collseq_table_lookup (collseq, fn); + if (fcollseq == ~((uint32_t) 0)) + /* XXX We don't know anything about the character + we are supposed to match. This means we are + failing. */ + goto range_not_matched; + + if (is_seqval) + lcollseq = cold; + else + lcollseq = __collseq_table_lookup (collseq, cold); +# else + fcollseq = collseq[fn]; + lcollseq = is_seqval ? cold : collseq[(UCHAR) cold]; +# endif + + is_seqval = false; + if (cend == L_('[') && *p == L_('.')) + { + uint32_t nrules = + _NL_CURRENT_WORD (LC_COLLATE, + _NL_COLLATE_NRULES); + const CHAR *startp = p; + size_t c1 = 0; + + while (1) + { + c = *++p; + if (c == L_('.') && p[1] == L_(']')) + { + p += 2; + break; + } + if (c == '\0') + return FNM_NOMATCH; + ++c1; + } + + if (nrules == 0) + { + /* There are no names defined in the + collation data. Therefore we only + accept the trivial names consisting + of the character itself. */ + if (c1 != 1) + return FNM_NOMATCH; + + cend = startp[1]; + } + else + { + int32_t table_size; + const int32_t *symb_table; + const unsigned char *extra; + int32_t idx; + int32_t elem; +# if WIDE_CHAR_VERSION + CHAR *wextra; +# endif + + table_size = + _NL_CURRENT_WORD (LC_COLLATE, + _NL_COLLATE_SYMB_HASH_SIZEMB); + symb_table = (const int32_t *) + _NL_CURRENT (LC_COLLATE, + _NL_COLLATE_SYMB_TABLEMB); + extra = (const unsigned char *) + _NL_CURRENT (LC_COLLATE, + _NL_COLLATE_SYMB_EXTRAMB); + + for (elem = 0; elem < table_size; elem++) + if (symb_table[2 * elem] != 0) + { + idx = symb_table[2 * elem + 1]; + /* Skip the name of collating + element. */ + idx += 1 + extra[idx]; +# if WIDE_CHAR_VERSION + /* Skip the byte sequence of the + collating element. */ + idx += 1 + extra[idx]; + /* Adjust for the alignment. */ + idx = (idx + 3) & ~3; + + wextra = (CHAR *) &extra[idx + 4]; + + if (/* Compare the length of the + sequence. */ + c1 == wextra[0] + /* Compare the wide char sequence. */ + && (__wmemcmp (startp + 1, + &wextra[1], c1) + == 0)) + /* Yep, this is the entry. */ + break; +# else + if (/* Compare the length of the + sequence. */ + c1 == extra[idx] + /* Compare the byte sequence. */ + && memcmp (startp + 1, + &extra[idx + 1], c1) == 0) + /* Yep, this is the entry. */ + break; +# endif + } + + if (elem < table_size) + { + /* Get the collation sequence value. */ + is_seqval = true; +# if WIDE_CHAR_VERSION + cend = wextra[1 + wextra[0]]; +# else + idx += 1 + extra[idx]; + /* Adjust for the alignment. */ + idx = (idx + 3) & ~3; + cend = *((int32_t *) &extra[idx]); +# endif + } + else if (c1 == 1) + { + cend = startp[1]; + c = *p++; + } + else + return FNM_NOMATCH; + } + } + else + { + if (!(flags & FNM_NOESCAPE) && cend == L_('\\')) + cend = *p++; + if (cend == L_('\0')) + return FNM_NOMATCH; + cend = FOLD (cend); + } + + /* XXX It is not entirely clear to me how to handle + characters which are not mentioned in the + collation specification. */ + if ( +# if WIDE_CHAR_VERSION + lcollseq == 0xffffffff || +# endif + lcollseq <= fcollseq) + { + /* We have to look at the upper bound. */ + uint32_t hcollseq; + + if (is_seqval) + hcollseq = cend; + else + { +# if WIDE_CHAR_VERSION + hcollseq = + __collseq_table_lookup (collseq, cend); + if (hcollseq == ~((uint32_t) 0)) + { + /* Hum, no information about the upper + bound. The matching succeeds if the + lower bound is matched exactly. */ + if (lcollseq != fcollseq) + goto range_not_matched; + + goto matched; + } +# else + hcollseq = collseq[cend]; +# endif + } + + if (lcollseq <= hcollseq && fcollseq <= hcollseq) + goto matched; + } +# if WIDE_CHAR_VERSION + range_not_matched: +# endif +#else + /* We use a boring value comparison of the character + values. This is better than comparing using + 'strcoll' since the latter would have surprising + and sometimes fatal consequences. */ + UCHAR cend = *p++; + + if (!(flags & FNM_NOESCAPE) && cend == L_('\\')) + cend = *p++; + if (cend == L_('\0')) + return FNM_NOMATCH; + + /* It is a range. */ + if ((UCHAR) cold <= fn && fn <= cend) + goto matched; +#endif + + c = *p++; + } + } + + if (c == L_(']')) + break; + } + + if (!not) + return FNM_NOMATCH; + break; + + matched: + /* Skip the rest of the [...] that already matched. */ + while ((c = *p++) != L_(']')) + { + if (c == L_('\0')) + /* [... (unterminated) loses. */ + return FNM_NOMATCH; + + if (!(flags & FNM_NOESCAPE) && c == L_('\\')) + { + if (*p == L_('\0')) + return FNM_NOMATCH; + /* XXX 1003.2d11 is unclear if this is right. */ + ++p; + } + else if (c == L_('[') && *p == L_(':')) + { + int c1 = 0; + const CHAR *startp = p; + + while (1) + { + c = *++p; + if (++c1 == CHAR_CLASS_MAX_LENGTH) + return FNM_NOMATCH; + + if (*p == L_(':') && p[1] == L_(']')) + break; + + if (c < L_('a') || c >= L_('z')) + { + p = startp - 2; + break; + } + } + p += 2; + } + else if (c == L_('[') && *p == L_('=')) + { + c = *++p; + if (c == L_('\0')) + return FNM_NOMATCH; + c = *++p; + if (c != L_('=') || p[1] != L_(']')) + return FNM_NOMATCH; + p += 2; + } + else if (c == L_('[') && *p == L_('.')) + { + while (1) + { + c = *++p; + if (c == L_('\0')) + return FNM_NOMATCH; + + if (c == L_('.') && p[1] == L_(']')) + break; + } + p += 2; + } + } + if (not) + return FNM_NOMATCH; + } + break; + + case L_('+'): + case L_('@'): + case L_('!'): + if (__glibc_unlikely (flags & FNM_EXTMATCH) && *p == '(') + { + int res = EXT (c, p, n, string_end, no_leading_period, flags, + alloca_used); + if (res != -1) + return res; + } + goto normal_match; + + case L_('/'): + if (NO_LEADING_PERIOD (flags)) + { + if (n == string_end || c != (UCHAR) *n) + return FNM_NOMATCH; + + new_no_leading_period = true; + break; + } + FALLTHROUGH; + default: + normal_match: + if (n == string_end || c != FOLD ((UCHAR) *n)) + return FNM_NOMATCH; + } + + no_leading_period = new_no_leading_period; + ++n; + } + + if (n == string_end) + return 0; + + if ((flags & FNM_LEADING_DIR) && n != string_end && *n == L_('/')) + /* The FNM_LEADING_DIR flag says that "foo*" matches "foobar/frobozz". */ + return 0; + + return FNM_NOMATCH; +} + + +static const CHAR * +END (const CHAR *pattern) +{ + const CHAR *p = pattern; + + while (1) + if (*++p == L_('\0')) + /* This is an invalid pattern. */ + return pattern; + else if (*p == L_('[')) + { + /* Handle brackets special. */ + if (posixly_correct == 0) + posixly_correct = getenv ("POSIXLY_CORRECT") != NULL ? 1 : -1; + + /* Skip the not sign. We have to recognize it because of a possibly + following ']'. */ + if (*++p == L_('!') || (posixly_correct < 0 && *p == L_('^'))) + ++p; + /* A leading ']' is recognized as such. */ + if (*p == L_(']')) + ++p; + /* Skip over all characters of the list. */ + while (*p != L_(']')) + if (*p++ == L_('\0')) + /* This is no valid pattern. */ + return pattern; + } + else if ((*p == L_('?') || *p == L_('*') || *p == L_('+') || *p == L_('@') + || *p == L_('!')) && p[1] == L_('(')) + { + p = END (p + 1); + if (*p == L_('\0')) + /* This is an invalid pattern. */ + return pattern; + } + else if (*p == L_(')')) + break; + + return p + 1; +} + + +static int +EXT (INT opt, const CHAR *pattern, const CHAR *string, const CHAR *string_end, + bool no_leading_period, int flags, size_t alloca_used) +{ + const CHAR *startp; + ptrdiff_t level; + struct patternlist + { + struct patternlist *next; + CHAR malloced; + CHAR str __flexarr; + } *list = NULL; + struct patternlist **lastp = &list; + size_t pattern_len = STRLEN (pattern); + bool any_malloced = false; + const CHAR *p; + const CHAR *rs; + int retval = 0; + + /* Parse the pattern. Store the individual parts in the list. */ + level = 0; + for (startp = p = pattern + 1; level >= 0; ++p) + if (*p == L_('\0')) + { + /* This is an invalid pattern. */ + retval = -1; + goto out; + } + else if (*p == L_('[')) + { + /* Handle brackets special. */ + if (posixly_correct == 0) + posixly_correct = getenv ("POSIXLY_CORRECT") != NULL ? 1 : -1; + + /* Skip the not sign. We have to recognize it because of a possibly + following ']'. */ + if (*++p == L_('!') || (posixly_correct < 0 && *p == L_('^'))) + ++p; + /* A leading ']' is recognized as such. */ + if (*p == L_(']')) + ++p; + /* Skip over all characters of the list. */ + while (*p != L_(']')) + if (*p++ == L_('\0')) + { + /* This is no valid pattern. */ + retval = -1; + goto out; + } + } + else if ((*p == L_('?') || *p == L_('*') || *p == L_('+') || *p == L_('@') + || *p == L_('!')) && p[1] == L_('(')) + /* Remember the nesting level. */ + ++level; + else if (*p == L_(')')) + { + if (level-- == 0) + { + /* This means we found the end of the pattern. */ +#define NEW_PATTERN \ + struct patternlist *newp; \ + size_t plen = (opt == L_('?') || opt == L_('@') \ + ? pattern_len : (p - startp + 1UL)); \ + idx_t slen = FLEXSIZEOF (struct patternlist, str, 0); \ + idx_t new_used = alloca_used + slen; \ + idx_t plensize; \ + if (ckd_mul (&plensize, plen, sizeof (CHAR)) \ + || ckd_add (&new_used, new_used, plensize)) \ + { \ + retval = -2; \ + goto out; \ + } \ + slen += plensize; \ + bool malloced = ! __libc_use_alloca (new_used); \ + if (__glibc_unlikely (malloced)) \ + { \ + newp = malloc (slen); \ + if (newp == NULL) \ + { \ + retval = -2; \ + goto out; \ + } \ + any_malloced = true; \ + } \ + else \ + newp = alloca_account (slen, alloca_used); \ + newp->next = NULL; \ + newp->malloced = malloced; \ + *((CHAR *) MEMPCPY (newp->str, startp, p - startp)) = L_('\0'); \ + *lastp = newp; \ + lastp = &newp->next + NEW_PATTERN; + } + } + else if (*p == L_('|')) + { + if (level == 0) + { + NEW_PATTERN; + startp = p + 1; + } + } + assert (list != NULL); + assert (p[-1] == L_(')')); +#undef NEW_PATTERN + + switch (opt) + { + case L_('*'): + if (FCT (p, string, string_end, no_leading_period, flags, NULL, + alloca_used) == 0) + goto success; + FALLTHROUGH; + case L_('+'): + do + { + for (rs = string; rs <= string_end; ++rs) + /* First match the prefix with the current pattern with the + current pattern. */ + if (FCT (list->str, string, rs, no_leading_period, + flags & FNM_FILE_NAME ? flags : flags & ~FNM_PERIOD, + NULL, alloca_used) == 0 + /* This was successful. Now match the rest with the rest + of the pattern. */ + && (FCT (p, rs, string_end, + rs == string + ? no_leading_period + : rs[-1] == '/' && NO_LEADING_PERIOD (flags), + flags & FNM_FILE_NAME + ? flags : flags & ~FNM_PERIOD, NULL, alloca_used) == 0 + /* This didn't work. Try the whole pattern. */ + || (rs != string + && FCT (pattern - 1, rs, string_end, + rs == string + ? no_leading_period + : rs[-1] == '/' && NO_LEADING_PERIOD (flags), + flags & FNM_FILE_NAME + ? flags : flags & ~FNM_PERIOD, NULL, + alloca_used) == 0))) + /* It worked. Signal success. */ + goto success; + } + while ((list = list->next) != NULL); + + /* None of the patterns lead to a match. */ + retval = FNM_NOMATCH; + break; + + case L_('?'): + if (FCT (p, string, string_end, no_leading_period, flags, NULL, + alloca_used) == 0) + goto success; + FALLTHROUGH; + case L_('@'): + do + /* I cannot believe it but 'strcat' is actually acceptable + here. Match the entire string with the prefix from the + pattern list and the rest of the pattern following the + pattern list. */ + if (FCT (STRCAT (list->str, p), string, string_end, + no_leading_period, + flags & FNM_FILE_NAME ? flags : flags & ~FNM_PERIOD, + NULL, alloca_used) == 0) + /* It worked. Signal success. */ + goto success; + while ((list = list->next) != NULL); + + /* None of the patterns lead to a match. */ + retval = FNM_NOMATCH; + break; + + case L_('!'): + for (rs = string; rs <= string_end; ++rs) + { + struct patternlist *runp; + + for (runp = list; runp != NULL; runp = runp->next) + if (FCT (runp->str, string, rs, no_leading_period, + flags & FNM_FILE_NAME ? flags : flags & ~FNM_PERIOD, + NULL, alloca_used) == 0) + break; + + /* If none of the patterns matched see whether the rest does. */ + if (runp == NULL + && (FCT (p, rs, string_end, + rs == string + ? no_leading_period + : rs[-1] == '/' && NO_LEADING_PERIOD (flags), + flags & FNM_FILE_NAME ? flags : flags & ~FNM_PERIOD, + NULL, alloca_used) == 0)) + /* This is successful. */ + goto success; + } + + /* None of the patterns together with the rest of the pattern + lead to a match. */ + retval = FNM_NOMATCH; + break; + + default: + assert (! "Invalid extended matching operator"); + retval = -1; + break; + } + + success: + out: + if (any_malloced) + while (list != NULL) + { + struct patternlist *old = list; + list = list->next; + if (old->malloced) + free (old); + } + + return retval; +} + + +#undef FOLD +#undef CHAR +#undef UCHAR +#undef INT +#undef FCT +#undef EXT +#undef END +#undef STRUCT +#undef MEMPCPY +#undef MEMCHR +#undef STRLEN +#undef STRCAT +#undef L_ +#undef UCHAR_TO_WCHAR +#undef WIDE_CHAR_VERSION +#undef FINDIDX diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/fopen.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/fopen.c new file mode 100644 index 00000000..d3b57a98 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/fopen.c @@ -0,0 +1,237 @@ +/* Open a stream to a file. + Copyright (C) 2007-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 2007. */ + +/* If the user's config.h happens to include , let it include only + the system's here, so that orig_fopen doesn't recurse to + rpl_fopen. */ +#define _GL_ALREADY_INCLUDING_STDIO_H +#include + +/* Get the original definition of fopen. It might be defined as a macro. */ +#include +#undef _GL_ALREADY_INCLUDING_STDIO_H + +static FILE * +orig_fopen (const char *filename, const char *mode) +{ + return fopen (filename, mode); +} + +/* Specification. */ +#ifdef __osf__ +/* Write "stdio.h" here, not , otherwise OSF/1 5.1 DTK cc eliminates + this include because of the preliminary #include above. */ +# include "stdio.h" +#else +# include +#endif + +#include +#include +#include +#include +#include +#include + +FILE * +rpl_fopen (const char *filename, const char *mode) +{ + int open_direction; + int open_flags; +#if GNULIB_FOPEN_GNU + bool open_flags_gnu; +# define BUF_SIZE 80 + char fdopen_mode_buf[BUF_SIZE + 1]; +#endif + +#if defined _WIN32 && ! defined __CYGWIN__ + if (strcmp (filename, "/dev/null") == 0) + filename = "NUL"; +#endif + + /* Parse the mode. */ + open_direction = 0; + open_flags = 0; +#if GNULIB_FOPEN_GNU + open_flags_gnu = false; +#endif + { + const char *p = mode; +#if GNULIB_FOPEN_GNU + char *q = fdopen_mode_buf; +#endif + + for (; *p != '\0'; p++) + { + switch (*p) + { + case 'r': + open_direction = O_RDONLY; +#if GNULIB_FOPEN_GNU + if (q < fdopen_mode_buf + BUF_SIZE) + *q++ = *p; +#endif + continue; + case 'w': + open_direction = O_WRONLY; + open_flags |= O_CREAT | O_TRUNC; +#if GNULIB_FOPEN_GNU + if (q < fdopen_mode_buf + BUF_SIZE) + *q++ = *p; +#endif + continue; + case 'a': + open_direction = O_WRONLY; + open_flags |= O_CREAT | O_APPEND; +#if GNULIB_FOPEN_GNU + if (q < fdopen_mode_buf + BUF_SIZE) + *q++ = *p; +#endif + continue; + case 'b': + /* While it is non-standard, O_BINARY is guaranteed by + gnulib . We can also assume that orig_fopen + supports the 'b' flag. */ + open_flags |= O_BINARY; +#if GNULIB_FOPEN_GNU + if (q < fdopen_mode_buf + BUF_SIZE) + *q++ = *p; +#endif + continue; + case '+': + open_direction = O_RDWR; +#if GNULIB_FOPEN_GNU + if (q < fdopen_mode_buf + BUF_SIZE) + *q++ = *p; +#endif + continue; +#if GNULIB_FOPEN_GNU + case 'x': + open_flags |= O_EXCL; + open_flags_gnu = true; + continue; + case 'e': + open_flags |= O_CLOEXEC; + open_flags_gnu = true; + continue; +#endif + default: + break; + } +#if GNULIB_FOPEN_GNU + /* The rest of the mode string can be a platform-dependent extension. + Copy it unmodified. */ + { + size_t len = strlen (p); + if (len > fdopen_mode_buf + BUF_SIZE - q) + len = fdopen_mode_buf + BUF_SIZE - q; + memcpy (q, p, len); + q += len; + } +#endif + break; + } +#if GNULIB_FOPEN_GNU + *q = '\0'; +#endif + } + +#if FOPEN_TRAILING_SLASH_BUG + /* Fail if the mode requires write access and the filename ends in a slash, + as POSIX says such a filename must name a directory + : + "A pathname that contains at least one non- character and that + ends with one or more trailing characters shall not be resolved + successfully unless the last pathname component before the trailing + characters names an existing directory" + If the named file already exists as a directory, then if a mode that + requires write access is specified, fopen() must fail because POSIX + + says that it fails with errno = EISDIR in this case. + If the named file does not exist or does not name a directory, then + fopen() must fail since the file does not contain a '.' directory. */ + { + size_t len = strlen (filename); + if (len > 0 && filename[len - 1] == '/') + { + int fd; + struct stat statbuf; + FILE *fp; + + if (open_direction != O_RDONLY) + { + errno = EISDIR; + return NULL; + } + + fd = open (filename, open_direction | open_flags, + S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); + if (fd < 0) + return NULL; + + if (fstat (fd, &statbuf) >= 0 && !S_ISDIR (statbuf.st_mode)) + { + close (fd); + errno = ENOTDIR; + return NULL; + } + +# if GNULIB_FOPEN_GNU + fp = fdopen (fd, fdopen_mode_buf); +# else + fp = fdopen (fd, mode); +# endif + if (fp == NULL) + { + int saved_errno = errno; + close (fd); + errno = saved_errno; + } + return fp; + } + } +#endif + +#if GNULIB_FOPEN_GNU + if (open_flags_gnu) + { + int fd; + FILE *fp; + + fd = open (filename, open_direction | open_flags, + S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); + if (fd < 0) + return NULL; + + fp = fdopen (fd, fdopen_mode_buf); + if (fp == NULL) + { + int saved_errno = errno; + close (fd); + errno = saved_errno; + } + return fp; + } +#endif + + /* open_direction is sometimes used, sometimes unused. + Silence gcc's warning about this situation. */ + (void) open_direction; + + return orig_fopen (filename, mode); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/free.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/free.c new file mode 100644 index 00000000..2f0c40ba --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/free.c @@ -0,0 +1,53 @@ +/* Make free() preserve errno. + + Copyright (C) 2003, 2006, 2009-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* written by Paul Eggert */ + +#include + +/* Specification. */ +#include + +/* A function definition is only needed if HAVE_FREE_POSIX is not defined. */ +#if !HAVE_FREE_POSIX + +# include + +void +rpl_free (void *p) +# undef free +{ +# if defined __GNUC__ && !defined __clang__ + /* An invalid GCC optimization + + would optimize away the assignments in the code below, when link-time + optimization (LTO) is enabled. Make the code more complicated, so that + GCC does not grok how to optimize it. */ + int err[2]; + err[0] = errno; + err[1] = errno; + errno = 0; + free (p); + errno = err[errno == 0]; +# else + int err = errno; + free (p); + errno = err; +# endif +} + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/freopen.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/freopen.c new file mode 100644 index 00000000..e003c0ba --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/freopen.c @@ -0,0 +1,96 @@ +/* Open a stream to a file. + Copyright (C) 2007-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 2007. */ + +/* If the user's config.h happens to include , let it include only + the system's here, so that orig_freopen doesn't recurse to + rpl_freopen. */ +#define _GL_ALREADY_INCLUDING_STDIO_H +#include + +/* Get the original definition of freopen. It might be defined as a macro. */ +#include +#undef _GL_ALREADY_INCLUDING_STDIO_H + +#include + +static FILE * +orig_freopen (const char *filename, const char *mode, FILE *stream) +{ + return freopen (filename, mode, stream); +} + +/* Specification. */ +#ifdef __osf__ +/* Write "stdio.h" here, not , otherwise OSF/1 5.1 DTK cc eliminates + this include because of the preliminary #include above. */ +# include "stdio.h" +#else +# include +#endif + +#include +#include +#include + +FILE * +rpl_freopen (const char *filename, const char *mode, FILE *stream) +{ + FILE *result; +#if defined _WIN32 && ! defined __CYGWIN__ + char const *null_device = "NUL"; + if (filename && strcmp (filename, "/dev/null") == 0) + filename = null_device; +#else + char const *null_device = "/dev/null"; +#endif + +#ifdef __KLIBC__ + errno = 0; +#endif + + result = orig_freopen (filename, mode, stream); + + if (!result) + { +#ifdef __KLIBC__ + /* On OS/2 kLIBC, freopen returns NULL even if it is successful + if filename is NULL. */ + if (!filename && !errno) + result = stream; +#endif + } + else if (filename) + { + int fd = fileno (result); + if (dup2 (fd, fd) < 0 && errno == EBADF) + { + int nullfd = open (null_device, O_RDONLY | O_CLOEXEC); + int err = 0; + if (nullfd != fd) + { + if (dup2 (nullfd, fd) < 0) + err = 1; + close (nullfd); + } + if (!err) + result = orig_freopen (filename, mode, result); + } + } + + return result; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/fstat.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/fstat.c new file mode 100644 index 00000000..205d5aab --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/fstat.c @@ -0,0 +1,94 @@ +/* fstat() replacement. + Copyright (C) 2011-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* If the user's config.h happens to include , let it include only + the system's here, so that orig_fstat doesn't recurse to + rpl_fstat. */ +#define __need_system_sys_stat_h +#include + +/* Get the original definition of fstat. It might be defined as a macro. */ +#include +#include +#undef __need_system_sys_stat_h + +#if defined _WIN32 && ! defined __CYGWIN__ +# define WINDOWS_NATIVE +#endif + +#if !defined WINDOWS_NATIVE + +static int +orig_fstat (int fd, struct stat *buf) +{ + return fstat (fd, buf); +} + +#endif + +/* Specification. */ +#ifdef __osf__ +/* Write "sys/stat.h" here, not , otherwise OSF/1 5.1 DTK cc + eliminates this include because of the preliminary #include + above. */ +# include "sys/stat.h" +#else +# include +#endif + +#include "stat-time.h" + +#include +#include +#ifdef WINDOWS_NATIVE +# define WIN32_LEAN_AND_MEAN +# include +# if GNULIB_MSVC_NOTHROW +# include "msvc-nothrow.h" +# else +# include +# endif +# include "stat-w32.h" +#endif + +int +rpl_fstat (int fd, struct stat *buf) +{ +#if REPLACE_FCHDIR && REPLACE_OPEN_DIRECTORY + /* Handle the case when rpl_open() used a dummy file descriptor to work + around an open() that can't normally visit directories. */ + const char *name = _gl_directory_name (fd); + if (name != NULL) + return stat (name, buf); +#endif + +#ifdef WINDOWS_NATIVE + /* Fill the fields ourselves, because the original fstat function returns + values for st_atime, st_mtime, st_ctime that depend on the current time + zone. See + */ + HANDLE h = (HANDLE) _get_osfhandle (fd); + + if (h == INVALID_HANDLE_VALUE) + { + errno = EBADF; + return -1; + } + return _gl_fstat_by_handle (h, NULL, buf); +#else + return stat_time_normalize (orig_fstat (fd, buf), buf); +#endif +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/fstatat.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/fstatat.c new file mode 100644 index 00000000..470ef336 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/fstatat.c @@ -0,0 +1,148 @@ +/* Work around an fstatat bug on Solaris 9. + + Copyright (C) 2006, 2009-2024 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 . */ + +/* Written by Paul Eggert and Jim Meyering. */ + +/* If the user's config.h happens to include , let it include only + the system's here, so that orig_fstatat doesn't recurse to + rpl_fstatat. */ +#define __need_system_sys_stat_h +#include + +/* Get the original definition of fstatat. It might be defined as a macro. */ +#include +#include +#undef __need_system_sys_stat_h + +#if HAVE_FSTATAT && HAVE_WORKING_FSTATAT_ZERO_FLAG +static int +orig_fstatat (int fd, char const *filename, struct stat *buf, int flags) +{ + return fstatat (fd, filename, buf, flags); +} +#endif + +#ifdef __osf__ +/* Write "sys/stat.h" here, not , otherwise OSF/1 5.1 DTK cc + eliminates this include because of the preliminary #include + above. */ +# include "sys/stat.h" +#else +# include +#endif + +#include "stat-time.h" + +#include +#include +#include +#include + +#if HAVE_FSTATAT && HAVE_WORKING_FSTATAT_ZERO_FLAG + +# ifndef LSTAT_FOLLOWS_SLASHED_SYMLINK +# define LSTAT_FOLLOWS_SLASHED_SYMLINK 0 +# endif + +static int +normal_fstatat (int fd, char const *file, struct stat *st, int flag) +{ + return stat_time_normalize (orig_fstatat (fd, file, st, flag), st); +} + +/* fstatat should always follow symbolic links that end in /, but on + Solaris 9 it doesn't if AT_SYMLINK_NOFOLLOW is specified. + Likewise, trailing slash on a non-directory should be an error. + These are the same problems that lstat.c and stat.c address, so + solve it in a similar way. + + AIX 7.1 fstatat (AT_FDCWD, ..., 0) always fails, which is a bug. + Work around this bug if FSTATAT_AT_FDCWD_0_BROKEN is nonzero. */ + +int +rpl_fstatat (int fd, char const *file, struct stat *st, int flag) +{ + int result = normal_fstatat (fd, file, st, flag); + size_t len; + + if (LSTAT_FOLLOWS_SLASHED_SYMLINK || result != 0) + return result; + len = strlen (file); + if (flag & AT_SYMLINK_NOFOLLOW) + { + /* Fix lstat behavior. */ + if (file[len - 1] != '/' || S_ISDIR (st->st_mode)) + return 0; + if (!S_ISLNK (st->st_mode)) + { + errno = ENOTDIR; + return -1; + } + result = normal_fstatat (fd, file, st, flag & ~AT_SYMLINK_NOFOLLOW); + } + /* Fix stat behavior. */ + if (result == 0 && !S_ISDIR (st->st_mode) && file[len - 1] == '/') + { + errno = ENOTDIR; + return -1; + } + return result; +} + +#else /* ! (HAVE_FSTATAT && HAVE_WORKING_FSTATAT_ZERO_FLAG) */ + +/* On mingw, the gnulib defines 'stat' as a function-like + macro; but using it in AT_FUNC_F2 causes compilation failure + because the preprocessor sees a use of a macro that requires two + arguments but is only given one. Hence, we need an inline + forwarder to get past the preprocessor. */ +static int +stat_func (char const *name, struct stat *st) +{ + return stat (name, st); +} + +/* Likewise, if there is no native 'lstat', then the gnulib + defined it as stat, which also needs adjustment. */ +# if !HAVE_LSTAT +# undef lstat +# define lstat stat_func +# endif + +/* Replacement for Solaris' function by the same name. + + First, try to simulate it via l?stat ("/proc/self/fd/FD/FILE"). + Failing that, simulate it via save_cwd/fchdir/(stat|lstat)/restore_cwd. + If either the save_cwd or the restore_cwd fails (relatively unlikely), + then give a diagnostic and exit nonzero. + Otherwise, this function works just like Solaris' fstatat. */ + +# define AT_FUNC_NAME fstatat +# define AT_FUNC_F1 lstat +# define AT_FUNC_F2 stat_func +# define AT_FUNC_USE_F1_COND AT_SYMLINK_NOFOLLOW +# define AT_FUNC_POST_FILE_PARAM_DECLS , struct stat *st, int flag +# define AT_FUNC_POST_FILE_ARGS , st +# include "at-func.c" +# undef AT_FUNC_NAME +# undef AT_FUNC_F1 +# undef AT_FUNC_F2 +# undef AT_FUNC_USE_F1_COND +# undef AT_FUNC_POST_FILE_PARAM_DECLS +# undef AT_FUNC_POST_FILE_ARGS + +#endif /* !HAVE_FSTATAT */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getcwd-lgpl.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getcwd-lgpl.c new file mode 100644 index 00000000..67ed2878 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getcwd-lgpl.c @@ -0,0 +1,127 @@ +/* Copyright (C) 2011-2024 Free Software Foundation, Inc. + This file is part of gnulib. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification */ +#include + +#include +#include +#include + +#if GNULIB_GETCWD +/* Favor GPL getcwd.c if both getcwd and getcwd-lgpl modules are in use. */ +typedef int dummy; +#else + +/* Get the name of the current working directory, and put it in SIZE + bytes of BUF. Returns NULL if the directory couldn't be determined + (perhaps because the absolute name was longer than PATH_MAX, or + because of missing read/search permissions on parent directories) + or SIZE was too small. If successful, returns BUF. If BUF is + NULL, an array is allocated with 'malloc'; the array is SIZE bytes + long, unless SIZE == 0, in which case it is as big as + necessary. */ + +# undef getcwd +# if defined _WIN32 && !defined __CYGWIN__ +# define getcwd _getcwd +# endif + +char * +rpl_getcwd (char *buf, size_t size) +{ + char *result; + + /* Handle single size operations. */ + if (buf) + { + /* Check SIZE argument. */ + if (!size) + { + errno = EINVAL; + return NULL; + } + return getcwd (buf, size); + } + + if (size) + { + buf = malloc (size); + if (!buf) + { + errno = ENOMEM; + return NULL; + } + result = getcwd (buf, size); + if (!result) + free (buf); + return result; + } + + /* Flexible sizing requested. Avoid over-allocation for the common + case of a name that fits within a 4k page, minus some space for + local variables, to be sure we don't skip over a guard page. */ + { + char tmp[4032]; + size = sizeof tmp; + char *ptr = getcwd (tmp, size); + if (ptr) + { + result = strdup (ptr); + if (!result) + errno = ENOMEM; + return result; + } + if (errno != ERANGE) + return NULL; + } + + /* My what a large directory name we have. */ + do + { + size <<= 1; + char *ptr = realloc (buf, size); + if (ptr == NULL) + { + free (buf); + errno = ENOMEM; + return NULL; + } + buf = ptr; + result = getcwd (buf, size); + } + while (!result && errno == ERANGE); + + if (!result) + free (buf); + else + { + /* Here result == buf. */ + /* Shrink result before returning it. */ + size_t actual_size = strlen (result) + 1; + if (actual_size < size) + { + char *shrinked_result = realloc (result, actual_size); + if (shrinked_result != NULL) + result = shrinked_result; + } + } + return result; +} + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getdtablesize.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getdtablesize.c new file mode 100644 index 00000000..762c100b --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getdtablesize.c @@ -0,0 +1,124 @@ +/* getdtablesize() function: Return maximum possible file descriptor value + 1. + Copyright (C) 2008-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2008. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +#if defined _WIN32 && ! defined __CYGWIN__ + +# include + +# if HAVE_MSVC_INVALID_PARAMETER_HANDLER +# include "msvc-inval.h" +# endif + +# if HAVE_MSVC_INVALID_PARAMETER_HANDLER +static int +_setmaxstdio_nothrow (int newmax) +{ + int result; + + TRY_MSVC_INVAL + { + result = _setmaxstdio (newmax); + } + CATCH_MSVC_INVAL + { + result = -1; + } + DONE_MSVC_INVAL; + + return result; +} +# else +# define _setmaxstdio_nothrow _setmaxstdio +# endif + +/* Cache for the previous getdtablesize () result. Safe to cache because + Windows also lacks setrlimit. */ +static int dtablesize; + +int +getdtablesize (void) +{ + if (dtablesize == 0) + { + /* We are looking for the number N such that the valid file descriptors + are 0..N-1. It can be obtained through a loop as follows: + { + int fd; + for (fd = 3; fd < 65536; fd++) + if (dup2 (0, fd) == -1) + break; + return fd; + } + On Windows XP, the result is 2048. + The drawback of this loop is that it allocates memory for a libc + internal array that is never freed. + + The number N can also be obtained as the upper bound for + _getmaxstdio (). _getmaxstdio () returns the maximum number of open + FILE objects. The sanity check in _setmaxstdio reveals the maximum + number of file descriptors. This too allocates memory, but it is + freed when we call _setmaxstdio with the original value. */ + int orig_max_stdio = _getmaxstdio (); + unsigned int bound; + for (bound = 0x10000; _setmaxstdio_nothrow (bound) < 0; bound = bound / 2) + ; + _setmaxstdio_nothrow (orig_max_stdio); + dtablesize = bound; + } + return dtablesize; +} + +#else + +# include +# include + +# ifndef RLIM_SAVED_CUR +# define RLIM_SAVED_CUR RLIM_INFINITY +# endif +# ifndef RLIM_SAVED_MAX +# define RLIM_SAVED_MAX RLIM_INFINITY +# endif + +# ifdef __CYGWIN__ + /* Cygwin 1.7.25 auto-increases the RLIMIT_NOFILE soft limit until it + hits the compile-time constant hard limit of 3200. We might as + well just report the hard limit. */ +# define rlim_cur rlim_max +# endif + +int +getdtablesize (void) +{ + struct rlimit lim; + + if (getrlimit (RLIMIT_NOFILE, &lim) == 0 + && 0 <= lim.rlim_cur && lim.rlim_cur <= INT_MAX + && lim.rlim_cur != RLIM_INFINITY + && lim.rlim_cur != RLIM_SAVED_CUR + && lim.rlim_cur != RLIM_SAVED_MAX) + return lim.rlim_cur; + + return INT_MAX; +} + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getopt-cdefs.in.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getopt-cdefs.in.h new file mode 100644 index 00000000..a1d304d4 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getopt-cdefs.in.h @@ -0,0 +1,70 @@ +/* getopt-on-non-glibc compatibility macros. + Copyright (C) 1989-2024 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. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef _GETOPT_CDEFS_H +#define _GETOPT_CDEFS_H 1 + +/* This header should not be used directly; include getopt.h or + unistd.h instead. It does not have a protective #error, because + the guard macro for getopt.h in gnulib is not fixed. */ + +/* getopt-core.h and getopt-ext.h are shared with GNU libc, and expect + a number of the internal macros supplied to GNU libc's headers by + sys/cdefs.h. Provide fallback definitions for all of them. */ +#if @HAVE_SYS_CDEFS_H@ +# include +#endif + +#ifndef __BEGIN_DECLS +# ifdef __cplusplus +# define __BEGIN_DECLS extern "C" { +# else +# define __BEGIN_DECLS /* nothing */ +# endif +#endif +#ifndef __END_DECLS +# ifdef __cplusplus +# define __END_DECLS } +# else +# define __END_DECLS /* nothing */ +# endif +#endif + +#ifndef __GNUC_PREREQ +# if defined __GNUC__ && defined __GNUC_VERSION__ +# define __GNUC_PREREQ(maj, min) \ + ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) +# else +# define __GNUC_PREREQ(maj, min) 0 +# endif +#endif + +#ifndef __THROW +# if defined __cplusplus && (__GNUC_PREREQ (2,8) || __clang_major__ >= 4) +# if __cplusplus >= 201103L +# define __THROW noexcept (true) +# else +# define __THROW throw () +# endif +# else +# define __THROW +# endif +#endif + +#endif /* _GETOPT_CDEFS_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getopt-core.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getopt-core.h new file mode 100644 index 00000000..12d09a25 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getopt-core.h @@ -0,0 +1,96 @@ +/* Declarations for getopt (basic, portable features only). + Copyright (C) 1989-2024 Free Software Foundation, Inc. + This file is part of the GNU C Library and is also part of gnulib. + Patches to this file should be submitted to both projects. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _GETOPT_CORE_H +#define _GETOPT_CORE_H 1 + +/* This header should not be used directly; include getopt.h or + unistd.h instead. Unlike most bits headers, it does not have + a protective #error, because the guard macro for getopt.h in + gnulib is not fixed. */ + +__BEGIN_DECLS + +/* For communication from 'getopt' to the caller. + When 'getopt' finds an option that takes an argument, + the argument value is returned here. + Also, when 'ordering' is RETURN_IN_ORDER, + each non-option ARGV-element is returned here. */ + +extern char *optarg; + +/* Index in ARGV of the next element to be scanned. + This is used for communication to and from the caller + and for communication between successive calls to 'getopt'. + + On entry to 'getopt', zero means this is the first call; initialize. + + When 'getopt' returns -1, this is the index of the first of the + non-option elements that the caller should itself scan. + + Otherwise, 'optind' communicates from one call to the next + how much of ARGV has been scanned so far. */ + +extern int optind; + +/* Callers store zero here to inhibit the error message 'getopt' prints + for unrecognized options. */ + +extern int opterr; + +/* Set to an option character which was unrecognized. */ + +extern int optopt; + +/* Get definitions and prototypes for functions to process the + arguments in ARGV (ARGC of them, minus the program name) for + options given in OPTS. + + Return the option character from OPTS just read. Return -1 when + there are no more options. For unrecognized options, or options + missing arguments, 'optopt' is set to the option letter, and '?' is + returned. + + The OPTS string is a list of characters which are recognized option + letters, optionally followed by colons, specifying that that letter + takes an argument, to be placed in 'optarg'. + + If a letter in OPTS is followed by two colons, its argument is + optional. This behavior is specific to the GNU 'getopt'. + + The argument '--' causes premature termination of argument + scanning, explicitly telling 'getopt' that there are no more + options. + + If OPTS begins with '-', then non-option arguments are treated as + arguments to the option '\1'. This behavior is specific to the GNU + 'getopt'. If OPTS begins with '+', or POSIXLY_CORRECT is set in + the environment, then do not permute arguments. + + For standards compliance, the 'argv' argument has the type + char *const *, but this is inaccurate; if argument permutation is + enabled, the argv array (not the strings it points to) must be + writable. */ + +extern int getopt (int ___argc, char *const *___argv, const char *__shortopts) + __THROW _GL_ARG_NONNULL ((2, 3)); + +__END_DECLS + +#endif /* _GETOPT_CORE_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getopt-ext.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getopt-ext.h new file mode 100644 index 00000000..e4b499d4 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getopt-ext.h @@ -0,0 +1,77 @@ +/* Declarations for getopt (GNU extensions). + Copyright (C) 1989-2024 Free Software Foundation, Inc. + This file is part of the GNU C Library and is also part of gnulib. + Patches to this file should be submitted to both projects. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _GETOPT_EXT_H +#define _GETOPT_EXT_H 1 + +/* This header should not be used directly; include getopt.h instead. + Unlike most bits headers, it does not have a protective #error, + because the guard macro for getopt.h in gnulib is not fixed. */ + +__BEGIN_DECLS + +/* Describe the long-named options requested by the application. + The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector + of 'struct option' terminated by an element containing a name which is + zero. + + The field 'has_arg' is: + no_argument (or 0) if the option does not take an argument, + required_argument (or 1) if the option requires an argument, + optional_argument (or 2) if the option takes an optional argument. + + If the field 'flag' is not NULL, it points to a variable that is set + to the value given in the field 'val' when the option is found, but + left unchanged if the option is not found. + + To have a long-named option do something other than set an 'int' to + a compiled-in constant, such as set a value from 'optarg', set the + option's 'flag' field to zero and its 'val' field to a nonzero + value (the equivalent single-letter option character, if there is + one). For long options that have a zero 'flag' field, 'getopt' + returns the contents of the 'val' field. */ + +struct option +{ + const char *name; + /* has_arg can't be an enum because some compilers complain about + type mismatches in all the code that assumes it is an int. */ + int has_arg; + int *flag; + int val; +}; + +/* Names for the values of the 'has_arg' field of 'struct option'. */ + +#define no_argument 0 +#define required_argument 1 +#define optional_argument 2 + +extern int getopt_long (int ___argc, char *__getopt_argv_const *___argv, + const char *__shortopts, + const struct option *__longopts, int *__longind) + __THROW _GL_ARG_NONNULL ((2, 3)); +extern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv, + const char *__shortopts, + const struct option *__longopts, int *__longind) + __THROW _GL_ARG_NONNULL ((2, 3)); + +__END_DECLS + +#endif /* _GETOPT_EXT_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getopt-pfx-core.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getopt-pfx-core.h new file mode 100644 index 00000000..78b7816a --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getopt-pfx-core.h @@ -0,0 +1,66 @@ +/* getopt (basic, portable features) gnulib wrapper header. + Copyright (C) 1989-2024 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. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef _GETOPT_PFX_CORE_H +#define _GETOPT_PFX_CORE_H 1 + +/* This header should not be used directly; include getopt.h or + unistd.h instead. It does not have a protective #error, because + the guard macro for getopt.h in gnulib is not fixed. */ + +/* Standalone applications should #define __GETOPT_PREFIX to an + identifier that prefixes the external functions and variables + defined in getopt-core.h and getopt-ext.h. Systematically + rename identifiers so that they do not collide with the system + functions and variables. Renaming avoids problems with some + compilers and linkers. */ +#ifdef __GETOPT_PREFIX +# ifndef __GETOPT_ID +# define __GETOPT_CONCAT(x, y) x ## y +# define __GETOPT_XCONCAT(x, y) __GETOPT_CONCAT (x, y) +# define __GETOPT_ID(y) __GETOPT_XCONCAT (__GETOPT_PREFIX, y) +# endif +# undef getopt +# undef optarg +# undef opterr +# undef optind +# undef optopt +# define getopt __GETOPT_ID (getopt) +# define optarg __GETOPT_ID (optarg) +# define opterr __GETOPT_ID (opterr) +# define optind __GETOPT_ID (optind) +# define optopt __GETOPT_ID (optopt) + +/* Work around 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 . */ +# 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. */ +# undef _GETOPT_CORE_H +#endif + +#include + +#endif /* _GETOPT_PFX_CORE_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getopt-pfx-ext.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getopt-pfx-ext.h new file mode 100644 index 00000000..f001c11e --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getopt-pfx-ext.h @@ -0,0 +1,70 @@ +/* getopt (GNU extensions) gnulib wrapper header. + Copyright (C) 1989-2024 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. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef _GETOPT_PFX_EXT_H +#define _GETOPT_PFX_EXT_H 1 + +/* This header should not be used directly; include getopt.h instead. + It does not have a protective #error, because the guard macro for + getopt.h in gnulib is not fixed. */ + +/* Standalone applications should #define __GETOPT_PREFIX to an + identifier that prefixes the external functions and variables + defined in getopt-core.h and getopt-ext.h. Systematically + rename identifiers so that they do not collide with the system + functions and variables. Renaming avoids problems with some + compilers and linkers. */ +#ifdef __GETOPT_PREFIX +# ifndef __GETOPT_ID +# define __GETOPT_CONCAT(x, y) x ## y +# define __GETOPT_XCONCAT(x, y) __GETOPT_CONCAT (x, y) +# define __GETOPT_ID(y) __GETOPT_XCONCAT (__GETOPT_PREFIX, y) +# endif +# undef getopt_long +# undef getopt_long_only +# undef option +# undef _getopt_internal +# define getopt_long __GETOPT_ID (getopt_long) +# define getopt_long_only __GETOPT_ID (getopt_long_only) +# define option __GETOPT_ID (option) +# define _getopt_internal __GETOPT_ID (getopt_internal) + +/* The system's getopt.h may have already included getopt-ext.h to + declare the unprefixed identifiers. Undef _GETOPT_EXT_H so that + getopt-ext.h declares them with prefixes. */ +# undef _GETOPT_EXT_H +#endif + +/* Standalone applications get correct prototypes for getopt_long and + getopt_long_only; they declare "char **argv". For backward + compatibility with old applications, if __GETOPT_PREFIX is not + defined, we supply GNU-libc-compatible, but incorrect, prototypes + using "char *const *argv". (GNU libc is stuck with the incorrect + prototypes, as they are baked into older versions of LSB.) */ +#ifndef __getopt_argv_const +# if defined __GETOPT_PREFIX +# define __getopt_argv_const /* empty */ +# else +# define __getopt_argv_const const +# endif +#endif + +#include + +#endif /* _GETOPT_PFX_EXT_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getopt.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getopt.c new file mode 100644 index 00000000..f66f119e --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getopt.c @@ -0,0 +1,814 @@ +/* Getopt for GNU. + Copyright (C) 1987-2024 Free Software Foundation, Inc. + This file is part of the GNU C Library and is also part of gnulib. + Patches to this file should be submitted to both projects. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _LIBC +# include +#endif + +#include + +#include +#include +#include +#include + +#ifdef _LIBC +/* When used as part of glibc, error printing must be done differently + for standards compliance. getopt is not a cancellation point, so + it must not call functions that are, and it is specified by an + older standard than stdio locking, so it must not refer to + functions in the "user namespace" related to stdio locking. + Finally, it must use glibc's internal message translation so that + the messages are looked up in the proper text domain. */ +# include +# define fprintf __fxprintf_nocancel +# define flockfile(fp) _IO_flockfile (fp) +# define funlockfile(fp) _IO_funlockfile (fp) +#else +# include "gettext.h" +# define _(msgid) gettext (msgid) +/* When used standalone, flockfile and funlockfile might not be + available. */ +# if (!defined _POSIX_THREAD_SAFE_FUNCTIONS \ + || (defined _WIN32 && ! defined __CYGWIN__)) +# define flockfile(fp) /* nop */ +# define funlockfile(fp) /* nop */ +# endif +/* When used standalone, do not attempt to use alloca. */ +# define __libc_use_alloca(size) 0 +# undef alloca +# define alloca(size) (abort (), (void *)0) +#endif + +/* This implementation of 'getopt' has three modes for handling + options interspersed with non-option arguments. It can stop + scanning for options at the first non-option argument encountered, + as POSIX specifies. It can continue scanning for options after the + first non-option argument, but permute 'argv' as it goes so that, + after 'getopt' is done, all the options precede all the non-option + arguments and 'optind' points to the first non-option argument. + Or, it can report non-option arguments as if they were arguments to + the option character '\x01'. + + The default behavior of 'getopt_long' is to permute the argument list. + When this implementation is used standalone, the default behavior of + 'getopt' is to stop at the first non-option argument, but when it is + used as part of GNU libc it also permutes the argument list. In both + cases, setting the environment variable POSIXLY_CORRECT to any value + disables permutation. + + If the first character of the OPTSTRING argument to 'getopt' or + 'getopt_long' is '+', both functions will stop at the first + non-option argument. If it is '-', both functions will report + non-option arguments as arguments to the option character '\x01'. */ + +#include "getopt_int.h" + +/* For communication from 'getopt' to the caller. + When 'getopt' finds an option that takes an argument, + the argument value is returned here. + Also, when 'ordering' is RETURN_IN_ORDER, + each non-option ARGV-element is returned here. */ + +char *optarg; + +/* Index in ARGV of the next element to be scanned. + This is used for communication to and from the caller + and for communication between successive calls to 'getopt'. + + On entry to 'getopt', zero means this is the first call; initialize. + + When 'getopt' returns -1, this is the index of the first of the + non-option elements that the caller should itself scan. + + Otherwise, 'optind' communicates from one call to the next + how much of ARGV has been scanned so far. */ + +/* 1003.2 says this must be 1 before any call. */ +int optind = 1; + +/* Callers store zero here to inhibit the error message + for unrecognized options. */ + +int opterr = 1; + +/* Set to an option character which was unrecognized. + This must be initialized on some systems to avoid linking in the + system's own getopt implementation. */ + +int optopt = '?'; + +/* Keep a global copy of all internal members of getopt_data. */ + +static struct _getopt_data getopt_data; + +/* Exchange two adjacent subsequences of ARGV. + One subsequence is elements [first_nonopt,last_nonopt) + which contains all the non-options that have been skipped so far. + The other is elements [last_nonopt,optind), which contains all + the options processed since those non-options were skipped. + + 'first_nonopt' and 'last_nonopt' are relocated so that they describe + the new indices of the non-options in ARGV after they are moved. */ + +static void +exchange (char **argv, struct _getopt_data *d) +{ + int bottom = d->__first_nonopt; + int middle = d->__last_nonopt; + int top = d->optind; + char *tem; + + /* Exchange the shorter segment with the far end of the longer segment. + That puts the shorter segment into the right place. + It leaves the longer segment in the right place overall, + but it consists of two parts that need to be swapped next. */ + + while (top > middle && middle > bottom) + { + if (top - middle > middle - bottom) + { + /* Bottom segment is the short one. */ + int len = middle - bottom; + int i; + + /* Swap it with the top part of the top segment. */ + for (i = 0; i < len; i++) + { + tem = argv[bottom + i]; + argv[bottom + i] = argv[top - (middle - bottom) + i]; + argv[top - (middle - bottom) + i] = tem; + } + /* Exclude the moved bottom segment from further swapping. */ + top -= len; + } + else + { + /* Top segment is the short one. */ + int len = top - middle; + int i; + + /* Swap it with the bottom part of the bottom segment. */ + for (i = 0; i < len; i++) + { + tem = argv[bottom + i]; + argv[bottom + i] = argv[middle + i]; + argv[middle + i] = tem; + } + /* Exclude the moved top segment from further swapping. */ + bottom += len; + } + } + + /* Update records for the slots the non-options now occupy. */ + + d->__first_nonopt += (d->optind - d->__last_nonopt); + d->__last_nonopt = d->optind; +} + +/* Process the argument starting with d->__nextchar as a long option. + d->optind should *not* have been advanced over this argument. + + If the value returned is -1, it was not actually a long option, the + state is unchanged, and the argument should be processed as a set + of short options (this can only happen when long_only is true). + Otherwise, the option (and its argument, if any) have been consumed + and the return value is the value to return from _getopt_internal_r. */ +static int +process_long_option (int argc, char **argv, const char *optstring, + const struct option *longopts, int *longind, + int long_only, struct _getopt_data *d, + int print_errors, const char *prefix) +{ + char *nameend; + size_t namelen; + const struct option *p; + const struct option *pfound = NULL; + int n_options; + int option_index; + + for (nameend = d->__nextchar; *nameend && *nameend != '='; nameend++) + /* Do nothing. */ ; + namelen = nameend - d->__nextchar; + + /* First look for an exact match, counting the options as a side + effect. */ + for (p = longopts, n_options = 0; p->name; p++, n_options++) + if (!strncmp (p->name, d->__nextchar, namelen) + && namelen == strlen (p->name)) + { + /* Exact match found. */ + pfound = p; + option_index = n_options; + break; + } + + if (pfound == NULL) + { + /* Didn't find an exact match, so look for abbreviations. */ + unsigned char *ambig_set = NULL; + /* Use simpler fallback diagnostic if ambig_set == &ambig_fallback. */ + unsigned char ambig_fallback; + void *ambig_malloced = NULL; + int indfound = -1; + + for (p = longopts, option_index = 0; p->name; p++, option_index++) + if (!strncmp (p->name, d->__nextchar, namelen)) + { + if (pfound == NULL) + { + /* First nonexact match found. */ + pfound = p; + indfound = option_index; + } + else if (long_only + || pfound->has_arg != p->has_arg + || pfound->flag != p->flag + || pfound->val != p->val) + { + /* Second or later nonexact match found. */ + if (ambig_set != &ambig_fallback) + { + if (!print_errors) + /* Don't waste effort tracking the ambig set if + we're not going to print it anyway. */ + ambig_set = &ambig_fallback; + else if (!ambig_set) + { + if (__libc_use_alloca (n_options)) + ambig_set = alloca (n_options); + else + { + ambig_malloced = malloc (n_options); + /* Fall back to simpler diagnostic if + memory allocation fails. */ + ambig_set = (ambig_malloced ? ambig_malloced + : &ambig_fallback); + } + + if (ambig_set != &ambig_fallback) + { + memset (ambig_set, 0, n_options); + ambig_set[indfound] = 1; + } + } + if (ambig_set && ambig_set != &ambig_fallback) + ambig_set[option_index] = 1; + } + } + } + + if (ambig_set) + { + if (print_errors) + { + if (ambig_set == &ambig_fallback) + fprintf (stderr, _("%s: option '%s%s' is ambiguous\n"), + argv[0], prefix, d->__nextchar); + else + { + flockfile (stderr); + fprintf (stderr, + _("%s: option '%s%s' is ambiguous; possibilities:"), + argv[0], prefix, d->__nextchar); + + for (option_index = 0; option_index < n_options; option_index++) + if (ambig_set[option_index]) + fprintf (stderr, " '%s%s'", + prefix, longopts[option_index].name); + + /* This must use 'fprintf' even though it's only + printing a single character, so that it goes through + __fxprintf_nocancel when compiled as part of glibc. */ + fprintf (stderr, "\n"); + funlockfile (stderr); + } + } + free (ambig_malloced); + d->__nextchar += strlen (d->__nextchar); + d->optind++; + d->optopt = 0; + return '?'; + } + + option_index = indfound; + } + + if (pfound == NULL) + { + /* Can't find it as a long option. If this is not getopt_long_only, + or the option starts with '--' or is not a valid short option, + then it's an error. */ + if (!long_only || argv[d->optind][1] == '-' + || strchr (optstring, *d->__nextchar) == NULL) + { + if (print_errors) + fprintf (stderr, _("%s: unrecognized option '%s%s'\n"), + argv[0], prefix, d->__nextchar); + + d->__nextchar = NULL; + d->optind++; + d->optopt = 0; + return '?'; + } + + /* Otherwise interpret it as a short option. */ + return -1; + } + + /* We have found a matching long option. Consume it. */ + d->optind++; + d->__nextchar = NULL; + if (*nameend) + { + /* Don't test has_arg with >, because some C compilers don't + allow it to be used on enums. */ + if (pfound->has_arg) + d->optarg = nameend + 1; + else + { + if (print_errors) + fprintf (stderr, + _("%s: option '%s%s' doesn't allow an argument\n"), + argv[0], prefix, pfound->name); + + d->optopt = pfound->val; + return '?'; + } + } + else if (pfound->has_arg == 1) + { + if (d->optind < argc) + d->optarg = argv[d->optind++]; + else + { + if (print_errors) + fprintf (stderr, + _("%s: option '%s%s' requires an argument\n"), + argv[0], prefix, pfound->name); + + d->optopt = pfound->val; + return optstring[0] == ':' ? ':' : '?'; + } + } + + if (longind != NULL) + *longind = option_index; + if (pfound->flag) + { + *(pfound->flag) = pfound->val; + return 0; + } + return pfound->val; +} + +/* Initialize internal data upon the first call to getopt. */ + +static const char * +_getopt_initialize (_GL_UNUSED int argc, + _GL_UNUSED char **argv, const char *optstring, + struct _getopt_data *d, int posixly_correct) +{ + /* Start processing options with ARGV-element 1 (since ARGV-element 0 + is the program name); the sequence of previously skipped + non-option ARGV-elements is empty. */ + if (d->optind == 0) + d->optind = 1; + + d->__first_nonopt = d->__last_nonopt = d->optind; + d->__nextchar = NULL; + + /* Determine how to handle the ordering of options and nonoptions. */ + if (optstring[0] == '-') + { + d->__ordering = RETURN_IN_ORDER; + ++optstring; + } + else if (optstring[0] == '+') + { + d->__ordering = REQUIRE_ORDER; + ++optstring; + } + else if (posixly_correct || !!getenv ("POSIXLY_CORRECT")) + d->__ordering = REQUIRE_ORDER; + else + d->__ordering = PERMUTE; + + d->__initialized = 1; + return optstring; +} + +/* Scan elements of ARGV (whose length is ARGC) for option characters + given in OPTSTRING. + + If an element of ARGV starts with '-', and is not exactly "-" or "--", + then it is an option element. The characters of this element + (aside from the initial '-') are option characters. If 'getopt' + is called repeatedly, it returns successively each of the option characters + from each of the option elements. + + If 'getopt' finds another option character, it returns that character, + updating 'optind' and 'nextchar' so that the next call to 'getopt' can + resume the scan with the following option character or ARGV-element. + + If there are no more option characters, 'getopt' returns -1. + Then 'optind' is the index in ARGV of the first ARGV-element + that is not an option. (The ARGV-elements have been permuted + so that those that are not options now come last.) + + OPTSTRING is a string containing the legitimate option characters. + If an option character is seen that is not listed in OPTSTRING, + return '?' after printing an error message. If you set 'opterr' to + zero, the error message is suppressed but we still return '?'. + + If a char in OPTSTRING is followed by a colon, that means it wants an arg, + so the following text in the same ARGV-element, or the text of the following + ARGV-element, is returned in 'optarg'. Two colons mean an option that + wants an optional arg; if there is text in the current ARGV-element, + it is returned in 'optarg', otherwise 'optarg' is set to zero. + + If OPTSTRING starts with '-' or '+', it requests different methods of + handling the non-option ARGV-elements. + See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above. + + Long-named options begin with '--' instead of '-'. + Their names may be abbreviated as long as the abbreviation is unique + or is an exact match for some defined option. If they have an + argument, it follows the option name in the same ARGV-element, separated + from the option name by a '=', or else the in next ARGV-element. + When 'getopt' finds a long-named option, it returns 0 if that option's + 'flag' field is nonzero, the value of the option's 'val' field + if the 'flag' field is zero. + + The elements of ARGV aren't really const, because we permute them. + But we pretend they're const in the prototype to be compatible + with other systems. + + LONGOPTS is a vector of 'struct option' terminated by an + element containing a name which is zero. + + LONGIND returns the index in LONGOPT of the long-named option found. + It is only valid when a long-named option has been found by the most + recent call. + + If LONG_ONLY is nonzero, '-' as well as '--' can introduce + long-named options. */ + +int +_getopt_internal_r (int argc, char **argv, const char *optstring, + const struct option *longopts, int *longind, + int long_only, struct _getopt_data *d, int posixly_correct) +{ + int print_errors = d->opterr; + + if (argc < 1) + return -1; + + d->optarg = NULL; + + if (d->optind == 0 || !d->__initialized) + optstring = _getopt_initialize (argc, argv, optstring, d, posixly_correct); + else if (optstring[0] == '-' || optstring[0] == '+') + optstring++; + + if (optstring[0] == ':') + print_errors = 0; + + /* Test whether ARGV[optind] points to a non-option argument. */ +#define NONOPTION_P (argv[d->optind][0] != '-' || argv[d->optind][1] == '\0') + + if (d->__nextchar == NULL || *d->__nextchar == '\0') + { + /* Advance to the next ARGV-element. */ + + /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been + moved back by the user (who may also have changed the arguments). */ + if (d->__last_nonopt > d->optind) + d->__last_nonopt = d->optind; + if (d->__first_nonopt > d->optind) + d->__first_nonopt = d->optind; + + if (d->__ordering == PERMUTE) + { + /* If we have just processed some options following some non-options, + exchange them so that the options come first. */ + + if (d->__first_nonopt != d->__last_nonopt + && d->__last_nonopt != d->optind) + exchange (argv, d); + else if (d->__last_nonopt != d->optind) + d->__first_nonopt = d->optind; + + /* Skip any additional non-options + and extend the range of non-options previously skipped. */ + + while (d->optind < argc && NONOPTION_P) + d->optind++; + d->__last_nonopt = d->optind; + } + + /* The special ARGV-element '--' means premature end of options. + Skip it like a null option, + then exchange with previous non-options as if it were an option, + then skip everything else like a non-option. */ + + if (d->optind != argc && !strcmp (argv[d->optind], "--")) + { + d->optind++; + + if (d->__first_nonopt != d->__last_nonopt + && d->__last_nonopt != d->optind) + exchange (argv, d); + else if (d->__first_nonopt == d->__last_nonopt) + d->__first_nonopt = d->optind; + d->__last_nonopt = argc; + + d->optind = argc; + } + + /* If we have done all the ARGV-elements, stop the scan + and back over any non-options that we skipped and permuted. */ + + if (d->optind == argc) + { + /* Set the next-arg-index to point at the non-options + that we previously skipped, so the caller will digest them. */ + if (d->__first_nonopt != d->__last_nonopt) + d->optind = d->__first_nonopt; + return -1; + } + + /* If we have come to a non-option and did not permute it, + either stop the scan or describe it to the caller and pass it by. */ + + if (NONOPTION_P) + { + if (d->__ordering == REQUIRE_ORDER) + return -1; + d->optarg = argv[d->optind++]; + return 1; + } + + /* We have found another option-ARGV-element. + Check whether it might be a long option. */ + if (longopts) + { + if (argv[d->optind][1] == '-') + { + /* "--foo" is always a long option. The special option + "--" was handled above. */ + d->__nextchar = argv[d->optind] + 2; + return process_long_option (argc, argv, optstring, longopts, + longind, long_only, d, + print_errors, "--"); + } + + /* If long_only and the ARGV-element has the form "-f", + where f is a valid short option, don't consider it an + abbreviated form of a long option that starts with f. + Otherwise there would be no way to give the -f short + option. + + On the other hand, if there's a long option "fubar" and + the ARGV-element is "-fu", do consider that an + abbreviation of the long option, just like "--fu", and + not "-f" with arg "u". + + This distinction seems to be the most useful approach. */ + if (long_only && (argv[d->optind][2] + || !strchr (optstring, argv[d->optind][1]))) + { + int code; + d->__nextchar = argv[d->optind] + 1; + code = process_long_option (argc, argv, optstring, longopts, + longind, long_only, d, + print_errors, "-"); + if (code != -1) + return code; + } + } + + /* It is not a long option. Skip the initial punctuation. */ + d->__nextchar = argv[d->optind] + 1; + } + + /* Look at and handle the next short option-character. */ + + { + char c = *d->__nextchar++; + const char *temp = strchr (optstring, c); + + /* Increment 'optind' when we start to process its last character. */ + if (*d->__nextchar == '\0') + ++d->optind; + + if (temp == NULL || c == ':' || c == ';') + { + if (print_errors) + fprintf (stderr, _("%s: invalid option -- '%c'\n"), argv[0], c); + d->optopt = c; + return '?'; + } + + /* Convenience. Treat POSIX -W foo same as long option --foo */ + if (temp[0] == 'W' && temp[1] == ';' && longopts != NULL) + { + /* This is an option that requires an argument. */ + if (*d->__nextchar != '\0') + d->optarg = d->__nextchar; + else if (d->optind == argc) + { + if (print_errors) + fprintf (stderr, + _("%s: option requires an argument -- '%c'\n"), + argv[0], c); + + d->optopt = c; + if (optstring[0] == ':') + c = ':'; + else + c = '?'; + return c; + } + else + d->optarg = argv[d->optind]; + + d->__nextchar = d->optarg; + d->optarg = NULL; + return process_long_option (argc, argv, optstring, longopts, longind, + 0 /* long_only */, d, print_errors, "-W "); + } + if (temp[1] == ':') + { + if (temp[2] == ':') + { + /* This is an option that accepts an argument optionally. */ + if (*d->__nextchar != '\0') + { + d->optarg = d->__nextchar; + d->optind++; + } + else + d->optarg = NULL; + d->__nextchar = NULL; + } + else + { + /* This is an option that requires an argument. */ + if (*d->__nextchar != '\0') + { + d->optarg = d->__nextchar; + /* If we end this ARGV-element by taking the rest as an arg, + we must advance to the next element now. */ + d->optind++; + } + else if (d->optind == argc) + { + if (print_errors) + fprintf (stderr, + _("%s: option requires an argument -- '%c'\n"), + argv[0], c); + + d->optopt = c; + if (optstring[0] == ':') + c = ':'; + else + c = '?'; + } + else + /* We already incremented 'optind' once; + increment it again when taking next ARGV-elt as argument. */ + d->optarg = argv[d->optind++]; + d->__nextchar = NULL; + } + } + return c; + } +} + +int +_getopt_internal (int argc, char **argv, const char *optstring, + const struct option *longopts, int *longind, int long_only, + int posixly_correct) +{ + int result; + + getopt_data.optind = optind; + getopt_data.opterr = opterr; + + result = _getopt_internal_r (argc, argv, optstring, longopts, + longind, long_only, &getopt_data, + posixly_correct); + + optind = getopt_data.optind; + optarg = getopt_data.optarg; + optopt = getopt_data.optopt; + + return result; +} + +/* glibc gets a LSB-compliant getopt and a POSIX-complaint __posix_getopt. + Standalone applications just get a POSIX-compliant getopt. + POSIX and LSB both require these functions to take 'char *const *argv' + even though this is incorrect (because of the permutation). */ +#define GETOPT_ENTRY(NAME, POSIXLY_CORRECT) \ + int \ + NAME (int argc, char *const *argv, const char *optstring) \ + { \ + return _getopt_internal (argc, (char **)argv, optstring, \ + 0, 0, 0, POSIXLY_CORRECT); \ + } + +#ifdef _LIBC +GETOPT_ENTRY(getopt, 0) +GETOPT_ENTRY(__posix_getopt, 1) +#else +GETOPT_ENTRY(getopt, 1) +#endif + + +#ifdef TEST + +/* Compile with -DTEST to make an executable for use in testing + the above definition of 'getopt'. */ + +int +main (int argc, char **argv) +{ + int c; + int digit_optind = 0; + + while (1) + { + int this_option_optind = optind ? optind : 1; + + c = getopt (argc, argv, "abc:d:0123456789"); + if (c == -1) + break; + + switch (c) + { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + if (digit_optind != 0 && digit_optind != this_option_optind) + printf ("digits occur in two different argv-elements.\n"); + digit_optind = this_option_optind; + printf ("option %c\n", c); + break; + + case 'a': + printf ("option a\n"); + break; + + case 'b': + printf ("option b\n"); + break; + + case 'c': + printf ("option c with value '%s'\n", optarg); + break; + + case '?': + break; + + default: + printf ("?? getopt returned character code 0%o ??\n", c); + } + } + + if (optind < argc) + { + printf ("non-option ARGV-elements: "); + while (optind < argc) + printf ("%s ", argv[optind++]); + printf ("\n"); + } + + exit (0); +} + +#endif /* TEST */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getopt.in.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getopt.in.h new file mode 100644 index 00000000..c2411a75 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getopt.in.h @@ -0,0 +1,61 @@ +/* Declarations for getopt. + Copyright (C) 1989-2024 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 + this file. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef _@GUARD_PREFIX@_GETOPT_H + +#if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +#endif +@PRAGMA_COLUMNS@ + +/* The include_next requires a split double-inclusion guard. We must + also inform the replacement unistd.h to not recursively use + ; our definitions will be present soon enough. */ +#if @HAVE_GETOPT_H@ +# define _GL_SYSTEM_GETOPT +# @INCLUDE_NEXT@ @NEXT_GETOPT_H@ +# undef _GL_SYSTEM_GETOPT +#endif + +#define _@GUARD_PREFIX@_GETOPT_H 1 + +/* Standalone applications should #define __GETOPT_PREFIX to an + identifier that prefixes the external functions and variables + defined in getopt-core.h and getopt-ext.h. When this happens, + include the headers that might declare getopt so that they will not + cause confusion if included after this file (if the system had + , we have already included it). */ +#if defined __GETOPT_PREFIX +# if !@HAVE_GETOPT_H@ +# define __need_system_stdlib_h +# include +# undef __need_system_stdlib_h +# include +# include +# endif +#endif + +/* The definition of _GL_ARG_NONNULL is copied here. */ + +#include +#include +#include + +#endif /* _@GUARD_PREFIX@_GETOPT_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getopt1.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getopt1.c new file mode 100644 index 00000000..c42d29f8 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getopt1.c @@ -0,0 +1,159 @@ +/* getopt_long and getopt_long_only entry points for GNU getopt. + Copyright (C) 1987-2024 Free Software Foundation, Inc. + This file is part of the GNU C Library and is also part of gnulib. + Patches to this file should be submitted to both projects. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _LIBC +# include +#endif + +#include +#include "getopt_int.h" + +int +getopt_long (int argc, char *__getopt_argv_const *argv, const char *options, + const struct option *long_options, int *opt_index) +{ + return _getopt_internal (argc, (char **) argv, options, long_options, + opt_index, 0, 0); +} + +int +_getopt_long_r (int argc, char **argv, const char *options, + const struct option *long_options, int *opt_index, + struct _getopt_data *d) +{ + return _getopt_internal_r (argc, argv, options, long_options, opt_index, + 0, d, 0); +} + +/* Like getopt_long, but '-' as well as '--' can indicate a long option. + If an option that starts with '-' (not '--') doesn't match a long option, + but does match a short option, it is parsed as a short option + instead. */ + +int +getopt_long_only (int argc, char *__getopt_argv_const *argv, + const char *options, + const struct option *long_options, int *opt_index) +{ + return _getopt_internal (argc, (char **) argv, options, long_options, + opt_index, 1, 0); +} + +int +_getopt_long_only_r (int argc, char **argv, const char *options, + const struct option *long_options, int *opt_index, + struct _getopt_data *d) +{ + return _getopt_internal_r (argc, argv, options, long_options, opt_index, + 1, d, 0); +} + + +#ifdef TEST + +#include +#include + +int +main (int argc, char **argv) +{ + int c; + int digit_optind = 0; + + while (1) + { + int this_option_optind = optind ? optind : 1; + int option_index = 0; + static const struct option long_options[] = + { + {"add", 1, 0, 0}, + {"append", 0, 0, 0}, + {"delete", 1, 0, 0}, + {"verbose", 0, 0, 0}, + {"create", 0, 0, 0}, + {"file", 1, 0, 0}, + {0, 0, 0, 0} + }; + + c = getopt_long (argc, argv, "abc:d:0123456789", + long_options, &option_index); + if (c == -1) + break; + + switch (c) + { + case 0: + printf ("option %s", long_options[option_index].name); + if (optarg) + printf (" with arg %s", optarg); + printf ("\n"); + break; + + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + if (digit_optind != 0 && digit_optind != this_option_optind) + printf ("digits occur in two different argv-elements.\n"); + digit_optind = this_option_optind; + printf ("option %c\n", c); + break; + + case 'a': + printf ("option a\n"); + break; + + case 'b': + printf ("option b\n"); + break; + + case 'c': + printf ("option c with value '%s'\n", optarg); + break; + + case 'd': + printf ("option d with value '%s'\n", optarg); + break; + + case '?': + break; + + default: + printf ("?? getopt returned character code 0%o ??\n", c); + } + } + + if (optind < argc) + { + printf ("non-option ARGV-elements: "); + while (optind < argc) + printf ("%s ", argv[optind++]); + printf ("\n"); + } + + exit (0); +} + +#endif /* TEST */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getopt_int.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getopt_int.h new file mode 100644 index 00000000..c00c0b69 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getopt_int.h @@ -0,0 +1,118 @@ +/* Internal declarations for getopt. + Copyright (C) 1989-2024 Free Software Foundation, Inc. + This file is part of the GNU C Library and is also part of gnulib. + Patches to this file should be submitted to both projects. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _GETOPT_INT_H +#define _GETOPT_INT_H 1 + +#include + +extern int _getopt_internal (int ___argc, char **___argv, + const char *__shortopts, + const struct option *__longopts, int *__longind, + int __long_only, int __posixly_correct); + + +/* Reentrant versions which can handle parsing multiple argument + vectors at the same time. */ + +/* Describe how to deal with options that follow non-option ARGV-elements. + + REQUIRE_ORDER means don't recognize them as options; stop option + processing when the first non-option is seen. This is what POSIX + specifies should happen. + + PERMUTE means permute the contents of ARGV as we scan, so that + eventually all the non-options are at the end. This allows options + to be given in any order, even with programs that were not written + to expect this. + + RETURN_IN_ORDER is an option available to programs that were + written to expect options and other ARGV-elements in any order + and that care about the ordering of the two. We describe each + non-option ARGV-element as if it were the argument of an option + with character code 1. + + The special argument '--' forces an end of option-scanning regardless + of the value of 'ordering'. In the case of RETURN_IN_ORDER, only + '--' can cause 'getopt' to return -1 with 'optind' != ARGC. */ + +enum __ord + { + REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER + }; + +/* Data type for reentrant functions. */ +struct _getopt_data +{ + /* These have exactly the same meaning as the corresponding global + variables, except that they are used for the reentrant + versions of getopt. */ + int optind; + int opterr; + int optopt; + char *optarg; + + /* Internal members. */ + + /* True if the internal members have been initialized. */ + int __initialized; + + /* The next char to be scanned in the option-element + in which the last option character we returned was found. + This allows us to pick up the scan where we left off. + + If this is zero, or a null string, it means resume the scan + by advancing to the next ARGV-element. */ + char *__nextchar; + + /* See __ord above. */ + enum __ord __ordering; + + /* Handle permutation of arguments. */ + + /* Describe the part of ARGV that contains non-options that have + been skipped. 'first_nonopt' is the index in ARGV of the first + of them; 'last_nonopt' is the index after the last of them. */ + + int __first_nonopt; + int __last_nonopt; +}; + +/* The initializer is necessary to set OPTIND and OPTERR to their + default values and to clear the initialization flag. */ +#define _GETOPT_DATA_INITIALIZER { 1, 1 } + +extern int _getopt_internal_r (int ___argc, char **___argv, + const char *__shortopts, + const struct option *__longopts, int *__longind, + int __long_only, struct _getopt_data *__data, + int __posixly_correct); + +extern int _getopt_long_r (int ___argc, char **___argv, + const char *__shortopts, + const struct option *__longopts, int *__longind, + struct _getopt_data *__data); + +extern int _getopt_long_only_r (int ___argc, char **___argv, + const char *__shortopts, + const struct option *__longopts, + int *__longind, + struct _getopt_data *__data); + +#endif /* getopt_int.h */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getpagesize.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getpagesize.c new file mode 100644 index 00000000..d2031553 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getpagesize.c @@ -0,0 +1,39 @@ +/* getpagesize emulation for systems where it cannot be done in a C macro. + + Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible and Martin Lambers. */ + +#include + +/* Specification. */ +#include + +/* This implementation is only for native Windows systems. */ +#if defined _WIN32 && ! defined __CYGWIN__ + +# define WIN32_LEAN_AND_MEAN +# include + +int +getpagesize (void) +{ + SYSTEM_INFO system_info; + GetSystemInfo (&system_info); + return system_info.dwPageSize; +} + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getprogname.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getprogname.c new file mode 100644 index 00000000..392a9a2f --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getprogname.c @@ -0,0 +1,312 @@ +/* Program name management. + Copyright (C) 2016-2024 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2.1 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. Also get __argv declaration. */ +#include + +#include /* get program_invocation_name declaration */ + +#ifdef _AIX +# include +# include +# include +#endif + +#ifdef __MVS__ +# ifndef _OPEN_SYS +# define _OPEN_SYS +# endif +# include +# include +#endif + +#ifdef __hpux +# include +# include +# include +# include +#endif + +#if defined __sgi || defined __osf__ +# include +# include +# include +# include +# include +#endif + +#if defined __SCO_VERSION__ || defined __sysv5__ +# include +# include +#endif + +#include "basename-lgpl.h" + +#ifndef HAVE_GETPROGNAME /* not Mac OS X, FreeBSD, NetBSD, OpenBSD >= 5.4, Solaris >= 11, Cygwin, Android API level >= 21 */ +char const * +getprogname (void) +{ +# if HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME /* glibc, BeOS */ + /* https://www.gnu.org/software/libc/manual/html_node/Error-Messages.html */ + return program_invocation_short_name; +# elif HAVE_DECL_PROGRAM_INVOCATION_NAME /* glibc, BeOS */ + /* https://www.gnu.org/software/libc/manual/html_node/Error-Messages.html */ + return last_component (program_invocation_name); +# elif HAVE_GETEXECNAME /* Solaris */ + /* https://docs.oracle.com/cd/E19253-01/816-5168/6mbb3hrb1/index.html */ + const char *p = getexecname (); + if (!p) + p = "?"; + return last_component (p); +# elif HAVE_DECL___ARGV /* mingw, MSVC */ + /* https://docs.microsoft.com/en-us/cpp/c-runtime-library/argc-argv-wargv */ + const char *p = __argv && __argv[0] ? __argv[0] : "?"; + return last_component (p); +# elif HAVE_VAR___PROGNAME /* OpenBSD, Android, QNX */ + /* https://man.openbsd.org/style.9 */ + /* http://www.qnx.de/developers/docs/6.5.0/index.jsp?topic=%2Fcom.qnx.doc.neutrino_lib_ref%2Fp%2F__progname.html */ + /* Be careful to declare this only when we absolutely need it + (OpenBSD 5.1), rather than when it's available. Otherwise, + its mere declaration makes program_invocation_short_name + malfunction (have zero length) with Fedora 25's glibc. */ + extern char *__progname; + const char *p = __progname; +# if defined __ANDROID__ + return last_component (p); +# else + return p && p[0] ? p : "?"; +# endif +# elif _AIX /* AIX */ + /* Idea by Bastien ROUCARIÈS, + https://lists.gnu.org/r/bug-gnulib/2010-12/msg00095.html + Reference: https://www.ibm.com/support/knowledgecenter/en/ssw_aix_61/com.ibm.aix.basetrf1/getprocs.htm + */ + static char *p; + static int first = 1; + if (first) + { + first = 0; + pid_t pid = getpid (); + struct procentry64 procs; + p = (0 < getprocs64 (&procs, sizeof procs, NULL, 0, &pid, 1) + ? strdup (procs.pi_comm) + : NULL); + if (!p) + p = "?"; + } + return p; +# elif defined __hpux + static char *p; + static int first = 1; + if (first) + { + first = 0; + pid_t pid = getpid (); + struct pst_status status; + if (pstat_getproc (&status, sizeof status, 0, pid) > 0) + { + char *ucomm = status.pst_ucomm; + char *cmd = status.pst_cmd; + if (strlen (ucomm) < PST_UCOMMLEN - 1) + p = ucomm; + else + { + /* ucomm is truncated to length PST_UCOMMLEN - 1. + Look at cmd instead. */ + char *space = strchr (cmd, ' '); + if (space != NULL) + *space = '\0'; + p = strrchr (cmd, '/'); + if (p != NULL) + p++; + else + p = cmd; + if (strlen (p) > PST_UCOMMLEN - 1 + && memcmp (p, ucomm, PST_UCOMMLEN - 1) == 0) + /* p is less truncated than ucomm. */ + ; + else + p = ucomm; + } + p = strdup (p); + } + else + { +# if !defined __LP64__ + /* Support for 32-bit programs running in 64-bit HP-UX. + The documented way to do this is to use the same source code + as above, but in a compilation unit where '#define _PSTAT64 1' + is in effect. I prefer a single compilation unit; the struct + size and the offsets are not going to change. */ + char status64[1216]; + if (__pstat_getproc64 (status64, sizeof status64, 0, pid) > 0) + { + char *ucomm = status64 + 288; + char *cmd = status64 + 168; + if (strlen (ucomm) < PST_UCOMMLEN - 1) + p = ucomm; + else + { + /* ucomm is truncated to length PST_UCOMMLEN - 1. + Look at cmd instead. */ + char *space = strchr (cmd, ' '); + if (space != NULL) + *space = '\0'; + p = strrchr (cmd, '/'); + if (p != NULL) + p++; + else + p = cmd; + if (strlen (p) > PST_UCOMMLEN - 1 + && memcmp (p, ucomm, PST_UCOMMLEN - 1) == 0) + /* p is less truncated than ucomm. */ + ; + else + p = ucomm; + } + p = strdup (p); + } + else +# endif + p = NULL; + } + if (!p) + p = "?"; + } + return p; +# elif __MVS__ /* z/OS */ + /* https://www.ibm.com/support/knowledgecenter/SSLTBW_2.1.0/com.ibm.zos.v2r1.bpxbd00/rtwgetp.htm */ + static char *p = "?"; + static int first = 1; + if (first) + { + pid_t pid = getpid (); + int token; + W_PSPROC buf; + first = 0; + memset (&buf, 0, sizeof(buf)); + buf.ps_cmdptr = (char *) malloc (buf.ps_cmdlen = PS_CMDBLEN_LONG); + buf.ps_conttyptr = (char *) malloc (buf.ps_conttylen = PS_CONTTYBLEN); + buf.ps_pathptr = (char *) malloc (buf.ps_pathlen = PS_PATHBLEN); + if (buf.ps_cmdptr && buf.ps_conttyptr && buf.ps_pathptr) + { + for (token = 0; token >= 0; + token = w_getpsent (token, &buf, sizeof(buf))) + { + if (token > 0 && buf.ps_pid == pid) + { + char *s = strdup (last_component (buf.ps_pathptr)); + if (s) + { +# if defined __XPLINK__ && __CHARSET_LIB == 1 + /* The compiler option -qascii is in use. + https://makingdeveloperslivesbetter.wordpress.com/2022/01/07/is-z-os-ascii-or-ebcdic-yes/ + https://www.ibm.com/docs/en/zos/2.5.0?topic=features-macros-related-compiler-option-settings + So, convert the result from EBCDIC to ASCII. + https://www.ibm.com/docs/en/zos/2.5.0?topic=functions-e2a-s-convert-string-from-ebcdic-ascii */ + if (__e2a_s (s) == (size_t)-1) + free (s); + else +# endif + p = s; + } + break; + } + } + } + free (buf.ps_cmdptr); + free (buf.ps_conttyptr); + free (buf.ps_pathptr); + } + return p; +# elif defined __sgi || defined __osf__ /* IRIX or Tru64 */ + char filename[50]; + int fd; + + # if defined __sgi + sprintf (filename, "/proc/pinfo/%d", (int) getpid ()); + # else + sprintf (filename, "/proc/%d", (int) getpid ()); + # endif + fd = open (filename, O_RDONLY | O_CLOEXEC); + if (0 <= fd) + { + prpsinfo_t buf; + int ioctl_ok = 0 <= ioctl (fd, PIOCPSINFO, &buf); + close (fd); + if (ioctl_ok) + { + char *name = buf.pr_fname; + size_t namesize = sizeof buf.pr_fname; + /* It may not be NUL-terminated. */ + char *namenul = memchr (name, '\0', namesize); + size_t namelen = namenul ? namenul - name : namesize; + char *namecopy = malloc (namelen + 1); + if (namecopy) + { + namecopy[namelen] = '\0'; + return memcpy (namecopy, name, namelen); + } + } + } + return NULL; +# elif defined __SCO_VERSION__ || defined __sysv5__ /* SCO OpenServer6/UnixWare */ + char buf[80]; + int fd; + sprintf (buf, "/proc/%d/cmdline", getpid()); + fd = open (buf, O_RDONLY); + if (0 <= fd) + { + size_t n = read (fd, buf, 79); + if (n > 0) + { + buf[n] = '\0'; /* Guarantee null-termination */ + char *progname; + progname = strrchr (buf, '/'); + if (progname) + { + progname = progname + 1; /* Skip the '/' */ + } + else + { + progname = buf; + } + char *ret; + ret = malloc (strlen (progname) + 1); + if (ret) + { + strcpy (ret, progname); + return ret; + } + } + close (fd); + } + return "?"; +# else +# error "getprogname module not ported to this OS" +# endif +} + +#endif + +/* + * Hey Emacs! + * Local Variables: + * coding: utf-8 + * End: + */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getprogname.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getprogname.h new file mode 100644 index 00000000..bee1c1a2 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getprogname.h @@ -0,0 +1,26 @@ +/* Program name management. + Copyright (C) 2016-2024 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2.1 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef _GL_GETPROGNAME_H +#define _GL_GETPROGNAME_H + +#include + +#if __GNUC__ || (__clang_major__ >= 4) +# warning "The include file getprogname.h is deprecated. Use instead." +#endif + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getrandom.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getrandom.c new file mode 100644 index 00000000..44283cf1 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/getrandom.c @@ -0,0 +1,190 @@ +/* Obtain a series of random bytes. + + Copyright 2020-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Paul Eggert. */ + +#include + +#include + +#include +#include +#include + +#if defined _WIN32 && ! defined __CYGWIN__ +# define WIN32_LEAN_AND_MEAN +# include +# if HAVE_BCRYPT_H +# include +# else +# define NTSTATUS LONG +typedef void * BCRYPT_ALG_HANDLE; +# define BCRYPT_USE_SYSTEM_PREFERRED_RNG 0x00000002 +# if HAVE_LIB_BCRYPT +extern NTSTATUS WINAPI BCryptGenRandom (BCRYPT_ALG_HANDLE, UCHAR *, ULONG, ULONG); +# endif +# endif +# if !HAVE_LIB_BCRYPT +# include +# ifndef CRYPT_VERIFY_CONTEXT +# define CRYPT_VERIFY_CONTEXT 0xF0000000 +# endif +# endif +#endif + +#include "minmax.h" + +#if defined _WIN32 && ! defined __CYGWIN__ + +/* Don't assume that UNICODE is not defined. */ +# undef LoadLibrary +# define LoadLibrary LoadLibraryA +# undef CryptAcquireContext +# define CryptAcquireContext CryptAcquireContextA + +# if !HAVE_LIB_BCRYPT + +/* Avoid warnings from gcc -Wcast-function-type. */ +# define GetProcAddress \ + (void *) GetProcAddress + +/* BCryptGenRandom with the BCRYPT_USE_SYSTEM_PREFERRED_RNG flag works only + starting with Windows 7. */ +typedef NTSTATUS (WINAPI * BCryptGenRandomFuncType) (BCRYPT_ALG_HANDLE, UCHAR *, ULONG, ULONG); +static BCryptGenRandomFuncType BCryptGenRandomFunc = NULL; +static BOOL initialized = FALSE; + +static void +initialize (void) +{ + HMODULE bcrypt = LoadLibrary ("bcrypt.dll"); + if (bcrypt != NULL) + { + BCryptGenRandomFunc = + (BCryptGenRandomFuncType) GetProcAddress (bcrypt, "BCryptGenRandom"); + } + initialized = TRUE; +} + +# else + +# define BCryptGenRandomFunc BCryptGenRandom + +# endif + +#else +/* These devices exist on all platforms except native Windows. */ + +/* Name of a device through which the kernel returns high quality random + numbers, from an entropy pool. When the pool is empty, the call blocks + until entropy sources have added enough bits of entropy. */ +# ifndef NAME_OF_RANDOM_DEVICE +# define NAME_OF_RANDOM_DEVICE "/dev/random" +# endif + +/* Name of a device through which the kernel returns random or pseudo-random + numbers. It uses an entropy pool, but, in order to avoid blocking, adds + bits generated by a pseudo-random number generator, as needed. */ +# ifndef NAME_OF_NONCE_DEVICE +# define NAME_OF_NONCE_DEVICE "/dev/urandom" +# endif + +#endif + +/* Set BUFFER (of size LENGTH) to random bytes under the control of FLAGS. + Return the number of bytes written (> 0). + Upon error, return -1 and set errno. */ +ssize_t +getrandom (void *buffer, size_t length, unsigned int flags) +#undef getrandom +{ +#if defined _WIN32 && ! defined __CYGWIN__ + /* BCryptGenRandom, defined in + + with the BCRYPT_USE_SYSTEM_PREFERRED_RNG flag + works in Windows 7 and newer. */ + static int bcrypt_not_working /* = 0 */; + if (!bcrypt_not_working) + { +# if !HAVE_LIB_BCRYPT + if (!initialized) + initialize (); +# endif + if (BCryptGenRandomFunc != NULL + && BCryptGenRandomFunc (NULL, buffer, length, + BCRYPT_USE_SYSTEM_PREFERRED_RNG) + == 0 /*STATUS_SUCCESS*/) + return length; + bcrypt_not_working = 1; + } +# if !HAVE_LIB_BCRYPT + /* CryptGenRandom, defined in + + works in older releases as well, but is now deprecated. + CryptAcquireContext, defined in + */ + { + static int crypt_initialized /* = 0 */; + static HCRYPTPROV provider; + if (!crypt_initialized) + { + if (CryptAcquireContext (&provider, NULL, NULL, PROV_RSA_FULL, + CRYPT_VERIFY_CONTEXT)) + crypt_initialized = 1; + else + crypt_initialized = -1; + } + if (crypt_initialized >= 0) + { + if (!CryptGenRandom (provider, length, buffer)) + { + errno = EIO; + return -1; + } + return length; + } + } +# endif + errno = ENOSYS; + return -1; +#elif HAVE_GETRANDOM + return getrandom (buffer, length, flags); +#else + static int randfd[2] = { -1, -1 }; + bool devrandom = (flags & GRND_RANDOM) != 0; + int fd = randfd[devrandom]; + + if (fd < 0) + { + static char const randdevice[][MAX (sizeof NAME_OF_NONCE_DEVICE, + sizeof NAME_OF_RANDOM_DEVICE)] + = { NAME_OF_NONCE_DEVICE, NAME_OF_RANDOM_DEVICE }; + int oflags = (O_RDONLY + O_CLOEXEC + + (flags & GRND_NONBLOCK ? O_NONBLOCK : 0)); + fd = open (randdevice[devrandom], oflags); + if (fd < 0) + { + if (errno == ENOENT || errno == ENOTDIR) + errno = ENOSYS; + return -1; + } + randfd[devrandom] = fd; + } + + return read (fd, buffer, length); +#endif +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/gettext.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/gettext.h new file mode 100644 index 00000000..39d5ae4d --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/gettext.h @@ -0,0 +1,300 @@ +/* Convenience header for conditional use of GNU . + Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2024 Free Software + Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef _LIBGETTEXT_H +#define _LIBGETTEXT_H 1 + +/* NLS can be disabled through the configure --disable-nls option + or through "#define ENABLE NLS 0" before including this file. */ +#if defined ENABLE_NLS && ENABLE_NLS + +/* Get declarations of GNU message catalog functions. */ +# include + +/* You can set the DEFAULT_TEXT_DOMAIN macro to specify the domain used by + the gettext() and ngettext() macros. This is an alternative to calling + textdomain(), and is useful for libraries. */ +# ifdef DEFAULT_TEXT_DOMAIN +# undef gettext +# define gettext(Msgid) \ + dgettext (DEFAULT_TEXT_DOMAIN, Msgid) +# undef ngettext +# define ngettext(Msgid1, Msgid2, N) \ + dngettext (DEFAULT_TEXT_DOMAIN, Msgid1, Msgid2, N) +# endif + +#else + +/* Solaris /usr/include/locale.h includes /usr/include/libintl.h, which + chokes if dcgettext is defined as a macro. So include it now, to make + later inclusions of a NOP. We don't include + as well because people using "gettext.h" will not include , + and also including would fail on SunOS 4, whereas + is OK. */ +#if defined(__sun) +# include +#endif + +/* Many header files from the libstdc++ coming with g++ 3.3 or newer include + , which chokes if dcgettext is defined as a macro. So include + it now, to make later inclusions of a NOP. */ +#if defined(__cplusplus) && defined(__GNUG__) && (__GNUC__ >= 3) +# include +# if (__GLIBC__ >= 2 && !defined __UCLIBC__) || _GLIBCXX_HAVE_LIBINTL_H +# include +# endif +#endif + +/* Disabled NLS. + The casts to 'const char *' serve the purpose of producing warnings + for invalid uses of the value returned from these functions. + On pre-ANSI systems without 'const', the config.h file is supposed to + contain "#define const". */ +# undef gettext +# define gettext(Msgid) ((const char *) (Msgid)) +# undef dgettext +# define dgettext(Domainname, Msgid) ((void) (Domainname), gettext (Msgid)) +# undef dcgettext +# define dcgettext(Domainname, Msgid, Category) \ + ((void) (Category), dgettext (Domainname, Msgid)) +# undef ngettext +# define ngettext(Msgid1, Msgid2, N) \ + ((N) == 1 \ + ? ((void) (Msgid2), (const char *) (Msgid1)) \ + : ((void) (Msgid1), (const char *) (Msgid2))) +# undef dngettext +# define dngettext(Domainname, Msgid1, Msgid2, N) \ + ((void) (Domainname), ngettext (Msgid1, Msgid2, N)) +# undef dcngettext +# define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \ + ((void) (Category), dngettext (Domainname, Msgid1, Msgid2, N)) +# undef textdomain +# define textdomain(Domainname) ((const char *) (Domainname)) +# undef bindtextdomain +# define bindtextdomain(Domainname, Dirname) \ + ((void) (Domainname), (const char *) (Dirname)) +# undef bind_textdomain_codeset +# define bind_textdomain_codeset(Domainname, Codeset) \ + ((void) (Domainname), (const char *) (Codeset)) + +#endif + +/* Prefer gnulib's setlocale override over libintl's setlocale override. */ +#ifdef GNULIB_defined_setlocale +# undef setlocale +# define setlocale rpl_setlocale +#endif + +/* A pseudo function call that serves as a marker for the automated + extraction of messages, but does not call gettext(). The run-time + translation is done at a different place in the code. + The argument, String, should be a literal string. Concatenated strings + and other string expressions won't work. + The macro's expansion is not parenthesized, so that it is suitable as + initializer for static 'char[]' or 'const char[]' variables. */ +#define gettext_noop(String) String + +/* The separator between msgctxt and msgid in a .mo file. */ +#define GETTEXT_CONTEXT_GLUE "\004" + +/* Pseudo function calls, taking a MSGCTXT and a MSGID instead of just a + MSGID. MSGCTXT and MSGID must be string literals. MSGCTXT should be + short and rarely need to change. + The letter 'p' stands for 'particular' or 'special'. */ +#ifdef DEFAULT_TEXT_DOMAIN +# define pgettext(Msgctxt, Msgid) \ + pgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES) +#else +# define pgettext(Msgctxt, Msgid) \ + pgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES) +#endif +#define dpgettext(Domainname, Msgctxt, Msgid) \ + pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES) +#define dcpgettext(Domainname, Msgctxt, Msgid, Category) \ + pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, Category) +#ifdef DEFAULT_TEXT_DOMAIN +# define npgettext(Msgctxt, Msgid, MsgidPlural, N) \ + npgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES) +#else +# define npgettext(Msgctxt, Msgid, MsgidPlural, N) \ + npgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES) +#endif +#define dnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N) \ + npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES) +#define dcnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N, Category) \ + npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, Category) + +#if defined __GNUC__ || defined __clang__ +__inline +#else +#ifdef __cplusplus +inline +#endif +#endif +static const char * +pgettext_aux (const char *domain, + const char *msg_ctxt_id, const char *msgid, + int category) +{ + const char *translation = dcgettext (domain, msg_ctxt_id, category); + if (translation == msg_ctxt_id) + return msgid; + else + return translation; +} + +#if defined __GNUC__ || defined __clang__ +__inline +#else +#ifdef __cplusplus +inline +#endif +#endif +static const char * +npgettext_aux (const char *domain, + const char *msg_ctxt_id, const char *msgid, + const char *msgid_plural, unsigned long int n, + int category) +{ + const char *translation = + dcngettext (domain, msg_ctxt_id, msgid_plural, n, category); + if (translation == msg_ctxt_id || translation == msgid_plural) + return (n == 1 ? msgid : msgid_plural); + else + return translation; +} + +/* The same thing extended for non-constant arguments. Here MSGCTXT and MSGID + can be arbitrary expressions. But for string literals these macros are + less efficient than those above. */ + +#include + +/* GNULIB_NO_VLA can be defined to disable use of VLAs even if supported. + This relates to the -Wvla and -Wvla-larger-than warnings, enabled in + the default GCC many warnings set. This allows programs to disable use + of VLAs, which may be unintended, or may be awkward to support portably, + or may have security implications due to non-deterministic stack usage. */ + +#if (!defined GNULIB_NO_VLA \ + && defined __STDC_VERSION__ && 199901L <= __STDC_VERSION__ \ + && !defined __STDC_NO_VLA__) +# define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 1 +#else +# define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 0 +#endif + +#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS +#include +#endif + +#define pgettext_expr(Msgctxt, Msgid) \ + dcpgettext_expr (NULL, Msgctxt, Msgid, LC_MESSAGES) +#define dpgettext_expr(Domainname, Msgctxt, Msgid) \ + dcpgettext_expr (Domainname, Msgctxt, Msgid, LC_MESSAGES) + +#if defined __GNUC__ || defined __clang__ +__inline +#else +#ifdef __cplusplus +inline +#endif +#endif +static const char * +dcpgettext_expr (const char *domain, + const char *msgctxt, const char *msgid, + int category) +{ + size_t msgctxt_len = strlen (msgctxt) + 1; + size_t msgid_len = strlen (msgid) + 1; + const char *translation; +#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS + char msg_ctxt_id[msgctxt_len + msgid_len]; +#else + char buf[1024]; + char *msg_ctxt_id = + (msgctxt_len + msgid_len <= sizeof (buf) + ? buf + : (char *) malloc (msgctxt_len + msgid_len)); + if (msg_ctxt_id != NULL) +#endif + { + int found_translation; + memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1); + msg_ctxt_id[msgctxt_len - 1] = '\004'; + memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len); + translation = dcgettext (domain, msg_ctxt_id, category); + found_translation = (translation != msg_ctxt_id); +#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS + if (msg_ctxt_id != buf) + free (msg_ctxt_id); +#endif + if (found_translation) + return translation; + } + return msgid; +} + +#define npgettext_expr(Msgctxt, Msgid, MsgidPlural, N) \ + dcnpgettext_expr (NULL, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES) +#define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \ + dcnpgettext_expr (Domainname, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES) + +#if defined __GNUC__ || defined __clang__ +__inline +#else +#ifdef __cplusplus +inline +#endif +#endif +static const char * +dcnpgettext_expr (const char *domain, + const char *msgctxt, const char *msgid, + const char *msgid_plural, unsigned long int n, + int category) +{ + size_t msgctxt_len = strlen (msgctxt) + 1; + size_t msgid_len = strlen (msgid) + 1; + const char *translation; +#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS + char msg_ctxt_id[msgctxt_len + msgid_len]; +#else + char buf[1024]; + char *msg_ctxt_id = + (msgctxt_len + msgid_len <= sizeof (buf) + ? buf + : (char *) malloc (msgctxt_len + msgid_len)); + if (msg_ctxt_id != NULL) +#endif + { + int found_translation; + memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1); + msg_ctxt_id[msgctxt_len - 1] = '\004'; + memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len); + translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category); + found_translation = !(translation == msg_ctxt_id || translation == msgid_plural); +#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS + if (msg_ctxt_id != buf) + free (msg_ctxt_id); +#endif + if (found_translation) + return translation; + } + return (n == 1 ? msgid : msgid_plural); +} + +#endif /* _LIBGETTEXT_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/gettime.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/gettime.c new file mode 100644 index 00000000..38d36859 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/gettime.c @@ -0,0 +1,51 @@ +/* gettime -- get the system clock + + Copyright (C) 2002, 2004-2007, 2009-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Paul Eggert. */ + +#include + +#include "timespec.h" + +#include + +/* Get the system time into *TS. */ + +void +gettime (struct timespec *ts) +{ +#if defined CLOCK_REALTIME && HAVE_CLOCK_GETTIME + clock_gettime (CLOCK_REALTIME, ts); +#elif defined HAVE_TIMESPEC_GET + timespec_get (ts, TIME_UTC); +#else + struct timeval tv; + gettimeofday (&tv, NULL); + *ts = (struct timespec) { .tv_sec = tv.tv_sec, + .tv_nsec = tv.tv_usec * 1000 }; +#endif +} + +/* Return the current system time as a struct timespec. */ + +struct timespec +current_timespec (void) +{ + struct timespec ts; + gettime (&ts); + return ts; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/gettimeofday.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/gettimeofday.c new file mode 100644 index 00000000..8dd26f73 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/gettimeofday.c @@ -0,0 +1,151 @@ +/* Provide gettimeofday for systems that don't have it or for which it's broken. + + Copyright (C) 2001-2003, 2005-2007, 2009-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* written by Jim Meyering */ + +#include + +/* Specification. */ +#include + +#include + +#if defined _WIN32 && ! defined __CYGWIN__ +# define WINDOWS_NATIVE +# include +#endif + +#ifdef WINDOWS_NATIVE + +/* Don't assume that UNICODE is not defined. */ +# undef LoadLibrary +# define LoadLibrary LoadLibraryA + +# if !(_WIN32_WINNT >= _WIN32_WINNT_WIN8) + +/* Avoid warnings from gcc -Wcast-function-type. */ +# define GetProcAddress \ + (void *) GetProcAddress + +/* GetSystemTimePreciseAsFileTime was introduced only in Windows 8. */ +typedef void (WINAPI * GetSystemTimePreciseAsFileTimeFuncType) (FILETIME *lpTime); +static GetSystemTimePreciseAsFileTimeFuncType GetSystemTimePreciseAsFileTimeFunc = NULL; +static BOOL initialized = FALSE; + +static void +initialize (void) +{ + HMODULE kernel32 = LoadLibrary ("kernel32.dll"); + if (kernel32 != NULL) + { + GetSystemTimePreciseAsFileTimeFunc = + (GetSystemTimePreciseAsFileTimeFuncType) GetProcAddress (kernel32, "GetSystemTimePreciseAsFileTime"); + } + initialized = TRUE; +} + +# else + +# define GetSystemTimePreciseAsFileTimeFunc GetSystemTimePreciseAsFileTime + +# endif + +#endif + +/* This is a wrapper for gettimeofday. It is used only on systems + that lack this function, or whose implementation of this function + causes problems. + Work around the bug in some systems whereby gettimeofday clobbers + the static buffer that localtime uses for its return value. The + gettimeofday function from Mac OS X 10.0.4 (i.e., Darwin 1.3.7) has + this problem. */ + +int +gettimeofday (struct timeval *restrict tv, void *restrict tz) +{ +#undef gettimeofday +#ifdef WINDOWS_NATIVE + + /* On native Windows, there are two ways to get the current time: + GetSystemTimeAsFileTime + + or + GetSystemTimePreciseAsFileTime + . + GetSystemTimeAsFileTime produces values that jump by increments of + 15.627 milliseconds (!) on average. + Whereas GetSystemTimePreciseAsFileTime values usually jump by 1 or 2 + microseconds. + More discussion on this topic: + . */ + FILETIME current_time; + +# if !(_WIN32_WINNT >= _WIN32_WINNT_WIN8) + if (!initialized) + initialize (); +# endif + if (GetSystemTimePreciseAsFileTimeFunc != NULL) + GetSystemTimePreciseAsFileTimeFunc (¤t_time); + else + GetSystemTimeAsFileTime (¤t_time); + + /* Convert from FILETIME to 'struct timeval'. */ + /* FILETIME: */ + ULONGLONG since_1601 = + ((ULONGLONG) current_time.dwHighDateTime << 32) + | (ULONGLONG) current_time.dwLowDateTime; + /* Between 1601-01-01 and 1970-01-01 there were 280 normal years and 89 leap + years, in total 134774 days. */ + ULONGLONG since_1970 = + since_1601 - (ULONGLONG) 134774 * (ULONGLONG) 86400 * (ULONGLONG) 10000000; + ULONGLONG microseconds_since_1970 = since_1970 / (ULONGLONG) 10; + *tv = (struct timeval) { + .tv_sec = microseconds_since_1970 / (ULONGLONG) 1000000, + .tv_usec = microseconds_since_1970 % (ULONGLONG) 1000000 + }; + + return 0; + +#else + +# if HAVE_GETTIMEOFDAY + +# if defined timeval /* 'struct timeval' overridden by gnulib? */ +# undef timeval + struct timeval otv; + int result = gettimeofday (&otv, (struct timezone *) tz); + if (result == 0) + *tv = otv; +# else + int result = gettimeofday (tv, (struct timezone *) tz); +# endif + + return result; + +# else + +# if !defined OK_TO_USE_1S_CLOCK +# error "Only 1-second nominal clock resolution found. Is that intended?" \ + "If so, compile with the -DOK_TO_USE_1S_CLOCK option." +# endif + *tv = (struct timeval) { .tv_sec = time (NULL), .tv_usec = 0 }; + + return 0; + +# endif +#endif +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/glthread/.gitignore b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/glthread/.gitignore new file mode 100644 index 00000000..e0605e15 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/glthread/.gitignore @@ -0,0 +1,3 @@ +/lock.c +/lock.h +/threadlib.c diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/glthread/lock.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/glthread/lock.c new file mode 100644 index 00000000..6661ad6a --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/glthread/lock.c @@ -0,0 +1,749 @@ +/* Locking in multithreaded situations. + Copyright (C) 2005-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 2005. + Based on GCC's gthr-posix.h, gthr-posix95.h. */ + +#include + +#include "glthread/lock.h" + +/* ========================================================================= */ + +#if USE_ISOC_THREADS || USE_ISOC_AND_POSIX_THREADS + +/* -------------------------- gl_lock_t datatype -------------------------- */ + +int +glthread_lock_init (gl_lock_t *lock) +{ + if (mtx_init (&lock->mutex, mtx_plain) != thrd_success) + return ENOMEM; + lock->init_needed = 0; + return 0; +} + +int +glthread_lock_lock (gl_lock_t *lock) +{ + if (lock->init_needed) + call_once (&lock->init_once, lock->init_func); + if (mtx_lock (&lock->mutex) != thrd_success) + return EAGAIN; + return 0; +} + +int +glthread_lock_unlock (gl_lock_t *lock) +{ + if (lock->init_needed) + call_once (&lock->init_once, lock->init_func); + if (mtx_unlock (&lock->mutex) != thrd_success) + return EINVAL; + return 0; +} + +int +glthread_lock_destroy (gl_lock_t *lock) +{ + if (lock->init_needed) + call_once (&lock->init_once, lock->init_func); + mtx_destroy (&lock->mutex); + return 0; +} + +/* ------------------------- gl_rwlock_t datatype ------------------------- */ + +int +glthread_rwlock_init (gl_rwlock_t *lock) +{ + if (mtx_init (&lock->lock, mtx_plain) != thrd_success + || cnd_init (&lock->waiting_readers) != thrd_success + || cnd_init (&lock->waiting_writers) != thrd_success) + return ENOMEM; + lock->waiting_writers_count = 0; + lock->runcount = 0; + lock->init_needed = 0; + return 0; +} + +int +glthread_rwlock_rdlock (gl_rwlock_t *lock) +{ + if (lock->init_needed) + call_once (&lock->init_once, lock->init_func); + if (mtx_lock (&lock->lock) != thrd_success) + return EAGAIN; + /* 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. */ + if (cnd_wait (&lock->waiting_readers, &lock->lock) != thrd_success) + { + mtx_unlock (&lock->lock); + return EINVAL; + } + } + lock->runcount++; + if (mtx_unlock (&lock->lock) != thrd_success) + return EINVAL; + return 0; +} + +int +glthread_rwlock_wrlock (gl_rwlock_t *lock) +{ + if (lock->init_needed) + call_once (&lock->init_once, lock->init_func); + if (mtx_lock (&lock->lock) != thrd_success) + return EAGAIN; + /* 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++; + if (cnd_wait (&lock->waiting_writers, &lock->lock) != thrd_success) + { + lock->waiting_writers_count--; + mtx_unlock (&lock->lock); + return EINVAL; + } + lock->waiting_writers_count--; + } + lock->runcount--; /* runcount becomes -1 */ + if (mtx_unlock (&lock->lock) != thrd_success) + return EINVAL; + return 0; +} + +int +glthread_rwlock_unlock (gl_rwlock_t *lock) +{ + if (lock->init_needed) + call_once (&lock->init_once, lock->init_func); + if (mtx_lock (&lock->lock) != thrd_success) + return EAGAIN; + if (lock->runcount < 0) + { + /* Drop a writer lock. */ + if (!(lock->runcount == -1)) + { + mtx_unlock (&lock->lock); + return EINVAL; + } + lock->runcount = 0; + } + else + { + /* Drop a reader lock. */ + if (!(lock->runcount > 0)) + { + mtx_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. */ + if (cnd_signal (&lock->waiting_writers) != thrd_success) + { + mtx_unlock (&lock->lock); + return EINVAL; + } + } + else + { + /* Wake up all waiting readers. */ + if (cnd_broadcast (&lock->waiting_readers) != thrd_success) + { + mtx_unlock (&lock->lock); + return EINVAL; + } + } + } + if (mtx_unlock (&lock->lock) != thrd_success) + return EINVAL; + return 0; +} + +int +glthread_rwlock_destroy (gl_rwlock_t *lock) +{ + if (lock->init_needed) + call_once (&lock->init_once, lock->init_func); + mtx_destroy (&lock->lock); + cnd_destroy (&lock->waiting_readers); + cnd_destroy (&lock->waiting_writers); + return 0; +} + +/* --------------------- gl_recursive_lock_t datatype --------------------- */ + +int +glthread_recursive_lock_init (gl_recursive_lock_t *lock) +{ + if (mtx_init (&lock->mutex, mtx_plain | mtx_recursive) != thrd_success) + return ENOMEM; + lock->init_needed = 0; + return 0; +} + +int +glthread_recursive_lock_lock (gl_recursive_lock_t *lock) +{ + if (lock->init_needed) + call_once (&lock->init_once, lock->init_func); + if (mtx_lock (&lock->mutex) != thrd_success) + return EAGAIN; + return 0; +} + +int +glthread_recursive_lock_unlock (gl_recursive_lock_t *lock) +{ + if (lock->init_needed) + call_once (&lock->init_once, lock->init_func); + if (mtx_unlock (&lock->mutex) != thrd_success) + return EINVAL; + return 0; +} + +int +glthread_recursive_lock_destroy (gl_recursive_lock_t *lock) +{ + if (lock->init_needed) + call_once (&lock->init_once, lock->init_func); + mtx_destroy (&lock->mutex); + return 0; +} + +/* -------------------------- gl_once_t datatype -------------------------- */ + +#endif + +/* ========================================================================= */ + +#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))) + +# if defined PTHREAD_RWLOCK_INITIALIZER || defined PTHREAD_RWLOCK_INITIALIZER_NP + +# 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; +} + +# if !(PTHREAD_IN_USE_DETECTION_HARD || USE_POSIX_THREADS_WEAK) + +int +glthread_once_multithreaded (pthread_once_t *once_control, + void (*init_function) (void)) +{ + int err = pthread_once (once_control, init_function); + if (err == ENOSYS) + { + /* This happens on FreeBSD 11: The pthread_once function in libc returns + ENOSYS. */ + if (glthread_once_singlethreaded (once_control)) + init_function (); + return 0; + } + return err; +} + +# endif + +#endif + +/* ========================================================================= */ + +#if USE_WINDOWS_THREADS + +#endif + +/* ========================================================================= */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/glthread/lock.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/glthread/lock.h new file mode 100644 index 00000000..2d5cb320 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/glthread/lock.h @@ -0,0 +1,799 @@ +/* Locking in multithreaded situations. + Copyright (C) 2005-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 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 + +/* This file uses HAVE_THREADS_H, HAVE_PTHREAD_RWLOCK, + HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER, + PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP, + HAVE_PTHREAD_MUTEX_RECURSIVE. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +#include +#include + +#if !defined c11_threads_in_use +# if HAVE_THREADS_H && USE_POSIX_THREADS_FROM_LIBC +# define c11_threads_in_use() 1 +# elif HAVE_THREADS_H && USE_POSIX_THREADS_WEAK +# include +# pragma weak thrd_exit +# define c11_threads_in_use() (thrd_exit != NULL) +# else +# define c11_threads_in_use() 0 +# endif +#endif + +/* ========================================================================= */ + +#if USE_ISOC_THREADS || USE_ISOC_AND_POSIX_THREADS + +/* Use the ISO C threads library. */ + +# include + +# ifdef __cplusplus +extern "C" { +# endif + +/* -------------------------- gl_lock_t datatype -------------------------- */ + +typedef struct + { + int volatile init_needed; + once_flag init_once; + void (*init_func) (void); + mtx_t mutex; + } + gl_lock_t; +# define gl_lock_define(STORAGECLASS, NAME) \ + STORAGECLASS gl_lock_t NAME; +# define gl_lock_define_initialized(STORAGECLASS, NAME) \ + static void _atomic_init_##NAME (void); \ + STORAGECLASS gl_lock_t NAME = \ + { 1, ONCE_FLAG_INIT, _atomic_init_##NAME }; \ + static void _atomic_init_##NAME (void) \ + { \ + if (glthread_lock_init (&(NAME))) \ + abort (); \ + } +extern int glthread_lock_init (gl_lock_t *lock); +extern int glthread_lock_lock (gl_lock_t *lock); +extern int glthread_lock_unlock (gl_lock_t *lock); +extern int glthread_lock_destroy (gl_lock_t *lock); + +/* ------------------------- gl_rwlock_t datatype ------------------------- */ + +typedef struct + { + int volatile init_needed; + once_flag init_once; + void (*init_func) (void); + mtx_t lock; /* protects the remaining fields */ + cnd_t waiting_readers; /* waiting readers */ + cnd_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) \ + static void _atomic_init_##NAME (void); \ + STORAGECLASS gl_rwlock_t NAME = \ + { 1, ONCE_FLAG_INIT, _atomic_init_##NAME }; \ + static void _atomic_init_##NAME (void) \ + { \ + if (glthread_rwlock_init (&(NAME))) \ + abort (); \ + } +extern int glthread_rwlock_init (gl_rwlock_t *lock); +extern int glthread_rwlock_rdlock (gl_rwlock_t *lock); +extern int glthread_rwlock_wrlock (gl_rwlock_t *lock); +extern int glthread_rwlock_unlock (gl_rwlock_t *lock); +extern int glthread_rwlock_destroy (gl_rwlock_t *lock); + +/* --------------------- gl_recursive_lock_t datatype --------------------- */ + +typedef struct + { + int volatile init_needed; + once_flag init_once; + void (*init_func) (void); + mtx_t mutex; + } + 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) \ + static void _atomic_init_##NAME (void); \ + STORAGECLASS gl_recursive_lock_t NAME = \ + { 1, ONCE_FLAG_INIT, _atomic_init_##NAME }; \ + static void _atomic_init_##NAME (void) \ + { \ + if (glthread_recursive_lock_init (&(NAME))) \ + abort (); \ + } +extern int glthread_recursive_lock_init (gl_recursive_lock_t *lock); +extern int glthread_recursive_lock_lock (gl_recursive_lock_t *lock); +extern int glthread_recursive_lock_unlock (gl_recursive_lock_t *lock); +extern int glthread_recursive_lock_destroy (gl_recursive_lock_t *lock); + +/* -------------------------- gl_once_t datatype -------------------------- */ + +typedef once_flag gl_once_t; +# define gl_once_define(STORAGECLASS, NAME) \ + STORAGECLASS once_flag NAME = ONCE_FLAG_INIT; +# define glthread_once(ONCE_CONTROL, INITFUNCTION) \ + (call_once (ONCE_CONTROL, INITFUNCTION), 0) + +# ifdef __cplusplus +} +# endif + +#endif + +/* ========================================================================= */ + +#if USE_POSIX_THREADS + +/* Use the POSIX threads library. */ + +# include + +# 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))) + +# if defined PTHREAD_RWLOCK_INITIALIZER || defined PTHREAD_RWLOCK_INITIALIZER_NP + +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 +# if defined PTHREAD_RWLOCK_INITIALIZER +# define gl_rwlock_initializer \ + PTHREAD_RWLOCK_INITIALIZER +# else +# define gl_rwlock_initializer \ + PTHREAD_RWLOCK_INITIALIZER_NP +# endif +# 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; +# if PTHREAD_IN_USE_DETECTION_HARD || USE_POSIX_THREADS_WEAK +# define glthread_once(ONCE_CONTROL, INITFUNCTION) \ + (pthread_in_use () \ + ? pthread_once (ONCE_CONTROL, INITFUNCTION) \ + : (glthread_once_singlethreaded (ONCE_CONTROL) ? (INITFUNCTION (), 0) : 0)) +# else +# define glthread_once(ONCE_CONTROL, INITFUNCTION) \ + (pthread_in_use () \ + ? glthread_once_multithreaded (ONCE_CONTROL, INITFUNCTION) \ + : (glthread_once_singlethreaded (ONCE_CONTROL) ? (INITFUNCTION (), 0) : 0)) +extern int glthread_once_multithreaded (pthread_once_t *once_control, + void (*init_function) (void)); +# endif +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 + +# 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_ISOC_THREADS || USE_POSIX_THREADS || USE_ISOC_AND_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 */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/glthread/threadlib.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/glthread/threadlib.c new file mode 100644 index 00000000..7a776768 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/glthread/threadlib.c @@ -0,0 +1,108 @@ +/* Multithreading primitives. + Copyright (C) 2005-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 2005. */ + +#include + +/* ========================================================================= */ + +#if USE_POSIX_THREADS || USE_ISOC_AND_POSIX_THREADS + +/* Use the POSIX threads library. */ + +# include +# include +# include + +# if PTHREAD_IN_USE_DETECTION_HARD + +# if defined __FreeBSD__ || defined __DragonFly__ /* FreeBSD */ + +/* Test using pthread_key_create. */ + +int +glthread_in_use (void) +{ + static int tested; + static int result; /* 1: linked with -lpthread, 0: only with libc */ + + if (!tested) + { + pthread_key_t key; + int err = pthread_key_create (&key, NULL); + + if (err == ENOSYS) + result = 0; + else + { + result = 1; + if (err == 0) + pthread_key_delete (key); + } + tested = 1; + } + return result; +} + +# else /* Solaris, HP-UX */ + +/* Test using pthread_create. */ + +/* 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 + +#endif + +/* ========================================================================= */ + +/* This declaration is solely to ensure that after preprocessing + this file is never empty. */ +typedef int dummy; diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/gnulib.mk b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/gnulib.mk new file mode 100644 index 00000000..b38c8d3d --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/gnulib.mk @@ -0,0 +1,4189 @@ +## DO NOT EDIT! GENERATED AUTOMATICALLY! +## Process this file with automake to produce Makefile.in. +# Copyright (C) 2002-2024 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 +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This file 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 file. If not, see . +# +# As a special exception to the GNU General Public License, +# this file may be distributed as part of a program that +# contains a configuration script generated by Autoconf, under +# the same distribution terms as the rest of that program. +# +# Generated by gnulib-tool. +# Reproduce by: +# gnulib-tool --import \ +# --local-dir=gl \ +# --lib=libdiffutils \ +# --source-base=lib \ +# --m4-base=m4 \ +# --doc-base=doc \ +# --tests-base=gnulib-tests \ +# --aux-dir=build-aux \ +# --with-tests \ +# --makefile-name=gnulib.mk \ +# --no-conditional-dependencies \ +# --no-libtool \ +# --macro-prefix=gl \ +# --avoid=localename \ +# --avoid=lock-tests \ +# --avoid=setlocale \ +# announce-gen \ +# argmatch \ +# assert-h \ +# attribute \ +# binary-io \ +# builtin-expect \ +# c-ctype \ +# c-stack \ +# c32isspace \ +# c32tolower \ +# c32width \ +# careadlinkat \ +# config-h \ +# count-leading-zeros \ +# diffseq \ +# dirname \ +# do-release-commit-and-tag \ +# dup2 \ +# error \ +# exclude \ +# exitfail \ +# extensions \ +# extern-inline \ +# fcntl \ +# fdopendir \ +# file-type \ +# filenamecat \ +# flexmember \ +# fnmatch-gnu \ +# fstatat \ +# getopt-gnu \ +# gettext-h \ +# git-version-gen \ +# gitlog-to-changelog \ +# gnu-make \ +# gnu-web-doc-update \ +# gnumakefile \ +# gnupload \ +# hard-locale \ +# ialloc \ +# idx \ +# intprops \ +# inttypes \ +# isblank \ +# largefile \ +# lstat \ +# maintainer-makefile \ +# manywarnings \ +# mbrtoc32 \ +# mempcpy \ +# minmax \ +# mkstemp \ +# mktime \ +# nstrftime \ +# nullptr \ +# openat \ +# pclose \ +# perl \ +# popen \ +# progname \ +# propername-lite \ +# raise \ +# rawmemchr \ +# readdir \ +# readlinkat \ +# readme-release \ +# regex \ +# same-inode \ +# sh-quote \ +# sigaction \ +# signal \ +# sigprocmask \ +# stat \ +# stat-macros \ +# stat-time \ +# stdbool \ +# stdckdint \ +# stdint \ +# stpcpy \ +# strcase \ +# strptime \ +# strtoimax \ +# sys_wait \ +# system-quote \ +# time_rz \ +# timespec \ +# timespec_get \ +# unistd \ +# unlocked-io \ +# update-copyright \ +# verify \ +# version-etc \ +# version-etc-fsf \ +# xalloc \ +# xfreopen \ +# xmalloca \ +# xstdopen \ +# xstrtoimax \ +# year2038 + + +MOSTLYCLEANFILES += core *.stackdump +# No GNU Make output. + +noinst_LIBRARIES += libdiffutils.a + +libdiffutils_a_SOURCES = +libdiffutils_a_CFLAGS = $(AM_CFLAGS) $(GL_CFLAG_GNULIB_WARNINGS) +libdiffutils_a_LIBADD = $(gl_LIBOBJS) +libdiffutils_a_DEPENDENCIES = $(gl_LIBOBJS) +EXTRA_libdiffutils_a_SOURCES = + +## begin gnulib module absolute-header + +# Use this preprocessor expression to decide whether #include_next works. +# Do not rely on a 'configure'-time test for this, since the expression +# might appear in an installed header, which is used by some other compiler. +HAVE_INCLUDE_NEXT = (__GNUC__ || __clang__ || 60000000 <= __DECC_VER) + +## end gnulib module absolute-header + +## begin gnulib module alloca-opt + +BUILT_SOURCES += $(ALLOCA_H) + +# We need the following in order to create when the system +# doesn't have one that works with the given compiler. +if GL_GENERATE_ALLOCA_H +alloca.h: alloca.in.h $(top_builddir)/config.status + $(gl_V_at)$(SED_HEADER_STDOUT) \ + -e 's|@''HAVE_ALLOCA_H''@|$(HAVE_ALLOCA_H)|g' \ + $(srcdir)/alloca.in.h > $@-t + $(AM_V_at)mv $@-t $@ +else +alloca.h: $(top_builddir)/config.status + rm -f $@ +endif +MOSTLYCLEANFILES += alloca.h alloca.h-t + +EXTRA_DIST += alloca.in.h + +## end gnulib module alloca-opt + +## begin gnulib module allocator + +libdiffutils_a_SOURCES += allocator.c + +EXTRA_DIST += allocator.h + +## end gnulib module allocator + +## begin gnulib module announce-gen + + +EXTRA_DIST += $(top_srcdir)/build-aux/announce-gen + +## end gnulib module announce-gen + +## begin gnulib module argmatch + +libdiffutils_a_SOURCES += argmatch.c + +EXTRA_DIST += argmatch.h + +## end gnulib module argmatch + +## begin gnulib module assert-h + +BUILT_SOURCES += $(ASSERT_H) + +# We need the following in order to create when the system +# doesn't have one that works with the given compiler. +if GL_GENERATE_ASSERT_H +assert.h: assert.in.h verify.h $(top_builddir)/config.status + $(gl_V_at){ $(SED_HEADER_STDOUT) \ + -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_ASSERT_H''@|$(NEXT_ASSERT_H)|g' \ + < $(srcdir)/assert.in.h && \ + sed -e '/@assert.h omit start@/,/@assert.h omit end@/d' \ + -e 's|_gl_verify|_gl_static_assert|g' \ + -e 's|_GL_VERIFY|_GL_STATIC_ASSERT|g' \ + -e 's|_GL\(_STATIC_ASSERT_H\)|_GL\1|g' \ + < $(srcdir)/verify.h; \ + } > $@-t + $(AM_V_at)mv $@-t $@ +else +assert.h: $(top_builddir)/config.status + rm -f $@ +endif +MOSTLYCLEANFILES += assert.h assert.h-t + +EXTRA_DIST += assert.in.h verify.h + +## end gnulib module assert-h + +## begin gnulib module assure + + +EXTRA_DIST += assure.h + +## end gnulib module assure + +## begin gnulib module at-internal + +libdiffutils_a_SOURCES += openat-priv.h openat-proc.c + +## end gnulib module at-internal + +## begin gnulib module attribute + + +EXTRA_DIST += attribute.h + +## end gnulib module attribute + +## begin gnulib module basename-lgpl + +libdiffutils_a_SOURCES += basename-lgpl.c + +EXTRA_DIST += basename-lgpl.h + +## end gnulib module basename-lgpl + +## begin gnulib module binary-io + +libdiffutils_a_SOURCES += binary-io.h binary-io.c + +## end gnulib module binary-io + +## begin gnulib module bitrotate + +libdiffutils_a_SOURCES += bitrotate.h bitrotate.c + +## end gnulib module bitrotate + +## begin gnulib module btoc32 + +libdiffutils_a_SOURCES += btoc32.c + +## end gnulib module btoc32 + +## begin gnulib module btowc + +if GL_COND_OBJ_BTOWC +libdiffutils_a_SOURCES += btowc.c +endif + +## end gnulib module btowc + +## begin gnulib module c-ctype + +libdiffutils_a_SOURCES += c-ctype.h c-ctype.c + +## end gnulib module c-ctype + +## begin gnulib module c-file-type + +libdiffutils_a_SOURCES += c-file-type.c + +EXTRA_DIST += file-type.h + +## end gnulib module c-file-type + +## begin gnulib module c-stack + +libdiffutils_a_SOURCES += c-stack.h c-stack.c + +## end gnulib module c-stack + +## begin gnulib module c-strcase + +libdiffutils_a_SOURCES += c-strcase.h c-strcasecmp.c c-strncasecmp.c + +## end gnulib module c-strcase + +## begin gnulib module c-strcaseeq + + +EXTRA_DIST += c-strcaseeq.h + +## end gnulib module c-strcaseeq + +## begin gnulib module c32_apply_type_test + +libdiffutils_a_SOURCES += c32_apply_type_test.c + +## end gnulib module c32_apply_type_test + +## begin gnulib module c32_get_type_test + +libdiffutils_a_SOURCES += c32_get_type_test.c + +## end gnulib module c32_get_type_test + +## begin gnulib module c32isalnum + +libdiffutils_a_SOURCES += c32isalnum.c + +EXTRA_DIST += c32is-impl.h + +## end gnulib module c32isalnum + +## begin gnulib module c32isalpha + +libdiffutils_a_SOURCES += c32isalpha.c + +EXTRA_DIST += c32is-impl.h + +## end gnulib module c32isalpha + +## begin gnulib module c32isblank + +libdiffutils_a_SOURCES += c32isblank.c + +EXTRA_DIST += c32is-impl.h + +## end gnulib module c32isblank + +## begin gnulib module c32iscntrl + +libdiffutils_a_SOURCES += c32iscntrl.c + +EXTRA_DIST += c32is-impl.h + +## end gnulib module c32iscntrl + +## begin gnulib module c32isdigit + +libdiffutils_a_SOURCES += c32isdigit.c + +EXTRA_DIST += c32is-impl.h + +## end gnulib module c32isdigit + +## begin gnulib module c32isgraph + +libdiffutils_a_SOURCES += c32isgraph.c + +EXTRA_DIST += c32is-impl.h + +## end gnulib module c32isgraph + +## begin gnulib module c32islower + +libdiffutils_a_SOURCES += c32islower.c + +EXTRA_DIST += c32is-impl.h + +## end gnulib module c32islower + +## begin gnulib module c32isprint + +libdiffutils_a_SOURCES += c32isprint.c + +EXTRA_DIST += c32is-impl.h + +## end gnulib module c32isprint + +## begin gnulib module c32ispunct + +libdiffutils_a_SOURCES += c32ispunct.c + +EXTRA_DIST += c32is-impl.h + +## end gnulib module c32ispunct + +## begin gnulib module c32isspace + +libdiffutils_a_SOURCES += c32isspace.c + +EXTRA_DIST += c32is-impl.h + +## end gnulib module c32isspace + +## begin gnulib module c32isupper + +libdiffutils_a_SOURCES += c32isupper.c + +EXTRA_DIST += c32is-impl.h + +## end gnulib module c32isupper + +## begin gnulib module c32isxdigit + +libdiffutils_a_SOURCES += c32isxdigit.c + +EXTRA_DIST += c32is-impl.h + +## end gnulib module c32isxdigit + +## begin gnulib module c32tolower + +libdiffutils_a_SOURCES += c32tolower.c + +EXTRA_DIST += c32to-impl.h + +## end gnulib module c32tolower + +## begin gnulib module c32width + +libdiffutils_a_SOURCES += c32width.c + +## end gnulib module c32width + +## begin gnulib module calloc-gnu + + +EXTRA_DIST += calloc.c + +EXTRA_libdiffutils_a_SOURCES += calloc.c + +## end gnulib module calloc-gnu + +## begin gnulib module calloc-posix + + +EXTRA_DIST += calloc.c + +EXTRA_libdiffutils_a_SOURCES += calloc.c + +## end gnulib module calloc-posix + +## begin gnulib module careadlinkat + +libdiffutils_a_SOURCES += careadlinkat.c + +EXTRA_DIST += careadlinkat.h + +## end gnulib module careadlinkat + +## begin gnulib module chdir-long + +if GL_COND_OBJ_CHDIR_LONG +libdiffutils_a_SOURCES += chdir-long.c +endif + +EXTRA_DIST += chdir-long.h + +## end gnulib module chdir-long + +## begin gnulib module cloexec + +libdiffutils_a_SOURCES += cloexec.c + +EXTRA_DIST += cloexec.h + +## end gnulib module cloexec + +## begin gnulib module close + +if GL_COND_OBJ_CLOSE +libdiffutils_a_SOURCES += close.c +endif + +## end gnulib module close + +## begin gnulib module closedir + +if GL_COND_OBJ_CLOSEDIR +libdiffutils_a_SOURCES += closedir.c +endif + +EXTRA_DIST += dirent-private.h + +## end gnulib module closedir + +## begin gnulib module count-leading-zeros + +libdiffutils_a_SOURCES += count-leading-zeros.c + +EXTRA_DIST += count-leading-zeros.h + +## end gnulib module count-leading-zeros + +## begin gnulib module ctype + +BUILT_SOURCES += ctype.h + +# We need the following in order to create when the system +# doesn't have one that works with the given compiler. +ctype.h: ctype.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) + $(gl_V_at)$(SED_HEADER_STDOUT) \ + -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_CTYPE_H''@|$(NEXT_CTYPE_H)|g' \ + -e 's/@''GNULIB_ISBLANK''@/$(GL_GNULIB_ISBLANK)/g' \ + -e 's/@''HAVE_ISBLANK''@/$(HAVE_ISBLANK)/g' \ + -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ + -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ + $(srcdir)/ctype.in.h > $@-t + $(AM_V_at)mv $@-t $@ +MOSTLYCLEANFILES += ctype.h ctype.h-t + +EXTRA_DIST += ctype.in.h + +## end gnulib module ctype + +## begin gnulib module diffseq + +libdiffutils_a_SOURCES += diffseq.h + +## end gnulib module diffseq + +## begin gnulib module dirent + +BUILT_SOURCES += dirent.h + +# We need the following in order to create when the system +# doesn't have one that works with the given compiler. +dirent.h: dirent.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) + $(gl_V_at)$(SED_HEADER_STDOUT) \ + -e 's|@''GUARD_PREFIX''@|GL|g' \ + -e 's|@''HAVE_DIRENT_H''@|$(HAVE_DIRENT_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_DIRENT_H''@|$(NEXT_DIRENT_H)|g' \ + -e 's/@''DIR_HAS_FD_MEMBER''@/$(DIR_HAS_FD_MEMBER)/g' \ + -e 's/@''GNULIB_OPENDIR''@/$(GL_GNULIB_OPENDIR)/g' \ + -e 's/@''GNULIB_READDIR''@/$(GL_GNULIB_READDIR)/g' \ + -e 's/@''GNULIB_REWINDDIR''@/$(GL_GNULIB_REWINDDIR)/g' \ + -e 's/@''GNULIB_CLOSEDIR''@/$(GL_GNULIB_CLOSEDIR)/g' \ + -e 's/@''GNULIB_DIRFD''@/$(GL_GNULIB_DIRFD)/g' \ + -e 's/@''GNULIB_FDOPENDIR''@/$(GL_GNULIB_FDOPENDIR)/g' \ + -e 's/@''GNULIB_SCANDIR''@/$(GL_GNULIB_SCANDIR)/g' \ + -e 's/@''GNULIB_ALPHASORT''@/$(GL_GNULIB_ALPHASORT)/g' \ + -e 's/@''HAVE_OPENDIR''@/$(HAVE_OPENDIR)/g' \ + -e 's/@''HAVE_READDIR''@/$(HAVE_READDIR)/g' \ + -e 's/@''HAVE_REWINDDIR''@/$(HAVE_REWINDDIR)/g' \ + -e 's/@''HAVE_CLOSEDIR''@/$(HAVE_CLOSEDIR)/g' \ + -e 's|@''HAVE_DECL_DIRFD''@|$(HAVE_DECL_DIRFD)|g' \ + -e 's|@''HAVE_DECL_FDOPENDIR''@|$(HAVE_DECL_FDOPENDIR)|g' \ + -e 's|@''HAVE_FDOPENDIR''@|$(HAVE_FDOPENDIR)|g' \ + -e 's|@''HAVE_SCANDIR''@|$(HAVE_SCANDIR)|g' \ + -e 's|@''HAVE_ALPHASORT''@|$(HAVE_ALPHASORT)|g' \ + -e 's|@''REPLACE_OPENDIR''@|$(REPLACE_OPENDIR)|g' \ + -e 's|@''REPLACE_READDIR''@|$(REPLACE_READDIR)|g' \ + -e 's|@''REPLACE_REWINDDIR''@|$(REPLACE_REWINDDIR)|g' \ + -e 's|@''REPLACE_CLOSEDIR''@|$(REPLACE_CLOSEDIR)|g' \ + -e 's|@''REPLACE_DIRFD''@|$(REPLACE_DIRFD)|g' \ + -e 's|@''REPLACE_FDOPENDIR''@|$(REPLACE_FDOPENDIR)|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)/dirent.in.h > $@-t + $(AM_V_at)mv $@-t $@ +MOSTLYCLEANFILES += dirent.h dirent.h-t + +EXTRA_DIST += dirent.in.h + +## end gnulib module dirent + +## begin gnulib module dirfd + +if GL_COND_OBJ_DIRFD +libdiffutils_a_SOURCES += dirfd.c +endif + +EXTRA_DIST += dirent-private.h + +## end gnulib module dirfd + +## begin gnulib module dirname + +libdiffutils_a_SOURCES += dirname.c basename.c + +EXTRA_DIST += stripslash.c + +EXTRA_libdiffutils_a_SOURCES += stripslash.c + +## end gnulib module dirname + +## begin gnulib module dirname-lgpl + +libdiffutils_a_SOURCES += dirname-lgpl.c stripslash.c + +EXTRA_DIST += dirname.h + +## end gnulib module dirname-lgpl + +## begin gnulib module do-release-commit-and-tag + + +EXTRA_DIST += $(top_srcdir)/build-aux/do-release-commit-and-tag + +## end gnulib module do-release-commit-and-tag + +## begin gnulib module dup + +if GL_COND_OBJ_DUP +libdiffutils_a_SOURCES += dup.c +endif + +## end gnulib module dup + +## begin gnulib module dup2 + +if GL_COND_OBJ_DUP2 +libdiffutils_a_SOURCES += dup2.c +endif + +## end gnulib module dup2 + +## begin gnulib module errno + +BUILT_SOURCES += $(ERRNO_H) + +# We need the following in order to create when the system +# doesn't have one that is POSIX compliant. +if GL_GENERATE_ERRNO_H +errno.h: errno.in.h $(top_builddir)/config.status + $(gl_V_at)$(SED_HEADER_STDOUT) \ + -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_ERRNO_H''@|$(NEXT_ERRNO_H)|g' \ + -e 's|@''EMULTIHOP_HIDDEN''@|$(EMULTIHOP_HIDDEN)|g' \ + -e 's|@''EMULTIHOP_VALUE''@|$(EMULTIHOP_VALUE)|g' \ + -e 's|@''ENOLINK_HIDDEN''@|$(ENOLINK_HIDDEN)|g' \ + -e 's|@''ENOLINK_VALUE''@|$(ENOLINK_VALUE)|g' \ + -e 's|@''EOVERFLOW_HIDDEN''@|$(EOVERFLOW_HIDDEN)|g' \ + -e 's|@''EOVERFLOW_VALUE''@|$(EOVERFLOW_VALUE)|g' \ + $(srcdir)/errno.in.h > $@-t + $(AM_V_at)mv $@-t $@ +else +errno.h: $(top_builddir)/config.status + rm -f $@ +endif +MOSTLYCLEANFILES += errno.h errno.h-t + +EXTRA_DIST += errno.in.h + +## end gnulib module errno + +## begin gnulib module error + +if GL_COND_OBJ_ERROR +libdiffutils_a_SOURCES += error.c +endif + +## end gnulib module error + +## begin gnulib module error-h + +BUILT_SOURCES += error.h + +# We need the following in order to override . +error.h: error.in.h $(top_builddir)/config.status $(CXXDEFS_H) + $(gl_V_at)$(SED_HEADER_STDOUT) \ + -e 's|@''GUARD_PREFIX''@|GL|g' \ + -e 's|@''HAVE_ERROR_H''@|$(HAVE_ERROR_H)|g' \ + -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ + -e 's|@''NEXT_ERROR_H''@|$(NEXT_ERROR_H)|g' \ + -e 's|@''HAVE_ERROR''@|$(HAVE_ERROR)|g' \ + -e 's|@''HAVE_ERROR_AT_LINE''@|$(HAVE_ERROR_AT_LINE)|g' \ + -e 's|@''REPLACE_ERROR''@|$(REPLACE_ERROR)|g' \ + -e 's|@''REPLACE_ERROR_AT_LINE''@|$(REPLACE_ERROR_AT_LINE)|g' \ + -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ + $(srcdir)/error.in.h > $@-t + $(AM_V_at)mv $@-t $@ +MOSTLYCLEANFILES += error.h error.h-t + +EXTRA_DIST += error.in.h + +## end gnulib module error-h + +## begin gnulib module exclude + +libdiffutils_a_SOURCES += exclude.c + +EXTRA_DIST += exclude.h + +## end gnulib module exclude + +## begin gnulib module exitfail + +libdiffutils_a_SOURCES += exitfail.c + +EXTRA_DIST += exitfail.h + +## end gnulib module exitfail + +## begin gnulib module fchdir + +if GL_COND_OBJ_FCHDIR +libdiffutils_a_SOURCES += fchdir.c +endif + +## end gnulib module fchdir + +## begin gnulib module fcntl + +if GL_COND_OBJ_FCNTL +libdiffutils_a_SOURCES += fcntl.c +endif + +## end gnulib module fcntl + +## begin gnulib module fcntl-h + +BUILT_SOURCES += fcntl.h + +# We need the following in order to create when the system +# doesn't have one that works with the given compiler. +fcntl.h: fcntl.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) + $(gl_V_at)$(SED_HEADER_STDOUT) \ + -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_FCNTL_H''@|$(NEXT_FCNTL_H)|g' \ + -e 's/@''GNULIB_CREAT''@/$(GL_GNULIB_CREAT)/g' \ + -e 's/@''GNULIB_FCNTL''@/$(GL_GNULIB_FCNTL)/g' \ + -e 's/@''GNULIB_NONBLOCKING''@/$(GL_GNULIB_NONBLOCKING)/g' \ + -e 's/@''GNULIB_OPEN''@/$(GL_GNULIB_OPEN)/g' \ + -e 's/@''GNULIB_OPENAT''@/$(GL_GNULIB_OPENAT)/g' \ + -e 's/@''GNULIB_MDA_CREAT''@/$(GL_GNULIB_MDA_CREAT)/g' \ + -e 's/@''GNULIB_MDA_OPEN''@/$(GL_GNULIB_MDA_OPEN)/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' \ + -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)/fcntl.in.h > $@-t + $(AM_V_at)mv $@-t $@ +MOSTLYCLEANFILES += fcntl.h fcntl.h-t + +EXTRA_DIST += fcntl.in.h + +## end gnulib module fcntl-h + +## begin gnulib module fd-hook + +libdiffutils_a_SOURCES += fd-hook.c + +EXTRA_DIST += fd-hook.h + +## end gnulib module fd-hook + +## begin gnulib module fd-safer-flag + +libdiffutils_a_SOURCES += fd-safer-flag.c dup-safer-flag.c + +## end gnulib module fd-safer-flag + +## begin gnulib module fdopendir + +if GL_COND_OBJ_FDOPENDIR +libdiffutils_a_SOURCES += fdopendir.c +endif + +EXTRA_DIST += dirent-private.h + +## end gnulib module fdopendir + +## begin gnulib module file-type + +libdiffutils_a_SOURCES += file-type.c + +EXTRA_DIST += file-type.h + +## end gnulib module file-type + +## begin gnulib module filename + + +EXTRA_DIST += filename.h + +## end gnulib module filename + +## begin gnulib module filenamecat + +libdiffutils_a_SOURCES += filenamecat.c + +## end gnulib module filenamecat + +## begin gnulib module filenamecat-lgpl + +libdiffutils_a_SOURCES += filenamecat-lgpl.c + +EXTRA_DIST += filenamecat.h + +## end gnulib module filenamecat-lgpl + +## begin gnulib module flexmember + + +EXTRA_DIST += flexmember.h + +## end gnulib module flexmember + +## begin gnulib module fnmatch + + +EXTRA_DIST += fnmatch.c fnmatch_loop.c + +EXTRA_libdiffutils_a_SOURCES += fnmatch.c fnmatch_loop.c + +## end gnulib module fnmatch + +## begin gnulib module fnmatch-gnu + + +EXTRA_DIST += fnmatch.c + +EXTRA_libdiffutils_a_SOURCES += fnmatch.c + +## end gnulib module fnmatch-gnu + +## begin gnulib module fnmatch-h + +BUILT_SOURCES += $(FNMATCH_H) + +# We need the following in order to create . +if GL_GENERATE_FNMATCH_H +fnmatch.h: fnmatch.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) + $(gl_V_at)$(SED_HEADER_STDOUT) \ + -e 's|@''GUARD_PREFIX''@|GL|g' \ + -e 's|@''HAVE_FNMATCH_H''@|$(HAVE_FNMATCH_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_FNMATCH_H''@|$(NEXT_FNMATCH_H)|g' \ + -e 's/@''GNULIB_FNMATCH''@/$(GL_GNULIB_FNMATCH)/g' \ + -e 's|@''HAVE_FNMATCH''@|$(HAVE_FNMATCH)|g' \ + -e 's|@''REPLACE_FNMATCH''@|$(REPLACE_FNMATCH)|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)/fnmatch.in.h > $@-t + $(AM_V_at)mv $@-t $@ +else +fnmatch.h: $(top_builddir)/config.status + rm -f $@ +endif +MOSTLYCLEANFILES += fnmatch.h fnmatch.h-t + +EXTRA_DIST += fnmatch.in.h + +## end gnulib module fnmatch-h + +## begin gnulib module fopen + + +EXTRA_DIST += fopen.c + +EXTRA_libdiffutils_a_SOURCES += fopen.c + +## end gnulib module fopen + +## begin gnulib module fopen-gnu + + +EXTRA_DIST += fopen.c + +EXTRA_libdiffutils_a_SOURCES += fopen.c + +## end gnulib module fopen-gnu + +## begin gnulib module free-posix + +if GL_COND_OBJ_FREE +libdiffutils_a_SOURCES += free.c +endif + +## end gnulib module free-posix + +## begin gnulib module freopen + +if GL_COND_OBJ_FREOPEN +libdiffutils_a_SOURCES += freopen.c +endif + +## end gnulib module freopen + +## begin gnulib module fstat + +if GL_COND_OBJ_FSTAT +libdiffutils_a_SOURCES += fstat.c +endif + +EXTRA_DIST += stat-w32.c stat-w32.h + +EXTRA_libdiffutils_a_SOURCES += stat-w32.c + +## end gnulib module fstat + +## begin gnulib module fstatat + +if GL_COND_OBJ_FSTATAT +libdiffutils_a_SOURCES += fstatat.c +endif + +EXTRA_DIST += at-func.c + +EXTRA_libdiffutils_a_SOURCES += at-func.c + +## end gnulib module fstatat + +## begin gnulib module gen-header + +# In 'sed', replace the pattern space with a "DO NOT EDIT" comment. +SED_HEADER_NOEDIT = s,.*,/* DO NOT EDIT! GENERATED AUTOMATICALLY! */, + +# '$(SED_HEADER_STDOUT) -e "..."' runs 'sed' but first outputs "DO NOT EDIT". +SED_HEADER_STDOUT = sed -e 1h -e '1$(SED_HEADER_NOEDIT)' -e 1G + +# '$(SED_HEADER_TO_AT_t) FILE' copies FILE to $@-t, prepending a leading +# "DO_NOT_EDIT". Although this could be done more simply via: +# SED_HEADER_TO_AT_t = $(SED_HEADER_STDOUT) > $@-t +# the -n and 'w' avoid a fork+exec, at least when GNU Make is used. +SED_HEADER_TO_AT_t = $(SED_HEADER_STDOUT) -n -e 'w $@-t' + +# Use $(gl_V_at) instead of $(AM_V_GEN) or $(AM_V_at) on a line that +# is its recipe's first line if and only if @NMD@ lines are absent. +gl_V_at = $(AM_V_GEN) + +## end gnulib module gen-header + +## begin gnulib module gendocs + + +EXTRA_DIST += $(top_srcdir)/build-aux/gendocs.sh + +## end gnulib module gendocs + +## begin gnulib module getcwd-lgpl + +if GL_COND_OBJ_GETCWD_LGPL +libdiffutils_a_SOURCES += getcwd-lgpl.c +endif + +## end gnulib module getcwd-lgpl + +## begin gnulib module getdtablesize + +if GL_COND_OBJ_GETDTABLESIZE +libdiffutils_a_SOURCES += getdtablesize.c +endif + +## end gnulib module getdtablesize + +## begin gnulib module getopt-posix + +BUILT_SOURCES += $(GETOPT_H) $(GETOPT_CDEFS_H) + +# We need the following in order to create when the system +# doesn't have one that works with the given compiler. +if GL_GENERATE_GETOPT_H +getopt.h: getopt.in.h $(top_builddir)/config.status $(ARG_NONNULL_H) + $(gl_V_at)$(SED_HEADER_STDOUT) \ + -e 's|@''GUARD_PREFIX''@|GL|g' \ + -e 's|@''HAVE_GETOPT_H''@|$(HAVE_GETOPT_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_GETOPT_H''@|$(NEXT_GETOPT_H)|g' \ + -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ + $(srcdir)/getopt.in.h > $@-t + $(AM_V_at)mv $@-t $@ +else +getopt.h: $(top_builddir)/config.status + rm -f $@ +endif + +if GL_GENERATE_GETOPT_CDEFS_H +getopt-cdefs.h: getopt-cdefs.in.h $(top_builddir)/config.status + $(AM_V_GEN)$(SED_HEADER_STDOUT) \ + -e 's|@''HAVE_SYS_CDEFS_H''@|$(HAVE_SYS_CDEFS_H)|g' \ + $(srcdir)/getopt-cdefs.in.h > $@-t + $(AM_V_at)mv $@-t $@ +else +getopt-cdefs.h: $(top_builddir)/config.status + rm -f $@ +endif + +MOSTLYCLEANFILES += getopt.h getopt.h-t getopt-cdefs.h getopt-cdefs.h-t + +if GL_COND_OBJ_GETOPT +libdiffutils_a_SOURCES += getopt.c getopt1.c +endif + +EXTRA_DIST += getopt-cdefs.in.h getopt-core.h getopt-ext.h getopt-pfx-core.h getopt-pfx-ext.h getopt.in.h getopt_int.h + +## end gnulib module getopt-posix + +## begin gnulib module getpagesize + +if GL_COND_OBJ_GETPAGESIZE +libdiffutils_a_SOURCES += getpagesize.c +endif + +## end gnulib module getpagesize + +## begin gnulib module getprogname + +if GL_COND_OBJ_GETPROGNAME +libdiffutils_a_SOURCES += getprogname.c +endif + +EXTRA_DIST += getprogname.h + +## end gnulib module getprogname + +## begin gnulib module getrandom + +if GL_COND_OBJ_GETRANDOM +libdiffutils_a_SOURCES += getrandom.c +endif + +## end gnulib module getrandom + +## begin gnulib module gettext-h + +libdiffutils_a_SOURCES += gettext.h + +## end gnulib module gettext-h + +## begin gnulib module gettime + +libdiffutils_a_SOURCES += gettime.c + +## end gnulib module gettime + +## begin gnulib module gettimeofday + +if GL_COND_OBJ_GETTIMEOFDAY +libdiffutils_a_SOURCES += gettimeofday.c +endif + +## end gnulib module gettimeofday + +## begin gnulib module git-version-gen + + +EXTRA_DIST += $(top_srcdir)/build-aux/git-version-gen + +## end gnulib module git-version-gen + +## begin gnulib module gitlog-to-changelog + + +EXTRA_DIST += $(top_srcdir)/build-aux/gitlog-to-changelog + +## end gnulib module gitlog-to-changelog + +## begin gnulib module glibc-internal/dynarray + +BUILT_SOURCES += malloc/dynarray.gl.h malloc/dynarray-skeleton.gl.h + +malloc/dynarray.gl.h: malloc/dynarray.h + $(AM_V_GEN)$(MKDIR_P) '%reldir%/malloc' + $(AM_V_at)$(SED_HEADER_STDOUT) \ + -e '/libc_hidden_proto/d' \ + $(srcdir)/malloc/dynarray.h > $@-t + $(AM_V_at)mv $@-t $@ +MOSTLYCLEANFILES += malloc/dynarray.gl.h malloc/dynarray.gl.h-t + +malloc/dynarray-skeleton.gl.h: malloc/dynarray-skeleton.c + $(AM_V_GEN)$(MKDIR_P) '%reldir%/malloc' + $(AM_V_at)$(SED_HEADER_STDOUT) \ + -e 's|||g' \ + -e 's|__attribute_maybe_unused__|_GL_ATTRIBUTE_MAYBE_UNUSED|g' \ + -e 's|__attribute_nonnull__|_GL_ATTRIBUTE_NONNULL|g' \ + -e 's|__attribute_warn_unused_result__|_GL_ATTRIBUTE_NODISCARD|g' \ + -e 's|__glibc_likely|_GL_LIKELY|g' \ + -e 's|__glibc_unlikely|_GL_UNLIKELY|g' \ + $(srcdir)/malloc/dynarray-skeleton.c > $@-t + $(AM_V_at)mv $@-t $@ +MOSTLYCLEANFILES += malloc/dynarray-skeleton.gl.h malloc/dynarray-skeleton.gl.h-t + +libdiffutils_a_SOURCES += malloc/dynarray_at_failure.c malloc/dynarray_emplace_enlarge.c malloc/dynarray_finalize.c malloc/dynarray_resize.c malloc/dynarray_resize_clear.c + +EXTRA_DIST += dynarray.h malloc/dynarray-skeleton.c malloc/dynarray.h + +EXTRA_libdiffutils_a_SOURCES += malloc/dynarray-skeleton.c + +## end gnulib module glibc-internal/dynarray + +## begin gnulib module gnu-make + +##Sample usage of gnu-make module: +#if GNU_MAKE +# [nicer features that work only with GNU Make] +#else +# [fallback features that work in any 'make' implementation; see +# https://pubs.opengroup.org/onlinepubs/9699919799/utilities/make.html +# for the POSIX specification] +#endif + +## end gnulib module gnu-make + +## begin gnulib module gnu-web-doc-update + + +EXTRA_DIST += $(top_srcdir)/build-aux/gnu-web-doc-update + +## end gnulib module gnu-web-doc-update + +## begin gnulib module gnumakefile + +EXTRA_DIST += $(top_srcdir)/GNUmakefile +distclean-local: clean-GNUmakefile +clean-GNUmakefile: + test '$(srcdir)' = . || rm -f $(top_builddir)/GNUmakefile + +## end gnulib module gnumakefile + +## begin gnulib module gnupload + + +EXTRA_DIST += $(top_srcdir)/build-aux/gnupload + +## end gnulib module gnupload + +## begin gnulib module hard-locale + +libdiffutils_a_SOURCES += hard-locale.c + +EXTRA_DIST += hard-locale.h + +## end gnulib module hard-locale + +## begin gnulib module hash + +libdiffutils_a_SOURCES += hash.c + +EXTRA_DIST += hash.h + +## end gnulib module hash + +## begin gnulib module havelib + + +EXTRA_DIST += $(top_srcdir)/build-aux/config.rpath + +## end gnulib module havelib + +## begin gnulib module ialloc + +libdiffutils_a_SOURCES += ialloc.c + +EXTRA_DIST += ialloc.h + +## end gnulib module ialloc + +## begin gnulib module idx + +libdiffutils_a_SOURCES += idx.h + +## end gnulib module idx + +## begin gnulib module ignore-value + + +EXTRA_DIST += ignore-value.h + +## end gnulib module ignore-value + +## begin gnulib module intprops + + +EXTRA_DIST += intprops-internal.h intprops.h + +## end gnulib module intprops + +## begin gnulib module inttypes-incomplete + +BUILT_SOURCES += inttypes.h + +# We need the following in order to create 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) + $(gl_V_at)$(SED_HEADER_STDOUT) \ + -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/@''APPLE_UNIVERSAL_BUILD''@/$(APPLE_UNIVERSAL_BUILD)/g' \ + -e 's/@''PRIPTR_PREFIX''@/$(PRIPTR_PREFIX)/g' \ + -e 's/@''GNULIB_IMAXABS''@/$(GL_GNULIB_IMAXABS)/g' \ + -e 's/@''GNULIB_IMAXDIV''@/$(GL_GNULIB_IMAXDIV)/g' \ + -e 's/@''GNULIB_STRTOIMAX''@/$(GL_GNULIB_STRTOIMAX)/g' \ + -e 's/@''GNULIB_STRTOUMAX''@/$(GL_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_IMAXABS''@/$(REPLACE_IMAXABS)/g' \ + -e 's/@''REPLACE_IMAXDIV''@/$(REPLACE_IMAXDIV)/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 + $(AM_V_at)mv $@-t $@ +MOSTLYCLEANFILES += inttypes.h inttypes.h-t + +EXTRA_DIST += inttypes.in.h + +## end gnulib module inttypes-incomplete + +## begin gnulib module isblank + +if GL_COND_OBJ_ISBLANK +libdiffutils_a_SOURCES += isblank.c +endif + +## end gnulib module isblank + +## begin gnulib module iswblank + +if GL_COND_OBJ_ISWBLANK +libdiffutils_a_SOURCES += iswblank.c +endif + +## end gnulib module iswblank + +## begin gnulib module iswctype + +if GL_COND_OBJ_ISWCTYPE +libdiffutils_a_SOURCES += iswctype.c +endif + +EXTRA_DIST += iswctype-impl.h + +## end gnulib module iswctype + +## begin gnulib module iswdigit + +if GL_COND_OBJ_ISWDIGIT +libdiffutils_a_SOURCES += iswdigit.c +endif + +## end gnulib module iswdigit + +## begin gnulib module iswpunct + +if GL_COND_OBJ_ISWPUNCT +libdiffutils_a_SOURCES += iswpunct.c +endif + +## end gnulib module iswpunct + +## begin gnulib module iswxdigit + +if GL_COND_OBJ_ISWXDIGIT +libdiffutils_a_SOURCES += iswxdigit.c +endif + +## end gnulib module iswxdigit + +## begin gnulib module langinfo + +BUILT_SOURCES += langinfo.h + +# We need the following in order to create an empty placeholder for +# when the system doesn't have one. +langinfo.h: langinfo.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) + $(gl_V_at)$(SED_HEADER_STDOUT) \ + -e 's|@''GUARD_PREFIX''@|GL|g' \ + -e 's|@''HAVE_LANGINFO_H''@|$(HAVE_LANGINFO_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_LANGINFO_H''@|$(NEXT_LANGINFO_H)|g' \ + -e 's/@''GNULIB_NL_LANGINFO''@/$(GL_GNULIB_NL_LANGINFO)/g' \ + -e 's|@''HAVE_LANGINFO_CODESET''@|$(HAVE_LANGINFO_CODESET)|g' \ + -e 's|@''HAVE_LANGINFO_T_FMT_AMPM''@|$(HAVE_LANGINFO_T_FMT_AMPM)|g' \ + -e 's|@''HAVE_LANGINFO_ALTMON''@|$(HAVE_LANGINFO_ALTMON)|g' \ + -e 's|@''HAVE_LANGINFO_ERA''@|$(HAVE_LANGINFO_ERA)|g' \ + -e 's|@''HAVE_LANGINFO_YESEXPR''@|$(HAVE_LANGINFO_YESEXPR)|g' \ + -e 's|@''HAVE_NL_LANGINFO''@|$(HAVE_NL_LANGINFO)|g' \ + -e 's|@''REPLACE_NL_LANGINFO''@|$(REPLACE_NL_LANGINFO)|g' \ + -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ + -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ + $(srcdir)/langinfo.in.h > $@-t + $(AM_V_at)mv $@-t $@ +MOSTLYCLEANFILES += langinfo.h langinfo.h-t + +EXTRA_DIST += langinfo.in.h + +## end gnulib module langinfo + +## begin gnulib module libc-config + + +EXTRA_DIST += cdefs.h libc-config.h + +## end gnulib module libc-config + +## begin gnulib module limits-h + +BUILT_SOURCES += $(LIMITS_H) + +# We need the following in order to create when the system +# doesn't have one that is compatible with GNU. +if GL_GENERATE_LIMITS_H +limits.h: limits.in.h $(top_builddir)/config.status + $(gl_V_at)$(SED_HEADER_STDOUT) \ + -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_LIMITS_H''@|$(NEXT_LIMITS_H)|g' \ + $(srcdir)/limits.in.h > $@-t + $(AM_V_at)mv $@-t $@ +else +limits.h: $(top_builddir)/config.status + rm -f $@ +endif +MOSTLYCLEANFILES += limits.h limits.h-t + +EXTRA_DIST += limits.in.h + +## end gnulib module limits-h + +## begin gnulib module localcharset + +libdiffutils_a_SOURCES += localcharset.c + +EXTRA_DIST += localcharset.h + +## end gnulib module localcharset + +## begin gnulib module locale + +BUILT_SOURCES += locale.h + +# We need the following in order to create 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) + $(gl_V_at)$(SED_HEADER_STDOUT) \ + -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''@/$(GL_GNULIB_LOCALECONV)/g' \ + -e 's/@''GNULIB_SETLOCALE''@/$(GL_GNULIB_SETLOCALE)/g' \ + -e 's/@''GNULIB_SETLOCALE_NULL''@/$(GL_GNULIB_SETLOCALE_NULL)/g' \ + -e 's/@''GNULIB_DUPLOCALE''@/$(GL_GNULIB_DUPLOCALE)/g' \ + -e 's/@''GNULIB_LOCALENAME''@/$(GL_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 's|@''LOCALENAME_ENHANCE_LOCALE_FUNCS''@|$(LOCALENAME_ENHANCE_LOCALE_FUNCS)|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 + $(AM_V_at)mv $@-t $@ +MOSTLYCLEANFILES += locale.h locale.h-t + +EXTRA_DIST += locale.in.h + +## end gnulib module locale + +## begin gnulib module localeconv + +if GL_COND_OBJ_LOCALECONV +libdiffutils_a_SOURCES += localeconv.c +endif + +## end gnulib module localeconv + +## begin gnulib module lock + +libdiffutils_a_SOURCES += glthread/lock.h glthread/lock.c + +## end gnulib module lock + +## begin gnulib module lstat + +if GL_COND_OBJ_LSTAT +libdiffutils_a_SOURCES += lstat.c +endif + +## end gnulib module lstat + +## begin gnulib module maintainer-makefile + +EXTRA_DIST += $(top_srcdir)/maint.mk + +## end gnulib module maintainer-makefile + +## begin gnulib module malloc-gnu + + +EXTRA_DIST += malloc.c + +EXTRA_libdiffutils_a_SOURCES += malloc.c + +## end gnulib module malloc-gnu + +## begin gnulib module malloc-posix + + +EXTRA_DIST += malloc.c + +EXTRA_libdiffutils_a_SOURCES += malloc.c + +## end gnulib module malloc-posix + +## begin gnulib module malloca + +libdiffutils_a_SOURCES += malloca.c + +EXTRA_DIST += malloca.h + +## end gnulib module malloca + +## begin gnulib module mbchar + +libdiffutils_a_SOURCES += mbchar.c + +EXTRA_DIST += mbchar.h + +## end gnulib module mbchar + +## begin gnulib module mbrtoc32 + +if GL_COND_OBJ_MBRTOC32 +libdiffutils_a_SOURCES += mbrtoc32.c +endif + +EXTRA_DIST += lc-charset-dispatch.c lc-charset-dispatch.h mbrtowc-impl-utf8.h mbrtowc-impl.h mbtowc-lock.c mbtowc-lock.h windows-initguard.h + +EXTRA_libdiffutils_a_SOURCES += lc-charset-dispatch.c mbtowc-lock.c + +## end gnulib module mbrtoc32 + +## begin gnulib module mbrtowc + +if GL_COND_OBJ_MBRTOWC +libdiffutils_a_SOURCES += mbrtowc.c +endif + +EXTRA_DIST += lc-charset-dispatch.c lc-charset-dispatch.h mbrtowc-impl-utf8.h mbrtowc-impl.h mbtowc-lock.c mbtowc-lock.h windows-initguard.h + +EXTRA_libdiffutils_a_SOURCES += lc-charset-dispatch.c mbtowc-lock.c + +## end gnulib module mbrtowc + +## begin gnulib module mbscasecmp + +libdiffutils_a_SOURCES += mbscasecmp.c + +## end gnulib module mbscasecmp + +## begin gnulib module mbsinit + +if GL_COND_OBJ_MBSINIT +libdiffutils_a_SOURCES += mbsinit.c +endif + +## end gnulib module mbsinit + +## begin gnulib module mbsrtoc32s + +libdiffutils_a_SOURCES += mbsrtoc32s.c + +EXTRA_DIST += mbsrtoc32s-state.c mbsrtowcs-impl.h + +EXTRA_libdiffutils_a_SOURCES += mbsrtoc32s-state.c + +## end gnulib module mbsrtoc32s + +## begin gnulib module mbsrtowcs + +if GL_COND_OBJ_MBSRTOWCS +libdiffutils_a_SOURCES += mbsrtowcs.c +endif + +EXTRA_DIST += mbsrtowcs-impl.h mbsrtowcs-state.c + +EXTRA_libdiffutils_a_SOURCES += mbsrtowcs-state.c + +## end gnulib module mbsrtowcs + +## begin gnulib module mbszero + +libdiffutils_a_SOURCES += mbszero.c + +## end gnulib module mbszero + +## begin gnulib module mbtowc + +if GL_COND_OBJ_MBTOWC +libdiffutils_a_SOURCES += mbtowc.c +endif + +EXTRA_DIST += mbtowc-impl.h + +## end gnulib module mbtowc + +## begin gnulib module mbuiter + +libdiffutils_a_SOURCES += mbuiter.h mbuiter.c + +## end gnulib module mbuiter + +## begin gnulib module mbuiterf + +libdiffutils_a_SOURCES += mbuiterf.h mbuiterf.c + +## end gnulib module mbuiterf + +## begin gnulib module memchr + +if GL_COND_OBJ_MEMCHR +libdiffutils_a_SOURCES += memchr.c +endif + +EXTRA_DIST += memchr.valgrind + +## end gnulib module memchr + +## begin gnulib module mempcpy + +if GL_COND_OBJ_MEMPCPY +libdiffutils_a_SOURCES += mempcpy.c +endif + +## end gnulib module mempcpy + +## begin gnulib module memrchr + +if GL_COND_OBJ_MEMRCHR +libdiffutils_a_SOURCES += memrchr.c +endif + +## end gnulib module memrchr + +## begin gnulib module minmax + +libdiffutils_a_SOURCES += minmax.h + +## end gnulib module minmax + +## begin gnulib module mkdir + +if GL_COND_OBJ_MKDIR +libdiffutils_a_SOURCES += mkdir.c +endif + +## end gnulib module mkdir + +## begin gnulib module mkstemp + +if GL_COND_OBJ_MKSTEMP +libdiffutils_a_SOURCES += mkstemp.c +endif + +## end gnulib module mkstemp + +## begin gnulib module mktime + + +EXTRA_DIST += mktime-internal.h mktime.c + +EXTRA_libdiffutils_a_SOURCES += mktime.c + +## end gnulib module mktime + +## begin gnulib module mktime-internal + + +EXTRA_DIST += mktime-internal.h mktime.c + +EXTRA_libdiffutils_a_SOURCES += mktime.c + +## end gnulib module mktime-internal + +## begin gnulib module msvc-inval + +if GL_COND_OBJ_MSVC_INVAL +libdiffutils_a_SOURCES += msvc-inval.c +endif + +EXTRA_DIST += msvc-inval.h + +## end gnulib module msvc-inval + +## begin gnulib module msvc-nothrow + +if GL_COND_OBJ_MSVC_NOTHROW +libdiffutils_a_SOURCES += msvc-nothrow.c +endif + +EXTRA_DIST += msvc-nothrow.h + +## end gnulib module msvc-nothrow + +## begin gnulib module nl_langinfo + +if GL_COND_OBJ_NL_LANGINFO +libdiffutils_a_SOURCES += nl_langinfo.c +endif +if GL_COND_OBJ_NL_LANGINFO_LOCK +libdiffutils_a_SOURCES += nl_langinfo-lock.c +endif + +EXTRA_DIST += windows-initguard.h + +## end gnulib module nl_langinfo + +## begin gnulib module nstrftime + +libdiffutils_a_SOURCES += nstrftime.c + +EXTRA_DIST += strftime.h + +## end gnulib module nstrftime + +## begin gnulib module open + +if GL_COND_OBJ_OPEN +libdiffutils_a_SOURCES += open.c +endif + +## end gnulib module open + +## begin gnulib module openat + +if GL_COND_OBJ_OPENAT +libdiffutils_a_SOURCES += openat.c +endif + +## end gnulib module openat + +## begin gnulib module openat-die + +libdiffutils_a_SOURCES += openat-die.c + +## end gnulib module openat-die + +## begin gnulib module openat-h + + +EXTRA_DIST += openat.h + +## end gnulib module openat-h + +## begin gnulib module opendir + +if GL_COND_OBJ_OPENDIR +libdiffutils_a_SOURCES += opendir.c +endif + +EXTRA_DIST += dirent-private.h + +## end gnulib module opendir + +## begin gnulib module pathmax + + +EXTRA_DIST += pathmax.h + +## end gnulib module pathmax + +## begin gnulib module pclose + +if GL_COND_OBJ_PCLOSE +libdiffutils_a_SOURCES += pclose.c +endif + +## end gnulib module pclose + +## begin gnulib module pipe-posix + +if GL_COND_OBJ_PIPE +libdiffutils_a_SOURCES += pipe.c +endif + +## end gnulib module pipe-posix + +## begin gnulib module popen + +if GL_COND_OBJ_POPEN +libdiffutils_a_SOURCES += popen.c +endif + +## end gnulib module popen + +## begin gnulib module progname + +libdiffutils_a_SOURCES += progname.h progname.c + +## end gnulib module progname + +## begin gnulib module propername-lite + +libdiffutils_a_SOURCES += propername-lite.c propername.h + +## end gnulib module propername-lite + +## begin gnulib module quote + + +EXTRA_DIST += quote.h + +## end gnulib module quote + +## begin gnulib module quotearg + +libdiffutils_a_SOURCES += quotearg.c + +EXTRA_DIST += quote.h quotearg.h + +## end gnulib module quotearg + +## begin gnulib module raise + +if GL_COND_OBJ_RAISE +libdiffutils_a_SOURCES += raise.c +endif + +## end gnulib module raise + +## begin gnulib module rawmemchr + +if GL_COND_OBJ_RAWMEMCHR +libdiffutils_a_SOURCES += rawmemchr.c +endif + +EXTRA_DIST += rawmemchr.valgrind + +## end gnulib module rawmemchr + +## begin gnulib module readdir + +if GL_COND_OBJ_READDIR +libdiffutils_a_SOURCES += readdir.c +endif + +EXTRA_DIST += dirent-private.h + +## end gnulib module readdir + +## begin gnulib module readlink + +if GL_COND_OBJ_READLINK +libdiffutils_a_SOURCES += readlink.c +endif + +## end gnulib module readlink + +## begin gnulib module readlinkat + +if GL_COND_OBJ_READLINKAT +libdiffutils_a_SOURCES += readlinkat.c +endif + +EXTRA_DIST += at-func.c + +EXTRA_libdiffutils_a_SOURCES += at-func.c + +## end gnulib module readlinkat + +## begin gnulib module realloc-gnu + + +EXTRA_DIST += realloc.c + +EXTRA_libdiffutils_a_SOURCES += realloc.c + +## end gnulib module realloc-gnu + +## begin gnulib module realloc-posix + + +EXTRA_DIST += realloc.c + +EXTRA_libdiffutils_a_SOURCES += realloc.c + +## end gnulib module realloc-posix + +## begin gnulib module reallocarray + +if GL_COND_OBJ_REALLOCARRAY +libdiffutils_a_SOURCES += reallocarray.c +endif + +## end gnulib module reallocarray + +## begin gnulib module regex + +if GL_COND_OBJ_REGEX +libdiffutils_a_SOURCES += regex.c +endif + +EXTRA_DIST += regcomp.c regex.h regex_internal.c regex_internal.h regexec.c + +EXTRA_libdiffutils_a_SOURCES += regcomp.c regex_internal.c regexec.c + +## end gnulib module regex + +## begin gnulib module same-inode + +libdiffutils_a_SOURCES += same-inode.h same-inode.c + +## end gnulib module same-inode + +## begin gnulib module save-cwd + +libdiffutils_a_SOURCES += save-cwd.c + +EXTRA_DIST += save-cwd.h + +## end gnulib module save-cwd + +## begin gnulib module setenv + +if GL_COND_OBJ_SETENV +libdiffutils_a_SOURCES += setenv.c +endif + +## end gnulib module setenv + +## begin gnulib module setlocale-null + +libdiffutils_a_SOURCES += setlocale_null.c +if GL_COND_OBJ_SETLOCALE_LOCK +libdiffutils_a_SOURCES += setlocale-lock.c +endif + +EXTRA_DIST += setlocale_null.h windows-initguard.h + +## end gnulib module setlocale-null + +## begin gnulib module sh-quote + +libdiffutils_a_SOURCES += sh-quote.h sh-quote.c + +## end gnulib module sh-quote + +## begin gnulib module sigaction + +if GL_COND_OBJ_SIGACTION +libdiffutils_a_SOURCES += sigaction.c +endif +libdiffutils_a_SOURCES += sig-handler.c + +EXTRA_DIST += sig-handler.h + +## end gnulib module sigaction + +## begin gnulib module signal-h + +BUILT_SOURCES += signal.h + +# We need the following in order to create when the system +# doesn't have a complete one. +signal.h: signal.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) + $(gl_V_at)$(SED_HEADER_STDOUT) \ + -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_SIGNAL_H''@|$(NEXT_SIGNAL_H)|g' \ + -e 's/@''GNULIB_PTHREAD_SIGMASK''@/$(GL_GNULIB_PTHREAD_SIGMASK)/g' \ + -e 's/@''GNULIB_RAISE''@/$(GL_GNULIB_RAISE)/g' \ + -e 's/@''GNULIB_SIGNAL_H_SIGPIPE''@/$(GL_GNULIB_SIGNAL_H_SIGPIPE)/g' \ + -e 's/@''GNULIB_SIGPROCMASK''@/$(GL_GNULIB_SIGPROCMASK)/g' \ + -e 's/@''GNULIB_SIGACTION''@/$(GL_GNULIB_SIGACTION)/g' \ + -e 's|@''HAVE_POSIX_SIGNALBLOCKING''@|$(HAVE_POSIX_SIGNALBLOCKING)|g' \ + -e 's|@''HAVE_PTHREAD_SIGMASK''@|$(HAVE_PTHREAD_SIGMASK)|g' \ + -e 's|@''HAVE_RAISE''@|$(HAVE_RAISE)|g' \ + -e 's|@''HAVE_SIGSET_T''@|$(HAVE_SIGSET_T)|g' \ + -e 's|@''HAVE_SIGINFO_T''@|$(HAVE_SIGINFO_T)|g' \ + -e 's|@''HAVE_SIGACTION''@|$(HAVE_SIGACTION)|g' \ + -e 's|@''HAVE_STRUCT_SIGACTION_SA_SIGACTION''@|$(HAVE_STRUCT_SIGACTION_SA_SIGACTION)|g' \ + -e 's|@''HAVE_TYPE_VOLATILE_SIG_ATOMIC_T''@|$(HAVE_TYPE_VOLATILE_SIG_ATOMIC_T)|g' \ + -e 's|@''HAVE_SIGHANDLER_T''@|$(HAVE_SIGHANDLER_T)|g' \ + -e 's|@''REPLACE_PTHREAD_SIGMASK''@|$(REPLACE_PTHREAD_SIGMASK)|g' \ + -e 's|@''REPLACE_RAISE''@|$(REPLACE_RAISE)|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)/signal.in.h > $@-t + $(AM_V_at)mv $@-t $@ +MOSTLYCLEANFILES += signal.h signal.h-t + +EXTRA_DIST += signal.in.h + +## end gnulib module signal-h + +## begin gnulib module sigprocmask + +if GL_COND_OBJ_SIGPROCMASK +libdiffutils_a_SOURCES += sigprocmask.c +endif + +## end gnulib module sigprocmask + +## begin gnulib module sigsegv + +BUILT_SOURCES += $(SIGSEGV_H) + +if GL_GENERATE_SIGSEGV_H +sigsegv.h: sigsegv.in.h $(top_builddir)/config.status + $(gl_V_at)$(SED_HEADER_TO_AT_t) $(srcdir)/sigsegv.in.h + $(AM_V_at)mv $@-t $@ +else +sigsegv.h: $(top_builddir)/config.status + rm -f $@ +endif +MOSTLYCLEANFILES += sigsegv.h sigsegv.h-t + +if GL_GENERATE_SIGSEGV_H +libdiffutils_a_SOURCES += sigsegv.c stackvma.c +endif + +EXTRA_DIST += sigsegv.in.h stackvma.h + +## end gnulib module sigsegv + +## begin gnulib module snippet/_Noreturn + +# Because this Makefile snippet defines a variable used by other +# gnulib Makefile snippets, it must be present in all makefiles that +# need it. This is ensured by the applicability 'all' defined above. + +_NORETURN_H=$(srcdir)/_Noreturn.h + +EXTRA_DIST += _Noreturn.h + +## end gnulib module snippet/_Noreturn + +## begin gnulib module snippet/arg-nonnull + +# Because this Makefile snippet defines a variable used by other +# gnulib Makefile snippets, it must be present in all makefiles that +# need it. This is ensured by the applicability 'all' defined above. + +ARG_NONNULL_H=$(srcdir)/arg-nonnull.h + +EXTRA_DIST += arg-nonnull.h + +## end gnulib module snippet/arg-nonnull + +## begin gnulib module snippet/c++defs + +# Because this Makefile snippet defines a variable used by other +# gnulib Makefile snippets, it must be present in all makefiles that +# need it. This is ensured by the applicability 'all' defined above. + +CXXDEFS_H=$(srcdir)/c++defs.h + +EXTRA_DIST += c++defs.h + +## end gnulib module snippet/c++defs + +## begin gnulib module snippet/warn-on-use + +# Because this Makefile snippet defines a variable used by other +# gnulib Makefile snippets, it must be present in all makefiles that +# need it. This is ensured by the applicability 'all' defined above. + +WARN_ON_USE_H=$(srcdir)/warn-on-use.h + +EXTRA_DIST += warn-on-use.h + +## end gnulib module snippet/warn-on-use + +## begin gnulib module stat + +if GL_COND_OBJ_STAT +libdiffutils_a_SOURCES += stat.c +endif + +EXTRA_DIST += stat-w32.c stat-w32.h + +EXTRA_libdiffutils_a_SOURCES += stat-w32.c + +## end gnulib module stat + +## begin gnulib module stat-macros + + +EXTRA_DIST += stat-macros.h + +## end gnulib module stat-macros + +## begin gnulib module stat-time + +libdiffutils_a_SOURCES += stat-time.c + +EXTRA_DIST += stat-time.h + +## end gnulib module stat-time + +## begin gnulib module stdarg + +BUILT_SOURCES += $(STDARG_H) + +# We need the following in order to create when the system +# doesn't have one that works with the given compiler. +if GL_GENERATE_STDARG_H +stdarg.h: stdarg.in.h $(top_builddir)/config.status + $(gl_V_at)$(SED_HEADER_STDOUT) \ + -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_STDARG_H''@|$(NEXT_STDARG_H)|g' \ + $(srcdir)/stdarg.in.h > $@-t + $(AM_V_at)mv $@-t $@ +else +stdarg.h: $(top_builddir)/config.status + rm -f $@ +endif +MOSTLYCLEANFILES += stdarg.h stdarg.h-t + +EXTRA_DIST += stdarg.in.h + +## end gnulib module stdarg + +## begin gnulib module stdckdint + +BUILT_SOURCES += $(STDCKDINT_H) + +# We need the following in order to create when the system +# doesn't have one that works with the given compiler. +if GL_GENERATE_STDCKDINT_H +stdckdint.h: stdckdint.in.h $(top_builddir)/config.status + $(gl_V_at)$(SED_HEADER_STDOUT) \ + $(srcdir)/stdckdint.in.h > $@-t + $(AM_V_at)mv $@-t $@ +else +stdckdint.h: $(top_builddir)/config.status + rm -f $@ +endif +MOSTLYCLEANFILES += stdckdint.h stdckdint.h-t + +EXTRA_DIST += intprops-internal.h stdckdint.in.h + +## end gnulib module stdckdint + +## begin gnulib module stddef + +BUILT_SOURCES += $(STDDEF_H) + +# We need the following in order to create when the system +# doesn't have one that works with the given compiler. +if GL_GENERATE_STDDEF_H +stddef.h: stddef.in.h $(top_builddir)/config.status + $(gl_V_at)$(SED_HEADER_STDOUT) \ + -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_STDDEF_H''@|$(NEXT_STDDEF_H)|g' \ + -e 's|@''HAVE_MAX_ALIGN_T''@|$(HAVE_MAX_ALIGN_T)|g' \ + -e 's|@''HAVE_WCHAR_T''@|$(HAVE_WCHAR_T)|g' \ + -e 's|@''REPLACE_NULL''@|$(REPLACE_NULL)|g' \ + $(srcdir)/stddef.in.h > $@-t + $(AM_V_at)mv $@-t $@ +else +stddef.h: $(top_builddir)/config.status + rm -f $@ +endif +MOSTLYCLEANFILES += stddef.h stddef.h-t + +EXTRA_DIST += stddef.in.h + +## end gnulib module stddef + +## begin gnulib module stdint + +BUILT_SOURCES += $(STDINT_H) + +# We need the following in order to create when the system +# doesn't have one that works with the given compiler. +if GL_GENERATE_STDINT_H +stdint.h: stdint.in.h $(top_builddir)/config.status + $(gl_V_at)$(SED_HEADER_STDOUT) \ + -e 's|@''GUARD_PREFIX''@|GL|g' \ + -e 's/@''HAVE_STDINT_H''@/$(HAVE_STDINT_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_STDINT_H''@|$(NEXT_STDINT_H)|g' \ + -e 's/@''HAVE_C99_STDINT_H''@/$(HAVE_C99_STDINT_H)/g' \ + -e 's/@''HAVE_SYS_TYPES_H''@/$(HAVE_SYS_TYPES_H)/g' \ + -e 's/@''HAVE_INTTYPES_H''@/$(HAVE_INTTYPES_H)/g' \ + -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/@''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' \ + -e 's/@''BITSIZEOF_SIG_ATOMIC_T''@/$(BITSIZEOF_SIG_ATOMIC_T)/g' \ + -e 's/@''HAVE_SIGNED_SIG_ATOMIC_T''@/$(HAVE_SIGNED_SIG_ATOMIC_T)/g' \ + -e 's/@''SIG_ATOMIC_T_SUFFIX''@/$(SIG_ATOMIC_T_SUFFIX)/g' \ + -e 's/@''BITSIZEOF_SIZE_T''@/$(BITSIZEOF_SIZE_T)/g' \ + -e 's/@''SIZE_T_SUFFIX''@/$(SIZE_T_SUFFIX)/g' \ + -e 's/@''BITSIZEOF_WCHAR_T''@/$(BITSIZEOF_WCHAR_T)/g' \ + -e 's/@''HAVE_SIGNED_WCHAR_T''@/$(HAVE_SIGNED_WCHAR_T)/g' \ + -e 's/@''WCHAR_T_SUFFIX''@/$(WCHAR_T_SUFFIX)/g' \ + -e 's/@''BITSIZEOF_WINT_T''@/$(BITSIZEOF_WINT_T)/g' \ + -e 's/@''HAVE_SIGNED_WINT_T''@/$(HAVE_SIGNED_WINT_T)/g' \ + -e 's/@''WINT_T_SUFFIX''@/$(WINT_T_SUFFIX)/g' \ + -e 's/@''GNULIBHEADERS_OVERRIDE_WINT_T''@/$(GNULIBHEADERS_OVERRIDE_WINT_T)/g' \ + $(srcdir)/stdint.in.h > $@-t + $(AM_V_at)mv $@-t $@ +else +stdint.h: $(top_builddir)/config.status + rm -f $@ +endif +MOSTLYCLEANFILES += stdint.h stdint.h-t + +EXTRA_DIST += stdint.in.h + +## end gnulib module stdint + +## begin gnulib module stdio + +BUILT_SOURCES += stdio.h + +# We need the following in order to create when the system +# doesn't have one that works with the given compiler. +stdio.h: stdio.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) + $(gl_V_at)$(SED_HEADER_STDOUT) \ + -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_STDIO_H''@|$(NEXT_STDIO_H)|g' \ + -e 's/@''GNULIB_DPRINTF''@/$(GL_GNULIB_DPRINTF)/g' \ + -e 's/@''GNULIB_FCLOSE''@/$(GL_GNULIB_FCLOSE)/g' \ + -e 's/@''GNULIB_FDOPEN''@/$(GL_GNULIB_FDOPEN)/g' \ + -e 's/@''GNULIB_FFLUSH''@/$(GL_GNULIB_FFLUSH)/g' \ + -e 's/@''GNULIB_FGETC''@/$(GL_GNULIB_FGETC)/g' \ + -e 's/@''GNULIB_FGETS''@/$(GL_GNULIB_FGETS)/g' \ + -e 's/@''GNULIB_FOPEN''@/$(GL_GNULIB_FOPEN)/g' \ + -e 's/@''GNULIB_FOPEN_GNU''@/$(GL_GNULIB_FOPEN_GNU)/g' \ + -e 's/@''GNULIB_FPRINTF''@/$(GL_GNULIB_FPRINTF)/g' \ + -e 's/@''GNULIB_FPRINTF_POSIX''@/$(GL_GNULIB_FPRINTF_POSIX)/g' \ + -e 's/@''GNULIB_FPURGE''@/$(GL_GNULIB_FPURGE)/g' \ + -e 's/@''GNULIB_FPUTC''@/$(GL_GNULIB_FPUTC)/g' \ + -e 's/@''GNULIB_FPUTS''@/$(GL_GNULIB_FPUTS)/g' \ + -e 's/@''GNULIB_FREAD''@/$(GL_GNULIB_FREAD)/g' \ + -e 's/@''GNULIB_FREOPEN''@/$(GL_GNULIB_FREOPEN)/g' \ + -e 's/@''GNULIB_FSCANF''@/$(GL_GNULIB_FSCANF)/g' \ + -e 's/@''GNULIB_FSEEK''@/$(GL_GNULIB_FSEEK)/g' \ + -e 's/@''GNULIB_FSEEKO''@/$(GL_GNULIB_FSEEKO)/g' \ + -e 's/@''GNULIB_FTELL''@/$(GL_GNULIB_FTELL)/g' \ + -e 's/@''GNULIB_FTELLO''@/$(GL_GNULIB_FTELLO)/g' \ + -e 's/@''GNULIB_FWRITE''@/$(GL_GNULIB_FWRITE)/g' \ + -e 's/@''GNULIB_GETC''@/$(GL_GNULIB_GETC)/g' \ + -e 's/@''GNULIB_GETCHAR''@/$(GL_GNULIB_GETCHAR)/g' \ + -e 's/@''GNULIB_GETDELIM''@/$(GL_GNULIB_GETDELIM)/g' \ + -e 's/@''GNULIB_GETLINE''@/$(GL_GNULIB_GETLINE)/g' \ + -e 's/@''GNULIB_OBSTACK_PRINTF''@/$(GL_GNULIB_OBSTACK_PRINTF)/g' \ + -e 's/@''GNULIB_OBSTACK_PRINTF_POSIX''@/$(GL_GNULIB_OBSTACK_PRINTF_POSIX)/g' \ + -e 's/@''GNULIB_PCLOSE''@/$(GL_GNULIB_PCLOSE)/g' \ + -e 's/@''GNULIB_PERROR''@/$(GL_GNULIB_PERROR)/g' \ + -e 's/@''GNULIB_POPEN''@/$(GL_GNULIB_POPEN)/g' \ + -e 's/@''GNULIB_PRINTF''@/$(GL_GNULIB_PRINTF)/g' \ + -e 's/@''GNULIB_PRINTF_POSIX''@/$(GL_GNULIB_PRINTF_POSIX)/g' \ + -e 's/@''GNULIB_PUTC''@/$(GL_GNULIB_PUTC)/g' \ + -e 's/@''GNULIB_PUTCHAR''@/$(GL_GNULIB_PUTCHAR)/g' \ + -e 's/@''GNULIB_PUTS''@/$(GL_GNULIB_PUTS)/g' \ + -e 's/@''GNULIB_REMOVE''@/$(GL_GNULIB_REMOVE)/g' \ + -e 's/@''GNULIB_RENAME''@/$(GL_GNULIB_RENAME)/g' \ + -e 's/@''GNULIB_RENAMEAT''@/$(GL_GNULIB_RENAMEAT)/g' \ + -e 's/@''GNULIB_SCANF''@/$(GL_GNULIB_SCANF)/g' \ + -e 's/@''GNULIB_SNPRINTF''@/$(GL_GNULIB_SNPRINTF)/g' \ + -e 's/@''GNULIB_SPRINTF_POSIX''@/$(GL_GNULIB_SPRINTF_POSIX)/g' \ + -e 's/@''GNULIB_STDIO_H_NONBLOCKING''@/$(GL_GNULIB_STDIO_H_NONBLOCKING)/g' \ + -e 's/@''GNULIB_STDIO_H_SIGPIPE''@/$(GL_GNULIB_STDIO_H_SIGPIPE)/g' \ + -e 's/@''GNULIB_TMPFILE''@/$(GL_GNULIB_TMPFILE)/g' \ + -e 's/@''GNULIB_VASPRINTF''@/$(GL_GNULIB_VASPRINTF)/g' \ + -e 's/@''GNULIB_VDPRINTF''@/$(GL_GNULIB_VDPRINTF)/g' \ + -e 's/@''GNULIB_VFPRINTF''@/$(GL_GNULIB_VFPRINTF)/g' \ + -e 's/@''GNULIB_VFPRINTF_POSIX''@/$(GL_GNULIB_VFPRINTF_POSIX)/g' \ + -e 's/@''GNULIB_VFSCANF''@/$(GL_GNULIB_VFSCANF)/g' \ + -e 's/@''GNULIB_VSCANF''@/$(GL_GNULIB_VSCANF)/g' \ + -e 's/@''GNULIB_VPRINTF''@/$(GL_GNULIB_VPRINTF)/g' \ + -e 's/@''GNULIB_VPRINTF_POSIX''@/$(GL_GNULIB_VPRINTF_POSIX)/g' \ + -e 's/@''GNULIB_VSNPRINTF''@/$(GL_GNULIB_VSNPRINTF)/g' \ + -e 's/@''GNULIB_VSPRINTF_POSIX''@/$(GL_GNULIB_VSPRINTF_POSIX)/g' \ + -e 's/@''GNULIB_MDA_FCLOSEALL''@/$(GL_GNULIB_MDA_FCLOSEALL)/g' \ + -e 's/@''GNULIB_MDA_FDOPEN''@/$(GL_GNULIB_MDA_FDOPEN)/g' \ + -e 's/@''GNULIB_MDA_FILENO''@/$(GL_GNULIB_MDA_FILENO)/g' \ + -e 's/@''GNULIB_MDA_GETW''@/$(GL_GNULIB_MDA_GETW)/g' \ + -e 's/@''GNULIB_MDA_PUTW''@/$(GL_GNULIB_MDA_PUTW)/g' \ + -e 's/@''GNULIB_MDA_TEMPNAM''@/$(GL_GNULIB_MDA_TEMPNAM)/g' \ + < $(srcdir)/stdio.in.h > $@-t1 + $(AM_V_at)sed \ + -e 's|@''HAVE_DECL_FCLOSEALL''@|$(HAVE_DECL_FCLOSEALL)|g' \ + -e 's|@''HAVE_DECL_FPURGE''@|$(HAVE_DECL_FPURGE)|g' \ + -e 's|@''HAVE_DECL_FSEEKO''@|$(HAVE_DECL_FSEEKO)|g' \ + -e 's|@''HAVE_DECL_FTELLO''@|$(HAVE_DECL_FTELLO)|g' \ + -e 's|@''HAVE_DECL_GETDELIM''@|$(HAVE_DECL_GETDELIM)|g' \ + -e 's|@''HAVE_DECL_GETLINE''@|$(HAVE_DECL_GETLINE)|g' \ + -e 's|@''HAVE_DECL_GETW''@|$(HAVE_DECL_GETW)|g' \ + -e 's|@''HAVE_DECL_OBSTACK_PRINTF''@|$(HAVE_DECL_OBSTACK_PRINTF)|g' \ + -e 's|@''HAVE_DECL_PUTW''@|$(HAVE_DECL_PUTW)|g' \ + -e 's|@''HAVE_DECL_SNPRINTF''@|$(HAVE_DECL_SNPRINTF)|g' \ + -e 's|@''HAVE_DECL_VSNPRINTF''@|$(HAVE_DECL_VSNPRINTF)|g' \ + -e 's|@''HAVE_DPRINTF''@|$(HAVE_DPRINTF)|g' \ + -e 's|@''HAVE_FSEEKO''@|$(HAVE_FSEEKO)|g' \ + -e 's|@''HAVE_FTELLO''@|$(HAVE_FTELLO)|g' \ + -e 's|@''HAVE_PCLOSE''@|$(HAVE_PCLOSE)|g' \ + -e 's|@''HAVE_POPEN''@|$(HAVE_POPEN)|g' \ + -e 's|@''HAVE_RENAMEAT''@|$(HAVE_RENAMEAT)|g' \ + -e 's|@''HAVE_VASPRINTF''@|$(HAVE_VASPRINTF)|g' \ + -e 's|@''HAVE_VDPRINTF''@|$(HAVE_VDPRINTF)|g' \ + < $@-t1 > $@-t2 + $(AM_V_at)sed \ + -e 's|@''REPLACE_DPRINTF''@|$(REPLACE_DPRINTF)|g' \ + -e 's|@''REPLACE_FCLOSE''@|$(REPLACE_FCLOSE)|g' \ + -e 's|@''REPLACE_FDOPEN''@|$(REPLACE_FDOPEN)|g' \ + -e 's|@''REPLACE_FFLUSH''@|$(REPLACE_FFLUSH)|g' \ + -e 's|@''REPLACE_FOPEN''@|$(REPLACE_FOPEN)|g' \ + -e 's|@''REPLACE_FOPEN_FOR_FOPEN_GNU''@|$(REPLACE_FOPEN_FOR_FOPEN_GNU)|g' \ + -e 's|@''REPLACE_FPRINTF''@|$(REPLACE_FPRINTF)|g' \ + -e 's|@''REPLACE_FPURGE''@|$(REPLACE_FPURGE)|g' \ + -e 's|@''REPLACE_FREOPEN''@|$(REPLACE_FREOPEN)|g' \ + -e 's|@''REPLACE_FSEEK''@|$(REPLACE_FSEEK)|g' \ + -e 's|@''REPLACE_FSEEKO''@|$(REPLACE_FSEEKO)|g' \ + -e 's|@''REPLACE_FTELL''@|$(REPLACE_FTELL)|g' \ + -e 's|@''REPLACE_FTELLO''@|$(REPLACE_FTELLO)|g' \ + -e 's|@''REPLACE_GETDELIM''@|$(REPLACE_GETDELIM)|g' \ + -e 's|@''REPLACE_GETLINE''@|$(REPLACE_GETLINE)|g' \ + -e 's|@''REPLACE_OBSTACK_PRINTF''@|$(REPLACE_OBSTACK_PRINTF)|g' \ + -e 's|@''REPLACE_PERROR''@|$(REPLACE_PERROR)|g' \ + -e 's|@''REPLACE_POPEN''@|$(REPLACE_POPEN)|g' \ + -e 's|@''REPLACE_PRINTF''@|$(REPLACE_PRINTF)|g' \ + -e 's|@''REPLACE_REMOVE''@|$(REPLACE_REMOVE)|g' \ + -e 's|@''REPLACE_RENAME''@|$(REPLACE_RENAME)|g' \ + -e 's|@''REPLACE_RENAMEAT''@|$(REPLACE_RENAMEAT)|g' \ + -e 's|@''REPLACE_SNPRINTF''@|$(REPLACE_SNPRINTF)|g' \ + -e 's|@''REPLACE_SPRINTF''@|$(REPLACE_SPRINTF)|g' \ + -e 's|@''REPLACE_STDIO_READ_FUNCS''@|$(REPLACE_STDIO_READ_FUNCS)|g' \ + -e 's|@''REPLACE_STDIO_WRITE_FUNCS''@|$(REPLACE_STDIO_WRITE_FUNCS)|g' \ + -e 's|@''REPLACE_TMPFILE''@|$(REPLACE_TMPFILE)|g' \ + -e 's|@''REPLACE_VASPRINTF''@|$(REPLACE_VASPRINTF)|g' \ + -e 's|@''REPLACE_VDPRINTF''@|$(REPLACE_VDPRINTF)|g' \ + -e 's|@''REPLACE_VFPRINTF''@|$(REPLACE_VFPRINTF)|g' \ + -e 's|@''REPLACE_VPRINTF''@|$(REPLACE_VPRINTF)|g' \ + -e 's|@''REPLACE_VSNPRINTF''@|$(REPLACE_VSNPRINTF)|g' \ + -e 's|@''REPLACE_VSPRINTF''@|$(REPLACE_VSPRINTF)|g' \ + -e 's|@''ASM_SYMBOL_PREFIX''@|$(ASM_SYMBOL_PREFIX)|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)' \ + < $@-t2 > $@-t3 + $(AM_V_at)rm -f $@-t1 $@-t2 + $(AM_V_at)mv $@-t3 $@ +MOSTLYCLEANFILES += stdio.h stdio.h-t1 stdio.h-t2 stdio.h-t3 + +if GL_COND_OBJ_STDIO_READ +libdiffutils_a_SOURCES += stdio-read.c +endif +if GL_COND_OBJ_STDIO_WRITE +libdiffutils_a_SOURCES += stdio-write.c +endif + +EXTRA_DIST += stdio.in.h + +## end gnulib module stdio + +## begin gnulib module stdlib + +BUILT_SOURCES += stdlib.h + +# We need the following in order to create when the system +# doesn't have one that works with the given compiler. +stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \ + $(_NORETURN_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) + $(gl_V_at)$(SED_HEADER_STDOUT) \ + -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_STDLIB_H''@|$(NEXT_STDLIB_H)|g' \ + -e 's/@''GNULIB__EXIT''@/$(GL_GNULIB__EXIT)/g' \ + -e 's/@''GNULIB_ALIGNED_ALLOC''@/$(GL_GNULIB_ALIGNED_ALLOC)/g' \ + -e 's/@''GNULIB_ATOLL''@/$(GL_GNULIB_ATOLL)/g' \ + -e 's/@''GNULIB_CALLOC_GNU''@/$(GL_GNULIB_CALLOC_GNU)/g' \ + -e 's/@''GNULIB_CALLOC_POSIX''@/$(GL_GNULIB_CALLOC_POSIX)/g' \ + -e 's/@''GNULIB_CANONICALIZE_FILE_NAME''@/$(GL_GNULIB_CANONICALIZE_FILE_NAME)/g' \ + -e 's/@''GNULIB_FREE_POSIX''@/$(GL_GNULIB_FREE_POSIX)/g' \ + -e 's/@''GNULIB_GETLOADAVG''@/$(GL_GNULIB_GETLOADAVG)/g' \ + -e 's/@''GNULIB_GETPROGNAME''@/$(GL_GNULIB_GETPROGNAME)/g' \ + -e 's/@''GNULIB_GETSUBOPT''@/$(GL_GNULIB_GETSUBOPT)/g' \ + -e 's/@''GNULIB_GRANTPT''@/$(GL_GNULIB_GRANTPT)/g' \ + -e 's/@''GNULIB_MALLOC_GNU''@/$(GL_GNULIB_MALLOC_GNU)/g' \ + -e 's/@''GNULIB_MALLOC_POSIX''@/$(GL_GNULIB_MALLOC_POSIX)/g' \ + -e 's/@''GNULIB_MBSTOWCS''@/$(GL_GNULIB_MBSTOWCS)/g' \ + -e 's/@''GNULIB_MBTOWC''@/$(GL_GNULIB_MBTOWC)/g' \ + -e 's/@''GNULIB_MKDTEMP''@/$(GL_GNULIB_MKDTEMP)/g' \ + -e 's/@''GNULIB_MKOSTEMP''@/$(GL_GNULIB_MKOSTEMP)/g' \ + -e 's/@''GNULIB_MKOSTEMPS''@/$(GL_GNULIB_MKOSTEMPS)/g' \ + -e 's/@''GNULIB_MKSTEMP''@/$(GL_GNULIB_MKSTEMP)/g' \ + -e 's/@''GNULIB_MKSTEMPS''@/$(GL_GNULIB_MKSTEMPS)/g' \ + -e 's/@''GNULIB_POSIX_MEMALIGN''@/$(GL_GNULIB_POSIX_MEMALIGN)/g' \ + -e 's/@''GNULIB_POSIX_OPENPT''@/$(GL_GNULIB_POSIX_OPENPT)/g' \ + -e 's/@''GNULIB_PTSNAME''@/$(GL_GNULIB_PTSNAME)/g' \ + -e 's/@''GNULIB_PTSNAME_R''@/$(GL_GNULIB_PTSNAME_R)/g' \ + -e 's/@''GNULIB_PUTENV''@/$(GL_GNULIB_PUTENV)/g' \ + -e 's/@''GNULIB_QSORT_R''@/$(GL_GNULIB_QSORT_R)/g' \ + -e 's/@''GNULIB_RAND''@/$(GL_GNULIB_RAND)/g' \ + -e 's/@''GNULIB_RANDOM''@/$(GL_GNULIB_RANDOM)/g' \ + -e 's/@''GNULIB_RANDOM_R''@/$(GL_GNULIB_RANDOM_R)/g' \ + -e 's/@''GNULIB_REALLOC_GNU''@/$(GL_GNULIB_REALLOC_GNU)/g' \ + -e 's/@''GNULIB_REALLOC_POSIX''@/$(GL_GNULIB_REALLOC_POSIX)/g' \ + -e 's/@''GNULIB_REALLOCARRAY''@/$(GL_GNULIB_REALLOCARRAY)/g' \ + -e 's/@''GNULIB_REALPATH''@/$(GL_GNULIB_REALPATH)/g' \ + -e 's/@''GNULIB_RPMATCH''@/$(GL_GNULIB_RPMATCH)/g' \ + -e 's/@''GNULIB_SECURE_GETENV''@/$(GL_GNULIB_SECURE_GETENV)/g' \ + -e 's/@''GNULIB_SETENV''@/$(GL_GNULIB_SETENV)/g' \ + -e 's/@''GNULIB_STRTOD''@/$(GL_GNULIB_STRTOD)/g' \ + -e 's/@''GNULIB_STRTOL''@/$(GL_GNULIB_STRTOL)/g' \ + -e 's/@''GNULIB_STRTOLD''@/$(GL_GNULIB_STRTOLD)/g' \ + -e 's/@''GNULIB_STRTOLL''@/$(GL_GNULIB_STRTOLL)/g' \ + -e 's/@''GNULIB_STRTOUL''@/$(GL_GNULIB_STRTOUL)/g' \ + -e 's/@''GNULIB_STRTOULL''@/$(GL_GNULIB_STRTOULL)/g' \ + -e 's/@''GNULIB_SYSTEM_POSIX''@/$(GL_GNULIB_SYSTEM_POSIX)/g' \ + -e 's/@''GNULIB_UNLOCKPT''@/$(GL_GNULIB_UNLOCKPT)/g' \ + -e 's/@''GNULIB_UNSETENV''@/$(GL_GNULIB_UNSETENV)/g' \ + -e 's/@''GNULIB_WCTOMB''@/$(GL_GNULIB_WCTOMB)/g' \ + -e 's/@''GNULIB_MDA_ECVT''@/$(GL_GNULIB_MDA_ECVT)/g' \ + -e 's/@''GNULIB_MDA_FCVT''@/$(GL_GNULIB_MDA_FCVT)/g' \ + -e 's/@''GNULIB_MDA_GCVT''@/$(GL_GNULIB_MDA_GCVT)/g' \ + -e 's/@''GNULIB_MDA_MKTEMP''@/$(GL_GNULIB_MDA_MKTEMP)/g' \ + -e 's/@''GNULIB_MDA_PUTENV''@/$(GL_GNULIB_MDA_PUTENV)/g' \ + < $(srcdir)/stdlib.in.h > $@-t1 + $(AM_V_at)sed \ + -e 's|@''HAVE__EXIT''@|$(HAVE__EXIT)|g' \ + -e 's|@''HAVE_ALIGNED_ALLOC''@|$(HAVE_ALIGNED_ALLOC)|g' \ + -e 's|@''HAVE_ATOLL''@|$(HAVE_ATOLL)|g' \ + -e 's|@''HAVE_CANONICALIZE_FILE_NAME''@|$(HAVE_CANONICALIZE_FILE_NAME)|g' \ + -e 's|@''HAVE_DECL_ECVT''@|$(HAVE_DECL_ECVT)|g' \ + -e 's|@''HAVE_DECL_FCVT''@|$(HAVE_DECL_FCVT)|g' \ + -e 's|@''HAVE_DECL_GCVT''@|$(HAVE_DECL_GCVT)|g' \ + -e 's|@''HAVE_DECL_GETLOADAVG''@|$(HAVE_DECL_GETLOADAVG)|g' \ + -e 's|@''HAVE_DECL_PROGRAM_INVOCATION_NAME''@|$(HAVE_DECL_PROGRAM_INVOCATION_NAME)|g' \ + -e 's|@''HAVE_GETPROGNAME''@|$(HAVE_GETPROGNAME)|g' \ + -e 's|@''HAVE_GETSUBOPT''@|$(HAVE_GETSUBOPT)|g' \ + -e 's|@''HAVE_GRANTPT''@|$(HAVE_GRANTPT)|g' \ + -e 's|@''HAVE_INITSTATE''@|$(HAVE_INITSTATE)|g' \ + -e 's|@''HAVE_DECL_INITSTATE''@|$(HAVE_DECL_INITSTATE)|g' \ + -e 's|@''HAVE_MBTOWC''@|$(HAVE_MBTOWC)|g' \ + -e 's|@''HAVE_MKDTEMP''@|$(HAVE_MKDTEMP)|g' \ + -e 's|@''HAVE_MKOSTEMP''@|$(HAVE_MKOSTEMP)|g' \ + -e 's|@''HAVE_MKOSTEMPS''@|$(HAVE_MKOSTEMPS)|g' \ + -e 's|@''HAVE_MKSTEMP''@|$(HAVE_MKSTEMP)|g' \ + -e 's|@''HAVE_MKSTEMPS''@|$(HAVE_MKSTEMPS)|g' \ + -e 's|@''HAVE_POSIX_MEMALIGN''@|$(HAVE_POSIX_MEMALIGN)|g' \ + -e 's|@''HAVE_POSIX_OPENPT''@|$(HAVE_POSIX_OPENPT)|g' \ + -e 's|@''HAVE_PTSNAME''@|$(HAVE_PTSNAME)|g' \ + -e 's|@''HAVE_PTSNAME_R''@|$(HAVE_PTSNAME_R)|g' \ + -e 's|@''HAVE_QSORT_R''@|$(HAVE_QSORT_R)|g' \ + -e 's|@''HAVE_RANDOM''@|$(HAVE_RANDOM)|g' \ + -e 's|@''HAVE_RANDOM_H''@|$(HAVE_RANDOM_H)|g' \ + -e 's|@''HAVE_RANDOM_R''@|$(HAVE_RANDOM_R)|g' \ + -e 's|@''HAVE_REALLOCARRAY''@|$(HAVE_REALLOCARRAY)|g' \ + -e 's|@''HAVE_REALPATH''@|$(HAVE_REALPATH)|g' \ + -e 's|@''HAVE_RPMATCH''@|$(HAVE_RPMATCH)|g' \ + -e 's|@''HAVE_SECURE_GETENV''@|$(HAVE_SECURE_GETENV)|g' \ + -e 's|@''HAVE_DECL_SETENV''@|$(HAVE_DECL_SETENV)|g' \ + -e 's|@''HAVE_SETSTATE''@|$(HAVE_SETSTATE)|g' \ + -e 's|@''HAVE_DECL_SETSTATE''@|$(HAVE_DECL_SETSTATE)|g' \ + -e 's|@''HAVE_STRTOD''@|$(HAVE_STRTOD)|g' \ + -e 's|@''HAVE_STRTOL''@|$(HAVE_STRTOL)|g' \ + -e 's|@''HAVE_STRTOLD''@|$(HAVE_STRTOLD)|g' \ + -e 's|@''HAVE_STRTOLL''@|$(HAVE_STRTOLL)|g' \ + -e 's|@''HAVE_STRTOUL''@|$(HAVE_STRTOUL)|g' \ + -e 's|@''HAVE_STRTOULL''@|$(HAVE_STRTOULL)|g' \ + -e 's|@''HAVE_STRUCT_RANDOM_DATA''@|$(HAVE_STRUCT_RANDOM_DATA)|g' \ + -e 's|@''HAVE_SYS_LOADAVG_H''@|$(HAVE_SYS_LOADAVG_H)|g' \ + -e 's|@''HAVE_UNLOCKPT''@|$(HAVE_UNLOCKPT)|g' \ + -e 's|@''HAVE_DECL_UNSETENV''@|$(HAVE_DECL_UNSETENV)|g' \ + < $@-t1 > $@-t2 + $(AM_V_at)sed \ + -e 's|@''REPLACE__EXIT''@|$(REPLACE__EXIT)|g' \ + -e 's|@''REPLACE_ALIGNED_ALLOC''@|$(REPLACE_ALIGNED_ALLOC)|g' \ + -e 's|@''REPLACE_CALLOC_FOR_CALLOC_GNU''@|$(REPLACE_CALLOC_FOR_CALLOC_GNU)|g' \ + -e 's|@''REPLACE_CALLOC_FOR_CALLOC_POSIX''@|$(REPLACE_CALLOC_FOR_CALLOC_POSIX)|g' \ + -e 's|@''REPLACE_CANONICALIZE_FILE_NAME''@|$(REPLACE_CANONICALIZE_FILE_NAME)|g' \ + -e 's|@''REPLACE_FREE''@|$(REPLACE_FREE)|g' \ + -e 's|@''REPLACE_GETLOADAVG''@|$(REPLACE_GETLOADAVG)|g' \ + -e 's|@''REPLACE_GETPROGNAME''@|$(REPLACE_GETPROGNAME)|g' \ + -e 's|@''REPLACE_GETSUBOPT''@|$(REPLACE_GETSUBOPT)|g' \ + -e 's|@''REPLACE_INITSTATE''@|$(REPLACE_INITSTATE)|g' \ + -e 's|@''REPLACE_MALLOC_FOR_MALLOC_GNU''@|$(REPLACE_MALLOC_FOR_MALLOC_GNU)|g' \ + -e 's|@''REPLACE_MALLOC_FOR_MALLOC_POSIX''@|$(REPLACE_MALLOC_FOR_MALLOC_POSIX)|g' \ + -e 's|@''REPLACE_MB_CUR_MAX''@|$(REPLACE_MB_CUR_MAX)|g' \ + -e 's|@''REPLACE_MBSTOWCS''@|$(REPLACE_MBSTOWCS)|g' \ + -e 's|@''REPLACE_MBTOWC''@|$(REPLACE_MBTOWC)|g' \ + -e 's|@''REPLACE_MKOSTEMP''@|$(REPLACE_MKOSTEMP)|g' \ + -e 's|@''REPLACE_MKOSTEMPS''@|$(REPLACE_MKOSTEMPS)|g' \ + -e 's|@''REPLACE_MKSTEMP''@|$(REPLACE_MKSTEMP)|g' \ + -e 's|@''REPLACE_POSIX_MEMALIGN''@|$(REPLACE_POSIX_MEMALIGN)|g' \ + -e 's|@''REPLACE_POSIX_OPENPT''@|$(REPLACE_POSIX_OPENPT)|g' \ + -e 's|@''REPLACE_PTSNAME''@|$(REPLACE_PTSNAME)|g' \ + -e 's|@''REPLACE_PTSNAME_R''@|$(REPLACE_PTSNAME_R)|g' \ + -e 's|@''REPLACE_PUTENV''@|$(REPLACE_PUTENV)|g' \ + -e 's|@''REPLACE_QSORT_R''@|$(REPLACE_QSORT_R)|g' \ + -e 's|@''REPLACE_RAND''@|$(REPLACE_RAND)|g' \ + -e 's|@''REPLACE_RANDOM''@|$(REPLACE_RANDOM)|g' \ + -e 's|@''REPLACE_RANDOM_R''@|$(REPLACE_RANDOM_R)|g' \ + -e 's|@''REPLACE_REALLOC_FOR_REALLOC_GNU''@|$(REPLACE_REALLOC_FOR_REALLOC_GNU)|g' \ + -e 's|@''REPLACE_REALLOC_FOR_REALLOC_POSIX''@|$(REPLACE_REALLOC_FOR_REALLOC_POSIX)|g' \ + -e 's|@''REPLACE_REALLOCARRAY''@|$(REPLACE_REALLOCARRAY)|g' \ + -e 's|@''REPLACE_REALPATH''@|$(REPLACE_REALPATH)|g' \ + -e 's|@''REPLACE_SETENV''@|$(REPLACE_SETENV)|g' \ + -e 's|@''REPLACE_SETSTATE''@|$(REPLACE_SETSTATE)|g' \ + -e 's|@''REPLACE_STRTOD''@|$(REPLACE_STRTOD)|g' \ + -e 's|@''REPLACE_STRTOL''@|$(REPLACE_STRTOL)|g' \ + -e 's|@''REPLACE_STRTOLD''@|$(REPLACE_STRTOLD)|g' \ + -e 's|@''REPLACE_STRTOLL''@|$(REPLACE_STRTOLL)|g' \ + -e 's|@''REPLACE_STRTOUL''@|$(REPLACE_STRTOUL)|g' \ + -e 's|@''REPLACE_STRTOULL''@|$(REPLACE_STRTOULL)|g' \ + -e 's|@''REPLACE_UNSETENV''@|$(REPLACE_UNSETENV)|g' \ + -e 's|@''REPLACE_WCTOMB''@|$(REPLACE_WCTOMB)|g' \ + -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ + -e '/definition of _Noreturn/r $(_NORETURN_H)' \ + -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ + -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ + < $@-t2 > $@-t3 + $(AM_V_at)rm -f $@-t1 $@-t2 + $(AM_V_at)mv $@-t3 $@ +MOSTLYCLEANFILES += stdlib.h stdlib.h-t1 stdlib.h-t2 stdlib.h-t3 + +EXTRA_DIST += stdlib.in.h + +## end gnulib module stdlib + +## begin gnulib module stdopen + +libdiffutils_a_SOURCES += stdopen.c + +EXTRA_DIST += stdopen.h + +## end gnulib module stdopen + +## begin gnulib module stpcpy + +if GL_COND_OBJ_STPCPY +libdiffutils_a_SOURCES += stpcpy.c +endif + +## end gnulib module stpcpy + +## begin gnulib module strcase + +if GL_COND_OBJ_STRCASECMP +libdiffutils_a_SOURCES += strcasecmp.c +endif +if GL_COND_OBJ_STRNCASECMP +libdiffutils_a_SOURCES += strncasecmp.c +endif + +## end gnulib module strcase + +## begin gnulib module strdup-posix + +if GL_COND_OBJ_STRDUP +libdiffutils_a_SOURCES += strdup.c +endif + +## end gnulib module strdup-posix + +## begin gnulib module streq + + +EXTRA_DIST += streq.h + +## end gnulib module streq + +## begin gnulib module strerror + +if GL_COND_OBJ_STRERROR +libdiffutils_a_SOURCES += strerror.c +endif + +## end gnulib module strerror + +## begin gnulib module strerror-override + +if GL_COND_OBJ_STRERROR_OVERRIDE +libdiffutils_a_SOURCES += strerror-override.c +endif + +EXTRA_DIST += strerror-override.h + +## end gnulib module strerror-override + +## begin gnulib module string + +BUILT_SOURCES += string.h + +# We need the following in order to create when the system +# doesn't have one that works with the given compiler. +string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) + $(gl_V_at)$(SED_HEADER_STDOUT) \ + -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_STRING_H''@|$(NEXT_STRING_H)|g' \ + -e 's/@''GNULIB_EXPLICIT_BZERO''@/$(GL_GNULIB_EXPLICIT_BZERO)/g' \ + -e 's/@''GNULIB_FFSL''@/$(GL_GNULIB_FFSL)/g' \ + -e 's/@''GNULIB_FFSLL''@/$(GL_GNULIB_FFSLL)/g' \ + -e 's/@''GNULIB_MBSLEN''@/$(GL_GNULIB_MBSLEN)/g' \ + -e 's/@''GNULIB_MBSNLEN''@/$(GL_GNULIB_MBSNLEN)/g' \ + -e 's/@''GNULIB_MBSCHR''@/$(GL_GNULIB_MBSCHR)/g' \ + -e 's/@''GNULIB_MBSRCHR''@/$(GL_GNULIB_MBSRCHR)/g' \ + -e 's/@''GNULIB_MBSSTR''@/$(GL_GNULIB_MBSSTR)/g' \ + -e 's/@''GNULIB_MBSCASECMP''@/$(GL_GNULIB_MBSCASECMP)/g' \ + -e 's/@''GNULIB_MBSNCASECMP''@/$(GL_GNULIB_MBSNCASECMP)/g' \ + -e 's/@''GNULIB_MBSPCASECMP''@/$(GL_GNULIB_MBSPCASECMP)/g' \ + -e 's/@''GNULIB_MBSCASESTR''@/$(GL_GNULIB_MBSCASESTR)/g' \ + -e 's/@''GNULIB_MBSCSPN''@/$(GL_GNULIB_MBSCSPN)/g' \ + -e 's/@''GNULIB_MBSPBRK''@/$(GL_GNULIB_MBSPBRK)/g' \ + -e 's/@''GNULIB_MBSSPN''@/$(GL_GNULIB_MBSSPN)/g' \ + -e 's/@''GNULIB_MBSSEP''@/$(GL_GNULIB_MBSSEP)/g' \ + -e 's/@''GNULIB_MBSTOK_R''@/$(GL_GNULIB_MBSTOK_R)/g' \ + -e 's/@''GNULIB_MEMCHR''@/$(GL_GNULIB_MEMCHR)/g' \ + -e 's/@''GNULIB_MEMMEM''@/$(GL_GNULIB_MEMMEM)/g' \ + -e 's/@''GNULIB_MEMPCPY''@/$(GL_GNULIB_MEMPCPY)/g' \ + -e 's/@''GNULIB_MEMRCHR''@/$(GL_GNULIB_MEMRCHR)/g' \ + -e 's/@''GNULIB_MEMSET_EXPLICIT''@/$(GL_GNULIB_MEMSET_EXPLICIT)/g' \ + -e 's/@''GNULIB_RAWMEMCHR''@/$(GL_GNULIB_RAWMEMCHR)/g' \ + -e 's/@''GNULIB_STPCPY''@/$(GL_GNULIB_STPCPY)/g' \ + -e 's/@''GNULIB_STPNCPY''@/$(GL_GNULIB_STPNCPY)/g' \ + -e 's/@''GNULIB_STRCHRNUL''@/$(GL_GNULIB_STRCHRNUL)/g' \ + -e 's/@''GNULIB_STRDUP''@/$(GL_GNULIB_STRDUP)/g' \ + -e 's/@''GNULIB_STRNCAT''@/$(GL_GNULIB_STRNCAT)/g' \ + -e 's/@''GNULIB_STRNDUP''@/$(GL_GNULIB_STRNDUP)/g' \ + -e 's/@''GNULIB_STRNLEN''@/$(GL_GNULIB_STRNLEN)/g' \ + -e 's/@''GNULIB_STRPBRK''@/$(GL_GNULIB_STRPBRK)/g' \ + -e 's/@''GNULIB_STRSEP''@/$(GL_GNULIB_STRSEP)/g' \ + -e 's/@''GNULIB_STRSTR''@/$(GL_GNULIB_STRSTR)/g' \ + -e 's/@''GNULIB_STRCASESTR''@/$(GL_GNULIB_STRCASESTR)/g' \ + -e 's/@''GNULIB_STRTOK_R''@/$(GL_GNULIB_STRTOK_R)/g' \ + -e 's/@''GNULIB_STRERROR''@/$(GL_GNULIB_STRERROR)/g' \ + -e 's/@''GNULIB_STRERROR_R''@/$(GL_GNULIB_STRERROR_R)/g' \ + -e 's/@''GNULIB_STRERRORNAME_NP''@/$(GL_GNULIB_STRERRORNAME_NP)/g' \ + -e 's/@''GNULIB_SIGABBREV_NP''@/$(GL_GNULIB_SIGABBREV_NP)/g' \ + -e 's/@''GNULIB_SIGDESCR_NP''@/$(GL_GNULIB_SIGDESCR_NP)/g' \ + -e 's/@''GNULIB_STRSIGNAL''@/$(GL_GNULIB_STRSIGNAL)/g' \ + -e 's/@''GNULIB_STRVERSCMP''@/$(GL_GNULIB_STRVERSCMP)/g' \ + -e 's/@''GNULIB_MDA_MEMCCPY''@/$(GL_GNULIB_MDA_MEMCCPY)/g' \ + -e 's/@''GNULIB_MDA_STRDUP''@/$(GL_GNULIB_MDA_STRDUP)/g' \ + -e 's/@''GNULIB_FREE_POSIX''@/$(GL_GNULIB_FREE_POSIX)/g' \ + < $(srcdir)/string.in.h > $@-t1 + $(AM_V_at)sed \ + -e 's|@''HAVE_EXPLICIT_BZERO''@|$(HAVE_EXPLICIT_BZERO)|g' \ + -e 's|@''HAVE_FFSL''@|$(HAVE_FFSL)|g' \ + -e 's|@''HAVE_FFSLL''@|$(HAVE_FFSLL)|g' \ + -e 's|@''HAVE_MBSLEN''@|$(HAVE_MBSLEN)|g' \ + -e 's|@''HAVE_DECL_MEMMEM''@|$(HAVE_DECL_MEMMEM)|g' \ + -e 's|@''HAVE_MEMPCPY''@|$(HAVE_MEMPCPY)|g' \ + -e 's|@''HAVE_DECL_MEMRCHR''@|$(HAVE_DECL_MEMRCHR)|g' \ + -e 's|@''HAVE_MEMSET_EXPLICIT''@|$(HAVE_MEMSET_EXPLICIT)|g' \ + -e 's|@''HAVE_RAWMEMCHR''@|$(HAVE_RAWMEMCHR)|g' \ + -e 's|@''HAVE_STPCPY''@|$(HAVE_STPCPY)|g' \ + -e 's|@''HAVE_STPNCPY''@|$(HAVE_STPNCPY)|g' \ + -e 's|@''HAVE_STRCHRNUL''@|$(HAVE_STRCHRNUL)|g' \ + -e 's|@''HAVE_DECL_STRDUP''@|$(HAVE_DECL_STRDUP)|g' \ + -e 's|@''HAVE_DECL_STRNDUP''@|$(HAVE_DECL_STRNDUP)|g' \ + -e 's|@''HAVE_DECL_STRNLEN''@|$(HAVE_DECL_STRNLEN)|g' \ + -e 's|@''HAVE_STRPBRK''@|$(HAVE_STRPBRK)|g' \ + -e 's|@''HAVE_STRSEP''@|$(HAVE_STRSEP)|g' \ + -e 's|@''HAVE_STRCASESTR''@|$(HAVE_STRCASESTR)|g' \ + -e 's|@''HAVE_DECL_STRTOK_R''@|$(HAVE_DECL_STRTOK_R)|g' \ + -e 's|@''HAVE_DECL_STRERROR_R''@|$(HAVE_DECL_STRERROR_R)|g' \ + -e 's|@''HAVE_STRERRORNAME_NP''@|$(HAVE_STRERRORNAME_NP)|g' \ + -e 's|@''HAVE_SIGABBREV_NP''@|$(HAVE_SIGABBREV_NP)|g' \ + -e 's|@''HAVE_SIGDESCR_NP''@|$(HAVE_SIGDESCR_NP)|g' \ + -e 's|@''HAVE_DECL_STRSIGNAL''@|$(HAVE_DECL_STRSIGNAL)|g' \ + -e 's|@''HAVE_STRVERSCMP''@|$(HAVE_STRVERSCMP)|g' \ + -e 's|@''REPLACE_FFSLL''@|$(REPLACE_FFSLL)|g' \ + -e 's|@''REPLACE_MEMCHR''@|$(REPLACE_MEMCHR)|g' \ + -e 's|@''REPLACE_MEMMEM''@|$(REPLACE_MEMMEM)|g' \ + -e 's|@''REPLACE_MEMPCPY''@|$(REPLACE_MEMPCPY)|g' \ + -e 's|@''REPLACE_MEMSET_EXPLICIT''@|$(REPLACE_MEMSET_EXPLICIT)|g' \ + -e 's|@''REPLACE_FREE''@|$(REPLACE_FREE)|g' \ + -e 's|@''REPLACE_STPCPY''@|$(REPLACE_STPCPY)|g' \ + -e 's|@''REPLACE_STPNCPY''@|$(REPLACE_STPNCPY)|g' \ + -e 's|@''REPLACE_STRCHRNUL''@|$(REPLACE_STRCHRNUL)|g' \ + -e 's|@''REPLACE_STRDUP''@|$(REPLACE_STRDUP)|g' \ + -e 's|@''REPLACE_STRNCAT''@|$(REPLACE_STRNCAT)|g' \ + -e 's|@''REPLACE_STRNDUP''@|$(REPLACE_STRNDUP)|g' \ + -e 's|@''REPLACE_STRNLEN''@|$(REPLACE_STRNLEN)|g' \ + -e 's|@''REPLACE_STRSTR''@|$(REPLACE_STRSTR)|g' \ + -e 's|@''REPLACE_STRCASESTR''@|$(REPLACE_STRCASESTR)|g' \ + -e 's|@''REPLACE_STRTOK_R''@|$(REPLACE_STRTOK_R)|g' \ + -e 's|@''REPLACE_STRERROR''@|$(REPLACE_STRERROR)|g' \ + -e 's|@''REPLACE_STRERROR_R''@|$(REPLACE_STRERROR_R)|g' \ + -e 's|@''REPLACE_STRERRORNAME_NP''@|$(REPLACE_STRERRORNAME_NP)|g' \ + -e 's|@''REPLACE_STRSIGNAL''@|$(REPLACE_STRSIGNAL)|g' \ + -e 's|@''REPLACE_STRVERSCMP''@|$(REPLACE_STRVERSCMP)|g' \ + -e 's|@''UNDEFINE_STRTOK_R''@|$(UNDEFINE_STRTOK_R)|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)' \ + < $@-t1 > $@-t2 + $(AM_V_at)rm -f $@-t1 + $(AM_V_at)mv $@-t2 $@ +MOSTLYCLEANFILES += string.h string.h-t1 string.h-t2 + +EXTRA_DIST += string.in.h + +## end gnulib module string + +## begin gnulib module strings + +BUILT_SOURCES += strings.h + +# We need the following in order to create when the system +# doesn't have one that works with the given compiler. +strings.h: strings.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H) + $(gl_V_at)$(SED_HEADER_STDOUT) \ + -e 's|@''GUARD_PREFIX''@|GL|g' \ + -e 's|@''HAVE_STRINGS_H''@|$(HAVE_STRINGS_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_STRINGS_H''@|$(NEXT_STRINGS_H)|g' \ + -e 's/@''GNULIB_FFS''@/$(GL_GNULIB_FFS)/g' \ + -e 's|@''HAVE_FFS''@|$(HAVE_FFS)|g' \ + -e 's|@''HAVE_STRCASECMP''@|$(HAVE_STRCASECMP)|g' \ + -e 's|@''HAVE_DECL_STRNCASECMP''@|$(HAVE_DECL_STRNCASECMP)|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)/strings.in.h > $@-t + $(AM_V_at)mv $@-t $@ +MOSTLYCLEANFILES += strings.h strings.h-t + +EXTRA_DIST += strings.in.h + +## end gnulib module strings + +## begin gnulib module strnlen + +if GL_COND_OBJ_STRNLEN +libdiffutils_a_SOURCES += strnlen.c +endif + +## end gnulib module strnlen + +## begin gnulib module strnlen1 + +libdiffutils_a_SOURCES += strnlen1.h strnlen1.c + +## end gnulib module strnlen1 + +## begin gnulib module strptime + +if GL_COND_OBJ_STRPTIME +libdiffutils_a_SOURCES += strptime.c +endif + +## end gnulib module strptime + +## begin gnulib module strtoimax + +if GL_COND_OBJ_STRTOIMAX +libdiffutils_a_SOURCES += strtoimax.c +endif + +## end gnulib module strtoimax + +## begin gnulib module strtoll + +if GL_COND_OBJ_STRTOLL +libdiffutils_a_SOURCES += strtoll.c +endif + +EXTRA_DIST += strtol.c + +EXTRA_libdiffutils_a_SOURCES += strtol.c + +## end gnulib module strtoll + +## begin gnulib module sys_random + +BUILT_SOURCES += sys/random.h + +# We need the following in order to create when the system +# doesn't have one. +sys/random.h: sys_random.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) + $(AM_V_GEN)$(MKDIR_P) '%reldir%/sys' + $(AM_V_at)$(SED_HEADER_STDOUT) \ + -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_SYS_RANDOM_H''@|$(NEXT_SYS_RANDOM_H)|g' \ + -e 's|@''HAVE_SYS_RANDOM_H''@|$(HAVE_SYS_RANDOM_H)|g' \ + -e 's/@''GNULIB_GETRANDOM''@/$(GL_GNULIB_GETRANDOM)/g' \ + -e 's/@''HAVE_GETRANDOM''@/$(HAVE_GETRANDOM)/g' \ + -e 's/@''REPLACE_GETRANDOM''@/$(REPLACE_GETRANDOM)/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)/sys_random.in.h > $@-t + $(AM_V_at)mv $@-t $@ +MOSTLYCLEANFILES += sys/random.h sys/random.h-t +MOSTLYCLEANDIRS += sys + +EXTRA_DIST += sys_random.in.h + +## end gnulib module sys_random + +## begin gnulib module sys_stat + +BUILT_SOURCES += sys/stat.h + +# We need the following in order to create when the system +# has one that is incomplete. +sys/stat.h: sys_stat.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) + $(AM_V_GEN)$(MKDIR_P) '%reldir%/sys' + $(AM_V_at)$(SED_HEADER_STDOUT) \ + -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_SYS_STAT_H''@|$(NEXT_SYS_STAT_H)|g' \ + -e 's|@''WINDOWS_64_BIT_ST_SIZE''@|$(WINDOWS_64_BIT_ST_SIZE)|g' \ + -e 's|@''WINDOWS_STAT_TIMESPEC''@|$(WINDOWS_STAT_TIMESPEC)|g' \ + -e 's/@''GNULIB_CHMOD''@/$(GL_GNULIB_CHMOD)/g' \ + -e 's/@''GNULIB_FCHMODAT''@/$(GL_GNULIB_FCHMODAT)/g' \ + -e 's/@''GNULIB_FSTAT''@/$(GL_GNULIB_FSTAT)/g' \ + -e 's/@''GNULIB_FSTATAT''@/$(GL_GNULIB_FSTATAT)/g' \ + -e 's/@''GNULIB_FUTIMENS''@/$(GL_GNULIB_FUTIMENS)/g' \ + -e 's/@''GNULIB_GETUMASK''@/$(GL_GNULIB_GETUMASK)/g' \ + -e 's/@''GNULIB_LCHMOD''@/$(GL_GNULIB_LCHMOD)/g' \ + -e 's/@''GNULIB_LSTAT''@/$(GL_GNULIB_LSTAT)/g' \ + -e 's/@''GNULIB_MKDIR''@/$(GL_GNULIB_MKDIR)/g' \ + -e 's/@''GNULIB_MKDIRAT''@/$(GL_GNULIB_MKDIRAT)/g' \ + -e 's/@''GNULIB_MKFIFO''@/$(GL_GNULIB_MKFIFO)/g' \ + -e 's/@''GNULIB_MKFIFOAT''@/$(GL_GNULIB_MKFIFOAT)/g' \ + -e 's/@''GNULIB_MKNOD''@/$(GL_GNULIB_MKNOD)/g' \ + -e 's/@''GNULIB_MKNODAT''@/$(GL_GNULIB_MKNODAT)/g' \ + -e 's/@''GNULIB_STAT''@/$(GL_GNULIB_STAT)/g' \ + -e 's/@''GNULIB_UTIMENSAT''@/$(GL_GNULIB_UTIMENSAT)/g' \ + -e 's/@''GNULIB_OVERRIDES_STRUCT_STAT''@/$(GL_GNULIB_OVERRIDES_STRUCT_STAT)/g' \ + -e 's/@''GNULIB_MDA_CHMOD''@/$(GL_GNULIB_MDA_CHMOD)/g' \ + -e 's/@''GNULIB_MDA_MKDIR''@/$(GL_GNULIB_MDA_MKDIR)/g' \ + -e 's/@''GNULIB_MDA_UMASK''@/$(GL_GNULIB_MDA_UMASK)/g' \ + -e 's|@''HAVE_FCHMODAT''@|$(HAVE_FCHMODAT)|g' \ + -e 's|@''HAVE_FSTATAT''@|$(HAVE_FSTATAT)|g' \ + -e 's|@''HAVE_FUTIMENS''@|$(HAVE_FUTIMENS)|g' \ + -e 's|@''HAVE_GETUMASK''@|$(HAVE_GETUMASK)|g' \ + -e 's|@''HAVE_LCHMOD''@|$(HAVE_LCHMOD)|g' \ + -e 's|@''HAVE_LSTAT''@|$(HAVE_LSTAT)|g' \ + -e 's|@''HAVE_MKDIRAT''@|$(HAVE_MKDIRAT)|g' \ + -e 's|@''HAVE_MKFIFO''@|$(HAVE_MKFIFO)|g' \ + -e 's|@''HAVE_MKFIFOAT''@|$(HAVE_MKFIFOAT)|g' \ + -e 's|@''HAVE_MKNOD''@|$(HAVE_MKNOD)|g' \ + -e 's|@''HAVE_MKNODAT''@|$(HAVE_MKNODAT)|g' \ + -e 's|@''HAVE_UTIMENSAT''@|$(HAVE_UTIMENSAT)|g' \ + -e 's|@''REPLACE_CHMOD''@|$(REPLACE_CHMOD)|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' \ + -e 's|@''REPLACE_LSTAT''@|$(REPLACE_LSTAT)|g' \ + -e 's|@''REPLACE_MKDIR''@|$(REPLACE_MKDIR)|g' \ + -e 's|@''REPLACE_MKFIFO''@|$(REPLACE_MKFIFO)|g' \ + -e 's|@''REPLACE_MKFIFOAT''@|$(REPLACE_MKFIFOAT)|g' \ + -e 's|@''REPLACE_MKNOD''@|$(REPLACE_MKNOD)|g' \ + -e 's|@''REPLACE_MKNODAT''@|$(REPLACE_MKNODAT)|g' \ + -e 's|@''REPLACE_STAT''@|$(REPLACE_STAT)|g' \ + -e 's|@''REPLACE_UTIMENSAT''@|$(REPLACE_UTIMENSAT)|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)/sys_stat.in.h > $@-t + $(AM_V_at)mv $@-t $@ +MOSTLYCLEANFILES += sys/stat.h sys/stat.h-t +MOSTLYCLEANDIRS += sys + +EXTRA_DIST += sys_stat.in.h + +## end gnulib module sys_stat + +## begin gnulib module sys_time + +BUILT_SOURCES += sys/time.h + +# We need the following in order to create when the system +# doesn't have one that works with the given compiler. +sys/time.h: sys_time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) + $(AM_V_GEN)$(MKDIR_P) '%reldir%/sys' + $(AM_V_at)$(SED_HEADER_STDOUT) \ + -e 's|@''GUARD_PREFIX''@|GL|g' \ + -e 's/@''HAVE_SYS_TIME_H''@/$(HAVE_SYS_TIME_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_SYS_TIME_H''@|$(NEXT_SYS_TIME_H)|g' \ + -e 's/@''GNULIB_GETTIMEOFDAY''@/$(GL_GNULIB_GETTIMEOFDAY)/g' \ + -e 's|@''HAVE_WINSOCK2_H''@|$(HAVE_WINSOCK2_H)|g' \ + -e 's/@''HAVE_GETTIMEOFDAY''@/$(HAVE_GETTIMEOFDAY)/g' \ + -e 's/@''HAVE_STRUCT_TIMEVAL''@/$(HAVE_STRUCT_TIMEVAL)/g' \ + -e 's/@''REPLACE_GETTIMEOFDAY''@/$(REPLACE_GETTIMEOFDAY)/g' \ + -e 's/@''REPLACE_STRUCT_TIMEVAL''@/$(REPLACE_STRUCT_TIMEVAL)/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)/sys_time.in.h > $@-t + $(AM_V_at)mv $@-t $@ +MOSTLYCLEANFILES += sys/time.h sys/time.h-t + +EXTRA_DIST += sys_time.in.h + +## end gnulib module sys_time + +## begin gnulib module sys_types + +BUILT_SOURCES += sys/types.h + +# We need the following in order to create when the system +# doesn't have one that works with the given compiler. +sys/types.h: sys_types.in.h $(top_builddir)/config.status + $(AM_V_GEN)$(MKDIR_P) '%reldir%/sys' + $(AM_V_at)$(SED_HEADER_STDOUT) \ + -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_SYS_TYPES_H''@|$(NEXT_SYS_TYPES_H)|g' \ + -e 's|@''WINDOWS_64_BIT_OFF_T''@|$(WINDOWS_64_BIT_OFF_T)|g' \ + -e 's|@''WINDOWS_STAT_INODES''@|$(WINDOWS_STAT_INODES)|g' \ + $(srcdir)/sys_types.in.h > $@-t + $(AM_V_at)mv $@-t $@ +MOSTLYCLEANFILES += sys/types.h sys/types.h-t + +EXTRA_DIST += sys_types.in.h + +## end gnulib module sys_types + +## begin gnulib module sys_wait + +BUILT_SOURCES += sys/wait.h + +# We need the following in order to create when the system +# has one that is incomplete. +sys/wait.h: sys_wait.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) + $(AM_V_GEN)$(MKDIR_P) '%reldir%/sys' + $(AM_V_at)$(SED_HEADER_STDOUT) \ + -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_SYS_WAIT_H''@|$(NEXT_SYS_WAIT_H)|g' \ + -e 's/@''GNULIB_WAITPID''@/$(GL_GNULIB_WAITPID)/g' \ + -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ + -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ + $(srcdir)/sys_wait.in.h > $@-t + $(AM_V_at)mv $@-t $@ +MOSTLYCLEANFILES += sys/wait.h sys/wait.h-t +MOSTLYCLEANDIRS += sys + +EXTRA_DIST += sys_wait.in.h + +## end gnulib module sys_wait + +## begin gnulib module system-quote + +libdiffutils_a_SOURCES += system-quote.h system-quote.c + +## end gnulib module system-quote + +## begin gnulib module tempname + +libdiffutils_a_SOURCES += tempname.c + +EXTRA_DIST += tempname.h + +## end gnulib module tempname + +## begin gnulib module threadlib + +libdiffutils_a_SOURCES += glthread/threadlib.c + +## end gnulib module threadlib + +## begin gnulib module time-h + +BUILT_SOURCES += time.h + +# We need the following in order to create when the system +# doesn't have one that works with the given compiler. +time.h: time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) + $(gl_V_at)$(SED_HEADER_STDOUT) \ + -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_TIME_H''@|$(NEXT_TIME_H)|g' \ + -e 's/@''GNULIB_CTIME''@/$(GL_GNULIB_CTIME)/g' \ + -e 's/@''GNULIB_LOCALTIME''@/$(GL_GNULIB_LOCALTIME)/g' \ + -e 's/@''GNULIB_MKTIME''@/$(GL_GNULIB_MKTIME)/g' \ + -e 's/@''GNULIB_NANOSLEEP''@/$(GL_GNULIB_NANOSLEEP)/g' \ + -e 's/@''GNULIB_STRFTIME''@/$(GL_GNULIB_STRFTIME)/g' \ + -e 's/@''GNULIB_STRPTIME''@/$(GL_GNULIB_STRPTIME)/g' \ + -e 's/@''GNULIB_TIME''@/$(GL_GNULIB_TIME)/g' \ + -e 's/@''GNULIB_TIMEGM''@/$(GL_GNULIB_TIMEGM)/g' \ + -e 's/@''GNULIB_TIMESPEC_GET''@/$(GL_GNULIB_TIMESPEC_GET)/g' \ + -e 's/@''GNULIB_TIMESPEC_GETRES''@/$(GL_GNULIB_TIMESPEC_GETRES)/g' \ + -e 's/@''GNULIB_TIME_R''@/$(GL_GNULIB_TIME_R)/g' \ + -e 's/@''GNULIB_TIME_RZ''@/$(GL_GNULIB_TIME_RZ)/g' \ + -e 's/@''GNULIB_TZSET''@/$(GL_GNULIB_TZSET)/g' \ + -e 's/@''GNULIB_MDA_TZSET''@/$(GL_GNULIB_MDA_TZSET)/g' \ + -e 's|@''HAVE_DECL_LOCALTIME_R''@|$(HAVE_DECL_LOCALTIME_R)|g' \ + -e 's|@''HAVE_NANOSLEEP''@|$(HAVE_NANOSLEEP)|g' \ + -e 's|@''HAVE_STRPTIME''@|$(HAVE_STRPTIME)|g' \ + -e 's|@''HAVE_TIMEGM''@|$(HAVE_TIMEGM)|g' \ + -e 's|@''HAVE_TIMESPEC_GET''@|$(HAVE_TIMESPEC_GET)|g' \ + -e 's|@''HAVE_TIMESPEC_GETRES''@|$(HAVE_TIMESPEC_GETRES)|g' \ + -e 's|@''HAVE_TIMEZONE_T''@|$(HAVE_TIMEZONE_T)|g' \ + -e 's|@''REPLACE_CTIME''@|$(REPLACE_CTIME)|g' \ + -e 's|@''REPLACE_GMTIME''@|$(REPLACE_GMTIME)|g' \ + -e 's|@''REPLACE_LOCALTIME''@|$(REPLACE_LOCALTIME)|g' \ + -e 's|@''REPLACE_LOCALTIME_R''@|$(REPLACE_LOCALTIME_R)|g' \ + -e 's|@''REPLACE_MKTIME''@|$(REPLACE_MKTIME)|g' \ + -e 's|@''REPLACE_NANOSLEEP''@|$(REPLACE_NANOSLEEP)|g' \ + -e 's|@''REPLACE_STRFTIME''@|$(REPLACE_STRFTIME)|g' \ + -e 's|@''REPLACE_TIME''@|$(REPLACE_TIME)|g' \ + -e 's|@''REPLACE_TIMEGM''@|$(REPLACE_TIMEGM)|g' \ + -e 's|@''REPLACE_TIMESPEC_GET''@|$(REPLACE_TIMESPEC_GET)|g' \ + -e 's|@''REPLACE_TIMESPEC_GETRES''@|$(REPLACE_TIMESPEC_GETRES)|g' \ + -e 's|@''REPLACE_TZSET''@|$(REPLACE_TZSET)|g' \ + -e 's|@''PTHREAD_H_DEFINES_STRUCT_TIMESPEC''@|$(PTHREAD_H_DEFINES_STRUCT_TIMESPEC)|g' \ + -e 's|@''SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \ + -e 's|@''TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \ + -e 's|@''UNISTD_H_DEFINES_STRUCT_TIMESPEC''@|$(UNISTD_H_DEFINES_STRUCT_TIMESPEC)|g' \ + -e 's|@''TIME_H_DEFINES_TIME_UTC''@|$(TIME_H_DEFINES_TIME_UTC)|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)/time.in.h > $@-t + $(AM_V_at)mv $@-t $@ +MOSTLYCLEANFILES += time.h time.h-t + +EXTRA_DIST += time.in.h + +## end gnulib module time-h + +## begin gnulib module time_r + +if GL_COND_OBJ_TIME_R +libdiffutils_a_SOURCES += time_r.c +endif + +## end gnulib module time_r + +## begin gnulib module time_rz + +if GL_COND_OBJ_TIME_RZ +libdiffutils_a_SOURCES += time_rz.c +endif + +EXTRA_DIST += time-internal.h + +## end gnulib module time_rz + +## begin gnulib module timegm + +if GL_COND_OBJ_TIMEGM +libdiffutils_a_SOURCES += timegm.c +endif + +EXTRA_DIST += mktime-internal.h + +## end gnulib module timegm + +## begin gnulib module timespec + +libdiffutils_a_SOURCES += timespec.c + +EXTRA_DIST += timespec.h + +## end gnulib module timespec + +## begin gnulib module timespec_get + +if GL_COND_OBJ_TIMESPEC_GET +libdiffutils_a_SOURCES += timespec_get.c +endif + +## end gnulib module timespec_get + +## begin gnulib module tzset + +if GL_COND_OBJ_TZSET +libdiffutils_a_SOURCES += tzset.c +endif + +## end gnulib module tzset + +## begin gnulib module uchar + +BUILT_SOURCES += uchar.h + +uchar.h: uchar.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) + $(gl_V_at)$(SED_HEADER_STDOUT) \ + -e 's|@''GUARD_PREFIX''@|GL|g' \ + -e 's/@''HAVE_UCHAR_H''@/$(HAVE_UCHAR_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_UCHAR_H''@|$(NEXT_UCHAR_H)|g' \ + -e 's|@''CXX_HAS_CHAR8_TYPE''@|$(CXX_HAS_CHAR8_TYPE)|g' \ + -e 's|@''CXX_HAS_UCHAR_TYPES''@|$(CXX_HAS_UCHAR_TYPES)|g' \ + -e 's|@''SMALL_WCHAR_T''@|$(SMALL_WCHAR_T)|g' \ + -e 's|@''GNULIBHEADERS_OVERRIDE_CHAR8_T''@|$(GNULIBHEADERS_OVERRIDE_CHAR8_T)|g' \ + -e 's|@''GNULIBHEADERS_OVERRIDE_CHAR16_T''@|$(GNULIBHEADERS_OVERRIDE_CHAR16_T)|g' \ + -e 's|@''GNULIBHEADERS_OVERRIDE_CHAR32_T''@|$(GNULIBHEADERS_OVERRIDE_CHAR32_T)|g' \ + -e 's/@''GNULIB_BTOC32''@/$(GL_GNULIB_BTOC32)/g' \ + -e 's/@''GNULIB_BTOWC''@/$(GL_GNULIB_BTOWC)/g' \ + -e 's/@''GNULIB_C32ISALNUM''@/$(GL_GNULIB_C32ISALNUM)/g' \ + -e 's/@''GNULIB_C32ISALPHA''@/$(GL_GNULIB_C32ISALPHA)/g' \ + -e 's/@''GNULIB_C32ISBLANK''@/$(GL_GNULIB_C32ISBLANK)/g' \ + -e 's/@''GNULIB_C32ISCNTRL''@/$(GL_GNULIB_C32ISCNTRL)/g' \ + -e 's/@''GNULIB_C32ISDIGIT''@/$(GL_GNULIB_C32ISDIGIT)/g' \ + -e 's/@''GNULIB_C32ISGRAPH''@/$(GL_GNULIB_C32ISGRAPH)/g' \ + -e 's/@''GNULIB_C32ISLOWER''@/$(GL_GNULIB_C32ISLOWER)/g' \ + -e 's/@''GNULIB_C32ISPRINT''@/$(GL_GNULIB_C32ISPRINT)/g' \ + -e 's/@''GNULIB_C32ISPUNCT''@/$(GL_GNULIB_C32ISPUNCT)/g' \ + -e 's/@''GNULIB_C32ISSPACE''@/$(GL_GNULIB_C32ISSPACE)/g' \ + -e 's/@''GNULIB_C32ISUPPER''@/$(GL_GNULIB_C32ISUPPER)/g' \ + -e 's/@''GNULIB_C32ISXDIGIT''@/$(GL_GNULIB_C32ISXDIGIT)/g' \ + -e 's/@''GNULIB_C32TOLOWER''@/$(GL_GNULIB_C32TOLOWER)/g' \ + -e 's/@''GNULIB_C32TOUPPER''@/$(GL_GNULIB_C32TOUPPER)/g' \ + -e 's/@''GNULIB_C32WIDTH''@/$(GL_GNULIB_C32WIDTH)/g' \ + -e 's/@''GNULIB_C32RTOMB''@/$(GL_GNULIB_C32RTOMB)/g' \ + -e 's/@''GNULIB_C32SNRTOMBS''@/$(GL_GNULIB_C32SNRTOMBS)/g' \ + -e 's/@''GNULIB_C32SRTOMBS''@/$(GL_GNULIB_C32SRTOMBS)/g' \ + -e 's/@''GNULIB_C32STOMBS''@/$(GL_GNULIB_C32STOMBS)/g' \ + -e 's/@''GNULIB_C32SWIDTH''@/$(GL_GNULIB_C32SWIDTH)/g' \ + -e 's/@''GNULIB_C32TOB''@/$(GL_GNULIB_C32TOB)/g' \ + -e 's/@''GNULIB_C32_APPLY_MAPPING''@/$(GL_GNULIB_C32_APPLY_MAPPING)/g' \ + -e 's/@''GNULIB_C32_APPLY_TYPE_TEST''@/$(GL_GNULIB_C32_APPLY_TYPE_TEST)/g' \ + -e 's/@''GNULIB_C32_GET_MAPPING''@/$(GL_GNULIB_C32_GET_MAPPING)/g' \ + -e 's/@''GNULIB_C32_GET_TYPE_TEST''@/$(GL_GNULIB_C32_GET_TYPE_TEST)/g' \ + -e 's/@''GNULIB_ISWCTYPE''@/$(GL_GNULIB_ISWCTYPE)/g' \ + -e 's/@''GNULIB_ISWDIGIT''@/$(GL_GNULIB_ISWDIGIT)/g' \ + -e 's/@''GNULIB_ISWXDIGIT''@/$(GL_GNULIB_ISWXDIGIT)/g' \ + -e 's/@''GNULIB_MBRTOC16''@/$(GL_GNULIB_MBRTOC16)/g' \ + -e 's/@''GNULIB_MBRTOC32''@/$(GL_GNULIB_MBRTOC32)/g' \ + -e 's/@''GNULIB_MBSNRTOC32S''@/$(GL_GNULIB_MBSNRTOC32S)/g' \ + -e 's/@''GNULIB_MBSNRTOWCS''@/$(GL_GNULIB_MBSNRTOWCS)/g' \ + -e 's/@''GNULIB_MBSRTOC32S''@/$(GL_GNULIB_MBSRTOC32S)/g' \ + -e 's/@''GNULIB_MBSRTOWCS''@/$(GL_GNULIB_MBSRTOWCS)/g' \ + -e 's/@''GNULIB_MBSTOC32S''@/$(GL_GNULIB_MBSTOC32S)/g' \ + -e 's/@''GNULIB_TOWCTRANS''@/$(GL_GNULIB_TOWCTRANS)/g' \ + -e 's/@''GNULIB_WCSNRTOMBS''@/$(GL_GNULIB_WCSNRTOMBS)/g' \ + -e 's/@''GNULIB_WCSRTOMBS''@/$(GL_GNULIB_WCSRTOMBS)/g' \ + -e 's/@''GNULIB_WCSWIDTH''@/$(GL_GNULIB_WCSWIDTH)/g' \ + -e 's/@''GNULIB_WCTOB''@/$(GL_GNULIB_WCTOB)/g' \ + -e 's/@''GNULIB_WCTRANS''@/$(GL_GNULIB_WCTRANS)/g' \ + -e 's/@''GNULIB_WCTYPE''@/$(GL_GNULIB_WCTYPE)/g' \ + -e 's/@''GNULIB_WCWIDTH''@/$(GL_GNULIB_WCWIDTH)/g' \ + -e 's|@''HAVE_C32RTOMB''@|$(HAVE_C32RTOMB)|g' \ + -e 's|@''HAVE_MBRTOC16''@|$(HAVE_MBRTOC16)|g' \ + -e 's|@''HAVE_MBRTOC32''@|$(HAVE_MBRTOC32)|g' \ + -e 's|@''REPLACE_C32RTOMB''@|$(REPLACE_C32RTOMB)|g' \ + -e 's|@''REPLACE_MBRTOC16''@|$(REPLACE_MBRTOC16)|g' \ + -e 's|@''REPLACE_MBRTOC32''@|$(REPLACE_MBRTOC32)|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)/uchar.in.h > $@-t + $(AM_V_at)mv $@-t $@ +MOSTLYCLEANFILES += uchar.h uchar.h-t + +EXTRA_DIST += uchar.in.h + +## end gnulib module uchar + +## begin gnulib module unicase/base + +BUILT_SOURCES += $(LIBUNISTRING_UNICASE_H) + +unicase.h: unicase.in.h + $(gl_V_at)$(SED_HEADER_STDOUT) \ + -e 's|@''HAVE_UNISTRING_WOE32DLL_H''@|$(HAVE_UNISTRING_WOE32DLL_H)|g' \ + -e 's/@''GNULIB_UNICASE_EMPTY_PREFIX_CONTEXT_DLL_VARIABLE''@/$(GL_GNULIB_UNICASE_EMPTY_PREFIX_CONTEXT_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICASE_EMPTY_SUFFIX_CONTEXT_DLL_VARIABLE''@/$(GL_GNULIB_UNICASE_EMPTY_SUFFIX_CONTEXT_DLL_VARIABLE)/g' \ + $(srcdir)/unicase.in.h > $@-t + $(AM_V_at)mv $@-t $@ +MOSTLYCLEANFILES += unicase.h unicase.h-t + +EXTRA_DIST += unicase.in.h + +## end gnulib module unicase/base + +## begin gnulib module unicase/tolower + +if LIBUNISTRING_COMPILE_UNICASE_TOLOWER +libdiffutils_a_SOURCES += unicase/tolower.c +endif + +EXTRA_DIST += unicase/simple-mapping.h unicase/tolower.h + +## end gnulib module unicase/tolower + +## begin gnulib module unictype/base + +BUILT_SOURCES += $(LIBUNISTRING_UNICTYPE_H) + +unictype.h: unictype.in.h + $(gl_V_at)$(SED_HEADER_STDOUT) \ + -e 's|@''HAVE_UNISTRING_WOE32DLL_H''@|$(HAVE_UNISTRING_WOE32DLL_H)|g' \ + -e 's/@''GNULIB_UNICTYPE_CATEGORY_L_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_L_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_CATEGORY_LC_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_LC_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_CATEGORY_LU_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_LU_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_CATEGORY_LL_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_LL_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_CATEGORY_LT_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_LT_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_CATEGORY_LM_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_LM_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_CATEGORY_LO_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_LO_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_CATEGORY_M_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_M_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_CATEGORY_MN_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_MN_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_CATEGORY_MC_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_MC_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_CATEGORY_ME_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_ME_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_CATEGORY_N_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_N_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_CATEGORY_ND_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_ND_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_CATEGORY_NL_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_NL_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_CATEGORY_NO_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_NO_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_CATEGORY_P_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_P_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_CATEGORY_PC_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_PC_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_CATEGORY_PD_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_PD_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_CATEGORY_PS_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_PS_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_CATEGORY_PE_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_PE_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_CATEGORY_PI_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_PI_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_CATEGORY_PF_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_PF_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_CATEGORY_PO_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_PO_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_CATEGORY_S_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_S_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_CATEGORY_SM_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_SM_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_CATEGORY_SC_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_SC_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_CATEGORY_SK_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_SK_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_CATEGORY_SO_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_SO_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_CATEGORY_Z_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_Z_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_CATEGORY_ZS_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_ZS_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_CATEGORY_ZL_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_ZL_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_CATEGORY_ZP_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_ZP_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_CATEGORY_C_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_C_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_CATEGORY_CC_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_CC_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_CATEGORY_CF_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_CF_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_CATEGORY_CS_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_CS_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_CATEGORY_CO_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_CO_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_CATEGORY_CN_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_CN_DLL_VARIABLE)/g' \ + < $(srcdir)/unictype.in.h > $@-t1 + $(AM_V_at)sed \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_WHITE_SPACE_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_WHITE_SPACE_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_ALPHABETIC_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_ALPHABETIC_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_OTHER_ALPHABETIC_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_OTHER_ALPHABETIC_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_NOT_A_CHARACTER_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_NOT_A_CHARACTER_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_DEFAULT_IGNORABLE_CODE_POINT_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_DEFAULT_IGNORABLE_CODE_POINT_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_OTHER_DEFAULT_IGNORABLE_CODE_POINT_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_OTHER_DEFAULT_IGNORABLE_CODE_POINT_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_DEPRECATED_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_DEPRECATED_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_LOGICAL_ORDER_EXCEPTION_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_LOGICAL_ORDER_EXCEPTION_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_VARIATION_SELECTOR_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_VARIATION_SELECTOR_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_PRIVATE_USE_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_PRIVATE_USE_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_UNASSIGNED_CODE_VALUE_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_UNASSIGNED_CODE_VALUE_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_UPPERCASE_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_UPPERCASE_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_OTHER_UPPERCASE_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_OTHER_UPPERCASE_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_LOWERCASE_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_LOWERCASE_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_OTHER_LOWERCASE_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_OTHER_LOWERCASE_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_TITLECASE_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_TITLECASE_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_CASED_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_CASED_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_CASE_IGNORABLE_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_CASE_IGNORABLE_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_CHANGES_WHEN_LOWERCASED_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_CHANGES_WHEN_LOWERCASED_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_CHANGES_WHEN_UPPERCASED_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_CHANGES_WHEN_UPPERCASED_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_CHANGES_WHEN_TITLECASED_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_CHANGES_WHEN_TITLECASED_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_CHANGES_WHEN_CASEFOLDED_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_CHANGES_WHEN_CASEFOLDED_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_CHANGES_WHEN_CASEMAPPED_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_CHANGES_WHEN_CASEMAPPED_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_SOFT_DOTTED_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_SOFT_DOTTED_DLL_VARIABLE)/g' \ + < $@-t1 > $@-t2 + $(AM_V_at)sed \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_ID_START_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_ID_START_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_OTHER_ID_START_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_OTHER_ID_START_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_ID_CONTINUE_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_ID_CONTINUE_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_OTHER_ID_CONTINUE_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_OTHER_ID_CONTINUE_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_XID_START_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_XID_START_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_XID_CONTINUE_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_XID_CONTINUE_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_PATTERN_WHITE_SPACE_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_PATTERN_WHITE_SPACE_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_PATTERN_SYNTAX_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_PATTERN_SYNTAX_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_JOIN_CONTROL_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_JOIN_CONTROL_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_GRAPHEME_BASE_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_GRAPHEME_BASE_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_GRAPHEME_EXTEND_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_GRAPHEME_EXTEND_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_OTHER_GRAPHEME_EXTEND_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_OTHER_GRAPHEME_EXTEND_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_GRAPHEME_LINK_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_GRAPHEME_LINK_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_BIDI_CONTROL_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_BIDI_CONTROL_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_BIDI_LEFT_TO_RIGHT_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_BIDI_LEFT_TO_RIGHT_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_BIDI_HEBREW_RIGHT_TO_LEFT_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_BIDI_HEBREW_RIGHT_TO_LEFT_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_BIDI_ARABIC_RIGHT_TO_LEFT_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_BIDI_ARABIC_RIGHT_TO_LEFT_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_BIDI_EUROPEAN_DIGIT_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_BIDI_EUROPEAN_DIGIT_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_BIDI_EUR_NUM_SEPARATOR_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_BIDI_EUR_NUM_SEPARATOR_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_BIDI_EUR_NUM_TERMINATOR_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_BIDI_EUR_NUM_TERMINATOR_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_BIDI_ARABIC_DIGIT_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_BIDI_ARABIC_DIGIT_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_BIDI_COMMON_SEPARATOR_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_BIDI_COMMON_SEPARATOR_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_BIDI_BLOCK_SEPARATOR_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_BIDI_BLOCK_SEPARATOR_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_BIDI_SEGMENT_SEPARATOR_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_BIDI_SEGMENT_SEPARATOR_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_BIDI_WHITESPACE_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_BIDI_WHITESPACE_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_BIDI_NON_SPACING_MARK_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_BIDI_NON_SPACING_MARK_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_BIDI_BOUNDARY_NEUTRAL_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_BIDI_BOUNDARY_NEUTRAL_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_BIDI_PDF_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_BIDI_PDF_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_BIDI_EMBEDDING_OR_OVERRIDE_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_BIDI_EMBEDDING_OR_OVERRIDE_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_BIDI_OTHER_NEUTRAL_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_BIDI_OTHER_NEUTRAL_DLL_VARIABLE)/g' \ + < $@-t2 > $@-t3 + $(AM_V_at)sed \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_HEX_DIGIT_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_HEX_DIGIT_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_ASCII_HEX_DIGIT_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_ASCII_HEX_DIGIT_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_IDEOGRAPHIC_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_IDEOGRAPHIC_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_UNIFIED_IDEOGRAPH_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_UNIFIED_IDEOGRAPH_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_RADICAL_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_RADICAL_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_IDS_BINARY_OPERATOR_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_IDS_BINARY_OPERATOR_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_IDS_TRINARY_OPERATOR_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_IDS_TRINARY_OPERATOR_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_EMOJI_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_EMOJI_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_EMOJI_PRESENTATION_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_EMOJI_PRESENTATION_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_EMOJI_MODIFIER_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_EMOJI_MODIFIER_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_EMOJI_MODIFIER_BASE_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_EMOJI_MODIFIER_BASE_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_EMOJI_COMPONENT_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_EMOJI_COMPONENT_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_EXTENDED_PICTOGRAPHIC_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_EXTENDED_PICTOGRAPHIC_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_ZERO_WIDTH_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_ZERO_WIDTH_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_SPACE_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_SPACE_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_NON_BREAK_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_NON_BREAK_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_ISO_CONTROL_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_ISO_CONTROL_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_FORMAT_CONTROL_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_FORMAT_CONTROL_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_DASH_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_DASH_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_HYPHEN_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_HYPHEN_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_PUNCTUATION_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_PUNCTUATION_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_LINE_SEPARATOR_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_LINE_SEPARATOR_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_PARAGRAPH_SEPARATOR_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_PARAGRAPH_SEPARATOR_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_QUOTATION_MARK_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_QUOTATION_MARK_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_SENTENCE_TERMINAL_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_SENTENCE_TERMINAL_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_TERMINAL_PUNCTUATION_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_TERMINAL_PUNCTUATION_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_CURRENCY_SYMBOL_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_CURRENCY_SYMBOL_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_MATH_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_MATH_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_OTHER_MATH_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_OTHER_MATH_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_PAIRED_PUNCTUATION_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_PAIRED_PUNCTUATION_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_LEFT_OF_PAIR_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_LEFT_OF_PAIR_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_COMBINING_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_COMBINING_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_COMPOSITE_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_COMPOSITE_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_DECIMAL_DIGIT_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_DECIMAL_DIGIT_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_NUMERIC_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_NUMERIC_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_DIACRITIC_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_DIACRITIC_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_EXTENDER_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_EXTENDER_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_IGNORABLE_CONTROL_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_IGNORABLE_CONTROL_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNICTYPE_PROPERTY_REGIONAL_INDICATOR_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_REGIONAL_INDICATOR_DLL_VARIABLE)/g' \ + < $@-t3 > $@-t4 + $(AM_V_at)rm -f $@-t1 $@-t2 $@-t3 + $(AM_V_at)mv $@-t4 $@ +MOSTLYCLEANFILES += unictype.h unictype.h-t1 unictype.h-t2 unictype.h-t3 unictype.h-t4 + +EXTRA_DIST += unictype.in.h + +## end gnulib module unictype/base + +## begin gnulib module unictype/ctype-alnum + +if LIBUNISTRING_COMPILE_UNICTYPE_CTYPE_ALNUM +libdiffutils_a_SOURCES += unictype/ctype_alnum.c +endif + +EXTRA_DIST += unictype/bitmap.h unictype/ctype_alnum.h + +## end gnulib module unictype/ctype-alnum + +## begin gnulib module unictype/ctype-alpha + +if LIBUNISTRING_COMPILE_UNICTYPE_CTYPE_ALPHA +libdiffutils_a_SOURCES += unictype/ctype_alpha.c +endif + +EXTRA_DIST += unictype/bitmap.h unictype/ctype_alpha.h + +## end gnulib module unictype/ctype-alpha + +## begin gnulib module unictype/ctype-blank + +if LIBUNISTRING_COMPILE_UNICTYPE_CTYPE_BLANK +libdiffutils_a_SOURCES += unictype/ctype_blank.c +endif + +EXTRA_DIST += unictype/bitmap.h unictype/ctype_blank.h + +## end gnulib module unictype/ctype-blank + +## begin gnulib module unictype/ctype-cntrl + +if LIBUNISTRING_COMPILE_UNICTYPE_CTYPE_CNTRL +libdiffutils_a_SOURCES += unictype/ctype_cntrl.c +endif + +EXTRA_DIST += unictype/bitmap.h unictype/ctype_cntrl.h + +## end gnulib module unictype/ctype-cntrl + +## begin gnulib module unictype/ctype-digit + +if LIBUNISTRING_COMPILE_UNICTYPE_CTYPE_DIGIT +libdiffutils_a_SOURCES += unictype/ctype_digit.c +endif + +EXTRA_DIST += unictype/bitmap.h unictype/ctype_digit.h + +## end gnulib module unictype/ctype-digit + +## begin gnulib module unictype/ctype-graph + +if LIBUNISTRING_COMPILE_UNICTYPE_CTYPE_GRAPH +libdiffutils_a_SOURCES += unictype/ctype_graph.c +endif + +EXTRA_DIST += unictype/bitmap.h unictype/ctype_graph.h + +## end gnulib module unictype/ctype-graph + +## begin gnulib module unictype/ctype-lower + +if LIBUNISTRING_COMPILE_UNICTYPE_CTYPE_LOWER +libdiffutils_a_SOURCES += unictype/ctype_lower.c +endif + +EXTRA_DIST += unictype/bitmap.h unictype/ctype_lower.h + +## end gnulib module unictype/ctype-lower + +## begin gnulib module unictype/ctype-print + +if LIBUNISTRING_COMPILE_UNICTYPE_CTYPE_PRINT +libdiffutils_a_SOURCES += unictype/ctype_print.c +endif + +EXTRA_DIST += unictype/bitmap.h unictype/ctype_print.h + +## end gnulib module unictype/ctype-print + +## begin gnulib module unictype/ctype-punct + +if LIBUNISTRING_COMPILE_UNICTYPE_CTYPE_PUNCT +libdiffutils_a_SOURCES += unictype/ctype_punct.c +endif + +EXTRA_DIST += unictype/bitmap.h unictype/ctype_punct.h + +## end gnulib module unictype/ctype-punct + +## begin gnulib module unictype/ctype-space + +if LIBUNISTRING_COMPILE_UNICTYPE_CTYPE_SPACE +libdiffutils_a_SOURCES += unictype/ctype_space.c +endif + +EXTRA_DIST += unictype/bitmap.h unictype/ctype_space.h + +## end gnulib module unictype/ctype-space + +## begin gnulib module unictype/ctype-upper + +if LIBUNISTRING_COMPILE_UNICTYPE_CTYPE_UPPER +libdiffutils_a_SOURCES += unictype/ctype_upper.c +endif + +EXTRA_DIST += unictype/bitmap.h unictype/ctype_upper.h + +## end gnulib module unictype/ctype-upper + +## begin gnulib module unictype/ctype-xdigit + +if LIBUNISTRING_COMPILE_UNICTYPE_CTYPE_XDIGIT +libdiffutils_a_SOURCES += unictype/ctype_xdigit.c +endif + +EXTRA_DIST += unictype/bitmap.h unictype/ctype_xdigit.h + +## end gnulib module unictype/ctype-xdigit + +## begin gnulib module uninorm/base + +BUILT_SOURCES += $(LIBUNISTRING_UNINORM_H) + +uninorm.h: uninorm.in.h + $(gl_V_at)$(SED_HEADER_STDOUT) \ + -e 's|@''HAVE_UNISTRING_WOE32DLL_H''@|$(HAVE_UNISTRING_WOE32DLL_H)|g' \ + -e 's/@''GNULIB_UNINORM_NFD_DLL_VARIABLE''@/$(GL_GNULIB_UNINORM_NFD_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNINORM_NFC_DLL_VARIABLE''@/$(GL_GNULIB_UNINORM_NFC_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNINORM_NFKD_DLL_VARIABLE''@/$(GL_GNULIB_UNINORM_NFKD_DLL_VARIABLE)/g' \ + -e 's/@''GNULIB_UNINORM_NFKC_DLL_VARIABLE''@/$(GL_GNULIB_UNINORM_NFKC_DLL_VARIABLE)/g' \ + $(srcdir)/uninorm.in.h > $@-t + $(AM_V_at)mv $@-t $@ +MOSTLYCLEANFILES += uninorm.h uninorm.h-t + +EXTRA_DIST += uninorm.in.h + +## end gnulib module uninorm/base + +## begin gnulib module unistd + +BUILT_SOURCES += unistd.h +libdiffutils_a_SOURCES += unistd.c + +# We need the following in order to create an empty placeholder for +# when the system doesn't have one. +unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) + $(gl_V_at)$(SED_HEADER_STDOUT) \ + -e 's|@''GUARD_PREFIX''@|GL|g' \ + -e 's|@''HAVE_UNISTD_H''@|$(HAVE_UNISTD_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_UNISTD_H''@|$(NEXT_UNISTD_H)|g' \ + -e 's|@''WINDOWS_64_BIT_OFF_T''@|$(WINDOWS_64_BIT_OFF_T)|g' \ + -e 's/@''GNULIB_ACCESS''@/$(GL_GNULIB_ACCESS)/g' \ + -e 's/@''GNULIB_CHDIR''@/$(GL_GNULIB_CHDIR)/g' \ + -e 's/@''GNULIB_CHOWN''@/$(GL_GNULIB_CHOWN)/g' \ + -e 's/@''GNULIB_CLOSE''@/$(GL_GNULIB_CLOSE)/g' \ + -e 's/@''GNULIB_COPY_FILE_RANGE''@/$(GL_GNULIB_COPY_FILE_RANGE)/g' \ + -e 's/@''GNULIB_DUP''@/$(GL_GNULIB_DUP)/g' \ + -e 's/@''GNULIB_DUP2''@/$(GL_GNULIB_DUP2)/g' \ + -e 's/@''GNULIB_DUP3''@/$(GL_GNULIB_DUP3)/g' \ + -e 's/@''GNULIB_ENVIRON''@/$(GL_GNULIB_ENVIRON)/g' \ + -e 's/@''GNULIB_EUIDACCESS''@/$(GL_GNULIB_EUIDACCESS)/g' \ + -e 's/@''GNULIB_EXECL''@/$(GL_GNULIB_EXECL)/g' \ + -e 's/@''GNULIB_EXECLE''@/$(GL_GNULIB_EXECLE)/g' \ + -e 's/@''GNULIB_EXECLP''@/$(GL_GNULIB_EXECLP)/g' \ + -e 's/@''GNULIB_EXECV''@/$(GL_GNULIB_EXECV)/g' \ + -e 's/@''GNULIB_EXECVE''@/$(GL_GNULIB_EXECVE)/g' \ + -e 's/@''GNULIB_EXECVP''@/$(GL_GNULIB_EXECVP)/g' \ + -e 's/@''GNULIB_EXECVPE''@/$(GL_GNULIB_EXECVPE)/g' \ + -e 's/@''GNULIB_FACCESSAT''@/$(GL_GNULIB_FACCESSAT)/g' \ + -e 's/@''GNULIB_FCHDIR''@/$(GL_GNULIB_FCHDIR)/g' \ + -e 's/@''GNULIB_FCHOWNAT''@/$(GL_GNULIB_FCHOWNAT)/g' \ + -e 's/@''GNULIB_FDATASYNC''@/$(GL_GNULIB_FDATASYNC)/g' \ + -e 's/@''GNULIB_FSYNC''@/$(GL_GNULIB_FSYNC)/g' \ + -e 's/@''GNULIB_FTRUNCATE''@/$(GL_GNULIB_FTRUNCATE)/g' \ + < $(srcdir)/unistd.in.h > $@-t1 + $(AM_V_at)sed \ + -e 's/@''GNULIB_GETCWD''@/$(GL_GNULIB_GETCWD)/g' \ + -e 's/@''GNULIB_GETDOMAINNAME''@/$(GL_GNULIB_GETDOMAINNAME)/g' \ + -e 's/@''GNULIB_GETDTABLESIZE''@/$(GL_GNULIB_GETDTABLESIZE)/g' \ + -e 's/@''GNULIB_GETENTROPY''@/$(GL_GNULIB_GETENTROPY)/g' \ + -e 's/@''GNULIB_GETGROUPS''@/$(GL_GNULIB_GETGROUPS)/g' \ + -e 's/@''GNULIB_GETHOSTNAME''@/$(GL_GNULIB_GETHOSTNAME)/g' \ + -e 's/@''GNULIB_GETLOGIN''@/$(GL_GNULIB_GETLOGIN)/g' \ + -e 's/@''GNULIB_GETLOGIN_R''@/$(GL_GNULIB_GETLOGIN_R)/g' \ + -e 's/@''GNULIB_GETOPT_POSIX''@/$(GL_GNULIB_GETOPT_POSIX)/g' \ + -e 's/@''GNULIB_GETPAGESIZE''@/$(GL_GNULIB_GETPAGESIZE)/g' \ + -e 's/@''GNULIB_GETPASS''@/$(GL_GNULIB_GETPASS)/g' \ + -e 's/@''GNULIB_GETPASS_GNU''@/$(GL_GNULIB_GETPASS_GNU)/g' \ + -e 's/@''GNULIB_GETUSERSHELL''@/$(GL_GNULIB_GETUSERSHELL)/g' \ + -e 's/@''GNULIB_GROUP_MEMBER''@/$(GL_GNULIB_GROUP_MEMBER)/g' \ + -e 's/@''GNULIB_ISATTY''@/$(GL_GNULIB_ISATTY)/g' \ + -e 's/@''GNULIB_LCHOWN''@/$(GL_GNULIB_LCHOWN)/g' \ + -e 's/@''GNULIB_LINK''@/$(GL_GNULIB_LINK)/g' \ + -e 's/@''GNULIB_LINKAT''@/$(GL_GNULIB_LINKAT)/g' \ + -e 's/@''GNULIB_LSEEK''@/$(GL_GNULIB_LSEEK)/g' \ + -e 's/@''GNULIB_PIPE''@/$(GL_GNULIB_PIPE)/g' \ + -e 's/@''GNULIB_PIPE2''@/$(GL_GNULIB_PIPE2)/g' \ + -e 's/@''GNULIB_PREAD''@/$(GL_GNULIB_PREAD)/g' \ + -e 's/@''GNULIB_PWRITE''@/$(GL_GNULIB_PWRITE)/g' \ + -e 's/@''GNULIB_READ''@/$(GL_GNULIB_READ)/g' \ + -e 's/@''GNULIB_READLINK''@/$(GL_GNULIB_READLINK)/g' \ + -e 's/@''GNULIB_READLINKAT''@/$(GL_GNULIB_READLINKAT)/g' \ + -e 's/@''GNULIB_RMDIR''@/$(GL_GNULIB_RMDIR)/g' \ + -e 's/@''GNULIB_SETHOSTNAME''@/$(GL_GNULIB_SETHOSTNAME)/g' \ + -e 's/@''GNULIB_SLEEP''@/$(GL_GNULIB_SLEEP)/g' \ + -e 's/@''GNULIB_SYMLINK''@/$(GL_GNULIB_SYMLINK)/g' \ + -e 's/@''GNULIB_SYMLINKAT''@/$(GL_GNULIB_SYMLINKAT)/g' \ + -e 's/@''GNULIB_TRUNCATE''@/$(GL_GNULIB_TRUNCATE)/g' \ + -e 's/@''GNULIB_TTYNAME_R''@/$(GL_GNULIB_TTYNAME_R)/g' \ + -e 's/@''GNULIB_UNISTD_H_GETOPT''@/0$(GL_GNULIB_UNISTD_H_GETOPT)/g' \ + -e 's/@''GNULIB_UNISTD_H_NONBLOCKING''@/$(GL_GNULIB_UNISTD_H_NONBLOCKING)/g' \ + -e 's/@''GNULIB_UNISTD_H_SIGPIPE''@/$(GL_GNULIB_UNISTD_H_SIGPIPE)/g' \ + -e 's/@''GNULIB_UNLINK''@/$(GL_GNULIB_UNLINK)/g' \ + -e 's/@''GNULIB_UNLINKAT''@/$(GL_GNULIB_UNLINKAT)/g' \ + -e 's/@''GNULIB_USLEEP''@/$(GL_GNULIB_USLEEP)/g' \ + -e 's/@''GNULIB_WRITE''@/$(GL_GNULIB_WRITE)/g' \ + -e 's/@''GNULIB_MDA_ACCESS''@/$(GL_GNULIB_MDA_ACCESS)/g' \ + -e 's/@''GNULIB_MDA_CHDIR''@/$(GL_GNULIB_MDA_CHDIR)/g' \ + -e 's/@''GNULIB_MDA_CLOSE''@/$(GL_GNULIB_MDA_CLOSE)/g' \ + -e 's/@''GNULIB_MDA_DUP''@/$(GL_GNULIB_MDA_DUP)/g' \ + -e 's/@''GNULIB_MDA_DUP2''@/$(GL_GNULIB_MDA_DUP2)/g' \ + -e 's/@''GNULIB_MDA_EXECL''@/$(GL_GNULIB_MDA_EXECL)/g' \ + -e 's/@''GNULIB_MDA_EXECLE''@/$(GL_GNULIB_MDA_EXECLE)/g' \ + -e 's/@''GNULIB_MDA_EXECLP''@/$(GL_GNULIB_MDA_EXECLP)/g' \ + -e 's/@''GNULIB_MDA_EXECV''@/$(GL_GNULIB_MDA_EXECV)/g' \ + -e 's/@''GNULIB_MDA_EXECVE''@/$(GL_GNULIB_MDA_EXECVE)/g' \ + -e 's/@''GNULIB_MDA_EXECVP''@/$(GL_GNULIB_MDA_EXECVP)/g' \ + -e 's/@''GNULIB_MDA_EXECVPE''@/$(GL_GNULIB_MDA_EXECVPE)/g' \ + -e 's/@''GNULIB_MDA_GETCWD''@/$(GL_GNULIB_MDA_GETCWD)/g' \ + -e 's/@''GNULIB_MDA_GETPID''@/$(GL_GNULIB_MDA_GETPID)/g' \ + -e 's/@''GNULIB_MDA_ISATTY''@/$(GL_GNULIB_MDA_ISATTY)/g' \ + -e 's/@''GNULIB_MDA_LSEEK''@/$(GL_GNULIB_MDA_LSEEK)/g' \ + -e 's/@''GNULIB_MDA_READ''@/$(GL_GNULIB_MDA_READ)/g' \ + -e 's/@''GNULIB_MDA_RMDIR''@/$(GL_GNULIB_MDA_RMDIR)/g' \ + -e 's/@''GNULIB_MDA_SWAB''@/$(GL_GNULIB_MDA_SWAB)/g' \ + -e 's/@''GNULIB_MDA_UNLINK''@/$(GL_GNULIB_MDA_UNLINK)/g' \ + -e 's/@''GNULIB_MDA_WRITE''@/$(GL_GNULIB_MDA_WRITE)/g' \ + < $@-t1 > $@-t2 + $(AM_V_at)sed \ + -e 's|@''HAVE_CHOWN''@|$(HAVE_CHOWN)|g' \ + -e 's|@''HAVE_COPY_FILE_RANGE''@|$(HAVE_COPY_FILE_RANGE)|g' \ + -e 's|@''HAVE_DUP3''@|$(HAVE_DUP3)|g' \ + -e 's|@''HAVE_EUIDACCESS''@|$(HAVE_EUIDACCESS)|g' \ + -e 's|@''HAVE_EXECVPE''@|$(HAVE_EXECVPE)|g' \ + -e 's|@''HAVE_FACCESSAT''@|$(HAVE_FACCESSAT)|g' \ + -e 's|@''HAVE_FCHDIR''@|$(HAVE_FCHDIR)|g' \ + -e 's|@''HAVE_FCHOWNAT''@|$(HAVE_FCHOWNAT)|g' \ + -e 's|@''HAVE_FDATASYNC''@|$(HAVE_FDATASYNC)|g' \ + -e 's|@''HAVE_FSYNC''@|$(HAVE_FSYNC)|g' \ + -e 's|@''HAVE_FTRUNCATE''@|$(HAVE_FTRUNCATE)|g' \ + -e 's|@''HAVE_GETDTABLESIZE''@|$(HAVE_GETDTABLESIZE)|g' \ + -e 's|@''HAVE_GETENTROPY''@|$(HAVE_GETENTROPY)|g' \ + -e 's|@''HAVE_GETGROUPS''@|$(HAVE_GETGROUPS)|g' \ + -e 's|@''HAVE_GETHOSTNAME''@|$(HAVE_GETHOSTNAME)|g' \ + -e 's|@''HAVE_GETPAGESIZE''@|$(HAVE_GETPAGESIZE)|g' \ + -e 's|@''HAVE_GETPASS''@|$(HAVE_GETPASS)|g' \ + -e 's|@''HAVE_GROUP_MEMBER''@|$(HAVE_GROUP_MEMBER)|g' \ + -e 's|@''HAVE_LCHOWN''@|$(HAVE_LCHOWN)|g' \ + -e 's|@''HAVE_LINK''@|$(HAVE_LINK)|g' \ + -e 's|@''HAVE_LINKAT''@|$(HAVE_LINKAT)|g' \ + -e 's|@''HAVE_PIPE''@|$(HAVE_PIPE)|g' \ + -e 's|@''HAVE_PIPE2''@|$(HAVE_PIPE2)|g' \ + -e 's|@''HAVE_PREAD''@|$(HAVE_PREAD)|g' \ + -e 's|@''HAVE_PWRITE''@|$(HAVE_PWRITE)|g' \ + -e 's|@''HAVE_READLINK''@|$(HAVE_READLINK)|g' \ + -e 's|@''HAVE_READLINKAT''@|$(HAVE_READLINKAT)|g' \ + -e 's|@''HAVE_SETHOSTNAME''@|$(HAVE_SETHOSTNAME)|g' \ + -e 's|@''HAVE_SLEEP''@|$(HAVE_SLEEP)|g' \ + -e 's|@''HAVE_SYMLINK''@|$(HAVE_SYMLINK)|g' \ + -e 's|@''HAVE_SYMLINKAT''@|$(HAVE_SYMLINKAT)|g' \ + -e 's|@''HAVE_UNLINKAT''@|$(HAVE_UNLINKAT)|g' \ + -e 's|@''HAVE_USLEEP''@|$(HAVE_USLEEP)|g' \ + -e 's|@''HAVE_DECL_ENVIRON''@|$(HAVE_DECL_ENVIRON)|g' \ + -e 's|@''HAVE_DECL_EXECVPE''@|$(HAVE_DECL_EXECVPE)|g' \ + -e 's|@''HAVE_DECL_FCHDIR''@|$(HAVE_DECL_FCHDIR)|g' \ + -e 's|@''HAVE_DECL_FDATASYNC''@|$(HAVE_DECL_FDATASYNC)|g' \ + -e 's|@''HAVE_DECL_GETDOMAINNAME''@|$(HAVE_DECL_GETDOMAINNAME)|g' \ + -e 's|@''HAVE_DECL_GETLOGIN''@|$(HAVE_DECL_GETLOGIN)|g' \ + -e 's|@''HAVE_DECL_GETLOGIN_R''@|$(HAVE_DECL_GETLOGIN_R)|g' \ + -e 's|@''HAVE_DECL_GETPAGESIZE''@|$(HAVE_DECL_GETPAGESIZE)|g' \ + -e 's|@''HAVE_DECL_GETUSERSHELL''@|$(HAVE_DECL_GETUSERSHELL)|g' \ + -e 's|@''HAVE_DECL_SETHOSTNAME''@|$(HAVE_DECL_SETHOSTNAME)|g' \ + -e 's|@''HAVE_DECL_TRUNCATE''@|$(HAVE_DECL_TRUNCATE)|g' \ + -e 's|@''HAVE_DECL_TTYNAME_R''@|$(HAVE_DECL_TTYNAME_R)|g' \ + -e 's|@''HAVE_OS_H''@|$(HAVE_OS_H)|g' \ + -e 's|@''HAVE_SYS_PARAM_H''@|$(HAVE_SYS_PARAM_H)|g' \ + < $@-t2 > $@-t3 + $(AM_V_at)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_COPY_FILE_RANGE''@|$(REPLACE_COPY_FILE_RANGE)|g' \ + -e 's|@''REPLACE_DUP''@|$(REPLACE_DUP)|g' \ + -e 's|@''REPLACE_DUP2''@|$(REPLACE_DUP2)|g' \ + -e 's|@''REPLACE_DUP3''@|$(REPLACE_DUP3)|g' \ + -e 's|@''REPLACE_EXECL''@|$(REPLACE_EXECL)|g' \ + -e 's|@''REPLACE_EXECLE''@|$(REPLACE_EXECLE)|g' \ + -e 's|@''REPLACE_EXECLP''@|$(REPLACE_EXECLP)|g' \ + -e 's|@''REPLACE_EXECV''@|$(REPLACE_EXECV)|g' \ + -e 's|@''REPLACE_EXECVE''@|$(REPLACE_EXECVE)|g' \ + -e 's|@''REPLACE_EXECVP''@|$(REPLACE_EXECVP)|g' \ + -e 's|@''REPLACE_EXECVPE''@|$(REPLACE_EXECVPE)|g' \ + -e 's|@''REPLACE_FACCESSAT''@|$(REPLACE_FACCESSAT)|g' \ + -e 's|@''REPLACE_FCHDIR''@|$(REPLACE_FCHDIR)|g' \ + -e 's|@''REPLACE_FCHOWNAT''@|$(REPLACE_FCHOWNAT)|g' \ + -e 's|@''REPLACE_FDATASYNC''@|$(REPLACE_FDATASYNC)|g' \ + -e 's|@''REPLACE_FTRUNCATE''@|$(REPLACE_FTRUNCATE)|g' \ + -e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \ + -e 's|@''REPLACE_GETDOMAINNAME''@|$(REPLACE_GETDOMAINNAME)|g' \ + -e 's|@''REPLACE_GETDTABLESIZE''@|$(REPLACE_GETDTABLESIZE)|g' \ + -e 's|@''REPLACE_GETENTROPY''@|$(REPLACE_GETENTROPY)|g' \ + -e 's|@''REPLACE_GETLOGIN_R''@|$(REPLACE_GETLOGIN_R)|g' \ + -e 's|@''REPLACE_GETGROUPS''@|$(REPLACE_GETGROUPS)|g' \ + -e 's|@''REPLACE_GETPAGESIZE''@|$(REPLACE_GETPAGESIZE)|g' \ + -e 's|@''REPLACE_GETPASS''@|$(REPLACE_GETPASS)|g' \ + -e 's|@''REPLACE_GETPASS_FOR_GETPASS_GNU''@|$(REPLACE_GETPASS_FOR_GETPASS_GNU)|g' \ + -e 's|@''REPLACE_ISATTY''@|$(REPLACE_ISATTY)|g' \ + -e 's|@''REPLACE_LCHOWN''@|$(REPLACE_LCHOWN)|g' \ + -e 's|@''REPLACE_LINK''@|$(REPLACE_LINK)|g' \ + -e 's|@''REPLACE_LINKAT''@|$(REPLACE_LINKAT)|g' \ + -e 's|@''REPLACE_LSEEK''@|$(REPLACE_LSEEK)|g' \ + -e 's|@''REPLACE_PIPE2''@|$(REPLACE_PIPE2)|g' \ + -e 's|@''REPLACE_PREAD''@|$(REPLACE_PREAD)|g' \ + -e 's|@''REPLACE_PWRITE''@|$(REPLACE_PWRITE)|g' \ + -e 's|@''REPLACE_READ''@|$(REPLACE_READ)|g' \ + -e 's|@''REPLACE_READLINK''@|$(REPLACE_READLINK)|g' \ + -e 's|@''REPLACE_READLINKAT''@|$(REPLACE_READLINKAT)|g' \ + -e 's|@''REPLACE_RMDIR''@|$(REPLACE_RMDIR)|g' \ + -e 's|@''REPLACE_SETHOSTNAME''@|$(REPLACE_SETHOSTNAME)|g' \ + -e 's|@''REPLACE_SLEEP''@|$(REPLACE_SLEEP)|g' \ + -e 's|@''REPLACE_SYMLINK''@|$(REPLACE_SYMLINK)|g' \ + -e 's|@''REPLACE_SYMLINKAT''@|$(REPLACE_SYMLINKAT)|g' \ + -e 's|@''REPLACE_TRUNCATE''@|$(REPLACE_TRUNCATE)|g' \ + -e 's|@''REPLACE_TTYNAME_R''@|$(REPLACE_TTYNAME_R)|g' \ + -e 's|@''REPLACE_UNLINK''@|$(REPLACE_UNLINK)|g' \ + -e 's|@''REPLACE_UNLINKAT''@|$(REPLACE_UNLINKAT)|g' \ + -e 's|@''REPLACE_USLEEP''@|$(REPLACE_USLEEP)|g' \ + -e 's|@''REPLACE_WRITE''@|$(REPLACE_WRITE)|g' \ + -e 's|@''UNISTD_H_HAVE_SYS_RANDOM_H''@|$(UNISTD_H_HAVE_SYS_RANDOM_H)|g' \ + -e 's|@''UNISTD_H_HAVE_WINSOCK2_H''@|$(UNISTD_H_HAVE_WINSOCK2_H)|g' \ + -e 's|@''UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS''@|$(UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS)|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)' \ + < $@-t3 > $@-t4 + $(AM_V_at)rm -f $@-t1 $@-t2 $@-t3 + $(AM_V_at)mv $@-t4 $@ +MOSTLYCLEANFILES += unistd.h unistd.h-t1 unistd.h-t2 unistd.h-t3 unistd.h-t4 + +EXTRA_DIST += unistd.in.h + +## end gnulib module unistd + +## begin gnulib module unistd-safer + +libdiffutils_a_SOURCES += dup-safer.c fd-safer.c pipe-safer.c + +EXTRA_DIST += unistd--.h unistd-safer.h + +## end gnulib module unistd-safer + +## begin gnulib module unistr/base + +BUILT_SOURCES += $(LIBUNISTRING_UNISTR_H) + +unistr.h: unistr.in.h + $(gl_V_at)$(SED_HEADER_TO_AT_t) $(srcdir)/unistr.in.h + $(AM_V_at)mv $@-t $@ +MOSTLYCLEANFILES += unistr.h unistr.h-t + +EXTRA_DIST += unistr.in.h + +## end gnulib module unistr/base + +## begin gnulib module unistr/u32-chr + +if LIBUNISTRING_COMPILE_UNISTR_U32_CHR +libdiffutils_a_SOURCES += unistr/u32-chr.c +endif + +## end gnulib module unistr/u32-chr + +## begin gnulib module unistr/u32-cpy + +if LIBUNISTRING_COMPILE_UNISTR_U32_CPY +libdiffutils_a_SOURCES += unistr/u32-cpy.c +endif + +EXTRA_DIST += unistr/u-cpy.h + +## end gnulib module unistr/u32-cpy + +## begin gnulib module unistr/u32-pcpy + +if LIBUNISTRING_COMPILE_UNISTR_U32_PCPY +libdiffutils_a_SOURCES += unistr/u32-pcpy.c +endif + +EXTRA_DIST += unistr/u-pcpy.h + +## end gnulib module unistr/u32-pcpy + +## begin gnulib module unistr/u32-strcat + +if LIBUNISTRING_COMPILE_UNISTR_U32_STRCAT +libdiffutils_a_SOURCES += unistr/u32-strcat.c +endif + +EXTRA_DIST += unistr/u-strcat.h + +## end gnulib module unistr/u32-strcat + +## begin gnulib module unistr/u32-strlen + +if LIBUNISTRING_COMPILE_UNISTR_U32_STRLEN +libdiffutils_a_SOURCES += unistr/u32-strlen.c +endif + +EXTRA_DIST += unistr/u-strlen.h + +## end gnulib module unistr/u32-strlen + +## begin gnulib module unitypes + +BUILT_SOURCES += $(LIBUNISTRING_UNITYPES_H) + +unitypes.h: unitypes.in.h + $(gl_V_at)$(SED_HEADER_TO_AT_t) $(srcdir)/unitypes.in.h + $(AM_V_at)mv $@-t $@ +MOSTLYCLEANFILES += unitypes.h unitypes.h-t + +EXTRA_DIST += unitypes.in.h + +## end gnulib module unitypes + +## begin gnulib module uniwidth/base + +BUILT_SOURCES += $(LIBUNISTRING_UNIWIDTH_H) + +uniwidth.h: uniwidth.in.h + $(gl_V_at)$(SED_HEADER_TO_AT_t) $(srcdir)/uniwidth.in.h + $(AM_V_at)mv $@-t $@ +MOSTLYCLEANFILES += uniwidth.h uniwidth.h-t + +EXTRA_DIST += localcharset.h uniwidth.in.h + +## end gnulib module uniwidth/base + +## begin gnulib module uniwidth/width + +if LIBUNISTRING_COMPILE_UNIWIDTH_WIDTH +libdiffutils_a_SOURCES += uniwidth/width.c +endif + +EXTRA_DIST += unictype/bitmap.h uniwidth/cjk.h uniwidth/width0.h uniwidth/width2.h + +## end gnulib module uniwidth/width + +## begin gnulib module unlocked-io-internal + + +EXTRA_DIST += unlocked-io.h + +## end gnulib module unlocked-io-internal + +## begin gnulib module unsetenv + +if GL_COND_OBJ_UNSETENV +libdiffutils_a_SOURCES += unsetenv.c +endif + +## end gnulib module unsetenv + +## begin gnulib module update-copyright + + +EXTRA_DIST += $(top_srcdir)/build-aux/update-copyright + +## end gnulib module update-copyright + +## begin gnulib module useless-if-before-free + + +EXTRA_DIST += $(top_srcdir)/build-aux/useless-if-before-free + +## end gnulib module useless-if-before-free + +## begin gnulib module vc-list-files + + +EXTRA_DIST += $(top_srcdir)/build-aux/vc-list-files + +## end gnulib module vc-list-files + +## begin gnulib module verify + + +EXTRA_DIST += verify.h + +## end gnulib module verify + +## begin gnulib module version-etc + +libdiffutils_a_SOURCES += version-etc.h version-etc.c + +## end gnulib module version-etc + +## begin gnulib module version-etc-fsf + +libdiffutils_a_SOURCES += version-etc-fsf.c + +## end gnulib module version-etc-fsf + +## begin gnulib module wchar + +BUILT_SOURCES += wchar.h + +# We need the following in order to create when the system +# version does not work standalone. +wchar.h: wchar.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) + $(gl_V_at)$(SED_HEADER_STDOUT) \ + -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|@''HAVE_FEATURES_H''@|$(HAVE_FEATURES_H)|g' \ + -e 's|@''NEXT_WCHAR_H''@|$(NEXT_WCHAR_H)|g' \ + -e 's|@''HAVE_WCHAR_H''@|$(HAVE_WCHAR_H)|g' \ + -e 's/@''HAVE_CRTDEFS_H''@/$(HAVE_CRTDEFS_H)/g' \ + -e 's/@''GNULIBHEADERS_OVERRIDE_WINT_T''@/$(GNULIBHEADERS_OVERRIDE_WINT_T)/g' \ + -e 's/@''GNULIB_BTOWC''@/$(GL_GNULIB_BTOWC)/g' \ + -e 's/@''GNULIB_WCTOB''@/$(GL_GNULIB_WCTOB)/g' \ + -e 's/@''GNULIB_MBSINIT''@/$(GL_GNULIB_MBSINIT)/g' \ + -e 's/@''GNULIB_MBSZERO''@/$(GL_GNULIB_MBSZERO)/g' \ + -e 's/@''GNULIB_MBRTOWC''@/$(GL_GNULIB_MBRTOWC)/g' \ + -e 's/@''GNULIB_MBRLEN''@/$(GL_GNULIB_MBRLEN)/g' \ + -e 's/@''GNULIB_MBSRTOWCS''@/$(GL_GNULIB_MBSRTOWCS)/g' \ + -e 's/@''GNULIB_MBSNRTOWCS''@/$(GL_GNULIB_MBSNRTOWCS)/g' \ + -e 's/@''GNULIB_WCRTOMB''@/$(GL_GNULIB_WCRTOMB)/g' \ + -e 's/@''GNULIB_WCSRTOMBS''@/$(GL_GNULIB_WCSRTOMBS)/g' \ + -e 's/@''GNULIB_WCSNRTOMBS''@/$(GL_GNULIB_WCSNRTOMBS)/g' \ + -e 's/@''GNULIB_WCWIDTH''@/$(GL_GNULIB_WCWIDTH)/g' \ + -e 's/@''GNULIB_WMEMCHR''@/$(GL_GNULIB_WMEMCHR)/g' \ + -e 's/@''GNULIB_WMEMCMP''@/$(GL_GNULIB_WMEMCMP)/g' \ + -e 's/@''GNULIB_WMEMCPY''@/$(GL_GNULIB_WMEMCPY)/g' \ + -e 's/@''GNULIB_WMEMMOVE''@/$(GL_GNULIB_WMEMMOVE)/g' \ + -e 's/@''GNULIB_WMEMPCPY''@/$(GL_GNULIB_WMEMPCPY)/g' \ + -e 's/@''GNULIB_WMEMSET''@/$(GL_GNULIB_WMEMSET)/g' \ + -e 's/@''GNULIB_WCSLEN''@/$(GL_GNULIB_WCSLEN)/g' \ + -e 's/@''GNULIB_WCSNLEN''@/$(GL_GNULIB_WCSNLEN)/g' \ + -e 's/@''GNULIB_WCSCPY''@/$(GL_GNULIB_WCSCPY)/g' \ + -e 's/@''GNULIB_WCPCPY''@/$(GL_GNULIB_WCPCPY)/g' \ + -e 's/@''GNULIB_WCSNCPY''@/$(GL_GNULIB_WCSNCPY)/g' \ + -e 's/@''GNULIB_WCPNCPY''@/$(GL_GNULIB_WCPNCPY)/g' \ + -e 's/@''GNULIB_WCSCAT''@/$(GL_GNULIB_WCSCAT)/g' \ + -e 's/@''GNULIB_WCSNCAT''@/$(GL_GNULIB_WCSNCAT)/g' \ + -e 's/@''GNULIB_WCSCMP''@/$(GL_GNULIB_WCSCMP)/g' \ + -e 's/@''GNULIB_WCSNCMP''@/$(GL_GNULIB_WCSNCMP)/g' \ + -e 's/@''GNULIB_WCSCASECMP''@/$(GL_GNULIB_WCSCASECMP)/g' \ + -e 's/@''GNULIB_WCSNCASECMP''@/$(GL_GNULIB_WCSNCASECMP)/g' \ + -e 's/@''GNULIB_WCSCOLL''@/$(GL_GNULIB_WCSCOLL)/g' \ + -e 's/@''GNULIB_WCSXFRM''@/$(GL_GNULIB_WCSXFRM)/g' \ + -e 's/@''GNULIB_WCSDUP''@/$(GL_GNULIB_WCSDUP)/g' \ + -e 's/@''GNULIB_WCSCHR''@/$(GL_GNULIB_WCSCHR)/g' \ + -e 's/@''GNULIB_WCSRCHR''@/$(GL_GNULIB_WCSRCHR)/g' \ + -e 's/@''GNULIB_WCSCSPN''@/$(GL_GNULIB_WCSCSPN)/g' \ + -e 's/@''GNULIB_WCSSPN''@/$(GL_GNULIB_WCSSPN)/g' \ + -e 's/@''GNULIB_WCSPBRK''@/$(GL_GNULIB_WCSPBRK)/g' \ + -e 's/@''GNULIB_WCSSTR''@/$(GL_GNULIB_WCSSTR)/g' \ + -e 's/@''GNULIB_WCSTOK''@/$(GL_GNULIB_WCSTOK)/g' \ + -e 's/@''GNULIB_WCSWIDTH''@/$(GL_GNULIB_WCSWIDTH)/g' \ + -e 's/@''GNULIB_WCSFTIME''@/$(GL_GNULIB_WCSFTIME)/g' \ + -e 's/@''GNULIB_WGETCWD''@/$(GL_GNULIB_WGETCWD)/g' \ + -e 's/@''GNULIB_MDA_WCSDUP''@/$(GL_GNULIB_MDA_WCSDUP)/g' \ + -e 's/@''GNULIB_FREE_POSIX''@/$(GL_GNULIB_FREE_POSIX)/g' \ + < $(srcdir)/wchar.in.h > $@-t1 + $(AM_V_at)sed \ + -e 's|@''HAVE_WINT_T''@|$(HAVE_WINT_T)|g' \ + -e 's|@''HAVE_BTOWC''@|$(HAVE_BTOWC)|g' \ + -e 's|@''HAVE_MBSINIT''@|$(HAVE_MBSINIT)|g' \ + -e 's|@''HAVE_MBRTOWC''@|$(HAVE_MBRTOWC)|g' \ + -e 's|@''HAVE_MBRLEN''@|$(HAVE_MBRLEN)|g' \ + -e 's|@''HAVE_MBSRTOWCS''@|$(HAVE_MBSRTOWCS)|g' \ + -e 's|@''HAVE_MBSNRTOWCS''@|$(HAVE_MBSNRTOWCS)|g' \ + -e 's|@''HAVE_WCRTOMB''@|$(HAVE_WCRTOMB)|g' \ + -e 's|@''HAVE_WCSRTOMBS''@|$(HAVE_WCSRTOMBS)|g' \ + -e 's|@''HAVE_WCSNRTOMBS''@|$(HAVE_WCSNRTOMBS)|g' \ + -e 's|@''HAVE_WMEMCHR''@|$(HAVE_WMEMCHR)|g' \ + -e 's|@''HAVE_WMEMCMP''@|$(HAVE_WMEMCMP)|g' \ + -e 's|@''HAVE_WMEMCPY''@|$(HAVE_WMEMCPY)|g' \ + -e 's|@''HAVE_WMEMMOVE''@|$(HAVE_WMEMMOVE)|g' \ + -e 's|@''HAVE_WMEMPCPY''@|$(HAVE_WMEMPCPY)|g' \ + -e 's|@''HAVE_WMEMSET''@|$(HAVE_WMEMSET)|g' \ + -e 's|@''HAVE_WCSLEN''@|$(HAVE_WCSLEN)|g' \ + -e 's|@''HAVE_WCSNLEN''@|$(HAVE_WCSNLEN)|g' \ + -e 's|@''HAVE_WCSCPY''@|$(HAVE_WCSCPY)|g' \ + -e 's|@''HAVE_WCPCPY''@|$(HAVE_WCPCPY)|g' \ + -e 's|@''HAVE_WCSNCPY''@|$(HAVE_WCSNCPY)|g' \ + -e 's|@''HAVE_WCPNCPY''@|$(HAVE_WCPNCPY)|g' \ + -e 's|@''HAVE_WCSCAT''@|$(HAVE_WCSCAT)|g' \ + -e 's|@''HAVE_WCSNCAT''@|$(HAVE_WCSNCAT)|g' \ + -e 's|@''HAVE_WCSCMP''@|$(HAVE_WCSCMP)|g' \ + -e 's|@''HAVE_WCSNCMP''@|$(HAVE_WCSNCMP)|g' \ + -e 's|@''HAVE_WCSCASECMP''@|$(HAVE_WCSCASECMP)|g' \ + -e 's|@''HAVE_WCSNCASECMP''@|$(HAVE_WCSNCASECMP)|g' \ + -e 's|@''HAVE_WCSCOLL''@|$(HAVE_WCSCOLL)|g' \ + -e 's|@''HAVE_WCSXFRM''@|$(HAVE_WCSXFRM)|g' \ + -e 's|@''HAVE_WCSDUP''@|$(HAVE_WCSDUP)|g' \ + -e 's|@''HAVE_WCSCHR''@|$(HAVE_WCSCHR)|g' \ + -e 's|@''HAVE_WCSRCHR''@|$(HAVE_WCSRCHR)|g' \ + -e 's|@''HAVE_WCSCSPN''@|$(HAVE_WCSCSPN)|g' \ + -e 's|@''HAVE_WCSSPN''@|$(HAVE_WCSSPN)|g' \ + -e 's|@''HAVE_WCSPBRK''@|$(HAVE_WCSPBRK)|g' \ + -e 's|@''HAVE_WCSSTR''@|$(HAVE_WCSSTR)|g' \ + -e 's|@''HAVE_WCSTOK''@|$(HAVE_WCSTOK)|g' \ + -e 's|@''HAVE_WCSWIDTH''@|$(HAVE_WCSWIDTH)|g' \ + -e 's|@''HAVE_WCSFTIME''@|$(HAVE_WCSFTIME)|g' \ + -e 's|@''HAVE_DECL_WCTOB''@|$(HAVE_DECL_WCTOB)|g' \ + -e 's|@''HAVE_DECL_WCSDUP''@|$(HAVE_DECL_WCSDUP)|g' \ + -e 's|@''HAVE_DECL_WCWIDTH''@|$(HAVE_DECL_WCWIDTH)|g' \ + < $@-t1 > $@-t2 + $(AM_V_at)sed \ + -e 's|@''REPLACE_MBSTATE_T''@|$(REPLACE_MBSTATE_T)|g' \ + -e 's|@''REPLACE_BTOWC''@|$(REPLACE_BTOWC)|g' \ + -e 's|@''REPLACE_WCTOB''@|$(REPLACE_WCTOB)|g' \ + -e 's|@''REPLACE_FREE''@|$(REPLACE_FREE)|g' \ + -e 's|@''REPLACE_MBSINIT''@|$(REPLACE_MBSINIT)|g' \ + -e 's|@''REPLACE_MBRTOWC''@|$(REPLACE_MBRTOWC)|g' \ + -e 's|@''REPLACE_MBRLEN''@|$(REPLACE_MBRLEN)|g' \ + -e 's|@''REPLACE_MBSRTOWCS''@|$(REPLACE_MBSRTOWCS)|g' \ + -e 's|@''REPLACE_MBSNRTOWCS''@|$(REPLACE_MBSNRTOWCS)|g' \ + -e 's|@''REPLACE_WCRTOMB''@|$(REPLACE_WCRTOMB)|g' \ + -e 's|@''REPLACE_WCSRTOMBS''@|$(REPLACE_WCSRTOMBS)|g' \ + -e 's|@''REPLACE_WCSNRTOMBS''@|$(REPLACE_WCSNRTOMBS)|g' \ + -e 's|@''REPLACE_WCWIDTH''@|$(REPLACE_WCWIDTH)|g' \ + -e 's|@''REPLACE_WCSWIDTH''@|$(REPLACE_WCSWIDTH)|g' \ + -e 's|@''REPLACE_WCSFTIME''@|$(REPLACE_WCSFTIME)|g' \ + -e 's|@''REPLACE_WCSCMP''@|$(REPLACE_WCSCMP)|g' \ + -e 's|@''REPLACE_WCSNCMP''@|$(REPLACE_WCSNCMP)|g' \ + -e 's|@''REPLACE_WCSSTR''@|$(REPLACE_WCSSTR)|g' \ + -e 's|@''REPLACE_WCSTOK''@|$(REPLACE_WCSTOK)|g' \ + -e 's|@''REPLACE_WMEMCMP''@|$(REPLACE_WMEMCMP)|g' \ + -e 's|@''REPLACE_WMEMPCPY''@|$(REPLACE_WMEMPCPY)|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)' \ + < $@-t2 > $@-t3 + $(AM_V_at)rm -f $@-t1 $@-t2 + $(AM_V_at)mv $@-t3 $@ +MOSTLYCLEANFILES += wchar.h wchar.h-t1 wchar.h-t2 wchar.h-t3 + +EXTRA_DIST += wchar.in.h + +## end gnulib module wchar + +## begin gnulib module wcrtomb + +if GL_COND_OBJ_WCRTOMB +libdiffutils_a_SOURCES += wcrtomb.c +endif + +## end gnulib module wcrtomb + +## begin gnulib module wctype + +if GL_COND_OBJ_WCTYPE +libdiffutils_a_SOURCES += wctype.c +endif + +EXTRA_DIST += wctype-impl.h + +## end gnulib module wctype + +## begin gnulib module wctype-h + +BUILT_SOURCES += wctype.h +libdiffutils_a_SOURCES += wctype-h.c + +# We need the following in order to create when the system +# doesn't have one that works with the given compiler. +wctype.h: wctype.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) + $(gl_V_at)$(SED_HEADER_STDOUT) \ + -e 's|@''GUARD_PREFIX''@|GL|g' \ + -e 's/@''HAVE_WCTYPE_H''@/$(HAVE_WCTYPE_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_WCTYPE_H''@|$(NEXT_WCTYPE_H)|g' \ + -e 's/@''HAVE_CRTDEFS_H''@/$(HAVE_CRTDEFS_H)/g' \ + -e 's/@''GNULIBHEADERS_OVERRIDE_WINT_T''@/$(GNULIBHEADERS_OVERRIDE_WINT_T)/g' \ + -e 's/@''GNULIB_ISWBLANK''@/$(GL_GNULIB_ISWBLANK)/g' \ + -e 's/@''GNULIB_ISWDIGIT''@/$(GL_GNULIB_ISWDIGIT)/g' \ + -e 's/@''GNULIB_ISWPUNCT''@/$(GL_GNULIB_ISWPUNCT)/g' \ + -e 's/@''GNULIB_ISWXDIGIT''@/$(GL_GNULIB_ISWXDIGIT)/g' \ + -e 's/@''GNULIB_WCTYPE''@/$(GL_GNULIB_WCTYPE)/g' \ + -e 's/@''GNULIB_ISWCTYPE''@/$(GL_GNULIB_ISWCTYPE)/g' \ + -e 's/@''GNULIB_WCTRANS''@/$(GL_GNULIB_WCTRANS)/g' \ + -e 's/@''GNULIB_TOWCTRANS''@/$(GL_GNULIB_TOWCTRANS)/g' \ + -e 's/@''HAVE_ISWBLANK''@/$(HAVE_ISWBLANK)/g' \ + -e 's/@''HAVE_ISWCNTRL''@/$(HAVE_ISWCNTRL)/g' \ + -e 's/@''HAVE_WCTYPE_T''@/$(HAVE_WCTYPE_T)/g' \ + -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_ISWPUNCT''@/$(REPLACE_ISWPUNCT)/g' \ + -e 's/@''REPLACE_ISWXDIGIT''@/$(REPLACE_ISWXDIGIT)/g' \ + -e 's/@''REPLACE_ISWCNTRL''@/$(REPLACE_ISWCNTRL)/g' \ + -e 's/@''REPLACE_TOWLOWER''@/$(REPLACE_TOWLOWER)/g' \ + -e 's/@''REPLACE_WCTRANS''@/$(REPLACE_WCTRANS)/g' \ + -e 's/@''REPLACE_WCTYPE''@/$(REPLACE_WCTYPE)/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)/wctype.in.h > $@-t + $(AM_V_at)mv $@-t $@ +MOSTLYCLEANFILES += wctype.h wctype.h-t + +EXTRA_DIST += wctype.in.h + +## end gnulib module wctype-h + +## begin gnulib module wcwidth + +if GL_COND_OBJ_WCWIDTH +libdiffutils_a_SOURCES += wcwidth.c +endif + +## end gnulib module wcwidth + +## begin gnulib module windows-mutex + +if GL_COND_OBJ_WINDOWS_MUTEX +libdiffutils_a_SOURCES += windows-mutex.c +endif + +EXTRA_DIST += windows-initguard.h windows-mutex.h + +## end gnulib module windows-mutex + +## begin gnulib module windows-once + +if GL_COND_OBJ_WINDOWS_ONCE +libdiffutils_a_SOURCES += windows-once.c +endif + +EXTRA_DIST += windows-once.h + +## end gnulib module windows-once + +## begin gnulib module windows-recmutex + +if GL_COND_OBJ_WINDOWS_RECMUTEX +libdiffutils_a_SOURCES += windows-recmutex.c +endif + +EXTRA_DIST += windows-initguard.h windows-recmutex.h + +## end gnulib module windows-recmutex + +## begin gnulib module windows-rwlock + +if GL_COND_OBJ_WINDOWS_RWLOCK +libdiffutils_a_SOURCES += windows-rwlock.c +endif + +EXTRA_DIST += windows-initguard.h windows-rwlock.h + +## end gnulib module windows-rwlock + +## begin gnulib module wmemchr + +if GL_COND_OBJ_WMEMCHR +libdiffutils_a_SOURCES += wmemchr.c +endif + +EXTRA_DIST += wmemchr-impl.h + +## end gnulib module wmemchr + +## begin gnulib module wmempcpy + +if GL_COND_OBJ_WMEMPCPY +libdiffutils_a_SOURCES += wmempcpy.c +endif + +## end gnulib module wmempcpy + +## begin gnulib module xalloc + +libdiffutils_a_SOURCES += xmalloc.c + +EXTRA_DIST += xalloc.h + +## end gnulib module xalloc + +## begin gnulib module xalloc-die + +libdiffutils_a_SOURCES += xalloc-die.c + +EXTRA_DIST += xalloc.h + +## end gnulib module xalloc-die + +## begin gnulib module xalloc-oversized + + +EXTRA_DIST += xalloc-oversized.h + +## end gnulib module xalloc-oversized + +## begin gnulib module xfreopen + +libdiffutils_a_SOURCES += xfreopen.c xfreopen.h + +## end gnulib module xfreopen + +## begin gnulib module xmalloca + +libdiffutils_a_SOURCES += xmalloca.c + +EXTRA_DIST += xmalloca.h + +## end gnulib module xmalloca + +## begin gnulib module xstdopen + +libdiffutils_a_SOURCES += xstdopen.c + +EXTRA_DIST += xstdopen.h + +## end gnulib module xstdopen + +## begin gnulib module xstrtoimax + +libdiffutils_a_SOURCES += xstrtoimax.c + +## end gnulib module xstrtoimax + +## begin gnulib module xstrtol + +libdiffutils_a_SOURCES += xstrtol.c xstrtoul.c + +EXTRA_DIST += xstrtol.h + +## end gnulib module xstrtol + + +mostlyclean-local: mostlyclean-generic + @for dir in '' $(MOSTLYCLEANDIRS); do \ + if test -n "$$dir" && test -d $$dir; then \ + echo "rmdir $$dir"; rmdir $$dir; \ + fi; \ + done; \ + : +distclean-local: distclean-gnulib-libobjs +distclean-gnulib-libobjs: + -rm -f @gl_LIBOBJDEPS@ +maintainer-clean-local: distclean-gnulib-libobjs diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/hard-locale.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/hard-locale.c new file mode 100644 index 00000000..653c5809 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/hard-locale.c @@ -0,0 +1,47 @@ +/* hard-locale.c -- Determine whether a locale is hard. + + Copyright (C) 1997-1999, 2002-2004, 2006-2007, 2009-2024 Free Software + Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +#include "hard-locale.h" + +#include +#include +#include + +bool +hard_locale (int category) +{ + char locale[SETLOCALE_NULL_MAX]; + + if (setlocale_null_r (category, locale, sizeof (locale))) + return false; + + if (!(strcmp (locale, "C") == 0 || strcmp (locale, "POSIX") == 0)) + return true; + +#if defined __ANDROID__ + /* On Android 5.0 or newer, it is possible to set a locale that has the same + name as the "C" locale but in fact uses UTF-8 encoding. Cf. test case 2 in + . */ + if (MB_CUR_MAX > 1) + return true; +#endif + + return false; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/hard-locale.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/hard-locale.h new file mode 100644 index 00000000..21c5c546 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/hard-locale.h @@ -0,0 +1,28 @@ +/* Determine whether a locale is hard. + + Copyright (C) 1999, 2003-2004, 2009-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef HARD_LOCALE_H_ +# define HARD_LOCALE_H_ 1 + +/* 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. + Note: This function uses the current global locale; it ignores the + per-thread locale. */ +extern bool hard_locale (int category); + +#endif /* HARD_LOCALE_H_ */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/hash.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/hash.c new file mode 100644 index 00000000..2b123be7 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/hash.c @@ -0,0 +1,1120 @@ +/* hash - hashing table processing. + + Copyright (C) 1998-2004, 2006-2007, 2009-2024 Free Software Foundation, Inc. + + Written by Jim Meyering, 1992. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* A generic hash table package. */ + +/* Define USE_OBSTACK to 1 if you want the allocator to use obstacks instead + of malloc. If you change USE_OBSTACK, you have to recompile! */ + +#include + +#include "hash.h" + +#include "bitrotate.h" +#include "xalloc-oversized.h" + +#include +#include +#include +#include + +#if USE_OBSTACK +# include "obstack.h" +# ifndef obstack_chunk_alloc +# define obstack_chunk_alloc malloc +# endif +# ifndef obstack_chunk_free +# define obstack_chunk_free free +# endif +#endif + +struct hash_entry + { + void *data; + struct hash_entry *next; + }; + +struct hash_table + { + /* The array of buckets starts at BUCKET and extends to BUCKET_LIMIT-1, + for a possibility of N_BUCKETS. Among those, N_BUCKETS_USED buckets + are not empty, there are N_ENTRIES active entries in the table. */ + struct hash_entry *bucket; + struct hash_entry const *bucket_limit; + size_t n_buckets; + size_t n_buckets_used; + size_t n_entries; + + /* Tuning arguments, kept in a physically separate structure. */ + const Hash_tuning *tuning; + + /* Three functions are given to 'hash_initialize', see the documentation + block for this function. In a word, HASHER randomizes a user entry + into a number up from 0 up to some maximum minus 1; COMPARATOR returns + true if two user entries compare equally; and DATA_FREER is the cleanup + function for a user entry. */ + Hash_hasher hasher; + Hash_comparator comparator; + Hash_data_freer data_freer; + + /* A linked list of freed struct hash_entry structs. */ + struct hash_entry *free_entry_list; + +#if USE_OBSTACK + /* Whenever obstacks are used, it is possible to allocate all overflowed + entries into a single stack, so they all can be freed in a single + operation. It is not clear if the speedup is worth the trouble. */ + struct obstack entry_stack; +#endif + }; + +/* A hash table contains many internal entries, each holding a pointer to + some user-provided data (also called a user entry). An entry indistinctly + refers to both the internal entry and its associated user entry. A user + entry contents may be hashed by a randomization function (the hashing + function, or just "hasher" for short) into a number (or "slot") between 0 + and the current table size. At each slot position in the hash table, + starts a linked chain of entries for which the user data all hash to this + slot. A bucket is the collection of all entries hashing to the same slot. + + A good "hasher" function will distribute entries rather evenly in buckets. + In the ideal case, the length of each bucket is roughly the number of + entries divided by the table size. Finding the slot for a data is usually + done in constant time by the "hasher", and the later finding of a precise + entry is linear in time with the size of the bucket. Consequently, a + larger hash table size (that is, a larger number of buckets) is prone to + yielding shorter chains, *given* the "hasher" function behaves properly. + + Long buckets slow down the lookup algorithm. One might use big hash table + sizes in hope to reduce the average length of buckets, but this might + become inordinate, as unused slots in the hash table take some space. The + best bet is to make sure you are using a good "hasher" function (beware + that those are not that easy to write! :-), and to use a table size + larger than the actual number of entries. */ + +/* If an insertion makes the ratio of nonempty buckets to table size larger + than the growth threshold (a number between 0.0 and 1.0), then increase + the table size by multiplying by the growth factor (a number greater than + 1.0). The growth threshold defaults to 0.8, and the growth factor + defaults to 1.414, meaning that the table will have doubled its size + every second time 80% of the buckets get used. */ +#define DEFAULT_GROWTH_THRESHOLD 0.8f +#define DEFAULT_GROWTH_FACTOR 1.414f + +/* If a deletion empties a bucket and causes the ratio of used buckets to + table size to become smaller than the shrink threshold (a number between + 0.0 and 1.0), then shrink the table by multiplying by the shrink factor (a + number greater than the shrink threshold but smaller than 1.0). The shrink + threshold and factor default to 0.0 and 1.0, meaning that the table never + shrinks. */ +#define DEFAULT_SHRINK_THRESHOLD 0.0f +#define DEFAULT_SHRINK_FACTOR 1.0f + +/* Use this to initialize or reset a TUNING structure to + some sensible values. */ +static const Hash_tuning default_tuning = + { + DEFAULT_SHRINK_THRESHOLD, + DEFAULT_SHRINK_FACTOR, + DEFAULT_GROWTH_THRESHOLD, + DEFAULT_GROWTH_FACTOR, + false + }; + +/* Information and lookup. */ + +size_t +hash_get_n_buckets (const Hash_table *table) +{ + return table->n_buckets; +} + +size_t +hash_get_n_buckets_used (const Hash_table *table) +{ + return table->n_buckets_used; +} + +size_t +hash_get_n_entries (const Hash_table *table) +{ + return table->n_entries; +} + +size_t +hash_get_max_bucket_length (const Hash_table *table) +{ + struct hash_entry const *bucket; + size_t max_bucket_length = 0; + + for (bucket = table->bucket; bucket < table->bucket_limit; bucket++) + { + if (bucket->data) + { + struct hash_entry const *cursor = bucket; + size_t bucket_length = 1; + + while (cursor = cursor->next, cursor) + bucket_length++; + + if (bucket_length > max_bucket_length) + max_bucket_length = bucket_length; + } + } + + return max_bucket_length; +} + +bool +hash_table_ok (const Hash_table *table) +{ + struct hash_entry const *bucket; + size_t n_buckets_used = 0; + size_t n_entries = 0; + + for (bucket = table->bucket; bucket < table->bucket_limit; bucket++) + { + if (bucket->data) + { + struct hash_entry const *cursor = bucket; + + /* Count bucket head. */ + n_buckets_used++; + n_entries++; + + /* Count bucket overflow. */ + while (cursor = cursor->next, cursor) + n_entries++; + } + } + + if (n_buckets_used == table->n_buckets_used && n_entries == table->n_entries) + return true; + + return false; +} + +void +hash_print_statistics (const Hash_table *table, FILE *stream) +{ + size_t n_entries = hash_get_n_entries (table); + size_t n_buckets = hash_get_n_buckets (table); + size_t n_buckets_used = hash_get_n_buckets_used (table); + size_t max_bucket_length = hash_get_max_bucket_length (table); + + fprintf (stream, "# entries: %lu\n", (unsigned long int) n_entries); + fprintf (stream, "# buckets: %lu\n", (unsigned long int) n_buckets); + fprintf (stream, "# buckets used: %lu (%.2f%%)\n", + (unsigned long int) n_buckets_used, + (100.0 * n_buckets_used) / n_buckets); + fprintf (stream, "max bucket length: %lu\n", + (unsigned long int) max_bucket_length); +} + +/* Hash KEY and return a pointer to the selected bucket. + If TABLE->hasher misbehaves, abort. */ +static struct hash_entry * +safe_hasher (const Hash_table *table, const void *key) +{ + size_t n = table->hasher (key, table->n_buckets); + if (! (n < table->n_buckets)) + abort (); + return table->bucket + n; +} + +void * +hash_lookup (const Hash_table *table, const void *entry) +{ + struct hash_entry const *bucket = safe_hasher (table, entry); + struct hash_entry const *cursor; + + if (bucket->data == NULL) + return NULL; + + for (cursor = bucket; cursor; cursor = cursor->next) + if (entry == cursor->data || table->comparator (entry, cursor->data)) + return cursor->data; + + return NULL; +} + +/* Walking. */ + +void * +hash_get_first (const Hash_table *table) +{ + struct hash_entry const *bucket; + + if (table->n_entries == 0) + return NULL; + + for (bucket = table->bucket; ; bucket++) + if (! (bucket < table->bucket_limit)) + abort (); + else if (bucket->data) + return bucket->data; +} + +void * +hash_get_next (const Hash_table *table, const void *entry) +{ + struct hash_entry const *bucket = safe_hasher (table, entry); + struct hash_entry const *cursor; + + /* Find next entry in the same bucket. */ + cursor = bucket; + do + { + if (cursor->data == entry && cursor->next) + return cursor->next->data; + cursor = cursor->next; + } + while (cursor != NULL); + + /* Find first entry in any subsequent bucket. */ + while (++bucket < table->bucket_limit) + if (bucket->data) + return bucket->data; + + /* None found. */ + return NULL; +} + +size_t +hash_get_entries (const Hash_table *table, void **buffer, + size_t buffer_size) +{ + size_t counter = 0; + struct hash_entry const *bucket; + struct hash_entry const *cursor; + + for (bucket = table->bucket; bucket < table->bucket_limit; bucket++) + { + if (bucket->data) + { + for (cursor = bucket; cursor; cursor = cursor->next) + { + if (counter >= buffer_size) + return counter; + buffer[counter++] = cursor->data; + } + } + } + + return counter; +} + +size_t +hash_do_for_each (const Hash_table *table, Hash_processor processor, + void *processor_data) +{ + size_t counter = 0; + struct hash_entry const *bucket; + struct hash_entry const *cursor; + + for (bucket = table->bucket; bucket < table->bucket_limit; bucket++) + { + if (bucket->data) + { + for (cursor = bucket; cursor; cursor = cursor->next) + { + if (! processor (cursor->data, processor_data)) + return counter; + counter++; + } + } + } + + return counter; +} + +/* Allocation and clean-up. */ + +#if USE_DIFF_HASH + +/* About hashings, Paul Eggert writes to me (FP), on 1994-01-01: "Please see + B. J. McKenzie, R. Harries & T. Bell, Selecting a hashing algorithm, + Software--practice & experience 20, 2 (Feb 1990), 209-224. Good hash + algorithms tend to be domain-specific, so what's good for [diffutils'] io.c + may not be good for your application." */ + +size_t +hash_string (const char *string, size_t n_buckets) +{ +# define HASH_ONE_CHAR(Value, Byte) \ + ((Byte) + rotl_sz (Value, 7)) + + size_t value = 0; + unsigned char ch; + + for (; (ch = *string); string++) + value = HASH_ONE_CHAR (value, ch); + return value % n_buckets; + +# undef HASH_ONE_CHAR +} + +#else /* not USE_DIFF_HASH */ + +/* This one comes from 'recode', and performs a bit better than the above as + per a few experiments. It is inspired from a hashing routine found in the + very old Cyber 'snoop', itself written in typical Greg Mansfield style. + (By the way, what happened to this excellent man? Is he still alive?) */ + +size_t +hash_string (const char *string, size_t n_buckets) +{ + size_t value = 0; + unsigned char ch; + + for (; (ch = *string); string++) + value = (value * 31 + ch) % n_buckets; + return value; +} + +#endif /* not USE_DIFF_HASH */ + +/* Return true if CANDIDATE is a prime number. CANDIDATE should be an odd + number at least equal to 11. */ + +static bool _GL_ATTRIBUTE_CONST +is_prime (size_t candidate) +{ + size_t divisor = 3; + size_t square = divisor * divisor; + + while (square < candidate && (candidate % divisor)) + { + divisor++; + square += 4 * divisor; + divisor++; + } + + return (candidate % divisor ? true : false); +} + +/* Round a given CANDIDATE number up to the nearest prime, and return that + prime. Primes lower than 10 are merely skipped. */ + +static size_t _GL_ATTRIBUTE_CONST +next_prime (size_t candidate) +{ + /* Skip small primes. */ + if (candidate < 10) + candidate = 10; + + /* Make it definitely odd. */ + candidate |= 1; + + while (SIZE_MAX != candidate && !is_prime (candidate)) + candidate += 2; + + return candidate; +} + +void +hash_reset_tuning (Hash_tuning *tuning) +{ + *tuning = default_tuning; +} + +/* If the user passes a NULL hasher, we hash the raw pointer. */ +static size_t +raw_hasher (const void *data, size_t n) +{ + /* When hashing unique pointers, it is often the case that they were + generated by malloc and thus have the property that the low-order + bits are 0. As this tends to give poorer performance with small + tables, we rotate the pointer value before performing division, + in an attempt to improve hash quality. */ + size_t val = rotr_sz ((size_t) data, 3); + return val % n; +} + +/* If the user passes a NULL comparator, we use pointer comparison. */ +static bool +raw_comparator (const void *a, const void *b) +{ + return a == b; +} + + +/* For the given hash TABLE, check the user supplied tuning structure for + reasonable values, and return true if there is no gross error with it. + Otherwise, definitively reset the TUNING field to some acceptable default + in the hash table (that is, the user loses the right of further modifying + tuning arguments), and return false. */ + +static bool +check_tuning (Hash_table *table) +{ + const Hash_tuning *tuning = table->tuning; + float epsilon; + if (tuning == &default_tuning) + return true; + + /* Be a bit stricter than mathematics would require, so that + rounding errors in size calculations do not cause allocations to + fail to grow or shrink as they should. The smallest allocation + is 11 (due to next_prime's algorithm), so an epsilon of 0.1 + should be good enough. */ + epsilon = 0.1f; + + if (epsilon < tuning->growth_threshold + && tuning->growth_threshold < 1 - epsilon + && 1 + epsilon < tuning->growth_factor + && 0 <= tuning->shrink_threshold + && tuning->shrink_threshold + epsilon < tuning->shrink_factor + && tuning->shrink_factor <= 1 + && tuning->shrink_threshold + epsilon < tuning->growth_threshold) + return true; + + table->tuning = &default_tuning; + return false; +} + +/* Compute the size of the bucket array for the given CANDIDATE and + TUNING, or return 0 if there is no possible way to allocate that + many entries. */ + +static size_t _GL_ATTRIBUTE_PURE +compute_bucket_size (size_t candidate, const Hash_tuning *tuning) +{ + if (!tuning->is_n_buckets) + { + float new_candidate = candidate / tuning->growth_threshold; + if ((float) SIZE_MAX <= new_candidate) + goto nomem; + candidate = new_candidate; + } + candidate = next_prime (candidate); + if (xalloc_oversized (candidate, sizeof (struct hash_entry *))) + goto nomem; + return candidate; + + nomem: + errno = ENOMEM; + return 0; +} + +Hash_table * +hash_initialize (size_t candidate, const Hash_tuning *tuning, + Hash_hasher hasher, Hash_comparator comparator, + Hash_data_freer data_freer) +{ + Hash_table *table; + + if (hasher == NULL) + hasher = raw_hasher; + if (comparator == NULL) + comparator = raw_comparator; + + table = malloc (sizeof *table); + if (table == NULL) + return NULL; + + if (!tuning) + tuning = &default_tuning; + table->tuning = tuning; + if (!check_tuning (table)) + { + /* Fail if the tuning options are invalid. This is the only occasion + when the user gets some feedback about it. Once the table is created, + if the user provides invalid tuning options, we silently revert to + using the defaults, and ignore further request to change the tuning + options. */ + errno = EINVAL; + goto fail; + } + + table->n_buckets = compute_bucket_size (candidate, tuning); + if (!table->n_buckets) + goto fail; + + table->bucket = calloc (table->n_buckets, sizeof *table->bucket); + if (table->bucket == NULL) + goto fail; + table->bucket_limit = table->bucket + table->n_buckets; + table->n_buckets_used = 0; + table->n_entries = 0; + + table->hasher = hasher; + table->comparator = comparator; + table->data_freer = data_freer; + + table->free_entry_list = NULL; +#if USE_OBSTACK + obstack_init (&table->entry_stack); +#endif + return table; + + fail: + free (table); + return NULL; +} + +void +hash_clear (Hash_table *table) +{ + struct hash_entry *bucket; + + for (bucket = table->bucket; bucket < table->bucket_limit; bucket++) + { + if (bucket->data) + { + struct hash_entry *cursor; + struct hash_entry *next; + + /* Free the bucket overflow. */ + for (cursor = bucket->next; cursor; cursor = next) + { + if (table->data_freer) + table->data_freer (cursor->data); + cursor->data = NULL; + + next = cursor->next; + /* Relinking is done one entry at a time, as it is to be expected + that overflows are either rare or short. */ + cursor->next = table->free_entry_list; + table->free_entry_list = cursor; + } + + /* Free the bucket head. */ + if (table->data_freer) + table->data_freer (bucket->data); + bucket->data = NULL; + bucket->next = NULL; + } + } + + table->n_buckets_used = 0; + table->n_entries = 0; +} + +void +hash_free (Hash_table *table) +{ + struct hash_entry *bucket; + struct hash_entry *cursor; + struct hash_entry *next; + int err = errno; + + /* Call the user data_freer function. */ + if (table->data_freer && table->n_entries) + { + for (bucket = table->bucket; bucket < table->bucket_limit; bucket++) + { + if (bucket->data) + { + for (cursor = bucket; cursor; cursor = cursor->next) + table->data_freer (cursor->data); + } + } + } + +#if USE_OBSTACK + + obstack_free (&table->entry_stack, NULL); + +#else + + /* Free all bucket overflowed entries. */ + for (bucket = table->bucket; bucket < table->bucket_limit; bucket++) + { + for (cursor = bucket->next; cursor; cursor = next) + { + next = cursor->next; + free (cursor); + } + } + + /* Also reclaim the internal list of previously freed entries. */ + for (cursor = table->free_entry_list; cursor; cursor = next) + { + next = cursor->next; + free (cursor); + } + +#endif + + /* Free the remainder of the hash table structure. */ + free (table->bucket); + free (table); + + errno = err; +} + +/* Insertion and deletion. */ + +/* Get a new hash entry for a bucket overflow, possibly by recycling a + previously freed one. If this is not possible, allocate a new one. */ + +static struct hash_entry * +allocate_entry (Hash_table *table) +{ + struct hash_entry *new; + + if (table->free_entry_list) + { + new = table->free_entry_list; + table->free_entry_list = new->next; + } + else + { +#if USE_OBSTACK + new = obstack_alloc (&table->entry_stack, sizeof *new); +#else + new = malloc (sizeof *new); +#endif + } + + return new; +} + +/* Free a hash entry which was part of some bucket overflow, + saving it for later recycling. */ + +static void +free_entry (Hash_table *table, struct hash_entry *entry) +{ + entry->data = NULL; + entry->next = table->free_entry_list; + table->free_entry_list = entry; +} + +/* This private function is used to help with insertion and deletion. When + ENTRY matches an entry in the table, return a pointer to the corresponding + user data and set *BUCKET_HEAD to the head of the selected bucket. + Otherwise, return NULL. When DELETE is true and ENTRY matches an entry in + the table, unlink the matching entry. */ + +static void * +hash_find_entry (Hash_table *table, const void *entry, + struct hash_entry **bucket_head, bool delete) +{ + struct hash_entry *bucket = safe_hasher (table, entry); + struct hash_entry *cursor; + + *bucket_head = bucket; + + /* Test for empty bucket. */ + if (bucket->data == NULL) + return NULL; + + /* See if the entry is the first in the bucket. */ + if (entry == bucket->data || table->comparator (entry, bucket->data)) + { + void *data = bucket->data; + + if (delete) + { + if (bucket->next) + { + struct hash_entry *next = bucket->next; + + /* Bump the first overflow entry into the bucket head, then save + the previous first overflow entry for later recycling. */ + *bucket = *next; + free_entry (table, next); + } + else + { + bucket->data = NULL; + } + } + + return data; + } + + /* Scan the bucket overflow. */ + for (cursor = bucket; cursor->next; cursor = cursor->next) + { + if (entry == cursor->next->data + || table->comparator (entry, cursor->next->data)) + { + void *data = cursor->next->data; + + if (delete) + { + struct hash_entry *next = cursor->next; + + /* Unlink the entry to delete, then save the freed entry for later + recycling. */ + cursor->next = next->next; + free_entry (table, next); + } + + return data; + } + } + + /* No entry found. */ + return NULL; +} + +/* Internal helper, to move entries from SRC to DST. Both tables must + share the same free entry list. If SAFE, only move overflow + entries, saving bucket heads for later, so that no allocations will + occur. Return false (setting errno) if the free entry list is + exhausted and an allocation fails. */ + +static bool +transfer_entries (Hash_table *dst, Hash_table *src, bool safe) +{ + struct hash_entry *bucket; + struct hash_entry *cursor; + struct hash_entry *next; + for (bucket = src->bucket; bucket < src->bucket_limit; bucket++) + if (bucket->data) + { + void *data; + struct hash_entry *new_bucket; + + /* Within each bucket, transfer overflow entries first and + then the bucket head, to minimize memory pressure. After + all, the only time we might allocate is when moving the + bucket head, but moving overflow entries first may create + free entries that can be recycled by the time we finally + get to the bucket head. */ + for (cursor = bucket->next; cursor; cursor = next) + { + data = cursor->data; + new_bucket = safe_hasher (dst, data); + + next = cursor->next; + + if (new_bucket->data) + { + /* Merely relink an existing entry, when moving from a + bucket overflow into a bucket overflow. */ + cursor->next = new_bucket->next; + new_bucket->next = cursor; + } + else + { + /* Free an existing entry, when moving from a bucket + overflow into a bucket header. */ + new_bucket->data = data; + dst->n_buckets_used++; + free_entry (dst, cursor); + } + } + /* Now move the bucket head. Be sure that if we fail due to + allocation failure that the src table is in a consistent + state. */ + data = bucket->data; + bucket->next = NULL; + if (safe) + continue; + new_bucket = safe_hasher (dst, data); + + if (new_bucket->data) + { + /* Allocate or recycle an entry, when moving from a bucket + header into a bucket overflow. */ + struct hash_entry *new_entry = allocate_entry (dst); + + if (new_entry == NULL) + return false; + + new_entry->data = data; + new_entry->next = new_bucket->next; + new_bucket->next = new_entry; + } + else + { + /* Move from one bucket header to another. */ + new_bucket->data = data; + dst->n_buckets_used++; + } + bucket->data = NULL; + src->n_buckets_used--; + } + return true; +} + +bool +hash_rehash (Hash_table *table, size_t candidate) +{ + Hash_table storage; + Hash_table *new_table; + size_t new_size = compute_bucket_size (candidate, table->tuning); + + if (!new_size) + return false; + if (new_size == table->n_buckets) + return true; + new_table = &storage; + new_table->bucket = calloc (new_size, sizeof *new_table->bucket); + if (new_table->bucket == NULL) + return false; + new_table->n_buckets = new_size; + new_table->bucket_limit = new_table->bucket + new_size; + new_table->n_buckets_used = 0; + new_table->n_entries = 0; + new_table->tuning = table->tuning; + new_table->hasher = table->hasher; + new_table->comparator = table->comparator; + new_table->data_freer = table->data_freer; + + /* In order for the transfer to successfully complete, we need + additional overflow entries when distinct buckets in the old + table collide into a common bucket in the new table. The worst + case possible is a hasher that gives a good spread with the old + size, but returns a constant with the new size; if we were to + guarantee table->n_buckets_used-1 free entries in advance, then + the transfer would be guaranteed to not allocate memory. + However, for large tables, a guarantee of no further allocation + introduces a lot of extra memory pressure, all for an unlikely + corner case (most rehashes reduce, rather than increase, the + number of overflow entries needed). So, we instead ensure that + the transfer process can be reversed if we hit a memory + allocation failure mid-transfer. */ + + /* Merely reuse the extra old space into the new table. */ +#if USE_OBSTACK + new_table->entry_stack = table->entry_stack; +#endif + new_table->free_entry_list = table->free_entry_list; + + if (transfer_entries (new_table, table, false)) + { + /* Entries transferred successfully; tie up the loose ends. */ + free (table->bucket); + table->bucket = new_table->bucket; + table->bucket_limit = new_table->bucket_limit; + table->n_buckets = new_table->n_buckets; + table->n_buckets_used = new_table->n_buckets_used; + table->free_entry_list = new_table->free_entry_list; + /* table->n_entries and table->entry_stack already hold their value. */ + return true; + } + + /* We've allocated new_table->bucket (and possibly some entries), + exhausted the free list, and moved some but not all entries into + new_table. We must undo the partial move before returning + failure. The only way to get into this situation is if new_table + uses fewer buckets than the old table, so we will reclaim some + free entries as overflows in the new table are put back into + distinct buckets in the old table. + + There are some pathological cases where a single pass through the + table requires more intermediate overflow entries than using two + passes. Two passes give worse cache performance and takes + longer, but at this point, we're already out of memory, so slow + and safe is better than failure. */ + int err = errno; + table->free_entry_list = new_table->free_entry_list; + if (! (transfer_entries (table, new_table, true) + && transfer_entries (table, new_table, false))) + abort (); + /* table->n_entries already holds its value. */ + free (new_table->bucket); + errno = err; + return false; +} + +int +hash_insert_if_absent (Hash_table *table, void const *entry, + void const **matched_ent) +{ + void *data; + struct hash_entry *bucket; + + /* The caller cannot insert a NULL entry, since hash_lookup returns NULL + to indicate "not found", and hash_find_entry uses "bucket->data == NULL" + to indicate an empty bucket. */ + if (! entry) + abort (); + + /* If there's a matching entry already in the table, return that. */ + if ((data = hash_find_entry (table, entry, &bucket, false)) != NULL) + { + if (matched_ent) + *matched_ent = data; + return 0; + } + + /* If the growth threshold of the buckets in use has been reached, increase + the table size and rehash. There's no point in checking the number of + entries: if the hashing function is ill-conditioned, rehashing is not + likely to improve it. */ + + if (table->n_buckets_used + > table->tuning->growth_threshold * table->n_buckets) + { + /* Check more fully, before starting real work. If tuning arguments + became invalid, the second check will rely on proper defaults. */ + check_tuning (table); + if (table->n_buckets_used + > table->tuning->growth_threshold * table->n_buckets) + { + const Hash_tuning *tuning = table->tuning; + float candidate = + (tuning->is_n_buckets + ? (table->n_buckets * tuning->growth_factor) + : (table->n_buckets * tuning->growth_factor + * tuning->growth_threshold)); + + if ((float) SIZE_MAX <= candidate) + { + errno = ENOMEM; + return -1; + } + + /* If the rehash fails, arrange to return NULL. */ + if (!hash_rehash (table, candidate)) + return -1; + + /* Update the bucket we are interested in. */ + if (hash_find_entry (table, entry, &bucket, false) != NULL) + abort (); + } + } + + /* ENTRY is not matched, it should be inserted. */ + + if (bucket->data) + { + struct hash_entry *new_entry = allocate_entry (table); + + if (new_entry == NULL) + return -1; + + /* Add ENTRY in the overflow of the bucket. */ + + new_entry->data = (void *) entry; + new_entry->next = bucket->next; + bucket->next = new_entry; + table->n_entries++; + return 1; + } + + /* Add ENTRY right in the bucket head. */ + + bucket->data = (void *) entry; + table->n_entries++; + table->n_buckets_used++; + + return 1; +} + +void * +hash_insert (Hash_table *table, void const *entry) +{ + void const *matched_ent; + int err = hash_insert_if_absent (table, entry, &matched_ent); + return (err == -1 + ? NULL + : (void *) (err == 0 ? matched_ent : entry)); +} + +void * +hash_remove (Hash_table *table, const void *entry) +{ + void *data; + struct hash_entry *bucket; + + data = hash_find_entry (table, entry, &bucket, true); + if (!data) + return NULL; + + table->n_entries--; + if (!bucket->data) + { + table->n_buckets_used--; + + /* If the shrink threshold of the buckets in use has been reached, + rehash into a smaller table. */ + + if (table->n_buckets_used + < table->tuning->shrink_threshold * table->n_buckets) + { + /* Check more fully, before starting real work. If tuning arguments + became invalid, the second check will rely on proper defaults. */ + check_tuning (table); + if (table->n_buckets_used + < table->tuning->shrink_threshold * table->n_buckets) + { + const Hash_tuning *tuning = table->tuning; + size_t candidate = + (tuning->is_n_buckets + ? table->n_buckets * tuning->shrink_factor + : (table->n_buckets * tuning->shrink_factor + * tuning->growth_threshold)); + + if (!hash_rehash (table, candidate)) + { + /* Failure to allocate memory in an attempt to + shrink the table is not fatal. But since memory + is low, we can at least be kind and free any + spare entries, rather than keeping them tied up + in the free entry list. */ +#if ! USE_OBSTACK + struct hash_entry *cursor = table->free_entry_list; + struct hash_entry *next; + while (cursor) + { + next = cursor->next; + free (cursor); + cursor = next; + } + table->free_entry_list = NULL; +#endif + } + } + } + } + + return data; +} + +void * +hash_delete (Hash_table *table, const void *entry) +{ + return hash_remove (table, entry); +} + +/* Testing. */ + +#if TESTING + +void +hash_print (const Hash_table *table) +{ + struct hash_entry *bucket = (struct hash_entry *) table->bucket; + + for ( ; bucket < table->bucket_limit; bucket++) + { + struct hash_entry *cursor; + + if (bucket) + printf ("%lu:\n", (unsigned long int) (bucket - table->bucket)); + + for (cursor = bucket; cursor; cursor = cursor->next) + { + char const *s = cursor->data; + /* FIXME */ + if (s) + printf (" %s\n", s); + } + } +} + +#endif /* TESTING */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/hash.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/hash.h new file mode 100644 index 00000000..f764985f --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/hash.h @@ -0,0 +1,273 @@ +/* hash - hashing table processing. + Copyright (C) 1998-1999, 2001, 2003, 2009-2024 Free Software Foundation, + Inc. + Written by Jim Meyering , 1998. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* A generic hash table package. */ + +/* Make sure USE_OBSTACK is defined to 1 if you want the allocator to use + obstacks instead of malloc, and recompile 'hash.c' with same setting. */ + +#ifndef HASH_H_ +# define HASH_H_ + +/* This file uses _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_DEPRECATED, + _GL_ATTRIBUTE_MALLOC, _GL_ATTRIBUTE_NODISCARD, _GL_ATTRIBUTE_PURE, + _GL_ATTRIBUTE_RETURNS_NONNULL. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +# include + +# ifdef __cplusplus +extern "C" { +# endif + +struct hash_tuning + { + /* This structure is mainly used for 'hash_initialize', see the block + documentation of 'hash_reset_tuning' for more complete comments. */ + + float shrink_threshold; /* ratio of used buckets to trigger a shrink */ + float shrink_factor; /* ratio of new smaller size to original size */ + float growth_threshold; /* ratio of used buckets to trigger a growth */ + float growth_factor; /* ratio of new bigger size to original size */ + bool is_n_buckets; /* if CANDIDATE really means table size */ + }; + +typedef struct hash_tuning Hash_tuning; + +struct hash_table; + +typedef struct hash_table Hash_table; + +/* + * Information and lookup. + */ + +/* The following few functions provide information about the overall hash + table organization: the number of entries, number of buckets and maximum + length of buckets. */ + +/* Return the number of buckets in the hash table. The table size, the total + number of buckets (used plus unused), or the maximum number of slots, are + the same quantity. */ +extern size_t hash_get_n_buckets (const Hash_table *table) + _GL_ATTRIBUTE_PURE; + +/* Return the number of slots in use (non-empty buckets). */ +extern size_t hash_get_n_buckets_used (const Hash_table *table) + _GL_ATTRIBUTE_PURE; + +/* Return the number of active entries. */ +extern size_t hash_get_n_entries (const Hash_table *table) + _GL_ATTRIBUTE_PURE; + +/* Return the length of the longest chain (bucket). */ +extern size_t hash_get_max_bucket_length (const Hash_table *table) + _GL_ATTRIBUTE_PURE; + +/* Do a mild validation of a hash table, by traversing it and checking two + statistics. */ +extern bool hash_table_ok (const Hash_table *table) + _GL_ATTRIBUTE_PURE; + +extern void hash_print_statistics (const Hash_table *table, FILE *stream); + +/* If ENTRY matches an entry already in the hash table, return the + entry from the table. Otherwise, return NULL. */ +extern void *hash_lookup (const Hash_table *table, const void *entry); + +/* + * Walking. + */ + +/* The functions in this page traverse the hash table and process the + contained entries. For the traversal to work properly, the hash table + should not be resized nor modified while any particular entry is being + processed. In particular, entries should not be added, and an entry + may be removed only if there is no shrink threshold and the entry being + removed has already been passed to hash_get_next. */ + +/* Return the first data in the table, or NULL if the table is empty. */ +extern void *hash_get_first (const Hash_table *table) + _GL_ATTRIBUTE_PURE; + +/* Return the user data for the entry following ENTRY, where ENTRY has been + returned by a previous call to either 'hash_get_first' or 'hash_get_next'. + Return NULL if there are no more entries. */ +extern void *hash_get_next (const Hash_table *table, const void *entry); + +/* Fill BUFFER with pointers to active user entries in the hash table, then + return the number of pointers copied. Do not copy more than BUFFER_SIZE + pointers. */ +extern size_t hash_get_entries (const Hash_table *table, void **buffer, + size_t buffer_size); + +typedef bool (*Hash_processor) (void *entry, void *processor_data); + +/* Call a PROCESSOR function for each entry of a hash table, and return the + number of entries for which the processor function returned success. A + pointer to some PROCESSOR_DATA which will be made available to each call to + the processor function. The PROCESSOR accepts two arguments: the first is + the user entry being walked into, the second is the value of PROCESSOR_DATA + as received. The walking continue for as long as the PROCESSOR function + returns nonzero. When it returns zero, the walking is interrupted. */ +extern size_t hash_do_for_each (const Hash_table *table, + Hash_processor processor, void *processor_data); + +/* + * Allocation and clean-up. + */ + +/* Return a hash index for a NUL-terminated STRING between 0 and N_BUCKETS-1. + This is a convenience routine for constructing other hashing functions. */ +extern size_t hash_string (const char *string, size_t n_buckets) + _GL_ATTRIBUTE_PURE; + +extern void hash_reset_tuning (Hash_tuning *tuning); + +typedef size_t (*Hash_hasher) (const void *entry, size_t table_size); +typedef bool (*Hash_comparator) (const void *entry1, const void *entry2); +typedef void (*Hash_data_freer) (void *entry); + +/* Reclaim all storage associated with a hash table. If a data_freer + function has been supplied by the user when the hash table was created, + this function applies it to the data of each entry before freeing that + entry. This function preserves errno, like 'free'. */ +extern void hash_free (Hash_table *table); + +/* Allocate and return a new hash table, or NULL upon failure. The initial + number of buckets is automatically selected so as to _guarantee_ that you + may insert at least CANDIDATE different user entries before any growth of + the hash table size occurs. So, if have a reasonably tight a-priori upper + bound on the number of entries you intend to insert in the hash table, you + may save some table memory and insertion time, by specifying it here. If + the IS_N_BUCKETS field of the TUNING structure is true, the CANDIDATE + argument has its meaning changed to the wanted number of buckets. + + TUNING points to a structure of user-supplied values, in case some fine + tuning is wanted over the default behavior of the hasher. If TUNING is + NULL, the default tuning parameters are used instead. If TUNING is + provided but the values requested are out of bounds or might cause + rounding errors, return NULL. + + The user-supplied HASHER function, when not NULL, accepts two + arguments ENTRY and TABLE_SIZE. It computes, by hashing ENTRY contents, a + slot number for that entry which should be in the range 0..TABLE_SIZE-1. + This slot number is then returned. + + The user-supplied COMPARATOR function, when not NULL, accepts two + arguments pointing to user data, it then returns true for a pair of entries + that compare equal, or false otherwise. This function is internally called + on entries which are already known to hash to the same bucket index, + but which are distinct pointers. + + The user-supplied DATA_FREER function, when not NULL, may be later called + with the user data as an argument, just before the entry containing the + data gets freed. This happens from within 'hash_free' or 'hash_clear'. + You should specify this function only if you want these functions to free + all of your 'data' data. This is typically the case when your data is + simply an auxiliary struct that you have malloc'd to aggregate several + values. + + Set errno on failure; otherwise errno is unspecified. */ +_GL_ATTRIBUTE_NODISCARD +extern Hash_table *hash_initialize (size_t candidate, + const Hash_tuning *tuning, + Hash_hasher hasher, + Hash_comparator comparator, + Hash_data_freer data_freer) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC (hash_free, 1); + +/* Like hash_initialize, but invokes xalloc_die instead of returning NULL. */ +/* This function is defined by module 'xhash'. */ +_GL_ATTRIBUTE_NODISCARD +extern Hash_table *hash_xinitialize (size_t candidate, + const Hash_tuning *tuning, + Hash_hasher hasher, + Hash_comparator comparator, + Hash_data_freer data_freer) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC (hash_free, 1) + _GL_ATTRIBUTE_RETURNS_NONNULL; + +/* Make all buckets empty, placing any chained entries on the free list. + Apply the user-specified function data_freer (if any) to the data of any + affected entries. */ +extern void hash_clear (Hash_table *table); + +/* + * Insertion and deletion. + */ + +/* For an already existing hash table, change the number of buckets through + specifying CANDIDATE. The contents of the hash table are preserved. The + new number of buckets is automatically selected so as to _guarantee_ that + the table may receive at least CANDIDATE different user entries, including + those already in the table, before any other growth of the hash table size + occurs. If TUNING->IS_N_BUCKETS is true, then CANDIDATE specifies the + exact number of buckets desired. Return true iff the rehash succeeded, + false (setting errno) otherwise. */ +_GL_ATTRIBUTE_NODISCARD +extern bool hash_rehash (Hash_table *table, size_t candidate); + +/* If ENTRY matches an entry already in the hash table, return the pointer + to the entry from the table. Otherwise, insert ENTRY and return ENTRY. + Return NULL (setting errno) if the storage required for insertion + cannot be allocated. This implementation does not support + duplicate entries or insertion of NULL. */ +_GL_ATTRIBUTE_NODISCARD +extern void *hash_insert (Hash_table *table, const void *entry); + +/* Same as hash_insert, but invokes xalloc_die instead of returning NULL. */ +/* This function is defined by module 'xhash'. */ +extern void *hash_xinsert (Hash_table *table, const void *entry); + +/* Insert ENTRY into hash TABLE if there is not already a matching entry. + + Return -1 (setting errno) upon memory allocation failure. + Return 1 if insertion succeeded. + Return 0 if there is already a matching entry in the table, + and in that case, if MATCHED_ENT is non-NULL, set *MATCHED_ENT + to that entry. + + This interface is easier to use than hash_insert when you must + distinguish between the latter two cases. More importantly, + hash_insert is unusable for some types of ENTRY values. When using + hash_insert, the only way to distinguish those cases is to compare + the return value and ENTRY. That works only when you can have two + different ENTRY values that point to data that compares "equal". Thus, + when the ENTRY value is a simple scalar, you must use + hash_insert_if_absent. ENTRY must not be NULL. */ +extern int hash_insert_if_absent (Hash_table *table, const void *entry, + const void **matched_ent); + +/* If ENTRY is already in the table, remove it and return the just-deleted + data (the user may want to deallocate its storage). If ENTRY is not in the + table, don't modify the table and return NULL. */ +extern void *hash_remove (Hash_table *table, const void *entry); + +/* Same as hash_remove. This interface is deprecated. + FIXME: Remove in 2022. */ +_GL_ATTRIBUTE_DEPRECATED +extern void *hash_delete (Hash_table *table, const void *entry); + +# ifdef __cplusplus +} +# endif + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/ialloc.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/ialloc.c new file mode 100644 index 00000000..8564a15b --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/ialloc.c @@ -0,0 +1,21 @@ +/* malloc with idx_t rather than size_t + + Copyright 2021-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +#define IALLOC_INLINE _GL_EXTERN_INLINE +#include "ialloc.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/ialloc.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/ialloc.h new file mode 100644 index 00000000..2aa94ae7 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/ialloc.h @@ -0,0 +1,140 @@ +/* ialloc.h -- malloc with idx_t rather than size_t + + Copyright 2021-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef IALLOC_H_ +#define IALLOC_H_ + +/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, _GL_ATTRIBUTE_COLD, + _GL_ATTRIBUTE_MALLOC. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +#include "idx.h" + +#include +#include +#include +#if defined __CHERI_PURE_CAPABILITY__ +# include +#endif + +_GL_INLINE_HEADER_BEGIN +#ifndef IALLOC_INLINE +# define IALLOC_INLINE _GL_INLINE +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +IALLOC_INLINE void * _GL_ATTRIBUTE_COLD +_gl_alloc_nomem (void) +{ + errno = ENOMEM; + return NULL; +} + +/* imalloc (size) is like malloc (size). + It returns a non-NULL pointer to size bytes of memory. + Upon failure, it returns NULL with errno set. */ +IALLOC_INLINE +_GL_ATTRIBUTE_MALLOC /*_GL_ATTRIBUTE_DEALLOC_FREE*/ +void * +imalloc (idx_t s) +{ + return s <= SIZE_MAX ? malloc (s) : _gl_alloc_nomem (); +} + +/* irealloc (ptr, size) is like realloc (ptr, size). + It returns a non-NULL pointer to size bytes of memory. + Upon failure, it returns NULL with errno set. */ +IALLOC_INLINE +/*_GL_ATTRIBUTE_DEALLOC_FREE*/ +void * +irealloc (void *p, idx_t s) +{ + if (s <= SIZE_MAX) + { + /* Work around GNU realloc glitch by treating a zero size as if it + were 1, so that returning NULL is equivalent to failing. */ + p = realloc (p, s | !s); +#if defined __CHERI_PURE_CAPABILITY__ + if (p != NULL) + p = cheri_bounds_set (p, s); +#endif + return p; + } + else + return _gl_alloc_nomem (); +} + +/* icalloc (num, size) is like calloc (num, size). + It returns a non-NULL pointer to num * size bytes of memory. + Upon failure, it returns NULL with errno set. */ +IALLOC_INLINE +_GL_ATTRIBUTE_MALLOC /*_GL_ATTRIBUTE_DEALLOC_FREE*/ +void * +icalloc (idx_t n, idx_t s) +{ + if (SIZE_MAX < n) + { + if (s != 0) + return _gl_alloc_nomem (); + n = 0; + } + if (SIZE_MAX < s) + { + if (n != 0) + return _gl_alloc_nomem (); + s = 0; + } + return calloc (n, s); +} + +/* ireallocarray (ptr, num, size) is like reallocarray (ptr, num, size). + It returns a non-NULL pointer to num * size bytes of memory. + Upon failure, it returns NULL with errno set. */ +IALLOC_INLINE void * +ireallocarray (void *p, idx_t n, idx_t s) +{ + if (n <= SIZE_MAX && s <= SIZE_MAX) + { + /* Work around GNU reallocarray glitch by treating a zero size as if + it were 1, so that returning NULL is equivalent to failing. */ + size_t nx = n; + size_t sx = s; + if (n == 0 || s == 0) + nx = sx = 1; + p = reallocarray (p, nx, sx); +#if defined __CHERI_PURE_CAPABILITY__ + if (p != NULL && (n == 0 || s == 0)) + p = cheri_bounds_set (p, 0); +#endif + return p; + } + else + return _gl_alloc_nomem (); +} + +#ifdef __cplusplus +} +#endif + +_GL_INLINE_HEADER_END + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/idx.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/idx.h new file mode 100644 index 00000000..f9ce0acd --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/idx.h @@ -0,0 +1,134 @@ +/* A type for indices and sizes. + Copyright (C) 2020-2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _IDX_H +#define _IDX_H + +/* Get ptrdiff_t. */ +#include + +/* Get PTRDIFF_MAX. */ +#include + +/* The type 'idx_t' holds an (array) index or an (object) size. + Its implementation promotes to a signed integer type, + which can hold the values + 0..2^63-1 (on 64-bit platforms) or + 0..2^31-1 (on 32-bit platforms). + + Why a signed integer type? + + * Security: Signed types can be checked for overflow via + '-fsanitize=undefined', but unsigned types cannot. + + * Comparisons without surprises: ISO C99 § 6.3.1.8 specifies a few + surprising results for comparisons, such as + + (int) -3 < (unsigned long) 7 => false + (int) -3 < (unsigned int) 7 => false + and on 32-bit machines: + (long) -3 < (unsigned int) 7 => false + + This is surprising because the natural comparison order is by + value in the realm of infinite-precision signed integers (ℤ). + + The best way to get rid of such surprises is to use signed types + for numerical integer values, and use unsigned types only for + bit masks and enums. + + Why not use 'size_t' directly? + + * Because 'size_t' is an unsigned type, and a signed type is better. + See above. + + Why not use 'ssize_t'? + + * 'ptrdiff_t' is more portable; it is standardized by ISO C + whereas 'ssize_t' is standardized only by POSIX. + + * 'ssize_t' is not required to be as wide as 'size_t', and some + now-obsolete POSIX platforms had 'size_t' wider than 'ssize_t'. + + * Conversely, some now-obsolete platforms had 'ptrdiff_t' wider + than 'size_t', which can be a win and conforms to POSIX. + + Won't this cause a problem with objects larger than PTRDIFF_MAX? + + * Typical modern or large platforms do not allocate such objects, + so this is not much of a problem in practice; for example, you + can safely write 'idx_t len = strlen (s);'. To port to older + small platforms where allocations larger than PTRDIFF_MAX could + in theory be a problem, you can use Gnulib's ialloc module, or + functions like ximalloc in Gnulib's xalloc module. + + Why not use 'ptrdiff_t' directly? + + * Maintainability: When reading and modifying code, it helps to know that + a certain variable cannot have negative values. For example, when you + have a loop + + int n = ...; + for (int i = 0; i < n; i++) ... + + or + + ptrdiff_t n = ...; + for (ptrdiff_t i = 0; i < n; i++) ... + + you have to ask yourself "what if n < 0?". Whereas in + + idx_t n = ...; + for (idx_t i = 0; i < n; i++) ... + + you know that this case cannot happen. + + Similarly, when a programmer writes + + idx_t = ptr2 - ptr1; + + there is an implied assertion that ptr1 and ptr2 point into the same + object and that ptr1 <= ptr2. + + * Being future-proof: In the future, range types (integers which are + constrained to a certain range of values) may be added to C compilers + or to the C standard. Several programming languages (Ada, Haskell, + Common Lisp, Pascal) already have range types. Such range types may + help producing good code and good warnings. The type 'idx_t' could + then be typedef'ed to a range type that is signed after promotion. */ + +/* In the future, idx_t could be typedef'ed to a signed range type. + The clang "extended integer types", supported in Clang 11 or newer + , + are a special case of range types. However, these types don't support binary + operators with plain integer types (e.g. expressions such as x > 1). + Therefore, they don't behave like signed types (and not like unsigned types + either). So, we cannot use them here. */ + +/* Use the signed type 'ptrdiff_t'. */ +/* Note: ISO C does not mandate that 'size_t' and 'ptrdiff_t' have the same + size, but it is so on all platforms we have seen since 1990. */ +typedef ptrdiff_t idx_t; + +/* IDX_MAX is the maximum value of an idx_t. */ +#define IDX_MAX PTRDIFF_MAX + +/* So far no need has been found for an IDX_WIDTH macro. + Perhaps there should be another macro IDX_VALUE_BITS that does not + count the sign bit and is therefore one less than PTRDIFF_WIDTH. */ + +#endif /* _IDX_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/ignore-value.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/ignore-value.h new file mode 100644 index 00000000..de4a240c --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/ignore-value.h @@ -0,0 +1,51 @@ +/* ignore a function return without a compiler warning. -*- coding: utf-8 -*- + + Copyright (C) 2008-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Jim Meyering, Eric Blake and Pádraig Brady. */ + +/* Use "ignore_value" to avoid a warning when using a function declared with + gcc's warn_unused_result attribute, but for which you really do want to + ignore the result. Traditionally, people have used a "(void)" cast to + indicate that a function's return value is deliberately unused. However, + if the function is declared with __attribute__((warn_unused_result)), + gcc issues a warning even with the cast. + + Caution: most of the time, you really should heed gcc's warning, and + check the return value. However, in those exceptional cases in which + you're sure you know what you're doing, use this function. + + For the record, here's one of the ignorable warnings: + "copy.c:233: warning: ignoring return value of 'fchown', + declared with attribute warn_unused_result". */ + +#ifndef _GL_IGNORE_VALUE_H +#define _GL_IGNORE_VALUE_H + +/* Normally casting an expression to void discards its value, but GCC + versions 3.4 and newer have __attribute__ ((__warn_unused_result__)) + which may cause unwanted diagnostics in that case. Use __typeof__ + and __extension__ to work around the problem, if the workaround is + known to be needed. + The workaround is not needed with clang. */ +#if (3 < __GNUC__ + (4 <= __GNUC_MINOR__)) && !defined __clang__ +# define ignore_value(x) \ + (__extension__ ({ __typeof__ (x) __x = (x); (void) __x; })) +#else +# define ignore_value(x) ((void) (x)) +#endif + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/intprops-internal.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/intprops-internal.h new file mode 100644 index 00000000..c8a87d2b --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/intprops-internal.h @@ -0,0 +1,397 @@ +/* intprops-internal.h -- properties of integer types not visible to users + + Copyright (C) 2001-2024 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef _GL_INTPROPS_INTERNAL_H +#define _GL_INTPROPS_INTERNAL_H + +#include + +/* Pacify GCC 13.2 in some calls to _GL_EXPR_SIGNED. */ +#if defined __GNUC__ && 4 < __GNUC__ + (3 <= __GNUC_MINOR__) +# pragma GCC diagnostic ignored "-Wtype-limits" +#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)) + +/* Act like _GL_INT_CONVERT (E, -V) but work around a bug in IRIX 6.5 cc; see + . */ +#define _GL_INT_NEGATE_CONVERT(e, v) ((1 ? 0 : (e)) - (v)) + +/* The extra casts in the following macros work around compiler bugs, + e.g., in Cray C 5.0.3.0. */ + +/* True if the real type T is signed. */ +#define _GL_TYPE_SIGNED(t) (! ((t) 0 < (t) -1)) + +/* Return 1 if the real expression E, after promotion, has a + signed or floating type. Do not evaluate E. */ +#define _GL_EXPR_SIGNED(e) (_GL_INT_NEGATE_CONVERT (e, 1) < 0) + + +/* Minimum and maximum values for integer types and expressions. */ + +/* The width in bits of the integer type or expression T. + Do not evaluate T. T must not be a bit-field expression. + Padding bits are not supported; this is checked at compile-time below. */ +#define _GL_TYPE_WIDTH(t) (sizeof (t) * CHAR_BIT) + +/* The maximum and minimum values for the type of the expression E, + after integer promotion. E is not evaluated. */ +#define _GL_INT_MINIMUM(e) \ + (_GL_EXPR_SIGNED (e) \ + ? ~ _GL_SIGNED_INT_MAXIMUM (e) \ + : _GL_INT_CONVERT (e, 0)) +#define _GL_INT_MAXIMUM(e) \ + (_GL_EXPR_SIGNED (e) \ + ? _GL_SIGNED_INT_MAXIMUM (e) \ + : _GL_INT_NEGATE_CONVERT (e, 1)) +#define _GL_SIGNED_INT_MAXIMUM(e) \ + (((_GL_INT_CONVERT (e, 1) << (_GL_TYPE_WIDTH (+ (e)) - 2)) - 1) * 2 + 1) + +/* Work around OpenVMS incompatibility with C99. */ +#if !defined LLONG_MAX && defined __INT64_MAX +# define LLONG_MAX __INT64_MAX +# define LLONG_MIN __INT64_MIN +#endif + +/* This include file assumes that signed types are two's complement without + padding bits; the above macros have undefined behavior otherwise. + If this is a problem for you, please let us know how to fix it for your host. + This assumption is tested by the intprops-tests module. */ + +/* Does the __typeof__ keyword work? This could be done by + 'configure', but for now it's easier to do it by hand. */ +#if (2 <= __GNUC__ \ + || (4 <= __clang_major__) \ + || (1210 <= __IBMC__ && defined __IBM__TYPEOF__) \ + || (0x5110 <= __SUNPRO_C && !__STDC__)) +# define _GL_HAVE___TYPEOF__ 1 +#else +# define _GL_HAVE___TYPEOF__ 0 +#endif + +/* Return 1 if the integer type or expression T might be signed. Return 0 + if it is definitely unsigned. T must not be a bit-field expression. + This macro does not evaluate its argument, and expands to an + integer constant expression. */ +#if _GL_HAVE___TYPEOF__ +# define _GL_SIGNED_TYPE_OR_EXPR(t) _GL_TYPE_SIGNED (__typeof__ (t)) +#else +# define _GL_SIGNED_TYPE_OR_EXPR(t) 1 +#endif + +/* Return 1 if - A would overflow in [MIN,MAX] arithmetic. + A should not have side effects, and A's type should be an + integer with minimum value MIN and maximum MAX. */ +#define _GL_INT_NEGATE_RANGE_OVERFLOW(a, min, max) \ + ((min) < 0 ? (a) < - (max) : 0 < (a)) + +/* True if __builtin_add_overflow (A, B, P) and __builtin_sub_overflow + (A, B, P) work when P is non-null. */ +#ifdef __EDG__ +/* EDG-based compilers like nvc 22.1 cannot add 64-bit signed to unsigned + . */ +# define _GL_HAS_BUILTIN_ADD_OVERFLOW 0 +#elif defined __has_builtin +# define _GL_HAS_BUILTIN_ADD_OVERFLOW __has_builtin (__builtin_add_overflow) +/* __builtin_{add,sub}_overflow exists but is not reliable in GCC 5.x and 6.x, + see . */ +#elif 7 <= __GNUC__ +# define _GL_HAS_BUILTIN_ADD_OVERFLOW 1 +#else +# define _GL_HAS_BUILTIN_ADD_OVERFLOW 0 +#endif + +/* True if __builtin_mul_overflow (A, B, P) works when P is non-null. */ +#if defined __clang_major__ && __clang_major__ < 14 +/* Work around Clang bug . */ +# 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 + __builtin_sub_overflow_p and __builtin_mul_overflow_p. */ +#ifdef __EDG__ +/* In EDG-based compilers like ICC 2021.3 and earlier, + __builtin_add_overflow_p etc. are not treated as integral constant + expressions even when all arguments are. */ +# define _GL_HAS_BUILTIN_OVERFLOW_P 0 +#elif defined __has_builtin +# define _GL_HAS_BUILTIN_OVERFLOW_P __has_builtin (__builtin_mul_overflow_p) +#else +# define _GL_HAS_BUILTIN_OVERFLOW_P (7 <= __GNUC__) +#endif + +#if (!defined _GL_STDCKDINT_H && 202311 <= __STDC_VERSION__ \ + && ! (_GL_HAS_BUILTIN_ADD_OVERFLOW && _GL_HAS_BUILTIN_MUL_OVERFLOW)) +# include +#endif + +/* Store the low-order bits of A + B, A - B, A * B, respectively, into *R. + Return 1 if the result overflows. Arguments should not have side + effects and A, B and *R can be of any integer type other than char, + bool, a bit-precise integer type, or an enumeration type. */ +#if _GL_HAS_BUILTIN_ADD_OVERFLOW +# define _GL_INT_ADD_WRAPV(a, b, r) __builtin_add_overflow (a, b, r) +# define _GL_INT_SUBTRACT_WRAPV(a, b, r) __builtin_sub_overflow (a, b, r) +#elif defined ckd_add && defined ckd_sub && !defined _GL_STDCKDINT_H +# define _GL_INT_ADD_WRAPV(a, b, r) ckd_add (r, + (a), + (b)) +# define _GL_INT_SUBTRACT_WRAPV(a, b, r) ckd_sub (r, + (a), + (b)) +#else +# define _GL_INT_ADD_WRAPV(a, b, r) \ + _GL_INT_OP_WRAPV (a, b, r, +, _GL_INT_ADD_RANGE_OVERFLOW) +# define _GL_INT_SUBTRACT_WRAPV(a, b, r) \ + _GL_INT_OP_WRAPV (a, b, r, -, _GL_INT_SUBTRACT_RANGE_OVERFLOW) +#endif +#if _GL_HAS_BUILTIN_MUL_OVERFLOW +# if ((9 < __GNUC__ + (3 <= __GNUC_MINOR__) \ + || (__GNUC__ == 8 && 4 <= __GNUC_MINOR__)) \ + && !defined __EDG__) +# define _GL_INT_MULTIPLY_WRAPV(a, b, r) __builtin_mul_overflow (a, b, r) +# else + /* Work around GCC bug 91450. */ +# define _GL_INT_MULTIPLY_WRAPV(a, b, r) \ + ((!_GL_SIGNED_TYPE_OR_EXPR (*(r)) && _GL_EXPR_SIGNED (a) && _GL_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 +#elif defined ckd_mul && !defined _GL_STDCKDINT_H +# define _GL_INT_MULTIPLY_WRAPV(a, b, r) ckd_mul (r, + (a), + (b)) +#else +# define _GL_INT_MULTIPLY_WRAPV(a, b, r) \ + _GL_INT_OP_WRAPV (a, b, r, *, _GL_INT_MULTIPLY_RANGE_OVERFLOW) +#endif + +/* Nonzero if this compiler has GCC bug 68193 or Clang bug 25390. See: + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68193 + https://llvm.org/bugs/show_bug.cgi?id=25390 + For now, assume all versions of GCC-like compilers generate bogus + warnings for _Generic. This matters only for compilers that + lack relevant builtins. */ +#if __GNUC__ || defined __clang__ +# define _GL__GENERIC_BOGUS 1 +#else +# define _GL__GENERIC_BOGUS 0 +#endif + +/* Store the low-order bits of A B into *R, where OP specifies + the operation and OVERFLOW the overflow predicate. Return 1 if the + result overflows. Arguments should not have side effects, + and A, B and *R can be of any integer type other than char, bool, a + bit-precise integer type, or an enumeration type. */ +#if 201112 <= __STDC_VERSION__ && !_GL__GENERIC_BOGUS +# define _GL_INT_OP_WRAPV(a, b, r, op, overflow) \ + (_Generic \ + (*(r), \ + signed char: \ + _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \ + signed char, SCHAR_MIN, SCHAR_MAX), \ + unsigned char: \ + _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \ + unsigned char, 0, UCHAR_MAX), \ + short int: \ + _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \ + short int, SHRT_MIN, SHRT_MAX), \ + unsigned short int: \ + _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \ + unsigned short int, 0, USHRT_MAX), \ + int: \ + _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \ + int, INT_MIN, INT_MAX), \ + unsigned int: \ + _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \ + unsigned int, 0, UINT_MAX), \ + long int: \ + _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \ + long int, LONG_MIN, LONG_MAX), \ + unsigned long int: \ + _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \ + unsigned long int, 0, ULONG_MAX), \ + long long int: \ + _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \ + long long int, LLONG_MIN, LLONG_MAX), \ + unsigned long long int: \ + _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \ + unsigned long long int, 0, ULLONG_MAX))) +#else +/* Store the low-order bits of A B into *R, where OP specifies + the operation and OVERFLOW the overflow predicate. If *R is + signed, its type is ST with bounds SMIN..SMAX; otherwise its type + is UT with bounds U..UMAX. ST and UT are narrower than int. + Return 1 if the result overflows. Arguments should not have side + effects, and A, B and *R can be of any integer type other than + char, bool, a bit-precise integer type, or an enumeration type. */ +# if _GL_HAVE___TYPEOF__ +# define _GL_INT_OP_WRAPV_SMALLISH(a,b,r,op,overflow,st,smin,smax,ut,umax) \ + (_GL_TYPE_SIGNED (__typeof__ (*(r))) \ + ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, st, smin, smax) \ + : _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, ut, 0, umax)) +# else +# define _GL_INT_OP_WRAPV_SMALLISH(a,b,r,op,overflow,st,smin,smax,ut,umax) \ + (overflow (a, b, smin, smax) \ + ? (overflow (a, b, 0, umax) \ + ? (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a,b,op,unsigned,st), 1) \ + : (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a,b,op,unsigned,st)) < 0) \ + : (overflow (a, b, 0, umax) \ + ? (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a,b,op,unsigned,st)) >= 0 \ + : (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a,b,op,unsigned,st), 0))) +# endif + +# define _GL_INT_OP_WRAPV(a, b, r, op, overflow) \ + (sizeof *(r) == sizeof (signed char) \ + ? _GL_INT_OP_WRAPV_SMALLISH (a, b, r, op, overflow, \ + signed char, SCHAR_MIN, SCHAR_MAX, \ + unsigned char, UCHAR_MAX) \ + : sizeof *(r) == sizeof (short int) \ + ? _GL_INT_OP_WRAPV_SMALLISH (a, b, r, op, overflow, \ + short int, SHRT_MIN, SHRT_MAX, \ + unsigned short int, USHRT_MAX) \ + : sizeof *(r) == sizeof (int) \ + ? (_GL_EXPR_SIGNED (*(r)) \ + ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \ + int, INT_MIN, INT_MAX) \ + : _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \ + unsigned int, 0, UINT_MAX)) \ + : _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow)) +# ifdef LLONG_MAX +# define _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow) \ + (sizeof *(r) == sizeof (long int) \ + ? (_GL_EXPR_SIGNED (*(r)) \ + ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \ + long int, LONG_MIN, LONG_MAX) \ + : _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \ + unsigned long int, 0, ULONG_MAX)) \ + : (_GL_EXPR_SIGNED (*(r)) \ + ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \ + long long int, LLONG_MIN, LLONG_MAX) \ + : _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \ + unsigned long long int, 0, ULLONG_MAX))) +# else +# define _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow) \ + (_GL_EXPR_SIGNED (*(r)) \ + ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \ + long int, LONG_MIN, LONG_MAX) \ + : _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \ + unsigned long int, 0, ULONG_MAX)) +# endif +#endif + +/* Store the low-order bits of A B into *R, where the operation + is given by OP. Use the unsigned type UT for calculation to avoid + overflow problems. *R's type is T, with extrema TMIN and TMAX. + T can be any signed integer type other than char, bool, a + bit-precise integer type, or an enumeration type. + Return 1 if the result overflows. */ +#define _GL_INT_OP_CALC(a, b, r, op, overflow, ut, t, tmin, tmax) \ + (overflow (a, b, tmin, tmax) \ + ? (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a, b, op, ut, t), 1) \ + : (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a, b, op, ut, t), 0)) + +/* Return 1 if the integer expressions A - B and -A would overflow, + respectively. Arguments should not have side effects, + and can be any signed integer type other than char, bool, a + bit-precise integer type, or an enumeration type. + These macros are tuned for their last input argument being a constant. */ + +#if _GL_HAS_BUILTIN_OVERFLOW_P +# define _GL_INT_NEGATE_OVERFLOW(a) \ + __builtin_sub_overflow_p (0, a, (__typeof__ (- (a))) 0) +#else +# define _GL_INT_NEGATE_OVERFLOW(a) \ + _GL_INT_NEGATE_RANGE_OVERFLOW (a, _GL_INT_MINIMUM (a), _GL_INT_MAXIMUM (a)) +#endif + +/* Return the low-order bits of A B, where the operation is given + by OP. Use the unsigned type UT for calculation to avoid undefined + behavior on signed integer overflow, and convert the result to type T. + UT is at least as wide as T and is no narrower than unsigned int, + T is two's complement, and there is no padding or trap representations. + Assume that converting UT to T yields the low-order bits, as is + done in all known two's-complement C compilers. E.g., see: + https://gcc.gnu.org/onlinedocs/gcc/Integers-implementation.html + + According to the C standard, converting UT to T yields an + implementation-defined result or signal for values outside T's + range. However, code that works around this theoretical problem + runs afoul of a compiler bug in Oracle Studio 12.3 x86. See: + https://lists.gnu.org/r/bug-gnulib/2017-04/msg00049.html + As the compiler bug is real, don't try to work around the + theoretical problem. */ + +#define _GL_INT_OP_WRAPV_VIA_UNSIGNED(a, b, op, ut, t) \ + ((t) ((ut) (a) op (ut) (b))) + +/* Return true if the numeric values A + B, A - B, A * B fall outside + the range TMIN..TMAX. Arguments should not have side effects + and can be any integer type other than char, bool, + a bit-precise integer type, or an enumeration type. + TMIN should be signed and nonpositive. + TMAX should be positive, and should be signed unless TMIN is zero. */ +#define _GL_INT_ADD_RANGE_OVERFLOW(a, b, tmin, tmax) \ + ((b) < 0 \ + ? (((tmin) \ + ? ((_GL_EXPR_SIGNED (_GL_INT_CONVERT (a, (tmin) - (b))) || (b) < (tmin)) \ + && (a) < (tmin) - (b)) \ + : (a) <= -1 - (b)) \ + || ((_GL_EXPR_SIGNED (a) ? 0 <= (a) : (tmax) < (a)) && (tmax) < (a) + (b))) \ + : (a) < 0 \ + ? (((tmin) \ + ? ((_GL_EXPR_SIGNED (_GL_INT_CONVERT (b, (tmin) - (a))) || (a) < (tmin)) \ + && (b) < (tmin) - (a)) \ + : (b) <= -1 - (a)) \ + || ((_GL_EXPR_SIGNED (_GL_INT_CONVERT (a, b)) || (tmax) < (b)) \ + && (tmax) < (a) + (b))) \ + : (tmax) < (b) || (tmax) - (b) < (a)) +#define _GL_INT_SUBTRACT_RANGE_OVERFLOW(a, b, tmin, tmax) \ + (((a) < 0) == ((b) < 0) \ + ? ((a) < (b) \ + ? !(tmin) || -1 - (tmin) < (b) - (a) - 1 \ + : (tmax) < (a) - (b)) \ + : (a) < 0 \ + ? ((!_GL_EXPR_SIGNED (_GL_INT_CONVERT ((a) - (tmin), b)) && (a) - (tmin) < 0) \ + || (a) - (tmin) < (b)) \ + : ((! (_GL_EXPR_SIGNED (_GL_INT_CONVERT (tmax, b)) \ + && _GL_EXPR_SIGNED (_GL_INT_CONVERT ((tmax) + (b), a))) \ + && (tmax) <= -1 - (b)) \ + || (tmax) + (b) < (a))) +#define _GL_INT_MULTIPLY_RANGE_OVERFLOW(a, b, tmin, tmax) \ + ((b) < 0 \ + ? ((a) < 0 \ + ? (_GL_EXPR_SIGNED (_GL_INT_CONVERT (tmax, b)) \ + ? (a) < (tmax) / (b) \ + : ((_GL_INT_NEGATE_OVERFLOW (b) \ + ? _GL_INT_CONVERT (b, tmax) >> (_GL_TYPE_WIDTH (+ (b)) - 1) \ + : (tmax) / -(b)) \ + <= -1 - (a))) \ + : _GL_INT_NEGATE_OVERFLOW (_GL_INT_CONVERT (b, tmin)) && (b) == -1 \ + ? (_GL_EXPR_SIGNED (a) \ + ? 0 < (a) + (tmin) \ + : 0 < (a) && -1 - (tmin) < (a) - 1) \ + : (tmin) / (b) < (a)) \ + : (b) == 0 \ + ? 0 \ + : ((a) < 0 \ + ? (_GL_INT_NEGATE_OVERFLOW (_GL_INT_CONVERT (a, tmin)) && (a) == -1 \ + ? (_GL_EXPR_SIGNED (b) ? 0 < (b) + (tmin) : -1 - (tmin) < (b) - 1) \ + : (tmin) / (a) < (b)) \ + : (tmax) / (b) < (a))) + +#endif /* _GL_INTPROPS_INTERNAL_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/intprops.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/intprops.h new file mode 100644 index 00000000..43734f34 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/intprops.h @@ -0,0 +1,335 @@ +/* intprops.h -- properties of integer types + + Copyright (C) 2001-2024 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef _GL_INTPROPS_H +#define _GL_INTPROPS_H + +#include "intprops-internal.h" + +/* The extra casts in the following macros work around compiler bugs, + e.g., in Cray C 5.0.3.0. */ + +/* True if the arithmetic type T is an integer type. bool counts as + an integer. */ +#define TYPE_IS_INTEGER(t) ((t) 1.5 == 1) + +/* True if the real type T is signed. */ +#define TYPE_SIGNED(t) _GL_TYPE_SIGNED (t) + +/* Return 1 if the real expression E, after promotion, has a + signed or floating type. Do not evaluate E. */ +#define EXPR_SIGNED(e) _GL_EXPR_SIGNED (e) + + +/* Minimum and maximum values for integer types and expressions. */ + +/* The width in bits of the integer type or expression T. + Do not evaluate T. T must not be a bit-field expression. + Padding bits are not supported; this is checked at compile-time below. */ +#define TYPE_WIDTH(t) _GL_TYPE_WIDTH (t) + +/* The maximum and minimum values for the integer type T. */ +#define TYPE_MINIMUM(t) ((t) ~ TYPE_MAXIMUM (t)) +#define TYPE_MAXIMUM(t) \ + ((t) (! TYPE_SIGNED (t) \ + ? (t) -1 \ + : ((((t) 1 << (TYPE_WIDTH (t) - 2)) - 1) * 2 + 1))) + +/* Bound on length of the string representing an unsigned integer + value representable in B bits. log10 (2.0) < 146/485. The + smallest value of B where this bound is not tight is 2621. */ +#define INT_BITS_STRLEN_BOUND(b) (((b) * 146 + 484) / 485) + +/* Bound on length of the string representing an integer type or expression T. + T must not be a bit-field expression. + + Subtract 1 for the sign bit if T is signed, and then add 1 more for + a minus sign if needed. + + Because _GL_SIGNED_TYPE_OR_EXPR sometimes returns 1 when its argument is + unsigned, this macro may overestimate the true bound by one byte when + applied to unsigned types of size 2, 4, 16, ... bytes. */ +#define INT_STRLEN_BOUND(t) \ + (INT_BITS_STRLEN_BOUND (TYPE_WIDTH (t) - _GL_SIGNED_TYPE_OR_EXPR (t)) \ + + _GL_SIGNED_TYPE_OR_EXPR (t)) + +/* Bound on buffer size needed to represent an integer type or expression T, + including the terminating null. T must not be a bit-field expression. */ +#define INT_BUFSIZE_BOUND(t) (INT_STRLEN_BOUND (t) + 1) + + +/* Range overflow checks. + + The INT__RANGE_OVERFLOW macros return 1 if the corresponding C + operators overflow arithmetically when given the same arguments. + These macros do not rely on undefined or implementation-defined behavior. + Although their implementations are simple and straightforward, + they are harder to use and may be less efficient than the + INT__WRAPV, INT__OK, and INT__OVERFLOW macros described below. + + Example usage: + + long int i = ...; + long int j = ...; + if (INT_MULTIPLY_RANGE_OVERFLOW (i, j, LONG_MIN, LONG_MAX)) + printf ("multiply would overflow"); + else + printf ("product is %ld", i * j); + + Restrictions on *_RANGE_OVERFLOW macros: + + These macros do not check for all possible numerical problems or + undefined or unspecified behavior: they do not check for division + by zero, for bad shift counts, or for shifting negative numbers. + + These macros may evaluate their arguments zero or multiple times, + so the arguments should not have side effects. The arithmetic + arguments (including the MIN and MAX arguments) must be of the same + integer type after the usual arithmetic conversions, and the type + must have minimum value MIN and maximum MAX. Unsigned types should + use a zero MIN of the proper type. + + Because all arguments are subject to integer promotions, these + macros typically do not work on types narrower than 'int'. + + These macros are tuned for constant MIN and MAX. For commutative + operations such as A + B, they are also tuned for constant B. */ + +/* Return 1 if A + B would overflow in [MIN,MAX] arithmetic. + See above for restrictions. */ +#define INT_ADD_RANGE_OVERFLOW(a, b, min, max) \ + ((b) < 0 \ + ? (a) < (min) - (b) \ + : (max) - (b) < (a)) + +/* Return 1 if A - B would overflow in [MIN,MAX] arithmetic. + See above for restrictions. */ +#define INT_SUBTRACT_RANGE_OVERFLOW(a, b, min, max) \ + ((b) < 0 \ + ? (max) + (b) < (a) \ + : (a) < (min) + (b)) + +/* Return 1 if - A would overflow in [MIN,MAX] arithmetic. + See above for restrictions. */ +#define INT_NEGATE_RANGE_OVERFLOW(a, min, max) \ + _GL_INT_NEGATE_RANGE_OVERFLOW (a, min, max) + +/* Return 1 if A * B would overflow in [MIN,MAX] arithmetic. + See above for restrictions. Avoid && and || as they tickle + bugs in Sun C 5.11 2010/08/13 and other compilers; see + . */ +#define INT_MULTIPLY_RANGE_OVERFLOW(a, b, min, max) \ + ((b) < 0 \ + ? ((a) < 0 \ + ? (a) < (max) / (b) \ + : (b) == -1 \ + ? 0 \ + : (min) / (b) < (a)) \ + : (b) == 0 \ + ? 0 \ + : ((a) < 0 \ + ? (a) < (min) / (b) \ + : (max) / (b) < (a))) + +/* Return 1 if A / B would overflow in [MIN,MAX] arithmetic. + See above for restrictions. Do not check for division by zero. */ +#define INT_DIVIDE_RANGE_OVERFLOW(a, b, min, max) \ + ((min) < 0 && (b) == -1 && (a) < - (max)) + +/* Return 1 if A % B would overflow in [MIN,MAX] arithmetic. + See above for restrictions. Do not check for division by zero. + Mathematically, % should never overflow, but on x86-like hosts + INT_MIN % -1 traps, and the C standard permits this, so treat this + as an overflow too. */ +#define INT_REMAINDER_RANGE_OVERFLOW(a, b, min, max) \ + INT_DIVIDE_RANGE_OVERFLOW (a, b, min, max) + +/* Return 1 if A << B would overflow in [MIN,MAX] arithmetic. + See above for restrictions. Here, MIN and MAX are for A only, and B need + not be of the same type as the other arguments. The C standard says that + behavior is undefined for shifts unless 0 <= B < wordwidth, and that when + A is negative then A << B has undefined behavior and A >> B has + implementation-defined behavior, but do not check these other + restrictions. */ +#define INT_LEFT_SHIFT_RANGE_OVERFLOW(a, b, min, max) \ + ((a) < 0 \ + ? (a) < (min) >> (b) \ + : (max) >> (b) < (a)) + +/* The _GL*_OVERFLOW macros have the same restrictions as the + *_RANGE_OVERFLOW macros, except that they do not assume that operands + (e.g., A and B) have the same type as MIN and MAX. Instead, they assume + that the result (e.g., A + B) has that type. */ +#if _GL_HAS_BUILTIN_OVERFLOW_P +# define _GL_ADD_OVERFLOW(a, b, min, max) \ + __builtin_add_overflow_p (a, b, (__typeof__ ((a) + (b))) 0) +# define _GL_SUBTRACT_OVERFLOW(a, b, min, max) \ + __builtin_sub_overflow_p (a, b, (__typeof__ ((a) - (b))) 0) +# define _GL_MULTIPLY_OVERFLOW(a, b, min, max) \ + __builtin_mul_overflow_p (a, b, (__typeof__ ((a) * (b))) 0) +#else +# define _GL_ADD_OVERFLOW(a, b, min, max) \ + ((min) < 0 ? INT_ADD_RANGE_OVERFLOW (a, b, min, max) \ + : (a) < 0 ? (b) <= (a) + (b) \ + : (b) < 0 ? (a) <= (a) + (b) \ + : (a) + (b) < (b)) +# define _GL_SUBTRACT_OVERFLOW(a, b, min, max) \ + ((min) < 0 ? INT_SUBTRACT_RANGE_OVERFLOW (a, b, min, max) \ + : (a) < 0 ? 1 \ + : (b) < 0 ? (a) - (b) <= (a) \ + : (a) < (b)) +# define _GL_MULTIPLY_OVERFLOW(a, b, min, max) \ + (((min) == 0 && (((a) < 0 && 0 < (b)) || ((b) < 0 && 0 < (a)))) \ + || INT_MULTIPLY_RANGE_OVERFLOW (a, b, min, max)) +#endif +#define _GL_DIVIDE_OVERFLOW(a, b, min, max) \ + ((min) < 0 ? (b) == _GL_INT_NEGATE_CONVERT (min, 1) && (a) < - (max) \ + : (a) < 0 ? (b) <= (a) + (b) - 1 \ + : (b) < 0 && (a) + (b) <= (a)) +#define _GL_REMAINDER_OVERFLOW(a, b, min, max) \ + ((min) < 0 ? (b) == _GL_INT_NEGATE_CONVERT (min, 1) && (a) < - (max) \ + : (a) < 0 ? (a) % (b) != ((max) - (b) + 1) % (b) \ + : (b) < 0 && ! _GL_UNSIGNED_NEG_MULTIPLE (a, b, max)) + +/* Return a nonzero value if A is a mathematical multiple of B, where + A is unsigned, B is negative, and MAX is the maximum value of A's + type. A's type must be the same as (A % B)'s type. Normally (A % + -B == 0) suffices, but things get tricky if -B would overflow. */ +#define _GL_UNSIGNED_NEG_MULTIPLE(a, b, max) \ + (((b) < -_GL_SIGNED_INT_MAXIMUM (b) \ + ? (_GL_SIGNED_INT_MAXIMUM (b) == (max) \ + ? (a) \ + : (a) % (_GL_INT_CONVERT (a, _GL_SIGNED_INT_MAXIMUM (b)) + 1)) \ + : (a) % - (b)) \ + == 0) + +/* Check for integer overflow, and report low order bits of answer. + + The INT__OVERFLOW macros return 1 if the corresponding C operators + might not yield numerically correct answers due to arithmetic overflow. + The INT__WRAPV macros compute the low-order bits of the sum, + difference, and product of two C integers, and return 1 if these + low-order bits are not numerically correct. + These macros work correctly on all known practical hosts, and do not rely + on undefined behavior due to signed arithmetic overflow. + + Example usage, assuming A and B are long int: + + if (INT_MULTIPLY_OVERFLOW (a, b)) + printf ("result would overflow\n"); + else + printf ("result is %ld (no overflow)\n", a * b); + + Example usage with WRAPV flavor: + + long int result; + bool overflow = INT_MULTIPLY_WRAPV (a, b, &result); + printf ("result is %ld (%s)\n", result, + overflow ? "after overflow" : "no overflow"); + + Restrictions on these macros: + + These macros do not check for all possible numerical problems or + undefined or unspecified behavior: they do not check for division + by zero, for bad shift counts, or for shifting negative numbers. + + These macros may evaluate their arguments zero or multiple times, so the + arguments should not have side effects. + + The WRAPV macros are not constant expressions. They support only + +, binary -, and *. + + Because the WRAPV macros convert the result, they report overflow + in different circumstances than the OVERFLOW macros do. For + example, in the typical case with 16-bit 'short' and 32-bit 'int', + if A, B and *R are all of type 'short' then INT_ADD_OVERFLOW (A, B) + returns false because the addition cannot overflow after A and B + are converted to 'int', whereas INT_ADD_WRAPV (A, B, R) returns + true or false depending on whether the sum fits into 'short'. + + These macros are tuned for their last input argument being a constant. + + A, B, and *R should be integers; they need not be the same type, + and they need not be all signed or all unsigned. + However, none of the integer types should be bit-precise, + and *R's type should not be char, bool, or an enumeration type. + + Return 1 if the integer expressions A * B, A - B, -A, A * B, A / B, + A % B, and A << B would overflow, respectively. */ + +#define INT_ADD_OVERFLOW(a, b) \ + _GL_BINARY_OP_OVERFLOW (a, b, _GL_ADD_OVERFLOW) +#define INT_SUBTRACT_OVERFLOW(a, b) \ + _GL_BINARY_OP_OVERFLOW (a, b, _GL_SUBTRACT_OVERFLOW) +#define INT_NEGATE_OVERFLOW(a) _GL_INT_NEGATE_OVERFLOW (a) +#define INT_MULTIPLY_OVERFLOW(a, b) \ + _GL_BINARY_OP_OVERFLOW (a, b, _GL_MULTIPLY_OVERFLOW) +#define INT_DIVIDE_OVERFLOW(a, b) \ + _GL_BINARY_OP_OVERFLOW (a, b, _GL_DIVIDE_OVERFLOW) +#define INT_REMAINDER_OVERFLOW(a, b) \ + _GL_BINARY_OP_OVERFLOW (a, b, _GL_REMAINDER_OVERFLOW) +#define INT_LEFT_SHIFT_OVERFLOW(a, b) \ + INT_LEFT_SHIFT_RANGE_OVERFLOW (a, b, \ + _GL_INT_MINIMUM (a), _GL_INT_MAXIMUM (a)) + +/* Return 1 if the expression A B would overflow, + where OP_RESULT_OVERFLOW (A, B, MIN, MAX) does the actual test, + assuming MIN and MAX are the minimum and maximum for the result type. + Arguments should be free of side effects. */ +#define _GL_BINARY_OP_OVERFLOW(a, b, op_result_overflow) \ + op_result_overflow (a, b, \ + _GL_INT_MINIMUM (_GL_INT_CONVERT (a, b)), \ + _GL_INT_MAXIMUM (_GL_INT_CONVERT (a, b))) + +/* Store the low-order bits of A + B, A - B, A * B, respectively, into *R. + Return 1 if the result overflows. See above for restrictions. */ +#define INT_ADD_WRAPV(a, b, r) _GL_INT_ADD_WRAPV (a, b, r) +#define INT_SUBTRACT_WRAPV(a, b, r) _GL_INT_SUBTRACT_WRAPV (a, b, r) +#define INT_MULTIPLY_WRAPV(a, b, r) _GL_INT_MULTIPLY_WRAPV (a, b, r) + +/* The following macros compute A + B, A - B, and A * B, respectively. + If no overflow occurs, they set *R to the result and return 1; + otherwise, they return 0 and may modify *R. + + Example usage: + + long int result; + if (INT_ADD_OK (a, b, &result)) + printf ("result is %ld\n", result); + else + printf ("overflow\n"); + + A, B, and *R should be integers; they need not be the same type, + and they need not be all signed or all unsigned. + However, none of the integer types should be bit-precise, + and *R's type should not be char, bool, or an enumeration type. + + These macros work correctly on all known practical hosts, and do not rely + on undefined behavior due to signed arithmetic overflow. + + These macros are not constant expressions. + + These macros may evaluate their arguments zero or multiple times, so the + arguments should not have side effects. + + These macros are tuned for B being a constant. */ + +#define INT_ADD_OK(a, b, r) (! INT_ADD_WRAPV (a, b, r)) +#define INT_SUBTRACT_OK(a, b, r) (! INT_SUBTRACT_WRAPV (a, b, r)) +#define INT_MULTIPLY_OK(a, b, r) (! INT_MULTIPLY_WRAPV (a, b, r)) + +#endif /* _GL_INTPROPS_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/inttypes.in.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/inttypes.in.h new file mode 100644 index 00000000..b9ab8a4b --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/inttypes.in.h @@ -0,0 +1,1033 @@ +/* Copyright (C) 2006-2024 Free Software Foundation, Inc. + Written by Paul Eggert, Bruno Haible, Derek Price. + This file is part of gnulib. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* + * ISO C 99 for platforms that lack it. + * + */ + +#if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +#endif +@PRAGMA_COLUMNS@ + +/* Include the original if it exists, and if this file + has not been included yet or if this file includes gnulib stdint.h + which in turn includes this file. + The include_next requires a split double-inclusion guard. */ +#if ! defined INTTYPES_H || defined _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H +# if @HAVE_INTTYPES_H@ + + /* Some pre-C++11 implementations need this. */ +# if defined __cplusplus && ! defined __STDC_FORMAT_MACROS +# define __STDC_FORMAT_MACROS 1 +# endif + +# @INCLUDE_NEXT@ @NEXT_INTTYPES_H@ + +# define _GL_FINISHED_INCLUDING_SYSTEM_INTTYPES_H +# endif +#endif + +#if ! defined INTTYPES_H && ! defined _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H +#define INTTYPES_H + +/* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +/* Include or the gnulib replacement. + But avoid namespace pollution on glibc systems. */ +#ifndef __GLIBC__ +# include +#endif +/* Get CHAR_BIT, INT_MAX, LONG_MAX, etc. */ +#include +/* On mingw, __USE_MINGW_ANSI_STDIO only works if is also included */ +#if defined _WIN32 && ! defined __CYGWIN__ +# include +#endif + +#if !(INT_MAX == 0x7fffffff && INT_MIN + INT_MAX == -1) +# error "This file assumes that 'int' is 32-bit two's complement. Please report your platform and compiler to ." +#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. */ + +/* 7.8.1 Macros for format specifiers */ + +#if defined _TNS_R_TARGET + /* Tandem NonStop R series and compatible platforms released before + July 2005 support %Ld but not %lld. */ +# define _LONG_LONG_FORMAT_PREFIX "L" +#else +# define _LONG_LONG_FORMAT_PREFIX "ll" +#endif + +#if !defined PRId8 +# ifdef INT8_MAX +# define PRId8 "d" +# endif +#endif +#if !defined PRIi8 +# ifdef INT8_MAX +# define PRIi8 "i" +# endif +#endif +#if !defined PRIo8 +# ifdef UINT8_MAX +# define PRIo8 "o" +# endif +#endif +#if !defined PRIu8 +# ifdef UINT8_MAX +# define PRIu8 "u" +# endif +#endif +#if !defined PRIx8 +# ifdef UINT8_MAX +# define PRIx8 "x" +# endif +#endif +#if !defined PRIX8 +# ifdef UINT8_MAX +# define PRIX8 "X" +# endif +#endif +#if !defined PRId16 +# ifdef INT16_MAX +# define PRId16 "d" +# endif +#endif +#if !defined PRIi16 +# ifdef INT16_MAX +# define PRIi16 "i" +# endif +#endif +#if !defined PRIo16 +# ifdef UINT16_MAX +# define PRIo16 "o" +# endif +#endif +#if !defined PRIu16 +# ifdef UINT16_MAX +# define PRIu16 "u" +# endif +#endif +#if !defined PRIx16 +# ifdef UINT16_MAX +# define PRIx16 "x" +# endif +#endif +#if !defined PRIX16 +# ifdef UINT16_MAX +# define PRIX16 "X" +# endif +#endif +#if !defined PRId32 +# ifdef INT32_MAX +# define PRId32 "d" +# endif +#endif +#if !defined PRIi32 +# ifdef INT32_MAX +# define PRIi32 "i" +# endif +#endif +#if !defined PRIo32 +# ifdef UINT32_MAX +# define PRIo32 "o" +# endif +#endif +#if !defined PRIu32 +# ifdef UINT32_MAX +# define PRIu32 "u" +# endif +#endif +#if !defined PRIx32 +# ifdef UINT32_MAX +# define PRIx32 "x" +# endif +#endif +#if !defined PRIX32 +# ifdef UINT32_MAX +# define PRIX32 "X" +# endif +#endif +#ifdef INT64_MAX +# if (@APPLE_UNIVERSAL_BUILD@ ? defined _LP64 : @INT64_MAX_EQ_LONG_MAX@) +# define _PRI64_PREFIX "l" +# elif defined _MSC_VER || defined __MINGW32__ +# define _PRI64_PREFIX "I64" +# elif LONG_MAX >> 30 == 1 +# define _PRI64_PREFIX _LONG_LONG_FORMAT_PREFIX +# endif +# if !defined PRId64 +# define PRId64 _PRI64_PREFIX "d" +# endif +# if !defined PRIi64 +# define PRIi64 _PRI64_PREFIX "i" +# endif +#endif +#ifdef UINT64_MAX +# if (@APPLE_UNIVERSAL_BUILD@ ? defined _LP64 : @UINT64_MAX_EQ_ULONG_MAX@) +# define _PRIu64_PREFIX "l" +# elif defined _MSC_VER || defined __MINGW32__ +# define _PRIu64_PREFIX "I64" +# elif ULONG_MAX >> 31 == 1 +# define _PRIu64_PREFIX _LONG_LONG_FORMAT_PREFIX +# endif +# if !defined PRIo64 +# define PRIo64 _PRIu64_PREFIX "o" +# endif +# if !defined PRIu64 +# define PRIu64 _PRIu64_PREFIX "u" +# endif +# if !defined PRIx64 +# define PRIx64 _PRIu64_PREFIX "x" +# endif +# if !defined PRIX64 +# define PRIX64 _PRIu64_PREFIX "X" +# endif +#endif + +#if !defined PRIdLEAST8 +# define PRIdLEAST8 "d" +#endif +#if !defined PRIiLEAST8 +# define PRIiLEAST8 "i" +#endif +#if !defined PRIoLEAST8 +# define PRIoLEAST8 "o" +#endif +#if !defined PRIuLEAST8 +# define PRIuLEAST8 "u" +#endif +#if !defined PRIxLEAST8 +# define PRIxLEAST8 "x" +#endif +#if !defined PRIXLEAST8 +# define PRIXLEAST8 "X" +#endif +#if !defined PRIdLEAST16 +# define PRIdLEAST16 "d" +#endif +#if !defined PRIiLEAST16 +# define PRIiLEAST16 "i" +#endif +#if !defined PRIoLEAST16 +# define PRIoLEAST16 "o" +#endif +#if !defined PRIuLEAST16 +# define PRIuLEAST16 "u" +#endif +#if !defined PRIxLEAST16 +# define PRIxLEAST16 "x" +#endif +#if !defined PRIXLEAST16 +# define PRIXLEAST16 "X" +#endif +#if !defined PRIdLEAST32 +# define PRIdLEAST32 "d" +#endif +#if !defined PRIiLEAST32 +# define PRIiLEAST32 "i" +#endif +#if !defined PRIoLEAST32 +# define PRIoLEAST32 "o" +#endif +#if !defined PRIuLEAST32 +# define PRIuLEAST32 "u" +#endif +#if !defined PRIxLEAST32 +# define PRIxLEAST32 "x" +#endif +#if !defined PRIXLEAST32 +# define PRIXLEAST32 "X" +#endif +#ifdef INT64_MAX +# if !defined PRIdLEAST64 +# define PRIdLEAST64 PRId64 +# endif +# if !defined PRIiLEAST64 +# define PRIiLEAST64 PRIi64 +# endif +#endif +#ifdef UINT64_MAX +# if !defined PRIoLEAST64 +# define PRIoLEAST64 PRIo64 +# endif +# if !defined PRIuLEAST64 +# define PRIuLEAST64 PRIu64 +# endif +# if !defined PRIxLEAST64 +# define PRIxLEAST64 PRIx64 +# endif +# if !defined PRIXLEAST64 +# define PRIXLEAST64 PRIX64 +# endif +#endif + +#if !defined PRIdFAST8 +# if INT_FAST8_MAX > INT32_MAX +# define PRIdFAST8 PRId64 +# else +# define PRIdFAST8 "d" +# endif +#endif +#if !defined PRIiFAST8 +# if INT_FAST8_MAX > INT32_MAX +# define PRIiFAST8 PRIi64 +# else +# define PRIiFAST8 "i" +# endif +#endif +#if !defined PRIoFAST8 +# if UINT_FAST8_MAX > UINT32_MAX +# define PRIoFAST8 PRIo64 +# else +# define PRIoFAST8 "o" +# endif +#endif +#if !defined PRIuFAST8 +# if UINT_FAST8_MAX > UINT32_MAX +# define PRIuFAST8 PRIu64 +# else +# define PRIuFAST8 "u" +# endif +#endif +#if !defined PRIxFAST8 +# if UINT_FAST8_MAX > UINT32_MAX +# define PRIxFAST8 PRIx64 +# else +# define PRIxFAST8 "x" +# endif +#endif +#if !defined PRIXFAST8 +# if UINT_FAST8_MAX > UINT32_MAX +# define PRIXFAST8 PRIX64 +# else +# define PRIXFAST8 "X" +# endif +#endif +#if !defined PRIdFAST16 +# if INT_FAST16_MAX > INT32_MAX +# define PRIdFAST16 PRId64 +# else +# define PRIdFAST16 "d" +# endif +#endif +#if !defined PRIiFAST16 +# if INT_FAST16_MAX > INT32_MAX +# define PRIiFAST16 PRIi64 +# else +# define PRIiFAST16 "i" +# endif +#endif +#if !defined PRIoFAST16 +# if UINT_FAST16_MAX > UINT32_MAX +# define PRIoFAST16 PRIo64 +# else +# define PRIoFAST16 "o" +# endif +#endif +#if !defined PRIuFAST16 +# if UINT_FAST16_MAX > UINT32_MAX +# define PRIuFAST16 PRIu64 +# else +# define PRIuFAST16 "u" +# endif +#endif +#if !defined PRIxFAST16 +# if UINT_FAST16_MAX > UINT32_MAX +# define PRIxFAST16 PRIx64 +# else +# define PRIxFAST16 "x" +# endif +#endif +#if !defined PRIXFAST16 +# if UINT_FAST16_MAX > UINT32_MAX +# define PRIXFAST16 PRIX64 +# else +# define PRIXFAST16 "X" +# endif +#endif +#if !defined PRIdFAST32 +# if INT_FAST32_MAX > INT32_MAX +# define PRIdFAST32 PRId64 +# else +# define PRIdFAST32 "d" +# endif +#endif +#if !defined PRIiFAST32 +# if INT_FAST32_MAX > INT32_MAX +# define PRIiFAST32 PRIi64 +# else +# define PRIiFAST32 "i" +# endif +#endif +#if !defined PRIoFAST32 +# if UINT_FAST32_MAX > UINT32_MAX +# define PRIoFAST32 PRIo64 +# else +# define PRIoFAST32 "o" +# endif +#endif +#if !defined PRIuFAST32 +# if UINT_FAST32_MAX > UINT32_MAX +# define PRIuFAST32 PRIu64 +# else +# define PRIuFAST32 "u" +# endif +#endif +#if !defined PRIxFAST32 +# if UINT_FAST32_MAX > UINT32_MAX +# define PRIxFAST32 PRIx64 +# else +# define PRIxFAST32 "x" +# endif +#endif +#if !defined PRIXFAST32 +# if UINT_FAST32_MAX > UINT32_MAX +# define PRIXFAST32 PRIX64 +# else +# define PRIXFAST32 "X" +# endif +#endif +#ifdef INT64_MAX +# if !defined PRIdFAST64 +# define PRIdFAST64 PRId64 +# endif +# if !defined PRIiFAST64 +# define PRIiFAST64 PRIi64 +# endif +#endif +#ifdef UINT64_MAX +# if !defined PRIoFAST64 +# define PRIoFAST64 PRIo64 +# endif +# if !defined PRIuFAST64 +# define PRIuFAST64 PRIu64 +# endif +# if !defined PRIxFAST64 +# define PRIxFAST64 PRIx64 +# endif +# if !defined PRIXFAST64 +# define PRIXFAST64 PRIX64 +# endif +#endif + +#if !defined PRIdMAX +# if @INT32_MAX_LT_INTMAX_MAX@ +# define PRIdMAX PRId64 +# else +# define PRIdMAX "ld" +# endif +#endif +#if !defined PRIiMAX +# if @INT32_MAX_LT_INTMAX_MAX@ +# define PRIiMAX PRIi64 +# else +# define PRIiMAX "li" +# endif +#endif +#if !defined PRIoMAX +# if @UINT32_MAX_LT_UINTMAX_MAX@ +# define PRIoMAX PRIo64 +# else +# define PRIoMAX "lo" +# endif +#endif +#if !defined PRIuMAX +# if @UINT32_MAX_LT_UINTMAX_MAX@ +# define PRIuMAX PRIu64 +# else +# define PRIuMAX "lu" +# endif +#endif +#if !defined PRIxMAX +# if @UINT32_MAX_LT_UINTMAX_MAX@ +# define PRIxMAX PRIx64 +# else +# define PRIxMAX "lx" +# endif +#endif +#if !defined PRIXMAX +# if @UINT32_MAX_LT_UINTMAX_MAX@ +# define PRIXMAX PRIX64 +# else +# define PRIXMAX "lX" +# endif +#endif + +#if !defined PRIdPTR +# ifdef INTPTR_MAX +# define PRIdPTR @PRIPTR_PREFIX@ "d" +# endif +#endif +#if !defined PRIiPTR +# ifdef INTPTR_MAX +# define PRIiPTR @PRIPTR_PREFIX@ "i" +# endif +#endif +#if !defined PRIoPTR +# ifdef UINTPTR_MAX +# define PRIoPTR @PRIPTR_PREFIX@ "o" +# endif +#endif +#if !defined PRIuPTR +# ifdef UINTPTR_MAX +# define PRIuPTR @PRIPTR_PREFIX@ "u" +# endif +#endif +#if !defined PRIxPTR +# ifdef UINTPTR_MAX +# define PRIxPTR @PRIPTR_PREFIX@ "x" +# endif +#endif +#if !defined PRIXPTR +# ifdef UINTPTR_MAX +# define PRIXPTR @PRIPTR_PREFIX@ "X" +# endif +#endif + +#if !defined SCNd8 +# ifdef INT8_MAX +# define SCNd8 "hhd" +# endif +#endif +#if !defined SCNi8 +# ifdef INT8_MAX +# define SCNi8 "hhi" +# endif +#endif +#if !defined SCNo8 +# ifdef UINT8_MAX +# define SCNo8 "hho" +# endif +#endif +#if !defined SCNu8 +# ifdef UINT8_MAX +# define SCNu8 "hhu" +# endif +#endif +#if !defined SCNx8 +# ifdef UINT8_MAX +# define SCNx8 "hhx" +# endif +#endif +#if !defined SCNd16 +# ifdef INT16_MAX +# define SCNd16 "hd" +# endif +#endif +#if !defined SCNi16 +# ifdef INT16_MAX +# define SCNi16 "hi" +# endif +#endif +#if !defined SCNo16 +# ifdef UINT16_MAX +# define SCNo16 "ho" +# endif +#endif +#if !defined SCNu16 +# ifdef UINT16_MAX +# define SCNu16 "hu" +# endif +#endif +#if !defined SCNx16 +# ifdef UINT16_MAX +# define SCNx16 "hx" +# endif +#endif +#if !defined SCNd32 +# ifdef INT32_MAX +# define SCNd32 "d" +# endif +#endif +#if !defined SCNi32 +# ifdef INT32_MAX +# define SCNi32 "i" +# endif +#endif +#if !defined SCNo32 +# ifdef UINT32_MAX +# define SCNo32 "o" +# endif +#endif +#if !defined SCNu32 +# ifdef UINT32_MAX +# define SCNu32 "u" +# endif +#endif +#if !defined SCNx32 +# ifdef UINT32_MAX +# define SCNx32 "x" +# endif +#endif +#ifdef INT64_MAX +# if (@APPLE_UNIVERSAL_BUILD@ ? defined _LP64 : @INT64_MAX_EQ_LONG_MAX@) +# define _SCN64_PREFIX "l" +# elif defined _MSC_VER || defined __MINGW32__ +# define _SCN64_PREFIX "I64" +# elif LONG_MAX >> 30 == 1 +# define _SCN64_PREFIX _LONG_LONG_FORMAT_PREFIX +# endif +# if !defined SCNd64 +# define SCNd64 _SCN64_PREFIX "d" +# endif +# if !defined SCNi64 +# define SCNi64 _SCN64_PREFIX "i" +# endif +#endif +#ifdef UINT64_MAX +# if (@APPLE_UNIVERSAL_BUILD@ ? defined _LP64 : @UINT64_MAX_EQ_ULONG_MAX@) +# define _SCNu64_PREFIX "l" +# elif defined _MSC_VER || defined __MINGW32__ +# define _SCNu64_PREFIX "I64" +# elif ULONG_MAX >> 31 == 1 +# define _SCNu64_PREFIX _LONG_LONG_FORMAT_PREFIX +# endif +# if !defined SCNo64 +# define SCNo64 _SCNu64_PREFIX "o" +# endif +# if !defined SCNu64 +# define SCNu64 _SCNu64_PREFIX "u" +# endif +# if !defined SCNx64 +# define SCNx64 _SCNu64_PREFIX "x" +# endif +#endif + +#if !defined SCNdLEAST8 +# define SCNdLEAST8 "hhd" +#endif +#if !defined SCNiLEAST8 +# define SCNiLEAST8 "hhi" +#endif +#if !defined SCNoLEAST8 +# define SCNoLEAST8 "hho" +#endif +#if !defined SCNuLEAST8 +# define SCNuLEAST8 "hhu" +#endif +#if !defined SCNxLEAST8 +# define SCNxLEAST8 "hhx" +#endif +#if !defined SCNdLEAST16 +# define SCNdLEAST16 "hd" +#endif +#if !defined SCNiLEAST16 +# define SCNiLEAST16 "hi" +#endif +#if !defined SCNoLEAST16 +# define SCNoLEAST16 "ho" +#endif +#if !defined SCNuLEAST16 +# define SCNuLEAST16 "hu" +#endif +#if !defined SCNxLEAST16 +# define SCNxLEAST16 "hx" +#endif +#if !defined SCNdLEAST32 +# define SCNdLEAST32 "d" +#endif +#if !defined SCNiLEAST32 +# define SCNiLEAST32 "i" +#endif +#if !defined SCNoLEAST32 +# define SCNoLEAST32 "o" +#endif +#if !defined SCNuLEAST32 +# define SCNuLEAST32 "u" +#endif +#if !defined SCNxLEAST32 +# define SCNxLEAST32 "x" +#endif +#ifdef INT64_MAX +# if !defined SCNdLEAST64 +# define SCNdLEAST64 SCNd64 +# endif +# if !defined SCNiLEAST64 +# define SCNiLEAST64 SCNi64 +# endif +#endif +#ifdef UINT64_MAX +# if !defined SCNoLEAST64 +# define SCNoLEAST64 SCNo64 +# endif +# if !defined SCNuLEAST64 +# define SCNuLEAST64 SCNu64 +# endif +# if !defined SCNxLEAST64 +# define SCNxLEAST64 SCNx64 +# endif +#endif + +#if !defined SCNdFAST8 +# if INT_FAST8_MAX > INT32_MAX +# define SCNdFAST8 SCNd64 +# elif INT_FAST8_MAX == 0x7fff +# define SCNdFAST8 "hd" +# elif INT_FAST8_MAX == 0x7f +# define SCNdFAST8 "hhd" +# else +# define SCNdFAST8 "d" +# endif +#endif +#if !defined SCNiFAST8 +# if INT_FAST8_MAX > INT32_MAX +# define SCNiFAST8 SCNi64 +# elif INT_FAST8_MAX == 0x7fff +# define SCNiFAST8 "hi" +# elif INT_FAST8_MAX == 0x7f +# define SCNiFAST8 "hhi" +# else +# define SCNiFAST8 "i" +# endif +#endif +#if !defined SCNoFAST8 +# if UINT_FAST8_MAX > UINT32_MAX +# define SCNoFAST8 SCNo64 +# elif UINT_FAST8_MAX == 0xffff +# define SCNoFAST8 "ho" +# elif UINT_FAST8_MAX == 0xff +# define SCNoFAST8 "hho" +# else +# define SCNoFAST8 "o" +# endif +#endif +#if !defined SCNuFAST8 +# if UINT_FAST8_MAX > UINT32_MAX +# define SCNuFAST8 SCNu64 +# elif UINT_FAST8_MAX == 0xffff +# define SCNuFAST8 "hu" +# elif UINT_FAST8_MAX == 0xff +# define SCNuFAST8 "hhu" +# else +# define SCNuFAST8 "u" +# endif +#endif +#if !defined SCNxFAST8 +# if UINT_FAST8_MAX > UINT32_MAX +# define SCNxFAST8 SCNx64 +# elif UINT_FAST8_MAX == 0xffff +# define SCNxFAST8 "hx" +# elif UINT_FAST8_MAX == 0xff +# define SCNxFAST8 "hhx" +# else +# define SCNxFAST8 "x" +# endif +#endif +#if !defined SCNdFAST16 +# if INT_FAST16_MAX > INT32_MAX +# define SCNdFAST16 SCNd64 +# elif INT_FAST16_MAX == 0x7fff +# define SCNdFAST16 "hd" +# else +# define SCNdFAST16 "d" +# endif +#endif +#if !defined SCNiFAST16 +# if INT_FAST16_MAX > INT32_MAX +# define SCNiFAST16 SCNi64 +# elif INT_FAST16_MAX == 0x7fff +# define SCNiFAST16 "hi" +# else +# define SCNiFAST16 "i" +# endif +#endif +#if !defined SCNoFAST16 +# if UINT_FAST16_MAX > UINT32_MAX +# define SCNoFAST16 SCNo64 +# elif UINT_FAST16_MAX == 0xffff +# define SCNoFAST16 "ho" +# else +# define SCNoFAST16 "o" +# endif +#endif +#if !defined SCNuFAST16 +# if UINT_FAST16_MAX > UINT32_MAX +# define SCNuFAST16 SCNu64 +# elif UINT_FAST16_MAX == 0xffff +# define SCNuFAST16 "hu" +# else +# define SCNuFAST16 "u" +# endif +#endif +#if !defined SCNxFAST16 +# if UINT_FAST16_MAX > UINT32_MAX +# define SCNxFAST16 SCNx64 +# elif UINT_FAST16_MAX == 0xffff +# define SCNxFAST16 "hx" +# else +# define SCNxFAST16 "x" +# endif +#endif +#if !defined SCNdFAST32 +# if INT_FAST32_MAX > INT32_MAX +# define SCNdFAST32 SCNd64 +# else +# define SCNdFAST32 "d" +# endif +#endif +#if !defined SCNiFAST32 +# if INT_FAST32_MAX > INT32_MAX +# define SCNiFAST32 SCNi64 +# else +# define SCNiFAST32 "i" +# endif +#endif +#if !defined SCNoFAST32 +# if UINT_FAST32_MAX > UINT32_MAX +# define SCNoFAST32 SCNo64 +# else +# define SCNoFAST32 "o" +# endif +#endif +#if !defined SCNuFAST32 +# if UINT_FAST32_MAX > UINT32_MAX +# define SCNuFAST32 SCNu64 +# else +# define SCNuFAST32 "u" +# endif +#endif +#if !defined SCNxFAST32 +# if UINT_FAST32_MAX > UINT32_MAX +# define SCNxFAST32 SCNx64 +# else +# define SCNxFAST32 "x" +# endif +#endif +#ifdef INT64_MAX +# if !defined SCNdFAST64 +# define SCNdFAST64 SCNd64 +# endif +# if !defined SCNiFAST64 +# define SCNiFAST64 SCNi64 +# endif +#endif +#ifdef UINT64_MAX +# if !defined SCNoFAST64 +# define SCNoFAST64 SCNo64 +# endif +# if !defined SCNuFAST64 +# define SCNuFAST64 SCNu64 +# endif +# if !defined SCNxFAST64 +# define SCNxFAST64 SCNx64 +# endif +#endif + +#if !defined SCNdMAX +# if @INT32_MAX_LT_INTMAX_MAX@ +# define SCNdMAX SCNd64 +# else +# define SCNdMAX "ld" +# endif +#endif +#if !defined SCNiMAX +# if @INT32_MAX_LT_INTMAX_MAX@ +# define SCNiMAX SCNi64 +# else +# define SCNiMAX "li" +# endif +#endif +#if !defined SCNoMAX +# if @UINT32_MAX_LT_UINTMAX_MAX@ +# define SCNoMAX SCNo64 +# else +# define SCNoMAX "lo" +# endif +#endif +#if !defined SCNuMAX +# if @UINT32_MAX_LT_UINTMAX_MAX@ +# define SCNuMAX SCNu64 +# else +# define SCNuMAX "lu" +# endif +#endif +#if !defined SCNxMAX +# if @UINT32_MAX_LT_UINTMAX_MAX@ +# define SCNxMAX SCNx64 +# else +# define SCNxMAX "lx" +# endif +#endif + +#if !defined SCNdPTR +# ifdef INTPTR_MAX +# define SCNdPTR @PRIPTR_PREFIX@ "d" +# endif +#endif +#if !defined SCNiPTR +# ifdef INTPTR_MAX +# define SCNiPTR @PRIPTR_PREFIX@ "i" +# endif +#endif +#if !defined SCNoPTR +# ifdef UINTPTR_MAX +# define SCNoPTR @PRIPTR_PREFIX@ "o" +# endif +#endif +#if !defined SCNuPTR +# ifdef UINTPTR_MAX +# define SCNuPTR @PRIPTR_PREFIX@ "u" +# endif +#endif +#if !defined SCNxPTR +# ifdef UINTPTR_MAX +# define SCNxPTR @PRIPTR_PREFIX@ "x" +# endif +#endif + +/* 7.8.2 Functions for greatest-width integer types */ + +#ifdef __cplusplus +extern "C" { +#endif + +#if @GNULIB_IMAXABS@ +# if @REPLACE_IMAXABS@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef imaxabs +# define imaxabs rpl_imaxabs +# endif +_GL_FUNCDECL_RPL (imaxabs, intmax_t, (intmax_t x)); +_GL_CXXALIAS_RPL (imaxabs, intmax_t, (intmax_t x)); +# else +# if !@HAVE_DECL_IMAXABS@ +_GL_FUNCDECL_SYS (imaxabs, intmax_t, (intmax_t x)); +# endif +_GL_CXXALIAS_SYS (imaxabs, intmax_t, (intmax_t x)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (imaxabs); +# endif +#elif defined GNULIB_POSIXCHECK +# undef imaxabs +# if HAVE_RAW_DECL_IMAXABS +_GL_WARN_ON_USE (imaxabs, "imaxabs is unportable - " + "use gnulib module imaxabs for portability"); +# endif +#endif + +#if @GNULIB_IMAXDIV@ +# if !@HAVE_IMAXDIV_T@ +# if !GNULIB_defined_imaxdiv_t +typedef struct { intmax_t quot; intmax_t rem; } imaxdiv_t; +# define GNULIB_defined_imaxdiv_t 1 +# endif +# endif +# if @REPLACE_IMAXDIV@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef imaxdiv +# define imaxdiv rpl_imaxdiv +# endif +_GL_FUNCDECL_RPL (imaxdiv, imaxdiv_t, (intmax_t numer, intmax_t denom)); +_GL_CXXALIAS_RPL (imaxdiv, imaxdiv_t, (intmax_t numer, intmax_t denom)); +# else +# if !@HAVE_DECL_IMAXDIV@ +_GL_FUNCDECL_SYS (imaxdiv, imaxdiv_t, (intmax_t numer, intmax_t denom)); +# endif +_GL_CXXALIAS_SYS (imaxdiv, imaxdiv_t, (intmax_t numer, intmax_t denom)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (imaxdiv); +# endif +#elif defined GNULIB_POSIXCHECK +# undef imaxdiv +# if HAVE_RAW_DECL_IMAXDIV +_GL_WARN_ON_USE (imaxdiv, "imaxdiv is unportable - " + "use gnulib module imaxdiv for portability"); +# endif +#endif + +#if @GNULIB_STRTOIMAX@ +# if @REPLACE_STRTOIMAX@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef strtoimax +# define strtoimax rpl_strtoimax +# endif +_GL_FUNCDECL_RPL (strtoimax, intmax_t, + (const char *restrict, char **restrict, int) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (strtoimax, intmax_t, + (const char *restrict, char **restrict, int)); +# else +# if !@HAVE_DECL_STRTOIMAX@ +# undef strtoimax +_GL_FUNCDECL_SYS (strtoimax, intmax_t, + (const char *restrict, char **restrict, int) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (strtoimax, intmax_t, + (const char *restrict, char **restrict, int)); +# endif +_GL_CXXALIASWARN (strtoimax); +#elif defined GNULIB_POSIXCHECK +# undef strtoimax +# if HAVE_RAW_DECL_STRTOIMAX +_GL_WARN_ON_USE (strtoimax, "strtoimax is unportable - " + "use gnulib module strtoimax for portability"); +# endif +#endif + +#if @GNULIB_STRTOUMAX@ +# if @REPLACE_STRTOUMAX@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef strtoumax +# define strtoumax rpl_strtoumax +# endif +_GL_FUNCDECL_RPL (strtoumax, uintmax_t, + (const char *restrict, char **restrict, int) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (strtoumax, uintmax_t, + (const char *restrict, char **restrict, int)); +# else +# if !@HAVE_DECL_STRTOUMAX@ +# undef strtoumax +_GL_FUNCDECL_SYS (strtoumax, uintmax_t, + (const char *restrict, char **restrict, int) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (strtoumax, uintmax_t, + (const char *restrict, char **restrict, int)); +# endif +_GL_CXXALIASWARN (strtoumax); +#elif defined GNULIB_POSIXCHECK +# undef strtoumax +# if HAVE_RAW_DECL_STRTOUMAX +_GL_WARN_ON_USE (strtoumax, "strtoumax is unportable - " + "use gnulib module strtoumax for portability"); +# endif +#endif + +/* Don't bother defining or declaring wcstoimax and wcstoumax, since + wide-character functions like this are hardly ever useful. */ + +#ifdef __cplusplus +} +#endif + +#endif /* !defined INTTYPES_H && !defined _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/isblank.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/isblank.c new file mode 100644 index 00000000..d16450aa --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/isblank.c @@ -0,0 +1,33 @@ +/* Test whether a character is a blank. + + Copyright (C) 2009-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +int +isblank (int c) +{ + /* On all known platforms, in all predefined locales, isblank(c) is likely + equivalent with (c == ' ' || c == '\t'). Look at the glibc definition + (in glibc/localedata/locales/i18n): The "blank" characters are '\t', ' ', + U+1680, U+180E, U+2000..U+2006, U+2008..U+200A, U+205F, U+3000, and none + except the first two is present in a common 8-bit encoding. Therefore + the substitute for other platforms is not more complicated than this. */ + return (c == ' ' || c == '\t'); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/iswblank.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/iswblank.c new file mode 100644 index 00000000..f699850a --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/iswblank.c @@ -0,0 +1,26 @@ +/* Test wide character for being blank. + Copyright (C) 2008-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +int +iswblank (wint_t wc) +{ + return wc == ' ' || wc == '\t'; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/iswctype-impl.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/iswctype-impl.h new file mode 100644 index 00000000..999f220c --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/iswctype-impl.h @@ -0,0 +1,22 @@ +/* Test whether a wide character has a given property. + Copyright (C) 2011-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2011. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +int +iswctype (wint_t wc, wctype_t desc) +{ + return ((int (*) (wint_t)) desc) (wc); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/iswctype.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/iswctype.c new file mode 100644 index 00000000..f4e6f015 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/iswctype.c @@ -0,0 +1,36 @@ +/* Test whether a wide character has a given property. + Copyright (C) 2011-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2011. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +#if GNULIB_defined_wint_t && !GNULIB_defined_wctype_t + +int +iswctype (wint_t wc, wctype_t desc) +# undef iswctype +{ + return ((wchar_t) wc == wc ? iswctype ((wchar_t) wc, desc) : 0); +} + +#else + +# include "iswctype-impl.h" + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/iswdigit.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/iswdigit.c new file mode 100644 index 00000000..57363ab8 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/iswdigit.c @@ -0,0 +1,26 @@ +/* Test wide character for being a digit. + Copyright (C) 2020-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +int +iswdigit (wint_t wc) +{ + return wc >= '0' && wc <= '9'; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/iswpunct.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/iswpunct.c new file mode 100644 index 00000000..c7cb28b5 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/iswpunct.c @@ -0,0 +1,33 @@ +/* Test wide character for being a punctuation or symbol character. + Copyright (C) 2023-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +#include + +int +iswpunct (wint_t wc) +#undef iswpunct +{ +#if defined __ANDROID__ + if ((unsigned int) wc < 128) + return ispunct ((unsigned int) wc); +#endif + return iswpunct (wc); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/iswxdigit.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/iswxdigit.c new file mode 100644 index 00000000..d32e3b0f --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/iswxdigit.c @@ -0,0 +1,33 @@ +/* Test wide character for being a hexadecimal digit. + Copyright (C) 2020-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +int +iswxdigit (wint_t wc) +{ + return ((wc >= '0' && wc <= '9') +#if 'A' == 0x41 && 'a' == 0x61 + /* Optimization, assuming ASCII */ + || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'F') +#else + || (wc >= 'A' && wc <= 'F') || (wc >= 'a' && wc <= 'f') +#endif + ); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/langinfo.in.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/langinfo.in.h new file mode 100644 index 00000000..febbd25f --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/langinfo.in.h @@ -0,0 +1,229 @@ +/* Substitute for and wrapper around . + Copyright (C) 2009-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* + * POSIX for platforms that lack it or have an incomplete one. + * + */ + +#ifndef _@GUARD_PREFIX@_LANGINFO_H + +#if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +#endif +@PRAGMA_COLUMNS@ + +/* The include_next requires a split double-inclusion guard. */ +#if @HAVE_LANGINFO_H@ +# @INCLUDE_NEXT@ @NEXT_LANGINFO_H@ +#endif + +#ifndef _@GUARD_PREFIX@_LANGINFO_H +#define _@GUARD_PREFIX@_LANGINFO_H + +/* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + + +#if !@HAVE_LANGINFO_H@ + +/* A platform that lacks . */ + +/* Assume that it also lacks and the nl_item type. */ +# if !GNULIB_defined_nl_item +typedef int nl_item; +# define GNULIB_defined_nl_item 1 +# endif + +/* nl_langinfo items of the LC_CTYPE category */ +# define CODESET 10000 +/* nl_langinfo items of the LC_NUMERIC category */ +# define RADIXCHAR 10001 +# define DECIMAL_POINT RADIXCHAR +# define THOUSEP 10002 +# define THOUSANDS_SEP THOUSEP +# define GROUPING 10114 +/* nl_langinfo items of the LC_TIME category */ +# define D_T_FMT 10003 +# define D_FMT 10004 +# define T_FMT 10005 +# define T_FMT_AMPM 10006 +# define AM_STR 10007 +# define PM_STR 10008 +# define DAY_1 10009 +# define DAY_2 (DAY_1 + 1) +# define DAY_3 (DAY_1 + 2) +# define DAY_4 (DAY_1 + 3) +# define DAY_5 (DAY_1 + 4) +# define DAY_6 (DAY_1 + 5) +# define DAY_7 (DAY_1 + 6) +# define ABDAY_1 10016 +# define ABDAY_2 (ABDAY_1 + 1) +# define ABDAY_3 (ABDAY_1 + 2) +# define ABDAY_4 (ABDAY_1 + 3) +# define ABDAY_5 (ABDAY_1 + 4) +# define ABDAY_6 (ABDAY_1 + 5) +# define ABDAY_7 (ABDAY_1 + 6) +# define MON_1 10023 +# define MON_2 (MON_1 + 1) +# define MON_3 (MON_1 + 2) +# define MON_4 (MON_1 + 3) +# define MON_5 (MON_1 + 4) +# define MON_6 (MON_1 + 5) +# define MON_7 (MON_1 + 6) +# define MON_8 (MON_1 + 7) +# define MON_9 (MON_1 + 8) +# define MON_10 (MON_1 + 9) +# define MON_11 (MON_1 + 10) +# define MON_12 (MON_1 + 11) +# define ALTMON_1 10200 +# define ALTMON_2 (ALTMON_1 + 1) +# define ALTMON_3 (ALTMON_1 + 2) +# define ALTMON_4 (ALTMON_1 + 3) +# define ALTMON_5 (ALTMON_1 + 4) +# define ALTMON_6 (ALTMON_1 + 5) +# define ALTMON_7 (ALTMON_1 + 6) +# define ALTMON_8 (ALTMON_1 + 7) +# define ALTMON_9 (ALTMON_1 + 8) +# define ALTMON_10 (ALTMON_1 + 9) +# define ALTMON_11 (ALTMON_1 + 10) +# define ALTMON_12 (ALTMON_1 + 11) +# define ABMON_1 10035 +# define ABMON_2 (ABMON_1 + 1) +# define ABMON_3 (ABMON_1 + 2) +# define ABMON_4 (ABMON_1 + 3) +# define ABMON_5 (ABMON_1 + 4) +# define ABMON_6 (ABMON_1 + 5) +# define ABMON_7 (ABMON_1 + 6) +# define ABMON_8 (ABMON_1 + 7) +# define ABMON_9 (ABMON_1 + 8) +# define ABMON_10 (ABMON_1 + 9) +# define ABMON_11 (ABMON_1 + 10) +# define ABMON_12 (ABMON_1 + 11) +# define ERA 10047 +# define ERA_D_FMT 10048 +# define ERA_D_T_FMT 10049 +# define ERA_T_FMT 10050 +# define ALT_DIGITS 10051 +/* nl_langinfo items of the LC_MONETARY category */ +# define CRNCYSTR 10052 +# define CURRENCY_SYMBOL CRNCYSTR +# define INT_CURR_SYMBOL 10100 +# define MON_DECIMAL_POINT 10101 +# define MON_THOUSANDS_SEP 10102 +# define MON_GROUPING 10103 +# define POSITIVE_SIGN 10104 +# define NEGATIVE_SIGN 10105 +# define FRAC_DIGITS 10106 +# define INT_FRAC_DIGITS 10107 +# define P_CS_PRECEDES 10108 +# define N_CS_PRECEDES 10109 +# define P_SEP_BY_SPACE 10110 +# define N_SEP_BY_SPACE 10111 +# define P_SIGN_POSN 10112 +# define N_SIGN_POSN 10113 +/* nl_langinfo items of the LC_MESSAGES category */ +# define YESEXPR 10053 +# define NOEXPR 10054 + +#else + +/* A platform that has . */ + +# if !@HAVE_LANGINFO_CODESET@ +# define CODESET 10000 +# define GNULIB_defined_CODESET 1 +# endif + +# if !@HAVE_LANGINFO_T_FMT_AMPM@ +# define T_FMT_AMPM 10006 +# define GNULIB_defined_T_FMT_AMPM 1 +# endif + +# if !@HAVE_LANGINFO_ALTMON@ +# define ALTMON_1 10200 +# define ALTMON_2 (ALTMON_1 + 1) +# define ALTMON_3 (ALTMON_1 + 2) +# define ALTMON_4 (ALTMON_1 + 3) +# define ALTMON_5 (ALTMON_1 + 4) +# define ALTMON_6 (ALTMON_1 + 5) +# define ALTMON_7 (ALTMON_1 + 6) +# define ALTMON_8 (ALTMON_1 + 7) +# define ALTMON_9 (ALTMON_1 + 8) +# define ALTMON_10 (ALTMON_1 + 9) +# define ALTMON_11 (ALTMON_1 + 10) +# define ALTMON_12 (ALTMON_1 + 11) +# define GNULIB_defined_ALTMON 1 +# endif + +# if !@HAVE_LANGINFO_ERA@ +# define ERA 10047 +# define ERA_D_FMT 10048 +# define ERA_D_T_FMT 10049 +# define ERA_T_FMT 10050 +# define ALT_DIGITS 10051 +# define GNULIB_defined_ERA 1 +# endif + +# if !@HAVE_LANGINFO_YESEXPR@ +# define YESEXPR 10053 +# define NOEXPR 10054 +# define GNULIB_defined_YESEXPR 1 +# endif + +#endif + +/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ + +/* The definition of _GL_WARN_ON_USE is copied here. */ + +/* Declare overridden functions. */ + + +/* Return a piece of locale dependent information. + Note: The difference between nl_langinfo (CODESET) and locale_charset () + is that the latter normalizes the encoding names to GNU conventions. */ + +#if @GNULIB_NL_LANGINFO@ +# if @REPLACE_NL_LANGINFO@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef nl_langinfo +# define nl_langinfo rpl_nl_langinfo +# endif +_GL_FUNCDECL_RPL (nl_langinfo, char *, (nl_item item)); +_GL_CXXALIAS_RPL (nl_langinfo, char *, (nl_item item)); +# else +# if !@HAVE_NL_LANGINFO@ +_GL_FUNCDECL_SYS (nl_langinfo, char *, (nl_item item)); +# endif +_GL_CXXALIAS_SYS (nl_langinfo, char *, (nl_item item)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (nl_langinfo); +# endif +#elif defined GNULIB_POSIXCHECK +# undef nl_langinfo +# if HAVE_RAW_DECL_NL_LANGINFO +_GL_WARN_ON_USE (nl_langinfo, "nl_langinfo is not portable - " + "use gnulib module nl_langinfo for portability"); +# endif +#endif + + +#endif /* _@GUARD_PREFIX@_LANGINFO_H */ +#endif /* _@GUARD_PREFIX@_LANGINFO_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/lc-charset-dispatch.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/lc-charset-dispatch.c new file mode 100644 index 00000000..e2f8b2f5 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/lc-charset-dispatch.c @@ -0,0 +1,82 @@ +/* Dispatching based on the current locale's character encoding. + Copyright (C) 2018-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 2018. */ + +#include + +/* Specification. */ +#include "lc-charset-dispatch.h" + +#if GNULIB_defined_mbstate_t + +# include "localcharset.h" +# include "streq.h" + +# if GNULIB_WCHAR_SINGLE_LOCALE +/* 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_LOCALE +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_LOCALE + +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 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/lc-charset-dispatch.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/lc-charset-dispatch.h new file mode 100644 index 00000000..4c1cf5f1 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/lc-charset-dispatch.h @@ -0,0 +1,40 @@ +/* Dispatching based on the current locale's character encoding. + Copyright (C) 2018-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 2018. */ + +#include + +#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 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/libc-config.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/libc-config.h new file mode 100644 index 00000000..70114608 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/libc-config.h @@ -0,0 +1,204 @@ +/* System definitions for code taken from the GNU C Library + + Copyright 2017-2024 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this program; if not, see + . */ + +/* Written by Paul Eggert. */ + +/* This is intended to be a good-enough substitute for glibc system + macros like those defined in , so that Gnulib code + shared with glibc can do this as the first #include: + + #ifndef _LIBC + # include + #endif + + When compiled as part of glibc this is a no-op; when compiled as + part of Gnulib this includes Gnulib's and defines macros + that glibc library code would normally assume. + + Note: This header file MUST NOT be included by public header files + of Gnulib. */ + +#include + +/* On glibc this includes and and #defines + _FEATURES_H, __WORDSIZE, and __set_errno. On FreeBSD 11 and + DragonFlyBSD 5.9 it includes which defines __nonnull. + Elsewhere it is harmless. */ +#include + +/* From glibc . */ +#ifndef __set_errno +# define __set_errno(val) (errno = (val)) +#endif + +/* From glibc . */ + +#ifndef __GNUC_PREREQ +# if defined __GNUC__ && defined __GNUC_MINOR__ +# define __GNUC_PREREQ(maj, min) ((maj) < __GNUC__ + ((min) <= __GNUC_MINOR__)) +# else +# define __GNUC_PREREQ(maj, min) 0 +# endif +#endif + +#ifndef __glibc_clang_prereq +# if defined __clang_major__ && defined __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 +#endif + +#ifndef __attribute_nonnull__ +/* either does not exist, or is too old for Gnulib. + Prepare to include , which is Gnulib's version of a + more-recent glibc . */ + +/* Define _FEATURES_H so that does not include . */ +# ifndef _FEATURES_H +# define _FEATURES_H 1 +# endif +/* Define __GNULIB_CDEFS so that does not attempt to include + nonexistent files. */ +# define __GNULIB_CDEFS +/* Undef the macros unconditionally defined by our copy of glibc + , so that they do not clash with any system-defined + versions. */ +# undef _SYS_CDEFS_H +# undef __ASMNAME +# undef __ASMNAME2 +# undef __BEGIN_DECLS +# undef __CONCAT +# undef __END_DECLS +# undef __HAVE_GENERIC_SELECTION +# undef __LDBL_COMPAT +# undef __LDBL_REDIR +# undef __LDBL_REDIR1 +# undef __LDBL_REDIR1_DECL +# undef __LDBL_REDIR1_NTH +# undef __LDBL_REDIR2_DECL +# undef __LDBL_REDIR_DECL +# undef __LDBL_REDIR_NTH +# undef __LEAF +# undef __LEAF_ATTR +# undef __NTH +# undef __NTHNL +# undef __REDIRECT +# undef __REDIRECT_LDBL +# undef __REDIRECT_NTH +# undef __REDIRECT_NTHNL +# undef __REDIRECT_NTH_LDBL +# undef __STRING +# undef __THROW +# undef __THROWNL +# undef __attr_access +# undef __attr_access_none +# undef __attr_dealloc +# undef __attr_dealloc_free +# undef __attribute__ +# undef __attribute_alloc_align__ +# undef __attribute_alloc_size__ +# undef __attribute_artificial__ +# undef __attribute_const__ +# undef __attribute_deprecated__ +# undef __attribute_deprecated_msg__ +# undef __attribute_format_arg__ +# undef __attribute_format_strfmon__ +# undef __attribute_malloc__ +# undef __attribute_maybe_unused__ +# undef __attribute_noinline__ +# undef __attribute_nonstring__ +# undef __attribute_pure__ +# undef __attribute_returns_twice__ +# undef __attribute_used__ +# undef __attribute_warn_unused_result__ +# undef __errordecl +# undef __extension__ +# undef __extern_always_inline +# undef __extern_inline +# undef __flexarr +# undef __fortified_attr_access +# undef __fortify_function +# undef __glibc_c99_flexarr_available +# undef __glibc_has_attribute +# undef __glibc_has_builtin +# undef __glibc_has_extension +# undef __glibc_likely +# undef __glibc_macro_warning +# undef __glibc_macro_warning1 +# undef __glibc_unlikely +# undef __inline +# undef __ptr_t +# undef __restrict +# undef __restrict_arr +# undef __va_arg_pack +# undef __va_arg_pack_len +# undef __warnattr +# undef __wur +# ifndef __GNULIB_CDEFS +# undef __bos +# undef __bos0 +# undef __glibc_fortify +# undef __glibc_fortify_n +# undef __glibc_objsize +# undef __glibc_objsize0 +# undef __glibc_safe_len_cond +# undef __glibc_safe_or_unknown_len +# undef __glibc_unsafe_len +# undef __glibc_unsigned_or_positive +# endif + +/* Include our copy of glibc . */ +# include + +/* __inline is too pessimistic for non-GCC. */ +# undef __inline +# ifndef HAVE___INLINE +# if 199901 <= __STDC_VERSION__ || defined inline +# define __inline inline +# else +# define __inline +# endif +# endif + +#endif /* defined __glibc_likely */ + + +/* A substitute for glibc , good enough for Gnulib. */ +#define attribute_hidden +#define libc_hidden_proto(name) +#define libc_hidden_def(name) +#define libc_hidden_weak(name) +#define libc_hidden_ver(local, name) +#define strong_alias(name, aliasname) +#define weak_alias(name, aliasname) + +/* A substitute for glibc , good enough for Gnulib. */ +#define SHLIB_COMPAT(lib, introduced, obsoleted) 0 +#define compat_symbol(lib, local, symbol, version) extern int dummy +#define versioned_symbol(lib, local, symbol, version) extern int dummy diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/limits.in.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/limits.in.h new file mode 100644 index 00000000..c65eb4c1 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/limits.in.h @@ -0,0 +1,151 @@ +/* A GNU-like . + + Copyright 2016-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +#endif +@PRAGMA_COLUMNS@ + +#if defined _GL_ALREADY_INCLUDING_LIMITS_H +/* Special invocation convention: + On Haiku/x86_64, we have a sequence of nested includes + -> -> . + In this situation, LONG_MAX and INT_MAX are not yet defined, + therefore we should not attempt to define LONG_BIT. */ + +#@INCLUDE_NEXT@ @NEXT_LIMITS_H@ + +#else +/* Normal invocation convention. */ + +#ifndef _@GUARD_PREFIX@_LIMITS_H + +# define _GL_ALREADY_INCLUDING_LIMITS_H + +/* The include_next requires a split double-inclusion guard. */ +# @INCLUDE_NEXT@ @NEXT_LIMITS_H@ + +# undef _GL_ALREADY_INCLUDING_LIMITS_H + +#ifndef _@GUARD_PREFIX@_LIMITS_H +#define _@GUARD_PREFIX@_LIMITS_H + +#ifndef LLONG_MIN +# if defined LONG_LONG_MIN /* HP-UX 11.31 */ +# define LLONG_MIN LONG_LONG_MIN +# elif defined LONGLONG_MIN /* IRIX 6.5 */ +# define LLONG_MIN LONGLONG_MIN +# elif defined __GNUC__ +# define LLONG_MIN (- __LONG_LONG_MAX__ - 1LL) +# endif +#endif +#ifndef LLONG_MAX +# if defined LONG_LONG_MAX /* HP-UX 11.31 */ +# define LLONG_MAX LONG_LONG_MAX +# elif defined LONGLONG_MAX /* IRIX 6.5 */ +# define LLONG_MAX LONGLONG_MAX +# elif defined __GNUC__ +# define LLONG_MAX __LONG_LONG_MAX__ +# endif +#endif +#ifndef ULLONG_MAX +# if defined ULONG_LONG_MAX /* HP-UX 11.31 */ +# define ULLONG_MAX ULONG_LONG_MAX +# elif defined ULONGLONG_MAX /* IRIX 6.5 */ +# define ULLONG_MAX ULONGLONG_MAX +# elif defined __GNUC__ +# define ULLONG_MAX (__LONG_LONG_MAX__ * 2ULL + 1ULL) +# endif +#endif + +/* The number of usable bits in an unsigned or signed integer type + with minimum value MIN and maximum value MAX, as an int expression + suitable in #if. Cover all known practical hosts. This + implementation exploits the fact that MAX is 1 less than a power of + 2, and merely counts the number of 1 bits in MAX; "COBn" means + "count the number of 1 bits in the low-order n bits"). */ +#define _GL_INTEGER_WIDTH(min, max) (((min) < 0) + _GL_COB128 (max)) +#define _GL_COB128(n) (_GL_COB64 ((n) >> 31 >> 31 >> 2) + _GL_COB64 (n)) +#define _GL_COB64(n) (_GL_COB32 ((n) >> 31 >> 1) + _GL_COB32 (n)) +#define _GL_COB32(n) (_GL_COB16 ((n) >> 16) + _GL_COB16 (n)) +#define _GL_COB16(n) (_GL_COB8 ((n) >> 8) + _GL_COB8 (n)) +#define _GL_COB8(n) (_GL_COB4 ((n) >> 4) + _GL_COB4 (n)) +#define _GL_COB4(n) (!!((n) & 8) + !!((n) & 4) + !!((n) & 2) + !!((n) & 1)) + +#ifndef WORD_BIT +/* Assume 'int' is 32 bits wide. */ +# define WORD_BIT 32 +#endif +#ifndef LONG_BIT +/* Assume 'long' is 32 or 64 bits wide. */ +# if LONG_MAX == INT_MAX +# define LONG_BIT 32 +# else +# define LONG_BIT 64 +# endif +#endif + +/* Assume no multibyte character is longer than 16 bytes. */ +#ifndef MB_LEN_MAX +# define MB_LEN_MAX 16 +#endif + +/* Macros specified by C23 and by ISO/IEC TS 18661-1:2014. */ + +#if (! defined ULLONG_WIDTH \ + && (defined _GNU_SOURCE || defined __STDC_WANT_IEC_60559_BFP_EXT__ \ + || (defined __STDC_VERSION__ && 201710 < __STDC_VERSION__))) +# define CHAR_WIDTH _GL_INTEGER_WIDTH (CHAR_MIN, CHAR_MAX) +# define SCHAR_WIDTH _GL_INTEGER_WIDTH (SCHAR_MIN, SCHAR_MAX) +# define UCHAR_WIDTH _GL_INTEGER_WIDTH (0, UCHAR_MAX) +# define SHRT_WIDTH _GL_INTEGER_WIDTH (SHRT_MIN, SHRT_MAX) +# define USHRT_WIDTH _GL_INTEGER_WIDTH (0, USHRT_MAX) +# define INT_WIDTH _GL_INTEGER_WIDTH (INT_MIN, INT_MAX) +# define UINT_WIDTH _GL_INTEGER_WIDTH (0, UINT_MAX) +# define LONG_WIDTH _GL_INTEGER_WIDTH (LONG_MIN, LONG_MAX) +# define ULONG_WIDTH _GL_INTEGER_WIDTH (0, ULONG_MAX) +# define LLONG_WIDTH _GL_INTEGER_WIDTH (LLONG_MIN, LLONG_MAX) +# define ULLONG_WIDTH _GL_INTEGER_WIDTH (0, ULLONG_MAX) +#endif + +/* Macros specified by C23. */ + +#if (defined _GNU_SOURCE \ + || (defined __STDC_VERSION__ && 201710 < __STDC_VERSION__)) +# if ! defined BOOL_WIDTH +# define BOOL_WIDTH 1 +# define BOOL_MAX 1 +# elif ! defined BOOL_MAX +# define BOOL_MAX 1 +# endif +#endif + +/* Macro specified by POSIX. */ + +/* The maximum ssize_t value. Although it might not be of ssize_t type + as it should be, it's too much trouble to fix this minor detail. */ +#ifndef SSIZE_MAX +# ifdef _WIN64 +# define SSIZE_MAX LLONG_MAX +# else +# define SSIZE_MAX LONG_MAX +# endif +#endif + +#endif /* _@GUARD_PREFIX@_LIMITS_H */ +#endif /* _@GUARD_PREFIX@_LIMITS_H */ +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/localcharset.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/localcharset.c new file mode 100644 index 00000000..93c4baa4 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/localcharset.c @@ -0,0 +1,1159 @@ +/* Determine a canonical name for the current locale's character encoding. + + Copyright (C) 2000-2006, 2008-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible . */ + +#include + +/* Specification. */ +#include "localcharset.h" + +#include +#include +#include +#include + +#if defined __APPLE__ && defined __MACH__ && HAVE_LANGINFO_CODESET +# define DARWIN7 /* Darwin 7 or newer, i.e. Mac OS X 10.3 or newer */ +#endif + +#if defined _WIN32 && !defined __CYGWIN__ +# define WINDOWS_NATIVE +# include +#endif + +#if defined __EMX__ +/* Assume EMX program runs on OS/2, even if compiled under DOS. */ +# ifndef OS2 +# define OS2 +# endif +#endif + +#if !defined WINDOWS_NATIVE +# if HAVE_LANGINFO_CODESET +# include +# else +# if 0 /* see comment regarding use of setlocale(), below */ +# include +# endif +# endif +# ifdef __CYGWIN__ +# define WIN32_LEAN_AND_MEAN +# include +# endif +#elif defined WINDOWS_NATIVE +# define WIN32_LEAN_AND_MEAN +# include + /* 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 +# include +#endif + +/* For MB_CUR_MAX_L */ +#if defined DARWIN7 +# include +#endif + + +#if HAVE_LANGINFO_CODESET || defined WINDOWS_NATIVE || defined OS2 + +/* On these platforms, we use a mapping from non-canonical encoding name + to GNU canonical encoding name. */ + +/* With glibc-2.1 or newer, we don't need any canonicalization, + because glibc has iconv and both glibc and libiconv support all + GNU canonical names directly. */ +# if !((defined __GNU_LIBRARY__ && __GLIBC__ >= 2) || defined __UCLIBC__) + +struct table_entry +{ + const char alias[11+1]; + const char canonical[11+1]; +}; + +/* Table of platform-dependent mappings, sorted in ascending order. */ +static const struct table_entry alias_table[] = + { +# if defined __FreeBSD__ /* FreeBSD */ + /*{ "ARMSCII-8", "ARMSCII-8" },*/ + { "Big5", "BIG5" }, + { "C", "ASCII" }, + /*{ "CP1131", "CP1131" },*/ + /*{ "CP1251", "CP1251" },*/ + /*{ "CP866", "CP866" },*/ + /*{ "GB18030", "GB18030" },*/ + /*{ "GB2312", "GB2312" },*/ + /*{ "GBK", "GBK" },*/ + /*{ "ISCII-DEV", "?" },*/ + { "ISO8859-1", "ISO-8859-1" }, + { "ISO8859-13", "ISO-8859-13" }, + { "ISO8859-15", "ISO-8859-15" }, + { "ISO8859-2", "ISO-8859-2" }, + { "ISO8859-5", "ISO-8859-5" }, + { "ISO8859-7", "ISO-8859-7" }, + { "ISO8859-9", "ISO-8859-9" }, + /*{ "KOI8-R", "KOI8-R" },*/ + /*{ "KOI8-U", "KOI8-U" },*/ + { "SJIS", "SHIFT_JIS" }, + { "US-ASCII", "ASCII" }, + { "eucCN", "GB2312" }, + { "eucJP", "EUC-JP" }, + { "eucKR", "EUC-KR" } +# define alias_table_defined +# endif +# if defined __NetBSD__ /* NetBSD */ + { "646", "ASCII" }, + /*{ "ARMSCII-8", "ARMSCII-8" },*/ + /*{ "BIG5", "BIG5" },*/ + { "Big5-HKSCS", "BIG5-HKSCS" }, + /*{ "CP1251", "CP1251" },*/ + /*{ "CP866", "CP866" },*/ + /*{ "GB18030", "GB18030" },*/ + /*{ "GB2312", "GB2312" },*/ + { "ISO8859-1", "ISO-8859-1" }, + { "ISO8859-13", "ISO-8859-13" }, + { "ISO8859-15", "ISO-8859-15" }, + { "ISO8859-2", "ISO-8859-2" }, + { "ISO8859-4", "ISO-8859-4" }, + { "ISO8859-5", "ISO-8859-5" }, + { "ISO8859-7", "ISO-8859-7" }, + /*{ "KOI8-R", "KOI8-R" },*/ + /*{ "KOI8-U", "KOI8-U" },*/ + /*{ "PT154", "PT154" },*/ + { "SJIS", "SHIFT_JIS" }, + { "eucCN", "GB2312" }, + { "eucJP", "EUC-JP" }, + { "eucKR", "EUC-KR" }, + { "eucTW", "EUC-TW" } +# define alias_table_defined +# endif +# if defined __OpenBSD__ /* OpenBSD */ + { "646", "ASCII" }, + { "ISO8859-1", "ISO-8859-1" }, + { "ISO8859-13", "ISO-8859-13" }, + { "ISO8859-15", "ISO-8859-15" }, + { "ISO8859-2", "ISO-8859-2" }, + { "ISO8859-4", "ISO-8859-4" }, + { "ISO8859-5", "ISO-8859-5" }, + { "ISO8859-7", "ISO-8859-7" }, + { "US-ASCII", "ASCII" } +# define alias_table_defined +# endif +# if defined __APPLE__ && defined __MACH__ /* Mac OS X */ + /* Darwin 7.5 has nl_langinfo(CODESET), but sometimes its value is + useless: + - It returns the empty string when LANG is set to a locale of the + form ll_CC, although ll_CC/LC_CTYPE is a symlink to an UTF-8 + LC_CTYPE file. + - The environment variables LANG, LC_CTYPE, LC_ALL are not set by + the system; nl_langinfo(CODESET) returns "US-ASCII" in this case. + - The documentation says: + "... all code that calls BSD system routines should ensure + that the const *char parameters of these routines are in UTF-8 + encoding. All BSD system functions expect their string + parameters to be in UTF-8 encoding and nothing else." + It also says + "An additional caveat is that string parameters for files, + paths, and other file-system entities must be in canonical + UTF-8. In a canonical UTF-8 Unicode string, all decomposable + characters are decomposed ..." + but this is not true: You can pass non-decomposed UTF-8 strings + to file system functions, and it is the OS which will convert + them to decomposed UTF-8 before accessing the file system. + - The Apple Terminal application displays UTF-8 by default. + - However, other applications are free to use different encodings: + - xterm uses ISO-8859-1 by default. + - TextEdit uses MacRoman by default. + We prefer UTF-8 over decomposed UTF-8-MAC because one should + minimize the use of decomposed Unicode. Unfortunately, through the + Darwin file system, decomposed UTF-8 strings are leaked into user + space nevertheless. + Then there are also the locales with encodings other than US-ASCII + and UTF-8. These locales can be occasionally useful to users (e.g. + when grepping through ISO-8859-1 encoded text files), when all their + file names are in US-ASCII. + */ + { "ARMSCII-8", "ARMSCII-8" }, + { "Big5", "BIG5" }, + { "Big5HKSCS", "BIG5-HKSCS" }, + { "CP1131", "CP1131" }, + { "CP1251", "CP1251" }, + { "CP866", "CP866" }, + { "CP949", "CP949" }, + { "GB18030", "GB18030" }, + { "GB2312", "GB2312" }, + { "GBK", "GBK" }, + /*{ "ISCII-DEV", "?" },*/ + { "ISO8859-1", "ISO-8859-1" }, + { "ISO8859-13", "ISO-8859-13" }, + { "ISO8859-15", "ISO-8859-15" }, + { "ISO8859-2", "ISO-8859-2" }, + { "ISO8859-4", "ISO-8859-4" }, + { "ISO8859-5", "ISO-8859-5" }, + { "ISO8859-7", "ISO-8859-7" }, + { "ISO8859-9", "ISO-8859-9" }, + { "KOI8-R", "KOI8-R" }, + { "KOI8-U", "KOI8-U" }, + { "PT154", "PT154" }, + { "SJIS", "SHIFT_JIS" }, + { "eucCN", "GB2312" }, + { "eucJP", "EUC-JP" }, + { "eucKR", "EUC-KR" } +# define alias_table_defined +# endif +# if defined _AIX /* AIX */ + /*{ "GBK", "GBK" },*/ + { "IBM-1046", "CP1046" }, + { "IBM-1124", "CP1124" }, + { "IBM-1129", "CP1129" }, + { "IBM-1252", "CP1252" }, + { "IBM-850", "CP850" }, + { "IBM-856", "CP856" }, + { "IBM-921", "ISO-8859-13" }, + { "IBM-922", "CP922" }, + { "IBM-932", "CP932" }, + { "IBM-943", "CP943" }, + { "IBM-eucCN", "GB2312" }, + { "IBM-eucJP", "EUC-JP" }, + { "IBM-eucKR", "EUC-KR" }, + { "IBM-eucTW", "EUC-TW" }, + { "ISO8859-1", "ISO-8859-1" }, + { "ISO8859-15", "ISO-8859-15" }, + { "ISO8859-2", "ISO-8859-2" }, + { "ISO8859-5", "ISO-8859-5" }, + { "ISO8859-6", "ISO-8859-6" }, + { "ISO8859-7", "ISO-8859-7" }, + { "ISO8859-8", "ISO-8859-8" }, + { "ISO8859-9", "ISO-8859-9" }, + { "TIS-620", "TIS-620" }, + /*{ "UTF-8", "UTF-8" },*/ + { "big5", "BIG5" } +# define alias_table_defined +# endif +# if defined __hpux /* HP-UX */ + { "SJIS", "SHIFT_JIS" }, + { "arabic8", "HP-ARABIC8" }, + { "big5", "BIG5" }, + { "cp1251", "CP1251" }, + { "eucJP", "EUC-JP" }, + { "eucKR", "EUC-KR" }, + { "eucTW", "EUC-TW" }, + { "gb18030", "GB18030" }, + { "greek8", "HP-GREEK8" }, + { "hebrew8", "HP-HEBREW8" }, + { "hkbig5", "BIG5-HKSCS" }, + { "hp15CN", "GB2312" }, + { "iso88591", "ISO-8859-1" }, + { "iso885913", "ISO-8859-13" }, + { "iso885915", "ISO-8859-15" }, + { "iso88592", "ISO-8859-2" }, + { "iso88594", "ISO-8859-4" }, + { "iso88595", "ISO-8859-5" }, + { "iso88596", "ISO-8859-6" }, + { "iso88597", "ISO-8859-7" }, + { "iso88598", "ISO-8859-8" }, + { "iso88599", "ISO-8859-9" }, + { "kana8", "HP-KANA8" }, + { "koi8r", "KOI8-R" }, + { "roman8", "HP-ROMAN8" }, + { "tis620", "TIS-620" }, + { "turkish8", "HP-TURKISH8" }, + { "utf8", "UTF-8" } +# define alias_table_defined +# endif +# if defined __sgi /* IRIX */ + { "ISO8859-1", "ISO-8859-1" }, + { "ISO8859-15", "ISO-8859-15" }, + { "ISO8859-2", "ISO-8859-2" }, + { "ISO8859-5", "ISO-8859-5" }, + { "ISO8859-7", "ISO-8859-7" }, + { "ISO8859-9", "ISO-8859-9" }, + { "eucCN", "GB2312" }, + { "eucJP", "EUC-JP" }, + { "eucKR", "EUC-KR" }, + { "eucTW", "EUC-TW" } +# define alias_table_defined +# endif +# if defined __osf__ /* OSF/1 */ + /*{ "GBK", "GBK" },*/ + { "ISO8859-1", "ISO-8859-1" }, + { "ISO8859-15", "ISO-8859-15" }, + { "ISO8859-2", "ISO-8859-2" }, + { "ISO8859-4", "ISO-8859-4" }, + { "ISO8859-5", "ISO-8859-5" }, + { "ISO8859-7", "ISO-8859-7" }, + { "ISO8859-8", "ISO-8859-8" }, + { "ISO8859-9", "ISO-8859-9" }, + { "KSC5601", "CP949" }, + { "SJIS", "SHIFT_JIS" }, + { "TACTIS", "TIS-620" }, + /*{ "UTF-8", "UTF-8" },*/ + { "big5", "BIG5" }, + { "cp850", "CP850" }, + { "dechanyu", "DEC-HANYU" }, + { "dechanzi", "GB2312" }, + { "deckanji", "DEC-KANJI" }, + { "deckorean", "EUC-KR" }, + { "eucJP", "EUC-JP" }, + { "eucKR", "EUC-KR" }, + { "eucTW", "EUC-TW" }, + { "sdeckanji", "EUC-JP" } +# define alias_table_defined +# endif +# if defined __sun /* Solaris */ + { "5601", "EUC-KR" }, + { "646", "ASCII" }, + /*{ "BIG5", "BIG5" },*/ + { "Big5-HKSCS", "BIG5-HKSCS" }, + { "GB18030", "GB18030" }, + /*{ "GBK", "GBK" },*/ + { "ISO8859-1", "ISO-8859-1" }, + { "ISO8859-11", "TIS-620" }, + { "ISO8859-13", "ISO-8859-13" }, + { "ISO8859-15", "ISO-8859-15" }, + { "ISO8859-2", "ISO-8859-2" }, + { "ISO8859-3", "ISO-8859-3" }, + { "ISO8859-4", "ISO-8859-4" }, + { "ISO8859-5", "ISO-8859-5" }, + { "ISO8859-6", "ISO-8859-6" }, + { "ISO8859-7", "ISO-8859-7" }, + { "ISO8859-8", "ISO-8859-8" }, + { "ISO8859-9", "ISO-8859-9" }, + { "PCK", "SHIFT_JIS" }, + { "TIS620.2533", "TIS-620" }, + /*{ "UTF-8", "UTF-8" },*/ + { "ansi-1251", "CP1251" }, + { "cns11643", "EUC-TW" }, + { "eucJP", "EUC-JP" }, + { "gb2312", "GB2312" }, + { "koi8-r", "KOI8-R" } +# define alias_table_defined +# endif +# if defined __minix /* Minix */ + { "646", "ASCII" } +# define alias_table_defined +# endif +# if defined WINDOWS_NATIVE || defined __CYGWIN__ /* Windows */ + { "CP1361", "JOHAB" }, + { "CP20127", "ASCII" }, + { "CP20866", "KOI8-R" }, + { "CP20936", "GB2312" }, + { "CP21866", "KOI8-RU" }, + { "CP28591", "ISO-8859-1" }, + { "CP28592", "ISO-8859-2" }, + { "CP28593", "ISO-8859-3" }, + { "CP28594", "ISO-8859-4" }, + { "CP28595", "ISO-8859-5" }, + { "CP28596", "ISO-8859-6" }, + { "CP28597", "ISO-8859-7" }, + { "CP28598", "ISO-8859-8" }, + { "CP28599", "ISO-8859-9" }, + { "CP28605", "ISO-8859-15" }, + { "CP38598", "ISO-8859-8" }, + { "CP51932", "EUC-JP" }, + { "CP51936", "GB2312" }, + { "CP51949", "EUC-KR" }, + { "CP51950", "EUC-TW" }, + { "CP54936", "GB18030" }, + { "CP65001", "UTF-8" }, + { "CP936", "GBK" } +# define alias_table_defined +# endif +# if defined OS2 /* OS/2 */ + /* The list of encodings is taken from "List of OS/2 Codepages" + by Alex Taylor: + . + See also "__convcp() of kLIBC": + . */ + { "CP1004", "CP1252" }, + /*{ "CP1041", "CP943" },*/ + /*{ "CP1088", "CP949" },*/ + { "CP1089", "ISO-8859-6" }, + /*{ "CP1114", "CP950" },*/ + /*{ "CP1115", "GB2312" },*/ + { "CP1208", "UTF-8" }, + /*{ "CP1380", "GB2312" },*/ + { "CP1381", "GB2312" }, + { "CP1383", "GB2312" }, + { "CP1386", "GBK" }, + /*{ "CP301", "CP943" },*/ + { "CP3372", "EUC-JP" }, + { "CP4946", "CP850" }, + /*{ "CP5048", "JIS_X0208-1990" },*/ + /*{ "CP5049", "JIS_X0212-1990" },*/ + /*{ "CP5067", "KS_C_5601-1987" },*/ + { "CP813", "ISO-8859-7" }, + { "CP819", "ISO-8859-1" }, + { "CP878", "KOI8-R" }, + /*{ "CP897", "CP943" },*/ + { "CP912", "ISO-8859-2" }, + { "CP913", "ISO-8859-3" }, + { "CP914", "ISO-8859-4" }, + { "CP915", "ISO-8859-5" }, + { "CP916", "ISO-8859-8" }, + { "CP920", "ISO-8859-9" }, + { "CP921", "ISO-8859-13" }, + { "CP923", "ISO-8859-15" }, + /*{ "CP941", "CP943" },*/ + /*{ "CP947", "CP950" },*/ + /*{ "CP951", "CP949" },*/ + /*{ "CP952", "JIS_X0208-1990" },*/ + /*{ "CP953", "JIS_X0212-1990" },*/ + { "CP954", "EUC-JP" }, + { "CP964", "EUC-TW" }, + { "CP970", "EUC-KR" }, + /*{ "CP971", "KS_C_5601-1987" },*/ + { "IBM-1004", "CP1252" }, + /*{ "IBM-1006", "?" },*/ + /*{ "IBM-1008", "?" },*/ + /*{ "IBM-1041", "CP943" },*/ + /*{ "IBM-1051", "?" },*/ + /*{ "IBM-1088", "CP949" },*/ + { "IBM-1089", "ISO-8859-6" }, + /*{ "IBM-1098", "?" },*/ + /*{ "IBM-1114", "CP950" },*/ + /*{ "IBM-1115", "GB2312" },*/ + /*{ "IBM-1116", "?" },*/ + /*{ "IBM-1117", "?" },*/ + /*{ "IBM-1118", "?" },*/ + /*{ "IBM-1119", "?" },*/ + { "IBM-1124", "CP1124" }, + { "IBM-1125", "CP1125" }, + { "IBM-1131", "CP1131" }, + { "IBM-1208", "UTF-8" }, + { "IBM-1250", "CP1250" }, + { "IBM-1251", "CP1251" }, + { "IBM-1252", "CP1252" }, + { "IBM-1253", "CP1253" }, + { "IBM-1254", "CP1254" }, + { "IBM-1255", "CP1255" }, + { "IBM-1256", "CP1256" }, + { "IBM-1257", "CP1257" }, + /*{ "IBM-1275", "?" },*/ + /*{ "IBM-1276", "?" },*/ + /*{ "IBM-1277", "?" },*/ + /*{ "IBM-1280", "?" },*/ + /*{ "IBM-1281", "?" },*/ + /*{ "IBM-1282", "?" },*/ + /*{ "IBM-1283", "?" },*/ + /*{ "IBM-1380", "GB2312" },*/ + { "IBM-1381", "GB2312" }, + { "IBM-1383", "GB2312" }, + { "IBM-1386", "GBK" }, + /*{ "IBM-301", "CP943" },*/ + { "IBM-3372", "EUC-JP" }, + { "IBM-367", "ASCII" }, + { "IBM-437", "CP437" }, + { "IBM-4946", "CP850" }, + /*{ "IBM-5048", "JIS_X0208-1990" },*/ + /*{ "IBM-5049", "JIS_X0212-1990" },*/ + /*{ "IBM-5067", "KS_C_5601-1987" },*/ + { "IBM-813", "ISO-8859-7" }, + { "IBM-819", "ISO-8859-1" }, + { "IBM-850", "CP850" }, + /*{ "IBM-851", "?" },*/ + { "IBM-852", "CP852" }, + { "IBM-855", "CP855" }, + { "IBM-856", "CP856" }, + { "IBM-857", "CP857" }, + /*{ "IBM-859", "?" },*/ + { "IBM-860", "CP860" }, + { "IBM-861", "CP861" }, + { "IBM-862", "CP862" }, + { "IBM-863", "CP863" }, + { "IBM-864", "CP864" }, + { "IBM-865", "CP865" }, + { "IBM-866", "CP866" }, + /*{ "IBM-868", "?" },*/ + { "IBM-869", "CP869" }, + { "IBM-874", "CP874" }, + { "IBM-878", "KOI8-R" }, + /*{ "IBM-895", "?" },*/ + /*{ "IBM-897", "CP943" },*/ + /*{ "IBM-907", "?" },*/ + /*{ "IBM-909", "?" },*/ + { "IBM-912", "ISO-8859-2" }, + { "IBM-913", "ISO-8859-3" }, + { "IBM-914", "ISO-8859-4" }, + { "IBM-915", "ISO-8859-5" }, + { "IBM-916", "ISO-8859-8" }, + { "IBM-920", "ISO-8859-9" }, + { "IBM-921", "ISO-8859-13" }, + { "IBM-922", "CP922" }, + { "IBM-923", "ISO-8859-15" }, + { "IBM-932", "CP932" }, + /*{ "IBM-941", "CP943" },*/ + /*{ "IBM-942", "?" },*/ + { "IBM-943", "CP943" }, + /*{ "IBM-947", "CP950" },*/ + { "IBM-949", "CP949" }, + { "IBM-950", "CP950" }, + /*{ "IBM-951", "CP949" },*/ + /*{ "IBM-952", "JIS_X0208-1990" },*/ + /*{ "IBM-953", "JIS_X0212-1990" },*/ + { "IBM-954", "EUC-JP" }, + /*{ "IBM-955", "?" },*/ + { "IBM-964", "EUC-TW" }, + { "IBM-970", "EUC-KR" }, + /*{ "IBM-971", "KS_C_5601-1987" },*/ + { "IBM-eucCN", "GB2312" }, + { "IBM-eucJP", "EUC-JP" }, + { "IBM-eucKR", "EUC-KR" }, + { "IBM-eucTW", "EUC-TW" }, + { "IBM33722", "EUC-JP" }, + { "ISO8859-1", "ISO-8859-1" }, + { "ISO8859-2", "ISO-8859-2" }, + { "ISO8859-3", "ISO-8859-3" }, + { "ISO8859-4", "ISO-8859-4" }, + { "ISO8859-5", "ISO-8859-5" }, + { "ISO8859-6", "ISO-8859-6" }, + { "ISO8859-7", "ISO-8859-7" }, + { "ISO8859-8", "ISO-8859-8" }, + { "ISO8859-9", "ISO-8859-9" }, + /*{ "JISX0201-1976", "JISX0201-1976" },*/ + /*{ "JISX0208-1978", "?" },*/ + /*{ "JISX0208-1983", "JIS_X0208-1983" },*/ + /*{ "JISX0208-1990", "JIS_X0208-1990" },*/ + /*{ "JISX0212-1990", "JIS_X0212-1990" },*/ + /*{ "KSC5601-1987", "KS_C_5601-1987" },*/ + { "SJIS-1", "CP943" }, + { "SJIS-2", "CP943" }, + { "eucJP", "EUC-JP" }, + { "eucKR", "EUC-KR" }, + { "eucTW-1993", "EUC-TW" } +# define alias_table_defined +# endif +# if defined VMS /* OpenVMS */ + /* The list of encodings is taken from the OpenVMS 7.3-1 documentation + "Compaq C Run-Time Library Reference Manual for OpenVMS systems" + section 10.7 "Handling Different Character Sets". */ + { "DECHANYU", "DEC-HANYU" }, + { "DECHANZI", "GB2312" }, + { "DECKANJI", "DEC-KANJI" }, + { "DECKOREAN", "EUC-KR" }, + { "ISO8859-1", "ISO-8859-1" }, + { "ISO8859-2", "ISO-8859-2" }, + { "ISO8859-5", "ISO-8859-5" }, + { "ISO8859-7", "ISO-8859-7" }, + { "ISO8859-8", "ISO-8859-8" }, + { "ISO8859-9", "ISO-8859-9" }, + { "SDECKANJI", "EUC-JP" }, + { "SJIS", "SHIFT_JIS" }, + { "eucJP", "EUC-JP" }, + { "eucTW", "EUC-TW" } +# define alias_table_defined +# endif +# ifndef alias_table_defined + /* Just a dummy entry, to avoid a C syntax error. */ + { "", "" } +# endif + }; + +# endif + +#else + +/* On these platforms, we use a mapping from locale name to GNU canonical + encoding name. */ + +struct table_entry +{ + const char locale[17+1]; + const char canonical[11+1]; +}; + +/* Table of platform-dependent mappings, sorted in ascending order. */ +static const struct table_entry locale_table[] = + { +# if defined __FreeBSD__ /* FreeBSD 4.2 */ + { "cs_CZ.ISO_8859-2", "ISO-8859-2" }, + { "da_DK.DIS_8859-15", "ISO-8859-15" }, + { "da_DK.ISO_8859-1", "ISO-8859-1" }, + { "de_AT.DIS_8859-15", "ISO-8859-15" }, + { "de_AT.ISO_8859-1", "ISO-8859-1" }, + { "de_CH.DIS_8859-15", "ISO-8859-15" }, + { "de_CH.ISO_8859-1", "ISO-8859-1" }, + { "de_DE.DIS_8859-15", "ISO-8859-15" }, + { "de_DE.ISO_8859-1", "ISO-8859-1" }, + { "en_AU.DIS_8859-15", "ISO-8859-15" }, + { "en_AU.ISO_8859-1", "ISO-8859-1" }, + { "en_CA.DIS_8859-15", "ISO-8859-15" }, + { "en_CA.ISO_8859-1", "ISO-8859-1" }, + { "en_GB.DIS_8859-15", "ISO-8859-15" }, + { "en_GB.ISO_8859-1", "ISO-8859-1" }, + { "en_US.DIS_8859-15", "ISO-8859-15" }, + { "en_US.ISO_8859-1", "ISO-8859-1" }, + { "es_ES.DIS_8859-15", "ISO-8859-15" }, + { "es_ES.ISO_8859-1", "ISO-8859-1" }, + { "fi_FI.DIS_8859-15", "ISO-8859-15" }, + { "fi_FI.ISO_8859-1", "ISO-8859-1" }, + { "fr_BE.DIS_8859-15", "ISO-8859-15" }, + { "fr_BE.ISO_8859-1", "ISO-8859-1" }, + { "fr_CA.DIS_8859-15", "ISO-8859-15" }, + { "fr_CA.ISO_8859-1", "ISO-8859-1" }, + { "fr_CH.DIS_8859-15", "ISO-8859-15" }, + { "fr_CH.ISO_8859-1", "ISO-8859-1" }, + { "fr_FR.DIS_8859-15", "ISO-8859-15" }, + { "fr_FR.ISO_8859-1", "ISO-8859-1" }, + { "hr_HR.ISO_8859-2", "ISO-8859-2" }, + { "hu_HU.ISO_8859-2", "ISO-8859-2" }, + { "is_IS.DIS_8859-15", "ISO-8859-15" }, + { "is_IS.ISO_8859-1", "ISO-8859-1" }, + { "it_CH.DIS_8859-15", "ISO-8859-15" }, + { "it_CH.ISO_8859-1", "ISO-8859-1" }, + { "it_IT.DIS_8859-15", "ISO-8859-15" }, + { "it_IT.ISO_8859-1", "ISO-8859-1" }, + { "ja_JP.EUC", "EUC-JP" }, + { "ja_JP.SJIS", "SHIFT_JIS" }, + { "ja_JP.Shift_JIS", "SHIFT_JIS" }, + { "ko_KR.EUC", "EUC-KR" }, + { "la_LN.ASCII", "ASCII" }, + { "la_LN.DIS_8859-15", "ISO-8859-15" }, + { "la_LN.ISO_8859-1", "ISO-8859-1" }, + { "la_LN.ISO_8859-2", "ISO-8859-2" }, + { "la_LN.ISO_8859-4", "ISO-8859-4" }, + { "lt_LN.ASCII", "ASCII" }, + { "lt_LN.DIS_8859-15", "ISO-8859-15" }, + { "lt_LN.ISO_8859-1", "ISO-8859-1" }, + { "lt_LN.ISO_8859-2", "ISO-8859-2" }, + { "lt_LT.ISO_8859-4", "ISO-8859-4" }, + { "nl_BE.DIS_8859-15", "ISO-8859-15" }, + { "nl_BE.ISO_8859-1", "ISO-8859-1" }, + { "nl_NL.DIS_8859-15", "ISO-8859-15" }, + { "nl_NL.ISO_8859-1", "ISO-8859-1" }, + { "no_NO.DIS_8859-15", "ISO-8859-15" }, + { "no_NO.ISO_8859-1", "ISO-8859-1" }, + { "pl_PL.ISO_8859-2", "ISO-8859-2" }, + { "pt_PT.DIS_8859-15", "ISO-8859-15" }, + { "pt_PT.ISO_8859-1", "ISO-8859-1" }, + { "ru_RU.CP866", "CP866" }, + { "ru_RU.ISO_8859-5", "ISO-8859-5" }, + { "ru_RU.KOI8-R", "KOI8-R" }, + { "ru_SU.CP866", "CP866" }, + { "ru_SU.ISO_8859-5", "ISO-8859-5" }, + { "ru_SU.KOI8-R", "KOI8-R" }, + { "sl_SI.ISO_8859-2", "ISO-8859-2" }, + { "sv_SE.DIS_8859-15", "ISO-8859-15" }, + { "sv_SE.ISO_8859-1", "ISO-8859-1" }, + { "uk_UA.KOI8-U", "KOI8-U" }, + { "zh_CN.EUC", "GB2312" }, + { "zh_TW.BIG5", "BIG5" }, + { "zh_TW.Big5", "BIG5" } +# define locale_table_defined +# endif +# if defined __DJGPP__ /* DOS / DJGPP 2.03 */ + /* The encodings given here may not all be correct. + If you find that the encoding given for your language and + country is not the one your DOS machine actually uses, just + correct it in this file, and send a mail to + Juan Manuel Guerrero + and . */ + { "C", "ASCII" }, + { "ar", "CP864" }, + { "ar_AE", "CP864" }, + { "ar_DZ", "CP864" }, + { "ar_EG", "CP864" }, + { "ar_IQ", "CP864" }, + { "ar_IR", "CP864" }, + { "ar_JO", "CP864" }, + { "ar_KW", "CP864" }, + { "ar_MA", "CP864" }, + { "ar_OM", "CP864" }, + { "ar_QA", "CP864" }, + { "ar_SA", "CP864" }, + { "ar_SY", "CP864" }, + { "be", "CP866" }, + { "be_BE", "CP866" }, + { "bg", "CP866" }, /* not CP855 ?? */ + { "bg_BG", "CP866" }, /* not CP855 ?? */ + { "ca", "CP850" }, + { "ca_ES", "CP850" }, + { "cs", "CP852" }, + { "cs_CZ", "CP852" }, + { "da", "CP865" }, /* not CP850 ?? */ + { "da_DK", "CP865" }, /* not CP850 ?? */ + { "de", "CP850" }, + { "de_AT", "CP850" }, + { "de_CH", "CP850" }, + { "de_DE", "CP850" }, + { "el", "CP869" }, + { "el_GR", "CP869" }, + { "en", "CP850" }, + { "en_AU", "CP850" }, /* not CP437 ?? */ + { "en_CA", "CP850" }, + { "en_GB", "CP850" }, + { "en_NZ", "CP437" }, + { "en_US", "CP437" }, + { "en_ZA", "CP850" }, /* not CP437 ?? */ + { "eo", "CP850" }, + { "eo_EO", "CP850" }, + { "es", "CP850" }, + { "es_AR", "CP850" }, + { "es_BO", "CP850" }, + { "es_CL", "CP850" }, + { "es_CO", "CP850" }, + { "es_CR", "CP850" }, + { "es_CU", "CP850" }, + { "es_DO", "CP850" }, + { "es_EC", "CP850" }, + { "es_ES", "CP850" }, + { "es_GT", "CP850" }, + { "es_HN", "CP850" }, + { "es_MX", "CP850" }, + { "es_NI", "CP850" }, + { "es_PA", "CP850" }, + { "es_PE", "CP850" }, + { "es_PY", "CP850" }, + { "es_SV", "CP850" }, + { "es_UY", "CP850" }, + { "es_VE", "CP850" }, + { "et", "CP850" }, + { "et_EE", "CP850" }, + { "eu", "CP850" }, + { "eu_ES", "CP850" }, + { "fi", "CP850" }, + { "fi_FI", "CP850" }, + { "fr", "CP850" }, + { "fr_BE", "CP850" }, + { "fr_CA", "CP850" }, + { "fr_CH", "CP850" }, + { "fr_FR", "CP850" }, + { "ga", "CP850" }, + { "ga_IE", "CP850" }, + { "gd", "CP850" }, + { "gd_GB", "CP850" }, + { "gl", "CP850" }, + { "gl_ES", "CP850" }, + { "he", "CP862" }, + { "he_IL", "CP862" }, + { "hr", "CP852" }, + { "hr_HR", "CP852" }, + { "hu", "CP852" }, + { "hu_HU", "CP852" }, + { "id", "CP850" }, /* not CP437 ?? */ + { "id_ID", "CP850" }, /* not CP437 ?? */ + { "is", "CP861" }, /* not CP850 ?? */ + { "is_IS", "CP861" }, /* not CP850 ?? */ + { "it", "CP850" }, + { "it_CH", "CP850" }, + { "it_IT", "CP850" }, + { "ja", "CP932" }, + { "ja_JP", "CP932" }, + { "kr", "CP949" }, /* not CP934 ?? */ + { "kr_KR", "CP949" }, /* not CP934 ?? */ + { "lt", "CP775" }, + { "lt_LT", "CP775" }, + { "lv", "CP775" }, + { "lv_LV", "CP775" }, + { "mk", "CP866" }, /* not CP855 ?? */ + { "mk_MK", "CP866" }, /* not CP855 ?? */ + { "mt", "CP850" }, + { "mt_MT", "CP850" }, + { "nb", "CP865" }, /* not CP850 ?? */ + { "nb_NO", "CP865" }, /* not CP850 ?? */ + { "nl", "CP850" }, + { "nl_BE", "CP850" }, + { "nl_NL", "CP850" }, + { "nn", "CP865" }, /* not CP850 ?? */ + { "nn_NO", "CP865" }, /* not CP850 ?? */ + { "no", "CP865" }, /* not CP850 ?? */ + { "no_NO", "CP865" }, /* not CP850 ?? */ + { "pl", "CP852" }, + { "pl_PL", "CP852" }, + { "pt", "CP850" }, + { "pt_BR", "CP850" }, + { "pt_PT", "CP850" }, + { "ro", "CP852" }, + { "ro_RO", "CP852" }, + { "ru", "CP866" }, + { "ru_RU", "CP866" }, + { "sk", "CP852" }, + { "sk_SK", "CP852" }, + { "sl", "CP852" }, + { "sl_SI", "CP852" }, + { "sq", "CP852" }, + { "sq_AL", "CP852" }, + { "sr", "CP852" }, /* CP852 or CP866 or CP855 ?? */ + { "sr_CS", "CP852" }, /* CP852 or CP866 or CP855 ?? */ + { "sr_YU", "CP852" }, /* CP852 or CP866 or CP855 ?? */ + { "sv", "CP850" }, + { "sv_SE", "CP850" }, + { "th", "CP874" }, + { "th_TH", "CP874" }, + { "tr", "CP857" }, + { "tr_TR", "CP857" }, + { "uk", "CP1125" }, + { "uk_UA", "CP1125" }, + { "zh_CN", "GBK" }, + { "zh_TW", "CP950" } /* not CP938 ?? */ +# define locale_table_defined +# endif +# ifndef locale_table_defined + /* Just a dummy entry, to avoid a C syntax error. */ + { "", "" } +# endif + }; + +#endif + + +/* 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 + 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. */ + +#ifdef STATIC +STATIC +#endif +const char * +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 + + /* Most systems support nl_langinfo (CODESET) nowadays. */ + codeset = nl_langinfo (CODESET); + +# ifdef __CYGWIN__ + /* Cygwin < 1.7 does not have locales. nl_langinfo (CODESET) always + returns "US-ASCII". Return the suffix of the locale name from the + environment variables (if present) or the codepage as a number. */ + if (codeset != NULL && strcmp (codeset, "US-ASCII") == 0) + { + const char *locale; + static char resultbuf[2 + 10 + 1]; + + locale = getenv ("LC_ALL"); + if (locale == NULL || locale[0] == '\0') + { + locale = getenv ("LC_CTYPE"); + if (locale == NULL || locale[0] == '\0') + locale = getenv ("LANG"); + } + if (locale != NULL && locale[0] != '\0') + { + /* If the locale name contains an encoding after the dot, return + it. */ + const char *dot = strchr (locale, '.'); + + if (dot != NULL) + { + const char *modifier; + + dot++; + /* Look for the possible @... trailer and remove it, if any. */ + modifier = strchr (dot, '@'); + if (modifier == NULL) + return dot; + if (modifier - dot < sizeof (resultbuf)) + { + /* This way of filling resultbuf is multithread-safe. */ + memcpy (resultbuf, dot, modifier - dot); + resultbuf [modifier - dot] = '\0'; + return resultbuf; + } + } + } + + /* The Windows API has a function returning the locale's codepage as a + number: GetACP(). This encoding is used by Cygwin, unless the user + has set the environment variable CYGWIN=codepage:oem (which very few + people do). + Output directed to console windows needs to be converted (to + GetOEMCP() if the console is using a raster font, or to + GetConsoleOutputCP() if it is using a TrueType font). Cygwin does + this conversion transparently (see winsup/cygwin/fhandler_console.cc), + converting to GetConsoleOutputCP(). This leads to correct results, + except when SetConsoleOutputCP has been called and a raster font is + in use. */ + { + char buf[2 + 10 + 1]; + + sprintf (buf, "CP%u", GetACP ()); + strcpy (resultbuf, buf); + codeset = resultbuf; + } + } +# endif + + if (codeset == NULL) + /* The canonical name cannot be determined. */ + codeset = ""; + +# elif defined WINDOWS_NATIVE + + 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_CTYPE, NULL); + char *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. */ + sprintf (buf, "CP%u", GetACP ()); + } + /* For a locale name such as "French_France.65001", in Windows 10, + setlocale now returns "French_France.utf8" instead. */ + if (strcmp (buf + 2, "65001") == 0 || strcmp (buf + 2, "utf8") == 0) + codeset = "UTF-8"; + else + { + strcpy (resultbuf, buf); + codeset = resultbuf; + } + +# elif defined OS2 + + const char *locale; + static char resultbuf[2 + 10 + 1]; + ULONG cp[3]; + ULONG cplen; + + codeset = NULL; + + /* Allow user to override the codeset, as set in the operating system, + with standard language environment variables. */ + locale = getenv ("LC_ALL"); + if (locale == NULL || locale[0] == '\0') + { + locale = getenv ("LC_CTYPE"); + if (locale == NULL || locale[0] == '\0') + locale = getenv ("LANG"); + } + if (locale != NULL && locale[0] != '\0') + { + /* If the locale name contains an encoding after the dot, return it. */ + const char *dot = strchr (locale, '.'); + + if (dot != NULL) + { + const char *modifier; + + dot++; + /* Look for the possible @... trailer and remove it, if any. */ + modifier = strchr (dot, '@'); + if (modifier == NULL) + return dot; + if (modifier - dot < sizeof (resultbuf)) + { + /* This way of filling resultbuf is multithread-safe. */ + memcpy (resultbuf, dot, modifier - dot); + resultbuf [modifier - dot] = '\0'; + return resultbuf; + } + } + + /* For the POSIX locale, don't use the system's codepage. */ + if (strcmp (locale, "C") == 0 || strcmp (locale, "POSIX") == 0) + codeset = ""; + } + + if (codeset == NULL) + { + /* OS/2 has a function returning the locale's codepage as a number. */ + if (DosQueryCp (sizeof (cp), cp, &cplen)) + codeset = ""; + else + { + char buf[2 + 10 + 1]; + + sprintf (buf, "CP%u", cp[0]); + strcpy (resultbuf, buf); + codeset = resultbuf; + } + } + +# else + +# error "Add code for other platforms here." + +# endif + + /* Resolve alias. */ + { +# ifdef alias_table_defined + /* On some platforms, UTF-8 locales are the most frequently used ones. + Speed up the common case and slow down the less common cases by + testing for this case first. */ +# if defined __OpenBSD__ || (defined __APPLE__ && defined __MACH__) || defined __sun || defined __CYGWIN__ + if (strcmp (codeset, "UTF-8") == 0) + goto done_table_lookup; + else +# endif + { + const struct table_entry * const table = alias_table; + size_t const table_size = + sizeof (alias_table) / sizeof (struct table_entry); + /* The table is sorted. Perform a binary search. */ + size_t hi = table_size; + size_t lo = 0; + while (lo < hi) + { + /* Invariant: + for i < lo, strcmp (table[i].alias, codeset) < 0, + for i >= hi, strcmp (table[i].alias, codeset) > 0. */ + size_t mid = (hi + lo) >> 1; /* >= lo, < hi */ + int cmp = strcmp (table[mid].alias, codeset); + if (cmp < 0) + lo = mid + 1; + else if (cmp > 0) + hi = mid; + else + { + /* Found an i with + strcmp (table[i].alias, codeset) == 0. */ + codeset = table[mid].canonical; + goto done_table_lookup; + } + } + } + if (0) + done_table_lookup: {} + else +# endif + { + /* Did not find it in the table. */ + /* On Mac OS X, all modern locales use the UTF-8 encoding. + BeOS and Haiku have a single locale, and it has UTF-8 encoding. */ +# if (defined __APPLE__ && defined __MACH__) || defined __BEOS__ || defined __HAIKU__ + codeset = "UTF-8"; +# else + /* Don't return an empty string. GNU libc and GNU libiconv interpret + the empty string as denoting "the locale's character encoding", + thus GNU libiconv would call this function a second time. */ + if (codeset[0] == '\0') + codeset = "ASCII"; +# endif + } + } + +#else + + /* On old systems which lack it, use setlocale or getenv. */ + const char *locale = NULL; + + /* But most old systems don't have a complete set of locales. Some + (like DJGPP) have only the C locale. Therefore we don't use setlocale + here; it would return "C" when it doesn't support the locale name the + user has set. */ +# if 0 + locale = setlocale (LC_CTYPE, NULL); +# endif + if (locale == NULL || locale[0] == '\0') + { + locale = getenv ("LC_ALL"); + if (locale == NULL || locale[0] == '\0') + { + locale = getenv ("LC_CTYPE"); + if (locale == NULL || locale[0] == '\0') + locale = getenv ("LANG"); + if (locale == NULL) + locale = ""; + } + } + + /* Map locale name to canonical encoding name. */ + { +# ifdef locale_table_defined + const struct table_entry * const table = locale_table; + size_t const table_size = + sizeof (locale_table) / sizeof (struct table_entry); + /* The table is sorted. Perform a binary search. */ + size_t hi = table_size; + size_t lo = 0; + while (lo < hi) + { + /* Invariant: + for i < lo, strcmp (table[i].locale, locale) < 0, + for i >= hi, strcmp (table[i].locale, locale) > 0. */ + size_t mid = (hi + lo) >> 1; /* >= lo, < hi */ + int cmp = strcmp (table[mid].locale, locale); + if (cmp < 0) + lo = mid + 1; + else if (cmp > 0) + hi = mid; + else + { + /* Found an i with + strcmp (table[i].locale, locale) == 0. */ + codeset = table[mid].canonical; + goto done_table_lookup; + } + } + if (0) + done_table_lookup: ; + else +# endif + { + /* Did not find it in the table. */ + /* On Mac OS X, all modern locales use the UTF-8 encoding. + BeOS and Haiku have a single locale, and it has UTF-8 encoding. */ +# if (defined __APPLE__ && defined __MACH__) || defined __BEOS__ || defined __HAIKU__ + codeset = "UTF-8"; +# else + /* The canonical name cannot be determined. */ + /* Don't return an empty string. GNU libc and GNU libiconv interpret + the empty string as denoting "the locale's character encoding", + thus GNU libiconv would call this function a second time. */ + codeset = "ASCII"; +# endif + } + } + +#endif + +#ifdef DARWIN7 + /* Mac OS X sets MB_CUR_MAX to 1 when LC_ALL=C, and "UTF-8" + (the default codeset) does not work when MB_CUR_MAX is 1. */ + if (strcmp (codeset, "UTF-8") == 0 && MB_CUR_MAX_L (uselocale (NULL)) <= 1) + codeset = "ASCII"; +#endif + + return codeset; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/localcharset.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/localcharset.h new file mode 100644 index 00000000..47214024 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/localcharset.h @@ -0,0 +1,135 @@ +/* Determine a canonical name for the current locale's character encoding. + Copyright (C) 2000-2003, 2009-2024 Free Software Foundation, Inc. + This file is part of the GNU CHARSET Library. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef _LOCALCHARSET_H +#define _LOCALCHARSET_H + + +#ifdef __cplusplus +extern "C" { +#endif + + +/* 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 + 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); + +/* About GNU canonical names for character encodings: + + Every canonical name must be supported by GNU libiconv. Support by GNU libc + is also desirable. + + The name is case insensitive. Usually an upper case MIME charset name is + preferred. + + The current list of these GNU canonical names is: + + name MIME? used by which systems + (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 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 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 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 + KOI8-R Y glibc hpux solaris freebsd netbsd openbsd darwin + KOI8-U Y glibc freebsd netbsd openbsd darwin cygwin + KOI8-T glibc + CP437 dos + CP775 dos + CP850 aix osf dos + CP852 dos + CP855 dos + CP856 aix + CP857 dos + CP861 dos + CP862 dos + CP864 dos + CP865 dos + CP866 freebsd netbsd openbsd darwin dos + CP869 dos + CP874 windows dos + CP922 aix + CP932 aix cygwin windows dos + CP943 aix zos + CP949 osf darwin windows dos + CP950 windows dos + CP1046 aix + CP1124 aix + CP1125 dos + CP1129 aix + CP1131 freebsd darwin + CP1250 windows + CP1251 glibc hpux solaris freebsd netbsd openbsd darwin cygwin windows + CP1252 aix windows + CP1253 windows + CP1254 windows + CP1255 glibc windows + CP1256 windows + CP1257 windows + 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 zos + EUC-TW glibc aix hpux irix osf solaris netbsd + 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 solaris windows + TIS-620 glibc aix hpux osf solaris cygwin zos + ARMSCII-8 glibc freebsd netbsd darwin + GEORGIAN-PS glibc cygwin + PT154 glibc netbsd cygwin + HP-ROMAN8 hpux + HP-ARABIC8 hpux + HP-GREEK8 hpux + HP-HEBREW8 hpux + HP-TURKISH8 hpux + HP-KANA8 hpux + DEC-KANJI osf + DEC-HANYU osf + UTF-8 Y glibc aix hpux osf solaris netbsd darwin cygwin 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.). + + Note: ASCII and ANSI_X3.4-1968 are synonymous canonical names. Applications + must understand both names and treat them as equivalent. + */ + + +#ifdef __cplusplus +} +#endif + + +#endif /* _LOCALCHARSET_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/locale.in.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/locale.in.h new file mode 100644 index 00000000..bda07c93 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/locale.in.h @@ -0,0 +1,310 @@ +/* A POSIX . + Copyright (C) 2007-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#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 + +/* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +/* NetBSD 5.0 mis-defines NULL. */ +#include + +/* Mac OS X 10.5 defines the locale_t type in . */ +#if @HAVE_XLOCALE_H@ +# include +#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 + */ + + /* 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 + */ + + /* 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@ && @LOCALENAME_ENHANCE_LOCALE_FUNCS@ && @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 __GLIBC__ >= 2 && @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@ && @LOCALENAME_ENHANCE_LOCALE_FUNCS@ && @HAVE_DUPLOCALE@) +# if @HAVE_DUPLOCALE@ /* locale_t may be undefined if !@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 +_GL_CXXALIAS_SYS (duplocale, locale_t, (locale_t locale)); +# endif +# endif +# if __GLIBC__ >= 2 && @HAVE_DUPLOCALE@ +_GL_CXXALIASWARN (duplocale); +# endif +# if @HAVE_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@ && @LOCALENAME_ENHANCE_LOCALE_FUNCS@ && @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 __GLIBC__ >= 2 && @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) */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/localeconv.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/localeconv.c new file mode 100644 index 00000000..10fc7b74 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/localeconv.c @@ -0,0 +1,114 @@ +/* Query locale dependent information for formatting numbers. + Copyright (C) 2012-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +#include + +#if HAVE_STRUCT_LCONV_DECIMAL_POINT + +# define FIX_CHAR_VALUE(x) ((x) >= 0 ? (x) : CHAR_MAX) + +/* Override for platforms where 'struct lconv' lacks the int_p_*, int_n_* + members or where fields of type 'char' are set to -1 instead of CHAR_MAX. */ + +struct lconv * +localeconv (void) +{ + static struct lconv result; +# undef lconv +# undef localeconv + struct lconv *sys_result = localeconv (); + + result.decimal_point = sys_result->decimal_point; + result.thousands_sep = sys_result->thousands_sep; + result.grouping = sys_result->grouping; + result.mon_decimal_point = sys_result->mon_decimal_point; + result.mon_thousands_sep = sys_result->mon_thousands_sep; + result.mon_grouping = sys_result->mon_grouping; + result.positive_sign = sys_result->positive_sign; + result.negative_sign = sys_result->negative_sign; + result.currency_symbol = sys_result->currency_symbol; + result.frac_digits = FIX_CHAR_VALUE (sys_result->frac_digits); + result.p_cs_precedes = FIX_CHAR_VALUE (sys_result->p_cs_precedes); + result.p_sign_posn = FIX_CHAR_VALUE (sys_result->p_sign_posn); + result.p_sep_by_space = FIX_CHAR_VALUE (sys_result->p_sep_by_space); + result.n_cs_precedes = FIX_CHAR_VALUE (sys_result->n_cs_precedes); + result.n_sign_posn = FIX_CHAR_VALUE (sys_result->n_sign_posn); + result.n_sep_by_space = FIX_CHAR_VALUE (sys_result->n_sep_by_space); + result.int_curr_symbol = sys_result->int_curr_symbol; + result.int_frac_digits = FIX_CHAR_VALUE (sys_result->int_frac_digits); +# if HAVE_STRUCT_LCONV_INT_P_CS_PRECEDES + result.int_p_cs_precedes = FIX_CHAR_VALUE (sys_result->int_p_cs_precedes); + result.int_p_sign_posn = FIX_CHAR_VALUE (sys_result->int_p_sign_posn); + result.int_p_sep_by_space = FIX_CHAR_VALUE (sys_result->int_p_sep_by_space); + result.int_n_cs_precedes = FIX_CHAR_VALUE (sys_result->int_n_cs_precedes); + result.int_n_sign_posn = FIX_CHAR_VALUE (sys_result->int_n_sign_posn); + result.int_n_sep_by_space = FIX_CHAR_VALUE (sys_result->int_n_sep_by_space); +# else + result.int_p_cs_precedes = FIX_CHAR_VALUE (sys_result->p_cs_precedes); + result.int_p_sign_posn = FIX_CHAR_VALUE (sys_result->p_sign_posn); + result.int_p_sep_by_space = FIX_CHAR_VALUE (sys_result->p_sep_by_space); + result.int_n_cs_precedes = FIX_CHAR_VALUE (sys_result->n_cs_precedes); + result.int_n_sign_posn = FIX_CHAR_VALUE (sys_result->n_sign_posn); + result.int_n_sep_by_space = FIX_CHAR_VALUE (sys_result->n_sep_by_space); +# endif + + return &result; +} + +#else + +/* Override for platforms where 'struct lconv' is a dummy. */ + +struct lconv * +localeconv (void) +{ + static /*const*/ struct lconv result = + { + /* decimal_point */ ".", + /* thousands_sep */ "", + /* grouping */ "", + /* mon_decimal_point */ "", + /* mon_thousands_sep */ "", + /* mon_grouping */ "", + /* positive_sign */ "", + /* negative_sign */ "", + /* currency_symbol */ "", + /* frac_digits */ CHAR_MAX, + /* p_cs_precedes */ CHAR_MAX, + /* p_sign_posn */ CHAR_MAX, + /* p_sep_by_space */ CHAR_MAX, + /* n_cs_precedes */ CHAR_MAX, + /* n_sign_posn */ CHAR_MAX, + /* n_sep_by_space */ CHAR_MAX, + /* int_curr_symbol */ "", + /* int_frac_digits */ CHAR_MAX, + /* int_p_cs_precedes */ CHAR_MAX, + /* int_p_sign_posn */ CHAR_MAX, + /* int_p_sep_by_space */ CHAR_MAX, + /* int_n_cs_precedes */ CHAR_MAX, + /* int_n_sign_posn */ CHAR_MAX, + /* int_n_sep_by_space */ CHAR_MAX + }; + + return &result; +} + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/lstat.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/lstat.c new file mode 100644 index 00000000..7c09957e --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/lstat.c @@ -0,0 +1,104 @@ +/* Work around a bug of lstat on some systems + + Copyright (C) 1997-2006, 2008-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* written by Jim Meyering */ + +/* If the user's config.h happens to include , let it include only + the system's here, so that orig_lstat doesn't recurse to + rpl_lstat. */ +#define __need_system_sys_stat_h +#include + +#if !HAVE_LSTAT +/* On systems that lack symlinks, our replacement already + defined lstat as stat, so there is nothing further to do other than + avoid an empty file. */ +typedef int dummy; +#else /* HAVE_LSTAT */ + +/* Get the original definition of lstat. It might be defined as a macro. */ +# include +# include +# undef __need_system_sys_stat_h + +static int +orig_lstat (const char *filename, struct stat *buf) +{ + return lstat (filename, buf); +} + +/* Specification. */ +# ifdef __osf__ +/* Write "sys/stat.h" here, not , otherwise OSF/1 5.1 DTK cc + eliminates this include because of the preliminary #include + above. */ +# include "sys/stat.h" +# else +# include +# endif + +# include "stat-time.h" + +# include +# include + +/* lstat works differently on Linux and Solaris systems. POSIX (see + "pathname resolution" in the glossary) requires that programs like + 'ls' take into consideration the fact that FILE has a trailing slash + when FILE is a symbolic link. On Linux and Solaris 10 systems, the + lstat function already has the desired semantics (in treating + 'lstat ("symlink/", sbuf)' just like 'lstat ("symlink/.", sbuf)', + but on Solaris 9 and earlier it does not. + + If FILE has a trailing slash and specifies a symbolic link, + then use stat() to get more info on the referent of FILE. + If the referent is a non-directory, then set errno to ENOTDIR + and return -1. Otherwise, return stat's result. */ + +int +rpl_lstat (const char *file, struct stat *sbuf) +{ + int result = orig_lstat (file, sbuf); + + /* This replacement file can blindly check against '/' rather than + using the ISSLASH macro, because all platforms with '\\' either + lack symlinks (mingw) or have working lstat (cygwin) and thus do + not compile this file. 0 len should have already been filtered + out above, with a failure return of ENOENT. */ + if (result == 0) + { + if (S_ISDIR (sbuf->st_mode) || file[strlen (file) - 1] != '/') + result = stat_time_normalize (result, sbuf); + else + { + /* At this point, a trailing slash is permitted only on + symlink-to-dir; but it should have found information on the + directory, not the symlink. Call 'stat' to get info about the + link's referent. Our replacement stat guarantees valid results, + even if the symlink is not pointing to a directory. */ + if (!S_ISLNK (sbuf->st_mode)) + { + errno = ENOTDIR; + return -1; + } + result = stat (file, sbuf); + } + } + return result; +} + +#endif /* HAVE_LSTAT */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/malloc.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/malloc.c new file mode 100644 index 00000000..2a7867a1 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/malloc.c @@ -0,0 +1,51 @@ +/* malloc() function that is glibc compatible. + + Copyright (C) 1997-1998, 2006-2007, 2009-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* written by Jim Meyering and Bruno Haible */ + +#define _GL_USE_STDLIB_ALLOC 1 +#include + +#include + +#include + +#include "xalloc-oversized.h" + +/* Allocate an N-byte block of memory from the heap, even if N is 0. */ + +void * +rpl_malloc (size_t n) +{ + if (n == 0) + n = 1; + + if (xalloc_oversized (n, 1)) + { + errno = ENOMEM; + return NULL; + } + + void *result = malloc (n); + +#if !HAVE_MALLOC_POSIX + if (result == NULL) + errno = ENOMEM; +#endif + + return result; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/malloc/.gitignore b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/malloc/.gitignore new file mode 100644 index 00000000..0c6fbbe9 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/malloc/.gitignore @@ -0,0 +1,7 @@ +/dynarray-skeleton.c +/dynarray.h +/dynarray_at_failure.c +/dynarray_emplace_enlarge.c +/dynarray_finalize.c +/dynarray_resize.c +/dynarray_resize_clear.c diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/malloc/dynarray-skeleton.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/malloc/dynarray-skeleton.c new file mode 100644 index 00000000..a95241ab --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/malloc/dynarray-skeleton.c @@ -0,0 +1,528 @@ +/* Type-safe arrays which grow dynamically. + Copyright (C) 2017-2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* Pre-processor macros which act as parameters: + + DYNARRAY_STRUCT + The struct tag of dynamic array to be defined. + DYNARRAY_ELEMENT + The type name of the element type. Elements are copied + as if by memcpy, and can change address as the dynamic + array grows. + DYNARRAY_PREFIX + The prefix of the functions which are defined. + + The following parameters are optional: + + DYNARRAY_ELEMENT_FREE + DYNARRAY_ELEMENT_FREE (E) is evaluated to deallocate the + contents of elements. E is of type DYNARRAY_ELEMENT *. + DYNARRAY_ELEMENT_INIT + DYNARRAY_ELEMENT_INIT (E) is evaluated to initialize a new + element. E is of type DYNARRAY_ELEMENT *. + If DYNARRAY_ELEMENT_FREE but not DYNARRAY_ELEMENT_INIT is + defined, new elements are automatically zero-initialized. + Otherwise, new elements have undefined contents. + DYNARRAY_INITIAL_SIZE + The size of the statically allocated array (default: + at least 2, more elements if they fit into 128 bytes). + Must be a preprocessor constant. If DYNARRAY_INITIAL_SIZE is 0, + there is no statically allocated array at, and all non-empty + arrays are heap-allocated. + DYNARRAY_FINAL_TYPE + The name of the type which holds the final array. If not + defined, is PREFIX##finalize not provided. DYNARRAY_FINAL_TYPE + must be a struct type, with members of type DYNARRAY_ELEMENT and + size_t at the start (in this order). + + These macros are undefined after this header file has been + included. + + The following types are provided (their members are private to the + dynarray implementation): + + struct DYNARRAY_STRUCT + + The following functions are provided: + + void DYNARRAY_PREFIX##init (struct DYNARRAY_STRUCT *); + void DYNARRAY_PREFIX##free (struct DYNARRAY_STRUCT *); + bool DYNARRAY_PREFIX##has_failed (const struct DYNARRAY_STRUCT *); + void DYNARRAY_PREFIX##mark_failed (struct DYNARRAY_STRUCT *); + size_t DYNARRAY_PREFIX##size (const struct DYNARRAY_STRUCT *); + DYNARRAY_ELEMENT *DYNARRAY_PREFIX##begin (const struct DYNARRAY_STRUCT *); + DYNARRAY_ELEMENT *DYNARRAY_PREFIX##end (const struct DYNARRAY_STRUCT *); + DYNARRAY_ELEMENT *DYNARRAY_PREFIX##at (struct DYNARRAY_STRUCT *, size_t); + void DYNARRAY_PREFIX##add (struct DYNARRAY_STRUCT *, DYNARRAY_ELEMENT); + DYNARRAY_ELEMENT *DYNARRAY_PREFIX##emplace (struct DYNARRAY_STRUCT *); + bool DYNARRAY_PREFIX##resize (struct DYNARRAY_STRUCT *, size_t); + void DYNARRAY_PREFIX##remove_last (struct DYNARRAY_STRUCT *); + void DYNARRAY_PREFIX##clear (struct DYNARRAY_STRUCT *); + + The following functions are provided are provided if the + prerequisites are met: + + bool DYNARRAY_PREFIX##finalize (struct DYNARRAY_STRUCT *, + DYNARRAY_FINAL_TYPE *); + (if DYNARRAY_FINAL_TYPE is defined) + DYNARRAY_ELEMENT *DYNARRAY_PREFIX##finalize (struct DYNARRAY_STRUCT *, + size_t *); + (if DYNARRAY_FINAL_TYPE is not defined) +*/ + +#include + +#include +#include +#include + +#ifndef DYNARRAY_STRUCT +# error "DYNARRAY_STRUCT must be defined" +#endif + +#ifndef DYNARRAY_ELEMENT +# error "DYNARRAY_ELEMENT must be defined" +#endif + +#ifndef DYNARRAY_PREFIX +# error "DYNARRAY_PREFIX must be defined" +#endif + +#ifdef DYNARRAY_INITIAL_SIZE +# if DYNARRAY_INITIAL_SIZE < 0 +# error "DYNARRAY_INITIAL_SIZE must be non-negative" +# endif +# if DYNARRAY_INITIAL_SIZE > 0 +# define DYNARRAY_HAVE_SCRATCH 1 +# else +# define DYNARRAY_HAVE_SCRATCH 0 +# endif +#else +/* Provide a reasonable default which limits the size of + DYNARRAY_STRUCT. */ +# define DYNARRAY_INITIAL_SIZE \ + (sizeof (DYNARRAY_ELEMENT) > 64 ? 2 : 128 / sizeof (DYNARRAY_ELEMENT)) +# define DYNARRAY_HAVE_SCRATCH 1 +#endif + +/* Public type definitions. */ + +/* All fields of this struct are private to the implementation. */ +struct DYNARRAY_STRUCT +{ + union + { + struct dynarray_header dynarray_abstract; + struct + { + /* These fields must match struct dynarray_header. */ + size_t used; + size_t allocated; + DYNARRAY_ELEMENT *array; + } dynarray_header; + } u; + +#if DYNARRAY_HAVE_SCRATCH + /* Initial inline allocation. */ + DYNARRAY_ELEMENT scratch[DYNARRAY_INITIAL_SIZE]; +#endif +}; + +/* Internal use only: Helper macros. */ + +/* Ensure macro-expansion of DYNARRAY_PREFIX. */ +#define DYNARRAY_CONCAT0(prefix, name) prefix##name +#define DYNARRAY_CONCAT1(prefix, name) DYNARRAY_CONCAT0(prefix, name) +#define DYNARRAY_NAME(name) DYNARRAY_CONCAT1(DYNARRAY_PREFIX, name) + +/* Use DYNARRAY_FREE instead of DYNARRAY_NAME (free), + so that Gnulib does not change 'free' to 'rpl_free'. */ +#define DYNARRAY_FREE DYNARRAY_CONCAT1 (DYNARRAY_NAME (f), ree) + +/* Address of the scratch buffer if any. */ +#if DYNARRAY_HAVE_SCRATCH +# define DYNARRAY_SCRATCH(list) (list)->scratch +#else +# define DYNARRAY_SCRATCH(list) NULL +#endif + +/* Internal use only: Helper functions. */ + +/* Internal function. Call DYNARRAY_ELEMENT_FREE with the array + elements. Name mangling needed due to the DYNARRAY_ELEMENT_FREE + macro expansion. */ +static inline void +DYNARRAY_NAME (free__elements__) (DYNARRAY_ELEMENT *__dynarray_array, + size_t __dynarray_used) +{ +#ifdef DYNARRAY_ELEMENT_FREE + for (size_t __dynarray_i = 0; __dynarray_i < __dynarray_used; ++__dynarray_i) + DYNARRAY_ELEMENT_FREE (&__dynarray_array[__dynarray_i]); +#endif /* DYNARRAY_ELEMENT_FREE */ +} + +/* Internal function. Free the non-scratch array allocation. */ +static inline void +DYNARRAY_NAME (free__array__) (struct DYNARRAY_STRUCT *list) +{ +#if DYNARRAY_HAVE_SCRATCH + if (list->u.dynarray_header.array != list->scratch) + free (list->u.dynarray_header.array); +#else + free (list->u.dynarray_header.array); +#endif +} + +/* Public functions. */ + +/* Initialize a dynamic array object. This must be called before any + use of the object. */ +__attribute_nonnull__ ((1)) +static void +DYNARRAY_NAME (init) (struct DYNARRAY_STRUCT *list) +{ + list->u.dynarray_header.used = 0; + list->u.dynarray_header.allocated = DYNARRAY_INITIAL_SIZE; + list->u.dynarray_header.array = DYNARRAY_SCRATCH (list); +} + +/* Deallocate the dynamic array and its elements. */ +__attribute_maybe_unused__ __attribute_nonnull__ ((1)) +static void +DYNARRAY_FREE (struct DYNARRAY_STRUCT *list) +{ + DYNARRAY_NAME (free__elements__) + (list->u.dynarray_header.array, list->u.dynarray_header.used); + DYNARRAY_NAME (free__array__) (list); + DYNARRAY_NAME (init) (list); +} + +/* Return true if the dynamic array is in an error state. */ +__attribute_nonnull__ ((1)) +static inline bool +DYNARRAY_NAME (has_failed) (const struct DYNARRAY_STRUCT *list) +{ + return list->u.dynarray_header.allocated == __dynarray_error_marker (); +} + +/* Mark the dynamic array as failed. All elements are deallocated as + a side effect. */ +__attribute_nonnull__ ((1)) +static void +DYNARRAY_NAME (mark_failed) (struct DYNARRAY_STRUCT *list) +{ + DYNARRAY_NAME (free__elements__) + (list->u.dynarray_header.array, list->u.dynarray_header.used); + DYNARRAY_NAME (free__array__) (list); + list->u.dynarray_header.array = DYNARRAY_SCRATCH (list); + list->u.dynarray_header.used = 0; + list->u.dynarray_header.allocated = __dynarray_error_marker (); +} + +/* Return the number of elements which have been added to the dynamic + array. */ +__attribute_nonnull__ ((1)) +static inline size_t +DYNARRAY_NAME (size) (const struct DYNARRAY_STRUCT *list) +{ + return list->u.dynarray_header.used; +} + +/* Return a pointer to the array element at INDEX. Terminate the + process if INDEX is out of bounds. */ +__attribute_nonnull__ ((1)) +static inline DYNARRAY_ELEMENT * +DYNARRAY_NAME (at) (struct DYNARRAY_STRUCT *list, size_t index) +{ + if (__glibc_unlikely (index >= DYNARRAY_NAME (size) (list))) + __libc_dynarray_at_failure (DYNARRAY_NAME (size) (list), index); + return list->u.dynarray_header.array + index; +} + +/* Return a pointer to the first array element, if any. For a + zero-length array, the pointer can be NULL even though the dynamic + array has not entered the failure state. */ +__attribute_nonnull__ ((1)) +static inline DYNARRAY_ELEMENT * +DYNARRAY_NAME (begin) (struct DYNARRAY_STRUCT *list) +{ + return list->u.dynarray_header.array; +} + +/* Return a pointer one element past the last array element. For a + zero-length array, the pointer can be NULL even though the dynamic + array has not entered the failure state. */ +__attribute_nonnull__ ((1)) +static inline DYNARRAY_ELEMENT * +DYNARRAY_NAME (end) (struct DYNARRAY_STRUCT *list) +{ + return list->u.dynarray_header.array + list->u.dynarray_header.used; +} + +/* Internal function. Slow path for the add function below. */ +static void +DYNARRAY_NAME (add__) (struct DYNARRAY_STRUCT *list, DYNARRAY_ELEMENT item) +{ + if (__glibc_unlikely + (!__libc_dynarray_emplace_enlarge (&list->u.dynarray_abstract, + DYNARRAY_SCRATCH (list), + sizeof (DYNARRAY_ELEMENT)))) + { + DYNARRAY_NAME (mark_failed) (list); + return; + } + + /* Copy the new element and increase the array length. */ + list->u.dynarray_header.array[list->u.dynarray_header.used++] = item; +} + +/* Add ITEM at the end of the array, enlarging it by one element. + Mark *LIST as failed if the dynamic array allocation size cannot be + increased. */ +__attribute_nonnull__ ((1)) +static inline void +DYNARRAY_NAME (add) (struct DYNARRAY_STRUCT *list, DYNARRAY_ELEMENT item) +{ + /* Do nothing in case of previous error. */ + if (DYNARRAY_NAME (has_failed) (list)) + return; + + /* Enlarge the array if necessary. */ + if (__glibc_unlikely (list->u.dynarray_header.used + == list->u.dynarray_header.allocated)) + { + DYNARRAY_NAME (add__) (list, item); + return; + } + + /* Copy the new element and increase the array length. */ + list->u.dynarray_header.array[list->u.dynarray_header.used++] = item; +} + +/* Internal function. Building block for the emplace functions below. + Assumes space for one more element in *LIST. */ +static inline DYNARRAY_ELEMENT * +DYNARRAY_NAME (emplace__tail__) (struct DYNARRAY_STRUCT *list) +{ + DYNARRAY_ELEMENT *result + = &list->u.dynarray_header.array[list->u.dynarray_header.used]; + ++list->u.dynarray_header.used; +#if defined (DYNARRAY_ELEMENT_INIT) + DYNARRAY_ELEMENT_INIT (result); +#elif defined (DYNARRAY_ELEMENT_FREE) + memset (result, 0, sizeof (*result)); +#endif + return result; +} + +/* Internal function. Slow path for the emplace function below. */ +static DYNARRAY_ELEMENT * +DYNARRAY_NAME (emplace__) (struct DYNARRAY_STRUCT *list) +{ + if (__glibc_unlikely + (!__libc_dynarray_emplace_enlarge (&list->u.dynarray_abstract, + DYNARRAY_SCRATCH (list), + sizeof (DYNARRAY_ELEMENT)))) + { + DYNARRAY_NAME (mark_failed) (list); + return NULL; + } + return DYNARRAY_NAME (emplace__tail__) (list); +} + +/* Allocate a place for a new element in *LIST and return a pointer to + it. The pointer can be NULL if the dynamic array cannot be + enlarged due to a memory allocation failure. */ +__attribute_maybe_unused__ __attribute_warn_unused_result__ +__attribute_nonnull__ ((1)) +static +/* Avoid inlining with the larger initialization code. */ +#if !(defined (DYNARRAY_ELEMENT_INIT) || defined (DYNARRAY_ELEMENT_FREE)) +inline +#endif +DYNARRAY_ELEMENT * +DYNARRAY_NAME (emplace) (struct DYNARRAY_STRUCT *list) +{ + /* Do nothing in case of previous error. */ + if (DYNARRAY_NAME (has_failed) (list)) + return NULL; + + /* Enlarge the array if necessary. */ + if (__glibc_unlikely (list->u.dynarray_header.used + == list->u.dynarray_header.allocated)) + return (DYNARRAY_NAME (emplace__) (list)); + return DYNARRAY_NAME (emplace__tail__) (list); +} + +/* Change the size of *LIST to SIZE. If SIZE is larger than the + existing size, new elements are added (which can be initialized). + Otherwise, the list is truncated, and elements are freed. Return + false on memory allocation failure (and mark *LIST as failed). */ +__attribute_maybe_unused__ __attribute_nonnull__ ((1)) +static bool +DYNARRAY_NAME (resize) (struct DYNARRAY_STRUCT *list, size_t size) +{ + if (size > list->u.dynarray_header.used) + { + bool ok; +#if defined (DYNARRAY_ELEMENT_INIT) + /* The new elements have to be initialized. */ + size_t old_size = list->u.dynarray_header.used; + ok = __libc_dynarray_resize (&list->u.dynarray_abstract, + size, DYNARRAY_SCRATCH (list), + sizeof (DYNARRAY_ELEMENT)); + if (ok) + for (size_t i = old_size; i < size; ++i) + { + DYNARRAY_ELEMENT_INIT (&list->u.dynarray_header.array[i]); + } +#elif defined (DYNARRAY_ELEMENT_FREE) + /* Zero initialization is needed so that the elements can be + safely freed. */ + ok = __libc_dynarray_resize_clear + (&list->u.dynarray_abstract, size, + DYNARRAY_SCRATCH (list), sizeof (DYNARRAY_ELEMENT)); +#else + ok = __libc_dynarray_resize (&list->u.dynarray_abstract, + size, DYNARRAY_SCRATCH (list), + sizeof (DYNARRAY_ELEMENT)); +#endif + if (__glibc_unlikely (!ok)) + DYNARRAY_NAME (mark_failed) (list); + return ok; + } + else + { + /* The list has shrunk in size. Free the removed elements. */ + DYNARRAY_NAME (free__elements__) + (list->u.dynarray_header.array + size, + list->u.dynarray_header.used - size); + list->u.dynarray_header.used = size; + return true; + } +} + +/* Remove the last element of LIST if it is present. */ +__attribute_maybe_unused__ __attribute_nonnull__ ((1)) +static void +DYNARRAY_NAME (remove_last) (struct DYNARRAY_STRUCT *list) +{ + /* used > 0 implies that the array is the non-failed state. */ + if (list->u.dynarray_header.used > 0) + { + size_t new_length = list->u.dynarray_header.used - 1; +#ifdef DYNARRAY_ELEMENT_FREE + DYNARRAY_ELEMENT_FREE (&list->u.dynarray_header.array[new_length]); +#endif + list->u.dynarray_header.used = new_length; + } +} + +/* Remove all elements from the list. The elements are freed, but the + list itself is not. */ +__attribute_maybe_unused__ __attribute_nonnull__ ((1)) +static void +DYNARRAY_NAME (clear) (struct DYNARRAY_STRUCT *list) +{ + /* free__elements__ does nothing if the list is in the failed + state. */ + DYNARRAY_NAME (free__elements__) + (list->u.dynarray_header.array, list->u.dynarray_header.used); + list->u.dynarray_header.used = 0; +} + +#ifdef DYNARRAY_FINAL_TYPE +/* Transfer the dynamic array to a permanent location at *RESULT. + Returns true on success on false on allocation failure. In either + case, *LIST is re-initialized and can be reused. A NULL pointer is + stored in *RESULT if LIST refers to an empty list. On success, the + pointer in *RESULT is heap-allocated and must be deallocated using + free. */ +__attribute_maybe_unused__ __attribute_warn_unused_result__ +__attribute_nonnull__ ((1, 2)) +static bool +DYNARRAY_NAME (finalize) (struct DYNARRAY_STRUCT *list, + DYNARRAY_FINAL_TYPE *result) +{ + struct dynarray_finalize_result res; + if (__libc_dynarray_finalize (&list->u.dynarray_abstract, + DYNARRAY_SCRATCH (list), + sizeof (DYNARRAY_ELEMENT), &res)) + { + /* On success, the result owns all the data. */ + DYNARRAY_NAME (init) (list); + *result = (DYNARRAY_FINAL_TYPE) { res.array, res.length }; + return true; + } + else + { + /* On error, we need to free all data. */ + DYNARRAY_FREE (list); + errno = ENOMEM; + return false; + } +} +#else /* !DYNARRAY_FINAL_TYPE */ +/* Transfer the dynamic array to a heap-allocated array and return a + pointer to it. The pointer is NULL if memory allocation fails, or + if the array is empty, so this function should be used only for + arrays which are known not be empty (usually because they always + have a sentinel at the end). If LENGTHP is not NULL, the array + length is written to *LENGTHP. *LIST is re-initialized and can be + reused. */ +__attribute_maybe_unused__ __attribute_warn_unused_result__ +__attribute_nonnull__ ((1)) +static DYNARRAY_ELEMENT * +DYNARRAY_NAME (finalize) (struct DYNARRAY_STRUCT *list, size_t *lengthp) +{ + struct dynarray_finalize_result res; + if (__libc_dynarray_finalize (&list->u.dynarray_abstract, + DYNARRAY_SCRATCH (list), + sizeof (DYNARRAY_ELEMENT), &res)) + { + /* On success, the result owns all the data. */ + DYNARRAY_NAME (init) (list); + if (lengthp != NULL) + *lengthp = res.length; + return res.array; + } + else + { + /* On error, we need to free all data. */ + DYNARRAY_FREE (list); + errno = ENOMEM; + return NULL; + } +} +#endif /* !DYNARRAY_FINAL_TYPE */ + +/* Undo macro definitions. */ + +#undef DYNARRAY_CONCAT0 +#undef DYNARRAY_CONCAT1 +#undef DYNARRAY_NAME +#undef DYNARRAY_SCRATCH +#undef DYNARRAY_HAVE_SCRATCH + +#undef DYNARRAY_STRUCT +#undef DYNARRAY_ELEMENT +#undef DYNARRAY_PREFIX +#undef DYNARRAY_ELEMENT_FREE +#undef DYNARRAY_ELEMENT_INIT +#undef DYNARRAY_INITIAL_SIZE +#undef DYNARRAY_FINAL_TYPE diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/malloc/dynarray.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/malloc/dynarray.h new file mode 100644 index 00000000..3163e278 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/malloc/dynarray.h @@ -0,0 +1,177 @@ +/* Type-safe arrays which grow dynamically. Shared definitions. + Copyright (C) 2017-2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* To use the dynarray facility, you need to include + and define the parameter macros + documented in that file. + + A minimal example which provides a growing list of integers can be + defined like this: + + struct int_array + { + // Pointer to result array followed by its length, + // as required by DYNARRAY_FINAL_TYPE. + int *array; + size_t length; + }; + + #define DYNARRAY_STRUCT dynarray_int + #define DYNARRAY_ELEMENT int + #define DYNARRAY_PREFIX dynarray_int_ + #define DYNARRAY_FINAL_TYPE struct int_array + #include + + To create a three-element array with elements 1, 2, 3, use this + code: + + struct dynarray_int dyn; + dynarray_int_init (&dyn); + for (int i = 1; i <= 3; ++i) + { + int *place = dynarray_int_emplace (&dyn); + assert (place != NULL); + *place = i; + } + struct int_array result; + bool ok = dynarray_int_finalize (&dyn, &result); + assert (ok); + assert (result.length == 3); + assert (result.array[0] == 1); + assert (result.array[1] == 2); + assert (result.array[2] == 3); + free (result.array); + + If the elements contain resources which must be freed, define + DYNARRAY_ELEMENT_FREE appropriately, like this: + + struct str_array + { + char **array; + size_t length; + }; + + #define DYNARRAY_STRUCT dynarray_str + #define DYNARRAY_ELEMENT char * + #define DYNARRAY_ELEMENT_FREE(ptr) free (*ptr) + #define DYNARRAY_PREFIX dynarray_str_ + #define DYNARRAY_FINAL_TYPE struct str_array + #include + + Compared to scratch buffers, dynamic arrays have the following + features: + + - They have an element type, and are not just an untyped buffer of + bytes. + + - When growing, previously stored elements are preserved. (It is + expected that scratch_buffer_grow_preserve and + scratch_buffer_set_array_size eventually go away because all + current users are moved to dynamic arrays.) + + - Scratch buffers have a more aggressive growth policy because + growing them typically means a retry of an operation (across an + NSS service module boundary), which is expensive. + + - For the same reason, scratch buffers have a much larger initial + stack allocation. */ + +#ifndef _DYNARRAY_H +#define _DYNARRAY_H + +#include +#include + +struct dynarray_header +{ + size_t used; + size_t allocated; + void *array; +}; + +/* Marker used in the allocated member to indicate that an error was + encountered. */ +static inline size_t +__dynarray_error_marker (void) +{ + return -1; +} + +/* Internal function. See the has_failed function in + dynarray-skeleton.c. */ +static inline bool +__dynarray_error (struct dynarray_header *list) +{ + return list->allocated == __dynarray_error_marker (); +} + +/* Internal function. Enlarge the dynamically allocated area of the + array to make room for one more element. SCRATCH is a pointer to + the scratch area (which is not heap-allocated and must not be + freed). ELEMENT_SIZE is the size, in bytes, of one element. + Return false on failure, true on success. */ +bool __libc_dynarray_emplace_enlarge (struct dynarray_header *, + void *scratch, size_t element_size); + +/* Internal function. Enlarge the dynamically allocated area of the + array to make room for at least SIZE elements (which must be larger + than the existing used part of the dynamic array). SCRATCH is a + pointer to the scratch area (which is not heap-allocated and must + not be freed). ELEMENT_SIZE is the size, in bytes, of one element. + Return false on failure, true on success. */ +bool __libc_dynarray_resize (struct dynarray_header *, size_t size, + void *scratch, size_t element_size); + +/* Internal function. Like __libc_dynarray_resize, but clear the new + part of the dynamic array. */ +bool __libc_dynarray_resize_clear (struct dynarray_header *, size_t size, + void *scratch, size_t element_size); + +/* Internal type. */ +struct dynarray_finalize_result +{ + void *array; + size_t length; +}; + +/* Internal function. Copy the dynamically-allocated area to an + explicitly-sized heap allocation. SCRATCH is a pointer to the + embedded scratch space. ELEMENT_SIZE is the size, in bytes, of the + element type. On success, true is returned, and pointer and length + are written to *RESULT. On failure, false is returned. The caller + has to take care of some of the memory management; this function is + expected to be called from dynarray-skeleton.c. */ +bool __libc_dynarray_finalize (struct dynarray_header *list, void *scratch, + size_t element_size, + struct dynarray_finalize_result *result); + + +/* Internal function. Terminate the process after an index error. + SIZE is the number of elements of the dynamic array. INDEX is the + lookup index which triggered the failure. */ +_Noreturn void __libc_dynarray_at_failure (size_t size, size_t index); + +#ifndef _ISOMAC +libc_hidden_proto (__libc_dynarray_emplace_enlarge) +libc_hidden_proto (__libc_dynarray_resize) +libc_hidden_proto (__libc_dynarray_resize_clear) +libc_hidden_proto (__libc_dynarray_finalize) +libc_hidden_proto (__libc_dynarray_at_failure) +#endif + +#endif /* _DYNARRAY_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/malloc/dynarray_at_failure.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/malloc/dynarray_at_failure.c new file mode 100644 index 00000000..95e34e7a --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/malloc/dynarray_at_failure.c @@ -0,0 +1,40 @@ +/* Report an dynamic array index out of bounds condition. + Copyright (C) 2017-2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _LIBC +# include +# include +#endif + +#include +#include + +void +__libc_dynarray_at_failure (size_t size, size_t index) +{ +#ifdef _LIBC + char buf[200]; + __snprintf (buf, sizeof (buf), "Fatal glibc error: " + "array index %zu not less than array length %zu\n", + index, size); + __libc_fatal (buf); +#else + abort (); +#endif +} +libc_hidden_def (__libc_dynarray_at_failure) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/malloc/dynarray_emplace_enlarge.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/malloc/dynarray_emplace_enlarge.c new file mode 100644 index 00000000..7bdba159 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/malloc/dynarray_emplace_enlarge.c @@ -0,0 +1,77 @@ +/* Increase the size of a dynamic array in preparation of an emplace operation. + Copyright (C) 2017-2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _LIBC +# include +#endif + +#include +#include +#include +#include +#include + +bool +__libc_dynarray_emplace_enlarge (struct dynarray_header *list, + void *scratch, size_t element_size) +{ + size_t new_allocated; + if (list->allocated == 0) + { + /* No scratch buffer provided. Choose a reasonable default + size. */ + if (element_size < 4) + new_allocated = 16; + else if (element_size < 8) + new_allocated = 8; + else + new_allocated = 4; + } + else + /* Increase the allocated size, using an exponential growth + policy. */ + { + new_allocated = list->allocated + list->allocated / 2 + 1; + if (new_allocated <= list->allocated) + { + /* Overflow. */ + __set_errno (ENOMEM); + return false; + } + } + + size_t new_size; + if (ckd_mul (&new_size, new_allocated, element_size)) + return false; + void *new_array; + if (list->array == scratch) + { + /* The previous array was not heap-allocated. */ + new_array = malloc (new_size); + if (new_array != NULL && list->array != NULL) + memcpy (new_array, list->array, list->used * element_size); + } + else + new_array = realloc (list->array, new_size); + if (new_array == NULL) + return false; + list->array = new_array; + list->allocated = new_allocated; + return true; +} +libc_hidden_def (__libc_dynarray_emplace_enlarge) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/malloc/dynarray_finalize.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/malloc/dynarray_finalize.c new file mode 100644 index 00000000..52764f73 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/malloc/dynarray_finalize.c @@ -0,0 +1,66 @@ +/* Copy the dynamically-allocated area to an explicitly-sized heap allocation. + Copyright (C) 2017-2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _LIBC +# include +#endif + +#include +#include +#include + +bool +__libc_dynarray_finalize (struct dynarray_header *list, + void *scratch, size_t element_size, + struct dynarray_finalize_result *result) +{ + if (__dynarray_error (list)) + /* The caller will reported the deferred error. */ + return false; + + size_t used = list->used; + + /* Empty list. */ + if (used == 0) + { + /* An empty list could still be backed by a heap-allocated + array. Free it if necessary. */ + if (list->array != scratch) + free (list->array); + *result = (struct dynarray_finalize_result) { NULL, 0 }; + return true; + } + + size_t allocation_size = used * element_size; + void *heap_array = malloc (allocation_size); + if (heap_array != NULL) + { + /* The new array takes ownership of the strings. */ + if (list->array != NULL) + memcpy (heap_array, list->array, allocation_size); + if (list->array != scratch) + free (list->array); + *result = (struct dynarray_finalize_result) + { .array = heap_array, .length = used }; + return true; + } + else + /* The caller will perform the freeing operation. */ + return false; +} +libc_hidden_def (__libc_dynarray_finalize) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/malloc/dynarray_resize.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/malloc/dynarray_resize.c new file mode 100644 index 00000000..7323f8ee --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/malloc/dynarray_resize.c @@ -0,0 +1,68 @@ +/* Increase the size of a dynamic array. + Copyright (C) 2017-2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _LIBC +# include +#endif + +#include +#include +#include +#include +#include + +bool +__libc_dynarray_resize (struct dynarray_header *list, size_t size, + void *scratch, size_t element_size) +{ + /* The existing allocation provides sufficient room. */ + if (size <= list->allocated) + { + list->used = size; + return true; + } + + /* Otherwise, use size as the new allocation size. The caller is + expected to provide the final size of the array, so there is no + over-allocation here. */ + + size_t new_size_bytes; + if (ckd_mul (&new_size_bytes, size, element_size)) + { + /* Overflow. */ + __set_errno (ENOMEM); + return false; + } + void *new_array; + if (list->array == scratch) + { + /* The previous array was not heap-allocated. */ + new_array = malloc (new_size_bytes); + if (new_array != NULL && list->array != NULL) + memcpy (new_array, list->array, list->used * element_size); + } + else + new_array = realloc (list->array, new_size_bytes); + if (new_array == NULL) + return false; + list->array = new_array; + list->allocated = size; + list->used = size; + return true; +} +libc_hidden_def (__libc_dynarray_resize) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/malloc/dynarray_resize_clear.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/malloc/dynarray_resize_clear.c new file mode 100644 index 00000000..aa17f740 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/malloc/dynarray_resize_clear.c @@ -0,0 +1,39 @@ +/* Increase the size of a dynamic array and clear the new part. + Copyright (C) 2017-2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _LIBC +# include +#endif + +#include +#include + +bool +__libc_dynarray_resize_clear (struct dynarray_header *list, size_t size, + void *scratch, size_t element_size) +{ + size_t old_size = list->used; + if (!__libc_dynarray_resize (list, size, scratch, element_size)) + return false; + /* __libc_dynarray_resize already checked for overflow. */ + char *array = list->array; + memset (array + (old_size * element_size), 0, + (size - old_size) * element_size); + return true; +} +libc_hidden_def (__libc_dynarray_resize_clear) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/malloca.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/malloca.c new file mode 100644 index 00000000..e75c72df --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/malloca.c @@ -0,0 +1,135 @@ +/* Safe automatic memory allocation. + Copyright (C) 2003, 2006-2007, 2009-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2003, 2018. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#define _GL_USE_STDLIB_ALLOC 1 +#include + +/* Specification. */ +#include "malloca.h" + +#include +#if defined __CHERI_PURE_CAPABILITY__ +# include +#endif + +#include "idx.h" + +/* The speed critical point in this file is freea() applied to an alloca() + result: it must be fast, to match the speed of alloca(). The speed of + mmalloca() and freea() in the other case are not critical, because they + are only invoked for big memory sizes. + Here we use a bit in the address as an indicator, an idea by Ondřej Bílka. + malloca() can return three types of pointers: + - Pointers ≡ 0 mod 2*sa_alignment_max come from stack allocation. + - Pointers ≡ sa_alignment_max mod 2*sa_alignment_max come from heap + allocation. + - NULL comes from a failed heap allocation. */ + +#if defined __CHERI_PURE_CAPABILITY__ +/* Type for holding the original malloc() result. */ +typedef uintptr_t small_t; +#else +/* Type for holding very small pointer differences. */ +typedef unsigned char small_t; +/* Verify that it is wide enough. */ +static_assert (2 * sa_alignment_max - 1 <= (small_t) -1); +#endif + +void * +mmalloca (size_t n) +{ +#if HAVE_ALLOCA + /* Allocate one more word, used to determine the address to pass to freea(), + and room for the alignment ≡ sa_alignment_max mod 2*sa_alignment_max. */ + uintptr_t alignment2_mask = 2 * sa_alignment_max - 1; + int plus = sizeof (small_t) + alignment2_mask; + idx_t nplus; + if (!ckd_add (&nplus, n, plus) && !xalloc_oversized (nplus, 1)) + { + char *mem = (char *) malloc (nplus); + + if (mem != NULL) + { + uintptr_t umem = (uintptr_t) mem; + /* The ckd_add avoids signed integer overflow on + theoretical platforms where UINTPTR_MAX <= INT_MAX. */ + uintptr_t umemplus; + ckd_add (&umemplus, umem, sizeof (small_t) + sa_alignment_max - 1); + idx_t offset = (umemplus - umemplus % (2 * sa_alignment_max) + + sa_alignment_max - umem); + void *p = mem + offset; + /* Here p >= mem + sizeof (small_t), + and p <= mem + sizeof (small_t) + 2 * sa_alignment_max - 1 + hence p + n <= mem + nplus. + So, the memory range [p, p+n) lies in the allocated memory range + [mem, mem + nplus). */ + small_t *sp = p; +# if defined __CHERI_PURE_CAPABILITY__ + sp[-1] = umem; + p = (char *) cheri_bounds_set ((char *) p - sizeof (small_t), + sizeof (small_t) + n) + + sizeof (small_t); +# else + sp[-1] = offset; +# endif + /* p ≡ sa_alignment_max mod 2*sa_alignment_max. */ + return p; + } + } + /* Out of memory. */ + return NULL; +#else +# if !MALLOC_0_IS_NONNULL + if (n == 0) + n = 1; +# endif + return malloc (n); +#endif +} + +#if HAVE_ALLOCA +void +freea (void *p) +{ + /* Check argument. */ + uintptr_t u = (uintptr_t) p; + if (u & (sa_alignment_max - 1)) + { + /* p was not the result of a malloca() call. Invalid argument. */ + abort (); + } + /* Determine whether p was a non-NULL pointer returned by mmalloca(). */ + if (u & sa_alignment_max) + { + char *cp = p; + small_t *sp = p; +# if defined __CHERI_PURE_CAPABILITY__ + void *mem = sp[-1]; +# else + void *mem = cp - sp[-1]; +# endif + free (mem); + } +} +#endif + +/* + * Hey Emacs! + * Local Variables: + * coding: utf-8 + * End: + */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/malloca.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/malloca.h new file mode 100644 index 00000000..c5208421 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/malloca.h @@ -0,0 +1,147 @@ +/* Safe automatic memory allocation. + Copyright (C) 2003-2007, 2009-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2003. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef _MALLOCA_H +#define _MALLOCA_H + +/* This file uses _GL_ATTRIBUTE_ALLOC_SIZE, _GL_ATTRIBUTE_DEALLOC, + _GL_ATTRIBUTE_MALLOC, HAVE_ALLOCA. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +#include +#include +#include +#include +#if defined __CHERI_PURE_CAPABILITY__ +# include +#endif + +#include "xalloc-oversized.h" + + +#ifdef __cplusplus +extern "C" { +#endif + + +/* safe_alloca(N) is equivalent to alloca(N) when it is safe to call + alloca(N); otherwise it returns NULL. It either returns N bytes of + memory allocated on the stack, that lasts until the function returns, + or NULL. + Use of safe_alloca should be avoided: + - inside arguments of function calls - undefined behaviour, + - in inline functions - the allocation may actually last until the + calling function returns. +*/ +#if HAVE_ALLOCA +/* The OS usually guarantees only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + allocate anything larger than 4096 bytes. Also care for the possibility + of a few compiler-allocated temporary stack slots. + This must be a macro, not a function. */ +# define safe_alloca(N) ((N) < 4032 ? alloca (N) : NULL) +#else +# define safe_alloca(N) ((void) (N), NULL) +#endif + +/* Free a block of memory allocated through malloca(). */ +#if HAVE_ALLOCA +extern void freea (void *p); +#else +# define freea free +#endif + +/* malloca(N) is a safe variant of alloca(N). It allocates N bytes of + memory allocated on the stack, that must be freed using freea() before + the function returns. Upon failure, it returns NULL. */ +#if HAVE_ALLOCA +# if defined __CHERI_PURE_CAPABILITY__ +# define malloca(N) \ + ((N) < 4032 - (2 * sa_alignment_max - 1) \ + ? cheri_bounds_set ((void *) (((uintptr_t) \ + (char *) \ + alloca ((N) + 2 * sa_alignment_max - 1) \ + + (2 * sa_alignment_max - 1)) \ + & ~(uintptr_t)(2 * sa_alignment_max - 1)), \ + (N)) \ + : mmalloca (N)) +# else +# define malloca(N) \ + ((N) < 4032 - (2 * sa_alignment_max - 1) \ + ? (void *) (((uintptr_t) (char *) alloca ((N) + 2 * sa_alignment_max - 1) \ + + (2 * sa_alignment_max - 1)) \ + & ~(uintptr_t)(2 * sa_alignment_max - 1)) \ + : mmalloca (N)) +# endif +#else +# define malloca(N) \ + mmalloca (N) +#endif +extern void *mmalloca (size_t n) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC (freea, 1) + _GL_ATTRIBUTE_ALLOC_SIZE ((1)); + +/* nmalloca(N,S) is an overflow-safe variant of malloca (N * S). + It allocates an array of N objects, each with S bytes of memory, + on the stack. N and S should be nonnegative and free of side effects. + The array must be freed using freea() before the function returns. */ +#define nmalloca(n, s) \ + (xalloc_oversized (n, s) ? NULL : malloca ((n) * (size_t) (s))) + + +#ifdef __cplusplus +} +#endif + + +/* ------------------- Auxiliary, non-public definitions ------------------- */ + +/* Determine the alignment of a type at compile time. */ +#if defined __GNUC__ || defined __clang__ || defined __IBM__ALIGNOF__ +# define sa_alignof __alignof__ +#elif defined __cplusplus + template struct sa_alignof_helper { char __slot1; type __slot2; }; +# define sa_alignof(type) offsetof (sa_alignof_helper, __slot2) +#elif defined __hpux + /* Work around a HP-UX 10.20 cc bug with enums constants defined as offsetof + values. */ +# define sa_alignof(type) (sizeof (type) <= 4 ? 4 : 8) +#elif defined _AIX + /* Work around an AIX 3.2.5 xlc bug with enums constants defined as offsetof + values. */ +# define sa_alignof(type) (sizeof (type) <= 4 ? 4 : 8) +#else +# define sa_alignof(type) offsetof (struct { char __slot1; type __slot2; }, __slot2) +#endif + +enum +{ +/* The desired alignment of memory allocations is the maximum alignment + among all elementary types. */ + sa_alignment_long = sa_alignof (long), + sa_alignment_double = sa_alignof (double), + sa_alignment_longlong = sa_alignof (long long), + sa_alignment_longdouble = sa_alignof (long double), + sa_alignment_max = ((sa_alignment_long - 1) | (sa_alignment_double - 1) + | (sa_alignment_longlong - 1) + | (sa_alignment_longdouble - 1) + ) + 1 +}; + +#endif /* _MALLOCA_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbchar.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbchar.c new file mode 100644 index 00000000..d94b7c33 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbchar.c @@ -0,0 +1,23 @@ +/* Copyright (C) 2001, 2006, 2009-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + + +#include + +#define MBCHAR_INLINE _GL_EXTERN_INLINE + +#include + +#include "mbchar.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbchar.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbchar.h new file mode 100644 index 00000000..c06ef11b --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbchar.h @@ -0,0 +1,373 @@ +/* Multibyte character data type. + Copyright (C) 2001, 2005-2007, 2009-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible . */ + +/* A multibyte character is a short subsequence of a char* string, + representing a single 32-bit wide character. + + We use multibyte characters instead of 32-bit wide characters because + of the following goals: + 1) correct multibyte handling, i.e. operate according to the LC_CTYPE + locale, + 2) ease of maintenance, i.e. the maintainer needs not know all details + of the ISO C 99 standard, + 3) don't fail grossly if the input is not in the encoding set by the + locale, because often different encodings are in use in the same + countries (ISO-8859-1/UTF-8, EUC-JP/Shift_JIS, ...), + 4) fast in the case of ASCII characters. + + Multibyte characters are only accessed through the mb* macros. + + mb_ptr (mbc) + return a pointer to the beginning of the multibyte sequence. + + mb_len (mbc) + returns the number of bytes occupied by the multibyte sequence. + Always > 0. + + mb_iseq (mbc, sc) + returns true if mbc is the standard ASCII character sc. + + mb_isnul (mbc) + returns true if mbc is the nul character. + + mb_cmp (mbc1, mbc2) + returns a positive, zero, or negative value depending on whether mbc1 + sorts after, same or before mbc2. + + mb_casecmp (mbc1, mbc2) + returns a positive, zero, or negative value depending on whether mbc1 + sorts after, same or before mbc2, modulo upper/lowercase conversion. + + mb_equal (mbc1, mbc2) + returns true if mbc1 and mbc2 are equal. + + mb_caseequal (mbc1, mbc2) + returns true if mbc1 and mbc2 are equal modulo upper/lowercase conversion. + + mb_isalnum (mbc) + returns true if mbc is alphanumeric. + + mb_isalpha (mbc) + returns true if mbc is alphabetic. + + mb_isascii(mbc) + returns true if mbc is plain ASCII. + + mb_isblank (mbc) + returns true if mbc is a blank. + + mb_iscntrl (mbc) + returns true if mbc is a control character. + + mb_isdigit (mbc) + returns true if mbc is a decimal digit. + + mb_isgraph (mbc) + returns true if mbc is a graphic character. + + mb_islower (mbc) + returns true if mbc is lowercase. + + mb_isprint (mbc) + returns true if mbc is a printable character. + + mb_ispunct (mbc) + returns true if mbc is a punctuation character. + + mb_isspace (mbc) + returns true if mbc is a space character. + + mb_isupper (mbc) + returns true if mbc is uppercase. + + mb_isxdigit (mbc) + returns true if mbc is a hexadecimal digit. + + mb_width (mbc) + returns the number of columns on the output device occupied by mbc. + Always >= 0. + + mb_putc (mbc, stream) + outputs mbc on stream, a byte oriented FILE stream opened for output. + + mb_setascii (&mbc, sc) + assigns the standard ASCII character sc to mbc. + (Only available if the 'mbfile' module is in use.) + + mb_copy (&destmbc, &srcmbc) + copies srcmbc to destmbc. + + Here are the function prototypes of the macros. + + extern const char * mb_ptr (const mbchar_t mbc); + extern size_t mb_len (const mbchar_t mbc); + extern bool mb_iseq (const mbchar_t mbc, char sc); + extern bool mb_isnul (const mbchar_t mbc); + extern int mb_cmp (const mbchar_t mbc1, const mbchar_t mbc2); + extern int mb_casecmp (const mbchar_t mbc1, const mbchar_t mbc2); + extern bool mb_equal (const mbchar_t mbc1, const mbchar_t mbc2); + extern bool mb_caseequal (const mbchar_t mbc1, const mbchar_t mbc2); + extern bool mb_isalnum (const mbchar_t mbc); + extern bool mb_isalpha (const mbchar_t mbc); + extern bool mb_isascii (const mbchar_t mbc); + extern bool mb_isblank (const mbchar_t mbc); + extern bool mb_iscntrl (const mbchar_t mbc); + extern bool mb_isdigit (const mbchar_t mbc); + extern bool mb_isgraph (const mbchar_t mbc); + extern bool mb_islower (const mbchar_t mbc); + extern bool mb_isprint (const mbchar_t mbc); + extern bool mb_ispunct (const mbchar_t mbc); + extern bool mb_isspace (const mbchar_t mbc); + extern bool mb_isupper (const mbchar_t mbc); + extern bool mb_isxdigit (const mbchar_t mbc); + extern int mb_width (const mbchar_t mbc); + extern void mb_putc (const mbchar_t mbc, FILE *stream); + extern void mb_setascii (mbchar_t *new, char sc); + extern void mb_copy (mbchar_t *new, const mbchar_t *old); + */ + +#ifndef _MBCHAR_H +#define _MBCHAR_H 1 + +/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +#include +#include + +_GL_INLINE_HEADER_BEGIN +#ifndef MBCHAR_INLINE +# define MBCHAR_INLINE _GL_INLINE +#endif + +/* The longest multibyte characters, nowadays, are 4 bytes long. + Regardless of the values of MB_CUR_MAX and MB_LEN_MAX. */ +#define MBCHAR_BUF_SIZE 4 + +struct mbchar +{ + const char *ptr; /* pointer to current character */ + size_t bytes; /* number of bytes of current character, > 0 */ + bool wc_valid; /* true if wc is a valid 32-bit wide character */ + char32_t wc; /* if wc_valid: the current character */ +#if defined GNULIB_MBFILE + char buf[MBCHAR_BUF_SIZE]; /* room for the bytes, used for file input only */ +#endif +}; + +/* EOF (not a real character) is represented with bytes = 0 and + wc_valid = false. */ + +typedef struct mbchar mbchar_t; + +/* Access the current character. */ +#define mb_ptr(mbc) ((mbc).ptr) +#define mb_len(mbc) ((mbc).bytes) + +/* Comparison of characters. */ +#define mb_iseq(mbc, sc) ((mbc).wc_valid && (mbc).wc == (sc)) +#define mb_isnul(mbc) ((mbc).wc_valid && (mbc).wc == 0) +#define mb_cmp(mbc1, mbc2) \ + ((mbc1).wc_valid \ + ? ((mbc2).wc_valid \ + ? _GL_CMP ((mbc1).wc, (mbc2).wc) \ + : -1) \ + : ((mbc2).wc_valid \ + ? 1 \ + : (mbc1).bytes == (mbc2).bytes \ + ? memcmp ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes) \ + : (mbc1).bytes < (mbc2).bytes \ + ? (memcmp ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes) > 0 ? 1 : -1) \ + : (memcmp ((mbc1).ptr, (mbc2).ptr, (mbc2).bytes) >= 0 ? 1 : -1))) +#define mb_casecmp(mbc1, mbc2) \ + ((mbc1).wc_valid \ + ? ((mbc2).wc_valid \ + ? _GL_CMP (c32tolower ((mbc1).wc), c32tolower ((mbc2).wc)) \ + : -1) \ + : ((mbc2).wc_valid \ + ? 1 \ + : (mbc1).bytes == (mbc2).bytes \ + ? memcmp ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes) \ + : (mbc1).bytes < (mbc2).bytes \ + ? (memcmp ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes) > 0 ? 1 : -1) \ + : (memcmp ((mbc1).ptr, (mbc2).ptr, (mbc2).bytes) >= 0 ? 1 : -1))) +#define mb_equal(mbc1, mbc2) \ + ((mbc1).wc_valid && (mbc2).wc_valid \ + ? (mbc1).wc == (mbc2).wc \ + : (mbc1).bytes == (mbc2).bytes \ + && memcmp ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes) == 0) +#define mb_caseequal(mbc1, mbc2) \ + ((mbc1).wc_valid && (mbc2).wc_valid \ + ? c32tolower ((mbc1).wc) == c32tolower ((mbc2).wc) \ + : (mbc1).bytes == (mbc2).bytes \ + && memcmp ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes) == 0) + +/* , classification. */ +#define mb_isascii(mbc) \ + ((mbc).wc_valid && (mbc).wc >= 0 && (mbc).wc <= 127) +#define mb_isalnum(mbc) ((mbc).wc_valid && c32isalnum ((mbc).wc)) +#define mb_isalpha(mbc) ((mbc).wc_valid && c32isalpha ((mbc).wc)) +#define mb_isblank(mbc) ((mbc).wc_valid && c32isblank ((mbc).wc)) +#define mb_iscntrl(mbc) ((mbc).wc_valid && c32iscntrl ((mbc).wc)) +#define mb_isdigit(mbc) ((mbc).wc_valid && c32isdigit ((mbc).wc)) +#define mb_isgraph(mbc) ((mbc).wc_valid && c32isgraph ((mbc).wc)) +#define mb_islower(mbc) ((mbc).wc_valid && c32islower ((mbc).wc)) +#define mb_isprint(mbc) ((mbc).wc_valid && c32isprint ((mbc).wc)) +#define mb_ispunct(mbc) ((mbc).wc_valid && c32ispunct ((mbc).wc)) +#define mb_isspace(mbc) ((mbc).wc_valid && c32isspace ((mbc).wc)) +#define mb_isupper(mbc) ((mbc).wc_valid && c32isupper ((mbc).wc)) +#define mb_isxdigit(mbc) ((mbc).wc_valid && c32isxdigit ((mbc).wc)) + +/* Extra function. */ + +/* Unprintable characters appear as a small box of width 1. */ +#define MB_UNPRINTABLE_WIDTH 1 + +MBCHAR_INLINE int +mb_width_aux (char32_t wc) +{ + int w = c32width (wc); + /* For unprintable characters, arbitrarily return 0 for control characters + and MB_UNPRINTABLE_WIDTH otherwise. */ + return (w >= 0 ? w : c32iscntrl (wc) ? 0 : MB_UNPRINTABLE_WIDTH); +} + +#define mb_width(mbc) \ + ((mbc).wc_valid ? mb_width_aux ((mbc).wc) : MB_UNPRINTABLE_WIDTH) + +/* Output. */ +#define mb_putc(mbc, stream) fwrite ((mbc).ptr, 1, (mbc).bytes, (stream)) + +#if defined GNULIB_MBFILE +/* Assignment. */ +# define mb_setascii(mbc, sc) \ + ((mbc)->ptr = (mbc)->buf, (mbc)->bytes = 1, (mbc)->wc_valid = 1, \ + (mbc)->wc = (mbc)->buf[0] = (sc)) +#endif + +/* Copying a character. */ +MBCHAR_INLINE void +mb_copy (mbchar_t *new_mbc, const mbchar_t *old_mbc) +{ +#if defined GNULIB_MBFILE + if (old_mbc->ptr == &old_mbc->buf[0]) + { + memcpy (&new_mbc->buf[0], &old_mbc->buf[0], old_mbc->bytes); + new_mbc->ptr = &new_mbc->buf[0]; + } + else +#endif + new_mbc->ptr = old_mbc->ptr; + new_mbc->bytes = old_mbc->bytes; + if ((new_mbc->wc_valid = old_mbc->wc_valid)) + new_mbc->wc = old_mbc->wc; +} + + +/* is_basic(c) tests whether the single-byte character c is + - in the ISO C "basic character set" or is one of '@', '$', and '`' + which ISO C 23 § 5.2.1.1.(1) guarantees to be single-byte and in + practice are safe to treat as basic in the execution character set, + or + - in the POSIX "portable character set", which + + equally guarantees to be single-byte. + This is a convenience function, and is in this file only to share code + between mbiter.h, mbuiter.h, and mbfile.h. */ +#if (' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ + && ('$' == 36) && ('%' == 37) && ('&' == 38) && ('\'' == 39) \ + && ('(' == 40) && (')' == 41) && ('*' == 42) && ('+' == 43) \ + && (',' == 44) && ('-' == 45) && ('.' == 46) && ('/' == 47) \ + && ('0' == 48) && ('1' == 49) && ('2' == 50) && ('3' == 51) \ + && ('4' == 52) && ('5' == 53) && ('6' == 54) && ('7' == 55) \ + && ('8' == 56) && ('9' == 57) && (':' == 58) && (';' == 59) \ + && ('<' == 60) && ('=' == 61) && ('>' == 62) && ('?' == 63) \ + && ('@' == 64) && ('A' == 65) && ('B' == 66) && ('C' == 67) \ + && ('D' == 68) && ('E' == 69) && ('F' == 70) && ('G' == 71) \ + && ('H' == 72) && ('I' == 73) && ('J' == 74) && ('K' == 75) \ + && ('L' == 76) && ('M' == 77) && ('N' == 78) && ('O' == 79) \ + && ('P' == 80) && ('Q' == 81) && ('R' == 82) && ('S' == 83) \ + && ('T' == 84) && ('U' == 85) && ('V' == 86) && ('W' == 87) \ + && ('X' == 88) && ('Y' == 89) && ('Z' == 90) && ('[' == 91) \ + && ('\\' == 92) && (']' == 93) && ('^' == 94) && ('_' == 95) \ + && ('`' == 96) && ('a' == 97) && ('b' == 98) && ('c' == 99) \ + && ('d' == 100) && ('e' == 101) && ('f' == 102) && ('g' == 103) \ + && ('h' == 104) && ('i' == 105) && ('j' == 106) && ('k' == 107) \ + && ('l' == 108) && ('m' == 109) && ('n' == 110) && ('o' == 111) \ + && ('p' == 112) && ('q' == 113) && ('r' == 114) && ('s' == 115) \ + && ('t' == 116) && ('u' == 117) && ('v' == 118) && ('w' == 119) \ + && ('x' == 120) && ('y' == 121) && ('z' == 122) && ('{' == 123) \ + && ('|' == 124) && ('}' == 125) && ('~' == 126) +/* The character set is ISO-646, not EBCDIC. */ +# define IS_BASIC_ASCII 1 + +/* All locale encodings (see localcharset.h) map the characters 0x00..0x7F + to U+0000..U+007F, like ASCII, except for + CP864 different mapping of '%' + SHIFT_JIS different mappings of 0x5C, 0x7E + JOHAB different mapping of 0x5C + However, these characters in the range 0x20..0x7E are in the ISO C + "basic character set" and in the POSIX "portable character set", which + ISO C and POSIX guarantee to be single-byte. Thus, locales with these + encodings are not POSIX compliant. And they are most likely not in use + any more (as of 2023). */ +# define is_basic(c) ((unsigned char) (c) < 0x80) + +#else + +MBCHAR_INLINE bool +is_basic (char c) +{ + switch (c) + { + case '\0': + case '\007': case '\010': + case '\t': case '\n': case '\v': case '\f': case '\r': + case ' ': case '!': case '"': case '#': case '$': case '%': + case '&': case '\'': case '(': case ')': case '*': + case '+': case ',': case '-': case '.': case '/': + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + case ':': case ';': case '<': case '=': case '>': + case '?': case '@': + case 'A': case 'B': case 'C': case 'D': case 'E': + case 'F': case 'G': case 'H': case 'I': case 'J': + case 'K': case 'L': case 'M': case 'N': case 'O': + case 'P': case 'Q': case 'R': case 'S': case 'T': + case 'U': case 'V': case 'W': case 'X': case 'Y': + case 'Z': + case '[': case '\\': case ']': case '^': case '_': case '`': + case 'a': case 'b': case 'c': case 'd': case 'e': + case 'f': case 'g': case 'h': case 'i': case 'j': + case 'k': case 'l': case 'm': case 'n': case 'o': + case 'p': case 'q': case 'r': case 's': case 't': + case 'u': case 'v': case 'w': case 'x': case 'y': + case 'z': case '{': case '|': case '}': case '~': + return 1; + default: + return 0; + } +} + +#endif + +_GL_INLINE_HEADER_END + +#endif /* _MBCHAR_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbrtoc32.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbrtoc32.c new file mode 100644 index 00000000..56e4a860 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbrtoc32.c @@ -0,0 +1,288 @@ +/* Convert multibyte character to 32-bit wide character. + Copyright (C) 2020-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 2020. */ + +#include + +/* Specification. */ +#include + +#include "attribute.h" + +#include +#include + +#if GL_CHAR32_T_IS_UNICODE +# include "lc-charset-unicode.h" +#endif + +#if GNULIB_defined_mbstate_t /* AIX, IRIX */ +/* Implement mbrtoc32() on top of mbtowc() for the non-UTF-8 locales + and directly for the UTF-8 locales. */ + +/* Note: On AIX (64-bit) we can implement mbrtoc32 in two equivalent ways: + - in a way that parallels the override of mbrtowc; this is the code branch + here; + - in a way that invokes the overridden mbrtowc; this would be the #else + branch below. + They are equivalent. */ + +# if AVOID_ANY_THREADS + +/* The option '--disable-threads' explicitly requests no locking. */ + +# elif defined _WIN32 && !defined __CYGWIN__ + +# define WIN32_LEAN_AND_MEAN /* avoid including junk */ +# include + +# elif HAVE_PTHREAD_API + +# include +# if HAVE_THREADS_H && HAVE_WEAK_SYMBOLS +# include +# 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 + +# endif + +# include "lc-charset-dispatch.h" +# include "mbtowc-lock.h" + +static_assert (sizeof (mbstate_t) >= 4); +static char internal_state[4]; + +size_t +mbrtoc32 (char32_t *pwc, const char *s, size_t n, mbstate_t *ps) +{ +# define FITS_IN_CHAR_TYPE(wc) 1 +# include "mbrtowc-impl.h" +} + +#else /* glibc, macOS, FreeBSD, NetBSD, OpenBSD, HP-UX, Solaris, Cygwin, mingw, MSVC, Minix, Android */ + +/* Implement mbrtoc32() based on the original mbrtoc32() or on mbrtowc(). */ + +# include + +# include "localcharset.h" +# include "streq.h" + +# if MBRTOC32_IN_C_LOCALE_MAYBE_EILSEQ +# include "hard-locale.h" +# include +# endif + +static mbstate_t internal_state; + +size_t +mbrtoc32 (char32_t *pwc, const char *s, size_t n, mbstate_t *ps) +# undef mbrtoc32 +{ + /* It's simpler to handle the case s == NULL upfront, than to worry about + this case later, before every test of pwc and n. */ + if (s == NULL) + { + pwc = NULL; + s = ""; + n = 1; + } + +# if MBRTOC32_EMPTY_INPUT_BUG || _GL_SMALL_WCHAR_T + if (n == 0) + return (size_t) -2; +# endif + + if (ps == NULL) + ps = &internal_state; + +# if HAVE_WORKING_MBRTOC32 + /* mbrtoc32() may produce different values for wc than mbrtowc(). Therefore + use mbrtoc32(). */ + +# if defined _WIN32 && !defined __CYGWIN__ + char32_t wc; + size_t ret = mbrtoc32 (&wc, s, n, ps); + if (ret < (size_t) -2 && pwc != NULL) + *pwc = wc; +# else + size_t ret = mbrtoc32 (pwc, s, n, ps); +# endif + +# if GNULIB_MBRTOC32_REGULAR + /* Verify that mbrtoc32 is regular. */ + if (ret < (size_t) -3 && ! mbsinit (ps)) + /* This occurs on glibc 2.36. */ + mbszero (ps); + if (ret == (size_t) -3) + abort (); +# endif + +# if MBRTOC32_IN_C_LOCALE_MAYBE_EILSEQ + if ((size_t) -2 <= ret && n != 0 && ! hard_locale (LC_CTYPE)) + { + if (pwc != NULL) + *pwc = (unsigned char) *s; + return 1; + } +# endif + + return ret; + +# elif _GL_SMALL_WCHAR_T + + /* Special-case all encodings that may produce wide character values + > WCHAR_MAX. */ + const char *encoding = locale_charset (); + if (STREQ_OPT (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0, 0)) + { + /* Special-case the UTF-8 encoding. Assume that the wide-character + encoding in a UTF-8 locale is UCS-2 or, equivalently, UTF-16. */ + /* Here n > 0. */ + char *pstate = (char *)ps; + size_t nstate = pstate[0]; + char buf[4]; + const char *p; + size_t m; + 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. */ + + { +# define FITS_IN_CHAR_TYPE(wc) 1 +# include "mbrtowc-impl-utf8.h" + } + + success: + if (nstate >= (res > 0 ? res : 1)) + abort (); + res -= nstate; + /* Set *ps to an initial state. */ +# if defined _WIN32 && !defined __CYGWIN__ + /* Native Windows. */ + /* 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. */ + *(unsigned int *)pstate = 0; +# elif defined __CYGWIN__ + /* Cygwin defines 'mbstate_t' as an 8-byte struct; the first 4 bytes + matter. */ + ps->__count = 0; +# else + pstate[0] = 0; +# endif + 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); + } + else + { + wchar_t wc; + size_t ret = mbrtowc (&wc, s, n, ps); + if (ret < (size_t) -2 && pwc != NULL) + *pwc = wc; + return ret; + } + +# else + + /* char32_t and wchar_t are equivalent. Use mbrtowc(). */ + wchar_t wc; + size_t ret = mbrtowc (&wc, s, n, ps); + +# if GNULIB_MBRTOC32_REGULAR + /* Ensure that mbrtoc32 is regular. */ + if (ret < (size_t) -2 && ! mbsinit (ps)) + /* This occurs on glibc 2.12. */ + mbszero (ps); +# endif + +# if GL_CHAR32_T_IS_UNICODE && GL_CHAR32_T_VS_WCHAR_T_NEEDS_CONVERSION + if (ret < (size_t) -2 && wc != 0) + { + wc = locale_encoding_to_unicode (wc); + if (wc == 0) + { + ret = (size_t) -1; + errno = EILSEQ; + } + } +# endif + if (ret < (size_t) -2 && pwc != NULL) + *pwc = wc; + return ret; + +# endif +} + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbrtowc-impl-utf8.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbrtowc-impl-utf8.h new file mode 100644 index 00000000..3a3ba13c --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbrtowc-impl-utf8.h @@ -0,0 +1,138 @@ +/* Convert multibyte character to wide character. + Copyright (C) 1999-2002, 2005-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 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; diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbrtowc-impl.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbrtowc-impl.h new file mode 100644 index 00000000..963631ca --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbrtowc-impl.h @@ -0,0 +1,262 @@ +/* Convert multibyte character to wide character. + Copyright (C) 1999-2002, 2005-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 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); + } diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbrtowc.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbrtowc.c new file mode 100644 index 00000000..8a1646d2 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbrtowc.c @@ -0,0 +1,161 @@ +/* Convert multibyte character to wide character. + Copyright (C) 1999-2002, 2005-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2008. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +#if GNULIB_defined_mbstate_t +/* Implement mbrtowc() on top of mbtowc() for the non-UTF-8 locales + and directly for the UTF-8 locales. */ + +# include +# include +# include + +# if AVOID_ANY_THREADS + +/* The option '--disable-threads' explicitly requests no locking. */ + +# elif defined _WIN32 && !defined __CYGWIN__ + +# define WIN32_LEAN_AND_MEAN /* avoid including junk */ +# include + +# elif HAVE_PTHREAD_API + +# include +# if HAVE_THREADS_H && HAVE_WEAK_SYMBOLS +# include +# 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 + +# endif + +# include "attribute.h" +# include "lc-charset-dispatch.h" +# include "mbtowc-lock.h" + +static_assert (sizeof (mbstate_t) >= 4); +static char internal_state[4]; + +size_t +mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps) +{ +# 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 +# endif + +# undef mbrtowc + +size_t +rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps) +{ + size_t ret; + wchar_t wc; + +# if MBRTOWC_NULL_ARG2_BUG || MBRTOWC_RETVAL_BUG || MBRTOWC_EMPTY_INPUT_BUG + if (s == NULL) + { + pwc = NULL; + s = ""; + n = 1; + } +# endif + +# if MBRTOWC_EMPTY_INPUT_BUG + if (n == 0) + return (size_t) -2; +# endif + + if (! pwc) + pwc = &wc; + +# if MBRTOWC_RETVAL_BUG + { + static mbstate_t internal_state; + + /* Override mbrtowc's internal state. We cannot call mbsinit() on the + hidden internal state, but we can call it on our variable. */ + if (ps == NULL) + ps = &internal_state; + + if (!mbsinit (ps)) + { + /* Parse the rest of the multibyte character byte for byte. */ + size_t count = 0; + for (; n > 0; s++, n--) + { + ret = mbrtowc (&wc, s, 1, ps); + + if (ret == (size_t)(-1)) + return (size_t)(-1); + count++; + if (ret != (size_t)(-2)) + { + /* The multibyte character has been completed. */ + *pwc = wc; + return (wc == 0 ? 0 : count); + } + } + return (size_t)(-2); + } + } +# 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 MBRTOWC_IN_C_LOCALE_MAYBE_EILSEQ + if ((size_t) -2 <= ret && n != 0 && ! hard_locale (LC_CTYPE)) + { + unsigned char uc = *s; + *pwc = uc; + return 1; + } +# endif + + return ret; +} + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbscasecmp.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbscasecmp.c new file mode 100644 index 00000000..1abeb129 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbscasecmp.c @@ -0,0 +1,114 @@ +/* Case-insensitive string comparison function. + Copyright (C) 1998-1999, 2005-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2005, + based on earlier glibc code. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +#include +#include +#include +#include + +#if GNULIB_MCEL_PREFER +# include "mcel.h" +#else +# include "mbuiterf.h" +#endif + +/* Compare the character strings S1 and S2, ignoring case, returning less than, + equal to or greater than zero if S1 is lexicographically less than, equal to + or greater than S2. + Note: This function may, in multibyte locales, return 0 for strings of + different lengths! */ +int +mbscasecmp (const char *s1, const char *s2) +{ + if (s1 == s2) + return 0; + + const char *iter1 = s1; + const char *iter2 = s2; + + /* Be careful not to look at the entire extent of s1 or s2 until needed. + This is useful because when two strings differ, the difference is + most often already in the very few first characters. */ + if (MB_CUR_MAX > 1) + { +#if GNULIB_MCEL_PREFER + while (true) + { + mcel_t g1 = mcel_scanz (iter1); iter1 += g1.len; + mcel_t g2 = mcel_scanz (iter2); iter2 += g2.len; + int cmp = mcel_tocmp (c32tolower, g1, g2); + if (cmp | !g1.ch) + return cmp; + } +#else + mbuif_state_t state1; + mbuif_init (state1); + + mbuif_state_t state2; + mbuif_init (state2); + + while (mbuif_avail (state1, iter1) && mbuif_avail (state2, iter2)) + { + mbchar_t cur1 = mbuif_next (state1, iter1); + mbchar_t cur2 = mbuif_next (state2, iter2); + int cmp = mb_casecmp (cur1, cur2); + + if (cmp != 0) + return cmp; + + iter1 += mb_len (cur1); + iter2 += mb_len (cur2); + } + if (mbuif_avail (state1, iter1)) + /* s2 terminated before s1. */ + return 1; + if (mbuif_avail (state2, iter2)) + /* s1 terminated before s2. */ + return -1; + return 0; +#endif + } + else + for (;;) + { + unsigned char c1 = *iter1++; + unsigned char c2 = *iter2++; + /* On machines where 'char' and 'int' are types of the same size, the + difference of two 'unsigned char' values - including the sign bit - + doesn't fit in an 'int'. */ + int cmp = UCHAR_MAX <= INT_MAX ? c1 - c2 : _GL_CMP (c1, c2); + if (cmp != 0) + { + c1 = tolower (c1); + if (c1 == c2) + cmp = 0; + else + { + c2 = tolower (c2); + cmp = UCHAR_MAX <= INT_MAX ? c1 - c2 : _GL_CMP (c1, c2); + } + } + if (cmp | !c1) + return cmp; + } +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbsinit.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbsinit.c new file mode 100644 index 00000000..d1b8475c --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbsinit.c @@ -0,0 +1,69 @@ +/* Test for initial conversion state. + Copyright (C) 2008-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2008. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + + +#if GNULIB_defined_mbstate_t + +/* Platforms that lack mbsinit() also lack mbrlen(), mbrtowc(), mbsrtowcs() + and wcrtomb(), wcsrtombs(). + We assume that + - sizeof (mbstate_t) >= 4, + - only stateless encodings are supported (such as UTF-8 and EUC-JP, but + not ISO-2022 variants), + - for each encoding, the number of bytes for a wide character is <= 4. + (This maximum is attained for UTF-8, GB18030, EUC-TW.) + We define the meaning of mbstate_t as follows: + - In mb -> wc direction, mbstate_t's first byte contains the number of + buffered bytes (in the range 0..3), followed by up to 3 buffered bytes. + See mbrtowc.c. + - In wc -> mb direction, mbstate_t contains no information. In other + words, it is always in an initial state. */ + +static_assert (sizeof (mbstate_t) >= 4); + +int +mbsinit (const mbstate_t *ps) +{ + const char *pstate = (const char *)ps; + + return pstate == NULL || pstate[0] == 0; +} + +#else + +int +mbsinit (const mbstate_t *ps) +{ +# if defined _WIN32 && !defined __CYGWIN__ + /* Native Windows. */ + /* 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; +# else + /* Minix, HP-UX 11.00, Solaris 2.6, Interix, ... */ + /* Maybe this definition works, maybe not... */ + return ps == NULL || *(const char *)ps == 0; +# endif +} + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbsrtoc32s-state.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbsrtoc32s-state.c new file mode 100644 index 00000000..4f6eeaa9 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbsrtoc32s-state.c @@ -0,0 +1,37 @@ +/* Convert string to 32-bit wide string. + Copyright (C) 2008-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2020. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +#include + +/* Internal state used by the functions mbsrtoc32s() and mbsnrtoc32s(). */ +mbstate_t _gl_mbsrtoc32s_state +/* The state must initially be in an "initial state"; so, zero-initialize it. + On most systems, putting it into BSS is sufficient. Not so on Mac OS X 10.3, + see . + When it needs an initializer, use 0 or {0} as initializer? 0 only works + when mbstate_t is a scalar type (such as when gnulib defines it, or on + AIX, IRIX, mingw). {0} works as an initializer in all cases: for a struct + or union type, but also for a scalar type (ISO C 99, 6.7.8.(11)). */ +#if defined __ELF__ + /* On ELF systems, variables in BSS behave well. */ +#else + /* Use braces, to be on the safe side. */ + = { 0 } +#endif + ; diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbsrtoc32s.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbsrtoc32s.c new file mode 100644 index 00000000..896dc512 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbsrtoc32s.c @@ -0,0 +1,65 @@ +/* Convert string to 32-bit wide string. + Copyright (C) 2020-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2020. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +#define IN_MBSRTOC32S +/* Specification. */ +#include + +#include + +#if (HAVE_WORKING_MBRTOC32 && !_GL_WCHAR_T_IS_UCS4) || (GL_CHAR32_T_IS_UNICODE && GL_CHAR32_T_VS_WCHAR_T_NEEDS_CONVERSION) || _GL_SMALL_WCHAR_T +/* The char32_t encoding of a multibyte character may be different than its + wchar_t encoding, or char32_t is wider than wchar_t. */ + +# include +# include +# include + +# include "strnlen1.h" + +extern mbstate_t _gl_mbsrtoc32s_state; + +# define FUNC mbsrtoc32s +# define DCHAR_T char32_t +# define INTERNAL_STATE _gl_mbsrtoc32s_state +# define MBRTOWC mbrtoc32 +# if GNULIB_MBRTOC32_REGULAR + /* If the 'mbrtoc32-regular' module is in use, we don't need to handle + a (size_t)(-3) return value from mbrtoc32. */ +# define USES_C32 0 +# else +# define USES_C32 1 +# endif +# include "mbsrtowcs-impl.h" + +#else +/* char32_t and wchar_t are equivalent. */ + +static_assert (sizeof (char32_t) == sizeof (wchar_t)); + +# if _GL_WCHAR_T_IS_UCS4 +_GL_EXTERN_INLINE +# endif +size_t +mbsrtoc32s (char32_t *dest, const char **srcp, size_t len, mbstate_t *ps) +{ + return mbsrtowcs ((wchar_t *) dest, srcp, len, ps); +} + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbsrtowcs-impl.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbsrtowcs-impl.h new file mode 100644 index 00000000..9043fb88 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbsrtowcs-impl.h @@ -0,0 +1,123 @@ +/* Convert string to wide string. + Copyright (C) 2008-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2008. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +size_t +FUNC (DCHAR_T *dest, const char **srcp, size_t len, mbstate_t *ps) +{ + if (ps == NULL) + ps = &INTERNAL_STATE; + { + const char *src = *srcp; + + if (dest != NULL) + { + DCHAR_T *destptr = dest; + + for (; len > 0; destptr++, len--) + { + size_t src_avail; + size_t ret; + + /* An optimized variant of + src_avail = strnlen1 (src, MB_LEN_MAX); */ + if (src[0] == '\0') + src_avail = 1; + else if (src[1] == '\0') + src_avail = 2; + else if (src[2] == '\0') + src_avail = 3; + else if (MB_LEN_MAX <= 4 || src[3] == '\0') + src_avail = 4; + else + src_avail = 4 + strnlen1 (src + 4, MB_LEN_MAX - 4); + + /* Parse the next multibyte character. */ + ret = MBRTOWC (destptr, src, src_avail, ps); + + if (ret == (size_t)(-2)) + /* Encountered a multibyte character that extends past a '\0' byte + or that is longer than MB_LEN_MAX bytes. Cannot happen. */ + abort (); + + if (ret == (size_t)(-1)) + goto bad_input; + if (ret == 0) + { + src = NULL; + /* Here mbsinit (ps). */ + break; + } + if (!(USES_C32 && ret == (size_t)(-3))) + src += ret; + } + + *srcp = src; + return destptr - dest; + } + else + { + /* Ignore dest and len, don't store *srcp at the end, and + don't clobber *ps. */ + mbstate_t state = *ps; + size_t totalcount = 0; + + for (;; totalcount++) + { + size_t src_avail; + size_t ret; + + /* An optimized variant of + src_avail = strnlen1 (src, MB_LEN_MAX); */ + if (src[0] == '\0') + src_avail = 1; + else if (src[1] == '\0') + src_avail = 2; + else if (src[2] == '\0') + src_avail = 3; + else if (MB_LEN_MAX <= 4 || src[3] == '\0') + src_avail = 4; + else + src_avail = 4 + strnlen1 (src + 4, MB_LEN_MAX - 4); + + /* Parse the next multibyte character. */ + ret = MBRTOWC (NULL, src, src_avail, &state); + + if (ret == (size_t)(-2)) + /* Encountered a multibyte character that extends past a '\0' byte + or that is longer than MB_LEN_MAX bytes. Cannot happen. */ + abort (); + + if (ret == (size_t)(-1)) + goto bad_input2; + if (ret == 0) + { + /* Here mbsinit (&state). */ + break; + } + src += ret; + } + + return totalcount; + } + + bad_input: + *srcp = src; + bad_input2: + errno = EILSEQ; + return (size_t)(-1); + } +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbsrtowcs-state.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbsrtowcs-state.c new file mode 100644 index 00000000..cbb8753b --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbsrtowcs-state.c @@ -0,0 +1,37 @@ +/* Convert string to wide string. + Copyright (C) 2008-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2008. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +#include + +/* Internal state used by the functions mbsrtowcs() and mbsnrtowcs(). */ +mbstate_t _gl_mbsrtowcs_state +/* The state must initially be in an "initial state"; so, zero-initialize it. + On most systems, putting it into BSS is sufficient. Not so on Mac OS X 10.3, + see . + When it needs an initializer, use 0 or {0} as initializer? 0 only works + when mbstate_t is a scalar type (such as when gnulib defines it, or on + AIX, IRIX, mingw). {0} works as an initializer in all cases: for a struct + or union type, but also for a scalar type (ISO C 99, 6.7.8.(11)). */ +#if defined __ELF__ + /* On ELF systems, variables in BSS behave well. */ +#else + /* Use braces, to be on the safe side. */ + = { 0 } +#endif + ; diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbsrtowcs.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbsrtowcs.c new file mode 100644 index 00000000..c77179f6 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbsrtowcs.c @@ -0,0 +1,37 @@ +/* Convert string to wide string. + Copyright (C) 2008-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2008. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +#include +#include +#include + +#include "strnlen1.h" + + +extern mbstate_t _gl_mbsrtowcs_state; + +#define FUNC mbsrtowcs +#define DCHAR_T wchar_t +#define INTERNAL_STATE _gl_mbsrtowcs_state +#define MBRTOWC mbrtowc +#define USES_C32 0 +#include "mbsrtowcs-impl.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbszero.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbszero.c new file mode 100644 index 00000000..25af2848 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbszero.c @@ -0,0 +1,23 @@ +/* Put an mbstate_t into an initial conversion state. + Copyright (C) 2023-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 2023. */ + +#include + +#define IN_MBSZERO +/* Specification and implementation. */ +#include diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbtowc-impl.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbtowc-impl.h new file mode 100644 index 00000000..92efb4a7 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbtowc-impl.h @@ -0,0 +1,44 @@ +/* Convert multibyte character to wide character. + Copyright (C) 2011-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2011. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* We don't need a static internal state, because the encoding is not state + dependent, and when mbrtowc returns (size_t)(-2). we throw the result + away. */ + +int +mbtowc (wchar_t *pwc, const char *s, size_t n) +{ + if (s == NULL) + return 0; + else + { + mbstate_t state; + wchar_t wc; + size_t result; + + mbszero (&state); + result = mbrtowc (&wc, s, n, &state); + if (result == (size_t)-1 || result == (size_t)-2) + { + errno = EILSEQ; + return -1; + } + if (pwc != NULL) + *pwc = wc; + return (wc == 0 ? 0 : result); + } +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbtowc-lock.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbtowc-lock.c new file mode 100644 index 00000000..9001c5af --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbtowc-lock.c @@ -0,0 +1,151 @@ +/* Return the internal lock used by mbrtowc and mbrtoc32. + Copyright (C) 2019-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 2019-2020. */ + +#include + +/* The option '--disable-threads' explicitly requests no locking. */ +/* When it is known that the gl_get_mbtowc_lock function is defined + by a dependency library, it should not be defined here. */ +#if AVOID_ANY_THREADS || 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 SHLIB_EXPORTED +# if HAVE_VISIBILITY + /* Override the effect of the compiler option '-fvisibility=hidden'. */ +# define SHLIB_EXPORTED __attribute__((__visibility__("default"))) +# elif defined _WIN32 || defined __CYGWIN__ +# define SHLIB_EXPORTED __declspec(dllexport) +# else +# define SHLIB_EXPORTED +# endif +# endif + +# if defined _WIN32 && !defined __CYGWIN__ + +# define WIN32_LEAN_AND_MEAN /* avoid including junk */ +# include + +# 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. */ +SHLIB_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 + +static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; + +/* Make sure the function gets exported from shared libraries. */ +SHLIB_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 +# include + +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. */ +SHLIB_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 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbtowc-lock.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbtowc-lock.h new file mode 100644 index 00000000..10f7dc7c --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbtowc-lock.h @@ -0,0 +1,125 @@ +/* Use the internal lock used by mbrtowc and mbrtoc32. + Copyright (C) 2019-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 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 an initial state. + This is needed at least with glibc, uClibc, and MSVC CRT. + See . */ + mbtowc (NULL, NULL, 0); + + return mbtowc (pwc, p, m); +} + +/* Prohibit renaming this symbol. */ +#undef gl_get_mbtowc_lock + +#if AVOID_ANY_THREADS || GNULIB_MBRTOWC_SINGLE_THREAD + +/* All uses of this function are in a single thread. No locking needed. */ + +static int +mbtowc_with_lock (wchar_t *pwc, const char *p, size_t m) +{ + return mbtowc_unlocked (pwc, p, m); +} + +#elif 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 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbtowc.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbtowc.c new file mode 100644 index 00000000..31a2d635 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbtowc.c @@ -0,0 +1,26 @@ +/* Convert multibyte character to wide character. + Copyright (C) 2011-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2011. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +#include + +#include +#include +#include + +#include "mbtowc-impl.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbuiter.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbuiter.c new file mode 100644 index 00000000..505654c9 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbuiter.c @@ -0,0 +1,20 @@ +/* Iterating through multibyte strings: macros for multi-byte encodings. + Copyright (C) 2012-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +#define MBUITER_INLINE _GL_EXTERN_INLINE +#include "mbuiter.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbuiter.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbuiter.h new file mode 100644 index 00000000..9af3c98e --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbuiter.h @@ -0,0 +1,267 @@ +/* Iterating through multibyte strings: macros for multi-byte encodings. + Copyright (C) 2001, 2005, 2007, 2009-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible . */ + +/* The macros in this file implement forward iteration through a + multi-byte string, without knowing its length a-priori. + + With these macros, an iteration loop that looks like + + char *iter; + for (iter = buf; *iter != '\0'; iter++) + { + do_something (*iter); + } + + becomes + + mbui_iterator_t iter; + for (mbui_init (iter, buf); mbui_avail (iter); mbui_advance (iter)) + { + do_something (mbui_cur_ptr (iter), mb_len (mbui_cur (iter))); + } + + The benefit of these macros over plain use of mbrtowc is: + - Handling of invalid multibyte sequences is possible without + making the code more complicated, while still preserving the + invalid multibyte sequences. + + Compared to mbiter.h, the macros here don't need to know the string's + length a-priori. The downside is that at each step, the look-ahead + that guards against overrunning the terminating '\0' is more expensive. + The mbui_* macros are therefore suitable when there is a high probability + that only the first few multibyte characters need to be inspected. + Whereas the mbi_* macros are better if usually the iteration runs + through the entire string. + + mbui_iterator_t + is a type usable for variable declarations. + + mbui_init (iter, startptr) + initializes the iterator, starting at startptr. + + mbui_avail (iter) + returns true if there are more multibyte characters available before + the end of string is reached. In this case, mbui_cur (iter) is + initialized to the next multibyte character. + + mbui_advance (iter) + advances the iterator by one multibyte character. + + mbui_cur (iter) + returns the current multibyte character, of type mbchar_t. All the + macros defined in mbchar.h can be used on it. + + mbui_cur_ptr (iter) + return a pointer to the beginning of the current multibyte character. + + mbui_reloc (iter, ptrdiff) + relocates iterator when the string is moved by ptrdiff bytes. + + mbui_copy (&destiter, &srciter) + copies srciter to destiter. + + Here are the function prototypes of the macros. + + extern void mbui_init (mbui_iterator_t iter, const char *startptr); + extern bool mbui_avail (mbui_iterator_t iter); + extern void mbui_advance (mbui_iterator_t iter); + extern mbchar_t mbui_cur (mbui_iterator_t iter); + extern const char * mbui_cur_ptr (mbui_iterator_t iter); + extern void mbui_reloc (mbui_iterator_t iter, ptrdiff_t ptrdiff); + extern void mbui_copy (mbui_iterator_t *new, const mbui_iterator_t *old); + */ + +#ifndef _MBUITER_H +#define _MBUITER_H 1 + +/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, + _GL_ATTRIBUTE_ALWAYS_INLINE. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +#include +#include +#include +#include +#include +#include + +#include "mbchar.h" +#include "strnlen1.h" + +_GL_INLINE_HEADER_BEGIN +#ifndef MBUITER_INLINE +# define MBUITER_INLINE _GL_INLINE _GL_ATTRIBUTE_ALWAYS_INLINE +#endif + +struct mbuiter_multi +{ + #if !GNULIB_MBRTOC32_REGULAR + bool in_shift; /* true if next byte may not be interpreted as ASCII */ + /* If GNULIB_MBRTOC32_REGULAR, it is always false, + so optimize it away. */ + #endif + mbstate_t state; /* if in_shift: current shift state */ + /* If GNULIB_MBRTOC32_REGULAR, it is in an initial state + before and after every mbuiter_multi_next invocation. + */ + bool next_done; /* true if mbui_avail has already filled the following */ + unsigned int cur_max; /* A cache of MB_CUR_MAX. */ + struct mbchar cur; /* the current character: + const char *cur.ptr pointer to current character + The following are only valid after mbui_avail. + size_t cur.bytes number of bytes of current character + bool cur.wc_valid true if wc is a valid 32-bit wide character + char32_t cur.wc if wc_valid: the current character + */ +}; + +MBUITER_INLINE void +mbuiter_multi_next (struct mbuiter_multi *iter) +{ + if (iter->next_done) + return; + #if !GNULIB_MBRTOC32_REGULAR + if (iter->in_shift) + goto with_shift; + #endif + /* Handle most ASCII characters quickly, without calling mbrtowc(). */ + if (is_basic (*iter->cur.ptr)) + { + /* These characters are part of the POSIX portable character set. + For most of them, namely those in the ISO C basic character set, + ISO C 99 guarantees that their wide character code is identical to + their char code. For the few other ones, this is the case as well, + in all locale encodings that are in use. The 32-bit wide character + code is the same as well. */ + iter->cur.bytes = 1; + iter->cur.wc = *iter->cur.ptr; + iter->cur.wc_valid = true; + } + else + { + assert (mbsinit (&iter->state)); + #if !GNULIB_MBRTOC32_REGULAR + iter->in_shift = true; + with_shift: + #endif + iter->cur.bytes = mbrtoc32 (&iter->cur.wc, iter->cur.ptr, + strnlen1 (iter->cur.ptr, iter->cur_max), + &iter->state); + if (iter->cur.bytes == (size_t) -1) + { + /* An invalid multibyte sequence was encountered. */ + iter->cur.bytes = 1; + iter->cur.wc_valid = false; + /* Allow the next invocation to continue from a sane state. */ + #if !GNULIB_MBRTOC32_REGULAR + iter->in_shift = false; + #endif + mbszero (&iter->state); + } + else if (iter->cur.bytes == (size_t) -2) + { + /* An incomplete multibyte character at the end. */ + iter->cur.bytes = strlen (iter->cur.ptr); + iter->cur.wc_valid = false; + /* Whether to set iter->in_shift = false and reset iter->state + or not is not important; the string end is reached anyway. */ + } + else + { + if (iter->cur.bytes == 0) + { + /* A null wide character was encountered. */ + iter->cur.bytes = 1; + assert (*iter->cur.ptr == '\0'); + assert (iter->cur.wc == 0); + } + #if !GNULIB_MBRTOC32_REGULAR + else if (iter->cur.bytes == (size_t) -3) + /* The previous multibyte sequence produced an additional 32-bit + wide character. */ + iter->cur.bytes = 0; + #endif + iter->cur.wc_valid = true; + + /* When in an initial state, we can go back treating ASCII + characters more quickly. */ + #if !GNULIB_MBRTOC32_REGULAR + if (mbsinit (&iter->state)) + iter->in_shift = false; + #endif + } + } + iter->next_done = true; +} + +MBUITER_INLINE void +mbuiter_multi_reloc (struct mbuiter_multi *iter, ptrdiff_t ptrdiff) +{ + iter->cur.ptr += ptrdiff; +} + +MBUITER_INLINE void +mbuiter_multi_copy (struct mbuiter_multi *new_iter, const struct mbuiter_multi *old_iter) +{ + #if !GNULIB_MBRTOC32_REGULAR + if ((new_iter->in_shift = old_iter->in_shift)) + memcpy (&new_iter->state, &old_iter->state, sizeof (mbstate_t)); + else + #endif + mbszero (&new_iter->state); + new_iter->next_done = old_iter->next_done; + new_iter->cur_max = old_iter->cur_max; + mb_copy (&new_iter->cur, &old_iter->cur); +} + +/* Iteration macros. */ +typedef struct mbuiter_multi mbui_iterator_t; +#if !GNULIB_MBRTOC32_REGULAR +#define mbui_init(iter, startptr) \ + ((iter).cur.ptr = (startptr), \ + (iter).in_shift = false, mbszero (&(iter).state), \ + (iter).next_done = false, \ + (iter).cur_max = MB_CUR_MAX) +#else +/* Optimized: no in_shift. */ +#define mbui_init(iter, startptr) \ + ((iter).cur.ptr = (startptr), \ + mbszero (&(iter).state), \ + (iter).next_done = false, \ + (iter).cur_max = MB_CUR_MAX) +#endif +#define mbui_avail(iter) \ + (mbuiter_multi_next (&(iter)), !mb_isnul ((iter).cur)) +#define mbui_advance(iter) \ + ((iter).cur.ptr += (iter).cur.bytes, (iter).next_done = false) + +/* Access to the current character. */ +#define mbui_cur(iter) (iter).cur +#define mbui_cur_ptr(iter) (iter).cur.ptr + +/* Relocation. */ +#define mbui_reloc(iter, ptrdiff) mbuiter_multi_reloc (&iter, ptrdiff) + +/* Copying an iterator. */ +#define mbui_copy mbuiter_multi_copy + +_GL_INLINE_HEADER_END + +#endif /* _MBUITER_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbuiterf.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbuiterf.c new file mode 100644 index 00000000..b345c0d6 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbuiterf.c @@ -0,0 +1,20 @@ +/* Iterating through multibyte strings: macros for multi-byte encodings. + Copyright (C) 2023-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +#define MBUITERF_INLINE _GL_EXTERN_INLINE +#include "mbuiterf.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbuiterf.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbuiterf.h new file mode 100644 index 00000000..22e84627 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mbuiterf.h @@ -0,0 +1,213 @@ +/* Iterating through multibyte strings, faster: macros for multi-byte encodings. + Copyright (C) 2001, 2005, 2007, 2009-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , + with insights from Paul Eggert. */ + +/* The macros in this file implement forward iteration through a + multi-byte string, without knowing its length a-priori. + + With these macros, an iteration loop that looks like + + char *iter; + for (iter = buf; *iter != '\0'; iter++) + { + do_something (*iter); + } + + becomes + + mbuif_state_t state; + [const] char *iter; + for (mbuif_init (state), iter = buf; mbuif_avail (state, iter); ) + { + mbchar_t cur = mbuif_next (state, iter); + // Note: Here always mb_ptr (cur) == iter. + do_something (iter, mb_len (cur)); + iter += mb_len (cur); + } + + The benefit of these macros over plain use of mbrtowc or mbrtoc32 is: + - Handling of invalid multibyte sequences is possible without + making the code more complicated, while still preserving the + invalid multibyte sequences. + + Compared to mbiterf.h, the macros here don't need to know the string's + length a-priori. The downside is that at each step, the look-ahead + that guards against overrunning the terminating '\0' is more expensive. + The mbuif_* macros are therefore suitable when there is a high probability + that only the first few multibyte characters need to be inspected. + Whereas the mbif_* macros are better if usually the iteration runs + through the entire string. + + The benefit of these macros over those from mbuiter.h is that it + produces faster code with today's optimizing compilers (because mbuif_next + returns its result by value). + + mbuif_state_t + is a type usable for variable declarations. + + mbuif_init (state) + initializes the state. + + mbuif_avail (state, iter) + returns true if another loop round is needed. + + mbuif_next (state, iter) + returns the next multibyte character. + It asssumes that the state is initialized and that *iter != '\0'. + + Here are the function prototypes of the macros. + + extern void mbuif_init (mbuif_state_t state); + extern bool mbuif_avail (mbuif_state_t state, const char *iter); + extern mbchar_t mbuif_next (mbuif_state_t state, const char *iter); + */ + +#ifndef _MBUITERF_H +#define _MBUITERF_H 1 + +/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, + _GL_ATTRIBUTE_ALWAYS_INLINE. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +#include +#include +#include +#include +#include +#include + +#include "mbchar.h" +#include "strnlen1.h" + +_GL_INLINE_HEADER_BEGIN +#ifndef MBUITERF_INLINE +# define MBUITERF_INLINE _GL_INLINE _GL_ATTRIBUTE_ALWAYS_INLINE +#endif + +struct mbuif_state +{ + #if !GNULIB_MBRTOC32_REGULAR + bool in_shift; /* true if next byte may not be interpreted as ASCII */ + /* If GNULIB_MBRTOC32_REGULAR, it is always false, + so optimize it away. */ + #endif + mbstate_t state; /* if in_shift: current shift state */ + /* If GNULIB_MBRTOC32_REGULAR, it is in an initial state + before and after every mbuiterf_next invocation. + */ + unsigned int cur_max; /* A cache of MB_CUR_MAX. */ +}; + +MBUITERF_INLINE mbchar_t +mbuiterf_next (struct mbuif_state *ps, const char *iter) +{ + #if !GNULIB_MBRTOC32_REGULAR + if (ps->in_shift) + goto with_shift; + #endif + /* Handle most ASCII characters quickly, without calling mbrtowc(). */ + if (is_basic (*iter)) + { + /* These characters are part of the POSIX portable character set. + For most of them, namely those in the ISO C basic character set, + ISO C 99 guarantees that their wide character code is identical to + their char code. For the few other ones, this is the case as well, + in all locale encodings that are in use. The 32-bit wide character + code is the same as well. */ + return (mbchar_t) { .ptr = iter, .bytes = 1, .wc_valid = true, .wc = *iter }; + } + else + { + assert (mbsinit (&ps->state)); + #if !GNULIB_MBRTOC32_REGULAR + ps->in_shift = true; + with_shift:; + #endif + size_t bytes; + char32_t wc; + bytes = mbrtoc32 (&wc, iter, strnlen1 (iter, ps->cur_max), &ps->state); + if (bytes == (size_t) -1) + { + /* An invalid multibyte sequence was encountered. */ + /* Allow the next invocation to continue from a sane state. */ + #if !GNULIB_MBRTOC32_REGULAR + ps->in_shift = false; + #endif + mbszero (&ps->state); + return (mbchar_t) { .ptr = iter, .bytes = 1, .wc_valid = false }; + } + else if (bytes == (size_t) -2) + { + /* An incomplete multibyte character at the end. */ + /* Whether to set ps->in_shift = false and reset ps->state or not is + not important; the string end is reached anyway. */ + return (mbchar_t) { .ptr = iter, .bytes = strlen (iter), .wc_valid = false }; + } + else + { + if (bytes == 0) + { + /* A null wide character was encountered. */ + bytes = 1; + assert (*iter == '\0'); + assert (wc == 0); + } + #if !GNULIB_MBRTOC32_REGULAR + else if (bytes == (size_t) -3) + /* The previous multibyte sequence produced an additional 32-bit + wide character. */ + bytes = 0; + #endif + + /* When in an initial state, we can go back treating ASCII + characters more quickly. */ + #if !GNULIB_MBRTOC32_REGULAR + if (mbsinit (&ps->state)) + ps->in_shift = false; + #endif + return (mbchar_t) { .ptr = iter, .bytes = bytes, .wc_valid = true, .wc = wc }; + } + } +} + +/* Iteration macros. */ +typedef struct mbuif_state mbuif_state_t; +#if !GNULIB_MBRTOC32_REGULAR +#define mbuif_init(st) \ + ((st).in_shift = false, mbszero (&(st).state), \ + (st).cur_max = MB_CUR_MAX) +#else +/* Optimized: no in_shift. */ +#define mbuif_init(st) \ + (mbszero (&(st).state), \ + (st).cur_max = MB_CUR_MAX) +#endif +#if !GNULIB_MBRTOC32_REGULAR +#define mbuif_avail(st, iter) ((st).in_shift || (*(iter) != '\0')) +#else +/* Optimized: no in_shift. */ +#define mbuif_avail(st, iter) (*(iter) != '\0') +#endif +#define mbuif_next(st, iter) \ + mbuiterf_next (&(st), (iter)) + +_GL_INLINE_HEADER_END + +#endif /* _MBUITERF_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/memchr.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/memchr.c new file mode 100644 index 00000000..67687a8f --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/memchr.c @@ -0,0 +1,172 @@ +/* Copyright (C) 1991, 1993, 1996-1997, 1999-2000, 2003-2004, 2006, 2008-2024 + Free Software Foundation, Inc. + + Based on strlen implementation by Torbjorn Granlund (tege@sics.se), + with help from Dan Sahlin (dan@sics.se) and + commentary by Jim Blandy (jimb@ai.mit.edu); + adaptation to memchr suggested by Dick Karpinski (dick@cca.ucsf.edu), + and implemented by Roland McGrath (roland@ai.mit.edu). + + NOTE: The canonical source of this file is maintained with the GNU C Library. + Bugs can be reported to bug-glibc@prep.ai.mit.edu. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef _LIBC +# include +#endif + +#include + +#include + +#if defined _LIBC +# include +#else +# define reg_char char +#endif + +#include + +#if HAVE_BP_SYM_H || defined _LIBC +# include +#else +# define BP_SYM(sym) sym +#endif + +#undef __memchr +#ifdef _LIBC +# undef memchr +#endif + +#ifndef weak_alias +# define __memchr memchr +#endif + +/* Search no more than N bytes of S for C. */ +void * +__memchr (void const *s, int c_in, size_t n) +{ + /* On 32-bit hardware, choosing longword to be a 32-bit unsigned + long instead of a 64-bit uintmax_t tends to give better + performance. On 64-bit hardware, unsigned long is generally 64 + bits already. Change this typedef to experiment with + performance. */ + typedef unsigned long int longword; + + const unsigned char *char_ptr; + const longword *longword_ptr; + longword repeated_one; + longword repeated_c; + unsigned reg_char c; + + c = (unsigned char) c_in; + + /* Handle the first few bytes by reading one byte at a time. + Do this until CHAR_PTR is aligned on a longword boundary. */ + for (char_ptr = (const unsigned char *) s; + n > 0 && (size_t) char_ptr % sizeof (longword) != 0; + --n, ++char_ptr) + if (*char_ptr == c) + return (void *) char_ptr; + + longword_ptr = (const longword *) char_ptr; + + /* All these elucidatory comments refer to 4-byte longwords, + but the theory applies equally well to any size longwords. */ + + /* Compute auxiliary longword values: + repeated_one is a value which has a 1 in every byte. + repeated_c has c in every byte. */ + repeated_one = 0x01010101; + repeated_c = c | (c << 8); + repeated_c |= repeated_c << 16; + if (0xffffffffU < (longword) -1) + { + repeated_one |= repeated_one << 31 << 1; + repeated_c |= repeated_c << 31 << 1; + if (8 < sizeof (longword)) + { + size_t i; + + for (i = 64; i < sizeof (longword) * 8; i *= 2) + { + repeated_one |= repeated_one << i; + repeated_c |= repeated_c << i; + } + } + } + + /* Instead of the traditional loop which tests each byte, we will test a + longword at a time. The tricky part is testing if *any of the four* + bytes in the longword in question are equal to c. We first use an xor + with repeated_c. This reduces the task to testing whether *any of the + four* bytes in longword1 is zero. + + We compute tmp = + ((longword1 - repeated_one) & ~longword1) & (repeated_one << 7). + That is, we perform the following operations: + 1. Subtract repeated_one. + 2. & ~longword1. + 3. & a mask consisting of 0x80 in every byte. + Consider what happens in each byte: + - If a byte of longword1 is zero, step 1 and 2 transform it into 0xff, + and step 3 transforms it into 0x80. A carry can also be propagated + to more significant bytes. + - If a byte of longword1 is nonzero, let its lowest 1 bit be at + position k (0 <= k <= 7); so the lowest k bits are 0. After step 1, + the byte ends in a single bit of value 0 and k bits of value 1. + After step 2, the result is just k bits of value 1: 2^k - 1. After + step 3, the result is 0. And no carry is produced. + So, if longword1 has only non-zero bytes, tmp is zero. + Whereas if longword1 has a zero byte, call j the position of the least + significant zero byte. Then the result has a zero at positions 0, ..., + j-1 and a 0x80 at position j. We cannot predict the result at the more + significant bytes (positions j+1..3), but it does not matter since we + already have a non-zero bit at position 8*j+7. + + So, the test whether any byte in longword1 is zero is equivalent to + testing whether tmp is nonzero. */ + + while (n >= sizeof (longword)) + { + longword longword1 = *longword_ptr ^ repeated_c; + + if ((((longword1 - repeated_one) & ~longword1) + & (repeated_one << 7)) != 0) + break; + longword_ptr++; + n -= sizeof (longword); + } + + char_ptr = (const unsigned char *) longword_ptr; + + /* At this point, we know that either n < sizeof (longword), or one of the + sizeof (longword) bytes starting at char_ptr is == c. On little-endian + machines, we could determine the first such byte without any further + memory accesses, just by looking at the tmp result from the last loop + iteration. But this does not work on big-endian machines. Choose code + that works in both cases. */ + + for (; n > 0; --n, ++char_ptr) + { + if (*char_ptr == c) + return (void *) char_ptr; + } + + return NULL; +} +#ifdef weak_alias +weak_alias (__memchr, BP_SYM (memchr)) +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/memchr.valgrind b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/memchr.valgrind new file mode 100644 index 00000000..0295d7e6 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/memchr.valgrind @@ -0,0 +1,30 @@ +# Suppress a valgrind message about use of uninitialized memory in memchr(). + +# Copyright (C) 2009-2024 Free Software Foundation, Inc. +# +# This file is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as +# published by the Free Software Foundation; either version 2.1 of the +# License, or (at your option) any later version. +# +# This file is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this program. If not, see . + +# POSIX states that when the character is found, memchr must not read extra +# bytes in an overestimated length (for example, where memchr is used to +# implement strnlen). However, we use a safe word read to provide a speedup. +{ + memchr-value4 + Memcheck:Value4 + fun:rpl_memchr +} +{ + memchr-value8 + Memcheck:Value8 + fun:rpl_memchr +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mempcpy.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mempcpy.c new file mode 100644 index 00000000..63886778 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mempcpy.c @@ -0,0 +1,33 @@ +/* Copy memory area and return pointer after last written byte. + Copyright (C) 2003, 2007, 2009-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +/* A function definition is only needed if HAVE_MEMPCPY is not defined. */ +#if !HAVE_MEMPCPY + +/* Copy N bytes of SRC to DEST, return pointer to bytes after the + last written byte. */ +void * +mempcpy (void *dest, const void *src, size_t n) +{ + return (char *) memcpy (dest, src, n) + n; +} + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/memrchr.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/memrchr.c new file mode 100644 index 00000000..3df1f479 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/memrchr.c @@ -0,0 +1,161 @@ +/* memrchr -- find the last occurrence of a byte in a memory block + + Copyright (C) 1991, 1993, 1996-1997, 1999-2000, 2003-2024 Free Software + Foundation, Inc. + + Based on strlen implementation by Torbjorn Granlund (tege@sics.se), + with help from Dan Sahlin (dan@sics.se) and + commentary by Jim Blandy (jimb@ai.mit.edu); + adaptation to memchr suggested by Dick Karpinski (dick@cca.ucsf.edu), + and implemented by Roland McGrath (roland@ai.mit.edu). + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#if defined _LIBC +# include +#else +# include +# define reg_char char +#endif + +#include +#include + +#undef __memrchr +#ifdef _LIBC +# undef memrchr +#endif + +#ifndef weak_alias +# define __memrchr memrchr +#endif + +/* Search no more than N bytes of S for C. */ +void * +__memrchr (void const *s, int c_in, size_t n) +{ + /* On 32-bit hardware, choosing longword to be a 32-bit unsigned + long instead of a 64-bit uintmax_t tends to give better + performance. On 64-bit hardware, unsigned long is generally 64 + bits already. Change this typedef to experiment with + performance. */ + typedef unsigned long int longword; + + const unsigned char *char_ptr; + const longword *longword_ptr; + longword repeated_one; + longword repeated_c; + unsigned reg_char c; + + c = (unsigned char) c_in; + + /* Handle the last few bytes by reading one byte at a time. + Do this until CHAR_PTR is aligned on a longword boundary. */ + for (char_ptr = (const unsigned char *) s + n; + n > 0 && (size_t) char_ptr % sizeof (longword) != 0; + --n) + if (*--char_ptr == c) + return (void *) char_ptr; + + longword_ptr = (const void *) char_ptr; + + /* All these elucidatory comments refer to 4-byte longwords, + but the theory applies equally well to any size longwords. */ + + /* Compute auxiliary longword values: + repeated_one is a value which has a 1 in every byte. + repeated_c has c in every byte. */ + repeated_one = 0x01010101; + repeated_c = c | (c << 8); + repeated_c |= repeated_c << 16; + if (0xffffffffU < (longword) -1) + { + repeated_one |= repeated_one << 31 << 1; + repeated_c |= repeated_c << 31 << 1; + if (8 < sizeof (longword)) + { + size_t i; + + for (i = 64; i < sizeof (longword) * 8; i *= 2) + { + repeated_one |= repeated_one << i; + repeated_c |= repeated_c << i; + } + } + } + + /* Instead of the traditional loop which tests each byte, we will test a + longword at a time. The tricky part is testing if *any of the four* + bytes in the longword in question are equal to c. We first use an xor + with repeated_c. This reduces the task to testing whether *any of the + four* bytes in longword1 is zero. + + We compute tmp = + ((longword1 - repeated_one) & ~longword1) & (repeated_one << 7). + That is, we perform the following operations: + 1. Subtract repeated_one. + 2. & ~longword1. + 3. & a mask consisting of 0x80 in every byte. + Consider what happens in each byte: + - If a byte of longword1 is zero, step 1 and 2 transform it into 0xff, + and step 3 transforms it into 0x80. A carry can also be propagated + to more significant bytes. + - If a byte of longword1 is nonzero, let its lowest 1 bit be at + position k (0 <= k <= 7); so the lowest k bits are 0. After step 1, + the byte ends in a single bit of value 0 and k bits of value 1. + After step 2, the result is just k bits of value 1: 2^k - 1. After + step 3, the result is 0. And no carry is produced. + So, if longword1 has only non-zero bytes, tmp is zero. + Whereas if longword1 has a zero byte, call j the position of the least + significant zero byte. Then the result has a zero at positions 0, ..., + j-1 and a 0x80 at position j. We cannot predict the result at the more + significant bytes (positions j+1..3), but it does not matter since we + already have a non-zero bit at position 8*j+7. + + So, the test whether any byte in longword1 is zero is equivalent to + testing whether tmp is nonzero. */ + + while (n >= sizeof (longword)) + { + longword longword1 = *--longword_ptr ^ repeated_c; + + if ((((longword1 - repeated_one) & ~longword1) + & (repeated_one << 7)) != 0) + { + longword_ptr++; + break; + } + n -= sizeof (longword); + } + + char_ptr = (const unsigned char *) longword_ptr; + + /* At this point, we know that either n < sizeof (longword), or one of the + sizeof (longword) bytes starting at char_ptr is == c. On little-endian + machines, we could determine the first such byte without any further + memory accesses, just by looking at the tmp result from the last loop + iteration. But this does not work on big-endian machines. Choose code + that works in both cases. */ + + while (n-- > 0) + { + if (*--char_ptr == c) + return (void *) char_ptr; + } + + return NULL; +} +#ifdef weak_alias +weak_alias (__memrchr, memrchr) +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/minmax.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/minmax.h new file mode 100644 index 00000000..f3df58b0 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/minmax.h @@ -0,0 +1,65 @@ +/* MIN, MAX macros. + Copyright (C) 1995, 1998, 2001, 2003, 2005, 2009-2024 Free Software + Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef _MINMAX_H +#define _MINMAX_H + +/* Note: MIN, MAX are also defined in on some systems + (glibc, IRIX, HP-UX, OSF/1). Therefore you might get warnings about + MIN, MAX macro redefinitions on some systems; the workaround is to + #include this file as the last one among the #include list. */ + +/* This file uses HAVE_MINMAX_IN_LIMITS_H, HAVE_MINMAX_IN_SYS_PARAM_H. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +/* Before we define the following symbols we get the file + since otherwise we get redefinitions on some systems if is + included after this file. Likewise for . + If more than one of these system headers define MIN and MAX, pick just + one of the headers (because the definitions most likely are the same). */ +#if HAVE_MINMAX_IN_LIMITS_H +# include +#elif HAVE_MINMAX_IN_SYS_PARAM_H +# include +#endif + +/* Note: MIN and MAX should be used with two arguments of the + same type. They might not return the minimum and maximum of their two + arguments, if the arguments have different types or have unusual + floating-point values. For example, on a typical host with 32-bit 'int', + 64-bit 'long long', and 64-bit IEEE 754 'double' types: + + MAX (-1, 2147483648) returns 4294967295. + MAX (9007199254740992.0, 9007199254740993) returns 9007199254740992.0. + MAX (NaN, 0.0) returns 0.0. + MAX (+0.0, -0.0) returns -0.0. + + and in each case the answer is in some sense bogus. */ + +/* MAX(a,b) returns the maximum of A and B. */ +#ifndef MAX +# define MAX(a,b) ((a) > (b) ? (a) : (b)) +#endif + +/* MIN(a,b) returns the minimum of A and B. */ +#ifndef MIN +# define MIN(a,b) ((a) < (b) ? (a) : (b)) +#endif + +#endif /* _MINMAX_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mkdir.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mkdir.c new file mode 100644 index 00000000..21d77677 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mkdir.c @@ -0,0 +1,93 @@ +/* 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-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* written by Jim Meyering */ + +#include + +/* Specification. */ +#include + +#include +#include +#include +#include + +#include "dirname.h" + +/* Disable the definition of mkdir to rpl_mkdir (from the + substitute) in this file. Otherwise, we'd get an endless recursion. */ +#undef mkdir + +/* mingw's _mkdir() function has 1 argument, but we pass 2 arguments. + Additionally, it declares _mkdir (and depending on compile flags, an + alias mkdir), only in the nonstandard includes and , + which are included in the override. */ +#if defined _WIN32 && ! defined __CYGWIN__ +# define mkdir(name,mode) _mkdir (name) +# define maybe_unused _GL_UNUSED +#else +# define maybe_unused /* empty */ +#endif + +/* This function is required at least for NetBSD 1.5.2. */ + +int +rpl_mkdir (char const *dir, maybe_unused mode_t mode) +{ + int ret_val; + char *tmp_dir; + size_t len = strlen (dir); + + if (len && dir[len - 1] == '/') + { + tmp_dir = strdup (dir); + if (!tmp_dir) + { + /* Rather than rely on strdup-posix, we set errno ourselves. */ + errno = ENOMEM; + return -1; + } + strip_trailing_slashes (tmp_dir); + } + else + { + tmp_dir = (char *) dir; + } +#if FUNC_MKDIR_DOT_BUG + /* Additionally, cygwin 1.5 mistakenly creates a directory "d/./". */ + { + char *last = last_component (tmp_dir); + if (*last == '.' && (last[1] == '\0' + || (last[1] == '.' && last[2] == '\0'))) + { + struct stat st; + if (stat (tmp_dir, &st) == 0 || errno == EOVERFLOW) + errno = EEXIST; + return -1; + } + } +#endif /* FUNC_MKDIR_DOT_BUG */ + + ret_val = mkdir (tmp_dir, mode); + + if (tmp_dir != dir) + free (tmp_dir); + + return ret_val; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mkstemp.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mkstemp.c new file mode 100644 index 00000000..724638df --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mkstemp.c @@ -0,0 +1,50 @@ +/* Copyright (C) 1998-1999, 2001, 2005-2007, 2009-2024 Free Software + Foundation, Inc. + This file is derived from the one in the GNU C Library. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#if !_LIBC +# include +#endif + +#include + +#if !_LIBC +# include "tempname.h" +# define __gen_tempname gen_tempname +# ifndef __GT_FILE +# define __GT_FILE GT_FILE +# endif +#endif + +#include + +#ifndef __GT_FILE +# define __GT_FILE 0 +#endif + +/* Generate a unique temporary file name from XTEMPLATE. + The last six characters of XTEMPLATE must be "XXXXXX"; + they are replaced with a string that makes the file name unique. + Then open the file and return a fd. + + If you are creating temporary files which will later be removed, + consider using the clean-temp module, which avoids several pitfalls + of using mkstemp directly. */ +int +mkstemp (char *xtemplate) +{ + return __gen_tempname (xtemplate, 0, 0, __GT_FILE); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mktime-internal.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mktime-internal.h new file mode 100644 index 00000000..709c36bd --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mktime-internal.h @@ -0,0 +1,79 @@ +/* Internals of mktime and related functions + Copyright 2016-2023 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Paul Eggert . + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _LIBC +# include +#endif + +/* mktime_offset_t is a signed type wide enough to hold a UTC offset + in seconds, and used as part of the type of the offset-guess + argument to mktime_internal. In Glibc, it is always long int. + When in Gnulib, use time_t on platforms where time_t + is signed, to be compatible with platforms like BeOS that export + this implementation detail of mktime. On platforms where time_t is + unsigned, GNU and POSIX code can assume 'int' is at least 32 bits + which is wide enough for a UTC offset. */ +#ifdef _LIBC +typedef long int mktime_offset_t; +#elif defined TIME_T_IS_SIGNED +typedef time_t mktime_offset_t; +#else +typedef int mktime_offset_t; +#endif + +/* The source code uses identifiers like __time64_t for glibc + timestamps that can contain 64-bit values even when time_t is only + 32 bits. These are just macros for the ordinary identifiers unless + compiling within glibc when time_t is 32 bits. */ +#if ! (defined _LIBC && __TIMESIZE != 64) +# undef __time64_t +# define __time64_t time_t +# define __gmtime64_r __gmtime_r +# define __localtime64_r __localtime_r +# define __mktime64 mktime +# define __timegm64 timegm +#endif + +#ifndef _LIBC + +/* Although glibc source code uses leading underscores, Gnulib wants + ordinary names. + + Portable standalone applications should supply a that + declares a POSIX-compliant localtime_r, for the benefit of older + implementations that lack localtime_r or have a nonstandard one. + Similarly for gmtime_r. See the gnulib time_r module for one way + to implement this. */ + +# undef __gmtime_r +# undef __localtime_r +# define __gmtime_r gmtime_r +# define __localtime_r localtime_r + +# define __mktime_internal mktime_internal + +#endif + +/* Subroutine of mktime. Return the time_t representation of TP and + normalize TP, given that a struct tm * maps to a time_t as performed + by FUNC. Record next guess for localtime-gmtime offset in *OFFSET. */ +extern __time64_t __mktime_internal (struct tm *tp, + struct tm *(*func) (__time64_t const *, + struct tm *), + mktime_offset_t *offset) attribute_hidden; diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mktime.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mktime.c new file mode 100644 index 00000000..c704f415 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/mktime.c @@ -0,0 +1,579 @@ +/* Convert a 'struct tm' to a time_t value. + Copyright (C) 1993-2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Paul Eggert . + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* The following macros influence what gets defined when this file is compiled: + + Macro/expression Which gnulib module This compilation unit + should define + + _LIBC (glibc proper) mktime + + NEED_MKTIME_WORKING mktime rpl_mktime + || NEED_MKTIME_WINDOWS + + NEED_MKTIME_INTERNAL mktime-internal mktime_internal + */ + +#ifndef _LIBC +# include +#endif + +/* Assume that leap seconds are possible, unless told otherwise. + If the host has a 'zic' command with a '-L leapsecondfilename' option, + then it supports leap seconds; otherwise it probably doesn't. */ +#ifndef LEAP_SECONDS_POSSIBLE +# define LEAP_SECONDS_POSSIBLE 1 +#endif + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include + +#ifndef NEED_MKTIME_INTERNAL +# define NEED_MKTIME_INTERNAL 0 +#endif +#ifndef NEED_MKTIME_WINDOWS +# define NEED_MKTIME_WINDOWS 0 +#endif +#ifndef NEED_MKTIME_WORKING +# define NEED_MKTIME_WORKING 0 +#endif + +#include "mktime-internal.h" + +#if !defined _LIBC && (NEED_MKTIME_WORKING || NEED_MKTIME_WINDOWS) +static void +my_tzset (void) +{ +# if NEED_MKTIME_WINDOWS + /* Rectify the value of the environment variable TZ. + There are four possible kinds of such values: + - Traditional US time zone names, e.g. "PST8PDT". Syntax: see + + - Time zone names based on geography, that contain one or more + slashes, e.g. "Europe/Moscow". + - Time zone names based on geography, without slashes, e.g. + "Singapore". + - Time zone names that contain explicit DST rules. Syntax: see + + The Microsoft CRT understands only the first kind. It produces incorrect + results if the value of TZ is of the other kinds. + But in a Cygwin environment, /etc/profile.d/tzset.sh sets TZ to a value + of the second kind for most geographies, or of the first kind in a few + other geographies. If it is of the second kind, neutralize it. For the + Microsoft CRT, an absent or empty TZ means the time zone that the user + has set in the Windows Control Panel. + If the value of TZ is of the third or fourth kind -- Cygwin programs + understand these syntaxes as well --, it does not matter whether we + neutralize it or not, since these values occur only when a Cygwin user + has set TZ explicitly; this case is 1. rare and 2. under the user's + responsibility. */ + const char *tz = getenv ("TZ"); + if (tz != NULL && strchr (tz, '/') != NULL) + _putenv ("TZ="); +# else + tzset (); +# endif +} +# undef __tzset +# define __tzset() my_tzset () +#endif + +#if defined _LIBC || NEED_MKTIME_WORKING || NEED_MKTIME_INTERNAL + +/* A signed type that can represent an integer number of years + multiplied by four times the number of seconds in a year. It is + needed when converting a tm_year value times the number of seconds + in a year. The factor of four comes because these products need + to be subtracted from each other, and sometimes with an offset + added to them, and then with another timestamp added, without + worrying about overflow. + + Much of the code uses long_int to represent __time64_t values, to + lessen the hassle of dealing with platforms where __time64_t is + unsigned, and because long_int should suffice to represent all + __time64_t values that mktime can generate even on platforms where + __time64_t is wider than the int components of struct tm. */ + +#if INT_MAX <= LONG_MAX / 4 / 366 / 24 / 60 / 60 +typedef long int long_int; +#else +typedef long long int long_int; +#endif +verify (INT_MAX <= TYPE_MAXIMUM (long_int) / 4 / 366 / 24 / 60 / 60); + +/* Shift A right by B bits portably, by dividing A by 2**B and + truncating towards minus infinity. B should be in the range 0 <= B + <= LONG_INT_BITS - 2, where LONG_INT_BITS is the number of useful + bits in a long_int. LONG_INT_BITS is at least 32. + + ISO C99 says that A >> B is implementation-defined if A < 0. Some + implementations (e.g., UNICOS 9.0 on a Cray Y-MP EL) don't shift + right in the usual way when A < 0, so SHR falls back on division if + ordinary A >> B doesn't seem to be the usual signed shift. */ + +static long_int +shr (long_int a, int b) +{ + long_int one = 1; + return (-one >> 1 == -1 + ? a >> b + : (a + (a < 0)) / (one << b) - (a < 0)); +} + +/* Bounds for the intersection of __time64_t and long_int. */ + +static long_int const mktime_min + = ((TYPE_SIGNED (__time64_t) + && TYPE_MINIMUM (__time64_t) < TYPE_MINIMUM (long_int)) + ? TYPE_MINIMUM (long_int) : TYPE_MINIMUM (__time64_t)); +static long_int const mktime_max + = (TYPE_MAXIMUM (long_int) < TYPE_MAXIMUM (__time64_t) + ? TYPE_MAXIMUM (long_int) : TYPE_MAXIMUM (__time64_t)); + +#define EPOCH_YEAR 1970 +#define TM_YEAR_BASE 1900 +verify (TM_YEAR_BASE % 100 == 0); + +/* Is YEAR + TM_YEAR_BASE a leap year? */ +static bool +leapyear (long_int year) +{ + /* Don't add YEAR to TM_YEAR_BASE, as that might overflow. + Also, work even if YEAR is negative. */ + return + ((year & 3) == 0 + && (year % 100 != 0 + || ((year / 100) & 3) == (- (TM_YEAR_BASE / 100) & 3))); +} + +/* How many days come before each month (0-12). */ +#ifndef _LIBC +static +#endif +const unsigned short int __mon_yday[2][13] = + { + /* Normal years. */ + { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 }, + /* Leap years. */ + { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 } + }; + + +/* Do the values A and B differ according to the rules for tm_isdst? + A and B differ if one is zero and the other positive. */ +static bool +isdst_differ (int a, int b) +{ + return (!a != !b) && (0 <= a) && (0 <= b); +} + +/* Return an integer value measuring (YEAR1-YDAY1 HOUR1:MIN1:SEC1) - + (YEAR0-YDAY0 HOUR0:MIN0:SEC0) in seconds, assuming that the clocks + were not adjusted between the timestamps. + + The YEAR values uses the same numbering as TP->tm_year. Values + need not be in the usual range. However, YEAR1 - YEAR0 must not + overflow even when multiplied by three times the number of seconds + in a year, and likewise for YDAY1 - YDAY0 and three times the + number of seconds in a day. */ + +static long_int +ydhms_diff (long_int year1, long_int yday1, int hour1, int min1, int sec1, + int year0, int yday0, int hour0, int min0, int sec0) +{ + verify (-1 / 2 == 0); + + /* Compute intervening leap days correctly even if year is negative. + Take care to avoid integer overflow here. */ + int a4 = shr (year1, 2) + shr (TM_YEAR_BASE, 2) - ! (year1 & 3); + int b4 = shr (year0, 2) + shr (TM_YEAR_BASE, 2) - ! (year0 & 3); + int a100 = (a4 + (a4 < 0)) / 25 - (a4 < 0); + int b100 = (b4 + (b4 < 0)) / 25 - (b4 < 0); + int a400 = shr (a100, 2); + int b400 = shr (b100, 2); + int intervening_leap_days = (a4 - b4) - (a100 - b100) + (a400 - b400); + + /* Compute the desired time without overflowing. */ + long_int years = year1 - year0; + long_int days = 365 * years + yday1 - yday0 + intervening_leap_days; + long_int hours = 24 * days + hour1 - hour0; + long_int minutes = 60 * hours + min1 - min0; + long_int seconds = 60 * minutes + sec1 - sec0; + return seconds; +} + +/* Return the average of A and B, even if A + B would overflow. + Round toward positive infinity. */ +static long_int +long_int_avg (long_int a, long_int b) +{ + return shr (a, 1) + shr (b, 1) + ((a | b) & 1); +} + +/* Return a long_int value corresponding to (YEAR-YDAY HOUR:MIN:SEC) + minus *TP seconds, assuming no clock adjustments occurred between + the two timestamps. + + YEAR and YDAY must not be so large that multiplying them by three times the + number of seconds in a year (or day, respectively) would overflow long_int. + *TP should be in the usual range. */ +static long_int +tm_diff (long_int year, long_int yday, int hour, int min, int sec, + struct tm const *tp) +{ + return ydhms_diff (year, yday, hour, min, sec, + tp->tm_year, tp->tm_yday, + tp->tm_hour, tp->tm_min, tp->tm_sec); +} + +/* Use CONVERT to convert T to a struct tm value in *TM. T must be in + range for __time64_t. Return TM if successful, NULL (setting errno) on + failure. */ +static struct tm * +convert_time (struct tm *(*convert) (const __time64_t *, struct tm *), + long_int t, struct tm *tm) +{ + __time64_t x = t; + return convert (&x, tm); +} + +/* Use CONVERT to convert *T to a broken down time in *TP. + If *T is out of range for conversion, adjust it so that + it is the nearest in-range value and then convert that. + A value is in range if it fits in both __time64_t and long_int. + Return TP on success, NULL (setting errno) on failure. */ +static struct tm * +ranged_convert (struct tm *(*convert) (const __time64_t *, struct tm *), + long_int *t, struct tm *tp) +{ + long_int t1 = (*t < mktime_min ? mktime_min + : *t <= mktime_max ? *t : mktime_max); + struct tm *r = convert_time (convert, t1, tp); + if (r) + { + *t = t1; + return r; + } + if (errno != EOVERFLOW) + return NULL; + + long_int bad = t1; + long_int ok = 0; + struct tm oktm; oktm.tm_sec = -1; + + /* BAD is a known out-of-range value, and OK is a known in-range one. + Use binary search to narrow the range between BAD and OK until + they differ by 1. */ + while (true) + { + long_int mid = long_int_avg (ok, bad); + if (mid == ok || mid == bad) + break; + if (convert_time (convert, mid, tp)) + ok = mid, oktm = *tp; + else if (errno != EOVERFLOW) + return NULL; + else + bad = mid; + } + + if (oktm.tm_sec < 0) + return NULL; + *t = ok; + *tp = oktm; + return tp; +} + + +/* Convert *TP to a __time64_t value, inverting + the monotonic and mostly-unit-linear conversion function CONVERT. + Use *OFFSET to keep track of a guess at the offset of the result, + compared to what the result would be for UTC without leap seconds. + If *OFFSET's guess is correct, only one CONVERT call is needed. + If successful, set *TP to the canonicalized struct tm; + otherwise leave *TP alone, return ((time_t) -1) and set errno. + This function is external because it is used also by timegm.c. */ +__time64_t +__mktime_internal (struct tm *tp, + struct tm *(*convert) (const __time64_t *, struct tm *), + mktime_offset_t *offset) +{ + struct tm tm; + + /* The maximum number of probes (calls to CONVERT) should be enough + to handle any combinations of time zone rule changes, solar time, + leap seconds, and oscillations around a spring-forward gap. + POSIX.1 prohibits leap seconds, but some hosts have them anyway. */ + int remaining_probes = 6; + + /* Time requested. Copy it in case CONVERT modifies *TP; this can + occur if TP is localtime's returned value and CONVERT is localtime. */ + int sec = tp->tm_sec; + int min = tp->tm_min; + int hour = tp->tm_hour; + int mday = tp->tm_mday; + int mon = tp->tm_mon; + int year_requested = tp->tm_year; + int isdst = tp->tm_isdst; + + /* 1 if the previous probe was DST. */ + int dst2 = 0; + + /* Ensure that mon is in range, and set year accordingly. */ + int mon_remainder = mon % 12; + int negative_mon_remainder = mon_remainder < 0; + int mon_years = mon / 12 - negative_mon_remainder; + long_int lyear_requested = year_requested; + long_int year = lyear_requested + mon_years; + + /* The other values need not be in range: + the remaining code handles overflows correctly. */ + + /* Calculate day of year from year, month, and day of month. + The result need not be in range. */ + int mon_yday = ((__mon_yday[leapyear (year)] + [mon_remainder + 12 * negative_mon_remainder]) + - 1); + long_int lmday = mday; + long_int yday = mon_yday + lmday; + + mktime_offset_t off = *offset; + int negative_offset_guess; + + int sec_requested = sec; + + if (LEAP_SECONDS_POSSIBLE) + { + /* Handle out-of-range seconds specially, + since ydhms_diff assumes every minute has 60 seconds. */ + if (sec < 0) + sec = 0; + if (59 < sec) + sec = 59; + } + + /* Invert CONVERT by probing. First assume the same offset as last + time. */ + + ckd_sub (&negative_offset_guess, 0, off); + long_int t0 = ydhms_diff (year, yday, hour, min, sec, + EPOCH_YEAR - TM_YEAR_BASE, 0, 0, 0, + negative_offset_guess); + long_int t = t0, t1 = t0, t2 = t0; + + /* Repeatedly use the error to improve the guess. */ + + while (true) + { + if (! ranged_convert (convert, &t, &tm)) + return -1; + long_int dt = tm_diff (year, yday, hour, min, sec, &tm); + if (dt == 0) + break; + + if (t == t1 && t != t2 + && (tm.tm_isdst < 0 + || (isdst < 0 + ? dst2 <= (tm.tm_isdst != 0) + : (isdst != 0) != (tm.tm_isdst != 0)))) + /* We can't possibly find a match, as we are oscillating + between two values. The requested time probably falls + within a spring-forward gap of size DT. Follow the common + practice in this case, which is to return a time that is DT + away from the requested time, preferring a time whose + tm_isdst differs from the requested value. (If no tm_isdst + was requested and only one of the two values has a nonzero + tm_isdst, prefer that value.) In practice, this is more + useful than returning -1. */ + goto offset_found; + + remaining_probes--; + if (remaining_probes == 0) + { + __set_errno (EOVERFLOW); + return -1; + } + + t1 = t2, t2 = t, t += dt, dst2 = tm.tm_isdst != 0; + } + + /* We have a match. Check whether tm.tm_isdst has the requested + value, if any. */ + if (isdst_differ (isdst, tm.tm_isdst)) + { + /* tm.tm_isdst has the wrong value. Look for a neighboring + time with the right value, and use its UTC offset. + + Heuristic: probe the adjacent timestamps in both directions, + looking for the desired isdst. If none is found within a + reasonable duration bound, assume a one-hour DST difference. + This should work for all real time zone histories in the tz + database. */ + + /* +1 if we wanted standard time but got DST, -1 if the reverse. */ + int dst_difference = (isdst == 0) - (tm.tm_isdst == 0); + + /* Distance between probes when looking for a DST boundary. In + tzdata2003a, the shortest period of DST is 601200 seconds + (e.g., America/Recife starting 2000-10-08 01:00), and the + shortest period of non-DST surrounded by DST is 694800 + seconds (Africa/Tunis starting 1943-04-17 01:00). Use the + minimum of these two values, so we don't miss these short + periods when probing. */ + int stride = 601200; + + /* In TZDB 2021e, the longest period of DST (or of non-DST), in + which the DST (or adjacent DST) difference is not one hour, + is 457243209 seconds: e.g., America/Cambridge_Bay with leap + seconds, starting 1965-10-31 00:00 in a switch from + double-daylight time (-05) to standard time (-07), and + continuing to 1980-04-27 02:00 in a switch from standard time + (-07) to daylight time (-06). */ + int duration_max = 457243209; + + /* Search in both directions, so the maximum distance is half + the duration; add the stride to avoid off-by-1 problems. */ + int delta_bound = duration_max / 2 + stride; + + int delta, direction; + + for (delta = stride; delta < delta_bound; delta += stride) + for (direction = -1; direction <= 1; direction += 2) + { + long_int ot; + if (! ckd_add (&ot, t, delta * direction)) + { + struct tm otm; + if (! ranged_convert (convert, &ot, &otm)) + return -1; + if (! isdst_differ (isdst, otm.tm_isdst)) + { + /* We found the desired tm_isdst. + Extrapolate back to the desired time. */ + long_int gt = ot + tm_diff (year, yday, hour, min, sec, + &otm); + if (mktime_min <= gt && gt <= mktime_max) + { + if (convert_time (convert, gt, &tm)) + { + t = gt; + goto offset_found; + } + if (errno != EOVERFLOW) + return -1; + } + } + } + } + + /* No unusual DST offset was found nearby. Assume one-hour DST. */ + t += 60 * 60 * dst_difference; + if (mktime_min <= t && t <= mktime_max && convert_time (convert, t, &tm)) + goto offset_found; + + __set_errno (EOVERFLOW); + return -1; + } + + offset_found: + /* Set *OFFSET to the low-order bits of T - T0 - NEGATIVE_OFFSET_GUESS. + This is just a heuristic to speed up the next mktime call, and + correctness is unaffected if integer overflow occurs here. */ + ckd_sub (offset, t, t0); + ckd_sub (offset, *offset, negative_offset_guess); + + if (LEAP_SECONDS_POSSIBLE && sec_requested != tm.tm_sec) + { + /* Adjust time to reflect the tm_sec requested, not the normalized value. + Also, repair any damage from a false match due to a leap second. */ + long_int sec_adjustment = sec == 0 && tm.tm_sec == 60; + sec_adjustment -= sec; + sec_adjustment += sec_requested; + if (ckd_add (&t, t, sec_adjustment) + || ! (mktime_min <= t && t <= mktime_max)) + { + __set_errno (EOVERFLOW); + return -1; + } + if (! convert_time (convert, t, &tm)) + return -1; + } + + *tp = tm; + return t; +} + +#endif /* _LIBC || NEED_MKTIME_WORKING || NEED_MKTIME_INTERNAL */ + +#if defined _LIBC || NEED_MKTIME_WORKING || NEED_MKTIME_WINDOWS + +/* Convert *TP to a __time64_t value. */ +__time64_t +__mktime64 (struct tm *tp) +{ + /* POSIX.1 8.1.1 requires that whenever mktime() is called, the + time zone names contained in the external variable 'tzname' shall + be set as if the tzset() function had been called. */ + __tzset (); + +# if defined _LIBC || NEED_MKTIME_WORKING + static mktime_offset_t localtime_offset; + return __mktime_internal (tp, __localtime64_r, &localtime_offset); +# else +# undef mktime + return mktime (tp); +# endif +} +#endif /* _LIBC || NEED_MKTIME_WORKING || NEED_MKTIME_WINDOWS */ + +#if defined _LIBC && __TIMESIZE != 64 + +libc_hidden_def (__mktime64) + +time_t +mktime (struct tm *tp) +{ + struct tm tm = *tp; + __time64_t t = __mktime64 (&tm); + if (in_time_t_range (t)) + { + *tp = tm; + return t; + } + else + { + __set_errno (EOVERFLOW); + return -1; + } +} + +#endif + +weak_alias (mktime, timelocal) +libc_hidden_def (mktime) +libc_hidden_weak (timelocal) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/msvc-inval.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/msvc-inval.c new file mode 100644 index 00000000..da3fc86a --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/msvc-inval.c @@ -0,0 +1,129 @@ +/* Invalid parameter handler for MSVC runtime libraries. + Copyright (C) 2011-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "msvc-inval.h" + +#if HAVE_MSVC_INVALID_PARAMETER_HANDLER \ + && !(MSVC_INVALID_PARAMETER_HANDLING == SANE_LIBRARY_HANDLING) + +/* Get _invalid_parameter_handler type and _set_invalid_parameter_handler + declaration. */ +# include + +# if MSVC_INVALID_PARAMETER_HANDLING == DEFAULT_HANDLING + +static void __cdecl +gl_msvc_invalid_parameter_handler (const wchar_t *expression, + const wchar_t *function, + const wchar_t *file, + unsigned int line, + uintptr_t dummy) +{ +} + +# else + +/* Get declarations of the native Windows API functions. */ +# define WIN32_LEAN_AND_MEAN +# include + +# if defined _MSC_VER + +static void __cdecl +gl_msvc_invalid_parameter_handler (const wchar_t *expression, + const wchar_t *function, + const wchar_t *file, + unsigned int line, + uintptr_t dummy) +{ + RaiseException (STATUS_GNULIB_INVALID_PARAMETER, 0, 0, NULL); +} + +# else + +/* An index to thread-local storage. */ +static DWORD tls_index; +static int tls_initialized /* = 0 */; + +/* Used as a fallback only. */ +static struct gl_msvc_inval_per_thread not_per_thread; + +struct gl_msvc_inval_per_thread * +gl_msvc_inval_current (void) +{ + if (!tls_initialized) + { + tls_index = TlsAlloc (); + tls_initialized = 1; + } + if (tls_index == TLS_OUT_OF_INDEXES) + /* TlsAlloc had failed. */ + return ¬_per_thread; + else + { + struct gl_msvc_inval_per_thread *pointer = + (struct gl_msvc_inval_per_thread *) TlsGetValue (tls_index); + if (pointer == NULL) + { + /* First call. Allocate a new 'struct gl_msvc_inval_per_thread'. */ + pointer = + (struct gl_msvc_inval_per_thread *) + malloc (sizeof (struct gl_msvc_inval_per_thread)); + if (pointer == NULL) + /* Could not allocate memory. Use the global storage. */ + pointer = ¬_per_thread; + TlsSetValue (tls_index, pointer); + } + return pointer; + } +} + +static void __cdecl +gl_msvc_invalid_parameter_handler (const wchar_t *expression, + const wchar_t *function, + const wchar_t *file, + unsigned int line, + uintptr_t dummy) +{ + struct gl_msvc_inval_per_thread *current = gl_msvc_inval_current (); + if (current->restart_valid) + longjmp (current->restart, 1); + else + /* An invalid parameter notification from outside the gnulib code. + Give the caller a chance to intervene. */ + RaiseException (STATUS_GNULIB_INVALID_PARAMETER, 0, 0, NULL); +} + +# endif + +# endif + +static int gl_msvc_inval_initialized /* = 0 */; + +void +gl_msvc_inval_ensure_handler (void) +{ + if (gl_msvc_inval_initialized == 0) + { + _set_invalid_parameter_handler (gl_msvc_invalid_parameter_handler); + gl_msvc_inval_initialized = 1; + } +} + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/msvc-inval.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/msvc-inval.h new file mode 100644 index 00000000..7aee6e5d --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/msvc-inval.h @@ -0,0 +1,227 @@ +/* Invalid parameter handler for MSVC runtime libraries. + Copyright (C) 2011-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef _MSVC_INVAL_H +#define _MSVC_INVAL_H + +/* With MSVC runtime libraries with the "invalid parameter handler" concept, + functions like fprintf(), dup2(), or close() crash when the caller passes + an invalid argument. But POSIX wants error codes (such as EINVAL or EBADF) + instead. + This file defines macros that turn such an invalid parameter notification + into a non-local exit. An error code can then be produced at the target + of this exit. You can thus write code like + + TRY_MSVC_INVAL + { + + } + CATCH_MSVC_INVAL + { + + } + DONE_MSVC_INVAL; + + This entire block expands to a single statement. + + The handling of invalid parameters can be done in three ways: + + * The default way, which is reasonable for programs (not libraries): + AC_DEFINE([MSVC_INVALID_PARAMETER_HANDLING], [DEFAULT_HANDLING]) + + * The way for libraries that make "hairy" calls (like close(-1), or + fclose(fp) where fileno(fp) is closed, or simply getdtablesize()): + AC_DEFINE([MSVC_INVALID_PARAMETER_HANDLING], [HAIRY_LIBRARY_HANDLING]) + + * The way for libraries that make no "hairy" calls: + AC_DEFINE([MSVC_INVALID_PARAMETER_HANDLING], [SANE_LIBRARY_HANDLING]) + */ + +/* This file uses HAVE_MSVC_INVALID_PARAMETER_HANDLER. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +#define DEFAULT_HANDLING 0 +#define HAIRY_LIBRARY_HANDLING 1 +#define SANE_LIBRARY_HANDLING 2 + +#if HAVE_MSVC_INVALID_PARAMETER_HANDLER \ + && !(MSVC_INVALID_PARAMETER_HANDLING == SANE_LIBRARY_HANDLING) +/* A native Windows platform with the "invalid parameter handler" concept, + and either DEFAULT_HANDLING or HAIRY_LIBRARY_HANDLING. */ + +# if MSVC_INVALID_PARAMETER_HANDLING == DEFAULT_HANDLING +/* Default handling. */ + +# ifdef __cplusplus +extern "C" { +# endif + +/* Ensure that the invalid parameter handler in installed that just returns. + Because we assume no other part of the program installs a different + invalid parameter handler, this solution is multithread-safe. */ +extern void gl_msvc_inval_ensure_handler (void); + +# ifdef __cplusplus +} +# endif + +# define TRY_MSVC_INVAL \ + do \ + { \ + gl_msvc_inval_ensure_handler (); \ + if (1) +# define CATCH_MSVC_INVAL \ + else +# define DONE_MSVC_INVAL \ + } \ + while (0) + +# else +/* Handling for hairy libraries. */ + +# include + +/* Gnulib can define its own status codes, as described in the page + "Raising Software Exceptions" on microsoft.com + . + Our status codes are composed of + - 0xE0000000, mandatory for all user-defined status codes, + - 0x474E550, a API identifier ("GNU"), + - 0, 1, 2, ..., used to distinguish different status codes from the + same API. */ +# define STATUS_GNULIB_INVALID_PARAMETER (0xE0000000 + 0x474E550 + 0) + +# if defined _MSC_VER +/* A compiler that supports __try/__except, as described in the page + "try-except statement" on microsoft.com + . + With __try/__except, we can use the multithread-safe exception handling. */ + +# ifdef __cplusplus +extern "C" { +# endif + +/* Ensure that the invalid parameter handler in installed that raises a + software exception with code STATUS_GNULIB_INVALID_PARAMETER. + Because we assume no other part of the program installs a different + invalid parameter handler, this solution is multithread-safe. */ +extern void gl_msvc_inval_ensure_handler (void); + +# ifdef __cplusplus +} +# endif + +# define TRY_MSVC_INVAL \ + do \ + { \ + gl_msvc_inval_ensure_handler (); \ + __try +# define CATCH_MSVC_INVAL \ + __except (GetExceptionCode () == STATUS_GNULIB_INVALID_PARAMETER \ + ? EXCEPTION_EXECUTE_HANDLER \ + : EXCEPTION_CONTINUE_SEARCH) +# define DONE_MSVC_INVAL \ + } \ + while (0) + +# else +/* Any compiler. + We can only use setjmp/longjmp. */ + +# include + +# ifdef __cplusplus +extern "C" { +# endif + +struct gl_msvc_inval_per_thread +{ + /* The restart that will resume execution at the code between + CATCH_MSVC_INVAL and DONE_MSVC_INVAL. It is enabled only between + TRY_MSVC_INVAL and CATCH_MSVC_INVAL. */ + jmp_buf restart; + + /* Tells whether the contents of restart is valid. */ + int restart_valid; +}; + +/* Ensure that the invalid parameter handler in installed that passes + control to the gl_msvc_inval_restart if it is valid, or raises a + software exception with code STATUS_GNULIB_INVALID_PARAMETER otherwise. + Because we assume no other part of the program installs a different + invalid parameter handler, this solution is multithread-safe. */ +extern void gl_msvc_inval_ensure_handler (void); + +/* Return a pointer to the per-thread data for the current thread. */ +extern struct gl_msvc_inval_per_thread *gl_msvc_inval_current (void); + +# ifdef __cplusplus +} +# endif + +# define TRY_MSVC_INVAL \ + do \ + { \ + struct gl_msvc_inval_per_thread *msvc_inval_current; \ + gl_msvc_inval_ensure_handler (); \ + msvc_inval_current = gl_msvc_inval_current (); \ + /* First, initialize gl_msvc_inval_restart. */ \ + if (setjmp (msvc_inval_current->restart) == 0) \ + { \ + /* Then, mark it as valid. */ \ + msvc_inval_current->restart_valid = 1; +# define CATCH_MSVC_INVAL \ + /* Execution completed. \ + Mark gl_msvc_inval_restart as invalid. */ \ + msvc_inval_current->restart_valid = 0; \ + } \ + else \ + { \ + /* Execution triggered an invalid parameter notification. \ + Mark gl_msvc_inval_restart as invalid. */ \ + msvc_inval_current->restart_valid = 0; +# define DONE_MSVC_INVAL \ + } \ + } \ + while (0) + +# endif + +# endif + +#else +/* A platform that does not need to the invalid parameter handler, + or when SANE_LIBRARY_HANDLING is desired. */ + +/* The braces here avoid GCC warnings like + "warning: suggest explicit braces to avoid ambiguous 'else'". */ +# define TRY_MSVC_INVAL \ + do \ + { \ + if (1) +# define CATCH_MSVC_INVAL \ + else +# define DONE_MSVC_INVAL \ + } \ + while (0) + +#endif + +#endif /* _MSVC_INVAL_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/msvc-nothrow.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/msvc-nothrow.c new file mode 100644 index 00000000..06b35a61 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/msvc-nothrow.c @@ -0,0 +1,51 @@ +/* Wrappers that don't throw invalid parameter notifications + with MSVC runtime libraries. + Copyright (C) 2011-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "msvc-nothrow.h" + +/* Get declarations of the native Windows API functions. */ +#define WIN32_LEAN_AND_MEAN +#include + +#if HAVE_MSVC_INVALID_PARAMETER_HANDLER +# include "msvc-inval.h" +#endif + +#undef _get_osfhandle + +#if HAVE_MSVC_INVALID_PARAMETER_HANDLER +intptr_t +_gl_nothrow_get_osfhandle (int fd) +{ + intptr_t result; + + TRY_MSVC_INVAL + { + result = _get_osfhandle (fd); + } + CATCH_MSVC_INVAL + { + result = (intptr_t) INVALID_HANDLE_VALUE; + } + DONE_MSVC_INVAL; + + return result; +} +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/msvc-nothrow.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/msvc-nothrow.h new file mode 100644 index 00000000..dc6dd35d --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/msvc-nothrow.h @@ -0,0 +1,48 @@ +/* Wrappers that don't throw invalid parameter notifications + with MSVC runtime libraries. + Copyright (C) 2011-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef _MSVC_NOTHROW_H +#define _MSVC_NOTHROW_H + +/* With MSVC runtime libraries with the "invalid parameter handler" concept, + functions like fprintf(), dup2(), or close() crash when the caller passes + an invalid argument. But POSIX wants error codes (such as EINVAL or EBADF) + instead. + This file defines wrappers that turn such an invalid parameter notification + into an error code. */ + +/* This file uses HAVE_MSVC_INVALID_PARAMETER_HANDLER. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +#if defined _WIN32 && ! defined __CYGWIN__ + +/* Get original declaration of _get_osfhandle. */ +# include + +# if HAVE_MSVC_INVALID_PARAMETER_HANDLER + +/* Override _get_osfhandle. */ +extern intptr_t _gl_nothrow_get_osfhandle (int fd); +# define _get_osfhandle _gl_nothrow_get_osfhandle + +# endif + +#endif + +#endif /* _MSVC_NOTHROW_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/nl_langinfo-lock.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/nl_langinfo-lock.c new file mode 100644 index 00000000..5a248ed8 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/nl_langinfo-lock.c @@ -0,0 +1,151 @@ +/* Return the internal lock used by nl_langinfo. + Copyright (C) 2019-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 2019-2020. */ + +#include + +/* The option '--disable-threads' explicitly requests no locking. */ +/* When it is known that the gl_get_nl_langinfo_lock function is defined + by a dependency library, it should not be defined here. */ +#if AVOID_ANY_THREADS || OMIT_NL_LANGINFO_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 nl_langinfo. + 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_nl_langinfo_lock + +/* Macro for exporting a symbol (function, not variable) defined in this file, + when compiled into a shared library. */ +# ifndef SHLIB_EXPORTED +# if HAVE_VISIBILITY + /* Override the effect of the compiler option '-fvisibility=hidden'. */ +# define SHLIB_EXPORTED __attribute__((__visibility__("default"))) +# elif defined _WIN32 || defined __CYGWIN__ +# define SHLIB_EXPORTED __declspec(dllexport) +# else +# define SHLIB_EXPORTED +# endif +# endif + +# if defined _WIN32 && !defined __CYGWIN__ + +# define WIN32_LEAN_AND_MEAN /* avoid including junk */ +# include + +# 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. */ +SHLIB_EXPORTED CRITICAL_SECTION *gl_get_nl_langinfo_lock (void); + +static glwthread_initguard_t guard = GLWTHREAD_INITGUARD_INIT; +static CRITICAL_SECTION lock; + +/* Returns the internal lock used by nl_langinfo. */ +CRITICAL_SECTION * +gl_get_nl_langinfo_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 + +static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; + +/* Make sure the function gets exported from shared libraries. */ +SHLIB_EXPORTED pthread_mutex_t *gl_get_nl_langinfo_lock (void); + +/* Returns the internal lock used by nl_langinfo. */ +pthread_mutex_t * +gl_get_nl_langinfo_lock (void) +{ + return &mutex; +} + +# elif HAVE_THREADS_H + +# include +# include + +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. */ +SHLIB_EXPORTED mtx_t *gl_get_nl_langinfo_lock (void); + +/* Returns the internal lock used by nl_langinfo. */ +mtx_t * +gl_get_nl_langinfo_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 nl_langinfo.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_nl_langinfo_lock) = &gl_get_nl_langinfo_lock; +# endif + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/nl_langinfo.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/nl_langinfo.c new file mode 100644 index 00000000..64ff93b0 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/nl_langinfo.c @@ -0,0 +1,585 @@ +/* nl_langinfo() replacement: query locale dependent information. + + Copyright (C) 2007-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +#include +#include +#include +#if defined _WIN32 && ! defined __CYGWIN__ +# define WIN32_LEAN_AND_MEAN /* avoid including junk */ +# include +# include +#endif + +#if REPLACE_NL_LANGINFO && !NL_LANGINFO_MTSAFE + +# if AVOID_ANY_THREADS + +/* The option '--disable-threads' explicitly requests no locking. */ + +# elif defined _WIN32 && !defined __CYGWIN__ + +# define WIN32_LEAN_AND_MEAN /* avoid including junk */ +# include + +# elif HAVE_PTHREAD_API + +# include +# if HAVE_THREADS_H && HAVE_WEAK_SYMBOLS +# include +# 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 + +# endif + +#endif + +/* nl_langinfo() must be multithread-safe. To achieve this without using + thread-local storage: + 1. We use a specific static buffer for each possible argument. + So that different threads can call nl_langinfo with different arguments, + without interfering. + 2. 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 !REPLACE_NL_LANGINFO || GNULIB_defined_CODESET +/* Return the codeset of the current locale, if this is easily deducible. + Otherwise, return "". */ +static char * +ctype_codeset (void) +{ + /* This function is only used on platforms which don't have uselocale(). + Therefore we don't need to look at the per-thread locale first, here. */ + static char result[2 + 10 + 1]; + char buf[2 + 10 + 1]; + char locale[SETLOCALE_NULL_MAX]; + char *codeset; + size_t codesetlen; + + if (setlocale_null_r (LC_CTYPE, locale, sizeof (locale))) + locale[0] = '\0'; + + codeset = buf; + codeset[0] = '\0'; + + if (locale[0]) + { + /* If the locale name contains an encoding after the dot, return it. */ + char *dot = strchr (locale, '.'); + + if (dot) + { + /* Look for the possible @... trailer and remove it, if any. */ + char *codeset_start = dot + 1; + char const *modifier = strchr (codeset_start, '@'); + + if (! modifier) + codeset = codeset_start; + else + { + codesetlen = modifier - codeset_start; + if (codesetlen < sizeof buf) + { + codeset = memcpy (buf, codeset_start, codesetlen); + codeset[codesetlen] = '\0'; + } + } + } + } + +# if defined _WIN32 && ! defined __CYGWIN__ + /* If setlocale is successful, it returns the number of the + codepage, as a string. Otherwise, fall back on Windows API + GetACP, which returns the locale's codepage as a number (although + this doesn't change according to what the 'setlocale' call specified). + Either way, prepend "CP" to make it a valid codeset name. */ + codesetlen = strlen (codeset); + if (0 < codesetlen && codesetlen < sizeof buf - 2) + memmove (buf + 2, codeset, codesetlen + 1); + else + sprintf (buf + 2, "%u", GetACP ()); + /* For a locale name such as "French_France.65001", in Windows 10, + setlocale now returns "French_France.utf8" instead. */ + if (strcmp (buf + 2, "65001") == 0 || strcmp (buf + 2, "utf8") == 0) + return (char *) "UTF-8"; + else + { + memcpy (buf, "CP", 2); + strcpy (result, buf); + return result; + } +# else + strcpy (result, codeset); + return result; +#endif +} +#endif + + +#if REPLACE_NL_LANGINFO + +/* Override nl_langinfo with support for added nl_item values. */ + +# undef nl_langinfo + +/* Without locking, on Solaris 11.3, test-nl_langinfo-mt fails, with message + "thread5 disturbed by threadN!", even when threadN invokes only + nl_langinfo (CODESET); + nl_langinfo (CRNCYSTR); + Similarly on Solaris 10. */ + +# if !NL_LANGINFO_MTSAFE /* Solaris */ + +# define ITEMS (MAXSTRMSG + 1) +# define MAX_RESULT_LEN 80 + +static char * +nl_langinfo_unlocked (nl_item item) +{ + static char result[ITEMS][MAX_RESULT_LEN]; + + /* The result of nl_langinfo is in storage that can be overwritten by + other calls to nl_langinfo. */ + char *tmp = nl_langinfo (item); + if (item >= 0 && item < ITEMS && tmp != NULL) + { + size_t tmp_len = strlen (tmp); + if (tmp_len < MAX_RESULT_LEN) + strcpy (result[item], tmp); + else + { + /* Produce a truncated result. Oh well... */ + result[item][MAX_RESULT_LEN - 1] = '\0'; + memcpy (result[item], tmp, MAX_RESULT_LEN - 1); + } + return result[item]; + } + else + return tmp; +} + +/* Use a lock, so that no two threads can invoke nl_langinfo_unlocked + at the same time. */ + +/* Prohibit renaming this symbol. */ +# undef gl_get_nl_langinfo_lock + +# if AVOID_ANY_THREADS + +/* The option '--disable-threads' explicitly requests no locking. */ +# define nl_langinfo_with_lock nl_langinfo_unlocked + +# elif defined _WIN32 && !defined __CYGWIN__ + +extern __declspec(dllimport) CRITICAL_SECTION *gl_get_nl_langinfo_lock (void); + +static char * +nl_langinfo_with_lock (nl_item item) +{ + CRITICAL_SECTION *lock = gl_get_nl_langinfo_lock (); + char *ret; + + EnterCriticalSection (lock); + ret = nl_langinfo_unlocked (item); + LeaveCriticalSection (lock); + + return ret; +} + +# elif HAVE_PTHREAD_API + +extern +# if defined _WIN32 || defined __CYGWIN__ + __declspec(dllimport) +# endif + pthread_mutex_t *gl_get_nl_langinfo_lock (void); + +# if HAVE_WEAK_SYMBOLS /* musl libc, FreeBSD, NetBSD, OpenBSD, Haiku */ + + /* 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 char * +nl_langinfo_with_lock (nl_item item) +{ + if (pthread_in_use()) + { + pthread_mutex_t *lock = gl_get_nl_langinfo_lock (); + char *ret; + + if (pthread_mutex_lock (lock)) + abort (); + ret = nl_langinfo_unlocked (item); + if (pthread_mutex_unlock (lock)) + abort (); + + return ret; + } + else + return nl_langinfo_unlocked (item); +} + +# elif HAVE_THREADS_H + +extern mtx_t *gl_get_nl_langinfo_lock (void); + +static char * +nl_langinfo_with_lock (nl_item item) +{ + mtx_t *lock = gl_get_nl_langinfo_lock (); + char *ret; + + if (mtx_lock (lock) != thrd_success) + abort (); + ret = nl_langinfo_unlocked (item); + if (mtx_unlock (lock) != thrd_success) + abort (); + + return ret; +} + +# endif + +# else + +/* On other platforms, no lock is needed. */ +# define nl_langinfo_with_lock nl_langinfo + +# endif + +char * +rpl_nl_langinfo (nl_item item) +{ + switch (item) + { +# if GNULIB_defined_CODESET + case CODESET: + return ctype_codeset (); +# endif +# if GNULIB_defined_T_FMT_AMPM + case T_FMT_AMPM: + return (char *) "%I:%M:%S %p"; +# endif +# if GNULIB_defined_ALTMON + case ALTMON_1: + case ALTMON_2: + case ALTMON_3: + case ALTMON_4: + case ALTMON_5: + case ALTMON_6: + case ALTMON_7: + case ALTMON_8: + case ALTMON_9: + case ALTMON_10: + case ALTMON_11: + case ALTMON_12: + /* We don't ship the appropriate localizations with gnulib. Therefore, + treat ALTMON_i like MON_i. */ + item = item - ALTMON_1 + MON_1; + break; +# endif +# if GNULIB_defined_ERA + case ERA: + /* The format is not standardized. In glibc it is a sequence of strings + of the form "direction:offset:start_date:end_date:era_name:era_format" + with an empty string at the end. */ + return (char *) ""; + case ERA_D_FMT: + /* The %Ex conversion in strftime behaves like %x if the locale does not + have an alternative time format. */ + item = D_FMT; + break; + case ERA_D_T_FMT: + /* The %Ec conversion in strftime behaves like %c if the locale does not + have an alternative time format. */ + item = D_T_FMT; + break; + case ERA_T_FMT: + /* The %EX conversion in strftime behaves like %X if the locale does not + have an alternative time format. */ + item = T_FMT; + break; + case ALT_DIGITS: + /* The format is not standardized. In glibc it is a sequence of 10 + strings, appended in memory. */ + return (char *) "\0\0\0\0\0\0\0\0\0\0"; +# endif +# if GNULIB_defined_YESEXPR || !FUNC_NL_LANGINFO_YESEXPR_WORKS + case YESEXPR: + return (char *) "^[yY]"; + case NOEXPR: + return (char *) "^[nN]"; +# endif + default: + break; + } + return nl_langinfo_with_lock (item); +} + +#else + +/* Provide nl_langinfo from scratch, either for native MS-Windows, or + for old Unix platforms without locales, such as Linux libc5 or + BeOS. */ + +# include + +char * +nl_langinfo (nl_item item) +{ + char buf[100]; + struct tm tmm = { 0 }; + + switch (item) + { + /* nl_langinfo items of the LC_CTYPE category */ + case CODESET: + { + char *codeset = ctype_codeset (); + if (*codeset) + return codeset; + } +# ifdef __BEOS__ + return (char *) "UTF-8"; +# else + return (char *) "ISO-8859-1"; +# endif + /* nl_langinfo items of the LC_NUMERIC category */ + case RADIXCHAR: + return localeconv () ->decimal_point; + case THOUSEP: + return localeconv () ->thousands_sep; +# ifdef GROUPING + case GROUPING: + return localeconv () ->grouping; +# endif + /* nl_langinfo items of the LC_TIME category. + TODO: Really use the locale. */ + case D_T_FMT: + case ERA_D_T_FMT: + return (char *) "%a %b %e %H:%M:%S %Y"; + case D_FMT: + case ERA_D_FMT: + return (char *) "%m/%d/%y"; + case T_FMT: + case ERA_T_FMT: + return (char *) "%H:%M:%S"; + case T_FMT_AMPM: + return (char *) "%I:%M:%S %p"; + case AM_STR: + { + static char result[80]; + if (!strftime (buf, sizeof result, "%p", &tmm)) + return (char *) "AM"; + strcpy (result, buf); + return result; + } + case PM_STR: + { + static char result[80]; + tmm.tm_hour = 12; + if (!strftime (buf, sizeof result, "%p", &tmm)) + return (char *) "PM"; + strcpy (result, buf); + return result; + } + case DAY_1: + case DAY_2: + case DAY_3: + case DAY_4: + case DAY_5: + case DAY_6: + case DAY_7: + { + static char result[7][50]; + static char const days[][sizeof "Wednesday"] = { + "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", + "Friday", "Saturday" + }; + tmm.tm_wday = item - DAY_1; + if (!strftime (buf, sizeof result[0], "%A", &tmm)) + return (char *) days[item - DAY_1]; + strcpy (result[item - DAY_1], buf); + return result[item - DAY_1]; + } + case ABDAY_1: + case ABDAY_2: + case ABDAY_3: + case ABDAY_4: + case ABDAY_5: + case ABDAY_6: + case ABDAY_7: + { + static char result[7][30]; + static char const abdays[][sizeof "Sun"] = { + "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" + }; + tmm.tm_wday = item - ABDAY_1; + if (!strftime (buf, sizeof result[0], "%a", &tmm)) + return (char *) abdays[item - ABDAY_1]; + strcpy (result[item - ABDAY_1], buf); + return result[item - ABDAY_1]; + } + { + static char const months[][sizeof "September"] = { + "January", "February", "March", "April", "May", "June", "July", + "August", "September", "October", "November", "December" + }; + case MON_1: + case MON_2: + case MON_3: + case MON_4: + case MON_5: + case MON_6: + case MON_7: + case MON_8: + case MON_9: + case MON_10: + case MON_11: + case MON_12: + { + static char result[12][50]; + tmm.tm_mon = item - MON_1; + if (!strftime (buf, sizeof result[0], "%B", &tmm)) + return (char *) months[item - MON_1]; + strcpy (result[item - MON_1], buf); + return result[item - MON_1]; + } + case ALTMON_1: + case ALTMON_2: + case ALTMON_3: + case ALTMON_4: + case ALTMON_5: + case ALTMON_6: + case ALTMON_7: + case ALTMON_8: + case ALTMON_9: + case ALTMON_10: + case ALTMON_11: + case ALTMON_12: + { + static char result[12][50]; + tmm.tm_mon = item - ALTMON_1; + /* The platforms without nl_langinfo() don't support strftime with + %OB. We don't even need to try. */ + #if 0 + if (!strftime (buf, sizeof result[0], "%OB", &tmm)) + #endif + if (!strftime (buf, sizeof result[0], "%B", &tmm)) + return (char *) months[item - ALTMON_1]; + strcpy (result[item - ALTMON_1], buf); + return result[item - ALTMON_1]; + } + } + case ABMON_1: + case ABMON_2: + case ABMON_3: + case ABMON_4: + case ABMON_5: + case ABMON_6: + case ABMON_7: + case ABMON_8: + case ABMON_9: + case ABMON_10: + case ABMON_11: + case ABMON_12: + { + static char result[12][30]; + static char const abmonths[][sizeof "Jan"] = { + "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", + "Aug", "Sep", "Oct", "Nov", "Dec" + }; + tmm.tm_mon = item - ABMON_1; + if (!strftime (buf, sizeof result[0], "%b", &tmm)) + return (char *) abmonths[item - ABMON_1]; + strcpy (result[item - ABMON_1], buf); + return result[item - ABMON_1]; + } + case ERA: + return (char *) ""; + case ALT_DIGITS: + return (char *) "\0\0\0\0\0\0\0\0\0\0"; + /* nl_langinfo items of the LC_MONETARY category. */ + case CRNCYSTR: + return localeconv () ->currency_symbol; +# ifdef INT_CURR_SYMBOL + case INT_CURR_SYMBOL: + return localeconv () ->int_curr_symbol; + case MON_DECIMAL_POINT: + return localeconv () ->mon_decimal_point; + case MON_THOUSANDS_SEP: + return localeconv () ->mon_thousands_sep; + case MON_GROUPING: + return localeconv () ->mon_grouping; + case POSITIVE_SIGN: + return localeconv () ->positive_sign; + case NEGATIVE_SIGN: + return localeconv () ->negative_sign; + case FRAC_DIGITS: + return & localeconv () ->frac_digits; + case INT_FRAC_DIGITS: + return & localeconv () ->int_frac_digits; + case P_CS_PRECEDES: + return & localeconv () ->p_cs_precedes; + case N_CS_PRECEDES: + return & localeconv () ->n_cs_precedes; + case P_SEP_BY_SPACE: + return & localeconv () ->p_sep_by_space; + case N_SEP_BY_SPACE: + return & localeconv () ->n_sep_by_space; + case P_SIGN_POSN: + return & localeconv () ->p_sign_posn; + case N_SIGN_POSN: + return & localeconv () ->n_sign_posn; +# endif + /* nl_langinfo items of the LC_MESSAGES category + TODO: Really use the locale. */ + case YESEXPR: + return (char *) "^[yY]"; + case NOEXPR: + return (char *) "^[nN]"; + default: + return (char *) ""; + } +} + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/nstrftime.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/nstrftime.c new file mode 100644 index 00000000..21596329 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/nstrftime.c @@ -0,0 +1,1510 @@ +/* Copyright (C) 1991-2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifdef _LIBC +# define USE_IN_EXTENDED_LOCALE_MODEL 1 +# define HAVE_STRUCT_ERA_ENTRY 1 +# define HAVE_TM_GMTOFF 1 +# define HAVE_STRUCT_TM_TM_ZONE 1 +# define HAVE_TZNAME 1 +# include "../locale/localeinfo.h" +#else +# include +# if FPRINTFTIME +# include "fprintftime.h" +# else +# include "strftime.h" +# endif +# include "time-internal.h" +#endif + +#include +#include +#include + +#if HAVE_TZNAME && !HAVE_DECL_TZNAME +extern char *tzname[]; +#endif + +/* Do multibyte processing if multibyte encodings are supported, unless + multibyte sequences are safe in formats. Multibyte sequences are + safe if they cannot contain byte sequences that look like format + conversion specifications. The multibyte encodings used by the + C library on the various platforms (UTF-8, GB2312, GBK, CP936, + GB18030, EUC-TW, BIG5, BIG5-HKSCS, CP950, EUC-JP, EUC-KR, CP949, + SHIFT_JIS, CP932, JOHAB) are safe for formats, because the byte '%' + cannot occur in a multibyte character except in the first byte. + + The DEC-HANYU encoding used on OSF/1 is not safe for formats, but + this encoding has never been seen in real-life use, so we ignore + it. */ +#if !(defined __osf__ && 0) +# define MULTIBYTE_IS_FORMAT_SAFE 1 +#endif +#define DO_MULTIBYTE (! MULTIBYTE_IS_FORMAT_SAFE) + +#if DO_MULTIBYTE +# include + static const mbstate_t mbstate_zero; +#endif + +#include +#include +#include +#include +#include + +#include "attribute.h" +#include + +#ifdef COMPILE_WIDE +# include +# define CHAR_T wchar_t +# define UCHAR_T unsigned int +# define L_(Str) L##Str +# define NLW(Sym) _NL_W##Sym + +# define MEMCPY(d, s, n) __wmemcpy (d, s, n) +# define STRLEN(s) __wcslen (s) + +#else +# define CHAR_T char +# define UCHAR_T unsigned char +# define L_(Str) Str +# define NLW(Sym) Sym +# define ABALTMON_1 _NL_ABALTMON_1 + +# define MEMCPY(d, s, n) memcpy (d, s, n) +# define STRLEN(s) strlen (s) + +#endif + +/* Shift A right by B bits portably, by dividing A by 2**B and + truncating towards minus infinity. A and B should be free of side + effects, and B should be in the range 0 <= B <= INT_BITS - 2, where + INT_BITS is the number of useful bits in an int. GNU code can + assume that INT_BITS is at least 32. + + ISO C99 says that A >> B is implementation-defined if A < 0. Some + implementations (e.g., UNICOS 9.0 on a Cray Y-MP EL) don't shift + right in the usual way when A < 0, so SHR falls back on division if + ordinary A >> B doesn't seem to be the usual signed shift. */ +#define SHR(a, b) \ + (-1 >> 1 == -1 \ + ? (a) >> (b) \ + : ((a) + ((a) < 0)) / (1 << (b)) - ((a) < 0)) + +#define TM_YEAR_BASE 1900 + +#ifndef __isleap +/* Nonzero if YEAR is a leap year (every 4 years, + except every 100th isn't, and every 400th is). */ +# define __isleap(year) \ + ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0)) +#endif + + +#ifdef _LIBC +# define mktime_z(tz, tm) mktime (tm) +# define tzname __tzname +# define tzset __tzset +#endif + +#ifndef FPRINTFTIME +# define FPRINTFTIME 0 +#endif + +#if FPRINTFTIME +# define STREAM_OR_CHAR_T FILE +# define STRFTIME_ARG(x) /* empty */ +#else +# define STREAM_OR_CHAR_T CHAR_T +# define STRFTIME_ARG(x) x, +#endif + +#if FPRINTFTIME +# define memset_byte(P, Len, Byte) \ + do { size_t _i; for (_i = 0; _i < Len; _i++) fputc (Byte, P); } while (0) +# define memset_space(P, Len) memset_byte (P, Len, ' ') +# define memset_zero(P, Len) memset_byte (P, Len, '0') +#elif defined COMPILE_WIDE +# define memset_space(P, Len) (wmemset (P, L' ', Len), (P) += (Len)) +# define memset_zero(P, Len) (wmemset (P, L'0', Len), (P) += (Len)) +#else +# define memset_space(P, Len) (memset (P, ' ', Len), (P) += (Len)) +# define memset_zero(P, Len) (memset (P, '0', Len), (P) += (Len)) +#endif + +#if FPRINTFTIME +# define advance(P, N) +#else +# define advance(P, N) ((P) += (N)) +#endif + +#define add(n, f) width_add (width, n, f) +#define width_add(width, n, f) \ + do \ + { \ + size_t _n = (n); \ + size_t _w = pad == L_('-') || width < 0 ? 0 : width; \ + size_t _incr = _n < _w ? _w : _n; \ + if (_incr >= maxsize - i) \ + { \ + errno = ERANGE; \ + return 0; \ + } \ + if (p) \ + { \ + if (_n < _w) \ + { \ + size_t _delta = _w - _n; \ + if (pad == L_('0') || pad == L_('+')) \ + memset_zero (p, _delta); \ + else \ + memset_space (p, _delta); \ + } \ + f; \ + advance (p, _n); \ + } \ + i += _incr; \ + } while (0) + +#define add1(c) width_add1 (width, c) +#if FPRINTFTIME +# define width_add1(width, c) width_add (width, 1, fputc (c, p)) +#else +# define width_add1(width, c) width_add (width, 1, *p = c) +#endif + +#define cpy(n, s) width_cpy (width, n, s) +#if FPRINTFTIME +# define width_cpy(width, n, s) \ + width_add (width, n, \ + do \ + { \ + if (to_lowcase) \ + fwrite_lowcase (p, (s), _n); \ + else if (to_uppcase) \ + fwrite_uppcase (p, (s), _n); \ + else \ + { \ + /* Ignore the value of fwrite. The caller can determine whether \ + an error occurred by inspecting ferror (P). All known fwrite \ + implementations set the stream's error indicator when they \ + fail due to ENOMEM etc., even though C11 and POSIX.1-2008 do \ + not require this. */ \ + fwrite (s, _n, 1, p); \ + } \ + } \ + while (0) \ + ) +#else +# define width_cpy(width, n, s) \ + width_add (width, n, \ + if (to_lowcase) \ + memcpy_lowcase (p, (s), _n LOCALE_ARG); \ + else if (to_uppcase) \ + memcpy_uppcase (p, (s), _n LOCALE_ARG); \ + else \ + MEMCPY ((void *) p, (void const *) (s), _n)) +#endif + +#ifdef COMPILE_WIDE +# ifndef USE_IN_EXTENDED_LOCALE_MODEL +# undef __mbsrtowcs_l +# define __mbsrtowcs_l(d, s, l, st, loc) __mbsrtowcs (d, s, l, st) +# endif +#endif + + +#if defined _LIBC && defined USE_IN_EXTENDED_LOCALE_MODEL +/* We use this code also for the extended locale handling where the + function gets as an additional argument the locale which has to be + used. To access the values we have to redefine the _NL_CURRENT + macro. */ +# define strftime __strftime_l +# define wcsftime __wcsftime_l +# undef _NL_CURRENT +# define _NL_CURRENT(category, item) \ + (current->values[_NL_ITEM_INDEX (item)].string) +# define LOCALE_PARAM , locale_t loc +# define LOCALE_ARG , loc +# define HELPER_LOCALE_ARG , current +#else +# define LOCALE_PARAM +# define LOCALE_ARG +# ifdef _LIBC +# define HELPER_LOCALE_ARG , _NL_CURRENT_DATA (LC_TIME) +# else +# define HELPER_LOCALE_ARG +# endif +#endif + +#ifdef COMPILE_WIDE +# ifdef USE_IN_EXTENDED_LOCALE_MODEL +# define TOUPPER(Ch, L) __towupper_l (Ch, L) +# define TOLOWER(Ch, L) __towlower_l (Ch, L) +# else +# define TOUPPER(Ch, L) towupper (Ch) +# define TOLOWER(Ch, L) towlower (Ch) +# endif +#else +# ifdef USE_IN_EXTENDED_LOCALE_MODEL +# define TOUPPER(Ch, L) __toupper_l (Ch, L) +# define TOLOWER(Ch, L) __tolower_l (Ch, L) +# else +# define TOUPPER(Ch, L) toupper (Ch) +# define TOLOWER(Ch, L) tolower (Ch) +# endif +#endif +/* We don't use 'isdigit' here since the locale dependent + interpretation is not what we want here. We only need to accept + the arabic digits in the ASCII range. One day there is perhaps a + more reliable way to accept other sets of digits. */ +#define ISDIGIT(Ch) ((unsigned int) (Ch) - L_('0') <= 9) + +/* Avoid false GCC warning "'memset' specified size 18446744073709551615 exceeds + maximum object size 9223372036854775807", caused by insufficient data flow + analysis and value propagation of the 'width_add' expansion when GCC is not + optimizing. Cf. . */ +#if __GNUC__ >= 7 && !__OPTIMIZE__ +# pragma GCC diagnostic ignored "-Wstringop-overflow" +#endif + +#if FPRINTFTIME +static void +fwrite_lowcase (FILE *fp, const CHAR_T *src, size_t len) +{ + while (len-- > 0) + { + fputc (TOLOWER ((UCHAR_T) *src, loc), fp); + ++src; + } +} + +static void +fwrite_uppcase (FILE *fp, const CHAR_T *src, size_t len) +{ + while (len-- > 0) + { + fputc (TOUPPER ((UCHAR_T) *src, loc), fp); + ++src; + } +} +#else +static CHAR_T *memcpy_lowcase (CHAR_T *dest, const CHAR_T *src, + size_t len LOCALE_PARAM); + +static CHAR_T * +memcpy_lowcase (CHAR_T *dest, const CHAR_T *src, size_t len LOCALE_PARAM) +{ + while (len-- > 0) + dest[len] = TOLOWER ((UCHAR_T) src[len], loc); + return dest; +} + +static CHAR_T *memcpy_uppcase (CHAR_T *dest, const CHAR_T *src, + size_t len LOCALE_PARAM); + +static CHAR_T * +memcpy_uppcase (CHAR_T *dest, const CHAR_T *src, size_t len LOCALE_PARAM) +{ + while (len-- > 0) + dest[len] = TOUPPER ((UCHAR_T) src[len], loc); + return dest; +} +#endif + + +#if ! HAVE_TM_GMTOFF +/* Yield the difference between *A and *B, + measured in seconds, ignoring leap seconds. */ +# define tm_diff ftime_tm_diff +static int tm_diff (const struct tm *, const struct tm *); +static int +tm_diff (const struct tm *a, const struct tm *b) +{ + /* Compute intervening leap days correctly even if year is negative. + Take care to avoid int overflow in leap day calculations, + but it's OK to assume that A and B are close to each other. */ + int a4 = SHR (a->tm_year, 2) + SHR (TM_YEAR_BASE, 2) - ! (a->tm_year & 3); + int b4 = SHR (b->tm_year, 2) + SHR (TM_YEAR_BASE, 2) - ! (b->tm_year & 3); + int a100 = (a4 + (a4 < 0)) / 25 - (a4 < 0); + int b100 = (b4 + (b4 < 0)) / 25 - (b4 < 0); + int a400 = SHR (a100, 2); + int b400 = SHR (b100, 2); + int intervening_leap_days = (a4 - b4) - (a100 - b100) + (a400 - b400); + int years = a->tm_year - b->tm_year; + int days = (365 * years + intervening_leap_days + + (a->tm_yday - b->tm_yday)); + return (60 * (60 * (24 * days + (a->tm_hour - b->tm_hour)) + + (a->tm_min - b->tm_min)) + + (a->tm_sec - b->tm_sec)); +} +#endif /* ! HAVE_TM_GMTOFF */ + + + +/* The number of days from the first day of the first ISO week of this + year to the year day YDAY with week day WDAY. ISO weeks start on + Monday; the first ISO week has the year's first Thursday. YDAY may + be as small as YDAY_MINIMUM. */ +#define ISO_WEEK_START_WDAY 1 /* Monday */ +#define ISO_WEEK1_WDAY 4 /* Thursday */ +#define YDAY_MINIMUM (-366) +static int iso_week_days (int, int); +static __inline int +iso_week_days (int yday, int wday) +{ + /* Add enough to the first operand of % to make it nonnegative. */ + int big_enough_multiple_of_7 = (-YDAY_MINIMUM / 7 + 2) * 7; + return (yday + - (yday - wday + ISO_WEEK1_WDAY + big_enough_multiple_of_7) % 7 + + ISO_WEEK1_WDAY - ISO_WEEK_START_WDAY); +} + + +/* When compiling this file, GNU applications can #define my_strftime + to a symbol (typically nstrftime) to get an extended strftime with + extra arguments TZ and NS. */ + +#if FPRINTFTIME +# undef my_strftime +# define my_strftime fprintftime +#endif + +#ifdef my_strftime +# define extra_args , tz, ns +# define extra_args_spec , timezone_t tz, int ns +#else +# if defined COMPILE_WIDE +# define my_strftime wcsftime +# define nl_get_alt_digit _nl_get_walt_digit +# else +# define my_strftime strftime +# define nl_get_alt_digit _nl_get_alt_digit +# endif +# define extra_args +# define extra_args_spec +/* We don't have this information in general. */ +# define tz 1 +# define ns 0 +#endif + +static size_t __strftime_internal (STREAM_OR_CHAR_T *, STRFTIME_ARG (size_t) + const CHAR_T *, const struct tm *, + bool, int, int, bool * + extra_args_spec LOCALE_PARAM); + +/* Write information from TP into S according to the format + string FORMAT, writing no more that MAXSIZE characters + (including the terminating '\0') and returning number of + characters written. If S is NULL, nothing will be written + anywhere, so to determine how many characters would be + written, use NULL for S and (size_t) -1 for MAXSIZE. */ +size_t +my_strftime (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) + const CHAR_T *format, + const struct tm *tp extra_args_spec LOCALE_PARAM) +{ + bool tzset_called = false; + return __strftime_internal (s, STRFTIME_ARG (maxsize) format, tp, false, + 0, -1, &tzset_called extra_args LOCALE_ARG); +} +libc_hidden_def (my_strftime) + +/* Just like my_strftime, above, but with more parameters. + UPCASE indicates that the result should be converted to upper case. + YR_SPEC and WIDTH specify the padding and width for the year. + *TZSET_CALLED indicates whether tzset has been called here. */ +static size_t +__strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) + const CHAR_T *format, + const struct tm *tp, bool upcase, + int yr_spec, int width, bool *tzset_called + extra_args_spec LOCALE_PARAM) +{ +#if defined _LIBC && defined USE_IN_EXTENDED_LOCALE_MODEL + struct __locale_data *const current = loc->__locales[LC_TIME]; +#endif +#if FPRINTFTIME + size_t maxsize = (size_t) -1; +#endif + + int saved_errno = errno; + int hour12 = tp->tm_hour; +#ifdef _NL_CURRENT + /* We cannot make the following values variables since we must delay + the evaluation of these values until really needed since some + expressions might not be valid in every situation. The 'struct tm' + might be generated by a strptime() call that initialized + only a few elements. Dereference the pointers only if the format + requires this. Then it is ok to fail if the pointers are invalid. */ +# define a_wkday \ + ((const CHAR_T *) (tp->tm_wday < 0 || tp->tm_wday > 6 \ + ? "?" : _NL_CURRENT (LC_TIME, NLW(ABDAY_1) + tp->tm_wday))) +# define f_wkday \ + ((const CHAR_T *) (tp->tm_wday < 0 || tp->tm_wday > 6 \ + ? "?" : _NL_CURRENT (LC_TIME, NLW(DAY_1) + tp->tm_wday))) +# define a_month \ + ((const CHAR_T *) (tp->tm_mon < 0 || tp->tm_mon > 11 \ + ? "?" : _NL_CURRENT (LC_TIME, NLW(ABMON_1) + tp->tm_mon))) +# define f_month \ + ((const CHAR_T *) (tp->tm_mon < 0 || tp->tm_mon > 11 \ + ? "?" : _NL_CURRENT (LC_TIME, NLW(MON_1) + tp->tm_mon))) +# define a_altmonth \ + ((const CHAR_T *) (tp->tm_mon < 0 || tp->tm_mon > 11 \ + ? "?" : _NL_CURRENT (LC_TIME, NLW(ABALTMON_1) + tp->tm_mon))) +# define f_altmonth \ + ((const CHAR_T *) (tp->tm_mon < 0 || tp->tm_mon > 11 \ + ? "?" : _NL_CURRENT (LC_TIME, NLW(ALTMON_1) + tp->tm_mon))) +# define ampm \ + ((const CHAR_T *) _NL_CURRENT (LC_TIME, tp->tm_hour > 11 \ + ? NLW(PM_STR) : NLW(AM_STR))) + +# define aw_len STRLEN (a_wkday) +# define am_len STRLEN (a_month) +# define aam_len STRLEN (a_altmonth) +# define ap_len STRLEN (ampm) +#endif +#if HAVE_TZNAME + char **tzname_vec = tzname; +#endif + const char *zone; + size_t i = 0; + STREAM_OR_CHAR_T *p = s; + const CHAR_T *f; +#if DO_MULTIBYTE && !defined COMPILE_WIDE + const char *format_end = NULL; +#endif + + zone = NULL; +#if HAVE_STRUCT_TM_TM_ZONE + /* The POSIX test suite assumes that setting + the environment variable TZ to a new value before calling strftime() + will influence the result (the %Z format) even if the information in + TP is computed with a totally different time zone. + This is bogus: though POSIX allows bad behavior like this, + POSIX does not require it. Do the right thing instead. */ + zone = (const char *) tp->tm_zone; +#endif +#if HAVE_TZNAME + if (!tz) + { + if (! (zone && *zone)) + zone = "GMT"; + } + else + { +# if !HAVE_STRUCT_TM_TM_ZONE + /* Infer the zone name from *TZ instead of from TZNAME. */ + tzname_vec = tz->tzname_copy; +# endif + } + /* The tzset() call might have changed the value. */ + if (!(zone && *zone) && tp->tm_isdst >= 0) + { + /* POSIX.1 requires that local time zone information be used as + though strftime called tzset. */ +# ifndef my_strftime + if (!*tzset_called) + { + tzset (); + *tzset_called = true; + } +# endif + zone = tzname_vec[tp->tm_isdst != 0]; + } +#endif + if (! zone) + zone = ""; + + if (hour12 > 12) + hour12 -= 12; + else + if (hour12 == 0) + hour12 = 12; + + for (f = format; *f != '\0'; width = -1, f++) + { + int pad = 0; /* Padding for number ('_', '-', '+', '0', or 0). */ + int modifier; /* Field modifier ('E', 'O', or 0). */ + int digits = 0; /* Max digits for numeric format. */ + int number_value; /* Numeric value to be printed. */ + unsigned int u_number_value; /* (unsigned int) number_value. */ + bool negative_number; /* The number is negative. */ + bool always_output_a_sign; /* +/- should always be output. */ + int tz_colon_mask; /* Bitmask of where ':' should appear. */ + const CHAR_T *subfmt; + CHAR_T *bufp; + CHAR_T buf[1 + + 2 /* for the two colons in a %::z or %:::z time zone */ + + (sizeof (int) < sizeof (time_t) + ? INT_STRLEN_BOUND (time_t) + : INT_STRLEN_BOUND (int))]; + bool to_lowcase = false; + bool to_uppcase = upcase; + size_t colons; + bool change_case = false; + int format_char; + int subwidth; + +#if DO_MULTIBYTE && !defined COMPILE_WIDE + switch (*f) + { + case L_('%'): + break; + + case L_('\b'): case L_('\t'): case L_('\n'): + case L_('\v'): case L_('\f'): case L_('\r'): + case L_(' '): case L_('!'): case L_('"'): case L_('#'): case L_('&'): + case L_('\''): case L_('('): case L_(')'): case L_('*'): case L_('+'): + case L_(','): case L_('-'): case L_('.'): case L_('/'): case L_('0'): + case L_('1'): case L_('2'): case L_('3'): case L_('4'): case L_('5'): + case L_('6'): case L_('7'): case L_('8'): case L_('9'): case L_(':'): + case L_(';'): case L_('<'): case L_('='): case L_('>'): case L_('?'): + case L_('A'): case L_('B'): case L_('C'): case L_('D'): case L_('E'): + case L_('F'): case L_('G'): case L_('H'): case L_('I'): case L_('J'): + case L_('K'): case L_('L'): case L_('M'): case L_('N'): case L_('O'): + case L_('P'): case L_('Q'): case L_('R'): case L_('S'): case L_('T'): + case L_('U'): case L_('V'): case L_('W'): case L_('X'): case L_('Y'): + case L_('Z'): case L_('['): case L_('\\'): case L_(']'): case L_('^'): + case L_('_'): case L_('a'): case L_('b'): case L_('c'): case L_('d'): + case L_('e'): case L_('f'): case L_('g'): case L_('h'): case L_('i'): + case L_('j'): case L_('k'): case L_('l'): case L_('m'): case L_('n'): + case L_('o'): case L_('p'): case L_('q'): case L_('r'): case L_('s'): + case L_('t'): case L_('u'): case L_('v'): case L_('w'): case L_('x'): + case L_('y'): case L_('z'): case L_('{'): case L_('|'): case L_('}'): + case L_('~'): + /* The C Standard requires these 98 characters (plus '%') to + be in the basic execution character set. None of these + characters can start a multibyte sequence, so they need + not be analyzed further. */ + add1 (*f); + continue; + + default: + /* Copy this multibyte sequence until we reach its end, find + an error, or come back to the initial shift state. */ + { + mbstate_t mbstate = mbstate_zero; + size_t len = 0; + size_t fsize; + + if (! format_end) + format_end = f + strlen (f) + 1; + fsize = format_end - f; + + do + { + size_t bytes = mbrlen (f + len, fsize - len, &mbstate); + + if (bytes == 0) + break; + + if (bytes == (size_t) -2) + { + len += strlen (f + len); + break; + } + + if (bytes == (size_t) -1) + { + len++; + break; + } + + len += bytes; + } + while (! mbsinit (&mbstate)); + + cpy (len, f); + f += len - 1; + continue; + } + } + +#else /* ! DO_MULTIBYTE */ + + /* Either multibyte encodings are not supported, they are + safe for formats, so any non-'%' byte can be copied through, + or this is the wide character version. */ + if (*f != L_('%')) + { + add1 (*f); + continue; + } + +#endif /* ! DO_MULTIBYTE */ + + char const *percent = f; + + /* Check for flags that can modify a format. */ + while (1) + { + switch (*++f) + { + /* This influences the number formats. */ + case L_('_'): + case L_('-'): + case L_('+'): + case L_('0'): + pad = *f; + continue; + + /* This changes textual output. */ + case L_('^'): + to_uppcase = true; + continue; + case L_('#'): + change_case = true; + continue; + + default: + break; + } + break; + } + + if (ISDIGIT (*f)) + { + width = 0; + do + { + if (ckd_mul (&width, width, 10) + || ckd_add (&width, width, *f - L_('0'))) + width = INT_MAX; + ++f; + } + while (ISDIGIT (*f)); + } + + /* Check for modifiers. */ + switch (*f) + { + case L_('E'): + case L_('O'): + modifier = *f++; + break; + + default: + modifier = 0; + break; + } + + /* Now do the specified format. */ + format_char = *f; + switch (format_char) + { +#define DO_NUMBER(d, v) \ + do \ + { \ + digits = d; \ + number_value = v; \ + goto do_number; \ + } \ + while (0) +#define DO_SIGNED_NUMBER(d, negative, v) \ + DO_MAYBE_SIGNED_NUMBER (d, negative, v, do_signed_number) +#define DO_YEARISH(d, negative, v) \ + DO_MAYBE_SIGNED_NUMBER (d, negative, v, do_yearish) +#define DO_MAYBE_SIGNED_NUMBER(d, negative, v, label) \ + do \ + { \ + digits = d; \ + negative_number = negative; \ + u_number_value = v; \ + goto label; \ + } \ + while (0) + + /* The mask is not what you might think. + When the ordinal i'th bit is set, insert a colon + before the i'th digit of the time zone representation. */ +#define DO_TZ_OFFSET(d, mask, v) \ + do \ + { \ + digits = d; \ + tz_colon_mask = mask; \ + u_number_value = v; \ + goto do_tz_offset; \ + } \ + while (0) +#define DO_NUMBER_SPACEPAD(d, v) \ + do \ + { \ + digits = d; \ + number_value = v; \ + goto do_number_spacepad; \ + } \ + while (0) + + case L_('%'): + if (f - 1 != percent) + goto bad_percent; + add1 (*f); + break; + + case L_('a'): + if (modifier != 0) + goto bad_format; + if (change_case) + { + to_uppcase = true; + to_lowcase = false; + } +#ifdef _NL_CURRENT + cpy (aw_len, a_wkday); + break; +#else + goto underlying_strftime; +#endif + + case 'A': + if (modifier != 0) + goto bad_format; + if (change_case) + { + to_uppcase = true; + to_lowcase = false; + } +#ifdef _NL_CURRENT + cpy (STRLEN (f_wkday), f_wkday); + break; +#else + goto underlying_strftime; +#endif + + case L_('b'): + case L_('h'): + if (change_case) + { + to_uppcase = true; + to_lowcase = false; + } + if (modifier == L_('E')) + goto bad_format; +#ifdef _NL_CURRENT + if (modifier == L_('O')) + cpy (aam_len, a_altmonth); + else + cpy (am_len, a_month); + break; +#else + goto underlying_strftime; +#endif + + case L_('B'): + if (modifier == L_('E')) + goto bad_format; + if (change_case) + { + to_uppcase = true; + to_lowcase = false; + } +#ifdef _NL_CURRENT + if (modifier == L_('O')) + cpy (STRLEN (f_altmonth), f_altmonth); + else + cpy (STRLEN (f_month), f_month); + break; +#else + goto underlying_strftime; +#endif + + case L_('c'): + if (modifier == L_('O')) + goto bad_format; +#ifdef _NL_CURRENT + if (! (modifier == L_('E') + && (*(subfmt = + (const CHAR_T *) _NL_CURRENT (LC_TIME, + NLW(ERA_D_T_FMT))) + != '\0'))) + subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(D_T_FMT)); +#else + goto underlying_strftime; +#endif + + subformat: + subwidth = -1; + subformat_width: + { + size_t len = __strftime_internal (NULL, STRFTIME_ARG ((size_t) -1) + subfmt, tp, to_uppcase, + pad, subwidth, tzset_called + extra_args LOCALE_ARG); + add (len, __strftime_internal (p, + STRFTIME_ARG (maxsize - i) + subfmt, tp, to_uppcase, + pad, subwidth, tzset_called + extra_args LOCALE_ARG)); + } + break; + +#if !(defined _NL_CURRENT && HAVE_STRUCT_ERA_ENTRY) + underlying_strftime: + { + /* The relevant information is available only via the + underlying strftime implementation, so use that. */ + char ufmt[5]; + char *u = ufmt; + char ubuf[1024]; /* enough for any single format in practice */ + size_t len; + /* Make sure we're calling the actual underlying strftime. + In some cases, config.h contains something like + "#define strftime rpl_strftime". */ +# ifdef strftime +# undef strftime + size_t strftime (char *, size_t, const char *, struct tm const *); +# endif + + /* The space helps distinguish strftime failure from empty + output. */ + *u++ = ' '; + *u++ = '%'; + if (modifier != 0) + *u++ = modifier; + *u++ = format_char; + *u = '\0'; + len = strftime (ubuf, sizeof ubuf, ufmt, tp); + if (len != 0) + cpy (len - 1, ubuf + 1); + } + break; +#endif + + case L_('C'): + if (modifier == L_('E')) + { +#if HAVE_STRUCT_ERA_ENTRY + struct era_entry *era = _nl_get_era_entry (tp HELPER_LOCALE_ARG); + if (era) + { +# ifdef COMPILE_WIDE + size_t len = __wcslen (era->era_wname); + cpy (len, era->era_wname); +# else + size_t len = strlen (era->era_name); + cpy (len, era->era_name); +# endif + break; + } +#else + goto underlying_strftime; +#endif + } + + { + bool negative_year = tp->tm_year < - TM_YEAR_BASE; + bool zero_thru_1899 = !negative_year & (tp->tm_year < 0); + int century = ((tp->tm_year - 99 * zero_thru_1899) / 100 + + TM_YEAR_BASE / 100); + DO_YEARISH (2, negative_year, century); + } + + case L_('x'): + if (modifier == L_('O')) + goto bad_format; +#ifdef _NL_CURRENT + if (! (modifier == L_('E') + && (*(subfmt = + (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(ERA_D_FMT))) + != L_('\0')))) + subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(D_FMT)); + goto subformat; +#else + goto underlying_strftime; +#endif + case L_('D'): + if (modifier != 0) + goto bad_format; + subfmt = L_("%m/%d/%y"); + goto subformat; + + case L_('d'): + if (modifier == L_('E')) + goto bad_format; + + DO_NUMBER (2, tp->tm_mday); + + case L_('e'): + if (modifier == L_('E')) + goto bad_format; + + DO_NUMBER_SPACEPAD (2, tp->tm_mday); + + /* All numeric formats set DIGITS and NUMBER_VALUE (or U_NUMBER_VALUE) + and then jump to one of these labels. */ + + do_tz_offset: + always_output_a_sign = true; + goto do_number_body; + + do_yearish: + if (pad == 0) + pad = yr_spec; + always_output_a_sign + = (pad == L_('+') + && ((digits == 2 ? 99 : 9999) < u_number_value + || digits < width)); + goto do_maybe_signed_number; + + do_number_spacepad: + if (pad == 0) + pad = L_('_'); + + do_number: + /* Format NUMBER_VALUE according to the MODIFIER flag. */ + negative_number = number_value < 0; + u_number_value = number_value; + + do_signed_number: + always_output_a_sign = false; + + do_maybe_signed_number: + tz_colon_mask = 0; + + do_number_body: + /* Format U_NUMBER_VALUE according to the MODIFIER flag. + NEGATIVE_NUMBER is nonzero if the original number was + negative; in this case it was converted directly to + unsigned int (i.e., modulo (UINT_MAX + 1)) without + negating it. */ + if (modifier == L_('O') && !negative_number) + { +#ifdef _NL_CURRENT + /* Get the locale specific alternate representation of + the number. If none exist NULL is returned. */ + const CHAR_T *cp = nl_get_alt_digit (u_number_value + HELPER_LOCALE_ARG); + + if (cp != NULL) + { + size_t digitlen = STRLEN (cp); + if (digitlen != 0) + { + cpy (digitlen, cp); + break; + } + } +#else + goto underlying_strftime; +#endif + } + + bufp = buf + sizeof (buf) / sizeof (buf[0]); + + if (negative_number) + u_number_value = - u_number_value; + + do + { + if (tz_colon_mask & 1) + *--bufp = ':'; + tz_colon_mask >>= 1; + *--bufp = u_number_value % 10 + L_('0'); + u_number_value /= 10; + } + while (u_number_value != 0 || tz_colon_mask != 0); + + do_number_sign_and_padding: + if (pad == 0) + pad = L_('0'); + if (width < 0) + width = digits; + + { + CHAR_T sign_char = (negative_number ? L_('-') + : always_output_a_sign ? L_('+') + : 0); + int numlen = buf + sizeof buf / sizeof buf[0] - bufp; + int shortage = width - !!sign_char - numlen; + int padding = pad == L_('-') || shortage <= 0 ? 0 : shortage; + + if (sign_char) + { + if (pad == L_('_')) + { + if (p) + memset_space (p, padding); + i += padding; + width -= padding; + } + width_add1 (0, sign_char); + width--; + } + + cpy (numlen, bufp); + } + break; + + case L_('F'): + if (modifier != 0) + goto bad_format; + if (pad == 0 && width < 0) + { + pad = L_('+'); + subwidth = 4; + } + else + { + subwidth = width - 6; + if (subwidth < 0) + subwidth = 0; + } + subfmt = L_("%Y-%m-%d"); + goto subformat_width; + + case L_('H'): + if (modifier == L_('E')) + goto bad_format; + + DO_NUMBER (2, tp->tm_hour); + + case L_('I'): + if (modifier == L_('E')) + goto bad_format; + + DO_NUMBER (2, hour12); + + case L_('k'): /* GNU extension. */ + if (modifier == L_('E')) + goto bad_format; + + DO_NUMBER_SPACEPAD (2, tp->tm_hour); + + case L_('l'): /* GNU extension. */ + if (modifier == L_('E')) + goto bad_format; + + DO_NUMBER_SPACEPAD (2, hour12); + + case L_('j'): + if (modifier == L_('E')) + goto bad_format; + + DO_SIGNED_NUMBER (3, tp->tm_yday < -1, tp->tm_yday + 1U); + + case L_('M'): + if (modifier == L_('E')) + goto bad_format; + + DO_NUMBER (2, tp->tm_min); + + case L_('m'): + if (modifier == L_('E')) + goto bad_format; + + DO_SIGNED_NUMBER (2, tp->tm_mon < -1, tp->tm_mon + 1U); + +#ifndef _LIBC + case L_('N'): /* GNU extension. */ + if (modifier == L_('E')) + goto bad_format; + { + int n = ns, ns_digits = 9; + if (width <= 0) + width = ns_digits; + int ndigs = ns_digits; + while (width < ndigs || (1 < ndigs && n % 10 == 0)) + ndigs--, n /= 10; + for (int j = ndigs; 0 < j; j--) + buf[j - 1] = n % 10 + L_('0'), n /= 10; + if (!pad) + pad = L_('0'); + width_cpy (0, ndigs, buf); + width_add (width - ndigs, 0, (void) 0); + } + break; +#endif + + case L_('n'): + add1 (L_('\n')); + break; + + case L_('P'): + to_lowcase = true; +#ifndef _NL_CURRENT + format_char = L_('p'); +#endif + FALLTHROUGH; + case L_('p'): + if (change_case) + { + to_uppcase = false; + to_lowcase = true; + } +#ifdef _NL_CURRENT + cpy (ap_len, ampm); + break; +#else + goto underlying_strftime; +#endif + + case L_('q'): /* GNU extension. */ + DO_SIGNED_NUMBER (1, false, ((tp->tm_mon * 11) >> 5) + 1); + + case L_('R'): + subfmt = L_("%H:%M"); + goto subformat; + + case L_('r'): +#ifdef _NL_CURRENT + if (*(subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, + NLW(T_FMT_AMPM))) + == L_('\0')) + subfmt = L_("%I:%M:%S %p"); + goto subformat; +#else + goto underlying_strftime; +#endif + + case L_('S'): + if (modifier == L_('E')) + goto bad_format; + + DO_NUMBER (2, tp->tm_sec); + + case L_('s'): /* GNU extension. */ + { + struct tm ltm; + time_t t; + + ltm = *tp; + ltm.tm_yday = -1; + t = mktime_z (tz, <m); + if (ltm.tm_yday < 0) + { + errno = EOVERFLOW; + return 0; + } + + /* Generate string value for T using time_t arithmetic; + this works even if sizeof (long) < sizeof (time_t). */ + + bufp = buf + sizeof (buf) / sizeof (buf[0]); + negative_number = t < 0; + + do + { + int d = t % 10; + t /= 10; + *--bufp = (negative_number ? -d : d) + L_('0'); + } + while (t != 0); + + digits = 1; + always_output_a_sign = false; + goto do_number_sign_and_padding; + } + + case L_('X'): + if (modifier == L_('O')) + goto bad_format; +#ifdef _NL_CURRENT + if (! (modifier == L_('E') + && (*(subfmt = + (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(ERA_T_FMT))) + != L_('\0')))) + subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(T_FMT)); + goto subformat; +#else + goto underlying_strftime; +#endif + case L_('T'): + subfmt = L_("%H:%M:%S"); + goto subformat; + + case L_('t'): + add1 (L_('\t')); + break; + + case L_('u'): + DO_NUMBER (1, (tp->tm_wday - 1 + 7) % 7 + 1); + + case L_('U'): + if (modifier == L_('E')) + goto bad_format; + + DO_NUMBER (2, (tp->tm_yday - tp->tm_wday + 7) / 7); + + case L_('V'): + case L_('g'): + case L_('G'): + if (modifier == L_('E')) + goto bad_format; + { + /* YEAR is a leap year if and only if (tp->tm_year + TM_YEAR_BASE) + is a leap year, except that YEAR and YEAR - 1 both work + correctly even when (tp->tm_year + TM_YEAR_BASE) would + overflow. */ + int year = (tp->tm_year + + (tp->tm_year < 0 + ? TM_YEAR_BASE % 400 + : TM_YEAR_BASE % 400 - 400)); + int year_adjust = 0; + int days = iso_week_days (tp->tm_yday, tp->tm_wday); + + if (days < 0) + { + /* This ISO week belongs to the previous year. */ + year_adjust = -1; + days = iso_week_days (tp->tm_yday + (365 + __isleap (year - 1)), + tp->tm_wday); + } + else + { + int d = iso_week_days (tp->tm_yday - (365 + __isleap (year)), + tp->tm_wday); + if (0 <= d) + { + /* This ISO week belongs to the next year. */ + year_adjust = 1; + days = d; + } + } + + switch (*f) + { + case L_('g'): + { + int yy = (tp->tm_year % 100 + year_adjust) % 100; + DO_YEARISH (2, false, + (0 <= yy + ? yy + : tp->tm_year < -TM_YEAR_BASE - year_adjust + ? -yy + : yy + 100)); + } + + case L_('G'): + DO_YEARISH (4, tp->tm_year < -TM_YEAR_BASE - year_adjust, + (tp->tm_year + (unsigned int) TM_YEAR_BASE + + year_adjust)); + + default: + DO_NUMBER (2, days / 7 + 1); + } + } + + case L_('W'): + if (modifier == L_('E')) + goto bad_format; + + DO_NUMBER (2, (tp->tm_yday - (tp->tm_wday - 1 + 7) % 7 + 7) / 7); + + case L_('w'): + if (modifier == L_('E')) + goto bad_format; + + DO_NUMBER (1, tp->tm_wday); + + case L_('Y'): + if (modifier == L_('E')) + { +#if HAVE_STRUCT_ERA_ENTRY + struct era_entry *era = _nl_get_era_entry (tp HELPER_LOCALE_ARG); + if (era) + { +# ifdef COMPILE_WIDE + subfmt = era->era_wformat; +# else + subfmt = era->era_format; +# endif + if (pad == 0) + pad = yr_spec; + goto subformat; + } +#else + goto underlying_strftime; +#endif + } + if (modifier == L_('O')) + goto bad_format; + + DO_YEARISH (4, tp->tm_year < -TM_YEAR_BASE, + tp->tm_year + (unsigned int) TM_YEAR_BASE); + + case L_('y'): + if (modifier == L_('E')) + { +#if HAVE_STRUCT_ERA_ENTRY + struct era_entry *era = _nl_get_era_entry (tp HELPER_LOCALE_ARG); + if (era) + { + int delta = tp->tm_year - era->start_date[0]; + if (pad == 0) + pad = yr_spec; + DO_NUMBER (2, (era->offset + + delta * era->absolute_direction)); + } +#else + goto underlying_strftime; +#endif + } + + { + int yy = tp->tm_year % 100; + if (yy < 0) + yy = tp->tm_year < - TM_YEAR_BASE ? -yy : yy + 100; + DO_YEARISH (2, false, yy); + } + + case L_('Z'): + if (change_case) + { + to_uppcase = false; + to_lowcase = true; + } + +#ifdef COMPILE_WIDE + { + /* The zone string is always given in multibyte form. We have + to convert it to wide character. */ + size_t w = pad == L_('-') || width < 0 ? 0 : width; + char const *z = zone; + mbstate_t st = {0}; + size_t len = __mbsrtowcs_l (p, &z, maxsize - i, &st, loc); + if (len == (size_t) -1) + return 0; + size_t incr = len < w ? w : len; + if (incr >= maxsize - i) + { + errno = ERANGE; + return 0; + } + if (p) + { + if (len < w) + { + size_t delta = w - len; + __wmemmove (p + delta, p, len); + wchar_t wc = pad == L_('0') || pad == L_('+') ? L'0' : L' '; + wmemset (p, wc, delta); + } + p += incr; + } + i += incr; + } +#else + cpy (strlen (zone), zone); +#endif + break; + + case L_(':'): + /* :, ::, and ::: are valid only just before 'z'. + :::: etc. are rejected later. */ + for (colons = 1; f[colons] == L_(':'); colons++) + continue; + if (f[colons] != L_('z')) + goto bad_format; + f += colons; + goto do_z_conversion; + + case L_('z'): + colons = 0; + + do_z_conversion: + if (tp->tm_isdst < 0) + break; + + { + int diff; + int hour_diff; + int min_diff; + int sec_diff; +#if HAVE_TM_GMTOFF + diff = tp->tm_gmtoff; +#else + if (!tz) + diff = 0; + else + { + struct tm gtm; + struct tm ltm; + time_t lt; + + /* POSIX.1 requires that local time zone information be used as + though strftime called tzset. */ +# ifndef my_strftime + if (!*tzset_called) + { + tzset (); + *tzset_called = true; + } +# endif + + ltm = *tp; + ltm.tm_wday = -1; + lt = mktime_z (tz, <m); + if (ltm.tm_wday < 0 || ! localtime_rz (0, <, >m)) + break; + diff = tm_diff (<m, >m); + } +#endif + + negative_number = diff < 0 || (diff == 0 && *zone == '-'); + hour_diff = diff / 60 / 60; + min_diff = diff / 60 % 60; + sec_diff = diff % 60; + + switch (colons) + { + case 0: /* +hhmm */ + DO_TZ_OFFSET (5, 0, hour_diff * 100 + min_diff); + + case 1: tz_hh_mm: /* +hh:mm */ + DO_TZ_OFFSET (6, 04, hour_diff * 100 + min_diff); + + case 2: tz_hh_mm_ss: /* +hh:mm:ss */ + DO_TZ_OFFSET (9, 024, + hour_diff * 10000 + min_diff * 100 + sec_diff); + + case 3: /* +hh if possible, else +hh:mm, else +hh:mm:ss */ + if (sec_diff != 0) + goto tz_hh_mm_ss; + if (min_diff != 0) + goto tz_hh_mm; + DO_TZ_OFFSET (3, 0, hour_diff); + + default: + goto bad_format; + } + } + + case L_('\0'): /* GNU extension: % at end of format. */ + bad_percent: + --f; + FALLTHROUGH; + default: + /* Unknown format; output the format, including the '%', + since this is most likely the right thing to do if a + multibyte string has been misparsed. */ + bad_format: + cpy (f - percent + 1, percent); + break; + } + } + +#if ! FPRINTFTIME + if (p && maxsize != 0) + *p = L_('\0'); +#endif + + errno = saved_errno; + return i; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/open.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/open.c new file mode 100644 index 00000000..e690c9ea --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/open.c @@ -0,0 +1,213 @@ +/* Open a descriptor to a file. + Copyright (C) 2007-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 2007. */ + +/* If the user's config.h happens to include , let it include only + the system's here, so that orig_open doesn't recurse to + rpl_open. */ +#define __need_system_fcntl_h +#include + +/* Get the original definition of open. It might be defined as a macro. */ +#include +#include +#undef __need_system_fcntl_h + +static int +orig_open (const char *filename, int flags, mode_t mode) +{ +#if defined _WIN32 && !defined __CYGWIN__ + return _open (filename, flags, mode); +#else + return open (filename, flags, mode); +#endif +} + +/* Specification. */ +#ifdef __osf__ +/* Write "fcntl.h" here, not , otherwise OSF/1 5.1 DTK cc eliminates + this include because of the preliminary #include above. */ +# include "fcntl.h" +#else +# include +#endif + +#include "cloexec.h" + +#include +#include +#include +#include +#include +#include + +#ifndef REPLACE_OPEN_DIRECTORY +# define REPLACE_OPEN_DIRECTORY 0 +#endif + +int +open (const char *filename, int flags, ...) +{ + /* 0 = unknown, 1 = yes, -1 = no. */ +#if GNULIB_defined_O_CLOEXEC + int have_cloexec = -1; +#else + static int have_cloexec; +#endif + + mode_t mode; + int fd; + + mode = 0; + if (flags & O_CREAT) + { + va_list arg; + va_start (arg, flags); + + /* We have to use PROMOTED_MODE_T instead of mode_t, otherwise GCC 4 + creates crashing code when 'mode_t' is smaller than 'int'. */ + mode = va_arg (arg, PROMOTED_MODE_T); + + va_end (arg); + } + +#if GNULIB_defined_O_NONBLOCK + /* The only known platform that lacks O_NONBLOCK is mingw, but it + also lacks named pipes and Unix sockets, which are the only two + file types that require non-blocking handling in open(). + Therefore, it is safe to ignore O_NONBLOCK here. It is handy + that mingw also lacks openat(), so that is also covered here. */ + flags &= ~O_NONBLOCK; +#endif + +#if defined _WIN32 && ! defined __CYGWIN__ + if (strcmp (filename, "/dev/null") == 0) + filename = "NUL"; +#endif + +#if OPEN_TRAILING_SLASH_BUG + /* Fail if one of O_CREAT, O_WRONLY, O_RDWR is specified and the filename + ends in a slash, as POSIX says such a filename must name a directory + : + "A pathname that contains at least one non- character and that + ends with one or more trailing characters shall not be resolved + successfully unless the last pathname component before the trailing + characters names an existing directory" + If the named file already exists as a directory, then + - if O_CREAT is specified, open() must fail because of the semantics + of O_CREAT, + - if O_WRONLY or O_RDWR is specified, open() must fail because POSIX + + says that it fails with errno = EISDIR in this case. + If the named file does not exist or does not name a directory, then + - if O_CREAT is specified, open() must fail since open() cannot create + directories, + - if O_WRONLY or O_RDWR is specified, open() must fail because the + file does not contain a '.' directory. */ + if ((flags & O_CREAT) + || (flags & O_ACCMODE) == O_RDWR + || (flags & O_ACCMODE) == O_WRONLY) + { + size_t len = strlen (filename); + if (len > 0 && filename[len - 1] == '/') + { + errno = EISDIR; + return -1; + } + } +#endif + + fd = orig_open (filename, + flags & ~(have_cloexec < 0 ? O_CLOEXEC : 0), mode); + + if (flags & O_CLOEXEC) + { + if (! have_cloexec) + { + if (0 <= fd) + have_cloexec = 1; + else if (errno == EINVAL) + { + fd = orig_open (filename, flags & ~O_CLOEXEC, mode); + have_cloexec = -1; + } + } + if (have_cloexec < 0 && 0 <= fd) + set_cloexec_flag (fd, true); + } + + +#if REPLACE_FCHDIR + /* Implementing fchdir and fdopendir requires the ability to open a + directory file descriptor. If open doesn't support that (as on + mingw), we use a dummy file that behaves the same as directories + on Linux (ie. always reports EOF on attempts to read()), and + override fstat() in fchdir.c to hide the fact that we have a + dummy. */ + if (REPLACE_OPEN_DIRECTORY && fd < 0 && errno == EACCES + && ((flags & O_ACCMODE) == O_RDONLY + || (O_SEARCH != O_RDONLY && (flags & O_ACCMODE) == O_SEARCH))) + { + struct stat statbuf; + if (stat (filename, &statbuf) == 0 && S_ISDIR (statbuf.st_mode)) + { + /* Maximum recursion depth of 1. */ + fd = open ("/dev/null", flags, mode); + if (0 <= fd) + fd = _gl_register_fd (fd, filename); + } + else + errno = EACCES; + } +#endif + +#if OPEN_TRAILING_SLASH_BUG + /* If the filename ends in a slash and fd does not refer to a directory, + then fail. + Rationale: POSIX says such a filename must name a directory + : + "A pathname that contains at least one non- character and that + ends with one or more trailing characters shall not be resolved + successfully unless the last pathname component before the trailing + characters names an existing directory" + If the named file without the slash is not a directory, open() must fail + with ENOTDIR. */ + if (fd >= 0) + { + /* We know len is positive, since open did not fail with ENOENT. */ + size_t len = strlen (filename); + if (filename[len - 1] == '/') + { + struct stat statbuf; + + if (fstat (fd, &statbuf) >= 0 && !S_ISDIR (statbuf.st_mode)) + { + close (fd); + errno = ENOTDIR; + return -1; + } + } + } +#endif + +#if REPLACE_FCHDIR + if (!REPLACE_OPEN_DIRECTORY && 0 <= fd) + fd = _gl_register_fd (fd, filename); +#endif + + return fd; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/openat-die.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/openat-die.c new file mode 100644 index 00000000..959c77d0 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/openat-die.c @@ -0,0 +1,62 @@ +/* Report a save- or restore-cwd failure in our openat replacement and then exit. + + Copyright (C) 2005-2006, 2008-2024 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 . */ + +#include + +#include "openat.h" + +#include + +#ifndef GNULIB_LIBPOSIX +# include +#endif + +#include "exitfail.h" + +#include "gettext.h" +#define _(msgid) gettext (msgid) + +_Noreturn void +openat_save_fail (int errnum) +{ +#ifndef GNULIB_LIBPOSIX + error (exit_failure, errnum, + _("unable to record current working directory")); +#endif + /* _Noreturn cannot be applied to error, since it returns + when its first argument is 0. To help compilers understand that this + function does not return, call abort. Also, the abort is a + safety feature if exit_failure is 0 (which shouldn't happen). */ + abort (); +} + + +/* Exit with an error about failure to restore the working directory + during an openat emulation. The caller must ensure that fd 2 is + not a just-opened fd, even when openat_safer is not in use. */ + +_Noreturn void +openat_restore_fail (int errnum) +{ +#ifndef GNULIB_LIBPOSIX + error (exit_failure, errnum, + _("failed to return to initial working directory")); +#endif + + /* As above. */ + abort (); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/openat-priv.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/openat-priv.h new file mode 100644 index 00000000..7fd4beb5 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/openat-priv.h @@ -0,0 +1,64 @@ +/* Internals for openat-like functions. + + Copyright (C) 2005-2006, 2009-2024 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 . */ + +/* written by Jim Meyering */ + +#ifndef _GL_HEADER_OPENAT_PRIV +#define _GL_HEADER_OPENAT_PRIV + +#include +#include +#include + +/* Maximum number of bytes that it is safe to allocate as a single + array on the stack, and that is known as a compile-time constant. + The assumption is that we'll touch the array very quickly, or a + temporary very near the array, provoking an out-of-memory trap. On + some operating systems, there is only one guard page for the stack, + and a page size can be as small as 4096 bytes. Subtract 64 in the + hope that this will let the compiler touch a nearby temporary and + provoke a trap. */ +#define SAFER_ALLOCA_MAX (4096 - 64) + +#define SAFER_ALLOCA(m) ((m) < SAFER_ALLOCA_MAX ? (m) : SAFER_ALLOCA_MAX) + +#if defined PATH_MAX +# define OPENAT_BUFFER_SIZE SAFER_ALLOCA (PATH_MAX) +#elif defined _XOPEN_PATH_MAX +# define OPENAT_BUFFER_SIZE SAFER_ALLOCA (_XOPEN_PATH_MAX) +#else +# define OPENAT_BUFFER_SIZE SAFER_ALLOCA (1024) +#endif + +char *openat_proc_name (char buf[OPENAT_BUFFER_SIZE], int fd, char const *file); + +/* Trying to access a BUILD_PROC_NAME file will fail on systems without + /proc support, and even on systems *with* ProcFS support. Return + nonzero if the failure may be legitimate, e.g., because /proc is not + readable, or the particular .../fd/N directory is not present. */ +#define EXPECTED_ERRNO(Errno) \ + ((Errno) == ENOTDIR || (Errno) == ENOENT \ + || (Errno) == EPERM || (Errno) == EACCES \ + || (Errno) == ENOSYS /* Solaris 8 */ \ + || (Errno) == EOPNOTSUPP /* FreeBSD */) + +/* Wrapper function shared among linkat and renameat. */ +int at_func2 (int fd1, char const *file1, + int fd2, char const *file2, + int (*func) (char const *file1, char const *file2)); + +#endif /* _GL_HEADER_OPENAT_PRIV */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/openat-proc.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/openat-proc.c new file mode 100644 index 00000000..7ccb734f --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/openat-proc.c @@ -0,0 +1,154 @@ +/* Create /proc/self/fd-related names for subfiles of open directories. + + Copyright (C) 2006, 2009-2024 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 . */ + +/* Written by Paul Eggert. */ + +#include + +#include "openat-priv.h" + +#include +#include +#include + +#include +#include +#include +#include + +#ifdef __KLIBC__ /* OS/2 */ +# include +#endif +#ifdef __MVS__ /* z/OS */ +# include +#endif + +#include "intprops.h" + +/* Set BUF to the name of the subfile of the directory identified by + FD, where the subfile is named FILE. If successful, return BUF if + the result fits in BUF, dynamically allocated memory otherwise. + Return NULL (setting errno) on error. */ +char * +openat_proc_name (char buf[OPENAT_BUFFER_SIZE], int fd, char const *file) +{ + char *result = buf; + int dirlen; + + /* Make sure the caller gets ENOENT when appropriate. */ + if (!*file) + { + buf[0] = '\0'; + return buf; + } + +#if !(defined __KLIBC__ || defined __MVS__) + /* Generic code for Linux, Solaris, and similar platforms. */ +# define PROC_SELF_FD_FORMAT "/proc/self/fd/%d/" + { + enum { + PROC_SELF_FD_DIR_SIZE_BOUND + = (sizeof PROC_SELF_FD_FORMAT - (sizeof "%d" - 1) + + INT_STRLEN_BOUND (int)) + }; + + static int proc_status = 0; + if (! proc_status) + { + /* Set PROC_STATUS to a positive value if /proc/self/fd is + reliable, and a negative value otherwise. Solaris 10 + /proc/self/fd mishandles "..", and any file name might expand + to ".." after symbolic link expansion, so avoid /proc/self/fd + if it mishandles "..". Solaris 10 has openat, but this + problem is exhibited on code that built on Solaris 8 and + running on Solaris 10. */ + + int proc_self_fd = + open ("/proc/self/fd", + O_SEARCH | O_DIRECTORY | O_NOCTTY | O_NONBLOCK | O_CLOEXEC); + if (proc_self_fd < 0) + proc_status = -1; + else + { + /* Detect whether /proc/self/fd/%i/../fd exists, where %i is the + number of a file descriptor open on /proc/self/fd. On Linux, + that name resolves to /proc/self/fd, which was opened above. + However, on Solaris, it may resolve to /proc/self/fd/fd, which + cannot exist, since all names in /proc/self/fd are numeric. */ + char dotdot_buf[PROC_SELF_FD_DIR_SIZE_BOUND + sizeof "../fd" - 1]; + sprintf (dotdot_buf, PROC_SELF_FD_FORMAT "../fd", proc_self_fd); + proc_status = access (dotdot_buf, F_OK) ? -1 : 1; + close (proc_self_fd); + } + } + + if (proc_status < 0) + return NULL; + else + { + size_t bufsize = PROC_SELF_FD_DIR_SIZE_BOUND + strlen (file); + if (OPENAT_BUFFER_SIZE < bufsize) + { + result = malloc (bufsize); + if (! result) + return NULL; + } + + dirlen = sprintf (result, PROC_SELF_FD_FORMAT, fd); + } + } +#else /* (defined __KLIBC__ || defined __MVS__), i.e. OS/2 or z/OS */ + /* OS/2 kLIBC provides a function to retrieve a path from a fd. */ + { + size_t bufsize; + +# ifdef __KLIBC__ + char dir[_MAX_PATH]; + if (__libc_Back_ioFHToPath (fd, dir, sizeof dir)) + return NULL; +# endif +# ifdef __MVS__ + char dir[_XOPEN_PATH_MAX]; + /* Documentation: + https://www.ibm.com/docs/en/zos/2.2.0?topic=functions-w-ioctl-w-pioctl-control-devices */ + if (w_ioctl (fd, _IOCC_GPN, sizeof dir, dir) < 0) + return NULL; + /* Documentation: + https://www.ibm.com/docs/en/zos/2.2.0?topic=functions-e2a-l-convert-characters-from-ebcdic-ascii */ + dirlen = __e2a_l (dir, strlen (dir)); + if (dirlen < 0 || dirlen >= sizeof dir) + return NULL; + dir[dirlen] = '\0'; +# endif + + dirlen = strlen (dir); + bufsize = dirlen + 1 + strlen (file) + 1; /* 1 for '/', 1 for null */ + if (OPENAT_BUFFER_SIZE < bufsize) + { + result = malloc (bufsize); + if (! result) + return NULL; + } + + strcpy (result, dir); + result[dirlen++] = '/'; + } +#endif + + strcpy (result + dirlen, file); + return result; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/openat.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/openat.c new file mode 100644 index 00000000..65cfc5ed --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/openat.c @@ -0,0 +1,315 @@ +/* provide a replacement openat function + Copyright (C) 2004-2024 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 . */ + +/* written by Jim Meyering */ + +/* If the user's config.h happens to include , let it include only + the system's here, so that orig_openat doesn't recurse to + rpl_openat. */ +#define __need_system_fcntl_h +#include + +/* Get the original definition of open. It might be defined as a macro. */ +#include +#include +#undef __need_system_fcntl_h + +#if HAVE_OPENAT +static int +orig_openat (int fd, char const *filename, int flags, mode_t mode) +{ + return openat (fd, filename, flags, mode); +} +#endif + +#ifdef __osf__ +/* Write "fcntl.h" here, not , otherwise OSF/1 5.1 DTK cc eliminates + this include because of the preliminary #include above. */ +# include "fcntl.h" +#else +# include +#endif + +#include "openat.h" + +#include "cloexec.h" + +#include +#include +#include +#include +#include +#include + +#if HAVE_OPENAT + +/* Like openat, but support O_CLOEXEC and work around Solaris 9 bugs + with trailing slash. */ +int +rpl_openat (int dfd, char const *filename, int flags, ...) +{ + /* 0 = unknown, 1 = yes, -1 = no. */ +#if GNULIB_defined_O_CLOEXEC + int have_cloexec = -1; +#else + static int have_cloexec; +#endif + + mode_t mode; + int fd; + + mode = 0; + if (flags & O_CREAT) + { + va_list arg; + va_start (arg, flags); + + /* We have to use PROMOTED_MODE_T instead of mode_t, otherwise GCC 4 + creates crashing code when 'mode_t' is smaller than 'int'. */ + mode = va_arg (arg, PROMOTED_MODE_T); + + va_end (arg); + } + +# if OPEN_TRAILING_SLASH_BUG + /* Fail if one of O_CREAT, O_WRONLY, O_RDWR is specified and the filename + ends in a slash, as POSIX says such a filename must name a directory + : + "A pathname that contains at least one non- character and that + ends with one or more trailing characters shall not be resolved + successfully unless the last pathname component before the trailing + characters names an existing directory" + If the named file already exists as a directory, then + - if O_CREAT is specified, open() must fail because of the semantics + of O_CREAT, + - if O_WRONLY or O_RDWR is specified, open() must fail because POSIX + + says that it fails with errno = EISDIR in this case. + If the named file does not exist or does not name a directory, then + - if O_CREAT is specified, open() must fail since open() cannot create + directories, + - if O_WRONLY or O_RDWR is specified, open() must fail because the + file does not contain a '.' directory. */ + if ((flags & O_CREAT) + || (flags & O_ACCMODE) == O_RDWR + || (flags & O_ACCMODE) == O_WRONLY) + { + size_t len = strlen (filename); + if (len > 0 && filename[len - 1] == '/') + { + errno = EISDIR; + return -1; + } + } +# endif + + fd = orig_openat (dfd, filename, + flags & ~(have_cloexec < 0 ? O_CLOEXEC : 0), mode); + + if (flags & O_CLOEXEC) + { + if (! have_cloexec) + { + if (0 <= fd) + have_cloexec = 1; + else if (errno == EINVAL) + { + fd = orig_openat (dfd, filename, flags & ~O_CLOEXEC, mode); + have_cloexec = -1; + } + } + if (have_cloexec < 0 && 0 <= fd) + set_cloexec_flag (fd, true); + } + + +# if OPEN_TRAILING_SLASH_BUG + /* If the filename ends in a slash and fd does not refer to a directory, + then fail. + Rationale: POSIX says such a filename must name a directory + : + "A pathname that contains at least one non- character and that + ends with one or more trailing characters shall not be resolved + successfully unless the last pathname component before the trailing + characters names an existing directory" + If the named file without the slash is not a directory, open() must fail + with ENOTDIR. */ + if (fd >= 0) + { + /* We know len is positive, since open did not fail with ENOENT. */ + size_t len = strlen (filename); + if (filename[len - 1] == '/') + { + struct stat statbuf; + + if (fstat (fd, &statbuf) >= 0 && !S_ISDIR (statbuf.st_mode)) + { + close (fd); + errno = ENOTDIR; + return -1; + } + } + } +# endif + + return fd; +} + +#else /* !HAVE_OPENAT */ + +# include "filename.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */ +# include "openat-priv.h" +# include "save-cwd.h" + +/* Replacement for Solaris' openat function. + + First, try to simulate it via open ("/proc/self/fd/FD/FILE"). + Failing that, simulate it by doing save_cwd/fchdir/open/restore_cwd. + If either the save_cwd or the restore_cwd fails (relatively unlikely), + then give a diagnostic and exit nonzero. + Otherwise, upon failure, set errno and return -1, as openat does. + Upon successful completion, return a file descriptor. */ +int +openat (int fd, char const *file, int flags, ...) +{ + mode_t mode = 0; + + if (flags & O_CREAT) + { + va_list arg; + va_start (arg, flags); + + /* We have to use PROMOTED_MODE_T instead of mode_t, otherwise GCC 4 + creates crashing code when 'mode_t' is smaller than 'int'. */ + mode = va_arg (arg, PROMOTED_MODE_T); + + va_end (arg); + } + + return openat_permissive (fd, file, flags, mode, NULL); +} + +/* Like openat (FD, FILE, FLAGS, MODE), but if CWD_ERRNO is + nonnull, set *CWD_ERRNO to an errno value if unable to save + or restore the initial working directory. This is needed only + the first time remove.c's remove_dir opens a command-line + directory argument. + + If a previous attempt to restore the current working directory + failed, then we must not even try to access a '.'-relative name. + It is the caller's responsibility not to call this function + in that case. */ + +int +openat_permissive (int fd, char const *file, int flags, mode_t mode, + int *cwd_errno) +{ + struct saved_cwd saved_cwd; + int saved_errno; + int err; + bool save_ok; + + if (fd == AT_FDCWD || IS_ABSOLUTE_FILE_NAME (file)) + return open (file, flags, mode); + + { + char buf[OPENAT_BUFFER_SIZE]; + char *proc_file = openat_proc_name (buf, fd, file); + if (proc_file) + { + int open_result = open (proc_file, flags, mode); + int open_errno = errno; + if (proc_file != buf) + free (proc_file); + /* If the syscall succeeds, or if it fails with an unexpected + errno value, then return right away. Otherwise, fall through + and resort to using save_cwd/restore_cwd. */ + if (0 <= open_result || ! EXPECTED_ERRNO (open_errno)) + { + errno = open_errno; + return open_result; + } + } + } + + save_ok = (save_cwd (&saved_cwd) == 0); + if (! save_ok) + { + if (! cwd_errno) + openat_save_fail (errno); + *cwd_errno = errno; + } + if (0 <= fd && fd == saved_cwd.desc) + { + /* If saving the working directory collides with the user's + requested fd, then the user's fd must have been closed to + begin with. */ + free_cwd (&saved_cwd); + errno = EBADF; + return -1; + } + + err = fchdir (fd); + saved_errno = errno; + + if (! err) + { + err = open (file, flags, mode); + saved_errno = errno; + if (save_ok && restore_cwd (&saved_cwd) != 0) + { + if (! cwd_errno) + { + /* Don't write a message to just-created fd 2. */ + saved_errno = errno; + if (err == STDERR_FILENO) + close (err); + openat_restore_fail (saved_errno); + } + *cwd_errno = errno; + } + } + + free_cwd (&saved_cwd); + errno = saved_errno; + return err; +} + +/* Return true if our openat implementation must resort to + using save_cwd and restore_cwd. */ +bool +openat_needs_fchdir (void) +{ + bool needs_fchdir = true; + int fd = open ("/", O_SEARCH | O_CLOEXEC); + + if (0 <= fd) + { + char buf[OPENAT_BUFFER_SIZE]; + char *proc_file = openat_proc_name (buf, fd, "."); + if (proc_file) + { + needs_fchdir = false; + if (proc_file != buf) + free (proc_file); + } + close (fd); + } + + return needs_fchdir; +} + +#endif /* !HAVE_OPENAT */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/openat.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/openat.h new file mode 100644 index 00000000..dc34092b --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/openat.h @@ -0,0 +1,127 @@ +/* provide a replacement openat function + Copyright (C) 2004-2006, 2008-2024 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 . */ + +/* written by Jim Meyering */ + +#ifndef _GL_HEADER_OPENAT +#define _GL_HEADER_OPENAT + +/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, _Noreturn, + _GL_ATTRIBUTE_DEPRECATED, HAVE_OPENAT. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +#include + +#include +#include +#include + +_GL_INLINE_HEADER_BEGIN + +#if !HAVE_OPENAT + +int openat_permissive (int fd, char const *file, int flags, mode_t mode, + int *cwd_errno); +bool openat_needs_fchdir (void); + +#else + +# define openat_permissive(Fd, File, Flags, Mode, Cwd_errno) \ + openat (Fd, File, Flags, Mode) +# define openat_needs_fchdir() false + +#endif + +_Noreturn void openat_restore_fail (int); +_Noreturn void openat_save_fail (int); + +/* Using these function names makes application code + slightly more readable than it would be with + fchownat (..., 0) or fchownat (..., AT_SYMLINK_NOFOLLOW). */ + +#if GNULIB_CHOWNAT + +# ifndef CHOWNAT_INLINE +# define CHOWNAT_INLINE _GL_INLINE +# endif + +CHOWNAT_INLINE int +chownat (int fd, char const *file, uid_t owner, gid_t group) +{ + return fchownat (fd, file, owner, group, 0); +} + +CHOWNAT_INLINE int +lchownat (int fd, char const *file, uid_t owner, gid_t group) +{ + return fchownat (fd, file, owner, group, AT_SYMLINK_NOFOLLOW); +} + +#endif + +#if GNULIB_CHMODAT + +# ifndef CHMODAT_INLINE +# define CHMODAT_INLINE _GL_INLINE +# endif + +CHMODAT_INLINE int +chmodat (int fd, char const *file, mode_t mode) +{ + return fchmodat (fd, file, mode, 0); +} + +CHMODAT_INLINE int +lchmodat (int fd, char const *file, mode_t mode) +{ + return fchmodat (fd, file, mode, AT_SYMLINK_NOFOLLOW); +} + +#endif + +#if GNULIB_STATAT + +# ifndef STATAT_INLINE +# define STATAT_INLINE _GL_INLINE +# endif + +_GL_ATTRIBUTE_DEPRECATED +STATAT_INLINE int +statat (int fd, char const *name, struct stat *st) +{ + return fstatat (fd, name, st, 0); +} + +_GL_ATTRIBUTE_DEPRECATED +STATAT_INLINE int +lstatat (int fd, char const *name, struct stat *st) +{ + return fstatat (fd, name, st, AT_SYMLINK_NOFOLLOW); +} + +#endif + +/* For now, there are no wrappers named laccessat or leuidaccessat, + since gnulib doesn't support faccessat(,AT_SYMLINK_NOFOLLOW) and + since access rights on symlinks are of limited utility. Likewise, + wrappers are not provided for accessat or euidaccessat, so as to + avoid dragging in -lgen on some platforms. */ + +_GL_INLINE_HEADER_END + +#endif /* _GL_HEADER_OPENAT */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/opendir.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/opendir.c new file mode 100644 index 00000000..df768076 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/opendir.c @@ -0,0 +1,186 @@ +/* Start reading the entries of a directory. + Copyright (C) 2006-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +#include +#include + +#if HAVE_OPENDIR + +/* Override opendir(), to keep track of the open file descriptors. + Needed because there is a function dirfd(). */ + +#else + +# include "filename.h" + +#endif + +#include +#include + +#if GNULIB_defined_DIR +# include "dirent-private.h" +#endif + +#if REPLACE_FCHDIR +# include +#endif + +#if defined _WIN32 && ! defined __CYGWIN__ +/* Don't assume that UNICODE is not defined. */ +# undef WIN32_FIND_DATA +# define WIN32_FIND_DATA WIN32_FIND_DATAA +# undef GetFullPathName +# define GetFullPathName GetFullPathNameA +# undef FindFirstFile +# define FindFirstFile FindFirstFileA +#endif + +DIR * +opendir (const char *dir_name) +#undef opendir +{ +#if HAVE_DIRENT_H /* equivalent to HAVE_OPENDIR */ + DIR *dirp; + +# if GNULIB_defined_DIR +# undef DIR + + dirp = (struct gl_directory *) malloc (sizeof (struct gl_directory)); + if (dirp == NULL) + { + errno = ENOMEM; + return NULL; + } + + DIR *real_dirp = opendir (dir_name); + if (real_dirp == NULL) + { + int saved_errno = errno; + free (dirp); + errno = saved_errno; + return NULL; + } + + dirp->fd_to_close = -1; + dirp->real_dirp = real_dirp; +# else + dirp = opendir (dir_name); + if (dirp == NULL) + return NULL; +# endif + +#else + + char dir_name_mask[MAX_PATH + 1 + 1 + 1]; + int status; + HANDLE current; + WIN32_FIND_DATA entry; + struct gl_directory *dirp; + + if (dir_name[0] == '\0') + { + errno = ENOENT; + return NULL; + } + + /* Make the dir_name absolute, so that we continue reading the same + directory if the current directory changed between this opendir() + call and a subsequent rewinddir() call. */ + if (!GetFullPathName (dir_name, MAX_PATH, dir_name_mask, NULL)) + { + errno = EINVAL; + return NULL; + } + + /* Append the mask. + "*" and "*.*" appear to be equivalent. */ + { + char *p; + + p = dir_name_mask + strlen (dir_name_mask); + if (p > dir_name_mask && !ISSLASH (p[-1])) + *p++ = '\\'; + *p++ = '*'; + *p = '\0'; + } + + /* Start searching the directory. */ + status = -1; + current = FindFirstFile (dir_name_mask, &entry); + if (current == INVALID_HANDLE_VALUE) + { + switch (GetLastError ()) + { + case ERROR_FILE_NOT_FOUND: + status = -2; + break; + case ERROR_PATH_NOT_FOUND: + errno = ENOENT; + return NULL; + case ERROR_DIRECTORY: + errno = ENOTDIR; + return NULL; + case ERROR_ACCESS_DENIED: + errno = EACCES; + return NULL; + default: + errno = EIO; + return NULL; + } + } + + /* Allocate the result. */ + dirp = + (struct gl_directory *) + malloc (offsetof (struct gl_directory, dir_name_mask[0]) + + strlen (dir_name_mask) + 1); + if (dirp == NULL) + { + if (current != INVALID_HANDLE_VALUE) + FindClose (current); + errno = ENOMEM; + return NULL; + } + dirp->fd_to_close = -1; + dirp->status = status; + dirp->current = current; + if (status == -1) + memcpy (&dirp->entry, &entry, sizeof (WIN32_FIND_DATA)); + strcpy (dirp->dir_name_mask, dir_name_mask); + +#endif + +#if REPLACE_FCHDIR + { + int fd = dirfd (dirp); + if (0 <= fd && _gl_register_fd (fd, dir_name) != fd) + { + int saved_errno = errno; + closedir (dirp); + errno = saved_errno; + return NULL; + } + } +#endif + + return dirp; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/pathmax.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/pathmax.h new file mode 100644 index 00000000..d6512c6f --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/pathmax.h @@ -0,0 +1,88 @@ +/* Define PATH_MAX somehow. Requires sys/types.h. + Copyright (C) 1992, 1999, 2001, 2003, 2005, 2009-2024 Free Software + Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef _PATHMAX_H +# define _PATHMAX_H + +/* POSIX:2008 defines PATH_MAX to be the maximum number of bytes in a filename, + including the terminating NUL byte. + + PATH_MAX is not defined on systems which have no limit on filename length, + such as GNU/Hurd. + + This file does *not* define PATH_MAX always. Programs that use this file + can handle the GNU/Hurd case in several ways: + - Either with a package-wide handling, or with a per-file handling, + - Either through a + #ifdef PATH_MAX + or through a fallback like + #ifndef PATH_MAX + # define PATH_MAX 8192 + #endif + or through a fallback like + #ifndef PATH_MAX + # define PATH_MAX pathconf ("/", _PC_PATH_MAX) + #endif + */ + +/* This file uses HAVE_SYS_PARAM_H. */ +# if !_GL_CONFIG_H_INCLUDED +# error "Please include config.h first." +# endif + +# include + +# include + +# ifndef _POSIX_PATH_MAX +# define _POSIX_PATH_MAX 256 +# endif + +/* Don't include sys/param.h if it already has been. */ +# if defined HAVE_SYS_PARAM_H && !defined PATH_MAX && !defined MAXPATHLEN +# include +# endif + +# if !defined PATH_MAX && defined MAXPATHLEN +# define PATH_MAX MAXPATHLEN +# endif + +# ifdef __hpux +/* On HP-UX, PATH_MAX designates the maximum number of bytes in a filename, + *not* including the terminating NUL byte, and is set to 1023. + Additionally, when _XOPEN_SOURCE is defined to 500 or more, PATH_MAX is + not defined at all any more. */ +# undef PATH_MAX +# define PATH_MAX 1024 +# endif + +# if defined _WIN32 && ! defined __CYGWIN__ +/* The page "Naming Files, Paths, and Namespaces" on msdn.microsoft.com, + section "Maximum Path Length Limitation", + + explains that the maximum size of a filename, including the terminating + NUL byte, is 260 = 3 + 256 + 1. + This is the same value as + - FILENAME_MAX in , + - _MAX_PATH in , + - MAX_PATH in . + Undefine the original value, because mingw's gets it wrong. */ +# undef PATH_MAX +# define PATH_MAX 260 +# endif + +#endif /* _PATHMAX_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/pclose.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/pclose.c new file mode 100644 index 00000000..ed9c74eb --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/pclose.c @@ -0,0 +1,28 @@ +/* Close a stream to a sub-process. + Copyright (C) 2011-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +/* Native Windows API. */ + +int +pclose (FILE *stream) +{ + return _pclose (stream); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/pipe-safer.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/pipe-safer.c new file mode 100644 index 00000000..3f2143e5 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/pipe-safer.c @@ -0,0 +1,52 @@ +/* Invoke pipe, but avoid some glitches. + Copyright (C) 2005-2006, 2009-2024 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 . */ + +/* Written by Jim Meyering. */ + +#include + +#include "unistd-safer.h" + +#include +#include + +/* Like pipe, but ensure that neither of the file descriptors is + STDIN_FILENO, STDOUT_FILENO, or STDERR_FILENO. Fail with ENOSYS on + platforms that lack pipe. */ + +int +pipe_safer (int fd[2]) +{ + if (pipe (fd) == 0) + { + int i; + for (i = 0; i < 2; i++) + { + fd[i] = fd_safer (fd[i]); + if (fd[i] < 0) + { + int saved_errno = errno; + close (fd[1 - i]); + errno = saved_errno; + return -1; + } + } + + return 0; + } + + return -1; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/pipe.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/pipe.c new file mode 100644 index 00000000..fa6db541 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/pipe.c @@ -0,0 +1,50 @@ +/* Create a pipe. + Copyright (C) 2009-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +#if defined _WIN32 && ! defined __CYGWIN__ +/* Native Windows API. */ + +/* Get _pipe(). */ +# include + +/* Get _O_BINARY. */ +# include + +int +pipe (int fd[2]) +{ + /* Mingw changes fd to {-1,-1} on failure, but this violates + http://austingroupbugs.net/view.php?id=467 */ + int tmp[2]; + int result = _pipe (tmp, 4096, _O_BINARY); + if (!result) + { + fd[0] = tmp[0]; + fd[1] = tmp[1]; + } + return result; +} + +#else + +# error "This platform lacks a pipe function, and Gnulib doesn't provide a replacement. This is a bug in Gnulib." + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/popen.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/popen.c new file mode 100644 index 00000000..513b4e1e --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/popen.c @@ -0,0 +1,103 @@ +/* Open a stream to a sub-process. + Copyright (C) 2009-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Eric Blake , 2009. */ + +#include + +/* Specification. */ +#include + +#if defined _WIN32 && ! defined __CYGWIN__ +/* Native Windows API. */ + +# include + +FILE * +popen (const char *filename, const char *mode) +{ + /* Use binary mode by default. */ + if (strcmp (mode, "r") == 0) + mode = "rb"; + else if (strcmp (mode, "w") == 0) + mode = "wb"; + + return _popen (filename, mode); +} + +#else + +# include +# include +# include +# include + +# undef popen + +FILE * +rpl_popen (const char *filename, const char *mode) +{ + /* All other platforms have popen and fcntl. + The bug of the child clobbering its own file descriptors if stdin + or stdout was closed in the parent can be worked around by + opening those two fds as close-on-exec to begin with. */ + /* Cygwin 1.5.x also has a bug where the popen fd is improperly + marked close-on-exec, and if the application undoes this, then + the fd leaks into subsequent popen calls. We could work around + this by maintaining a list of all fd's opened by popen, and + temporarily marking them cloexec around the real popen call, but + we would also have to override pclose, and the bookkeeping seems + extreme given that cygwin 1.7 no longer has the bug. */ + FILE *result; + int cloexec0 = fcntl (STDIN_FILENO, F_GETFD); + int cloexec1 = fcntl (STDOUT_FILENO, F_GETFD); + int saved_errno; + + /* If either stdin or stdout was closed (that is, fcntl failed), + then we open a dummy close-on-exec fd to occupy that slot. That + way, popen's internal use of pipe() will not contain either fd 0 + or 1, overcoming the fact that the child process blindly calls + close() on the parent's end of the pipe without first checking + whether it is clobbering the fd just placed there via dup2(); the + exec will get rid of the dummy fd's in the child. Fortunately, + closed stderr in the parent does not cause problems in the + child. */ + if (cloexec0 < 0) + { + if (open ("/dev/null", O_RDONLY) != STDIN_FILENO + || fcntl (STDIN_FILENO, F_SETFD, + fcntl (STDIN_FILENO, F_GETFD) | FD_CLOEXEC) == -1) + abort (); + } + if (cloexec1 < 0) + { + if (open ("/dev/null", O_RDONLY) != STDOUT_FILENO + || fcntl (STDOUT_FILENO, F_SETFD, + fcntl (STDOUT_FILENO, F_GETFD) | FD_CLOEXEC) == -1) + abort (); + } + result = popen (filename, mode); + /* Now, close any dummy fd's created in the parent. */ + saved_errno = errno; + if (cloexec0 < 0) + close (STDIN_FILENO); + if (cloexec1 < 0) + close (STDOUT_FILENO); + errno = saved_errno; + return result; +} + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/progname.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/progname.c new file mode 100644 index 00000000..db17f5b2 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/progname.c @@ -0,0 +1,92 @@ +/* Program name management. + Copyright (C) 2001-2003, 2005-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2001. + + 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 . */ + + +#include + +/* Specification. */ +#undef ENABLE_RELOCATABLE /* avoid defining set_program_name as a macro */ +#include "progname.h" + +#include /* get program_invocation_name declaration */ +#include +#include +#include + + +/* String containing name the program is called with. + To be initialized by main(). */ +const char *program_name = NULL; + +/* Set program_name, based on argv[0]. + argv0 must be a string allocated with indefinite extent, and must not be + modified after this call. */ +void +set_program_name (const char *argv0) +{ + /* libtool creates a temporary executable whose name is sometimes prefixed + with "lt-" (depends on the platform). It also makes argv[0] absolute. + But the name of the temporary executable is a detail that should not be + visible to the end user and to the test suite. + Remove this "/.libs/" or "/.libs/lt-" prefix here. */ + const char *slash; + const char *base; + + /* Sanity check. POSIX requires the invoking process to pass a non-NULL + argv[0]. */ + if (argv0 == NULL) + { + /* It's a bug in the invoking program. Help diagnosing it. */ + fputs ("A NULL argv[0] was passed through an exec system call.\n", + stderr); + abort (); + } + + slash = strrchr (argv0, '/'); + base = (slash != NULL ? slash + 1 : argv0); + if (base - argv0 >= 7 && strncmp (base - 7, "/.libs/", 7) == 0) + { + argv0 = base; + if (strncmp (base, "lt-", 3) == 0) + { + argv0 = base + 3; + /* On glibc systems, remove the "lt-" prefix from the variable + program_invocation_short_name. */ +#if HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME + program_invocation_short_name = (char *) argv0; +#endif + } + } + + /* But don't strip off a leading / in general, because when the user + runs + /some/hidden/place/bin/cp foo foo + he should get the error message + /some/hidden/place/bin/cp: `foo' and `foo' are the same file + not + cp: `foo' and `foo' are the same file + */ + + program_name = argv0; + + /* On glibc systems, the error() function comes from libc and uses the + variable program_invocation_name, not program_name. So set this variable + as well. */ +#if HAVE_DECL_PROGRAM_INVOCATION_NAME + program_invocation_name = (char *) argv0; +#endif +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/progname.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/progname.h new file mode 100644 index 00000000..a61872bf --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/progname.h @@ -0,0 +1,62 @@ +/* Program name management. + Copyright (C) 2001-2004, 2006, 2009-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2001. + + 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 . */ + +#ifndef _PROGNAME_H +#define _PROGNAME_H + +/* Programs using this file should do the following in main(): + set_program_name (argv[0]); + */ + + +#ifdef __cplusplus +extern "C" { +#endif + + +/* String containing name the program is called with. */ +extern const char *program_name; + +/* Set program_name, based on argv[0]. + argv0 must be a string allocated with indefinite extent, and must not be + modified after this call. */ +extern void set_program_name (const char *argv0); + +#if ENABLE_RELOCATABLE + +/* Set program_name, based on argv[0], and original installation prefix and + directory, for relocatability. */ +extern void set_program_name_and_installdir (const char *argv0, + const char *orig_installprefix, + const char *orig_installdir); +#undef set_program_name +#define set_program_name(ARG0) \ + set_program_name_and_installdir (ARG0, INSTALLPREFIX, INSTALLDIR) + +/* Return the full pathname of the current executable, based on the earlier + call to set_program_name_and_installdir. Return NULL if unknown. */ +extern char *get_full_program_name (void); + +#endif + + +#ifdef __cplusplus +} +#endif + + +#endif /* _PROGNAME_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/propername-lite.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/propername-lite.c new file mode 100644 index 00000000..7694a116 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/propername-lite.c @@ -0,0 +1,36 @@ +/* Localization of proper names. + Copyright 2023-2024 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 . */ + +#include + +/* Specification. */ +#include "propername.h" + +#include "c-strcase.h" +#include "gettext.h" +#include "localcharset.h" + +/* Return the localization of the name spelled NAME_ASCII in ASCII, + and NAME_UTF8 in UTF-8. */ + +char const * +proper_name_lite (char const *name_ascii, char const *name_utf8) +{ + char const *translation = gettext (name_ascii); + return (translation != name_ascii ? translation + : c_strcasecmp (locale_charset (), "UTF-8") == 0 ? name_utf8 + : name_ascii); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/propername.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/propername.h new file mode 100644 index 00000000..6247a991 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/propername.h @@ -0,0 +1,134 @@ +/* Localization of proper names. -*- coding: utf-8 -*- + Copyright (C) 2006, 2008-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2006. + + 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 . */ + +/* INTRODUCTION + + What do + + Torbjörn Granlund (coreutils) + François Pinard (coreutils) + Danilo Å egan (gettext) + + have in common? + + A non-ASCII name. This causes trouble in the --version output. The simple + "solution" unfortunately mutilates the name. + + $ du --version | grep Granlund + Écrit par Torbjorn Granlund, David MacKenzie, Paul Eggert et Jim Meyering. + + $ ptx --version | grep Pinard + Écrit par F. Pinard. + + What is desirable, is to print the full name if the output character set + allows it, and the ASCIIfied name only as a fallback. + + $ recode-sr-latin --version + ... + Written by Danilo Å egan and Bruno Haible. + + $ LC_ALL=C recode-sr-latin --version + ... + Written by Danilo Segan and Bruno Haible. + + The 'propername' and 'propername-lite' modules do this. Plus, for + languages that do not use the Latin alphabet, they allow a translator + to write the name using that different writing system. In that case the + propername and propername_utf8 output will look like this: + () + whereas the propername_lite output will just be the translated name + if available, otherwise the original name (in UTF-8 if possible and + in ASCII if not). + + To use the 'propername' module requires two simple steps: + + 1) Add it to the list of gnulib modules to import, + + 2) Change the arguments of version_etc(), + + from "Paul Eggert" + to proper_name ("Paul Eggert") + + from "Torbjorn Granlund" + to proper_name_utf8 ("Torbjorn Granlund", "Torbj\303\266rn Granlund") + or proper_name_lite ("Torbjorn Granlund", "Torbj\303\266rn Granlund") + + from "F. Pinard" + to proper_name_utf8 ("Franc,ois Pinard", "Fran\303\247ois Pinard") + or proper_name_lite ("Franc,ois Pinard", "Fran\303\247ois Pinard") + + In source code, the second argument of proper_name_lite and + proper_name_utf8 should use octal escapes, not UTF-8 - e.g., + "Fran\303\247ois Pinard", not "François Pinard". Doing it + this way can avoid mishandling non-ASCII characters if the + source is recoded to non-UTF-8, or if the compiler does not + treat UTF-8 as-is in character string contents. + + (Optionally, here you can also add / * TRANSLATORS: ... * / comments + explaining how the name is written or pronounced.) + + Here is an example in context. + + char const *author_names[2] = { + / * TRANSLATORS: This is the proper name "Danilo Å egan". + In the original Cyrillic it is "Данило Шеган". * / + proper_name_utf8 ("Danilo Segan", "Danilo \305\240egan"), + proper_name ("Bruno Haible") + }; + + Differences between proper_name_utf8 and proper_name_lite: + * proper_name_lite uses the localization provided by the translator. + If there is no localization, it uses the name with Unicode characters + only in UTF-8 locales, otherwise it uses the original name in English. + * proper_name_utf8 is more elaborate: + - It uses the name with Unicode characters also when the locale encoding + is not UTF-8 but contains the necessary characters (e.g. ISO-8859-x or + GB18030). + - If there is a localization, it produces a better result when the + translator has given a poor localization. + */ + +#ifndef _PROPERNAME_H +#define _PROPERNAME_H + + +#ifdef __cplusplus +extern "C" { +#endif + +/* Return the localization of NAME. NAME is written in ASCII. */ +extern const char * proper_name (const char *name) /* NOT attribute const */; + +/* Return the localization of a name whose original writing is not ASCII. + NAME_UTF8 is the real name, written in UTF-8 with octal or hexadecimal + escape sequences. NAME_ASCII is a fallback written only with ASCII + characters. */ +extern const char * proper_name_utf8 (const char *name_ascii, + const char *name_utf8); + +/* Return the localization of the name spelled NAME_ASCII in ASCII, + and NAME_UTF8 in UTF-8. This function needs less infrastructure + than proper_name and proper_name_utf8. */ +extern const char *proper_name_lite (const char *name_ascii, + const char *name_utf8); + +#ifdef __cplusplus +} +#endif + + +#endif /* _PROPERNAME_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/quote.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/quote.h new file mode 100644 index 00000000..2a1c5813 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/quote.h @@ -0,0 +1,46 @@ +/* quote.h - prototypes for quote.c + + Copyright (C) 1998-2001, 2003, 2009-2024 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 . */ + +#ifndef QUOTE_H_ +# define QUOTE_H_ 1 + +# include + +/* The quoting options used by quote_n and quote. Its type is incomplete, + so it's useful only in expressions like '"e_quoting_options'. */ +extern struct quoting_options quote_quoting_options; + +/* Return an unambiguous printable representation of ARG (of size + ARGSIZE), allocated in slot N, suitable for diagnostics. If + ARGSIZE is SIZE_MAX, use the string length of the argument for + ARGSIZE. */ +char const *quote_n_mem (int n, char const *arg, size_t argsize); + +/* Return an unambiguous printable representation of ARG (of size + ARGSIZE), suitable for diagnostics. If ARGSIZE is SIZE_MAX, use + the string length of the argument for ARGSIZE. */ +char const *quote_mem (char const *arg, size_t argsize); + +/* Return an unambiguous printable representation of ARG, allocated in + slot N, suitable for diagnostics. */ +char const *quote_n (int n, char const *arg); + +/* Return an unambiguous printable representation of ARG, suitable for + diagnostics. */ +char const *quote (char const *arg); + +#endif /* !QUOTE_H_ */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/quotearg.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/quotearg.c new file mode 100644 index 00000000..847101e6 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/quotearg.c @@ -0,0 +1,1084 @@ +/* quotearg.c - quote arguments for output + + Copyright (C) 1998-2002, 2004-2024 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 . */ + +/* Written by Paul Eggert */ + +/* Without this pragma, gcc 4.7.0 20111124 mistakenly suggests that + the quoting_options_from_style function might be candidate for + attribute 'pure' */ +#if (__GNUC__ == 4 && 6 <= __GNUC_MINOR__) || 4 < __GNUC__ +# pragma GCC diagnostic ignored "-Wsuggest-attribute=pure" +#endif + +#include + +#include "quotearg.h" +#include "quote.h" + +#include "attribute.h" +#include "minmax.h" +#include "xalloc.h" +#include "c-strcaseeq.h" +#include "localcharset.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "gettext.h" +#define _(msgid) gettext (msgid) +#define N_(msgid) msgid + +#ifndef SIZE_MAX +# define SIZE_MAX ((size_t) -1) +#endif + +#define INT_BITS (sizeof (int) * CHAR_BIT) + +struct quoting_options +{ + /* Basic quoting style. */ + enum quoting_style style; + + /* Additional flags. Bitwise combination of enum quoting_flags. */ + int flags; + + /* Quote the characters indicated by this bit vector even if the + quoting style would not normally require them to be quoted. */ + unsigned int quote_these_too[(UCHAR_MAX / INT_BITS) + 1]; + + /* The left quote for custom_quoting_style. */ + char const *left_quote; + + /* The right quote for custom_quoting_style. */ + char const *right_quote; +}; + +/* Names of quoting styles. */ +char const *const quoting_style_args[] = +{ + "literal", + "shell", + "shell-always", + "shell-escape", + "shell-escape-always", + "c", + "c-maybe", + "escape", + "locale", + "clocale", + 0 +}; + +/* Correspondences to quoting style names. */ +enum quoting_style const quoting_style_vals[] = +{ + literal_quoting_style, + shell_quoting_style, + shell_always_quoting_style, + shell_escape_quoting_style, + shell_escape_always_quoting_style, + c_quoting_style, + c_maybe_quoting_style, + escape_quoting_style, + locale_quoting_style, + clocale_quoting_style +}; + +/* The default quoting options. */ +static struct quoting_options default_quoting_options; + +/* Allocate a new set of quoting options, with contents initially identical + to O if O is not null, or to the default if O is null. + It is the caller's responsibility to free the result. */ +struct quoting_options * +clone_quoting_options (struct quoting_options *o) +{ + int e = errno; + struct quoting_options *p = xmemdup (o ? o : &default_quoting_options, + sizeof *o); + errno = e; + return p; +} + +/* Get the value of O's quoting style. If O is null, use the default. */ +enum quoting_style +get_quoting_style (struct quoting_options const *o) +{ + return (o ? o : &default_quoting_options)->style; +} + +/* In O (or in the default if O is null), + set the value of the quoting style to S. */ +void +set_quoting_style (struct quoting_options *o, enum quoting_style s) +{ + (o ? o : &default_quoting_options)->style = s; +} + +/* In O (or in the default if O is null), + set the value of the quoting options for character C to I. + Return the old value. Currently, the only values defined for I are + 0 (the default) and 1 (which means to quote the character even if + it would not otherwise be quoted). */ +int +set_char_quoting (struct quoting_options *o, char c, int i) +{ + unsigned char uc = c; + unsigned int *p = + (o ? o : &default_quoting_options)->quote_these_too + uc / INT_BITS; + int shift = uc % INT_BITS; + int r = (*p >> shift) & 1; + *p ^= ((i & 1) ^ r) << shift; + return r; +} + +/* In O (or in the default if O is null), + set the value of the quoting options flag to I, which can be a + bitwise combination of enum quoting_flags, or 0 for default + behavior. Return the old value. */ +int +set_quoting_flags (struct quoting_options *o, int i) +{ + int r; + if (!o) + o = &default_quoting_options; + r = o->flags; + o->flags = i; + return r; +} + +void +set_custom_quoting (struct quoting_options *o, + char const *left_quote, char const *right_quote) +{ + if (!o) + o = &default_quoting_options; + o->style = custom_quoting_style; + if (!left_quote || !right_quote) + abort (); + o->left_quote = left_quote; + o->right_quote = right_quote; +} + +/* Return quoting options for STYLE, with no extra quoting. */ +static struct quoting_options /* NOT PURE!! */ +quoting_options_from_style (enum quoting_style style) +{ + struct quoting_options o = { literal_quoting_style, 0, { 0 }, NULL, NULL }; + if (style == custom_quoting_style) + abort (); + o.style = style; + return o; +} + +/* MSGID approximates a quotation mark. Return its translation if it + has one; otherwise, return either it or "\"", depending on S. + + S is either clocale_quoting_style or locale_quoting_style. */ +static char const * +gettext_quote (char const *msgid, enum quoting_style s) +{ + char const *translation = _(msgid); + char const *locale_code; + + if (translation != msgid) + return translation; + + /* For UTF-8 and GB-18030, use single quotes U+2018 and U+2019. + Here is a list of other locales that include U+2018 and U+2019: + + ISO-8859-7 0xA1 KOI8-T 0x91 + CP869 0x8B CP874 0x91 + CP932 0x81 0x65 CP936 0xA1 0xAE + CP949 0xA1 0xAE CP950 0xA1 0xA5 + CP1250 0x91 CP1251 0x91 + CP1252 0x91 CP1253 0x91 + CP1254 0x91 CP1255 0x91 + CP1256 0x91 CP1257 0x91 + EUC-JP 0xA1 0xC6 EUC-KR 0xA1 0xAE + EUC-TW 0xA1 0xE4 BIG5 0xA1 0xA5 + BIG5-HKSCS 0xA1 0xA5 EUC-CN 0xA1 0xAE + GBK 0xA1 0xAE Georgian-PS 0x91 + PT154 0x91 + + None of these is still in wide use; using iconv is overkill. */ + locale_code = locale_charset (); + if (STRCASEEQ (locale_code, "UTF-8", 'U','T','F','-','8',0,0,0,0)) + return msgid[0] == '`' ? "\xe2\x80\x98": "\xe2\x80\x99"; + if (STRCASEEQ (locale_code, "GB18030", 'G','B','1','8','0','3','0',0,0)) + return msgid[0] == '`' ? "\xa1\ae": "\xa1\xaf"; + + return (s == clocale_quoting_style ? "\"" : "'"); +} + +/* Place into buffer BUFFER (of size BUFFERSIZE) a quoted version of + argument ARG (of size ARGSIZE), using QUOTING_STYLE, FLAGS, and + QUOTE_THESE_TOO to control quoting. + Terminate the output with a null character, and return the written + size of the output, not counting the terminating null. + If BUFFERSIZE is too small to store the output string, return the + value that would have been returned had BUFFERSIZE been large enough. + If ARGSIZE is SIZE_MAX, use the string length of the argument for ARGSIZE. + + This function acts like quotearg_buffer (BUFFER, BUFFERSIZE, ARG, + ARGSIZE, O), except it breaks O into its component pieces and is + not careful about errno. */ + +static size_t +quotearg_buffer_restyled (char *buffer, size_t buffersize, + char const *arg, size_t argsize, + enum quoting_style quoting_style, int flags, + unsigned int const *quote_these_too, + char const *left_quote, + char const *right_quote) +{ + size_t i; + size_t len = 0; + size_t orig_buffersize = 0; + char const *quote_string = 0; + size_t quote_string_len = 0; + bool backslash_escapes = false; + bool unibyte_locale = MB_CUR_MAX == 1; + bool elide_outer_quotes = (flags & QA_ELIDE_OUTER_QUOTES) != 0; + bool pending_shell_escape_end = false; + bool encountered_single_quote = false; + bool all_c_and_shell_quote_compat = true; + +#define STORE(c) \ + do \ + { \ + if (len < buffersize) \ + buffer[len] = (c); \ + len++; \ + } \ + while (0) + +#define START_ESC() \ + do \ + { \ + if (elide_outer_quotes) \ + goto force_outer_quoting_style; \ + escaping = true; \ + if (quoting_style == shell_always_quoting_style \ + && ! pending_shell_escape_end) \ + { \ + STORE ('\''); \ + STORE ('$'); \ + STORE ('\''); \ + pending_shell_escape_end = true; \ + } \ + STORE ('\\'); \ + } \ + while (0) + +#define END_ESC() \ + do \ + { \ + if (pending_shell_escape_end && ! escaping) \ + { \ + STORE ('\''); \ + STORE ('\''); \ + pending_shell_escape_end = false; \ + } \ + } \ + while (0) + + process_input: + + switch (quoting_style) + { + case c_maybe_quoting_style: + quoting_style = c_quoting_style; + elide_outer_quotes = true; + FALLTHROUGH; + case c_quoting_style: + if (!elide_outer_quotes) + STORE ('"'); + backslash_escapes = true; + quote_string = "\""; + quote_string_len = 1; + break; + + case escape_quoting_style: + backslash_escapes = true; + elide_outer_quotes = false; + break; + + case locale_quoting_style: + case clocale_quoting_style: + case custom_quoting_style: + { + if (quoting_style != custom_quoting_style) + { + /* TRANSLATORS: + Get translations for open and closing quotation marks. + The message catalog should translate "`" to a left + quotation mark suitable for the locale, and similarly for + "'". For example, a French Unicode local should translate + these to U+00AB (LEFT-POINTING DOUBLE ANGLE + QUOTATION MARK), and U+00BB (RIGHT-POINTING DOUBLE ANGLE + QUOTATION MARK), respectively. + + If the catalog has no translation, we will try to + use Unicode U+2018 (LEFT SINGLE QUOTATION MARK) and + Unicode U+2019 (RIGHT SINGLE QUOTATION MARK). If the + current locale is not Unicode, locale_quoting_style + will quote 'like this', and clocale_quoting_style will + quote "like this". You should always include translations + for "`" and "'" even if U+2018 and U+2019 are appropriate + for your locale. + + If you don't know what to put here, please see + + and use glyphs suitable for your language. */ + left_quote = gettext_quote (N_("`"), quoting_style); + right_quote = gettext_quote (N_("'"), quoting_style); + } + if (!elide_outer_quotes) + for (quote_string = left_quote; *quote_string; quote_string++) + STORE (*quote_string); + backslash_escapes = true; + quote_string = right_quote; + quote_string_len = strlen (quote_string); + } + break; + + case shell_escape_quoting_style: + backslash_escapes = true; + FALLTHROUGH; + case shell_quoting_style: + elide_outer_quotes = true; + FALLTHROUGH; + case shell_escape_always_quoting_style: + if (!elide_outer_quotes) + backslash_escapes = true; + FALLTHROUGH; + case shell_always_quoting_style: + quoting_style = shell_always_quoting_style; + if (!elide_outer_quotes) + STORE ('\''); + quote_string = "'"; + quote_string_len = 1; + break; + + case literal_quoting_style: + elide_outer_quotes = false; + break; + + default: + abort (); + } + + for (i = 0; ! (argsize == SIZE_MAX ? arg[i] == '\0' : i == argsize); i++) + { + unsigned char c; + unsigned char esc; + bool is_right_quote = false; + bool escaping = false; + bool c_and_shell_quote_compat = false; + + if (backslash_escapes + && quoting_style != shell_always_quoting_style + && quote_string_len + && (i + quote_string_len + <= (argsize == SIZE_MAX && 1 < quote_string_len + /* Use strlen only if we must: when argsize is SIZE_MAX, + and when the quote string is more than 1 byte long. + If we do call strlen, save the result. */ + ? (argsize = strlen (arg)) : argsize)) + && memcmp (arg + i, quote_string, quote_string_len) == 0) + { + if (elide_outer_quotes) + goto force_outer_quoting_style; + is_right_quote = true; + } + + c = arg[i]; + switch (c) + { + case '\0': + if (backslash_escapes) + { + START_ESC (); + /* If quote_string were to begin with digits, we'd need to + test for the end of the arg as well. However, it's + hard to imagine any locale that would use digits in + quotes, and set_custom_quoting is documented not to + accept them. Use only a single \0 with shell-escape + as currently digits are not printed within $'...' */ + if (quoting_style != shell_always_quoting_style + && i + 1 < argsize && '0' <= arg[i + 1] && arg[i + 1] <= '9') + { + STORE ('0'); + STORE ('0'); + } + c = '0'; + /* We don't have to worry that this last '0' will be + backslash-escaped because, again, quote_string should + not start with it and because quote_these_too is + documented as not accepting it. */ + } + else if (flags & QA_ELIDE_NULL_BYTES) + continue; + break; + + case '?': + switch (quoting_style) + { + case shell_always_quoting_style: + if (elide_outer_quotes) + goto force_outer_quoting_style; + break; + + case c_quoting_style: + if ((flags & QA_SPLIT_TRIGRAPHS) + && i + 2 < argsize && arg[i + 1] == '?') + switch (arg[i + 2]) + { + case '!': case '\'': + case '(': case ')': case '-': case '/': + case '<': case '=': case '>': + /* Escape the second '?' in what would otherwise be + a trigraph. */ + if (elide_outer_quotes) + goto force_outer_quoting_style; + c = arg[i + 2]; + i += 2; + STORE ('?'); + STORE ('"'); + STORE ('"'); + STORE ('?'); + break; + + default: + break; + } + break; + + default: + break; + } + break; + + case '\a': esc = 'a'; goto c_escape; + case '\b': esc = 'b'; goto c_escape; + case '\f': esc = 'f'; goto c_escape; + case '\n': esc = 'n'; goto c_and_shell_escape; + case '\r': esc = 'r'; goto c_and_shell_escape; + case '\t': esc = 't'; goto c_and_shell_escape; + case '\v': esc = 'v'; goto c_escape; + case '\\': esc = c; + /* Never need to escape '\' in shell case. */ + if (quoting_style == shell_always_quoting_style) + { + if (elide_outer_quotes) + goto force_outer_quoting_style; + goto store_c; + } + + /* No need to escape the escape if we are trying to elide + outer quotes and nothing else is problematic. */ + if (backslash_escapes && elide_outer_quotes && quote_string_len) + goto store_c; + + c_and_shell_escape: + if (quoting_style == shell_always_quoting_style + && elide_outer_quotes) + goto force_outer_quoting_style; + /* fall through */ + c_escape: + if (backslash_escapes) + { + c = esc; + goto store_escape; + } + break; + + case '{': case '}': /* sometimes special if isolated */ + if (! (argsize == SIZE_MAX ? arg[1] == '\0' : argsize == 1)) + break; + FALLTHROUGH; + case '#': case '~': + if (i != 0) + break; + FALLTHROUGH; + case ' ': + c_and_shell_quote_compat = true; + FALLTHROUGH; + case '!': /* special in bash */ + case '"': case '$': case '&': + case '(': case ')': case '*': case ';': + case '<': + case '=': /* sometimes special in 0th or (with "set -k") later args */ + case '>': case '[': + case '^': /* special in old /bin/sh, e.g., Solaris 10 */ + case '`': case '|': + /* A shell special character. */ + if (quoting_style == shell_always_quoting_style + && elide_outer_quotes) + goto force_outer_quoting_style; + break; + + case '\'': + encountered_single_quote = true; + c_and_shell_quote_compat = true; + if (quoting_style == shell_always_quoting_style) + { + if (elide_outer_quotes) + goto force_outer_quoting_style; + + if (buffersize && ! orig_buffersize) + { + /* Just scan string to see if supports a more concise + representation, rather than writing a longer string + but returning the length of the more concise form. */ + orig_buffersize = buffersize; + buffersize = 0; + } + + STORE ('\''); + STORE ('\\'); + STORE ('\''); + pending_shell_escape_end = false; + } + break; + + case '%': case '+': case ',': case '-': case '.': case '/': + case '0': case '1': case '2': case '3': case '4': case '5': + case '6': case '7': case '8': case '9': case ':': + case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': + case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': + case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': + case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': + case 'Y': case 'Z': case ']': case '_': case 'a': case 'b': + case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': + case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': + case 'o': case 'p': case 'q': case 'r': case 's': case 't': + case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': + /* These characters don't cause problems, no matter what the + quoting style is. They cannot start multibyte sequences. + A digit or a special letter would cause trouble if it + appeared at the beginning of quote_string because we'd then + escape by prepending a backslash. However, it's hard to + imagine any locale that would use digits or letters as + quotes, and set_custom_quoting is documented not to accept + them. Also, a digit or a special letter would cause + trouble if it appeared in quote_these_too, but that's also + documented as not accepting them. */ + c_and_shell_quote_compat = true; + break; + + default: + /* If we have a multibyte sequence, copy it until we reach + its end, find an error, or come back to the initial shift + state. For C-like styles, if the sequence has + unprintable characters, escape the whole sequence, since + we can't easily escape single characters within it. */ + { + /* Length of multibyte sequence found so far. */ + size_t m; + + bool printable; + + if (unibyte_locale) + { + m = 1; + printable = isprint (c) != 0; + } + else + { + mbstate_t mbstate; + mbszero (&mbstate); + + m = 0; + printable = true; + if (argsize == SIZE_MAX) + argsize = strlen (arg); + + for (;;) + { + char32_t w; + size_t bytes = mbrtoc32 (&w, &arg[i + m], + argsize - (i + m), &mbstate); + if (bytes == 0) + break; + else if (bytes == (size_t) -1) + { + printable = false; + break; + } + else if (bytes == (size_t) -2) + { + printable = false; + while (i + m < argsize && arg[i + m]) + m++; + break; + } + else + { + #if !GNULIB_MBRTOC32_REGULAR + if (bytes == (size_t) -3) + bytes = 0; + #endif + /* Work around a bug with older shells that "see" a '\' + that is really the 2nd byte of a multibyte character. + In practice the problem is limited to ASCII + chars >= '@' that are shell special chars. */ + if ('[' == 0x5b && elide_outer_quotes + && quoting_style == shell_always_quoting_style) + { + size_t j; + for (j = 1; j < bytes; j++) + switch (arg[i + m + j]) + { + case '[': case '\\': case '^': + case '`': case '|': + goto force_outer_quoting_style; + + default: + break; + } + } + + if (! c32isprint (w)) + printable = false; + m += bytes; + } + #if !GNULIB_MBRTOC32_REGULAR + if (mbsinit (&mbstate)) + #endif + break; + } + } + + c_and_shell_quote_compat = printable; + + if (1 < m || (backslash_escapes && ! printable)) + { + /* Output a multibyte sequence, or an escaped + unprintable unibyte character. */ + size_t ilim = i + m; + + for (;;) + { + if (backslash_escapes && ! printable) + { + START_ESC (); + STORE ('0' + (c >> 6)); + STORE ('0' + ((c >> 3) & 7)); + c = '0' + (c & 7); + } + else if (is_right_quote) + { + STORE ('\\'); + is_right_quote = false; + } + if (ilim <= i + 1) + break; + END_ESC (); + STORE (c); + c = arg[++i]; + } + + goto store_c; + } + } + } + + if (! (((backslash_escapes && quoting_style != shell_always_quoting_style) + || elide_outer_quotes) + && quote_these_too + && quote_these_too[c / INT_BITS] >> (c % INT_BITS) & 1) + && !is_right_quote) + goto store_c; + + store_escape: + START_ESC (); + + store_c: + END_ESC (); + STORE (c); + + if (! c_and_shell_quote_compat) + all_c_and_shell_quote_compat = false; + } + + if (len == 0 && quoting_style == shell_always_quoting_style + && elide_outer_quotes) + goto force_outer_quoting_style; + + /* Single shell quotes (') are commonly enough used as an apostrophe, + that we attempt to minimize the quoting in this case. Note itʼs + better to use the apostrophe modifier "\u02BC" if possible, as that + renders better and works with the word match regex \W+ etc. */ + if (quoting_style == shell_always_quoting_style && ! elide_outer_quotes + && encountered_single_quote) + { + if (all_c_and_shell_quote_compat) + return quotearg_buffer_restyled (buffer, orig_buffersize, arg, argsize, + c_quoting_style, + flags, quote_these_too, + left_quote, right_quote); + else if (! buffersize && orig_buffersize) + { + /* Disable read-only scan, and reprocess to write quoted string. */ + buffersize = orig_buffersize; + len = 0; + goto process_input; + } + } + + if (quote_string && !elide_outer_quotes) + for (; *quote_string; quote_string++) + STORE (*quote_string); + + if (len < buffersize) + buffer[len] = '\0'; + return len; + + force_outer_quoting_style: + /* Don't reuse quote_these_too, since the addition of outer quotes + sufficiently quotes the specified characters. */ + if (quoting_style == shell_always_quoting_style && backslash_escapes) + quoting_style = shell_escape_always_quoting_style; + return quotearg_buffer_restyled (buffer, buffersize, arg, argsize, + quoting_style, + flags & ~QA_ELIDE_OUTER_QUOTES, NULL, + left_quote, right_quote); +} + +/* Place into buffer BUFFER (of size BUFFERSIZE) a quoted version of + argument ARG (of size ARGSIZE), using O to control quoting. + If O is null, use the default. + Terminate the output with a null character, and return the written + size of the output, not counting the terminating null. + If BUFFERSIZE is too small to store the output string, return the + value that would have been returned had BUFFERSIZE been large enough. + If ARGSIZE is SIZE_MAX, use the string length of the argument for + ARGSIZE. */ +size_t +quotearg_buffer (char *buffer, size_t buffersize, + char const *arg, size_t argsize, + struct quoting_options const *o) +{ + struct quoting_options const *p = o ? o : &default_quoting_options; + int e = errno; + size_t r = quotearg_buffer_restyled (buffer, buffersize, arg, argsize, + p->style, p->flags, p->quote_these_too, + p->left_quote, p->right_quote); + errno = e; + return r; +} + +char * +quotearg_alloc (char const *arg, size_t argsize, + struct quoting_options const *o) +{ + return quotearg_alloc_mem (arg, argsize, NULL, o); +} + +/* Like quotearg_buffer (..., ARG, ARGSIZE, O), except return newly + allocated storage containing the quoted string, and store the + resulting size into *SIZE, if non-NULL. The result can contain + embedded null bytes only if ARGSIZE is not SIZE_MAX, SIZE is not + NULL, and set_quoting_flags has not set the null byte elision + flag. */ +char * +quotearg_alloc_mem (char const *arg, size_t argsize, size_t *size, + struct quoting_options const *o) +{ + struct quoting_options const *p = o ? o : &default_quoting_options; + int e = errno; + /* Elide embedded null bytes if we can't return a size. */ + int flags = p->flags | (size ? 0 : QA_ELIDE_NULL_BYTES); + size_t bufsize = quotearg_buffer_restyled (0, 0, arg, argsize, p->style, + flags, p->quote_these_too, + p->left_quote, + p->right_quote) + 1; + char *buf = xcharalloc (bufsize); + quotearg_buffer_restyled (buf, bufsize, arg, argsize, p->style, flags, + p->quote_these_too, + p->left_quote, p->right_quote); + errno = e; + if (size) + *size = bufsize - 1; + return buf; +} + +/* A storage slot with size and pointer to a value. */ +struct slotvec +{ + size_t size; + char *val; +}; + +/* Preallocate a slot 0 buffer, so that the caller can always quote + one small component of a "memory exhausted" message in slot 0. */ +static char slot0[256]; +static int nslots = 1; +static struct slotvec slotvec0 = {sizeof slot0, slot0}; +static struct slotvec *slotvec = &slotvec0; + +void +quotearg_free (void) +{ + struct slotvec *sv = slotvec; + int i; + for (i = 1; i < nslots; i++) + free (sv[i].val); + if (sv[0].val != slot0) + { + free (sv[0].val); + slotvec0.size = sizeof slot0; + slotvec0.val = slot0; + } + if (sv != &slotvec0) + { + free (sv); + slotvec = &slotvec0; + } + nslots = 1; +} + +/* Use storage slot N to return a quoted version of argument ARG. + ARG is of size ARGSIZE, but if that is SIZE_MAX, ARG is a + null-terminated string. + OPTIONS specifies the quoting options. + The returned value points to static storage that can be + reused by the next call to this function with the same value of N. + N must be nonnegative; it is typically small, and must be + less than MIN (INT_MAX, IDX_MAX). The type of N is signed + to allow for future extensions (using negative values). */ +static char * +quotearg_n_options (int n, char const *arg, size_t argsize, + struct quoting_options const *options) +{ + int e = errno; + + struct slotvec *sv = slotvec; + + int nslots_max = MIN (INT_MAX, IDX_MAX); + if (! (0 <= n && n < nslots_max)) + abort (); + + if (nslots <= n) + { + bool preallocated = (sv == &slotvec0); + idx_t new_nslots = nslots; + + slotvec = sv = xpalloc (preallocated ? NULL : sv, &new_nslots, + n - nslots + 1, nslots_max, sizeof *sv); + if (preallocated) + *sv = slotvec0; + memset (sv + nslots, 0, (new_nslots - nslots) * sizeof *sv); + nslots = new_nslots; + } + + { + size_t size = sv[n].size; + char *val = sv[n].val; + /* Elide embedded null bytes since we don't return a size. */ + int flags = options->flags | QA_ELIDE_NULL_BYTES; + size_t qsize = quotearg_buffer_restyled (val, size, arg, argsize, + options->style, flags, + options->quote_these_too, + options->left_quote, + options->right_quote); + + if (size <= qsize) + { + sv[n].size = size = qsize + 1; + if (val != slot0) + free (val); + sv[n].val = val = xcharalloc (size); + quotearg_buffer_restyled (val, size, arg, argsize, options->style, + flags, options->quote_these_too, + options->left_quote, + options->right_quote); + } + + errno = e; + return val; + } +} + +char * +quotearg_n (int n, char const *arg) +{ + return quotearg_n_options (n, arg, SIZE_MAX, &default_quoting_options); +} + +char * +quotearg_n_mem (int n, char const *arg, size_t argsize) +{ + return quotearg_n_options (n, arg, argsize, &default_quoting_options); +} + +char * +quotearg (char const *arg) +{ + return quotearg_n (0, arg); +} + +char * +quotearg_mem (char const *arg, size_t argsize) +{ + return quotearg_n_mem (0, arg, argsize); +} + +char * +quotearg_n_style (int n, enum quoting_style s, char const *arg) +{ + struct quoting_options const o = quoting_options_from_style (s); + return quotearg_n_options (n, arg, SIZE_MAX, &o); +} + +char * +quotearg_n_style_mem (int n, enum quoting_style s, + char const *arg, size_t argsize) +{ + struct quoting_options const o = quoting_options_from_style (s); + return quotearg_n_options (n, arg, argsize, &o); +} + +char * +quotearg_style (enum quoting_style s, char const *arg) +{ + return quotearg_n_style (0, s, arg); +} + +char * +quotearg_style_mem (enum quoting_style s, char const *arg, size_t argsize) +{ + return quotearg_n_style_mem (0, s, arg, argsize); +} + +char * +quotearg_char_mem (char const *arg, size_t argsize, char ch) +{ + struct quoting_options options; + options = default_quoting_options; + set_char_quoting (&options, ch, 1); + return quotearg_n_options (0, arg, argsize, &options); +} + +char * +quotearg_char (char const *arg, char ch) +{ + return quotearg_char_mem (arg, SIZE_MAX, ch); +} + +char * +quotearg_colon (char const *arg) +{ + return quotearg_char (arg, ':'); +} + +char * +quotearg_colon_mem (char const *arg, size_t argsize) +{ + return quotearg_char_mem (arg, argsize, ':'); +} + +char * +quotearg_n_style_colon (int n, enum quoting_style s, char const *arg) +{ + struct quoting_options options; + options = quoting_options_from_style (s); + set_char_quoting (&options, ':', 1); + return quotearg_n_options (n, arg, SIZE_MAX, &options); +} + +char * +quotearg_n_custom (int n, char const *left_quote, + char const *right_quote, char const *arg) +{ + return quotearg_n_custom_mem (n, left_quote, right_quote, arg, + SIZE_MAX); +} + +char * +quotearg_n_custom_mem (int n, char const *left_quote, + char const *right_quote, + char const *arg, size_t argsize) +{ + struct quoting_options o = default_quoting_options; + set_custom_quoting (&o, left_quote, right_quote); + return quotearg_n_options (n, arg, argsize, &o); +} + +char * +quotearg_custom (char const *left_quote, char const *right_quote, + char const *arg) +{ + return quotearg_n_custom (0, left_quote, right_quote, arg); +} + +char * +quotearg_custom_mem (char const *left_quote, char const *right_quote, + char const *arg, size_t argsize) +{ + return quotearg_n_custom_mem (0, left_quote, right_quote, arg, + argsize); +} + + +/* The quoting option used by the functions of quote.h. */ +struct quoting_options quote_quoting_options = + { + locale_quoting_style, + 0, + { 0 }, + NULL, NULL + }; + +char const * +quote_n_mem (int n, char const *arg, size_t argsize) +{ + return quotearg_n_options (n, arg, argsize, "e_quoting_options); +} + +char const * +quote_mem (char const *arg, size_t argsize) +{ + return quote_n_mem (0, arg, argsize); +} + +char const * +quote_n (int n, char const *arg) +{ + return quote_n_mem (n, arg, SIZE_MAX); +} + +char const * +quote (char const *arg) +{ + return quote_n (0, arg); +} + +/* + * Hey Emacs! + * Local Variables: + * coding: utf-8 + * End: + */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/quotearg.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/quotearg.h new file mode 100644 index 00000000..4e9099ff --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/quotearg.h @@ -0,0 +1,436 @@ +/* quotearg.h - quote arguments for output + + Copyright (C) 1998-2002, 2004, 2006, 2008-2024 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 . */ + +/* Written by Paul Eggert */ + +#ifndef QUOTEARG_H_ +# define QUOTEARG_H_ 1 + +/* This file uses _GL_ATTRIBUTE_MALLOC, _GL_ATTRIBUTE_RETURNS_NONNULL. */ +# if !_GL_CONFIG_H_INCLUDED +# error "Please include config.h first." +# endif + +# include + +/* Basic quoting styles. For each style, an example is given on the + input strings "simple", "\0 \t\n'\"\033?""?/\\", and "a:b", using + quotearg_buffer, quotearg_mem, and quotearg_colon_mem with that + style and the default flags and quoted characters. Note that the + examples are shown here as valid C strings rather than what + displays on a terminal (with "??/" as a trigraph for "\\"). */ +enum quoting_style + { + /* Output names as-is (ls --quoting-style=literal). Can result in + embedded null bytes if QA_ELIDE_NULL_BYTES is not in + effect. + + quotearg_buffer: + "simple", "\0 \t\n'\"\033??/\\", "a:b" + quotearg: + "simple", " \t\n'\"\033??/\\", "a:b" + quotearg_colon: + "simple", " \t\n'\"\033??/\\", "a:b" + */ + literal_quoting_style, + + /* Quote names for the shell if they contain shell metacharacters + or would cause ambiguous output (ls --quoting-style=shell). + Can result in embedded null bytes if QA_ELIDE_NULL_BYTES is not + in effect. + + quotearg_buffer: + "simple", "'\0 \t\n'\\''\"\033??/\\'", "a:b" + quotearg: + "simple", "' \t\n'\\''\"\033??/\\'", "a:b" + quotearg_colon: + "simple", "' \t\n'\\''\"\033??/\\'", "'a:b'" + */ + shell_quoting_style, + + /* Quote names for the shell, even if they would normally not + require quoting (ls --quoting-style=shell-always). Can result + in embedded null bytes if QA_ELIDE_NULL_BYTES is not in effect. + Behaves like shell_quoting_style if QA_ELIDE_OUTER_QUOTES is in + effect. + + quotearg_buffer: + "'simple'", "'\0 \t\n'\\''\"\033??/\\'", "'a:b'" + quotearg: + "'simple'", "' \t\n'\\''\"\033??/\\'", "'a:b'" + quotearg_colon: + "'simple'", "' \t\n'\\''\"\033??/\\'", "'a:b'" + */ + shell_always_quoting_style, + + /* Quote names for the shell if they contain shell metacharacters + or other problematic characters (ls --quoting-style=shell-escape). + Non printable characters are quoted using the $'...' syntax, + which originated in ksh93 and is widely supported by most shells, + and proposed for inclusion in POSIX. + + quotearg_buffer: + "simple", "''$'\\0'' '$'\\t\\n'\\''\"'$'\\033''??/\\'", "a:b" + quotearg: + "simple", "''$'\\0'' '$'\\t\\n'\\''\"'$'\\033''??/\\'", "a:b" + quotearg_colon: + "simple", "''$'\\0'' '$'\\t\\n'\\''\"'$'\\033''??/\\'", "'a:b'" + */ + shell_escape_quoting_style, + + /* Quote names for the shell even if they would normally not + require quoting (ls --quoting-style=shell-escape). + Non printable characters are quoted using the $'...' syntax, + which originated in ksh93 and is widely supported by most shells, + and proposed for inclusion in POSIX. Behaves like + shell_escape_quoting_style if QA_ELIDE_OUTER_QUOTES is in effect. + + quotearg_buffer: + "simple", "''$'\\0'' '$'\\t\\n'\\''\"'$'\\033''??/\'", "a:b" + quotearg: + "simple", "''$'\\0'' '$'\\t\\n'\\''\"'$'\\033''??/\'", "a:b" + quotearg_colon: + "simple", "''$'\\0'' '$'\\t\\n'\\''\"'$'\\033''??/\'", "'a:b'" + */ + shell_escape_always_quoting_style, + + /* Quote names as for a C language string (ls --quoting-style=c). + Behaves like c_maybe_quoting_style if QA_ELIDE_OUTER_QUOTES is + in effect. Split into consecutive strings if + QA_SPLIT_TRIGRAPHS. + + quotearg_buffer: + "\"simple\"", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "\"a:b\"" + quotearg: + "\"simple\"", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "\"a:b\"" + quotearg_colon: + "\"simple\"", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "\"a\\:b\"" + */ + c_quoting_style, + + /* Like c_quoting_style except omit the surrounding double-quote + characters if no quoted characters are encountered. + + quotearg_buffer: + "simple", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "a:b" + quotearg: + "simple", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "a:b" + quotearg_colon: + "simple", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "\"a:b\"" + */ + c_maybe_quoting_style, + + /* Like c_quoting_style except always omit the surrounding + double-quote characters and ignore QA_SPLIT_TRIGRAPHS + (ls --quoting-style=escape). + + quotearg_buffer: + "simple", "\\0 \\t\\n'\"\\033??/\\\\", "a:b" + quotearg: + "simple", "\\0 \\t\\n'\"\\033??/\\\\", "a:b" + quotearg_colon: + "simple", "\\0 \\t\\n'\"\\033??/\\\\", "a\\:b" + */ + escape_quoting_style, + + /* Like clocale_quoting_style, but use single quotes in the + default C locale or if the program does not use gettext + (ls --quoting-style=locale). For UTF-8 locales, quote + characters will use Unicode. + + LC_MESSAGES=C + quotearg_buffer: + "'simple'", "'\\0 \\t\\n\\'\"\\033??/\\\\'", "'a:b'" + quotearg: + "'simple'", "'\\0 \\t\\n\\'\"\\033??/\\\\'", "'a:b'" + quotearg_colon: + "'simple'", "'\\0 \\t\\n\\'\"\\033??/\\\\'", "'a\\:b'" + + LC_MESSAGES=pt_PT.utf8 + quotearg_buffer: + "\302\253simple\302\273", + "\302\253\\0 \\t\\n'\"\\033??/\\\\\302\253", "\302\253a:b\302\273" + quotearg: + "\302\253simple\302\273", + "\302\253\\0 \\t\\n'\"\\033??/\\\\\302\253", "\302\253a:b\302\273" + quotearg_colon: + "\302\253simple\302\273", + "\302\253\\0 \\t\\n'\"\\033??/\\\\\302\253", "\302\253a\\:b\302\273" + */ + locale_quoting_style, + + /* Like c_quoting_style except use quotation marks appropriate for + the locale and ignore QA_SPLIT_TRIGRAPHS + (ls --quoting-style=clocale). + + LC_MESSAGES=C + quotearg_buffer: + "\"simple\"", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "\"a:b\"" + quotearg: + "\"simple\"", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "\"a:b\"" + quotearg_colon: + "\"simple\"", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "\"a\\:b\"" + + LC_MESSAGES=pt_PT.utf8 + quotearg_buffer: + "\302\253simple\302\273", + "\302\253\\0 \\t\\n'\"\\033??/\\\\\302\253", "\302\253a:b\302\273" + quotearg: + "\302\253simple\302\273", + "\302\253\\0 \\t\\n'\"\\033??/\\\\\302\253", "\302\253a:b\302\273" + quotearg_colon: + "\302\253simple\302\273", + "\302\253\\0 \\t\\n'\"\\033??/\\\\\302\253", "\302\253a\\:b\302\273" + */ + clocale_quoting_style, + + /* Like clocale_quoting_style except use the custom quotation marks + set by set_custom_quoting. If custom quotation marks are not + set, the behavior is undefined. + + left_quote = right_quote = "'" + quotearg_buffer: + "'simple'", "'\\0 \\t\\n\\'\"\\033??/\\\\'", "'a:b'" + quotearg: + "'simple'", "'\\0 \\t\\n\\'\"\\033??/\\\\'", "'a:b'" + quotearg_colon: + "'simple'", "'\\0 \\t\\n\\'\"\\033??/\\\\'", "'a\\:b'" + + left_quote = "(" and right_quote = ")" + quotearg_buffer: + "(simple)", "(\\0 \\t\\n'\"\\033??/\\\\)", "(a:b)" + quotearg: + "(simple)", "(\\0 \\t\\n'\"\\033??/\\\\)", "(a:b)" + quotearg_colon: + "(simple)", "(\\0 \\t\\n'\"\\033??/\\\\)", "(a\\:b)" + + left_quote = ":" and right_quote = " " + quotearg_buffer: + ":simple ", ":\\0\\ \\t\\n'\"\\033??/\\\\ ", ":a:b " + quotearg: + ":simple ", ":\\0\\ \\t\\n'\"\\033??/\\\\ ", ":a:b " + quotearg_colon: + ":simple ", ":\\0\\ \\t\\n'\"\\033??/\\\\ ", ":a\\:b " + + left_quote = "\"'" and right_quote = "'\"" + Notice that this is treated as a single level of quotes or two + levels where the outer quote need not be escaped within the inner + quotes. For two levels where the outer quote must be escaped + within the inner quotes, you must use separate quotearg + invocations. + quotearg_buffer: + "\"'simple'\"", "\"'\\0 \\t\\n\\'\"\\033??/\\\\'\"", "\"'a:b'\"" + quotearg: + "\"'simple'\"", "\"'\\0 \\t\\n\\'\"\\033??/\\\\'\"", "\"'a:b'\"" + quotearg_colon: + "\"'simple'\"", "\"'\\0 \\t\\n\\'\"\\033??/\\\\'\"", "\"'a\\:b'\"" + */ + custom_quoting_style + }; + +/* Flags for use in set_quoting_flags. */ +enum quoting_flags + { + /* Always elide null bytes from styles that do not quote them, + even when the length of the result is available to the + caller. */ + QA_ELIDE_NULL_BYTES = 0x01, + + /* Omit the surrounding quote characters if no escaped characters + are encountered. Note that if no other character needs + escaping, then neither does the escape character. */ + QA_ELIDE_OUTER_QUOTES = 0x02, + + /* In the c_quoting_style and c_maybe_quoting_style, split ANSI + trigraph sequences into concatenated strings (for example, + "?""?/" rather than "??/", which could be confused with + "\\"). */ + QA_SPLIT_TRIGRAPHS = 0x04 + }; + +/* For now, --quoting-style=literal is the default, but this may change. */ +# ifndef DEFAULT_QUOTING_STYLE +# define DEFAULT_QUOTING_STYLE literal_quoting_style +# endif + +/* Names of quoting styles and their corresponding values. */ +extern char const *const quoting_style_args[]; +extern enum quoting_style const quoting_style_vals[]; + +struct quoting_options; + +/* The functions listed below set and use a hidden variable + that contains the default quoting style options. */ + +/* Allocate a new set of quoting options, with contents initially identical + to O if O is not null, or to the default if O is null. + It is the caller's responsibility to free the result. */ +struct quoting_options *clone_quoting_options (struct quoting_options *o) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE + _GL_ATTRIBUTE_RETURNS_NONNULL; + +/* Get the value of O's quoting style. If O is null, use the default. */ +enum quoting_style get_quoting_style (struct quoting_options const *o); + +/* In O (or in the default if O is null), + set the value of the quoting style to S. */ +void set_quoting_style (struct quoting_options *o, enum quoting_style s); + +/* In O (or in the default if O is null), + set the value of the quoting options for character C to I. + Return the old value. Currently, the only values defined for I are + 0 (the default) and 1 (which means to quote the character even if + it would not otherwise be quoted). C must never be a digit or a + letter that has special meaning after a backslash (for example, "\t" + for tab). */ +int set_char_quoting (struct quoting_options *o, char c, int i); + +/* In O (or in the default if O is null), + set the value of the quoting options flag to I, which can be a + bitwise combination of enum quoting_flags, or 0 for default + behavior. Return the old value. */ +int set_quoting_flags (struct quoting_options *o, int i); + +/* In O (or in the default if O is null), + set the value of the quoting style to custom_quoting_style, + set the left quote to LEFT_QUOTE, and set the right quote to + RIGHT_QUOTE. Each of LEFT_QUOTE and RIGHT_QUOTE must be + null-terminated and can be the empty string. Because backslashes are + used for escaping, it does not make sense for RIGHT_QUOTE to contain + a backslash. RIGHT_QUOTE must not begin with a digit or a letter + that has special meaning after a backslash (for example, "\t" for + tab). */ +void set_custom_quoting (struct quoting_options *o, + char const *left_quote, + char const *right_quote); + +/* Place into buffer BUFFER (of size BUFFERSIZE) a quoted version of + argument ARG (of size ARGSIZE), using O to control quoting. + If O is null, use the default. + Terminate the output with a null character, and return the written + size of the output, not counting the terminating null. + If BUFFERSIZE is too small to store the output string, return the + value that would have been returned had BUFFERSIZE been large enough. + If ARGSIZE is -1, use the string length of the argument for ARGSIZE. + On output, BUFFER might contain embedded null bytes if ARGSIZE was + not -1, the style of O does not use backslash escapes, and the + flags of O do not request elision of null bytes.*/ +size_t quotearg_buffer (char *restrict buffer, size_t buffersize, + char const *arg, size_t argsize, + struct quoting_options const *o); + +/* Like quotearg_buffer, except return the result in a newly allocated + buffer. It is the caller's responsibility to free the result. The + result will not contain embedded null bytes. */ +char *quotearg_alloc (char const *arg, size_t argsize, + struct quoting_options const *o) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE + _GL_ATTRIBUTE_RETURNS_NONNULL; + +/* Like quotearg_alloc, except that the length of the result, + excluding the terminating null byte, is stored into SIZE if it is + non-NULL. The result might contain embedded null bytes if ARGSIZE + was not -1, SIZE was not NULL, the style of O does not use + backslash escapes, and the flags of O do not request elision of + null bytes.*/ +char *quotearg_alloc_mem (char const *arg, size_t argsize, + size_t *size, struct quoting_options const *o) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE + _GL_ATTRIBUTE_RETURNS_NONNULL; + +/* Use storage slot N to return a quoted version of the string ARG. + Use the default quoting options. + The returned value points to static storage that can be + reused by the next call to this function with the same value of N. + N must be nonnegative. The output of all functions in the + quotearg_n family are guaranteed to not contain embedded null + bytes.*/ +char *quotearg_n (int n, char const *arg); + +/* Equivalent to quotearg_n (0, ARG). */ +char *quotearg (char const *arg); + +/* Use storage slot N to return a quoted version of the argument ARG + of size ARGSIZE. This is like quotearg_n (N, ARG), except it can + quote null bytes. */ +char *quotearg_n_mem (int n, char const *arg, size_t argsize); + +/* Equivalent to quotearg_n_mem (0, ARG, ARGSIZE). */ +char *quotearg_mem (char const *arg, size_t argsize); + +/* Use style S and storage slot N to return a quoted version of the string ARG. + This is like quotearg_n (N, ARG), except that it uses S with no other + options to specify the quoting method. */ +char *quotearg_n_style (int n, enum quoting_style s, char const *arg); + +/* Use style S and storage slot N to return a quoted version of the + argument ARG of size ARGSIZE. This is like quotearg_n_style + (N, S, ARG), except it can quote null bytes. */ +char *quotearg_n_style_mem (int n, enum quoting_style s, + char const *arg, size_t argsize); + +/* Equivalent to quotearg_n_style (0, S, ARG). */ +char *quotearg_style (enum quoting_style s, char const *arg); + +/* Equivalent to quotearg_n_style_mem (0, S, ARG, ARGSIZE). */ +char *quotearg_style_mem (enum quoting_style s, + char const *arg, size_t argsize); + +/* Like quotearg (ARG), except also quote any instances of CH. + See set_char_quoting for a description of acceptable CH values. */ +char *quotearg_char (char const *arg, char ch); + +/* Like quotearg_char (ARG, CH), except it can quote null bytes. */ +char *quotearg_char_mem (char const *arg, size_t argsize, char ch); + +/* Equivalent to quotearg_char (ARG, ':'). */ +char *quotearg_colon (char const *arg); + +/* Like quotearg_colon (ARG), except it can quote null bytes. */ +char *quotearg_colon_mem (char const *arg, size_t argsize); + +/* Like quotearg_n_style, except with ':' quoting enabled. */ +char *quotearg_n_style_colon (int n, enum quoting_style s, char const *arg); + +/* Like quotearg_n_style (N, S, ARG) but with S as custom_quoting_style + with left quote as LEFT_QUOTE and right quote as RIGHT_QUOTE. See + set_custom_quoting for a description of acceptable LEFT_QUOTE and + RIGHT_QUOTE values. */ +char *quotearg_n_custom (int n, char const *left_quote, + char const *right_quote, char const *arg); + +/* Like quotearg_n_custom (N, LEFT_QUOTE, RIGHT_QUOTE, ARG) except it + can quote null bytes. */ +char *quotearg_n_custom_mem (int n, char const *left_quote, + char const *right_quote, + char const *arg, size_t argsize); + +/* Equivalent to quotearg_n_custom (0, LEFT_QUOTE, RIGHT_QUOTE, ARG). */ +char *quotearg_custom (char const *left_quote, char const *right_quote, + char const *arg); + +/* Equivalent to quotearg_n_custom_mem (0, LEFT_QUOTE, RIGHT_QUOTE, ARG, + ARGSIZE). */ +char *quotearg_custom_mem (char const *left_quote, + char const *right_quote, + char const *arg, size_t argsize); + +/* Free any dynamically allocated memory. */ +void quotearg_free (void); + +#endif /* !QUOTEARG_H_ */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/raise.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/raise.c new file mode 100644 index 00000000..891f355a --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/raise.c @@ -0,0 +1,83 @@ +/* Provide a non-threads replacement for the POSIX raise function. + + Copyright (C) 2002-2003, 2005-2006, 2009-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* written by Jim Meyering and Bruno Haible */ + +#include + +/* Specification. */ +#include + +#if HAVE_RAISE +/* Native Windows platform. */ + +# include + +# if HAVE_MSVC_INVALID_PARAMETER_HANDLER +# include "msvc-inval.h" +# endif + +# if HAVE_MSVC_INVALID_PARAMETER_HANDLER +/* Forward declaration. */ +static int raise_nothrow (int sig); +# else +# define raise_nothrow raise +# endif + +#else +/* An old Unix platform. */ + +# include + +#endif + +int +raise (int sig) +#undef raise +{ +#if GNULIB_defined_signal_blocking && GNULIB_defined_SIGPIPE + if (sig == SIGPIPE) + return _gl_raise_SIGPIPE (); +#endif + +#if HAVE_RAISE + return raise_nothrow (sig); +#else + return kill (getpid (), sig); +#endif +} + +#if HAVE_RAISE && HAVE_MSVC_INVALID_PARAMETER_HANDLER +static int +raise_nothrow (int sig) +{ + int result; + + TRY_MSVC_INVAL + { + result = raise (sig); + } + CATCH_MSVC_INVAL + { + result = -1; + errno = EINVAL; + } + DONE_MSVC_INVAL; + + return result; +} +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/rawmemchr.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/rawmemchr.c new file mode 100644 index 00000000..013e7f8c --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/rawmemchr.c @@ -0,0 +1,135 @@ +/* Searching in a string. + Copyright (C) 2008-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +/* A function definition is needed only if HAVE_RAWMEMCHR is not defined. */ +#if !HAVE_RAWMEMCHR + +# include +# include + + +/* Find the first occurrence of C in S. */ +void * +rawmemchr (const void *s, int c_in) +{ +# ifdef __CHERI_PURE_CAPABILITY__ + /* Most architectures let you read an aligned word, + even if the unsigned char array at S ends in the middle of the word. + However CHERI does not, so call memchr + with the underlying object's remaining length. + This cannot return NULL if S points to a C_IN-terminated array. + Use builtins rather than including which is less stable. */ + return memchr (s, c_in, (__builtin_cheri_length_get (s) + - __builtin_cheri_offset_get (s))); +# else + + /* You can change this typedef to experiment with performance. */ + typedef uintptr_t longword; + /* Verify that the longword type lacks padding bits. */ + static_assert (UINTPTR_WIDTH == UCHAR_WIDTH * sizeof (uintptr_t)); + + const unsigned char *char_ptr; + unsigned char c = c_in; + + /* Handle the first few bytes by reading one byte at a time. + Do this until CHAR_PTR is aligned on a natural longword boundary, + as using alignof (longword) might be slower. */ + for (char_ptr = (const unsigned char *) s; + (uintptr_t) char_ptr % sizeof (longword) != 0; + ++char_ptr) + if (*char_ptr == c) + return (void *) char_ptr; + + longword const *longword_ptr = s = char_ptr; + + /* Compute auxiliary longword values: + repeated_one is a value which has a 1 in every byte. + repeated_c has c in every byte. */ + longword repeated_one = (longword) -1 / UCHAR_MAX; + longword repeated_c = repeated_one * c; + longword repeated_hibit = repeated_one * (UCHAR_MAX / 2 + 1); + + /* Instead of the traditional loop which tests each byte, we will + test a longword at a time. The tricky part is testing if any of + the bytes in the longword in question are equal to + c. We first use an xor with repeated_c. This reduces the task + to testing whether any of the bytes in longword1 is zero. + + (The following comments assume 8-bit bytes, as POSIX requires; + the code's use of UCHAR_MAX should work even if bytes have more + than 8 bits.) + + We compute tmp = + ((longword1 - repeated_one) & ~longword1) & (repeated_one * 0x80). + That is, we perform the following operations: + 1. Subtract repeated_one. + 2. & ~longword1. + 3. & a mask consisting of 0x80 in every byte. + Consider what happens in each byte: + - If a byte of longword1 is zero, step 1 and 2 transform it into 0xff, + and step 3 transforms it into 0x80. A carry can also be propagated + to more significant bytes. + - If a byte of longword1 is nonzero, let its lowest 1 bit be at + position k (0 <= k <= 7); so the lowest k bits are 0. After step 1, + the byte ends in a single bit of value 0 and k bits of value 1. + After step 2, the result is just k bits of value 1: 2^k - 1. After + step 3, the result is 0. And no carry is produced. + So, if longword1 has only non-zero bytes, tmp is zero. + Whereas if longword1 has a zero byte, call j the position of the least + significant zero byte. Then the result has a zero at positions 0, ..., + j-1 and a 0x80 at position j. We cannot predict the result at the more + significant bytes (positions j+1..3), but it does not matter since we + already have a non-zero bit at position 8*j+7. + + The test whether any byte in longword1 is zero is equivalent + to testing whether tmp is nonzero. + + This test can read beyond the end of a string, depending on where + C_IN is encountered. However, this is considered safe since the + initialization phase ensured that the read will be aligned, + therefore, the read will not cross page boundaries and will not + cause a fault. */ + + while (1) + { + longword longword1 = *longword_ptr ^ repeated_c; + + if ((((longword1 - repeated_one) & ~longword1) & repeated_hibit) != 0) + break; + longword_ptr++; + } + + char_ptr = s = longword_ptr; + + /* At this point, we know that one of the sizeof (longword) bytes + starting at char_ptr is == c. If we knew endianness, we + could determine the first such byte without any further memory + accesses, just by looking at the tmp result from the last loop + iteration. However, the following simple and portable code does + not attempt this potential optimization. */ + + while (*char_ptr != c) + char_ptr++; + return (void *) char_ptr; +# endif +} + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/rawmemchr.valgrind b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/rawmemchr.valgrind new file mode 100644 index 00000000..bb201f73 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/rawmemchr.valgrind @@ -0,0 +1,28 @@ +# Suppress a valgrind message about use of uninitialized memory in rawmemchr(). + +# Copyright (C) 2008-2024 Free Software Foundation, Inc. +# +# This file is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as +# published by the Free Software Foundation; either version 2.1 of the +# License, or (at your option) any later version. +# +# This file is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this program. If not, see . + +# This use is OK because it provides only a speedup. +{ + rawmemchr-value4 + Memcheck:Value4 + fun:rawmemchr +} +{ + rawmemchr-value8 + Memcheck:Value8 + fun:rawmemchr +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/readdir.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/readdir.c new file mode 100644 index 00000000..fab19643 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/readdir.c @@ -0,0 +1,109 @@ +/* Read the next entry of a directory. + Copyright (C) 2011-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +#include +#include + +#if GNULIB_defined_DIR +# include "dirent-private.h" +#endif + +/* Don't assume that UNICODE is not defined. */ +#undef FindNextFile +#define FindNextFile FindNextFileA + +struct dirent * +readdir (DIR *dirp) +#undef readdir +{ +#if HAVE_DIRENT_H /* equivalent to HAVE_READDIR */ + return readdir (dirp->real_dirp); +#else + char type; + struct dirent *result; + + /* There is no need to add code to produce entries for "." and "..". + According to the POSIX:2008 section "4.12 Pathname Resolution" + + "." and ".." are syntactic entities. + POSIX also says: + "If entries for dot or dot-dot exist, one entry shall be returned + for dot and one entry shall be returned for dot-dot; otherwise, + they shall not be returned." */ + + switch (dirp->status) + { + case -2: + /* End of directory already reached. */ + return NULL; + case -1: + break; + case 0: + if (!FindNextFile (dirp->current, &dirp->entry)) + { + switch (GetLastError ()) + { + case ERROR_NO_MORE_FILES: + dirp->status = -2; + return NULL; + default: + errno = EIO; + return NULL; + } + } + break; + default: + errno = dirp->status; + return NULL; + } + + dirp->status = 0; + + if (dirp->entry.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) + type = DT_DIR; + else if (dirp->entry.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) + type = DT_LNK; + else if ((dirp->entry.dwFileAttributes + & ~(FILE_ATTRIBUTE_READONLY + | FILE_ATTRIBUTE_HIDDEN + | FILE_ATTRIBUTE_SYSTEM + | FILE_ATTRIBUTE_ARCHIVE + | FILE_ATTRIBUTE_NORMAL + | FILE_ATTRIBUTE_TEMPORARY + | FILE_ATTRIBUTE_SPARSE_FILE + | FILE_ATTRIBUTE_COMPRESSED + | FILE_ATTRIBUTE_NOT_CONTENT_INDEXED + | FILE_ATTRIBUTE_ENCRYPTED)) == 0) + /* Devices like COM1, LPT1, NUL would also have the attributes 0x20 but + they cannot occur here. */ + type = DT_REG; + else + type = DT_UNKNOWN; + + /* Reuse the memory of dirp->entry for the result. */ + result = + (struct dirent *) + ((char *) dirp->entry.cFileName - offsetof (struct dirent, d_name[0])); + result->d_type = type; + + return result; +#endif +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/readlink.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/readlink.c new file mode 100644 index 00000000..a5369fa9 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/readlink.c @@ -0,0 +1,104 @@ +/* Read the contents of a symbolic link. + Copyright (C) 2003-2007, 2009-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +#include +#include +#include + +#if !HAVE_READLINK + +/* readlink() substitute for systems that don't have a readlink() function, + such as DJGPP 2.03 and mingw32. */ + +ssize_t +readlink (char const *file, _GL_UNUSED char *buf, + _GL_UNUSED size_t bufsize) +{ + struct stat statbuf; + + /* In general we should use lstat() here, not stat(). But on platforms + without symbolic links, lstat() - if it exists - would be equivalent to + stat(), therefore we can use stat(). This saves us a configure check. */ + if (stat (file, &statbuf) >= 0) + errno = EINVAL; + return -1; +} + +#else /* HAVE_READLINK */ + +# undef readlink + +/* readlink() wrapper that uses correct types, for systems like cygwin + 1.5.x where readlink returns int, and which rejects trailing slash, + for Solaris 9. */ + +ssize_t +rpl_readlink (char const *file, char *buf, size_t bufsize) +{ +# if READLINK_TRAILING_SLASH_BUG + size_t file_len = strlen (file); + if (file_len && file[file_len - 1] == '/') + { + /* Even if FILE without the slash is a symlink to a directory, + both lstat() and stat() must resolve the trailing slash to + the directory rather than the symlink. We can therefore + safely use stat() to distinguish between EINVAL and + ENOTDIR/ENOENT, avoiding extra overhead of rpl_lstat(). */ + struct stat st; + if (stat (file, &st) == 0 || errno == EOVERFLOW) + errno = EINVAL; + return -1; + } +# endif /* READLINK_TRAILING_SLASH_BUG */ + + ssize_t r = readlink (file, buf, bufsize); + +# if READLINK_TRUNCATE_BUG + if (r < 0 && errno == ERANGE) + { + /* Try again with a bigger buffer. This is just for test cases; + real code invariably discards short reads. */ + char stackbuf[4032]; + r = readlink (file, stackbuf, sizeof stackbuf); + if (r < 0) + { + if (errno == ERANGE) + { + /* Clear the buffer, which is good enough for real code. + Thankfully, no test cases try short reads of enormous + symlinks and what would be the point anyway? */ + r = bufsize; + memset (buf, 0, r); + } + } + else + { + if (bufsize < r) + r = bufsize; + memcpy (buf, stackbuf, r); + } + } +# endif + + return r; +} + +#endif /* HAVE_READLINK */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/readlinkat.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/readlinkat.c new file mode 100644 index 00000000..faf85401 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/readlinkat.c @@ -0,0 +1,113 @@ +/* Read a symlink relative to an open directory. + Copyright (C) 2009-2024 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 . */ + +/* written by Eric Blake */ + +#include + +/* Specification. */ +#include + +#include +#include +#include +#include + +#if HAVE_READLINKAT + +# undef fstatat +# undef readlinkat + +ssize_t +rpl_readlinkat (int fd, char const *file, char *buf, size_t bufsize) +{ +# if READLINK_TRAILING_SLASH_BUG + size_t file_len = strlen (file); + if (file_len && file[file_len - 1] == '/') + { + /* Even if FILE without the slash is a symlink to a directory, + both lstat() and stat() must resolve the trailing slash to + the directory rather than the symlink. We can therefore + safely use fstatat(..., 0) to distinguish between EINVAL and + ENOTDIR/ENOENT, avoiding extra overhead of rpl_fstatat(). */ + struct stat st; + if (fstatat (fd, file, &st, 0) == 0 || errno == EOVERFLOW) + errno = EINVAL; + return -1; + } +# endif /* READLINK_TRAILING_SLASH_BUG */ + + ssize_t r = readlinkat (fd, file, buf, bufsize); + +# if READLINK_TRUNCATE_BUG + if (r < 0 && errno == ERANGE) + { + /* Try again with a bigger buffer. This is just for test cases; + real code invariably discards short reads. */ + char stackbuf[4032]; + r = readlinkat (fd, file, stackbuf, sizeof stackbuf); + if (r < 0) + { + if (errno == ERANGE) + { + /* Clear the buffer, which is good enough for real code. + Thankfully, no test cases try short reads of enormous + symlinks and what would be the point anyway? */ + r = bufsize; + memset (buf, 0, r); + } + } + else + { + if (bufsize < r) + r = bufsize; + memcpy (buf, stackbuf, r); + } + } +# endif + + return r; +} + +#else + +/* Gnulib provides a readlink stub for mingw; use it for distinction + between EINVAL and ENOENT, rather than always failing with ENOSYS. */ + +/* POSIX 2008 says that unlike readlink, readlinkat returns 0 for + success instead of the buffer length. But this would render + readlinkat worthless since readlink does not guarantee a + NUL-terminated buffer. Assume this was a bug in POSIX. */ + +/* Read the contents of symlink FILE into buffer BUF of size BUFSIZE, in the + directory open on descriptor FD. If possible, do it without changing + the working directory. Otherwise, resort to using save_cwd/fchdir, + then readlink/restore_cwd. If either the save_cwd or the restore_cwd + fails, then give a diagnostic and exit nonzero. */ + +# define AT_FUNC_NAME readlinkat +# define AT_FUNC_F1 readlink +# define AT_FUNC_POST_FILE_PARAM_DECLS , char *buf, size_t bufsize +# define AT_FUNC_POST_FILE_ARGS , buf, bufsize +# define AT_FUNC_RESULT ssize_t +# include "at-func.c" +# undef AT_FUNC_NAME +# undef AT_FUNC_F1 +# undef AT_FUNC_POST_FILE_PARAM_DECLS +# undef AT_FUNC_POST_FILE_ARGS +# undef AT_FUNC_RESULT + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/realloc.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/realloc.c new file mode 100644 index 00000000..05731396 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/realloc.c @@ -0,0 +1,63 @@ +/* realloc() function that is glibc compatible. + + Copyright (C) 1997, 2003-2004, 2006-2007, 2009-2024 Free Software + Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* written by Jim Meyering and Bruno Haible */ + +#include + +#include + +#include + +#include "xalloc-oversized.h" + +/* Call the system's realloc below. This file does not define + _GL_USE_STDLIB_ALLOC because it needs Gnulib's malloc if present. */ +#undef realloc + +/* Change the size of an allocated block of memory P to N bytes, + with error checking. If P is NULL, use malloc. Otherwise if N is zero, + free P and return NULL. */ + +void * +rpl_realloc (void *p, size_t n) +{ + if (p == NULL) + return malloc (n); + + if (n == 0) + { + free (p); + return NULL; + } + + if (xalloc_oversized (n, 1)) + { + errno = ENOMEM; + return NULL; + } + + void *result = realloc (p, n); + +#if !HAVE_MALLOC_POSIX + if (result == NULL) + errno = ENOMEM; +#endif + + return result; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/reallocarray.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/reallocarray.c new file mode 100644 index 00000000..09711a0e --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/reallocarray.c @@ -0,0 +1,38 @@ +/* reallocarray function that is glibc compatible. + + Copyright (C) 2017-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* written by Darshit Shah */ + +#include + +#include +#include +#include + +void * +reallocarray (void *ptr, size_t nmemb, size_t size) +{ + size_t nbytes; + if (ckd_mul (&nbytes, nmemb, size)) + { + errno = ENOMEM; + return NULL; + } + + /* Rely on the semantics of GNU realloc. */ + return realloc (ptr, nbytes); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/regcomp.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/regcomp.c new file mode 100644 index 00000000..696cf813 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/regcomp.c @@ -0,0 +1,3788 @@ +/* Extended regular expression matching and search library. + Copyright (C) 2002-2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Isamu Hasegawa . + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifdef _LIBC +# include +#endif + +static reg_errcode_t re_compile_internal (regex_t *preg, const char * pattern, + size_t length, reg_syntax_t syntax); +static void re_compile_fastmap_iter (regex_t *bufp, + const re_dfastate_t *init_state, + char *fastmap); +static reg_errcode_t init_dfa (re_dfa_t *dfa, size_t pat_len); +static void free_charset (re_charset_t *cset); +static void free_workarea_compile (regex_t *preg); +static reg_errcode_t create_initial_state (re_dfa_t *dfa); +static void optimize_utf8 (re_dfa_t *dfa); +static reg_errcode_t analyze (regex_t *preg); +static reg_errcode_t preorder (bin_tree_t *root, + reg_errcode_t (fn (void *, bin_tree_t *)), + void *extra); +static reg_errcode_t postorder (bin_tree_t *root, + reg_errcode_t (fn (void *, bin_tree_t *)), + void *extra); +static reg_errcode_t optimize_subexps (void *extra, bin_tree_t *node); +static reg_errcode_t lower_subexps (void *extra, bin_tree_t *node); +static bin_tree_t *lower_subexp (reg_errcode_t *err, regex_t *preg, + bin_tree_t *node); +static reg_errcode_t calc_first (void *extra, bin_tree_t *node); +static reg_errcode_t calc_next (void *extra, bin_tree_t *node); +static reg_errcode_t link_nfa_nodes (void *extra, bin_tree_t *node); +static Idx duplicate_node (re_dfa_t *dfa, Idx org_idx, unsigned int constraint); +static Idx search_duplicated_node (const re_dfa_t *dfa, Idx org_node, + unsigned int constraint); +static reg_errcode_t calc_eclosure (re_dfa_t *dfa); +static reg_errcode_t calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa, + Idx node, bool root); +static reg_errcode_t calc_inveclosure (re_dfa_t *dfa); +static Idx fetch_number (re_string_t *input, re_token_t *token, + reg_syntax_t syntax); +static int peek_token (re_token_t *token, re_string_t *input, + reg_syntax_t syntax); +static bin_tree_t *parse (re_string_t *regexp, regex_t *preg, + reg_syntax_t syntax, reg_errcode_t *err); +static bin_tree_t *parse_reg_exp (re_string_t *regexp, regex_t *preg, + re_token_t *token, reg_syntax_t syntax, + Idx nest, reg_errcode_t *err); +static bin_tree_t *parse_branch (re_string_t *regexp, regex_t *preg, + re_token_t *token, reg_syntax_t syntax, + Idx nest, reg_errcode_t *err); +static bin_tree_t *parse_expression (re_string_t *regexp, regex_t *preg, + re_token_t *token, reg_syntax_t syntax, + Idx nest, reg_errcode_t *err); +static bin_tree_t *parse_sub_exp (re_string_t *regexp, regex_t *preg, + re_token_t *token, reg_syntax_t syntax, + Idx nest, reg_errcode_t *err); +static bin_tree_t *parse_dup_op (bin_tree_t *dup_elem, re_string_t *regexp, + re_dfa_t *dfa, re_token_t *token, + reg_syntax_t syntax, reg_errcode_t *err); +static bin_tree_t *parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, + re_token_t *token, reg_syntax_t syntax, + reg_errcode_t *err); +static reg_errcode_t parse_bracket_element (bracket_elem_t *elem, + re_string_t *regexp, + re_token_t *token, int token_len, + re_dfa_t *dfa, + reg_syntax_t syntax, + bool accept_hyphen); +static reg_errcode_t parse_bracket_symbol (bracket_elem_t *elem, + re_string_t *regexp, + re_token_t *token); +static reg_errcode_t build_equiv_class (bitset_t sbcset, + re_charset_t *mbcset, + Idx *equiv_class_alloc, + const unsigned char *name); +static reg_errcode_t build_charclass (RE_TRANSLATE_TYPE trans, + bitset_t sbcset, + re_charset_t *mbcset, + Idx *char_class_alloc, + const char *class_name, + reg_syntax_t syntax); +static bin_tree_t *build_charclass_op (re_dfa_t *dfa, + RE_TRANSLATE_TYPE trans, + const char *class_name, + const char *extra, + bool non_match, reg_errcode_t *err); +static bin_tree_t *create_tree (re_dfa_t *dfa, + bin_tree_t *left, bin_tree_t *right, + re_token_type_t type); +static bin_tree_t *create_token_tree (re_dfa_t *dfa, + bin_tree_t *left, bin_tree_t *right, + const re_token_t *token); +static bin_tree_t *duplicate_tree (const bin_tree_t *src, re_dfa_t *dfa); +static void free_token (re_token_t *node); +static reg_errcode_t free_tree (void *extra, bin_tree_t *node); +static reg_errcode_t mark_opt_subexp (void *extra, bin_tree_t *node); + +/* This table gives an error message for each of the error codes listed + in regex.h. Obviously the order here has to be same as there. + POSIX doesn't require that we do anything for REG_NOERROR, + but why not be nice? */ + +static const char __re_error_msgid[] = + { +#define REG_NOERROR_IDX 0 + gettext_noop ("Success") /* REG_NOERROR */ + "\0" +#define REG_NOMATCH_IDX (REG_NOERROR_IDX + sizeof "Success") + gettext_noop ("No match") /* REG_NOMATCH */ + "\0" +#define REG_BADPAT_IDX (REG_NOMATCH_IDX + sizeof "No match") + gettext_noop ("Invalid regular expression") /* REG_BADPAT */ + "\0" +#define REG_ECOLLATE_IDX (REG_BADPAT_IDX + sizeof "Invalid regular expression") + gettext_noop ("Invalid collation character") /* REG_ECOLLATE */ + "\0" +#define REG_ECTYPE_IDX (REG_ECOLLATE_IDX + sizeof "Invalid collation character") + gettext_noop ("Invalid character class name") /* REG_ECTYPE */ + "\0" +#define REG_EESCAPE_IDX (REG_ECTYPE_IDX + sizeof "Invalid character class name") + gettext_noop ("Trailing backslash") /* REG_EESCAPE */ + "\0" +#define REG_ESUBREG_IDX (REG_EESCAPE_IDX + sizeof "Trailing backslash") + gettext_noop ("Invalid back reference") /* REG_ESUBREG */ + "\0" +#define REG_EBRACK_IDX (REG_ESUBREG_IDX + sizeof "Invalid back reference") + gettext_noop ("Unmatched [, [^, [:, [., or [=") /* REG_EBRACK */ + "\0" +#define REG_EPAREN_IDX (REG_EBRACK_IDX + sizeof "Unmatched [, [^, [:, [., or [=") + gettext_noop ("Unmatched ( or \\(") /* REG_EPAREN */ + "\0" +#define REG_EBRACE_IDX (REG_EPAREN_IDX + sizeof "Unmatched ( or \\(") + gettext_noop ("Unmatched \\{") /* REG_EBRACE */ + "\0" +#define REG_BADBR_IDX (REG_EBRACE_IDX + sizeof "Unmatched \\{") + gettext_noop ("Invalid content of \\{\\}") /* REG_BADBR */ + "\0" +#define REG_ERANGE_IDX (REG_BADBR_IDX + sizeof "Invalid content of \\{\\}") + gettext_noop ("Invalid range end") /* REG_ERANGE */ + "\0" +#define REG_ESPACE_IDX (REG_ERANGE_IDX + sizeof "Invalid range end") + gettext_noop ("Memory exhausted") /* REG_ESPACE */ + "\0" +#define REG_BADRPT_IDX (REG_ESPACE_IDX + sizeof "Memory exhausted") + gettext_noop ("Invalid preceding regular expression") /* REG_BADRPT */ + "\0" +#define REG_EEND_IDX (REG_BADRPT_IDX + sizeof "Invalid preceding regular expression") + gettext_noop ("Premature end of regular expression") /* REG_EEND */ + "\0" +#define REG_ESIZE_IDX (REG_EEND_IDX + sizeof "Premature end of regular expression") + gettext_noop ("Regular expression too big") /* REG_ESIZE */ + "\0" +#define REG_ERPAREN_IDX (REG_ESIZE_IDX + sizeof "Regular expression too big") + gettext_noop ("Unmatched ) or \\)") /* REG_ERPAREN */ + }; + +static const size_t __re_error_msgid_idx[] = + { + REG_NOERROR_IDX, + REG_NOMATCH_IDX, + REG_BADPAT_IDX, + REG_ECOLLATE_IDX, + REG_ECTYPE_IDX, + REG_EESCAPE_IDX, + REG_ESUBREG_IDX, + REG_EBRACK_IDX, + REG_EPAREN_IDX, + REG_EBRACE_IDX, + REG_BADBR_IDX, + REG_ERANGE_IDX, + REG_ESPACE_IDX, + REG_BADRPT_IDX, + REG_EEND_IDX, + REG_ESIZE_IDX, + REG_ERPAREN_IDX + }; + +/* Entry points for GNU code. */ + +/* re_compile_pattern is the GNU regular expression compiler: it + compiles PATTERN (of length LENGTH) and puts the result in BUFP. + Returns 0 if the pattern was valid, otherwise an error string. + + Assumes the 'allocated' (and perhaps 'buffer') and 'translate' fields + are set in BUFP on entry. */ + +const char * +re_compile_pattern (const char *pattern, size_t length, + struct re_pattern_buffer *bufp) +{ + reg_errcode_t ret; + + /* And GNU code determines whether or not to get register information + by passing null for the REGS argument to re_match, etc., not by + setting no_sub, unless RE_NO_SUB is set. */ + bufp->no_sub = !!(re_syntax_options & RE_NO_SUB); + + /* Match anchors at newline. */ + bufp->newline_anchor = 1; + + ret = re_compile_internal (bufp, pattern, length, re_syntax_options); + + if (!ret) + return NULL; + return gettext (__re_error_msgid + __re_error_msgid_idx[(int) ret]); +} +weak_alias (__re_compile_pattern, re_compile_pattern) + +/* Set by 're_set_syntax' to the current regexp syntax to recognize. Can + also be assigned to arbitrarily: each pattern buffer stores its own + syntax, so it can be changed between regex compilations. */ +/* This has no initializer because initialized variables in Emacs + become read-only after dumping. */ +reg_syntax_t re_syntax_options; + + +/* Specify the precise syntax of regexps for compilation. This provides + for compatibility for various utilities which historically have + different, incompatible syntaxes. + + The argument SYNTAX is a bit mask comprised of the various bits + defined in regex.h. We return the old syntax. */ + +reg_syntax_t +re_set_syntax (reg_syntax_t syntax) +{ + reg_syntax_t ret = re_syntax_options; + + re_syntax_options = syntax; + return ret; +} +weak_alias (__re_set_syntax, re_set_syntax) + +int +re_compile_fastmap (struct re_pattern_buffer *bufp) +{ + re_dfa_t *dfa = bufp->buffer; + char *fastmap = bufp->fastmap; + + memset (fastmap, '\0', sizeof (char) * SBC_MAX); + re_compile_fastmap_iter (bufp, dfa->init_state, fastmap); + if (dfa->init_state != dfa->init_state_word) + re_compile_fastmap_iter (bufp, dfa->init_state_word, fastmap); + if (dfa->init_state != dfa->init_state_nl) + re_compile_fastmap_iter (bufp, dfa->init_state_nl, fastmap); + if (dfa->init_state != dfa->init_state_begbuf) + re_compile_fastmap_iter (bufp, dfa->init_state_begbuf, fastmap); + bufp->fastmap_accurate = 1; + return 0; +} +weak_alias (__re_compile_fastmap, re_compile_fastmap) + +static __always_inline void +re_set_fastmap (char *fastmap, bool icase, int ch) +{ + fastmap[ch] = 1; + if (icase) + fastmap[tolower (ch)] = 1; +} + +/* Helper function for re_compile_fastmap. + Compile fastmap for the initial_state INIT_STATE. */ + +static void +re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state, + char *fastmap) +{ + re_dfa_t *dfa = bufp->buffer; + Idx node_cnt; + bool icase = (dfa->mb_cur_max == 1 && (bufp->syntax & RE_ICASE)); + for (node_cnt = 0; node_cnt < init_state->nodes.nelem; ++node_cnt) + { + Idx node = init_state->nodes.elems[node_cnt]; + re_token_type_t type = dfa->nodes[node].type; + + if (type == CHARACTER) + { + re_set_fastmap (fastmap, icase, dfa->nodes[node].opr.c); + if ((bufp->syntax & RE_ICASE) && dfa->mb_cur_max > 1) + { + unsigned char buf[MB_LEN_MAX]; + unsigned char *p; + wchar_t wc; + mbstate_t state; + + p = buf; + *p++ = dfa->nodes[node].opr.c; + while (++node < dfa->nodes_len + && dfa->nodes[node].type == CHARACTER + && dfa->nodes[node].mb_partial) + *p++ = dfa->nodes[node].opr.c; + memset (&state, '\0', sizeof (state)); + if (__mbrtowc (&wc, (const char *) buf, p - buf, + &state) == p - buf + && (__wcrtomb ((char *) buf, __towlower (wc), &state) + != (size_t) -1)) + re_set_fastmap (fastmap, false, buf[0]); + } + } + else if (type == SIMPLE_BRACKET) + { + int i, ch; + for (i = 0, ch = 0; i < BITSET_WORDS; ++i) + { + int j; + bitset_word_t w = dfa->nodes[node].opr.sbcset[i]; + for (j = 0; j < BITSET_WORD_BITS; ++j, ++ch) + if (w & ((bitset_word_t) 1 << j)) + re_set_fastmap (fastmap, icase, ch); + } + } + else if (type == COMPLEX_BRACKET) + { + re_charset_t *cset = dfa->nodes[node].opr.mbcset; + Idx i; + +#ifdef _LIBC + /* See if we have to try all bytes which start multiple collation + elements. + e.g. In da_DK, we want to catch 'a' since "aa" is a valid + collation element, and don't catch 'b' since 'b' is + the only collation element which starts from 'b' (and + it is caught by SIMPLE_BRACKET). */ + if (_NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES) != 0 + && (cset->ncoll_syms || cset->nranges)) + { + const int32_t *table = (const int32_t *) + _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB); + for (i = 0; i < SBC_MAX; ++i) + if (table[i] < 0) + re_set_fastmap (fastmap, icase, i); + } +#endif /* _LIBC */ + + /* See if we have to start the match at all multibyte characters, + i.e. where we would not find an invalid sequence. This only + applies to multibyte character sets; for single byte character + sets, the SIMPLE_BRACKET again suffices. */ + if (dfa->mb_cur_max > 1 + && (cset->nchar_classes || cset->non_match || cset->nranges +#ifdef _LIBC + || cset->nequiv_classes +#endif /* _LIBC */ + )) + { + unsigned char c = 0; + do + { + mbstate_t mbs; + memset (&mbs, 0, sizeof (mbs)); + if (__mbrtowc (NULL, (char *) &c, 1, &mbs) == (size_t) -2) + re_set_fastmap (fastmap, false, (int) c); + } + while (++c != 0); + } + + else + { + /* ... Else catch all bytes which can start the mbchars. */ + for (i = 0; i < cset->nmbchars; ++i) + { + char buf[256]; + mbstate_t state; + memset (&state, '\0', sizeof (state)); + if (__wcrtomb (buf, cset->mbchars[i], &state) != (size_t) -1) + re_set_fastmap (fastmap, icase, *(unsigned char *) buf); + if ((bufp->syntax & RE_ICASE) && dfa->mb_cur_max > 1) + { + if (__wcrtomb (buf, __towlower (cset->mbchars[i]), &state) + != (size_t) -1) + re_set_fastmap (fastmap, false, *(unsigned char *) buf); + } + } + } + } + else if (type == OP_PERIOD || type == OP_UTF8_PERIOD || type == END_OF_RE) + { + memset (fastmap, '\1', sizeof (char) * SBC_MAX); + if (type == END_OF_RE) + bufp->can_be_null = 1; + return; + } + } +} + +/* Entry point for POSIX code. */ +/* regcomp takes a regular expression as a string and compiles it. + + PREG is a regex_t *. We do not expect any fields to be initialized, + since POSIX says we shouldn't. Thus, we set + + 'buffer' to the compiled pattern; + 'used' to the length of the compiled pattern; + 'syntax' to RE_SYNTAX_POSIX_EXTENDED if the + REG_EXTENDED bit in CFLAGS is set; otherwise, to + RE_SYNTAX_POSIX_BASIC; + 'newline_anchor' to REG_NEWLINE being set in CFLAGS; + 'fastmap' to an allocated space for the fastmap; + 'fastmap_accurate' to zero; + 're_nsub' to the number of subexpressions in PATTERN. + + PATTERN is the address of the pattern string. + + CFLAGS is a series of bits which affect compilation. + + If REG_EXTENDED is set, we use POSIX extended syntax; otherwise, we + use POSIX basic syntax. + + If REG_NEWLINE is set, then . and [^...] don't match newline. + Also, regexec will try a match beginning after every newline. + + If REG_ICASE is set, then we considers upper- and lowercase + versions of letters to be equivalent when matching. + + If REG_NOSUB is set, then when PREG is passed to regexec, that + routine will report only success or failure, and nothing about the + registers. + + It returns 0 if it succeeds, nonzero if it doesn't. (See regex.h for + the return codes and their meanings.) */ + +int +regcomp (regex_t *__restrict preg, const char *__restrict pattern, int cflags) +{ + reg_errcode_t ret; + reg_syntax_t syntax = ((cflags & REG_EXTENDED) ? RE_SYNTAX_POSIX_EXTENDED + : RE_SYNTAX_POSIX_BASIC); + + preg->buffer = NULL; + preg->allocated = 0; + preg->used = 0; + + /* Try to allocate space for the fastmap. */ + preg->fastmap = re_malloc (char, SBC_MAX); + if (__glibc_unlikely (preg->fastmap == NULL)) + return REG_ESPACE; + + syntax |= (cflags & REG_ICASE) ? RE_ICASE : 0; + + /* If REG_NEWLINE is set, newlines are treated differently. */ + if (cflags & REG_NEWLINE) + { /* REG_NEWLINE implies neither . nor [^...] match newline. */ + syntax &= ~RE_DOT_NEWLINE; + syntax |= RE_HAT_LISTS_NOT_NEWLINE; + /* It also changes the matching behavior. */ + preg->newline_anchor = 1; + } + else + preg->newline_anchor = 0; + preg->no_sub = !!(cflags & REG_NOSUB); + preg->translate = NULL; + + ret = re_compile_internal (preg, pattern, strlen (pattern), syntax); + + /* POSIX doesn't distinguish between an unmatched open-group and an + unmatched close-group: both are REG_EPAREN. */ + if (ret == REG_ERPAREN) + ret = REG_EPAREN; + + /* We have already checked preg->fastmap != NULL. */ + if (__glibc_likely (ret == REG_NOERROR)) + /* Compute the fastmap now, since regexec cannot modify the pattern + buffer. This function never fails in this implementation. */ + (void) re_compile_fastmap (preg); + else + { + /* Some error occurred while compiling the expression. */ + re_free (preg->fastmap); + preg->fastmap = NULL; + } + + return (int) ret; +} +libc_hidden_def (__regcomp) +weak_alias (__regcomp, regcomp) + +/* Returns a message corresponding to an error code, ERRCODE, returned + from either regcomp or regexec. We don't use PREG here. */ + +size_t +regerror (int errcode, const regex_t *__restrict preg, char *__restrict errbuf, + size_t errbuf_size) +{ + const char *msg; + size_t msg_size; + int nerrcodes = sizeof __re_error_msgid_idx / sizeof __re_error_msgid_idx[0]; + + if (__glibc_unlikely (errcode < 0 || errcode >= nerrcodes)) + /* Only error codes returned by the rest of the code should be passed + to this routine. If we are given anything else, or if other regex + code generates an invalid error code, then the program has a bug. + Dump core so we can fix it. */ + abort (); + + msg = gettext (__re_error_msgid + __re_error_msgid_idx[errcode]); + + msg_size = strlen (msg) + 1; /* Includes the null. */ + + if (__glibc_likely (errbuf_size != 0)) + { + size_t cpy_size = msg_size; + if (__glibc_unlikely (msg_size > errbuf_size)) + { + cpy_size = errbuf_size - 1; + errbuf[cpy_size] = '\0'; + } + memcpy (errbuf, msg, cpy_size); + } + + return msg_size; +} +weak_alias (__regerror, regerror) + + +/* This static array is used for the map to single-byte characters when + UTF-8 is used. Otherwise we would allocate memory just to initialize + it the same all the time. UTF-8 is the preferred encoding so this is + a worthwhile optimization. */ +static const bitset_t utf8_sb_map = +{ + /* Set the first 128 bits. */ +#if (defined __GNUC__ || __clang_major__ >= 4) && !defined __STRICT_ANSI__ + [0 ... 0x80 / BITSET_WORD_BITS - 1] = BITSET_WORD_MAX +#else +# if 4 * BITSET_WORD_BITS < ASCII_CHARS +# error "bitset_word_t is narrower than 32 bits" +# elif 3 * BITSET_WORD_BITS < ASCII_CHARS + BITSET_WORD_MAX, BITSET_WORD_MAX, BITSET_WORD_MAX, +# elif 2 * BITSET_WORD_BITS < ASCII_CHARS + BITSET_WORD_MAX, BITSET_WORD_MAX, +# elif 1 * BITSET_WORD_BITS < ASCII_CHARS + BITSET_WORD_MAX, +# endif + (BITSET_WORD_MAX + >> (SBC_MAX % BITSET_WORD_BITS == 0 + ? 0 + : BITSET_WORD_BITS - SBC_MAX % BITSET_WORD_BITS)) +#endif +}; + + +static void +free_dfa_content (re_dfa_t *dfa) +{ + Idx i, j; + + if (dfa->nodes) + for (i = 0; i < dfa->nodes_len; ++i) + free_token (dfa->nodes + i); + re_free (dfa->nexts); + for (i = 0; i < dfa->nodes_len; ++i) + { + if (dfa->eclosures != NULL) + re_node_set_free (dfa->eclosures + i); + if (dfa->inveclosures != NULL) + re_node_set_free (dfa->inveclosures + i); + if (dfa->edests != NULL) + re_node_set_free (dfa->edests + i); + } + re_free (dfa->edests); + re_free (dfa->eclosures); + re_free (dfa->inveclosures); + re_free (dfa->nodes); + + if (dfa->state_table) + for (i = 0; i <= dfa->state_hash_mask; ++i) + { + struct re_state_table_entry *entry = dfa->state_table + i; + for (j = 0; j < entry->num; ++j) + { + re_dfastate_t *state = entry->array[j]; + free_state (state); + } + re_free (entry->array); + } + re_free (dfa->state_table); + if (dfa->sb_char != utf8_sb_map) + re_free (dfa->sb_char); + re_free (dfa->subexp_map); +#ifdef DEBUG + re_free (dfa->re_str); +#endif + + re_free (dfa); +} + + +/* Free dynamically allocated space used by PREG. */ + +void +regfree (regex_t *preg) +{ + re_dfa_t *dfa = preg->buffer; + if (__glibc_likely (dfa != NULL)) + { + lock_fini (dfa->lock); + free_dfa_content (dfa); + } + preg->buffer = NULL; + preg->allocated = 0; + + re_free (preg->fastmap); + preg->fastmap = NULL; + + re_free (preg->translate); + preg->translate = NULL; +} +libc_hidden_def (__regfree) +weak_alias (__regfree, regfree) + +/* Entry points compatible with 4.2 BSD regex library. We don't define + them unless specifically requested. */ + +#if defined _REGEX_RE_COMP || defined _LIBC + +/* BSD has one and only one pattern buffer. */ +static struct re_pattern_buffer re_comp_buf; + +char * +# ifdef _LIBC +/* Make these definitions weak in libc, so POSIX programs can redefine + these names if they don't use our functions, and still use + regcomp/regexec above without link errors. */ +weak_function +# endif +re_comp (const char *s) +{ + reg_errcode_t ret; + char *fastmap; + + if (!s) + { + if (!re_comp_buf.buffer) + return gettext ("No previous regular expression"); + return 0; + } + + if (re_comp_buf.buffer) + { + fastmap = re_comp_buf.fastmap; + re_comp_buf.fastmap = NULL; + __regfree (&re_comp_buf); + memset (&re_comp_buf, '\0', sizeof (re_comp_buf)); + re_comp_buf.fastmap = fastmap; + } + + if (re_comp_buf.fastmap == NULL) + { + re_comp_buf.fastmap = re_malloc (char, SBC_MAX); + if (re_comp_buf.fastmap == NULL) + return (char *) gettext (__re_error_msgid + + __re_error_msgid_idx[(int) REG_ESPACE]); + } + + /* Since 're_exec' always passes NULL for the 'regs' argument, we + don't need to initialize the pattern buffer fields which affect it. */ + + /* Match anchors at newlines. */ + re_comp_buf.newline_anchor = 1; + + ret = re_compile_internal (&re_comp_buf, s, strlen (s), re_syntax_options); + + if (!ret) + return NULL; + + /* Yes, we're discarding 'const' here if !HAVE_LIBINTL. */ + return (char *) gettext (__re_error_msgid + __re_error_msgid_idx[(int) ret]); +} + +#ifdef _LIBC +libc_freeres_fn (free_mem) +{ + __regfree (&re_comp_buf); +} +#endif + +#endif /* _REGEX_RE_COMP */ + +/* Internal entry point. + Compile the regular expression PATTERN, whose length is LENGTH. + SYNTAX indicate regular expression's syntax. */ + +static reg_errcode_t +re_compile_internal (regex_t *preg, const char * pattern, size_t length, + reg_syntax_t syntax) +{ + reg_errcode_t err = REG_NOERROR; + re_dfa_t *dfa; + re_string_t regexp; + + /* Initialize the pattern buffer. */ + preg->fastmap_accurate = 0; + preg->syntax = syntax; + preg->not_bol = preg->not_eol = 0; + preg->used = 0; + preg->re_nsub = 0; + preg->can_be_null = 0; + preg->regs_allocated = REGS_UNALLOCATED; + + /* Initialize the dfa. */ + dfa = preg->buffer; + if (__glibc_unlikely (preg->allocated < sizeof (re_dfa_t))) + { + /* If zero allocated, but buffer is non-null, try to realloc + enough space. This loses if buffer's address is bogus, but + that is the user's responsibility. If ->buffer is NULL this + is a simple allocation. */ + dfa = re_realloc (preg->buffer, re_dfa_t, 1); + if (dfa == NULL) + return REG_ESPACE; + preg->allocated = sizeof (re_dfa_t); + preg->buffer = dfa; + } + preg->used = sizeof (re_dfa_t); + + err = init_dfa (dfa, length); + if (__glibc_unlikely (err == REG_NOERROR && lock_init (dfa->lock) != 0)) + err = REG_ESPACE; + if (__glibc_unlikely (err != REG_NOERROR)) + { + free_dfa_content (dfa); + preg->buffer = NULL; + preg->allocated = 0; + return err; + } +#ifdef DEBUG + /* Note: length+1 will not overflow since it is checked in init_dfa. */ + dfa->re_str = re_malloc (char, length + 1); + strncpy (dfa->re_str, pattern, length + 1); +#endif + + err = re_string_construct (®exp, pattern, length, preg->translate, + (syntax & RE_ICASE) != 0, dfa); + if (__glibc_unlikely (err != REG_NOERROR)) + { + re_compile_internal_free_return: + free_workarea_compile (preg); + re_string_destruct (®exp); + lock_fini (dfa->lock); + free_dfa_content (dfa); + preg->buffer = NULL; + preg->allocated = 0; + return err; + } + + /* Parse the regular expression, and build a structure tree. */ + preg->re_nsub = 0; + dfa->str_tree = parse (®exp, preg, syntax, &err); + if (__glibc_unlikely (dfa->str_tree == NULL)) + goto re_compile_internal_free_return; + + /* Analyze the tree and create the nfa. */ + err = analyze (preg); + if (__glibc_unlikely (err != REG_NOERROR)) + goto re_compile_internal_free_return; + + /* If possible, do searching in single byte encoding to speed things up. */ + if (dfa->is_utf8 && !(syntax & RE_ICASE) && preg->translate == NULL) + optimize_utf8 (dfa); + + /* Then create the initial state of the dfa. */ + err = create_initial_state (dfa); + + /* Release work areas. */ + free_workarea_compile (preg); + re_string_destruct (®exp); + + if (__glibc_unlikely (err != REG_NOERROR)) + { + lock_fini (dfa->lock); + free_dfa_content (dfa); + preg->buffer = NULL; + preg->allocated = 0; + } + + return err; +} + +/* Initialize DFA. We use the length of the regular expression PAT_LEN + as the initial length of some arrays. */ + +static reg_errcode_t +init_dfa (re_dfa_t *dfa, size_t pat_len) +{ + __re_size_t table_size; +#ifndef _LIBC + const char *codeset_name; +#endif + size_t max_i18n_object_size = MAX (sizeof (wchar_t), sizeof (wctype_t)); + size_t max_object_size = + MAX (sizeof (struct re_state_table_entry), + MAX (sizeof (re_token_t), + MAX (sizeof (re_node_set), + MAX (sizeof (regmatch_t), + max_i18n_object_size)))); + + memset (dfa, '\0', sizeof (re_dfa_t)); + + /* Force allocation of str_tree_storage the first time. */ + dfa->str_tree_storage_idx = BIN_TREE_STORAGE_SIZE; + + /* Avoid overflows. The extra "/ 2" is for the table_size doubling + calculation below, and for similar doubling calculations + elsewhere. And it's <= rather than <, because some of the + doubling calculations add 1 afterwards. */ + if (__glibc_unlikely (MIN (IDX_MAX, SIZE_MAX / max_object_size) / 2 + <= pat_len)) + return REG_ESPACE; + + dfa->nodes_alloc = pat_len + 1; + dfa->nodes = re_malloc (re_token_t, dfa->nodes_alloc); + + /* table_size = 2 ^ ceil(log pat_len) */ + for (table_size = 1; ; table_size <<= 1) + if (table_size > pat_len) + break; + + dfa->state_table = calloc (sizeof (struct re_state_table_entry), table_size); + dfa->state_hash_mask = table_size - 1; + + dfa->mb_cur_max = MB_CUR_MAX; +#ifdef _LIBC + if (dfa->mb_cur_max == 6 + && strcmp (_NL_CURRENT (LC_CTYPE, _NL_CTYPE_CODESET_NAME), "UTF-8") == 0) + dfa->is_utf8 = 1; + dfa->map_notascii = (_NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_MAP_TO_NONASCII) + != 0); +#else + codeset_name = nl_langinfo (CODESET); + if ((codeset_name[0] == 'U' || codeset_name[0] == 'u') + && (codeset_name[1] == 'T' || codeset_name[1] == 't') + && (codeset_name[2] == 'F' || codeset_name[2] == 'f') + && strcmp (codeset_name + 3 + (codeset_name[3] == '-'), "8") == 0) + dfa->is_utf8 = 1; + + /* We check exhaustively in the loop below if this charset is a + superset of ASCII. */ + dfa->map_notascii = 0; +#endif + + if (dfa->mb_cur_max > 1) + { + if (dfa->is_utf8) + dfa->sb_char = (re_bitset_ptr_t) utf8_sb_map; + else + { + int i, j, ch; + + dfa->sb_char = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1); + if (__glibc_unlikely (dfa->sb_char == NULL)) + return REG_ESPACE; + + /* Set the bits corresponding to single byte chars. */ + for (i = 0, ch = 0; i < BITSET_WORDS; ++i) + for (j = 0; j < BITSET_WORD_BITS; ++j, ++ch) + { + wint_t wch = __btowc (ch); + if (wch != WEOF) + dfa->sb_char[i] |= (bitset_word_t) 1 << j; +#ifndef _LIBC + if (isascii (ch) && wch != ch) + dfa->map_notascii = 1; +#endif + } + } + } + + if (__glibc_unlikely (dfa->nodes == NULL || dfa->state_table == NULL)) + return REG_ESPACE; + return REG_NOERROR; +} + +/* Initialize WORD_CHAR table, which indicate which character is + "word". In this case "word" means that it is the word construction + character used by some operators like "\<", "\>", etc. */ + +static void +init_word_char (re_dfa_t *dfa) +{ + int i = 0; + int j; + int ch = 0; + dfa->word_ops_used = 1; + if (__glibc_likely (dfa->map_notascii == 0)) + { + bitset_word_t bits0 = 0x00000000; + bitset_word_t bits1 = 0x03ff0000; + bitset_word_t bits2 = 0x87fffffe; + bitset_word_t bits3 = 0x07fffffe; + if (BITSET_WORD_BITS == 64) + { + /* Pacify gcc -Woverflow on 32-bit platforms. */ + dfa->word_char[0] = bits1 << 31 << 1 | bits0; + dfa->word_char[1] = bits3 << 31 << 1 | bits2; + i = 2; + } + else if (BITSET_WORD_BITS == 32) + { + dfa->word_char[0] = bits0; + dfa->word_char[1] = bits1; + dfa->word_char[2] = bits2; + dfa->word_char[3] = bits3; + i = 4; + } + else + goto general_case; + ch = 128; + + if (__glibc_likely (dfa->is_utf8)) + { + memset (&dfa->word_char[i], '\0', (SBC_MAX - ch) / 8); + return; + } + } + + general_case: + for (; i < BITSET_WORDS; ++i) + for (j = 0; j < BITSET_WORD_BITS; ++j, ++ch) + if (isalnum (ch) || ch == '_') + dfa->word_char[i] |= (bitset_word_t) 1 << j; +} + +/* Free the work area which are only used while compiling. */ + +static void +free_workarea_compile (regex_t *preg) +{ + re_dfa_t *dfa = preg->buffer; + bin_tree_storage_t *storage, *next; + for (storage = dfa->str_tree_storage; storage; storage = next) + { + next = storage->next; + re_free (storage); + } + dfa->str_tree_storage = NULL; + dfa->str_tree_storage_idx = BIN_TREE_STORAGE_SIZE; + dfa->str_tree = NULL; + re_free (dfa->org_indices); + dfa->org_indices = NULL; +} + +/* Create initial states for all contexts. */ + +static reg_errcode_t +create_initial_state (re_dfa_t *dfa) +{ + Idx first, i; + reg_errcode_t err; + re_node_set init_nodes; + + /* Initial states have the epsilon closure of the node which is + the first node of the regular expression. */ + first = dfa->str_tree->first->node_idx; + dfa->init_node = first; + err = re_node_set_init_copy (&init_nodes, dfa->eclosures + first); + if (__glibc_unlikely (err != REG_NOERROR)) + return err; + + /* The back-references which are in initial states can epsilon transit, + since in this case all of the subexpressions can be null. + Then we add epsilon closures of the nodes which are the next nodes of + the back-references. */ + if (dfa->nbackref > 0) + for (i = 0; i < init_nodes.nelem; ++i) + { + Idx node_idx = init_nodes.elems[i]; + re_token_type_t type = dfa->nodes[node_idx].type; + + Idx clexp_idx; + if (type != OP_BACK_REF) + continue; + for (clexp_idx = 0; clexp_idx < init_nodes.nelem; ++clexp_idx) + { + re_token_t *clexp_node; + clexp_node = dfa->nodes + init_nodes.elems[clexp_idx]; + if (clexp_node->type == OP_CLOSE_SUBEXP + && clexp_node->opr.idx == dfa->nodes[node_idx].opr.idx) + break; + } + if (clexp_idx == init_nodes.nelem) + continue; + + if (type == OP_BACK_REF) + { + Idx dest_idx = dfa->edests[node_idx].elems[0]; + if (!re_node_set_contains (&init_nodes, dest_idx)) + { + reg_errcode_t merge_err + = re_node_set_merge (&init_nodes, dfa->eclosures + dest_idx); + if (merge_err != REG_NOERROR) + return merge_err; + i = 0; + } + } + } + + /* It must be the first time to invoke acquire_state. */ + dfa->init_state = re_acquire_state_context (&err, dfa, &init_nodes, 0); + /* We don't check ERR here, since the initial state must not be NULL. */ + if (__glibc_unlikely (dfa->init_state == NULL)) + return err; + if (dfa->init_state->has_constraint) + { + dfa->init_state_word = re_acquire_state_context (&err, dfa, &init_nodes, + CONTEXT_WORD); + dfa->init_state_nl = re_acquire_state_context (&err, dfa, &init_nodes, + CONTEXT_NEWLINE); + dfa->init_state_begbuf = re_acquire_state_context (&err, dfa, + &init_nodes, + CONTEXT_NEWLINE + | CONTEXT_BEGBUF); + if (__glibc_unlikely (dfa->init_state_word == NULL + || dfa->init_state_nl == NULL + || dfa->init_state_begbuf == NULL)) + return err; + } + else + dfa->init_state_word = dfa->init_state_nl + = dfa->init_state_begbuf = dfa->init_state; + + re_node_set_free (&init_nodes); + return REG_NOERROR; +} + +/* If it is possible to do searching in single byte encoding instead of UTF-8 + to speed things up, set dfa->mb_cur_max to 1, clear is_utf8 and change + DFA nodes where needed. */ + +static void +optimize_utf8 (re_dfa_t *dfa) +{ + Idx node; + int i; + bool mb_chars = false; + bool has_period = false; + + for (node = 0; node < dfa->nodes_len; ++node) + switch (dfa->nodes[node].type) + { + case CHARACTER: + if (dfa->nodes[node].opr.c >= ASCII_CHARS) + mb_chars = true; + break; + case ANCHOR: + switch (dfa->nodes[node].opr.ctx_type) + { + case LINE_FIRST: + case LINE_LAST: + case BUF_FIRST: + case BUF_LAST: + break; + default: + /* Word anchors etc. cannot be handled. It's okay to test + opr.ctx_type since constraints (for all DFA nodes) are + created by ORing one or more opr.ctx_type values. */ + return; + } + break; + case OP_PERIOD: + has_period = true; + break; + case OP_BACK_REF: + case OP_ALT: + case END_OF_RE: + case OP_DUP_ASTERISK: + case OP_OPEN_SUBEXP: + case OP_CLOSE_SUBEXP: + break; + case COMPLEX_BRACKET: + return; + case SIMPLE_BRACKET: + /* Just double check. */ + { + int rshift = (ASCII_CHARS % BITSET_WORD_BITS == 0 + ? 0 + : BITSET_WORD_BITS - ASCII_CHARS % BITSET_WORD_BITS); + for (i = ASCII_CHARS / BITSET_WORD_BITS; i < BITSET_WORDS; ++i) + { + if (dfa->nodes[node].opr.sbcset[i] >> rshift != 0) + return; + rshift = 0; + } + } + break; + default: + abort (); + } + + if (mb_chars || has_period) + for (node = 0; node < dfa->nodes_len; ++node) + { + if (dfa->nodes[node].type == CHARACTER + && dfa->nodes[node].opr.c >= ASCII_CHARS) + dfa->nodes[node].mb_partial = 0; + else if (dfa->nodes[node].type == OP_PERIOD) + dfa->nodes[node].type = OP_UTF8_PERIOD; + } + + /* The search can be in single byte locale. */ + dfa->mb_cur_max = 1; + dfa->is_utf8 = 0; + dfa->has_mb_node = dfa->nbackref > 0 || has_period; +} + +/* Analyze the structure tree, and calculate "first", "next", "edest", + "eclosure", and "inveclosure". */ + +static reg_errcode_t +analyze (regex_t *preg) +{ + re_dfa_t *dfa = preg->buffer; + reg_errcode_t ret; + + /* Allocate arrays. */ + dfa->nexts = re_malloc (Idx, dfa->nodes_alloc); + dfa->org_indices = re_malloc (Idx, dfa->nodes_alloc); + dfa->edests = re_malloc (re_node_set, dfa->nodes_alloc); + dfa->eclosures = re_malloc (re_node_set, dfa->nodes_alloc); + if (__glibc_unlikely (dfa->nexts == NULL || dfa->org_indices == NULL + || dfa->edests == NULL || dfa->eclosures == NULL)) + return REG_ESPACE; + + dfa->subexp_map = re_malloc (Idx, preg->re_nsub); + if (dfa->subexp_map != NULL) + { + Idx i; + for (i = 0; i < preg->re_nsub; i++) + dfa->subexp_map[i] = i; + preorder (dfa->str_tree, optimize_subexps, dfa); + for (i = 0; i < preg->re_nsub; i++) + if (dfa->subexp_map[i] != i) + break; + if (i == preg->re_nsub) + { + re_free (dfa->subexp_map); + dfa->subexp_map = NULL; + } + } + + ret = postorder (dfa->str_tree, lower_subexps, preg); + if (__glibc_unlikely (ret != REG_NOERROR)) + return ret; + ret = postorder (dfa->str_tree, calc_first, dfa); + if (__glibc_unlikely (ret != REG_NOERROR)) + return ret; + preorder (dfa->str_tree, calc_next, dfa); + ret = preorder (dfa->str_tree, link_nfa_nodes, dfa); + if (__glibc_unlikely (ret != REG_NOERROR)) + return ret; + ret = calc_eclosure (dfa); + if (__glibc_unlikely (ret != REG_NOERROR)) + return ret; + + /* We only need this during the prune_impossible_nodes pass in regexec.c; + skip it if p_i_n will not run, as calc_inveclosure can be quadratic. */ + if ((!preg->no_sub && preg->re_nsub > 0 && dfa->has_plural_match) + || dfa->nbackref) + { + dfa->inveclosures = re_malloc (re_node_set, dfa->nodes_len); + if (__glibc_unlikely (dfa->inveclosures == NULL)) + return REG_ESPACE; + ret = calc_inveclosure (dfa); + } + + return ret; +} + +/* Our parse trees are very unbalanced, so we cannot use a stack to + implement parse tree visits. Instead, we use parent pointers and + some hairy code in these two functions. */ +static reg_errcode_t +postorder (bin_tree_t *root, reg_errcode_t (fn (void *, bin_tree_t *)), + void *extra) +{ + bin_tree_t *node, *prev; + + for (node = root; ; ) + { + /* Descend down the tree, preferably to the left (or to the right + if that's the only child). */ + while (node->left || node->right) + if (node->left) + node = node->left; + else + node = node->right; + + do + { + reg_errcode_t err = fn (extra, node); + if (__glibc_unlikely (err != REG_NOERROR)) + return err; + if (node->parent == NULL) + return REG_NOERROR; + prev = node; + node = node->parent; + } + /* Go up while we have a node that is reached from the right. */ + while (node->right == prev || node->right == NULL); + node = node->right; + } +} + +static reg_errcode_t +preorder (bin_tree_t *root, reg_errcode_t (fn (void *, bin_tree_t *)), + void *extra) +{ + bin_tree_t *node; + + for (node = root; ; ) + { + reg_errcode_t err = fn (extra, node); + if (__glibc_unlikely (err != REG_NOERROR)) + return err; + + /* Go to the left node, or up and to the right. */ + if (node->left) + node = node->left; + else + { + bin_tree_t *prev = NULL; + while (node->right == prev || node->right == NULL) + { + prev = node; + node = node->parent; + if (!node) + return REG_NOERROR; + } + node = node->right; + } + } +} + +/* Optimization pass: if a SUBEXP is entirely contained, strip it and tell + re_search_internal to map the inner one's opr.idx to this one's. Adjust + backreferences as well. Requires a preorder visit. */ +static reg_errcode_t +optimize_subexps (void *extra, bin_tree_t *node) +{ + re_dfa_t *dfa = (re_dfa_t *) extra; + + if (node->token.type == OP_BACK_REF && dfa->subexp_map) + { + int idx = node->token.opr.idx; + node->token.opr.idx = dfa->subexp_map[idx]; + dfa->used_bkref_map |= 1 << node->token.opr.idx; + } + + else if (node->token.type == SUBEXP + && node->left && node->left->token.type == SUBEXP) + { + Idx other_idx = node->left->token.opr.idx; + + node->left = node->left->left; + if (node->left) + node->left->parent = node; + + dfa->subexp_map[other_idx] = dfa->subexp_map[node->token.opr.idx]; + if (other_idx < BITSET_WORD_BITS) + dfa->used_bkref_map &= ~((bitset_word_t) 1 << other_idx); + } + + return REG_NOERROR; +} + +/* Lowering pass: Turn each SUBEXP node into the appropriate concatenation + of OP_OPEN_SUBEXP, the body of the SUBEXP (if any) and OP_CLOSE_SUBEXP. */ +static reg_errcode_t +lower_subexps (void *extra, bin_tree_t *node) +{ + regex_t *preg = (regex_t *) extra; + reg_errcode_t err = REG_NOERROR; + + if (node->left && node->left->token.type == SUBEXP) + { + node->left = lower_subexp (&err, preg, node->left); + if (node->left) + node->left->parent = node; + } + if (node->right && node->right->token.type == SUBEXP) + { + node->right = lower_subexp (&err, preg, node->right); + if (node->right) + node->right->parent = node; + } + + return err; +} + +static bin_tree_t * +lower_subexp (reg_errcode_t *err, regex_t *preg, bin_tree_t *node) +{ + re_dfa_t *dfa = preg->buffer; + bin_tree_t *body = node->left; + bin_tree_t *op, *cls, *tree1, *tree; + + if (preg->no_sub + /* We do not optimize empty subexpressions, because otherwise we may + have bad CONCAT nodes with NULL children. This is obviously not + very common, so we do not lose much. An example that triggers + this case is the sed "script" /\(\)/x. */ + && node->left != NULL + && (node->token.opr.idx >= BITSET_WORD_BITS + || !(dfa->used_bkref_map + & ((bitset_word_t) 1 << node->token.opr.idx)))) + return node->left; + + /* Convert the SUBEXP node to the concatenation of an + OP_OPEN_SUBEXP, the contents, and an OP_CLOSE_SUBEXP. */ + op = create_tree (dfa, NULL, NULL, OP_OPEN_SUBEXP); + cls = create_tree (dfa, NULL, NULL, OP_CLOSE_SUBEXP); + tree1 = body ? create_tree (dfa, body, cls, CONCAT) : cls; + tree = create_tree (dfa, op, tree1, CONCAT); + if (__glibc_unlikely (tree == NULL || tree1 == NULL + || op == NULL || cls == NULL)) + { + *err = REG_ESPACE; + return NULL; + } + + op->token.opr.idx = cls->token.opr.idx = node->token.opr.idx; + op->token.opt_subexp = cls->token.opt_subexp = node->token.opt_subexp; + return tree; +} + +/* Pass 1 in building the NFA: compute FIRST and create unlinked automaton + nodes. Requires a postorder visit. */ +static reg_errcode_t +calc_first (void *extra, bin_tree_t *node) +{ + re_dfa_t *dfa = (re_dfa_t *) extra; + if (node->token.type == CONCAT) + { + node->first = node->left->first; + node->node_idx = node->left->node_idx; + } + else + { + node->first = node; + node->node_idx = re_dfa_add_node (dfa, node->token); + if (__glibc_unlikely (node->node_idx == -1)) + return REG_ESPACE; + if (node->token.type == ANCHOR) + dfa->nodes[node->node_idx].constraint = node->token.opr.ctx_type; + } + return REG_NOERROR; +} + +/* Pass 2: compute NEXT on the tree. Preorder visit. */ +static reg_errcode_t +calc_next (void *extra, bin_tree_t *node) +{ + switch (node->token.type) + { + case OP_DUP_ASTERISK: + node->left->next = node; + break; + case CONCAT: + node->left->next = node->right->first; + node->right->next = node->next; + break; + default: + if (node->left) + node->left->next = node->next; + if (node->right) + node->right->next = node->next; + break; + } + return REG_NOERROR; +} + +/* Pass 3: link all DFA nodes to their NEXT node (any order will do). */ +static reg_errcode_t +link_nfa_nodes (void *extra, bin_tree_t *node) +{ + re_dfa_t *dfa = (re_dfa_t *) extra; + Idx idx = node->node_idx; + reg_errcode_t err = REG_NOERROR; + + switch (node->token.type) + { + case CONCAT: + break; + + case END_OF_RE: + DEBUG_ASSERT (node->next == NULL); + break; + + case OP_DUP_ASTERISK: + case OP_ALT: + { + Idx left, right; + dfa->has_plural_match = 1; + if (node->left != NULL) + left = node->left->first->node_idx; + else + left = node->next->node_idx; + if (node->right != NULL) + right = node->right->first->node_idx; + else + right = node->next->node_idx; + DEBUG_ASSERT (left > -1); + DEBUG_ASSERT (right > -1); + err = re_node_set_init_2 (dfa->edests + idx, left, right); + } + break; + + case ANCHOR: + case OP_OPEN_SUBEXP: + case OP_CLOSE_SUBEXP: + err = re_node_set_init_1 (dfa->edests + idx, node->next->node_idx); + break; + + case OP_BACK_REF: + dfa->nexts[idx] = node->next->node_idx; + if (node->token.type == OP_BACK_REF) + err = re_node_set_init_1 (dfa->edests + idx, dfa->nexts[idx]); + break; + + default: + DEBUG_ASSERT (!IS_EPSILON_NODE (node->token.type)); + dfa->nexts[idx] = node->next->node_idx; + break; + } + + return err; +} + +/* Duplicate the epsilon closure of the node ROOT_NODE. + Note that duplicated nodes have constraint INIT_CONSTRAINT in addition + to their own constraint. */ + +static reg_errcode_t +duplicate_node_closure (re_dfa_t *dfa, Idx top_org_node, Idx top_clone_node, + Idx root_node, unsigned int init_constraint) +{ + Idx org_node, clone_node; + bool ok; + unsigned int constraint = init_constraint; + for (org_node = top_org_node, clone_node = top_clone_node;;) + { + Idx org_dest, clone_dest; + if (dfa->nodes[org_node].type == OP_BACK_REF) + { + /* If the back reference epsilon-transit, its destination must + also have the constraint. Then duplicate the epsilon closure + of the destination of the back reference, and store it in + edests of the back reference. */ + org_dest = dfa->nexts[org_node]; + re_node_set_empty (dfa->edests + clone_node); + clone_dest = duplicate_node (dfa, org_dest, constraint); + if (__glibc_unlikely (clone_dest == -1)) + return REG_ESPACE; + dfa->nexts[clone_node] = dfa->nexts[org_node]; + ok = re_node_set_insert (dfa->edests + clone_node, clone_dest); + if (__glibc_unlikely (! ok)) + return REG_ESPACE; + } + else if (dfa->edests[org_node].nelem == 0) + { + /* In case of the node can't epsilon-transit, don't duplicate the + destination and store the original destination as the + destination of the node. */ + dfa->nexts[clone_node] = dfa->nexts[org_node]; + break; + } + else if (dfa->edests[org_node].nelem == 1) + { + /* In case of the node can epsilon-transit, and it has only one + destination. */ + org_dest = dfa->edests[org_node].elems[0]; + re_node_set_empty (dfa->edests + clone_node); + /* If the node is root_node itself, it means the epsilon closure + has a loop. Then tie it to the destination of the root_node. */ + if (org_node == root_node && clone_node != org_node) + { + ok = re_node_set_insert (dfa->edests + clone_node, org_dest); + if (__glibc_unlikely (! ok)) + return REG_ESPACE; + break; + } + /* In case the node has another constraint, append it. */ + constraint |= dfa->nodes[org_node].constraint; + clone_dest = duplicate_node (dfa, org_dest, constraint); + if (__glibc_unlikely (clone_dest == -1)) + return REG_ESPACE; + ok = re_node_set_insert (dfa->edests + clone_node, clone_dest); + if (__glibc_unlikely (! ok)) + return REG_ESPACE; + } + else /* dfa->edests[org_node].nelem == 2 */ + { + /* In case of the node can epsilon-transit, and it has two + destinations. In the bin_tree_t and DFA, that's '|' and '*'. */ + org_dest = dfa->edests[org_node].elems[0]; + re_node_set_empty (dfa->edests + clone_node); + /* Search for a duplicated node which satisfies the constraint. */ + clone_dest = search_duplicated_node (dfa, org_dest, constraint); + if (clone_dest == -1) + { + /* There is no such duplicated node, create a new one. */ + reg_errcode_t err; + clone_dest = duplicate_node (dfa, org_dest, constraint); + if (__glibc_unlikely (clone_dest == -1)) + return REG_ESPACE; + ok = re_node_set_insert (dfa->edests + clone_node, clone_dest); + if (__glibc_unlikely (! ok)) + return REG_ESPACE; + err = duplicate_node_closure (dfa, org_dest, clone_dest, + root_node, constraint); + if (__glibc_unlikely (err != REG_NOERROR)) + return err; + } + else + { + /* There is a duplicated node which satisfies the constraint, + use it to avoid infinite loop. */ + ok = re_node_set_insert (dfa->edests + clone_node, clone_dest); + if (__glibc_unlikely (! ok)) + return REG_ESPACE; + } + + org_dest = dfa->edests[org_node].elems[1]; + clone_dest = duplicate_node (dfa, org_dest, constraint); + if (__glibc_unlikely (clone_dest == -1)) + return REG_ESPACE; + ok = re_node_set_insert (dfa->edests + clone_node, clone_dest); + if (__glibc_unlikely (! ok)) + return REG_ESPACE; + } + org_node = org_dest; + clone_node = clone_dest; + } + return REG_NOERROR; +} + +/* Search for a node which is duplicated from the node ORG_NODE, and + satisfies the constraint CONSTRAINT. */ + +static Idx +search_duplicated_node (const re_dfa_t *dfa, Idx org_node, + unsigned int constraint) +{ + Idx idx; + for (idx = dfa->nodes_len - 1; dfa->nodes[idx].duplicated && idx > 0; --idx) + { + if (org_node == dfa->org_indices[idx] + && constraint == dfa->nodes[idx].constraint) + return idx; /* Found. */ + } + return -1; /* Not found. */ +} + +/* Duplicate the node whose index is ORG_IDX and set the constraint CONSTRAINT. + Return the index of the new node, or -1 if insufficient storage is + available. */ + +static Idx +duplicate_node (re_dfa_t *dfa, Idx org_idx, unsigned int constraint) +{ + Idx dup_idx = re_dfa_add_node (dfa, dfa->nodes[org_idx]); + if (__glibc_likely (dup_idx != -1)) + { + dfa->nodes[dup_idx].constraint = constraint; + dfa->nodes[dup_idx].constraint |= dfa->nodes[org_idx].constraint; + dfa->nodes[dup_idx].duplicated = 1; + + /* Store the index of the original node. */ + dfa->org_indices[dup_idx] = org_idx; + } + return dup_idx; +} + +static reg_errcode_t +calc_inveclosure (re_dfa_t *dfa) +{ + Idx src, idx; + bool ok; + for (idx = 0; idx < dfa->nodes_len; ++idx) + re_node_set_init_empty (dfa->inveclosures + idx); + + for (src = 0; src < dfa->nodes_len; ++src) + { + Idx *elems = dfa->eclosures[src].elems; + for (idx = 0; idx < dfa->eclosures[src].nelem; ++idx) + { + ok = re_node_set_insert_last (dfa->inveclosures + elems[idx], src); + if (__glibc_unlikely (! ok)) + return REG_ESPACE; + } + } + + return REG_NOERROR; +} + +/* Calculate "eclosure" for all the node in DFA. */ + +static reg_errcode_t +calc_eclosure (re_dfa_t *dfa) +{ + Idx node_idx; + bool incomplete; + DEBUG_ASSERT (dfa->nodes_len > 0); + incomplete = false; + /* For each nodes, calculate epsilon closure. */ + for (node_idx = 0; ; ++node_idx) + { + reg_errcode_t err; + re_node_set eclosure_elem; + if (node_idx == dfa->nodes_len) + { + if (!incomplete) + break; + incomplete = false; + node_idx = 0; + } + + DEBUG_ASSERT (dfa->eclosures[node_idx].nelem != -1); + + /* If we have already calculated, skip it. */ + if (dfa->eclosures[node_idx].nelem != 0) + continue; + /* Calculate epsilon closure of 'node_idx'. */ + err = calc_eclosure_iter (&eclosure_elem, dfa, node_idx, true); + if (__glibc_unlikely (err != REG_NOERROR)) + return err; + + if (dfa->eclosures[node_idx].nelem == 0) + { + incomplete = true; + re_node_set_free (&eclosure_elem); + } + } + return REG_NOERROR; +} + +/* Calculate epsilon closure of NODE. */ + +static reg_errcode_t +calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa, Idx node, bool root) +{ + reg_errcode_t err; + Idx i; + re_node_set eclosure; + bool incomplete = false; + err = re_node_set_alloc (&eclosure, dfa->edests[node].nelem + 1); + if (__glibc_unlikely (err != REG_NOERROR)) + return err; + + /* An epsilon closure includes itself. */ + eclosure.elems[eclosure.nelem++] = node; + + /* This indicates that we are calculating this node now. + We reference this value to avoid infinite loop. */ + dfa->eclosures[node].nelem = -1; + + /* If the current node has constraints, duplicate all nodes + since they must inherit the constraints. */ + if (dfa->nodes[node].constraint + && dfa->edests[node].nelem + && !dfa->nodes[dfa->edests[node].elems[0]].duplicated) + { + err = duplicate_node_closure (dfa, node, node, node, + dfa->nodes[node].constraint); + if (__glibc_unlikely (err != REG_NOERROR)) + return err; + } + + /* Expand each epsilon destination nodes. */ + if (IS_EPSILON_NODE(dfa->nodes[node].type)) + for (i = 0; i < dfa->edests[node].nelem; ++i) + { + re_node_set eclosure_elem; + Idx edest = dfa->edests[node].elems[i]; + /* If calculating the epsilon closure of 'edest' is in progress, + return intermediate result. */ + if (dfa->eclosures[edest].nelem == -1) + { + incomplete = true; + continue; + } + /* If we haven't calculated the epsilon closure of 'edest' yet, + calculate now. Otherwise use calculated epsilon closure. */ + if (dfa->eclosures[edest].nelem == 0) + { + err = calc_eclosure_iter (&eclosure_elem, dfa, edest, false); + if (__glibc_unlikely (err != REG_NOERROR)) + return err; + } + else + eclosure_elem = dfa->eclosures[edest]; + /* Merge the epsilon closure of 'edest'. */ + err = re_node_set_merge (&eclosure, &eclosure_elem); + if (__glibc_unlikely (err != REG_NOERROR)) + return err; + /* If the epsilon closure of 'edest' is incomplete, + the epsilon closure of this node is also incomplete. */ + if (dfa->eclosures[edest].nelem == 0) + { + incomplete = true; + re_node_set_free (&eclosure_elem); + } + } + + if (incomplete && !root) + dfa->eclosures[node].nelem = 0; + else + dfa->eclosures[node] = eclosure; + *new_set = eclosure; + return REG_NOERROR; +} + +/* Functions for token which are used in the parser. */ + +/* Fetch a token from INPUT. + We must not use this function inside bracket expressions. */ + +static void +fetch_token (re_token_t *result, re_string_t *input, reg_syntax_t syntax) +{ + re_string_skip_bytes (input, peek_token (result, input, syntax)); +} + +/* Peek a token from INPUT, and return the length of the token. + We must not use this function inside bracket expressions. */ + +static int +peek_token (re_token_t *token, re_string_t *input, reg_syntax_t syntax) +{ + unsigned char c; + + if (re_string_eoi (input)) + { + token->type = END_OF_RE; + return 0; + } + + c = re_string_peek_byte (input, 0); + token->opr.c = c; + + token->word_char = 0; + token->mb_partial = 0; + if (input->mb_cur_max > 1 + && !re_string_first_byte (input, re_string_cur_idx (input))) + { + token->type = CHARACTER; + token->mb_partial = 1; + return 1; + } + if (c == '\\') + { + unsigned char c2; + if (re_string_cur_idx (input) + 1 >= re_string_length (input)) + { + token->type = BACK_SLASH; + return 1; + } + + c2 = re_string_peek_byte_case (input, 1); + token->opr.c = c2; + token->type = CHARACTER; + if (input->mb_cur_max > 1) + { + wint_t wc = re_string_wchar_at (input, + re_string_cur_idx (input) + 1); + token->word_char = IS_WIDE_WORD_CHAR (wc) != 0; + } + else + token->word_char = IS_WORD_CHAR (c2) != 0; + + switch (c2) + { + case '|': + if (!(syntax & RE_LIMITED_OPS) && !(syntax & RE_NO_BK_VBAR)) + token->type = OP_ALT; + break; + case '1': case '2': case '3': case '4': case '5': + case '6': case '7': case '8': case '9': + if (!(syntax & RE_NO_BK_REFS)) + { + token->type = OP_BACK_REF; + token->opr.idx = c2 - '1'; + } + break; + case '<': + if (!(syntax & RE_NO_GNU_OPS)) + { + token->type = ANCHOR; + token->opr.ctx_type = WORD_FIRST; + } + break; + case '>': + if (!(syntax & RE_NO_GNU_OPS)) + { + token->type = ANCHOR; + token->opr.ctx_type = WORD_LAST; + } + break; + case 'b': + if (!(syntax & RE_NO_GNU_OPS)) + { + token->type = ANCHOR; + token->opr.ctx_type = WORD_DELIM; + } + break; + case 'B': + if (!(syntax & RE_NO_GNU_OPS)) + { + token->type = ANCHOR; + token->opr.ctx_type = NOT_WORD_DELIM; + } + break; + case 'w': + if (!(syntax & RE_NO_GNU_OPS)) + token->type = OP_WORD; + break; + case 'W': + if (!(syntax & RE_NO_GNU_OPS)) + token->type = OP_NOTWORD; + break; + case 's': + if (!(syntax & RE_NO_GNU_OPS)) + token->type = OP_SPACE; + break; + case 'S': + if (!(syntax & RE_NO_GNU_OPS)) + token->type = OP_NOTSPACE; + break; + case '`': + if (!(syntax & RE_NO_GNU_OPS)) + { + token->type = ANCHOR; + token->opr.ctx_type = BUF_FIRST; + } + break; + case '\'': + if (!(syntax & RE_NO_GNU_OPS)) + { + token->type = ANCHOR; + token->opr.ctx_type = BUF_LAST; + } + break; + case '(': + if (!(syntax & RE_NO_BK_PARENS)) + token->type = OP_OPEN_SUBEXP; + break; + case ')': + if (!(syntax & RE_NO_BK_PARENS)) + token->type = OP_CLOSE_SUBEXP; + break; + case '+': + if (!(syntax & RE_LIMITED_OPS) && (syntax & RE_BK_PLUS_QM)) + token->type = OP_DUP_PLUS; + break; + case '?': + if (!(syntax & RE_LIMITED_OPS) && (syntax & RE_BK_PLUS_QM)) + token->type = OP_DUP_QUESTION; + break; + case '{': + if ((syntax & RE_INTERVALS) && (!(syntax & RE_NO_BK_BRACES))) + token->type = OP_OPEN_DUP_NUM; + break; + case '}': + if ((syntax & RE_INTERVALS) && (!(syntax & RE_NO_BK_BRACES))) + token->type = OP_CLOSE_DUP_NUM; + break; + default: + break; + } + return 2; + } + + token->type = CHARACTER; + if (input->mb_cur_max > 1) + { + wint_t wc = re_string_wchar_at (input, re_string_cur_idx (input)); + token->word_char = IS_WIDE_WORD_CHAR (wc) != 0; + } + else + token->word_char = IS_WORD_CHAR (token->opr.c); + + switch (c) + { + case '\n': + if (syntax & RE_NEWLINE_ALT) + token->type = OP_ALT; + break; + case '|': + if (!(syntax & RE_LIMITED_OPS) && (syntax & RE_NO_BK_VBAR)) + token->type = OP_ALT; + break; + case '*': + token->type = OP_DUP_ASTERISK; + break; + case '+': + if (!(syntax & RE_LIMITED_OPS) && !(syntax & RE_BK_PLUS_QM)) + token->type = OP_DUP_PLUS; + break; + case '?': + if (!(syntax & RE_LIMITED_OPS) && !(syntax & RE_BK_PLUS_QM)) + token->type = OP_DUP_QUESTION; + break; + case '{': + if ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES)) + token->type = OP_OPEN_DUP_NUM; + break; + case '}': + if ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES)) + token->type = OP_CLOSE_DUP_NUM; + break; + case '(': + if (syntax & RE_NO_BK_PARENS) + token->type = OP_OPEN_SUBEXP; + break; + case ')': + if (syntax & RE_NO_BK_PARENS) + token->type = OP_CLOSE_SUBEXP; + break; + case '[': + token->type = OP_OPEN_BRACKET; + break; + case '.': + token->type = OP_PERIOD; + break; + case '^': + if (!(syntax & (RE_CONTEXT_INDEP_ANCHORS | RE_CARET_ANCHORS_HERE)) + && re_string_cur_idx (input) != 0) + { + char prev = re_string_peek_byte (input, -1); + if (!(syntax & RE_NEWLINE_ALT) || prev != '\n') + break; + } + token->type = ANCHOR; + token->opr.ctx_type = LINE_FIRST; + break; + case '$': + if (!(syntax & RE_CONTEXT_INDEP_ANCHORS) + && re_string_cur_idx (input) + 1 != re_string_length (input)) + { + re_token_t next; + re_string_skip_bytes (input, 1); + peek_token (&next, input, syntax); + re_string_skip_bytes (input, -1); + if (next.type != OP_ALT && next.type != OP_CLOSE_SUBEXP) + break; + } + token->type = ANCHOR; + token->opr.ctx_type = LINE_LAST; + break; + default: + break; + } + return 1; +} + +/* Peek a token from INPUT, and return the length of the token. + We must not use this function out of bracket expressions. */ + +static int +peek_token_bracket (re_token_t *token, re_string_t *input, reg_syntax_t syntax) +{ + unsigned char c; + if (re_string_eoi (input)) + { + token->type = END_OF_RE; + return 0; + } + c = re_string_peek_byte (input, 0); + token->opr.c = c; + + if (input->mb_cur_max > 1 + && !re_string_first_byte (input, re_string_cur_idx (input))) + { + token->type = CHARACTER; + return 1; + } + + if (c == '\\' && (syntax & RE_BACKSLASH_ESCAPE_IN_LISTS) + && re_string_cur_idx (input) + 1 < re_string_length (input)) + { + /* In this case, '\' escape a character. */ + unsigned char c2; + re_string_skip_bytes (input, 1); + c2 = re_string_peek_byte (input, 0); + token->opr.c = c2; + token->type = CHARACTER; + return 1; + } + if (c == '[') /* '[' is a special char in a bracket exps. */ + { + unsigned char c2; + int token_len; + if (re_string_cur_idx (input) + 1 < re_string_length (input)) + c2 = re_string_peek_byte (input, 1); + else + c2 = 0; + token->opr.c = c2; + token_len = 2; + switch (c2) + { + case '.': + token->type = OP_OPEN_COLL_ELEM; + break; + + case '=': + token->type = OP_OPEN_EQUIV_CLASS; + break; + + case ':': + if (syntax & RE_CHAR_CLASSES) + { + token->type = OP_OPEN_CHAR_CLASS; + break; + } + FALLTHROUGH; + default: + token->type = CHARACTER; + token->opr.c = c; + token_len = 1; + break; + } + return token_len; + } + switch (c) + { + case ']': + token->type = OP_CLOSE_BRACKET; + break; + case '^': + token->type = OP_NON_MATCH_LIST; + break; + case '-': + /* In V7 Unix grep and Unix awk and mawk, [...---...] + (3 adjacent minus signs) stands for a single minus sign. + Support that without breaking anything else. */ + if (! (re_string_cur_idx (input) + 2 < re_string_length (input) + && re_string_peek_byte (input, 1) == '-' + && re_string_peek_byte (input, 2) == '-')) + { + token->type = OP_CHARSET_RANGE; + break; + } + re_string_skip_bytes (input, 2); + FALLTHROUGH; + default: + token->type = CHARACTER; + } + return 1; +} + +/* Functions for parser. */ + +/* Entry point of the parser. + Parse the regular expression REGEXP and return the structure tree. + If an error occurs, ERR is set by error code, and return NULL. + This function build the following tree, from regular expression : + CAT + / \ + / \ + EOR + + CAT means concatenation. + EOR means end of regular expression. */ + +static bin_tree_t * +parse (re_string_t *regexp, regex_t *preg, reg_syntax_t syntax, + reg_errcode_t *err) +{ + re_dfa_t *dfa = preg->buffer; + bin_tree_t *tree, *eor, *root; + re_token_t current_token; + dfa->syntax = syntax; + fetch_token (¤t_token, regexp, syntax | RE_CARET_ANCHORS_HERE); + tree = parse_reg_exp (regexp, preg, ¤t_token, syntax, 0, err); + if (__glibc_unlikely (*err != REG_NOERROR && tree == NULL)) + return NULL; + eor = create_tree (dfa, NULL, NULL, END_OF_RE); + if (tree != NULL) + root = create_tree (dfa, tree, eor, CONCAT); + else + root = eor; + if (__glibc_unlikely (eor == NULL || root == NULL)) + { + *err = REG_ESPACE; + return NULL; + } + return root; +} + +/* This function build the following tree, from regular expression + |: + ALT + / \ + / \ + + + ALT means alternative, which represents the operator '|'. */ + +static bin_tree_t * +parse_reg_exp (re_string_t *regexp, regex_t *preg, re_token_t *token, + reg_syntax_t syntax, Idx nest, reg_errcode_t *err) +{ + re_dfa_t *dfa = preg->buffer; + bin_tree_t *tree, *branch = NULL; + bitset_word_t initial_bkref_map = dfa->completed_bkref_map; + tree = parse_branch (regexp, preg, token, syntax, nest, err); + if (__glibc_unlikely (*err != REG_NOERROR && tree == NULL)) + return NULL; + + while (token->type == OP_ALT) + { + fetch_token (token, regexp, syntax | RE_CARET_ANCHORS_HERE); + if (token->type != OP_ALT && token->type != END_OF_RE + && (nest == 0 || token->type != OP_CLOSE_SUBEXP)) + { + bitset_word_t accumulated_bkref_map = dfa->completed_bkref_map; + dfa->completed_bkref_map = initial_bkref_map; + branch = parse_branch (regexp, preg, token, syntax, nest, err); + if (__glibc_unlikely (*err != REG_NOERROR && branch == NULL)) + { + if (tree != NULL) + postorder (tree, free_tree, NULL); + return NULL; + } + dfa->completed_bkref_map |= accumulated_bkref_map; + } + else + branch = NULL; + tree = create_tree (dfa, tree, branch, OP_ALT); + if (__glibc_unlikely (tree == NULL)) + { + *err = REG_ESPACE; + return NULL; + } + } + return tree; +} + +/* This function build the following tree, from regular expression + : + CAT + / \ + / \ + + + CAT means concatenation. */ + +static bin_tree_t * +parse_branch (re_string_t *regexp, regex_t *preg, re_token_t *token, + reg_syntax_t syntax, Idx nest, reg_errcode_t *err) +{ + bin_tree_t *tree, *expr; + re_dfa_t *dfa = preg->buffer; + tree = parse_expression (regexp, preg, token, syntax, nest, err); + if (__glibc_unlikely (*err != REG_NOERROR && tree == NULL)) + return NULL; + + while (token->type != OP_ALT && token->type != END_OF_RE + && (nest == 0 || token->type != OP_CLOSE_SUBEXP)) + { + expr = parse_expression (regexp, preg, token, syntax, nest, err); + if (__glibc_unlikely (*err != REG_NOERROR && expr == NULL)) + { + if (tree != NULL) + postorder (tree, free_tree, NULL); + return NULL; + } + if (tree != NULL && expr != NULL) + { + bin_tree_t *newtree = create_tree (dfa, tree, expr, CONCAT); + if (newtree == NULL) + { + postorder (expr, free_tree, NULL); + postorder (tree, free_tree, NULL); + *err = REG_ESPACE; + return NULL; + } + tree = newtree; + } + else if (tree == NULL) + tree = expr; + /* Otherwise expr == NULL, we don't need to create new tree. */ + } + return tree; +} + +/* This function build the following tree, from regular expression a*: + * + | + a +*/ + +static bin_tree_t * +parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token, + reg_syntax_t syntax, Idx nest, reg_errcode_t *err) +{ + re_dfa_t *dfa = preg->buffer; + bin_tree_t *tree; + switch (token->type) + { + case CHARACTER: + tree = create_token_tree (dfa, NULL, NULL, token); + if (__glibc_unlikely (tree == NULL)) + { + *err = REG_ESPACE; + return NULL; + } + if (dfa->mb_cur_max > 1) + { + while (!re_string_eoi (regexp) + && !re_string_first_byte (regexp, re_string_cur_idx (regexp))) + { + bin_tree_t *mbc_remain; + fetch_token (token, regexp, syntax); + mbc_remain = create_token_tree (dfa, NULL, NULL, token); + tree = create_tree (dfa, tree, mbc_remain, CONCAT); + if (__glibc_unlikely (mbc_remain == NULL || tree == NULL)) + { + *err = REG_ESPACE; + return NULL; + } + } + } + break; + + case OP_OPEN_SUBEXP: + tree = parse_sub_exp (regexp, preg, token, syntax, nest + 1, err); + if (__glibc_unlikely (*err != REG_NOERROR && tree == NULL)) + return NULL; + break; + + case OP_OPEN_BRACKET: + tree = parse_bracket_exp (regexp, dfa, token, syntax, err); + if (__glibc_unlikely (*err != REG_NOERROR && tree == NULL)) + return NULL; + break; + + case OP_BACK_REF: + if (!__glibc_likely (dfa->completed_bkref_map & (1 << token->opr.idx))) + { + *err = REG_ESUBREG; + return NULL; + } + dfa->used_bkref_map |= 1 << token->opr.idx; + tree = create_token_tree (dfa, NULL, NULL, token); + if (__glibc_unlikely (tree == NULL)) + { + *err = REG_ESPACE; + return NULL; + } + ++dfa->nbackref; + dfa->has_mb_node = 1; + break; + + case OP_OPEN_DUP_NUM: + if (syntax & RE_CONTEXT_INVALID_DUP) + { + *err = REG_BADRPT; + return NULL; + } + FALLTHROUGH; + case OP_DUP_ASTERISK: + case OP_DUP_PLUS: + case OP_DUP_QUESTION: + if (syntax & RE_CONTEXT_INVALID_OPS) + { + *err = REG_BADRPT; + return NULL; + } + else if (syntax & RE_CONTEXT_INDEP_OPS) + { + fetch_token (token, regexp, syntax); + return parse_expression (regexp, preg, token, syntax, nest, err); + } + FALLTHROUGH; + case OP_CLOSE_SUBEXP: + if ((token->type == OP_CLOSE_SUBEXP) + && !(syntax & RE_UNMATCHED_RIGHT_PAREN_ORD)) + { + *err = REG_ERPAREN; + return NULL; + } + FALLTHROUGH; + case OP_CLOSE_DUP_NUM: + /* We treat it as a normal character. */ + + /* Then we can these characters as normal characters. */ + token->type = CHARACTER; + /* mb_partial and word_char bits should be initialized already + by peek_token. */ + tree = create_token_tree (dfa, NULL, NULL, token); + if (__glibc_unlikely (tree == NULL)) + { + *err = REG_ESPACE; + return NULL; + } + break; + + case ANCHOR: + if ((token->opr.ctx_type + & (WORD_DELIM | NOT_WORD_DELIM | WORD_FIRST | WORD_LAST)) + && dfa->word_ops_used == 0) + init_word_char (dfa); + if (token->opr.ctx_type == WORD_DELIM + || token->opr.ctx_type == NOT_WORD_DELIM) + { + bin_tree_t *tree_first, *tree_last; + if (token->opr.ctx_type == WORD_DELIM) + { + token->opr.ctx_type = WORD_FIRST; + tree_first = create_token_tree (dfa, NULL, NULL, token); + token->opr.ctx_type = WORD_LAST; + } + else + { + token->opr.ctx_type = INSIDE_WORD; + tree_first = create_token_tree (dfa, NULL, NULL, token); + token->opr.ctx_type = INSIDE_NOTWORD; + } + tree_last = create_token_tree (dfa, NULL, NULL, token); + tree = create_tree (dfa, tree_first, tree_last, OP_ALT); + if (__glibc_unlikely (tree_first == NULL || tree_last == NULL + || tree == NULL)) + { + *err = REG_ESPACE; + return NULL; + } + } + else + { + tree = create_token_tree (dfa, NULL, NULL, token); + if (__glibc_unlikely (tree == NULL)) + { + *err = REG_ESPACE; + return NULL; + } + } + /* We must return here, since ANCHORs can't be followed + by repetition operators. + eg. RE"^*" is invalid or "", + it must not be "". */ + fetch_token (token, regexp, syntax); + return tree; + + case OP_PERIOD: + tree = create_token_tree (dfa, NULL, NULL, token); + if (__glibc_unlikely (tree == NULL)) + { + *err = REG_ESPACE; + return NULL; + } + if (dfa->mb_cur_max > 1) + dfa->has_mb_node = 1; + break; + + case OP_WORD: + case OP_NOTWORD: + tree = build_charclass_op (dfa, regexp->trans, + "alnum", + "_", + token->type == OP_NOTWORD, err); + if (__glibc_unlikely (*err != REG_NOERROR && tree == NULL)) + return NULL; + break; + + case OP_SPACE: + case OP_NOTSPACE: + tree = build_charclass_op (dfa, regexp->trans, + "space", + "", + token->type == OP_NOTSPACE, err); + if (__glibc_unlikely (*err != REG_NOERROR && tree == NULL)) + return NULL; + break; + + case OP_ALT: + case END_OF_RE: + return NULL; + + case BACK_SLASH: + *err = REG_EESCAPE; + return NULL; + + default: + /* Must not happen? */ + DEBUG_ASSERT (false); + return NULL; + } + fetch_token (token, regexp, syntax); + + while (token->type == OP_DUP_ASTERISK || token->type == OP_DUP_PLUS + || token->type == OP_DUP_QUESTION || token->type == OP_OPEN_DUP_NUM) + { + bin_tree_t *dup_tree = parse_dup_op (tree, regexp, dfa, token, + syntax, err); + if (__glibc_unlikely (*err != REG_NOERROR && dup_tree == NULL)) + { + if (tree != NULL) + postorder (tree, free_tree, NULL); + return NULL; + } + tree = dup_tree; + /* In BRE consecutive duplications are not allowed. */ + if ((syntax & RE_CONTEXT_INVALID_DUP) + && (token->type == OP_DUP_ASTERISK + || token->type == OP_OPEN_DUP_NUM)) + { + if (tree != NULL) + postorder (tree, free_tree, NULL); + *err = REG_BADRPT; + return NULL; + } + } + + return tree; +} + +/* This function build the following tree, from regular expression + (): + SUBEXP + | + +*/ + +static bin_tree_t * +parse_sub_exp (re_string_t *regexp, regex_t *preg, re_token_t *token, + reg_syntax_t syntax, Idx nest, reg_errcode_t *err) +{ + re_dfa_t *dfa = preg->buffer; + bin_tree_t *tree; + size_t cur_nsub; + cur_nsub = preg->re_nsub++; + + fetch_token (token, regexp, syntax | RE_CARET_ANCHORS_HERE); + + /* The subexpression may be a null string. */ + if (token->type == OP_CLOSE_SUBEXP) + tree = NULL; + else + { + tree = parse_reg_exp (regexp, preg, token, syntax, nest, err); + if (__glibc_unlikely (*err == REG_NOERROR + && token->type != OP_CLOSE_SUBEXP)) + { + if (tree != NULL) + postorder (tree, free_tree, NULL); + *err = REG_EPAREN; + } + if (__glibc_unlikely (*err != REG_NOERROR)) + return NULL; + } + + if (cur_nsub <= '9' - '1') + dfa->completed_bkref_map |= 1 << cur_nsub; + + tree = create_tree (dfa, tree, NULL, SUBEXP); + if (__glibc_unlikely (tree == NULL)) + { + *err = REG_ESPACE; + return NULL; + } + tree->token.opr.idx = cur_nsub; + return tree; +} + +/* This function parse repetition operators like "*", "+", "{1,3}" etc. */ + +static bin_tree_t * +parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa, + re_token_t *token, reg_syntax_t syntax, reg_errcode_t *err) +{ + bin_tree_t *tree = NULL, *old_tree = NULL; + Idx i, start, end, start_idx = re_string_cur_idx (regexp); + re_token_t start_token = *token; + + if (token->type == OP_OPEN_DUP_NUM) + { + end = 0; + start = fetch_number (regexp, token, syntax); + if (start == -1) + { + if (token->type == CHARACTER && token->opr.c == ',') + start = 0; /* We treat "{,m}" as "{0,m}". */ + else + { + *err = REG_BADBR; /* {} is invalid. */ + return NULL; + } + } + if (__glibc_likely (start != -2)) + { + /* We treat "{n}" as "{n,n}". */ + end = ((token->type == OP_CLOSE_DUP_NUM) ? start + : ((token->type == CHARACTER && token->opr.c == ',') + ? fetch_number (regexp, token, syntax) : -2)); + } + if (__glibc_unlikely (start == -2 || end == -2)) + { + /* Invalid sequence. */ + if (__glibc_unlikely (!(syntax & RE_INVALID_INTERVAL_ORD))) + { + if (token->type == END_OF_RE) + *err = REG_EBRACE; + else + *err = REG_BADBR; + + return NULL; + } + + /* If the syntax bit is set, rollback. */ + re_string_set_index (regexp, start_idx); + *token = start_token; + token->type = CHARACTER; + /* mb_partial and word_char bits should be already initialized by + peek_token. */ + return elem; + } + + if (__glibc_unlikely ((end != -1 && start > end) + || token->type != OP_CLOSE_DUP_NUM)) + { + /* First number greater than second. */ + *err = REG_BADBR; + return NULL; + } + + if (__glibc_unlikely (RE_DUP_MAX < (end == -1 ? start : end))) + { + *err = REG_ESIZE; + return NULL; + } + } + else + { + start = (token->type == OP_DUP_PLUS) ? 1 : 0; + end = (token->type == OP_DUP_QUESTION) ? 1 : -1; + } + + fetch_token (token, regexp, syntax); + + if (__glibc_unlikely (elem == NULL)) + return NULL; + if (__glibc_unlikely (start == 0 && end == 0)) + { + postorder (elem, free_tree, NULL); + return NULL; + } + + /* Extract "{n,m}" to "...{0,}". */ + if (__glibc_unlikely (start > 0)) + { + tree = elem; + for (i = 2; i <= start; ++i) + { + elem = duplicate_tree (elem, dfa); + tree = create_tree (dfa, tree, elem, CONCAT); + if (__glibc_unlikely (elem == NULL || tree == NULL)) + goto parse_dup_op_espace; + } + + if (start == end) + return tree; + + /* Duplicate ELEM before it is marked optional. */ + elem = duplicate_tree (elem, dfa); + if (__glibc_unlikely (elem == NULL)) + goto parse_dup_op_espace; + old_tree = tree; + } + else + old_tree = NULL; + + if (elem->token.type == SUBEXP) + { + uintptr_t subidx = elem->token.opr.idx; + postorder (elem, mark_opt_subexp, (void *) subidx); + } + + tree = create_tree (dfa, elem, NULL, + (end == -1 ? OP_DUP_ASTERISK : OP_ALT)); + if (__glibc_unlikely (tree == NULL)) + goto parse_dup_op_espace; + + /* This loop is actually executed only when end != -1, + to rewrite {0,n} as ((...?)?)?... We have + already created the start+1-th copy. */ + if (TYPE_SIGNED (Idx) || end != -1) + for (i = start + 2; i <= end; ++i) + { + elem = duplicate_tree (elem, dfa); + tree = create_tree (dfa, tree, elem, CONCAT); + if (__glibc_unlikely (elem == NULL || tree == NULL)) + goto parse_dup_op_espace; + + tree = create_tree (dfa, tree, NULL, OP_ALT); + if (__glibc_unlikely (tree == NULL)) + goto parse_dup_op_espace; + } + + if (old_tree) + tree = create_tree (dfa, old_tree, tree, CONCAT); + + return tree; + + parse_dup_op_espace: + *err = REG_ESPACE; + return NULL; +} + +/* Size of the names for collating symbol/equivalence_class/character_class. + I'm not sure, but maybe enough. */ +#define BRACKET_NAME_BUF_SIZE 32 + +#ifndef _LIBC + +/* Convert the byte B to the corresponding wide character. In a + unibyte locale, treat B as itself. In a multibyte locale, return + WEOF if B is an encoding error. */ +static wint_t +parse_byte (unsigned char b, re_dfa_t const *dfa) +{ + return dfa->mb_cur_max > 1 ? __btowc (b) : b; +} + +/* Local function for parse_bracket_exp used in _LIBC environment. + Build the range expression which starts from START_ELEM, and ends + at END_ELEM. The result are written to MBCSET and SBCSET. + RANGE_ALLOC is the allocated size of mbcset->range_starts, and + mbcset->range_ends, is a pointer argument since we may + update it. */ + +static reg_errcode_t +build_range_exp (bitset_t sbcset, re_charset_t *mbcset, Idx *range_alloc, + bracket_elem_t *start_elem, bracket_elem_t *end_elem, + re_dfa_t *dfa, reg_syntax_t syntax, uint_fast32_t nrules, + const unsigned char *collseqmb, const char *collseqwc, + int_fast32_t table_size, const void *symb_table, + const unsigned char *extra) +{ + /* Equivalence Classes and Character Classes can't be a range start/end. */ + if (__glibc_unlikely (start_elem->type == EQUIV_CLASS + || start_elem->type == CHAR_CLASS + || end_elem->type == EQUIV_CLASS + || end_elem->type == CHAR_CLASS)) + return REG_ERANGE; + + /* We can handle no multi character collating elements without libc + support. */ + if (__glibc_unlikely ((start_elem->type == COLL_SYM + && strlen ((char *) start_elem->opr.name) > 1) + || (end_elem->type == COLL_SYM + && strlen ((char *) end_elem->opr.name) > 1))) + return REG_ECOLLATE; + + unsigned int + start_ch = ((start_elem->type == SB_CHAR) ? start_elem->opr.ch + : ((start_elem->type == COLL_SYM) ? start_elem->opr.name[0] + : 0)), + end_ch = ((end_elem->type == SB_CHAR) ? end_elem->opr.ch + : ((end_elem->type == COLL_SYM) ? end_elem->opr.name[0] + : 0)); + wint_t + start_wc = ((start_elem->type == SB_CHAR || start_elem->type == COLL_SYM) + ? parse_byte (start_ch, dfa) : start_elem->opr.wch), + end_wc = ((end_elem->type == SB_CHAR || end_elem->type == COLL_SYM) + ? parse_byte (end_ch, dfa) : end_elem->opr.wch); + + if (start_wc == WEOF || end_wc == WEOF) + return REG_ECOLLATE; + else if (__glibc_unlikely ((syntax & RE_NO_EMPTY_RANGES) + && start_wc > end_wc)) + return REG_ERANGE; + + /* Got valid collation sequence values, add them as a new entry. + However, for !_LIBC we have no collation elements: if the + character set is single byte, the single byte character set + that we build below suffices. parse_bracket_exp passes + no MBCSET if dfa->mb_cur_max == 1. */ + if (dfa->mb_cur_max > 1) + { + /* Check the space of the arrays. */ + if (__glibc_unlikely (*range_alloc == mbcset->nranges)) + { + /* There is not enough space, need realloc. */ + wchar_t *new_array_start, *new_array_end; + Idx new_nranges; + + /* +1 in case of mbcset->nranges is 0. */ + new_nranges = 2 * mbcset->nranges + 1; + /* Use realloc since mbcset->range_starts and mbcset->range_ends + are NULL if *range_alloc == 0. */ + new_array_start = re_realloc (mbcset->range_starts, wchar_t, + new_nranges); + new_array_end = re_realloc (mbcset->range_ends, wchar_t, + new_nranges); + + if (__glibc_unlikely (new_array_start == NULL + || new_array_end == NULL)) + { + re_free (new_array_start); + re_free (new_array_end); + return REG_ESPACE; + } + + mbcset->range_starts = new_array_start; + mbcset->range_ends = new_array_end; + *range_alloc = new_nranges; + } + + mbcset->range_starts[mbcset->nranges] = start_wc; + mbcset->range_ends[mbcset->nranges++] = end_wc; + } + + /* Build the table for single byte characters. */ + for (wchar_t wc = 0; wc < SBC_MAX; ++wc) + { + if (start_wc <= wc && wc <= end_wc) + bitset_set (sbcset, wc); + } + + return REG_NOERROR; +} +#endif /* not _LIBC */ + +#ifndef _LIBC +/* Helper function for parse_bracket_exp only used in case of NOT _LIBC. + Build the collating element which is represented by NAME. + The result are written to MBCSET and SBCSET. + COLL_SYM_ALLOC is the allocated size of mbcset->coll_sym, is a + pointer argument since we may update it. */ + +static reg_errcode_t +build_collating_symbol (bitset_t sbcset, re_charset_t *mbcset, + Idx *coll_sym_alloc, const unsigned char *name, + uint_fast32_t nrules, int_fast32_t table_size, + const void *symb_table, const unsigned char *extra) +{ + size_t name_len = strlen ((const char *) name); + if (__glibc_unlikely (name_len != 1)) + return REG_ECOLLATE; + else + { + bitset_set (sbcset, name[0]); + return REG_NOERROR; + } +} +#endif /* not _LIBC */ + +#ifdef _LIBC +/* Local function for parse_bracket_exp used in _LIBC environment. + Seek the collating symbol entry corresponding to NAME. + Return the index of the symbol in the SYMB_TABLE, + or -1 if not found. */ + +static __always_inline int32_t +seek_collating_symbol_entry (const unsigned char *name, size_t name_len, + const int32_t *symb_table, + int_fast32_t table_size, + const unsigned char *extra) +{ + int_fast32_t elem; + + for (elem = 0; elem < table_size; elem++) + if (symb_table[2 * elem] != 0) + { + int32_t idx = symb_table[2 * elem + 1]; + /* Skip the name of collating element name. */ + idx += 1 + extra[idx]; + if (/* Compare the length of the name. */ + name_len == extra[idx] + /* Compare the name. */ + && memcmp (name, &extra[idx + 1], name_len) == 0) + /* Yep, this is the entry. */ + return elem; + } + return -1; +} + +/* Local function for parse_bracket_exp used in _LIBC environment. + Look up the collation sequence value of BR_ELEM. + Return the value if succeeded, UINT_MAX otherwise. */ + +static __always_inline unsigned int +lookup_collation_sequence_value (bracket_elem_t *br_elem, uint32_t nrules, + const unsigned char *collseqmb, + const char *collseqwc, + int_fast32_t table_size, + const int32_t *symb_table, + const unsigned char *extra) +{ + if (br_elem->type == SB_CHAR) + { + /* if (MB_CUR_MAX == 1) */ + if (nrules == 0) + return collseqmb[br_elem->opr.ch]; + else + { + wint_t wc = __btowc (br_elem->opr.ch); + return __collseq_table_lookup (collseqwc, wc); + } + } + else if (br_elem->type == MB_CHAR) + { + if (nrules != 0) + return __collseq_table_lookup (collseqwc, br_elem->opr.wch); + } + else if (br_elem->type == COLL_SYM) + { + size_t sym_name_len = strlen ((char *) br_elem->opr.name); + if (nrules != 0) + { + int32_t elem, idx; + elem = seek_collating_symbol_entry (br_elem->opr.name, + sym_name_len, + symb_table, table_size, + extra); + if (elem != -1) + { + /* We found the entry. */ + idx = symb_table[2 * elem + 1]; + /* Skip the name of collating element name. */ + idx += 1 + extra[idx]; + /* Skip the byte sequence of the collating element. */ + idx += 1 + extra[idx]; + /* Adjust for the alignment. */ + idx = (idx + 3) & ~3; + /* Skip the multibyte collation sequence value. */ + idx += sizeof (unsigned int); + /* Skip the wide char sequence of the collating element. */ + idx += sizeof (unsigned int) * + (1 + *(unsigned int *) (extra + idx)); + /* Return the collation sequence value. */ + return *(unsigned int *) (extra + idx); + } + else if (sym_name_len == 1) + { + /* No valid character. Match it as a single byte + character. */ + return collseqmb[br_elem->opr.name[0]]; + } + } + else if (sym_name_len == 1) + return collseqmb[br_elem->opr.name[0]]; + } + return UINT_MAX; +} + +/* Local function for parse_bracket_exp used in _LIBC environment. + Build the range expression which starts from START_ELEM, and ends + at END_ELEM. The result are written to MBCSET and SBCSET. + RANGE_ALLOC is the allocated size of mbcset->range_starts, and + mbcset->range_ends, is a pointer argument since we may + update it. */ + +static __always_inline reg_errcode_t +build_range_exp (bitset_t sbcset, re_charset_t *mbcset, Idx *range_alloc, + bracket_elem_t *start_elem, bracket_elem_t *end_elem, + re_dfa_t *dfa, reg_syntax_t syntax, uint32_t nrules, + const unsigned char *collseqmb, const char *collseqwc, + int_fast32_t table_size, const int32_t *symb_table, + const unsigned char *extra) +{ + unsigned int ch; + uint32_t start_collseq; + uint32_t end_collseq; + + /* Equivalence Classes and Character Classes can't be a range + start/end. */ + if (__glibc_unlikely (start_elem->type == EQUIV_CLASS + || start_elem->type == CHAR_CLASS + || end_elem->type == EQUIV_CLASS + || end_elem->type == CHAR_CLASS)) + return REG_ERANGE; + + /* FIXME: Implement rational ranges here, too. */ + start_collseq = lookup_collation_sequence_value (start_elem, nrules, collseqmb, collseqwc, + table_size, symb_table, extra); + end_collseq = lookup_collation_sequence_value (end_elem, nrules, collseqmb, collseqwc, + table_size, symb_table, extra); + /* Check start/end collation sequence values. */ + if (__glibc_unlikely (start_collseq == UINT_MAX + || end_collseq == UINT_MAX)) + return REG_ECOLLATE; + if (__glibc_unlikely ((syntax & RE_NO_EMPTY_RANGES) + && start_collseq > end_collseq)) + return REG_ERANGE; + + /* Got valid collation sequence values, add them as a new entry. + However, if we have no collation elements, and the character set + is single byte, the single byte character set that we + build below suffices. */ + if (nrules > 0 || dfa->mb_cur_max > 1) + { + /* Check the space of the arrays. */ + if (__glibc_unlikely (*range_alloc == mbcset->nranges)) + { + /* There is not enough space, need realloc. */ + uint32_t *new_array_start; + uint32_t *new_array_end; + int new_nranges; + + /* +1 in case of mbcset->nranges is 0. */ + new_nranges = 2 * mbcset->nranges + 1; + new_array_start = re_realloc (mbcset->range_starts, uint32_t, + new_nranges); + new_array_end = re_realloc (mbcset->range_ends, uint32_t, + new_nranges); + + if (__glibc_unlikely (new_array_start == NULL + || new_array_end == NULL)) + return REG_ESPACE; + + mbcset->range_starts = new_array_start; + mbcset->range_ends = new_array_end; + *range_alloc = new_nranges; + } + + mbcset->range_starts[mbcset->nranges] = start_collseq; + mbcset->range_ends[mbcset->nranges++] = end_collseq; + } + + /* Build the table for single byte characters. */ + for (ch = 0; ch < SBC_MAX; ch++) + { + uint32_t ch_collseq; + /* if (MB_CUR_MAX == 1) */ + if (nrules == 0) + ch_collseq = collseqmb[ch]; + else + ch_collseq = __collseq_table_lookup (collseqwc, __btowc (ch)); + if (start_collseq <= ch_collseq && ch_collseq <= end_collseq) + bitset_set (sbcset, ch); + } + return REG_NOERROR; +} + +/* Local function for parse_bracket_exp used in _LIBC environment. + Build the collating element which is represented by NAME. + The result are written to MBCSET and SBCSET. + COLL_SYM_ALLOC is the allocated size of mbcset->coll_sym, is a + pointer argument since we may update it. */ + +static __always_inline reg_errcode_t +build_collating_symbol (bitset_t sbcset, re_charset_t *mbcset, + Idx *coll_sym_alloc, const unsigned char *name, + uint_fast32_t nrules, int_fast32_t table_size, + const int32_t *symb_table, const unsigned char *extra) +{ + int32_t elem, idx; + size_t name_len = strlen ((const char *) name); + if (nrules != 0) + { + elem = seek_collating_symbol_entry (name, name_len, symb_table, + table_size, extra); + if (elem != -1) + { + /* We found the entry. */ + idx = symb_table[2 * elem + 1]; + /* Skip the name of collating element name. */ + idx += 1 + extra[idx]; + } + else if (name_len == 1) + { + /* No valid character, treat it as a normal + character. */ + bitset_set (sbcset, name[0]); + return REG_NOERROR; + } + else + return REG_ECOLLATE; + + /* Got valid collation sequence, add it as a new entry. */ + /* Check the space of the arrays. */ + if (__glibc_unlikely (*coll_sym_alloc == mbcset->ncoll_syms)) + { + /* Not enough, realloc it. */ + /* +1 in case of mbcset->ncoll_syms is 0. */ + int new_coll_sym_alloc = 2 * mbcset->ncoll_syms + 1; + /* Use realloc since mbcset->coll_syms is NULL + if *alloc == 0. */ + int32_t *new_coll_syms = re_realloc (mbcset->coll_syms, int32_t, + new_coll_sym_alloc); + if (__glibc_unlikely (new_coll_syms == NULL)) + return REG_ESPACE; + mbcset->coll_syms = new_coll_syms; + *coll_sym_alloc = new_coll_sym_alloc; + } + mbcset->coll_syms[mbcset->ncoll_syms++] = idx; + return REG_NOERROR; + } + else + { + if (__glibc_unlikely (name_len != 1)) + return REG_ECOLLATE; + else + { + bitset_set (sbcset, name[0]); + return REG_NOERROR; + } + } +} +#endif /* _LIBC */ + +/* This function parse bracket expression like "[abc]", "[a-c]", + "[[.a-a.]]" etc. */ + +static bin_tree_t * +parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token, + reg_syntax_t syntax, reg_errcode_t *err) +{ + const unsigned char *collseqmb = NULL; + const char *collseqwc = NULL; + uint_fast32_t nrules = 0; + int_fast32_t table_size = 0; + const void *symb_table = NULL; + const unsigned char *extra = NULL; + + re_token_t br_token; + re_bitset_ptr_t sbcset; + re_charset_t *mbcset; + Idx coll_sym_alloc = 0, range_alloc = 0, mbchar_alloc = 0; + Idx equiv_class_alloc = 0, char_class_alloc = 0; + bool non_match = false; + bin_tree_t *work_tree; + int token_len; + bool first_round = true; +#ifdef _LIBC + collseqmb = (const unsigned char *) + _NL_CURRENT (LC_COLLATE, _NL_COLLATE_COLLSEQMB); + nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES); + if (nrules) + { + /* + if (MB_CUR_MAX > 1) + */ + collseqwc = _NL_CURRENT (LC_COLLATE, _NL_COLLATE_COLLSEQWC); + table_size = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_SYMB_HASH_SIZEMB); + symb_table = _NL_CURRENT (LC_COLLATE, _NL_COLLATE_SYMB_TABLEMB); + extra = (const unsigned char *) _NL_CURRENT (LC_COLLATE, + _NL_COLLATE_SYMB_EXTRAMB); + } +#endif + sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1); + mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1); + if (__glibc_unlikely (sbcset == NULL || mbcset == NULL)) + { + re_free (sbcset); + re_free (mbcset); + *err = REG_ESPACE; + return NULL; + } + + token_len = peek_token_bracket (token, regexp, syntax); + if (__glibc_unlikely (token->type == END_OF_RE)) + { + *err = REG_BADPAT; + goto parse_bracket_exp_free_return; + } + if (token->type == OP_NON_MATCH_LIST) + { + mbcset->non_match = 1; + non_match = true; + if (syntax & RE_HAT_LISTS_NOT_NEWLINE) + bitset_set (sbcset, '\n'); + re_string_skip_bytes (regexp, token_len); /* Skip a token. */ + token_len = peek_token_bracket (token, regexp, syntax); + if (__glibc_unlikely (token->type == END_OF_RE)) + { + *err = REG_BADPAT; + goto parse_bracket_exp_free_return; + } + } + + /* We treat the first ']' as a normal character. */ + if (token->type == OP_CLOSE_BRACKET) + token->type = CHARACTER; + + while (1) + { + bracket_elem_t start_elem, end_elem; + unsigned char start_name_buf[BRACKET_NAME_BUF_SIZE]; + unsigned char end_name_buf[BRACKET_NAME_BUF_SIZE]; + reg_errcode_t ret; + int token_len2 = 0; + bool is_range_exp = false; + re_token_t token2; + + start_elem.opr.name = start_name_buf; + start_elem.type = COLL_SYM; + ret = parse_bracket_element (&start_elem, regexp, token, token_len, dfa, + syntax, first_round); + if (__glibc_unlikely (ret != REG_NOERROR)) + { + *err = ret; + goto parse_bracket_exp_free_return; + } + first_round = false; + + /* Get information about the next token. We need it in any case. */ + token_len = peek_token_bracket (token, regexp, syntax); + + /* Do not check for ranges if we know they are not allowed. */ + if (start_elem.type != CHAR_CLASS && start_elem.type != EQUIV_CLASS) + { + if (__glibc_unlikely (token->type == END_OF_RE)) + { + *err = REG_EBRACK; + goto parse_bracket_exp_free_return; + } + if (token->type == OP_CHARSET_RANGE) + { + re_string_skip_bytes (regexp, token_len); /* Skip '-'. */ + token_len2 = peek_token_bracket (&token2, regexp, syntax); + if (__glibc_unlikely (token2.type == END_OF_RE)) + { + *err = REG_EBRACK; + goto parse_bracket_exp_free_return; + } + if (token2.type == OP_CLOSE_BRACKET) + { + /* We treat the last '-' as a normal character. */ + re_string_skip_bytes (regexp, -token_len); + token->type = CHARACTER; + } + else + is_range_exp = true; + } + } + + if (is_range_exp == true) + { + end_elem.opr.name = end_name_buf; + end_elem.type = COLL_SYM; + ret = parse_bracket_element (&end_elem, regexp, &token2, token_len2, + dfa, syntax, true); + if (__glibc_unlikely (ret != REG_NOERROR)) + { + *err = ret; + goto parse_bracket_exp_free_return; + } + + token_len = peek_token_bracket (token, regexp, syntax); + + *err = build_range_exp (sbcset, mbcset, &range_alloc, + &start_elem, &end_elem, + dfa, syntax, nrules, collseqmb, collseqwc, + table_size, symb_table, extra); + if (__glibc_unlikely (*err != REG_NOERROR)) + goto parse_bracket_exp_free_return; + } + else + { + switch (start_elem.type) + { + case SB_CHAR: + bitset_set (sbcset, start_elem.opr.ch); + break; + case MB_CHAR: + /* Check whether the array has enough space. */ + if (__glibc_unlikely (mbchar_alloc == mbcset->nmbchars)) + { + wchar_t *new_mbchars; + /* Not enough, realloc it. */ + /* +1 in case of mbcset->nmbchars is 0. */ + mbchar_alloc = 2 * mbcset->nmbchars + 1; + /* Use realloc since array is NULL if *alloc == 0. */ + new_mbchars = re_realloc (mbcset->mbchars, wchar_t, + mbchar_alloc); + if (__glibc_unlikely (new_mbchars == NULL)) + goto parse_bracket_exp_espace; + mbcset->mbchars = new_mbchars; + } + mbcset->mbchars[mbcset->nmbchars++] = start_elem.opr.wch; + break; + case EQUIV_CLASS: + *err = build_equiv_class (sbcset, + mbcset, &equiv_class_alloc, + start_elem.opr.name); + if (__glibc_unlikely (*err != REG_NOERROR)) + goto parse_bracket_exp_free_return; + break; + case COLL_SYM: + *err = build_collating_symbol (sbcset, + mbcset, &coll_sym_alloc, + start_elem.opr.name, + nrules, table_size, symb_table, extra); + if (__glibc_unlikely (*err != REG_NOERROR)) + goto parse_bracket_exp_free_return; + break; + case CHAR_CLASS: + *err = build_charclass (regexp->trans, sbcset, + mbcset, &char_class_alloc, + (const char *) start_elem.opr.name, + syntax); + if (__glibc_unlikely (*err != REG_NOERROR)) + goto parse_bracket_exp_free_return; + break; + default: + DEBUG_ASSERT (false); + break; + } + } + if (__glibc_unlikely (token->type == END_OF_RE)) + { + *err = REG_EBRACK; + goto parse_bracket_exp_free_return; + } + if (token->type == OP_CLOSE_BRACKET) + break; + } + + re_string_skip_bytes (regexp, token_len); /* Skip a token. */ + + /* If it is non-matching list. */ + if (non_match) + bitset_not (sbcset); + + /* Ensure only single byte characters are set. */ + if (dfa->mb_cur_max > 1) + bitset_mask (sbcset, dfa->sb_char); + + if (mbcset->nmbchars || mbcset->ncoll_syms || mbcset->nequiv_classes + || mbcset->nranges || (dfa->mb_cur_max > 1 && (mbcset->nchar_classes + || mbcset->non_match))) + { + bin_tree_t *mbc_tree; + int sbc_idx; + /* Build a tree for complex bracket. */ + dfa->has_mb_node = 1; + br_token.type = COMPLEX_BRACKET; + br_token.opr.mbcset = mbcset; + mbc_tree = create_token_tree (dfa, NULL, NULL, &br_token); + if (__glibc_unlikely (mbc_tree == NULL)) + goto parse_bracket_exp_espace; + for (sbc_idx = 0; sbc_idx < BITSET_WORDS; ++sbc_idx) + if (sbcset[sbc_idx]) + break; + /* If there are no bits set in sbcset, there is no point + of having both SIMPLE_BRACKET and COMPLEX_BRACKET. */ + if (sbc_idx < BITSET_WORDS) + { + /* Build a tree for simple bracket. */ + br_token.type = SIMPLE_BRACKET; + br_token.opr.sbcset = sbcset; + work_tree = create_token_tree (dfa, NULL, NULL, &br_token); + if (__glibc_unlikely (work_tree == NULL)) + goto parse_bracket_exp_espace; + + /* Then join them by ALT node. */ + work_tree = create_tree (dfa, work_tree, mbc_tree, OP_ALT); + if (__glibc_unlikely (work_tree == NULL)) + goto parse_bracket_exp_espace; + } + else + { + re_free (sbcset); + work_tree = mbc_tree; + } + } + else + { + free_charset (mbcset); + /* Build a tree for simple bracket. */ + br_token.type = SIMPLE_BRACKET; + br_token.opr.sbcset = sbcset; + work_tree = create_token_tree (dfa, NULL, NULL, &br_token); + if (__glibc_unlikely (work_tree == NULL)) + goto parse_bracket_exp_espace; + } + return work_tree; + + parse_bracket_exp_espace: + *err = REG_ESPACE; + parse_bracket_exp_free_return: + re_free (sbcset); + free_charset (mbcset); + return NULL; +} + +/* Parse an element in the bracket expression. */ + +static reg_errcode_t +parse_bracket_element (bracket_elem_t *elem, re_string_t *regexp, + re_token_t *token, int token_len, re_dfa_t *dfa, + reg_syntax_t syntax, bool accept_hyphen) +{ + int cur_char_size; + cur_char_size = re_string_char_size_at (regexp, re_string_cur_idx (regexp)); + if (cur_char_size > 1) + { + elem->type = MB_CHAR; + elem->opr.wch = re_string_wchar_at (regexp, re_string_cur_idx (regexp)); + re_string_skip_bytes (regexp, cur_char_size); + return REG_NOERROR; + } + re_string_skip_bytes (regexp, token_len); /* Skip a token. */ + if (token->type == OP_OPEN_COLL_ELEM || token->type == OP_OPEN_CHAR_CLASS + || token->type == OP_OPEN_EQUIV_CLASS) + return parse_bracket_symbol (elem, regexp, token); + if (__glibc_unlikely (token->type == OP_CHARSET_RANGE) && !accept_hyphen) + { + /* A '-' must only appear as anything but a range indicator before + the closing bracket. Everything else is an error. */ + re_token_t token2; + (void) peek_token_bracket (&token2, regexp, syntax); + if (token2.type != OP_CLOSE_BRACKET) + /* The actual error value is not standardized since this whole + case is undefined. But ERANGE makes good sense. */ + return REG_ERANGE; + } + elem->type = SB_CHAR; + elem->opr.ch = token->opr.c; + return REG_NOERROR; +} + +/* Parse a bracket symbol in the bracket expression. Bracket symbols are + such as [::], [..], and + [==]. */ + +static reg_errcode_t +parse_bracket_symbol (bracket_elem_t *elem, re_string_t *regexp, + re_token_t *token) +{ + unsigned char ch, delim = token->opr.c; + int i = 0; + if (re_string_eoi(regexp)) + return REG_EBRACK; + for (;; ++i) + { + if (i >= BRACKET_NAME_BUF_SIZE) + return REG_EBRACK; + if (token->type == OP_OPEN_CHAR_CLASS) + ch = re_string_fetch_byte_case (regexp); + else + ch = re_string_fetch_byte (regexp); + if (re_string_eoi(regexp)) + return REG_EBRACK; + if (ch == delim && re_string_peek_byte (regexp, 0) == ']') + break; + elem->opr.name[i] = ch; + } + re_string_skip_bytes (regexp, 1); + elem->opr.name[i] = '\0'; + switch (token->type) + { + case OP_OPEN_COLL_ELEM: + elem->type = COLL_SYM; + break; + case OP_OPEN_EQUIV_CLASS: + elem->type = EQUIV_CLASS; + break; + case OP_OPEN_CHAR_CLASS: + elem->type = CHAR_CLASS; + break; + default: + break; + } + return REG_NOERROR; +} + + /* Helper function for parse_bracket_exp. + Build the equivalence class which is represented by NAME. + The result are written to MBCSET and SBCSET. + EQUIV_CLASS_ALLOC is the allocated size of mbcset->equiv_classes, + is a pointer argument since we may update it. */ + +static reg_errcode_t +build_equiv_class (bitset_t sbcset, re_charset_t *mbcset, + Idx *equiv_class_alloc, const unsigned char *name) +{ +#ifdef _LIBC + uint32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES); + if (nrules != 0) + { + const int32_t *table, *indirect; + const unsigned char *weights, *extra, *cp; + unsigned char char_buf[2]; + int32_t idx1, idx2; + unsigned int ch; + size_t len; + /* Calculate the index for equivalence class. */ + cp = name; + table = (const int32_t *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB); + weights = (const unsigned char *) _NL_CURRENT (LC_COLLATE, + _NL_COLLATE_WEIGHTMB); + extra = (const unsigned char *) _NL_CURRENT (LC_COLLATE, + _NL_COLLATE_EXTRAMB); + indirect = (const int32_t *) _NL_CURRENT (LC_COLLATE, + _NL_COLLATE_INDIRECTMB); + idx1 = findidx (table, indirect, extra, &cp, -1); + if (__glibc_unlikely (idx1 == 0 || *cp != '\0')) + /* This isn't a valid character. */ + return REG_ECOLLATE; + + /* Build single byte matching table for this equivalence class. */ + len = weights[idx1 & 0xffffff]; + for (ch = 0; ch < SBC_MAX; ++ch) + { + char_buf[0] = ch; + cp = char_buf; + idx2 = findidx (table, indirect, extra, &cp, 1); +/* + idx2 = table[ch]; +*/ + if (idx2 == 0) + /* This isn't a valid character. */ + continue; + /* Compare only if the length matches and the collation rule + index is the same. */ + if (len == weights[idx2 & 0xffffff] && (idx1 >> 24) == (idx2 >> 24) + && memcmp (weights + (idx1 & 0xffffff) + 1, + weights + (idx2 & 0xffffff) + 1, len) == 0) + bitset_set (sbcset, ch); + } + /* Check whether the array has enough space. */ + if (__glibc_unlikely (*equiv_class_alloc == mbcset->nequiv_classes)) + { + /* Not enough, realloc it. */ + /* +1 in case of mbcset->nequiv_classes is 0. */ + Idx new_equiv_class_alloc = 2 * mbcset->nequiv_classes + 1; + /* Use realloc since the array is NULL if *alloc == 0. */ + int32_t *new_equiv_classes = re_realloc (mbcset->equiv_classes, + int32_t, + new_equiv_class_alloc); + if (__glibc_unlikely (new_equiv_classes == NULL)) + return REG_ESPACE; + mbcset->equiv_classes = new_equiv_classes; + *equiv_class_alloc = new_equiv_class_alloc; + } + mbcset->equiv_classes[mbcset->nequiv_classes++] = idx1; + } + else +#endif /* _LIBC */ + { + if (__glibc_unlikely (strlen ((const char *) name) != 1)) + return REG_ECOLLATE; + bitset_set (sbcset, *name); + } + return REG_NOERROR; +} + + /* Helper function for parse_bracket_exp. + Build the character class which is represented by NAME. + The result are written to MBCSET and SBCSET. + CHAR_CLASS_ALLOC is the allocated size of mbcset->char_classes, + is a pointer argument since we may update it. */ + +static reg_errcode_t +build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset, + re_charset_t *mbcset, Idx *char_class_alloc, + const char *class_name, reg_syntax_t syntax) +{ + int i; + const char *name = class_name; + + /* In case of REG_ICASE "upper" and "lower" match the both of + upper and lower cases. */ + if ((syntax & RE_ICASE) + && (strcmp (name, "upper") == 0 || strcmp (name, "lower") == 0)) + name = "alpha"; + + /* Check the space of the arrays. */ + if (__glibc_unlikely (*char_class_alloc == mbcset->nchar_classes)) + { + /* Not enough, realloc it. */ + /* +1 in case of mbcset->nchar_classes is 0. */ + Idx new_char_class_alloc = 2 * mbcset->nchar_classes + 1; + /* Use realloc since array is NULL if *alloc == 0. */ + wctype_t *new_char_classes = re_realloc (mbcset->char_classes, wctype_t, + new_char_class_alloc); + if (__glibc_unlikely (new_char_classes == NULL)) + return REG_ESPACE; + mbcset->char_classes = new_char_classes; + *char_class_alloc = new_char_class_alloc; + } + mbcset->char_classes[mbcset->nchar_classes++] = __wctype (name); + +#define BUILD_CHARCLASS_LOOP(ctype_func) \ + do { \ + if (__glibc_unlikely (trans != NULL)) \ + { \ + for (i = 0; i < SBC_MAX; ++i) \ + if (ctype_func (i)) \ + bitset_set (sbcset, trans[i]); \ + } \ + else \ + { \ + for (i = 0; i < SBC_MAX; ++i) \ + if (ctype_func (i)) \ + bitset_set (sbcset, i); \ + } \ + } while (0) + + if (strcmp (name, "alnum") == 0) + BUILD_CHARCLASS_LOOP (isalnum); + else if (strcmp (name, "cntrl") == 0) + BUILD_CHARCLASS_LOOP (iscntrl); + else if (strcmp (name, "lower") == 0) + BUILD_CHARCLASS_LOOP (islower); + else if (strcmp (name, "space") == 0) + BUILD_CHARCLASS_LOOP (isspace); + else if (strcmp (name, "alpha") == 0) + BUILD_CHARCLASS_LOOP (isalpha); + else if (strcmp (name, "digit") == 0) + BUILD_CHARCLASS_LOOP (isdigit); + else if (strcmp (name, "print") == 0) + BUILD_CHARCLASS_LOOP (isprint); + else if (strcmp (name, "upper") == 0) + BUILD_CHARCLASS_LOOP (isupper); + else if (strcmp (name, "blank") == 0) + BUILD_CHARCLASS_LOOP (isblank); + else if (strcmp (name, "graph") == 0) + BUILD_CHARCLASS_LOOP (isgraph); + else if (strcmp (name, "punct") == 0) + BUILD_CHARCLASS_LOOP (ispunct); + else if (strcmp (name, "xdigit") == 0) + BUILD_CHARCLASS_LOOP (isxdigit); + else + return REG_ECTYPE; + + return REG_NOERROR; +} + +static bin_tree_t * +build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans, + const char *class_name, + const char *extra, bool non_match, + reg_errcode_t *err) +{ + re_bitset_ptr_t sbcset; + re_charset_t *mbcset; + Idx alloc = 0; + reg_errcode_t ret; + bin_tree_t *tree; + + sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1); + if (__glibc_unlikely (sbcset == NULL)) + { + *err = REG_ESPACE; + return NULL; + } + mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1); + if (__glibc_unlikely (mbcset == NULL)) + { + re_free (sbcset); + *err = REG_ESPACE; + return NULL; + } + mbcset->non_match = non_match; + + /* We don't care the syntax in this case. */ + ret = build_charclass (trans, sbcset, mbcset, &alloc, class_name, 0); + + if (__glibc_unlikely (ret != REG_NOERROR)) + { + re_free (sbcset); + free_charset (mbcset); + *err = ret; + return NULL; + } + /* \w match '_' also. */ + for (; *extra; extra++) + bitset_set (sbcset, *extra); + + /* If it is non-matching list. */ + if (non_match) + bitset_not (sbcset); + + /* Ensure only single byte characters are set. */ + if (dfa->mb_cur_max > 1) + bitset_mask (sbcset, dfa->sb_char); + + /* Build a tree for simple bracket. */ + re_token_t br_token = { .type = SIMPLE_BRACKET, .opr.sbcset = sbcset }; + tree = create_token_tree (dfa, NULL, NULL, &br_token); + if (__glibc_unlikely (tree == NULL)) + goto build_word_op_espace; + + if (dfa->mb_cur_max > 1) + { + bin_tree_t *mbc_tree; + /* Build a tree for complex bracket. */ + br_token.type = COMPLEX_BRACKET; + br_token.opr.mbcset = mbcset; + dfa->has_mb_node = 1; + mbc_tree = create_token_tree (dfa, NULL, NULL, &br_token); + if (__glibc_unlikely (mbc_tree == NULL)) + goto build_word_op_espace; + /* Then join them by ALT node. */ + tree = create_tree (dfa, tree, mbc_tree, OP_ALT); + if (__glibc_likely (mbc_tree != NULL)) + return tree; + } + else + { + free_charset (mbcset); + return tree; + } + + build_word_op_espace: + re_free (sbcset); + free_charset (mbcset); + *err = REG_ESPACE; + return NULL; +} + +/* This is intended for the expressions like "a{1,3}". + Fetch a number from 'input', and return the number. + Return -1 if the number field is empty like "{,1}". + Return RE_DUP_MAX + 1 if the number field is too large. + Return -2 if an error occurred. */ + +static Idx +fetch_number (re_string_t *input, re_token_t *token, reg_syntax_t syntax) +{ + Idx num = -1; + unsigned char c; + while (1) + { + fetch_token (token, input, syntax); + c = token->opr.c; + if (__glibc_unlikely (token->type == END_OF_RE)) + return -2; + if (token->type == OP_CLOSE_DUP_NUM || c == ',') + break; + num = ((token->type != CHARACTER || c < '0' || '9' < c || num == -2) + ? -2 + : num == -1 + ? c - '0' + : MIN (RE_DUP_MAX + 1, num * 10 + c - '0')); + } + return num; +} + +static void +free_charset (re_charset_t *cset) +{ + re_free (cset->mbchars); +#ifdef _LIBC + re_free (cset->coll_syms); + re_free (cset->equiv_classes); +#endif + re_free (cset->range_starts); + re_free (cset->range_ends); + re_free (cset->char_classes); + re_free (cset); +} + +/* Functions for binary tree operation. */ + +/* Create a tree node. */ + +static bin_tree_t * +create_tree (re_dfa_t *dfa, bin_tree_t *left, bin_tree_t *right, + re_token_type_t type) +{ + re_token_t t = { .type = type }; + return create_token_tree (dfa, left, right, &t); +} + +static bin_tree_t * +create_token_tree (re_dfa_t *dfa, bin_tree_t *left, bin_tree_t *right, + const re_token_t *token) +{ + bin_tree_t *tree; + if (__glibc_unlikely (dfa->str_tree_storage_idx == BIN_TREE_STORAGE_SIZE)) + { + bin_tree_storage_t *storage = re_malloc (bin_tree_storage_t, 1); + + if (storage == NULL) + return NULL; + storage->next = dfa->str_tree_storage; + dfa->str_tree_storage = storage; + dfa->str_tree_storage_idx = 0; + } + tree = &dfa->str_tree_storage->data[dfa->str_tree_storage_idx++]; + + tree->parent = NULL; + tree->left = left; + tree->right = right; + tree->token = *token; + tree->token.duplicated = 0; + tree->token.opt_subexp = 0; + tree->first = NULL; + tree->next = NULL; + tree->node_idx = -1; + + if (left != NULL) + left->parent = tree; + if (right != NULL) + right->parent = tree; + return tree; +} + +/* Mark the tree SRC as an optional subexpression. + To be called from preorder or postorder. */ + +static reg_errcode_t +mark_opt_subexp (void *extra, bin_tree_t *node) +{ + Idx idx = (uintptr_t) extra; + if (node->token.type == SUBEXP && node->token.opr.idx == idx) + node->token.opt_subexp = 1; + + return REG_NOERROR; +} + +/* Free the allocated memory inside NODE. */ + +static void +free_token (re_token_t *node) +{ + if (node->type == COMPLEX_BRACKET && node->duplicated == 0) + free_charset (node->opr.mbcset); + else if (node->type == SIMPLE_BRACKET && node->duplicated == 0) + re_free (node->opr.sbcset); +} + +/* Worker function for tree walking. Free the allocated memory inside NODE + and its children. */ + +static reg_errcode_t +free_tree (void *extra, bin_tree_t *node) +{ + free_token (&node->token); + return REG_NOERROR; +} + + +/* Duplicate the node SRC, and return new node. This is a preorder + visit similar to the one implemented by the generic visitor, but + we need more infrastructure to maintain two parallel trees --- so, + it's easier to duplicate. */ + +static bin_tree_t * +duplicate_tree (const bin_tree_t *root, re_dfa_t *dfa) +{ + const bin_tree_t *node; + bin_tree_t *dup_root; + bin_tree_t **p_new = &dup_root, *dup_node = root->parent; + + for (node = root; ; ) + { + /* Create a new tree and link it back to the current parent. */ + *p_new = create_token_tree (dfa, NULL, NULL, &node->token); + if (*p_new == NULL) + return NULL; + (*p_new)->parent = dup_node; + (*p_new)->token.duplicated = 1; + dup_node = *p_new; + + /* Go to the left node, or up and to the right. */ + if (node->left) + { + node = node->left; + p_new = &dup_node->left; + } + else + { + const bin_tree_t *prev = NULL; + while (node->right == prev || node->right == NULL) + { + prev = node; + node = node->parent; + dup_node = dup_node->parent; + if (!node) + return dup_root; + } + node = node->right; + p_new = &dup_node->right; + } + } +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/regex.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/regex.c new file mode 100644 index 00000000..3beb0deb --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/regex.c @@ -0,0 +1,84 @@ +/* Extended regular expression matching and search library. + Copyright (C) 2002-2023 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Isamu Hasegawa . + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#define __STDC_WANT_IEC_60559_BFP_EXT__ + +#ifndef _LIBC +# include + +# if __GNUC_PREREQ (4, 6) +# pragma GCC diagnostic ignored "-Wsuggest-attribute=pure" +# pragma GCC diagnostic ignored "-Wvla" +# endif +# if __GNUC_PREREQ (4, 3) +# pragma GCC diagnostic ignored "-Wold-style-definition" +# pragma GCC diagnostic ignored "-Wtype-limits" +# endif +#endif + +/* Make sure no one compiles this code with a C++ compiler. */ +#if defined __cplusplus && defined _LIBC +# error "This is C code, use a C compiler" +#endif + +#ifdef _LIBC +/* We have to keep the namespace clean. */ +# define regfree(preg) __regfree (preg) +# define regexec(pr, st, nm, pm, ef) __regexec (pr, st, nm, pm, ef) +# define regcomp(preg, pattern, cflags) __regcomp (preg, pattern, cflags) +# define regerror(errcode, preg, errbuf, errbuf_size) \ + __regerror(errcode, preg, errbuf, errbuf_size) +# define re_set_registers(bu, re, nu, st, en) \ + __re_set_registers (bu, re, nu, st, en) +# define re_match_2(bufp, string1, size1, string2, size2, pos, regs, stop) \ + __re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) +# define re_match(bufp, string, size, pos, regs) \ + __re_match (bufp, string, size, pos, regs) +# define re_search(bufp, string, size, startpos, range, regs) \ + __re_search (bufp, string, size, startpos, range, regs) +# define re_compile_pattern(pattern, length, bufp) \ + __re_compile_pattern (pattern, length, bufp) +# define re_set_syntax(syntax) __re_set_syntax (syntax) +# define re_search_2(bufp, st1, s1, st2, s2, startpos, range, regs, stop) \ + __re_search_2 (bufp, st1, s1, st2, s2, startpos, range, regs, stop) +# define re_compile_fastmap(bufp) __re_compile_fastmap (bufp) + +# include "../locale/localeinfo.h" +#endif + +/* On some systems, limits.h sets RE_DUP_MAX to a lower value than + GNU regex allows. Include it before , which correctly + #undefs RE_DUP_MAX and sets it to the right value. */ +#include + +#include +#include "regex_internal.h" + +#include "regex_internal.c" +#include "regcomp.c" +#include "regexec.c" + +/* Binary backward compatibility. */ +#if _LIBC +# include +# if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_3) +link_warning (re_max_failures, "the 're_max_failures' variable is obsolete and will go away.") +int re_max_failures = 2000; +# endif +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/regex.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/regex.h new file mode 100644 index 00000000..9ef0252f --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/regex.h @@ -0,0 +1,699 @@ +/* Definitions for data structures and routines for the regular + expression library. + Copyright (C) 1985, 1989-2023 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _REGEX_H +#define _REGEX_H 1 + +#include + +/* Allow the use in C++ code. */ +#ifdef __cplusplus +extern "C" { +#endif + +/* Define __USE_GNU to declare GNU extensions that violate the + POSIX name space rules. */ +#ifdef _GNU_SOURCE +# define __USE_GNU 1 +#endif + +#ifdef _REGEX_LARGE_OFFSETS + +/* Use types and values that are wide enough to represent signed and + unsigned byte offsets in memory. This currently works only when + the regex code is used outside of the GNU C library; it is not yet + supported within glibc itself, and glibc users should not define + _REGEX_LARGE_OFFSETS. */ + +/* The type of object sizes. */ +typedef size_t __re_size_t; + +/* The type of object sizes, in places where the traditional code + uses unsigned long int. */ +typedef size_t __re_long_size_t; + +#else + +/* The traditional GNU regex implementation mishandles strings longer + than INT_MAX. */ +typedef unsigned int __re_size_t; +typedef unsigned long int __re_long_size_t; + +#endif + +/* The following two types have to be signed and unsigned integer type + wide enough to hold a value of a pointer. For most ANSI compilers + ptrdiff_t and size_t should be likely OK. Still size of these two + types is 2 for Microsoft C. Ugh... */ +typedef long int s_reg_t; +typedef unsigned long int active_reg_t; + +/* The following bits are used to determine the regexp syntax we + recognize. The set/not-set meanings are chosen so that Emacs syntax + remains the value 0. The bits are given in alphabetical order, and + the definitions shifted by one from the previous bit; thus, when we + add or remove a bit, only one other definition need change. */ +typedef unsigned long int reg_syntax_t; + +#ifdef __USE_GNU +/* If this bit is not set, then \ inside a bracket expression is literal. + If set, then such a \ quotes the following character. */ +# define RE_BACKSLASH_ESCAPE_IN_LISTS ((unsigned long int) 1) + +/* If this bit is not set, then + and ? are operators, and \+ and \? are + literals. + If set, then \+ and \? are operators and + and ? are literals. */ +# define RE_BK_PLUS_QM (RE_BACKSLASH_ESCAPE_IN_LISTS << 1) + +/* If this bit is set, then character classes are supported. They are: + [:alpha:], [:upper:], [:lower:], [:digit:], [:alnum:], [:xdigit:], + [:space:], [:print:], [:punct:], [:graph:], and [:cntrl:]. + If not set, then character classes are not supported. */ +# define RE_CHAR_CLASSES (RE_BK_PLUS_QM << 1) + +/* If this bit is set, then ^ and $ are always anchors (outside bracket + expressions, of course). + If this bit is not set, then it depends: + ^ is an anchor if it is at the beginning of a regular + expression or after an open-group or an alternation operator; + $ is an anchor if it is at the end of a regular expression, or + before a close-group or an alternation operator. + + This bit could be (re)combined with RE_CONTEXT_INDEP_OPS, because + POSIX draft 11.2 says that * etc. in leading positions is undefined. + We already implemented a previous draft which made those constructs + invalid, though, so we haven't changed the code back. */ +# define RE_CONTEXT_INDEP_ANCHORS (RE_CHAR_CLASSES << 1) + +/* If this bit is set, then special characters are always special + regardless of where they are in the pattern. + If this bit is not set, then special characters are special only in + some contexts; otherwise they are ordinary. Specifically, + * + ? and intervals are only special when not after the beginning, + open-group, or alternation operator. */ +# define RE_CONTEXT_INDEP_OPS (RE_CONTEXT_INDEP_ANCHORS << 1) + +/* If this bit is set, then *, +, ?, and { cannot be first in an re or + immediately after an alternation or begin-group operator. */ +# define RE_CONTEXT_INVALID_OPS (RE_CONTEXT_INDEP_OPS << 1) + +/* If this bit is set, then . matches newline. + If not set, then it doesn't. */ +# define RE_DOT_NEWLINE (RE_CONTEXT_INVALID_OPS << 1) + +/* If this bit is set, then . doesn't match NUL. + If not set, then it does. */ +# define RE_DOT_NOT_NULL (RE_DOT_NEWLINE << 1) + +/* If this bit is set, nonmatching lists [^...] do not match newline. + If not set, they do. */ +# define RE_HAT_LISTS_NOT_NEWLINE (RE_DOT_NOT_NULL << 1) + +/* If this bit is set, either \{...\} or {...} defines an + interval, depending on RE_NO_BK_BRACES. + If not set, \{, \}, {, and } are literals. */ +# define RE_INTERVALS (RE_HAT_LISTS_NOT_NEWLINE << 1) + +/* If this bit is set, +, ? and | aren't recognized as operators. + If not set, they are. */ +# define RE_LIMITED_OPS (RE_INTERVALS << 1) + +/* If this bit is set, newline is an alternation operator. + If not set, newline is literal. */ +# define RE_NEWLINE_ALT (RE_LIMITED_OPS << 1) + +/* If this bit is set, then '{...}' defines an interval, and \{ and \} + are literals. + If not set, then '\{...\}' defines an interval. */ +# define RE_NO_BK_BRACES (RE_NEWLINE_ALT << 1) + +/* If this bit is set, (...) defines a group, and \( and \) are literals. + If not set, \(...\) defines a group, and ( and ) are literals. */ +# define RE_NO_BK_PARENS (RE_NO_BK_BRACES << 1) + +/* If this bit is set, then \ matches . + If not set, then \ is a back-reference. */ +# define RE_NO_BK_REFS (RE_NO_BK_PARENS << 1) + +/* If this bit is set, then | is an alternation operator, and \| is literal. + If not set, then \| is an alternation operator, and | is literal. */ +# define RE_NO_BK_VBAR (RE_NO_BK_REFS << 1) + +/* If this bit is set, then an ending range point collating higher + than the starting range point, as in [z-a], is invalid. + If not set, then when ending range point collates higher than the + starting range point, the range is ignored. */ +# define RE_NO_EMPTY_RANGES (RE_NO_BK_VBAR << 1) + +/* If this bit is set, then an unmatched ) is ordinary. + If not set, then an unmatched ) is invalid. */ +# define RE_UNMATCHED_RIGHT_PAREN_ORD (RE_NO_EMPTY_RANGES << 1) + +/* If this bit is set, succeed as soon as we match the whole pattern, + without further backtracking. */ +# define RE_NO_POSIX_BACKTRACKING (RE_UNMATCHED_RIGHT_PAREN_ORD << 1) + +/* If this bit is set, do not process the GNU regex operators. + If not set, then the GNU regex operators are recognized. */ +# define RE_NO_GNU_OPS (RE_NO_POSIX_BACKTRACKING << 1) + +/* If this bit is set, turn on internal regex debugging. + If not set, and debugging was on, turn it off. + This only works if regex.c is compiled -DDEBUG. + We define this bit always, so that all that's needed to turn on + debugging is to recompile regex.c; the calling code can always have + this bit set, and it won't affect anything in the normal case. */ +# define RE_DEBUG (RE_NO_GNU_OPS << 1) + +/* If this bit is set, a syntactically invalid interval is treated as + a string of ordinary characters. For example, the ERE 'a{1' is + treated as 'a\{1'. */ +# define RE_INVALID_INTERVAL_ORD (RE_DEBUG << 1) + +/* If this bit is set, then ignore case when matching. + If not set, then case is significant. */ +# define RE_ICASE (RE_INVALID_INTERVAL_ORD << 1) + +/* This bit is used internally like RE_CONTEXT_INDEP_ANCHORS but only + for ^, because it is difficult to scan the regex backwards to find + whether ^ should be special. */ +# define RE_CARET_ANCHORS_HERE (RE_ICASE << 1) + +/* If this bit is set, then \{ cannot be first in a regex or + immediately after an alternation, open-group or \} operator. */ +# define RE_CONTEXT_INVALID_DUP (RE_CARET_ANCHORS_HERE << 1) + +/* If this bit is set, then no_sub will be set to 1 during + re_compile_pattern. */ +# define RE_NO_SUB (RE_CONTEXT_INVALID_DUP << 1) +#endif + +/* This global variable defines the particular regexp syntax to use (for + some interfaces). When a regexp is compiled, the syntax used is + stored in the pattern buffer, so changing this does not affect + already-compiled regexps. */ +extern reg_syntax_t re_syntax_options; + +#ifdef __USE_GNU +/* Define combinations of the above bits for the standard possibilities. + (The [[[ comments delimit what gets put into the Texinfo file, so + don't delete them!) */ +/* [[[begin syntaxes]]] */ +# define RE_SYNTAX_EMACS 0 + +# define RE_SYNTAX_AWK \ + (RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DOT_NOT_NULL \ + | RE_NO_BK_PARENS | RE_NO_BK_REFS \ + | RE_NO_BK_VBAR | RE_NO_EMPTY_RANGES \ + | RE_DOT_NEWLINE | RE_CONTEXT_INDEP_ANCHORS \ + | RE_CHAR_CLASSES \ + | RE_UNMATCHED_RIGHT_PAREN_ORD | RE_NO_GNU_OPS) + +# define RE_SYNTAX_GNU_AWK \ + ((RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS \ + | RE_INVALID_INTERVAL_ORD) \ + & ~(RE_DOT_NOT_NULL | RE_CONTEXT_INDEP_OPS \ + | RE_CONTEXT_INVALID_OPS )) + +# define RE_SYNTAX_POSIX_AWK \ + (RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS \ + | RE_INTERVALS | RE_NO_GNU_OPS \ + | RE_INVALID_INTERVAL_ORD) + +# define RE_SYNTAX_GREP \ + ((RE_SYNTAX_POSIX_BASIC | RE_NEWLINE_ALT) \ + & ~(RE_CONTEXT_INVALID_DUP | RE_DOT_NOT_NULL)) + +# define RE_SYNTAX_EGREP \ + ((RE_SYNTAX_POSIX_EXTENDED | RE_INVALID_INTERVAL_ORD | RE_NEWLINE_ALT) \ + & ~(RE_CONTEXT_INVALID_OPS | RE_DOT_NOT_NULL)) + +/* POSIX grep -E behavior is no longer incompatible with GNU. */ +# define RE_SYNTAX_POSIX_EGREP \ + RE_SYNTAX_EGREP + +/* P1003.2/D11.2, section 4.20.7.1, lines 5078ff. */ +# define RE_SYNTAX_ED RE_SYNTAX_POSIX_BASIC + +# define RE_SYNTAX_SED RE_SYNTAX_POSIX_BASIC + +/* Syntax bits common to both basic and extended POSIX regex syntax. */ +# define _RE_SYNTAX_POSIX_COMMON \ + (RE_CHAR_CLASSES | RE_DOT_NEWLINE | RE_DOT_NOT_NULL \ + | RE_INTERVALS | RE_NO_EMPTY_RANGES) + +# define RE_SYNTAX_POSIX_BASIC \ + (_RE_SYNTAX_POSIX_COMMON | RE_BK_PLUS_QM | RE_CONTEXT_INVALID_DUP) + +/* Differs from ..._POSIX_BASIC only in that RE_BK_PLUS_QM becomes + RE_LIMITED_OPS, i.e., \? \+ \| are not recognized. Actually, this + isn't minimal, since other operators, such as \`, aren't disabled. */ +# define RE_SYNTAX_POSIX_MINIMAL_BASIC \ + (_RE_SYNTAX_POSIX_COMMON | RE_LIMITED_OPS) + +# define RE_SYNTAX_POSIX_EXTENDED \ + (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \ + | RE_CONTEXT_INDEP_OPS | RE_NO_BK_BRACES \ + | RE_NO_BK_PARENS | RE_NO_BK_VBAR \ + | RE_CONTEXT_INVALID_OPS | RE_UNMATCHED_RIGHT_PAREN_ORD) + +/* Differs from ..._POSIX_EXTENDED in that RE_CONTEXT_INDEP_OPS is + removed and RE_NO_BK_REFS is added. */ +# define RE_SYNTAX_POSIX_MINIMAL_EXTENDED \ + (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \ + | RE_CONTEXT_INVALID_OPS | RE_NO_BK_BRACES \ + | RE_NO_BK_PARENS | RE_NO_BK_REFS \ + | RE_NO_BK_VBAR | RE_UNMATCHED_RIGHT_PAREN_ORD) +/* [[[end syntaxes]]] */ + +/* Maximum number of duplicates an interval can allow. POSIX-conforming + systems might define this in , but we want our + value, so remove any previous define. */ +# ifdef _REGEX_INCLUDE_LIMITS_H +# include +# endif +# ifdef RE_DUP_MAX +# undef RE_DUP_MAX +# endif + +/* RE_DUP_MAX is 2**15 - 1 because an earlier implementation stored + the counter as a 2-byte signed integer. This is no longer true, so + RE_DUP_MAX could be increased to (INT_MAX / 10 - 1), or to + ((SIZE_MAX - 9) / 10) if _REGEX_LARGE_OFFSETS is defined. + However, there would be a huge performance problem if someone + actually used a pattern like a\{214748363\}, so RE_DUP_MAX retains + its historical value. */ +# define RE_DUP_MAX (0x7fff) +#endif + + +/* POSIX 'cflags' bits (i.e., information for 'regcomp'). */ + +/* If this bit is set, then use extended regular expression syntax. + If not set, then use basic regular expression syntax. */ +#define REG_EXTENDED 1 + +/* If this bit is set, then ignore case when matching. + If not set, then case is significant. */ +#define REG_ICASE (1 << 1) + +/* If this bit is set, then anchors do not match at newline + characters in the string. + If not set, then anchors do match at newlines. */ +#define REG_NEWLINE (1 << 2) + +/* If this bit is set, then report only success or fail in regexec. + If not set, then returns differ between not matching and errors. */ +#define REG_NOSUB (1 << 3) + + +/* POSIX 'eflags' bits (i.e., information for regexec). */ + +/* If this bit is set, then the beginning-of-line operator doesn't match + the beginning of the string (presumably because it's not the + beginning of a line). + If not set, then the beginning-of-line operator does match the + beginning of the string. */ +#define REG_NOTBOL 1 + +/* Like REG_NOTBOL, except for the end-of-line. */ +#define REG_NOTEOL (1 << 1) + +/* Use PMATCH[0] to delimit the start and end of the search in the + buffer. */ +#define REG_STARTEND (1 << 2) + + +/* If any error codes are removed, changed, or added, update the + '__re_error_msgid' table in regcomp.c. */ + +typedef enum +{ + _REG_ENOSYS = -1, /* This will never happen for this implementation. */ + _REG_NOERROR = 0, /* Success. */ + _REG_NOMATCH, /* Didn't find a match (for regexec). */ + + /* POSIX regcomp return error codes. (In the order listed in the + standard.) */ + _REG_BADPAT, /* Invalid pattern. */ + _REG_ECOLLATE, /* Invalid collating element. */ + _REG_ECTYPE, /* Invalid character class name. */ + _REG_EESCAPE, /* Trailing backslash. */ + _REG_ESUBREG, /* Invalid back reference. */ + _REG_EBRACK, /* Unmatched left bracket. */ + _REG_EPAREN, /* Parenthesis imbalance. */ + _REG_EBRACE, /* Unmatched \{. */ + _REG_BADBR, /* Invalid contents of \{\}. */ + _REG_ERANGE, /* Invalid range end. */ + _REG_ESPACE, /* Ran out of memory. */ + _REG_BADRPT, /* No preceding re for repetition op. */ + + /* Error codes we've added. */ + _REG_EEND, /* Premature end. */ + _REG_ESIZE, /* Too large (e.g., repeat count too large). */ + _REG_ERPAREN /* Unmatched ) or \); not returned from regcomp. */ +} reg_errcode_t; + +#if defined _XOPEN_SOURCE || defined __USE_XOPEN2K +# define REG_ENOSYS _REG_ENOSYS +#endif +#define REG_NOERROR _REG_NOERROR +#define REG_NOMATCH _REG_NOMATCH +#define REG_BADPAT _REG_BADPAT +#define REG_ECOLLATE _REG_ECOLLATE +#define REG_ECTYPE _REG_ECTYPE +#define REG_EESCAPE _REG_EESCAPE +#define REG_ESUBREG _REG_ESUBREG +#define REG_EBRACK _REG_EBRACK +#define REG_EPAREN _REG_EPAREN +#define REG_EBRACE _REG_EBRACE +#define REG_BADBR _REG_BADBR +#define REG_ERANGE _REG_ERANGE +#define REG_ESPACE _REG_ESPACE +#define REG_BADRPT _REG_BADRPT +#define REG_EEND _REG_EEND +#define REG_ESIZE _REG_ESIZE +#define REG_ERPAREN _REG_ERPAREN + +/* This data structure represents a compiled pattern. Before calling + the pattern compiler, the fields 'buffer', 'allocated', 'fastmap', + and 'translate' can be set. After the pattern has been compiled, + the fields 're_nsub', 'not_bol' and 'not_eol' are available. All + other fields are private to the regex routines. */ + +#ifndef RE_TRANSLATE_TYPE +# define __RE_TRANSLATE_TYPE unsigned char * +# ifdef __USE_GNU +# define RE_TRANSLATE_TYPE __RE_TRANSLATE_TYPE +# endif +#endif + +#ifdef __USE_GNU +# define __REPB_PREFIX(name) name +#else +# define __REPB_PREFIX(name) __##name +#endif + +struct re_pattern_buffer +{ + /* Space that holds the compiled pattern. The type + 'struct re_dfa_t' is private and is not declared here. */ + struct re_dfa_t *__REPB_PREFIX(buffer); + + /* Number of bytes to which 'buffer' points. */ + __re_long_size_t __REPB_PREFIX(allocated); + + /* Number of bytes actually used in 'buffer'. */ + __re_long_size_t __REPB_PREFIX(used); + + /* Syntax setting with which the pattern was compiled. */ + reg_syntax_t __REPB_PREFIX(syntax); + + /* Pointer to a fastmap, if any, otherwise zero. re_search uses the + fastmap, if there is one, to skip over impossible starting points + for matches. */ + char *__REPB_PREFIX(fastmap); + + /* Either a translate table to apply to all characters before + comparing them, or zero for no translation. The translation is + applied to a pattern when it is compiled and to a string when it + is matched. */ + __RE_TRANSLATE_TYPE __REPB_PREFIX(translate); + + /* Number of subexpressions found by the compiler. */ + size_t re_nsub; + + /* Zero if this pattern cannot match the empty string, one else. + Well, in truth it's used only in 're_search_2', to see whether or + not we should use the fastmap, so we don't set this absolutely + perfectly; see 're_compile_fastmap' (the "duplicate" case). */ + unsigned __REPB_PREFIX(can_be_null) : 1; + + /* If REGS_UNALLOCATED, allocate space in the 'regs' structure + for 'max (RE_NREGS, re_nsub + 1)' groups. + If REGS_REALLOCATE, reallocate space if necessary. + If REGS_FIXED, use what's there. */ +#ifdef __USE_GNU +# define REGS_UNALLOCATED 0 +# define REGS_REALLOCATE 1 +# define REGS_FIXED 2 +#endif + unsigned __REPB_PREFIX(regs_allocated) : 2; + + /* Set to zero when 're_compile_pattern' compiles a pattern; set to + one by 're_compile_fastmap' if it updates the fastmap. */ + unsigned __REPB_PREFIX(fastmap_accurate) : 1; + + /* If set, 're_match_2' does not return information about + subexpressions. */ + unsigned __REPB_PREFIX(no_sub) : 1; + + /* If set, a beginning-of-line anchor doesn't match at the beginning + of the string. */ + unsigned __REPB_PREFIX(not_bol) : 1; + + /* Similarly for an end-of-line anchor. */ + unsigned __REPB_PREFIX(not_eol) : 1; + + /* If true, an anchor at a newline matches. */ + unsigned __REPB_PREFIX(newline_anchor) : 1; +}; + +typedef struct re_pattern_buffer regex_t; + +/* Type for byte offsets within the string. POSIX mandates this. */ +#ifdef _REGEX_LARGE_OFFSETS +/* POSIX 1003.1-2008 requires that regoff_t be at least as wide as + ptrdiff_t and ssize_t. We don't know of any hosts where ptrdiff_t + is wider than ssize_t, so ssize_t is safe. ptrdiff_t is not + visible here, so use ssize_t. */ +typedef ssize_t regoff_t; +#else +/* The traditional GNU regex implementation mishandles strings longer + than INT_MAX. */ +typedef int regoff_t; +#endif + + +#ifdef __USE_GNU +/* This is the structure we store register match data in. See + regex.texinfo for a full description of what registers match. */ +struct re_registers +{ + __re_size_t num_regs; + regoff_t *start; + regoff_t *end; +}; + + +/* If 'regs_allocated' is REGS_UNALLOCATED in the pattern buffer, + 're_match_2' returns information about at least this many registers + the first time a 'regs' structure is passed. */ +# ifndef RE_NREGS +# define RE_NREGS 30 +# endif +#endif + + +/* POSIX specification for registers. Aside from the different names than + 're_registers', POSIX uses an array of structures, instead of a + structure of arrays. */ +typedef struct +{ + regoff_t rm_so; /* Byte offset from string's start to substring's start. */ + regoff_t rm_eo; /* Byte offset from string's start to substring's end. */ +} regmatch_t; + +/* Declarations for routines. */ + +#ifndef _REGEX_NELTS +# if (defined __STDC_VERSION__ && 199901L <= __STDC_VERSION__ \ + && !defined __STDC_NO_VLA__) +# define _REGEX_NELTS(n) n +# else +# define _REGEX_NELTS(n) +# endif +#endif + +#if defined __GNUC__ && 4 < __GNUC__ + (6 <= __GNUC_MINOR__) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wvla" +#endif + +#ifndef _Attr_access_ +# ifdef __attr_access +# define _Attr_access_(arg) __attr_access (arg) +# elif defined __GNUC__ && 10 <= __GNUC__ +# define _Attr_access_(x) __attribute__ ((__access__ x)) +# else +# define _Attr_access_(x) +# endif +#endif + +#ifdef __USE_GNU +/* Sets the current default syntax to SYNTAX, and return the old syntax. + You can also simply assign to the 're_syntax_options' variable. */ +extern reg_syntax_t re_set_syntax (reg_syntax_t __syntax); + +/* Compile the regular expression PATTERN, with length LENGTH + and syntax given by the global 're_syntax_options', into the buffer + BUFFER. Return NULL if successful, and an error string if not. + + To free the allocated storage, you must call 'regfree' on BUFFER. + Note that the translate table must either have been initialized by + 'regcomp', with a malloc'ed value, or set to NULL before calling + 'regfree'. */ +extern const char *re_compile_pattern (const char *__pattern, size_t __length, + struct re_pattern_buffer *__buffer) + _Attr_access_ ((__read_only__, 1, 2)); + + +/* Compile a fastmap for the compiled pattern in BUFFER; used to + accelerate searches. Return 0 if successful and -2 if was an + internal error. */ +extern int re_compile_fastmap (struct re_pattern_buffer *__buffer); + + +/* Search in the string STRING (with length LENGTH) for the pattern + compiled into BUFFER. Start searching at position START, for RANGE + characters. Return the starting position of the match, -1 for no + match, or -2 for an internal error. Also return register + information in REGS (if REGS and BUFFER->no_sub are nonzero). */ +extern regoff_t re_search (struct re_pattern_buffer *__buffer, + const char *__String, regoff_t __length, + regoff_t __start, regoff_t __range, + struct re_registers *__regs) + _Attr_access_ ((__read_only__, 2, 3)); + + +/* Like 're_search', but search in the concatenation of STRING1 and + STRING2. Also, stop searching at index START + STOP. */ +extern regoff_t re_search_2 (struct re_pattern_buffer *__buffer, + const char *__string1, regoff_t __length1, + const char *__string2, regoff_t __length2, + regoff_t __start, regoff_t __range, + struct re_registers *__regs, + regoff_t __stop) + _Attr_access_ ((__read_only__, 2, 3)) + _Attr_access_ ((__read_only__, 4, 5)); + + +/* Like 're_search', but return how many characters in STRING the regexp + in BUFFER matched, starting at position START. */ +extern regoff_t re_match (struct re_pattern_buffer *__buffer, + const char *__String, regoff_t __length, + regoff_t __start, struct re_registers *__regs) + _Attr_access_ ((__read_only__, 2, 3)); + + +/* Relates to 're_match' as 're_search_2' relates to 're_search'. */ +extern regoff_t re_match_2 (struct re_pattern_buffer *__buffer, + const char *__string1, regoff_t __length1, + const char *__string2, regoff_t __length2, + regoff_t __start, struct re_registers *__regs, + regoff_t __stop) + _Attr_access_ ((__read_only__, 2, 3)) + _Attr_access_ ((__read_only__, 4, 5)); + + +/* Set REGS to hold NUM_REGS registers, storing them in STARTS and + ENDS. Subsequent matches using BUFFER and REGS will use this memory + for recording register information. STARTS and ENDS must be + allocated with malloc, and must each be at least 'NUM_REGS * sizeof + (regoff_t)' bytes long. + + If NUM_REGS == 0, then subsequent matches should allocate their own + register data. + + Unless this function is called, the first search or match using + BUFFER will allocate its own register data, without + freeing the old data. */ +extern void re_set_registers (struct re_pattern_buffer *__buffer, + struct re_registers *__regs, + __re_size_t __num_regs, + regoff_t *__starts, regoff_t *__ends); +#endif /* Use GNU */ + +#if defined _REGEX_RE_COMP || (defined _LIBC && defined __USE_MISC) +/* 4.2 bsd compatibility. */ +extern char *re_comp (const char *); +extern int re_exec (const char *); +#endif + +/* For plain 'restrict', use glibc's __restrict if defined. + Otherwise, GCC 2.95 and later have "__restrict"; C99 compilers have + "restrict", and "configure" may have defined "restrict". + Other compilers use __restrict, __restrict__, and _Restrict, and + 'configure' might #define 'restrict' to those words, so pick a + different name. */ +#ifndef _Restrict_ +# if defined __restrict \ + || 2 < __GNUC__ + (95 <= __GNUC_MINOR__) \ + || __clang_major__ >= 3 +# define _Restrict_ __restrict +# elif 199901L <= __STDC_VERSION__ || defined restrict +# define _Restrict_ restrict +# else +# define _Restrict_ +# endif +#endif +/* For the ISO C99 syntax + array_name[restrict] + use glibc's __restrict_arr if available. + Otherwise, GCC 3.1 and clang support this syntax (but not in C++ mode). + Other ISO C99 compilers support it as well. */ +#ifndef _Restrict_arr_ +# ifdef __restrict_arr +# define _Restrict_arr_ __restrict_arr +# elif ((199901L <= __STDC_VERSION__ \ + || 3 < __GNUC__ + (1 <= __GNUC_MINOR__) \ + || __clang_major__ >= 3) \ + && !defined __cplusplus) +# define _Restrict_arr_ _Restrict_ +# else +# define _Restrict_arr_ +# endif +#endif + +/* POSIX compatibility. */ +extern int regcomp (regex_t *_Restrict_ __preg, + const char *_Restrict_ __pattern, + int __cflags); + +extern int regexec (const regex_t *_Restrict_ __preg, + const char *_Restrict_ __String, size_t __nmatch, + regmatch_t __pmatch[_Restrict_arr_ + _REGEX_NELTS (__nmatch)], + int __eflags); + +extern size_t regerror (int __errcode, const regex_t *_Restrict_ __preg, + char *_Restrict_ __errbuf, size_t __errbuf_size) + _Attr_access_ ((__write_only__, 3, 4)); + +extern void regfree (regex_t *__preg); + +#if defined __GNUC__ && 4 < __GNUC__ + (6 <= __GNUC_MINOR__) +# pragma GCC diagnostic pop +#endif + +#ifdef __cplusplus +} +#endif /* C++ */ + +#endif /* regex.h */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/regex_internal.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/regex_internal.c new file mode 100644 index 00000000..8cd096eb --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/regex_internal.c @@ -0,0 +1,1711 @@ +/* Extended regular expression matching and search library. + Copyright (C) 2002-2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Isamu Hasegawa . + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +static void re_string_construct_common (const char *str, Idx len, + re_string_t *pstr, + RE_TRANSLATE_TYPE trans, bool icase, + const re_dfa_t *dfa); +static re_dfastate_t *create_ci_newstate (const re_dfa_t *dfa, + const re_node_set *nodes, + re_hashval_t hash); +static re_dfastate_t *create_cd_newstate (const re_dfa_t *dfa, + const re_node_set *nodes, + unsigned int context, + re_hashval_t hash); +static reg_errcode_t re_string_realloc_buffers (re_string_t *pstr, + Idx new_buf_len); +static void build_wcs_buffer (re_string_t *pstr); +static reg_errcode_t build_wcs_upper_buffer (re_string_t *pstr); +static void build_upper_buffer (re_string_t *pstr); +static void re_string_translate_buffer (re_string_t *pstr); +static unsigned int re_string_context_at (const re_string_t *input, Idx idx, + int eflags) __attribute__ ((pure)); + +/* Functions for string operation. */ + +/* This function allocate the buffers. It is necessary to call + re_string_reconstruct before using the object. */ + +static reg_errcode_t +__attribute_warn_unused_result__ +re_string_allocate (re_string_t *pstr, const char *str, Idx len, Idx init_len, + RE_TRANSLATE_TYPE trans, bool icase, const re_dfa_t *dfa) +{ + reg_errcode_t ret; + Idx init_buf_len; + + /* Ensure at least one character fits into the buffers. */ + if (init_len < dfa->mb_cur_max) + init_len = dfa->mb_cur_max; + init_buf_len = (len + 1 < init_len) ? len + 1: init_len; + re_string_construct_common (str, len, pstr, trans, icase, dfa); + + ret = re_string_realloc_buffers (pstr, init_buf_len); + if (__glibc_unlikely (ret != REG_NOERROR)) + return ret; + + pstr->word_char = dfa->word_char; + pstr->word_ops_used = dfa->word_ops_used; + pstr->mbs = pstr->mbs_allocated ? pstr->mbs : (unsigned char *) str; + pstr->valid_len = (pstr->mbs_allocated || dfa->mb_cur_max > 1) ? 0 : len; + pstr->valid_raw_len = pstr->valid_len; + return REG_NOERROR; +} + +/* This function allocate the buffers, and initialize them. */ + +static reg_errcode_t +__attribute_warn_unused_result__ +re_string_construct (re_string_t *pstr, const char *str, Idx len, + RE_TRANSLATE_TYPE trans, bool icase, const re_dfa_t *dfa) +{ + reg_errcode_t ret; + memset (pstr, '\0', sizeof (re_string_t)); + re_string_construct_common (str, len, pstr, trans, icase, dfa); + + if (len > 0) + { + ret = re_string_realloc_buffers (pstr, len + 1); + if (__glibc_unlikely (ret != REG_NOERROR)) + return ret; + } + pstr->mbs = pstr->mbs_allocated ? pstr->mbs : (unsigned char *) str; + + if (icase) + { + if (dfa->mb_cur_max > 1) + { + while (1) + { + ret = build_wcs_upper_buffer (pstr); + if (__glibc_unlikely (ret != REG_NOERROR)) + return ret; + if (pstr->valid_raw_len >= len) + break; + if (pstr->bufs_len > pstr->valid_len + dfa->mb_cur_max) + break; + ret = re_string_realloc_buffers (pstr, pstr->bufs_len * 2); + if (__glibc_unlikely (ret != REG_NOERROR)) + return ret; + } + } + else + build_upper_buffer (pstr); + } + else + { + if (dfa->mb_cur_max > 1) + build_wcs_buffer (pstr); + else + { + if (trans != NULL) + re_string_translate_buffer (pstr); + else + { + pstr->valid_len = pstr->bufs_len; + pstr->valid_raw_len = pstr->bufs_len; + } + } + } + + return REG_NOERROR; +} + +/* Helper functions for re_string_allocate, and re_string_construct. */ + +static reg_errcode_t +__attribute_warn_unused_result__ +re_string_realloc_buffers (re_string_t *pstr, Idx new_buf_len) +{ + if (pstr->mb_cur_max > 1) + { + wint_t *new_wcs; + + /* Avoid overflow in realloc. */ + const size_t max_object_size = MAX (sizeof (wint_t), sizeof (Idx)); + if (__glibc_unlikely (MIN (IDX_MAX, SIZE_MAX / max_object_size) + < new_buf_len)) + return REG_ESPACE; + + new_wcs = re_realloc (pstr->wcs, wint_t, new_buf_len); + if (__glibc_unlikely (new_wcs == NULL)) + return REG_ESPACE; + pstr->wcs = new_wcs; + if (pstr->offsets != NULL) + { + Idx *new_offsets = re_realloc (pstr->offsets, Idx, new_buf_len); + if (__glibc_unlikely (new_offsets == NULL)) + return REG_ESPACE; + pstr->offsets = new_offsets; + } + } + if (pstr->mbs_allocated) + { + unsigned char *new_mbs = re_realloc (pstr->mbs, unsigned char, + new_buf_len); + if (__glibc_unlikely (new_mbs == NULL)) + return REG_ESPACE; + pstr->mbs = new_mbs; + } + pstr->bufs_len = new_buf_len; + return REG_NOERROR; +} + + +static void +re_string_construct_common (const char *str, Idx len, re_string_t *pstr, + RE_TRANSLATE_TYPE trans, bool icase, + const re_dfa_t *dfa) +{ + pstr->raw_mbs = (const unsigned char *) str; + pstr->len = len; + pstr->raw_len = len; + pstr->trans = trans; + pstr->icase = icase; + pstr->mbs_allocated = (trans != NULL || icase); + pstr->mb_cur_max = dfa->mb_cur_max; + pstr->is_utf8 = dfa->is_utf8; + pstr->map_notascii = dfa->map_notascii; + pstr->stop = pstr->len; + pstr->raw_stop = pstr->stop; +} + + +/* Build wide character buffer PSTR->WCS. + If the byte sequence of the string are: + (0), (1), (0), (1), + Then wide character buffer will be: + , WEOF , , WEOF , + We use WEOF for padding, they indicate that the position isn't + a first byte of a multibyte character. + + Note that this function assumes PSTR->VALID_LEN elements are already + built and starts from PSTR->VALID_LEN. */ + +static void +build_wcs_buffer (re_string_t *pstr) +{ +#ifdef _LIBC + unsigned char buf[MB_LEN_MAX]; + DEBUG_ASSERT (MB_LEN_MAX >= pstr->mb_cur_max); +#else + unsigned char buf[64]; +#endif + mbstate_t prev_st; + Idx byte_idx, end_idx, remain_len; + size_t mbclen; + + /* Build the buffers from pstr->valid_len to either pstr->len or + pstr->bufs_len. */ + end_idx = (pstr->bufs_len > pstr->len) ? pstr->len : pstr->bufs_len; + for (byte_idx = pstr->valid_len; byte_idx < end_idx;) + { + wchar_t wc; + const char *p; + + remain_len = end_idx - byte_idx; + prev_st = pstr->cur_state; + /* Apply the translation if we need. */ + if (__glibc_unlikely (pstr->trans != NULL)) + { + int i, ch; + + for (i = 0; i < pstr->mb_cur_max && i < remain_len; ++i) + { + ch = pstr->raw_mbs [pstr->raw_mbs_idx + byte_idx + i]; + buf[i] = pstr->mbs[byte_idx + i] = pstr->trans[ch]; + } + p = (const char *) buf; + } + else + p = (const char *) pstr->raw_mbs + pstr->raw_mbs_idx + byte_idx; + mbclen = __mbrtowc (&wc, p, remain_len, &pstr->cur_state); + if (__glibc_unlikely (mbclen == (size_t) -1 || mbclen == 0 + || (mbclen == (size_t) -2 + && pstr->bufs_len >= pstr->len))) + { + /* We treat these cases as a singlebyte character. */ + mbclen = 1; + wc = (wchar_t) pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx]; + if (__glibc_unlikely (pstr->trans != NULL)) + wc = pstr->trans[wc]; + pstr->cur_state = prev_st; + } + else if (__glibc_unlikely (mbclen == (size_t) -2)) + { + /* The buffer doesn't have enough space, finish to build. */ + pstr->cur_state = prev_st; + break; + } + + /* Write wide character and padding. */ + pstr->wcs[byte_idx++] = wc; + /* Write paddings. */ + for (remain_len = byte_idx + mbclen - 1; byte_idx < remain_len ;) + pstr->wcs[byte_idx++] = WEOF; + } + pstr->valid_len = byte_idx; + pstr->valid_raw_len = byte_idx; +} + +/* Build wide character buffer PSTR->WCS like build_wcs_buffer, + but for REG_ICASE. */ + +static reg_errcode_t +__attribute_warn_unused_result__ +build_wcs_upper_buffer (re_string_t *pstr) +{ + mbstate_t prev_st; + Idx src_idx, byte_idx, end_idx, remain_len; + size_t mbclen; +#ifdef _LIBC + char buf[MB_LEN_MAX]; + DEBUG_ASSERT (pstr->mb_cur_max <= MB_LEN_MAX); +#else + char buf[64]; +#endif + + byte_idx = pstr->valid_len; + end_idx = (pstr->bufs_len > pstr->len) ? pstr->len : pstr->bufs_len; + + /* The following optimization assumes that ASCII characters can be + mapped to wide characters with a simple cast. */ + if (! pstr->map_notascii && pstr->trans == NULL && !pstr->offsets_needed) + { + while (byte_idx < end_idx) + { + wchar_t wc; + unsigned char ch = pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx]; + + if (isascii (ch) && mbsinit (&pstr->cur_state)) + { + /* The next step uses the assumption that wchar_t is encoded + ASCII-safe: all ASCII values can be converted like this. */ + wchar_t wcu = __towupper (ch); + if (isascii (wcu)) + { + pstr->mbs[byte_idx] = wcu; + pstr->wcs[byte_idx] = wcu; + byte_idx++; + continue; + } + } + + remain_len = end_idx - byte_idx; + prev_st = pstr->cur_state; + mbclen = __mbrtowc (&wc, + ((const char *) pstr->raw_mbs + pstr->raw_mbs_idx + + byte_idx), remain_len, &pstr->cur_state); + if (__glibc_likely (0 < mbclen && mbclen < (size_t) -2)) + { + wchar_t wcu = __towupper (wc); + if (wcu != wc) + { + size_t mbcdlen; + + mbcdlen = __wcrtomb (buf, wcu, &prev_st); + if (__glibc_likely (mbclen == mbcdlen)) + memcpy (pstr->mbs + byte_idx, buf, mbclen); + else + { + src_idx = byte_idx; + goto offsets_needed; + } + } + else + memcpy (pstr->mbs + byte_idx, + pstr->raw_mbs + pstr->raw_mbs_idx + byte_idx, mbclen); + pstr->wcs[byte_idx++] = wcu; + /* Write paddings. */ + for (remain_len = byte_idx + mbclen - 1; byte_idx < remain_len ;) + pstr->wcs[byte_idx++] = WEOF; + } + else if (mbclen == (size_t) -1 || mbclen == 0 + || (mbclen == (size_t) -2 && pstr->bufs_len >= pstr->len)) + { + /* It is an invalid character, an incomplete character + at the end of the string, or '\0'. Just use the byte. */ + pstr->mbs[byte_idx] = ch; + /* And also cast it to wide char. */ + pstr->wcs[byte_idx++] = (wchar_t) ch; + if (__glibc_unlikely (mbclen == (size_t) -1)) + pstr->cur_state = prev_st; + } + else + { + /* The buffer doesn't have enough space, finish to build. */ + pstr->cur_state = prev_st; + break; + } + } + pstr->valid_len = byte_idx; + pstr->valid_raw_len = byte_idx; + return REG_NOERROR; + } + else + for (src_idx = pstr->valid_raw_len; byte_idx < end_idx;) + { + wchar_t wc; + const char *p; + offsets_needed: + remain_len = end_idx - byte_idx; + prev_st = pstr->cur_state; + if (__glibc_unlikely (pstr->trans != NULL)) + { + int i, ch; + + for (i = 0; i < pstr->mb_cur_max && i < remain_len; ++i) + { + ch = pstr->raw_mbs [pstr->raw_mbs_idx + src_idx + i]; + buf[i] = pstr->trans[ch]; + } + p = (const char *) buf; + } + else + p = (const char *) pstr->raw_mbs + pstr->raw_mbs_idx + src_idx; + mbclen = __mbrtowc (&wc, p, remain_len, &pstr->cur_state); + if (__glibc_likely (0 < mbclen && mbclen < (size_t) -2)) + { + wchar_t wcu = __towupper (wc); + if (wcu != wc) + { + size_t mbcdlen; + + mbcdlen = __wcrtomb ((char *) buf, wcu, &prev_st); + if (__glibc_likely (mbclen == mbcdlen)) + memcpy (pstr->mbs + byte_idx, buf, mbclen); + else if (mbcdlen != (size_t) -1) + { + size_t i; + + if (byte_idx + mbcdlen > pstr->bufs_len) + { + pstr->cur_state = prev_st; + break; + } + + if (pstr->offsets == NULL) + { + pstr->offsets = re_malloc (Idx, pstr->bufs_len); + + if (pstr->offsets == NULL) + return REG_ESPACE; + } + if (!pstr->offsets_needed) + { + for (i = 0; i < (size_t) byte_idx; ++i) + pstr->offsets[i] = i; + pstr->offsets_needed = 1; + } + + memcpy (pstr->mbs + byte_idx, buf, mbcdlen); + pstr->wcs[byte_idx] = wcu; + pstr->offsets[byte_idx] = src_idx; + for (i = 1; i < mbcdlen; ++i) + { + pstr->offsets[byte_idx + i] + = src_idx + (i < mbclen ? i : mbclen - 1); + pstr->wcs[byte_idx + i] = WEOF; + } + pstr->len += mbcdlen - mbclen; + if (pstr->raw_stop > src_idx) + pstr->stop += mbcdlen - mbclen; + end_idx = (pstr->bufs_len > pstr->len) + ? pstr->len : pstr->bufs_len; + byte_idx += mbcdlen; + src_idx += mbclen; + continue; + } + else + memcpy (pstr->mbs + byte_idx, p, mbclen); + } + else + memcpy (pstr->mbs + byte_idx, p, mbclen); + + if (__glibc_unlikely (pstr->offsets_needed != 0)) + { + size_t i; + for (i = 0; i < mbclen; ++i) + pstr->offsets[byte_idx + i] = src_idx + i; + } + src_idx += mbclen; + + pstr->wcs[byte_idx++] = wcu; + /* Write paddings. */ + for (remain_len = byte_idx + mbclen - 1; byte_idx < remain_len ;) + pstr->wcs[byte_idx++] = WEOF; + } + else if (mbclen == (size_t) -1 || mbclen == 0 + || (mbclen == (size_t) -2 && pstr->bufs_len >= pstr->len)) + { + /* It is an invalid character or '\0'. Just use the byte. */ + int ch = pstr->raw_mbs[pstr->raw_mbs_idx + src_idx]; + + if (__glibc_unlikely (pstr->trans != NULL)) + ch = pstr->trans [ch]; + pstr->mbs[byte_idx] = ch; + + if (__glibc_unlikely (pstr->offsets_needed != 0)) + pstr->offsets[byte_idx] = src_idx; + ++src_idx; + + /* And also cast it to wide char. */ + pstr->wcs[byte_idx++] = (wchar_t) ch; + if (__glibc_unlikely (mbclen == (size_t) -1)) + pstr->cur_state = prev_st; + } + else + { + /* The buffer doesn't have enough space, finish to build. */ + pstr->cur_state = prev_st; + break; + } + } + pstr->valid_len = byte_idx; + pstr->valid_raw_len = src_idx; + return REG_NOERROR; +} + +/* Skip characters until the index becomes greater than NEW_RAW_IDX. + Return the index. */ + +static Idx +re_string_skip_chars (re_string_t *pstr, Idx new_raw_idx, wint_t *last_wc) +{ + mbstate_t prev_st; + Idx rawbuf_idx; + size_t mbclen; + wint_t wc = WEOF; + + /* Skip the characters which are not necessary to check. */ + for (rawbuf_idx = pstr->raw_mbs_idx + pstr->valid_raw_len; + rawbuf_idx < new_raw_idx;) + { + wchar_t wc2; + Idx remain_len = pstr->raw_len - rawbuf_idx; + prev_st = pstr->cur_state; + mbclen = __mbrtowc (&wc2, (const char *) pstr->raw_mbs + rawbuf_idx, + remain_len, &pstr->cur_state); + if (__glibc_unlikely (mbclen == (size_t) -2 || mbclen == (size_t) -1 + || mbclen == 0)) + { + /* We treat these cases as a single byte character. */ + if (mbclen == 0 || remain_len == 0) + wc = L'\0'; + else + wc = *(unsigned char *) (pstr->raw_mbs + rawbuf_idx); + mbclen = 1; + pstr->cur_state = prev_st; + } + else + wc = wc2; + /* Then proceed the next character. */ + rawbuf_idx += mbclen; + } + *last_wc = wc; + return rawbuf_idx; +} + +/* Build the buffer PSTR->MBS, and apply the translation if we need. + This function is used in case of REG_ICASE. */ + +static void +build_upper_buffer (re_string_t *pstr) +{ + Idx char_idx, end_idx; + end_idx = (pstr->bufs_len > pstr->len) ? pstr->len : pstr->bufs_len; + + for (char_idx = pstr->valid_len; char_idx < end_idx; ++char_idx) + { + int ch = pstr->raw_mbs[pstr->raw_mbs_idx + char_idx]; + if (__glibc_unlikely (pstr->trans != NULL)) + ch = pstr->trans[ch]; + pstr->mbs[char_idx] = toupper (ch); + } + pstr->valid_len = char_idx; + pstr->valid_raw_len = char_idx; +} + +/* Apply TRANS to the buffer in PSTR. */ + +static void +re_string_translate_buffer (re_string_t *pstr) +{ + Idx buf_idx, end_idx; + end_idx = (pstr->bufs_len > pstr->len) ? pstr->len : pstr->bufs_len; + + for (buf_idx = pstr->valid_len; buf_idx < end_idx; ++buf_idx) + { + int ch = pstr->raw_mbs[pstr->raw_mbs_idx + buf_idx]; + pstr->mbs[buf_idx] = pstr->trans[ch]; + } + + pstr->valid_len = buf_idx; + pstr->valid_raw_len = buf_idx; +} + +/* This function re-construct the buffers. + Concretely, convert to wide character in case of pstr->mb_cur_max > 1, + convert to upper case in case of REG_ICASE, apply translation. */ + +static reg_errcode_t +__attribute_warn_unused_result__ +re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags) +{ + Idx offset; + + if (__glibc_unlikely (pstr->raw_mbs_idx <= idx)) + offset = idx - pstr->raw_mbs_idx; + else + { + /* Reset buffer. */ + if (pstr->mb_cur_max > 1) + memset (&pstr->cur_state, '\0', sizeof (mbstate_t)); + pstr->len = pstr->raw_len; + pstr->stop = pstr->raw_stop; + pstr->valid_len = 0; + pstr->raw_mbs_idx = 0; + pstr->valid_raw_len = 0; + pstr->offsets_needed = 0; + pstr->tip_context = ((eflags & REG_NOTBOL) ? CONTEXT_BEGBUF + : CONTEXT_NEWLINE | CONTEXT_BEGBUF); + if (!pstr->mbs_allocated) + pstr->mbs = (unsigned char *) pstr->raw_mbs; + offset = idx; + } + + if (__glibc_likely (offset != 0)) + { + /* Should the already checked characters be kept? */ + if (__glibc_likely (offset < pstr->valid_raw_len)) + { + /* Yes, move them to the front of the buffer. */ + if (__glibc_unlikely (pstr->offsets_needed)) + { + Idx low = 0, high = pstr->valid_len, mid; + do + { + mid = (high + low) / 2; + if (pstr->offsets[mid] > offset) + high = mid; + else if (pstr->offsets[mid] < offset) + low = mid + 1; + else + break; + } + while (low < high); + if (pstr->offsets[mid] < offset) + ++mid; + pstr->tip_context = re_string_context_at (pstr, mid - 1, + eflags); + /* This can be quite complicated, so handle specially + only the common and easy case where the character with + different length representation of lower and upper + case is present at or after offset. */ + if (pstr->valid_len > offset + && mid == offset && pstr->offsets[mid] == offset) + { + memmove (pstr->wcs, pstr->wcs + offset, + (pstr->valid_len - offset) * sizeof (wint_t)); + memmove (pstr->mbs, pstr->mbs + offset, pstr->valid_len - offset); + pstr->valid_len -= offset; + pstr->valid_raw_len -= offset; + for (low = 0; low < pstr->valid_len; low++) + pstr->offsets[low] = pstr->offsets[low + offset] - offset; + } + else + { + /* Otherwise, just find out how long the partial multibyte + character at offset is and fill it with WEOF/255. */ + pstr->len = pstr->raw_len - idx + offset; + pstr->stop = pstr->raw_stop - idx + offset; + pstr->offsets_needed = 0; + while (mid > 0 && pstr->offsets[mid - 1] == offset) + --mid; + while (mid < pstr->valid_len) + if (pstr->wcs[mid] != WEOF) + break; + else + ++mid; + if (mid == pstr->valid_len) + pstr->valid_len = 0; + else + { + pstr->valid_len = pstr->offsets[mid] - offset; + if (pstr->valid_len) + { + for (low = 0; low < pstr->valid_len; ++low) + pstr->wcs[low] = WEOF; + memset (pstr->mbs, 255, pstr->valid_len); + } + } + pstr->valid_raw_len = pstr->valid_len; + } + } + else + { + pstr->tip_context = re_string_context_at (pstr, offset - 1, + eflags); + if (pstr->mb_cur_max > 1) + memmove (pstr->wcs, pstr->wcs + offset, + (pstr->valid_len - offset) * sizeof (wint_t)); + if (__glibc_unlikely (pstr->mbs_allocated)) + memmove (pstr->mbs, pstr->mbs + offset, + pstr->valid_len - offset); + pstr->valid_len -= offset; + pstr->valid_raw_len -= offset; + DEBUG_ASSERT (pstr->valid_len > 0); + } + } + else + { + /* No, skip all characters until IDX. */ + Idx prev_valid_len = pstr->valid_len; + + if (__glibc_unlikely (pstr->offsets_needed)) + { + pstr->len = pstr->raw_len - idx + offset; + pstr->stop = pstr->raw_stop - idx + offset; + pstr->offsets_needed = 0; + } + pstr->valid_len = 0; + if (pstr->mb_cur_max > 1) + { + Idx wcs_idx; + wint_t wc = WEOF; + + if (pstr->is_utf8) + { + const unsigned char *raw, *p, *end; + + /* Special case UTF-8. Multi-byte chars start with any + byte other than 0x80 - 0xbf. */ + raw = pstr->raw_mbs + pstr->raw_mbs_idx; + end = raw + (offset - pstr->mb_cur_max); + if (end < pstr->raw_mbs) + end = pstr->raw_mbs; + p = raw + offset - 1; +#ifdef _LIBC + /* We know the wchar_t encoding is UCS4, so for the simple + case, ASCII characters, skip the conversion step. */ + if (isascii (*p) && __glibc_likely (pstr->trans == NULL)) + { + memset (&pstr->cur_state, '\0', sizeof (mbstate_t)); + /* pstr->valid_len = 0; */ + wc = (wchar_t) *p; + } + else +#endif + for (; p >= end; --p) + if ((*p & 0xc0) != 0x80) + { + mbstate_t cur_state; + wchar_t wc2; + Idx mlen = raw + pstr->len - p; + unsigned char buf[6]; + size_t mbclen; + + const unsigned char *pp = p; + if (__glibc_unlikely (pstr->trans != NULL)) + { + int i = mlen < 6 ? mlen : 6; + while (--i >= 0) + buf[i] = pstr->trans[p[i]]; + pp = buf; + } + /* XXX Don't use mbrtowc, we know which conversion + to use (UTF-8 -> UCS4). */ + memset (&cur_state, 0, sizeof (cur_state)); + mbclen = __mbrtowc (&wc2, (const char *) pp, mlen, + &cur_state); + if (raw + offset - p <= mbclen + && mbclen < (size_t) -2) + { + memset (&pstr->cur_state, '\0', + sizeof (mbstate_t)); + pstr->valid_len = mbclen - (raw + offset - p); + wc = wc2; + } + break; + } + } + + if (wc == WEOF) + pstr->valid_len = re_string_skip_chars (pstr, idx, &wc) - idx; + if (wc == WEOF) + pstr->tip_context + = re_string_context_at (pstr, prev_valid_len - 1, eflags); + else + pstr->tip_context = ((__glibc_unlikely (pstr->word_ops_used != 0) + && IS_WIDE_WORD_CHAR (wc)) + ? CONTEXT_WORD + : ((IS_WIDE_NEWLINE (wc) + && pstr->newline_anchor) + ? CONTEXT_NEWLINE : 0)); + if (__glibc_unlikely (pstr->valid_len)) + { + for (wcs_idx = 0; wcs_idx < pstr->valid_len; ++wcs_idx) + pstr->wcs[wcs_idx] = WEOF; + if (pstr->mbs_allocated) + memset (pstr->mbs, 255, pstr->valid_len); + } + pstr->valid_raw_len = pstr->valid_len; + } + else + { + int c = pstr->raw_mbs[pstr->raw_mbs_idx + offset - 1]; + pstr->valid_raw_len = 0; + if (pstr->trans) + c = pstr->trans[c]; + pstr->tip_context = (bitset_contain (pstr->word_char, c) + ? CONTEXT_WORD + : ((IS_NEWLINE (c) && pstr->newline_anchor) + ? CONTEXT_NEWLINE : 0)); + } + } + if (!__glibc_unlikely (pstr->mbs_allocated)) + pstr->mbs += offset; + } + pstr->raw_mbs_idx = idx; + pstr->len -= offset; + pstr->stop -= offset; + + /* Then build the buffers. */ + if (pstr->mb_cur_max > 1) + { + if (pstr->icase) + { + reg_errcode_t ret = build_wcs_upper_buffer (pstr); + if (__glibc_unlikely (ret != REG_NOERROR)) + return ret; + } + else + build_wcs_buffer (pstr); + } + else + if (__glibc_unlikely (pstr->mbs_allocated)) + { + if (pstr->icase) + build_upper_buffer (pstr); + else if (pstr->trans != NULL) + re_string_translate_buffer (pstr); + } + else + pstr->valid_len = pstr->len; + + pstr->cur_idx = 0; + return REG_NOERROR; +} + +static unsigned char +__attribute__ ((pure)) +re_string_peek_byte_case (const re_string_t *pstr, Idx idx) +{ + int ch; + Idx off; + + /* Handle the common (easiest) cases first. */ + if (__glibc_likely (!pstr->mbs_allocated)) + return re_string_peek_byte (pstr, idx); + + if (pstr->mb_cur_max > 1 + && ! re_string_is_single_byte_char (pstr, pstr->cur_idx + idx)) + return re_string_peek_byte (pstr, idx); + + off = pstr->cur_idx + idx; + if (pstr->offsets_needed) + off = pstr->offsets[off]; + + ch = pstr->raw_mbs[pstr->raw_mbs_idx + off]; + + /* Ensure that e.g. for tr_TR.UTF-8 BACKSLASH DOTLESS SMALL LETTER I + this function returns CAPITAL LETTER I instead of first byte of + DOTLESS SMALL LETTER I. The latter would confuse the parser, + since peek_byte_case doesn't advance cur_idx in any way. */ + if (pstr->offsets_needed && !isascii (ch)) + return re_string_peek_byte (pstr, idx); + + return ch; +} + +static unsigned char +re_string_fetch_byte_case (re_string_t *pstr) +{ + if (__glibc_likely (!pstr->mbs_allocated)) + return re_string_fetch_byte (pstr); + + if (pstr->offsets_needed) + { + Idx off; + int ch; + + /* For tr_TR.UTF-8 [[:islower:]] there is + [[: CAPITAL LETTER I WITH DOT lower:]] in mbs. Skip + in that case the whole multi-byte character and return + the original letter. On the other side, with + [[: DOTLESS SMALL LETTER I return [[:I, as doing + anything else would complicate things too much. */ + + if (!re_string_first_byte (pstr, pstr->cur_idx)) + return re_string_fetch_byte (pstr); + + off = pstr->offsets[pstr->cur_idx]; + ch = pstr->raw_mbs[pstr->raw_mbs_idx + off]; + + if (! isascii (ch)) + return re_string_fetch_byte (pstr); + + re_string_skip_bytes (pstr, + re_string_char_size_at (pstr, pstr->cur_idx)); + return ch; + } + + return pstr->raw_mbs[pstr->raw_mbs_idx + pstr->cur_idx++]; +} + +static void +re_string_destruct (re_string_t *pstr) +{ + re_free (pstr->wcs); + re_free (pstr->offsets); + if (pstr->mbs_allocated) + re_free (pstr->mbs); +} + +/* Return the context at IDX in INPUT. */ + +static unsigned int +re_string_context_at (const re_string_t *input, Idx idx, int eflags) +{ + int c; + if (__glibc_unlikely (idx < 0)) + /* In this case, we use the value stored in input->tip_context, + since we can't know the character in input->mbs[-1] here. */ + return input->tip_context; + if (__glibc_unlikely (idx == input->len)) + return ((eflags & REG_NOTEOL) ? CONTEXT_ENDBUF + : CONTEXT_NEWLINE | CONTEXT_ENDBUF); + if (input->mb_cur_max > 1) + { + wint_t wc; + Idx wc_idx = idx; + while(input->wcs[wc_idx] == WEOF) + { + DEBUG_ASSERT (wc_idx >= 0); + --wc_idx; + if (wc_idx < 0) + return input->tip_context; + } + wc = input->wcs[wc_idx]; + if (__glibc_unlikely (input->word_ops_used != 0) + && IS_WIDE_WORD_CHAR (wc)) + return CONTEXT_WORD; + return (IS_WIDE_NEWLINE (wc) && input->newline_anchor + ? CONTEXT_NEWLINE : 0); + } + else + { + c = re_string_byte_at (input, idx); + if (bitset_contain (input->word_char, c)) + return CONTEXT_WORD; + return IS_NEWLINE (c) && input->newline_anchor ? CONTEXT_NEWLINE : 0; + } +} + +/* Functions for set operation. */ + +static reg_errcode_t +__attribute_warn_unused_result__ +re_node_set_alloc (re_node_set *set, Idx size) +{ + set->alloc = size; + set->nelem = 0; + set->elems = re_malloc (Idx, size); + if (__glibc_unlikely (set->elems == NULL) + && (MALLOC_0_IS_NONNULL || size != 0)) + return REG_ESPACE; + return REG_NOERROR; +} + +static reg_errcode_t +__attribute_warn_unused_result__ +re_node_set_init_1 (re_node_set *set, Idx elem) +{ + set->alloc = 1; + set->nelem = 1; + set->elems = re_malloc (Idx, 1); + if (__glibc_unlikely (set->elems == NULL)) + { + set->alloc = set->nelem = 0; + return REG_ESPACE; + } + set->elems[0] = elem; + return REG_NOERROR; +} + +static reg_errcode_t +__attribute_warn_unused_result__ +re_node_set_init_2 (re_node_set *set, Idx elem1, Idx elem2) +{ + set->alloc = 2; + set->elems = re_malloc (Idx, 2); + if (__glibc_unlikely (set->elems == NULL)) + return REG_ESPACE; + if (elem1 == elem2) + { + set->nelem = 1; + set->elems[0] = elem1; + } + else + { + set->nelem = 2; + if (elem1 < elem2) + { + set->elems[0] = elem1; + set->elems[1] = elem2; + } + else + { + set->elems[0] = elem2; + set->elems[1] = elem1; + } + } + return REG_NOERROR; +} + +static reg_errcode_t +__attribute_warn_unused_result__ +re_node_set_init_copy (re_node_set *dest, const re_node_set *src) +{ + dest->nelem = src->nelem; + if (src->nelem > 0) + { + dest->alloc = dest->nelem; + dest->elems = re_malloc (Idx, dest->alloc); + if (__glibc_unlikely (dest->elems == NULL)) + { + dest->alloc = dest->nelem = 0; + return REG_ESPACE; + } + memcpy (dest->elems, src->elems, src->nelem * sizeof (Idx)); + } + else + re_node_set_init_empty (dest); + return REG_NOERROR; +} + +/* Calculate the intersection of the sets SRC1 and SRC2. And merge it to + DEST. Return value indicate the error code or REG_NOERROR if succeeded. + Note: We assume dest->elems is NULL, when dest->alloc is 0. */ + +static reg_errcode_t +__attribute_warn_unused_result__ +re_node_set_add_intersect (re_node_set *dest, const re_node_set *src1, + const re_node_set *src2) +{ + Idx i1, i2, is, id, delta, sbase; + if (src1->nelem == 0 || src2->nelem == 0) + return REG_NOERROR; + + /* We need dest->nelem + 2 * elems_in_intersection; this is a + conservative estimate. */ + if (src1->nelem + src2->nelem + dest->nelem > dest->alloc) + { + Idx new_alloc = src1->nelem + src2->nelem + dest->alloc; + Idx *new_elems = re_realloc (dest->elems, Idx, new_alloc); + if (__glibc_unlikely (new_elems == NULL)) + return REG_ESPACE; + dest->elems = new_elems; + dest->alloc = new_alloc; + } + + /* Find the items in the intersection of SRC1 and SRC2, and copy + into the top of DEST those that are not already in DEST itself. */ + sbase = dest->nelem + src1->nelem + src2->nelem; + i1 = src1->nelem - 1; + i2 = src2->nelem - 1; + id = dest->nelem - 1; + for (;;) + { + if (src1->elems[i1] == src2->elems[i2]) + { + /* Try to find the item in DEST. Maybe we could binary search? */ + while (id >= 0 && dest->elems[id] > src1->elems[i1]) + --id; + + if (id < 0 || dest->elems[id] != src1->elems[i1]) + dest->elems[--sbase] = src1->elems[i1]; + + if (--i1 < 0 || --i2 < 0) + break; + } + + /* Lower the highest of the two items. */ + else if (src1->elems[i1] < src2->elems[i2]) + { + if (--i2 < 0) + break; + } + else + { + if (--i1 < 0) + break; + } + } + + id = dest->nelem - 1; + is = dest->nelem + src1->nelem + src2->nelem - 1; + delta = is - sbase + 1; + + /* Now copy. When DELTA becomes zero, the remaining + DEST elements are already in place; this is more or + less the same loop that is in re_node_set_merge. */ + dest->nelem += delta; + if (delta > 0 && id >= 0) + for (;;) + { + if (dest->elems[is] > dest->elems[id]) + { + /* Copy from the top. */ + dest->elems[id + delta--] = dest->elems[is--]; + if (delta == 0) + break; + } + else + { + /* Slide from the bottom. */ + dest->elems[id + delta] = dest->elems[id]; + if (--id < 0) + break; + } + } + + /* Copy remaining SRC elements. */ + memcpy (dest->elems, dest->elems + sbase, delta * sizeof (Idx)); + + return REG_NOERROR; +} + +/* Calculate the union set of the sets SRC1 and SRC2. And store it to + DEST. Return value indicate the error code or REG_NOERROR if succeeded. */ + +static reg_errcode_t +__attribute_warn_unused_result__ +re_node_set_init_union (re_node_set *dest, const re_node_set *src1, + const re_node_set *src2) +{ + Idx i1, i2, id; + if (src1 != NULL && src1->nelem > 0 && src2 != NULL && src2->nelem > 0) + { + dest->alloc = src1->nelem + src2->nelem; + dest->elems = re_malloc (Idx, dest->alloc); + if (__glibc_unlikely (dest->elems == NULL)) + return REG_ESPACE; + } + else + { + if (src1 != NULL && src1->nelem > 0) + return re_node_set_init_copy (dest, src1); + else if (src2 != NULL && src2->nelem > 0) + return re_node_set_init_copy (dest, src2); + else + re_node_set_init_empty (dest); + return REG_NOERROR; + } + for (i1 = i2 = id = 0 ; i1 < src1->nelem && i2 < src2->nelem ;) + { + if (src1->elems[i1] > src2->elems[i2]) + { + dest->elems[id++] = src2->elems[i2++]; + continue; + } + if (src1->elems[i1] == src2->elems[i2]) + ++i2; + dest->elems[id++] = src1->elems[i1++]; + } + if (i1 < src1->nelem) + { + memcpy (dest->elems + id, src1->elems + i1, + (src1->nelem - i1) * sizeof (Idx)); + id += src1->nelem - i1; + } + else if (i2 < src2->nelem) + { + memcpy (dest->elems + id, src2->elems + i2, + (src2->nelem - i2) * sizeof (Idx)); + id += src2->nelem - i2; + } + dest->nelem = id; + return REG_NOERROR; +} + +/* Calculate the union set of the sets DEST and SRC. And store it to + DEST. Return value indicate the error code or REG_NOERROR if succeeded. */ + +static reg_errcode_t +__attribute_warn_unused_result__ +re_node_set_merge (re_node_set *dest, const re_node_set *src) +{ + Idx is, id, sbase, delta; + if (src == NULL || src->nelem == 0) + return REG_NOERROR; + if (dest->alloc < 2 * src->nelem + dest->nelem) + { + Idx new_alloc = 2 * (src->nelem + dest->alloc); + Idx *new_buffer = re_realloc (dest->elems, Idx, new_alloc); + if (__glibc_unlikely (new_buffer == NULL)) + return REG_ESPACE; + dest->elems = new_buffer; + dest->alloc = new_alloc; + } + + if (__glibc_unlikely (dest->nelem == 0)) + { + /* Although we already guaranteed above that dest->alloc != 0 and + therefore dest->elems != NULL, add a debug assertion to pacify + GCC 11.2.1's -fanalyzer. */ + DEBUG_ASSERT (dest->elems); + dest->nelem = src->nelem; + memcpy (dest->elems, src->elems, src->nelem * sizeof (Idx)); + return REG_NOERROR; + } + + /* Copy into the top of DEST the items of SRC that are not + found in DEST. Maybe we could binary search in DEST? */ + for (sbase = dest->nelem + 2 * src->nelem, + is = src->nelem - 1, id = dest->nelem - 1; is >= 0 && id >= 0; ) + { + if (dest->elems[id] == src->elems[is]) + is--, id--; + else if (dest->elems[id] < src->elems[is]) + dest->elems[--sbase] = src->elems[is--]; + else /* if (dest->elems[id] > src->elems[is]) */ + --id; + } + + if (is >= 0) + { + /* If DEST is exhausted, the remaining items of SRC must be unique. */ + sbase -= is + 1; + memcpy (dest->elems + sbase, src->elems, (is + 1) * sizeof (Idx)); + } + + id = dest->nelem - 1; + is = dest->nelem + 2 * src->nelem - 1; + delta = is - sbase + 1; + if (delta == 0) + return REG_NOERROR; + + /* Now copy. When DELTA becomes zero, the remaining + DEST elements are already in place. */ + dest->nelem += delta; + for (;;) + { + if (dest->elems[is] > dest->elems[id]) + { + /* Copy from the top. */ + dest->elems[id + delta--] = dest->elems[is--]; + if (delta == 0) + break; + } + else + { + /* Slide from the bottom. */ + dest->elems[id + delta] = dest->elems[id]; + if (--id < 0) + { + /* Copy remaining SRC elements. */ + memcpy (dest->elems, dest->elems + sbase, + delta * sizeof (Idx)); + break; + } + } + } + + return REG_NOERROR; +} + +/* Insert the new element ELEM to the re_node_set* SET. + SET should not already have ELEM. + Return true if successful. */ + +static bool +__attribute_warn_unused_result__ +re_node_set_insert (re_node_set *set, Idx elem) +{ + Idx idx; + /* In case the set is empty. */ + if (set->alloc == 0) + return __glibc_likely (re_node_set_init_1 (set, elem) == REG_NOERROR); + + if (__glibc_unlikely (set->nelem) == 0) + { + /* Although we already guaranteed above that set->alloc != 0 and + therefore set->elems != NULL, add a debug assertion to pacify + GCC 11.2 -fanalyzer. */ + DEBUG_ASSERT (set->elems); + set->elems[0] = elem; + ++set->nelem; + return true; + } + + /* Realloc if we need. */ + if (set->alloc == set->nelem) + { + Idx *new_elems; + set->alloc = set->alloc * 2; + new_elems = re_realloc (set->elems, Idx, set->alloc); + if (__glibc_unlikely (new_elems == NULL)) + return false; + set->elems = new_elems; + } + + /* Move the elements which follows the new element. Test the + first element separately to skip a check in the inner loop. */ + if (elem < set->elems[0]) + { + for (idx = set->nelem; idx > 0; idx--) + set->elems[idx] = set->elems[idx - 1]; + } + else + { + for (idx = set->nelem; set->elems[idx - 1] > elem; idx--) + set->elems[idx] = set->elems[idx - 1]; + DEBUG_ASSERT (set->elems[idx - 1] < elem); + } + + /* Insert the new element. */ + set->elems[idx] = elem; + ++set->nelem; + return true; +} + +/* Insert the new element ELEM to the re_node_set* SET. + SET should not already have any element greater than or equal to ELEM. + Return true if successful. */ + +static bool +__attribute_warn_unused_result__ +re_node_set_insert_last (re_node_set *set, Idx elem) +{ + /* Realloc if we need. */ + if (set->alloc == set->nelem) + { + Idx *new_elems; + set->alloc = (set->alloc + 1) * 2; + new_elems = re_realloc (set->elems, Idx, set->alloc); + if (__glibc_unlikely (new_elems == NULL)) + return false; + set->elems = new_elems; + } + + /* Insert the new element. */ + set->elems[set->nelem++] = elem; + return true; +} + +/* Compare two node sets SET1 and SET2. + Return true if SET1 and SET2 are equivalent. */ + +static bool +__attribute__ ((pure)) +re_node_set_compare (const re_node_set *set1, const re_node_set *set2) +{ + Idx i; + if (set1 == NULL || set2 == NULL || set1->nelem != set2->nelem) + return false; + for (i = set1->nelem ; --i >= 0 ; ) + if (set1->elems[i] != set2->elems[i]) + return false; + return true; +} + +/* Return (idx + 1) if SET contains the element ELEM, return 0 otherwise. */ + +static Idx +__attribute__ ((pure)) +re_node_set_contains (const re_node_set *set, Idx elem) +{ + __re_size_t idx, right, mid; + if (set->nelem <= 0) + return 0; + + /* Binary search the element. */ + idx = 0; + right = set->nelem - 1; + while (idx < right) + { + mid = (idx + right) / 2; + if (set->elems[mid] < elem) + idx = mid + 1; + else + right = mid; + } + return set->elems[idx] == elem ? idx + 1 : 0; +} + +static void +re_node_set_remove_at (re_node_set *set, Idx idx) +{ + if (idx < 0 || idx >= set->nelem) + return; + --set->nelem; + for (; idx < set->nelem; idx++) + set->elems[idx] = set->elems[idx + 1]; +} + + +/* Add the token TOKEN to dfa->nodes, and return the index of the token. + Or return -1 if an error occurred. */ + +static Idx +re_dfa_add_node (re_dfa_t *dfa, re_token_t token) +{ + if (__glibc_unlikely (dfa->nodes_len >= dfa->nodes_alloc)) + { + size_t new_nodes_alloc = dfa->nodes_alloc * 2; + Idx *new_nexts, *new_indices; + re_node_set *new_edests, *new_eclosures; + re_token_t *new_nodes; + + /* Avoid overflows in realloc. */ + const size_t max_object_size = MAX (sizeof (re_token_t), + MAX (sizeof (re_node_set), + sizeof (Idx))); + if (__glibc_unlikely (MIN (IDX_MAX, SIZE_MAX / max_object_size) + < new_nodes_alloc)) + return -1; + + new_nodes = re_realloc (dfa->nodes, re_token_t, new_nodes_alloc); + if (__glibc_unlikely (new_nodes == NULL)) + return -1; + dfa->nodes = new_nodes; + dfa->nodes_alloc = new_nodes_alloc; + new_nexts = re_realloc (dfa->nexts, Idx, new_nodes_alloc); + if (new_nexts != NULL) + dfa->nexts = new_nexts; + new_indices = re_realloc (dfa->org_indices, Idx, new_nodes_alloc); + if (new_indices != NULL) + dfa->org_indices = new_indices; + new_edests = re_realloc (dfa->edests, re_node_set, new_nodes_alloc); + if (new_edests != NULL) + dfa->edests = new_edests; + new_eclosures = re_realloc (dfa->eclosures, re_node_set, new_nodes_alloc); + if (new_eclosures != NULL) + dfa->eclosures = new_eclosures; + if (__glibc_unlikely (new_nexts == NULL || new_indices == NULL + || new_edests == NULL || new_eclosures == NULL)) + return -1; + } + dfa->nodes[dfa->nodes_len] = token; + dfa->nodes[dfa->nodes_len].constraint = 0; + dfa->nodes[dfa->nodes_len].accept_mb = + ((token.type == OP_PERIOD && dfa->mb_cur_max > 1) + || token.type == COMPLEX_BRACKET); + dfa->nexts[dfa->nodes_len] = -1; + re_node_set_init_empty (dfa->edests + dfa->nodes_len); + re_node_set_init_empty (dfa->eclosures + dfa->nodes_len); + return dfa->nodes_len++; +} + +static re_hashval_t +calc_state_hash (const re_node_set *nodes, unsigned int context) +{ + re_hashval_t hash = nodes->nelem + context; + Idx i; + for (i = 0 ; i < nodes->nelem ; i++) + hash += nodes->elems[i]; + return hash; +} + +/* Search for the state whose node_set is equivalent to NODES. + Return the pointer to the state, if we found it in the DFA. + Otherwise create the new one and return it. In case of an error + return NULL and set the error code in ERR. + Note: - We assume NULL as the invalid state, then it is possible that + return value is NULL and ERR is REG_NOERROR. + - We never return non-NULL value in case of any errors, it is for + optimization. */ + +static re_dfastate_t * +__attribute_warn_unused_result__ +re_acquire_state (reg_errcode_t *err, const re_dfa_t *dfa, + const re_node_set *nodes) +{ + re_hashval_t hash; + re_dfastate_t *new_state; + struct re_state_table_entry *spot; + Idx i; +#if defined GCC_LINT || defined lint + /* Suppress bogus uninitialized-variable warnings. */ + *err = REG_NOERROR; +#endif + if (__glibc_unlikely (nodes->nelem == 0)) + { + *err = REG_NOERROR; + return NULL; + } + hash = calc_state_hash (nodes, 0); + spot = dfa->state_table + (hash & dfa->state_hash_mask); + + for (i = 0 ; i < spot->num ; i++) + { + re_dfastate_t *state = spot->array[i]; + if (hash != state->hash) + continue; + if (re_node_set_compare (&state->nodes, nodes)) + return state; + } + + /* There are no appropriate state in the dfa, create the new one. */ + new_state = create_ci_newstate (dfa, nodes, hash); + if (__glibc_unlikely (new_state == NULL)) + *err = REG_ESPACE; + + return new_state; +} + +/* Search for the state whose node_set is equivalent to NODES and + whose context is equivalent to CONTEXT. + Return the pointer to the state, if we found it in the DFA. + Otherwise create the new one and return it. In case of an error + return NULL and set the error code in ERR. + Note: - We assume NULL as the invalid state, then it is possible that + return value is NULL and ERR is REG_NOERROR. + - We never return non-NULL value in case of any errors, it is for + optimization. */ + +static re_dfastate_t * +__attribute_warn_unused_result__ +re_acquire_state_context (reg_errcode_t *err, const re_dfa_t *dfa, + const re_node_set *nodes, unsigned int context) +{ + re_hashval_t hash; + re_dfastate_t *new_state; + struct re_state_table_entry *spot; + Idx i; +#if defined GCC_LINT || defined lint + /* Suppress bogus uninitialized-variable warnings. */ + *err = REG_NOERROR; +#endif + if (nodes->nelem == 0) + { + *err = REG_NOERROR; + return NULL; + } + hash = calc_state_hash (nodes, context); + spot = dfa->state_table + (hash & dfa->state_hash_mask); + + for (i = 0 ; i < spot->num ; i++) + { + re_dfastate_t *state = spot->array[i]; + if (state->hash == hash + && state->context == context + && re_node_set_compare (state->entrance_nodes, nodes)) + return state; + } + /* There are no appropriate state in 'dfa', create the new one. */ + new_state = create_cd_newstate (dfa, nodes, context, hash); + if (__glibc_unlikely (new_state == NULL)) + *err = REG_ESPACE; + + return new_state; +} + +/* Finish initialization of the new state NEWSTATE, and using its hash value + HASH put in the appropriate bucket of DFA's state table. Return value + indicates the error code if failed. */ + +static reg_errcode_t +__attribute_warn_unused_result__ +register_state (const re_dfa_t *dfa, re_dfastate_t *newstate, + re_hashval_t hash) +{ + struct re_state_table_entry *spot; + reg_errcode_t err; + Idx i; + + newstate->hash = hash; + err = re_node_set_alloc (&newstate->non_eps_nodes, newstate->nodes.nelem); + if (__glibc_unlikely (err != REG_NOERROR)) + return REG_ESPACE; + for (i = 0; i < newstate->nodes.nelem; i++) + { + Idx elem = newstate->nodes.elems[i]; + if (!IS_EPSILON_NODE (dfa->nodes[elem].type)) + if (! re_node_set_insert_last (&newstate->non_eps_nodes, elem)) + return REG_ESPACE; + } + + spot = dfa->state_table + (hash & dfa->state_hash_mask); + if (__glibc_unlikely (spot->alloc <= spot->num)) + { + Idx new_alloc = 2 * spot->num + 2; + re_dfastate_t **new_array = re_realloc (spot->array, re_dfastate_t *, + new_alloc); + if (__glibc_unlikely (new_array == NULL)) + return REG_ESPACE; + spot->array = new_array; + spot->alloc = new_alloc; + } + spot->array[spot->num++] = newstate; + return REG_NOERROR; +} + +static void +free_state (re_dfastate_t *state) +{ + re_node_set_free (&state->non_eps_nodes); + re_node_set_free (&state->inveclosure); + if (state->entrance_nodes != &state->nodes) + { + re_node_set_free (state->entrance_nodes); + re_free (state->entrance_nodes); + } + re_node_set_free (&state->nodes); + re_free (state->word_trtable); + re_free (state->trtable); + re_free (state); +} + +/* Create the new state which is independent of contexts. + Return the new state if succeeded, otherwise return NULL. */ + +static re_dfastate_t * +__attribute_warn_unused_result__ +create_ci_newstate (const re_dfa_t *dfa, const re_node_set *nodes, + re_hashval_t hash) +{ + Idx i; + reg_errcode_t err; + re_dfastate_t *newstate; + + newstate = (re_dfastate_t *) calloc (sizeof (re_dfastate_t), 1); + if (__glibc_unlikely (newstate == NULL)) + return NULL; + err = re_node_set_init_copy (&newstate->nodes, nodes); + if (__glibc_unlikely (err != REG_NOERROR)) + { + re_free (newstate); + return NULL; + } + + newstate->entrance_nodes = &newstate->nodes; + for (i = 0 ; i < nodes->nelem ; i++) + { + re_token_t *node = dfa->nodes + nodes->elems[i]; + re_token_type_t type = node->type; + if (type == CHARACTER && !node->constraint) + continue; + newstate->accept_mb |= node->accept_mb; + + /* If the state has the halt node, the state is a halt state. */ + if (type == END_OF_RE) + newstate->halt = 1; + else if (type == OP_BACK_REF) + newstate->has_backref = 1; + else if (type == ANCHOR || node->constraint) + newstate->has_constraint = 1; + } + err = register_state (dfa, newstate, hash); + if (__glibc_unlikely (err != REG_NOERROR)) + { + free_state (newstate); + newstate = NULL; + } + return newstate; +} + +/* Create the new state which is depend on the context CONTEXT. + Return the new state if succeeded, otherwise return NULL. */ + +static re_dfastate_t * +__attribute_warn_unused_result__ +create_cd_newstate (const re_dfa_t *dfa, const re_node_set *nodes, + unsigned int context, re_hashval_t hash) +{ + Idx i, nctx_nodes = 0; + reg_errcode_t err; + re_dfastate_t *newstate; + + newstate = (re_dfastate_t *) calloc (sizeof (re_dfastate_t), 1); + if (__glibc_unlikely (newstate == NULL)) + return NULL; + err = re_node_set_init_copy (&newstate->nodes, nodes); + if (__glibc_unlikely (err != REG_NOERROR)) + { + re_free (newstate); + return NULL; + } + + newstate->context = context; + newstate->entrance_nodes = &newstate->nodes; + + for (i = 0 ; i < nodes->nelem ; i++) + { + re_token_t *node = dfa->nodes + nodes->elems[i]; + re_token_type_t type = node->type; + unsigned int constraint = node->constraint; + + if (type == CHARACTER && !constraint) + continue; + newstate->accept_mb |= node->accept_mb; + + /* If the state has the halt node, the state is a halt state. */ + if (type == END_OF_RE) + newstate->halt = 1; + else if (type == OP_BACK_REF) + newstate->has_backref = 1; + + if (constraint) + { + if (newstate->entrance_nodes == &newstate->nodes) + { + re_node_set *entrance_nodes = re_malloc (re_node_set, 1); + if (__glibc_unlikely (entrance_nodes == NULL)) + { + free_state (newstate); + return NULL; + } + newstate->entrance_nodes = entrance_nodes; + if (re_node_set_init_copy (newstate->entrance_nodes, nodes) + != REG_NOERROR) + { + free_state (newstate); + return NULL; + } + nctx_nodes = 0; + newstate->has_constraint = 1; + } + + if (NOT_SATISFY_PREV_CONSTRAINT (constraint,context)) + { + re_node_set_remove_at (&newstate->nodes, i - nctx_nodes); + ++nctx_nodes; + } + } + } + err = register_state (dfa, newstate, hash); + if (__glibc_unlikely (err != REG_NOERROR)) + { + free_state (newstate); + newstate = NULL; + } + return newstate; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/regex_internal.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/regex_internal.h new file mode 100644 index 00000000..6165cb17 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/regex_internal.h @@ -0,0 +1,832 @@ +/* Extended regular expression matching and search library. + Copyright (C) 2002-2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Isamu Hasegawa . + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _REGEX_INTERNAL_H +#define _REGEX_INTERNAL_H 1 + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#ifndef _LIBC +# include +#endif + +#include +#include + +#if defined DEBUG && DEBUG != 0 +# include +# define DEBUG_ASSERT(x) assert (x) +#else +# define DEBUG_ASSERT(x) assume (x) +#endif + +#ifdef _LIBC +# include +# define lock_define(name) __libc_lock_define (, name) +# define lock_init(lock) (__libc_lock_init (lock), 0) +# define lock_fini(lock) ((void) 0) +# define lock_lock(lock) __libc_lock_lock (lock) +# define lock_unlock(lock) __libc_lock_unlock (lock) +#elif defined GNULIB_LOCK && !defined GNULIB_REGEX_SINGLE_THREAD +# include "glthread/lock.h" +# define lock_define(name) gl_lock_define (, name) +# define lock_init(lock) glthread_lock_init (&(lock)) +# define lock_fini(lock) glthread_lock_destroy (&(lock)) +# define lock_lock(lock) glthread_lock_lock (&(lock)) +# define lock_unlock(lock) glthread_lock_unlock (&(lock)) +#elif defined GNULIB_PTHREAD && !defined GNULIB_REGEX_SINGLE_THREAD +# include +# define lock_define(name) pthread_mutex_t name; +# define lock_init(lock) pthread_mutex_init (&(lock), 0) +# define lock_fini(lock) pthread_mutex_destroy (&(lock)) +# define lock_lock(lock) pthread_mutex_lock (&(lock)) +# define lock_unlock(lock) pthread_mutex_unlock (&(lock)) +#else +# define lock_define(name) +# define lock_init(lock) 0 +# define lock_fini(lock) ((void) 0) + /* The 'dfa' avoids an "unused variable 'dfa'" warning from GCC. */ +# define lock_lock(lock) ((void) dfa) +# define lock_unlock(lock) ((void) 0) +#endif + +/* In case that the system doesn't have isblank(). */ +#if !defined _LIBC && ! (defined isblank || (HAVE_ISBLANK && HAVE_DECL_ISBLANK)) +# define isblank(ch) ((ch) == ' ' || (ch) == '\t') +#endif + +/* regex code assumes isascii has its usual numeric meaning, + even if the portable character set uses EBCDIC encoding, + and even if wint_t is wider than int. */ +#ifndef _LIBC +# undef isascii +# define isascii(c) (((c) & ~0x7f) == 0) +#endif + +#ifdef _LIBC +# ifndef _RE_DEFINE_LOCALE_FUNCTIONS +# define _RE_DEFINE_LOCALE_FUNCTIONS 1 +# include +# include +# endif +#endif + +/* This is for other GNU distributions with internationalized messages. */ +#if (HAVE_LIBINTL_H && ENABLE_NLS) || defined _LIBC +# include +# ifdef _LIBC +# undef gettext +# define gettext(msgid) \ + __dcgettext (_libc_intl_domainname, msgid, LC_MESSAGES) +# endif +#else +# undef gettext +# define gettext(msgid) (msgid) +#endif + +#ifndef gettext_noop +/* This define is so xgettext can find the internationalizable + strings. */ +# define gettext_noop(String) String +#endif + +/* Number of ASCII characters. */ +#define ASCII_CHARS 0x80 + +/* Number of single byte characters. */ +#define SBC_MAX (UCHAR_MAX + 1) + +#define COLL_ELEM_LEN_MAX 8 + +/* The character which represents newline. */ +#define NEWLINE_CHAR '\n' +#define WIDE_NEWLINE_CHAR L'\n' + +/* Rename to standard API for using out of glibc. */ +#ifndef _LIBC +# undef __wctype +# undef __iswalnum +# undef __iswctype +# undef __towlower +# undef __towupper +# define __wctype wctype +# define __iswalnum iswalnum +# define __iswctype iswctype +# define __towlower towlower +# define __towupper towupper +# define __btowc btowc +# define __mbrtowc mbrtowc +# define __wcrtomb wcrtomb +# define __regfree regfree +#endif /* not _LIBC */ + +/* Types related to integers. Unless protected by #ifdef _LIBC, the + regex code should avoid exact-width types like int32_t and uint64_t + as some non-GCC platforms lack them, an issue when this code is + used in Gnulib. */ + +#ifndef ULONG_WIDTH +# define ULONG_WIDTH REGEX_UINTEGER_WIDTH (ULONG_MAX) +/* The number of usable bits in an unsigned integer type with maximum + value MAX, as an int expression suitable in #if. Cover all known + practical hosts. This implementation exploits the fact that MAX is + 1 less than a power of 2, and merely counts the number of 1 bits in + MAX; "COBn" means "count the number of 1 bits in the low-order n bits". */ +# define REGEX_UINTEGER_WIDTH(max) REGEX_COB128 (max) +# define REGEX_COB128(n) (REGEX_COB64 ((n) >> 31 >> 31 >> 2) + REGEX_COB64 (n)) +# define REGEX_COB64(n) (REGEX_COB32 ((n) >> 31 >> 1) + REGEX_COB32 (n)) +# define REGEX_COB32(n) (REGEX_COB16 ((n) >> 16) + REGEX_COB16 (n)) +# define REGEX_COB16(n) (REGEX_COB8 ((n) >> 8) + REGEX_COB8 (n)) +# define REGEX_COB8(n) (REGEX_COB4 ((n) >> 4) + REGEX_COB4 (n)) +# define REGEX_COB4(n) (!!((n) & 8) + !!((n) & 4) + !!((n) & 2) + ((n) & 1)) +# if ULONG_MAX / 2 + 1 != 1ul << (ULONG_WIDTH - 1) +# error "ULONG_MAX out of range" +# endif +#endif + +/* The type of indexes into strings. This is signed, not size_t, + since the API requires indexes to fit in regoff_t anyway, and using + signed integers makes the code a bit smaller and presumably faster. + The traditional GNU regex implementation uses int for indexes. + The POSIX-compatible implementation uses a possibly-wider type. + The name 'Idx' is three letters to minimize the hassle of + reindenting a lot of regex code that formerly used 'int'. */ +typedef regoff_t Idx; +#ifdef _REGEX_LARGE_OFFSETS +# define IDX_MAX SSIZE_MAX +#else +# define IDX_MAX INT_MAX +#endif + +/* A hash value, suitable for computing hash tables. */ +typedef __re_size_t re_hashval_t; + +/* An integer used to represent a set of bits. It must be unsigned, + and must be at least as wide as unsigned int. */ +typedef unsigned long int bitset_word_t; +/* All bits set in a bitset_word_t. */ +#define BITSET_WORD_MAX ULONG_MAX +/* Number of bits in a bitset_word_t. */ +#define BITSET_WORD_BITS ULONG_WIDTH + +/* Number of bitset_word_t values in a bitset_t. */ +#define BITSET_WORDS ((SBC_MAX + BITSET_WORD_BITS - 1) / BITSET_WORD_BITS) + +typedef bitset_word_t bitset_t[BITSET_WORDS]; +typedef bitset_word_t *re_bitset_ptr_t; +typedef const bitset_word_t *re_const_bitset_ptr_t; + +#define PREV_WORD_CONSTRAINT 0x0001 +#define PREV_NOTWORD_CONSTRAINT 0x0002 +#define NEXT_WORD_CONSTRAINT 0x0004 +#define NEXT_NOTWORD_CONSTRAINT 0x0008 +#define PREV_NEWLINE_CONSTRAINT 0x0010 +#define NEXT_NEWLINE_CONSTRAINT 0x0020 +#define PREV_BEGBUF_CONSTRAINT 0x0040 +#define NEXT_ENDBUF_CONSTRAINT 0x0080 +#define WORD_DELIM_CONSTRAINT 0x0100 +#define NOT_WORD_DELIM_CONSTRAINT 0x0200 + +typedef enum +{ + INSIDE_WORD = PREV_WORD_CONSTRAINT | NEXT_WORD_CONSTRAINT, + WORD_FIRST = PREV_NOTWORD_CONSTRAINT | NEXT_WORD_CONSTRAINT, + WORD_LAST = PREV_WORD_CONSTRAINT | NEXT_NOTWORD_CONSTRAINT, + INSIDE_NOTWORD = PREV_NOTWORD_CONSTRAINT | NEXT_NOTWORD_CONSTRAINT, + LINE_FIRST = PREV_NEWLINE_CONSTRAINT, + LINE_LAST = NEXT_NEWLINE_CONSTRAINT, + BUF_FIRST = PREV_BEGBUF_CONSTRAINT, + BUF_LAST = NEXT_ENDBUF_CONSTRAINT, + WORD_DELIM = WORD_DELIM_CONSTRAINT, + NOT_WORD_DELIM = NOT_WORD_DELIM_CONSTRAINT +} re_context_type; + +typedef struct +{ + Idx alloc; + Idx nelem; + Idx *elems; +} re_node_set; + +typedef enum +{ + NON_TYPE = 0, + + /* Node type, These are used by token, node, tree. */ + CHARACTER = 1, + END_OF_RE = 2, + SIMPLE_BRACKET = 3, + OP_BACK_REF = 4, + OP_PERIOD = 5, + COMPLEX_BRACKET = 6, + OP_UTF8_PERIOD = 7, + + /* We define EPSILON_BIT as a macro so that OP_OPEN_SUBEXP is used + when the debugger shows values of this enum type. */ +#define EPSILON_BIT 8 + OP_OPEN_SUBEXP = EPSILON_BIT | 0, + OP_CLOSE_SUBEXP = EPSILON_BIT | 1, + OP_ALT = EPSILON_BIT | 2, + OP_DUP_ASTERISK = EPSILON_BIT | 3, + ANCHOR = EPSILON_BIT | 4, + + /* Tree type, these are used only by tree. */ + CONCAT = 16, + SUBEXP = 17, + + /* Token type, these are used only by token. */ + OP_DUP_PLUS = 18, + OP_DUP_QUESTION, + OP_OPEN_BRACKET, + OP_CLOSE_BRACKET, + OP_CHARSET_RANGE, + OP_OPEN_DUP_NUM, + OP_CLOSE_DUP_NUM, + OP_NON_MATCH_LIST, + OP_OPEN_COLL_ELEM, + OP_CLOSE_COLL_ELEM, + OP_OPEN_EQUIV_CLASS, + OP_CLOSE_EQUIV_CLASS, + OP_OPEN_CHAR_CLASS, + OP_CLOSE_CHAR_CLASS, + OP_WORD, + OP_NOTWORD, + OP_SPACE, + OP_NOTSPACE, + BACK_SLASH + +} re_token_type_t; + +typedef struct +{ + /* Multibyte characters. */ + wchar_t *mbchars; + +#ifdef _LIBC + /* Collating symbols. */ + int32_t *coll_syms; +#endif + +#ifdef _LIBC + /* Equivalence classes. */ + int32_t *equiv_classes; +#endif + + /* Range expressions. */ +#ifdef _LIBC + uint32_t *range_starts; + uint32_t *range_ends; +#else + wchar_t *range_starts; + wchar_t *range_ends; +#endif + + /* Character classes. */ + wctype_t *char_classes; + + /* If this character set is the non-matching list. */ + unsigned int non_match : 1; + + /* # of multibyte characters. */ + Idx nmbchars; + + /* # of collating symbols. */ + Idx ncoll_syms; + + /* # of equivalence classes. */ + Idx nequiv_classes; + + /* # of range expressions. */ + Idx nranges; + + /* # of character classes. */ + Idx nchar_classes; +} re_charset_t; + +typedef struct +{ + union + { + unsigned char c; /* for CHARACTER */ + re_bitset_ptr_t sbcset; /* for SIMPLE_BRACKET */ + re_charset_t *mbcset; /* for COMPLEX_BRACKET */ + Idx idx; /* for BACK_REF */ + re_context_type ctx_type; /* for ANCHOR */ + } opr; +#if (__GNUC__ >= 2 || defined __clang__) && !defined __STRICT_ANSI__ + re_token_type_t type : 8; +#else + re_token_type_t type; +#endif + unsigned int constraint : 10; /* context constraint */ + unsigned int duplicated : 1; + unsigned int opt_subexp : 1; + unsigned int accept_mb : 1; + /* These 2 bits can be moved into the union if needed (e.g. if running out + of bits; move opr.c to opr.c.c and move the flags to opr.c.flags). */ + unsigned int mb_partial : 1; + unsigned int word_char : 1; +} re_token_t; + +#define IS_EPSILON_NODE(type) ((type) & EPSILON_BIT) + +struct re_string_t +{ + /* Indicate the raw buffer which is the original string passed as an + argument of regexec(), re_search(), etc.. */ + const unsigned char *raw_mbs; + /* Store the multibyte string. In case of "case insensitive mode" like + REG_ICASE, upper cases of the string are stored, otherwise MBS points + the same address that RAW_MBS points. */ + unsigned char *mbs; + /* Store the wide character string which is corresponding to MBS. */ + wint_t *wcs; + Idx *offsets; + mbstate_t cur_state; + /* Index in RAW_MBS. Each character mbs[i] corresponds to + raw_mbs[raw_mbs_idx + i]. */ + Idx raw_mbs_idx; + /* The length of the valid characters in the buffers. */ + Idx valid_len; + /* The corresponding number of bytes in raw_mbs array. */ + Idx valid_raw_len; + /* The length of the buffers MBS and WCS. */ + Idx bufs_len; + /* The index in MBS, which is updated by re_string_fetch_byte. */ + Idx cur_idx; + /* length of RAW_MBS array. */ + Idx raw_len; + /* This is RAW_LEN - RAW_MBS_IDX + VALID_LEN - VALID_RAW_LEN. */ + Idx len; + /* End of the buffer may be shorter than its length in the cases such + as re_match_2, re_search_2. Then, we use STOP for end of the buffer + instead of LEN. */ + Idx raw_stop; + /* This is RAW_STOP - RAW_MBS_IDX adjusted through OFFSETS. */ + Idx stop; + + /* The context of mbs[0]. We store the context independently, since + the context of mbs[0] may be different from raw_mbs[0], which is + the beginning of the input string. */ + unsigned int tip_context; + /* The translation passed as a part of an argument of re_compile_pattern. */ + RE_TRANSLATE_TYPE trans; + /* Copy of re_dfa_t's word_char. */ + re_const_bitset_ptr_t word_char; + /* true if REG_ICASE. */ + unsigned char icase; + unsigned char is_utf8; + unsigned char map_notascii; + unsigned char mbs_allocated; + unsigned char offsets_needed; + unsigned char newline_anchor; + unsigned char word_ops_used; + int mb_cur_max; +}; +typedef struct re_string_t re_string_t; + + +struct re_dfa_t; +typedef struct re_dfa_t re_dfa_t; + +#ifndef _LIBC +# define IS_IN(libc) false +#endif + +#define re_string_peek_byte(pstr, offset) \ + ((pstr)->mbs[(pstr)->cur_idx + offset]) +#define re_string_fetch_byte(pstr) \ + ((pstr)->mbs[(pstr)->cur_idx++]) +#define re_string_first_byte(pstr, idx) \ + ((idx) == (pstr)->valid_len || (pstr)->wcs[idx] != WEOF) +#define re_string_is_single_byte_char(pstr, idx) \ + ((pstr)->wcs[idx] != WEOF && ((pstr)->valid_len == (idx) + 1 \ + || (pstr)->wcs[(idx) + 1] != WEOF)) +#define re_string_eoi(pstr) ((pstr)->stop <= (pstr)->cur_idx) +#define re_string_cur_idx(pstr) ((pstr)->cur_idx) +#define re_string_get_buffer(pstr) ((pstr)->mbs) +#define re_string_length(pstr) ((pstr)->len) +#define re_string_byte_at(pstr,idx) ((pstr)->mbs[idx]) +#define re_string_skip_bytes(pstr,idx) ((pstr)->cur_idx += (idx)) +#define re_string_set_index(pstr,idx) ((pstr)->cur_idx = (idx)) + +#ifdef _LIBC +# define MALLOC_0_IS_NONNULL 1 +#elif !defined MALLOC_0_IS_NONNULL +# define MALLOC_0_IS_NONNULL 0 +#endif + +#ifndef MAX +# define MAX(a,b) ((a) < (b) ? (b) : (a)) +#endif +#ifndef MIN +# define MIN(a,b) ((a) < (b) ? (a) : (b)) +#endif + +#define re_malloc(t,n) ((t *) malloc ((n) * sizeof (t))) +#define re_realloc(p,t,n) ((t *) realloc (p, (n) * sizeof (t))) +#define re_free(p) free (p) + +struct bin_tree_t +{ + struct bin_tree_t *parent; + struct bin_tree_t *left; + struct bin_tree_t *right; + struct bin_tree_t *first; + struct bin_tree_t *next; + + re_token_t token; + + /* 'node_idx' is the index in dfa->nodes, if 'type' == 0. + Otherwise 'type' indicate the type of this node. */ + Idx node_idx; +}; +typedef struct bin_tree_t bin_tree_t; + +#define BIN_TREE_STORAGE_SIZE \ + ((1024 - sizeof (void *)) / sizeof (bin_tree_t)) + +struct bin_tree_storage_t +{ + struct bin_tree_storage_t *next; + bin_tree_t data[BIN_TREE_STORAGE_SIZE]; +}; +typedef struct bin_tree_storage_t bin_tree_storage_t; + +#define CONTEXT_WORD 1 +#define CONTEXT_NEWLINE (CONTEXT_WORD << 1) +#define CONTEXT_BEGBUF (CONTEXT_NEWLINE << 1) +#define CONTEXT_ENDBUF (CONTEXT_BEGBUF << 1) + +#define IS_WORD_CONTEXT(c) ((c) & CONTEXT_WORD) +#define IS_NEWLINE_CONTEXT(c) ((c) & CONTEXT_NEWLINE) +#define IS_BEGBUF_CONTEXT(c) ((c) & CONTEXT_BEGBUF) +#define IS_ENDBUF_CONTEXT(c) ((c) & CONTEXT_ENDBUF) +#define IS_ORDINARY_CONTEXT(c) ((c) == 0) + +#define IS_WORD_CHAR(ch) (isalnum (ch) || (ch) == '_') +#define IS_NEWLINE(ch) ((ch) == NEWLINE_CHAR) +#define IS_WIDE_WORD_CHAR(ch) (__iswalnum (ch) || (ch) == L'_') +#define IS_WIDE_NEWLINE(ch) ((ch) == WIDE_NEWLINE_CHAR) + +#define NOT_SATISFY_PREV_CONSTRAINT(constraint,context) \ + ((((constraint) & PREV_WORD_CONSTRAINT) && !IS_WORD_CONTEXT (context)) \ + || ((constraint & PREV_NOTWORD_CONSTRAINT) && IS_WORD_CONTEXT (context)) \ + || ((constraint & PREV_NEWLINE_CONSTRAINT) && !IS_NEWLINE_CONTEXT (context))\ + || ((constraint & PREV_BEGBUF_CONSTRAINT) && !IS_BEGBUF_CONTEXT (context))) + +#define NOT_SATISFY_NEXT_CONSTRAINT(constraint,context) \ + ((((constraint) & NEXT_WORD_CONSTRAINT) && !IS_WORD_CONTEXT (context)) \ + || (((constraint) & NEXT_NOTWORD_CONSTRAINT) && IS_WORD_CONTEXT (context)) \ + || (((constraint) & NEXT_NEWLINE_CONSTRAINT) && !IS_NEWLINE_CONTEXT (context)) \ + || (((constraint) & NEXT_ENDBUF_CONSTRAINT) && !IS_ENDBUF_CONTEXT (context))) + +struct re_dfastate_t +{ + re_hashval_t hash; + re_node_set nodes; + re_node_set non_eps_nodes; + re_node_set inveclosure; + re_node_set *entrance_nodes; + struct re_dfastate_t **trtable, **word_trtable; + unsigned int context : 4; + unsigned int halt : 1; + /* If this state can accept "multi byte". + Note that we refer to multibyte characters, and multi character + collating elements as "multi byte". */ + unsigned int accept_mb : 1; + /* If this state has backreference node(s). */ + unsigned int has_backref : 1; + unsigned int has_constraint : 1; +}; +typedef struct re_dfastate_t re_dfastate_t; + +struct re_state_table_entry +{ + Idx num; + Idx alloc; + re_dfastate_t **array; +}; + +/* Array type used in re_sub_match_last_t and re_sub_match_top_t. */ + +typedef struct +{ + Idx next_idx; + Idx alloc; + re_dfastate_t **array; +} state_array_t; + +/* Store information about the node NODE whose type is OP_CLOSE_SUBEXP. */ + +typedef struct +{ + Idx node; + Idx str_idx; /* The position NODE match at. */ + state_array_t path; +} re_sub_match_last_t; + +/* Store information about the node NODE whose type is OP_OPEN_SUBEXP. + And information about the node, whose type is OP_CLOSE_SUBEXP, + corresponding to NODE is stored in LASTS. */ + +typedef struct +{ + Idx str_idx; + Idx node; + state_array_t *path; + Idx alasts; /* Allocation size of LASTS. */ + Idx nlasts; /* The number of LASTS. */ + re_sub_match_last_t **lasts; +} re_sub_match_top_t; + +struct re_backref_cache_entry +{ + Idx node; + Idx str_idx; + Idx subexp_from; + Idx subexp_to; + bitset_word_t eps_reachable_subexps_map; + char more; +}; + +typedef struct +{ + /* The string object corresponding to the input string. */ + re_string_t input; + const re_dfa_t *const dfa; + /* EFLAGS of the argument of regexec. */ + int eflags; + /* Where the matching ends. */ + Idx match_last; + Idx last_node; + /* The state log used by the matcher. */ + re_dfastate_t **state_log; + Idx state_log_top; + /* Back reference cache. */ + Idx nbkref_ents; + Idx abkref_ents; + struct re_backref_cache_entry *bkref_ents; + int max_mb_elem_len; + Idx nsub_tops; + Idx asub_tops; + re_sub_match_top_t **sub_tops; +} re_match_context_t; + +typedef struct +{ + re_dfastate_t **sifted_states; + re_dfastate_t **limited_states; + Idx last_node; + Idx last_str_idx; + re_node_set limits; +} re_sift_context_t; + +struct re_fail_stack_ent_t +{ + Idx idx; + Idx node; + regmatch_t *regs; + re_node_set eps_via_nodes; +}; + +struct re_fail_stack_t +{ + Idx num; + Idx alloc; + struct re_fail_stack_ent_t *stack; +}; + +struct re_dfa_t +{ + re_token_t *nodes; + size_t nodes_alloc; + size_t nodes_len; + Idx *nexts; + Idx *org_indices; + re_node_set *edests; + re_node_set *eclosures; + re_node_set *inveclosures; + struct re_state_table_entry *state_table; + re_dfastate_t *init_state; + re_dfastate_t *init_state_word; + re_dfastate_t *init_state_nl; + re_dfastate_t *init_state_begbuf; + bin_tree_t *str_tree; + bin_tree_storage_t *str_tree_storage; + re_bitset_ptr_t sb_char; + int str_tree_storage_idx; + + /* number of subexpressions 're_nsub' is in regex_t. */ + re_hashval_t state_hash_mask; + Idx init_node; + Idx nbackref; /* The number of backreference in this dfa. */ + + /* Bitmap expressing which backreference is used. */ + bitset_word_t used_bkref_map; + bitset_word_t completed_bkref_map; + + unsigned int has_plural_match : 1; + /* If this dfa has "multibyte node", which is a backreference or + a node which can accept multibyte character or multi character + collating element. */ + unsigned int has_mb_node : 1; + unsigned int is_utf8 : 1; + unsigned int map_notascii : 1; + unsigned int word_ops_used : 1; + int mb_cur_max; + bitset_t word_char; + reg_syntax_t syntax; + Idx *subexp_map; +#ifdef DEBUG + char* re_str; +#endif + lock_define (lock) +}; + +#define re_node_set_init_empty(set) memset (set, '\0', sizeof (re_node_set)) +#define re_node_set_remove(set,id) \ + (re_node_set_remove_at (set, re_node_set_contains (set, id) - 1)) +#define re_node_set_empty(p) ((p)->nelem = 0) +#define re_node_set_free(set) re_free ((set)->elems) + + +typedef enum +{ + SB_CHAR, + MB_CHAR, + EQUIV_CLASS, + COLL_SYM, + CHAR_CLASS +} bracket_elem_type; + +typedef struct +{ + bracket_elem_type type; + union + { + unsigned char ch; + unsigned char *name; + wchar_t wch; + } opr; +} bracket_elem_t; + + +/* Functions for bitset_t operation. */ + +static inline void +bitset_set (bitset_t set, Idx i) +{ + set[i / BITSET_WORD_BITS] |= (bitset_word_t) 1 << i % BITSET_WORD_BITS; +} + +static inline void +bitset_clear (bitset_t set, Idx i) +{ + set[i / BITSET_WORD_BITS] &= ~ ((bitset_word_t) 1 << i % BITSET_WORD_BITS); +} + +static inline bool +bitset_contain (const bitset_t set, Idx i) +{ + return (set[i / BITSET_WORD_BITS] >> i % BITSET_WORD_BITS) & 1; +} + +static inline void +bitset_empty (bitset_t set) +{ + memset (set, '\0', sizeof (bitset_t)); +} + +static inline void +bitset_set_all (bitset_t set) +{ + memset (set, -1, sizeof (bitset_word_t) * (SBC_MAX / BITSET_WORD_BITS)); + if (SBC_MAX % BITSET_WORD_BITS != 0) + set[BITSET_WORDS - 1] = + ((bitset_word_t) 1 << SBC_MAX % BITSET_WORD_BITS) - 1; +} + +static inline void +bitset_copy (bitset_t dest, const bitset_t src) +{ + memcpy (dest, src, sizeof (bitset_t)); +} + +static inline void +bitset_not (bitset_t set) +{ + int bitset_i; + for (bitset_i = 0; bitset_i < SBC_MAX / BITSET_WORD_BITS; ++bitset_i) + set[bitset_i] = ~set[bitset_i]; + if (SBC_MAX % BITSET_WORD_BITS != 0) + set[BITSET_WORDS - 1] = + ((((bitset_word_t) 1 << SBC_MAX % BITSET_WORD_BITS) - 1) + & ~set[BITSET_WORDS - 1]); +} + +static inline void +bitset_merge (bitset_t dest, const bitset_t src) +{ + int bitset_i; + for (bitset_i = 0; bitset_i < BITSET_WORDS; ++bitset_i) + dest[bitset_i] |= src[bitset_i]; +} + +static inline void +bitset_mask (bitset_t dest, const bitset_t src) +{ + int bitset_i; + for (bitset_i = 0; bitset_i < BITSET_WORDS; ++bitset_i) + dest[bitset_i] &= src[bitset_i]; +} + +/* Functions for re_string. */ +static int +__attribute__ ((pure, unused)) +re_string_char_size_at (const re_string_t *pstr, Idx idx) +{ + int byte_idx; + if (pstr->mb_cur_max == 1) + return 1; + for (byte_idx = 1; idx + byte_idx < pstr->valid_len; ++byte_idx) + if (pstr->wcs[idx + byte_idx] != WEOF) + break; + return byte_idx; +} + +static wint_t +__attribute__ ((pure, unused)) +re_string_wchar_at (const re_string_t *pstr, Idx idx) +{ + if (pstr->mb_cur_max == 1) + return (wint_t) pstr->mbs[idx]; + return (wint_t) pstr->wcs[idx]; +} + +#ifdef _LIBC +# include +#endif + +static int +__attribute__ ((pure, unused)) +re_string_elem_size_at (const re_string_t *pstr, Idx idx) +{ +#ifdef _LIBC + const unsigned char *p, *extra; + const int32_t *table, *indirect; + uint_fast32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES); + + if (nrules != 0) + { + table = (const int32_t *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB); + extra = (const unsigned char *) + _NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAMB); + indirect = (const int32_t *) _NL_CURRENT (LC_COLLATE, + _NL_COLLATE_INDIRECTMB); + p = pstr->mbs + idx; + findidx (table, indirect, extra, &p, pstr->len - idx); + return p - pstr->mbs - idx; + } +#endif /* _LIBC */ + + return 1; +} + +#ifdef _LIBC +# if __glibc_has_attribute (__fallthrough__) +# define FALLTHROUGH __attribute__ ((__fallthrough__)) +# else +# define FALLTHROUGH ((void) 0) +# endif +#else +# include "attribute.h" +#endif + +#endif /* _REGEX_INTERNAL_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/regexec.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/regexec.c new file mode 100644 index 00000000..9f065dfa --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/regexec.c @@ -0,0 +1,4221 @@ +/* Extended regular expression matching and search library. + Copyright (C) 2002-2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Isamu Hasegawa . + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +static reg_errcode_t match_ctx_init (re_match_context_t *cache, int eflags, + Idx n); +static void match_ctx_clean (re_match_context_t *mctx); +static void match_ctx_free (re_match_context_t *cache); +static reg_errcode_t match_ctx_add_entry (re_match_context_t *cache, Idx node, + Idx str_idx, Idx from, Idx to); +static Idx search_cur_bkref_entry (const re_match_context_t *mctx, Idx str_idx); +static reg_errcode_t match_ctx_add_subtop (re_match_context_t *mctx, Idx node, + Idx str_idx); +static re_sub_match_last_t * match_ctx_add_sublast (re_sub_match_top_t *subtop, + Idx node, Idx str_idx); +static void sift_ctx_init (re_sift_context_t *sctx, re_dfastate_t **sifted_sts, + re_dfastate_t **limited_sts, Idx last_node, + Idx last_str_idx); +static reg_errcode_t re_search_internal (const regex_t *preg, + const char *string, Idx length, + Idx start, Idx last_start, Idx stop, + size_t nmatch, regmatch_t pmatch[], + int eflags); +static regoff_t re_search_2_stub (struct re_pattern_buffer *bufp, + const char *string1, Idx length1, + const char *string2, Idx length2, + Idx start, regoff_t range, + struct re_registers *regs, + Idx stop, bool ret_len); +static regoff_t re_search_stub (struct re_pattern_buffer *bufp, + const char *string, Idx length, Idx start, + regoff_t range, Idx stop, + struct re_registers *regs, + bool ret_len); +static unsigned re_copy_regs (struct re_registers *regs, regmatch_t *pmatch, + Idx nregs, int regs_allocated); +static reg_errcode_t prune_impossible_nodes (re_match_context_t *mctx); +static Idx check_matching (re_match_context_t *mctx, bool fl_longest_match, + Idx *p_match_first); +static Idx check_halt_state_context (const re_match_context_t *mctx, + const re_dfastate_t *state, Idx idx); +static void update_regs (const re_dfa_t *dfa, regmatch_t *pmatch, + regmatch_t *prev_idx_match, Idx cur_node, + Idx cur_idx, Idx nmatch); +static reg_errcode_t push_fail_stack (struct re_fail_stack_t *fs, + Idx str_idx, Idx dest_node, Idx nregs, + regmatch_t *regs, regmatch_t *prevregs, + re_node_set *eps_via_nodes); +static reg_errcode_t set_regs (const regex_t *preg, + const re_match_context_t *mctx, + size_t nmatch, regmatch_t *pmatch, + bool fl_backtrack); +static reg_errcode_t free_fail_stack_return (struct re_fail_stack_t *fs); + +static int sift_states_iter_mb (const re_match_context_t *mctx, + re_sift_context_t *sctx, + Idx node_idx, Idx str_idx, Idx max_str_idx); +static reg_errcode_t sift_states_backward (const re_match_context_t *mctx, + re_sift_context_t *sctx); +static reg_errcode_t build_sifted_states (const re_match_context_t *mctx, + re_sift_context_t *sctx, Idx str_idx, + re_node_set *cur_dest); +static reg_errcode_t update_cur_sifted_state (const re_match_context_t *mctx, + re_sift_context_t *sctx, + Idx str_idx, + re_node_set *dest_nodes); +static reg_errcode_t add_epsilon_src_nodes (const re_dfa_t *dfa, + re_node_set *dest_nodes, + const re_node_set *candidates); +static bool check_dst_limits (const re_match_context_t *mctx, + const re_node_set *limits, + Idx dst_node, Idx dst_idx, Idx src_node, + Idx src_idx); +static int check_dst_limits_calc_pos_1 (const re_match_context_t *mctx, + int boundaries, Idx subexp_idx, + Idx from_node, Idx bkref_idx); +static int check_dst_limits_calc_pos (const re_match_context_t *mctx, + Idx limit, Idx subexp_idx, + Idx node, Idx str_idx, + Idx bkref_idx); +static reg_errcode_t check_subexp_limits (const re_dfa_t *dfa, + re_node_set *dest_nodes, + const re_node_set *candidates, + re_node_set *limits, + struct re_backref_cache_entry *bkref_ents, + Idx str_idx); +static reg_errcode_t sift_states_bkref (const re_match_context_t *mctx, + re_sift_context_t *sctx, + Idx str_idx, const re_node_set *candidates); +static reg_errcode_t merge_state_array (const re_dfa_t *dfa, + re_dfastate_t **dst, + re_dfastate_t **src, Idx num); +static re_dfastate_t *find_recover_state (reg_errcode_t *err, + re_match_context_t *mctx); +static re_dfastate_t *transit_state (reg_errcode_t *err, + re_match_context_t *mctx, + re_dfastate_t *state); +static re_dfastate_t *merge_state_with_log (reg_errcode_t *err, + re_match_context_t *mctx, + re_dfastate_t *next_state); +static reg_errcode_t check_subexp_matching_top (re_match_context_t *mctx, + re_node_set *cur_nodes, + Idx str_idx); +#if 0 +static re_dfastate_t *transit_state_sb (reg_errcode_t *err, + re_match_context_t *mctx, + re_dfastate_t *pstate); +#endif +static reg_errcode_t transit_state_mb (re_match_context_t *mctx, + re_dfastate_t *pstate); +static reg_errcode_t transit_state_bkref (re_match_context_t *mctx, + const re_node_set *nodes); +static reg_errcode_t get_subexp (re_match_context_t *mctx, + Idx bkref_node, Idx bkref_str_idx); +static reg_errcode_t get_subexp_sub (re_match_context_t *mctx, + const re_sub_match_top_t *sub_top, + re_sub_match_last_t *sub_last, + Idx bkref_node, Idx bkref_str); +static Idx find_subexp_node (const re_dfa_t *dfa, const re_node_set *nodes, + Idx subexp_idx, int type); +static reg_errcode_t check_arrival (re_match_context_t *mctx, + state_array_t *path, Idx top_node, + Idx top_str, Idx last_node, Idx last_str, + int type); +static reg_errcode_t check_arrival_add_next_nodes (re_match_context_t *mctx, + Idx str_idx, + re_node_set *cur_nodes, + re_node_set *next_nodes); +static reg_errcode_t check_arrival_expand_ecl (const re_dfa_t *dfa, + re_node_set *cur_nodes, + Idx ex_subexp, int type); +static reg_errcode_t check_arrival_expand_ecl_sub (const re_dfa_t *dfa, + re_node_set *dst_nodes, + Idx target, Idx ex_subexp, + int type); +static reg_errcode_t expand_bkref_cache (re_match_context_t *mctx, + re_node_set *cur_nodes, Idx cur_str, + Idx subexp_num, int type); +static bool build_trtable (const re_dfa_t *dfa, re_dfastate_t *state); +static int check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx, + const re_string_t *input, Idx idx); +#ifdef _LIBC +static unsigned int find_collation_sequence_value (const unsigned char *mbs, + size_t name_len); +#endif +static Idx group_nodes_into_DFAstates (const re_dfa_t *dfa, + const re_dfastate_t *state, + re_node_set *states_node, + bitset_t *states_ch); +static bool check_node_accept (const re_match_context_t *mctx, + const re_token_t *node, Idx idx); +static reg_errcode_t extend_buffers (re_match_context_t *mctx, int min_len); + +/* Entry point for POSIX code. */ + +/* regexec searches for a given pattern, specified by PREG, in the + string STRING. + + If NMATCH is zero or REG_NOSUB was set in the cflags argument to + 'regcomp', we ignore PMATCH. Otherwise, we assume PMATCH has at + least NMATCH elements, and we set them to the offsets of the + corresponding matched substrings. + + EFLAGS specifies "execution flags" which affect matching: if + REG_NOTBOL is set, then ^ does not match at the beginning of the + string; if REG_NOTEOL is set, then $ does not match at the end. + + Return 0 if a match is found, REG_NOMATCH if not, REG_BADPAT if + EFLAGS is invalid. */ + +int +regexec (const regex_t *__restrict preg, const char *__restrict string, + size_t nmatch, regmatch_t pmatch[_REGEX_NELTS (nmatch)], int eflags) +{ + reg_errcode_t err; + Idx start, length; + re_dfa_t *dfa = preg->buffer; + + if (eflags & ~(REG_NOTBOL | REG_NOTEOL | REG_STARTEND)) + return REG_BADPAT; + + if (eflags & REG_STARTEND) + { + start = pmatch[0].rm_so; + length = pmatch[0].rm_eo; + } + else + { + start = 0; + length = strlen (string); + } + + lock_lock (dfa->lock); + if (preg->no_sub) + err = re_search_internal (preg, string, length, start, length, + length, 0, NULL, eflags); + else + err = re_search_internal (preg, string, length, start, length, + length, nmatch, pmatch, eflags); + lock_unlock (dfa->lock); + return err != REG_NOERROR; +} + +#ifdef _LIBC +libc_hidden_def (__regexec) + +# include +versioned_symbol (libc, __regexec, regexec, GLIBC_2_3_4); + +# if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_3_4) +__typeof__ (__regexec) __compat_regexec; + +int +attribute_compat_text_section +__compat_regexec (const regex_t *__restrict preg, + const char *__restrict string, size_t nmatch, + regmatch_t pmatch[_REGEX_NELTS (nmatch)], int eflags) +{ + return regexec (preg, string, nmatch, pmatch, + eflags & (REG_NOTBOL | REG_NOTEOL)); +} +compat_symbol (libc, __compat_regexec, regexec, GLIBC_2_0); +# endif +#endif + +/* Entry points for GNU code. */ + +/* re_match, re_search, re_match_2, re_search_2 + + The former two functions operate on STRING with length LENGTH, + while the later two operate on concatenation of STRING1 and STRING2 + with lengths LENGTH1 and LENGTH2, respectively. + + re_match() matches the compiled pattern in BUFP against the string, + starting at index START. + + re_search() first tries matching at index START, then it tries to match + starting from index START + 1, and so on. The last start position tried + is START + RANGE. (Thus RANGE = 0 forces re_search to operate the same + way as re_match().) + + The parameter STOP of re_{match,search}_2 specifies that no match exceeding + the first STOP characters of the concatenation of the strings should be + concerned. + + If REGS is not NULL, and BUFP->no_sub is not set, the offsets of the match + and all groups is stored in REGS. (For the "_2" variants, the offsets are + computed relative to the concatenation, not relative to the individual + strings.) + + On success, re_match* functions return the length of the match, re_search* + return the position of the start of the match. They return -1 on + match failure, -2 on error. */ + +regoff_t +re_match (struct re_pattern_buffer *bufp, const char *string, Idx length, + Idx start, struct re_registers *regs) +{ + return re_search_stub (bufp, string, length, start, 0, length, regs, true); +} +#ifdef _LIBC +weak_alias (__re_match, re_match) +#endif + +regoff_t +re_search (struct re_pattern_buffer *bufp, const char *string, Idx length, + Idx start, regoff_t range, struct re_registers *regs) +{ + return re_search_stub (bufp, string, length, start, range, length, regs, + false); +} +#ifdef _LIBC +weak_alias (__re_search, re_search) +#endif + +regoff_t +re_match_2 (struct re_pattern_buffer *bufp, const char *string1, Idx length1, + const char *string2, Idx length2, Idx start, + struct re_registers *regs, Idx stop) +{ + return re_search_2_stub (bufp, string1, length1, string2, length2, + start, 0, regs, stop, true); +} +#ifdef _LIBC +weak_alias (__re_match_2, re_match_2) +#endif + +regoff_t +re_search_2 (struct re_pattern_buffer *bufp, const char *string1, Idx length1, + const char *string2, Idx length2, Idx start, regoff_t range, + struct re_registers *regs, Idx stop) +{ + return re_search_2_stub (bufp, string1, length1, string2, length2, + start, range, regs, stop, false); +} +#ifdef _LIBC +weak_alias (__re_search_2, re_search_2) +#endif + +static regoff_t +re_search_2_stub (struct re_pattern_buffer *bufp, const char *string1, + Idx length1, const char *string2, Idx length2, Idx start, + regoff_t range, struct re_registers *regs, + Idx stop, bool ret_len) +{ + const char *str; + regoff_t rval; + Idx len; + char *s = NULL; + + if (__glibc_unlikely ((length1 < 0 || length2 < 0 || stop < 0 + || ckd_add (&len, length1, length2)))) + return -2; + + /* Concatenate the strings. */ + if (length2 > 0) + if (length1 > 0) + { + s = re_malloc (char, len); + + if (__glibc_unlikely (s == NULL)) + return -2; +#ifdef _LIBC + memcpy (__mempcpy (s, string1, length1), string2, length2); +#else + memcpy (s, string1, length1); + memcpy (s + length1, string2, length2); +#endif + str = s; + } + else + str = string2; + else + str = string1; + + rval = re_search_stub (bufp, str, len, start, range, stop, regs, + ret_len); + re_free (s); + return rval; +} + +/* The parameters have the same meaning as those of re_search. + Additional parameters: + If RET_LEN is true the length of the match is returned (re_match style); + otherwise the position of the match is returned. */ + +static regoff_t +re_search_stub (struct re_pattern_buffer *bufp, const char *string, Idx length, + Idx start, regoff_t range, Idx stop, struct re_registers *regs, + bool ret_len) +{ + reg_errcode_t result; + regmatch_t *pmatch; + Idx nregs; + regoff_t rval; + int eflags = 0; + re_dfa_t *dfa = bufp->buffer; + Idx last_start = start + range; + + /* Check for out-of-range. */ + if (__glibc_unlikely (start < 0 || start > length)) + return -1; + if (__glibc_unlikely (length < last_start + || (0 <= range && last_start < start))) + last_start = length; + else if (__glibc_unlikely (last_start < 0 + || (range < 0 && start <= last_start))) + last_start = 0; + + lock_lock (dfa->lock); + + eflags |= (bufp->not_bol) ? REG_NOTBOL : 0; + eflags |= (bufp->not_eol) ? REG_NOTEOL : 0; + + /* Compile fastmap if we haven't yet. */ + if (start < last_start && bufp->fastmap != NULL && !bufp->fastmap_accurate) + re_compile_fastmap (bufp); + + if (__glibc_unlikely (bufp->no_sub)) + regs = NULL; + + /* We need at least 1 register. */ + if (regs == NULL) + nregs = 1; + else if (__glibc_unlikely (bufp->regs_allocated == REGS_FIXED + && regs->num_regs <= bufp->re_nsub)) + { + nregs = regs->num_regs; + if (__glibc_unlikely (nregs < 1)) + { + /* Nothing can be copied to regs. */ + regs = NULL; + nregs = 1; + } + } + else + nregs = bufp->re_nsub + 1; + pmatch = re_malloc (regmatch_t, nregs); + if (__glibc_unlikely (pmatch == NULL)) + { + rval = -2; + goto out; + } + + result = re_search_internal (bufp, string, length, start, last_start, stop, + nregs, pmatch, eflags); + + rval = 0; + + /* I hope we needn't fill their regs with -1's when no match was found. */ + if (result != REG_NOERROR) + rval = result == REG_NOMATCH ? -1 : -2; + else if (regs != NULL) + { + /* If caller wants register contents data back, copy them. */ + bufp->regs_allocated = re_copy_regs (regs, pmatch, nregs, + bufp->regs_allocated); + if (__glibc_unlikely (bufp->regs_allocated == REGS_UNALLOCATED)) + rval = -2; + } + + if (__glibc_likely (rval == 0)) + { + if (ret_len) + { + DEBUG_ASSERT (pmatch[0].rm_so == start); + rval = pmatch[0].rm_eo - start; + } + else + rval = pmatch[0].rm_so; + } + re_free (pmatch); + out: + lock_unlock (dfa->lock); + return rval; +} + +static unsigned +re_copy_regs (struct re_registers *regs, regmatch_t *pmatch, Idx nregs, + int regs_allocated) +{ + int rval = REGS_REALLOCATE; + Idx i; + Idx need_regs = nregs + 1; + /* We need one extra element beyond 'num_regs' for the '-1' marker GNU code + uses. */ + + /* Have the register data arrays been allocated? */ + if (regs_allocated == REGS_UNALLOCATED) + { /* No. So allocate them with malloc. */ + regs->start = re_malloc (regoff_t, need_regs); + if (__glibc_unlikely (regs->start == NULL)) + return REGS_UNALLOCATED; + regs->end = re_malloc (regoff_t, need_regs); + if (__glibc_unlikely (regs->end == NULL)) + { + re_free (regs->start); + return REGS_UNALLOCATED; + } + regs->num_regs = need_regs; + } + else if (regs_allocated == REGS_REALLOCATE) + { /* Yes. If we need more elements than were already + allocated, reallocate them. If we need fewer, just + leave it alone. */ + if (__glibc_unlikely (need_regs > regs->num_regs)) + { + regoff_t *new_start = re_realloc (regs->start, regoff_t, need_regs); + regoff_t *new_end; + if (__glibc_unlikely (new_start == NULL)) + return REGS_UNALLOCATED; + new_end = re_realloc (regs->end, regoff_t, need_regs); + if (__glibc_unlikely (new_end == NULL)) + { + re_free (new_start); + return REGS_UNALLOCATED; + } + regs->start = new_start; + regs->end = new_end; + regs->num_regs = need_regs; + } + } + else + { + DEBUG_ASSERT (regs_allocated == REGS_FIXED); + /* This function may not be called with REGS_FIXED and nregs too big. */ + DEBUG_ASSERT (nregs <= regs->num_regs); + rval = REGS_FIXED; + } + + /* Copy the regs. */ + for (i = 0; i < nregs; ++i) + { + regs->start[i] = pmatch[i].rm_so; + regs->end[i] = pmatch[i].rm_eo; + } + for ( ; i < regs->num_regs; ++i) + regs->start[i] = regs->end[i] = -1; + + return rval; +} + +/* Set REGS to hold NUM_REGS registers, storing them in STARTS and + ENDS. Subsequent matches using PATTERN_BUFFER and REGS will use + this memory for recording register information. STARTS and ENDS + must be allocated using the malloc library routine, and must each + be at least NUM_REGS * sizeof (regoff_t) bytes long. + + If NUM_REGS == 0, then subsequent matches should allocate their own + register data. + + Unless this function is called, the first search or match using + PATTERN_BUFFER will allocate its own register data, without + freeing the old data. */ + +void +re_set_registers (struct re_pattern_buffer *bufp, struct re_registers *regs, + __re_size_t num_regs, regoff_t *starts, regoff_t *ends) +{ + if (num_regs) + { + bufp->regs_allocated = REGS_REALLOCATE; + regs->num_regs = num_regs; + regs->start = starts; + regs->end = ends; + } + else + { + bufp->regs_allocated = REGS_UNALLOCATED; + regs->num_regs = 0; + regs->start = regs->end = NULL; + } +} +#ifdef _LIBC +weak_alias (__re_set_registers, re_set_registers) +#endif + +/* Entry points compatible with 4.2 BSD regex library. We don't define + them unless specifically requested. */ + +#if defined _REGEX_RE_COMP || defined _LIBC +int +# ifdef _LIBC +weak_function +# endif +re_exec (const char *s) +{ + return 0 == regexec (&re_comp_buf, s, 0, NULL, 0); +} +#endif /* _REGEX_RE_COMP */ + +/* Internal entry point. */ + +/* Searches for a compiled pattern PREG in the string STRING, whose + length is LENGTH. NMATCH, PMATCH, and EFLAGS have the same + meaning as with regexec. LAST_START is START + RANGE, where + START and RANGE have the same meaning as with re_search. + Return REG_NOERROR if we find a match, and REG_NOMATCH if not, + otherwise return the error code. + Note: We assume front end functions already check ranges. + (0 <= LAST_START && LAST_START <= LENGTH) */ + +static reg_errcode_t +__attribute_warn_unused_result__ +re_search_internal (const regex_t *preg, const char *string, Idx length, + Idx start, Idx last_start, Idx stop, size_t nmatch, + regmatch_t pmatch[], int eflags) +{ + reg_errcode_t err; + const re_dfa_t *dfa = preg->buffer; + Idx left_lim, right_lim; + int incr; + bool fl_longest_match; + int match_kind; + Idx match_first; + Idx match_last = -1; + Idx extra_nmatch; + bool sb; + int ch; + re_match_context_t mctx = { .dfa = dfa }; + char *fastmap = ((preg->fastmap != NULL && preg->fastmap_accurate + && start != last_start && !preg->can_be_null) + ? preg->fastmap : NULL); + RE_TRANSLATE_TYPE t = preg->translate; + + extra_nmatch = (nmatch > preg->re_nsub) ? nmatch - (preg->re_nsub + 1) : 0; + nmatch -= extra_nmatch; + + /* Check if the DFA haven't been compiled. */ + if (__glibc_unlikely (preg->used == 0 || dfa->init_state == NULL + || dfa->init_state_word == NULL + || dfa->init_state_nl == NULL + || dfa->init_state_begbuf == NULL)) + return REG_NOMATCH; + + /* We assume front-end functions already check them. */ + DEBUG_ASSERT (0 <= last_start && last_start <= length); + + /* If initial states with non-begbuf contexts have no elements, + the regex must be anchored. If preg->newline_anchor is set, + we'll never use init_state_nl, so do not check it. */ + if (dfa->init_state->nodes.nelem == 0 + && dfa->init_state_word->nodes.nelem == 0 + && (dfa->init_state_nl->nodes.nelem == 0 + || !preg->newline_anchor)) + { + if (start != 0 && last_start != 0) + return REG_NOMATCH; + start = last_start = 0; + } + + /* We must check the longest matching, if nmatch > 0. */ + fl_longest_match = (nmatch != 0 || dfa->nbackref); + + err = re_string_allocate (&mctx.input, string, length, dfa->nodes_len + 1, + preg->translate, (preg->syntax & RE_ICASE) != 0, + dfa); + if (__glibc_unlikely (err != REG_NOERROR)) + goto free_return; + mctx.input.stop = stop; + mctx.input.raw_stop = stop; + mctx.input.newline_anchor = preg->newline_anchor; + + err = match_ctx_init (&mctx, eflags, dfa->nbackref * 2); + if (__glibc_unlikely (err != REG_NOERROR)) + goto free_return; + + /* We will log all the DFA states through which the dfa pass, + if nmatch > 1, or this dfa has "multibyte node", which is a + back-reference or a node which can accept multibyte character or + multi character collating element. */ + if (nmatch > 1 || dfa->has_mb_node) + { + /* Avoid overflow. */ + if (__glibc_unlikely ((MIN (IDX_MAX, SIZE_MAX / sizeof (re_dfastate_t *)) + <= mctx.input.bufs_len))) + { + err = REG_ESPACE; + goto free_return; + } + + mctx.state_log = re_malloc (re_dfastate_t *, mctx.input.bufs_len + 1); + if (__glibc_unlikely (mctx.state_log == NULL)) + { + err = REG_ESPACE; + goto free_return; + } + } + + match_first = start; + mctx.input.tip_context = (eflags & REG_NOTBOL) ? CONTEXT_BEGBUF + : CONTEXT_NEWLINE | CONTEXT_BEGBUF; + + /* Check incrementally whether the input string matches. */ + incr = (last_start < start) ? -1 : 1; + left_lim = (last_start < start) ? last_start : start; + right_lim = (last_start < start) ? start : last_start; + sb = dfa->mb_cur_max == 1; + match_kind = + (fastmap + ? ((sb || !(preg->syntax & RE_ICASE || t) ? 4 : 0) + | (start <= last_start ? 2 : 0) + | (t != NULL ? 1 : 0)) + : 8); + + for (;; match_first += incr) + { + err = REG_NOMATCH; + if (match_first < left_lim || right_lim < match_first) + goto free_return; + + /* Advance as rapidly as possible through the string, until we + find a plausible place to start matching. This may be done + with varying efficiency, so there are various possibilities: + only the most common of them are specialized, in order to + save on code size. We use a switch statement for speed. */ + switch (match_kind) + { + case 8: + /* No fastmap. */ + break; + + case 7: + /* Fastmap with single-byte translation, match forward. */ + while (__glibc_likely (match_first < right_lim) + && !fastmap[t[(unsigned char) string[match_first]]]) + ++match_first; + goto forward_match_found_start_or_reached_end; + + case 6: + /* Fastmap without translation, match forward. */ + while (__glibc_likely (match_first < right_lim) + && !fastmap[(unsigned char) string[match_first]]) + ++match_first; + + forward_match_found_start_or_reached_end: + if (__glibc_unlikely (match_first == right_lim)) + { + ch = match_first >= length + ? 0 : (unsigned char) string[match_first]; + if (!fastmap[t ? t[ch] : ch]) + goto free_return; + } + break; + + case 4: + case 5: + /* Fastmap without multi-byte translation, match backwards. */ + while (match_first >= left_lim) + { + ch = match_first >= length + ? 0 : (unsigned char) string[match_first]; + if (fastmap[t ? t[ch] : ch]) + break; + --match_first; + } + if (match_first < left_lim) + goto free_return; + break; + + default: + /* In this case, we can't determine easily the current byte, + since it might be a component byte of a multibyte + character. Then we use the constructed buffer instead. */ + for (;;) + { + /* If MATCH_FIRST is out of the valid range, reconstruct the + buffers. */ + __re_size_t offset = match_first - mctx.input.raw_mbs_idx; + if (__glibc_unlikely (offset + >= (__re_size_t) mctx.input.valid_raw_len)) + { + err = re_string_reconstruct (&mctx.input, match_first, + eflags); + if (__glibc_unlikely (err != REG_NOERROR)) + goto free_return; + + offset = match_first - mctx.input.raw_mbs_idx; + } + /* Use buffer byte if OFFSET is in buffer, otherwise '\0'. */ + ch = (offset < mctx.input.valid_len + ? re_string_byte_at (&mctx.input, offset) : 0); + if (fastmap[ch]) + break; + match_first += incr; + if (match_first < left_lim || match_first > right_lim) + { + err = REG_NOMATCH; + goto free_return; + } + } + break; + } + + /* Reconstruct the buffers so that the matcher can assume that + the matching starts from the beginning of the buffer. */ + err = re_string_reconstruct (&mctx.input, match_first, eflags); + if (__glibc_unlikely (err != REG_NOERROR)) + goto free_return; + + /* Don't consider this char as a possible match start if it part, + yet isn't the head, of a multibyte character. */ + if (!sb && !re_string_first_byte (&mctx.input, 0)) + continue; + + /* It seems to be appropriate one, then use the matcher. */ + /* We assume that the matching starts from 0. */ + mctx.state_log_top = mctx.nbkref_ents = mctx.max_mb_elem_len = 0; + match_last = check_matching (&mctx, fl_longest_match, + start <= last_start ? &match_first : NULL); + if (match_last != -1) + { + if (__glibc_unlikely (match_last == -2)) + { + err = REG_ESPACE; + goto free_return; + } + else + { + mctx.match_last = match_last; + if ((!preg->no_sub && nmatch > 1) || dfa->nbackref) + { + re_dfastate_t *pstate = mctx.state_log[match_last]; + mctx.last_node = check_halt_state_context (&mctx, pstate, + match_last); + } + if ((!preg->no_sub && nmatch > 1 && dfa->has_plural_match) + || dfa->nbackref) + { + err = prune_impossible_nodes (&mctx); + if (err == REG_NOERROR) + break; + if (__glibc_unlikely (err != REG_NOMATCH)) + goto free_return; + match_last = -1; + } + else + break; /* We found a match. */ + } + } + + match_ctx_clean (&mctx); + } + + DEBUG_ASSERT (match_last != -1); + DEBUG_ASSERT (err == REG_NOERROR); + + /* Set pmatch[] if we need. */ + if (nmatch > 0) + { + Idx reg_idx; + + /* Initialize registers. */ + for (reg_idx = 1; reg_idx < nmatch; ++reg_idx) + pmatch[reg_idx].rm_so = pmatch[reg_idx].rm_eo = -1; + + /* Set the points where matching start/end. */ + pmatch[0].rm_so = 0; + pmatch[0].rm_eo = mctx.match_last; + /* FIXME: This function should fail if mctx.match_last exceeds + the maximum possible regoff_t value. We need a new error + code REG_OVERFLOW. */ + + if (!preg->no_sub && nmatch > 1) + { + err = set_regs (preg, &mctx, nmatch, pmatch, + dfa->has_plural_match && dfa->nbackref > 0); + if (__glibc_unlikely (err != REG_NOERROR)) + goto free_return; + } + + /* At last, add the offset to each register, since we slid + the buffers so that we could assume that the matching starts + from 0. */ + for (reg_idx = 0; reg_idx < nmatch; ++reg_idx) + if (pmatch[reg_idx].rm_so != -1) + { + if (__glibc_unlikely (mctx.input.offsets_needed != 0)) + { + pmatch[reg_idx].rm_so = + (pmatch[reg_idx].rm_so == mctx.input.valid_len + ? mctx.input.valid_raw_len + : mctx.input.offsets[pmatch[reg_idx].rm_so]); + pmatch[reg_idx].rm_eo = + (pmatch[reg_idx].rm_eo == mctx.input.valid_len + ? mctx.input.valid_raw_len + : mctx.input.offsets[pmatch[reg_idx].rm_eo]); + } + pmatch[reg_idx].rm_so += match_first; + pmatch[reg_idx].rm_eo += match_first; + } + for (reg_idx = 0; reg_idx < extra_nmatch; ++reg_idx) + { + pmatch[nmatch + reg_idx].rm_so = -1; + pmatch[nmatch + reg_idx].rm_eo = -1; + } + + if (dfa->subexp_map) + for (reg_idx = 0; reg_idx + 1 < nmatch; reg_idx++) + if (dfa->subexp_map[reg_idx] != reg_idx) + { + pmatch[reg_idx + 1].rm_so + = pmatch[dfa->subexp_map[reg_idx] + 1].rm_so; + pmatch[reg_idx + 1].rm_eo + = pmatch[dfa->subexp_map[reg_idx] + 1].rm_eo; + } + } + + free_return: + re_free (mctx.state_log); + if (dfa->nbackref) + match_ctx_free (&mctx); + re_string_destruct (&mctx.input); + return err; +} + +static reg_errcode_t +__attribute_warn_unused_result__ +prune_impossible_nodes (re_match_context_t *mctx) +{ + const re_dfa_t *const dfa = mctx->dfa; + Idx halt_node, match_last; + reg_errcode_t ret; + re_dfastate_t **sifted_states; + re_dfastate_t **lim_states = NULL; + re_sift_context_t sctx; + DEBUG_ASSERT (mctx->state_log != NULL); + match_last = mctx->match_last; + halt_node = mctx->last_node; + + /* Avoid overflow. */ + if (__glibc_unlikely (MIN (IDX_MAX, SIZE_MAX / sizeof (re_dfastate_t *)) + <= match_last)) + return REG_ESPACE; + + sifted_states = re_malloc (re_dfastate_t *, match_last + 1); + if (__glibc_unlikely (sifted_states == NULL)) + { + ret = REG_ESPACE; + goto free_return; + } + if (dfa->nbackref) + { + lim_states = re_malloc (re_dfastate_t *, match_last + 1); + if (__glibc_unlikely (lim_states == NULL)) + { + ret = REG_ESPACE; + goto free_return; + } + while (1) + { + memset (lim_states, '\0', + sizeof (re_dfastate_t *) * (match_last + 1)); + sift_ctx_init (&sctx, sifted_states, lim_states, halt_node, + match_last); + ret = sift_states_backward (mctx, &sctx); + re_node_set_free (&sctx.limits); + if (__glibc_unlikely (ret != REG_NOERROR)) + goto free_return; + if (sifted_states[0] != NULL || lim_states[0] != NULL) + break; + do + { + --match_last; + if (match_last < 0) + { + ret = REG_NOMATCH; + goto free_return; + } + } while (mctx->state_log[match_last] == NULL + || !mctx->state_log[match_last]->halt); + halt_node = check_halt_state_context (mctx, + mctx->state_log[match_last], + match_last); + } + ret = merge_state_array (dfa, sifted_states, lim_states, + match_last + 1); + re_free (lim_states); + lim_states = NULL; + if (__glibc_unlikely (ret != REG_NOERROR)) + goto free_return; + } + else + { + sift_ctx_init (&sctx, sifted_states, lim_states, halt_node, match_last); + ret = sift_states_backward (mctx, &sctx); + re_node_set_free (&sctx.limits); + if (__glibc_unlikely (ret != REG_NOERROR)) + goto free_return; + if (sifted_states[0] == NULL) + { + ret = REG_NOMATCH; + goto free_return; + } + } + re_free (mctx->state_log); + mctx->state_log = sifted_states; + sifted_states = NULL; + mctx->last_node = halt_node; + mctx->match_last = match_last; + ret = REG_NOERROR; + free_return: + re_free (sifted_states); + re_free (lim_states); + return ret; +} + +/* Acquire an initial state and return it. + We must select appropriate initial state depending on the context, + since initial states may have constraints like "\<", "^", etc.. */ + +static __always_inline re_dfastate_t * +acquire_init_state_context (reg_errcode_t *err, const re_match_context_t *mctx, + Idx idx) +{ + const re_dfa_t *const dfa = mctx->dfa; + if (dfa->init_state->has_constraint) + { + unsigned int context; + context = re_string_context_at (&mctx->input, idx - 1, mctx->eflags); + if (IS_WORD_CONTEXT (context)) + return dfa->init_state_word; + else if (IS_ORDINARY_CONTEXT (context)) + return dfa->init_state; + else if (IS_BEGBUF_CONTEXT (context) && IS_NEWLINE_CONTEXT (context)) + return dfa->init_state_begbuf; + else if (IS_NEWLINE_CONTEXT (context)) + return dfa->init_state_nl; + else if (IS_BEGBUF_CONTEXT (context)) + { + /* It is relatively rare case, then calculate on demand. */ + return re_acquire_state_context (err, dfa, + dfa->init_state->entrance_nodes, + context); + } + else + /* Must not happen? */ + return dfa->init_state; + } + else + return dfa->init_state; +} + +/* Check whether the regular expression match input string INPUT or not, + and return the index where the matching end. Return -1 if + there is no match, and return -2 in case of an error. + FL_LONGEST_MATCH means we want the POSIX longest matching. + If P_MATCH_FIRST is not NULL, and the match fails, it is set to the + next place where we may want to try matching. + Note that the matcher assumes that the matching starts from the current + index of the buffer. */ + +static Idx +__attribute_warn_unused_result__ +check_matching (re_match_context_t *mctx, bool fl_longest_match, + Idx *p_match_first) +{ + const re_dfa_t *const dfa = mctx->dfa; + reg_errcode_t err; + Idx match = 0; + Idx match_last = -1; + Idx cur_str_idx = re_string_cur_idx (&mctx->input); + re_dfastate_t *cur_state; + bool at_init_state = p_match_first != NULL; + Idx next_start_idx = cur_str_idx; + + err = REG_NOERROR; + cur_state = acquire_init_state_context (&err, mctx, cur_str_idx); + /* An initial state must not be NULL (invalid). */ + if (__glibc_unlikely (cur_state == NULL)) + { + DEBUG_ASSERT (err == REG_ESPACE); + return -2; + } + + if (mctx->state_log != NULL) + { + mctx->state_log[cur_str_idx] = cur_state; + + /* Check OP_OPEN_SUBEXP in the initial state in case that we use them + later. E.g. Processing back references. */ + if (__glibc_unlikely (dfa->nbackref)) + { + at_init_state = false; + err = check_subexp_matching_top (mctx, &cur_state->nodes, 0); + if (__glibc_unlikely (err != REG_NOERROR)) + return err; + + if (cur_state->has_backref) + { + err = transit_state_bkref (mctx, &cur_state->nodes); + if (__glibc_unlikely (err != REG_NOERROR)) + return err; + } + } + } + + /* If the RE accepts NULL string. */ + if (__glibc_unlikely (cur_state->halt)) + { + if (!cur_state->has_constraint + || check_halt_state_context (mctx, cur_state, cur_str_idx)) + { + if (!fl_longest_match) + return cur_str_idx; + else + { + match_last = cur_str_idx; + match = 1; + } + } + } + + while (!re_string_eoi (&mctx->input)) + { + re_dfastate_t *old_state = cur_state; + Idx next_char_idx = re_string_cur_idx (&mctx->input) + 1; + + if ((__glibc_unlikely (next_char_idx >= mctx->input.bufs_len) + && mctx->input.bufs_len < mctx->input.len) + || (__glibc_unlikely (next_char_idx >= mctx->input.valid_len) + && mctx->input.valid_len < mctx->input.len)) + { + err = extend_buffers (mctx, next_char_idx + 1); + if (__glibc_unlikely (err != REG_NOERROR)) + { + DEBUG_ASSERT (err == REG_ESPACE); + return -2; + } + } + + cur_state = transit_state (&err, mctx, cur_state); + if (mctx->state_log != NULL) + cur_state = merge_state_with_log (&err, mctx, cur_state); + + if (cur_state == NULL) + { + /* Reached the invalid state or an error. Try to recover a valid + state using the state log, if available and if we have not + already found a valid (even if not the longest) match. */ + if (__glibc_unlikely (err != REG_NOERROR)) + return -2; + + if (mctx->state_log == NULL + || (match && !fl_longest_match) + || (cur_state = find_recover_state (&err, mctx)) == NULL) + break; + } + + if (__glibc_unlikely (at_init_state)) + { + if (old_state == cur_state) + next_start_idx = next_char_idx; + else + at_init_state = false; + } + + if (cur_state->halt) + { + /* Reached a halt state. + Check the halt state can satisfy the current context. */ + if (!cur_state->has_constraint + || check_halt_state_context (mctx, cur_state, + re_string_cur_idx (&mctx->input))) + { + /* We found an appropriate halt state. */ + match_last = re_string_cur_idx (&mctx->input); + match = 1; + + /* We found a match, do not modify match_first below. */ + p_match_first = NULL; + if (!fl_longest_match) + break; + } + } + } + + if (p_match_first) + *p_match_first += next_start_idx; + + return match_last; +} + +/* Check NODE match the current context. */ + +static bool +check_halt_node_context (const re_dfa_t *dfa, Idx node, unsigned int context) +{ + re_token_type_t type = dfa->nodes[node].type; + unsigned int constraint = dfa->nodes[node].constraint; + if (type != END_OF_RE) + return false; + if (!constraint) + return true; + if (NOT_SATISFY_NEXT_CONSTRAINT (constraint, context)) + return false; + return true; +} + +/* Check the halt state STATE match the current context. + Return 0 if not match, if the node, STATE has, is a halt node and + match the context, return the node. */ + +static Idx +check_halt_state_context (const re_match_context_t *mctx, + const re_dfastate_t *state, Idx idx) +{ + Idx i; + unsigned int context; + DEBUG_ASSERT (state->halt); + context = re_string_context_at (&mctx->input, idx, mctx->eflags); + for (i = 0; i < state->nodes.nelem; ++i) + if (check_halt_node_context (mctx->dfa, state->nodes.elems[i], context)) + return state->nodes.elems[i]; + return 0; +} + +/* Compute the next node to which "NFA" transit from NODE("NFA" is a NFA + corresponding to the DFA). + Return the destination node, and update EPS_VIA_NODES; + return -1 on match failure, -2 on error. */ + +static Idx +proceed_next_node (const re_match_context_t *mctx, Idx nregs, regmatch_t *regs, + regmatch_t *prevregs, + Idx *pidx, Idx node, re_node_set *eps_via_nodes, + struct re_fail_stack_t *fs) +{ + const re_dfa_t *const dfa = mctx->dfa; + if (IS_EPSILON_NODE (dfa->nodes[node].type)) + { + re_node_set *cur_nodes = &mctx->state_log[*pidx]->nodes; + re_node_set *edests = &dfa->edests[node]; + + if (! re_node_set_contains (eps_via_nodes, node)) + { + bool ok = re_node_set_insert (eps_via_nodes, node); + if (__glibc_unlikely (! ok)) + return -2; + } + + /* Pick a valid destination, or return -1 if none is found. */ + Idx dest_node = -1; + for (Idx i = 0; i < edests->nelem; i++) + { + Idx candidate = edests->elems[i]; + if (!re_node_set_contains (cur_nodes, candidate)) + continue; + if (dest_node == -1) + dest_node = candidate; + + else + { + /* In order to avoid infinite loop like "(a*)*", return the second + epsilon-transition if the first was already considered. */ + if (re_node_set_contains (eps_via_nodes, dest_node)) + return candidate; + + /* Otherwise, push the second epsilon-transition on the fail stack. */ + else if (fs != NULL + && push_fail_stack (fs, *pidx, candidate, nregs, regs, + prevregs, eps_via_nodes)) + return -2; + + /* We know we are going to exit. */ + break; + } + } + return dest_node; + } + else + { + Idx naccepted = 0; + re_token_type_t type = dfa->nodes[node].type; + + if (dfa->nodes[node].accept_mb) + naccepted = check_node_accept_bytes (dfa, node, &mctx->input, *pidx); + else if (type == OP_BACK_REF) + { + Idx subexp_idx = dfa->nodes[node].opr.idx + 1; + if (subexp_idx < nregs) + naccepted = regs[subexp_idx].rm_eo - regs[subexp_idx].rm_so; + if (fs != NULL) + { + if (subexp_idx >= nregs + || regs[subexp_idx].rm_so == -1 + || regs[subexp_idx].rm_eo == -1) + return -1; + else if (naccepted) + { + char *buf = (char *) re_string_get_buffer (&mctx->input); + if (mctx->input.valid_len - *pidx < naccepted + || (memcmp (buf + regs[subexp_idx].rm_so, buf + *pidx, + naccepted) + != 0)) + return -1; + } + } + + if (naccepted == 0) + { + Idx dest_node; + bool ok = re_node_set_insert (eps_via_nodes, node); + if (__glibc_unlikely (! ok)) + return -2; + dest_node = dfa->edests[node].elems[0]; + if (re_node_set_contains (&mctx->state_log[*pidx]->nodes, + dest_node)) + return dest_node; + } + } + + if (naccepted != 0 + || check_node_accept (mctx, dfa->nodes + node, *pidx)) + { + Idx dest_node = dfa->nexts[node]; + *pidx = (naccepted == 0) ? *pidx + 1 : *pidx + naccepted; + if (fs && (*pidx > mctx->match_last || mctx->state_log[*pidx] == NULL + || !re_node_set_contains (&mctx->state_log[*pidx]->nodes, + dest_node))) + return -1; + re_node_set_empty (eps_via_nodes); + return dest_node; + } + } + return -1; +} + +static reg_errcode_t +__attribute_warn_unused_result__ +push_fail_stack (struct re_fail_stack_t *fs, Idx str_idx, Idx dest_node, + Idx nregs, regmatch_t *regs, regmatch_t *prevregs, + re_node_set *eps_via_nodes) +{ + reg_errcode_t err; + Idx num = fs->num; + if (num == fs->alloc) + { + struct re_fail_stack_ent_t *new_array; + new_array = re_realloc (fs->stack, struct re_fail_stack_ent_t, + fs->alloc * 2); + if (new_array == NULL) + return REG_ESPACE; + fs->alloc *= 2; + fs->stack = new_array; + } + fs->stack[num].idx = str_idx; + fs->stack[num].node = dest_node; + fs->stack[num].regs = re_malloc (regmatch_t, 2 * nregs); + if (fs->stack[num].regs == NULL) + return REG_ESPACE; + fs->num = num + 1; + memcpy (fs->stack[num].regs, regs, sizeof (regmatch_t) * nregs); + memcpy (fs->stack[num].regs + nregs, prevregs, sizeof (regmatch_t) * nregs); + err = re_node_set_init_copy (&fs->stack[num].eps_via_nodes, eps_via_nodes); + return err; +} + +static Idx +pop_fail_stack (struct re_fail_stack_t *fs, Idx *pidx, Idx nregs, + regmatch_t *regs, regmatch_t *prevregs, + re_node_set *eps_via_nodes) +{ + if (fs == NULL || fs->num == 0) + return -1; + Idx num = --fs->num; + *pidx = fs->stack[num].idx; + memcpy (regs, fs->stack[num].regs, sizeof (regmatch_t) * nregs); + memcpy (prevregs, fs->stack[num].regs + nregs, sizeof (regmatch_t) * nregs); + re_node_set_free (eps_via_nodes); + re_free (fs->stack[num].regs); + *eps_via_nodes = fs->stack[num].eps_via_nodes; + DEBUG_ASSERT (0 <= fs->stack[num].node); + return fs->stack[num].node; +} + + +#define DYNARRAY_STRUCT regmatch_list +#define DYNARRAY_ELEMENT regmatch_t +#define DYNARRAY_PREFIX regmatch_list_ +#include + +/* Set the positions where the subexpressions are starts/ends to registers + PMATCH. + Note: We assume that pmatch[0] is already set, and + pmatch[i].rm_so == pmatch[i].rm_eo == -1 for 0 < i < nmatch. */ + +static reg_errcode_t +__attribute_warn_unused_result__ +set_regs (const regex_t *preg, const re_match_context_t *mctx, size_t nmatch, + regmatch_t *pmatch, bool fl_backtrack) +{ + const re_dfa_t *dfa = preg->buffer; + Idx idx, cur_node; + re_node_set eps_via_nodes; + struct re_fail_stack_t *fs; + struct re_fail_stack_t fs_body = { 0, 2, NULL }; + struct regmatch_list prev_match; + regmatch_list_init (&prev_match); + + DEBUG_ASSERT (nmatch > 1); + DEBUG_ASSERT (mctx->state_log != NULL); + if (fl_backtrack) + { + fs = &fs_body; + fs->stack = re_malloc (struct re_fail_stack_ent_t, fs->alloc); + if (fs->stack == NULL) + return REG_ESPACE; + } + else + fs = NULL; + + cur_node = dfa->init_node; + re_node_set_init_empty (&eps_via_nodes); + + if (!regmatch_list_resize (&prev_match, nmatch)) + { + regmatch_list_free (&prev_match); + free_fail_stack_return (fs); + return REG_ESPACE; + } + regmatch_t *prev_idx_match = regmatch_list_begin (&prev_match); + memcpy (prev_idx_match, pmatch, sizeof (regmatch_t) * nmatch); + + for (idx = pmatch[0].rm_so; idx <= pmatch[0].rm_eo ;) + { + update_regs (dfa, pmatch, prev_idx_match, cur_node, idx, nmatch); + + if ((idx == pmatch[0].rm_eo && cur_node == mctx->last_node) + || (fs && re_node_set_contains (&eps_via_nodes, cur_node))) + { + Idx reg_idx; + cur_node = -1; + if (fs) + { + for (reg_idx = 0; reg_idx < nmatch; ++reg_idx) + if (pmatch[reg_idx].rm_so > -1 && pmatch[reg_idx].rm_eo == -1) + { + cur_node = pop_fail_stack (fs, &idx, nmatch, pmatch, + prev_idx_match, &eps_via_nodes); + break; + } + } + if (cur_node < 0) + { + re_node_set_free (&eps_via_nodes); + regmatch_list_free (&prev_match); + return free_fail_stack_return (fs); + } + } + + /* Proceed to next node. */ + cur_node = proceed_next_node (mctx, nmatch, pmatch, prev_idx_match, + &idx, cur_node, + &eps_via_nodes, fs); + + if (__glibc_unlikely (cur_node < 0)) + { + if (__glibc_unlikely (cur_node == -2)) + { + re_node_set_free (&eps_via_nodes); + regmatch_list_free (&prev_match); + free_fail_stack_return (fs); + return REG_ESPACE; + } + cur_node = pop_fail_stack (fs, &idx, nmatch, pmatch, + prev_idx_match, &eps_via_nodes); + if (cur_node < 0) + { + re_node_set_free (&eps_via_nodes); + regmatch_list_free (&prev_match); + free_fail_stack_return (fs); + return REG_NOMATCH; + } + } + } + re_node_set_free (&eps_via_nodes); + regmatch_list_free (&prev_match); + return free_fail_stack_return (fs); +} + +static reg_errcode_t +free_fail_stack_return (struct re_fail_stack_t *fs) +{ + if (fs) + { + Idx fs_idx; + for (fs_idx = 0; fs_idx < fs->num; ++fs_idx) + { + re_node_set_free (&fs->stack[fs_idx].eps_via_nodes); + re_free (fs->stack[fs_idx].regs); + } + re_free (fs->stack); + } + return REG_NOERROR; +} + +static void +update_regs (const re_dfa_t *dfa, regmatch_t *pmatch, + regmatch_t *prev_idx_match, Idx cur_node, Idx cur_idx, Idx nmatch) +{ + int type = dfa->nodes[cur_node].type; + if (type == OP_OPEN_SUBEXP) + { + Idx reg_num = dfa->nodes[cur_node].opr.idx + 1; + + /* We are at the first node of this sub expression. */ + if (reg_num < nmatch) + { + pmatch[reg_num].rm_so = cur_idx; + pmatch[reg_num].rm_eo = -1; + } + } + else if (type == OP_CLOSE_SUBEXP) + { + /* We are at the last node of this sub expression. */ + Idx reg_num = dfa->nodes[cur_node].opr.idx + 1; + if (reg_num < nmatch) + { + if (pmatch[reg_num].rm_so < cur_idx) + { + pmatch[reg_num].rm_eo = cur_idx; + /* This is a non-empty match or we are not inside an optional + subexpression. Accept this right away. */ + memcpy (prev_idx_match, pmatch, sizeof (regmatch_t) * nmatch); + } + else + { + if (dfa->nodes[cur_node].opt_subexp + && prev_idx_match[reg_num].rm_so != -1) + /* We transited through an empty match for an optional + subexpression, like (a?)*, and this is not the subexp's + first match. Copy back the old content of the registers + so that matches of an inner subexpression are undone as + well, like in ((a?))*. */ + memcpy (pmatch, prev_idx_match, sizeof (regmatch_t) * nmatch); + else + /* We completed a subexpression, but it may be part of + an optional one, so do not update PREV_IDX_MATCH. */ + pmatch[reg_num].rm_eo = cur_idx; + } + } + } +} + +/* This function checks the STATE_LOG from the SCTX->last_str_idx to 0 + and sift the nodes in each states according to the following rules. + Updated state_log will be wrote to STATE_LOG. + + Rules: We throw away the Node 'a' in the STATE_LOG[STR_IDX] if... + 1. When STR_IDX == MATCH_LAST(the last index in the state_log): + If 'a' isn't the LAST_NODE and 'a' can't epsilon transit to + the LAST_NODE, we throw away the node 'a'. + 2. When 0 <= STR_IDX < MATCH_LAST and 'a' accepts + string 's' and transit to 'b': + i. If 'b' isn't in the STATE_LOG[STR_IDX+strlen('s')], we throw + away the node 'a'. + ii. If 'b' is in the STATE_LOG[STR_IDX+strlen('s')] but 'b' is + thrown away, we throw away the node 'a'. + 3. When 0 <= STR_IDX < MATCH_LAST and 'a' epsilon transit to 'b': + i. If 'b' isn't in the STATE_LOG[STR_IDX], we throw away the + node 'a'. + ii. If 'b' is in the STATE_LOG[STR_IDX] but 'b' is thrown away, + we throw away the node 'a'. */ + +#define STATE_NODE_CONTAINS(state,node) \ + ((state) != NULL && re_node_set_contains (&(state)->nodes, node)) + +static reg_errcode_t +sift_states_backward (const re_match_context_t *mctx, re_sift_context_t *sctx) +{ + reg_errcode_t err; + int null_cnt = 0; + Idx str_idx = sctx->last_str_idx; + re_node_set cur_dest; + + DEBUG_ASSERT (mctx->state_log != NULL && mctx->state_log[str_idx] != NULL); + + /* Build sifted state_log[str_idx]. It has the nodes which can epsilon + transit to the last_node and the last_node itself. */ + err = re_node_set_init_1 (&cur_dest, sctx->last_node); + if (__glibc_unlikely (err != REG_NOERROR)) + return err; + err = update_cur_sifted_state (mctx, sctx, str_idx, &cur_dest); + if (__glibc_unlikely (err != REG_NOERROR)) + goto free_return; + + /* Then check each states in the state_log. */ + while (str_idx > 0) + { + /* Update counters. */ + null_cnt = (sctx->sifted_states[str_idx] == NULL) ? null_cnt + 1 : 0; + if (null_cnt > mctx->max_mb_elem_len) + { + memset (sctx->sifted_states, '\0', + sizeof (re_dfastate_t *) * str_idx); + re_node_set_free (&cur_dest); + return REG_NOERROR; + } + re_node_set_empty (&cur_dest); + --str_idx; + + if (mctx->state_log[str_idx]) + { + err = build_sifted_states (mctx, sctx, str_idx, &cur_dest); + if (__glibc_unlikely (err != REG_NOERROR)) + goto free_return; + } + + /* Add all the nodes which satisfy the following conditions: + - It can epsilon transit to a node in CUR_DEST. + - It is in CUR_SRC. + And update state_log. */ + err = update_cur_sifted_state (mctx, sctx, str_idx, &cur_dest); + if (__glibc_unlikely (err != REG_NOERROR)) + goto free_return; + } + err = REG_NOERROR; + free_return: + re_node_set_free (&cur_dest); + return err; +} + +static reg_errcode_t +__attribute_warn_unused_result__ +build_sifted_states (const re_match_context_t *mctx, re_sift_context_t *sctx, + Idx str_idx, re_node_set *cur_dest) +{ + const re_dfa_t *const dfa = mctx->dfa; + const re_node_set *cur_src = &mctx->state_log[str_idx]->non_eps_nodes; + Idx i; + + /* Then build the next sifted state. + We build the next sifted state on 'cur_dest', and update + 'sifted_states[str_idx]' with 'cur_dest'. + Note: + 'cur_dest' is the sifted state from 'state_log[str_idx + 1]'. + 'cur_src' points the node_set of the old 'state_log[str_idx]' + (with the epsilon nodes pre-filtered out). */ + for (i = 0; i < cur_src->nelem; i++) + { + Idx prev_node = cur_src->elems[i]; + int naccepted = 0; + bool ok; + DEBUG_ASSERT (!IS_EPSILON_NODE (dfa->nodes[prev_node].type)); + + /* If the node may accept "multi byte". */ + if (dfa->nodes[prev_node].accept_mb) + naccepted = sift_states_iter_mb (mctx, sctx, prev_node, + str_idx, sctx->last_str_idx); + + /* We don't check backreferences here. + See update_cur_sifted_state(). */ + if (!naccepted + && check_node_accept (mctx, dfa->nodes + prev_node, str_idx) + && STATE_NODE_CONTAINS (sctx->sifted_states[str_idx + 1], + dfa->nexts[prev_node])) + naccepted = 1; + + if (naccepted == 0) + continue; + + if (sctx->limits.nelem) + { + Idx to_idx = str_idx + naccepted; + if (check_dst_limits (mctx, &sctx->limits, + dfa->nexts[prev_node], to_idx, + prev_node, str_idx)) + continue; + } + ok = re_node_set_insert (cur_dest, prev_node); + if (__glibc_unlikely (! ok)) + return REG_ESPACE; + } + + return REG_NOERROR; +} + +/* Helper functions. */ + +static reg_errcode_t +clean_state_log_if_needed (re_match_context_t *mctx, Idx next_state_log_idx) +{ + Idx top = mctx->state_log_top; + + if ((next_state_log_idx >= mctx->input.bufs_len + && mctx->input.bufs_len < mctx->input.len) + || (next_state_log_idx >= mctx->input.valid_len + && mctx->input.valid_len < mctx->input.len)) + { + reg_errcode_t err; + err = extend_buffers (mctx, next_state_log_idx + 1); + if (__glibc_unlikely (err != REG_NOERROR)) + return err; + } + + if (top < next_state_log_idx) + { + DEBUG_ASSERT (mctx->state_log != NULL); + memset (mctx->state_log + top + 1, '\0', + sizeof (re_dfastate_t *) * (next_state_log_idx - top)); + mctx->state_log_top = next_state_log_idx; + } + return REG_NOERROR; +} + +static reg_errcode_t +merge_state_array (const re_dfa_t *dfa, re_dfastate_t **dst, + re_dfastate_t **src, Idx num) +{ + Idx st_idx; + reg_errcode_t err; + for (st_idx = 0; st_idx < num; ++st_idx) + { + if (dst[st_idx] == NULL) + dst[st_idx] = src[st_idx]; + else if (src[st_idx] != NULL) + { + re_node_set merged_set; + err = re_node_set_init_union (&merged_set, &dst[st_idx]->nodes, + &src[st_idx]->nodes); + if (__glibc_unlikely (err != REG_NOERROR)) + return err; + dst[st_idx] = re_acquire_state (&err, dfa, &merged_set); + re_node_set_free (&merged_set); + if (__glibc_unlikely (err != REG_NOERROR)) + return err; + } + } + return REG_NOERROR; +} + +static reg_errcode_t +update_cur_sifted_state (const re_match_context_t *mctx, + re_sift_context_t *sctx, Idx str_idx, + re_node_set *dest_nodes) +{ + const re_dfa_t *const dfa = mctx->dfa; + reg_errcode_t err = REG_NOERROR; + const re_node_set *candidates; + candidates = ((mctx->state_log[str_idx] == NULL) ? NULL + : &mctx->state_log[str_idx]->nodes); + + if (dest_nodes->nelem == 0) + sctx->sifted_states[str_idx] = NULL; + else + { + if (candidates) + { + /* At first, add the nodes which can epsilon transit to a node in + DEST_NODE. */ + err = add_epsilon_src_nodes (dfa, dest_nodes, candidates); + if (__glibc_unlikely (err != REG_NOERROR)) + return err; + + /* Then, check the limitations in the current sift_context. */ + if (sctx->limits.nelem) + { + err = check_subexp_limits (dfa, dest_nodes, candidates, &sctx->limits, + mctx->bkref_ents, str_idx); + if (__glibc_unlikely (err != REG_NOERROR)) + return err; + } + } + + sctx->sifted_states[str_idx] = re_acquire_state (&err, dfa, dest_nodes); + if (__glibc_unlikely (err != REG_NOERROR)) + return err; + } + + if (candidates && mctx->state_log[str_idx]->has_backref) + { + err = sift_states_bkref (mctx, sctx, str_idx, candidates); + if (__glibc_unlikely (err != REG_NOERROR)) + return err; + } + return REG_NOERROR; +} + +static reg_errcode_t +__attribute_warn_unused_result__ +add_epsilon_src_nodes (const re_dfa_t *dfa, re_node_set *dest_nodes, + const re_node_set *candidates) +{ + reg_errcode_t err = REG_NOERROR; + Idx i; + + re_dfastate_t *state = re_acquire_state (&err, dfa, dest_nodes); + if (__glibc_unlikely (err != REG_NOERROR)) + return err; + + if (!state->inveclosure.alloc) + { + err = re_node_set_alloc (&state->inveclosure, dest_nodes->nelem); + if (__glibc_unlikely (err != REG_NOERROR)) + return REG_ESPACE; + for (i = 0; i < dest_nodes->nelem; i++) + { + err = re_node_set_merge (&state->inveclosure, + dfa->inveclosures + dest_nodes->elems[i]); + if (__glibc_unlikely (err != REG_NOERROR)) + return REG_ESPACE; + } + } + return re_node_set_add_intersect (dest_nodes, candidates, + &state->inveclosure); +} + +static reg_errcode_t +sub_epsilon_src_nodes (const re_dfa_t *dfa, Idx node, re_node_set *dest_nodes, + const re_node_set *candidates) +{ + Idx ecl_idx; + reg_errcode_t err; + re_node_set *inv_eclosure = dfa->inveclosures + node; + re_node_set except_nodes; + re_node_set_init_empty (&except_nodes); + for (ecl_idx = 0; ecl_idx < inv_eclosure->nelem; ++ecl_idx) + { + Idx cur_node = inv_eclosure->elems[ecl_idx]; + if (cur_node == node) + continue; + if (IS_EPSILON_NODE (dfa->nodes[cur_node].type)) + { + Idx edst1 = dfa->edests[cur_node].elems[0]; + Idx edst2 = ((dfa->edests[cur_node].nelem > 1) + ? dfa->edests[cur_node].elems[1] : -1); + if ((!re_node_set_contains (inv_eclosure, edst1) + && re_node_set_contains (dest_nodes, edst1)) + || (edst2 > 0 + && !re_node_set_contains (inv_eclosure, edst2) + && re_node_set_contains (dest_nodes, edst2))) + { + err = re_node_set_add_intersect (&except_nodes, candidates, + dfa->inveclosures + cur_node); + if (__glibc_unlikely (err != REG_NOERROR)) + { + re_node_set_free (&except_nodes); + return err; + } + } + } + } + for (ecl_idx = 0; ecl_idx < inv_eclosure->nelem; ++ecl_idx) + { + Idx cur_node = inv_eclosure->elems[ecl_idx]; + if (!re_node_set_contains (&except_nodes, cur_node)) + { + Idx idx = re_node_set_contains (dest_nodes, cur_node) - 1; + re_node_set_remove_at (dest_nodes, idx); + } + } + re_node_set_free (&except_nodes); + return REG_NOERROR; +} + +static bool +check_dst_limits (const re_match_context_t *mctx, const re_node_set *limits, + Idx dst_node, Idx dst_idx, Idx src_node, Idx src_idx) +{ + const re_dfa_t *const dfa = mctx->dfa; + Idx lim_idx, src_pos, dst_pos; + + Idx dst_bkref_idx = search_cur_bkref_entry (mctx, dst_idx); + Idx src_bkref_idx = search_cur_bkref_entry (mctx, src_idx); + for (lim_idx = 0; lim_idx < limits->nelem; ++lim_idx) + { + Idx subexp_idx; + struct re_backref_cache_entry *ent; + ent = mctx->bkref_ents + limits->elems[lim_idx]; + subexp_idx = dfa->nodes[ent->node].opr.idx; + + dst_pos = check_dst_limits_calc_pos (mctx, limits->elems[lim_idx], + subexp_idx, dst_node, dst_idx, + dst_bkref_idx); + src_pos = check_dst_limits_calc_pos (mctx, limits->elems[lim_idx], + subexp_idx, src_node, src_idx, + src_bkref_idx); + + /* In case of: + ( ) + ( ) + ( ) */ + if (src_pos == dst_pos) + continue; /* This is unrelated limitation. */ + else + return true; + } + return false; +} + +static int +check_dst_limits_calc_pos_1 (const re_match_context_t *mctx, int boundaries, + Idx subexp_idx, Idx from_node, Idx bkref_idx) +{ + const re_dfa_t *const dfa = mctx->dfa; + const re_node_set *eclosures = dfa->eclosures + from_node; + Idx node_idx; + + /* Else, we are on the boundary: examine the nodes on the epsilon + closure. */ + for (node_idx = 0; node_idx < eclosures->nelem; ++node_idx) + { + Idx node = eclosures->elems[node_idx]; + switch (dfa->nodes[node].type) + { + case OP_BACK_REF: + if (bkref_idx != -1) + { + struct re_backref_cache_entry *ent = mctx->bkref_ents + bkref_idx; + do + { + Idx dst; + int cpos; + + if (ent->node != node) + continue; + + if (subexp_idx < BITSET_WORD_BITS + && !(ent->eps_reachable_subexps_map + & ((bitset_word_t) 1 << subexp_idx))) + continue; + + /* Recurse trying to reach the OP_OPEN_SUBEXP and + OP_CLOSE_SUBEXP cases below. But, if the + destination node is the same node as the source + node, don't recurse because it would cause an + infinite loop: a regex that exhibits this behavior + is ()\1*\1* */ + dst = dfa->edests[node].elems[0]; + if (dst == from_node) + { + if (boundaries & 1) + return -1; + else /* if (boundaries & 2) */ + return 0; + } + + cpos = + check_dst_limits_calc_pos_1 (mctx, boundaries, subexp_idx, + dst, bkref_idx); + if (cpos == -1 /* && (boundaries & 1) */) + return -1; + if (cpos == 0 && (boundaries & 2)) + return 0; + + if (subexp_idx < BITSET_WORD_BITS) + ent->eps_reachable_subexps_map + &= ~((bitset_word_t) 1 << subexp_idx); + } + while (ent++->more); + } + break; + + case OP_OPEN_SUBEXP: + if ((boundaries & 1) && subexp_idx == dfa->nodes[node].opr.idx) + return -1; + break; + + case OP_CLOSE_SUBEXP: + if ((boundaries & 2) && subexp_idx == dfa->nodes[node].opr.idx) + return 0; + break; + + default: + break; + } + } + + return (boundaries & 2) ? 1 : 0; +} + +static int +check_dst_limits_calc_pos (const re_match_context_t *mctx, Idx limit, + Idx subexp_idx, Idx from_node, Idx str_idx, + Idx bkref_idx) +{ + struct re_backref_cache_entry *lim = mctx->bkref_ents + limit; + int boundaries; + + /* If we are outside the range of the subexpression, return -1 or 1. */ + if (str_idx < lim->subexp_from) + return -1; + + if (lim->subexp_to < str_idx) + return 1; + + /* If we are within the subexpression, return 0. */ + boundaries = (str_idx == lim->subexp_from); + boundaries |= (str_idx == lim->subexp_to) << 1; + if (boundaries == 0) + return 0; + + /* Else, examine epsilon closure. */ + return check_dst_limits_calc_pos_1 (mctx, boundaries, subexp_idx, + from_node, bkref_idx); +} + +/* Check the limitations of sub expressions LIMITS, and remove the nodes + which are against limitations from DEST_NODES. */ + +static reg_errcode_t +check_subexp_limits (const re_dfa_t *dfa, re_node_set *dest_nodes, + const re_node_set *candidates, re_node_set *limits, + struct re_backref_cache_entry *bkref_ents, Idx str_idx) +{ + reg_errcode_t err; + Idx node_idx, lim_idx; + + for (lim_idx = 0; lim_idx < limits->nelem; ++lim_idx) + { + Idx subexp_idx; + struct re_backref_cache_entry *ent; + ent = bkref_ents + limits->elems[lim_idx]; + + if (str_idx <= ent->subexp_from || ent->str_idx < str_idx) + continue; /* This is unrelated limitation. */ + + subexp_idx = dfa->nodes[ent->node].opr.idx; + if (ent->subexp_to == str_idx) + { + Idx ops_node = -1; + Idx cls_node = -1; + for (node_idx = 0; node_idx < dest_nodes->nelem; ++node_idx) + { + Idx node = dest_nodes->elems[node_idx]; + re_token_type_t type = dfa->nodes[node].type; + if (type == OP_OPEN_SUBEXP + && subexp_idx == dfa->nodes[node].opr.idx) + ops_node = node; + else if (type == OP_CLOSE_SUBEXP + && subexp_idx == dfa->nodes[node].opr.idx) + cls_node = node; + } + + /* Check the limitation of the open subexpression. */ + /* Note that (ent->subexp_to = str_idx != ent->subexp_from). */ + if (ops_node >= 0) + { + err = sub_epsilon_src_nodes (dfa, ops_node, dest_nodes, + candidates); + if (__glibc_unlikely (err != REG_NOERROR)) + return err; + } + + /* Check the limitation of the close subexpression. */ + if (cls_node >= 0) + for (node_idx = 0; node_idx < dest_nodes->nelem; ++node_idx) + { + Idx node = dest_nodes->elems[node_idx]; + if (!re_node_set_contains (dfa->inveclosures + node, + cls_node) + && !re_node_set_contains (dfa->eclosures + node, + cls_node)) + { + /* It is against this limitation. + Remove it form the current sifted state. */ + err = sub_epsilon_src_nodes (dfa, node, dest_nodes, + candidates); + if (__glibc_unlikely (err != REG_NOERROR)) + return err; + --node_idx; + } + } + } + else /* (ent->subexp_to != str_idx) */ + { + for (node_idx = 0; node_idx < dest_nodes->nelem; ++node_idx) + { + Idx node = dest_nodes->elems[node_idx]; + re_token_type_t type = dfa->nodes[node].type; + if (type == OP_CLOSE_SUBEXP || type == OP_OPEN_SUBEXP) + { + if (subexp_idx != dfa->nodes[node].opr.idx) + continue; + /* It is against this limitation. + Remove it form the current sifted state. */ + err = sub_epsilon_src_nodes (dfa, node, dest_nodes, + candidates); + if (__glibc_unlikely (err != REG_NOERROR)) + return err; + } + } + } + } + return REG_NOERROR; +} + +static reg_errcode_t +__attribute_warn_unused_result__ +sift_states_bkref (const re_match_context_t *mctx, re_sift_context_t *sctx, + Idx str_idx, const re_node_set *candidates) +{ + const re_dfa_t *const dfa = mctx->dfa; + reg_errcode_t err; + Idx node_idx, node; + re_sift_context_t local_sctx; + Idx first_idx = search_cur_bkref_entry (mctx, str_idx); + + if (first_idx == -1) + return REG_NOERROR; + + local_sctx.sifted_states = NULL; /* Mark that it hasn't been initialized. */ + + for (node_idx = 0; node_idx < candidates->nelem; ++node_idx) + { + Idx enabled_idx; + re_token_type_t type; + struct re_backref_cache_entry *entry; + node = candidates->elems[node_idx]; + type = dfa->nodes[node].type; + /* Avoid infinite loop for the REs like "()\1+". */ + if (node == sctx->last_node && str_idx == sctx->last_str_idx) + continue; + if (type != OP_BACK_REF) + continue; + + entry = mctx->bkref_ents + first_idx; + enabled_idx = first_idx; + do + { + Idx subexp_len; + Idx to_idx; + Idx dst_node; + bool ok; + re_dfastate_t *cur_state; + + if (entry->node != node) + continue; + subexp_len = entry->subexp_to - entry->subexp_from; + to_idx = str_idx + subexp_len; + dst_node = (subexp_len ? dfa->nexts[node] + : dfa->edests[node].elems[0]); + + if (to_idx > sctx->last_str_idx + || sctx->sifted_states[to_idx] == NULL + || !STATE_NODE_CONTAINS (sctx->sifted_states[to_idx], dst_node) + || check_dst_limits (mctx, &sctx->limits, node, + str_idx, dst_node, to_idx)) + continue; + + if (local_sctx.sifted_states == NULL) + { + local_sctx = *sctx; + err = re_node_set_init_copy (&local_sctx.limits, &sctx->limits); + if (__glibc_unlikely (err != REG_NOERROR)) + goto free_return; + } + local_sctx.last_node = node; + local_sctx.last_str_idx = str_idx; + ok = re_node_set_insert (&local_sctx.limits, enabled_idx); + if (__glibc_unlikely (! ok)) + { + err = REG_ESPACE; + goto free_return; + } + cur_state = local_sctx.sifted_states[str_idx]; + err = sift_states_backward (mctx, &local_sctx); + if (__glibc_unlikely (err != REG_NOERROR)) + goto free_return; + if (sctx->limited_states != NULL) + { + err = merge_state_array (dfa, sctx->limited_states, + local_sctx.sifted_states, + str_idx + 1); + if (__glibc_unlikely (err != REG_NOERROR)) + goto free_return; + } + local_sctx.sifted_states[str_idx] = cur_state; + re_node_set_remove (&local_sctx.limits, enabled_idx); + + /* mctx->bkref_ents may have changed, reload the pointer. */ + entry = mctx->bkref_ents + enabled_idx; + } + while (enabled_idx++, entry++->more); + } + err = REG_NOERROR; + free_return: + if (local_sctx.sifted_states != NULL) + { + re_node_set_free (&local_sctx.limits); + } + + return err; +} + + +static int +sift_states_iter_mb (const re_match_context_t *mctx, re_sift_context_t *sctx, + Idx node_idx, Idx str_idx, Idx max_str_idx) +{ + const re_dfa_t *const dfa = mctx->dfa; + int naccepted; + /* Check the node can accept "multi byte". */ + naccepted = check_node_accept_bytes (dfa, node_idx, &mctx->input, str_idx); + if (naccepted > 0 && str_idx + naccepted <= max_str_idx + && !STATE_NODE_CONTAINS (sctx->sifted_states[str_idx + naccepted], + dfa->nexts[node_idx])) + /* The node can't accept the "multi byte", or the + destination was already thrown away, then the node + couldn't accept the current input "multi byte". */ + naccepted = 0; + /* Otherwise, it is sure that the node could accept + 'naccepted' bytes input. */ + return naccepted; +} + +/* Functions for state transition. */ + +/* Return the next state to which the current state STATE will transit by + accepting the current input byte, and update STATE_LOG if necessary. + Return NULL on failure. + If STATE can accept a multibyte char/collating element/back reference + update the destination of STATE_LOG. */ + +static re_dfastate_t * +__attribute_warn_unused_result__ +transit_state (reg_errcode_t *err, re_match_context_t *mctx, + re_dfastate_t *state) +{ + re_dfastate_t **trtable; + unsigned char ch; + + /* If the current state can accept multibyte. */ + if (__glibc_unlikely (state->accept_mb)) + { + *err = transit_state_mb (mctx, state); + if (__glibc_unlikely (*err != REG_NOERROR)) + return NULL; + } + + /* Then decide the next state with the single byte. */ +#if 0 + if (0) + /* don't use transition table */ + return transit_state_sb (err, mctx, state); +#endif + + /* Use transition table */ + ch = re_string_fetch_byte (&mctx->input); + for (;;) + { + trtable = state->trtable; + if (__glibc_likely (trtable != NULL)) + return trtable[ch]; + + trtable = state->word_trtable; + if (__glibc_likely (trtable != NULL)) + { + unsigned int context; + context + = re_string_context_at (&mctx->input, + re_string_cur_idx (&mctx->input) - 1, + mctx->eflags); + if (IS_WORD_CONTEXT (context)) + return trtable[ch + SBC_MAX]; + else + return trtable[ch]; + } + + if (!build_trtable (mctx->dfa, state)) + { + *err = REG_ESPACE; + return NULL; + } + + /* Retry, we now have a transition table. */ + } +} + +/* Update the state_log if we need */ +static re_dfastate_t * +merge_state_with_log (reg_errcode_t *err, re_match_context_t *mctx, + re_dfastate_t *next_state) +{ + const re_dfa_t *const dfa = mctx->dfa; + Idx cur_idx = re_string_cur_idx (&mctx->input); + + if (cur_idx > mctx->state_log_top) + { + mctx->state_log[cur_idx] = next_state; + mctx->state_log_top = cur_idx; + } + else if (mctx->state_log[cur_idx] == 0) + { + mctx->state_log[cur_idx] = next_state; + } + else + { + re_dfastate_t *pstate; + unsigned int context; + re_node_set next_nodes, *log_nodes, *table_nodes = NULL; + /* If (state_log[cur_idx] != 0), it implies that cur_idx is + the destination of a multibyte char/collating element/ + back reference. Then the next state is the union set of + these destinations and the results of the transition table. */ + pstate = mctx->state_log[cur_idx]; + log_nodes = pstate->entrance_nodes; + if (next_state != NULL) + { + table_nodes = next_state->entrance_nodes; + *err = re_node_set_init_union (&next_nodes, table_nodes, + log_nodes); + if (__glibc_unlikely (*err != REG_NOERROR)) + return NULL; + } + else + next_nodes = *log_nodes; + /* Note: We already add the nodes of the initial state, + then we don't need to add them here. */ + + context = re_string_context_at (&mctx->input, + re_string_cur_idx (&mctx->input) - 1, + mctx->eflags); + next_state = mctx->state_log[cur_idx] + = re_acquire_state_context (err, dfa, &next_nodes, context); + /* We don't need to check errors here, since the return value of + this function is next_state and ERR is already set. */ + + if (table_nodes != NULL) + re_node_set_free (&next_nodes); + } + + if (__glibc_unlikely (dfa->nbackref) && next_state != NULL) + { + /* Check OP_OPEN_SUBEXP in the current state in case that we use them + later. We must check them here, since the back references in the + next state might use them. */ + *err = check_subexp_matching_top (mctx, &next_state->nodes, + cur_idx); + if (__glibc_unlikely (*err != REG_NOERROR)) + return NULL; + + /* If the next state has back references. */ + if (next_state->has_backref) + { + *err = transit_state_bkref (mctx, &next_state->nodes); + if (__glibc_unlikely (*err != REG_NOERROR)) + return NULL; + next_state = mctx->state_log[cur_idx]; + } + } + + return next_state; +} + +/* Skip bytes in the input that correspond to part of a + multi-byte match, then look in the log for a state + from which to restart matching. */ +static re_dfastate_t * +find_recover_state (reg_errcode_t *err, re_match_context_t *mctx) +{ + re_dfastate_t *cur_state; + do + { + Idx max = mctx->state_log_top; + Idx cur_str_idx = re_string_cur_idx (&mctx->input); + + do + { + if (++cur_str_idx > max) + return NULL; + re_string_skip_bytes (&mctx->input, 1); + } + while (mctx->state_log[cur_str_idx] == NULL); + + cur_state = merge_state_with_log (err, mctx, NULL); + } + while (*err == REG_NOERROR && cur_state == NULL); + return cur_state; +} + +/* Helper functions for transit_state. */ + +/* From the node set CUR_NODES, pick up the nodes whose types are + OP_OPEN_SUBEXP and which have corresponding back references in the regular + expression. And register them to use them later for evaluating the + corresponding back references. */ + +static reg_errcode_t +check_subexp_matching_top (re_match_context_t *mctx, re_node_set *cur_nodes, + Idx str_idx) +{ + const re_dfa_t *const dfa = mctx->dfa; + Idx node_idx; + reg_errcode_t err; + + /* TODO: This isn't efficient. + Because there might be more than one nodes whose types are + OP_OPEN_SUBEXP and whose index is SUBEXP_IDX, we must check all + nodes. + E.g. RE: (a){2} */ + for (node_idx = 0; node_idx < cur_nodes->nelem; ++node_idx) + { + Idx node = cur_nodes->elems[node_idx]; + if (dfa->nodes[node].type == OP_OPEN_SUBEXP + && dfa->nodes[node].opr.idx < BITSET_WORD_BITS + && (dfa->used_bkref_map + & ((bitset_word_t) 1 << dfa->nodes[node].opr.idx))) + { + err = match_ctx_add_subtop (mctx, node, str_idx); + if (__glibc_unlikely (err != REG_NOERROR)) + return err; + } + } + return REG_NOERROR; +} + +#if 0 +/* Return the next state to which the current state STATE will transit by + accepting the current input byte. Return NULL on failure. */ + +static re_dfastate_t * +transit_state_sb (reg_errcode_t *err, re_match_context_t *mctx, + re_dfastate_t *state) +{ + const re_dfa_t *const dfa = mctx->dfa; + re_node_set next_nodes; + re_dfastate_t *next_state; + Idx node_cnt, cur_str_idx = re_string_cur_idx (&mctx->input); + unsigned int context; + + *err = re_node_set_alloc (&next_nodes, state->nodes.nelem + 1); + if (__glibc_unlikely (*err != REG_NOERROR)) + return NULL; + for (node_cnt = 0; node_cnt < state->nodes.nelem; ++node_cnt) + { + Idx cur_node = state->nodes.elems[node_cnt]; + if (check_node_accept (mctx, dfa->nodes + cur_node, cur_str_idx)) + { + *err = re_node_set_merge (&next_nodes, + dfa->eclosures + dfa->nexts[cur_node]); + if (__glibc_unlikely (*err != REG_NOERROR)) + { + re_node_set_free (&next_nodes); + return NULL; + } + } + } + context = re_string_context_at (&mctx->input, cur_str_idx, mctx->eflags); + next_state = re_acquire_state_context (err, dfa, &next_nodes, context); + /* We don't need to check errors here, since the return value of + this function is next_state and ERR is already set. */ + + re_node_set_free (&next_nodes); + re_string_skip_bytes (&mctx->input, 1); + return next_state; +} +#endif + +static reg_errcode_t +transit_state_mb (re_match_context_t *mctx, re_dfastate_t *pstate) +{ + const re_dfa_t *const dfa = mctx->dfa; + reg_errcode_t err; + Idx i; + + for (i = 0; i < pstate->nodes.nelem; ++i) + { + re_node_set dest_nodes, *new_nodes; + Idx cur_node_idx = pstate->nodes.elems[i]; + int naccepted; + Idx dest_idx; + unsigned int context; + re_dfastate_t *dest_state; + + if (!dfa->nodes[cur_node_idx].accept_mb) + continue; + + if (dfa->nodes[cur_node_idx].constraint) + { + context = re_string_context_at (&mctx->input, + re_string_cur_idx (&mctx->input), + mctx->eflags); + if (NOT_SATISFY_NEXT_CONSTRAINT (dfa->nodes[cur_node_idx].constraint, + context)) + continue; + } + + /* How many bytes the node can accept? */ + naccepted = check_node_accept_bytes (dfa, cur_node_idx, &mctx->input, + re_string_cur_idx (&mctx->input)); + if (naccepted == 0) + continue; + + /* The node can accepts 'naccepted' bytes. */ + dest_idx = re_string_cur_idx (&mctx->input) + naccepted; + mctx->max_mb_elem_len = ((mctx->max_mb_elem_len < naccepted) ? naccepted + : mctx->max_mb_elem_len); + err = clean_state_log_if_needed (mctx, dest_idx); + if (__glibc_unlikely (err != REG_NOERROR)) + return err; + DEBUG_ASSERT (dfa->nexts[cur_node_idx] != -1); + new_nodes = dfa->eclosures + dfa->nexts[cur_node_idx]; + + dest_state = mctx->state_log[dest_idx]; + if (dest_state == NULL) + dest_nodes = *new_nodes; + else + { + err = re_node_set_init_union (&dest_nodes, + dest_state->entrance_nodes, new_nodes); + if (__glibc_unlikely (err != REG_NOERROR)) + return err; + } + context = re_string_context_at (&mctx->input, dest_idx - 1, + mctx->eflags); + mctx->state_log[dest_idx] + = re_acquire_state_context (&err, dfa, &dest_nodes, context); + if (dest_state != NULL) + re_node_set_free (&dest_nodes); + if (__glibc_unlikely (mctx->state_log[dest_idx] == NULL + && err != REG_NOERROR)) + return err; + } + return REG_NOERROR; +} + +static reg_errcode_t +transit_state_bkref (re_match_context_t *mctx, const re_node_set *nodes) +{ + const re_dfa_t *const dfa = mctx->dfa; + reg_errcode_t err; + Idx i; + Idx cur_str_idx = re_string_cur_idx (&mctx->input); + + for (i = 0; i < nodes->nelem; ++i) + { + Idx dest_str_idx, prev_nelem, bkc_idx; + Idx node_idx = nodes->elems[i]; + unsigned int context; + const re_token_t *node = dfa->nodes + node_idx; + re_node_set *new_dest_nodes; + + /* Check whether 'node' is a backreference or not. */ + if (node->type != OP_BACK_REF) + continue; + + if (node->constraint) + { + context = re_string_context_at (&mctx->input, cur_str_idx, + mctx->eflags); + if (NOT_SATISFY_NEXT_CONSTRAINT (node->constraint, context)) + continue; + } + + /* 'node' is a backreference. + Check the substring which the substring matched. */ + bkc_idx = mctx->nbkref_ents; + err = get_subexp (mctx, node_idx, cur_str_idx); + if (__glibc_unlikely (err != REG_NOERROR)) + goto free_return; + + /* And add the epsilon closures (which is 'new_dest_nodes') of + the backreference to appropriate state_log. */ + DEBUG_ASSERT (dfa->nexts[node_idx] != -1); + for (; bkc_idx < mctx->nbkref_ents; ++bkc_idx) + { + Idx subexp_len; + re_dfastate_t *dest_state; + struct re_backref_cache_entry *bkref_ent; + bkref_ent = mctx->bkref_ents + bkc_idx; + if (bkref_ent->node != node_idx || bkref_ent->str_idx != cur_str_idx) + continue; + subexp_len = bkref_ent->subexp_to - bkref_ent->subexp_from; + new_dest_nodes = (subexp_len == 0 + ? dfa->eclosures + dfa->edests[node_idx].elems[0] + : dfa->eclosures + dfa->nexts[node_idx]); + dest_str_idx = (cur_str_idx + bkref_ent->subexp_to + - bkref_ent->subexp_from); + context = re_string_context_at (&mctx->input, dest_str_idx - 1, + mctx->eflags); + dest_state = mctx->state_log[dest_str_idx]; + prev_nelem = ((mctx->state_log[cur_str_idx] == NULL) ? 0 + : mctx->state_log[cur_str_idx]->nodes.nelem); + /* Add 'new_dest_node' to state_log. */ + if (dest_state == NULL) + { + mctx->state_log[dest_str_idx] + = re_acquire_state_context (&err, dfa, new_dest_nodes, + context); + if (__glibc_unlikely (mctx->state_log[dest_str_idx] == NULL + && err != REG_NOERROR)) + goto free_return; + } + else + { + re_node_set dest_nodes; + err = re_node_set_init_union (&dest_nodes, + dest_state->entrance_nodes, + new_dest_nodes); + if (__glibc_unlikely (err != REG_NOERROR)) + { + re_node_set_free (&dest_nodes); + goto free_return; + } + mctx->state_log[dest_str_idx] + = re_acquire_state_context (&err, dfa, &dest_nodes, context); + re_node_set_free (&dest_nodes); + if (__glibc_unlikely (mctx->state_log[dest_str_idx] == NULL + && err != REG_NOERROR)) + goto free_return; + } + /* We need to check recursively if the backreference can epsilon + transit. */ + if (subexp_len == 0 + && mctx->state_log[cur_str_idx]->nodes.nelem > prev_nelem) + { + err = check_subexp_matching_top (mctx, new_dest_nodes, + cur_str_idx); + if (__glibc_unlikely (err != REG_NOERROR)) + goto free_return; + err = transit_state_bkref (mctx, new_dest_nodes); + if (__glibc_unlikely (err != REG_NOERROR)) + goto free_return; + } + } + } + err = REG_NOERROR; + free_return: + return err; +} + +/* Enumerate all the candidates which the backreference BKREF_NODE can match + at BKREF_STR_IDX, and register them by match_ctx_add_entry(). + Note that we might collect inappropriate candidates here. + However, the cost of checking them strictly here is too high, then we + delay these checking for prune_impossible_nodes(). */ + +static reg_errcode_t +__attribute_warn_unused_result__ +get_subexp (re_match_context_t *mctx, Idx bkref_node, Idx bkref_str_idx) +{ + const re_dfa_t *const dfa = mctx->dfa; + Idx subexp_num, sub_top_idx; + const char *buf = (const char *) re_string_get_buffer (&mctx->input); + /* Return if we have already checked BKREF_NODE at BKREF_STR_IDX. */ + Idx cache_idx = search_cur_bkref_entry (mctx, bkref_str_idx); + if (cache_idx != -1) + { + const struct re_backref_cache_entry *entry + = mctx->bkref_ents + cache_idx; + do + if (entry->node == bkref_node) + return REG_NOERROR; /* We already checked it. */ + while (entry++->more); + } + + subexp_num = dfa->nodes[bkref_node].opr.idx; + + /* For each sub expression */ + for (sub_top_idx = 0; sub_top_idx < mctx->nsub_tops; ++sub_top_idx) + { + reg_errcode_t err; + re_sub_match_top_t *sub_top = mctx->sub_tops[sub_top_idx]; + re_sub_match_last_t *sub_last; + Idx sub_last_idx, sl_str, bkref_str_off; + + if (dfa->nodes[sub_top->node].opr.idx != subexp_num) + continue; /* It isn't related. */ + + sl_str = sub_top->str_idx; + bkref_str_off = bkref_str_idx; + /* At first, check the last node of sub expressions we already + evaluated. */ + for (sub_last_idx = 0; sub_last_idx < sub_top->nlasts; ++sub_last_idx) + { + regoff_t sl_str_diff; + sub_last = sub_top->lasts[sub_last_idx]; + sl_str_diff = sub_last->str_idx - sl_str; + /* The matched string by the sub expression match with the substring + at the back reference? */ + if (sl_str_diff > 0) + { + if (__glibc_unlikely (bkref_str_off + sl_str_diff + > mctx->input.valid_len)) + { + /* Not enough chars for a successful match. */ + if (bkref_str_off + sl_str_diff > mctx->input.len) + break; + + err = clean_state_log_if_needed (mctx, + bkref_str_off + + sl_str_diff); + if (__glibc_unlikely (err != REG_NOERROR)) + return err; + buf = (const char *) re_string_get_buffer (&mctx->input); + } + if (memcmp (buf + bkref_str_off, buf + sl_str, sl_str_diff) != 0) + /* We don't need to search this sub expression any more. */ + break; + } + bkref_str_off += sl_str_diff; + sl_str += sl_str_diff; + err = get_subexp_sub (mctx, sub_top, sub_last, bkref_node, + bkref_str_idx); + + /* Reload buf, since the preceding call might have reallocated + the buffer. */ + buf = (const char *) re_string_get_buffer (&mctx->input); + + if (err == REG_NOMATCH) + continue; + if (__glibc_unlikely (err != REG_NOERROR)) + return err; + } + + if (sub_last_idx < sub_top->nlasts) + continue; + if (sub_last_idx > 0) + ++sl_str; + /* Then, search for the other last nodes of the sub expression. */ + for (; sl_str <= bkref_str_idx; ++sl_str) + { + Idx cls_node; + regoff_t sl_str_off; + const re_node_set *nodes; + sl_str_off = sl_str - sub_top->str_idx; + /* The matched string by the sub expression match with the substring + at the back reference? */ + if (sl_str_off > 0) + { + if (__glibc_unlikely (bkref_str_off >= mctx->input.valid_len)) + { + /* If we are at the end of the input, we cannot match. */ + if (bkref_str_off >= mctx->input.len) + break; + + err = extend_buffers (mctx, bkref_str_off + 1); + if (__glibc_unlikely (err != REG_NOERROR)) + return err; + + buf = (const char *) re_string_get_buffer (&mctx->input); + } + if (buf [bkref_str_off++] != buf[sl_str - 1]) + break; /* We don't need to search this sub expression + any more. */ + } + if (mctx->state_log[sl_str] == NULL) + continue; + /* Does this state have a ')' of the sub expression? */ + nodes = &mctx->state_log[sl_str]->nodes; + cls_node = find_subexp_node (dfa, nodes, subexp_num, + OP_CLOSE_SUBEXP); + if (cls_node == -1) + continue; /* No. */ + if (sub_top->path == NULL) + { + sub_top->path = calloc (sizeof (state_array_t), + sl_str - sub_top->str_idx + 1); + if (sub_top->path == NULL) + return REG_ESPACE; + } + /* Can the OP_OPEN_SUBEXP node arrive the OP_CLOSE_SUBEXP node + in the current context? */ + err = check_arrival (mctx, sub_top->path, sub_top->node, + sub_top->str_idx, cls_node, sl_str, + OP_CLOSE_SUBEXP); + if (err == REG_NOMATCH) + continue; + if (__glibc_unlikely (err != REG_NOERROR)) + return err; + sub_last = match_ctx_add_sublast (sub_top, cls_node, sl_str); + if (__glibc_unlikely (sub_last == NULL)) + return REG_ESPACE; + err = get_subexp_sub (mctx, sub_top, sub_last, bkref_node, + bkref_str_idx); + buf = (const char *) re_string_get_buffer (&mctx->input); + if (err == REG_NOMATCH) + continue; + if (__glibc_unlikely (err != REG_NOERROR)) + return err; + } + } + return REG_NOERROR; +} + +/* Helper functions for get_subexp(). */ + +/* Check SUB_LAST can arrive to the back reference BKREF_NODE at BKREF_STR. + If it can arrive, register the sub expression expressed with SUB_TOP + and SUB_LAST. */ + +static reg_errcode_t +get_subexp_sub (re_match_context_t *mctx, const re_sub_match_top_t *sub_top, + re_sub_match_last_t *sub_last, Idx bkref_node, Idx bkref_str) +{ + reg_errcode_t err; + Idx to_idx; + /* Can the subexpression arrive the back reference? */ + err = check_arrival (mctx, &sub_last->path, sub_last->node, + sub_last->str_idx, bkref_node, bkref_str, + OP_OPEN_SUBEXP); + if (err != REG_NOERROR) + return err; + err = match_ctx_add_entry (mctx, bkref_node, bkref_str, sub_top->str_idx, + sub_last->str_idx); + if (__glibc_unlikely (err != REG_NOERROR)) + return err; + to_idx = bkref_str + sub_last->str_idx - sub_top->str_idx; + return clean_state_log_if_needed (mctx, to_idx); +} + +/* Find the first node which is '(' or ')' and whose index is SUBEXP_IDX. + Search '(' if FL_OPEN, or search ')' otherwise. + TODO: This function isn't efficient... + Because there might be more than one nodes whose types are + OP_OPEN_SUBEXP and whose index is SUBEXP_IDX, we must check all + nodes. + E.g. RE: (a){2} */ + +static Idx +find_subexp_node (const re_dfa_t *dfa, const re_node_set *nodes, + Idx subexp_idx, int type) +{ + Idx cls_idx; + for (cls_idx = 0; cls_idx < nodes->nelem; ++cls_idx) + { + Idx cls_node = nodes->elems[cls_idx]; + const re_token_t *node = dfa->nodes + cls_node; + if (node->type == type + && node->opr.idx == subexp_idx) + return cls_node; + } + return -1; +} + +/* Check whether the node TOP_NODE at TOP_STR can arrive to the node + LAST_NODE at LAST_STR. We record the path onto PATH since it will be + heavily reused. + Return REG_NOERROR if it can arrive, REG_NOMATCH if it cannot, + REG_ESPACE if memory is exhausted. */ + +static reg_errcode_t +__attribute_warn_unused_result__ +check_arrival (re_match_context_t *mctx, state_array_t *path, Idx top_node, + Idx top_str, Idx last_node, Idx last_str, int type) +{ + const re_dfa_t *const dfa = mctx->dfa; + reg_errcode_t err = REG_NOERROR; + Idx subexp_num, backup_cur_idx, str_idx, null_cnt; + re_dfastate_t *cur_state = NULL; + re_node_set *cur_nodes, next_nodes; + re_dfastate_t **backup_state_log; + unsigned int context; + + subexp_num = dfa->nodes[top_node].opr.idx; + /* Extend the buffer if we need. */ + if (__glibc_unlikely (path->alloc < last_str + mctx->max_mb_elem_len + 1)) + { + re_dfastate_t **new_array; + Idx old_alloc = path->alloc; + Idx incr_alloc = last_str + mctx->max_mb_elem_len + 1; + Idx new_alloc; + if (__glibc_unlikely (IDX_MAX - old_alloc < incr_alloc)) + return REG_ESPACE; + new_alloc = old_alloc + incr_alloc; + if (__glibc_unlikely (SIZE_MAX / sizeof (re_dfastate_t *) < new_alloc)) + return REG_ESPACE; + new_array = re_realloc (path->array, re_dfastate_t *, new_alloc); + if (__glibc_unlikely (new_array == NULL)) + return REG_ESPACE; + path->array = new_array; + path->alloc = new_alloc; + memset (new_array + old_alloc, '\0', + sizeof (re_dfastate_t *) * (path->alloc - old_alloc)); + } + + str_idx = path->next_idx ? path->next_idx : top_str; + + /* Temporary modify MCTX. */ + backup_state_log = mctx->state_log; + backup_cur_idx = mctx->input.cur_idx; + mctx->state_log = path->array; + mctx->input.cur_idx = str_idx; + + /* Setup initial node set. */ + context = re_string_context_at (&mctx->input, str_idx - 1, mctx->eflags); + if (str_idx == top_str) + { + err = re_node_set_init_1 (&next_nodes, top_node); + if (__glibc_unlikely (err != REG_NOERROR)) + return err; + err = check_arrival_expand_ecl (dfa, &next_nodes, subexp_num, type); + if (__glibc_unlikely (err != REG_NOERROR)) + { + re_node_set_free (&next_nodes); + return err; + } + } + else + { + cur_state = mctx->state_log[str_idx]; + if (cur_state && cur_state->has_backref) + { + err = re_node_set_init_copy (&next_nodes, &cur_state->nodes); + if (__glibc_unlikely (err != REG_NOERROR)) + return err; + } + else + re_node_set_init_empty (&next_nodes); + } + if (str_idx == top_str || (cur_state && cur_state->has_backref)) + { + if (next_nodes.nelem) + { + err = expand_bkref_cache (mctx, &next_nodes, str_idx, + subexp_num, type); + if (__glibc_unlikely (err != REG_NOERROR)) + { + re_node_set_free (&next_nodes); + return err; + } + } + cur_state = re_acquire_state_context (&err, dfa, &next_nodes, context); + if (__glibc_unlikely (cur_state == NULL && err != REG_NOERROR)) + { + re_node_set_free (&next_nodes); + return err; + } + mctx->state_log[str_idx] = cur_state; + } + + for (null_cnt = 0; str_idx < last_str && null_cnt <= mctx->max_mb_elem_len;) + { + re_node_set_empty (&next_nodes); + if (mctx->state_log[str_idx + 1]) + { + err = re_node_set_merge (&next_nodes, + &mctx->state_log[str_idx + 1]->nodes); + if (__glibc_unlikely (err != REG_NOERROR)) + { + re_node_set_free (&next_nodes); + return err; + } + } + if (cur_state) + { + err = check_arrival_add_next_nodes (mctx, str_idx, + &cur_state->non_eps_nodes, + &next_nodes); + if (__glibc_unlikely (err != REG_NOERROR)) + { + re_node_set_free (&next_nodes); + return err; + } + } + ++str_idx; + if (next_nodes.nelem) + { + err = check_arrival_expand_ecl (dfa, &next_nodes, subexp_num, type); + if (__glibc_unlikely (err != REG_NOERROR)) + { + re_node_set_free (&next_nodes); + return err; + } + err = expand_bkref_cache (mctx, &next_nodes, str_idx, + subexp_num, type); + if (__glibc_unlikely (err != REG_NOERROR)) + { + re_node_set_free (&next_nodes); + return err; + } + } + context = re_string_context_at (&mctx->input, str_idx - 1, mctx->eflags); + cur_state = re_acquire_state_context (&err, dfa, &next_nodes, context); + if (__glibc_unlikely (cur_state == NULL && err != REG_NOERROR)) + { + re_node_set_free (&next_nodes); + return err; + } + mctx->state_log[str_idx] = cur_state; + null_cnt = cur_state == NULL ? null_cnt + 1 : 0; + } + re_node_set_free (&next_nodes); + cur_nodes = (mctx->state_log[last_str] == NULL ? NULL + : &mctx->state_log[last_str]->nodes); + path->next_idx = str_idx; + + /* Fix MCTX. */ + mctx->state_log = backup_state_log; + mctx->input.cur_idx = backup_cur_idx; + + /* Then check the current node set has the node LAST_NODE. */ + if (cur_nodes != NULL && re_node_set_contains (cur_nodes, last_node)) + return REG_NOERROR; + + return REG_NOMATCH; +} + +/* Helper functions for check_arrival. */ + +/* Calculate the destination nodes of CUR_NODES at STR_IDX, and append them + to NEXT_NODES. + TODO: This function is similar to the functions transit_state*(), + however this function has many additional works. + Can't we unify them? */ + +static reg_errcode_t +__attribute_warn_unused_result__ +check_arrival_add_next_nodes (re_match_context_t *mctx, Idx str_idx, + re_node_set *cur_nodes, re_node_set *next_nodes) +{ + const re_dfa_t *const dfa = mctx->dfa; + bool ok; + Idx cur_idx; + reg_errcode_t err = REG_NOERROR; + re_node_set union_set; + re_node_set_init_empty (&union_set); + for (cur_idx = 0; cur_idx < cur_nodes->nelem; ++cur_idx) + { + int naccepted = 0; + Idx cur_node = cur_nodes->elems[cur_idx]; + DEBUG_ASSERT (!IS_EPSILON_NODE (dfa->nodes[cur_node].type)); + + /* If the node may accept "multi byte". */ + if (dfa->nodes[cur_node].accept_mb) + { + naccepted = check_node_accept_bytes (dfa, cur_node, &mctx->input, + str_idx); + if (naccepted > 1) + { + re_dfastate_t *dest_state; + Idx next_node = dfa->nexts[cur_node]; + Idx next_idx = str_idx + naccepted; + dest_state = mctx->state_log[next_idx]; + re_node_set_empty (&union_set); + if (dest_state) + { + err = re_node_set_merge (&union_set, &dest_state->nodes); + if (__glibc_unlikely (err != REG_NOERROR)) + { + re_node_set_free (&union_set); + return err; + } + } + ok = re_node_set_insert (&union_set, next_node); + if (__glibc_unlikely (! ok)) + { + re_node_set_free (&union_set); + return REG_ESPACE; + } + mctx->state_log[next_idx] = re_acquire_state (&err, dfa, + &union_set); + if (__glibc_unlikely (mctx->state_log[next_idx] == NULL + && err != REG_NOERROR)) + { + re_node_set_free (&union_set); + return err; + } + } + } + + if (naccepted + || check_node_accept (mctx, dfa->nodes + cur_node, str_idx)) + { + ok = re_node_set_insert (next_nodes, dfa->nexts[cur_node]); + if (__glibc_unlikely (! ok)) + { + re_node_set_free (&union_set); + return REG_ESPACE; + } + } + } + re_node_set_free (&union_set); + return REG_NOERROR; +} + +/* For all the nodes in CUR_NODES, add the epsilon closures of them to + CUR_NODES, however exclude the nodes which are: + - inside the sub expression whose number is EX_SUBEXP, if FL_OPEN. + - out of the sub expression whose number is EX_SUBEXP, if !FL_OPEN. +*/ + +static reg_errcode_t +check_arrival_expand_ecl (const re_dfa_t *dfa, re_node_set *cur_nodes, + Idx ex_subexp, int type) +{ + reg_errcode_t err; + Idx idx, outside_node; + re_node_set new_nodes; + DEBUG_ASSERT (cur_nodes->nelem); + err = re_node_set_alloc (&new_nodes, cur_nodes->nelem); + if (__glibc_unlikely (err != REG_NOERROR)) + return err; + /* Create a new node set NEW_NODES with the nodes which are epsilon + closures of the node in CUR_NODES. */ + + for (idx = 0; idx < cur_nodes->nelem; ++idx) + { + Idx cur_node = cur_nodes->elems[idx]; + const re_node_set *eclosure = dfa->eclosures + cur_node; + outside_node = find_subexp_node (dfa, eclosure, ex_subexp, type); + if (outside_node == -1) + { + /* There are no problematic nodes, just merge them. */ + err = re_node_set_merge (&new_nodes, eclosure); + if (__glibc_unlikely (err != REG_NOERROR)) + { + re_node_set_free (&new_nodes); + return err; + } + } + else + { + /* There are problematic nodes, re-calculate incrementally. */ + err = check_arrival_expand_ecl_sub (dfa, &new_nodes, cur_node, + ex_subexp, type); + if (__glibc_unlikely (err != REG_NOERROR)) + { + re_node_set_free (&new_nodes); + return err; + } + } + } + re_node_set_free (cur_nodes); + *cur_nodes = new_nodes; + return REG_NOERROR; +} + +/* Helper function for check_arrival_expand_ecl. + Check incrementally the epsilon closure of TARGET, and if it isn't + problematic append it to DST_NODES. */ + +static reg_errcode_t +__attribute_warn_unused_result__ +check_arrival_expand_ecl_sub (const re_dfa_t *dfa, re_node_set *dst_nodes, + Idx target, Idx ex_subexp, int type) +{ + Idx cur_node; + for (cur_node = target; !re_node_set_contains (dst_nodes, cur_node);) + { + bool ok; + + if (dfa->nodes[cur_node].type == type + && dfa->nodes[cur_node].opr.idx == ex_subexp) + { + if (type == OP_CLOSE_SUBEXP) + { + ok = re_node_set_insert (dst_nodes, cur_node); + if (__glibc_unlikely (! ok)) + return REG_ESPACE; + } + break; + } + ok = re_node_set_insert (dst_nodes, cur_node); + if (__glibc_unlikely (! ok)) + return REG_ESPACE; + if (dfa->edests[cur_node].nelem == 0) + break; + if (dfa->edests[cur_node].nelem == 2) + { + reg_errcode_t err; + err = check_arrival_expand_ecl_sub (dfa, dst_nodes, + dfa->edests[cur_node].elems[1], + ex_subexp, type); + if (__glibc_unlikely (err != REG_NOERROR)) + return err; + } + cur_node = dfa->edests[cur_node].elems[0]; + } + return REG_NOERROR; +} + + +/* For all the back references in the current state, calculate the + destination of the back references by the appropriate entry + in MCTX->BKREF_ENTS. */ + +static reg_errcode_t +__attribute_warn_unused_result__ +expand_bkref_cache (re_match_context_t *mctx, re_node_set *cur_nodes, + Idx cur_str, Idx subexp_num, int type) +{ + const re_dfa_t *const dfa = mctx->dfa; + reg_errcode_t err; + Idx cache_idx_start = search_cur_bkref_entry (mctx, cur_str); + struct re_backref_cache_entry *ent; + + if (cache_idx_start == -1) + return REG_NOERROR; + + restart: + ent = mctx->bkref_ents + cache_idx_start; + do + { + Idx to_idx, next_node; + + /* Is this entry ENT is appropriate? */ + if (!re_node_set_contains (cur_nodes, ent->node)) + continue; /* No. */ + + to_idx = cur_str + ent->subexp_to - ent->subexp_from; + /* Calculate the destination of the back reference, and append it + to MCTX->STATE_LOG. */ + if (to_idx == cur_str) + { + /* The backreference did epsilon transit, we must re-check all the + node in the current state. */ + re_node_set new_dests; + reg_errcode_t err2, err3; + next_node = dfa->edests[ent->node].elems[0]; + if (re_node_set_contains (cur_nodes, next_node)) + continue; + err = re_node_set_init_1 (&new_dests, next_node); + err2 = check_arrival_expand_ecl (dfa, &new_dests, subexp_num, type); + err3 = re_node_set_merge (cur_nodes, &new_dests); + re_node_set_free (&new_dests); + if (__glibc_unlikely (err != REG_NOERROR || err2 != REG_NOERROR + || err3 != REG_NOERROR)) + { + err = (err != REG_NOERROR ? err + : (err2 != REG_NOERROR ? err2 : err3)); + return err; + } + /* TODO: It is still inefficient... */ + goto restart; + } + else + { + re_node_set union_set; + next_node = dfa->nexts[ent->node]; + if (mctx->state_log[to_idx]) + { + bool ok; + if (re_node_set_contains (&mctx->state_log[to_idx]->nodes, + next_node)) + continue; + err = re_node_set_init_copy (&union_set, + &mctx->state_log[to_idx]->nodes); + ok = re_node_set_insert (&union_set, next_node); + if (__glibc_unlikely (err != REG_NOERROR || ! ok)) + { + re_node_set_free (&union_set); + err = err != REG_NOERROR ? err : REG_ESPACE; + return err; + } + } + else + { + err = re_node_set_init_1 (&union_set, next_node); + if (__glibc_unlikely (err != REG_NOERROR)) + return err; + } + mctx->state_log[to_idx] = re_acquire_state (&err, dfa, &union_set); + re_node_set_free (&union_set); + if (__glibc_unlikely (mctx->state_log[to_idx] == NULL + && err != REG_NOERROR)) + return err; + } + } + while (ent++->more); + return REG_NOERROR; +} + +/* Build transition table for the state. + Return true if successful. */ + +static bool __attribute_noinline__ +build_trtable (const re_dfa_t *dfa, re_dfastate_t *state) +{ + reg_errcode_t err; + Idx i, j; + int ch; + bool need_word_trtable = false; + bitset_word_t elem, mask; + Idx ndests; /* Number of the destination states from 'state'. */ + re_dfastate_t **trtable; + re_dfastate_t *dest_states[SBC_MAX]; + re_dfastate_t *dest_states_word[SBC_MAX]; + re_dfastate_t *dest_states_nl[SBC_MAX]; + re_node_set follows; + bitset_t acceptable; + + /* We build DFA states which corresponds to the destination nodes + from 'state'. 'dests_node[i]' represents the nodes which i-th + destination state contains, and 'dests_ch[i]' represents the + characters which i-th destination state accepts. */ + re_node_set dests_node[SBC_MAX]; + bitset_t dests_ch[SBC_MAX]; + + /* Initialize transition table. */ + state->word_trtable = state->trtable = NULL; + + /* At first, group all nodes belonging to 'state' into several + destinations. */ + ndests = group_nodes_into_DFAstates (dfa, state, dests_node, dests_ch); + if (__glibc_unlikely (ndests <= 0)) + { + /* Return false in case of an error, true otherwise. */ + if (ndests == 0) + { + state->trtable = (re_dfastate_t **) + calloc (sizeof (re_dfastate_t *), SBC_MAX); + if (__glibc_unlikely (state->trtable == NULL)) + return false; + return true; + } + return false; + } + + err = re_node_set_alloc (&follows, ndests + 1); + if (__glibc_unlikely (err != REG_NOERROR)) + { + out_free: + re_node_set_free (&follows); + for (i = 0; i < ndests; ++i) + re_node_set_free (dests_node + i); + return false; + } + + bitset_empty (acceptable); + + /* Then build the states for all destinations. */ + for (i = 0; i < ndests; ++i) + { + Idx next_node; + re_node_set_empty (&follows); + /* Merge the follows of this destination states. */ + for (j = 0; j < dests_node[i].nelem; ++j) + { + next_node = dfa->nexts[dests_node[i].elems[j]]; + if (next_node != -1) + { + err = re_node_set_merge (&follows, dfa->eclosures + next_node); + if (__glibc_unlikely (err != REG_NOERROR)) + goto out_free; + } + } + dest_states[i] = re_acquire_state_context (&err, dfa, &follows, 0); + if (__glibc_unlikely (dest_states[i] == NULL && err != REG_NOERROR)) + goto out_free; + /* If the new state has context constraint, + build appropriate states for these contexts. */ + if (dest_states[i]->has_constraint) + { + dest_states_word[i] = re_acquire_state_context (&err, dfa, &follows, + CONTEXT_WORD); + if (__glibc_unlikely (dest_states_word[i] == NULL + && err != REG_NOERROR)) + goto out_free; + + if (dest_states[i] != dest_states_word[i] && dfa->mb_cur_max > 1) + need_word_trtable = true; + + dest_states_nl[i] = re_acquire_state_context (&err, dfa, &follows, + CONTEXT_NEWLINE); + if (__glibc_unlikely (dest_states_nl[i] == NULL && err != REG_NOERROR)) + goto out_free; + } + else + { + dest_states_word[i] = dest_states[i]; + dest_states_nl[i] = dest_states[i]; + } + bitset_merge (acceptable, dests_ch[i]); + } + + if (!__glibc_unlikely (need_word_trtable)) + { + /* We don't care about whether the following character is a word + character, or we are in a single-byte character set so we can + discern by looking at the character code: allocate a + 256-entry transition table. */ + trtable = state->trtable = + (re_dfastate_t **) calloc (sizeof (re_dfastate_t *), SBC_MAX); + if (__glibc_unlikely (trtable == NULL)) + goto out_free; + + /* For all characters ch...: */ + for (i = 0; i < BITSET_WORDS; ++i) + for (ch = i * BITSET_WORD_BITS, elem = acceptable[i], mask = 1; + elem; + mask <<= 1, elem >>= 1, ++ch) + if (__glibc_unlikely (elem & 1)) + { + /* There must be exactly one destination which accepts + character ch. See group_nodes_into_DFAstates. */ + for (j = 0; (dests_ch[j][i] & mask) == 0; ++j) + ; + + /* j-th destination accepts the word character ch. */ + if (dfa->word_char[i] & mask) + trtable[ch] = dest_states_word[j]; + else + trtable[ch] = dest_states[j]; + } + } + else + { + /* We care about whether the following character is a word + character, and we are in a multi-byte character set: discern + by looking at the character code: build two 256-entry + transition tables, one starting at trtable[0] and one + starting at trtable[SBC_MAX]. */ + trtable = state->word_trtable = + (re_dfastate_t **) calloc (sizeof (re_dfastate_t *), 2 * SBC_MAX); + if (__glibc_unlikely (trtable == NULL)) + goto out_free; + + /* For all characters ch...: */ + for (i = 0; i < BITSET_WORDS; ++i) + for (ch = i * BITSET_WORD_BITS, elem = acceptable[i], mask = 1; + elem; + mask <<= 1, elem >>= 1, ++ch) + if (__glibc_unlikely (elem & 1)) + { + /* There must be exactly one destination which accepts + character ch. See group_nodes_into_DFAstates. */ + for (j = 0; (dests_ch[j][i] & mask) == 0; ++j) + ; + + /* j-th destination accepts the word character ch. */ + trtable[ch] = dest_states[j]; + trtable[ch + SBC_MAX] = dest_states_word[j]; + } + } + + /* new line */ + if (bitset_contain (acceptable, NEWLINE_CHAR)) + { + /* The current state accepts newline character. */ + for (j = 0; j < ndests; ++j) + if (bitset_contain (dests_ch[j], NEWLINE_CHAR)) + { + /* k-th destination accepts newline character. */ + trtable[NEWLINE_CHAR] = dest_states_nl[j]; + if (need_word_trtable) + trtable[NEWLINE_CHAR + SBC_MAX] = dest_states_nl[j]; + /* There must be only one destination which accepts + newline. See group_nodes_into_DFAstates. */ + break; + } + } + + re_node_set_free (&follows); + for (i = 0; i < ndests; ++i) + re_node_set_free (dests_node + i); + return true; +} + +/* Group all nodes belonging to STATE into several destinations. + Then for all destinations, set the nodes belonging to the destination + to DESTS_NODE[i] and set the characters accepted by the destination + to DEST_CH[i]. Return the number of destinations if successful, + -1 on internal error. */ + +static Idx +group_nodes_into_DFAstates (const re_dfa_t *dfa, const re_dfastate_t *state, + re_node_set *dests_node, bitset_t *dests_ch) +{ + reg_errcode_t err; + bool ok; + Idx i, j, k; + Idx ndests; /* Number of the destinations from 'state'. */ + bitset_t accepts; /* Characters a node can accept. */ + const re_node_set *cur_nodes = &state->nodes; + bitset_empty (accepts); + ndests = 0; + + /* For all the nodes belonging to 'state', */ + for (i = 0; i < cur_nodes->nelem; ++i) + { + re_token_t *node = &dfa->nodes[cur_nodes->elems[i]]; + re_token_type_t type = node->type; + unsigned int constraint = node->constraint; + + /* Enumerate all single byte character this node can accept. */ + if (type == CHARACTER) + bitset_set (accepts, node->opr.c); + else if (type == SIMPLE_BRACKET) + { + bitset_merge (accepts, node->opr.sbcset); + } + else if (type == OP_PERIOD) + { + if (dfa->mb_cur_max > 1) + bitset_merge (accepts, dfa->sb_char); + else + bitset_set_all (accepts); + if (!(dfa->syntax & RE_DOT_NEWLINE)) + bitset_clear (accepts, '\n'); + if (dfa->syntax & RE_DOT_NOT_NULL) + bitset_clear (accepts, '\0'); + } + else if (type == OP_UTF8_PERIOD) + { + if (ASCII_CHARS % BITSET_WORD_BITS == 0) + memset (accepts, -1, ASCII_CHARS / CHAR_BIT); + else + bitset_merge (accepts, utf8_sb_map); + if (!(dfa->syntax & RE_DOT_NEWLINE)) + bitset_clear (accepts, '\n'); + if (dfa->syntax & RE_DOT_NOT_NULL) + bitset_clear (accepts, '\0'); + } + else + continue; + + /* Check the 'accepts' and sift the characters which are not + match it the context. */ + if (constraint) + { + if (constraint & NEXT_NEWLINE_CONSTRAINT) + { + bool accepts_newline = bitset_contain (accepts, NEWLINE_CHAR); + bitset_empty (accepts); + if (accepts_newline) + bitset_set (accepts, NEWLINE_CHAR); + else + continue; + } + if (constraint & NEXT_ENDBUF_CONSTRAINT) + { + bitset_empty (accepts); + continue; + } + + if (constraint & NEXT_WORD_CONSTRAINT) + { + bitset_word_t any_set = 0; + if (type == CHARACTER && !node->word_char) + { + bitset_empty (accepts); + continue; + } + if (dfa->mb_cur_max > 1) + for (j = 0; j < BITSET_WORDS; ++j) + any_set |= (accepts[j] &= (dfa->word_char[j] | ~dfa->sb_char[j])); + else + for (j = 0; j < BITSET_WORDS; ++j) + any_set |= (accepts[j] &= dfa->word_char[j]); + if (!any_set) + continue; + } + if (constraint & NEXT_NOTWORD_CONSTRAINT) + { + bitset_word_t any_set = 0; + if (type == CHARACTER && node->word_char) + { + bitset_empty (accepts); + continue; + } + if (dfa->mb_cur_max > 1) + for (j = 0; j < BITSET_WORDS; ++j) + any_set |= (accepts[j] &= ~(dfa->word_char[j] & dfa->sb_char[j])); + else + for (j = 0; j < BITSET_WORDS; ++j) + any_set |= (accepts[j] &= ~dfa->word_char[j]); + if (!any_set) + continue; + } + } + + /* Then divide 'accepts' into DFA states, or create a new + state. Above, we make sure that accepts is not empty. */ + for (j = 0; j < ndests; ++j) + { + bitset_t intersec; /* Intersection sets, see below. */ + bitset_t remains; + /* Flags, see below. */ + bitset_word_t has_intersec, not_subset, not_consumed; + + /* Optimization, skip if this state doesn't accept the character. */ + if (type == CHARACTER && !bitset_contain (dests_ch[j], node->opr.c)) + continue; + + /* Enumerate the intersection set of this state and 'accepts'. */ + has_intersec = 0; + for (k = 0; k < BITSET_WORDS; ++k) + has_intersec |= intersec[k] = accepts[k] & dests_ch[j][k]; + /* And skip if the intersection set is empty. */ + if (!has_intersec) + continue; + + /* Then check if this state is a subset of 'accepts'. */ + not_subset = not_consumed = 0; + for (k = 0; k < BITSET_WORDS; ++k) + { + not_subset |= remains[k] = ~accepts[k] & dests_ch[j][k]; + not_consumed |= accepts[k] = accepts[k] & ~dests_ch[j][k]; + } + + /* If this state isn't a subset of 'accepts', create a + new group state, which has the 'remains'. */ + if (not_subset) + { + bitset_copy (dests_ch[ndests], remains); + bitset_copy (dests_ch[j], intersec); + err = re_node_set_init_copy (dests_node + ndests, &dests_node[j]); + if (__glibc_unlikely (err != REG_NOERROR)) + goto error_return; + ++ndests; + } + + /* Put the position in the current group. */ + ok = re_node_set_insert (&dests_node[j], cur_nodes->elems[i]); + if (__glibc_unlikely (! ok)) + goto error_return; + + /* If all characters are consumed, go to next node. */ + if (!not_consumed) + break; + } + /* Some characters remain, create a new group. */ + if (j == ndests) + { + bitset_copy (dests_ch[ndests], accepts); + err = re_node_set_init_1 (dests_node + ndests, cur_nodes->elems[i]); + if (__glibc_unlikely (err != REG_NOERROR)) + goto error_return; + ++ndests; + bitset_empty (accepts); + } + } + assume (ndests <= SBC_MAX); + return ndests; + error_return: + for (j = 0; j < ndests; ++j) + re_node_set_free (dests_node + j); + return -1; +} + +/* Check how many bytes the node 'dfa->nodes[node_idx]' accepts. + Return the number of the bytes the node accepts. + STR_IDX is the current index of the input string. + + This function handles the nodes which can accept one character, or + one collating element like '.', '[a-z]', opposite to the other nodes + can only accept one byte. */ + +#ifdef _LIBC +# include +#endif + +static int +check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx, + const re_string_t *input, Idx str_idx) +{ + const re_token_t *node = dfa->nodes + node_idx; + int char_len, elem_len; + Idx i; + + if (__glibc_unlikely (node->type == OP_UTF8_PERIOD)) + { + unsigned char c = re_string_byte_at (input, str_idx), d; + if (__glibc_likely (c < 0xc2)) + return 0; + + if (str_idx + 2 > input->len) + return 0; + + d = re_string_byte_at (input, str_idx + 1); + if (c < 0xe0) + return (d < 0x80 || d > 0xbf) ? 0 : 2; + else if (c < 0xf0) + { + char_len = 3; + if (c == 0xe0 && d < 0xa0) + return 0; + } + else if (c < 0xf8) + { + char_len = 4; + if (c == 0xf0 && d < 0x90) + return 0; + } + else if (c < 0xfc) + { + char_len = 5; + if (c == 0xf8 && d < 0x88) + return 0; + } + else if (c < 0xfe) + { + char_len = 6; + if (c == 0xfc && d < 0x84) + return 0; + } + else + return 0; + + if (str_idx + char_len > input->len) + return 0; + + for (i = 1; i < char_len; ++i) + { + d = re_string_byte_at (input, str_idx + i); + if (d < 0x80 || d > 0xbf) + return 0; + } + return char_len; + } + + char_len = re_string_char_size_at (input, str_idx); + if (node->type == OP_PERIOD) + { + if (char_len <= 1) + return 0; + /* FIXME: I don't think this if is needed, as both '\n' + and '\0' are char_len == 1. */ + /* '.' accepts any one character except the following two cases. */ + if ((!(dfa->syntax & RE_DOT_NEWLINE) + && re_string_byte_at (input, str_idx) == '\n') + || ((dfa->syntax & RE_DOT_NOT_NULL) + && re_string_byte_at (input, str_idx) == '\0')) + return 0; + return char_len; + } + + elem_len = re_string_elem_size_at (input, str_idx); + if ((elem_len <= 1 && char_len <= 1) || char_len == 0) + return 0; + + if (node->type == COMPLEX_BRACKET) + { + const re_charset_t *cset = node->opr.mbcset; +#ifdef _LIBC + const unsigned char *pin + = ((const unsigned char *) re_string_get_buffer (input) + str_idx); + Idx j; + uint32_t nrules; +#endif + int match_len = 0; + wchar_t wc = ((cset->nranges || cset->nchar_classes || cset->nmbchars) + ? re_string_wchar_at (input, str_idx) : 0); + + /* match with multibyte character? */ + for (i = 0; i < cset->nmbchars; ++i) + if (wc == cset->mbchars[i]) + { + match_len = char_len; + goto check_node_accept_bytes_match; + } + /* match with character_class? */ + for (i = 0; i < cset->nchar_classes; ++i) + { + wctype_t wt = cset->char_classes[i]; + if (__iswctype (wc, wt)) + { + match_len = char_len; + goto check_node_accept_bytes_match; + } + } + +#ifdef _LIBC + nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES); + if (nrules != 0) + { + unsigned int in_collseq = 0; + const int32_t *table, *indirect; + const unsigned char *weights, *extra; + const char *collseqwc; + + /* match with collating_symbol? */ + if (cset->ncoll_syms) + extra = (const unsigned char *) + _NL_CURRENT (LC_COLLATE, _NL_COLLATE_SYMB_EXTRAMB); + for (i = 0; i < cset->ncoll_syms; ++i) + { + const unsigned char *coll_sym = extra + cset->coll_syms[i]; + /* Compare the length of input collating element and + the length of current collating element. */ + if (*coll_sym != elem_len) + continue; + /* Compare each bytes. */ + for (j = 0; j < *coll_sym; j++) + if (pin[j] != coll_sym[1 + j]) + break; + if (j == *coll_sym) + { + /* Match if every bytes is equal. */ + match_len = j; + goto check_node_accept_bytes_match; + } + } + + if (cset->nranges) + { + if (elem_len <= char_len) + { + collseqwc = _NL_CURRENT (LC_COLLATE, _NL_COLLATE_COLLSEQWC); + in_collseq = __collseq_table_lookup (collseqwc, wc); + } + else + in_collseq = find_collation_sequence_value (pin, elem_len); + } + /* match with range expression? */ + /* FIXME: Implement rational ranges here, too. */ + for (i = 0; i < cset->nranges; ++i) + if (cset->range_starts[i] <= in_collseq + && in_collseq <= cset->range_ends[i]) + { + match_len = elem_len; + goto check_node_accept_bytes_match; + } + + /* match with equivalence_class? */ + if (cset->nequiv_classes) + { + const unsigned char *cp = pin; + table = (const int32_t *) + _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB); + weights = (const unsigned char *) + _NL_CURRENT (LC_COLLATE, _NL_COLLATE_WEIGHTMB); + extra = (const unsigned char *) + _NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAMB); + indirect = (const int32_t *) + _NL_CURRENT (LC_COLLATE, _NL_COLLATE_INDIRECTMB); + int32_t idx = findidx (table, indirect, extra, &cp, elem_len); + int32_t rule = idx >> 24; + idx &= 0xffffff; + if (idx > 0) + { + size_t weight_len = weights[idx]; + for (i = 0; i < cset->nequiv_classes; ++i) + { + int32_t equiv_class_idx = cset->equiv_classes[i]; + int32_t equiv_class_rule = equiv_class_idx >> 24; + equiv_class_idx &= 0xffffff; + if (weights[equiv_class_idx] == weight_len + && equiv_class_rule == rule + && memcmp (weights + idx + 1, + weights + equiv_class_idx + 1, + weight_len) == 0) + { + match_len = elem_len; + goto check_node_accept_bytes_match; + } + } + } + } + } + else +#endif /* _LIBC */ + { + /* match with range expression? */ + for (i = 0; i < cset->nranges; ++i) + { + if (cset->range_starts[i] <= wc && wc <= cset->range_ends[i]) + { + match_len = char_len; + goto check_node_accept_bytes_match; + } + } + } + check_node_accept_bytes_match: + if (!cset->non_match) + return match_len; + else + { + if (match_len > 0) + return 0; + else + return (elem_len > char_len) ? elem_len : char_len; + } + } + return 0; +} + +#ifdef _LIBC +static unsigned int +find_collation_sequence_value (const unsigned char *mbs, size_t mbs_len) +{ + uint32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES); + if (nrules == 0) + { + if (mbs_len == 1) + { + /* No valid character. Match it as a single byte character. */ + const unsigned char *collseq = (const unsigned char *) + _NL_CURRENT (LC_COLLATE, _NL_COLLATE_COLLSEQMB); + return collseq[mbs[0]]; + } + return UINT_MAX; + } + else + { + int32_t idx; + const unsigned char *extra = (const unsigned char *) + _NL_CURRENT (LC_COLLATE, _NL_COLLATE_SYMB_EXTRAMB); + int32_t extrasize = (const unsigned char *) + _NL_CURRENT (LC_COLLATE, _NL_COLLATE_SYMB_EXTRAMB + 1) - extra; + + for (idx = 0; idx < extrasize;) + { + int mbs_cnt; + bool found = false; + int32_t elem_mbs_len; + /* Skip the name of collating element name. */ + idx = idx + extra[idx] + 1; + elem_mbs_len = extra[idx++]; + if (mbs_len == elem_mbs_len) + { + for (mbs_cnt = 0; mbs_cnt < elem_mbs_len; ++mbs_cnt) + if (extra[idx + mbs_cnt] != mbs[mbs_cnt]) + break; + if (mbs_cnt == elem_mbs_len) + /* Found the entry. */ + found = true; + } + /* Skip the byte sequence of the collating element. */ + idx += elem_mbs_len; + /* Adjust for the alignment. */ + idx = (idx + 3) & ~3; + /* Skip the collation sequence value. */ + idx += sizeof (uint32_t); + /* Skip the wide char sequence of the collating element. */ + idx = idx + sizeof (uint32_t) * (*(int32_t *) (extra + idx) + 1); + /* If we found the entry, return the sequence value. */ + if (found) + return *(uint32_t *) (extra + idx); + /* Skip the collation sequence value. */ + idx += sizeof (uint32_t); + } + return UINT_MAX; + } +} +#endif /* _LIBC */ + +/* Check whether the node accepts the byte which is IDX-th + byte of the INPUT. */ + +static bool +check_node_accept (const re_match_context_t *mctx, const re_token_t *node, + Idx idx) +{ + unsigned char ch; + ch = re_string_byte_at (&mctx->input, idx); + switch (node->type) + { + case CHARACTER: + if (node->opr.c != ch) + return false; + break; + + case SIMPLE_BRACKET: + if (!bitset_contain (node->opr.sbcset, ch)) + return false; + break; + + case OP_UTF8_PERIOD: + if (ch >= ASCII_CHARS) + return false; + FALLTHROUGH; + case OP_PERIOD: + if ((ch == '\n' && !(mctx->dfa->syntax & RE_DOT_NEWLINE)) + || (ch == '\0' && (mctx->dfa->syntax & RE_DOT_NOT_NULL))) + return false; + break; + + default: + return false; + } + + if (node->constraint) + { + /* The node has constraints. Check whether the current context + satisfies the constraints. */ + unsigned int context = re_string_context_at (&mctx->input, idx, + mctx->eflags); + if (NOT_SATISFY_NEXT_CONSTRAINT (node->constraint, context)) + return false; + } + + return true; +} + +/* Extend the buffers, if the buffers have run out. */ + +static reg_errcode_t +__attribute_warn_unused_result__ +extend_buffers (re_match_context_t *mctx, int min_len) +{ + reg_errcode_t ret; + re_string_t *pstr = &mctx->input; + + /* Avoid overflow. */ + if (__glibc_unlikely (MIN (IDX_MAX, SIZE_MAX / sizeof (re_dfastate_t *)) / 2 + <= pstr->bufs_len)) + return REG_ESPACE; + + /* Double the lengths of the buffers, but allocate at least MIN_LEN. */ + ret = re_string_realloc_buffers (pstr, + MAX (min_len, + MIN (pstr->len, pstr->bufs_len * 2))); + if (__glibc_unlikely (ret != REG_NOERROR)) + return ret; + + if (mctx->state_log != NULL) + { + /* And double the length of state_log. */ + /* XXX We have no indication of the size of this buffer. If this + allocation fail we have no indication that the state_log array + does not have the right size. */ + re_dfastate_t **new_array = re_realloc (mctx->state_log, re_dfastate_t *, + pstr->bufs_len + 1); + if (__glibc_unlikely (new_array == NULL)) + return REG_ESPACE; + mctx->state_log = new_array; + } + + /* Then reconstruct the buffers. */ + if (pstr->icase) + { + if (pstr->mb_cur_max > 1) + { + ret = build_wcs_upper_buffer (pstr); + if (__glibc_unlikely (ret != REG_NOERROR)) + return ret; + } + else + build_upper_buffer (pstr); + } + else + { + if (pstr->mb_cur_max > 1) + build_wcs_buffer (pstr); + else + { + if (pstr->trans != NULL) + re_string_translate_buffer (pstr); + } + } + return REG_NOERROR; +} + + +/* Functions for matching context. */ + +/* Initialize MCTX. */ + +static reg_errcode_t +__attribute_warn_unused_result__ +match_ctx_init (re_match_context_t *mctx, int eflags, Idx n) +{ + mctx->eflags = eflags; + mctx->match_last = -1; + if (n > 0) + { + /* Avoid overflow. */ + size_t max_object_size = + MAX (sizeof (struct re_backref_cache_entry), + sizeof (re_sub_match_top_t *)); + if (__glibc_unlikely (MIN (IDX_MAX, SIZE_MAX / max_object_size) < n)) + return REG_ESPACE; + + mctx->bkref_ents = re_malloc (struct re_backref_cache_entry, n); + mctx->sub_tops = re_malloc (re_sub_match_top_t *, n); + if (__glibc_unlikely (mctx->bkref_ents == NULL || mctx->sub_tops == NULL)) + return REG_ESPACE; + } + /* Already zero-ed by the caller. + else + mctx->bkref_ents = NULL; + mctx->nbkref_ents = 0; + mctx->nsub_tops = 0; */ + mctx->abkref_ents = n; + mctx->max_mb_elem_len = 1; + mctx->asub_tops = n; + return REG_NOERROR; +} + +/* Clean the entries which depend on the current input in MCTX. + This function must be invoked when the matcher changes the start index + of the input, or changes the input string. */ + +static void +match_ctx_clean (re_match_context_t *mctx) +{ + Idx st_idx; + for (st_idx = 0; st_idx < mctx->nsub_tops; ++st_idx) + { + Idx sl_idx; + re_sub_match_top_t *top = mctx->sub_tops[st_idx]; + for (sl_idx = 0; sl_idx < top->nlasts; ++sl_idx) + { + re_sub_match_last_t *last = top->lasts[sl_idx]; + re_free (last->path.array); + re_free (last); + } + re_free (top->lasts); + if (top->path) + { + re_free (top->path->array); + re_free (top->path); + } + re_free (top); + } + + mctx->nsub_tops = 0; + mctx->nbkref_ents = 0; +} + +/* Free all the memory associated with MCTX. */ + +static void +match_ctx_free (re_match_context_t *mctx) +{ + /* First, free all the memory associated with MCTX->SUB_TOPS. */ + match_ctx_clean (mctx); + re_free (mctx->sub_tops); + re_free (mctx->bkref_ents); +} + +/* Add a new backreference entry to MCTX. + Note that we assume that caller never call this function with duplicate + entry, and call with STR_IDX which isn't smaller than any existing entry. +*/ + +static reg_errcode_t +__attribute_warn_unused_result__ +match_ctx_add_entry (re_match_context_t *mctx, Idx node, Idx str_idx, Idx from, + Idx to) +{ + if (mctx->nbkref_ents >= mctx->abkref_ents) + { + struct re_backref_cache_entry* new_entry; + new_entry = re_realloc (mctx->bkref_ents, struct re_backref_cache_entry, + mctx->abkref_ents * 2); + if (__glibc_unlikely (new_entry == NULL)) + { + re_free (mctx->bkref_ents); + return REG_ESPACE; + } + mctx->bkref_ents = new_entry; + memset (mctx->bkref_ents + mctx->nbkref_ents, '\0', + sizeof (struct re_backref_cache_entry) * mctx->abkref_ents); + mctx->abkref_ents *= 2; + } + if (mctx->nbkref_ents > 0 + && mctx->bkref_ents[mctx->nbkref_ents - 1].str_idx == str_idx) + mctx->bkref_ents[mctx->nbkref_ents - 1].more = 1; + + mctx->bkref_ents[mctx->nbkref_ents].node = node; + mctx->bkref_ents[mctx->nbkref_ents].str_idx = str_idx; + mctx->bkref_ents[mctx->nbkref_ents].subexp_from = from; + mctx->bkref_ents[mctx->nbkref_ents].subexp_to = to; + + /* This is a cache that saves negative results of check_dst_limits_calc_pos. + If bit N is clear, means that this entry won't epsilon-transition to + an OP_OPEN_SUBEXP or OP_CLOSE_SUBEXP for the N+1-th subexpression. If + it is set, check_dst_limits_calc_pos_1 will recurse and try to find one + such node. + + A backreference does not epsilon-transition unless it is empty, so set + to all zeros if FROM != TO. */ + mctx->bkref_ents[mctx->nbkref_ents].eps_reachable_subexps_map + = (from == to ? -1 : 0); + + mctx->bkref_ents[mctx->nbkref_ents++].more = 0; + if (mctx->max_mb_elem_len < to - from) + mctx->max_mb_elem_len = to - from; + return REG_NOERROR; +} + +/* Return the first entry with the same str_idx, or -1 if none is + found. Note that MCTX->BKREF_ENTS is already sorted by MCTX->STR_IDX. */ + +static Idx +search_cur_bkref_entry (const re_match_context_t *mctx, Idx str_idx) +{ + Idx left, right, mid, last; + last = right = mctx->nbkref_ents; + for (left = 0; left < right;) + { + mid = (left + right) / 2; + if (mctx->bkref_ents[mid].str_idx < str_idx) + left = mid + 1; + else + right = mid; + } + if (left < last && mctx->bkref_ents[left].str_idx == str_idx) + return left; + else + return -1; +} + +/* Register the node NODE, whose type is OP_OPEN_SUBEXP, and which matches + at STR_IDX. */ + +static reg_errcode_t +__attribute_warn_unused_result__ +match_ctx_add_subtop (re_match_context_t *mctx, Idx node, Idx str_idx) +{ + DEBUG_ASSERT (mctx->sub_tops != NULL); + DEBUG_ASSERT (mctx->asub_tops > 0); + if (__glibc_unlikely (mctx->nsub_tops == mctx->asub_tops)) + { + Idx new_asub_tops = mctx->asub_tops * 2; + re_sub_match_top_t **new_array = re_realloc (mctx->sub_tops, + re_sub_match_top_t *, + new_asub_tops); + if (__glibc_unlikely (new_array == NULL)) + return REG_ESPACE; + mctx->sub_tops = new_array; + mctx->asub_tops = new_asub_tops; + } + mctx->sub_tops[mctx->nsub_tops] = calloc (1, sizeof (re_sub_match_top_t)); + if (__glibc_unlikely (mctx->sub_tops[mctx->nsub_tops] == NULL)) + return REG_ESPACE; + mctx->sub_tops[mctx->nsub_tops]->node = node; + mctx->sub_tops[mctx->nsub_tops++]->str_idx = str_idx; + return REG_NOERROR; +} + +/* Register the node NODE, whose type is OP_CLOSE_SUBEXP, and which matches + at STR_IDX, whose corresponding OP_OPEN_SUBEXP is SUB_TOP. + Return the new entry if successful, NULL if memory is exhausted. */ + +static re_sub_match_last_t * +match_ctx_add_sublast (re_sub_match_top_t *subtop, Idx node, Idx str_idx) +{ + re_sub_match_last_t *new_entry; + if (__glibc_unlikely (subtop->nlasts == subtop->alasts)) + { + Idx new_alasts = 2 * subtop->alasts + 1; + re_sub_match_last_t **new_array = re_realloc (subtop->lasts, + re_sub_match_last_t *, + new_alasts); + if (__glibc_unlikely (new_array == NULL)) + return NULL; + subtop->lasts = new_array; + subtop->alasts = new_alasts; + } + new_entry = calloc (1, sizeof (re_sub_match_last_t)); + if (__glibc_likely (new_entry != NULL)) + { + subtop->lasts[subtop->nlasts] = new_entry; + new_entry->node = node; + new_entry->str_idx = str_idx; + ++subtop->nlasts; + } + return new_entry; +} + +static void +sift_ctx_init (re_sift_context_t *sctx, re_dfastate_t **sifted_sts, + re_dfastate_t **limited_sts, Idx last_node, Idx last_str_idx) +{ + sctx->sifted_states = sifted_sts; + sctx->limited_states = limited_sts; + sctx->last_node = last_node; + sctx->last_str_idx = last_str_idx; + re_node_set_init_empty (&sctx->limits); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/same-inode.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/same-inode.c new file mode 100644 index 00000000..08c66a25 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/same-inode.c @@ -0,0 +1,3 @@ +#include +#define SAME_INODE_INLINE _GL_EXTERN_INLINE +#include "same-inode.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/same-inode.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/same-inode.h new file mode 100644 index 00000000..62dd088e --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/same-inode.h @@ -0,0 +1,85 @@ +/* Determine whether two stat buffers are known to refer to the same file. + + Copyright (C) 2006, 2009-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef SAME_INODE_H +#define SAME_INODE_H 1 + +/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +#include + +_GL_INLINE_HEADER_BEGIN +#ifndef SAME_INODE_INLINE +# define SAME_INODE_INLINE _GL_INLINE +#endif + +/* True if A and B point to structs with st_dev and st_ino members + that are known to represent the same file. + + Use | and ^ to shorten generated code, and to lessen the + probability of screwups if st_ino is an array. */ + +#if defined __VMS && __CRTL_VER < 80200000 +# define PSAME_INODE(a, b) (! (((a)->st_dev ^ (b)->st_dev) \ + | ((a)->st_ino[0] ^ (b)->st_ino[0]) \ + | ((a)->st_ino[1] ^ (b)->st_ino[1]) \ + | ((a)->st_ino[2] ^ (b)->st_ino[2]))) +#elif defined _WIN32 && ! defined __CYGWIN__ + /* Native Windows. */ +# if _GL_WINDOWS_STAT_INODES + /* stat() and fstat() set st_dev and st_ino to 0 if information about + the inode is not available. */ +# if _GL_WINDOWS_STAT_INODES == 2 +# define PSAME_INODE(a, b) \ + (! (! ((a)->st_dev | (a)->st_ino._gl_ino[0] | (a)->st_ino._gl_ino[1]) \ + | ((a)->st_dev ^ (b)->st_dev) \ + | ((a)->st_ino._gl_ino[0] ^ (b)->st_ino._gl_ino[0]) \ + | ((a)->st_ino._gl_ino[1] ^ (b)->st_ino._gl_ino[1]))) +# else +# define PSAME_INODE(a, b) (! (! ((a)->st_dev | (a)->st_ino) \ + | ((a)->st_dev ^ (b)->st_dev) \ + | ((a)->st_ino ^ (b)->st_ino))) +# endif +# else + /* stat() and fstat() set st_ino to 0 always. */ +# define PSAME_INODE(a, b) 0 +# endif +#else + /* POSIX. */ +# define PSAME_INODE(a, b) (! (((a)->st_dev ^ (b)->st_dev) \ + | ((a)->st_ino ^ (b)->st_ino))) +#endif + +/* True if struct objects A and B are known to represent the same file. */ + +#define SAME_INODE(a, b) PSAME_INODE (&(a), &(b)) + +/* True if *A and *B represent the same file. Unlike PSAME_INODE, + args are evaluated once and must point to struct stat. */ + +SAME_INODE_INLINE bool +psame_inode (struct stat const *a, struct stat const *b) +{ + return PSAME_INODE (a, b); +} + +_GL_INLINE_HEADER_END + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/save-cwd.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/save-cwd.c new file mode 100644 index 00000000..47f888c0 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/save-cwd.c @@ -0,0 +1,96 @@ +/* save-cwd.c -- Save and restore current working directory. + + Copyright (C) 1995, 1997-1998, 2003-2006, 2009-2024 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 . */ + +/* Written by Jim Meyering. */ + +#include + +#include "save-cwd.h" + +#include +#include +#include +#include + +#include "chdir-long.h" +#include "unistd--.h" + +#if GNULIB_FCNTL_SAFER +# include "fcntl--.h" +#else +# define GNULIB_FCNTL_SAFER 0 +#endif + +/* Record the location of the current working directory in CWD so that + the program may change to other directories and later use restore_cwd + to return to the recorded location. This function may allocate + space using malloc (via getcwd) or leave a file descriptor open; + use free_cwd to perform the necessary free or close. Upon failure, + no memory is allocated, any locally opened file descriptors are + closed; return non-zero -- in that case, free_cwd need not be + called, but doing so is ok. Otherwise, return zero. + + The _raison d'etre_ for this interface is that the working directory + is sometimes inaccessible, and getcwd is not robust or as efficient. + So, we prefer to use the open/fchdir approach, but fall back on + getcwd if necessary. This module works for most cases with just + the getcwd-lgpl module, but to be truly robust, use the getcwd module. + + Some systems lack fchdir altogether: e.g., OS/2, pre-2001 Cygwin, + SCO Xenix. Also, SunOS 4 and Irix 5.3 provide the function, yet it + doesn't work for partitions on which auditing is enabled. If + you're still using an obsolete system with these problems, please + send email to the maintainer of this code. */ + +int +save_cwd (struct saved_cwd *cwd) +{ + cwd->name = NULL; + + cwd->desc = open (".", O_SEARCH | O_CLOEXEC); + if (!GNULIB_FCNTL_SAFER) + cwd->desc = fd_safer_flag (cwd->desc, O_CLOEXEC); + if (cwd->desc < 0) + { + cwd->name = getcwd (NULL, 0); + return cwd->name ? 0 : -1; + } + + return 0; +} + +/* Change to recorded location, CWD, in directory hierarchy. + Upon failure, return -1 (errno is set by chdir or fchdir). + Upon success, return zero. */ + +int +restore_cwd (const struct saved_cwd *cwd) +{ + if (0 <= cwd->desc) + return fchdir (cwd->desc); + else + return chdir_long (cwd->name); +} + +void +free_cwd (struct saved_cwd *cwd) +{ + if (cwd->desc >= 0) + close (cwd->desc); + free (cwd->name); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/save-cwd.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/save-cwd.h new file mode 100644 index 00000000..692e4b97 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/save-cwd.h @@ -0,0 +1,34 @@ +/* Save and restore current working directory. + + Copyright (C) 1995, 1997-1998, 2003, 2009-2024 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 . */ + +/* Written by Jim Meyering. */ + +#ifndef SAVE_CWD_H +# define SAVE_CWD_H 1 + +struct saved_cwd + { + int desc; + char *name; + }; + +int save_cwd (struct saved_cwd *cwd); +int restore_cwd (const struct saved_cwd *cwd); +void free_cwd (struct saved_cwd *cwd); + +#endif /* SAVE_CWD_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/setenv.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/setenv.c new file mode 100644 index 00000000..9e2e9e2f --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/setenv.c @@ -0,0 +1,396 @@ +/* Copyright (C) 1992, 1995-2003, 2005-2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#if !_LIBC +/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc + optimizes away the name == NULL test below. */ +# define _GL_ARG_NONNULL(params) + +# define _GL_USE_STDLIB_ALLOC 1 +# include +#endif + +#include + +/* Specification. */ +#include + +#include +#ifndef __set_errno +# define __set_errno(ev) ((errno) = (ev)) +#endif + +#include +#if _LIBC || HAVE_UNISTD_H +# include +#endif + +#if !_LIBC +# include "malloca.h" +#endif + +#if _LIBC || !HAVE_SETENV + +#if !_LIBC +# define __environ environ +#endif + +#if _LIBC +/* This lock protects against simultaneous modifications of 'environ'. */ +# include +__libc_lock_define_initialized (static, envlock) +# define LOCK __libc_lock_lock (envlock) +# define UNLOCK __libc_lock_unlock (envlock) +#else +# define LOCK +# define UNLOCK +#endif + +/* In the GNU C library we must keep the namespace clean. */ +#ifdef _LIBC +# define setenv __setenv +# define clearenv __clearenv +# define tfind __tfind +# define tsearch __tsearch +#endif + +/* In the GNU C library implementation we try to be more clever and + allow arbitrarily many changes of the environment given that the used + values are from a small set. Outside glibc this will eat up all + memory after a while. */ +#if defined _LIBC || (defined HAVE_SEARCH_H && defined HAVE_TSEARCH \ + && (defined __GNUC__ || defined __clang__)) +# define USE_TSEARCH 1 +# include +typedef int (*compar_fn_t) (const void *, const void *); + +/* This is a pointer to the root of the search tree with the known + values. */ +static void *known_values; + +# define KNOWN_VALUE(Str) \ + __extension__ \ + ({ \ + void *value = tfind (Str, &known_values, (compar_fn_t) strcmp); \ + value != NULL ? *(char **) value : NULL; \ + }) +# define STORE_VALUE(Str) \ + tsearch (Str, &known_values, (compar_fn_t) strcmp) + +#else +# undef USE_TSEARCH + +# define KNOWN_VALUE(Str) NULL +# define STORE_VALUE(Str) do { } while (0) + +#endif + + +/* If this variable is not a null pointer we allocated the current + environment. */ +static char **last_environ; + + +/* This function is used by 'setenv' and 'putenv'. The difference between + the two functions is that for the former must create a new string which + is then placed in the environment, while the argument of 'putenv' + must be used directly. This is all complicated by the fact that we try + to reuse values once generated for a 'setenv' call since we can never + free the strings. */ +int +__add_to_environ (const char *name, const char *value, const char *combined, + int replace) +{ + char **ep; + size_t size; + const size_t namelen = strlen (name); + const size_t vallen = value != NULL ? strlen (value) + 1 : 0; + + LOCK; + + /* We have to get the pointer now that we have the lock and not earlier + since another thread might have created a new environment. */ + ep = __environ; + + size = 0; + if (ep != NULL) + { + for (; *ep != NULL; ++ep) + if (!strncmp (*ep, name, namelen) && (*ep)[namelen] == '=') + break; + else + ++size; + } + + if (ep == NULL || *ep == NULL) + { + char **new_environ; +#ifdef USE_TSEARCH + char *new_value; +#endif + + /* We allocated this space; we can extend it. */ + new_environ = + (char **) (last_environ == NULL + ? malloc ((size + 2) * sizeof (char *)) + : realloc (last_environ, (size + 2) * sizeof (char *))); + if (new_environ == NULL) + { + /* It's easier to set errno to ENOMEM than to rely on the + 'malloc-posix' and 'realloc-posix' gnulib modules. */ + __set_errno (ENOMEM); + UNLOCK; + return -1; + } + + /* If the whole entry is given add it. */ + if (combined != NULL) + /* We must not add the string to the search tree since it belongs + to the user. */ + new_environ[size] = (char *) combined; + else + { + /* See whether the value is already known. */ +#ifdef USE_TSEARCH +# ifdef _LIBC + new_value = (char *) alloca (namelen + 1 + vallen); + __mempcpy (__mempcpy (__mempcpy (new_value, name, namelen), "=", 1), + value, vallen); +# else + new_value = (char *) malloca (namelen + 1 + vallen); + if (new_value == NULL) + { + __set_errno (ENOMEM); + UNLOCK; + return -1; + } + memcpy (new_value, name, namelen); + new_value[namelen] = '='; + memcpy (&new_value[namelen + 1], value, vallen); +# endif + + new_environ[size] = KNOWN_VALUE (new_value); + if (new_environ[size] == NULL) +#endif + { + new_environ[size] = (char *) malloc (namelen + 1 + vallen); + if (new_environ[size] == NULL) + { +#if defined USE_TSEARCH && !defined _LIBC + freea (new_value); +#endif + __set_errno (ENOMEM); + UNLOCK; + return -1; + } + +#ifdef USE_TSEARCH + memcpy (new_environ[size], new_value, namelen + 1 + vallen); +#else + memcpy (new_environ[size], name, namelen); + new_environ[size][namelen] = '='; + memcpy (&new_environ[size][namelen + 1], value, vallen); +#endif + /* And save the value now. We cannot do this when we remove + the string since then we cannot decide whether it is a + user string or not. */ + STORE_VALUE (new_environ[size]); + } +#if defined USE_TSEARCH && !defined _LIBC + freea (new_value); +#endif + } + + if (__environ != last_environ) + memcpy ((char *) new_environ, (char *) __environ, + size * sizeof (char *)); + + new_environ[size + 1] = NULL; + + last_environ = __environ = new_environ; + } + else if (replace) + { + char *np; + + /* Use the user string if given. */ + if (combined != NULL) + np = (char *) combined; + else + { +#ifdef USE_TSEARCH + char *new_value; +# ifdef _LIBC + new_value = alloca (namelen + 1 + vallen); + __mempcpy (__mempcpy (__mempcpy (new_value, name, namelen), "=", 1), + value, vallen); +# else + new_value = malloca (namelen + 1 + vallen); + if (new_value == NULL) + { + __set_errno (ENOMEM); + UNLOCK; + return -1; + } + memcpy (new_value, name, namelen); + new_value[namelen] = '='; + memcpy (&new_value[namelen + 1], value, vallen); +# endif + + np = KNOWN_VALUE (new_value); + if (np == NULL) +#endif + { + np = (char *) malloc (namelen + 1 + vallen); + if (np == NULL) + { +#if defined USE_TSEARCH && !defined _LIBC + freea (new_value); +#endif + __set_errno (ENOMEM); + UNLOCK; + return -1; + } + +#ifdef USE_TSEARCH + memcpy (np, new_value, namelen + 1 + vallen); +#else + memcpy (np, name, namelen); + np[namelen] = '='; + memcpy (&np[namelen + 1], value, vallen); +#endif + /* And remember the value. */ + STORE_VALUE (np); + } +#if defined USE_TSEARCH && !defined _LIBC + freea (new_value); +#endif + } + + *ep = np; + } + + UNLOCK; + + return 0; +} + +int +setenv (const char *name, const char *value, int replace) +{ + if (name == NULL || *name == '\0' || strchr (name, '=') != NULL) + { + __set_errno (EINVAL); + return -1; + } + + return __add_to_environ (name, value, NULL, replace); +} + +/* The 'clearenv' was planned to be added to POSIX.1 but probably + never made it. Nevertheless the POSIX.9 standard (POSIX bindings + for Fortran 77) requires this function. */ +int +clearenv (void) +{ + LOCK; + + if (__environ == last_environ && __environ != NULL) + { + /* We allocated this environment so we can free it. */ + free (__environ); + last_environ = NULL; + } + + /* Clear the environment pointer removes the whole environment. */ + __environ = NULL; + + UNLOCK; + + return 0; +} + +#ifdef _LIBC +static void +free_mem (void) +{ + /* Remove all traces. */ + clearenv (); + + /* Now remove the search tree. */ + __tdestroy (known_values, free); + known_values = NULL; +} +text_set_element (__libc_subfreeres, free_mem); + + +# undef setenv +# undef clearenv +weak_alias (__setenv, setenv) +weak_alias (__clearenv, clearenv) +#endif + +#endif /* _LIBC || !HAVE_SETENV */ + +/* The rest of this file is called into use when replacing an existing + but buggy setenv. Known bugs include failure to diagnose invalid + name, and consuming a leading '=' from value. */ +#if HAVE_SETENV + +# undef setenv +# if !HAVE_DECL_SETENV +extern int setenv (const char *, const char *, int); +# endif +# define STREQ(a, b) (strcmp (a, b) == 0) + +int +rpl_setenv (const char *name, const char *value, int replace) +{ + int result; + if (!name || !*name || strchr (name, '=')) + { + errno = EINVAL; + return -1; + } + /* Call the real setenv even if replace is 0, in case implementation + has underlying data to update, such as when environ changes. */ + result = setenv (name, value, replace); + if (result == 0 && replace && *value == '=') + { + char *tmp = getenv (name); + if (!STREQ (tmp, value)) + { + int saved_errno; + size_t len = strlen (value); + tmp = malloca (len + 2); + if (tmp == NULL) + { + errno = ENOMEM; + return -1; + } + /* Since leading '=' is eaten, double it up. */ + *tmp = '='; + memcpy (tmp + 1, value, len + 1); + result = setenv (name, tmp, replace); + saved_errno = errno; + freea (tmp); + errno = saved_errno; + } + } + return result; +} + +#endif /* HAVE_SETENV */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/setlocale-lock.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/setlocale-lock.c new file mode 100644 index 00000000..192489c4 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/setlocale-lock.c @@ -0,0 +1,151 @@ +/* Return the internal lock used by setlocale_null_r. + Copyright (C) 2019-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 2019. */ + +#include + +/* The option '--disable-threads' explicitly requests no locking. */ +/* When it is known that the gl_get_setlocale_null_lock function is defined + by a dependency library, it should not be defined here. */ +#if AVOID_ANY_THREADS || OMIT_SETLOCALE_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 setlocale_null_r. + 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_setlocale_null_lock + +/* Macro for exporting a symbol (function, not variable) defined in this file, + when compiled into a shared library. */ +# ifndef SHLIB_EXPORTED +# if HAVE_VISIBILITY + /* Override the effect of the compiler option '-fvisibility=hidden'. */ +# define SHLIB_EXPORTED __attribute__((__visibility__("default"))) +# elif defined _WIN32 || defined __CYGWIN__ +# define SHLIB_EXPORTED __declspec(dllexport) +# else +# define SHLIB_EXPORTED +# endif +# endif + +# if defined _WIN32 && !defined __CYGWIN__ + +# define WIN32_LEAN_AND_MEAN /* avoid including junk */ +# include + +# 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. */ +SHLIB_EXPORTED CRITICAL_SECTION *gl_get_setlocale_null_lock (void); + +static glwthread_initguard_t guard = GLWTHREAD_INITGUARD_INIT; +static CRITICAL_SECTION lock; + +/* Returns the internal lock used by setlocale_null_r. */ +CRITICAL_SECTION * +gl_get_setlocale_null_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 + +static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; + +/* Make sure the function gets exported from shared libraries. */ +SHLIB_EXPORTED pthread_mutex_t *gl_get_setlocale_null_lock (void); + +/* Returns the internal lock used by setlocale_null_r. */ +pthread_mutex_t * +gl_get_setlocale_null_lock (void) +{ + return &mutex; +} + +# elif HAVE_THREADS_H + +# include +# include + +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. */ +SHLIB_EXPORTED mtx_t *gl_get_setlocale_null_lock (void); + +/* Returns the internal lock used by setlocale_null_r. */ +mtx_t * +gl_get_setlocale_null_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 setlocale_null.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_setlocale_null_lock) = &gl_get_setlocale_null_lock; +# endif + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/setlocale_null.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/setlocale_null.c new file mode 100644 index 00000000..697502fb --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/setlocale_null.c @@ -0,0 +1,422 @@ +/* Query the name of the current global locale. + Copyright (C) 2019-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 2019. */ + +#include + +/* Specification. */ +#include "setlocale_null.h" + +#include +#include +#include +#include +#if defined _WIN32 && !defined __CYGWIN__ +# include +#endif + +#if !(SETLOCALE_NULL_ALL_MTSAFE && SETLOCALE_NULL_ONE_MTSAFE) + +# if AVOID_ANY_THREADS + +/* The option '--disable-threads' explicitly requests no locking. */ + +# elif defined _WIN32 && !defined __CYGWIN__ + +# define WIN32_LEAN_AND_MEAN /* avoid including junk */ +# include + +# elif HAVE_PTHREAD_API + +# include +# if HAVE_THREADS_H && HAVE_WEAK_SYMBOLS +# include +# 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 + +# endif + +#endif + +/* Use the system's setlocale() function, not the gnulib override, here. */ +#undef setlocale + +static const char * +setlocale_null_androidfix (int category) +{ + const char *result = setlocale (category, NULL); + +#ifdef __ANDROID__ + if (result == NULL) + switch (category) + { + case LC_CTYPE: + case LC_NUMERIC: + case LC_TIME: + case LC_COLLATE: + case LC_MONETARY: + case LC_MESSAGES: + case LC_ALL: + case LC_PAPER: + case LC_NAME: + case LC_ADDRESS: + case LC_TELEPHONE: + case LC_MEASUREMENT: + result = "C"; + break; + default: + break; + } +#endif + + return result; +} + +static int +setlocale_null_unlocked (int category, char *buf, size_t bufsize) +{ +#if defined _WIN32 && !defined __CYGWIN__ && defined _MSC_VER + /* On native Windows, nowadays, the setlocale() implementation is based + on _wsetlocale() and uses malloc() for the result. We are better off + using _wsetlocale() directly. */ + const wchar_t *result = _wsetlocale (category, NULL); + + if (result == NULL) + { + /* CATEGORY is invalid. */ + if (bufsize > 0) + /* Return an empty string in BUF. + This is a convenience for callers that don't want to write explicit + code for handling EINVAL. */ + buf[0] = '\0'; + return EINVAL; + } + else + { + size_t length = wcslen (result); + if (length < bufsize) + { + size_t i; + + /* Convert wchar_t[] -> char[], assuming plain ASCII. */ + for (i = 0; i <= length; i++) + buf[i] = result[i]; + + return 0; + } + else + { + if (bufsize > 0) + { + /* Return a truncated result in BUF. + This is a convenience for callers that don't want to write + explicit code for handling ERANGE. */ + size_t i; + + /* Convert wchar_t[] -> char[], assuming plain ASCII. */ + for (i = 0; i < bufsize; i++) + buf[i] = result[i]; + buf[bufsize - 1] = '\0'; + } + return ERANGE; + } + } +#else + const char *result = setlocale_null_androidfix (category); + + if (result == NULL) + { + /* CATEGORY is invalid. */ + if (bufsize > 0) + /* Return an empty string in BUF. + This is a convenience for callers that don't want to write explicit + code for handling EINVAL. */ + buf[0] = '\0'; + return EINVAL; + } + else + { + size_t length = strlen (result); + if (length < bufsize) + { + memcpy (buf, result, length + 1); + return 0; + } + else + { + if (bufsize > 0) + { + /* Return a truncated result in BUF. + This is a convenience for callers that don't want to write + explicit code for handling ERANGE. */ + memcpy (buf, result, bufsize - 1); + buf[bufsize - 1] = '\0'; + } + return ERANGE; + } + } +#endif +} + +#if !(SETLOCALE_NULL_ALL_MTSAFE && SETLOCALE_NULL_ONE_MTSAFE) /* musl libc, macOS, FreeBSD, NetBSD, OpenBSD, AIX, Haiku, Cygwin < 3.4.6 */ + +/* Use a lock, so that no two threads can invoke setlocale_null_unlocked + at the same time. */ + +/* Prohibit renaming this symbol. */ +# undef gl_get_setlocale_null_lock + +# if AVOID_ANY_THREADS + +/* The option '--disable-threads' explicitly requests no locking. */ +# define setlocale_null_with_lock setlocale_null_unlocked + +# elif defined _WIN32 && !defined __CYGWIN__ + +extern __declspec(dllimport) CRITICAL_SECTION *gl_get_setlocale_null_lock (void); + +static int +setlocale_null_with_lock (int category, char *buf, size_t bufsize) +{ + CRITICAL_SECTION *lock = gl_get_setlocale_null_lock (); + int ret; + + EnterCriticalSection (lock); + ret = setlocale_null_unlocked (category, buf, bufsize); + LeaveCriticalSection (lock); + + return ret; +} + +# elif HAVE_PTHREAD_API /* musl libc, macOS, FreeBSD, NetBSD, OpenBSD, AIX, Haiku, Cygwin < 3.4.6 */ + +extern +# if defined _WIN32 || defined __CYGWIN__ + __declspec(dllimport) +# endif + pthread_mutex_t *gl_get_setlocale_null_lock (void); + +# if HAVE_WEAK_SYMBOLS /* musl libc, FreeBSD, NetBSD, OpenBSD, Haiku */ + + /* 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 +setlocale_null_with_lock (int category, char *buf, size_t bufsize) +{ + if (pthread_in_use()) + { + pthread_mutex_t *lock = gl_get_setlocale_null_lock (); + int ret; + + if (pthread_mutex_lock (lock)) + abort (); + ret = setlocale_null_unlocked (category, buf, bufsize); + if (pthread_mutex_unlock (lock)) + abort (); + + return ret; + } + else + return setlocale_null_unlocked (category, buf, bufsize); +} + +# elif HAVE_THREADS_H + +extern mtx_t *gl_get_setlocale_null_lock (void); + +static int +setlocale_null_with_lock (int category, char *buf, size_t bufsize) +{ + mtx_t *lock = gl_get_setlocale_null_lock (); + int ret; + + if (mtx_lock (lock) != thrd_success) + abort (); + ret = setlocale_null_unlocked (category, buf, bufsize); + if (mtx_unlock (lock) != thrd_success) + abort (); + + return ret; +} + +# endif + +#endif + +int +setlocale_null_r (int category, char *buf, size_t bufsize) +{ +#if SETLOCALE_NULL_ALL_MTSAFE +# if SETLOCALE_NULL_ONE_MTSAFE + + return setlocale_null_unlocked (category, buf, bufsize); + +# else + + if (category == LC_ALL) + return setlocale_null_unlocked (category, buf, bufsize); + else + return setlocale_null_with_lock (category, buf, bufsize); + +# endif +#else +# if SETLOCALE_NULL_ONE_MTSAFE + + if (category == LC_ALL) + return setlocale_null_with_lock (category, buf, bufsize); + else + return setlocale_null_unlocked (category, buf, bufsize); + +# else + + return setlocale_null_with_lock (category, buf, bufsize); + +# endif +#endif +} + +const char * +setlocale_null (int category) +{ +#if SETLOCALE_NULL_ALL_MTSAFE && SETLOCALE_NULL_ONE_MTSAFE + return setlocale_null_androidfix (category); +#else + + /* This call must be multithread-safe. To achieve this without using + thread-local storage: + 1. We use a specific static buffer for each possible CATEGORY + argument. So that different threads can call setlocale_mtsafe + with different CATEGORY arguments, without interfering. + 2. 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 (category == LC_ALL) + { +# if SETLOCALE_NULL_ALL_MTSAFE + return setlocale_null_androidfix (LC_ALL); +# else + char buf[SETLOCALE_NULL_ALL_MAX]; + static char resultbuf[SETLOCALE_NULL_ALL_MAX]; + + if (setlocale_null_r (LC_ALL, buf, sizeof (buf))) + return "C"; + strcpy (resultbuf, buf); + return resultbuf; +# endif + } + else + { +# if SETLOCALE_NULL_ONE_MTSAFE + return setlocale_null_androidfix (category); +# else + enum + { + LC_CTYPE_INDEX, + LC_NUMERIC_INDEX, + LC_TIME_INDEX, + LC_COLLATE_INDEX, + LC_MONETARY_INDEX, + LC_MESSAGES_INDEX, +# ifdef LC_PAPER + LC_PAPER_INDEX, +# endif +# ifdef LC_NAME + LC_NAME_INDEX, +# endif +# ifdef LC_ADDRESS + LC_ADDRESS_INDEX, +# endif +# ifdef LC_TELEPHONE + LC_TELEPHONE_INDEX, +# endif +# ifdef LC_MEASUREMENT + LC_MEASUREMENT_INDEX, +# endif +# ifdef LC_IDENTIFICATION + LC_IDENTIFICATION_INDEX, +# endif + LC_INDICES_COUNT + } + i; + char buf[SETLOCALE_NULL_MAX]; + static char resultbuf[LC_INDICES_COUNT][SETLOCALE_NULL_MAX]; + int err; + + err = setlocale_null_r (category, buf, sizeof (buf)); + if (err == EINVAL) + return NULL; + if (err) + return "C"; + + switch (category) + { + case LC_CTYPE: i = LC_CTYPE_INDEX; break; + case LC_NUMERIC: i = LC_NUMERIC_INDEX; break; + case LC_TIME: i = LC_TIME_INDEX; break; + case LC_COLLATE: i = LC_COLLATE_INDEX; break; + case LC_MONETARY: i = LC_MONETARY_INDEX; break; + case LC_MESSAGES: i = LC_MESSAGES_INDEX; break; +# ifdef LC_PAPER + case LC_PAPER: i = LC_PAPER_INDEX; break; +# endif +# ifdef LC_NAME + case LC_NAME: i = LC_NAME_INDEX; break; +# endif +# ifdef LC_ADDRESS + case LC_ADDRESS: i = LC_ADDRESS_INDEX; break; +# endif +# ifdef LC_TELEPHONE + case LC_TELEPHONE: i = LC_TELEPHONE_INDEX; break; +# endif +# ifdef LC_MEASUREMENT + case LC_MEASUREMENT: i = LC_MEASUREMENT_INDEX; break; +# endif +# ifdef LC_IDENTIFICATION + case LC_IDENTIFICATION: i = LC_IDENTIFICATION_INDEX; break; +# endif + default: + /* If you get here, a #ifdef LC_xxx is missing. */ + abort (); + } + + strcpy (resultbuf[i], buf); + return resultbuf[i]; +# endif + } +#endif +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/setlocale_null.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/setlocale_null.h new file mode 100644 index 00000000..defa2b41 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/setlocale_null.h @@ -0,0 +1,82 @@ +/* Query the name of the current global locale. + Copyright (C) 2019-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 2019. */ + +#ifndef _SETLOCALE_NULL_H +#define _SETLOCALE_NULL_H + +#include + +#include "arg-nonnull.h" + + +#ifdef __cplusplus +extern "C" { +#endif + + +/* Recommended size of a buffer for a locale name for a single category. + On glibc systems, you can have locale names that are relative file names; + assume a maximum length 256. + In native Windows, in 2018 the longest locale name was of length 58 + ("FYRO Macedonian_Former Yugoslav Republic of Macedonia.1251"). */ +#define SETLOCALE_NULL_MAX (256+1) + +/* Recommended size of a buffer for a locale name with all categories. + On glibc systems, you can have locale names that are relative file names; + assume maximum length 256 for each. There are 12 categories; so, the + maximum total length is 148+12*256. + In native Windows, there are 5 categories, and the maximum total length is + 55+5*58. */ +#define SETLOCALE_NULL_ALL_MAX (148+12*256+1) + +/* setlocale_null_r (CATEGORY, BUF, BUFSIZE) is like setlocale (CATEGORY, NULL), + except that + - it is guaranteed to be multithread-safe, + - it returns the resulting locale category name or locale name in the + user-supplied buffer BUF, which must be BUFSIZE bytes long. + The recommended minimum buffer size is + - SETLOCALE_NULL_MAX for CATEGORY != LC_ALL, and + - SETLOCALE_NULL_ALL_MAX for CATEGORY == LC_ALL. + The return value is an error code: 0 if the call is successful, EINVAL if + CATEGORY is invalid, or ERANGE if BUFSIZE is smaller than the length needed + size (including the trailing NUL byte). In the latter case, a truncated + result is returned in BUF, but still NUL-terminated if BUFSIZE > 0. + For this call to be multithread-safe, *all* calls to + setlocale (CATEGORY, NULL) in all other threads must have been converted + to use setlocale_null_r or setlocale_null as well, and the other threads + must not make other setlocale invocations (since changing the global locale + has side effects on all threads). */ +extern int setlocale_null_r (int category, char *buf, size_t bufsize) + _GL_ARG_NONNULL ((2)); + +/* setlocale_null (CATEGORY) is like setlocale (CATEGORY, NULL), except that + it is guaranteed to be multithread-safe. + The return value is NULL if CATEGORY is invalid. + For this call to be multithread-safe, *all* calls to + setlocale (CATEGORY, NULL) in all other threads must have been converted + to use setlocale_null_r or setlocale_null as well, and the other threads + must not make other setlocale invocations (since changing the global locale + has side effects on all threads). */ +extern const char *setlocale_null (int category); + + +#ifdef __cplusplus +} +#endif + +#endif /* _SETLOCALE_NULL_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/sh-quote.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/sh-quote.c new file mode 100644 index 00000000..03d20e96 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/sh-quote.c @@ -0,0 +1,107 @@ +/* Shell quoting. + Copyright (C) 2001-2004, 2006, 2009-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2001. + + 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 . */ + +#include + +/* Specification. */ +#include "sh-quote.h" + +#include + +#include "quotearg.h" +#include "xalloc.h" + +/* Describes quoting for sh compatible shells. */ +static struct quoting_options *sh_quoting_options; + +/* Initializes the sh_quoting_options variable. */ +static void +init_sh_quoting_options (void) +{ + sh_quoting_options = clone_quoting_options (NULL); + set_quoting_style (sh_quoting_options, shell_quoting_style); +} + +/* Returns the number of bytes needed for the quoted string. */ +size_t +shell_quote_length (const char *string) +{ + if (sh_quoting_options == NULL) + init_sh_quoting_options (); + return quotearg_buffer (NULL, 0, string, strlen (string), + sh_quoting_options); +} + +/* Copies the quoted string to p and returns the incremented p. + There must be room for shell_quote_length (string) + 1 bytes at p. */ +char * +shell_quote_copy (char *p, const char *string) +{ + if (sh_quoting_options == NULL) + init_sh_quoting_options (); + return p + quotearg_buffer (p, (size_t)(-1), string, strlen (string), + sh_quoting_options); +} + +/* Returns the freshly allocated quoted string. */ +char * +shell_quote (const char *string) +{ + if (sh_quoting_options == NULL) + init_sh_quoting_options (); + return quotearg_alloc (string, strlen (string), sh_quoting_options); +} + +/* Returns a freshly allocated string containing all argument strings, quoted, + separated through spaces. */ +char * +shell_quote_argv (const char * const *argv) +{ + if (*argv != NULL) + { + const char * const *argp; + size_t length; + char *command; + char *p; + + length = 0; + for (argp = argv; ; ) + { + length += shell_quote_length (*argp) + 1; + argp++; + if (*argp == NULL) + break; + } + + command = XNMALLOC (length, char); + + p = command; + for (argp = argv; ; ) + { + p = shell_quote_copy (p, *argp); + argp++; + if (*argp == NULL) + break; + *p++ = ' '; + } + *p = '\0'; + + return command; + } + else + return xstrdup (""); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/sh-quote.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/sh-quote.h new file mode 100644 index 00000000..753a27b4 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/sh-quote.h @@ -0,0 +1,58 @@ +/* Shell quoting. + Copyright (C) 2001-2002, 2004, 2009-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2001. + + 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 . */ + +#ifndef _SH_QUOTE_H +#define _SH_QUOTE_H + +/* When passing a command to a shell, we must quote the program name and + arguments, since Unix shells interpret characters like " ", "'", "<", ">", + "$", '*', '?' etc. in a special way. */ + +/* This file uses _GL_ATTRIBUTE_MALLOC, _GL_ATTRIBUTE_RETURNS_NONNULL. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Returns the number of bytes needed for the quoted string. */ +extern size_t shell_quote_length (const char *string); + +/* Copies the quoted string to p and returns the incremented p. + There must be room for shell_quote_length (string) + 1 bytes at p. */ +extern char * shell_quote_copy (char *restrict p, const char *string); + +/* Returns the freshly allocated quoted string. */ +extern char * shell_quote (const char *string) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE + _GL_ATTRIBUTE_RETURNS_NONNULL; + +/* Returns a freshly allocated string containing all argument strings, quoted, + separated through spaces. */ +extern char * shell_quote_argv (const char * const *argv) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE + _GL_ATTRIBUTE_RETURNS_NONNULL; + +#ifdef __cplusplus +} +#endif + +#endif /* _SH_QUOTE_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/sig-handler.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/sig-handler.c new file mode 100644 index 00000000..fcf82d15 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/sig-handler.c @@ -0,0 +1,21 @@ +/* Convenience declarations when working with . + + Copyright (C) 2012-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +#define SIG_HANDLER_INLINE _GL_EXTERN_INLINE +#include "sig-handler.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/sig-handler.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/sig-handler.h new file mode 100644 index 00000000..076d0abe --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/sig-handler.h @@ -0,0 +1,53 @@ +/* Convenience declarations when working with . + + Copyright (C) 2008-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef _GL_SIG_HANDLER_H +#define _GL_SIG_HANDLER_H + +/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, _GL_ATTRIBUTE_PURE. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +#include + +_GL_INLINE_HEADER_BEGIN +#ifndef SIG_HANDLER_INLINE +# define SIG_HANDLER_INLINE _GL_INLINE +#endif + +/* Convenience type when working with signal handlers. */ +typedef void (*sa_handler_t) (int); + +/* Return the handler of a signal, as a sa_handler_t value regardless + of its true type. The resulting function can be compared to + special values like SIG_IGN but it is not portable to call it. */ +SIG_HANDLER_INLINE sa_handler_t _GL_ATTRIBUTE_PURE +get_handler (struct sigaction const *a) +{ + /* POSIX says that special values like SIG_IGN can only occur when + action.sa_flags does not contain SA_SIGINFO. But in Linux 2.4, + for example, sa_sigaction and sa_handler are aliases and a signal + is ignored if sa_sigaction (after casting) equals SIG_IGN. In + this case, this implementation relies on the fact that the two + are aliases, and simply returns sa_handler. */ + return a->sa_handler; +} + +_GL_INLINE_HEADER_END + +#endif /* _GL_SIG_HANDLER_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/sigaction.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/sigaction.c new file mode 100644 index 00000000..1b2ceb52 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/sigaction.c @@ -0,0 +1,204 @@ +/* POSIX compatible signal blocking. + Copyright (C) 2008-2024 Free Software Foundation, Inc. + Written by Eric Blake , 2008. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +#include +#include +#include + +/* This implementation of sigaction is tailored to native Windows behavior: + signal() has SysV semantics (ie. the handler is uninstalled before + it is invoked). This is an inherent data race if an asynchronous + signal is sent twice in a row before we can reinstall our handler, + but there's nothing we can do about it. Meanwhile, sigprocmask() + is not present, and while we can use the gnulib replacement to + provide critical sections, it too suffers from potential data races + in the face of an ill-timed asynchronous signal. And we compound + the situation by reading static storage in a signal handler, which + POSIX warns is not generically async-signal-safe. Oh well. + + Additionally: + - We don't implement SA_NOCLDSTOP or SA_NOCLDWAIT, because SIGCHLD + is not defined. + - We don't implement SA_ONSTACK, because sigaltstack() is not present. + - We ignore SA_RESTART, because blocking native Windows API calls are + not interrupted anyway when an asynchronous signal occurs, and the + MSVCRT runtime never sets errno to EINTR. + - We don't implement SA_SIGINFO because it is impossible to do so + portably. + + POSIX states that an application should not mix signal() and + sigaction(). We support the use of signal() within the gnulib + sigprocmask() substitute, but all other application code linked + with this module should stick with only sigaction(). */ + +/* Check some of our assumptions. */ +#if defined SIGCHLD || defined HAVE_SIGALTSTACK || defined HAVE_SIGINTERRUPT +# error "Revisit the assumptions made in the sigaction module" +#endif + +/* Out-of-range substitutes make a good fallback for uncatchable + signals. */ +#ifndef SIGKILL +# define SIGKILL (-1) +#endif +#ifndef SIGSTOP +# define SIGSTOP (-1) +#endif + +/* On native Windows, as of 2008, the signal SIGABRT_COMPAT is an alias + for the signal SIGABRT. Only one signal handler is stored for both + SIGABRT and SIGABRT_COMPAT. SIGABRT_COMPAT is not a signal of its own. */ +#if defined _WIN32 && ! defined __CYGWIN__ +# undef SIGABRT_COMPAT +# define SIGABRT_COMPAT 6 +#endif + +/* A signal handler. */ +typedef void (*handler_t) (int signal); + +/* Set of current actions. If sa_handler for an entry is NULL, then + that signal is not currently handled by the sigaction handler. */ +static struct sigaction volatile action_array[NSIG] /* = 0 */; + +/* Signal handler that is installed for signals. */ +static void +sigaction_handler (int sig) +{ + handler_t handler; + sigset_t mask; + sigset_t oldmask; + int saved_errno = errno; + if (sig < 0 || NSIG <= sig || !action_array[sig].sa_handler) + { + /* Unexpected situation; be careful to avoid recursive abort. */ + if (sig == SIGABRT) + signal (SIGABRT, SIG_DFL); + abort (); + } + + /* Reinstall the signal handler when required; otherwise update the + bookkeeping so that the user's handler may call sigaction and get + accurate results. We know the signal isn't currently blocked, or + we wouldn't be in its handler, therefore we know that we are not + interrupting a sigaction() call. There is a race where any + asynchronous instance of the same signal occurring before we + reinstall the handler will trigger the default handler; oh + well. */ + handler = action_array[sig].sa_handler; + if ((action_array[sig].sa_flags & SA_RESETHAND) == 0) + signal (sig, sigaction_handler); + else + action_array[sig].sa_handler = NULL; + + /* Block appropriate signals. */ + mask = action_array[sig].sa_mask; + if ((action_array[sig].sa_flags & SA_NODEFER) == 0) + sigaddset (&mask, sig); + sigprocmask (SIG_BLOCK, &mask, &oldmask); + + /* Invoke the user's handler, then restore prior mask. */ + errno = saved_errno; + handler (sig); + saved_errno = errno; + sigprocmask (SIG_SETMASK, &oldmask, NULL); + errno = saved_errno; +} + +/* Change and/or query the action that will be taken on delivery of + signal SIG. If not NULL, ACT describes the new behavior. If not + NULL, OACT is set to the prior behavior. Return 0 on success, or + set errno and return -1 on failure. */ +int +sigaction (int sig, const struct sigaction *restrict act, + struct sigaction *restrict oact) +{ + sigset_t mask; + sigset_t oldmask; + int saved_errno; + + if (sig < 0 || NSIG <= sig || sig == SIGKILL || sig == SIGSTOP + || (act && act->sa_handler == SIG_ERR)) + { + errno = EINVAL; + return -1; + } + +#ifdef SIGABRT_COMPAT + if (sig == SIGABRT_COMPAT) + sig = SIGABRT; +#endif + + /* POSIX requires sigaction() to be async-signal-safe. In other + words, if an asynchronous signal can occur while we are anywhere + inside this function, the user's handler could then call + sigaction() recursively and expect consistent results. We meet + this rule by using sigprocmask to block all signals before + modifying any data structure that could be read from a signal + handler; this works since we know that the gnulib sigprocmask + replacement does not try to use sigaction() from its handler. */ + if (!act && !oact) + return 0; + sigfillset (&mask); + sigprocmask (SIG_BLOCK, &mask, &oldmask); + if (oact) + { + if (action_array[sig].sa_handler) + *oact = action_array[sig]; + else + { + /* Safe to change the handler at will here, since all + signals are currently blocked. */ + oact->sa_handler = signal (sig, SIG_DFL); + if (oact->sa_handler == SIG_ERR) + goto failure; + signal (sig, oact->sa_handler); + oact->sa_flags = SA_RESETHAND | SA_NODEFER; + sigemptyset (&oact->sa_mask); + } + } + + if (act) + { + /* Safe to install the handler before updating action_array, + since all signals are currently blocked. */ + if (act->sa_handler == SIG_DFL || act->sa_handler == SIG_IGN) + { + if (signal (sig, act->sa_handler) == SIG_ERR) + goto failure; + action_array[sig].sa_handler = NULL; + } + else + { + if (signal (sig, sigaction_handler) == SIG_ERR) + goto failure; + action_array[sig] = *act; + } + } + sigprocmask (SIG_SETMASK, &oldmask, NULL); + return 0; + + failure: + saved_errno = errno; + sigprocmask (SIG_SETMASK, &oldmask, NULL); + errno = saved_errno; + return -1; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/signal.in.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/signal.in.h new file mode 100644 index 00000000..107226e3 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/signal.in.h @@ -0,0 +1,500 @@ +/* A GNU-like . + + Copyright (C) 2006-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +#endif +@PRAGMA_COLUMNS@ + +#if defined __need_sig_atomic_t || defined __need_sigset_t || defined _GL_ALREADY_INCLUDING_SIGNAL_H || (defined _SIGNAL_H && !defined __SIZEOF_PTHREAD_MUTEX_T) +/* Special invocation convention: + - Inside glibc header files. + - On glibc systems we have a sequence of nested includes + -> -> . + In this situation, the functions are not yet declared, therefore we cannot + provide the C++ aliases. + - On glibc systems with GCC 4.3 we have a sequence of nested includes + -> -> -> . + In this situation, some of the functions are not yet declared, therefore + we cannot provide the C++ aliases. */ + +# @INCLUDE_NEXT@ @NEXT_SIGNAL_H@ + +#else +/* Normal invocation convention. */ + +#ifndef _@GUARD_PREFIX@_SIGNAL_H + +#define _GL_ALREADY_INCLUDING_SIGNAL_H + +/* Define pid_t, uid_t. + Also, mingw defines sigset_t not in , but in . + On Solaris 10, includes , which eventually includes + us; so include now, before the second inclusion guard. */ +#include + +/* The include_next requires a split double-inclusion guard. */ +#@INCLUDE_NEXT@ @NEXT_SIGNAL_H@ + +#undef _GL_ALREADY_INCLUDING_SIGNAL_H + +#ifndef _@GUARD_PREFIX@_SIGNAL_H +#define _@GUARD_PREFIX@_SIGNAL_H + +/* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +/* For testing the OpenBSD version. */ +#if (@GNULIB_PTHREAD_SIGMASK@ || defined GNULIB_POSIXCHECK) \ + && defined __OpenBSD__ +# include +#endif + +/* Mac OS X 10.3, FreeBSD < 8.0, OpenBSD < 5.1, OSF/1 4.0, Solaris 2.6, Android, + OS/2 kLIBC declare pthread_sigmask in , not in . + But avoid namespace pollution on glibc systems.*/ +#if (@GNULIB_PTHREAD_SIGMASK@ || defined GNULIB_POSIXCHECK) \ + && ((defined __APPLE__ && defined __MACH__) \ + || (defined __FreeBSD__ && __FreeBSD__ < 8) \ + || (defined __OpenBSD__ && OpenBSD < 201205) \ + || defined __osf__ || defined __sun || defined __ANDROID__ \ + || defined __KLIBC__) \ + && ! defined __GLIBC__ +# include +#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. */ + +/* On AIX, sig_atomic_t already includes volatile. C99 requires that + 'volatile sig_atomic_t' ignore the extra modifier, but C89 did not. + Hence, redefine this to a non-volatile type as needed. */ +#if ! @HAVE_TYPE_VOLATILE_SIG_ATOMIC_T@ +# if !GNULIB_defined_sig_atomic_t +typedef int rpl_sig_atomic_t; +# undef sig_atomic_t +# define sig_atomic_t rpl_sig_atomic_t +# define GNULIB_defined_sig_atomic_t 1 +# endif +#endif + +/* A set or mask of signals. */ +#if !@HAVE_SIGSET_T@ +# if !GNULIB_defined_sigset_t +typedef unsigned int sigset_t; +# define GNULIB_defined_sigset_t 1 +# endif +#endif + +/* Define sighandler_t, the type of signal handlers. A GNU extension. */ +#if !@HAVE_SIGHANDLER_T@ +# ifdef __cplusplus +extern "C" { +# endif +# if !GNULIB_defined_sighandler_t +typedef void (*sighandler_t) (int); +# define GNULIB_defined_sighandler_t 1 +# endif +# ifdef __cplusplus +} +# endif +#endif + + +#if @GNULIB_SIGNAL_H_SIGPIPE@ +# ifndef SIGPIPE +/* Define SIGPIPE to a value that does not overlap with other signals. */ +# define SIGPIPE 13 +# define GNULIB_defined_SIGPIPE 1 +/* To actually use SIGPIPE, you also need the gnulib modules 'sigprocmask', + 'write', 'stdio'. */ +# endif +#endif + + +/* Maximum signal number + 1. */ +#ifndef NSIG +# if defined __TANDEM +# define NSIG 32 +# endif +#endif + + +#if @GNULIB_PTHREAD_SIGMASK@ +# if @REPLACE_PTHREAD_SIGMASK@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pthread_sigmask +# define pthread_sigmask rpl_pthread_sigmask +# endif +_GL_FUNCDECL_RPL (pthread_sigmask, int, + (int how, + const sigset_t *restrict new_mask, + sigset_t *restrict old_mask)); +_GL_CXXALIAS_RPL (pthread_sigmask, int, + (int how, + const sigset_t *restrict new_mask, + sigset_t *restrict old_mask)); +# else +# if !(@HAVE_PTHREAD_SIGMASK@ || defined pthread_sigmask) +_GL_FUNCDECL_SYS (pthread_sigmask, int, + (int how, + const sigset_t *restrict new_mask, + sigset_t *restrict old_mask)); +# endif +_GL_CXXALIAS_SYS (pthread_sigmask, int, + (int how, + const sigset_t *restrict new_mask, + sigset_t *restrict old_mask)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (pthread_sigmask); +# endif +#elif defined GNULIB_POSIXCHECK +# undef pthread_sigmask +# if HAVE_RAW_DECL_PTHREAD_SIGMASK +_GL_WARN_ON_USE (pthread_sigmask, "pthread_sigmask is not portable - " + "use gnulib module pthread_sigmask for portability"); +# endif +#endif + + +#if @GNULIB_RAISE@ +# if @REPLACE_RAISE@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef raise +# define raise rpl_raise +# endif +_GL_FUNCDECL_RPL (raise, int, (int sig)); +_GL_CXXALIAS_RPL (raise, int, (int sig)); +# else +# if !@HAVE_RAISE@ +_GL_FUNCDECL_SYS (raise, int, (int sig)); +# endif +_GL_CXXALIAS_SYS (raise, int, (int sig)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (raise); +# endif +#elif defined GNULIB_POSIXCHECK +# undef raise +/* Assume raise is always declared. */ +_GL_WARN_ON_USE (raise, "raise can crash on native Windows - " + "use gnulib module raise for portability"); +#endif + + +#if @GNULIB_SIGPROCMASK@ +# if !@HAVE_POSIX_SIGNALBLOCKING@ + +# ifndef GNULIB_defined_signal_blocking +# define GNULIB_defined_signal_blocking 1 +# endif + +/* Maximum signal number + 1. */ +# ifndef NSIG +# define NSIG 32 +# endif + +/* This code supports only 32 signals. */ +# if !GNULIB_defined_verify_NSIG_constraint +typedef int verify_NSIG_constraint[NSIG <= 32 ? 1 : -1]; +# define GNULIB_defined_verify_NSIG_constraint 1 +# endif + +# endif + +/* When also using extern inline, suppress the use of static inline in + standard headers of problematic Apple configurations, as Libc at + least through Libc-825.26 (2013-04-09) mishandles it; see, e.g., + . + Perhaps Apple will fix this some day. */ +#if (defined _GL_EXTERN_INLINE_IN_USE && defined __APPLE__ \ + && (defined __i386__ || defined __x86_64__)) +# undef sigaddset +# undef sigdelset +# undef sigemptyset +# undef sigfillset +# undef sigismember +#endif + +/* Test whether a given signal is contained in a signal set. */ +# if @HAVE_POSIX_SIGNALBLOCKING@ +/* This function is defined as a macro on Mac OS X. */ +# if defined __cplusplus && defined GNULIB_NAMESPACE +# undef sigismember +# endif +# else +_GL_FUNCDECL_SYS (sigismember, int, (const sigset_t *set, int sig) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (sigismember, int, (const sigset_t *set, int sig)); +_GL_CXXALIASWARN (sigismember); + +/* Initialize a signal set to the empty set. */ +# if @HAVE_POSIX_SIGNALBLOCKING@ +/* This function is defined as a macro on Mac OS X. */ +# if defined __cplusplus && defined GNULIB_NAMESPACE +# undef sigemptyset +# endif +# else +_GL_FUNCDECL_SYS (sigemptyset, int, (sigset_t *set) _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (sigemptyset, int, (sigset_t *set)); +_GL_CXXALIASWARN (sigemptyset); + +/* Add a signal to a signal set. */ +# if @HAVE_POSIX_SIGNALBLOCKING@ +/* This function is defined as a macro on Mac OS X. */ +# if defined __cplusplus && defined GNULIB_NAMESPACE +# undef sigaddset +# endif +# else +_GL_FUNCDECL_SYS (sigaddset, int, (sigset_t *set, int sig) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (sigaddset, int, (sigset_t *set, int sig)); +_GL_CXXALIASWARN (sigaddset); + +/* Remove a signal from a signal set. */ +# if @HAVE_POSIX_SIGNALBLOCKING@ +/* This function is defined as a macro on Mac OS X. */ +# if defined __cplusplus && defined GNULIB_NAMESPACE +# undef sigdelset +# endif +# else +_GL_FUNCDECL_SYS (sigdelset, int, (sigset_t *set, int sig) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (sigdelset, int, (sigset_t *set, int sig)); +_GL_CXXALIASWARN (sigdelset); + +/* Fill a signal set with all possible signals. */ +# if @HAVE_POSIX_SIGNALBLOCKING@ +/* This function is defined as a macro on Mac OS X. */ +# if defined __cplusplus && defined GNULIB_NAMESPACE +# undef sigfillset +# endif +# else +_GL_FUNCDECL_SYS (sigfillset, int, (sigset_t *set) _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (sigfillset, int, (sigset_t *set)); +_GL_CXXALIASWARN (sigfillset); + +/* Return the set of those blocked signals that are pending. */ +# if !@HAVE_POSIX_SIGNALBLOCKING@ +_GL_FUNCDECL_SYS (sigpending, int, (sigset_t *set) _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (sigpending, int, (sigset_t *set)); +_GL_CXXALIASWARN (sigpending); + +/* If OLD_SET is not NULL, put the current set of blocked signals in *OLD_SET. + Then, if SET is not NULL, affect the current set of blocked signals by + combining it with *SET as indicated in OPERATION. + In this implementation, you are not allowed to change a signal handler + while the signal is blocked. */ +# if !@HAVE_POSIX_SIGNALBLOCKING@ +# define SIG_BLOCK 0 /* blocked_set = blocked_set | *set; */ +# define SIG_SETMASK 1 /* blocked_set = *set; */ +# define SIG_UNBLOCK 2 /* blocked_set = blocked_set & ~*set; */ +_GL_FUNCDECL_SYS (sigprocmask, int, + (int operation, + const sigset_t *restrict set, + sigset_t *restrict old_set)); +# endif +_GL_CXXALIAS_SYS (sigprocmask, int, + (int operation, + const sigset_t *restrict set, + sigset_t *restrict old_set)); +_GL_CXXALIASWARN (sigprocmask); + +/* Install the handler FUNC for signal SIG, and return the previous + handler. */ +# ifdef __cplusplus +extern "C" { +# endif +# if !GNULIB_defined_function_taking_int_returning_void_t +typedef void (*_gl_function_taking_int_returning_void_t) (int); +# define GNULIB_defined_function_taking_int_returning_void_t 1 +# endif +# ifdef __cplusplus +} +# endif +# if !@HAVE_POSIX_SIGNALBLOCKING@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define signal rpl_signal +# endif +_GL_FUNCDECL_RPL (signal, _gl_function_taking_int_returning_void_t, + (int sig, _gl_function_taking_int_returning_void_t func)); +_GL_CXXALIAS_RPL (signal, _gl_function_taking_int_returning_void_t, + (int sig, _gl_function_taking_int_returning_void_t func)); +# else +/* On OpenBSD, the declaration of 'signal' may not be present at this point, + because it occurs in , not directly. */ +# if defined __OpenBSD__ +_GL_FUNCDECL_SYS (signal, _gl_function_taking_int_returning_void_t, + (int sig, _gl_function_taking_int_returning_void_t func)); +# endif +_GL_CXXALIAS_SYS (signal, _gl_function_taking_int_returning_void_t, + (int sig, _gl_function_taking_int_returning_void_t func)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (signal); +# endif + +# if !@HAVE_POSIX_SIGNALBLOCKING@ && GNULIB_defined_SIGPIPE +/* Raise signal SIGPIPE. */ +_GL_EXTERN_C int _gl_raise_SIGPIPE (void); +# endif + +#elif defined GNULIB_POSIXCHECK +# undef sigaddset +# if HAVE_RAW_DECL_SIGADDSET +_GL_WARN_ON_USE (sigaddset, "sigaddset is unportable - " + "use the gnulib module sigprocmask for portability"); +# endif +# undef sigdelset +# if HAVE_RAW_DECL_SIGDELSET +_GL_WARN_ON_USE (sigdelset, "sigdelset is unportable - " + "use the gnulib module sigprocmask for portability"); +# endif +# undef sigemptyset +# if HAVE_RAW_DECL_SIGEMPTYSET +_GL_WARN_ON_USE (sigemptyset, "sigemptyset is unportable - " + "use the gnulib module sigprocmask for portability"); +# endif +# undef sigfillset +# if HAVE_RAW_DECL_SIGFILLSET +_GL_WARN_ON_USE (sigfillset, "sigfillset is unportable - " + "use the gnulib module sigprocmask for portability"); +# endif +# undef sigismember +# if HAVE_RAW_DECL_SIGISMEMBER +_GL_WARN_ON_USE (sigismember, "sigismember is unportable - " + "use the gnulib module sigprocmask for portability"); +# endif +# undef sigpending +# if HAVE_RAW_DECL_SIGPENDING +_GL_WARN_ON_USE (sigpending, "sigpending is unportable - " + "use the gnulib module sigprocmask for portability"); +# endif +# undef sigprocmask +# if HAVE_RAW_DECL_SIGPROCMASK +_GL_WARN_ON_USE (sigprocmask, "sigprocmask is unportable - " + "use the gnulib module sigprocmask for portability"); +# endif +#endif /* @GNULIB_SIGPROCMASK@ */ + + +#if @GNULIB_SIGACTION@ +# if !@HAVE_SIGACTION@ + +# if !@HAVE_SIGINFO_T@ + +# if !GNULIB_defined_siginfo_types + +/* Present to allow compilation, but unsupported by gnulib. */ +union sigval +{ + int sival_int; + void *sival_ptr; +}; + +/* Present to allow compilation, but unsupported by gnulib. */ +struct siginfo_t +{ + int si_signo; + int si_code; + int si_errno; + pid_t si_pid; + uid_t si_uid; + void *si_addr; + int si_status; + long si_band; + union sigval si_value; +}; +typedef struct siginfo_t siginfo_t; + +# define GNULIB_defined_siginfo_types 1 +# endif + +# endif /* !@HAVE_SIGINFO_T@ */ + +/* We assume that platforms which lack the sigaction() function also lack + the 'struct sigaction' type, and vice versa. */ + +# if !GNULIB_defined_struct_sigaction + +struct sigaction +{ + union + { + void (*_sa_handler) (int); + /* Present to allow compilation, but unsupported by gnulib. POSIX + says that implementations may, but not must, make sa_sigaction + overlap with sa_handler, but we know of no implementation where + they do not overlap. */ + void (*_sa_sigaction) (int, siginfo_t *, void *); + } _sa_func; + sigset_t sa_mask; + /* Not all POSIX flags are supported. */ + int sa_flags; +}; +# define sa_handler _sa_func._sa_handler +# define sa_sigaction _sa_func._sa_sigaction +/* Unsupported flags are not present. */ +# define SA_RESETHAND 1 +# define SA_NODEFER 2 +# define SA_RESTART 4 + +# define GNULIB_defined_struct_sigaction 1 +# endif + +_GL_FUNCDECL_SYS (sigaction, int, (int, const struct sigaction *restrict, + struct sigaction *restrict)); + +# elif !@HAVE_STRUCT_SIGACTION_SA_SIGACTION@ + +# define sa_sigaction sa_handler + +# endif /* !@HAVE_SIGACTION@, !@HAVE_STRUCT_SIGACTION_SA_SIGACTION@ */ + +_GL_CXXALIAS_SYS (sigaction, int, (int, const struct sigaction *restrict, + struct sigaction *restrict)); +_GL_CXXALIASWARN (sigaction); + +#elif defined GNULIB_POSIXCHECK +# undef sigaction +# if HAVE_RAW_DECL_SIGACTION +_GL_WARN_ON_USE (sigaction, "sigaction is unportable - " + "use the gnulib module sigaction for portability"); +# endif +#endif + +/* Some systems don't have SA_NODEFER. */ +#ifndef SA_NODEFER +# define SA_NODEFER 0 +#endif + + +#endif /* _@GUARD_PREFIX@_SIGNAL_H */ +#endif /* _@GUARD_PREFIX@_SIGNAL_H */ +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/sigprocmask.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/sigprocmask.c new file mode 100644 index 00000000..3df69b51 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/sigprocmask.c @@ -0,0 +1,349 @@ +/* POSIX compatible signal blocking. + Copyright (C) 2006-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2006. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +#include +#include +#include + +#if HAVE_MSVC_INVALID_PARAMETER_HANDLER +# include "msvc-inval.h" +#endif + +/* We assume that a platform without POSIX signal blocking functions + also does not have the POSIX sigaction() function, only the + signal() function. We also assume signal() has SysV semantics, + where any handler is uninstalled prior to being invoked. This is + true for native Windows platforms. */ + +/* We use raw signal(), but also provide a wrapper rpl_signal() so + that applications can query or change a blocked signal. */ +#undef signal + +/* Provide invalid signal numbers as fallbacks if the uncatchable + signals are not defined. */ +#ifndef SIGKILL +# define SIGKILL (-1) +#endif +#ifndef SIGSTOP +# define SIGSTOP (-1) +#endif + +/* On native Windows, as of 2008, the signal SIGABRT_COMPAT is an alias + for the signal SIGABRT. Only one signal handler is stored for both + SIGABRT and SIGABRT_COMPAT. SIGABRT_COMPAT is not a signal of its own. */ +#if defined _WIN32 && ! defined __CYGWIN__ +# undef SIGABRT_COMPAT +# define SIGABRT_COMPAT 6 +#endif +#ifdef SIGABRT_COMPAT +# define SIGABRT_COMPAT_MASK (1U << SIGABRT_COMPAT) +#else +# define SIGABRT_COMPAT_MASK 0 +#endif + +typedef void (*handler_t) (int); + +#if HAVE_MSVC_INVALID_PARAMETER_HANDLER +static handler_t +signal_nothrow (int sig, handler_t handler) +{ + handler_t result; + + TRY_MSVC_INVAL + { + result = signal (sig, handler); + } + CATCH_MSVC_INVAL + { + result = SIG_ERR; + errno = EINVAL; + } + DONE_MSVC_INVAL; + + return result; +} +# define signal signal_nothrow +#endif + +/* Handling of gnulib defined signals. */ + +#if GNULIB_defined_SIGPIPE +static handler_t SIGPIPE_handler = SIG_DFL; +#endif + +#if GNULIB_defined_SIGPIPE +static handler_t +ext_signal (int sig, handler_t handler) +{ + switch (sig) + { + case SIGPIPE: + { + handler_t old_handler = SIGPIPE_handler; + SIGPIPE_handler = handler; + return old_handler; + } + default: /* System defined signal */ + return signal (sig, handler); + } +} +# undef signal +# define signal ext_signal +#endif + +int +sigismember (const sigset_t *set, int sig) +{ + if (sig >= 0 && sig < NSIG) + { + #ifdef SIGABRT_COMPAT + if (sig == SIGABRT_COMPAT) + sig = SIGABRT; + #endif + + return (*set >> sig) & 1; + } + else + return 0; +} + +int +sigemptyset (sigset_t *set) +{ + *set = 0; + return 0; +} + +int +sigaddset (sigset_t *set, int sig) +{ + if (sig >= 0 && sig < NSIG) + { + #ifdef SIGABRT_COMPAT + if (sig == SIGABRT_COMPAT) + sig = SIGABRT; + #endif + + *set |= 1U << sig; + return 0; + } + else + { + errno = EINVAL; + return -1; + } +} + +int +sigdelset (sigset_t *set, int sig) +{ + if (sig >= 0 && sig < NSIG) + { + #ifdef SIGABRT_COMPAT + if (sig == SIGABRT_COMPAT) + sig = SIGABRT; + #endif + + *set &= ~(1U << sig); + return 0; + } + else + { + errno = EINVAL; + return -1; + } +} + + +int +sigfillset (sigset_t *set) +{ + *set = ((2U << (NSIG - 1)) - 1) & ~ SIGABRT_COMPAT_MASK; + return 0; +} + +/* Set of currently blocked signals. */ +static volatile sigset_t blocked_set /* = 0 */; + +/* Set of currently blocked and pending signals. */ +static volatile sig_atomic_t pending_array[NSIG] /* = { 0 } */; + +/* Signal handler that is installed for blocked signals. */ +static void +blocked_handler (int sig) +{ + /* Reinstall the handler, in case the signal occurs multiple times + while blocked. There is an inherent race where an asynchronous + signal in between when the kernel uninstalled the handler and + when we reinstall it will trigger the default handler; oh + well. */ + signal (sig, blocked_handler); + if (sig >= 0 && sig < NSIG) + pending_array[sig] = 1; +} + +int +sigpending (sigset_t *set) +{ + sigset_t pending = 0; + int sig; + + for (sig = 0; sig < NSIG; sig++) + if (pending_array[sig]) + pending |= 1U << sig; + *set = pending; + return 0; +} + +/* The previous signal handlers. + Only the array elements corresponding to blocked signals are relevant. */ +static volatile handler_t old_handlers[NSIG]; + +int +sigprocmask (int operation, const sigset_t *set, sigset_t *old_set) +{ + if (old_set != NULL) + *old_set = blocked_set; + + if (set != NULL) + { + sigset_t new_blocked_set; + sigset_t to_unblock; + sigset_t to_block; + + switch (operation) + { + case SIG_BLOCK: + new_blocked_set = blocked_set | *set; + break; + case SIG_SETMASK: + new_blocked_set = *set; + break; + case SIG_UNBLOCK: + new_blocked_set = blocked_set & ~*set; + break; + default: + errno = EINVAL; + return -1; + } + to_unblock = blocked_set & ~new_blocked_set; + to_block = new_blocked_set & ~blocked_set; + + if (to_block != 0) + { + int sig; + + for (sig = 0; sig < NSIG; sig++) + if ((to_block >> sig) & 1) + { + pending_array[sig] = 0; + if ((old_handlers[sig] = signal (sig, blocked_handler)) != SIG_ERR) + blocked_set |= 1U << sig; + } + } + + if (to_unblock != 0) + { + sig_atomic_t received[NSIG]; + int sig; + + for (sig = 0; sig < NSIG; sig++) + if ((to_unblock >> sig) & 1) + { + if (signal (sig, old_handlers[sig]) != blocked_handler) + /* The application changed a signal handler while the signal + was blocked, bypassing our rpl_signal replacement. + We don't support this. */ + abort (); + received[sig] = pending_array[sig]; + blocked_set &= ~(1U << sig); + pending_array[sig] = 0; + } + else + received[sig] = 0; + + for (sig = 0; sig < NSIG; sig++) + if (received[sig]) + raise (sig); + } + } + return 0; +} + +/* Install the handler FUNC for signal SIG, and return the previous + handler. */ +handler_t +rpl_signal (int sig, handler_t handler) +{ + /* We must provide a wrapper, so that a user can query what handler + they installed even if that signal is currently blocked. */ + if (sig >= 0 && sig < NSIG && sig != SIGKILL && sig != SIGSTOP + && handler != SIG_ERR) + { + #ifdef SIGABRT_COMPAT + if (sig == SIGABRT_COMPAT) + sig = SIGABRT; + #endif + + if (blocked_set & (1U << sig)) + { + /* POSIX states that sigprocmask and signal are both + async-signal-safe. This is not true of our + implementation - there is a slight data race where an + asynchronous interrupt on signal A can occur after we + install blocked_handler but before we have updated + old_handlers for signal B, such that handler A can see + stale information if it calls signal(B). Oh well - + signal handlers really shouldn't try to manipulate the + installed handlers of unrelated signals. */ + handler_t result = old_handlers[sig]; + old_handlers[sig] = handler; + return result; + } + else + return signal (sig, handler); + } + else + { + errno = EINVAL; + return SIG_ERR; + } +} + +#if GNULIB_defined_SIGPIPE +/* Raise the signal SIGPIPE. */ +int +_gl_raise_SIGPIPE (void) +{ + if (blocked_set & (1U << SIGPIPE)) + pending_array[SIGPIPE] = 1; + else + { + handler_t handler = SIGPIPE_handler; + if (handler == SIG_DFL) + exit (128 + SIGPIPE); + else if (handler != SIG_IGN) + (*handler) (SIGPIPE); + } + return 0; +} +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/sigsegv.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/sigsegv.c new file mode 100644 index 00000000..45e1618c --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/sigsegv.c @@ -0,0 +1,1482 @@ +/* Page fault handling library. + Copyright (C) 1993-2024 Free Software Foundation, Inc. + Copyright (C) 2018 Nylon Chen + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 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 . */ + +/* Written by Bruno Haible and Nylon Chen. */ + +#include + +/* Specification. */ +#include "sigsegv.h" + +#include +#include /* declares perror */ +#include /* defines uintptr_t */ +#include +#include +#if HAVE_GETRLIMIT +# include /* declares struct rlimit */ +#endif + +#ifdef __OpenBSD__ +# include /* defines macro OpenBSD */ +#endif + + +/* Version number. */ +int libsigsegv_version = LIBSIGSEGV_VERSION; + + +/* ======================= Fault handler information ======================= */ + +/* Define: + + SIGSEGV_FAULT_HANDLER_ARGLIST + is the argument list for the actual fault handler. + + and if available (optional): + + SIGSEGV_FAULT_ADDRESS + is a macro for fetching the fault address. + + SIGSEGV_FAULT_CONTEXT + is a macro giving a pointer to the entire fault context (i.e. + the register set etc.). + + SIGSEGV_FAULT_STACKPOINTER + is a macro for fetching the stackpointer at the moment the fault + occurred. + */ + +#if defined __linux__ && !defined __ANDROID__ /* Linux */ + +# define SIGSEGV_FAULT_HANDLER_ARGLIST int sig, siginfo_t *sip, void *ucp +# define SIGSEGV_FAULT_ADDRESS sip->si_addr +# define SIGSEGV_FAULT_CONTEXT ((ucontext_t *) ucp) +# define SIGSEGV_FAULT_ADDRESS_FROM_SIGINFO + +# if defined __alpha__ + +/* See glibc/sysdeps/unix/sysv/linux/alpha/sys/ucontext.h + and the definition of GET_STACK in + glibc/sysdeps/unix/sysv/linux/alpha/sigcontextinfo.h. + Note that the 'mcontext_t' defined in + glibc/sysdeps/unix/sysv/linux/alpha/sys/ucontext.h + and the 'struct sigcontext' defined in + are actually the same. */ + +# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext.sc_regs[30] + +# elif defined __arm64__ /* 64-bit */ + +/* See glibc/sysdeps/unix/sysv/linux/aarch64/sys/ucontext.h. + Note that the 'mcontext_t' defined in + glibc/sysdeps/unix/sysv/linux/aarch64/sys/ucontext.h + and the 'struct sigcontext' defined in + are actually the same. */ + +# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext.sp + +# elif defined __arm__ || defined __armhf__ /* 32-bit */ + +/* See glibc/sysdeps/unix/sysv/linux/arm/sys/ucontext.h + and the definition of GET_STACK in + glibc/sysdeps/unix/sysv/linux/arm/sigcontextinfo.h. + Note that the 'mcontext_t' defined in + glibc/sysdeps/unix/sysv/linux/arm/sys/ucontext.h + and the 'struct sigcontext' defined in + are actually the same. */ + +# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext.arm_sp + +# elif defined __cris__ + +/* See glibc-ports/sysdeps/unix/sysv/linux/cris/sys/ucontext.h. + Note that the 'mcontext_t' defined in + glibc-ports/sysdeps/unix/sysv/linux/cris/sys/ucontext.h + and the 'struct sigcontext' defined in + are actually the same. */ + +# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext.usp + +# elif defined __hppa__ + +/* See glibc/sysdeps/unix/sysv/linux/hppa/sys/ucontext.h. + Note that the 'mcontext_t' defined in + glibc/sysdeps/unix/sysv/linux/hppa/sys/ucontext.h + and the 'struct sigcontext' defined in + are actually the same. */ + +# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext.sc_gr[30] + +# elif defined __x86_64__ /* 64 bit registers */ + +/* See glibc/sysdeps/unix/sysv/linux/x86/sys/ucontext.h + and the definition of GET_STACK in + glibc/sysdeps/unix/sysv/linux/x86_64/sigcontextinfo.h. + Note that the 'mcontext_t' defined in + glibc/sysdeps/unix/sysv/linux/x86/sys/ucontext.h + and the 'struct sigcontext' defined in + glibc/sysdeps/unix/sysv/linux/x86/bits/sigcontext.h + (see also ) + are effectively the same. */ + +# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext.gregs[REG_RSP] + +# elif defined __i386__ /* 32 bit registers */ + +/* See glibc/sysdeps/unix/sysv/linux/x86/sys/ucontext.h + and the definition of GET_STACK in + glibc/sysdeps/unix/sysv/linux/i386/sigcontextinfo.h. + Note that the 'mcontext_t' defined in + glibc/sysdeps/unix/sysv/linux/x86/sys/ucontext.h + and the 'struct sigcontext_ia32' defined in + are effectively the same. */ + +# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext.gregs[REG_ESP] + /* same value as ((ucontext_t *) ucp)->uc_mcontext.gregs[REG_UESP] */ + +# elif defined __ia64__ + +/* See glibc/sysdeps/unix/sysv/linux/ia64/sys/ucontext.h. + Note that the 'mcontext_t' defined in + glibc/sysdeps/unix/sysv/linux/ia64/sys/ucontext.h + and the 'struct sigcontext' defined in + glibc/sysdeps/unix/sysv/linux/ia64/bits/sigcontext.h + (see also ) + are actually the same. */ + +/* IA-64 has two stack pointers, one that grows down, called $r12, and one + that grows up, called $bsp/$bspstore. */ +# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext.sc_gr[12] + +/* It would be better to access $bspstore instead of $bsp but I don't know + where to find it in 'struct sigcontext'. Anyway, it doesn't matter + because $bsp and $bspstore never differ by more than ca. 1 KB. */ +# define SIGSEGV_FAULT_BSP_POINTER ((ucontext_t *) ucp)->uc_mcontext.sc_ar_bsp + +# elif defined __loongarch__ + +/* See . + Note that the 'mcontext_t' defined in + and the 'struct sigcontext' defined in + (see also ) are effectively the same. */ + +# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext.__gregs[3] + +# elif defined __m68k__ + +/* See glibc/sysdeps/unix/sysv/linux/m68k/sys/ucontext.h + and the definition of GET_STACK in + glibc/sysdeps/unix/sysv/linux/m68k/sigcontextinfo.h. + Note that the 'mcontext_t' defined in + glibc/sysdeps/unix/sysv/linux/m68k/sys/ucontext.h + and the 'struct sigcontext' defined in + are quite different types. */ + +# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext.gregs[R_SP] + +# elif defined __mips__ || defined __mipsn32__ || defined __mips64__ + +/* See glibc/sysdeps/unix/sysv/linux/mips/sys/ucontext.h + and the definition of GET_STACK in + glibc/sysdeps/unix/sysv/linux/mips/sigcontextinfo.h. + Note that the 'mcontext_t' defined in + glibc/sysdeps/unix/sysv/linux/mips/sys/ucontext.h + and the 'struct sigcontext' defined in + glibc/sysdeps/unix/sysv/linux/mips/bits/sigcontext.h + (see also ) + are effectively the same. */ + +# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext.gregs[29] + +# elif defined __nds32__ + +/* See glibc/sysdeps/unix/sysv/linux/nds32/sys/ucontext.h + and the definition of GET_STACK in + glibc/sysdeps/unix/sysv/linux/nds32/sigcontextinfo.h. + Both are found in part 08/11 + . */ + +# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext.nds32_sp + +# elif defined __powerpc__ || defined __powerpc64__ || defined __powerpc64_elfv2__ + +/* See glibc/sysdeps/unix/sysv/linux/powerpc/sys/ucontext.h + and the definition of GET_STACK in + glibc/sysdeps/unix/sysv/linux/powerpc/sigcontextinfo.h. + Note that the 'mcontext_t' defined in + glibc/sysdeps/unix/sysv/linux/powerpc/sys/ucontext.h, + the 'struct sigcontext' defined in , + and the 'struct pt_regs' defined in + are quite different types. */ + +# if defined __powerpc64__ || defined __powerpc64_elfv2__ /* 64-bit */ +# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext.gp_regs[1] +# else /* 32-bit */ +# if MUSL_LIBC +/* musl libc has a different structure of ucontext_t in + musl/arch/powerpc/bits/signal.h. */ +/* The glibc comments say: + "Different versions of the kernel have stored the registers on signal + delivery at different offsets from the ucontext struct. Programs should + thus use the uc_mcontext.uc_regs pointer to find where the registers are + actually stored." */ +# if 0 +# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext.gregs[1] +# else +# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_regs->gregs[1] +# endif +# else +/* Assume the structure of ucontext_t in + glibc/sysdeps/unix/sysv/linux/powerpc/sys/ucontext.h. */ +/* Because of the union, both definitions should be equivalent. */ +# if 0 +# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext.regs->gpr[1] +# else +# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext.uc_regs->gregs[1] +# endif +# endif +# endif + +# elif defined __riscv32__ || __riscv64__ + +/* See glibc/sysdeps/unix/sysv/linux/riscv/sys/ucontext.h + and the definition of GET_STACK in + glibc/sysdeps/unix/sysv/linux/riscv/sigcontextinfo.h. + Note that the 'mcontext_t' defined in + glibc/sysdeps/unix/sysv/linux/riscv/sys/ucontext.h + and the 'struct sigcontext' defined in + glibc/sysdeps/unix/sysv/linux/riscv/bits/sigcontext.h + start with the same block of 32 general-purpose registers. */ + +# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext.__gregs[REG_SP] + +# elif defined __s390__ || defined __s390x__ + +/* See glibc/sysdeps/unix/sysv/linux/s390/sys/ucontext.h + and the definition of GET_STACK in + glibc/sysdeps/unix/sysv/linux/s390/sigcontextinfo.h. + Note that the 'mcontext_t' defined in + glibc/sysdeps/unix/sysv/linux/s390/sys/ucontext.h + and the '_sigregs' type, indirect part of 'struct sigcontext', defined + in , are effectively the same. */ + +# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext.gregs[15] + +# elif defined __sh__ + +/* See glibc/sysdeps/unix/sysv/linux/sh/sys/ucontext.h + and the definition of GET_STACK in + glibc/sysdeps/unix/sysv/linux/sh/sigcontextinfo.h. + Note that the 'mcontext_t' defined in + glibc/sysdeps/unix/sysv/linux/sh/sys/ucontext.h + and the 'struct sigcontext' defined in + are effectively the same. */ + +# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext.gregs[15] + +# elif defined __sparc__ || defined __sparc64__ + +/* See glibc/sysdeps/unix/sysv/linux/sparc/sys/ucontext.h + and the definition of GET_STACK in + glibc/sysdeps/unix/sysv/linux/sparc/{sparc32,sparc64}/sigcontextinfo.h. + Note that the 'mcontext_t' defined in + glibc/sysdeps/unix/sysv/linux/sparc/sys/ucontext.h + and the 'struct sigcontext' defined in + glibc/sysdeps/unix/sysv/linux/sparc/bits/sigcontext.h + (see also ) + are quite different types. */ + +# if defined __sparc64__/* 64-bit */ +/* From linux-4.8.1/arch/sparc/kernel/signal_64.c, function setup_rt_frame, we + see that ucp is not an 'ucontext_t *' but rather a 'struct sigcontext *' + that happens to have the same value as sip (which is possible because a + 'struct sigcontext' starts with 128 bytes room for the siginfo_t). */ +# define SIGSEGV_FAULT_STACKPOINTER (((struct sigcontext *) ucp)->sigc_regs.u_regs[14] + 2047) +# else /* 32-bit */ +/* From linux-4.8.1/arch/sparc/kernel/signal_32.c, function setup_rt_frame, + and linux-4.8.1/arch/sparc/kernel/signal32.c, function setup_rt_frame32, we + see that ucp is a 'struct pt_regs *' or 'struct pt_regs32 *', respectively. + In userland, this is a 'struct sigcontext *'. */ +# define SIGSEGV_FAULT_STACKPOINTER ((struct sigcontext *) ucp)->si_regs.u_regs[14] +# endif + +/* The sip->si_addr field is correct for a normal fault, but unusable in case + of a stack overflow. What I observe (when running + tests/test-sigsegv-catch-stackoverflow1, with a printf right at the beginning + of sigsegv_handler) is that sip->si_addr is near 0: + - in 64-bit mode: sip->si_addr = 0x000000000000030F, and gdb shows me that + the fault occurs in an instruction 'stx %o3,[%fp+0x30f]' and %fp is 0. + In fact, all registers %l0..%l7 and %i0..%i7 are 0. + - in 32-bit mode: sip->si_addr = 0xFFFFFA64, and gdb shows me that + the fault occurs in an instruction 'st %g2,[%fp-1436]' and %fp is 0. + In fact, all registers %l0..%l7 and %i0..%i7 are 0. + Apparently when the stack overflow occurred, some trap has tried to move the + contents of the registers %l0..%l7 and %i0..%i7 (a "window" in SPARC + terminology) to the stack, did not succeed in doing this, replaced all these + register values with 0, and resumed execution at the fault location. This + time, due to %fp = 0, a different fault was triggered. Now it is impossible + to determine the real (previous) fault address because, even if know the + faulting instruction, the previous register values have been lost. */ +# define BOGUS_FAULT_ADDRESS_UPON_STACK_OVERFLOW + +# else + +/* When adding support for other CPUs here: */ + +/* For SIGSEGV_FAULT_HANDLER_ARGLIST, see the definition of SIGCONTEXT in + glibc/sysdeps/unix/sysv/linux//sigcontextinfo.h. */ + +/* For SIGSEGV_FAULT_STACKPOINTER, see the definition of GET_STACK in + glibc/sysdeps/unix/sysv/linux//sigcontextinfo.h. */ + +# endif + +#endif + +#if defined __ANDROID__ /* Android */ +/* A platform that supports the POSIX:2008 (XPG 7) way, without + 'struct sigcontext' nor 'ucontext_t'. */ + +# define SIGSEGV_FAULT_HANDLER_ARGLIST int sig, siginfo_t *sip, void *context +# define SIGSEGV_FAULT_ADDRESS sip->si_addr +# define SIGSEGV_FAULT_CONTEXT context +# define SIGSEGV_FAULT_ADDRESS_FROM_SIGINFO + +#endif + +#if defined __GNU__ /* Hurd */ + +# define SIGSEGV_FAULT_HANDLER_ARGLIST int sig, long code, struct sigcontext *scp +# define SIGSEGV_FAULT_ADDRESS (unsigned long) code +# define SIGSEGV_FAULT_CONTEXT scp + +# if defined __x86_64__ +/* 64 bit registers */ + +/* scp points to a 'struct sigcontext' (defined in + glibc/sysdeps/mach/hurd/x86_64/bits/sigcontext.h). + The registers, at the moment the signal occurred, get pushed on the kernel + stack through gnumach/x86_64/locore.S:alltraps. They are denoted by a + 'struct i386_saved_state' (defined in gnumach/i386/i386/thread.h). + Upon invocation of the Mach interface function thread_get_state + + (= __thread_get_state in glibc), defined in gnumach/kern/thread.c, + the function thread_getstatus, defined in gnumach/i386/i386/pcb.c, copies the + register values in a different arrangement into a 'struct i386_thread_state', + defined in gnumach/i386/include/mach/i386/thread_status.h. (Different + arrangement: trapno, err get dropped; different order of r8...r15; also rsp + gets set to 0.) + This 'struct i386_thread_state' is actually the 'basic' part of a + 'struct machine_thread_all_state', defined in + glibc/sysdeps/mach/x86/thread_state.h. + From there, the function _hurd_setup_sighandler, defined in + glibc/sysdeps/mach/hurd/x86/trampoline.c, + 1. sets rsp to the same value as ursp, + 2. copies the 'struct i386_thread_state' into the appropriate part of a + 'struct sigcontext', defined in + glibc/sysdeps/mach/hurd/x86_64/bits/sigcontext.h. */ +/* Both sc_rsp and sc_ursp have the same value. + It appears more reliable to use sc_ursp because sc_rsp is marked as + "not used". */ +# define SIGSEGV_FAULT_STACKPOINTER scp->sc_ursp + +# elif defined __i386__ +/* 32 bit registers */ + +/* scp points to a 'struct sigcontext' (defined in + glibc/sysdeps/mach/hurd/i386/bits/sigcontext.h). + The registers, at the moment the signal occurred, get pushed on the kernel + stack through gnumach/i386/i386/locore.S:alltraps. They are denoted by a + 'struct i386_saved_state' (defined in gnumach/i386/i386/thread.h). + Upon invocation of the Mach interface function thread_get_state + + (= __thread_get_state in glibc), defined in gnumach/kern/thread.c, + the function thread_getstatus, defined in gnumach/i386/i386/pcb.c, copies the + register values in a different arrangement into a 'struct i386_thread_state', + defined in gnumach/i386/include/mach/i386/thread_status.h. (Different + arrangement: trapno, err get dropped; also esp gets set to 0.) + This 'struct i386_thread_state' is actually the 'basic' part of a + 'struct machine_thread_all_state', defined in + glibc/sysdeps/mach/x86/thread_state.h. + From there, the function _hurd_setup_sighandler, defined in + glibc/sysdeps/mach/hurd/x86/trampoline.c, + 1. sets esp to the same value as uesp, + 2. copies the 'struct i386_thread_state' into the appropriate part of a + 'struct sigcontext', defined in + glibc/sysdeps/mach/hurd/i386/bits/sigcontext.h. */ +/* Both sc_esp and sc_uesp have the same value. + It appears more reliable to use sc_uesp because sc_esp is marked as + "not used". */ +# define SIGSEGV_FAULT_STACKPOINTER scp->sc_uesp + +# endif + +#endif + +#if defined __FreeBSD_kernel__ || defined __FreeBSD__ || defined __DragonFly__ /* GNU/kFreeBSD, FreeBSD */ + +# if defined __arm__ || defined __armhf__ || (defined __arm64__ || defined __aarch64__) + +# define SIGSEGV_FAULT_HANDLER_ARGLIST int sig, siginfo_t *sip, void *ucp +# define SIGSEGV_FAULT_ADDRESS sip->si_addr +# define SIGSEGV_FAULT_CONTEXT ((ucontext_t *) ucp) + +# if defined __arm64__ || defined __aarch64__ /* 64-bit */ + +/* See sys/arm64/include/ucontext.h. */ + +# if defined __CHERI_PURE_CAPABILITY__ +# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext.mc_capregs.cap_sp +# else +# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext.mc_gpregs.gp_sp +# endif + +# elif defined __arm__ || defined __armhf__ /* 32-bit */ + +/* See sys/arm/include/ucontext.h. */ + +# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext.__gregs[_REG_SP] + +# endif + +# else + +/* On FreeBSD 12, both of these approaches work. On FreeBSD derivatives, the + first one has more chances to work. */ +# if 1 +/* Use signal handlers without SA_SIGINFO. */ + +# define SIGSEGV_FAULT_HANDLER_ARGLIST int sig, int code, struct sigcontext *scp, void *addr +# define SIGSEGV_FAULT_ADDRESS addr +# define SIGSEGV_FAULT_CONTEXT scp + +/* See sys/x86/include/signal.h. */ + +# if defined __x86_64__ +/* 64 bit registers */ + +# define SIGSEGV_FAULT_STACKPOINTER scp->sc_rsp + +# elif defined __i386__ +/* 32 bit registers */ + +# define SIGSEGV_FAULT_STACKPOINTER scp->sc_esp + +# endif + +# else +/* Use signal handlers with SA_SIGINFO. */ + +# define SIGSEGV_FAULT_HANDLER_ARGLIST int sig, siginfo_t *sip, void *scp +# define SIGSEGV_FAULT_ADDRESS sip->si_addr +# define SIGSEGV_FAULT_CONTEXT ((struct sigcontext *) scp) +# define SIGSEGV_FAULT_ADDRESS_FROM_SIGINFO + +/* See sys/x86/include/signal.h. */ + +# if defined __x86_64__ +/* 64 bit registers */ + +# define SIGSEGV_FAULT_STACKPOINTER ((struct sigcontext *) scp)->sc_rsp + +# elif defined __i386__ +/* 32 bit registers */ + +# define SIGSEGV_FAULT_STACKPOINTER ((struct sigcontext *) scp)->sc_esp + +# endif + +# endif + +# endif + +#endif + +#if defined __NetBSD__ /* NetBSD */ + +# define SIGSEGV_FAULT_HANDLER_ARGLIST int sig, siginfo_t *sip, void *ucp +# define SIGSEGV_FAULT_ADDRESS sip->si_addr +# define SIGSEGV_FAULT_CONTEXT ((ucontext_t *) ucp) +# define SIGSEGV_FAULT_ADDRESS_FROM_SIGINFO + +/* _UC_MACHINE_SP is a platform independent macro. + Defined in , see + http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/$arch/include/mcontext.h + Supported on alpha, amd64, i386, ia64, m68k, mips, powerpc, sparc since + NetBSD 2.0. + On i386, _UC_MACHINE_SP is the same as ->uc_mcontext.__gregs[_REG_UESP], + and apparently the same value as ->uc_mcontext.__gregs[_REG_ESP]. */ +# ifdef _UC_MACHINE_SP +# define SIGSEGV_FAULT_STACKPOINTER _UC_MACHINE_SP ((ucontext_t *) ucp) +# endif + +#endif + +#if defined __OpenBSD__ /* OpenBSD */ + +# define SIGSEGV_FAULT_HANDLER_ARGLIST int sig, siginfo_t *sip, struct sigcontext *scp +# define SIGSEGV_FAULT_ADDRESS sip->si_addr +# define SIGSEGV_FAULT_CONTEXT scp +# define SIGSEGV_FAULT_ADDRESS_FROM_SIGINFO + +# if defined __alpha__ + +/* See the definition of 'struct sigcontext' in + openbsd-src/sys/arch/alpha/include/signal.h. */ + +# define SIGSEGV_FAULT_STACKPOINTER scp->sc_regs[30] + +# elif defined __arm__ || defined __armhf__ + +/* See the definition of 'struct sigcontext' in + openbsd-src/sys/arch/arm/include/signal.h. */ + +# define SIGSEGV_FAULT_STACKPOINTER scp->sc_usr_sp + +# elif defined __hppa__ || defined __hppa64__ + +/* See the definition of 'struct sigcontext' in + openbsd-src/sys/arch/hppa/include/signal.h + and + openbsd-src/sys/arch/hppa64/include/signal.h. */ + +# define SIGSEGV_FAULT_STACKPOINTER scp->sc_regs[30] + +# elif defined __x86_64__ +/* 64 bit registers */ + +/* See the definition of 'struct sigcontext' in + openbsd-src/sys/arch/amd64/include/signal.h. */ + +# define SIGSEGV_FAULT_STACKPOINTER scp->sc_rsp + +# elif defined __i386__ +/* 32 bit registers */ + +/* See the definition of 'struct sigcontext' in + openbsd-src/sys/arch/i386/include/signal.h. */ + +# define SIGSEGV_FAULT_STACKPOINTER scp->sc_esp + +# elif defined __m68k__ + +/* See the definition of 'struct sigcontext' in + openbsd-src/sys/arch/m68k/include/signal.h. */ + +# define SIGSEGV_FAULT_STACKPOINTER scp->sc_sp + +# elif defined __m88k__ + +/* See the definition of 'struct sigcontext' in + openbsd-src/sys/arch/m88k/include/signal.h + and the definition of 'struct reg' in + openbsd-src/sys/arch/m88k/include/reg.h. */ + +# if OpenBSD >= 201211 /* OpenBSD version >= 5.2 */ +# define SIGSEGV_FAULT_STACKPOINTER scp->sc_regs[31] +# else +# define SIGSEGV_FAULT_STACKPOINTER scp->sc_regs.r[31] +# endif + +# elif defined __mips__ || defined __mipsn32__ || defined __mips64__ + +/* See the definition of 'struct sigcontext' in + openbsd-src/sys/arch/mips64/include/signal.h. */ + +# define SIGSEGV_FAULT_STACKPOINTER scp->sc_regs[29] + +# elif defined __powerpc64__ + +/* See the definition of 'struct sigcontext' in + openbsd-src/sys/arch/powerpc64/include/signal.h. */ + +# define SIGSEGV_FAULT_STACKPOINTER scp->sc_sp + +# elif defined __powerpc__ + +/* See the definition of 'struct sigcontext' and 'struct trapframe' in + openbsd-src/sys/arch/powerpc/include/signal.h. */ + +# define SIGSEGV_FAULT_STACKPOINTER scp->sc_frame.fixreg[1] + +# elif defined __sh__ + +/* See the definition of 'struct sigcontext' in + openbsd-src/sys/arch/sh/include/signal.h + and the definition of 'struct reg' in + openbsd-src/sys/arch/sh/include/reg.h. */ + +# if OpenBSD >= 201211 /* OpenBSD version >= 5.2 */ +# define SIGSEGV_FAULT_STACKPOINTER scp->sc_reg[20-15] +# else +# define SIGSEGV_FAULT_STACKPOINTER scp->sc_reg.r_r15 +# endif + +# elif defined __sparc__ || defined __sparc64__ + +/* See the definition of 'struct sigcontext' in + openbsd-src/sys/arch/sparc/include/signal.h + and + openbsd-src/sys/arch/sparc64/include/signal.h. */ + +# define SIGSEGV_FAULT_STACKPOINTER scp->sc_sp + +# elif defined __vax__ + +/* See the definition of 'struct sigcontext' in + openbsd-src/sys/arch/vax/include/signal.h. */ + +# define SIGSEGV_FAULT_STACKPOINTER scp->sc_sp + +# endif + +#endif + +#if (defined __APPLE__ && defined __MACH__) /* macOS */ + +# define SIGSEGV_FAULT_HANDLER_ARGLIST int sig, siginfo_t *sip, void *ucp +# define SIGSEGV_FAULT_ADDRESS sip->si_addr +# define SIGSEGV_FAULT_CONTEXT ((ucontext_t *) ucp) +# define SIGSEGV_FAULT_ADDRESS_FROM_SIGINFO + +# if defined __x86_64__ + +/* See the definitions of + - 'ucontext_t' and 'struct __darwin_ucontext' in , + - 'struct __darwin_mcontext64' in , and + - 'struct __darwin_x86_thread_state64' in . */ +# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext->__ss.__rsp + +# elif defined __i386__ + +/* See the definitions of + - 'ucontext_t' and 'struct __darwin_ucontext' in , + - 'struct __darwin_mcontext32' in , and + - 'struct __darwin_i386_thread_state' in . */ +# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext->__ss.__esp + +# elif defined __arm64__ + +/* See the definitions of + - 'ucontext_t' and 'struct __darwin_ucontext' in , + - 'struct __darwin_mcontext64' in , and + - 'struct __darwin_arm_thread_state64' in . */ +# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext->__ss.__sp + +# elif defined __powerpc__ + +/* See the definitions of + - 'ucontext_t' and 'struct __darwin_ucontext' in , + - 'struct __darwin_mcontext' in , and + - 'struct __darwin_ppc_thread_state' in . */ +# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext->__ss.__r1 + +# endif + +#endif + +#if defined _AIX /* AIX */ + +# define SIGSEGV_FAULT_HANDLER_ARGLIST int sig, siginfo_t *sip, void *ucp +# define SIGSEGV_FAULT_ADDRESS sip->si_addr +# define SIGSEGV_FAULT_CONTEXT ((ucontext_t *) ucp) +# define SIGSEGV_FAULT_ADDRESS_FROM_SIGINFO + +# if defined __powerpc__ || defined __powerpc64__ +# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext.jmp_context.gpr[1] +# endif + +#endif + +#if defined __sgi /* IRIX */ + +# define SIGSEGV_FAULT_HANDLER_ARGLIST int sig, int code, struct sigcontext *scp +# define SIGSEGV_FAULT_ADDRESS (unsigned long) scp->sc_badvaddr +# define SIGSEGV_FAULT_CONTEXT scp + +# if defined __mips__ || defined __mipsn32__ || defined __mips64__ +# define SIGSEGV_FAULT_STACKPOINTER scp->sc_regs[29] +# endif + +#endif + +#if defined __sun /* Solaris */ + +# define SIGSEGV_FAULT_HANDLER_ARGLIST int sig, siginfo_t *sip, void *ucp +# define SIGSEGV_FAULT_ADDRESS sip->si_addr +# define SIGSEGV_FAULT_CONTEXT ((ucontext_t *) ucp) +# define SIGSEGV_FAULT_ADDRESS_FROM_SIGINFO + +# if defined __x86_64__ +/* 64 bit registers */ + +# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext.gregs[REG_RSP] + +# elif defined __i386__ +/* 32 bit registers */ + +# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext.gregs[ESP] + +# elif defined __sparc__ || defined __sparc64__ + +# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext.gregs[REG_O6] + +# if SOLARIS11 + +/* On Solaris 11.3/SPARC, both in 32-bit and 64-bit mode, when catching + stack overflow, the fault address is correct the first time, but is zero + or near zero the second time. + 'truss tests/test-sigsegv-catch-stackoverflow1' shows it: + + In 32-bit mode: + + Incurred fault #6, FLTBOUNDS %pc = 0x000116E8 + siginfo: SIGSEGV SEGV_MAPERR addr=0xFFB00000 + Received signal #11, SIGSEGV [caught] + siginfo: SIGSEGV SEGV_MAPERR addr=0xFFB00000 + then + Incurred fault #6, FLTBOUNDS %pc = 0x000116E8 + siginfo: SIGSEGV SEGV_MAPERR addr=0x00000008 + Received signal #11, SIGSEGV [caught] + siginfo: SIGSEGV SEGV_MAPERR addr=0x00000008 + + In 64-bit mode: + + Incurred fault #6, FLTBOUNDS %pc = 0x100001C58 + siginfo: SIGSEGV SEGV_MAPERR addr=0xFFFFFFFF7FF00000 + Received signal #11, SIGSEGV [caught] + siginfo: SIGSEGV SEGV_MAPERR addr=0xFFFFFFFF7FF00000 + then + Incurred fault #6, FLTBOUNDS %pc = 0x100001C58 + siginfo: SIGSEGV SEGV_MAPERR addr=0x00000000 + Received signal #11, SIGSEGV [caught] + siginfo: SIGSEGV SEGV_MAPERR addr=0x00000000 + */ +# define BOGUS_FAULT_ADDRESS_UPON_STACK_OVERFLOW + +# endif + +# endif + +#endif + +#if defined __CYGWIN__ /* Cygwin */ + +# define SIGSEGV_FAULT_HANDLER_ARGLIST int sig, siginfo_t *sip, void *ucp +# define SIGSEGV_FAULT_ADDRESS sip->si_addr +# define SIGSEGV_FAULT_CONTEXT ((ucontext_t *) ucp) +# define SIGSEGV_FAULT_ADDRESS_FROM_SIGINFO + +/* See the definition of 'ucontext_t' in and + of 'struct __mcontext' in . */ +# if defined __x86_64__ +/* 64 bit registers */ +# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext.rsp +# elif defined __i386__ +/* 32 bit registers */ +# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext.esp +# endif + +#endif + +#if defined __HAIKU__ /* Haiku */ + +# define SIGSEGV_FAULT_HANDLER_ARGLIST int sig, siginfo_t *sip, void *ucp +# define SIGSEGV_FAULT_ADDRESS sip->si_addr +# define SIGSEGV_FAULT_CONTEXT ((ucontext_t *) ucp) +# define SIGSEGV_FAULT_ADDRESS_FROM_SIGINFO + +# if defined __x86_64__ +/* 64 bit registers */ + +/* See the definition of 'ucontext_t' in and + of 'struct vregs' in . */ + +# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext.rsp + +# elif defined __i386__ +/* 32 bit registers */ + +/* See the definition of 'ucontext_t' in and + of 'struct vregs' in . */ + +# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext.esp + +# endif + +#endif + +/* ========================================================================== */ + +/* List of signals that are sent when an invalid virtual memory address + is accessed, or when the stack overflows. */ +#if defined __GNU__ \ + || defined __FreeBSD_kernel__ || defined __FreeBSD__ || defined __DragonFly__ \ + || defined __NetBSD__ || defined __OpenBSD__ \ + || (defined __APPLE__ && defined __MACH__) +# if defined __CHERI__ +# define SIGSEGV_FOR_ALL_SIGNALS(var,body) \ + { int var; \ + var = SIGSEGV; { body } \ + var = SIGBUS; { body } \ + var = SIGPROT; { body } \ + } +# else +# define SIGSEGV_FOR_ALL_SIGNALS(var,body) \ + { int var; \ + var = SIGSEGV; { body } \ + var = SIGBUS; { body } \ + } +# endif +#else +# define SIGSEGV_FOR_ALL_SIGNALS(var,body) \ + { int var; var = SIGSEGV; { body } } +#endif + +/* ========================================================================== */ + +/* Determine the virtual memory area of a given address. */ +#include "stackvma.h" + +/* ========================================================================== */ + +/* On the average Unix platform, we define + + HAVE_SIGSEGV_RECOVERY + if there is a fault-*.h include file which defines + SIGSEGV_FAULT_HANDLER_ARGLIST and SIGSEGV_FAULT_ADDRESS. + + HAVE_STACK_OVERFLOW_RECOVERY + if HAVE_SIGALTSTACK is set and + at least two of the following are true: + A) There is a fault-*.h include file which defines + SIGSEGV_FAULT_HANDLER_ARGLIST and SIGSEGV_FAULT_ADDRESS. + B) There is a fault-*.h include file which defines + SIGSEGV_FAULT_HANDLER_ARGLIST and SIGSEGV_FAULT_STACKPOINTER. + C) There is a stackvma-*.c, other than stackvma-none.c, which + defines sigsegv_get_vma. + + Why? Obviously, to catch stack overflow, we need an alternate signal + stack; this requires kernel support. But we also need to distinguish + (with a reasonable confidence) a stack overflow from a regular SIGSEGV. + If we have A) and B), we use the + Heuristic AB: If the fault address is near the stack pointer, it's a + stack overflow. + If we have A) and C), we use the + Heuristic AC: If the fault address is near and beyond the bottom of + the stack's virtual memory area, it's a stack overflow. + If we have B) and C), we use the + Heuristic BC: If the stack pointer is near the bottom of the stack's + virtual memory area, it's a stack overflow. + This heuristic comes in two flavours: On OSes which let the stack's + VMA grow continuously, we determine the bottom by use of getrlimit(). + On OSes which preallocate the stack's VMA with its maximum size + (like BeOS), we use the stack's VMA directly. + */ + +#if HAVE_SIGSEGV_RECOVERY \ + && !(defined SIGSEGV_FAULT_HANDLER_ARGLIST && defined SIGSEGV_FAULT_ADDRESS) +# error "You need to define SIGSEGV_FAULT_HANDLER_ARGLIST and SIGSEGV_FAULT_ADDRESS before you can define HAVE_SIGSEGV_RECOVERY." +#endif +#if !HAVE_SIGSEGV_RECOVERY \ + && (defined SIGSEGV_FAULT_HANDLER_ARGLIST && defined SIGSEGV_FAULT_ADDRESS) \ + && !(defined __FreeBSD__ && (defined __sparc__ || defined __sparc64__)) +# if __GNUC__ || (__clang_major__ >= 4) +# warning "You can define HAVE_SIGSEGV_RECOVERY on this platform." +# else +# error "You can define HAVE_SIGSEGV_RECOVERY on this platform." +# endif +#endif + +#if HAVE_STACK_OVERFLOW_RECOVERY \ + && !(defined SIGSEGV_FAULT_ADDRESS + defined SIGSEGV_FAULT_STACKPOINTER + HAVE_STACKVMA >= 2) +# error "You need to define two of SIGSEGV_FAULT_ADDRESS, SIGSEGV_FAULT_STACKPOINTER, HAVE_STACKVMA, before you can define HAVE_STACK_OVERFLOW_RECOVERY." +#endif +#if !HAVE_STACK_OVERFLOW_RECOVERY \ + && (defined SIGSEGV_FAULT_ADDRESS + defined SIGSEGV_FAULT_STACKPOINTER + HAVE_STACKVMA >= 2) \ + && !(defined __FreeBSD__ && (defined __sparc__ || defined __sparc64__)) \ + && !(defined __NetBSD__ && (defined __sparc__ || defined __sparc64__)) +# if __GNUC__ || (__clang_major__ >= 4) +# warning "You can define HAVE_STACK_OVERFLOW_RECOVERY on this platform." +# else +# error "You can define HAVE_STACK_OVERFLOW_RECOVERY on this platform." +# endif +#endif + +/* ========================================================================== */ + +#if HAVE_STACK_OVERFLOW_RECOVERY + +/* ======= Leaving a signal handler executing on the alternate stack ======= */ + +/* Platform dependent: + Leaving a signal handler executing on the alternate stack. */ +static void sigsegv_reset_onstack_flag (void); + +/* -------------------------- leave-sigaltstack.c -------------------------- */ + +# if defined __GNU__ \ + || defined __FreeBSD_kernel__ || defined __FreeBSD__ || defined __DragonFly__ \ + || defined __NetBSD__ || defined __OpenBSD__ + +static void +sigsegv_reset_onstack_flag (void) +{ + stack_t ss; + + if (sigaltstack (NULL, &ss) >= 0) + { + ss.ss_flags &= ~SS_ONSTACK; + sigaltstack (&ss, NULL); + } +} + +/* --------------------------- leave-setcontext.c --------------------------- */ + +# elif defined __sgi || defined __sun /* IRIX, Solaris */ + +# include + +static void +sigsegv_reset_onstack_flag (void) +{ + ucontext_t uc; + + if (getcontext (&uc) >= 0) + /* getcontext returns twice. We are interested in the returned context + only the first time, i.e. when the SS_ONSTACK bit is set. */ + if (uc.uc_stack.ss_flags & SS_ONSTACK) + { + uc.uc_stack.ss_flags &= ~SS_ONSTACK; + /* Note that setcontext() does not refill uc. Therefore if + setcontext() keeps SS_ONSTACK set in the kernel, either + setcontext() will return -1 or getcontext() will return a + second time, with the SS_ONSTACK bit being cleared. */ + setcontext (&uc); + } +} + +/* ------------------------------ leave-nop.c ------------------------------ */ + +# else + +static void +sigsegv_reset_onstack_flag (void) +{ + /* Nothing to do. sigaltstack() simply looks at the stack pointer, + therefore SS_ONSTACK is not sticky. */ +} + +# endif + +/* ========================================================================== */ + +# if HAVE_STACKVMA + +/* Address of the last byte belonging to the stack vma. */ +static uintptr_t stack_top = 0; + +/* Needs to be called once only. */ +static void +remember_stack_top (void *some_variable_on_stack) +{ + struct vma_struct vma; + + if (sigsegv_get_vma ((uintptr_t) some_variable_on_stack, &vma) >= 0) + stack_top = vma.end - 1; +} + +# endif /* HAVE_STACKVMA */ + +static stackoverflow_handler_t stk_user_handler = (stackoverflow_handler_t)NULL; +static uintptr_t stk_extra_stack; +static size_t stk_extra_stack_size; + +#endif /* HAVE_STACK_OVERFLOW_RECOVERY */ + +#if HAVE_SIGSEGV_RECOVERY + +/* User's SIGSEGV handler. */ +static sigsegv_handler_t user_handler = (sigsegv_handler_t)NULL; + +#endif /* HAVE_SIGSEGV_RECOVERY */ + + +/* Our SIGSEGV handler, with OS dependent argument list. */ + +#if HAVE_SIGSEGV_RECOVERY + +static void +sigsegv_handler (SIGSEGV_FAULT_HANDLER_ARGLIST) +{ + void *address = (void *) (SIGSEGV_FAULT_ADDRESS); + +# if HAVE_STACK_OVERFLOW_RECOVERY +# if !(HAVE_STACKVMA || defined SIGSEGV_FAULT_STACKPOINTER) +#error "Insufficient heuristics for detecting a stack overflow. Either define CFG_STACKVMA and HAVE_STACKVMA correctly, or define SIGSEGV_FAULT_STACKPOINTER correctly, or undefine HAVE_STACK_OVERFLOW_RECOVERY!" +# endif + + /* Call user's handler. */ + if (user_handler && (*user_handler) (address, 0)) + { + /* Handler successful. */ + } + else + { + /* Handler declined responsibility. */ + + /* Did the user install a stack overflow handler? */ + if (stk_user_handler) + { + /* See whether it was a stack overflow. If so, longjump away. */ +# ifdef SIGSEGV_FAULT_STACKPOINTER + uintptr_t old_sp = (uintptr_t) (SIGSEGV_FAULT_STACKPOINTER); +# ifdef __ia64 + uintptr_t old_bsp = (uintptr_t) (SIGSEGV_FAULT_BSP_POINTER); +# endif +# endif + +# if HAVE_STACKVMA + /* Were we able to determine the stack top? */ + if (stack_top) + { + /* Determine stack bounds. */ + int saved_errno; + struct vma_struct vma; + int ret; + + saved_errno = errno; + ret = sigsegv_get_vma (stack_top, &vma); + errno = saved_errno; + if (ret >= 0) + { +# ifndef BOGUS_FAULT_ADDRESS_UPON_STACK_OVERFLOW + /* Heuristic AC: If the fault_address is nearer to the stack + segment's [start,end] than to the previous segment, we + consider it a stack overflow. + In the case of IA-64, we know that the previous segment + is the up-growing bsp segment, and either of the two + stacks can overflow. */ + uintptr_t addr = (uintptr_t) address; + +# ifdef __ia64 + if (addr >= vma.prev_end && addr <= vma.end - 1) +# else +# if STACK_DIRECTION < 0 + if (addr >= vma.start + ? (addr <= vma.end - 1) + : vma.is_near_this (addr, &vma)) +# else + if (addr <= vma.end - 1 + ? (addr >= vma.start) + : vma.is_near_this (addr, &vma)) +# endif +# endif + { +# else /* BOGUS_FAULT_ADDRESS_UPON_STACK_OVERFLOW */ +# if HAVE_GETRLIMIT && defined RLIMIT_STACK + /* Heuristic BC: If the stack size has reached its maximal size, + and old_sp is near the low end, we consider it a stack + overflow. */ + struct rlimit rl; + + saved_errno = errno; + ret = getrlimit (RLIMIT_STACK, &rl); + errno = saved_errno; + if (ret >= 0) + { + uintptr_t current_stack_size = vma.end - vma.start; + uintptr_t max_stack_size = rl.rlim_cur; + if (current_stack_size <= max_stack_size + 4096 + && max_stack_size <= current_stack_size + 4096 +# else + { + if (1 +# endif +# ifdef SIGSEGV_FAULT_STACKPOINTER + /* Heuristic BC: If we know old_sp, and it is neither + near the low end, nor in the alternate stack, then + it's probably not a stack overflow. */ + && ((old_sp >= stk_extra_stack + && old_sp <= stk_extra_stack + stk_extra_stack_size) +# if STACK_DIRECTION < 0 + || (old_sp <= vma.start + 4096 + && vma.start <= old_sp + 4096)) +# else + || (old_sp <= vma.end + 4096 + && vma.end <= old_sp + 4096)) +# endif +# endif + ) +# endif /* BOGUS_FAULT_ADDRESS_UPON_STACK_OVERFLOW */ +# else /* !HAVE_STACKVMA */ + /* Heuristic AB: If the fault address is near the stack pointer, + it's a stack overflow. */ + uintptr_t addr = (uintptr_t) address; + + if ((addr <= old_sp + 4096 && old_sp <= addr + 4096) +# ifdef __ia64 + || (addr <= old_bsp + 4096 && old_bsp <= addr + 4096) +# endif + ) + { + { + { +# endif /* !HAVE_STACKVMA */ + { +# ifdef SIGSEGV_FAULT_STACKPOINTER + int emergency = + (old_sp >= stk_extra_stack + && old_sp <= stk_extra_stack + stk_extra_stack_size); + stackoverflow_context_t context = (SIGSEGV_FAULT_CONTEXT); +# else + int emergency = 0; + stackoverflow_context_t context = (void *) 0; +# endif + /* Call user's handler. */ + (*stk_user_handler) (emergency, context); + } + } + } + } + } +# endif /* HAVE_STACK_OVERFLOW_RECOVERY */ + + if (user_handler && (*user_handler) (address, 1)) + { + /* Handler successful. */ + } + else + { + /* Handler declined responsibility for real. */ + + /* Remove ourselves and dump core. */ + SIGSEGV_FOR_ALL_SIGNALS (signo, signal (signo, SIG_DFL);) + } + +# if HAVE_STACK_OVERFLOW_RECOVERY + } +# endif /* HAVE_STACK_OVERFLOW_RECOVERY */ +} + +#elif HAVE_STACK_OVERFLOW_RECOVERY + +static void +# ifdef SIGSEGV_FAULT_STACKPOINTER +sigsegv_handler (SIGSEGV_FAULT_HANDLER_ARGLIST) +# else +sigsegv_handler (int sig) +# endif +{ +# if !((HAVE_GETRLIMIT && defined RLIMIT_STACK) || defined SIGSEGV_FAULT_STACKPOINTER) +# error "Insufficient heuristics for detecting a stack overflow. Either define SIGSEGV_FAULT_STACKPOINTER correctly, or undefine HAVE_STACK_OVERFLOW_RECOVERY!" +# endif + + /* Did the user install a handler? */ + if (stk_user_handler) + { + /* See whether it was a stack overflow. If so, longjump away. */ +# ifdef SIGSEGV_FAULT_STACKPOINTER + uintptr_t old_sp = (uintptr_t) (SIGSEGV_FAULT_STACKPOINTER); +# endif + + /* Were we able to determine the stack top? */ + if (stack_top) + { + /* Determine stack bounds. */ + int saved_errno; + struct vma_struct vma; + int ret; + + saved_errno = errno; + ret = sigsegv_get_vma (stack_top, &vma); + errno = saved_errno; + if (ret >= 0) + { +# if HAVE_GETRLIMIT && defined RLIMIT_STACK + /* Heuristic BC: If the stack size has reached its maximal size, + and old_sp is near the low end, we consider it a stack + overflow. */ + struct rlimit rl; + + saved_errno = errno; + ret = getrlimit (RLIMIT_STACK, &rl); + errno = saved_errno; + if (ret >= 0) + { + uintptr_t current_stack_size = vma.end - vma.start; + uintptr_t max_stack_size = rl.rlim_cur; + if (current_stack_size <= max_stack_size + 4096 + && max_stack_size <= current_stack_size + 4096 +# else + { + if (1 +# endif +# ifdef SIGSEGV_FAULT_STACKPOINTER + /* Heuristic BC: If we know old_sp, and it is neither + near the low end, nor in the alternate stack, then + it's probably not a stack overflow. */ + && ((old_sp >= stk_extra_stack + && old_sp <= stk_extra_stack + stk_extra_stack_size) +# if STACK_DIRECTION < 0 + || (old_sp <= vma.start + 4096 + && vma.start <= old_sp + 4096)) +# else + || (old_sp <= vma.end + 4096 + && vma.end <= old_sp + 4096)) +# endif +# endif + ) + { +# ifdef SIGSEGV_FAULT_STACKPOINTER + int emergency = + (old_sp >= stk_extra_stack + && old_sp <= stk_extra_stack + stk_extra_stack_size); + stackoverflow_context_t context = (SIGSEGV_FAULT_CONTEXT); +# else + int emergency = 0; + stackoverflow_context_t context = (void *) 0; +# endif + /* Call user's handler. */ + (*stk_user_handler)(emergency,context); + } + } + } + } + } + + /* Remove ourselves and dump core. */ + SIGSEGV_FOR_ALL_SIGNALS (signo, signal (signo, SIG_DFL);) +} + +#endif + + +#if HAVE_SIGSEGV_RECOVERY || HAVE_STACK_OVERFLOW_RECOVERY + +static void +install_for (int sig) +{ + struct sigaction action; + +# ifdef SIGSEGV_FAULT_ADDRESS_FROM_SIGINFO + action.sa_sigaction = (void (*) (int, siginfo_t *, void *)) &sigsegv_handler; +# else + action.sa_handler = (void (*) (int)) &sigsegv_handler; +# endif + /* Block most signals while SIGSEGV is being handled. */ + /* Signals SIGKILL, SIGSTOP cannot be blocked. */ + /* Signals SIGCONT, SIGTSTP, SIGTTIN, SIGTTOU are not blocked because + dealing with these signals seems dangerous. */ + /* Signals SIGILL, SIGABRT, SIGFPE, SIGSEGV, SIGTRAP, SIGIOT, SIGEMT, SIGBUS, + SIGSYS, SIGSTKFLT are not blocked because these are synchronous signals, + which may require immediate intervention, otherwise the process may + starve. */ + sigemptyset (&action.sa_mask); +# ifdef SIGHUP + sigaddset (&action.sa_mask,SIGHUP); +# endif +# ifdef SIGINT + sigaddset (&action.sa_mask,SIGINT); +# endif +# ifdef SIGQUIT + sigaddset (&action.sa_mask,SIGQUIT); +# endif +# ifdef SIGPIPE + sigaddset (&action.sa_mask,SIGPIPE); +# endif +# ifdef SIGALRM + sigaddset (&action.sa_mask,SIGALRM); +# endif +# ifdef SIGTERM + sigaddset (&action.sa_mask,SIGTERM); +# endif +# ifdef SIGUSR1 + sigaddset (&action.sa_mask,SIGUSR1); +# endif +# ifdef SIGUSR2 + sigaddset (&action.sa_mask,SIGUSR2); +# endif +# ifdef SIGCHLD + sigaddset (&action.sa_mask,SIGCHLD); +# endif +# ifdef SIGCLD + sigaddset (&action.sa_mask,SIGCLD); +# endif +# ifdef SIGURG + sigaddset (&action.sa_mask,SIGURG); +# endif +# ifdef SIGIO + sigaddset (&action.sa_mask,SIGIO); +# endif +# ifdef SIGPOLL + sigaddset (&action.sa_mask,SIGPOLL); +# endif +# ifdef SIGXCPU + sigaddset (&action.sa_mask,SIGXCPU); +# endif +# ifdef SIGXFSZ + sigaddset (&action.sa_mask,SIGXFSZ); +# endif +# ifdef SIGVTALRM + sigaddset (&action.sa_mask,SIGVTALRM); +# endif +# ifdef SIGPROF + sigaddset (&action.sa_mask,SIGPROF); +# endif +# ifdef SIGPWR + sigaddset (&action.sa_mask,SIGPWR); +# endif +# ifdef SIGLOST + sigaddset (&action.sa_mask,SIGLOST); +# endif +# ifdef SIGWINCH + sigaddset (&action.sa_mask,SIGWINCH); +# endif + /* Note that sigaction() implicitly adds sig itself to action.sa_mask. */ + /* Ask the OS to provide a structure siginfo_t to the handler. */ +# ifdef SIGSEGV_FAULT_ADDRESS_FROM_SIGINFO + action.sa_flags = SA_SIGINFO; +# else + action.sa_flags = 0; +# endif +# if HAVE_STACK_OVERFLOW_RECOVERY && HAVE_SIGALTSTACK /* not BeOS */ + /* Work around Linux 2.2.5 bug: If SA_ONSTACK is specified but sigaltstack() + has not been called, the kernel will busy loop, eating CPU time. So + avoid setting SA_ONSTACK until the user has requested stack overflow + handling. */ + if (stk_user_handler) + action.sa_flags |= SA_ONSTACK; +# endif + sigaction (sig, &action, (struct sigaction *) NULL); +} + +#endif /* HAVE_SIGSEGV_RECOVERY || HAVE_STACK_OVERFLOW_RECOVERY */ + +int +sigsegv_install_handler (sigsegv_handler_t handler) +{ +#if HAVE_SIGSEGV_RECOVERY + user_handler = handler; + + SIGSEGV_FOR_ALL_SIGNALS (sig, install_for (sig);) + + return 0; +#else + return -1; +#endif +} + +void +sigsegv_deinstall_handler (void) +{ +#if HAVE_SIGSEGV_RECOVERY + user_handler = (sigsegv_handler_t)NULL; + +# if HAVE_STACK_OVERFLOW_RECOVERY + if (!stk_user_handler) +# endif + { + SIGSEGV_FOR_ALL_SIGNALS (sig, signal (sig, SIG_DFL);) + } +#endif +} + +int +sigsegv_leave_handler (void (*continuation) (void*, void*, void*), + void* cont_arg1, void* cont_arg2, void* cont_arg3) +{ +#if HAVE_STACK_OVERFLOW_RECOVERY + /* + * Reset the system's knowledge that we are executing on the alternate + * stack. If we didn't do that, siglongjmp would be needed instead of + * longjmp to leave the signal handler. + */ + sigsegv_reset_onstack_flag (); +#endif + (*continuation) (cont_arg1, cont_arg2, cont_arg3); + return 1; +} + +int +stackoverflow_install_handler (stackoverflow_handler_t handler, + void *extra_stack, size_t extra_stack_size) +{ +#if HAVE_STACK_OVERFLOW_RECOVERY +# if HAVE_STACKVMA + if (!stack_top) + { + int dummy; + remember_stack_top (&dummy); + if (!stack_top) + return -1; + } +# endif + + stk_user_handler = handler; + stk_extra_stack = (uintptr_t) extra_stack; + stk_extra_stack_size = extra_stack_size; + { + stack_t ss; +# if SIGALTSTACK_SS_REVERSED + ss.ss_sp = (char *) extra_stack + extra_stack_size - sizeof (void *); + ss.ss_size = extra_stack_size - sizeof (void *); +# else + ss.ss_sp = extra_stack; + ss.ss_size = extra_stack_size; +# endif + ss.ss_flags = 0; /* no SS_DISABLE */ + if (sigaltstack (&ss, (stack_t*)0) < 0) + return -1; + } + + /* Install the signal handlers with SA_ONSTACK. */ + SIGSEGV_FOR_ALL_SIGNALS (sig, install_for (sig);) + return 0; +#else + return -1; +#endif +} + +void +stackoverflow_deinstall_handler (void) +{ +#if HAVE_STACK_OVERFLOW_RECOVERY + stk_user_handler = (stackoverflow_handler_t) NULL; + +# if HAVE_SIGSEGV_RECOVERY + if (user_handler) + { + /* Reinstall the signal handlers without SA_ONSTACK, to avoid Linux + bug. */ + SIGSEGV_FOR_ALL_SIGNALS (sig, install_for (sig);) + } + else +# endif + { + SIGSEGV_FOR_ALL_SIGNALS (sig, signal (sig, SIG_DFL);) + } + + { + stack_t ss; + ss.ss_flags = SS_DISABLE; + if (sigaltstack (&ss, (stack_t *) 0) < 0) + perror ("gnulib sigsegv (stackoverflow_deinstall_handler)"); + } +#endif +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/sigsegv.in.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/sigsegv.in.h new file mode 100644 index 00000000..bf604725 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/sigsegv.in.h @@ -0,0 +1,244 @@ +/* Page fault handling library. + Copyright (C) 1998-2024 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 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 . */ + +/* Written by Bruno Haible. */ + +#ifndef _SIGSEGV_H +#define _SIGSEGV_H + +/* Get size_t. */ +#include + +/* Define the fault context structure. */ +#if (defined __linux__ && !defined __ANDROID__) \ + || (defined __FreeBSD__ && (defined __arm__ || defined __armhf__ || defined __arm64__)) \ + || defined __NetBSD__ \ + || defined _AIX || defined __sun \ + || defined __CYGWIN__ +/* Linux, FreeBSD, NetBSD, AIX, Solaris, Cygwin */ +# include +#elif (defined __APPLE__ && defined __MACH__) +/* macOS */ +# include +#elif defined __HAIKU__ +/* Haiku */ +# include +#endif + +/* Correct the value of SIGSTKSZ on some systems. + glibc >= 2.34: When _GNU_SOURCE is defined, SIGSTKSZ is no longer a + compile-time constant. But most programs need a simple constant. + AIX 64-bit: original value 4096 is too small. + HP-UX: original value 8192 is too small. + Solaris 11/x86_64: original value 8192 is too small. */ +#include +#if __GLIBC__ >= 2 +# undef SIGSTKSZ +# if defined __ia64__ +# define SIGSTKSZ 262144 +# else +# define SIGSTKSZ 65536 +# endif +#endif +#if defined _AIX && defined _ARCH_PPC64 +# undef SIGSTKSZ +# define SIGSTKSZ 8192 +#endif +#if defined __hpux || (defined __sun && (defined __x86_64__ || defined __amd64__)) +# undef SIGSTKSZ +# define SIGSTKSZ 16384 +#endif + +/* HAVE_SIGSEGV_RECOVERY + is defined if the system supports catching SIGSEGV. */ +#if defined __linux__ || defined __ANDROID__ || defined __GNU__ \ + || defined __FreeBSD_kernel__ || (defined __FreeBSD__ && !(defined __sparc__ || defined __sparc64__)) || defined __DragonFly__ \ + || defined __NetBSD__ \ + || defined __OpenBSD__ \ + || (defined __APPLE__ && defined __MACH__) \ + || defined _AIX || defined __sgi || defined __sun \ + || defined __CYGWIN__ || defined __HAIKU__ +/* Linux, Hurd, GNU/kFreeBSD, FreeBSD, NetBSD, OpenBSD, macOS, AIX, IRIX, Solaris, Cygwin, Haiku */ +# define HAVE_SIGSEGV_RECOVERY 1 +#endif + +/* HAVE_STACK_OVERFLOW_RECOVERY + is defined if stack overflow can be caught. */ +#if defined __linux__ || defined __ANDROID__ || defined __GNU__ \ + || defined __FreeBSD_kernel__ || (defined __FreeBSD__ && !(defined __sparc__ || defined __sparc64__)) || defined __DragonFly__ \ + || (defined __NetBSD__ && !(defined __sparc__ || defined __sparc64__)) \ + || defined __OpenBSD__ \ + || (defined __APPLE__ && defined __MACH__) \ + || defined _AIX || defined __sgi || defined __sun \ + || defined __CYGWIN__ || defined __HAIKU__ +/* Linux, Hurd, GNU/kFreeBSD, FreeBSD, NetBSD, OpenBSD, macOS, AIX, IRIX, Solaris, Cygwin, Haiku */ +# define HAVE_STACK_OVERFLOW_RECOVERY 1 +#endif + + +#ifdef __cplusplus +extern "C" { +#endif + +#define LIBSIGSEGV_VERSION 0x020D /* version number: (major<<8) + minor */ +extern int libsigsegv_version; /* Likewise */ + +/* -------------------------------------------------------------------------- */ + +#if 1 /* really only HAVE_SIGSEGV_RECOVERY */ + +/* + * The mask of bits that are set to zero in a fault address that gets passed + * to a global SIGSEGV handler. + * On some platforms, the precise fault address is not known, only the memory + * page into which the fault address falls. This is apparently allowed by POSIX: + * + * says: "For some implementations, the value of si_addr may be inaccurate." + * In this case, the returned fault address is rounded down to a multiple of + * getpagesize() = sysconf(_SC_PAGESIZE). + * On such platforms, we define SIGSEGV_FAULT_ADDRESS_ALIGNMENT to be an upper + * bound for getpagesize() (and, like getpagesize(), also a power of 2). + * On the platforms where the returned fault address is the precise one, we + * define SIGSEGV_FAULT_ADDRESS_ALIGNMENT to 1. + */ +# if defined __NetBSD__ && (defined __sparc__ || defined __sparc64__) + /* getpagesize () is 0x1000 or 0x2000, depending on hardware. */ +# define SIGSEGV_FAULT_ADDRESS_ALIGNMENT 0x2000UL +# elif defined __linux__ && (defined __s390__ || defined __s390x__) + /* getpagesize () is 0x1000. */ +# define SIGSEGV_FAULT_ADDRESS_ALIGNMENT 0x1000UL +# else +# define SIGSEGV_FAULT_ADDRESS_ALIGNMENT 1UL +# endif + +/* + * The type of a global SIGSEGV handler. + * The fault address, with the bits (SIGSEGV_FAULT_ADDRESS_ALIGNMENT - 1) + * cleared, is passed as argument. + * The access type (read access or write access) is not passed; your handler + * has to know itself how to distinguish these two cases. + * The second argument is 0, meaning it could also be a stack overflow, or 1, + * meaning the handler should seriously try to fix the fault. + * The return value should be nonzero if the handler has done its job + * and no other handler should be called, or 0 if the handler declines + * responsibility for the given address. + * + * The handler is run at a moment when nothing about the global state of the + * program is known. Therefore it cannot use facilities that manipulate global + * variables or locks. In particular, it cannot use malloc(); use mmap() + * instead. It cannot use fopen(); use open() instead. Etc. All global + * variables that are accessed by the handler should be marked 'volatile'. + */ +typedef int (*sigsegv_handler_t) (void* fault_address, int serious); + +/* + * Installs a global SIGSEGV handler. + * This should be called once only, and it ignores any previously installed + * SIGSEGV handler. + * Returns 0 on success, or -1 if the system doesn't support catching SIGSEGV. + */ +extern int sigsegv_install_handler (sigsegv_handler_t handler); + +/* + * Deinstalls the global SIGSEGV handler. + * This goes back to the state where no SIGSEGV handler is installed. + */ +extern void sigsegv_deinstall_handler (void); + +/* + * Prepares leaving a SIGSEGV handler (through longjmp or similar means). + * Control is transferred by calling CONTINUATION with CONT_ARG1, CONT_ARG2, + * CONT_ARG3 as arguments. + * CONTINUATION must not return. + * The sigsegv_leave_handler function may return if called from a SIGSEGV + * handler; its return value should be used as the handler's return value. + * The sigsegv_leave_handler function does not return if called from a + * stack overflow handler. + */ +extern int sigsegv_leave_handler (void (*continuation) (void*, void*, void*), void* cont_arg1, void* cont_arg2, void* cont_arg3); + +#endif /* HAVE_SIGSEGV_RECOVERY */ + +#if 1 /* really only HAVE_STACK_OVERFLOW_RECOVERY */ + +/* + * The type of a context passed to a stack overflow handler. + * This type is system dependent; on some platforms it is an 'ucontext_t *', + * on some platforms it is a 'struct sigcontext *', on others merely an + * opaque 'void *'. + */ +# if (defined __linux__ && !defined __ANDROID__) \ + || (defined __FreeBSD__ && (defined __arm__ || defined __armhf__ || defined __arm64__)) \ + || defined __NetBSD__ \ + || (defined __APPLE__ && defined __MACH__) \ + || defined _AIX || defined __sun \ + || defined __CYGWIN__ || defined __HAIKU__ +typedef ucontext_t *stackoverflow_context_t; +# elif defined __GNU__ \ + || defined __FreeBSD_kernel__ || (defined __FreeBSD__ && !(defined __sparc__ || defined __sparc64__)) || defined __DragonFly__ \ + || defined __OpenBSD__ || defined __sgi +typedef struct sigcontext *stackoverflow_context_t; +# else +typedef void *stackoverflow_context_t; +# endif + +/* + * The type of a stack overflow handler. + * Such a handler should perform a longjmp call in order to reduce the amount + * of stack needed. It must not return. + * The emergency argument is 0 when the stack could be repared, or 1 if the + * application should better save its state and exit now. + * + * The handler is run at a moment when nothing about the global state of the + * program is known. Therefore it cannot use facilities that manipulate global + * variables or locks. In particular, it cannot use malloc(); use mmap() + * instead. It cannot use fopen(); use open() instead. Etc. All global + * variables that are accessed by the handler should be marked 'volatile'. + */ +typedef void (*stackoverflow_handler_t) (int emergency, stackoverflow_context_t scp); + +/* + * Installs a stack overflow handler. + * The extra_stack argument is a pointer to a pre-allocated area used as a + * stack for executing the handler. It typically comes from a static variable + * or from heap-allocated memory; placing it on the main stack may fail on + * some operating systems. + * Its size, passed in extra_stack_size, should be sufficiently large. The + * following code determines an appropriate size: + * #include + * #ifndef SIGSTKSZ / * glibc defines SIGSTKSZ for this purpose * / + * # define SIGSTKSZ 16384 / * on most platforms, 16 KB are sufficient * / + * #endif + * Returns 0 on success, or -1 if the system doesn't support catching stack + * overflow. + */ +extern int stackoverflow_install_handler (stackoverflow_handler_t handler, + void* extra_stack, size_t extra_stack_size); + +/* + * Deinstalls the stack overflow handler. + */ +extern void stackoverflow_deinstall_handler (void); + +#endif /* HAVE_STACK_OVERFLOW_RECOVERY */ + +/* -------------------------------------------------------------------------- */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SIGSEGV_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stackvma.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stackvma.c new file mode 100644 index 00000000..e93f9395 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stackvma.c @@ -0,0 +1,2381 @@ +/* Determine the virtual memory area of a given address. + Copyright (C) 2002-2024 Free Software Foundation, Inc. + Copyright (C) 2003-2006 Paolo Bonzini + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 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 . */ + +/* Written by Bruno Haible and Paolo Bonzini. */ + +#include + +/* On Solaris in 32-bit mode, when gnulib module 'largefile' is in use, + prevent a compilation error + "Cannot use procfs in the large file compilation environment" + while also preventing from not defining off_t. + On Android, when targeting Android 4.4 or older with a GCC toolchain, + prevent a compilation error + "error: call to 'mmap' declared with attribute error: mmap is not + available with _FILE_OFFSET_BITS=64 when using GCC until android-21. + Either raise your minSdkVersion, disable _FILE_OFFSET_BITS=64, or + switch to Clang." + The files that we access in this compilation unit are less than 2 GB + large. */ +#if defined __sun && !defined _LP64 && _FILE_OFFSET_BITS == 64 +# undef _FILE_OFFSET_BITS +# define _FILE_OFFSET_BITS 32 +#endif +#ifdef __ANDROID__ +# undef _FILE_OFFSET_BITS +#endif + +/* Specification. */ +#include "stackvma.h" + +#include +#include + +/* =========================== stackvma-simple.c =========================== */ + +#if defined __linux__ || defined __ANDROID__ \ + || defined __FreeBSD_kernel__ || defined __FreeBSD__ || defined __DragonFly__ \ + || defined __NetBSD__ \ + || (defined __APPLE__ && defined __MACH__) \ + || defined _AIX || defined __sgi || defined __sun \ + || defined __CYGWIN__ || defined __HAIKU__ + +/* This file contains the proximity test function for the simple cases, where + the OS has an API for enumerating the mapped ranges of virtual memory. */ + +# if STACK_DIRECTION < 0 + +/* Info about the gap between this VMA and the previous one. + addr must be < vma->start. */ +static int +simple_is_near_this (uintptr_t addr, struct vma_struct *vma) +{ + return (vma->start - addr <= (vma->start - vma->prev_end) / 2); +} + +# endif +# if STACK_DIRECTION > 0 + +/* Info about the gap between this VMA and the next one. + addr must be > vma->end - 1. */ +static int +simple_is_near_this (uintptr_t addr, struct vma_struct *vma) +{ + return (addr - vma->end < (vma->next_start - vma->end) / 2); +} + +# endif + +#endif + +/* =========================== stackvma-rofile.c =========================== */ +/* Buffered read-only streams. */ + +#if defined __linux__ || defined __ANDROID__ \ + || defined __FreeBSD_kernel__ || defined __FreeBSD__ || defined __DragonFly__ \ + || defined __NetBSD__ \ + || defined __CYGWIN__ + +# include /* errno, EINTR */ +# include /* open, O_RDONLY */ +# include /* size_t */ +# include /* getpagesize, lseek, read, close */ +# include +# include /* mmap, munmap */ + +# if defined __linux__ || defined __ANDROID__ +# include /* PATH_MAX */ +# endif + +/* Buffered read-only streams. + We cannot use here, because fopen() calls malloc(), and a malloc() + call may have been interrupted. + Also, we cannot use multiple read() calls, because if the buffer size is + smaller than the file's contents: + - On NetBSD, the second read() call would return 0, thus making the file + appear truncated. + - On DragonFly BSD, the first read() call would fail with errno = EFBIG. + - On all platforms, if some other thread is doing memory allocations or + deallocations between two read() calls, there is a high risk that the + result of these two read() calls don't fit together, and as a + consequence we will parse garbage and either omit some VMAs or return + VMAs with nonsensical addresses. + So use mmap(), and ignore the resulting VMA. + The stack-allocated buffer cannot be too large, because this can be called + when we are in the context of an alternate stack of just SIGSTKSZ bytes. */ + +# if defined __linux__ || defined __ANDROID__ + /* On Linux, if the file does not entirely fit into the buffer, the read() + function stops before the line that would come out truncated. The + maximum size of such a line is 73 + PATH_MAX bytes. To be sure that we + have read everything, we must verify that at least that many bytes are + left when read() returned. */ +# define MIN_LEFTOVER (73 + PATH_MAX) +# else +# define MIN_LEFTOVER 1 +# endif + +# if MIN_LEFTOVER < 1024 +# define STACK_ALLOCATED_BUFFER_SIZE 1024 +# else + /* There is no point in using a stack-allocated buffer if it is too small + anyway. */ +# define STACK_ALLOCATED_BUFFER_SIZE 1 +# endif + +struct rofile + { + size_t position; + size_t filled; + int eof_seen; + /* These fields deal with allocation of the buffer. */ + char *buffer; + char *auxmap; + size_t auxmap_length; + uintptr_t auxmap_start; + uintptr_t auxmap_end; + char stack_allocated_buffer[STACK_ALLOCATED_BUFFER_SIZE]; + }; + +/* Open a read-only file stream. */ +static int +rof_open (struct rofile *rof, const char *filename) +{ + int fd; + uintptr_t pagesize; + size_t size; + + fd = open (filename, O_RDONLY); + if (fd < 0) + return -1; + rof->position = 0; + rof->eof_seen = 0; + /* Try the static buffer first. */ + pagesize = 0; + rof->buffer = rof->stack_allocated_buffer; + size = sizeof (rof->stack_allocated_buffer); + rof->auxmap = NULL; + rof->auxmap_start = 0; + rof->auxmap_end = 0; + for (;;) + { + /* Attempt to read the contents in a single system call. */ + if (size > MIN_LEFTOVER) + { + int n = read (fd, rof->buffer, size); + if (n < 0 && errno == EINTR) + goto retry; +# if defined __DragonFly__ + if (!(n < 0 && errno == EFBIG)) +# endif + { + if (n <= 0) + /* Empty file. */ + goto fail1; + if (n + MIN_LEFTOVER <= size) + { + /* The buffer was sufficiently large. */ + rof->filled = n; +# if defined __linux__ || defined __ANDROID__ + /* On Linux, the read() call may stop even if the buffer was + large enough. We need the equivalent of full_read(). */ + for (;;) + { + n = read (fd, rof->buffer + rof->filled, size - rof->filled); + if (n < 0 && errno == EINTR) + goto retry; + if (n < 0) + /* Some error. */ + goto fail1; + if (n + MIN_LEFTOVER > size - rof->filled) + /* Allocate a larger buffer. */ + break; + if (n == 0) + { + /* Reached the end of file. */ + close (fd); + return 0; + } + rof->filled += n; + } +# else + close (fd); + return 0; +# endif + } + } + } + /* Allocate a larger buffer. */ + if (pagesize == 0) + { + pagesize = getpagesize (); + size = pagesize; + while (size <= MIN_LEFTOVER) + size = 2 * size; + } + else + { + size = 2 * size; + if (size == 0) + /* Wraparound. */ + goto fail1; + if (rof->auxmap != NULL) + munmap (rof->auxmap, rof->auxmap_length); + } + rof->auxmap = (void *) mmap ((void *) 0, size, PROT_READ | PROT_WRITE, + MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); + if (rof->auxmap == (void *) -1) + { + close (fd); + return -1; + } + rof->auxmap_length = size; + rof->auxmap_start = (uintptr_t) rof->auxmap; + rof->auxmap_end = rof->auxmap_start + size; + rof->buffer = (char *) rof->auxmap; + retry: + /* Restart. */ + if (lseek (fd, 0, SEEK_SET) < 0) + { + close (fd); + fd = open (filename, O_RDONLY); + if (fd < 0) + goto fail2; + } + } + fail1: + close (fd); + fail2: + if (rof->auxmap != NULL) + munmap (rof->auxmap, rof->auxmap_length); + return -1; +} + +/* Return the next byte from a read-only file stream without consuming it, + or -1 at EOF. */ +static int +rof_peekchar (struct rofile *rof) +{ + if (rof->position == rof->filled) + { + rof->eof_seen = 1; + return -1; + } + return (unsigned char) rof->buffer[rof->position]; +} + +/* Return the next byte from a read-only file stream, or -1 at EOF. */ +static int +rof_getchar (struct rofile *rof) +{ + int c = rof_peekchar (rof); + if (c >= 0) + rof->position++; + return c; +} + +/* Parse an unsigned hexadecimal number from a read-only file stream. */ +static int +rof_scanf_lx (struct rofile *rof, uintptr_t *valuep) +{ + uintptr_t value = 0; + unsigned int numdigits = 0; + for (;;) + { + int c = rof_peekchar (rof); + if (c >= '0' && c <= '9') + value = (value << 4) + (c - '0'); + else if (c >= 'A' && c <= 'F') + value = (value << 4) + (c - 'A' + 10); + else if (c >= 'a' && c <= 'f') + value = (value << 4) + (c - 'a' + 10); + else + break; + rof_getchar (rof); + numdigits++; + } + if (numdigits == 0) + return -1; + *valuep = value; + return 0; +} + +/* Close a read-only file stream. */ +static void +rof_close (struct rofile *rof) +{ + if (rof->auxmap != NULL) + munmap (rof->auxmap, rof->auxmap_length); +} + +#endif + +/* ========================== stackvma-vma-iter.c ========================== */ +/* Iterate through the virtual memory areas of the current process, + by reading from the /proc file system. */ + +/* This code is a simplified copy (no handling of protection flags) of the + code in gnulib's lib/vma-iter.c. */ + +#if defined __linux__ || defined __ANDROID__ \ + || defined __FreeBSD_kernel__ || defined __FreeBSD__ || defined __DragonFly__ \ + || defined __NetBSD__ \ + || defined __CYGWIN__ + +/* Forward declarations. */ +struct callback_locals; +static int callback (struct callback_locals *locals, uintptr_t start, uintptr_t end); + +# if defined __linux__ || defined __ANDROID__ || (defined __FreeBSD_kernel__ && !defined __FreeBSD__) || defined __CYGWIN__ +/* GNU/kFreeBSD mounts /proc as linprocfs, which looks like a Linux /proc + file system. */ + +static int +vma_iterate_proc (struct callback_locals *locals) +{ + struct rofile rof; + + /* Open the current process' maps file. It describes one VMA per line. */ + if (rof_open (&rof, "/proc/self/maps") >= 0) + { + uintptr_t auxmap_start = rof.auxmap_start; + uintptr_t auxmap_end = rof.auxmap_end; + + for (;;) + { + uintptr_t start, end; + int c; + + /* Parse one line. First start and end. */ + if (!(rof_scanf_lx (&rof, &start) >= 0 + && rof_getchar (&rof) == '-' + && rof_scanf_lx (&rof, &end) >= 0)) + break; + while (c = rof_getchar (&rof), c != -1 && c != '\n') + ; + + if (start <= auxmap_start && auxmap_end - 1 <= end - 1) + { + /* Consider [start,end-1] \ [auxmap_start,auxmap_end-1] + = [start,auxmap_start-1] u [auxmap_end,end-1]. */ + if (start < auxmap_start) + if (callback (locals, start, auxmap_start)) + break; + if (auxmap_end - 1 < end - 1) + if (callback (locals, auxmap_end, end)) + break; + } + else + { + if (callback (locals, start, end)) + break; + } + } + rof_close (&rof); + return 0; + } + + return -1; +} + +# elif defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__ + +static int +vma_iterate_proc (struct callback_locals *locals) +{ + struct rofile rof; + + /* Open the current process' maps file. It describes one VMA per line. + On FreeBSD: + Cf. + On NetBSD, there are two such files: + - /proc/curproc/map in near-FreeBSD syntax, + - /proc/curproc/maps in Linux syntax. + Cf. */ + if (rof_open (&rof, "/proc/curproc/map") >= 0) + { + uintptr_t auxmap_start = rof.auxmap_start; + uintptr_t auxmap_end = rof.auxmap_end; + + for (;;) + { + uintptr_t start, end; + int c; + + /* Parse one line. First start. */ + if (!(rof_getchar (&rof) == '0' + && rof_getchar (&rof) == 'x' + && rof_scanf_lx (&rof, &start) >= 0)) + break; + while (c = rof_peekchar (&rof), c == ' ' || c == '\t') + rof_getchar (&rof); + /* Then end. */ + if (!(rof_getchar (&rof) == '0' + && rof_getchar (&rof) == 'x' + && rof_scanf_lx (&rof, &end) >= 0)) + break; + while (c = rof_getchar (&rof), c != -1 && c != '\n') + ; + + if (start <= auxmap_start && auxmap_end - 1 <= end - 1) + { + /* Consider [start,end-1] \ [auxmap_start,auxmap_end-1] + = [start,auxmap_start-1] u [auxmap_end,end-1]. */ + if (start < auxmap_start) + if (callback (locals, start, auxmap_start)) + break; + if (auxmap_end - 1 < end - 1) + if (callback (locals, auxmap_end, end)) + break; + } + else + { + if (callback (locals, start, end)) + break; + } + } + rof_close (&rof); + return 0; + } + + return -1; +} + +# endif + +# if (defined __FreeBSD_kernel__ || defined __FreeBSD__) && defined KERN_PROC_VMMAP /* FreeBSD >= 7.1 */ + +# include /* struct kinfo_vmentry */ +# include /* sysctl */ + +static int +vma_iterate_bsd (struct callback_locals *locals) +{ + /* Documentation: https://www.freebsd.org/cgi/man.cgi?sysctl(3) */ + int info_path[] = { CTL_KERN, KERN_PROC, KERN_PROC_VMMAP, getpid () }; + size_t len; + size_t pagesize; + size_t memneed; + void *auxmap; + unsigned long auxmap_start; + unsigned long auxmap_end; + char *mem; + char *p; + char *p_end; + + len = 0; + if (sysctl (info_path, 4, NULL, &len, NULL, 0) < 0) + return -1; + /* Allow for small variations over time. In a multithreaded program + new VMAs can be allocated at any moment. */ + len = 2 * len + 200; + /* Allocate memneed bytes of memory. + We cannot use alloca here, because not much stack space is guaranteed. + We also cannot use malloc here, because a malloc() call may call mmap() + and thus pre-allocate available memory. + So use mmap(), and ignore the resulting VMA. */ + pagesize = getpagesize (); + memneed = len; + memneed = ((memneed - 1) / pagesize + 1) * pagesize; + auxmap = (void *) mmap ((void *) 0, memneed, PROT_READ | PROT_WRITE, + MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); + if (auxmap == (void *) -1) + return -1; + auxmap_start = (unsigned long) auxmap; + auxmap_end = auxmap_start + memneed; + mem = (char *) auxmap; + if (sysctl (info_path, 4, mem, &len, NULL, 0) < 0) + { + munmap (auxmap, memneed); + return -1; + } + p = mem; + p_end = mem + len; + while (p < p_end) + { + struct kinfo_vmentry *kve = (struct kinfo_vmentry *) p; + unsigned long start = kve->kve_start; + unsigned long end = kve->kve_end; + if (start <= auxmap_start && auxmap_end - 1 <= end - 1) + { + /* Consider [start,end-1] \ [auxmap_start,auxmap_end-1] + = [start,auxmap_start-1] u [auxmap_end,end-1]. */ + if (start < auxmap_start) + if (callback (locals, start, auxmap_start)) + break; + if (auxmap_end - 1 < end - 1) + if (callback (locals, auxmap_end, end)) + break; + } + else + { + if (callback (locals, start, end)) + break; + } + p += kve->kve_structsize; + } + munmap (auxmap, memneed); + return 0; +} + +# else + +# define vma_iterate_bsd(locals) (-1) + +# endif + + +/* Iterate over the virtual memory areas of the current process. + If such iteration is supported, the callback is called once for every + virtual memory area, in ascending order, with the following arguments: + - LOCALS is the same argument as passed to vma_iterate. + - START is the address of the first byte in the area, page-aligned. + - END is the address of the last byte in the area plus 1, page-aligned. + Note that it may be 0 for the last area in the address space. + If the callback returns 0, the iteration continues. If it returns 1, + the iteration terminates prematurely. + This function may open file descriptors, but does not call malloc(). + Return 0 if all went well, or -1 in case of error. */ +static int +vma_iterate (struct callback_locals *locals) +{ +# if defined __FreeBSD__ + /* On FreeBSD with procfs (but not GNU/kFreeBSD, which uses linprocfs), the + function vma_iterate_proc does not return the virtual memory areas that + were created by anonymous mmap. See + + So use vma_iterate_proc only as a fallback. */ + int retval = vma_iterate_bsd (locals); + if (retval == 0) + return 0; + + return vma_iterate_proc (locals); +# else + /* On the other platforms, try the /proc approach first, and the sysctl() + as a fallback. */ + int retval = vma_iterate_proc (locals); + if (retval == 0) + return 0; + + return vma_iterate_bsd (locals); +# endif +} + +#endif + +/* =========================== stackvma-mincore.c =========================== */ + +/* mincore() is a system call that allows to inquire the status of a + range of pages of virtual memory. In particular, it allows to inquire + whether a page is mapped at all (except on Mac OS X, where mincore + returns 0 even for unmapped addresses). + As of 2006, mincore() is supported by: possible bits: + - Linux, since Linux 2.4 and glibc 2.2, 1 + - Solaris, since Solaris 9, 1 + - MacOS X, since MacOS X 10.3 (at least), 1 + - FreeBSD, since FreeBSD 6.0, MINCORE_{INCORE,REFERENCED,MODIFIED} + - NetBSD, since NetBSD 3.0 (at least), 1 + - OpenBSD, since OpenBSD 2.6 (at least), 1 + - AIX, since AIX 5.3, 1 + As of 2019, also on + - Hurd. + However, while the API allows to easily determine the bounds of mapped + virtual memory, it does not make it easy to find the bounds of _unmapped_ + virtual memory ranges. We try to work around this, but it may still be + slow. */ + +#if defined __linux__ || defined __ANDROID__ \ + || defined __FreeBSD_kernel__ || defined __FreeBSD__ || defined __DragonFly__ \ + || defined __NetBSD__ /* || defined __OpenBSD__ */ \ + /* || (defined __APPLE__ && defined __MACH__) */ \ + || defined _AIX || defined __sun + +# include /* getpagesize, mincore */ +# include +# include /* mincore */ + +/* The AIX declaration of mincore() uses 'caddr_t', whereas the other platforms + use 'void *'. */ +# ifdef _AIX +typedef caddr_t MINCORE_ADDR_T; +# else +typedef void* MINCORE_ADDR_T; +# endif + +/* The glibc and musl declaration of mincore() uses 'unsigned char *', whereas + the BSD declaration uses 'char *'. */ +# if __GLIBC__ >= 2 || defined __linux__ || defined __ANDROID__ +typedef unsigned char pageinfo_t; +# else +typedef char pageinfo_t; +# endif + +/* Cache for getpagesize(). */ +static uintptr_t pagesize; + +/* Initialize pagesize. */ +static void +init_pagesize (void) +{ + pagesize = getpagesize (); +} + +/* Test whether the page starting at ADDR is among the address range. + ADDR must be a multiple of pagesize. */ +static int +is_mapped (uintptr_t addr) +{ + pageinfo_t vec[1]; + return mincore ((MINCORE_ADDR_T) addr, pagesize, vec) >= 0; +} + +/* Assuming that the page starting at ADDR is among the address range, + return the start of its virtual memory range. + ADDR must be a multiple of pagesize. */ +static uintptr_t +mapped_range_start (uintptr_t addr) +{ + /* Use a moderately sized VEC here, small enough that it fits on the stack + (without requiring malloc). */ + pageinfo_t vec[1024]; + uintptr_t stepsize = sizeof (vec); + + for (;;) + { + uintptr_t max_remaining; + + if (addr == 0) + return addr; + + max_remaining = addr / pagesize; + if (stepsize > max_remaining) + stepsize = max_remaining; + if (mincore ((MINCORE_ADDR_T) (addr - stepsize * pagesize), + stepsize * pagesize, vec) < 0) + /* Time to search in smaller steps. */ + break; + /* The entire range exists. Continue searching in large steps. */ + addr -= stepsize * pagesize; + } + for (;;) + { + uintptr_t halfstepsize1; + uintptr_t halfstepsize2; + + if (stepsize == 1) + return addr; + + /* Here we know that less than stepsize pages exist starting at addr. */ + halfstepsize1 = (stepsize + 1) / 2; + halfstepsize2 = stepsize / 2; + /* halfstepsize1 + halfstepsize2 = stepsize. */ + + if (mincore ((MINCORE_ADDR_T) (addr - halfstepsize1 * pagesize), + halfstepsize1 * pagesize, vec) < 0) + stepsize = halfstepsize1; + else + { + addr -= halfstepsize1 * pagesize; + stepsize = halfstepsize2; + } + } +} + +/* Assuming that the page starting at ADDR is among the address range, + return the end of its virtual memory range + 1. + ADDR must be a multiple of pagesize. */ +static uintptr_t +mapped_range_end (uintptr_t addr) +{ + /* Use a moderately sized VEC here, small enough that it fits on the stack + (without requiring malloc). */ + pageinfo_t vec[1024]; + uintptr_t stepsize = sizeof (vec); + + addr += pagesize; + for (;;) + { + uintptr_t max_remaining; + + if (addr == 0) /* wrapped around? */ + return addr; + + max_remaining = (- addr) / pagesize; + if (stepsize > max_remaining) + stepsize = max_remaining; + if (mincore ((MINCORE_ADDR_T) addr, stepsize * pagesize, vec) < 0) + /* Time to search in smaller steps. */ + break; + /* The entire range exists. Continue searching in large steps. */ + addr += stepsize * pagesize; + } + for (;;) + { + uintptr_t halfstepsize1; + uintptr_t halfstepsize2; + + if (stepsize == 1) + return addr; + + /* Here we know that less than stepsize pages exist starting at addr. */ + halfstepsize1 = (stepsize + 1) / 2; + halfstepsize2 = stepsize / 2; + /* halfstepsize1 + halfstepsize2 = stepsize. */ + + if (mincore ((MINCORE_ADDR_T) addr, halfstepsize1 * pagesize, vec) < 0) + stepsize = halfstepsize1; + else + { + addr += halfstepsize1 * pagesize; + stepsize = halfstepsize2; + } + } +} + +/* Determine whether an address range [ADDR1..ADDR2] is completely unmapped. + ADDR1 must be <= ADDR2. */ +static int +is_unmapped (uintptr_t addr1, uintptr_t addr2) +{ + uintptr_t count; + uintptr_t stepsize; + + /* Round addr1 down. */ + addr1 = (addr1 / pagesize) * pagesize; + /* Round addr2 up and turn it into an exclusive bound. */ + addr2 = ((addr2 / pagesize) + 1) * pagesize; + + /* This is slow: mincore() does not provide a way to determine the bounds + of the gaps directly. So we have to use mincore() on individual pages + over and over again. Only after we've verified that all pages are + unmapped, we know that the range is completely unmapped. + If we were to traverse the pages from bottom to top or from top to bottom, + it would be slow even in the average case. To speed up the search, we + exploit the fact that mapped memory ranges are larger than one page on + average, therefore we have good chances of hitting a mapped area if we + traverse only every second, or only fourth page, etc. This doesn't + decrease the worst-case runtime, only the average runtime. */ + count = (addr2 - addr1) / pagesize; + /* We have to test is_mapped (addr1 + i * pagesize) for 0 <= i < count. */ + for (stepsize = 1; stepsize < count; ) + stepsize = 2 * stepsize; + for (;;) + { + uintptr_t addr_stepsize; + uintptr_t i; + uintptr_t addr; + + stepsize = stepsize / 2; + if (stepsize == 0) + break; + addr_stepsize = stepsize * pagesize; + for (i = stepsize, addr = addr1 + addr_stepsize; + i < count; + i += 2 * stepsize, addr += 2 * addr_stepsize) + /* Here addr = addr1 + i * pagesize. */ + if (is_mapped (addr)) + return 0; + } + return 1; +} + +# if STACK_DIRECTION < 0 + +/* Info about the gap between this VMA and the previous one. + addr must be < vma->start. */ +static int +mincore_is_near_this (uintptr_t addr, struct vma_struct *vma) +{ + /* vma->start - addr <= (vma->start - vma->prev_end) / 2 + is mathematically equivalent to + vma->prev_end <= 2 * addr - vma->start + <==> is_unmapped (2 * addr - vma->start, vma->start - 1). + But be careful about overflow: if 2 * addr - vma->start is negative, + we consider a tiny "guard page" mapping [0, 0] to be present around + NULL; it intersects the range (2 * addr - vma->start, vma->start - 1), + therefore return false. */ + uintptr_t testaddr = addr - (vma->start - addr); + if (testaddr > addr) /* overflow? */ + return 0; + /* Here testaddr <= addr < vma->start. */ + return is_unmapped (testaddr, vma->start - 1); +} + +# endif +# if STACK_DIRECTION > 0 + +/* Info about the gap between this VMA and the next one. + addr must be > vma->end - 1. */ +static int +mincore_is_near_this (uintptr_t addr, struct vma_struct *vma) +{ + /* addr - vma->end < (vma->next_start - vma->end) / 2 + is mathematically equivalent to + vma->next_start > 2 * addr - vma->end + <==> is_unmapped (vma->end, 2 * addr - vma->end). + But be careful about overflow: if 2 * addr - vma->end is > ~0UL, + we consider a tiny "guard page" mapping [0, 0] to be present around + NULL; it intersects the range (vma->end, 2 * addr - vma->end), + therefore return false. */ + uintptr_t testaddr = addr + (addr - vma->end); + if (testaddr < addr) /* overflow? */ + return 0; + /* Here vma->end - 1 < addr <= testaddr. */ + return is_unmapped (vma->end, testaddr); +} + +# endif + +static int +mincore_get_vma (uintptr_t address, struct vma_struct *vma) +{ + if (pagesize == 0) + init_pagesize (); + address = (address / pagesize) * pagesize; + vma->start = mapped_range_start (address); + vma->end = mapped_range_end (address); + vma->is_near_this = mincore_is_near_this; + return 0; +} + +#endif + +/* ========================================================================== */ + +/* ---------------------------- stackvma-linux.c ---------------------------- */ + +#if defined __linux__ || defined __ANDROID__ /* Linux */ + +struct callback_locals +{ + uintptr_t address; + struct vma_struct *vma; +# if STACK_DIRECTION < 0 + uintptr_t prev; +# else + int stop_at_next_vma; +# endif + int retval; +}; + +static int +callback (struct callback_locals *locals, uintptr_t start, uintptr_t end) +{ +# if STACK_DIRECTION < 0 + if (locals->address >= start && locals->address <= end - 1) + { + locals->vma->start = start; + locals->vma->end = end; + locals->vma->prev_end = locals->prev; + locals->retval = 0; + return 1; + } + locals->prev = end; +# else + if (locals->stop_at_next_vma) + { + locals->vma->next_start = start; + locals->stop_at_next_vma = 0; + return 1; + } + if (locals->address >= start && locals->address <= end - 1) + { + locals->vma->start = start; + locals->vma->end = end; + locals->retval = 0; + locals->stop_at_next_vma = 1; + return 0; + } +# endif + return 0; +} + +int +sigsegv_get_vma (uintptr_t address, struct vma_struct *vma) +{ + struct callback_locals locals; + locals.address = address; + locals.vma = vma; +# if STACK_DIRECTION < 0 + locals.prev = 0; +# else + locals.stop_at_next_vma = 0; +# endif + locals.retval = -1; + + vma_iterate (&locals); + if (locals.retval == 0) + { +# if !(STACK_DIRECTION < 0) + if (locals.stop_at_next_vma) + vma->next_start = 0; +# endif + vma->is_near_this = simple_is_near_this; + return 0; + } + + return mincore_get_vma (address, vma); +} + +/* --------------------------- stackvma-freebsd.c --------------------------- */ + +#elif defined __FreeBSD_kernel__ || defined __FreeBSD__ || defined __DragonFly__ /* GNU/kFreeBSD, FreeBSD */ + +struct callback_locals +{ + uintptr_t address; + struct vma_struct *vma; + /* The stack appears as multiple adjacent segments, therefore we + merge adjacent segments. */ + uintptr_t curr_start, curr_end; +# if STACK_DIRECTION < 0 + uintptr_t prev_end; +# else + int stop_at_next_vma; +# endif + int retval; +}; + +static int +callback (struct callback_locals *locals, uintptr_t start, uintptr_t end) +{ + if (start == locals->curr_end) + { + /* Merge adjacent segments. */ + locals->curr_end = end; + return 0; + } +# if STACK_DIRECTION < 0 + if (locals->curr_start < locals->curr_end + && locals->address >= locals->curr_start + && locals->address <= locals->curr_end - 1) + { + locals->vma->start = locals->curr_start; + locals->vma->end = locals->curr_end; + locals->vma->prev_end = locals->prev_end; + locals->retval = 0; + return 1; + } + locals->prev_end = locals->curr_end; +# else + if (locals->stop_at_next_vma) + { + locals->vma->next_start = locals->curr_start; + locals->stop_at_next_vma = 0; + return 1; + } + if (locals->curr_start < locals->curr_end + && locals->address >= locals->curr_start + && locals->address <= locals->curr_end - 1) + { + locals->vma->start = locals->curr_start; + locals->vma->end = locals->curr_end; + locals->retval = 0; + locals->stop_at_next_vma = 1; + return 0; + } +# endif + locals->curr_start = start; locals->curr_end = end; + return 0; +} + +int +sigsegv_get_vma (uintptr_t address, struct vma_struct *vma) +{ + struct callback_locals locals; + locals.address = address; + locals.vma = vma; + locals.curr_start = 0; + locals.curr_end = 0; +# if STACK_DIRECTION < 0 + locals.prev_end = 0; +# else + locals.stop_at_next_vma = 0; +# endif + locals.retval = -1; + + vma_iterate (&locals); + if (locals.retval < 0) + { + if (locals.curr_start < locals.curr_end + && address >= locals.curr_start && address <= locals.curr_end - 1) + { + vma->start = locals.curr_start; + vma->end = locals.curr_end; +# if STACK_DIRECTION < 0 + vma->prev_end = locals.prev_end; +# else + vma->next_start = 0; +# endif + locals.retval = 0; + } + } + if (locals.retval == 0) + { +# if !(STACK_DIRECTION < 0) + if (locals.stop_at_next_vma) + vma->next_start = 0; +# endif + vma->is_near_this = simple_is_near_this; + return 0; + } + + /* FreeBSD 6.[01] doesn't allow to distinguish unmapped pages from + mapped but swapped-out pages. See whether it's fixed. */ + if (!is_mapped (0)) + /* OK, mincore() appears to work as expected. */ + return mincore_get_vma (address, vma); + return -1; +} + +/* --------------------------- stackvma-netbsd.c --------------------------- */ + +#elif defined __NetBSD__ /* NetBSD */ + +struct callback_locals +{ + uintptr_t address; + struct vma_struct *vma; + /* The stack appears as multiple adjacent segments, therefore we + merge adjacent segments. */ + uintptr_t curr_start, curr_end; +# if STACK_DIRECTION < 0 + uintptr_t prev_end; +# else + int stop_at_next_vma; +# endif + int retval; +}; + +static int +callback (struct callback_locals *locals, uintptr_t start, uintptr_t end) +{ + if (start == locals->curr_end) + { + /* Merge adjacent segments. */ + locals->curr_end = end; + return 0; + } +# if STACK_DIRECTION < 0 + if (locals->curr_start < locals->curr_end + && locals->address >= locals->curr_start + && locals->address <= locals->curr_end - 1) + { + locals->vma->start = locals->curr_start; + locals->vma->end = locals->curr_end; + locals->vma->prev_end = locals->prev_end; + locals->retval = 0; + return 1; + } + locals->prev_end = locals->curr_end; +# else + if (locals->stop_at_next_vma) + { + locals->vma->next_start = locals->curr_start; + locals->stop_at_next_vma = 0; + return 1; + } + if (locals->curr_start < locals->curr_end + && locals->address >= locals->curr_start + && locals->address <= locals->curr_end - 1) + { + locals->vma->start = locals->curr_start; + locals->vma->end = locals->curr_end; + locals->retval = 0; + locals->stop_at_next_vma = 1; + return 0; + } +# endif + locals->curr_start = start; locals->curr_end = end; + return 0; +} + +int +sigsegv_get_vma (uintptr_t address, struct vma_struct *vma) +{ + struct callback_locals locals; + locals.address = address; + locals.vma = vma; + locals.curr_start = 0; + locals.curr_end = 0; +# if STACK_DIRECTION < 0 + locals.prev_end = 0; +# else + locals.stop_at_next_vma = 0; +# endif + locals.retval = -1; + + vma_iterate (&locals); + if (locals.retval < 0) + { + if (locals.curr_start < locals.curr_end + && address >= locals.curr_start && address <= locals.curr_end - 1) + { + vma->start = locals.curr_start; + vma->end = locals.curr_end; +# if STACK_DIRECTION < 0 + vma->prev_end = locals.prev_end; +# else + vma->next_start = 0; +# endif + locals.retval = 0; + } + } + if (locals.retval == 0) + { +# if !(STACK_DIRECTION < 0) + if (locals.stop_at_next_vma) + vma->next_start = 0; +# endif + vma->is_near_this = simple_is_near_this; + return 0; + } + + return mincore_get_vma (address, vma); +} + +/* --------------------------- stackvma-mquery.c --------------------------- */ + +/* mquery() is a system call that allows to inquire the status of a + range of pages of virtual memory. In particular, it allows to inquire + whether a page is mapped at all, and where is the next unmapped page + after a given address. + As of 2021, mquery() is supported by: + - OpenBSD, since OpenBSD 3.4. + Note that this file can give different results. For example, on + OpenBSD 4.4 / i386 the stack segment (which starts around 0xcdbfe000) + ends at 0xcfbfdfff according to mincore, but at 0xffffffff according to + mquery. */ + +#elif defined __OpenBSD__ /* OpenBSD */ + +# include /* getpagesize, mincore */ +# include +# include /* mincore */ + +/* Cache for getpagesize(). */ +static uintptr_t pagesize; + +/* Initialize pagesize. */ +static void +init_pagesize (void) +{ + pagesize = getpagesize (); +} + +/* Test whether the page starting at ADDR is among the address range. + ADDR must be a multiple of pagesize. */ +static int +is_mapped (uintptr_t addr) +{ + /* Avoid calling mquery with a NULL first argument, because this argument + value has a specific meaning. We know the NULL page is unmapped. */ + if (addr == 0) + return 0; + return mquery ((void *) addr, pagesize, 0, MAP_FIXED, -1, 0) == (void *) -1; +} + +/* Assuming that the page starting at ADDR is among the address range, + return the start of its virtual memory range. + ADDR must be a multiple of pagesize. */ +static uintptr_t +mapped_range_start (uintptr_t addr) +{ + uintptr_t stepsize; + uintptr_t known_unmapped_page; + + /* Look at smaller addresses, in larger and larger steps, to minimize the + number of mquery() calls. */ + stepsize = pagesize; + for (;;) + { + uintptr_t hole; + + if (addr == 0) + abort (); + + if (addr <= stepsize) + { + known_unmapped_page = 0; + break; + } + + hole = (uintptr_t) mquery ((void *) (addr - stepsize), pagesize, + 0, 0, -1, 0); + if (!(hole == (uintptr_t) (void *) -1 || hole >= addr)) + { + /* Some part of [addr - stepsize, addr - 1] is unmapped. */ + known_unmapped_page = hole; + break; + } + + /* The entire range [addr - stepsize, addr - 1] is mapped. */ + addr -= stepsize; + + if (2 * stepsize > stepsize && 2 * stepsize < addr) + stepsize = 2 * stepsize; + } + + /* Now reduce the step size again. + We know that the page at known_unmapped_page is unmapped and that + 0 < addr - known_unmapped_page <= stepsize. */ + while (stepsize > pagesize && stepsize / 2 >= addr - known_unmapped_page) + stepsize = stepsize / 2; + /* Still 0 < addr - known_unmapped_page <= stepsize. */ + while (stepsize > pagesize) + { + uintptr_t hole; + + stepsize = stepsize / 2; + hole = (uintptr_t) mquery ((void *) (addr - stepsize), pagesize, + 0, 0, -1, 0); + if (!(hole == (uintptr_t) (void *) -1 || hole >= addr)) + /* Some part of [addr - stepsize, addr - 1] is unmapped. */ + known_unmapped_page = hole; + else + /* The entire range [addr - stepsize, addr - 1] is mapped. */ + addr -= stepsize; + /* Still 0 < addr - known_unmapped_page <= stepsize. */ + } + + return addr; +} + +/* Assuming that the page starting at ADDR is among the address range, + return the end of its virtual memory range + 1. + ADDR must be a multiple of pagesize. */ +static uintptr_t +mapped_range_end (uintptr_t addr) +{ + uintptr_t end; + + if (addr == 0) + abort (); + + end = (uintptr_t) mquery ((void *) addr, pagesize, 0, 0, -1, 0); + if (end == (uintptr_t) (void *) -1) + end = 0; /* wrap around */ + return end; +} + +/* Determine whether an address range [ADDR1..ADDR2] is completely unmapped. + ADDR1 must be <= ADDR2. */ +static int +is_unmapped (uintptr_t addr1, uintptr_t addr2) +{ + /* Round addr1 down. */ + addr1 = (addr1 / pagesize) * pagesize; + /* Round addr2 up and turn it into an exclusive bound. */ + addr2 = ((addr2 / pagesize) + 1) * pagesize; + + /* Avoid calling mquery with a NULL first argument, because this argument + value has a specific meaning. We know the NULL page is unmapped. */ + if (addr1 == 0) + addr1 = pagesize; + + if (addr1 < addr2) + { + if (mquery ((void *) addr1, addr2 - addr1, 0, MAP_FIXED, -1, 0) + == (void *) -1) + /* Not all the interval [addr1 .. addr2 - 1] is unmapped. */ + return 0; + else + /* The interval [addr1 .. addr2 - 1] is unmapped. */ + return 1; + } + return 1; +} + +# if STACK_DIRECTION < 0 + +/* Info about the gap between this VMA and the previous one. + addr must be < vma->start. */ +static int +mquery_is_near_this (uintptr_t addr, struct vma_struct *vma) +{ + /* vma->start - addr <= (vma->start - vma->prev_end) / 2 + is mathematically equivalent to + vma->prev_end <= 2 * addr - vma->start + <==> is_unmapped (2 * addr - vma->start, vma->start - 1). + But be careful about overflow: if 2 * addr - vma->start is negative, + we consider a tiny "guard page" mapping [0, 0] to be present around + NULL; it intersects the range (2 * addr - vma->start, vma->start - 1), + therefore return false. */ + uintptr_t testaddr = addr - (vma->start - addr); + if (testaddr > addr) /* overflow? */ + return 0; + /* Here testaddr <= addr < vma->start. */ + return is_unmapped (testaddr, vma->start - 1); +} + +# endif +# if STACK_DIRECTION > 0 + +/* Info about the gap between this VMA and the next one. + addr must be > vma->end - 1. */ +static int +mquery_is_near_this (uintptr_t addr, struct vma_struct *vma) +{ + /* addr - vma->end < (vma->next_start - vma->end) / 2 + is mathematically equivalent to + vma->next_start > 2 * addr - vma->end + <==> is_unmapped (vma->end, 2 * addr - vma->end). + But be careful about overflow: if 2 * addr - vma->end is > ~0UL, + we consider a tiny "guard page" mapping [0, 0] to be present around + NULL; it intersects the range (vma->end, 2 * addr - vma->end), + therefore return false. */ + uintptr_t testaddr = addr + (addr - vma->end); + if (testaddr < addr) /* overflow? */ + return 0; + /* Here vma->end - 1 < addr <= testaddr. */ + return is_unmapped (vma->end, testaddr); +} + +# endif + +int +sigsegv_get_vma (uintptr_t address, struct vma_struct *vma) +{ + if (pagesize == 0) + init_pagesize (); + address = (address / pagesize) * pagesize; + vma->start = mapped_range_start (address); + vma->end = mapped_range_end (address); + vma->is_near_this = mquery_is_near_this; + return 0; +} + +/* ---------------------------- stackvma-mach.c ---------------------------- */ + +#elif (defined __APPLE__ && defined __MACH__) /* macOS */ + +#include +#include +#include +#include + +int +sigsegv_get_vma (uintptr_t req_address, struct vma_struct *vma) +{ + uintptr_t prev_address = 0, prev_size = 0; + uintptr_t join_address = 0, join_size = 0; + int more = 1; + vm_address_t address; + vm_size_t size; + task_t task = mach_task_self (); + + for (address = VM_MIN_ADDRESS; more; address += size) + { + mach_port_t object_name; + /* In MacOS X 10.5, the types vm_address_t, vm_offset_t, vm_size_t have + 32 bits in 32-bit processes and 64 bits in 64-bit processes. Whereas + mach_vm_address_t and mach_vm_size_t are always 64 bits large. + MacOS X 10.5 has three vm_region like methods: + - vm_region. It has arguments that depend on whether the current + process is 32-bit or 64-bit. When linking dynamically, this + function exists only in 32-bit processes. Therefore we use it only + in 32-bit processes. + - vm_region_64. It has arguments that depend on whether the current + process is 32-bit or 64-bit. It interprets a flavor + VM_REGION_BASIC_INFO as VM_REGION_BASIC_INFO_64, which is + dangerous since 'struct vm_region_basic_info_64' is larger than + 'struct vm_region_basic_info'; therefore let's write + VM_REGION_BASIC_INFO_64 explicitly. + - mach_vm_region. It has arguments that are 64-bit always. This + function is useful when you want to access the VM of a process + other than the current process. + In 64-bit processes, we could use vm_region_64 or mach_vm_region. + I choose vm_region_64 because it uses the same types as vm_region, + resulting in less conditional code. */ +# if defined __aarch64__ || defined __ppc64__ || defined __x86_64__ + struct vm_region_basic_info_64 info; + mach_msg_type_number_t info_count = VM_REGION_BASIC_INFO_COUNT_64; + + more = (vm_region_64 (task, &address, &size, VM_REGION_BASIC_INFO_64, + (vm_region_info_t)&info, &info_count, &object_name) + == KERN_SUCCESS); +# else + struct vm_region_basic_info info; + mach_msg_type_number_t info_count = VM_REGION_BASIC_INFO_COUNT; + + more = (vm_region (task, &address, &size, VM_REGION_BASIC_INFO, + (vm_region_info_t)&info, &info_count, &object_name) + == KERN_SUCCESS); +# endif + if (!more) + { + address = join_address + join_size; + size = 0; + } + + if ((uintptr_t) address == join_address + join_size) + join_size += size; + else + { + prev_address = join_address; + prev_size = join_size; + join_address = (uintptr_t) address; + join_size = size; + } + + if (object_name != MACH_PORT_NULL) + mach_port_deallocate (mach_task_self (), object_name); + +# if STACK_DIRECTION < 0 + if (join_address <= req_address && join_address + join_size > req_address) + { + vma->start = join_address; + vma->end = join_address + join_size; + vma->prev_end = prev_address + prev_size; + vma->is_near_this = simple_is_near_this; + return 0; + } +# else + if (prev_address <= req_address && prev_address + prev_size > req_address) + { + vma->start = prev_address; + vma->end = prev_address + prev_size; + vma->next_start = join_address; + vma->is_near_this = simple_is_near_this; + return 0; + } +# endif + } + +# if STACK_DIRECTION > 0 + if (join_address <= req_address && join_address + size > req_address) + { + vma->start = prev_address; + vma->end = prev_address + prev_size; + vma->next_start = ~0UL; + vma->is_near_this = simple_is_near_this; + return 0; + } +# endif + + return -1; +} + +/* ----------------------------- stackvma-aix.c ----------------------------- */ + +#elif defined _AIX /* AIX */ + +# include /* getpagesize, getpid, close, read */ +# include /* EINTR */ +# include /* open */ +# include /* memcpy */ +# include +# include /* mmap, munmap */ +# include /* prmap_t */ +# include /* uname */ + +struct callback_locals +{ + uintptr_t address; + struct vma_struct *vma; +# if STACK_DIRECTION < 0 + uintptr_t prev; +# else + int stop_at_next_vma; +# endif + int retval; +}; + +static int +callback (struct callback_locals *locals, uintptr_t start, uintptr_t end) +{ +# if STACK_DIRECTION < 0 + if (locals->address >= start && locals->address <= end - 1) + { + locals->vma->start = start; + locals->vma->end = end; + locals->vma->prev_end = locals->prev; + locals->retval = 0; + return 1; + } + locals->prev = end; +# else + if (locals->stop_at_next_vma) + { + locals->vma->next_start = start; + locals->stop_at_next_vma = 0; + return 1; + } + if (locals->address >= start && locals->address <= end - 1) + { + locals->vma->start = start; + locals->vma->end = end; + locals->retval = 0; + locals->stop_at_next_vma = 1; + return 0; + } +# endif + return 0; +} + +/* Iterate over the virtual memory areas of the current process. + If such iteration is supported, the callback is called once for every + virtual memory area, in ascending order, with the following arguments: + - LOCALS is the same argument as passed to vma_iterate. + - START is the address of the first byte in the area, page-aligned. + - END is the address of the last byte in the area plus 1, page-aligned. + Note that it may be 0 for the last area in the address space. + If the callback returns 0, the iteration continues. If it returns 1, + the iteration terminates prematurely. + This function may open file descriptors, but does not call malloc(). + Return 0 if all went well, or -1 in case of error. */ +/* This code is a simplified copy (no handling of protection flags) of the + code in gnulib's lib/vma-iter.c. */ +static int +vma_iterate (struct callback_locals *locals) +{ + /* On AIX, there is a /proc/$pic/map file, that contains records of type + prmap_t, defined in . In older versions of AIX, it lists + only the virtual memory areas that are connected to a file, not the + anonymous ones. But at least since AIX 7.1, it is well usable. */ + + char fnamebuf[6+10+4+1]; + char *fname; + int fd; + size_t memneed; + + if (pagesize == 0) + init_pagesize (); + + /* Construct fname = sprintf (fnamebuf+i, "/proc/%u/map", getpid ()). */ + fname = fnamebuf + sizeof (fnamebuf) - (4+1); + memcpy (fname, "/map", 4+1); + { + unsigned int value = getpid (); + do + *--fname = (value % 10) + '0'; + while ((value = value / 10) > 0); + } + fname -= 6; + memcpy (fname, "/proc/", 6); + + fd = open (fname, O_RDONLY | O_CLOEXEC); + if (fd < 0) + return -1; + + /* The contents of /proc//map contains a number of prmap_t entries, + then an entirely null prmap_t entry, then a heap of NUL terminated + strings. + Documentation: https://www.ibm.com/docs/en/aix/7.1?topic=files-proc-file + We read the entire contents, but look only at the prmap_t entries and + ignore the tail part. */ + + for (memneed = 2 * pagesize; ; memneed = 2 * memneed) + { + /* Allocate memneed bytes of memory. + We cannot use alloca here, because not much stack space is guaranteed. + We also cannot use malloc here, because a malloc() call may call mmap() + and thus pre-allocate available memory. + So use mmap(), and ignore the resulting VMA if it occurs among the + resulting VMAs. (Normally it doesn't, because it was allocated after + the open() call.) */ + void *auxmap; + unsigned long auxmap_start; + unsigned long auxmap_end; + ssize_t nbytes; + + auxmap = (void *) mmap ((void *) 0, memneed, PROT_READ | PROT_WRITE, + MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); + if (auxmap == (void *) -1) + { + close (fd); + return -1; + } + auxmap_start = (unsigned long) auxmap; + auxmap_end = auxmap_start + memneed; + + /* Read the contents of /proc//map in a single system call. + This guarantees a consistent result (no duplicated or omitted + entries). */ + retry: + do + nbytes = read (fd, auxmap, memneed); + while (nbytes < 0 && errno == EINTR); + if (nbytes <= 0) + { + munmap (auxmap, memneed); + close (fd); + return -1; + } + if (nbytes == memneed) + { + /* Need more memory. */ + munmap (auxmap, memneed); + if (lseek (fd, 0, SEEK_SET) < 0) + { + close (fd); + return -1; + } + } + else + { + if (read (fd, (char *) auxmap + nbytes, 1) > 0) + { + /* Oops, we had a short read. Retry. */ + if (lseek (fd, 0, SEEK_SET) < 0) + { + munmap (auxmap, memneed); + close (fd); + return -1; + } + goto retry; + } + + /* We now have the entire contents of /proc//map in memory. */ + prmap_t* maps = (prmap_t *) auxmap; + + /* The entries are not sorted by address. Therefore + 1. Extract the relevant information into an array. + 2. Sort the array in ascending order. + 3. Invoke the callback. */ + typedef struct + { + uintptr_t start; + uintptr_t end; + } + vma_t; + /* Since 2 * sizeof (vma_t) <= sizeof (prmap_t), we can reuse the + same memory. */ + vma_t *vmas = (vma_t *) auxmap; + + vma_t *vp = vmas; + { + prmap_t* mp; + for (mp = maps;;) + { + unsigned long start, end; + + start = (unsigned long) mp->pr_vaddr; + end = start + mp->pr_size; + if (start == 0 && end == 0 && mp->pr_mflags == 0) + break; + /* Discard empty VMAs and kernel VMAs. */ + if (start < end && (mp->pr_mflags & MA_KERNTEXT) == 0) + { + if (start <= auxmap_start && auxmap_end - 1 <= end - 1) + { + /* Consider [start,end-1] \ [auxmap_start,auxmap_end-1] + = [start,auxmap_start-1] u [auxmap_end,end-1]. */ + if (start < auxmap_start) + { + vp->start = start; + vp->end = auxmap_start; + vp++; + } + if (auxmap_end - 1 < end - 1) + { + vp->start = auxmap_end; + vp->end = end; + vp++; + } + } + else + { + vp->start = start; + vp->end = end; + vp++; + } + } + mp++; + } + } + + size_t nvmas = vp - vmas; + /* Sort the array in ascending order. + Better not call qsort(), since it may call malloc(). + Insertion-sort is OK in this case, despite its worst-case running + time of O(N²), since the number of VMAs will rarely be larger than + 1000. */ + { + size_t i; + for (i = 1; i < nvmas; i++) + { + /* Invariant: Here vmas[0..i-1] is sorted. */ + size_t j; + for (j = i; j > 0 && vmas[j - 1].start > vmas[j].start; j--) + { + vma_t tmp = vmas[j - 1]; + vmas[j - 1] = vmas[j]; + vmas[j] = tmp; + } + /* Invariant: Here vmas[0..i] is sorted. */ + } + } + + /* Invoke the callback. */ + { + size_t i; + for (i = 0; i < nvmas; i++) + { + vma_t *vpi = &vmas[i]; + if (callback (locals, vpi->start, vpi->end)) + break; + } + } + + munmap (auxmap, memneed); + break; + } + } + + close (fd); + return 0; +} + +int +sigsegv_get_vma (uintptr_t address, struct vma_struct *vma) +{ + struct utsname u; + if (uname (&u) >= 0 + /* && strcmp (u.sysname, "AIX") == 0 */ + && !(u.version[0] >= '1' && u.version[0] <= '6' && u.version[1] == '\0')) + { + /* AIX 7 or higher. */ + struct callback_locals locals; + locals.address = address; + locals.vma = vma; +#if STACK_DIRECTION < 0 + locals.prev = 0; +#else + locals.stop_at_next_vma = 0; +#endif + locals.retval = -1; + + vma_iterate (&locals); + if (locals.retval == 0) + { +#if !(STACK_DIRECTION < 0) + if (locals.stop_at_next_vma) + vma->next_start = 0; +#endif + vma->is_near_this = simple_is_near_this; + return 0; + } + } + + return mincore_get_vma (address, vma); +} + +/* --------------------------- stackvma-procfs.c --------------------------- */ + +#elif defined __sgi || defined __sun /* IRIX, Solaris */ + +# include /* errno, EINTR */ +# include /* open, O_RDONLY */ +# include /* size_t */ +# include /* getpagesize, getpid, read, close */ +# include +# include /* mmap, munmap */ +# include /* fstat */ +# include /* memcpy */ + +/* Try to use the newer ("structured") /proc filesystem API, if supported. */ +# define _STRUCTURED_PROC 1 +# include /* prmap_t, optionally PIOC* */ + +# if !defined __sun + +/* Cache for getpagesize(). */ +static uintptr_t pagesize; + +/* Initialize pagesize. */ +static void +init_pagesize (void) +{ + pagesize = getpagesize (); +} + +# endif + +struct callback_locals +{ + uintptr_t address; + struct vma_struct *vma; +# if STACK_DIRECTION < 0 + uintptr_t prev; +# else + int stop_at_next_vma; +# endif + int retval; +}; + +static int +callback (struct callback_locals *locals, uintptr_t start, uintptr_t end) +{ +# if STACK_DIRECTION < 0 + if (locals->address >= start && locals->address <= end - 1) + { + locals->vma->start = start; + locals->vma->end = end; + locals->vma->prev_end = locals->prev; + locals->retval = 0; + return 1; + } + locals->prev = end; +# else + if (locals->stop_at_next_vma) + { + locals->vma->next_start = start; + locals->stop_at_next_vma = 0; + return 1; + } + if (locals->address >= start && locals->address <= end - 1) + { + locals->vma->start = start; + locals->vma->end = end; + locals->retval = 0; + locals->stop_at_next_vma = 1; + return 0; + } +# endif + return 0; +} + +/* Iterate over the virtual memory areas of the current process. + If such iteration is supported, the callback is called once for every + virtual memory area, in ascending order, with the following arguments: + - LOCALS is the same argument as passed to vma_iterate. + - START is the address of the first byte in the area, page-aligned. + - END is the address of the last byte in the area plus 1, page-aligned. + Note that it may be 0 for the last area in the address space. + If the callback returns 0, the iteration continues. If it returns 1, + the iteration terminates prematurely. + This function may open file descriptors, but does not call malloc(). + Return 0 if all went well, or -1 in case of error. */ +/* This code is a simplified copy (no handling of protection flags) of the + code in gnulib's lib/vma-iter.c. */ +static int +vma_iterate (struct callback_locals *locals) +{ + /* Note: Solaris defines a different type prmap_t with + _STRUCTURED_PROC than without! Here's a table of sizeof(prmap_t): + 32-bit 64-bit + _STRUCTURED_PROC = 0 32 56 + _STRUCTURED_PROC = 1 96 104 + Therefore, if the include files provide the newer API, prmap_t has + the bigger size, and thus you MUST use the newer API. And if the + include files provide the older API, prmap_t has the smaller size, + and thus you MUST use the older API. */ + +# if defined PIOCNMAP && defined PIOCMAP + /* We must use the older /proc interface. */ + + char fnamebuf[6+10+1]; + char *fname; + int fd; + int nmaps; + size_t memneed; +# if HAVE_MAP_ANONYMOUS +# define zero_fd -1 +# define map_flags MAP_ANONYMOUS +# else /* !HAVE_MAP_ANONYMOUS */ + int zero_fd; +# define map_flags 0 +# endif + void *auxmap; + uintptr_t auxmap_start; + uintptr_t auxmap_end; + prmap_t* maps; + prmap_t* mp; + + if (pagesize == 0) + init_pagesize (); + + /* Construct fname = sprintf (fnamebuf+i, "/proc/%u", getpid ()). */ + fname = fnamebuf + sizeof (fnamebuf) - 1; + *fname = '\0'; + { + unsigned int value = getpid (); + do + *--fname = (value % 10) + '0'; + while ((value = value / 10) > 0); + } + fname -= 6; + memcpy (fname, "/proc/", 6); + + fd = open (fname, O_RDONLY); + if (fd < 0) + return -1; + + if (ioctl (fd, PIOCNMAP, &nmaps) < 0) + goto fail2; + + memneed = (nmaps + 10) * sizeof (prmap_t); + /* Allocate memneed bytes of memory. + We cannot use alloca here, because not much stack space is guaranteed. + We also cannot use malloc here, because a malloc() call may call mmap() + and thus pre-allocate available memory. + So use mmap(), and ignore the resulting VMA. */ + memneed = ((memneed - 1) / pagesize + 1) * pagesize; +# if !HAVE_MAP_ANONYMOUS + zero_fd = open ("/dev/zero", O_RDONLY, 0644); + if (zero_fd < 0) + goto fail2; +# endif + auxmap = (void *) mmap ((void *) 0, memneed, PROT_READ | PROT_WRITE, + map_flags | MAP_PRIVATE, zero_fd, 0); +# if !HAVE_MAP_ANONYMOUS + close (zero_fd); +# endif + if (auxmap == (void *) -1) + goto fail2; + auxmap_start = (uintptr_t) auxmap; + auxmap_end = auxmap_start + memneed; + maps = (prmap_t *) auxmap; + + if (ioctl (fd, PIOCMAP, maps) < 0) + goto fail1; + + for (mp = maps;;) + { + uintptr_t start, end; + + start = (uintptr_t) mp->pr_vaddr; + end = start + mp->pr_size; + if (start == 0 && end == 0) + break; + mp++; + if (start <= auxmap_start && auxmap_end - 1 <= end - 1) + { + /* Consider [start,end-1] \ [auxmap_start,auxmap_end-1] + = [start,auxmap_start-1] u [auxmap_end,end-1]. */ + if (start < auxmap_start) + if (callback (locals, start, auxmap_start)) + break; + if (auxmap_end - 1 < end - 1) + if (callback (locals, auxmap_end, end)) + break; + } + else + { + if (callback (locals, start, end)) + break; + } + } + munmap (auxmap, memneed); + close (fd); + return 0; + + fail1: + munmap (auxmap, memneed); + fail2: + close (fd); + return -1; + +# else + /* We must use the newer /proc interface. + Documentation: + https://docs.oracle.com/cd/E23824_01/html/821-1473/proc-4.html + The contents of /proc//map consists of records of type + prmap_t. These are different in 32-bit and 64-bit processes, + but here we are fortunately accessing only the current process. */ + + char fnamebuf[6+10+4+1]; + char *fname; + int fd; + int nmaps; + size_t memneed; +# if HAVE_MAP_ANONYMOUS +# define zero_fd -1 +# define map_flags MAP_ANONYMOUS +# else /* !HAVE_MAP_ANONYMOUS */ + int zero_fd; +# define map_flags 0 +# endif + void *auxmap; + uintptr_t auxmap_start; + uintptr_t auxmap_end; + prmap_t* maps; + prmap_t* maps_end; + prmap_t* mp; + + if (pagesize == 0) + init_pagesize (); + + /* Construct fname = sprintf (fnamebuf+i, "/proc/%u/map", getpid ()). */ + fname = fnamebuf + sizeof (fnamebuf) - 1 - 4; + memcpy (fname, "/map", 4 + 1); + { + unsigned int value = getpid (); + do + *--fname = (value % 10) + '0'; + while ((value = value / 10) > 0); + } + fname -= 6; + memcpy (fname, "/proc/", 6); + + fd = open (fname, O_RDONLY); + if (fd < 0) + return -1; + + { + struct stat statbuf; + if (fstat (fd, &statbuf) < 0) + goto fail2; + nmaps = statbuf.st_size / sizeof (prmap_t); + } + + memneed = (nmaps + 10) * sizeof (prmap_t); + /* Allocate memneed bytes of memory. + We cannot use alloca here, because not much stack space is guaranteed. + We also cannot use malloc here, because a malloc() call may call mmap() + and thus pre-allocate available memory. + So use mmap(), and ignore the resulting VMA. */ + memneed = ((memneed - 1) / pagesize + 1) * pagesize; +# if !HAVE_MAP_ANONYMOUS + zero_fd = open ("/dev/zero", O_RDONLY, 0644); + if (zero_fd < 0) + goto fail2; +# endif + auxmap = (void *) mmap ((void *) 0, memneed, PROT_READ | PROT_WRITE, + map_flags | MAP_PRIVATE, zero_fd, 0); +# if !HAVE_MAP_ANONYMOUS + close (zero_fd); +# endif + if (auxmap == (void *) -1) + goto fail2; + auxmap_start = (uintptr_t) auxmap; + auxmap_end = auxmap_start + memneed; + maps = (prmap_t *) auxmap; + + /* Read up to memneed bytes from fd into maps. */ + { + size_t remaining = memneed; + size_t total_read = 0; + char *ptr = (char *) maps; + + do + { + size_t nread = read (fd, ptr, remaining); + if (nread == (size_t)-1) + { + if (errno == EINTR) + continue; + goto fail1; + } + if (nread == 0) + /* EOF */ + break; + total_read += nread; + ptr += nread; + remaining -= nread; + } + while (remaining > 0); + + nmaps = (memneed - remaining) / sizeof (prmap_t); + maps_end = maps + nmaps; + } + + for (mp = maps; mp < maps_end; mp++) + { + uintptr_t start, end; + + start = (uintptr_t) mp->pr_vaddr; + end = start + mp->pr_size; + if (start <= auxmap_start && auxmap_end - 1 <= end - 1) + { + /* Consider [start,end-1] \ [auxmap_start,auxmap_end-1] + = [start,auxmap_start-1] u [auxmap_end,end-1]. */ + if (start < auxmap_start) + if (callback (locals, start, auxmap_start)) + break; + if (auxmap_end - 1 < end - 1) + if (callback (locals, auxmap_end, end)) + break; + } + else + { + if (callback (locals, start, end)) + break; + } + } + munmap (auxmap, memneed); + close (fd); + return 0; + + fail1: + munmap (auxmap, memneed); + fail2: + close (fd); + return -1; + +# endif +} + +int +sigsegv_get_vma (uintptr_t address, struct vma_struct *vma) +{ + struct callback_locals locals; + locals.address = address; + locals.vma = vma; +# if STACK_DIRECTION < 0 + locals.prev = 0; +# else + locals.stop_at_next_vma = 0; +# endif + locals.retval = -1; + + vma_iterate (&locals); + if (locals.retval == 0) + { +# if !(STACK_DIRECTION < 0) + if (locals.stop_at_next_vma) + vma->next_start = 0; +# endif + vma->is_near_this = simple_is_near_this; + return 0; + } + +# if defined __sun + return mincore_get_vma (address, vma); +# else + return -1; +# endif +} + +/* -------------------------------------------------------------------------- */ + +#elif defined __CYGWIN__ /* Cygwin */ + +struct callback_locals +{ + uintptr_t address; + struct vma_struct *vma; + /* The stack appears as three adjacent segments, therefore we + merge adjacent segments. */ + uintptr_t curr_start, curr_end; +# if STACK_DIRECTION < 0 + uintptr_t prev_end; +# else + int stop_at_next_vma; +# endif + int retval; +}; + +static int +callback (struct callback_locals *locals, uintptr_t start, uintptr_t end) +{ + if (start == locals->curr_end) + { + /* Merge adjacent segments. */ + locals->curr_end = end; + return 0; + } +# if STACK_DIRECTION < 0 + if (locals->curr_start < locals->curr_end + && locals->address >= locals->curr_start + && locals->address <= locals->curr_end - 1) + { + locals->vma->start = locals->curr_start; + locals->vma->end = locals->curr_end; + locals->vma->prev_end = locals->prev_end; + locals->retval = 0; + return 1; + } + locals->prev_end = locals->curr_end; +# else + if (locals->stop_at_next_vma) + { + locals->vma->next_start = locals->curr_start; + locals->stop_at_next_vma = 0; + return 1; + } + if (locals->curr_start < locals->curr_end + && locals->address >= locals->curr_start + && locals->address <= locals->curr_end - 1) + { + locals->vma->start = locals->curr_start; + locals->vma->end = locals->curr_end; + locals->retval = 0; + locals->stop_at_next_vma = 1; + return 0; + } +# endif + locals->curr_start = start; locals->curr_end = end; + return 0; +} + +int +sigsegv_get_vma (uintptr_t address, struct vma_struct *vma) +{ + struct callback_locals locals; + locals.address = address; + locals.vma = vma; + locals.curr_start = 0; + locals.curr_end = 0; +# if STACK_DIRECTION < 0 + locals.prev_end = 0; +# else + locals.stop_at_next_vma = 0; +# endif + locals.retval = -1; + + vma_iterate (&locals); + if (locals.retval < 0) + { + if (locals.curr_start < locals.curr_end + && address >= locals.curr_start && address <= locals.curr_end - 1) + { + vma->start = locals.curr_start; + vma->end = locals.curr_end; +# if STACK_DIRECTION < 0 + vma->prev_end = locals.prev_end; +# else + vma->next_start = 0; +# endif + locals.retval = 0; + } + } + if (locals.retval == 0) + { +# if !(STACK_DIRECTION < 0) + if (locals.stop_at_next_vma) + vma->next_start = 0; +# endif + vma->is_near_this = simple_is_near_this; + return 0; + } + + return -1; +} + +/* ---------------------------- stackvma-beos.h ---------------------------- */ + +#elif defined __HAIKU__ /* Haiku */ + +# include /* get_next_area_info */ + +struct callback_locals +{ + uintptr_t address; + struct vma_struct *vma; +# if STACK_DIRECTION < 0 + uintptr_t prev; +# else + int stop_at_next_vma; +# endif + int retval; +}; + +static int +callback (struct callback_locals *locals, uintptr_t start, uintptr_t end) +{ +# if STACK_DIRECTION < 0 + if (locals->address >= start && locals->address <= end - 1) + { + locals->vma->start = start; + locals->vma->end = end; + locals->vma->prev_end = locals->prev; + locals->retval = 0; + return 1; + } + locals->prev = end; +# else + if (locals->stop_at_next_vma) + { + locals->vma->next_start = start; + locals->stop_at_next_vma = 0; + return 1; + } + if (locals->address >= start && locals->address <= end - 1) + { + locals->vma->start = start; + locals->vma->end = end; + locals->retval = 0; + locals->stop_at_next_vma = 1; + return 0; + } +# endif + return 0; +} + +/* Iterate over the virtual memory areas of the current process. + If such iteration is supported, the callback is called once for every + virtual memory area, in ascending order, with the following arguments: + - LOCALS is the same argument as passed to vma_iterate. + - START is the address of the first byte in the area, page-aligned. + - END is the address of the last byte in the area plus 1, page-aligned. + Note that it may be 0 for the last area in the address space. + If the callback returns 0, the iteration continues. If it returns 1, + the iteration terminates prematurely. + This function may open file descriptors, but does not call malloc(). + Return 0 if all went well, or -1 in case of error. */ +/* This code is a simplified copy (no handling of protection flags) of the + code in gnulib's lib/vma-iter.c. */ +static int +vma_iterate (struct callback_locals *locals) +{ + area_info info; + ssize_t cookie; + + cookie = 0; + while (get_next_area_info (0, &cookie, &info) == B_OK) + { + uintptr_t start, end; + + start = (uintptr_t) info.address; + end = start + info.size; + + if (callback (locals, start, end)) + break; + } + return 0; +} + +int +sigsegv_get_vma (uintptr_t address, struct vma_struct *vma) +{ + struct callback_locals locals; + locals.address = address; + locals.vma = vma; +# if STACK_DIRECTION < 0 + locals.prev = 0; +# else + locals.stop_at_next_vma = 0; +# endif + locals.retval = -1; + + vma_iterate (&locals); + if (locals.retval == 0) + { +# if !(STACK_DIRECTION < 0) + if (locals.stop_at_next_vma) + vma->next_start = 0; +# endif + vma->is_near_this = simple_is_near_this; + return 0; + } + return -1; +} + +/* -------------------------------------------------------------------------- */ + +#else /* Hurd, Minix, ... */ + +int +sigsegv_get_vma (uintptr_t address, struct vma_struct *vma) +{ + /* No way. */ + return -1; +} + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stackvma.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stackvma.h new file mode 100644 index 00000000..3b92a2d2 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stackvma.h @@ -0,0 +1,62 @@ +/* Determine the virtual memory area of a given address. + Copyright (C) 2002-2024 Free Software Foundation, Inc. + Copyright (C) 2003-2006 Paolo Bonzini + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 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 . */ + +/* Written by Bruno Haible and Paolo Bonzini. */ + +#ifndef _STACKVMA_H +#define _STACKVMA_H + +#include + +/* Describes a virtual memory area, with some info about the gap between + it and the next or previous virtual memory area. */ +struct vma_struct +{ + uintptr_t start; + uintptr_t end; +#if STACK_DIRECTION < 0 + /* Info about the gap between this VMA and the previous one. + addr must be < vma->start. */ + int (*is_near_this) (uintptr_t addr, struct vma_struct *vma); + /* Private field, not provided by all sigsegv_get_vma implementations. */ + uintptr_t prev_end; +#endif +#if STACK_DIRECTION > 0 + /* Info about the gap between this VMA and the next one. + addr must be > vma->end - 1. */ + int (*is_near_this) (uintptr_t addr, struct vma_struct *vma); + /* Private field, not provided by all sigsegv_get_vma implementations. */ + uintptr_t next_start; +#endif +}; + +/* Determines the virtual memory area to which a given address belongs, + and returns 0. Returns -1 if it cannot be determined. + This function is used to determine the stack extent when a fault occurs. */ +extern int sigsegv_get_vma (uintptr_t address, struct vma_struct *vma); + +/* Defined if sigsegv_get_vma actually works (i.e. does not always fail). */ +#if defined __linux__ || defined __ANDROID__ \ + || defined __FreeBSD_kernel__ || defined __FreeBSD__ || defined __DragonFly__ \ + || defined __NetBSD__ || defined __OpenBSD__ \ + || (defined __APPLE__ && defined __MACH__) \ + || defined _AIX || defined __sgi || defined __sun \ + || defined __CYGWIN__ || defined __HAIKU__ +# define HAVE_STACKVMA 1 +#endif + +#endif /* _STACKVMA_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stat-macros.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stat-macros.h new file mode 100644 index 00000000..8ab44ab2 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stat-macros.h @@ -0,0 +1,20 @@ +/* stat-related macros + + Copyright (C) 1993-2024 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 the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + This file 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 . */ + +/* All the mode bits that can be affected by chmod. */ +#define CHMOD_MODE_BITS \ + (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stat-time.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stat-time.c new file mode 100644 index 00000000..1ab01f53 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stat-time.c @@ -0,0 +1,21 @@ +/* stat-related time functions. + + Copyright (C) 2012-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +#define _GL_STAT_TIME_INLINE _GL_EXTERN_INLINE +#include "stat-time.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stat-time.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stat-time.h new file mode 100644 index 00000000..3cd8478f --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stat-time.h @@ -0,0 +1,245 @@ +/* stat-related time functions. + + Copyright (C) 2005, 2007, 2009-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Paul Eggert. */ + +#ifndef STAT_TIME_H +#define STAT_TIME_H 1 + +/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, _GL_UNUSED, + _GL_ATTRIBUTE_PURE, HAVE_STRUCT_STAT_*. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +#include +#include +#include +#include +#include + +_GL_INLINE_HEADER_BEGIN +#ifndef _GL_STAT_TIME_INLINE +# define _GL_STAT_TIME_INLINE _GL_INLINE +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* STAT_TIMESPEC (ST, ST_XTIM) is the ST_XTIM member for *ST of type + struct timespec, if available. If not, then STAT_TIMESPEC_NS (ST, + ST_XTIM) is the nanosecond component of the ST_XTIM member for *ST, + if available. ST_XTIM can be st_atim, st_ctim, st_mtim, or st_birthtim + for access, status change, data modification, or birth (creation) + time respectively. + + These macros are private to stat-time.h. */ +#if _GL_WINDOWS_STAT_TIMESPEC || defined HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC +# if _GL_WINDOWS_STAT_TIMESPEC || defined TYPEOF_STRUCT_STAT_ST_ATIM_IS_STRUCT_TIMESPEC +# define STAT_TIMESPEC(st, st_xtim) ((st)->st_xtim) +# define STAT_TIMESPEC_OFFSETOF(st_xtim) offsetof (struct stat, st_xtim) +# else +# define STAT_TIMESPEC_NS(st, st_xtim) ((st)->st_xtim.tv_nsec) +# endif +#elif defined HAVE_STRUCT_STAT_ST_ATIMESPEC_TV_NSEC +# define STAT_TIMESPEC(st, st_xtim) ((st)->st_xtim##espec) +# define STAT_TIMESPEC_OFFSETOF(st_xtim) offsetof (struct stat, st_xtim##espec) +#elif defined HAVE_STRUCT_STAT_ST_ATIMENSEC +# define STAT_TIMESPEC_NS(st, st_xtim) ((st)->st_xtim##ensec) +#elif defined HAVE_STRUCT_STAT_ST_ATIM_ST__TIM_TV_NSEC +# define STAT_TIMESPEC_NS(st, st_xtim) ((st)->st_xtim.st__tim.tv_nsec) +#endif + +/* Return the nanosecond component of *ST's access time. */ +_GL_STAT_TIME_INLINE long int _GL_ATTRIBUTE_PURE +get_stat_atime_ns (struct stat const *st) +{ +# if defined STAT_TIMESPEC + return STAT_TIMESPEC (st, st_atim).tv_nsec; +# elif defined STAT_TIMESPEC_NS + return STAT_TIMESPEC_NS (st, st_atim); +# else + return 0; +# endif +} + +/* Return the nanosecond component of *ST's status change time. */ +_GL_STAT_TIME_INLINE long int _GL_ATTRIBUTE_PURE +get_stat_ctime_ns (struct stat const *st) +{ +# if defined STAT_TIMESPEC + return STAT_TIMESPEC (st, st_ctim).tv_nsec; +# elif defined STAT_TIMESPEC_NS + return STAT_TIMESPEC_NS (st, st_ctim); +# else + return 0; +# endif +} + +/* Return the nanosecond component of *ST's data modification time. */ +_GL_STAT_TIME_INLINE long int _GL_ATTRIBUTE_PURE +get_stat_mtime_ns (struct stat const *st) +{ +# if defined STAT_TIMESPEC + return STAT_TIMESPEC (st, st_mtim).tv_nsec; +# elif defined STAT_TIMESPEC_NS + return STAT_TIMESPEC_NS (st, st_mtim); +# else + return 0; +# endif +} + +/* Return the nanosecond component of *ST's birth time. */ +_GL_STAT_TIME_INLINE long int _GL_ATTRIBUTE_PURE +get_stat_birthtime_ns (_GL_UNUSED struct stat const *st) +{ +# if defined HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC + return STAT_TIMESPEC (st, st_birthtim).tv_nsec; +# elif defined HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC + return STAT_TIMESPEC_NS (st, st_birthtim); +# else + return 0; +# endif +} + +/* Return *ST's access time. */ +_GL_STAT_TIME_INLINE struct timespec _GL_ATTRIBUTE_PURE +get_stat_atime (struct stat const *st) +{ +#ifdef STAT_TIMESPEC + return STAT_TIMESPEC (st, st_atim); +#else + return (struct timespec) { .tv_sec = st->st_atime, + .tv_nsec = get_stat_atime_ns (st) }; +#endif +} + +/* Return *ST's status change time. */ +_GL_STAT_TIME_INLINE struct timespec _GL_ATTRIBUTE_PURE +get_stat_ctime (struct stat const *st) +{ +#ifdef STAT_TIMESPEC + return STAT_TIMESPEC (st, st_ctim); +#else + return (struct timespec) { .tv_sec = st->st_ctime, + .tv_nsec = get_stat_ctime_ns (st) }; +#endif +} + +/* Return *ST's data modification time. */ +_GL_STAT_TIME_INLINE struct timespec _GL_ATTRIBUTE_PURE +get_stat_mtime (struct stat const *st) +{ +#ifdef STAT_TIMESPEC + return STAT_TIMESPEC (st, st_mtim); +#else + return (struct timespec) { .tv_sec = st->st_mtime, + .tv_nsec = get_stat_mtime_ns (st) }; +#endif +} + +/* Return *ST's birth time, if available; otherwise return a value + with tv_sec and tv_nsec both equal to -1. */ +_GL_STAT_TIME_INLINE struct timespec _GL_ATTRIBUTE_PURE +get_stat_birthtime (_GL_UNUSED struct stat const *st) +{ + struct timespec t; + +#if (defined HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC \ + || defined HAVE_STRUCT_STAT_ST_BIRTHTIM_TV_NSEC) + t = STAT_TIMESPEC (st, st_birthtim); +#elif defined HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC + t = (struct timespec) { .tv_sec = st->st_birthtime, + .tv_nsec = st->st_birthtimensec }; +#elif defined _WIN32 && ! defined __CYGWIN__ + /* Native Windows platforms (but not Cygwin) put the "file creation + time" in st_ctime (!). See + . */ +# if _GL_WINDOWS_STAT_TIMESPEC + t = st->st_ctim; +# else + t = (struct timespec) { .tv_sec = st->st_ctime }; +# endif +#else + /* Birth time is not supported. */ + t = (struct timespec) { .tv_sec = -1, .tv_nsec = -1 }; +#endif + +#if (defined HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC \ + || defined HAVE_STRUCT_STAT_ST_BIRTHTIM_TV_NSEC \ + || defined HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC) + /* FreeBSD and NetBSD sometimes signal the absence of knowledge by + using zero. Attempt to work around this problem. Alas, this can + report failure even for valid timestamps. Also, NetBSD + sometimes returns junk in the birth time fields; work around this + bug if it is detected. */ + if (! (t.tv_sec && 0 <= t.tv_nsec && t.tv_nsec < 1000000000)) + t = (struct timespec) { .tv_sec = -1, .tv_nsec = -1 }; +#endif + + return t; +} + +/* If a stat-like function returned RESULT, normalize the timestamps + in *ST, if this platform suffers from a macOS and Solaris bug where + tv_nsec might be negative. Return the adjusted RESULT, setting + errno to EOVERFLOW if normalization overflowed. This function + is intended to be private to this .h file. */ +_GL_STAT_TIME_INLINE int +stat_time_normalize (int result, _GL_UNUSED struct stat *st) +{ +#if (((defined __APPLE__ && defined __MACH__) || defined __sun) \ + && defined STAT_TIMESPEC_OFFSETOF) + if (result == 0) + { + long int timespec_hz = 1000000000; + short int const ts_off[] = { STAT_TIMESPEC_OFFSETOF (st_atim), + STAT_TIMESPEC_OFFSETOF (st_mtim), + STAT_TIMESPEC_OFFSETOF (st_ctim) }; + int i; + for (i = 0; i < sizeof ts_off / sizeof *ts_off; i++) + { + struct timespec *ts = (struct timespec *) ((char *) st + ts_off[i]); + long int q = ts->tv_nsec / timespec_hz; + long int r = ts->tv_nsec % timespec_hz; + if (r < 0) + { + r += timespec_hz; + q--; + } + ts->tv_nsec = r; + /* Overflow is possible, as Solaris 11 stat can yield + tv_sec == TYPE_MINIMUM (time_t) && tv_nsec == -1000000000. */ + if (ckd_add (&ts->tv_sec, q, ts->tv_sec)) + { + errno = EOVERFLOW; + return -1; + } + } + } +#endif + return result; +} + +#ifdef __cplusplus +} +#endif + +_GL_INLINE_HEADER_END + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stat-w32.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stat-w32.c new file mode 100644 index 00000000..ddd6f598 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stat-w32.c @@ -0,0 +1,460 @@ +/* Core of implementation of fstat and stat for native Windows. + Copyright (C) 2017-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible. */ + +#include + +#if defined _WIN32 && ! defined __CYGWIN__ + +/* Attempt to make define FILE_ID_INFO. + But ensure that the redefinition of _WIN32_WINNT does not make us assume + Windows Vista or newer when building for an older version of Windows. */ +#if HAVE_SDKDDKVER_H +# include +# if _WIN32_WINNT >= _WIN32_WINNT_VISTA +# define WIN32_ASSUME_VISTA 1 +# else +# define WIN32_ASSUME_VISTA 0 +# endif +# if !defined _WIN32_WINNT || (_WIN32_WINNT < _WIN32_WINNT_WIN8) +# undef _WIN32_WINNT +# define _WIN32_WINNT _WIN32_WINNT_WIN8 +# endif +#else +# define WIN32_ASSUME_VISTA (_WIN32_WINNT >= _WIN32_WINNT_VISTA) +#endif + +#include +#include +#include +#include +#include +#include +#include + +/* Specification. */ +#include "stat-w32.h" + +#include "pathmax.h" + +/* Don't assume that UNICODE is not defined. */ +#undef LoadLibrary +#define LoadLibrary LoadLibraryA +#undef GetFinalPathNameByHandle +#define GetFinalPathNameByHandle GetFinalPathNameByHandleA + +/* Older mingw headers do not define VOLUME_NAME_NONE. */ +#ifndef VOLUME_NAME_NONE +# define VOLUME_NAME_NONE 4 +#endif + +#if !WIN32_ASSUME_VISTA + +/* Avoid warnings from gcc -Wcast-function-type. */ +# define GetProcAddress \ + (void *) GetProcAddress + +# if _GL_WINDOWS_STAT_INODES == 2 +/* GetFileInformationByHandleEx was introduced only in Windows Vista. */ +typedef DWORD (WINAPI * GetFileInformationByHandleExFuncType) (HANDLE hFile, + FILE_INFO_BY_HANDLE_CLASS fiClass, + LPVOID lpBuffer, + DWORD dwBufferSize); +static GetFileInformationByHandleExFuncType GetFileInformationByHandleExFunc = NULL; +# endif +/* GetFinalPathNameByHandle was introduced only in Windows Vista. */ +typedef DWORD (WINAPI * GetFinalPathNameByHandleFuncType) (HANDLE hFile, + LPSTR lpFilePath, + DWORD lenFilePath, + DWORD dwFlags); +static GetFinalPathNameByHandleFuncType GetFinalPathNameByHandleFunc = NULL; +static BOOL initialized = FALSE; + +static void +initialize (void) +{ + HMODULE kernel32 = LoadLibrary ("kernel32.dll"); + if (kernel32 != NULL) + { +# if _GL_WINDOWS_STAT_INODES == 2 + GetFileInformationByHandleExFunc = + (GetFileInformationByHandleExFuncType) GetProcAddress (kernel32, "GetFileInformationByHandleEx"); +# endif + GetFinalPathNameByHandleFunc = + (GetFinalPathNameByHandleFuncType) GetProcAddress (kernel32, "GetFinalPathNameByHandleA"); + } + initialized = TRUE; +} + +#else + +# define GetFileInformationByHandleExFunc GetFileInformationByHandleEx +# define GetFinalPathNameByHandleFunc GetFinalPathNameByHandle + +#endif + +/* Converts a FILETIME to GMT time since 1970-01-01 00:00:00. */ +#if _GL_WINDOWS_STAT_TIMESPEC +struct timespec +_gl_convert_FILETIME_to_timespec (const FILETIME *ft) +{ + struct timespec result; + /* FILETIME: */ + unsigned long long since_1601 = + ((unsigned long long) ft->dwHighDateTime << 32) + | (unsigned long long) ft->dwLowDateTime; + if (since_1601 == 0) + { + result.tv_sec = 0; + result.tv_nsec = 0; + } + else + { + /* Between 1601-01-01 and 1970-01-01 there were 280 normal years and 89 + leap years, in total 134774 days. */ + unsigned long long since_1970 = + since_1601 - (unsigned long long) 134774 * (unsigned long long) 86400 * (unsigned long long) 10000000; + result.tv_sec = since_1970 / (unsigned long long) 10000000; + result.tv_nsec = (unsigned long) (since_1970 % (unsigned long long) 10000000) * 100; + } + return result; +} +#else +time_t +_gl_convert_FILETIME_to_POSIX (const FILETIME *ft) +{ + /* FILETIME: */ + unsigned long long since_1601 = + ((unsigned long long) ft->dwHighDateTime << 32) + | (unsigned long long) ft->dwLowDateTime; + if (since_1601 == 0) + return 0; + else + { + /* Between 1601-01-01 and 1970-01-01 there were 280 normal years and 89 + leap years, in total 134774 days. */ + unsigned long long since_1970 = + since_1601 - (unsigned long long) 134774 * (unsigned long long) 86400 * (unsigned long long) 10000000; + return since_1970 / (unsigned long long) 10000000; + } +} +#endif + +/* Fill *BUF with information about the file designated by H. + PATH is the file name, if known, otherwise NULL. + Return 0 if successful, or -1 with errno set upon failure. */ +int +_gl_fstat_by_handle (HANDLE h, const char *path, struct stat *buf) +{ + /* GetFileType + */ + DWORD type = GetFileType (h); + if (type == FILE_TYPE_DISK) + { +#if !WIN32_ASSUME_VISTA + if (!initialized) + initialize (); +#endif + + /* st_mode can be determined through + GetFileAttributesEx + + + or through + GetFileInformationByHandle + + + or through + GetFileInformationByHandleEx with argument FileBasicInfo + + + The latter requires -D_WIN32_WINNT=_WIN32_WINNT_VISTA or higher. */ + BY_HANDLE_FILE_INFORMATION info; + if (! GetFileInformationByHandle (h, &info)) + goto failed; + + /* Test for error conditions before starting to fill *buf. */ + if (sizeof (buf->st_size) <= 4 && info.nFileSizeHigh > 0) + { + errno = EOVERFLOW; + return -1; + } + +#if _GL_WINDOWS_STAT_INODES + /* st_ino can be determined through + GetFileInformationByHandle + + + as 64 bits, or through + GetFileInformationByHandleEx with argument FileIdInfo + + + as 128 bits. + The latter requires -D_WIN32_WINNT=_WIN32_WINNT_WIN8 or higher. */ + /* Experiments show that GetFileInformationByHandleEx does not provide + much more information than GetFileInformationByHandle: + * The dwVolumeSerialNumber from GetFileInformationByHandle is equal + to the low 32 bits of the 64-bit VolumeSerialNumber from + GetFileInformationByHandleEx, and is apparently sufficient for + identifying the device. + * The nFileIndex from GetFileInformationByHandle is equal to the low + 64 bits of the 128-bit FileId from GetFileInformationByHandleEx, + and the high 64 bits of this 128-bit FileId are zero. + * On a FAT file system, GetFileInformationByHandleEx fails with error + ERROR_INVALID_PARAMETER, whereas GetFileInformationByHandle + succeeds. + * On a CIFS/SMB file system, GetFileInformationByHandleEx fails with + error ERROR_INVALID_LEVEL, whereas GetFileInformationByHandle + succeeds. */ +# if _GL_WINDOWS_STAT_INODES == 2 + if (GetFileInformationByHandleExFunc != NULL) + { + FILE_ID_INFO id; + if (GetFileInformationByHandleExFunc (h, FileIdInfo, &id, sizeof (id))) + { + buf->st_dev = id.VolumeSerialNumber; + static_assert (sizeof (ino_t) == sizeof (id.FileId)); + memcpy (&buf->st_ino, &id.FileId, sizeof (ino_t)); + goto ino_done; + } + else + { + switch (GetLastError ()) + { + case ERROR_INVALID_PARAMETER: /* older Windows version, or FAT */ + case ERROR_INVALID_LEVEL: /* CIFS/SMB file system */ + goto fallback; + default: + goto failed; + } + } + } + fallback: ; + /* Fallback for older Windows versions. */ + buf->st_dev = info.dwVolumeSerialNumber; + buf->st_ino._gl_ino[0] = ((ULONGLONG) info.nFileIndexHigh << 32) | (ULONGLONG) info.nFileIndexLow; + buf->st_ino._gl_ino[1] = 0; + ino_done: ; +# else /* _GL_WINDOWS_STAT_INODES == 1 */ + buf->st_dev = info.dwVolumeSerialNumber; + buf->st_ino = ((ULONGLONG) info.nFileIndexHigh << 32) | (ULONGLONG) info.nFileIndexLow; +# endif +#else + /* st_ino is not wide enough for identifying a file on a device. + Without st_ino, st_dev is pointless. */ + buf->st_dev = 0; + buf->st_ino = 0; +#endif + + /* st_mode. */ + unsigned int mode = + /* XXX How to handle FILE_ATTRIBUTE_REPARSE_POINT ? */ + ((info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? _S_IFDIR | S_IEXEC_UGO : _S_IFREG) + | S_IREAD_UGO + | ((info.dwFileAttributes & FILE_ATTRIBUTE_READONLY) ? 0 : S_IWRITE_UGO); + if (!(info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) + { + /* Determine whether the file is executable by looking at the file + name suffix. + If the file name is already known, use it. Otherwise, for + non-empty files, it can be determined through + GetFinalPathNameByHandle + + or through + GetFileInformationByHandleEx with argument FileNameInfo + + + Both require -D_WIN32_WINNT=_WIN32_WINNT_VISTA or higher. */ + if (info.nFileSizeHigh > 0 || info.nFileSizeLow > 0) + { + char fpath[PATH_MAX]; + if (path != NULL + || (GetFinalPathNameByHandleFunc != NULL + && GetFinalPathNameByHandleFunc (h, fpath, sizeof (fpath), VOLUME_NAME_NONE) + < sizeof (fpath) + && (path = fpath, 1))) + { + const char *last_dot = NULL; + const char *p; + for (p = path; *p != '\0'; p++) + if (*p == '.') + last_dot = p; + if (last_dot != NULL) + { + const char *suffix = last_dot + 1; + if (_stricmp (suffix, "exe") == 0 + || _stricmp (suffix, "bat") == 0 + || _stricmp (suffix, "cmd") == 0 + || _stricmp (suffix, "com") == 0) + mode |= S_IEXEC_UGO; + } + } + else + /* Cannot determine file name. Pretend that it is executable. */ + mode |= S_IEXEC_UGO; + } + } + buf->st_mode = mode; + + /* st_nlink can be determined through + GetFileInformationByHandle + + + or through + GetFileInformationByHandleEx with argument FileStandardInfo + + + The latter requires -D_WIN32_WINNT=_WIN32_WINNT_VISTA or higher. */ + buf->st_nlink = (info.nNumberOfLinks > SHRT_MAX ? SHRT_MAX : info.nNumberOfLinks); + + /* There's no easy way to map the Windows SID concept to an integer. */ + buf->st_uid = 0; + buf->st_gid = 0; + + /* st_rdev is irrelevant for normal files and directories. */ + buf->st_rdev = 0; + + /* st_size can be determined through + GetFileSizeEx + + or through + GetFileAttributesEx + + + or through + GetFileInformationByHandle + + + or through + GetFileInformationByHandleEx with argument FileStandardInfo + + + The latter requires -D_WIN32_WINNT=_WIN32_WINNT_VISTA or higher. */ + if (sizeof (buf->st_size) <= 4) + /* Range check already done above. */ + buf->st_size = info.nFileSizeLow; + else + buf->st_size = ((long long) info.nFileSizeHigh << 32) | (long long) info.nFileSizeLow; + + /* st_atime, st_mtime, st_ctime can be determined through + GetFileTime + + or through + GetFileAttributesEx + + + or through + GetFileInformationByHandle + + + or through + GetFileInformationByHandleEx with argument FileBasicInfo + + + The latter requires -D_WIN32_WINNT=_WIN32_WINNT_VISTA or higher. */ +#if _GL_WINDOWS_STAT_TIMESPEC + buf->st_atim = _gl_convert_FILETIME_to_timespec (&info.ftLastAccessTime); + buf->st_mtim = _gl_convert_FILETIME_to_timespec (&info.ftLastWriteTime); + buf->st_ctim = _gl_convert_FILETIME_to_timespec (&info.ftCreationTime); +#else + buf->st_atime = _gl_convert_FILETIME_to_POSIX (&info.ftLastAccessTime); + buf->st_mtime = _gl_convert_FILETIME_to_POSIX (&info.ftLastWriteTime); + buf->st_ctime = _gl_convert_FILETIME_to_POSIX (&info.ftCreationTime); +#endif + + return 0; + } + else if (type == FILE_TYPE_CHAR || type == FILE_TYPE_PIPE) + { + buf->st_dev = 0; +#if _GL_WINDOWS_STAT_INODES == 2 + buf->st_ino._gl_ino[0] = buf->st_ino._gl_ino[1] = 0; +#else + buf->st_ino = 0; +#endif + buf->st_mode = (type == FILE_TYPE_PIPE ? _S_IFIFO : _S_IFCHR); + buf->st_nlink = 1; + buf->st_uid = 0; + buf->st_gid = 0; + buf->st_rdev = 0; + if (type == FILE_TYPE_PIPE) + { + /* PeekNamedPipe + */ + DWORD bytes_available; + if (PeekNamedPipe (h, NULL, 0, NULL, &bytes_available, NULL)) + buf->st_size = bytes_available; + else + buf->st_size = 0; + } + else + buf->st_size = 0; +#if _GL_WINDOWS_STAT_TIMESPEC + buf->st_atim.tv_sec = 0; buf->st_atim.tv_nsec = 0; + buf->st_mtim.tv_sec = 0; buf->st_mtim.tv_nsec = 0; + buf->st_ctim.tv_sec = 0; buf->st_ctim.tv_nsec = 0; +#else + buf->st_atime = 0; + buf->st_mtime = 0; + buf->st_ctime = 0; +#endif + return 0; + } + else + { + errno = ENOENT; + return -1; + } + + failed: + { + DWORD error = GetLastError (); + #if 0 + fprintf (stderr, "_gl_fstat_by_handle error 0x%x\n", (unsigned int) error); + #endif + switch (error) + { + case ERROR_ACCESS_DENIED: + case ERROR_SHARING_VIOLATION: + errno = EACCES; + break; + + case ERROR_OUTOFMEMORY: + errno = ENOMEM; + break; + + case ERROR_WRITE_FAULT: + case ERROR_READ_FAULT: + case ERROR_GEN_FAILURE: + errno = EIO; + break; + + default: + errno = EINVAL; + break; + } + return -1; + } +} + +#else + +/* This declaration is solely to ensure that after preprocessing + this file is never empty. */ +typedef int dummy; + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stat-w32.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stat-w32.h new file mode 100644 index 00000000..392faed1 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stat-w32.h @@ -0,0 +1,37 @@ +/* Core of implementation of fstat and stat for native Windows. + Copyright (C) 2017-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef _STAT_W32_H +#define _STAT_W32_H 1 + +/* Converts a FILETIME to GMT time since 1970-01-01 00:00:00. */ +#if _GL_WINDOWS_STAT_TIMESPEC +extern struct timespec _gl_convert_FILETIME_to_timespec (const FILETIME *ft); +#else +extern time_t _gl_convert_FILETIME_to_POSIX (const FILETIME *ft); +#endif + +/* Fill *BUF with information about the file designated by H. + PATH is the file name, if known, otherwise NULL. + Return 0 if successful, or -1 with errno set upon failure. */ +extern int _gl_fstat_by_handle (HANDLE h, const char *path, struct stat *buf); + +/* Bitmasks for st_mode. */ +#define S_IREAD_UGO (_S_IREAD | (_S_IREAD >> 3) | (_S_IREAD >> 6)) +#define S_IWRITE_UGO (_S_IWRITE | (_S_IWRITE >> 3) | (_S_IWRITE >> 6)) +#define S_IEXEC_UGO (_S_IEXEC | (_S_IEXEC >> 3) | (_S_IEXEC >> 6)) + +#endif /* _STAT_W32_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stat.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stat.c new file mode 100644 index 00000000..ecf9f9bb --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stat.c @@ -0,0 +1,438 @@ +/* Work around platform bugs in stat. + Copyright (C) 2009-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Eric Blake and Bruno Haible. */ + +/* If the user's config.h happens to include , let it include only + the system's here, so that orig_stat doesn't recurse to + rpl_stat. */ +#define __need_system_sys_stat_h +#include + +/* Get the original definition of stat. It might be defined as a macro. */ +#include +#include +#undef __need_system_sys_stat_h + +#if defined _WIN32 && ! defined __CYGWIN__ +# define WINDOWS_NATIVE +#endif + +#if !defined WINDOWS_NATIVE + +static int +orig_stat (const char *filename, struct stat *buf) +{ + return stat (filename, buf); +} + +#endif + +/* Specification. */ +#ifdef __osf__ +/* Write "sys/stat.h" here, not , otherwise OSF/1 5.1 DTK cc + eliminates this include because of the preliminary #include + above. */ +# include "sys/stat.h" +#else +# include +#endif + +#include "stat-time.h" + +#include +#include +#include +#include "filename.h" +#include "malloca.h" + +#ifdef WINDOWS_NATIVE +# define WIN32_LEAN_AND_MEAN +# include +# include "stat-w32.h" +/* Don't assume that UNICODE is not defined. */ +# undef WIN32_FIND_DATA +# define WIN32_FIND_DATA WIN32_FIND_DATAA +# undef CreateFile +# define CreateFile CreateFileA +# undef FindFirstFile +# define FindFirstFile FindFirstFileA +#endif + +#ifdef WINDOWS_NATIVE +/* Return TRUE if the given file name denotes an UNC root. */ +static BOOL +is_unc_root (const char *rname) +{ + /* Test whether it has the syntax '\\server\share'. */ + if (ISSLASH (rname[0]) && ISSLASH (rname[1])) + { + /* It starts with two slashes. Find the next slash. */ + const char *p = rname + 2; + const char *q = p; + while (*q != '\0' && !ISSLASH (*q)) + q++; + if (q > p && *q != '\0') + { + /* Found the next slash at q. */ + q++; + const char *r = q; + while (*r != '\0' && !ISSLASH (*r)) + r++; + if (r > q && *r == '\0') + return TRUE; + } + } + return FALSE; +} +#endif + +/* Store information about NAME into ST. Work around bugs with + trailing slashes. Mingw has other bugs (such as st_ino always + being 0 on success) which this wrapper does not work around. But + at least this implementation provides the ability to emulate fchdir + correctly. */ + +int +rpl_stat (char const *name, struct stat *buf) +{ +#ifdef WINDOWS_NATIVE + /* Fill the fields ourselves, because the original stat function returns + values for st_atime, st_mtime, st_ctime that depend on the current time + zone. See + */ + /* XXX Should we convert to wchar_t* and prepend '\\?\', in order to work + around length limitations + ? */ + + /* POSIX + specifies: "More than two leading characters shall be treated as + a single character." */ + if (ISSLASH (name[0]) && ISSLASH (name[1]) && ISSLASH (name[2])) + { + name += 2; + while (ISSLASH (name[1])) + name++; + } + + size_t len = strlen (name); + size_t drive_prefix_len = (HAS_DEVICE (name) ? 2 : 0); + + /* Remove trailing slashes (except the very first one, at position + drive_prefix_len), but remember their presence. */ + size_t rlen; + bool check_dir = false; + + rlen = len; + while (rlen > drive_prefix_len && ISSLASH (name[rlen-1])) + { + check_dir = true; + if (rlen == drive_prefix_len + 1) + break; + rlen--; + } + + /* Handle '' and 'C:'. */ + if (!check_dir && rlen == drive_prefix_len) + { + errno = ENOENT; + return -1; + } + + /* Handle '\\'. */ + if (rlen == 1 && ISSLASH (name[0]) && len >= 2) + { + errno = ENOENT; + return -1; + } + + const char *rname; + char *malloca_rname; + if (rlen == len) + { + rname = name; + malloca_rname = NULL; + } + else + { + malloca_rname = malloca (rlen + 1); + if (malloca_rname == NULL) + { + errno = ENOMEM; + return -1; + } + memcpy (malloca_rname, name, rlen); + malloca_rname[rlen] = '\0'; + rname = malloca_rname; + } + + /* There are two ways to get at the requested information: + - by scanning the parent directory and examining the relevant + directory entry, + - by opening the file directly. + The first approach fails for root directories (e.g. 'C:\') and + UNC root directories (e.g. '\\server\share'). + The second approach fails for some system files (e.g. 'C:\pagefile.sys' + and 'C:\hiberfil.sys'): ERROR_SHARING_VIOLATION. + The second approach gives more information (in particular, correct + st_dev, st_ino, st_nlink fields). + So we use the second approach and, as a fallback except for root and + UNC root directories, also the first approach. */ + { + int ret; + + { + /* Approach based on the file. */ + + /* Open a handle to the file. + CreateFile + + */ + HANDLE h = + CreateFile (rname, + FILE_READ_ATTRIBUTES, + FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, + NULL, + OPEN_EXISTING, + /* FILE_FLAG_POSIX_SEMANTICS (treat file names that differ only + in case as different) makes sense only when applied to *all* + filesystem operations. */ + FILE_FLAG_BACKUP_SEMANTICS /* | FILE_FLAG_POSIX_SEMANTICS */, + NULL); + if (h != INVALID_HANDLE_VALUE) + { + ret = _gl_fstat_by_handle (h, rname, buf); + CloseHandle (h); + goto done; + } + } + + /* Test for root and UNC root directories. */ + if ((rlen == drive_prefix_len + 1 && ISSLASH (rname[drive_prefix_len])) + || is_unc_root (rname)) + goto failed; + + /* Fallback. */ + { + /* Approach based on the directory entry. */ + + if (strchr (rname, '?') != NULL || strchr (rname, '*') != NULL) + { + /* Other Windows API functions would fail with error + ERROR_INVALID_NAME. */ + if (malloca_rname != NULL) + freea (malloca_rname); + errno = ENOENT; + return -1; + } + + /* Get the details about the directory entry. This can be done through + FindFirstFile + + + or through + FindFirstFileEx with argument FindExInfoBasic + + + */ + WIN32_FIND_DATA info; + HANDLE h = FindFirstFile (rname, &info); + if (h == INVALID_HANDLE_VALUE) + goto failed; + + /* Test for error conditions before starting to fill *buf. */ + if (sizeof (buf->st_size) <= 4 && info.nFileSizeHigh > 0) + { + FindClose (h); + if (malloca_rname != NULL) + freea (malloca_rname); + errno = EOVERFLOW; + return -1; + } + +# if _GL_WINDOWS_STAT_INODES + buf->st_dev = 0; +# if _GL_WINDOWS_STAT_INODES == 2 + buf->st_ino._gl_ino[0] = buf->st_ino._gl_ino[1] = 0; +# else /* _GL_WINDOWS_STAT_INODES == 1 */ + buf->st_ino = 0; +# endif +# else + /* st_ino is not wide enough for identifying a file on a device. + Without st_ino, st_dev is pointless. */ + buf->st_dev = 0; + buf->st_ino = 0; +# endif + + /* st_mode. */ + unsigned int mode = + /* XXX How to handle FILE_ATTRIBUTE_REPARSE_POINT ? */ + ((info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? _S_IFDIR | S_IEXEC_UGO : _S_IFREG) + | S_IREAD_UGO + | ((info.dwFileAttributes & FILE_ATTRIBUTE_READONLY) ? 0 : S_IWRITE_UGO); + if (!(info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) + { + /* Determine whether the file is executable by looking at the file + name suffix. */ + if (info.nFileSizeHigh > 0 || info.nFileSizeLow > 0) + { + const char *last_dot = NULL; + const char *p; + for (p = info.cFileName; *p != '\0'; p++) + if (*p == '.') + last_dot = p; + if (last_dot != NULL) + { + const char *suffix = last_dot + 1; + if (_stricmp (suffix, "exe") == 0 + || _stricmp (suffix, "bat") == 0 + || _stricmp (suffix, "cmd") == 0 + || _stricmp (suffix, "com") == 0) + mode |= S_IEXEC_UGO; + } + } + } + buf->st_mode = mode; + + /* st_nlink. Ignore hard links here. */ + buf->st_nlink = 1; + + /* There's no easy way to map the Windows SID concept to an integer. */ + buf->st_uid = 0; + buf->st_gid = 0; + + /* st_rdev is irrelevant for normal files and directories. */ + buf->st_rdev = 0; + + /* st_size. */ + if (sizeof (buf->st_size) <= 4) + /* Range check already done above. */ + buf->st_size = info.nFileSizeLow; + else + buf->st_size = ((long long) info.nFileSizeHigh << 32) | (long long) info.nFileSizeLow; + + /* st_atime, st_mtime, st_ctime. */ +# if _GL_WINDOWS_STAT_TIMESPEC + buf->st_atim = _gl_convert_FILETIME_to_timespec (&info.ftLastAccessTime); + buf->st_mtim = _gl_convert_FILETIME_to_timespec (&info.ftLastWriteTime); + buf->st_ctim = _gl_convert_FILETIME_to_timespec (&info.ftCreationTime); +# else + buf->st_atime = _gl_convert_FILETIME_to_POSIX (&info.ftLastAccessTime); + buf->st_mtime = _gl_convert_FILETIME_to_POSIX (&info.ftLastWriteTime); + buf->st_ctime = _gl_convert_FILETIME_to_POSIX (&info.ftCreationTime); +# endif + + FindClose (h); + + ret = 0; + } + + done: + if (ret >= 0 && check_dir && !S_ISDIR (buf->st_mode)) + { + errno = ENOTDIR; + ret = -1; + } + if (malloca_rname != NULL) + { + int saved_errno = errno; + freea (malloca_rname); + errno = saved_errno; + } + return ret; + } + + failed: + { + DWORD error = GetLastError (); + #if 0 + fprintf (stderr, "rpl_stat error 0x%x\n", (unsigned int) error); + #endif + + if (malloca_rname != NULL) + freea (malloca_rname); + + switch (error) + { + /* Some of these errors probably cannot happen with the specific flags + that we pass to CreateFile. But who knows... */ + case ERROR_FILE_NOT_FOUND: /* The last component of rname does not exist. */ + case ERROR_PATH_NOT_FOUND: /* Some directory component in rname does not exist. */ + case ERROR_BAD_PATHNAME: /* rname is such as '\\server'. */ + case ERROR_BAD_NET_NAME: /* rname is such as '\\server\nonexistentshare'. */ + case ERROR_INVALID_NAME: /* rname contains wildcards, misplaced colon, etc. */ + case ERROR_DIRECTORY: + errno = ENOENT; + break; + + case ERROR_ACCESS_DENIED: /* rname is such as 'C:\System Volume Information\foo'. */ + case ERROR_SHARING_VIOLATION: /* rname is such as 'C:\pagefile.sys' (second approach only). */ + /* XXX map to EACCES or EPERM? */ + errno = EACCES; + break; + + case ERROR_OUTOFMEMORY: + errno = ENOMEM; + break; + + case ERROR_WRITE_PROTECT: + errno = EROFS; + break; + + case ERROR_WRITE_FAULT: + case ERROR_READ_FAULT: + case ERROR_GEN_FAILURE: + errno = EIO; + break; + + case ERROR_BUFFER_OVERFLOW: + case ERROR_FILENAME_EXCED_RANGE: + errno = ENAMETOOLONG; + break; + + case ERROR_DELETE_PENDING: /* XXX map to EACCES or EPERM? */ + errno = EPERM; + break; + + default: + errno = EINVAL; + break; + } + + return -1; + } +#else + int result = orig_stat (name, buf); + if (result == 0) + { +# if REPLACE_FUNC_STAT_FILE + /* Solaris 9 mistakenly succeeds when given a non-directory with a + trailing slash. */ + if (!S_ISDIR (buf->st_mode)) + { + size_t len = strlen (name); + if (ISSLASH (name[len - 1])) + { + errno = ENOTDIR; + return -1; + } + } +# endif /* REPLACE_FUNC_STAT_FILE */ + result = stat_time_normalize (result, buf); + } + return result; +#endif +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stdarg.in.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stdarg.in.h new file mode 100644 index 00000000..65a39775 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stdarg.in.h @@ -0,0 +1,40 @@ +/* Substitute for and wrapper around . + Copyright (C) 2008-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef _@GUARD_PREFIX@_STDARG_H + +#if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +#endif +@PRAGMA_COLUMNS@ + +/* The include_next requires a split double-inclusion guard. */ +#@INCLUDE_NEXT@ @NEXT_STDARG_H@ + +#ifndef _@GUARD_PREFIX@_STDARG_H +#define _@GUARD_PREFIX@_STDARG_H + +/* This file uses va_copy. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +#ifndef va_copy +# define va_copy(a,b) ((a) = (b)) +#endif + +#endif /* _@GUARD_PREFIX@_STDARG_H */ +#endif /* _@GUARD_PREFIX@_STDARG_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stdckdint.in.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stdckdint.in.h new file mode 100644 index 00000000..91848806 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stdckdint.in.h @@ -0,0 +1,35 @@ +/* stdckdint.h -- checked integer arithmetic + + Copyright 2022-2024 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef _GL_STDCKDINT_H +#define _GL_STDCKDINT_H + +#include "intprops-internal.h" + +/* Store into *R the low-order bits of A + B, A - B, A * B, respectively. + Return 1 if the result overflows, 0 otherwise. + A, B, and *R can have any integer type other than char, bool, a + bit-precise integer type, or an enumeration type. + + These are like the standard macros introduced in C23, except that + arguments should not have side effects. */ + +#define ckd_add(r, a, b) ((bool) _GL_INT_ADD_WRAPV (a, b, r)) +#define ckd_sub(r, a, b) ((bool) _GL_INT_SUBTRACT_WRAPV (a, b, r)) +#define ckd_mul(r, a, b) ((bool) _GL_INT_MULTIPLY_WRAPV (a, b, r)) + +#endif /* _GL_STDCKDINT_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stddef.in.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stddef.in.h new file mode 100644 index 00000000..fa8998d9 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stddef.in.h @@ -0,0 +1,213 @@ +/* A substitute for POSIX 2008 , for platforms that have issues. + + Copyright (C) 2009-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Eric Blake. */ + +/* + * POSIX 2008 and ISO C 23 for platforms that have issues. + * + */ + +#if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +#endif +@PRAGMA_COLUMNS@ + +#if defined __need_wchar_t || defined __need_size_t \ + || defined __need_ptrdiff_t || defined __need_NULL \ + || defined __need_wint_t +/* Special invocation convention inside gcc header files. In + particular, gcc provides a version of that blindly + redefines NULL even when __need_wint_t was defined, even though + wint_t is not normally provided by . Hence, we must + remember if special invocation has ever been used to obtain wint_t, + in which case we need to clean up NULL yet again. */ + +# if !(defined _@GUARD_PREFIX@_STDDEF_H && defined _@GUARD_PREFIX@_STDDEF_WINT_T) +# ifdef __need_wint_t +# define _@GUARD_PREFIX@_STDDEF_WINT_T +# endif +# @INCLUDE_NEXT@ @NEXT_STDDEF_H@ + /* On TinyCC, make sure that the macros that indicate the special invocation + convention get undefined. */ +# undef __need_wchar_t +# undef __need_size_t +# undef __need_ptrdiff_t +# undef __need_NULL +# undef __need_wint_t +# endif + +#else +/* Normal invocation convention. */ + +# ifndef _@GUARD_PREFIX@_STDDEF_H + +/* On AIX 7.2, with xlc in 64-bit mode, defines max_align_t to a + type with alignment 4, but 'long' has alignment 8. */ +# if defined _AIX && defined __LP64__ && !@HAVE_MAX_ALIGN_T@ +# if !GNULIB_defined_max_align_t +# ifdef _MAX_ALIGN_T +/* /usr/include/stddef.h has already defined max_align_t. Override it. */ +typedef long rpl_max_align_t; +# define max_align_t rpl_max_align_t +# else +/* Prevent /usr/include/stddef.h from defining max_align_t. */ +typedef long max_align_t; +# define _MAX_ALIGN_T +# endif +# define __CLANG_MAX_ALIGN_T_DEFINED +# define GNULIB_defined_max_align_t 1 +# endif +# endif + +/* The include_next requires a split double-inclusion guard. */ + +# @INCLUDE_NEXT@ @NEXT_STDDEF_H@ + +/* On NetBSD 5.0, the definition of NULL lacks proper parentheses. */ +# if (@REPLACE_NULL@ \ + && (!defined _@GUARD_PREFIX@_STDDEF_H || defined _@GUARD_PREFIX@_STDDEF_WINT_T)) +# undef NULL +# ifdef __cplusplus + /* ISO C++ says that the macro NULL must expand to an integer constant + expression, hence '((void *) 0)' is not allowed in C++. */ +# if __GNUG__ >= 3 + /* GNU C++ has a __null macro that behaves like an integer ('int' or + 'long') but has the same size as a pointer. Use that, to avoid + warnings. */ +# define NULL __null +# else +# define NULL 0L +# endif +# else +# define NULL ((void *) 0) +# endif +# endif + +# ifndef _@GUARD_PREFIX@_STDDEF_H +# define _@GUARD_PREFIX@_STDDEF_H + +/* This file uses _Noreturn, _GL_ATTRIBUTE_NOTHROW. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +/* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions. + */ +#ifndef _GL_ATTRIBUTE_NOTHROW +# if defined __cplusplus +# if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major >= 4 +# if __cplusplus >= 201103L +# define _GL_ATTRIBUTE_NOTHROW noexcept (true) +# else +# define _GL_ATTRIBUTE_NOTHROW throw () +# endif +# else +# define _GL_ATTRIBUTE_NOTHROW +# endif +# else +# if (__GNUC__ + (__GNUC_MINOR__ >= 3) > 3) || defined __clang__ +# define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__)) +# else +# define _GL_ATTRIBUTE_NOTHROW +# endif +# endif +#endif + +/* Some platforms lack wchar_t. */ +#if !@HAVE_WCHAR_T@ +# define wchar_t int +#endif + +/* Some platforms lack max_align_t. The check for _GCC_MAX_ALIGN_T is + a hack in case the configure-time test was done with g++ even though + we are currently compiling with gcc. + On MSVC, max_align_t is defined only in C++ mode, after was + included. Its definition is good since it has an alignment of 8 (on x86 + and x86_64). + Similarly on OS/2 kLIBC. */ +#if (defined _MSC_VER || (defined __KLIBC__ && !defined __LIBCN__)) \ + && defined __cplusplus +# include +#else +# if ! (@HAVE_MAX_ALIGN_T@ || (defined _GCC_MAX_ALIGN_T && !defined __clang__)) +# if !GNULIB_defined_max_align_t +/* On the x86, the maximum storage alignment of double, long, etc. is 4, + but GCC's C11 ABI for x86 says that max_align_t has an alignment of 8, + and the C11 standard allows this. Work around this problem by + using __alignof__ (which returns 8 for double) rather than _Alignof + (which returns 4), and align each union member accordingly. */ +# if defined __GNUC__ || (__clang_major__ >= 4) +# define _GL_STDDEF_ALIGNAS(type) \ + __attribute__ ((__aligned__ (__alignof__ (type)))) +# else +# define _GL_STDDEF_ALIGNAS(type) /* */ +# endif +typedef union +{ + char *__p _GL_STDDEF_ALIGNAS (char *); + double __d _GL_STDDEF_ALIGNAS (double); + long double __ld _GL_STDDEF_ALIGNAS (long double); + long int __i _GL_STDDEF_ALIGNAS (long int); +} rpl_max_align_t; +# define max_align_t rpl_max_align_t +# define __CLANG_MAX_ALIGN_T_DEFINED +# define GNULIB_defined_max_align_t 1 +# endif +# endif +#endif + +/* ISO C 23 § 7.21.1 The unreachable macro */ +#ifndef unreachable + +/* Code borrowed from verify.h. */ +# ifndef _GL_HAS_BUILTIN_UNREACHABLE +# if defined __clang_major__ && __clang_major__ < 5 +# define _GL_HAS_BUILTIN_UNREACHABLE 0 +# elif 4 < __GNUC__ + (5 <= __GNUC_MINOR__) +# define _GL_HAS_BUILTIN_UNREACHABLE 1 +# elif defined __has_builtin +# define _GL_HAS_BUILTIN_UNREACHABLE __has_builtin (__builtin_unreachable) +# else +# define _GL_HAS_BUILTIN_UNREACHABLE 0 +# endif +# endif + +# if _GL_HAS_BUILTIN_UNREACHABLE +# define unreachable() __builtin_unreachable () +# elif 1200 <= _MSC_VER +# define unreachable() __assume (0) +# else +/* Declare abort(), without including . */ +extern +# if defined __cplusplus +"C" +# endif +_Noreturn +void abort (void) +# if defined __cplusplus && (__GLIBC__ >= 2) +_GL_ATTRIBUTE_NOTHROW +# endif +; +# define unreachable() abort () +# endif + +#endif + +# endif /* _@GUARD_PREFIX@_STDDEF_H */ +# endif /* _@GUARD_PREFIX@_STDDEF_H */ +#endif /* __need_XXX */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stdint.in.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stdint.in.h new file mode 100644 index 00000000..fea7483b --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stdint.in.h @@ -0,0 +1,742 @@ +/* Copyright (C) 2001-2002, 2004-2024 Free Software Foundation, Inc. + Written by Paul Eggert, Bruno Haible, Sam Steingold, Peter Burwood. + This file is part of gnulib. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* + * ISO C 99 for platforms that lack it. + * + */ + +#ifndef _@GUARD_PREFIX@_STDINT_H + +#if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +#endif +@PRAGMA_COLUMNS@ + +/* When including a system file that in turn includes , + use the system , not our substitute. This avoids + problems with (for example) VMS, whose includes + . */ +#define _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H + +/* On Android (Bionic libc), includes this file before + having defined 'time_t'. Therefore in this case avoid including + other system header files; just include the system's . + Ideally we should test __BIONIC__ here, but it is only defined after + has been included; hence test __ANDROID__ instead. */ +#if defined __ANDROID__ && defined _GL_INCLUDING_SYS_TYPES_H +# @INCLUDE_NEXT@ @NEXT_STDINT_H@ +#else + +/* Get those types that are already defined in other system include + files, so that we can "#define int8_t signed char" below without + worrying about a later system include file containing a "typedef + signed char int8_t;" that will get messed up by our macro. Our + macros should all be consistent with the system versions, except + for the "fast" types and macros, which we recommend against using + in public interfaces due to compiler differences. */ + +#if @HAVE_STDINT_H@ +# if defined __sgi && ! defined __c99 + /* Bypass IRIX's if in C89 mode, since it merely annoys users + with "This header file is to be used only for c99 mode compilations" + diagnostics. */ +# define __STDINT_H__ +# endif + + /* Some pre-C++11 implementations need this. */ +# ifdef __cplusplus +# ifndef __STDC_CONSTANT_MACROS +# define __STDC_CONSTANT_MACROS 1 +# endif +# ifndef __STDC_LIMIT_MACROS +# define __STDC_LIMIT_MACROS 1 +# endif +# endif + + /* Other systems may have an incomplete or buggy . + Include it before , since any "#include " + in would reinclude us, skipping our contents because + _@GUARD_PREFIX@_STDINT_H is defined. + The include_next requires a split double-inclusion guard. */ +# @INCLUDE_NEXT@ @NEXT_STDINT_H@ +#endif + +#if ! defined _@GUARD_PREFIX@_STDINT_H && ! defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H +#define _@GUARD_PREFIX@_STDINT_H + +/* Get SCHAR_MIN, SCHAR_MAX, UCHAR_MAX, INT_MIN, INT_MAX, + LONG_MIN, LONG_MAX, ULONG_MAX, _GL_INTEGER_WIDTH. */ +#include + +/* Override WINT_MIN and WINT_MAX if gnulib's or overrides + wint_t. */ +#if @GNULIBHEADERS_OVERRIDE_WINT_T@ +# undef WINT_MIN +# undef WINT_MAX +# define WINT_MIN 0x0U +# define WINT_MAX 0xffffffffU +#endif + +#if ! @HAVE_C99_STDINT_H@ + +/* defines some of the stdint.h types as well, on glibc, + IRIX 6.5, and OpenBSD 3.8 (via ). + AIX 5.2 isn't needed and causes troubles. + Mac OS X 10.4.6 includes (which is us), but + relies on the system definitions, so include + after @NEXT_STDINT_H@. */ +# if @HAVE_SYS_TYPES_H@ && ! defined _AIX +# include +# endif + +# if @HAVE_INTTYPES_H@ + /* In OpenBSD 3.8, includes , which defines + int{8,16,32,64}_t, uint{8,16,32,64}_t and __BIT_TYPES_DEFINED__. + also defines intptr_t and uintptr_t. */ +# include +# elif @HAVE_SYS_INTTYPES_H@ + /* Solaris 7 has the types except the *_fast*_t types, and + the macros except for *_FAST*_*, INTPTR_MIN, PTRDIFF_MIN, PTRDIFF_MAX. */ +# include +# endif + +# if @HAVE_SYS_BITYPES_H@ && ! defined __BIT_TYPES_DEFINED__ + /* Linux libc4 >= 4.6.7 and libc5 have a that defines + int{8,16,32,64}_t and __BIT_TYPES_DEFINED__. In libc5 >= 5.2.2 it is + included by . */ +# include +# endif + +# undef _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H + +/* Minimum and maximum values for an integer type under the usual assumption. + Return an unspecified value if BITS == 0, adding a check to pacify + picky compilers. */ + +/* These are separate macros, because if you try to merge these macros into + a single one, HP-UX cc rejects the resulting expression in constant + expressions. */ +# define _STDINT_UNSIGNED_MIN(bits, zero) \ + (zero) +# define _STDINT_SIGNED_MIN(bits, zero) \ + (~ _STDINT_MAX (1, bits, zero)) + +# define _STDINT_MAX(signed, bits, zero) \ + (((((zero) + 1) << ((bits) ? (bits) - 1 - (signed) : 0)) - 1) * 2 + 1) + +#if !GNULIB_defined_stdint_types + +/* 7.18.1.1. Exact-width integer types */ + +/* Here we assume a standard architecture where the hardware integer + types have 8, 16, 32, optionally 64 bits. */ + +# undef int8_t +# undef uint8_t +typedef signed char gl_int8_t; +typedef unsigned char gl_uint8_t; +# define int8_t gl_int8_t +# define uint8_t gl_uint8_t + +# undef int16_t +# undef uint16_t +typedef short int gl_int16_t; +typedef unsigned short int gl_uint16_t; +# define int16_t gl_int16_t +# define uint16_t gl_uint16_t + +# undef int32_t +# undef uint32_t +typedef int gl_int32_t; +typedef unsigned int gl_uint32_t; +# define int32_t gl_int32_t +# define uint32_t gl_uint32_t + +/* If the system defines INT64_MAX, assume int64_t works. That way, + if the underlying platform defines int64_t to be a 64-bit long long + int, the code below won't mistakenly define it to be a 64-bit long + int, which would mess up C++ name mangling. We must use #ifdef + rather than #if, to avoid an error with HP-UX 10.20 cc. */ + +# ifdef INT64_MAX +# define GL_INT64_T +# else +/* Do not undefine int64_t if gnulib is not being used with 64-bit + types, since otherwise it breaks platforms like Tandem/NSK. */ +# if LONG_MAX >> 31 >> 31 == 1 +# undef int64_t +typedef long int gl_int64_t; +# define int64_t gl_int64_t +# define GL_INT64_T +# elif defined _MSC_VER +# undef int64_t +typedef __int64 gl_int64_t; +# define int64_t gl_int64_t +# define GL_INT64_T +# else +# undef int64_t +typedef long long int gl_int64_t; +# define int64_t gl_int64_t +# define GL_INT64_T +# endif +# endif + +# ifdef UINT64_MAX +# define GL_UINT64_T +# else +# if ULONG_MAX >> 31 >> 31 >> 1 == 1 +# undef uint64_t +typedef unsigned long int gl_uint64_t; +# define uint64_t gl_uint64_t +# define GL_UINT64_T +# elif defined _MSC_VER +# undef uint64_t +typedef unsigned __int64 gl_uint64_t; +# define uint64_t gl_uint64_t +# define GL_UINT64_T +# else +# undef uint64_t +typedef unsigned long long int gl_uint64_t; +# define uint64_t gl_uint64_t +# define GL_UINT64_T +# endif +# endif + +/* Avoid collision with Solaris 2.5.1 etc. */ +# define _UINT8_T +# define _UINT32_T +# define _UINT64_T + + +/* 7.18.1.2. Minimum-width integer types */ + +/* Here we assume a standard architecture where the hardware integer + types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types + are the same as the corresponding N_t types. */ + +# undef int_least8_t +# undef uint_least8_t +# undef int_least16_t +# undef uint_least16_t +# undef int_least32_t +# undef uint_least32_t +# undef int_least64_t +# undef uint_least64_t +# define int_least8_t int8_t +# define uint_least8_t uint8_t +# define int_least16_t int16_t +# define uint_least16_t uint16_t +# define int_least32_t int32_t +# define uint_least32_t uint32_t +# ifdef GL_INT64_T +# define int_least64_t int64_t +# endif +# ifdef GL_UINT64_T +# define uint_least64_t uint64_t +# endif + +/* 7.18.1.3. Fastest minimum-width integer types */ + +/* Note: Other substitutes may define these types differently. + It is not recommended to use these types in public header files. */ + +/* Here we assume a standard architecture where the hardware integer + types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types + are taken from the same list of types. The following code normally + uses types consistent with glibc, as that lessens the chance of + incompatibility with older GNU hosts. */ + +# undef int_fast8_t +# undef uint_fast8_t +# undef int_fast16_t +# undef uint_fast16_t +# undef int_fast32_t +# undef uint_fast32_t +# undef int_fast64_t +# undef uint_fast64_t +typedef signed char gl_int_fast8_t; +typedef unsigned char gl_uint_fast8_t; + +# ifdef __sun +/* Define types compatible with SunOS 5.10, so that code compiled under + earlier SunOS versions works with code compiled under SunOS 5.10. */ +typedef int gl_int_fast32_t; +typedef unsigned int gl_uint_fast32_t; +# else +typedef long int gl_int_fast32_t; +typedef unsigned long int gl_uint_fast32_t; +# endif +typedef gl_int_fast32_t gl_int_fast16_t; +typedef gl_uint_fast32_t gl_uint_fast16_t; + +# define int_fast8_t gl_int_fast8_t +# define uint_fast8_t gl_uint_fast8_t +# define int_fast16_t gl_int_fast16_t +# define uint_fast16_t gl_uint_fast16_t +# define int_fast32_t gl_int_fast32_t +# define uint_fast32_t gl_uint_fast32_t +# ifdef GL_INT64_T +# define int_fast64_t int64_t +# endif +# ifdef GL_UINT64_T +# define uint_fast64_t uint64_t +# endif + +/* 7.18.1.4. Integer types capable of holding object pointers */ + +/* kLIBC's defines _INTPTR_T_DECLARED and needs its own + definitions of intptr_t and uintptr_t (which use int and unsigned) + to avoid clashes with declarations of system functions like sbrk. + Similarly, MinGW WSL-5.4.1 needs its own intptr_t and + uintptr_t to avoid conflicting declarations of system functions like + _findclose in . */ +# if !((defined __KLIBC__ && defined _INTPTR_T_DECLARED) \ + || (defined __INTPTR_WIDTH__ \ + && __INTPTR_WIDTH__ != (defined _WIN64 ? LLONG_WIDTH : LONG_WIDTH)) \ + || defined __MINGW32__) +# undef intptr_t +# undef uintptr_t +# ifdef _WIN64 +typedef long long int gl_intptr_t; +typedef unsigned long long int gl_uintptr_t; +# else +typedef long int gl_intptr_t; +typedef unsigned long int gl_uintptr_t; +# endif +# define intptr_t gl_intptr_t +# define uintptr_t gl_uintptr_t +# endif + +/* 7.18.1.5. Greatest-width integer types */ + +/* Note: These types are compiler dependent. It may be unwise to use them in + public header files. */ + +/* If the system defines INTMAX_MAX, assume that intmax_t works, and + similarly for UINTMAX_MAX and uintmax_t. This avoids problems with + assuming one type where another is used by the system. */ + +# ifndef INTMAX_MAX +# undef INTMAX_C +# undef intmax_t +# if LONG_MAX >> 30 == 1 +typedef long long int gl_intmax_t; +# define intmax_t gl_intmax_t +# elif defined GL_INT64_T +# define intmax_t int64_t +# else +typedef long int gl_intmax_t; +# define intmax_t gl_intmax_t +# endif +# endif + +# ifndef UINTMAX_MAX +# undef UINTMAX_C +# undef uintmax_t +# if ULONG_MAX >> 31 == 1 +typedef unsigned long long int gl_uintmax_t; +# define uintmax_t gl_uintmax_t +# elif defined GL_UINT64_T +# define uintmax_t uint64_t +# else +typedef unsigned long int gl_uintmax_t; +# define uintmax_t gl_uintmax_t +# endif +# endif + +/* Verify that intmax_t and uintmax_t have the same size. Too much code + breaks if this is not the case. If this check fails, the reason is likely + to be found in the autoconf macros. */ +typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof (uintmax_t) + ? 1 : -1]; + +# define GNULIB_defined_stdint_types 1 +# endif /* !GNULIB_defined_stdint_types */ + +/* 7.18.2. Limits of specified-width integer types */ + +/* 7.18.2.1. Limits of exact-width integer types */ + +/* Here we assume a standard architecture where the hardware integer + types have 8, 16, 32, optionally 64 bits. */ + +# undef INT8_MIN +# undef INT8_MAX +# undef UINT8_MAX +# define INT8_MIN (~ INT8_MAX) +# define INT8_MAX 127 +# define UINT8_MAX 255 + +# undef INT16_MIN +# undef INT16_MAX +# undef UINT16_MAX +# define INT16_MIN (~ INT16_MAX) +# define INT16_MAX 32767 +# define UINT16_MAX 65535 + +# undef INT32_MIN +# undef INT32_MAX +# undef UINT32_MAX +# define INT32_MIN (~ INT32_MAX) +# define INT32_MAX 2147483647 +# define UINT32_MAX 4294967295U + +# if defined GL_INT64_T && ! defined INT64_MAX +/* Prefer (- INTMAX_C (1) << 63) over (~ INT64_MAX) because SunPRO C 5.0 + evaluates the latter incorrectly in preprocessor expressions. */ +# define INT64_MIN (- INTMAX_C (1) << 63) +# define INT64_MAX INTMAX_C (9223372036854775807) +# endif + +# if defined GL_UINT64_T && ! defined UINT64_MAX +# define UINT64_MAX UINTMAX_C (18446744073709551615) +# endif + +/* 7.18.2.2. Limits of minimum-width integer types */ + +/* Here we assume a standard architecture where the hardware integer + types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types + are the same as the corresponding N_t types. */ + +# undef INT_LEAST8_MIN +# undef INT_LEAST8_MAX +# undef UINT_LEAST8_MAX +# define INT_LEAST8_MIN INT8_MIN +# define INT_LEAST8_MAX INT8_MAX +# define UINT_LEAST8_MAX UINT8_MAX + +# undef INT_LEAST16_MIN +# undef INT_LEAST16_MAX +# undef UINT_LEAST16_MAX +# define INT_LEAST16_MIN INT16_MIN +# define INT_LEAST16_MAX INT16_MAX +# define UINT_LEAST16_MAX UINT16_MAX + +# undef INT_LEAST32_MIN +# undef INT_LEAST32_MAX +# undef UINT_LEAST32_MAX +# define INT_LEAST32_MIN INT32_MIN +# define INT_LEAST32_MAX INT32_MAX +# define UINT_LEAST32_MAX UINT32_MAX + +# undef INT_LEAST64_MIN +# undef INT_LEAST64_MAX +# ifdef GL_INT64_T +# define INT_LEAST64_MIN INT64_MIN +# define INT_LEAST64_MAX INT64_MAX +# endif + +# undef UINT_LEAST64_MAX +# ifdef GL_UINT64_T +# define UINT_LEAST64_MAX UINT64_MAX +# endif + +/* 7.18.2.3. Limits of fastest minimum-width integer types */ + +/* Here we assume a standard architecture where the hardware integer + types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types + are taken from the same list of types. */ + +# undef INT_FAST8_MIN +# undef INT_FAST8_MAX +# undef UINT_FAST8_MAX +# define INT_FAST8_MIN SCHAR_MIN +# define INT_FAST8_MAX SCHAR_MAX +# define UINT_FAST8_MAX UCHAR_MAX + +# undef INT_FAST16_MIN +# undef INT_FAST16_MAX +# undef UINT_FAST16_MAX +# define INT_FAST16_MIN INT_FAST32_MIN +# define INT_FAST16_MAX INT_FAST32_MAX +# define UINT_FAST16_MAX UINT_FAST32_MAX + +# undef INT_FAST32_MIN +# undef INT_FAST32_MAX +# undef UINT_FAST32_MAX +# ifdef __sun +# define INT_FAST32_MIN INT_MIN +# define INT_FAST32_MAX INT_MAX +# define UINT_FAST32_MAX UINT_MAX +# else +# define INT_FAST32_MIN LONG_MIN +# define INT_FAST32_MAX LONG_MAX +# define UINT_FAST32_MAX ULONG_MAX +# endif + +# undef INT_FAST64_MIN +# undef INT_FAST64_MAX +# ifdef GL_INT64_T +# define INT_FAST64_MIN INT64_MIN +# define INT_FAST64_MAX INT64_MAX +# endif + +# undef UINT_FAST64_MAX +# ifdef GL_UINT64_T +# define UINT_FAST64_MAX UINT64_MAX +# endif + +/* 7.18.2.4. Limits of integer types capable of holding object pointers */ + +# undef INTPTR_MIN +# undef INTPTR_MAX +# undef UINTPTR_MAX +# ifdef _WIN64 +# define INTPTR_MIN LLONG_MIN +# define INTPTR_MAX LLONG_MAX +# define UINTPTR_MAX ULLONG_MAX +# else +# define INTPTR_MIN LONG_MIN +# define INTPTR_MAX LONG_MAX +# define UINTPTR_MAX ULONG_MAX +# endif + +/* 7.18.2.5. Limits of greatest-width integer types */ + +# ifndef INTMAX_MAX +# undef INTMAX_MIN +# ifdef INT64_MAX +# define INTMAX_MIN INT64_MIN +# define INTMAX_MAX INT64_MAX +# else +# define INTMAX_MIN INT32_MIN +# define INTMAX_MAX INT32_MAX +# endif +# endif + +# ifndef UINTMAX_MAX +# ifdef UINT64_MAX +# define UINTMAX_MAX UINT64_MAX +# else +# define UINTMAX_MAX UINT32_MAX +# endif +# endif + +/* 7.18.3. Limits of other integer types */ + +/* ptrdiff_t limits */ +# undef PTRDIFF_MIN +# undef PTRDIFF_MAX +# if @APPLE_UNIVERSAL_BUILD@ +# ifdef _LP64 +# define PTRDIFF_MIN _STDINT_SIGNED_MIN (64, 0l) +# define PTRDIFF_MAX _STDINT_MAX (1, 64, 0l) +# else +# define PTRDIFF_MIN _STDINT_SIGNED_MIN (32, 0) +# define PTRDIFF_MAX _STDINT_MAX (1, 32, 0) +# endif +# else +# define PTRDIFF_MIN \ + _STDINT_SIGNED_MIN (@BITSIZEOF_PTRDIFF_T@, 0@PTRDIFF_T_SUFFIX@) +# define PTRDIFF_MAX \ + _STDINT_MAX (1, @BITSIZEOF_PTRDIFF_T@, 0@PTRDIFF_T_SUFFIX@) +# endif + +/* sig_atomic_t limits */ +# undef SIG_ATOMIC_MIN +# undef SIG_ATOMIC_MAX +# if @HAVE_SIGNED_SIG_ATOMIC_T@ +# define SIG_ATOMIC_MIN \ + _STDINT_SIGNED_MIN (@BITSIZEOF_SIG_ATOMIC_T@, 0@SIG_ATOMIC_T_SUFFIX@) +# else +# define SIG_ATOMIC_MIN \ + _STDINT_UNSIGNED_MIN (@BITSIZEOF_SIG_ATOMIC_T@, 0@SIG_ATOMIC_T_SUFFIX@) +# endif +# define SIG_ATOMIC_MAX \ + _STDINT_MAX (@HAVE_SIGNED_SIG_ATOMIC_T@, @BITSIZEOF_SIG_ATOMIC_T@, \ + 0@SIG_ATOMIC_T_SUFFIX@) + + +/* size_t limit */ +# undef SIZE_MAX +# if @APPLE_UNIVERSAL_BUILD@ +# ifdef _LP64 +# define SIZE_MAX _STDINT_MAX (0, 64, 0ul) +# else +# define SIZE_MAX _STDINT_MAX (0, 32, 0ul) +# endif +# else +# define SIZE_MAX _STDINT_MAX (0, @BITSIZEOF_SIZE_T@, 0@SIZE_T_SUFFIX@) +# endif + +/* wchar_t limits */ +/* Get WCHAR_MIN, WCHAR_MAX. + This include is not on the top, above, because on OSF/1 4.0 we have a + sequence of nested includes + -> -> -> , and the latter includes + and assumes its types are already defined. */ +# if @HAVE_WCHAR_H@ && ! (defined WCHAR_MIN && defined WCHAR_MAX) +# define _GL_JUST_INCLUDE_SYSTEM_WCHAR_H +# include +# undef _GL_JUST_INCLUDE_SYSTEM_WCHAR_H +# endif +# undef WCHAR_MIN +# undef WCHAR_MAX +# if @HAVE_SIGNED_WCHAR_T@ +# define WCHAR_MIN \ + _STDINT_SIGNED_MIN (@BITSIZEOF_WCHAR_T@, 0@WCHAR_T_SUFFIX@) +# else +# define WCHAR_MIN \ + _STDINT_UNSIGNED_MIN (@BITSIZEOF_WCHAR_T@, 0@WCHAR_T_SUFFIX@) +# endif +# define WCHAR_MAX \ + _STDINT_MAX (@HAVE_SIGNED_WCHAR_T@, @BITSIZEOF_WCHAR_T@, 0@WCHAR_T_SUFFIX@) + +/* wint_t limits */ +/* If gnulib's or overrides wint_t, @WINT_T_SUFFIX@ is not + accurate, therefore use the definitions from above. */ +# if !@GNULIBHEADERS_OVERRIDE_WINT_T@ +# undef WINT_MIN +# undef WINT_MAX +# if @HAVE_SIGNED_WINT_T@ +# define WINT_MIN \ + _STDINT_SIGNED_MIN (@BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@) +# else +# define WINT_MIN \ + _STDINT_UNSIGNED_MIN (@BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@) +# endif +# define WINT_MAX \ + _STDINT_MAX (@HAVE_SIGNED_WINT_T@, @BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@) +# endif + +/* 7.18.4. Macros for integer constants */ + +/* 7.18.4.1. Macros for minimum-width integer constants */ +/* According to ISO C 99 Technical Corrigendum 1 */ + +/* Here we assume a standard architecture where the hardware integer + types have 8, 16, 32, optionally 64 bits, and int is 32 bits. */ + +# undef INT8_C +# undef UINT8_C +# define INT8_C(x) x +# define UINT8_C(x) x + +# undef INT16_C +# undef UINT16_C +# define INT16_C(x) x +# define UINT16_C(x) x + +# undef INT32_C +# undef UINT32_C +# define INT32_C(x) x +# define UINT32_C(x) x ## U + +# undef INT64_C +# undef UINT64_C +# if LONG_MAX >> 31 >> 31 == 1 +# define INT64_C(x) x##L +# elif defined _MSC_VER +# define INT64_C(x) x##i64 +# else +# define INT64_C(x) x##LL +# endif +# if ULONG_MAX >> 31 >> 31 >> 1 == 1 +# define UINT64_C(x) x##UL +# elif defined _MSC_VER +# define UINT64_C(x) x##ui64 +# else +# define UINT64_C(x) x##ULL +# endif + +/* 7.18.4.2. Macros for greatest-width integer constants */ + +# ifndef INTMAX_C +# if LONG_MAX >> 30 == 1 +# define INTMAX_C(x) x##LL +# elif defined GL_INT64_T +# define INTMAX_C(x) INT64_C(x) +# else +# define INTMAX_C(x) x##L +# endif +# endif + +# ifndef UINTMAX_C +# if ULONG_MAX >> 31 == 1 +# define UINTMAX_C(x) x##ULL +# elif defined GL_UINT64_T +# define UINTMAX_C(x) UINT64_C(x) +# else +# define UINTMAX_C(x) x##UL +# endif +# endif + +#endif /* !@HAVE_C99_STDINT_H@ */ + +/* Macros specified by ISO/IEC TS 18661-1:2014. */ + +#if (!defined UINTMAX_WIDTH \ + && (defined _GNU_SOURCE || defined __STDC_WANT_IEC_60559_BFP_EXT__)) +# ifdef INT8_MAX +# define INT8_WIDTH _GL_INTEGER_WIDTH (INT8_MIN, INT8_MAX) +# endif +# ifdef UINT8_MAX +# define UINT8_WIDTH _GL_INTEGER_WIDTH (0, UINT8_MAX) +# endif +# ifdef INT16_MAX +# define INT16_WIDTH _GL_INTEGER_WIDTH (INT16_MIN, INT16_MAX) +# endif +# ifdef UINT16_MAX +# define UINT16_WIDTH _GL_INTEGER_WIDTH (0, UINT16_MAX) +# endif +# ifdef INT32_MAX +# define INT32_WIDTH _GL_INTEGER_WIDTH (INT32_MIN, INT32_MAX) +# endif +# ifdef UINT32_MAX +# define UINT32_WIDTH _GL_INTEGER_WIDTH (0, UINT32_MAX) +# endif +# ifdef INT64_MAX +# define INT64_WIDTH _GL_INTEGER_WIDTH (INT64_MIN, INT64_MAX) +# endif +# ifdef UINT64_MAX +# define UINT64_WIDTH _GL_INTEGER_WIDTH (0, UINT64_MAX) +# endif +# define INT_LEAST8_WIDTH _GL_INTEGER_WIDTH (INT_LEAST8_MIN, INT_LEAST8_MAX) +# define UINT_LEAST8_WIDTH _GL_INTEGER_WIDTH (0, UINT_LEAST8_MAX) +# define INT_LEAST16_WIDTH _GL_INTEGER_WIDTH (INT_LEAST16_MIN, INT_LEAST16_MAX) +# define UINT_LEAST16_WIDTH _GL_INTEGER_WIDTH (0, UINT_LEAST16_MAX) +# define INT_LEAST32_WIDTH _GL_INTEGER_WIDTH (INT_LEAST32_MIN, INT_LEAST32_MAX) +# define UINT_LEAST32_WIDTH _GL_INTEGER_WIDTH (0, UINT_LEAST32_MAX) +# define INT_LEAST64_WIDTH _GL_INTEGER_WIDTH (INT_LEAST64_MIN, INT_LEAST64_MAX) +# define UINT_LEAST64_WIDTH _GL_INTEGER_WIDTH (0, UINT_LEAST64_MAX) +# define INT_FAST8_WIDTH _GL_INTEGER_WIDTH (INT_FAST8_MIN, INT_FAST8_MAX) +# define UINT_FAST8_WIDTH _GL_INTEGER_WIDTH (0, UINT_FAST8_MAX) +# define INT_FAST16_WIDTH _GL_INTEGER_WIDTH (INT_FAST16_MIN, INT_FAST16_MAX) +# define UINT_FAST16_WIDTH _GL_INTEGER_WIDTH (0, UINT_FAST16_MAX) +# define INT_FAST32_WIDTH _GL_INTEGER_WIDTH (INT_FAST32_MIN, INT_FAST32_MAX) +# define UINT_FAST32_WIDTH _GL_INTEGER_WIDTH (0, UINT_FAST32_MAX) +# define INT_FAST64_WIDTH _GL_INTEGER_WIDTH (INT_FAST64_MIN, INT_FAST64_MAX) +# define UINT_FAST64_WIDTH _GL_INTEGER_WIDTH (0, UINT_FAST64_MAX) +# define INTPTR_WIDTH _GL_INTEGER_WIDTH (INTPTR_MIN, INTPTR_MAX) +# define UINTPTR_WIDTH _GL_INTEGER_WIDTH (0, UINTPTR_MAX) +# define INTMAX_WIDTH _GL_INTEGER_WIDTH (INTMAX_MIN, INTMAX_MAX) +# define UINTMAX_WIDTH _GL_INTEGER_WIDTH (0, UINTMAX_MAX) +# define PTRDIFF_WIDTH _GL_INTEGER_WIDTH (PTRDIFF_MIN, PTRDIFF_MAX) +# define SIZE_WIDTH _GL_INTEGER_WIDTH (0, SIZE_MAX) +# define WCHAR_WIDTH _GL_INTEGER_WIDTH (WCHAR_MIN, WCHAR_MAX) +# ifdef WINT_MAX +# define WINT_WIDTH _GL_INTEGER_WIDTH (WINT_MIN, WINT_MAX) +# endif +# ifdef SIG_ATOMIC_MAX +# define SIG_ATOMIC_WIDTH _GL_INTEGER_WIDTH (SIG_ATOMIC_MIN, SIG_ATOMIC_MAX) +# endif +#endif /* !WINT_WIDTH && (_GNU_SOURCE || __STDC_WANT_IEC_60559_BFP_EXT__) */ + +#endif /* _@GUARD_PREFIX@_STDINT_H */ +#endif /* !(defined __ANDROID__ && ...) */ +#endif /* !defined _@GUARD_PREFIX@_STDINT_H && !defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stdio-read.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stdio-read.c new file mode 100644 index 00000000..253b8aa4 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stdio-read.c @@ -0,0 +1,168 @@ +/* POSIX compatible FILE stream read function. + Copyright (C) 2008-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2011. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +/* Replace these functions only if module 'nonblocking' is requested. */ +#if GNULIB_NONBLOCKING + +/* On native Windows platforms, when read() is called on a non-blocking pipe + with an empty buffer, ReadFile() fails with error GetLastError() = + ERROR_NO_DATA, and read() in consequence fails with error EINVAL. This + read() function is at the basis of the function which fills the buffer of + a FILE stream. */ + +# if defined _WIN32 && ! defined __CYGWIN__ + +# include +# include + +# define WIN32_LEAN_AND_MEAN /* avoid including junk */ +# include + +# if GNULIB_MSVC_NOTHROW +# include "msvc-nothrow.h" +# else +# include +# endif + +/* Don't assume that UNICODE is not defined. */ +# undef GetNamedPipeHandleState +# define GetNamedPipeHandleState GetNamedPipeHandleStateA + +# define CALL_WITH_ERRNO_FIX(RETTYPE, EXPRESSION, FAILED) \ + if (ferror (stream)) \ + return (EXPRESSION); \ + else \ + { \ + RETTYPE ret; \ + SetLastError (0); \ + ret = (EXPRESSION); \ + if (FAILED) \ + { \ + if (GetLastError () == ERROR_NO_DATA && ferror (stream)) \ + { \ + int fd = fileno (stream); \ + if (fd >= 0) \ + { \ + HANDLE h = (HANDLE) _get_osfhandle (fd); \ + if (GetFileType (h) == FILE_TYPE_PIPE) \ + { \ + /* h is a pipe or socket. */ \ + DWORD state; \ + if (GetNamedPipeHandleState (h, &state, NULL, NULL, \ + NULL, NULL, 0) \ + && (state & PIPE_NOWAIT) != 0) \ + /* h is a pipe in non-blocking mode. \ + Change errno from EINVAL to EAGAIN. */ \ + errno = EAGAIN; \ + } \ + } \ + } \ + } \ + return ret; \ + } + +/* Enable this function definition only if gnulib's has prepared it. + Otherwise we get a function definition conflict with mingw64's . */ +# if GNULIB_SCANF +int +scanf (const char *format, ...) +{ + int retval; + va_list args; + + va_start (args, format); + retval = vfscanf (stdin, format, args); + va_end (args); + + return retval; +} +# endif + +/* Enable this function definition only if gnulib's has prepared it. + Otherwise we get a function definition conflict with mingw64's . */ +# if GNULIB_FSCANF +int +fscanf (FILE *stream, const char *format, ...) +{ + int retval; + va_list args; + + va_start (args, format); + retval = vfscanf (stream, format, args); + va_end (args); + + return retval; +} +# endif + +/* Enable this function definition only if gnulib's has prepared it. + Otherwise we get a function definition conflict with mingw64's . */ +# if GNULIB_VSCANF +int +vscanf (const char *format, va_list args) +{ + return vfscanf (stdin, format, args); +} +# endif + +/* Enable this function definition only if gnulib's has prepared it. + Otherwise we get a function definition conflict with mingw64's . */ +# if GNULIB_VFSCANF +int +vfscanf (FILE *stream, const char *format, va_list args) +#undef vfscanf +{ + CALL_WITH_ERRNO_FIX (int, vfscanf (stream, format, args), ret == EOF) +} +# endif + +int +getchar (void) +{ + return fgetc (stdin); +} + +int +fgetc (FILE *stream) +#undef fgetc +{ + CALL_WITH_ERRNO_FIX (int, fgetc (stream), ret == EOF) +} + +char * +fgets (char *s, int n, FILE *stream) +#undef fgets +{ + CALL_WITH_ERRNO_FIX (char *, fgets (s, n, stream), ret == NULL) +} + +/* We intentionally don't bother to fix gets. */ + +size_t +fread (void *ptr, size_t s, size_t n, FILE *stream) +#undef fread +{ + CALL_WITH_ERRNO_FIX (size_t, fread (ptr, s, n, stream), ret < n) +} + +# endif +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stdio-write.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stdio-write.c new file mode 100644 index 00000000..ca6aa00c --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stdio-write.c @@ -0,0 +1,206 @@ +/* POSIX compatible FILE stream write function. + Copyright (C) 2008-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2008. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +/* Replace these functions only if module 'nonblocking' or module 'sigpipe' is + requested. */ +#if GNULIB_NONBLOCKING || GNULIB_SIGPIPE + +/* On native Windows platforms, SIGPIPE does not exist. When write() is + called on a pipe with no readers, WriteFile() fails with error + GetLastError() = ERROR_NO_DATA, and write() in consequence fails with + error EINVAL. This write() function is at the basis of the function + which flushes the buffer of a FILE stream. */ + +# if defined _WIN32 && ! defined __CYGWIN__ + +# include +# include +# include + +# define WIN32_LEAN_AND_MEAN /* avoid including junk */ +# include + +# if GNULIB_MSVC_NOTHROW +# include "msvc-nothrow.h" +# else +# include +# endif + +/* Don't assume that UNICODE is not defined. */ +# undef GetNamedPipeHandleState +# define GetNamedPipeHandleState GetNamedPipeHandleStateA + +# if GNULIB_NONBLOCKING +# define CLEAR_ERRNO \ + errno = 0; +# define HANDLE_ENOSPC \ + if (errno == ENOSPC && ferror (stream)) \ + { \ + int fd = fileno (stream); \ + if (fd >= 0) \ + { \ + HANDLE h = (HANDLE) _get_osfhandle (fd); \ + if (GetFileType (h) == FILE_TYPE_PIPE) \ + { \ + /* h is a pipe or socket. */ \ + DWORD state; \ + if (GetNamedPipeHandleState (h, &state, NULL, NULL, \ + NULL, NULL, 0) \ + && (state & PIPE_NOWAIT) != 0) \ + /* h is a pipe in non-blocking mode. \ + Change errno from ENOSPC to EAGAIN. */ \ + errno = EAGAIN; \ + } \ + } \ + } \ + else +# else +# define CLEAR_ERRNO +# define HANDLE_ENOSPC +# endif + +# if GNULIB_SIGPIPE +# define CLEAR_LastError \ + SetLastError (0); +# define HANDLE_ERROR_NO_DATA \ + if (GetLastError () == ERROR_NO_DATA && ferror (stream)) \ + { \ + int fd = fileno (stream); \ + if (fd >= 0 \ + && GetFileType ((HANDLE) _get_osfhandle (fd)) \ + == FILE_TYPE_PIPE) \ + { \ + /* Try to raise signal SIGPIPE. */ \ + raise (SIGPIPE); \ + /* If it is currently blocked or ignored, change errno from \ + EINVAL to EPIPE. */ \ + errno = EPIPE; \ + } \ + } \ + else +# else +# define CLEAR_LastError +# define HANDLE_ERROR_NO_DATA +# endif + +# define CALL_WITH_SIGPIPE_EMULATION(RETTYPE, EXPRESSION, FAILED) \ + if (ferror (stream)) \ + return (EXPRESSION); \ + else \ + { \ + RETTYPE ret; \ + CLEAR_ERRNO \ + CLEAR_LastError \ + ret = (EXPRESSION); \ + if (FAILED) \ + { \ + HANDLE_ENOSPC \ + HANDLE_ERROR_NO_DATA \ + ; \ + } \ + return ret; \ + } + +# if !REPLACE_PRINTF_POSIX /* avoid collision with printf.c */ +int +printf (const char *format, ...) +{ + int retval; + va_list args; + + va_start (args, format); + retval = vfprintf (stdout, format, args); + va_end (args); + + return retval; +} +# endif + +# if !REPLACE_FPRINTF_POSIX /* avoid collision with fprintf.c */ +int +fprintf (FILE *stream, const char *format, ...) +{ + int retval; + va_list args; + + va_start (args, format); + retval = vfprintf (stream, format, args); + va_end (args); + + return retval; +} +# endif + +# if !REPLACE_VPRINTF_POSIX /* avoid collision with vprintf.c */ +int +vprintf (const char *format, va_list args) +{ + return vfprintf (stdout, format, args); +} +# endif + +# if !REPLACE_VFPRINTF_POSIX /* avoid collision with vfprintf.c */ +int +vfprintf (FILE *stream, const char *format, va_list args) +#undef vfprintf +{ + CALL_WITH_SIGPIPE_EMULATION (int, vfprintf (stream, format, args), ret == EOF) +} +# endif + +int +putchar (int c) +{ + return fputc (c, stdout); +} + +int +fputc (int c, FILE *stream) +#undef fputc +{ + CALL_WITH_SIGPIPE_EMULATION (int, fputc (c, stream), ret == EOF) +} + +int +fputs (const char *string, FILE *stream) +#undef fputs +{ + CALL_WITH_SIGPIPE_EMULATION (int, fputs (string, stream), ret == EOF) +} + +int +puts (const char *string) +#undef puts +{ + FILE *stream = stdout; + CALL_WITH_SIGPIPE_EMULATION (int, puts (string), ret == EOF) +} + +size_t +fwrite (const void *ptr, size_t s, size_t n, FILE *stream) +#undef fwrite +{ + CALL_WITH_SIGPIPE_EMULATION (size_t, fwrite (ptr, s, n, stream), ret < n) +} + +# endif +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stdio.in.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stdio.in.h new file mode 100644 index 00000000..4947307e --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stdio.in.h @@ -0,0 +1,1843 @@ +/* A GNU-like . + + Copyright (C) 2004, 2007-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +#endif +@PRAGMA_COLUMNS@ + +#if defined __need_FILE || defined __need___FILE || defined _GL_ALREADY_INCLUDING_STDIO_H +/* Special invocation convention: + - Inside glibc header files. + - On OSF/1 5.1 we have a sequence of nested includes + -> -> -> -> + -> -> -> . + In this situation, the functions are not yet declared, therefore we cannot + provide the C++ aliases. */ + +#@INCLUDE_NEXT@ @NEXT_STDIO_H@ + +#else +/* Normal invocation convention. */ + +#ifndef _@GUARD_PREFIX@_STDIO_H + +/* Suppress macOS deprecation warnings for sprintf and vsprintf. */ +#if (defined __APPLE__ && defined __MACH__) && !defined _POSIX_C_SOURCE +# ifdef __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ +# include +# endif +# if (defined MAC_OS_X_VERSION_MIN_REQUIRED \ + && 130000 <= MAC_OS_X_VERSION_MIN_REQUIRED) +# define _POSIX_C_SOURCE 200809L +# define _GL_DEFINED__POSIX_C_SOURCE +# endif +#endif + +#define _GL_ALREADY_INCLUDING_STDIO_H + +/* The include_next requires a split double-inclusion guard. */ +#@INCLUDE_NEXT@ @NEXT_STDIO_H@ + +#undef _GL_ALREADY_INCLUDING_STDIO_H + +#ifdef _GL_DEFINED__POSIX_C_SOURCE +# undef _GL_DEFINED__POSIX_C_SOURCE +# undef _POSIX_C_SOURCE +#endif + +#ifndef _@GUARD_PREFIX@_STDIO_H +#define _@GUARD_PREFIX@_STDIO_H + +/* This file uses _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_FORMAT, + _GL_ATTRIBUTE_MALLOC, _GL_ATTRIBUTE_NOTHROW, GNULIB_POSIXCHECK, + HAVE_RAW_DECL_*. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +/* Get va_list. Needed on many systems, including glibc 2.8. */ +#include + +#include + +/* Get off_t and ssize_t. Needed on many systems, including glibc 2.8 + and eglibc 2.11.2. + May also define off_t to a 64-bit type on native Windows. */ +#include + +/* Solaris 10 and NetBSD 7.0 declare renameat in , not in . */ +/* But in any case avoid namespace pollution on glibc systems. */ +#if (@GNULIB_RENAMEAT@ || defined GNULIB_POSIXCHECK) && (defined __sun || defined __NetBSD__) \ + && ! defined __GLIBC__ +# include +#endif + +/* Android 4.3 declares renameat in , not in . */ +/* But in any case avoid namespace pollution on glibc systems. */ +#if (@GNULIB_RENAMEAT@ || defined GNULIB_POSIXCHECK) && defined __ANDROID__ \ + && ! defined __GLIBC__ +# include +#endif + +/* MSVC declares 'perror' in , not in . We must include + it before we #define perror rpl_perror. */ +/* But in any case avoid namespace pollution on glibc systems. */ +#if (@GNULIB_PERROR@ || defined GNULIB_POSIXCHECK) \ + && (defined _WIN32 && ! defined __CYGWIN__) \ + && ! defined __GLIBC__ +# include +#endif + +/* MSVC declares 'remove' in , not in . We must include + it before we #define remove rpl_remove. */ +/* MSVC declares 'rename' in , not in . We must include + it before we #define rename rpl_rename. */ +/* But in any case avoid namespace pollution on glibc systems. */ +#if (@GNULIB_REMOVE@ || @GNULIB_RENAME@ || defined GNULIB_POSIXCHECK) \ + && (defined _WIN32 && ! defined __CYGWIN__) \ + && ! defined __GLIBC__ +# include +#endif + + +/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers + that can be freed by passing them as the Ith argument to the + function F. */ +#ifndef _GL_ATTRIBUTE_DEALLOC +# if __GNUC__ >= 11 +# define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i))) +# else +# define _GL_ATTRIBUTE_DEALLOC(f, i) +# endif +#endif + +/* The __attribute__ feature is available in gcc versions 2.5 and later. + The __-protected variants of the attributes 'format' and 'printf' are + accepted by gcc versions 2.6.4 (effectively 2.7) and later. + We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because + gnulib and libintl do '#define printf __printf__' when they override + the 'printf' function. */ +#ifndef _GL_ATTRIBUTE_FORMAT +# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) || defined __clang__ +# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec)) +# else +# define _GL_ATTRIBUTE_FORMAT(spec) /* empty */ +# endif +#endif + +/* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly + allocated memory. */ +#ifndef _GL_ATTRIBUTE_MALLOC +# if __GNUC__ >= 3 || defined __clang__ +# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__)) +# else +# define _GL_ATTRIBUTE_MALLOC +# endif +#endif + +/* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions. + */ +#ifndef _GL_ATTRIBUTE_NOTHROW +# if defined __cplusplus +# if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major >= 4 +# if __cplusplus >= 201103L +# define _GL_ATTRIBUTE_NOTHROW noexcept (true) +# else +# define _GL_ATTRIBUTE_NOTHROW throw () +# endif +# else +# define _GL_ATTRIBUTE_NOTHROW +# endif +# else +# if (__GNUC__ + (__GNUC_MINOR__ >= 3) > 3) || defined __clang__ +# define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__)) +# else +# define _GL_ATTRIBUTE_NOTHROW +# endif +# endif +#endif + +/* An __attribute__ __format__ specifier for a function that takes a format + string and arguments, where the format string directives are the ones + standardized by ISO C99 and POSIX. + _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD */ +/* __gnu_printf__ is supported in GCC >= 4.4. */ +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) +# define _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD __gnu_printf__ +#else +# define _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD __printf__ +#endif + +/* An __attribute__ __format__ specifier for a function that takes a format + string and arguments, where the format string directives are the ones of the + system printf(), rather than the ones standardized by ISO C99 and POSIX. + _GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM */ +/* On mingw, Gnulib sets __USE_MINGW_ANSI_STDIO in order to get closer to + the standards. The macro GNULIB_PRINTF_ATTRIBUTE_FLAVOR_GNU indicates + whether this change is effective. On older mingw, it is not. */ +#if GNULIB_PRINTF_ATTRIBUTE_FLAVOR_GNU +# define _GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD +#else +# define _GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM __printf__ +#endif + +/* _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD + indicates to GCC that the function takes a format string and arguments, + where the format string directives are the ones standardized by ISO C99 + and POSIX. */ +#define _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD(formatstring_parameter, first_argument) \ + _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, formatstring_parameter, first_argument)) + +/* _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM is like _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD, + except that it indicates to GCC that the supported format string directives + are the ones of the system printf(), rather than the ones standardized by + ISO C99 and POSIX. */ +#define _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM(formatstring_parameter, first_argument) \ + _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM, formatstring_parameter, first_argument)) + +/* _GL_ATTRIBUTE_FORMAT_SCANF + indicates to GCC that the function takes a format string and arguments, + where the format string directives are the ones standardized by ISO C99 + and POSIX. */ +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) +# define _GL_ATTRIBUTE_FORMAT_SCANF(formatstring_parameter, first_argument) \ + _GL_ATTRIBUTE_FORMAT ((__gnu_scanf__, formatstring_parameter, first_argument)) +#else +# define _GL_ATTRIBUTE_FORMAT_SCANF(formatstring_parameter, first_argument) \ + _GL_ATTRIBUTE_FORMAT ((__scanf__, formatstring_parameter, first_argument)) +#endif + +/* _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM is like _GL_ATTRIBUTE_FORMAT_SCANF, + except that it indicates to GCC that the supported format string directives + are the ones of the system scanf(), rather than the ones standardized by + ISO C99 and POSIX. */ +#define _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM(formatstring_parameter, first_argument) \ + _GL_ATTRIBUTE_FORMAT ((__scanf__, formatstring_parameter, first_argument)) + +/* 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. */ + +/* Macros for stringification. */ +#define _GL_STDIO_STRINGIZE(token) #token +#define _GL_STDIO_MACROEXPAND_AND_STRINGIZE(token) _GL_STDIO_STRINGIZE(token) + +/* When also using extern inline, suppress the use of static inline in + standard headers of problematic Apple configurations, as Libc at + least through Libc-825.26 (2013-04-09) mishandles it; see, e.g., + . + Perhaps Apple will fix this some day. */ +#if (defined _GL_EXTERN_INLINE_IN_USE && defined __APPLE__ \ + && defined __GNUC__ && defined __STDC__) +# undef putc_unlocked +#endif + + +/* Maximum number of characters produced by printing a NaN value. */ +#ifndef _PRINTF_NAN_LEN_MAX +# if defined __FreeBSD__ || defined __DragonFly__ \ + || defined __NetBSD__ \ + || (defined __APPLE__ && defined __MACH__) +/* On BSD systems, a NaN value prints as just "nan", without a sign. */ +# define _PRINTF_NAN_LEN_MAX 3 +# elif (__GLIBC__ >= 2) || MUSL_LIBC || defined __OpenBSD__ || defined __sun || defined __CYGWIN__ +/* glibc, musl libc, OpenBSD, Solaris libc, and Cygwin produce "[-]nan". */ +# define _PRINTF_NAN_LEN_MAX 4 +# elif defined _AIX +/* AIX produces "[-]NaNQ". */ +# define _PRINTF_NAN_LEN_MAX 5 +# elif defined _WIN32 && !defined __CYGWIN__ +/* On native Windows, the output can be: + - with MSVC ucrt: "[-]nan" or "[-]nan(ind)" or "[-]nan(snan)", + - with mingw: "[-]1.#IND" or "[-]1.#QNAN". */ +# define _PRINTF_NAN_LEN_MAX 10 +# elif defined __sgi +/* On IRIX, the output typically is "[-]nan0xNNNNNNNN" with 8 hexadecimal + digits. */ +# define _PRINTF_NAN_LEN_MAX 14 +# else +/* We don't know, but 32 should be a safe maximum. */ +# define _PRINTF_NAN_LEN_MAX 32 +# endif +#endif + + +#if @GNULIB_DPRINTF@ +# if @REPLACE_DPRINTF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define dprintf rpl_dprintf +# endif +_GL_FUNCDECL_RPL (dprintf, int, (int fd, const char *restrict format, ...) + _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) + _GL_ARG_NONNULL ((2))); +_GL_CXXALIAS_RPL (dprintf, int, (int fd, const char *restrict format, ...)); +# else +# if !@HAVE_DPRINTF@ +_GL_FUNCDECL_SYS (dprintf, int, (int fd, const char *restrict format, ...) + _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) + _GL_ARG_NONNULL ((2))); +# endif +_GL_CXXALIAS_SYS (dprintf, int, (int fd, const char *restrict format, ...)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (dprintf); +# endif +#elif defined GNULIB_POSIXCHECK +# undef dprintf +# if HAVE_RAW_DECL_DPRINTF +_GL_WARN_ON_USE (dprintf, "dprintf is unportable - " + "use gnulib module dprintf for portability"); +# endif +#endif + +#if @GNULIB_FCLOSE@ +/* Close STREAM and its underlying file descriptor. */ +# if @REPLACE_FCLOSE@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define fclose rpl_fclose +# endif +_GL_FUNCDECL_RPL (fclose, int, (FILE *stream) _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (fclose, int, (FILE *stream)); +# else +_GL_CXXALIAS_SYS (fclose, int, (FILE *stream)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (fclose); +# endif +#elif defined GNULIB_POSIXCHECK +# undef fclose +/* Assume fclose is always declared. */ +_GL_WARN_ON_USE (fclose, "fclose is not always POSIX compliant - " + "use gnulib module fclose for portable POSIX compliance"); +#endif + +#if @GNULIB_MDA_FCLOSEALL@ +/* On native Windows, map 'fcloseall' to '_fcloseall', so that -loldnames is + not required. In C++ with GNULIB_NAMESPACE, avoid differences between + platforms by defining GNULIB_NAMESPACE::fcloseall on all platforms that have + it. */ +# if defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef fcloseall +# define fcloseall _fcloseall +# endif +_GL_CXXALIAS_MDA (fcloseall, int, (void)); +# else +# if @HAVE_DECL_FCLOSEALL@ +# if defined __FreeBSD__ || defined __DragonFly__ +_GL_CXXALIAS_SYS (fcloseall, void, (void)); +# else +_GL_CXXALIAS_SYS (fcloseall, int, (void)); +# endif +# endif +# endif +# if (defined _WIN32 && !defined __CYGWIN__) || @HAVE_DECL_FCLOSEALL@ +_GL_CXXALIASWARN (fcloseall); +# endif +#endif + +#if @GNULIB_FDOPEN@ +# if @REPLACE_FDOPEN@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef fdopen +# define fdopen rpl_fdopen +# endif +_GL_FUNCDECL_RPL (fdopen, FILE *, + (int fd, const char *mode) + _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1) + _GL_ATTRIBUTE_MALLOC); +_GL_CXXALIAS_RPL (fdopen, FILE *, (int fd, const char *mode)); +# elif defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef fdopen +# define fdopen _fdopen +# endif +_GL_CXXALIAS_MDA (fdopen, FILE *, (int fd, const char *mode)); +# else +# if __GNUC__ >= 11 +/* For -Wmismatched-dealloc: Associate fdopen with fclose or rpl_fclose. */ +# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 +_GL_FUNCDECL_SYS (fdopen, FILE *, + (int fd, const char *mode) + _GL_ATTRIBUTE_NOTHROW + _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1) + _GL_ATTRIBUTE_MALLOC); +# else +_GL_FUNCDECL_SYS (fdopen, FILE *, + (int fd, const char *mode) + _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1) + _GL_ATTRIBUTE_MALLOC); +# endif +# endif +_GL_CXXALIAS_SYS (fdopen, FILE *, (int fd, const char *mode)); +# endif +_GL_CXXALIASWARN (fdopen); +#else +# if @GNULIB_FCLOSE@ && __GNUC__ >= 11 && !defined fdopen +/* For -Wmismatched-dealloc: Associate fdopen with fclose or rpl_fclose. */ +# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 +_GL_FUNCDECL_SYS (fdopen, FILE *, + (int fd, const char *mode) + _GL_ATTRIBUTE_NOTHROW + _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1) + _GL_ATTRIBUTE_MALLOC); +# else +_GL_FUNCDECL_SYS (fdopen, FILE *, + (int fd, const char *mode) + _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1) + _GL_ATTRIBUTE_MALLOC); +# endif +# endif +# if defined GNULIB_POSIXCHECK +# undef fdopen +/* Assume fdopen is always declared. */ +_GL_WARN_ON_USE (fdopen, "fdopen on native Windows platforms is not POSIX compliant - " + "use gnulib module fdopen for portability"); +# elif @GNULIB_MDA_FDOPEN@ +/* On native Windows, map 'fdopen' to '_fdopen', so that -loldnames is not + required. In C++ with GNULIB_NAMESPACE, avoid differences between + platforms by defining GNULIB_NAMESPACE::fdopen always. */ +# if defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef fdopen +# define fdopen _fdopen +# endif +_GL_CXXALIAS_MDA (fdopen, FILE *, (int fd, const char *mode)); +# else +_GL_CXXALIAS_SYS (fdopen, FILE *, (int fd, const char *mode)); +# endif +_GL_CXXALIASWARN (fdopen); +# endif +#endif + +#if @GNULIB_FFLUSH@ +/* Flush all pending data on STREAM according to POSIX rules. Both + output and seekable input streams are supported. + Note! LOSS OF DATA can occur if fflush is applied on an input stream + that is _not_seekable_ or on an update stream that is _not_seekable_ + and in which the most recent operation was input. Seekability can + be tested with lseek(fileno(fp),0,SEEK_CUR). */ +# if @REPLACE_FFLUSH@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define fflush rpl_fflush +# endif +_GL_FUNCDECL_RPL (fflush, int, (FILE *gl_stream)); +_GL_CXXALIAS_RPL (fflush, int, (FILE *gl_stream)); +# else +_GL_CXXALIAS_SYS (fflush, int, (FILE *gl_stream)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (fflush); +# endif +#elif defined GNULIB_POSIXCHECK +# undef fflush +/* Assume fflush is always declared. */ +_GL_WARN_ON_USE (fflush, "fflush is not always POSIX compliant - " + "use gnulib module fflush for portable POSIX compliance"); +#endif + +#if @GNULIB_FGETC@ +# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef fgetc +# define fgetc rpl_fgetc +# endif +_GL_FUNCDECL_RPL (fgetc, int, (FILE *stream) _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (fgetc, int, (FILE *stream)); +# else +_GL_CXXALIAS_SYS (fgetc, int, (FILE *stream)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (fgetc); +# endif +#endif + +#if @GNULIB_FGETS@ +# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef fgets +# define fgets rpl_fgets +# endif +_GL_FUNCDECL_RPL (fgets, char *, + (char *restrict s, int n, FILE *restrict stream) + _GL_ARG_NONNULL ((1, 3))); +_GL_CXXALIAS_RPL (fgets, char *, + (char *restrict s, int n, FILE *restrict stream)); +# else +_GL_CXXALIAS_SYS (fgets, char *, + (char *restrict s, int n, FILE *restrict stream)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (fgets); +# endif +#endif + +#if @GNULIB_MDA_FILENO@ +/* On native Windows, map 'fileno' to '_fileno', so that -loldnames is not + required. In C++ with GNULIB_NAMESPACE, avoid differences between + platforms by defining GNULIB_NAMESPACE::fileno always. */ +# if defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef fileno +# define fileno _fileno +# endif +_GL_CXXALIAS_MDA (fileno, int, (FILE *restrict stream)); +# else +_GL_CXXALIAS_SYS (fileno, int, (FILE *restrict stream)); +# endif +_GL_CXXALIASWARN (fileno); +#endif + +#if @GNULIB_FOPEN@ +# if (@GNULIB_FOPEN@ && @REPLACE_FOPEN@) \ + || (@GNULIB_FOPEN_GNU@ && @REPLACE_FOPEN_FOR_FOPEN_GNU@) +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef fopen +# define fopen rpl_fopen +# endif +_GL_FUNCDECL_RPL (fopen, FILE *, + (const char *restrict filename, const char *restrict mode) + _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1) + _GL_ATTRIBUTE_MALLOC); +_GL_CXXALIAS_RPL (fopen, FILE *, + (const char *restrict filename, const char *restrict mode)); +# else +# if __GNUC__ >= 11 +/* For -Wmismatched-dealloc: Associate fopen with fclose or rpl_fclose. */ +_GL_FUNCDECL_SYS (fopen, FILE *, + (const char *restrict filename, const char *restrict mode) + _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)); +# endif +_GL_CXXALIAS_SYS (fopen, FILE *, + (const char *restrict filename, const char *restrict mode)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (fopen); +# endif +#else +# if @GNULIB_FCLOSE@ && __GNUC__ >= 11 && !defined fopen +/* For -Wmismatched-dealloc: Associate fopen with fclose or rpl_fclose. */ +_GL_FUNCDECL_SYS (fopen, FILE *, + (const char *restrict filename, const char *restrict mode) + _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)); +# endif +# if defined GNULIB_POSIXCHECK +# undef fopen +/* Assume fopen is always declared. */ +_GL_WARN_ON_USE (fopen, "fopen on native Windows platforms is not POSIX compliant - " + "use gnulib module fopen for portability"); +# endif +#endif + +#if @GNULIB_FPRINTF_POSIX@ || @GNULIB_FPRINTF@ +# if (@GNULIB_FPRINTF_POSIX@ && @REPLACE_FPRINTF@) \ + || (@GNULIB_FPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)) +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define fprintf rpl_fprintf +# endif +# define GNULIB_overrides_fprintf 1 +# if @GNULIB_FPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@ +_GL_FUNCDECL_RPL (fprintf, int, + (FILE *restrict fp, const char *restrict format, ...) + _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) + _GL_ARG_NONNULL ((1, 2))); +# else +_GL_FUNCDECL_RPL (fprintf, int, + (FILE *restrict fp, const char *restrict format, ...) + _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 3) + _GL_ARG_NONNULL ((1, 2))); +# endif +_GL_CXXALIAS_RPL (fprintf, int, + (FILE *restrict fp, const char *restrict format, ...)); +# else +_GL_CXXALIAS_SYS (fprintf, int, + (FILE *restrict fp, const char *restrict format, ...)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (fprintf); +# endif +#endif +#if !@GNULIB_FPRINTF_POSIX@ && defined GNULIB_POSIXCHECK +# if !GNULIB_overrides_fprintf +# undef fprintf +# endif +/* Assume fprintf is always declared. */ +_GL_WARN_ON_USE (fprintf, "fprintf is not always POSIX compliant - " + "use gnulib module fprintf-posix for portable " + "POSIX compliance"); +#endif + +#if @GNULIB_FPURGE@ +/* Discard all pending buffered I/O data on STREAM. + STREAM must not be wide-character oriented. + When discarding pending output, the file position is set back to where it + was before the write calls. When discarding pending input, the file + position is advanced to match the end of the previously read input. + Return 0 if successful. Upon error, return -1 and set errno. */ +# if @REPLACE_FPURGE@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define fpurge rpl_fpurge +# endif +_GL_FUNCDECL_RPL (fpurge, int, (FILE *gl_stream) _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (fpurge, int, (FILE *gl_stream)); +# else +# if !@HAVE_DECL_FPURGE@ +_GL_FUNCDECL_SYS (fpurge, int, (FILE *gl_stream) _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (fpurge, int, (FILE *gl_stream)); +# endif +_GL_CXXALIASWARN (fpurge); +#elif defined GNULIB_POSIXCHECK +# undef fpurge +# if HAVE_RAW_DECL_FPURGE +_GL_WARN_ON_USE (fpurge, "fpurge is not always present - " + "use gnulib module fpurge for portability"); +# endif +#endif + +#if @GNULIB_FPUTC@ +# if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@) +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef fputc +# define fputc rpl_fputc +# endif +_GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream) _GL_ARG_NONNULL ((2))); +_GL_CXXALIAS_RPL (fputc, int, (int c, FILE *stream)); +# else +_GL_CXXALIAS_SYS (fputc, int, (int c, FILE *stream)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (fputc); +# endif +#endif + +#if @GNULIB_FPUTS@ +# if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@) +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef fputs +# define fputs rpl_fputs +# endif +_GL_FUNCDECL_RPL (fputs, int, + (const char *restrict string, FILE *restrict stream) + _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (fputs, int, + (const char *restrict string, FILE *restrict stream)); +# else +_GL_CXXALIAS_SYS (fputs, int, + (const char *restrict string, FILE *restrict stream)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (fputs); +# endif +#endif + +#if @GNULIB_FREAD@ +# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef fread +# define fread rpl_fread +# endif +_GL_FUNCDECL_RPL (fread, size_t, + (void *restrict ptr, size_t s, size_t n, + FILE *restrict stream) + _GL_ARG_NONNULL ((4))); +_GL_CXXALIAS_RPL (fread, size_t, + (void *restrict ptr, size_t s, size_t n, + FILE *restrict stream)); +# else +_GL_CXXALIAS_SYS (fread, size_t, + (void *restrict ptr, size_t s, size_t n, + FILE *restrict stream)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (fread); +# endif +#endif + +#if @GNULIB_FREOPEN@ +# if @REPLACE_FREOPEN@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef freopen +# define freopen rpl_freopen +# endif +_GL_FUNCDECL_RPL (freopen, FILE *, + (const char *restrict filename, const char *restrict mode, + FILE *restrict stream) + _GL_ARG_NONNULL ((2, 3))); +_GL_CXXALIAS_RPL (freopen, FILE *, + (const char *restrict filename, const char *restrict mode, + FILE *restrict stream)); +# else +_GL_CXXALIAS_SYS (freopen, FILE *, + (const char *restrict filename, const char *restrict mode, + FILE *restrict stream)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (freopen); +# endif +#elif defined GNULIB_POSIXCHECK +# undef freopen +/* Assume freopen is always declared. */ +_GL_WARN_ON_USE (freopen, + "freopen on native Windows platforms is not POSIX compliant - " + "use gnulib module freopen for portability"); +#endif + +#if @GNULIB_FSCANF@ +# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef fscanf +# define fscanf rpl_fscanf +# endif +_GL_FUNCDECL_RPL (fscanf, int, + (FILE *restrict stream, const char *restrict format, ...) + _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 3) + _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (fscanf, int, + (FILE *restrict stream, const char *restrict format, ...)); +# else +_GL_CXXALIAS_SYS (fscanf, int, + (FILE *restrict stream, const char *restrict format, ...)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (fscanf); +# endif +#endif + + +/* Set up the following warnings, based on which modules are in use. + GNU Coding Standards discourage the use of fseek, since it imposes + an arbitrary limitation on some 32-bit hosts. Remember that the + fseek module depends on the fseeko module, so we only have three + cases to consider: + + 1. The developer is not using either module. Issue a warning under + GNULIB_POSIXCHECK for both functions, to remind them that both + functions have bugs on some systems. _GL_NO_LARGE_FILES has no + impact on this warning. + + 2. The developer is using both modules. They may be unaware of the + arbitrary limitations of fseek, so issue a warning under + GNULIB_POSIXCHECK. On the other hand, they may be using both + modules intentionally, so the developer can define + _GL_NO_LARGE_FILES in the compilation units where the use of fseek + is safe, to silence the warning. + + 3. The developer is using the fseeko module, but not fseek. Gnulib + guarantees that fseek will still work around platform bugs in that + case, but we presume that the developer is aware of the pitfalls of + fseek and was trying to avoid it, so issue a warning even when + GNULIB_POSIXCHECK is undefined. Again, _GL_NO_LARGE_FILES can be + defined to silence the warning in particular compilation units. + In C++ compilations with GNULIB_NAMESPACE, in order to avoid that + fseek gets defined as a macro, it is recommended that the developer + uses the fseek module, even if he is not calling the fseek function. + + Most gnulib clients that perform stream operations should fall into + category 3. */ + +#if @GNULIB_FSEEK@ +# if defined GNULIB_POSIXCHECK && !defined _GL_NO_LARGE_FILES +# define _GL_FSEEK_WARN /* Category 2, above. */ +# undef fseek +# endif +# if @REPLACE_FSEEK@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef fseek +# define fseek rpl_fseek +# endif +_GL_FUNCDECL_RPL (fseek, int, (FILE *fp, long offset, int whence) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (fseek, int, (FILE *fp, long offset, int whence)); +# else +_GL_CXXALIAS_SYS (fseek, int, (FILE *fp, long offset, int whence)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (fseek); +# endif +#endif + +#if @GNULIB_FSEEKO@ +# if !@GNULIB_FSEEK@ && !defined _GL_NO_LARGE_FILES +# define _GL_FSEEK_WARN /* Category 3, above. */ +# undef fseek +# endif +# if @REPLACE_FSEEKO@ +/* Provide an fseeko function that is aware of a preceding fflush(), and which + detects pipes. */ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef fseeko +# define fseeko rpl_fseeko +# endif +_GL_FUNCDECL_RPL (fseeko, int, (FILE *fp, off_t offset, int whence) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (fseeko, int, (FILE *fp, off_t offset, int whence)); +# else +# if ! @HAVE_DECL_FSEEKO@ +_GL_FUNCDECL_SYS (fseeko, int, (FILE *fp, off_t offset, int whence) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (fseeko, int, (FILE *fp, off_t offset, int whence)); +# endif +_GL_CXXALIASWARN (fseeko); +#elif defined GNULIB_POSIXCHECK +# define _GL_FSEEK_WARN /* Category 1, above. */ +# undef fseek +# undef fseeko +# if HAVE_RAW_DECL_FSEEKO +_GL_WARN_ON_USE (fseeko, "fseeko is unportable - " + "use gnulib module fseeko for portability"); +# endif +#endif + +#ifdef _GL_FSEEK_WARN +# undef _GL_FSEEK_WARN +/* Here, either fseek is undefined (but C89 guarantees that it is + declared), or it is defined as rpl_fseek (declared above). */ +_GL_WARN_ON_USE (fseek, "fseek cannot handle files larger than 4 GB " + "on 32-bit platforms - " + "use fseeko function for handling of large files"); +#endif + + +/* ftell, ftello. See the comments on fseek/fseeko. */ + +#if @GNULIB_FTELL@ +# if defined GNULIB_POSIXCHECK && !defined _GL_NO_LARGE_FILES +# define _GL_FTELL_WARN /* Category 2, above. */ +# undef ftell +# endif +# if @REPLACE_FTELL@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef ftell +# define ftell rpl_ftell +# endif +_GL_FUNCDECL_RPL (ftell, long, (FILE *fp) _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (ftell, long, (FILE *fp)); +# else +_GL_CXXALIAS_SYS (ftell, long, (FILE *fp)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (ftell); +# endif +#endif + +#if @GNULIB_FTELLO@ +# if !@GNULIB_FTELL@ && !defined _GL_NO_LARGE_FILES +# define _GL_FTELL_WARN /* Category 3, above. */ +# undef ftell +# endif +# if @REPLACE_FTELLO@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef ftello +# define ftello rpl_ftello +# endif +_GL_FUNCDECL_RPL (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (ftello, off_t, (FILE *fp)); +# else +# if ! @HAVE_DECL_FTELLO@ +_GL_FUNCDECL_SYS (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (ftello, off_t, (FILE *fp)); +# endif +_GL_CXXALIASWARN (ftello); +#elif defined GNULIB_POSIXCHECK +# define _GL_FTELL_WARN /* Category 1, above. */ +# undef ftell +# undef ftello +# if HAVE_RAW_DECL_FTELLO +_GL_WARN_ON_USE (ftello, "ftello is unportable - " + "use gnulib module ftello for portability"); +# endif +#endif + +#ifdef _GL_FTELL_WARN +# undef _GL_FTELL_WARN +/* Here, either ftell is undefined (but C89 guarantees that it is + declared), or it is defined as rpl_ftell (declared above). */ +_GL_WARN_ON_USE (ftell, "ftell cannot handle files larger than 4 GB " + "on 32-bit platforms - " + "use ftello function for handling of large files"); +#endif + + +#if @GNULIB_FWRITE@ +# if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@) +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef fwrite +# define fwrite rpl_fwrite +# endif +_GL_FUNCDECL_RPL (fwrite, size_t, + (const void *restrict ptr, size_t s, size_t n, + FILE *restrict stream) + _GL_ARG_NONNULL ((1, 4))); +_GL_CXXALIAS_RPL (fwrite, size_t, + (const void *restrict ptr, size_t s, size_t n, + FILE *restrict stream)); +# else +_GL_CXXALIAS_SYS (fwrite, size_t, + (const void *restrict ptr, size_t s, size_t n, + FILE *restrict stream)); + +/* Work around bug 11959 when fortifying glibc 2.4 through 2.15 + , + which sometimes causes an unwanted diagnostic for fwrite calls. + This affects only function declaration attributes under certain + versions of gcc and clang, and is not needed for C++. */ +# if (0 < __USE_FORTIFY_LEVEL \ + && __GLIBC__ == 2 && 4 <= __GLIBC_MINOR__ && __GLIBC_MINOR__ <= 15 \ + && 3 < __GNUC__ + (4 <= __GNUC_MINOR__) \ + && !defined __cplusplus) +# undef fwrite +# undef fwrite_unlocked +extern size_t __REDIRECT (rpl_fwrite, + (const void *__restrict, size_t, size_t, + FILE *__restrict), + fwrite); +extern size_t __REDIRECT (rpl_fwrite_unlocked, + (const void *__restrict, size_t, size_t, + FILE *__restrict), + fwrite_unlocked); +# define fwrite rpl_fwrite +# define fwrite_unlocked rpl_fwrite_unlocked +# endif +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (fwrite); +# endif +#endif + +#if @GNULIB_GETC@ +# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef getc +# define getc rpl_fgetc +# endif +_GL_FUNCDECL_RPL (fgetc, int, (FILE *stream) _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL_1 (getc, rpl_fgetc, int, (FILE *stream)); +# else +_GL_CXXALIAS_SYS (getc, int, (FILE *stream)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (getc); +# endif +#endif + +#if @GNULIB_GETCHAR@ +# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef getchar +# define getchar rpl_getchar +# endif +_GL_FUNCDECL_RPL (getchar, int, (void)); +_GL_CXXALIAS_RPL (getchar, int, (void)); +# else +_GL_CXXALIAS_SYS (getchar, int, (void)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (getchar); +# endif +#endif + +#if @GNULIB_GETDELIM@ +/* Read input, up to (and including) the next occurrence of DELIMITER, from + STREAM, store it in *LINEPTR (and NUL-terminate it). + *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE + bytes of space. It is realloc'd as necessary. + Return the number of bytes read and stored at *LINEPTR (not including the + NUL terminator), or -1 on error or EOF. */ +# if @REPLACE_GETDELIM@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef getdelim +# define getdelim rpl_getdelim +# endif +_GL_FUNCDECL_RPL (getdelim, ssize_t, + (char **restrict lineptr, size_t *restrict linesize, + int delimiter, + FILE *restrict stream) + _GL_ARG_NONNULL ((1, 2, 4))); +_GL_CXXALIAS_RPL (getdelim, ssize_t, + (char **restrict lineptr, size_t *restrict linesize, + int delimiter, + FILE *restrict stream)); +# else +# if !@HAVE_DECL_GETDELIM@ +_GL_FUNCDECL_SYS (getdelim, ssize_t, + (char **restrict lineptr, size_t *restrict linesize, + int delimiter, + FILE *restrict stream) + _GL_ARG_NONNULL ((1, 2, 4))); +# endif +_GL_CXXALIAS_SYS (getdelim, ssize_t, + (char **restrict lineptr, size_t *restrict linesize, + int delimiter, + FILE *restrict stream)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (getdelim); +# endif +#elif defined GNULIB_POSIXCHECK +# undef getdelim +# if HAVE_RAW_DECL_GETDELIM +_GL_WARN_ON_USE (getdelim, "getdelim is unportable - " + "use gnulib module getdelim for portability"); +# endif +#endif + +#if @GNULIB_GETLINE@ +/* Read a line, up to (and including) the next newline, from STREAM, store it + in *LINEPTR (and NUL-terminate it). + *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE + bytes of space. It is realloc'd as necessary. + Return the number of bytes read and stored at *LINEPTR (not including the + NUL terminator), or -1 on error or EOF. */ +# if @REPLACE_GETLINE@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef getline +# define getline rpl_getline +# endif +_GL_FUNCDECL_RPL (getline, ssize_t, + (char **restrict lineptr, size_t *restrict linesize, + FILE *restrict stream) + _GL_ARG_NONNULL ((1, 2, 3))); +_GL_CXXALIAS_RPL (getline, ssize_t, + (char **restrict lineptr, size_t *restrict linesize, + FILE *restrict stream)); +# else +# if !@HAVE_DECL_GETLINE@ +_GL_FUNCDECL_SYS (getline, ssize_t, + (char **restrict lineptr, size_t *restrict linesize, + FILE *restrict stream) + _GL_ARG_NONNULL ((1, 2, 3))); +# endif +_GL_CXXALIAS_SYS (getline, ssize_t, + (char **restrict lineptr, size_t *restrict linesize, + FILE *restrict stream)); +# endif +# if __GLIBC__ >= 2 && @HAVE_DECL_GETLINE@ +_GL_CXXALIASWARN (getline); +# endif +#elif defined GNULIB_POSIXCHECK +# undef getline +# if HAVE_RAW_DECL_GETLINE +_GL_WARN_ON_USE (getline, "getline is unportable - " + "use gnulib module getline for portability"); +# endif +#endif + +/* It is very rare that the developer ever has full control of stdin, + so any use of gets warrants an unconditional warning; besides, C11 + removed it. */ +#undef gets +#if HAVE_RAW_DECL_GETS && !defined __cplusplus +_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead"); +#endif + +#if @GNULIB_MDA_GETW@ +/* On native Windows, map 'getw' to '_getw', so that -loldnames is not + required. In C++ with GNULIB_NAMESPACE, avoid differences between + platforms by defining GNULIB_NAMESPACE::getw always. */ +# if defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef getw +# define getw _getw +# endif +_GL_CXXALIAS_MDA (getw, int, (FILE *restrict stream)); +# else +# if @HAVE_DECL_GETW@ +# if defined __APPLE__ && defined __MACH__ +/* The presence of the declaration depends on _POSIX_C_SOURCE. */ +_GL_FUNCDECL_SYS (getw, int, (FILE *restrict stream)); +# endif +_GL_CXXALIAS_SYS (getw, int, (FILE *restrict stream)); +# endif +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (getw); +# endif +#endif + +#if @GNULIB_OBSTACK_PRINTF@ || @GNULIB_OBSTACK_PRINTF_POSIX@ +struct obstack; +/* Grow an obstack with formatted output. Return the number of + bytes added to OBS. No trailing nul byte is added, and the + object should be closed with obstack_finish before use. Upon + memory allocation error, call obstack_alloc_failed_handler. Upon + other error, return -1. */ +# if @REPLACE_OBSTACK_PRINTF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define obstack_printf rpl_obstack_printf +# endif +_GL_FUNCDECL_RPL (obstack_printf, int, + (struct obstack *obs, const char *format, ...) + _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) + _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (obstack_printf, int, + (struct obstack *obs, const char *format, ...)); +# else +# if !@HAVE_DECL_OBSTACK_PRINTF@ +_GL_FUNCDECL_SYS (obstack_printf, int, + (struct obstack *obs, const char *format, ...) + _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) + _GL_ARG_NONNULL ((1, 2))); +# endif +_GL_CXXALIAS_SYS (obstack_printf, int, + (struct obstack *obs, const char *format, ...)); +# endif +_GL_CXXALIASWARN (obstack_printf); +# if @REPLACE_OBSTACK_PRINTF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define obstack_vprintf rpl_obstack_vprintf +# endif +_GL_FUNCDECL_RPL (obstack_vprintf, int, + (struct obstack *obs, const char *format, va_list args) + _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) + _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (obstack_vprintf, int, + (struct obstack *obs, const char *format, va_list args)); +# else +# if !@HAVE_DECL_OBSTACK_PRINTF@ +_GL_FUNCDECL_SYS (obstack_vprintf, int, + (struct obstack *obs, const char *format, va_list args) + _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) + _GL_ARG_NONNULL ((1, 2))); +# endif +_GL_CXXALIAS_SYS (obstack_vprintf, int, + (struct obstack *obs, const char *format, va_list args)); +# endif +_GL_CXXALIASWARN (obstack_vprintf); +#endif + +#if @GNULIB_PCLOSE@ +# if !@HAVE_PCLOSE@ +_GL_FUNCDECL_SYS (pclose, int, (FILE *stream) _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (pclose, int, (FILE *stream)); +_GL_CXXALIASWARN (pclose); +#elif defined GNULIB_POSIXCHECK +# undef pclose +# if HAVE_RAW_DECL_PCLOSE +_GL_WARN_ON_USE (pclose, "pclose is unportable - " + "use gnulib module pclose for more portability"); +# endif +#endif + +#if @GNULIB_PERROR@ +/* Print a message to standard error, describing the value of ERRNO, + (if STRING is not NULL and not empty) prefixed with STRING and ": ", + and terminated with a newline. */ +# if @REPLACE_PERROR@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define perror rpl_perror +# endif +_GL_FUNCDECL_RPL (perror, void, (const char *string)); +_GL_CXXALIAS_RPL (perror, void, (const char *string)); +# else +_GL_CXXALIAS_SYS (perror, void, (const char *string)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (perror); +# endif +#elif defined GNULIB_POSIXCHECK +# undef perror +/* Assume perror is always declared. */ +_GL_WARN_ON_USE (perror, "perror is not always POSIX compliant - " + "use gnulib module perror for portability"); +#endif + +#if @GNULIB_POPEN@ +# if @REPLACE_POPEN@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef popen +# define popen rpl_popen +# endif +_GL_FUNCDECL_RPL (popen, FILE *, + (const char *cmd, const char *mode) + _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1) + _GL_ATTRIBUTE_MALLOC); +_GL_CXXALIAS_RPL (popen, FILE *, (const char *cmd, const char *mode)); +# else +# if !@HAVE_POPEN@ || __GNUC__ >= 11 +_GL_FUNCDECL_SYS (popen, FILE *, + (const char *cmd, const char *mode) + _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1) + _GL_ATTRIBUTE_MALLOC); +# endif +_GL_CXXALIAS_SYS (popen, FILE *, (const char *cmd, const char *mode)); +# endif +_GL_CXXALIASWARN (popen); +#else +# if @GNULIB_PCLOSE@ && __GNUC__ >= 11 && !defined popen +/* For -Wmismatched-dealloc: Associate popen with pclose or rpl_pclose. */ +_GL_FUNCDECL_SYS (popen, FILE *, + (const char *cmd, const char *mode) + _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1) + _GL_ATTRIBUTE_MALLOC); +# endif +# if defined GNULIB_POSIXCHECK +# undef popen +# if HAVE_RAW_DECL_POPEN +_GL_WARN_ON_USE (popen, "popen is buggy on some platforms - " + "use gnulib module popen or pipe for more portability"); +# endif +# endif +#endif + +#if @GNULIB_PRINTF_POSIX@ || @GNULIB_PRINTF@ +# if (@GNULIB_PRINTF_POSIX@ && @REPLACE_PRINTF@) \ + || (@GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)) +# if defined __GNUC__ || defined __clang__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +/* Don't break __attribute__((format(printf,M,N))). */ +# define printf __printf__ +# endif +# if @GNULIB_PRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@ +_GL_FUNCDECL_RPL_1 (__printf__, int, + (const char *restrict format, ...) + __asm__ (@ASM_SYMBOL_PREFIX@ + _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf)) + _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 2) + _GL_ARG_NONNULL ((1))); +# else +_GL_FUNCDECL_RPL_1 (__printf__, int, + (const char *restrict format, ...) + __asm__ (@ASM_SYMBOL_PREFIX@ + _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf)) + _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 2) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_RPL_1 (printf, __printf__, int, (const char *format, ...)); +# else +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define printf rpl_printf +# endif +_GL_FUNCDECL_RPL (printf, int, + (const char *restrict format, ...) + _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 2) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (printf, int, (const char *restrict format, ...)); +# endif +# define GNULIB_overrides_printf 1 +# else +_GL_CXXALIAS_SYS (printf, int, (const char *restrict format, ...)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (printf); +# endif +#endif +#if !@GNULIB_PRINTF_POSIX@ && defined GNULIB_POSIXCHECK +# if !GNULIB_overrides_printf +# undef printf +# endif +/* Assume printf is always declared. */ +_GL_WARN_ON_USE (printf, "printf is not always POSIX compliant - " + "use gnulib module printf-posix for portable " + "POSIX compliance"); +#endif + +#if @GNULIB_PUTC@ +# if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@) +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef putc +# define putc rpl_fputc +# endif +_GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream) _GL_ARG_NONNULL ((2))); +_GL_CXXALIAS_RPL_1 (putc, rpl_fputc, int, (int c, FILE *stream)); +# else +_GL_CXXALIAS_SYS (putc, int, (int c, FILE *stream)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (putc); +# endif +#endif + +#if @GNULIB_PUTCHAR@ +# if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@) +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef putchar +# define putchar rpl_putchar +# endif +_GL_FUNCDECL_RPL (putchar, int, (int c)); +_GL_CXXALIAS_RPL (putchar, int, (int c)); +# else +_GL_CXXALIAS_SYS (putchar, int, (int c)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (putchar); +# endif +#endif + +#if @GNULIB_PUTS@ +# if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@) +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef puts +# define puts rpl_puts +# endif +_GL_FUNCDECL_RPL (puts, int, (const char *string) _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (puts, int, (const char *string)); +# else +_GL_CXXALIAS_SYS (puts, int, (const char *string)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (puts); +# endif +#endif + +#if @GNULIB_MDA_PUTW@ +/* On native Windows, map 'putw' to '_putw', so that -loldnames is not + required. In C++ with GNULIB_NAMESPACE, avoid differences between + platforms by defining GNULIB_NAMESPACE::putw always. */ +# if defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef putw +# define putw _putw +# endif +_GL_CXXALIAS_MDA (putw, int, (int w, FILE *restrict stream)); +# else +# if @HAVE_DECL_PUTW@ +# if defined __APPLE__ && defined __MACH__ +/* The presence of the declaration depends on _POSIX_C_SOURCE. */ +_GL_FUNCDECL_SYS (putw, int, (int w, FILE *restrict stream)); +# endif +_GL_CXXALIAS_SYS (putw, int, (int w, FILE *restrict stream)); +# endif +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (putw); +# endif +#endif + +#if @GNULIB_REMOVE@ +# if @REPLACE_REMOVE@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef remove +# define remove rpl_remove +# endif +_GL_FUNCDECL_RPL (remove, int, (const char *name) _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (remove, int, (const char *name)); +# else +_GL_CXXALIAS_SYS (remove, int, (const char *name)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (remove); +# endif +#elif defined GNULIB_POSIXCHECK +# undef remove +/* Assume remove is always declared. */ +_GL_WARN_ON_USE (remove, "remove cannot handle directories on some platforms - " + "use gnulib module remove for more portability"); +#endif + +#if @GNULIB_RENAME@ +# if @REPLACE_RENAME@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef rename +# define rename rpl_rename +# endif +_GL_FUNCDECL_RPL (rename, int, + (const char *old_filename, const char *new_filename) + _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (rename, int, + (const char *old_filename, const char *new_filename)); +# else +_GL_CXXALIAS_SYS (rename, int, + (const char *old_filename, const char *new_filename)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (rename); +# endif +#elif defined GNULIB_POSIXCHECK +# undef rename +/* Assume rename is always declared. */ +_GL_WARN_ON_USE (rename, "rename is buggy on some platforms - " + "use gnulib module rename for more portability"); +#endif + +#if @GNULIB_RENAMEAT@ +# if @REPLACE_RENAMEAT@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef renameat +# define renameat rpl_renameat +# endif +_GL_FUNCDECL_RPL (renameat, int, + (int fd1, char const *file1, int fd2, char const *file2) + _GL_ARG_NONNULL ((2, 4))); +_GL_CXXALIAS_RPL (renameat, int, + (int fd1, char const *file1, int fd2, char const *file2)); +# else +# if !@HAVE_RENAMEAT@ +_GL_FUNCDECL_SYS (renameat, int, + (int fd1, char const *file1, int fd2, char const *file2) + _GL_ARG_NONNULL ((2, 4))); +# endif +_GL_CXXALIAS_SYS (renameat, int, + (int fd1, char const *file1, int fd2, char const *file2)); +# endif +_GL_CXXALIASWARN (renameat); +#elif defined GNULIB_POSIXCHECK +# undef renameat +# if HAVE_RAW_DECL_RENAMEAT +_GL_WARN_ON_USE (renameat, "renameat is not portable - " + "use gnulib module renameat for portability"); +# endif +#endif + +#if @GNULIB_SCANF@ +# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@ +# if defined __GNUC__ || defined __clang__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef scanf +/* Don't break __attribute__((format(scanf,M,N))). */ +# define scanf __scanf__ +# endif +_GL_FUNCDECL_RPL_1 (__scanf__, int, + (const char *restrict format, ...) + __asm__ (@ASM_SYMBOL_PREFIX@ + _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_scanf)) + _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL_1 (scanf, __scanf__, int, (const char *restrict format, ...)); +# else +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef scanf +# define scanf rpl_scanf +# endif +_GL_FUNCDECL_RPL (scanf, int, (const char *restrict format, ...) + _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (scanf, int, (const char *restrict format, ...)); +# endif +# else +_GL_CXXALIAS_SYS (scanf, int, (const char *restrict format, ...)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (scanf); +# endif +#endif + +#if @GNULIB_SNPRINTF@ +# if @REPLACE_SNPRINTF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define snprintf rpl_snprintf +# endif +# define GNULIB_overrides_snprintf 1 +_GL_FUNCDECL_RPL (snprintf, int, + (char *restrict str, size_t size, + const char *restrict format, ...) + _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 4) + _GL_ARG_NONNULL ((3))); +_GL_CXXALIAS_RPL (snprintf, int, + (char *restrict str, size_t size, + const char *restrict format, ...)); +# else +# if !@HAVE_DECL_SNPRINTF@ +_GL_FUNCDECL_SYS (snprintf, int, + (char *restrict str, size_t size, + const char *restrict format, ...) + _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 4) + _GL_ARG_NONNULL ((3))); +# endif +_GL_CXXALIAS_SYS (snprintf, int, + (char *restrict str, size_t size, + const char *restrict format, ...)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (snprintf); +# endif +#elif defined GNULIB_POSIXCHECK +# undef snprintf +# if HAVE_RAW_DECL_SNPRINTF +_GL_WARN_ON_USE (snprintf, "snprintf is unportable - " + "use gnulib module snprintf for portability"); +# endif +#endif + +/* Some people would argue that all sprintf uses should be warned about + (for example, OpenBSD issues a link warning for it), + since it can cause security holes due to buffer overruns. + However, we believe that sprintf can be used safely, and is more + efficient than snprintf in those safe cases; and as proof of our + belief, we use sprintf in several gnulib modules. So this header + intentionally avoids adding a warning to sprintf except when + GNULIB_POSIXCHECK is defined. */ + +#if @GNULIB_SPRINTF_POSIX@ +# if @REPLACE_SPRINTF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define sprintf rpl_sprintf +# endif +# define GNULIB_overrides_sprintf 1 +_GL_FUNCDECL_RPL (sprintf, int, + (char *restrict str, const char *restrict format, ...) + _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) + _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (sprintf, int, + (char *restrict str, const char *restrict format, ...)); +# else +_GL_CXXALIAS_SYS (sprintf, int, + (char *restrict str, const char *restrict format, ...)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (sprintf); +# endif +#elif defined GNULIB_POSIXCHECK +# undef sprintf +/* Assume sprintf is always declared. */ +_GL_WARN_ON_USE (sprintf, "sprintf is not always POSIX compliant - " + "use gnulib module sprintf-posix for portable " + "POSIX compliance"); +#endif + +#if @GNULIB_MDA_TEMPNAM@ +/* On native Windows, map 'tempnam' to '_tempnam', so that -loldnames is not + required. In C++ with GNULIB_NAMESPACE, avoid differences between + platforms by defining GNULIB_NAMESPACE::tempnam always. */ +# if defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef tempnam +# define tempnam _tempnam +# endif +_GL_CXXALIAS_MDA (tempnam, char *, (const char *dir, const char *prefix)); +# else +_GL_CXXALIAS_SYS (tempnam, char *, (const char *dir, const char *prefix)); +# endif +_GL_CXXALIASWARN (tempnam); +#endif + +#if @GNULIB_TMPFILE@ +# if @REPLACE_TMPFILE@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define tmpfile rpl_tmpfile +# endif +_GL_FUNCDECL_RPL (tmpfile, FILE *, (void) + _GL_ATTRIBUTE_DEALLOC (fclose, 1) + _GL_ATTRIBUTE_MALLOC); +_GL_CXXALIAS_RPL (tmpfile, FILE *, (void)); +# else +# if __GNUC__ >= 11 +/* For -Wmismatched-dealloc: Associate tmpfile with fclose or rpl_fclose. */ +_GL_FUNCDECL_SYS (tmpfile, FILE *, (void) + _GL_ATTRIBUTE_DEALLOC (fclose, 1) + _GL_ATTRIBUTE_MALLOC); +# endif +_GL_CXXALIAS_SYS (tmpfile, FILE *, (void)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (tmpfile); +# endif +#else +# if @GNULIB_FCLOSE@ && __GNUC__ >= 11 && !defined tmpfile +/* For -Wmismatched-dealloc: Associate tmpfile with fclose or rpl_fclose. */ +_GL_FUNCDECL_SYS (tmpfile, FILE *, (void) + _GL_ATTRIBUTE_DEALLOC (fclose, 1) + _GL_ATTRIBUTE_MALLOC); +# endif +# if defined GNULIB_POSIXCHECK +# undef tmpfile +# if HAVE_RAW_DECL_TMPFILE +_GL_WARN_ON_USE (tmpfile, "tmpfile is not usable on mingw - " + "use gnulib module tmpfile for portability"); +# endif +# endif +#endif + +#if @GNULIB_VASPRINTF@ +/* Write formatted output to a string dynamically allocated with malloc(). + If the memory allocation succeeds, store the address of the string in + *RESULT and return the number of resulting bytes, excluding the trailing + NUL. Upon memory allocation error, or some other error, return -1. */ +# if @REPLACE_VASPRINTF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define asprintf rpl_asprintf +# endif +# define GNULIB_overrides_asprintf +_GL_FUNCDECL_RPL (asprintf, int, + (char **result, const char *format, ...) + _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) + _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (asprintf, int, + (char **result, const char *format, ...)); +# else +# if !@HAVE_VASPRINTF@ +_GL_FUNCDECL_SYS (asprintf, int, + (char **result, const char *format, ...) + _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) + _GL_ARG_NONNULL ((1, 2))); +# endif +_GL_CXXALIAS_SYS (asprintf, int, + (char **result, const char *format, ...)); +# endif +_GL_CXXALIASWARN (asprintf); +# if @REPLACE_VASPRINTF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define vasprintf rpl_vasprintf +# endif +# define GNULIB_overrides_vasprintf 1 +_GL_FUNCDECL_RPL (vasprintf, int, + (char **result, const char *format, va_list args) + _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) + _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (vasprintf, int, + (char **result, const char *format, va_list args)); +# else +# if !@HAVE_VASPRINTF@ +_GL_FUNCDECL_SYS (vasprintf, int, + (char **result, const char *format, va_list args) + _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) + _GL_ARG_NONNULL ((1, 2))); +# endif +_GL_CXXALIAS_SYS (vasprintf, int, + (char **result, const char *format, va_list args)); +# endif +_GL_CXXALIASWARN (vasprintf); +#endif + +#if @GNULIB_VDPRINTF@ +# if @REPLACE_VDPRINTF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define vdprintf rpl_vdprintf +# endif +_GL_FUNCDECL_RPL (vdprintf, int, + (int fd, const char *restrict format, va_list args) + _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) + _GL_ARG_NONNULL ((2))); +_GL_CXXALIAS_RPL (vdprintf, int, + (int fd, const char *restrict format, va_list args)); +# else +# if !@HAVE_VDPRINTF@ +_GL_FUNCDECL_SYS (vdprintf, int, + (int fd, const char *restrict format, va_list args) + _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) + _GL_ARG_NONNULL ((2))); +# endif +/* Need to cast, because on Solaris, the third parameter will likely be + __va_list args. */ +_GL_CXXALIAS_SYS_CAST (vdprintf, int, + (int fd, const char *restrict format, va_list args)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (vdprintf); +# endif +#elif defined GNULIB_POSIXCHECK +# undef vdprintf +# if HAVE_RAW_DECL_VDPRINTF +_GL_WARN_ON_USE (vdprintf, "vdprintf is unportable - " + "use gnulib module vdprintf for portability"); +# endif +#endif + +#if @GNULIB_VFPRINTF_POSIX@ || @GNULIB_VFPRINTF@ +# if (@GNULIB_VFPRINTF_POSIX@ && @REPLACE_VFPRINTF@) \ + || (@GNULIB_VFPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)) +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define vfprintf rpl_vfprintf +# endif +# define GNULIB_overrides_vfprintf 1 +# if @GNULIB_VFPRINTF_POSIX@ +_GL_FUNCDECL_RPL (vfprintf, int, + (FILE *restrict fp, + const char *restrict format, va_list args) + _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) + _GL_ARG_NONNULL ((1, 2))); +# else +_GL_FUNCDECL_RPL (vfprintf, int, + (FILE *restrict fp, + const char *restrict format, va_list args) + _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 0) + _GL_ARG_NONNULL ((1, 2))); +# endif +_GL_CXXALIAS_RPL (vfprintf, int, + (FILE *restrict fp, + const char *restrict format, va_list args)); +# else +/* Need to cast, because on Solaris, the third parameter is + __va_list args + and GCC's fixincludes did not change this to __gnuc_va_list. */ +_GL_CXXALIAS_SYS_CAST (vfprintf, int, + (FILE *restrict fp, + const char *restrict format, va_list args)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (vfprintf); +# endif +#endif +#if !@GNULIB_VFPRINTF_POSIX@ && defined GNULIB_POSIXCHECK +# if !GNULIB_overrides_vfprintf +# undef vfprintf +# endif +/* Assume vfprintf is always declared. */ +_GL_WARN_ON_USE (vfprintf, "vfprintf is not always POSIX compliant - " + "use gnulib module vfprintf-posix for portable " + "POSIX compliance"); +#endif + +#if @GNULIB_VFSCANF@ +# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef vfscanf +# define vfscanf rpl_vfscanf +# endif +_GL_FUNCDECL_RPL (vfscanf, int, + (FILE *restrict stream, + const char *restrict format, va_list args) + _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 0) + _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (vfscanf, int, + (FILE *restrict stream, + const char *restrict format, va_list args)); +# else +_GL_CXXALIAS_SYS (vfscanf, int, + (FILE *restrict stream, + const char *restrict format, va_list args)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (vfscanf); +# endif +#endif + +#if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VPRINTF@ +# if (@GNULIB_VPRINTF_POSIX@ && @REPLACE_VPRINTF@) \ + || (@GNULIB_VPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)) +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define vprintf rpl_vprintf +# endif +# define GNULIB_overrides_vprintf 1 +# if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@ +_GL_FUNCDECL_RPL (vprintf, int, (const char *restrict format, va_list args) + _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 0) + _GL_ARG_NONNULL ((1))); +# else +_GL_FUNCDECL_RPL (vprintf, int, (const char *restrict format, va_list args) + _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 0) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_RPL (vprintf, int, (const char *restrict format, va_list args)); +# else +/* Need to cast, because on Solaris, the second parameter is + __va_list args + and GCC's fixincludes did not change this to __gnuc_va_list. */ +_GL_CXXALIAS_SYS_CAST (vprintf, int, + (const char *restrict format, va_list args)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (vprintf); +# endif +#endif +#if !@GNULIB_VPRINTF_POSIX@ && defined GNULIB_POSIXCHECK +# if !GNULIB_overrides_vprintf +# undef vprintf +# endif +/* Assume vprintf is always declared. */ +_GL_WARN_ON_USE (vprintf, "vprintf is not always POSIX compliant - " + "use gnulib module vprintf-posix for portable " + "POSIX compliance"); +#endif + +#if @GNULIB_VSCANF@ +# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef vscanf +# define vscanf rpl_vscanf +# endif +_GL_FUNCDECL_RPL (vscanf, int, (const char *restrict format, va_list args) + _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 0) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (vscanf, int, (const char *restrict format, va_list args)); +# else +_GL_CXXALIAS_SYS (vscanf, int, (const char *restrict format, va_list args)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (vscanf); +# endif +#endif + +#if @GNULIB_VSNPRINTF@ +# if @REPLACE_VSNPRINTF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define vsnprintf rpl_vsnprintf +# endif +# define GNULIB_overrides_vsnprintf 1 +_GL_FUNCDECL_RPL (vsnprintf, int, + (char *restrict str, size_t size, + const char *restrict format, va_list args) + _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 0) + _GL_ARG_NONNULL ((3))); +_GL_CXXALIAS_RPL (vsnprintf, int, + (char *restrict str, size_t size, + const char *restrict format, va_list args)); +# else +# if !@HAVE_DECL_VSNPRINTF@ +_GL_FUNCDECL_SYS (vsnprintf, int, + (char *restrict str, size_t size, + const char *restrict format, va_list args) + _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 0) + _GL_ARG_NONNULL ((3))); +# endif +_GL_CXXALIAS_SYS (vsnprintf, int, + (char *restrict str, size_t size, + const char *restrict format, va_list args)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (vsnprintf); +# endif +#elif defined GNULIB_POSIXCHECK +# undef vsnprintf +# if HAVE_RAW_DECL_VSNPRINTF +_GL_WARN_ON_USE (vsnprintf, "vsnprintf is unportable - " + "use gnulib module vsnprintf for portability"); +# endif +#endif + +#if @GNULIB_VSPRINTF_POSIX@ +# if @REPLACE_VSPRINTF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define vsprintf rpl_vsprintf +# endif +# define GNULIB_overrides_vsprintf 1 +_GL_FUNCDECL_RPL (vsprintf, int, + (char *restrict str, + const char *restrict format, va_list args) + _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) + _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (vsprintf, int, + (char *restrict str, + const char *restrict format, va_list args)); +# else +/* Need to cast, because on Solaris, the third parameter is + __va_list args + and GCC's fixincludes did not change this to __gnuc_va_list. */ +_GL_CXXALIAS_SYS_CAST (vsprintf, int, + (char *restrict str, + const char *restrict format, va_list args)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (vsprintf); +# endif +#elif defined GNULIB_POSIXCHECK +# undef vsprintf +/* Assume vsprintf is always declared. */ +_GL_WARN_ON_USE (vsprintf, "vsprintf is not always POSIX compliant - " + "use gnulib module vsprintf-posix for portable " + "POSIX compliance"); +#endif + +#endif /* _@GUARD_PREFIX@_STDIO_H */ +#endif /* _@GUARD_PREFIX@_STDIO_H */ +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stdlib.in.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stdlib.in.h new file mode 100644 index 00000000..b901d175 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stdlib.in.h @@ -0,0 +1,1853 @@ +/* A GNU-like . + + Copyright (C) 1995, 2001-2004, 2006-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +#endif +@PRAGMA_COLUMNS@ + +#if defined __need_system_stdlib_h || defined __need_malloc_and_calloc +/* Special invocation conventions inside some gnulib header files, + and inside some glibc header files, respectively. */ + +#@INCLUDE_NEXT@ @NEXT_STDLIB_H@ + +#else +/* Normal invocation convention. */ + +#ifndef _@GUARD_PREFIX@_STDLIB_H + +/* The include_next requires a split double-inclusion guard. */ +#@INCLUDE_NEXT@ @NEXT_STDLIB_H@ + +#ifndef _@GUARD_PREFIX@_STDLIB_H +#define _@GUARD_PREFIX@_STDLIB_H + +/* This file uses _Noreturn, _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_MALLOC, + _GL_ATTRIBUTE_NOTHROW, _GL_ATTRIBUTE_PURE, GNULIB_POSIXCHECK, + HAVE_RAW_DECL_*. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +/* NetBSD 5.0 mis-defines NULL. */ +#include + +/* MirBSD 10 defines WEXITSTATUS in , not in . */ +#if @GNULIB_SYSTEM_POSIX@ && !defined WEXITSTATUS +# include +#endif + +/* Solaris declares getloadavg() in . */ +#if (@GNULIB_GETLOADAVG@ || defined GNULIB_POSIXCHECK) && @HAVE_SYS_LOADAVG_H@ +/* OpenIndiana has a bug: must be included before + . */ +# include +# include +#endif + +/* Native Windows platforms declare _mktemp() in . */ +#if defined _WIN32 && !defined __CYGWIN__ +# include +#endif + +#if @GNULIB_RANDOM_R@ + +/* OSF/1 5.1 declares 'struct random_data' in , which is included + from if _REENTRANT is defined. Include it whenever we need + 'struct random_data'. */ +# if @HAVE_RANDOM_H@ +# include +# endif + +# include + +# if !@HAVE_STRUCT_RANDOM_DATA@ +/* Define 'struct random_data'. + But allow multiple gnulib generated replacements to coexist. */ +# if !GNULIB_defined_struct_random_data +struct random_data +{ + int32_t *fptr; /* Front pointer. */ + int32_t *rptr; /* Rear pointer. */ + int32_t *state; /* Array of state values. */ + int rand_type; /* Type of random number generator. */ + int rand_deg; /* Degree of random number generator. */ + int rand_sep; /* Distance between front and rear. */ + int32_t *end_ptr; /* Pointer behind state table. */ +}; +# define GNULIB_defined_struct_random_data 1 +# endif +# endif +#endif + +#if (@GNULIB_MKSTEMP@ || @GNULIB_MKSTEMPS@ || @GNULIB_MKOSTEMP@ || @GNULIB_MKOSTEMPS@ || @GNULIB_GETSUBOPT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__ && !(defined _WIN32 && ! defined __CYGWIN__) +/* On Mac OS X 10.3, only declares mkstemp. */ +/* On Mac OS X 10.5, only declares mkstemps. */ +/* On Mac OS X 10.13, only declares mkostemp and mkostemps. */ +/* On Cygwin 1.7.1, only declares getsubopt. */ +/* But avoid namespace pollution on glibc systems and native Windows. */ +# include +#endif + +/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers + that can be freed by passing them as the Ith argument to the + function F. */ +#ifndef _GL_ATTRIBUTE_DEALLOC +# if __GNUC__ >= 11 +# define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i))) +# else +# define _GL_ATTRIBUTE_DEALLOC(f, i) +# endif +#endif + +/* _GL_ATTRIBUTE_DEALLOC_FREE declares that the function returns pointers that + can be freed via 'free'; it can be used only after declaring 'free'. */ +/* Applies to: functions. Cannot be used on inline functions. */ +#ifndef _GL_ATTRIBUTE_DEALLOC_FREE +# define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (free, 1) +#endif + +/* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly + allocated memory. */ +/* Applies to: functions. */ +#ifndef _GL_ATTRIBUTE_MALLOC +# if __GNUC__ >= 3 || defined __clang__ +# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__)) +# else +# define _GL_ATTRIBUTE_MALLOC +# endif +#endif + +/* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions. + */ +#ifndef _GL_ATTRIBUTE_NOTHROW +# if defined __cplusplus +# if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major >= 4 +# if __cplusplus >= 201103L +# define _GL_ATTRIBUTE_NOTHROW noexcept (true) +# else +# define _GL_ATTRIBUTE_NOTHROW throw () +# endif +# else +# define _GL_ATTRIBUTE_NOTHROW +# endif +# else +# if (__GNUC__ + (__GNUC_MINOR__ >= 3) > 3) || defined __clang__ +# define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__)) +# else +# define _GL_ATTRIBUTE_NOTHROW +# endif +# endif +#endif + +/* The __attribute__ feature is available in gcc versions 2.5 and later. + The attribute __pure__ was added in gcc 2.96. */ +#ifndef _GL_ATTRIBUTE_PURE +# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined __clang__ +# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) +# else +# define _GL_ATTRIBUTE_PURE /* empty */ +# endif +#endif + +/* The definition of _Noreturn is copied here. */ + +/* 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. */ + + +/* Some systems do not define EXIT_*, despite otherwise supporting C89. */ +#ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 +#endif +/* Tandem/NSK and other platforms that define EXIT_FAILURE as -1 interfere + with proper operation of xargs. */ +#ifndef EXIT_FAILURE +# define EXIT_FAILURE 1 +#elif EXIT_FAILURE != 1 +# undef EXIT_FAILURE +# define EXIT_FAILURE 1 +#endif + + +#if @GNULIB__EXIT@ +/* Terminate the current process with the given return code, without running + the 'atexit' handlers. */ +# if @REPLACE__EXIT@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef _Exit +# define _Exit rpl__Exit +# endif +_GL_FUNCDECL_RPL (_Exit, _Noreturn void, (int status)); +_GL_CXXALIAS_RPL (_Exit, void, (int status)); +# else +# if !@HAVE__EXIT@ +_GL_FUNCDECL_SYS (_Exit, _Noreturn void, (int status)); +# endif +_GL_CXXALIAS_SYS (_Exit, void, (int status)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (_Exit); +# endif +#elif defined GNULIB_POSIXCHECK +# undef _Exit +# if HAVE_RAW_DECL__EXIT +_GL_WARN_ON_USE (_Exit, "_Exit is unportable - " + "use gnulib module _Exit for portability"); +# endif +#endif + + +#if @GNULIB_FREE_POSIX@ +# if @REPLACE_FREE@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef free +# define free rpl_free +# endif +# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2) +_GL_FUNCDECL_RPL (free, void, (void *ptr) _GL_ATTRIBUTE_NOTHROW); +# else +_GL_FUNCDECL_RPL (free, void, (void *ptr)); +# endif +_GL_CXXALIAS_RPL (free, void, (void *ptr)); +# else +_GL_CXXALIAS_SYS (free, void, (void *ptr)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (free); +# endif +#elif defined GNULIB_POSIXCHECK +# undef free +/* Assume free is always declared. */ +_GL_WARN_ON_USE (free, "free is not future POSIX compliant everywhere - " + "use gnulib module free for portability"); +#endif + + +/* Allocate memory with indefinite extent and specified alignment. */ +#if @GNULIB_ALIGNED_ALLOC@ +# if @REPLACE_ALIGNED_ALLOC@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef aligned_alloc +# define aligned_alloc rpl_aligned_alloc +# endif +_GL_FUNCDECL_RPL (aligned_alloc, void *, + (size_t alignment, size_t size) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +_GL_CXXALIAS_RPL (aligned_alloc, void *, (size_t alignment, size_t size)); +# else +# if @HAVE_ALIGNED_ALLOC@ +# if __GNUC__ >= 11 +/* For -Wmismatched-dealloc: Associate aligned_alloc with free or rpl_free. */ +# if __GLIBC__ + (__GLIBC_MINOR__ >= 16) > 2 +_GL_FUNCDECL_SYS (aligned_alloc, void *, + (size_t alignment, size_t size) + _GL_ATTRIBUTE_NOTHROW + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# else +_GL_FUNCDECL_SYS (aligned_alloc, void *, + (size_t alignment, size_t size) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# endif +# endif +_GL_CXXALIAS_SYS (aligned_alloc, void *, (size_t alignment, size_t size)); +# endif +# endif +# if (__GLIBC__ >= 2) && @HAVE_ALIGNED_ALLOC@ +_GL_CXXALIASWARN (aligned_alloc); +# endif +#else +# if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined aligned_alloc +/* For -Wmismatched-dealloc: Associate aligned_alloc with free or rpl_free. */ +# if __GLIBC__ + (__GLIBC_MINOR__ >= 16) > 2 +_GL_FUNCDECL_SYS (aligned_alloc, void *, + (size_t alignment, size_t size) + _GL_ATTRIBUTE_NOTHROW + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# else +_GL_FUNCDECL_SYS (aligned_alloc, void *, + (size_t alignment, size_t size) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# endif +# endif +# if defined GNULIB_POSIXCHECK +# undef aligned_alloc +# if HAVE_RAW_DECL_ALIGNED_ALLOC +_GL_WARN_ON_USE (aligned_alloc, "aligned_alloc is not portable - " + "use gnulib module aligned_alloc for portability"); +# endif +# endif +#endif + +#if @GNULIB_ATOLL@ +/* Parse a signed decimal integer. + Returns the value of the integer. Errors are not detected. */ +# if !@HAVE_ATOLL@ +_GL_FUNCDECL_SYS (atoll, long long, (const char *string) + _GL_ATTRIBUTE_PURE + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (atoll, long long, (const char *string)); +_GL_CXXALIASWARN (atoll); +#elif defined GNULIB_POSIXCHECK +# undef atoll +# if HAVE_RAW_DECL_ATOLL +_GL_WARN_ON_USE (atoll, "atoll is unportable - " + "use gnulib module atoll for portability"); +# endif +#endif + +#if @GNULIB_CALLOC_POSIX@ +# if (@GNULIB_CALLOC_POSIX@ && @REPLACE_CALLOC_FOR_CALLOC_POSIX@) \ + || (@GNULIB_CALLOC_GNU@ && @REPLACE_CALLOC_FOR_CALLOC_GNU@) +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef calloc +# define calloc rpl_calloc +# endif +_GL_FUNCDECL_RPL (calloc, void *, + (size_t nmemb, size_t size) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +_GL_CXXALIAS_RPL (calloc, void *, (size_t nmemb, size_t size)); +# else +# if __GNUC__ >= 11 +/* For -Wmismatched-dealloc: Associate calloc with free or rpl_free. */ +# if __GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2 +_GL_FUNCDECL_SYS (calloc, void *, + (size_t nmemb, size_t size) + _GL_ATTRIBUTE_NOTHROW + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# else +_GL_FUNCDECL_SYS (calloc, void *, + (size_t nmemb, size_t size) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# endif +# endif +_GL_CXXALIAS_SYS (calloc, void *, (size_t nmemb, size_t size)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (calloc); +# endif +#else +# if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined calloc +/* For -Wmismatched-dealloc: Associate calloc with free or rpl_free. */ +# if __GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2 +_GL_FUNCDECL_SYS (calloc, void *, + (size_t nmemb, size_t size) + _GL_ATTRIBUTE_NOTHROW + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# else +_GL_FUNCDECL_SYS (calloc, void *, + (size_t nmemb, size_t size) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# endif +# endif +# if defined GNULIB_POSIXCHECK +# undef calloc +/* Assume calloc is always declared. */ +_GL_WARN_ON_USE (calloc, "calloc is not POSIX compliant everywhere - " + "use gnulib module calloc-posix for portability"); +# endif +#endif + +#if @GNULIB_CANONICALIZE_FILE_NAME@ +# if @REPLACE_CANONICALIZE_FILE_NAME@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define canonicalize_file_name rpl_canonicalize_file_name +# endif +_GL_FUNCDECL_RPL (canonicalize_file_name, char *, + (const char *name) + _GL_ARG_NONNULL ((1)) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +_GL_CXXALIAS_RPL (canonicalize_file_name, char *, (const char *name)); +# else +# if !@HAVE_CANONICALIZE_FILE_NAME@ || __GNUC__ >= 11 +# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 +_GL_FUNCDECL_SYS (canonicalize_file_name, char *, + (const char *name) + _GL_ATTRIBUTE_NOTHROW + _GL_ARG_NONNULL ((1)) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# else +_GL_FUNCDECL_SYS (canonicalize_file_name, char *, + (const char *name) + _GL_ARG_NONNULL ((1)) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# endif +# endif +_GL_CXXALIAS_SYS (canonicalize_file_name, char *, (const char *name)); +# endif +# ifndef GNULIB_defined_canonicalize_file_name +# define GNULIB_defined_canonicalize_file_name \ + (!@HAVE_CANONICALIZE_FILE_NAME@ || @REPLACE_CANONICALIZE_FILE_NAME@) +# endif +_GL_CXXALIASWARN (canonicalize_file_name); +#else +# if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined canonicalize_file_name +/* For -Wmismatched-dealloc: Associate canonicalize_file_name with free or + rpl_free. */ +# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 +_GL_FUNCDECL_SYS (canonicalize_file_name, char *, + (const char *name) + _GL_ATTRIBUTE_NOTHROW + _GL_ARG_NONNULL ((1)) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# else +_GL_FUNCDECL_SYS (canonicalize_file_name, char *, + (const char *name) + _GL_ARG_NONNULL ((1)) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# endif +# endif +# if defined GNULIB_POSIXCHECK +# undef canonicalize_file_name +# if HAVE_RAW_DECL_CANONICALIZE_FILE_NAME +_GL_WARN_ON_USE (canonicalize_file_name, + "canonicalize_file_name is unportable - " + "use gnulib module canonicalize-lgpl for portability"); +# endif +# endif +#endif + +#if @GNULIB_MDA_ECVT@ +/* On native Windows, map 'ecvt' to '_ecvt', so that -loldnames is not + required. In C++ with GNULIB_NAMESPACE, avoid differences between + platforms by defining GNULIB_NAMESPACE::ecvt on all platforms that have + it. */ +# if defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef ecvt +# define ecvt _ecvt +# endif +_GL_CXXALIAS_MDA (ecvt, char *, + (double number, int ndigits, int *decptp, int *signp)); +# else +# if @HAVE_DECL_ECVT@ +_GL_CXXALIAS_SYS (ecvt, char *, + (double number, int ndigits, int *decptp, int *signp)); +# endif +# endif +# if (defined _WIN32 && !defined __CYGWIN__) || @HAVE_DECL_ECVT@ +_GL_CXXALIASWARN (ecvt); +# endif +#endif + +#if @GNULIB_MDA_FCVT@ +/* On native Windows, map 'fcvt' to '_fcvt', so that -loldnames is not + required. In C++ with GNULIB_NAMESPACE, avoid differences between + platforms by defining GNULIB_NAMESPACE::fcvt on all platforms that have + it. */ +# if defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef fcvt +# define fcvt _fcvt +# endif +_GL_CXXALIAS_MDA (fcvt, char *, + (double number, int ndigits, int *decptp, int *signp)); +# else +# if @HAVE_DECL_FCVT@ +_GL_CXXALIAS_SYS (fcvt, char *, + (double number, int ndigits, int *decptp, int *signp)); +# endif +# endif +# if (defined _WIN32 && !defined __CYGWIN__) || @HAVE_DECL_FCVT@ +_GL_CXXALIASWARN (fcvt); +# endif +#endif + +#if @GNULIB_MDA_GCVT@ +/* On native Windows, map 'gcvt' to '_gcvt', so that -loldnames is not + required. In C++ with GNULIB_NAMESPACE, avoid differences between + platforms by defining GNULIB_NAMESPACE::gcvt on all platforms that have + it. */ +# if defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef gcvt +# define gcvt _gcvt +# endif +_GL_CXXALIAS_MDA (gcvt, char *, (double number, int ndigits, char *buf)); +# else +# if @HAVE_DECL_GCVT@ +_GL_CXXALIAS_SYS (gcvt, char *, (double number, int ndigits, char *buf)); +# endif +# endif +# if (defined _WIN32 && !defined __CYGWIN__) || @HAVE_DECL_GCVT@ +_GL_CXXALIASWARN (gcvt); +# endif +#endif + +#if @GNULIB_GETLOADAVG@ +/* Store max(NELEM,3) load average numbers in LOADAVG[]. + The three numbers are the load average of the last 1 minute, the last 5 + minutes, and the last 15 minutes, respectively. + LOADAVG is an array of NELEM numbers. */ +# if @REPLACE_GETLOADAVG@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef getloadavg +# define getloadavg rpl_getloadavg +# endif +_GL_FUNCDECL_RPL (getloadavg, int, (double loadavg[], int nelem) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (getloadavg, int, (double loadavg[], int nelem)); +# else +# if !@HAVE_DECL_GETLOADAVG@ +_GL_FUNCDECL_SYS (getloadavg, int, (double loadavg[], int nelem) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (getloadavg, int, (double loadavg[], int nelem)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (getloadavg); +# endif +#elif defined GNULIB_POSIXCHECK +# undef getloadavg +# if HAVE_RAW_DECL_GETLOADAVG +_GL_WARN_ON_USE (getloadavg, "getloadavg is not portable - " + "use gnulib module getloadavg for portability"); +# endif +#endif + +#if @GNULIB_GETPROGNAME@ +/* Return the base name of the executing program. + On native Windows this will usually end in ".exe" or ".EXE". */ +# if @REPLACE_GETPROGNAME@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef getprogname +# define getprogname rpl_getprogname +# endif +# if @HAVE_DECL_PROGRAM_INVOCATION_NAME@ +_GL_FUNCDECL_RPL (getprogname, const char *, (void) _GL_ATTRIBUTE_PURE); +# else +_GL_FUNCDECL_RPL (getprogname, const char *, (void)); +# endif +_GL_CXXALIAS_RPL (getprogname, const char *, (void)); +# else +# if !@HAVE_GETPROGNAME@ +# if @HAVE_DECL_PROGRAM_INVOCATION_NAME@ +_GL_FUNCDECL_SYS (getprogname, const char *, (void) _GL_ATTRIBUTE_PURE); +# else +_GL_FUNCDECL_SYS (getprogname, const char *, (void)); +# endif +# endif +_GL_CXXALIAS_SYS (getprogname, const char *, (void)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (getprogname); +# endif +#elif defined GNULIB_POSIXCHECK +# undef getprogname +# if HAVE_RAW_DECL_GETPROGNAME +_GL_WARN_ON_USE (getprogname, "getprogname is unportable - " + "use gnulib module getprogname for portability"); +# endif +#endif + +#if @GNULIB_GETSUBOPT@ +/* Assuming *OPTIONP is a comma separated list of elements of the form + "token" or "token=value", getsubopt parses the first of these elements. + If the first element refers to a "token" that is member of the given + NULL-terminated array of tokens: + - It replaces the comma with a NUL byte, updates *OPTIONP to point past + the first option and the comma, sets *VALUEP to the value of the + element (or NULL if it doesn't contain an "=" sign), + - It returns the index of the "token" in the given array of tokens. + Otherwise it returns -1, and *OPTIONP and *VALUEP are undefined. + For more details see the POSIX specification. + https://pubs.opengroup.org/onlinepubs/9699919799/functions/getsubopt.html */ +# if @REPLACE_GETSUBOPT@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef getsubopt +# define getsubopt rpl_getsubopt +# endif +_GL_FUNCDECL_RPL (getsubopt, int, + (char **optionp, char *const *tokens, char **valuep) + _GL_ARG_NONNULL ((1, 2, 3))); +_GL_CXXALIAS_RPL (getsubopt, int, + (char **optionp, char *const *tokens, char **valuep)); +# else +# if !@HAVE_GETSUBOPT@ +_GL_FUNCDECL_SYS (getsubopt, int, + (char **optionp, char *const *tokens, char **valuep) + _GL_ARG_NONNULL ((1, 2, 3))); +# endif +_GL_CXXALIAS_SYS (getsubopt, int, + (char **optionp, char *const *tokens, char **valuep)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (getsubopt); +# endif +#elif defined GNULIB_POSIXCHECK +# undef getsubopt +# if HAVE_RAW_DECL_GETSUBOPT +_GL_WARN_ON_USE (getsubopt, "getsubopt is unportable - " + "use gnulib module getsubopt for portability"); +# endif +#endif + +#if @GNULIB_GRANTPT@ +/* Change the ownership and access permission of the slave side of the + pseudo-terminal whose master side is specified by FD. */ +# if !@HAVE_GRANTPT@ +_GL_FUNCDECL_SYS (grantpt, int, (int fd)); +# endif +_GL_CXXALIAS_SYS (grantpt, int, (int fd)); +_GL_CXXALIASWARN (grantpt); +#elif defined GNULIB_POSIXCHECK +# undef grantpt +# if HAVE_RAW_DECL_GRANTPT +_GL_WARN_ON_USE (grantpt, "grantpt is not portable - " + "use gnulib module grantpt for portability"); +# endif +#endif + +/* If _GL_USE_STDLIB_ALLOC is nonzero, the including module does not + rely on GNU or POSIX semantics for malloc and realloc (for example, + by never specifying a zero size), so it does not need malloc or + realloc to be redefined. */ +#if @GNULIB_MALLOC_POSIX@ +# if (@GNULIB_MALLOC_POSIX@ && @REPLACE_MALLOC_FOR_MALLOC_POSIX@) \ + || (@GNULIB_MALLOC_GNU@ && @REPLACE_MALLOC_FOR_MALLOC_GNU@) +# if !((defined __cplusplus && defined GNULIB_NAMESPACE) \ + || _GL_USE_STDLIB_ALLOC) +# undef malloc +# define malloc rpl_malloc +# endif +_GL_FUNCDECL_RPL (malloc, void *, + (size_t size) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +_GL_CXXALIAS_RPL (malloc, void *, (size_t size)); +# else +# if __GNUC__ >= 11 +/* For -Wmismatched-dealloc: Associate malloc with free or rpl_free. */ +# if __GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2 +_GL_FUNCDECL_SYS (malloc, void *, + (size_t size) + _GL_ATTRIBUTE_NOTHROW + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# else +_GL_FUNCDECL_SYS (malloc, void *, + (size_t size) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# endif +# endif +_GL_CXXALIAS_SYS (malloc, void *, (size_t size)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (malloc); +# endif +#else +# if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined malloc +/* For -Wmismatched-dealloc: Associate malloc with free or rpl_free. */ +# if __GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2 +_GL_FUNCDECL_SYS (malloc, void *, + (size_t size) + _GL_ATTRIBUTE_NOTHROW + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# else +_GL_FUNCDECL_SYS (malloc, void *, + (size_t size) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# endif +# endif +# if defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC +# undef malloc +/* Assume malloc is always declared. */ +_GL_WARN_ON_USE (malloc, "malloc is not POSIX compliant everywhere - " + "use gnulib module malloc-posix for portability"); +# endif +#endif + +/* Return maximum number of bytes of a multibyte character. */ +#if @REPLACE_MB_CUR_MAX@ +# if !GNULIB_defined_MB_CUR_MAX +static inline +int gl_MB_CUR_MAX (void) +{ + /* Turn the value 3 to the value 4, as needed for the UTF-8 encoding. */ + return MB_CUR_MAX + (MB_CUR_MAX == 3); +} +# undef MB_CUR_MAX +# define MB_CUR_MAX gl_MB_CUR_MAX () +# define GNULIB_defined_MB_CUR_MAX 1 +# endif +#endif + +/* Convert a string to a wide string. */ +#if @GNULIB_MBSTOWCS@ +# if @REPLACE_MBSTOWCS@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef mbstowcs +# define mbstowcs rpl_mbstowcs +# endif +_GL_FUNCDECL_RPL (mbstowcs, size_t, + (wchar_t *restrict dest, const char *restrict src, + size_t len) + _GL_ARG_NONNULL ((2))); +_GL_CXXALIAS_RPL (mbstowcs, size_t, + (wchar_t *restrict dest, const char *restrict src, + size_t len)); +# else +_GL_CXXALIAS_SYS (mbstowcs, size_t, + (wchar_t *restrict dest, const char *restrict src, + size_t len)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (mbstowcs); +# endif +#elif defined GNULIB_POSIXCHECK +# undef mbstowcs +# if HAVE_RAW_DECL_MBSTOWCS +_GL_WARN_ON_USE (mbstowcs, "mbstowcs is unportable - " + "use gnulib module mbstowcs for portability"); +# endif +#endif + +/* Convert a multibyte character to a wide character. */ +#if @GNULIB_MBTOWC@ +# if @REPLACE_MBTOWC@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef mbtowc +# define mbtowc rpl_mbtowc +# endif +_GL_FUNCDECL_RPL (mbtowc, int, + (wchar_t *restrict pwc, const char *restrict s, size_t n)); +_GL_CXXALIAS_RPL (mbtowc, int, + (wchar_t *restrict pwc, const char *restrict s, size_t n)); +# else +# if !@HAVE_MBTOWC@ +_GL_FUNCDECL_SYS (mbtowc, int, + (wchar_t *restrict pwc, const char *restrict s, size_t n)); +# endif +_GL_CXXALIAS_SYS (mbtowc, int, + (wchar_t *restrict pwc, const char *restrict s, size_t n)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (mbtowc); +# endif +#elif defined GNULIB_POSIXCHECK +# undef mbtowc +# if HAVE_RAW_DECL_MBTOWC +_GL_WARN_ON_USE (mbtowc, "mbtowc is not portable - " + "use gnulib module mbtowc for portability"); +# endif +#endif + +#if @GNULIB_MKDTEMP@ +/* Create a unique temporary directory from TEMPLATE. + The last six characters of TEMPLATE must be "XXXXXX"; + they are replaced with a string that makes the directory name unique. + Returns TEMPLATE, or a null pointer if it cannot get a unique name. + The directory is created mode 700. */ +# if !@HAVE_MKDTEMP@ +_GL_FUNCDECL_SYS (mkdtemp, char *, (char * /*template*/) _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (mkdtemp, char *, (char * /*template*/)); +_GL_CXXALIASWARN (mkdtemp); +#elif defined GNULIB_POSIXCHECK +# undef mkdtemp +# if HAVE_RAW_DECL_MKDTEMP +_GL_WARN_ON_USE (mkdtemp, "mkdtemp is unportable - " + "use gnulib module mkdtemp for portability"); +# endif +#endif + +#if @GNULIB_MKOSTEMP@ +/* Create a unique temporary file from TEMPLATE. + The last six characters of TEMPLATE must be "XXXXXX"; + they are replaced with a string that makes the file name unique. + The flags are a bitmask, possibly including O_CLOEXEC (defined in ) + and O_TEXT, O_BINARY (defined in "binary-io.h"). + The file is then created, with the specified flags, ensuring it didn't exist + before. + The file is created read-write (mask at least 0600 & ~umask), but it may be + world-readable and world-writable (mask 0666 & ~umask), depending on the + implementation. + Returns the open file descriptor if successful, otherwise -1 and errno + set. */ +# if @REPLACE_MKOSTEMP@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef mkostemp +# define mkostemp rpl_mkostemp +# endif +_GL_FUNCDECL_RPL (mkostemp, int, (char * /*template*/, int /*flags*/) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (mkostemp, int, (char * /*template*/, int /*flags*/)); +# else +# if !@HAVE_MKOSTEMP@ +_GL_FUNCDECL_SYS (mkostemp, int, (char * /*template*/, int /*flags*/) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (mkostemp, int, (char * /*template*/, int /*flags*/)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (mkostemp); +# endif +#elif defined GNULIB_POSIXCHECK +# undef mkostemp +# if HAVE_RAW_DECL_MKOSTEMP +_GL_WARN_ON_USE (mkostemp, "mkostemp is unportable - " + "use gnulib module mkostemp for portability"); +# endif +#endif + +#if @GNULIB_MKOSTEMPS@ +/* Create a unique temporary file from TEMPLATE. + The last six characters of TEMPLATE before a suffix of length + SUFFIXLEN must be "XXXXXX"; + they are replaced with a string that makes the file name unique. + The flags are a bitmask, possibly including O_CLOEXEC (defined in ) + and O_TEXT, O_BINARY (defined in "binary-io.h"). + The file is then created, with the specified flags, ensuring it didn't exist + before. + The file is created read-write (mask at least 0600 & ~umask), but it may be + world-readable and world-writable (mask 0666 & ~umask), depending on the + implementation. + Returns the open file descriptor if successful, otherwise -1 and errno + set. */ +# if @REPLACE_MKOSTEMPS@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef mkostemps +# define mkostemps rpl_mkostemps +# endif +_GL_FUNCDECL_RPL (mkostemps, int, + (char * /*template*/, int /*suffixlen*/, int /*flags*/) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (mkostemps, int, + (char * /*template*/, int /*suffixlen*/, int /*flags*/)); +# else +# if !@HAVE_MKOSTEMPS@ +_GL_FUNCDECL_SYS (mkostemps, int, + (char * /*template*/, int /*suffixlen*/, int /*flags*/) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (mkostemps, int, + (char * /*template*/, int /*suffixlen*/, int /*flags*/)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (mkostemps); +# endif +#elif defined GNULIB_POSIXCHECK +# undef mkostemps +# if HAVE_RAW_DECL_MKOSTEMPS +_GL_WARN_ON_USE (mkostemps, "mkostemps is unportable - " + "use gnulib module mkostemps for portability"); +# endif +#endif + +#if @GNULIB_MKSTEMP@ +/* Create a unique temporary file from TEMPLATE. + The last six characters of TEMPLATE must be "XXXXXX"; + they are replaced with a string that makes the file name unique. + The file is then created, ensuring it didn't exist before. + The file is created read-write (mask at least 0600 & ~umask), but it may be + world-readable and world-writable (mask 0666 & ~umask), depending on the + implementation. + Returns the open file descriptor if successful, otherwise -1 and errno + set. */ +# if @REPLACE_MKSTEMP@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define mkstemp rpl_mkstemp +# endif +_GL_FUNCDECL_RPL (mkstemp, int, (char * /*template*/) _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (mkstemp, int, (char * /*template*/)); +# else +# if ! @HAVE_MKSTEMP@ +_GL_FUNCDECL_SYS (mkstemp, int, (char * /*template*/) _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (mkstemp, int, (char * /*template*/)); +# endif +_GL_CXXALIASWARN (mkstemp); +#elif defined GNULIB_POSIXCHECK +# undef mkstemp +# if HAVE_RAW_DECL_MKSTEMP +_GL_WARN_ON_USE (mkstemp, "mkstemp is unportable - " + "use gnulib module mkstemp for portability"); +# endif +#endif + +#if @GNULIB_MKSTEMPS@ +/* Create a unique temporary file from TEMPLATE. + The last six characters of TEMPLATE prior to a suffix of length + SUFFIXLEN must be "XXXXXX"; + they are replaced with a string that makes the file name unique. + The file is then created, ensuring it didn't exist before. + The file is created read-write (mask at least 0600 & ~umask), but it may be + world-readable and world-writable (mask 0666 & ~umask), depending on the + implementation. + Returns the open file descriptor if successful, otherwise -1 and errno + set. */ +# if !@HAVE_MKSTEMPS@ +_GL_FUNCDECL_SYS (mkstemps, int, (char * /*template*/, int /*suffixlen*/) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (mkstemps, int, (char * /*template*/, int /*suffixlen*/)); +_GL_CXXALIASWARN (mkstemps); +#elif defined GNULIB_POSIXCHECK +# undef mkstemps +# if HAVE_RAW_DECL_MKSTEMPS +_GL_WARN_ON_USE (mkstemps, "mkstemps is unportable - " + "use gnulib module mkstemps for portability"); +# endif +#endif + +#if @GNULIB_MDA_MKTEMP@ +/* On native Windows, map 'mktemp' to '_mktemp', so that -loldnames is not + required. In C++ with GNULIB_NAMESPACE, avoid differences between + platforms by defining GNULIB_NAMESPACE::mktemp always. */ +# if defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef mktemp +# define mktemp _mktemp +# endif +_GL_CXXALIAS_MDA (mktemp, char *, (char * /*template*/)); +# else +_GL_CXXALIAS_SYS (mktemp, char *, (char * /*template*/)); +# endif +_GL_CXXALIASWARN (mktemp); +#endif + +/* Allocate memory with indefinite extent and specified alignment. */ +#if @GNULIB_POSIX_MEMALIGN@ +# if @REPLACE_POSIX_MEMALIGN@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef posix_memalign +# define posix_memalign rpl_posix_memalign +# endif +_GL_FUNCDECL_RPL (posix_memalign, int, + (void **memptr, size_t alignment, size_t size) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (posix_memalign, int, + (void **memptr, size_t alignment, size_t size)); +# else +# if @HAVE_POSIX_MEMALIGN@ +_GL_CXXALIAS_SYS (posix_memalign, int, + (void **memptr, size_t alignment, size_t size)); +# endif +# endif +# if __GLIBC__ >= 2 && @HAVE_POSIX_MEMALIGN@ +_GL_CXXALIASWARN (posix_memalign); +# endif +#elif defined GNULIB_POSIXCHECK +# undef posix_memalign +# if HAVE_RAW_DECL_POSIX_MEMALIGN +_GL_WARN_ON_USE (posix_memalign, "posix_memalign is not portable - " + "use gnulib module posix_memalign for portability"); +# endif +#endif + +#if @GNULIB_POSIX_OPENPT@ +/* Return an FD open to the master side of a pseudo-terminal. Flags should + include O_RDWR, and may also include O_NOCTTY. */ +# if @REPLACE_POSIX_OPENPT@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef posix_openpt +# define posix_openpt rpl_posix_openpt +# endif +_GL_FUNCDECL_RPL (posix_openpt, int, (int flags)); +_GL_CXXALIAS_RPL (posix_openpt, int, (int flags)); +# else +# if !@HAVE_POSIX_OPENPT@ +_GL_FUNCDECL_SYS (posix_openpt, int, (int flags)); +# endif +_GL_CXXALIAS_SYS (posix_openpt, int, (int flags)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (posix_openpt); +# endif +#elif defined GNULIB_POSIXCHECK +# undef posix_openpt +# if HAVE_RAW_DECL_POSIX_OPENPT +_GL_WARN_ON_USE (posix_openpt, "posix_openpt is not portable - " + "use gnulib module posix_openpt for portability"); +# endif +#endif + +#if @GNULIB_PTSNAME@ +/* Return the pathname of the pseudo-terminal slave associated with + the master FD is open on, or NULL on errors. */ +# if @REPLACE_PTSNAME@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef ptsname +# define ptsname rpl_ptsname +# endif +_GL_FUNCDECL_RPL (ptsname, char *, (int fd)); +_GL_CXXALIAS_RPL (ptsname, char *, (int fd)); +# else +# if !@HAVE_PTSNAME@ +_GL_FUNCDECL_SYS (ptsname, char *, (int fd)); +# endif +_GL_CXXALIAS_SYS (ptsname, char *, (int fd)); +# endif +_GL_CXXALIASWARN (ptsname); +#elif defined GNULIB_POSIXCHECK +# undef ptsname +# if HAVE_RAW_DECL_PTSNAME +_GL_WARN_ON_USE (ptsname, "ptsname is not portable - " + "use gnulib module ptsname for portability"); +# endif +#endif + +#if @GNULIB_PTSNAME_R@ +/* Set the pathname of the pseudo-terminal slave associated with + the master FD is open on and return 0, or set errno and return + non-zero on errors. */ +# if @REPLACE_PTSNAME_R@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef ptsname_r +# define ptsname_r rpl_ptsname_r +# endif +_GL_FUNCDECL_RPL (ptsname_r, int, (int fd, char *buf, size_t len)); +_GL_CXXALIAS_RPL (ptsname_r, int, (int fd, char *buf, size_t len)); +# else +# if !@HAVE_PTSNAME_R@ +_GL_FUNCDECL_SYS (ptsname_r, int, (int fd, char *buf, size_t len)); +# endif +_GL_CXXALIAS_SYS (ptsname_r, int, (int fd, char *buf, size_t len)); +# endif +# ifndef GNULIB_defined_ptsname_r +# define GNULIB_defined_ptsname_r (!@HAVE_PTSNAME_R@ || @REPLACE_PTSNAME_R@) +# endif +_GL_CXXALIASWARN (ptsname_r); +#elif defined GNULIB_POSIXCHECK +# undef ptsname_r +# if HAVE_RAW_DECL_PTSNAME_R +_GL_WARN_ON_USE (ptsname_r, "ptsname_r is not portable - " + "use gnulib module ptsname_r for portability"); +# endif +#endif + +#if @GNULIB_PUTENV@ +# if @REPLACE_PUTENV@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef putenv +# define putenv rpl_putenv +# endif +_GL_FUNCDECL_RPL (putenv, int, (char *string) _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (putenv, int, (char *string)); +# elif defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef putenv +# define putenv _putenv +# endif +_GL_CXXALIAS_MDA (putenv, int, (char *string)); +# elif defined __KLIBC__ +/* Need to cast, because on OS/2 kLIBC, the first parameter is + const char *string. */ +_GL_CXXALIAS_SYS_CAST (putenv, int, (char *string)); +# else +_GL_CXXALIAS_SYS (putenv, int, (char *string)); +# endif +_GL_CXXALIASWARN (putenv); +#elif @GNULIB_MDA_PUTENV@ +/* On native Windows, map 'putenv' to '_putenv', so that -loldnames is not + required. In C++ with GNULIB_NAMESPACE, avoid differences between + platforms by defining GNULIB_NAMESPACE::putenv always. */ +# if defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef putenv +# define putenv _putenv +# endif +/* Need to cast, because on mingw, the parameter is either + 'const char *string' or 'char *string'. */ +_GL_CXXALIAS_MDA_CAST (putenv, int, (char *string)); +# elif defined __KLIBC__ +/* Need to cast, because on OS/2 kLIBC, the first parameter is + const char *string. */ +_GL_CXXALIAS_SYS_CAST (putenv, int, (char *string)); +# else +_GL_CXXALIAS_SYS (putenv, int, (char *string)); +# endif +_GL_CXXALIASWARN (putenv); +#endif + +#if @GNULIB_QSORT_R@ +/* Sort an array of NMEMB elements, starting at address BASE, each element + occupying SIZE bytes, in ascending order according to the comparison + function COMPARE. */ +# ifdef __cplusplus +extern "C" { +# endif +# if !GNULIB_defined_qsort_r_fn_types +typedef int (*_gl_qsort_r_compar_fn) (void const *, void const *, void *); +# define GNULIB_defined_qsort_r_fn_types 1 +# endif +# ifdef __cplusplus +} +# endif +# if @REPLACE_QSORT_R@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef qsort_r +# define qsort_r rpl_qsort_r +# endif +_GL_FUNCDECL_RPL (qsort_r, void, (void *base, size_t nmemb, size_t size, + _gl_qsort_r_compar_fn compare, + void *arg) _GL_ARG_NONNULL ((1, 4))); +_GL_CXXALIAS_RPL (qsort_r, void, (void *base, size_t nmemb, size_t size, + _gl_qsort_r_compar_fn compare, + void *arg)); +# else +# if !@HAVE_QSORT_R@ +_GL_FUNCDECL_SYS (qsort_r, void, (void *base, size_t nmemb, size_t size, + _gl_qsort_r_compar_fn compare, + void *arg) _GL_ARG_NONNULL ((1, 4))); +# endif +_GL_CXXALIAS_SYS (qsort_r, void, (void *base, size_t nmemb, size_t size, + _gl_qsort_r_compar_fn compare, + void *arg)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (qsort_r); +# endif +#elif defined GNULIB_POSIXCHECK +# undef qsort_r +# if HAVE_RAW_DECL_QSORT_R +_GL_WARN_ON_USE (qsort_r, "qsort_r is not portable - " + "use gnulib module qsort_r for portability"); +# endif +#endif + + +#if @GNULIB_RAND@ || (@GNULIB_RANDOM_R@ && !@HAVE_RANDOM_R@) +# ifndef RAND_MAX +# define RAND_MAX 2147483647 +# endif +#endif + + +#if @GNULIB_RAND@ +# if @REPLACE_RAND@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef rand +# define rand rpl_rand +# endif +_GL_FUNCDECL_RPL (rand, int, (void)); +_GL_CXXALIAS_RPL (rand, int, (void)); +# else +_GL_CXXALIAS_SYS (rand, int, (void)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (rand); +# endif +#endif + + +#if @GNULIB_RANDOM@ +# if @REPLACE_RANDOM@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef random +# define random rpl_random +# endif +_GL_FUNCDECL_RPL (random, long, (void)); +_GL_CXXALIAS_RPL (random, long, (void)); +# else +# if !@HAVE_RANDOM@ +_GL_FUNCDECL_SYS (random, long, (void)); +# endif +/* Need to cast, because on Haiku, the return type is + int. */ +_GL_CXXALIAS_SYS_CAST (random, long, (void)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (random); +# endif +#elif defined GNULIB_POSIXCHECK +# undef random +# if HAVE_RAW_DECL_RANDOM +_GL_WARN_ON_USE (random, "random is unportable - " + "use gnulib module random for portability"); +# endif +#endif + +#if @GNULIB_RANDOM@ +# if @REPLACE_RANDOM@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef srandom +# define srandom rpl_srandom +# endif +_GL_FUNCDECL_RPL (srandom, void, (unsigned int seed)); +_GL_CXXALIAS_RPL (srandom, void, (unsigned int seed)); +# else +# if !@HAVE_RANDOM@ +_GL_FUNCDECL_SYS (srandom, void, (unsigned int seed)); +# endif +/* Need to cast, because on FreeBSD, the first parameter is + unsigned long seed. */ +_GL_CXXALIAS_SYS_CAST (srandom, void, (unsigned int seed)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (srandom); +# endif +#elif defined GNULIB_POSIXCHECK +# undef srandom +# if HAVE_RAW_DECL_SRANDOM +_GL_WARN_ON_USE (srandom, "srandom is unportable - " + "use gnulib module random for portability"); +# endif +#endif + +#if @GNULIB_RANDOM@ +# if @REPLACE_INITSTATE@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef initstate +# define initstate rpl_initstate +# endif +_GL_FUNCDECL_RPL (initstate, char *, + (unsigned int seed, char *buf, size_t buf_size) + _GL_ARG_NONNULL ((2))); +_GL_CXXALIAS_RPL (initstate, char *, + (unsigned int seed, char *buf, size_t buf_size)); +# else +# if !@HAVE_INITSTATE@ || !@HAVE_DECL_INITSTATE@ +_GL_FUNCDECL_SYS (initstate, char *, + (unsigned int seed, char *buf, size_t buf_size) + _GL_ARG_NONNULL ((2))); +# endif +/* Need to cast, because on FreeBSD, the first parameter is + unsigned long seed. */ +_GL_CXXALIAS_SYS_CAST (initstate, char *, + (unsigned int seed, char *buf, size_t buf_size)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (initstate); +# endif +#elif defined GNULIB_POSIXCHECK +# undef initstate +# if HAVE_RAW_DECL_INITSTATE +_GL_WARN_ON_USE (initstate, "initstate is unportable - " + "use gnulib module random for portability"); +# endif +#endif + +#if @GNULIB_RANDOM@ +# if @REPLACE_SETSTATE@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef setstate +# define setstate rpl_setstate +# endif +_GL_FUNCDECL_RPL (setstate, char *, (char *arg_state) _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (setstate, char *, (char *arg_state)); +# else +# if !@HAVE_SETSTATE@ || !@HAVE_DECL_SETSTATE@ +_GL_FUNCDECL_SYS (setstate, char *, (char *arg_state) _GL_ARG_NONNULL ((1))); +# endif +/* Need to cast, because on Mac OS X 10.13, HP-UX, Solaris the first parameter + is const char *arg_state. */ +_GL_CXXALIAS_SYS_CAST (setstate, char *, (char *arg_state)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (setstate); +# endif +#elif defined GNULIB_POSIXCHECK +# undef setstate +# if HAVE_RAW_DECL_SETSTATE +_GL_WARN_ON_USE (setstate, "setstate is unportable - " + "use gnulib module random for portability"); +# endif +#endif + + +#if @GNULIB_RANDOM_R@ +# if @REPLACE_RANDOM_R@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef random_r +# define random_r rpl_random_r +# endif +_GL_FUNCDECL_RPL (random_r, int, (struct random_data *buf, int32_t *result) + _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (random_r, int, (struct random_data *buf, int32_t *result)); +# else +# if !@HAVE_RANDOM_R@ +_GL_FUNCDECL_SYS (random_r, int, (struct random_data *buf, int32_t *result) + _GL_ARG_NONNULL ((1, 2))); +# endif +_GL_CXXALIAS_SYS (random_r, int, (struct random_data *buf, int32_t *result)); +# endif +_GL_CXXALIASWARN (random_r); +#elif defined GNULIB_POSIXCHECK +# undef random_r +# if HAVE_RAW_DECL_RANDOM_R +_GL_WARN_ON_USE (random_r, "random_r is unportable - " + "use gnulib module random_r for portability"); +# endif +#endif + +#if @GNULIB_RANDOM_R@ +# if @REPLACE_RANDOM_R@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef srandom_r +# define srandom_r rpl_srandom_r +# endif +_GL_FUNCDECL_RPL (srandom_r, int, + (unsigned int seed, struct random_data *rand_state) + _GL_ARG_NONNULL ((2))); +_GL_CXXALIAS_RPL (srandom_r, int, + (unsigned int seed, struct random_data *rand_state)); +# else +# if !@HAVE_RANDOM_R@ +_GL_FUNCDECL_SYS (srandom_r, int, + (unsigned int seed, struct random_data *rand_state) + _GL_ARG_NONNULL ((2))); +# endif +_GL_CXXALIAS_SYS (srandom_r, int, + (unsigned int seed, struct random_data *rand_state)); +# endif +_GL_CXXALIASWARN (srandom_r); +#elif defined GNULIB_POSIXCHECK +# undef srandom_r +# if HAVE_RAW_DECL_SRANDOM_R +_GL_WARN_ON_USE (srandom_r, "srandom_r is unportable - " + "use gnulib module random_r for portability"); +# endif +#endif + +#if @GNULIB_RANDOM_R@ +# if @REPLACE_RANDOM_R@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef initstate_r +# define initstate_r rpl_initstate_r +# endif +_GL_FUNCDECL_RPL (initstate_r, int, + (unsigned int seed, char *buf, size_t buf_size, + struct random_data *rand_state) + _GL_ARG_NONNULL ((2, 4))); +_GL_CXXALIAS_RPL (initstate_r, int, + (unsigned int seed, char *buf, size_t buf_size, + struct random_data *rand_state)); +# else +# if !@HAVE_RANDOM_R@ +_GL_FUNCDECL_SYS (initstate_r, int, + (unsigned int seed, char *buf, size_t buf_size, + struct random_data *rand_state) + _GL_ARG_NONNULL ((2, 4))); +# endif +/* Need to cast, because on Haiku, the third parameter is + unsigned long buf_size. */ +_GL_CXXALIAS_SYS_CAST (initstate_r, int, + (unsigned int seed, char *buf, size_t buf_size, + struct random_data *rand_state)); +# endif +_GL_CXXALIASWARN (initstate_r); +#elif defined GNULIB_POSIXCHECK +# undef initstate_r +# if HAVE_RAW_DECL_INITSTATE_R +_GL_WARN_ON_USE (initstate_r, "initstate_r is unportable - " + "use gnulib module random_r for portability"); +# endif +#endif + +#if @GNULIB_RANDOM_R@ +# if @REPLACE_RANDOM_R@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef setstate_r +# define setstate_r rpl_setstate_r +# endif +_GL_FUNCDECL_RPL (setstate_r, int, + (char *arg_state, struct random_data *rand_state) + _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (setstate_r, int, + (char *arg_state, struct random_data *rand_state)); +# else +# if !@HAVE_RANDOM_R@ +_GL_FUNCDECL_SYS (setstate_r, int, + (char *arg_state, struct random_data *rand_state) + _GL_ARG_NONNULL ((1, 2))); +# endif +/* Need to cast, because on Haiku, the first parameter is + void *arg_state. */ +_GL_CXXALIAS_SYS_CAST (setstate_r, int, + (char *arg_state, struct random_data *rand_state)); +# endif +_GL_CXXALIASWARN (setstate_r); +#elif defined GNULIB_POSIXCHECK +# undef setstate_r +# if HAVE_RAW_DECL_SETSTATE_R +_GL_WARN_ON_USE (setstate_r, "setstate_r is unportable - " + "use gnulib module random_r for portability"); +# endif +#endif + + +#if @GNULIB_REALLOC_POSIX@ +# if (@GNULIB_REALLOC_POSIX@ && @REPLACE_REALLOC_FOR_REALLOC_POSIX@) \ + || (@GNULIB_REALLOC_GNU@ && @REPLACE_REALLOC_FOR_REALLOC_GNU@) +# if !((defined __cplusplus && defined GNULIB_NAMESPACE) \ + || _GL_USE_STDLIB_ALLOC) +# undef realloc +# define realloc rpl_realloc +# endif +_GL_FUNCDECL_RPL (realloc, void *, (void *ptr, size_t size) + _GL_ATTRIBUTE_DEALLOC_FREE); +_GL_CXXALIAS_RPL (realloc, void *, (void *ptr, size_t size)); +# else +# if __GNUC__ >= 11 +/* For -Wmismatched-dealloc: Associate realloc with free or rpl_free. */ +# if __GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2 +_GL_FUNCDECL_SYS (realloc, void *, + (void *ptr, size_t size) + _GL_ATTRIBUTE_NOTHROW + _GL_ATTRIBUTE_DEALLOC_FREE); +# else +_GL_FUNCDECL_SYS (realloc, void *, + (void *ptr, size_t size) + _GL_ATTRIBUTE_DEALLOC_FREE); +# endif +# endif +_GL_CXXALIAS_SYS (realloc, void *, (void *ptr, size_t size)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (realloc); +# endif +#else +# if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined realloc +/* For -Wmismatched-dealloc: Associate realloc with free or rpl_free. */ +# if __GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2 +_GL_FUNCDECL_SYS (realloc, void *, + (void *ptr, size_t size) + _GL_ATTRIBUTE_NOTHROW + _GL_ATTRIBUTE_DEALLOC_FREE); +# else +_GL_FUNCDECL_SYS (realloc, void *, + (void *ptr, size_t size) + _GL_ATTRIBUTE_DEALLOC_FREE); +# endif +# endif +# if defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC +# undef realloc +/* Assume realloc is always declared. */ +_GL_WARN_ON_USE (realloc, "realloc is not POSIX compliant everywhere - " + "use gnulib module realloc-posix for portability"); +# endif +#endif + + +#if @GNULIB_REALLOCARRAY@ +# if @REPLACE_REALLOCARRAY@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef reallocarray +# define reallocarray rpl_reallocarray +# endif +_GL_FUNCDECL_RPL (reallocarray, void *, + (void *ptr, size_t nmemb, size_t size)); +_GL_CXXALIAS_RPL (reallocarray, void *, + (void *ptr, size_t nmemb, size_t size)); +# else +# if ! @HAVE_REALLOCARRAY@ +_GL_FUNCDECL_SYS (reallocarray, void *, + (void *ptr, size_t nmemb, size_t size)); +# endif +_GL_CXXALIAS_SYS (reallocarray, void *, + (void *ptr, size_t nmemb, size_t size)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (reallocarray); +# endif +#elif defined GNULIB_POSIXCHECK +# undef reallocarray +# if HAVE_RAW_DECL_REALLOCARRAY +_GL_WARN_ON_USE (reallocarray, "reallocarray is not portable - " + "use gnulib module reallocarray for portability"); +# endif +#endif + +#if @GNULIB_REALPATH@ +# if @REPLACE_REALPATH@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define realpath rpl_realpath +# endif +_GL_FUNCDECL_RPL (realpath, char *, + (const char *restrict name, char *restrict resolved) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (realpath, char *, + (const char *restrict name, char *restrict resolved)); +# else +# if !@HAVE_REALPATH@ +_GL_FUNCDECL_SYS (realpath, char *, + (const char *restrict name, char *restrict resolved) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (realpath, char *, + (const char *restrict name, char *restrict resolved)); +# endif +_GL_CXXALIASWARN (realpath); +#elif defined GNULIB_POSIXCHECK +# undef realpath +# if HAVE_RAW_DECL_REALPATH +_GL_WARN_ON_USE (realpath, "realpath is unportable - use gnulib module " + "canonicalize or canonicalize-lgpl for portability"); +# endif +#endif + +#if @GNULIB_RPMATCH@ +/* Test a user response to a question. + Return 1 if it is affirmative, 0 if it is negative, or -1 if not clear. */ +# if !@HAVE_RPMATCH@ +_GL_FUNCDECL_SYS (rpmatch, int, (const char *response) _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (rpmatch, int, (const char *response)); +_GL_CXXALIASWARN (rpmatch); +#elif defined GNULIB_POSIXCHECK +# undef rpmatch +# if HAVE_RAW_DECL_RPMATCH +_GL_WARN_ON_USE (rpmatch, "rpmatch is unportable - " + "use gnulib module rpmatch for portability"); +# endif +#endif + +#if @GNULIB_SECURE_GETENV@ +/* Look up NAME in the environment, returning 0 in insecure situations. */ +# if !@HAVE_SECURE_GETENV@ +_GL_FUNCDECL_SYS (secure_getenv, char *, + (char const *name) _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (secure_getenv, char *, (char const *name)); +_GL_CXXALIASWARN (secure_getenv); +#elif defined GNULIB_POSIXCHECK +# undef secure_getenv +# if HAVE_RAW_DECL_SECURE_GETENV +_GL_WARN_ON_USE (secure_getenv, "secure_getenv is unportable - " + "use gnulib module secure_getenv for portability"); +# endif +#endif + +#if @GNULIB_SETENV@ +/* Set NAME to VALUE in the environment. + If REPLACE is nonzero, overwrite an existing value. */ +# if @REPLACE_SETENV@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef setenv +# define setenv rpl_setenv +# endif +_GL_FUNCDECL_RPL (setenv, int, + (const char *name, const char *value, int replace) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (setenv, int, + (const char *name, const char *value, int replace)); +# else +# if !@HAVE_DECL_SETENV@ +_GL_FUNCDECL_SYS (setenv, int, + (const char *name, const char *value, int replace) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (setenv, int, + (const char *name, const char *value, int replace)); +# endif +# if !(@REPLACE_SETENV@ && !@HAVE_DECL_SETENV@) +_GL_CXXALIASWARN (setenv); +# endif +#elif defined GNULIB_POSIXCHECK +# undef setenv +# if HAVE_RAW_DECL_SETENV +_GL_WARN_ON_USE (setenv, "setenv is unportable - " + "use gnulib module setenv for portability"); +# endif +#endif + +#if @GNULIB_STRTOD@ + /* Parse a double from STRING, updating ENDP if appropriate. */ +# if @REPLACE_STRTOD@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define strtod rpl_strtod +# endif +# define GNULIB_defined_strtod_function 1 +_GL_FUNCDECL_RPL (strtod, double, + (const char *restrict str, char **restrict endp) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (strtod, double, + (const char *restrict str, char **restrict endp)); +# else +# if !@HAVE_STRTOD@ +_GL_FUNCDECL_SYS (strtod, double, + (const char *restrict str, char **restrict endp) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (strtod, double, + (const char *restrict str, char **restrict endp)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (strtod); +# endif +#elif defined GNULIB_POSIXCHECK +# undef strtod +# if HAVE_RAW_DECL_STRTOD +_GL_WARN_ON_USE (strtod, "strtod is unportable - " + "use gnulib module strtod for portability"); +# endif +#endif + +#if @GNULIB_STRTOLD@ + /* Parse a 'long double' from STRING, updating ENDP if appropriate. */ +# if @REPLACE_STRTOLD@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define strtold rpl_strtold +# endif +# define GNULIB_defined_strtold_function 1 +_GL_FUNCDECL_RPL (strtold, long double, + (const char *restrict str, char **restrict endp) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (strtold, long double, + (const char *restrict str, char **restrict endp)); +# else +# if !@HAVE_STRTOLD@ +_GL_FUNCDECL_SYS (strtold, long double, + (const char *restrict str, char **restrict endp) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (strtold, long double, + (const char *restrict str, char **restrict endp)); +# endif +_GL_CXXALIASWARN (strtold); +#elif defined GNULIB_POSIXCHECK +# undef strtold +# if HAVE_RAW_DECL_STRTOLD +_GL_WARN_ON_USE (strtold, "strtold is unportable - " + "use gnulib module strtold for portability"); +# endif +#endif + +#if @GNULIB_STRTOL@ +/* Parse a signed integer whose textual representation starts at STRING. + The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0, + it may be decimal or octal (with prefix "0") or hexadecimal (with prefix + "0x"). + If ENDPTR is not NULL, the address of the first byte after the integer is + stored in *ENDPTR. + Upon overflow, the return value is LONG_MAX or LONG_MIN, and errno is set + to ERANGE. */ +# if @REPLACE_STRTOL@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define strtol rpl_strtol +# endif +# define GNULIB_defined_strtol_function 1 +_GL_FUNCDECL_RPL (strtol, long, + (const char *restrict string, char **restrict endptr, + int base) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (strtol, long, + (const char *restrict string, char **restrict endptr, + int base)); +# else +# if !@HAVE_STRTOL@ +_GL_FUNCDECL_SYS (strtol, long, + (const char *restrict string, char **restrict endptr, + int base) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (strtol, long, + (const char *restrict string, char **restrict endptr, + int base)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (strtol); +# endif +#elif defined GNULIB_POSIXCHECK +# undef strtol +# if HAVE_RAW_DECL_STRTOL +_GL_WARN_ON_USE (strtol, "strtol is unportable - " + "use gnulib module strtol for portability"); +# endif +#endif + +#if @GNULIB_STRTOLL@ +/* Parse a signed integer whose textual representation starts at STRING. + The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0, + it may be decimal or octal (with prefix "0") or hexadecimal (with prefix + "0x"). + If ENDPTR is not NULL, the address of the first byte after the integer is + stored in *ENDPTR. + Upon overflow, the return value is LLONG_MAX or LLONG_MIN, and errno is set + to ERANGE. */ +# if @REPLACE_STRTOLL@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define strtoll rpl_strtoll +# endif +# define GNULIB_defined_strtoll_function 1 +_GL_FUNCDECL_RPL (strtoll, long long, + (const char *restrict string, char **restrict endptr, + int base) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (strtoll, long long, + (const char *restrict string, char **restrict endptr, + int base)); +# else +# if !@HAVE_STRTOLL@ +_GL_FUNCDECL_SYS (strtoll, long long, + (const char *restrict string, char **restrict endptr, + int base) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (strtoll, long long, + (const char *restrict string, char **restrict endptr, + int base)); +# endif +_GL_CXXALIASWARN (strtoll); +#elif defined GNULIB_POSIXCHECK +# undef strtoll +# if HAVE_RAW_DECL_STRTOLL +_GL_WARN_ON_USE (strtoll, "strtoll is unportable - " + "use gnulib module strtoll for portability"); +# endif +#endif + +#if @GNULIB_STRTOUL@ +/* Parse an unsigned integer whose textual representation starts at STRING. + The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0, + it may be decimal or octal (with prefix "0") or hexadecimal (with prefix + "0x"). + If ENDPTR is not NULL, the address of the first byte after the integer is + stored in *ENDPTR. + Upon overflow, the return value is ULONG_MAX, and errno is set to ERANGE. */ +# if @REPLACE_STRTOUL@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define strtoul rpl_strtoul +# endif +# define GNULIB_defined_strtoul_function 1 +_GL_FUNCDECL_RPL (strtoul, unsigned long, + (const char *restrict string, char **restrict endptr, + int base) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (strtoul, unsigned long, + (const char *restrict string, char **restrict endptr, + int base)); +# else +# if !@HAVE_STRTOUL@ +_GL_FUNCDECL_SYS (strtoul, unsigned long, + (const char *restrict string, char **restrict endptr, + int base) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (strtoul, unsigned long, + (const char *restrict string, char **restrict endptr, + int base)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (strtoul); +# endif +#elif defined GNULIB_POSIXCHECK +# undef strtoul +# if HAVE_RAW_DECL_STRTOUL +_GL_WARN_ON_USE (strtoul, "strtoul is unportable - " + "use gnulib module strtoul for portability"); +# endif +#endif + +#if @GNULIB_STRTOULL@ +/* Parse an unsigned integer whose textual representation starts at STRING. + The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0, + it may be decimal or octal (with prefix "0") or hexadecimal (with prefix + "0x"). + If ENDPTR is not NULL, the address of the first byte after the integer is + stored in *ENDPTR. + Upon overflow, the return value is ULLONG_MAX, and errno is set to + ERANGE. */ +# if @REPLACE_STRTOULL@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define strtoull rpl_strtoull +# endif +# define GNULIB_defined_strtoull_function 1 +_GL_FUNCDECL_RPL (strtoull, unsigned long long, + (const char *restrict string, char **restrict endptr, + int base) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (strtoull, unsigned long long, + (const char *restrict string, char **restrict endptr, + int base)); +# else +# if !@HAVE_STRTOULL@ +_GL_FUNCDECL_SYS (strtoull, unsigned long long, + (const char *restrict string, char **restrict endptr, + int base) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (strtoull, unsigned long long, + (const char *restrict string, char **restrict endptr, + int base)); +# endif +_GL_CXXALIASWARN (strtoull); +#elif defined GNULIB_POSIXCHECK +# undef strtoull +# if HAVE_RAW_DECL_STRTOULL +_GL_WARN_ON_USE (strtoull, "strtoull is unportable - " + "use gnulib module strtoull for portability"); +# endif +#endif + +#if @GNULIB_UNLOCKPT@ +/* Unlock the slave side of the pseudo-terminal whose master side is specified + by FD, so that it can be opened. */ +# if !@HAVE_UNLOCKPT@ +_GL_FUNCDECL_SYS (unlockpt, int, (int fd)); +# endif +_GL_CXXALIAS_SYS (unlockpt, int, (int fd)); +_GL_CXXALIASWARN (unlockpt); +#elif defined GNULIB_POSIXCHECK +# undef unlockpt +# if HAVE_RAW_DECL_UNLOCKPT +_GL_WARN_ON_USE (unlockpt, "unlockpt is not portable - " + "use gnulib module unlockpt for portability"); +# endif +#endif + +#if @GNULIB_UNSETENV@ +/* Remove the variable NAME from the environment. */ +# if @REPLACE_UNSETENV@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef unsetenv +# define unsetenv rpl_unsetenv +# endif +_GL_FUNCDECL_RPL (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (unsetenv, int, (const char *name)); +# else +# if !@HAVE_DECL_UNSETENV@ +_GL_FUNCDECL_SYS (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (unsetenv, int, (const char *name)); +# endif +# if !(@REPLACE_UNSETENV@ && !@HAVE_DECL_UNSETENV@) +_GL_CXXALIASWARN (unsetenv); +# endif +#elif defined GNULIB_POSIXCHECK +# undef unsetenv +# if HAVE_RAW_DECL_UNSETENV +_GL_WARN_ON_USE (unsetenv, "unsetenv is unportable - " + "use gnulib module unsetenv for portability"); +# endif +#endif + +/* Convert a wide character to a multibyte character. */ +#if @GNULIB_WCTOMB@ +# if @REPLACE_WCTOMB@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef wctomb +# define wctomb rpl_wctomb +# endif +_GL_FUNCDECL_RPL (wctomb, int, (char *s, wchar_t wc)); +_GL_CXXALIAS_RPL (wctomb, int, (char *s, wchar_t wc)); +# else +_GL_CXXALIAS_SYS (wctomb, int, (char *s, wchar_t wc)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (wctomb); +# endif +#endif + + +#endif /* _@GUARD_PREFIX@_STDLIB_H */ +#endif /* _@GUARD_PREFIX@_STDLIB_H */ +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stdopen.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stdopen.c new file mode 100644 index 00000000..b3f69f02 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stdopen.c @@ -0,0 +1,66 @@ +/* stdopen.c - ensure that the three standard file descriptors are in use + + Copyright (C) 2005-2006, 2019-2024 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 . */ + +/* Written by Paul Eggert and Jim Meyering. */ + +#include + +#include "stdopen.h" + +#include +#include +#include +#include + +/* Try to ensure that all of the standard file numbers (0, 1, 2) + are in use. Without this, each application would have to guard + every call to open, dup, fopen, etc. with tests to ensure they + don't use one of the special file numbers when opening a file. + Return zero if successful, an errno value if at least one of + the file descriptors is initially closed and could not be opened. */ + +int +stdopen (void) +{ + int fd; + for (fd = STDIN_FILENO; fd <= STDERR_FILENO; fd++) + { + if (fcntl (fd, F_GETFD) < 0) + { + /* Open /dev/null with the contrary mode so that the typical + read (stdin) or write (stdout, stderr) operation will fail. + With descriptor 0, we can do even better on systems that + have /dev/full, by opening that write-only instead of + /dev/null. The only drawback is that a write-provoked + failure comes with a misleading errno value, ENOSPC. */ + int mode = fd == STDIN_FILENO ? O_WRONLY : O_RDONLY; + int full_fd = fd == STDIN_FILENO ? open ("/dev/full", mode) : -1; + int new_fd = full_fd < 0 ? open ("/dev/null", mode) : full_fd; + if (new_fd < 0) + return errno; + if (STDERR_FILENO < new_fd) + { + /* 0, 1, and 2 are already open somehow. + Our is not to reason why. */ + close (new_fd); + return 0; + } + } + } + + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stdopen.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stdopen.h new file mode 100644 index 00000000..96ac3017 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stdopen.h @@ -0,0 +1,32 @@ +/* Arrange for stdin/stdout/stderr to be open. + Copyright (C) 2005-2024 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 . */ + +/* Written by Jim Meyering, 2005. */ + +#ifndef STDOPEN_H +# define STDOPEN_H 1 + +# ifdef __cplusplus +extern "C" { +# endif + +int stdopen (void); + +# ifdef __cplusplus +} +# endif + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stpcpy.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stpcpy.c new file mode 100644 index 00000000..d4510054 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stpcpy.c @@ -0,0 +1,49 @@ +/* stpcpy.c -- copy a string and return pointer to end of new string + Copyright (C) 1992, 1995, 1997-1998, 2006, 2009-2024 Free Software + Foundation, Inc. + + NOTE: The canonical source of this file is maintained with the GNU C Library. + Bugs can be reported to bug-glibc@prep.ai.mit.edu. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +#include + +#undef __stpcpy +#ifdef _LIBC +# undef stpcpy +#endif + +#ifndef weak_alias +# define __stpcpy stpcpy +#endif + +/* Copy SRC to DEST, returning the address of the terminating '\0' in DEST. */ +char * +__stpcpy (char *dest, const char *src) +{ + register char *d = dest; + register const char *s = src; + + do + *d++ = *s; + while (*s++ != '\0'); + + return d - 1; +} +#ifdef weak_alias +weak_alias (__stpcpy, stpcpy) +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strcasecmp.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strcasecmp.c new file mode 100644 index 00000000..7939b404 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strcasecmp.c @@ -0,0 +1,60 @@ +/* Case-insensitive string comparison function. + Copyright (C) 1998-1999, 2005-2007, 2009-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +#include +#include + +/* Compare strings S1 and S2, ignoring case, returning less than, equal to or + greater than zero if S1 is lexicographically less than, equal to or greater + than S2. + Note: This function does not work with multibyte strings! */ + +int +strcasecmp (const char *s1, const char *s2) +{ + const unsigned char *p1 = (const unsigned char *) s1; + const unsigned char *p2 = (const unsigned char *) s2; + unsigned char c1, c2; + + if (p1 == p2) + return 0; + + do + { + c1 = tolower (*p1); + c2 = tolower (*p2); + + if (c1 == '\0') + break; + + ++p1; + ++p2; + } + while (c1 == c2); + + if (UCHAR_MAX <= INT_MAX) + return c1 - c2; + else + /* On machines where 'char' and 'int' are types of the same size, the + difference of two 'unsigned char' values - including the sign bit - + doesn't fit in an 'int'. */ + return _GL_CMP (c1, c2); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strdup.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strdup.c new file mode 100644 index 00000000..8d9e7c57 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strdup.c @@ -0,0 +1,54 @@ +/* Copyright (C) 1991, 1996-1998, 2002-2004, 2006-2007, 2009-2024 Free Software + Foundation, Inc. + + This file is part of the GNU C Library. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef _LIBC +# include +#endif + +/* Get specification. */ +#include + +#include + +#undef __strdup +#ifdef _LIBC +# undef strdup +#endif + +#ifndef weak_alias +# define __strdup strdup +#endif + +/* Duplicate S, returning an identical malloc'd string. */ +char * +__strdup (const char *s) +{ + size_t len = strlen (s) + 1; + void *new = malloc (len); + + if (new == NULL) + return NULL; + + return (char *) memcpy (new, s, len); +} +#ifdef libc_hidden_def +libc_hidden_def (__strdup) +#endif +#ifdef weak_alias +weak_alias (__strdup, strdup) +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/streq.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/streq.h new file mode 100644 index 00000000..12343463 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/streq.h @@ -0,0 +1,176 @@ +/* Optimized string comparison. + Copyright (C) 2001-2002, 2007, 2009-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible . */ + +#ifndef _GL_STREQ_H +#define _GL_STREQ_H + +#include + +/* STREQ_OPT allows to optimize string comparison with a small literal string. + STREQ_OPT (s, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0) + is semantically equivalent to + strcmp (s, "EUC-KR") == 0 + just faster. */ + +/* Help GCC to generate good code for string comparisons with + immediate strings. */ +#if (defined __GNUC__ || defined __clang__) && defined __OPTIMIZE__ + +static inline int +streq9 (const char *s1, const char *s2) +{ + return strcmp (s1 + 9, s2 + 9) == 0; +} + +static inline int +streq8 (const char *s1, const char *s2, char s28) +{ + if (s1[8] == s28) + { + if (s28 == 0) + return 1; + else + return streq9 (s1, s2); + } + else + return 0; +} + +static inline int +streq7 (const char *s1, const char *s2, char s27, char s28) +{ + if (s1[7] == s27) + { + if (s27 == 0) + return 1; + else + return streq8 (s1, s2, s28); + } + else + return 0; +} + +static inline int +streq6 (const char *s1, const char *s2, char s26, char s27, char s28) +{ + if (s1[6] == s26) + { + if (s26 == 0) + return 1; + else + return streq7 (s1, s2, s27, s28); + } + else + return 0; +} + +static inline int +streq5 (const char *s1, const char *s2, char s25, char s26, char s27, char s28) +{ + if (s1[5] == s25) + { + if (s25 == 0) + return 1; + else + return streq6 (s1, s2, s26, s27, s28); + } + else + return 0; +} + +static inline int +streq4 (const char *s1, const char *s2, char s24, char s25, char s26, char s27, char s28) +{ + if (s1[4] == s24) + { + if (s24 == 0) + return 1; + else + return streq5 (s1, s2, s25, s26, s27, s28); + } + else + return 0; +} + +static inline int +streq3 (const char *s1, const char *s2, char s23, char s24, char s25, char s26, char s27, char s28) +{ + if (s1[3] == s23) + { + if (s23 == 0) + return 1; + else + return streq4 (s1, s2, s24, s25, s26, s27, s28); + } + else + return 0; +} + +static inline int +streq2 (const char *s1, const char *s2, char s22, char s23, char s24, char s25, char s26, char s27, char s28) +{ + if (s1[2] == s22) + { + if (s22 == 0) + return 1; + else + return streq3 (s1, s2, s23, s24, s25, s26, s27, s28); + } + else + return 0; +} + +static inline int +streq1 (const char *s1, const char *s2, char s21, char s22, char s23, char s24, char s25, char s26, char s27, char s28) +{ + if (s1[1] == s21) + { + if (s21 == 0) + return 1; + else + return streq2 (s1, s2, s22, s23, s24, s25, s26, s27, s28); + } + else + return 0; +} + +static inline int +streq0 (const char *s1, const char *s2, char s20, char s21, char s22, char s23, char s24, char s25, char s26, char s27, char s28) +{ + if (s1[0] == s20) + { + if (s20 == 0) + return 1; + else + return streq1 (s1, s2, s21, s22, s23, s24, s25, s26, s27, s28); + } + else + return 0; +} + +#define STREQ_OPT(s1,s2,s20,s21,s22,s23,s24,s25,s26,s27,s28) \ + streq0 (s1, s2, s20, s21, s22, s23, s24, s25, s26, s27, s28) + +#else + +#define STREQ_OPT(s1,s2,s20,s21,s22,s23,s24,s25,s26,s27,s28) \ + (strcmp (s1, s2) == 0) + +#endif + +#endif /* _GL_STREQ_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strerror-override.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strerror-override.c new file mode 100644 index 00000000..b9c1c7ab --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strerror-override.c @@ -0,0 +1,306 @@ +/* strerror-override.c --- POSIX compatible system error routine + + Copyright (C) 2010-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 2010. */ + +#include + +#include "strerror-override.h" + +#include + +#if GNULIB_defined_EWINSOCK /* native Windows platforms */ +# if HAVE_WINSOCK2_H +# include +# endif +#endif + +#if !GNULIB_defined_strerror_override_macro + +/* If ERRNUM maps to an errno value defined by gnulib, return a string + describing the error. Otherwise return NULL. */ +const char * +strerror_override (int errnum) +{ + /* These error messages are taken from glibc/sysdeps/gnu/errlist.c. */ + switch (errnum) + { +# if REPLACE_STRERROR_0 + case 0: + return "Success"; +# endif + +# if GNULIB_defined_ESOCK /* native Windows platforms with older */ + case EINPROGRESS: + return "Operation now in progress"; + case EALREADY: + return "Operation already in progress"; + case ENOTSOCK: + return "Socket operation on non-socket"; + case EDESTADDRREQ: + return "Destination address required"; + case EMSGSIZE: + return "Message too long"; + case EPROTOTYPE: + return "Protocol wrong type for socket"; + case ENOPROTOOPT: + return "Protocol not available"; + case EPROTONOSUPPORT: + return "Protocol not supported"; + case EOPNOTSUPP: + return "Operation not supported"; + case EAFNOSUPPORT: + return "Address family not supported by protocol"; + case EADDRINUSE: + return "Address already in use"; + case EADDRNOTAVAIL: + return "Cannot assign requested address"; + case ENETDOWN: + return "Network is down"; + case ENETUNREACH: + return "Network is unreachable"; + case ECONNRESET: + return "Connection reset by peer"; + case ENOBUFS: + return "No buffer space available"; + case EISCONN: + return "Transport endpoint is already connected"; + case ENOTCONN: + return "Transport endpoint is not connected"; + case ETIMEDOUT: + return "Connection timed out"; + case ECONNREFUSED: + return "Connection refused"; + case ELOOP: + return "Too many levels of symbolic links"; + case EHOSTUNREACH: + return "No route to host"; + case EWOULDBLOCK: + return "Operation would block"; +# endif +# if GNULIB_defined_ESTREAMS /* native Windows platforms with older */ + case ETXTBSY: + return "Text file busy"; + case ENODATA: + return "No data available"; + case ENOSR: + return "Out of streams resources"; + case ENOSTR: + return "Device not a stream"; + case ETIME: + return "Timer expired"; + case EOTHER: + return "Other error"; +# endif +# if GNULIB_defined_EWINSOCK /* native Windows platforms */ + case ESOCKTNOSUPPORT: + return "Socket type not supported"; + case EPFNOSUPPORT: + return "Protocol family not supported"; + case ESHUTDOWN: + return "Cannot send after transport endpoint shutdown"; + case ETOOMANYREFS: + return "Too many references: cannot splice"; + case EHOSTDOWN: + return "Host is down"; + case EPROCLIM: + return "Too many processes"; + case EUSERS: + return "Too many users"; + case EDQUOT: + return "Disk quota exceeded"; + case ESTALE: + return "Stale NFS file handle"; + case EREMOTE: + return "Object is remote"; +# if HAVE_WINSOCK2_H + /* WSA_INVALID_HANDLE maps to EBADF */ + /* WSA_NOT_ENOUGH_MEMORY maps to ENOMEM */ + /* WSA_INVALID_PARAMETER maps to EINVAL */ + case WSA_OPERATION_ABORTED: + return "Overlapped operation aborted"; + case WSA_IO_INCOMPLETE: + return "Overlapped I/O event object not in signaled state"; + case WSA_IO_PENDING: + return "Overlapped operations will complete later"; + /* WSAEINTR maps to EINTR */ + /* WSAEBADF maps to EBADF */ + /* WSAEACCES maps to EACCES */ + /* WSAEFAULT maps to EFAULT */ + /* WSAEINVAL maps to EINVAL */ + /* WSAEMFILE maps to EMFILE */ + /* WSAEWOULDBLOCK maps to EWOULDBLOCK */ + /* WSAEINPROGRESS maps to EINPROGRESS */ + /* WSAEALREADY maps to EALREADY */ + /* WSAENOTSOCK maps to ENOTSOCK */ + /* WSAEDESTADDRREQ maps to EDESTADDRREQ */ + /* WSAEMSGSIZE maps to EMSGSIZE */ + /* WSAEPROTOTYPE maps to EPROTOTYPE */ + /* WSAENOPROTOOPT maps to ENOPROTOOPT */ + /* WSAEPROTONOSUPPORT maps to EPROTONOSUPPORT */ + /* WSAESOCKTNOSUPPORT is ESOCKTNOSUPPORT */ + /* WSAEOPNOTSUPP maps to EOPNOTSUPP */ + /* WSAEPFNOSUPPORT is EPFNOSUPPORT */ + /* WSAEAFNOSUPPORT maps to EAFNOSUPPORT */ + /* WSAEADDRINUSE maps to EADDRINUSE */ + /* WSAEADDRNOTAVAIL maps to EADDRNOTAVAIL */ + /* WSAENETDOWN maps to ENETDOWN */ + /* WSAENETUNREACH maps to ENETUNREACH */ + /* WSAENETRESET maps to ENETRESET */ + /* WSAECONNABORTED maps to ECONNABORTED */ + /* WSAECONNRESET maps to ECONNRESET */ + /* WSAENOBUFS maps to ENOBUFS */ + /* WSAEISCONN maps to EISCONN */ + /* WSAENOTCONN maps to ENOTCONN */ + /* WSAESHUTDOWN is ESHUTDOWN */ + /* WSAETOOMANYREFS is ETOOMANYREFS */ + /* WSAETIMEDOUT maps to ETIMEDOUT */ + /* WSAECONNREFUSED maps to ECONNREFUSED */ + /* WSAELOOP maps to ELOOP */ + /* WSAENAMETOOLONG maps to ENAMETOOLONG */ + /* WSAEHOSTDOWN is EHOSTDOWN */ + /* WSAEHOSTUNREACH maps to EHOSTUNREACH */ + /* WSAENOTEMPTY maps to ENOTEMPTY */ + /* WSAEPROCLIM is EPROCLIM */ + /* WSAEUSERS is EUSERS */ + /* WSAEDQUOT is EDQUOT */ + /* WSAESTALE is ESTALE */ + /* WSAEREMOTE is EREMOTE */ + case WSASYSNOTREADY: + return "Network subsystem is unavailable"; + case WSAVERNOTSUPPORTED: + return "Winsock.dll version out of range"; + case WSANOTINITIALISED: + return "Successful WSAStartup not yet performed"; + case WSAEDISCON: + return "Graceful shutdown in progress"; + case WSAENOMORE: case WSA_E_NO_MORE: + return "No more results"; + case WSAECANCELLED: case WSA_E_CANCELLED: + return "Call was canceled"; + case WSAEINVALIDPROCTABLE: + return "Procedure call table is invalid"; + case WSAEINVALIDPROVIDER: + return "Service provider is invalid"; + case WSAEPROVIDERFAILEDINIT: + return "Service provider failed to initialize"; + case WSASYSCALLFAILURE: + return "System call failure"; + case WSASERVICE_NOT_FOUND: + return "Service not found"; + case WSATYPE_NOT_FOUND: + return "Class type not found"; + case WSAEREFUSED: + return "Database query was refused"; + case WSAHOST_NOT_FOUND: + return "Host not found"; + case WSATRY_AGAIN: + return "Nonauthoritative host not found"; + case WSANO_RECOVERY: + return "Nonrecoverable error"; + case WSANO_DATA: + return "Valid name, no data record of requested type"; + /* WSA_QOS_* omitted */ +# endif +# endif + +# if GNULIB_defined_ENOMSG + case ENOMSG: + return "No message of desired type"; +# endif + +# if GNULIB_defined_EIDRM + case EIDRM: + return "Identifier removed"; +# endif + +# if GNULIB_defined_ENOLINK + case ENOLINK: + return "Link has been severed"; +# endif + +# if GNULIB_defined_EPROTO + case EPROTO: + return "Protocol error"; +# endif + +# if GNULIB_defined_EMULTIHOP + case EMULTIHOP: + return "Multihop attempted"; +# endif + +# if GNULIB_defined_EBADMSG + case EBADMSG: + return "Bad message"; +# endif + +# if GNULIB_defined_EOVERFLOW + case EOVERFLOW: + return "Value too large for defined data type"; +# endif + +# if GNULIB_defined_ENOTSUP + case ENOTSUP: + return "Not supported"; +# endif + +# if GNULIB_defined_ENETRESET + case ENETRESET: + return "Network dropped connection on reset"; +# endif + +# if GNULIB_defined_ECONNABORTED + case ECONNABORTED: + return "Software caused connection abort"; +# endif + +# if GNULIB_defined_ESTALE + case ESTALE: + return "Stale NFS file handle"; +# endif + +# if GNULIB_defined_EDQUOT + case EDQUOT: + return "Disk quota exceeded"; +# endif + +# if GNULIB_defined_ECANCELED + case ECANCELED: + return "Operation canceled"; +# endif + +# if GNULIB_defined_EOWNERDEAD + case EOWNERDEAD: + return "Owner died"; +# endif + +# if GNULIB_defined_ENOTRECOVERABLE + case ENOTRECOVERABLE: + return "State not recoverable"; +# endif + +# if GNULIB_defined_EILSEQ + case EILSEQ: + return "Invalid or incomplete multibyte or wide character"; +# endif + + default: + return NULL; + } +} + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strerror-override.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strerror-override.h new file mode 100644 index 00000000..872fa7d6 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strerror-override.h @@ -0,0 +1,62 @@ +/* strerror-override.h --- POSIX compatible system error routine + + Copyright (C) 2010-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef _GL_STRERROR_OVERRIDE_H +# define _GL_STRERROR_OVERRIDE_H + +/* This file uses _GL_ATTRIBUTE_CONST. */ +# if !_GL_CONFIG_H_INCLUDED +# error "Please include config.h first." +# endif + +# include +# include + +/* Reasonable buffer size that should never trigger ERANGE; if this + proves too small, we intentionally abort(), to remind us to fix + this value. */ +# define STACKBUF_LEN 256 + +/* If ERRNUM maps to an errno value defined by gnulib, return a string + describing the error. Otherwise return NULL. */ +# if REPLACE_STRERROR_0 \ + || GNULIB_defined_ESOCK \ + || GNULIB_defined_ESTREAMS \ + || GNULIB_defined_EWINSOCK \ + || GNULIB_defined_ENOMSG \ + || GNULIB_defined_EIDRM \ + || GNULIB_defined_ENOLINK \ + || GNULIB_defined_EPROTO \ + || GNULIB_defined_EMULTIHOP \ + || GNULIB_defined_EBADMSG \ + || GNULIB_defined_EOVERFLOW \ + || GNULIB_defined_ENOTSUP \ + || GNULIB_defined_ENETRESET \ + || GNULIB_defined_ECONNABORTED \ + || GNULIB_defined_ESTALE \ + || GNULIB_defined_EDQUOT \ + || GNULIB_defined_ECANCELED \ + || GNULIB_defined_EOWNERDEAD \ + || GNULIB_defined_ENOTRECOVERABLE \ + || GNULIB_defined_EILSEQ +extern const char *strerror_override (int errnum) _GL_ATTRIBUTE_CONST; +# else +# define strerror_override(ignored) NULL +# define GNULIB_defined_strerror_override_macro 1 +# endif + +#endif /* _GL_STRERROR_OVERRIDE_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strerror.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strerror.c new file mode 100644 index 00000000..6b760ff4 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strerror.c @@ -0,0 +1,70 @@ +/* strerror.c --- POSIX compatible system error routine + + Copyright (C) 2007-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +#include +#include +#include +#include + +#include "intprops.h" +#include "strerror-override.h" + +/* Use the system functions, not the gnulib overrides in this file. */ +#undef sprintf + +char * +strerror (int n) +#undef strerror +{ + static char buf[STACKBUF_LEN]; + size_t len; + + /* Cast away const, due to the historical signature of strerror; + callers should not be modifying the string. */ + const char *msg = strerror_override (n); + if (msg) + return (char *) msg; + + msg = strerror (n); + + /* Our strerror_r implementation might use the system's strerror + buffer, so all other clients of strerror have to see the error + copied into a buffer that we manage. This is not thread-safe, + even if the system strerror is, but portable programs shouldn't + be using strerror if they care about thread-safety. */ + if (!msg || !*msg) + { + static char const fmt[] = "Unknown error %d"; + static_assert (sizeof buf >= sizeof (fmt) + INT_STRLEN_BOUND (n)); + sprintf (buf, fmt, n); + errno = EINVAL; + return buf; + } + + /* Fix STACKBUF_LEN if this ever aborts. */ + len = strlen (msg); + if (sizeof buf <= len) + abort (); + + memcpy (buf, msg, len + 1); + return buf; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strftime.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strftime.h new file mode 100644 index 00000000..d6efdb84 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strftime.h @@ -0,0 +1,38 @@ +/* declarations for strftime.c + + Copyright (C) 2002, 2004, 2008-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Just like strftime, but with two more arguments: + POSIX requires that strftime use the local timezone information. + Use the timezone __TZ instead. Use __NS as the number of + nanoseconds in the %N directive. + + On error, set errno and return 0. Otherwise, return the number of + bytes generated (not counting the trailing NUL), preserving errno + if the number is 0. This errno behavior is in draft POSIX 202x + plus some requested changes to POSIX. */ +size_t nstrftime (char *restrict, size_t, char const *, struct tm const *, + timezone_t __tz, int __ns); + +#ifdef __cplusplus +} +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/string.in.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/string.in.h new file mode 100644 index 00000000..44ec2e7e --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/string.in.h @@ -0,0 +1,1460 @@ +/* A GNU-like . + + Copyright (C) 1995-1996, 2001-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +#endif +@PRAGMA_COLUMNS@ + +#if defined _GL_ALREADY_INCLUDING_STRING_H +/* Special invocation convention: + - On OS X/NetBSD we have a sequence of nested includes + -> -> "string.h" + In this situation system _chk variants due to -D_FORTIFY_SOURCE + might be used after any replacements defined here. */ + +#@INCLUDE_NEXT@ @NEXT_STRING_H@ + +#else +/* Normal invocation convention. */ + +#ifndef _@GUARD_PREFIX@_STRING_H + +#define _GL_ALREADY_INCLUDING_STRING_H + +/* The include_next requires a split double-inclusion guard. */ +#@INCLUDE_NEXT@ @NEXT_STRING_H@ + +#undef _GL_ALREADY_INCLUDING_STRING_H + +#ifndef _@GUARD_PREFIX@_STRING_H +#define _@GUARD_PREFIX@_STRING_H + +/* This file uses _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_MALLOC, + _GL_ATTRIBUTE_NOTHROW, _GL_ATTRIBUTE_PURE, GNULIB_POSIXCHECK, + HAVE_RAW_DECL_*. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +/* NetBSD 5.0 mis-defines NULL. */ +#include + +/* MirBSD defines mbslen as a macro. */ +#if @GNULIB_MBSLEN@ && defined __MirBSD__ +# include +#endif + +/* NetBSD 5.0 declares strsignal in , not in . */ +/* But in any case avoid namespace pollution on glibc systems. */ +#if (@GNULIB_STRSIGNAL@ || defined GNULIB_POSIXCHECK) && defined __NetBSD__ \ + && ! defined __GLIBC__ +# include +#endif + +/* AIX 7.2 and Android 13 declare ffsl and ffsll in , not in + . */ +/* But in any case avoid namespace pollution on glibc systems. */ +#if ((@GNULIB_FFSL@ || @GNULIB_FFSLL@ || defined GNULIB_POSIXCHECK) \ + && (defined _AIX || defined __ANDROID__)) \ + && ! defined __GLIBC__ +# include +#endif + +/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers + that can be freed by passing them as the Ith argument to the + function F. */ +#ifndef _GL_ATTRIBUTE_DEALLOC +# if __GNUC__ >= 11 +# define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i))) +# else +# define _GL_ATTRIBUTE_DEALLOC(f, i) +# endif +#endif + +/* _GL_ATTRIBUTE_DEALLOC_FREE declares that the function returns pointers that + can be freed via 'free'; it can be used only after declaring 'free'. */ +/* Applies to: functions. Cannot be used on inline functions. */ +#ifndef _GL_ATTRIBUTE_DEALLOC_FREE +# if defined __cplusplus && defined __GNUC__ && !defined __clang__ +/* Work around GCC bug */ +# define _GL_ATTRIBUTE_DEALLOC_FREE \ + _GL_ATTRIBUTE_DEALLOC ((void (*) (void *)) free, 1) +# else +# define _GL_ATTRIBUTE_DEALLOC_FREE \ + _GL_ATTRIBUTE_DEALLOC (free, 1) +# endif +#endif + +/* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly + allocated memory. */ +/* Applies to: functions. */ +#ifndef _GL_ATTRIBUTE_MALLOC +# if __GNUC__ >= 3 || defined __clang__ +# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__)) +# else +# define _GL_ATTRIBUTE_MALLOC +# endif +#endif + +/* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions. + */ +#ifndef _GL_ATTRIBUTE_NOTHROW +# if defined __cplusplus +# if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major >= 4 +# if __cplusplus >= 201103L +# define _GL_ATTRIBUTE_NOTHROW noexcept (true) +# else +# define _GL_ATTRIBUTE_NOTHROW throw () +# endif +# else +# define _GL_ATTRIBUTE_NOTHROW +# endif +# else +# if (__GNUC__ + (__GNUC_MINOR__ >= 3) > 3) || defined __clang__ +# define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__)) +# else +# define _GL_ATTRIBUTE_NOTHROW +# endif +# endif +#endif + +/* The __attribute__ feature is available in gcc versions 2.5 and later. + The attribute __pure__ was added in gcc 2.96. */ +#ifndef _GL_ATTRIBUTE_PURE +# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined __clang__ +# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) +# else +# define _GL_ATTRIBUTE_PURE /* empty */ +# endif +#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. */ + +/* Make _GL_ATTRIBUTE_DEALLOC_FREE work, even though may not have + been included yet. */ +#if @GNULIB_FREE_POSIX@ +# if (@REPLACE_FREE@ && !defined free \ + && !(defined __cplusplus && defined GNULIB_NAMESPACE)) +/* We can't do '#define free rpl_free' here. */ +# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2) +_GL_EXTERN_C void rpl_free (void *) _GL_ATTRIBUTE_NOTHROW; +# else +_GL_EXTERN_C void rpl_free (void *); +# endif +# undef _GL_ATTRIBUTE_DEALLOC_FREE +# define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (rpl_free, 1) +# else +# if defined _MSC_VER && !defined free +_GL_EXTERN_C +# if defined _DLL + __declspec (dllimport) +# endif + void __cdecl free (void *); +# else +# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2) +_GL_EXTERN_C void free (void *) _GL_ATTRIBUTE_NOTHROW; +# else +_GL_EXTERN_C void free (void *); +# endif +# endif +# endif +#else +# if defined _MSC_VER && !defined free +_GL_EXTERN_C +# if defined _DLL + __declspec (dllimport) +# endif + void __cdecl free (void *); +# else +# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2) +_GL_EXTERN_C void free (void *) _GL_ATTRIBUTE_NOTHROW; +# else +_GL_EXTERN_C void free (void *); +# endif +# endif +#endif + +/* Clear a block of memory. The compiler will not delete a call to + this function, even if the block is dead after the call. */ +#if @GNULIB_EXPLICIT_BZERO@ +# if ! @HAVE_EXPLICIT_BZERO@ +_GL_FUNCDECL_SYS (explicit_bzero, void, + (void *__dest, size_t __n) _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (explicit_bzero, void, (void *__dest, size_t __n)); +_GL_CXXALIASWARN (explicit_bzero); +#elif defined GNULIB_POSIXCHECK +# undef explicit_bzero +# if HAVE_RAW_DECL_EXPLICIT_BZERO +_GL_WARN_ON_USE (explicit_bzero, "explicit_bzero is unportable - " + "use gnulib module explicit_bzero for portability"); +# endif +#endif + +/* Find the index of the least-significant set bit. */ +#if @GNULIB_FFSL@ +# if !@HAVE_FFSL@ +_GL_FUNCDECL_SYS (ffsl, int, (long int i)); +# endif +_GL_CXXALIAS_SYS (ffsl, int, (long int i)); +_GL_CXXALIASWARN (ffsl); +#elif defined GNULIB_POSIXCHECK +# undef ffsl +# if HAVE_RAW_DECL_FFSL +_GL_WARN_ON_USE (ffsl, "ffsl is not portable - use the ffsl module"); +# endif +#endif + + +/* Find the index of the least-significant set bit. */ +#if @GNULIB_FFSLL@ +# if @REPLACE_FFSLL@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define ffsll rpl_ffsll +# endif +_GL_FUNCDECL_RPL (ffsll, int, (long long int i)); +_GL_CXXALIAS_RPL (ffsll, int, (long long int i)); +# else +# if !@HAVE_FFSLL@ +_GL_FUNCDECL_SYS (ffsll, int, (long long int i)); +# endif +_GL_CXXALIAS_SYS (ffsll, int, (long long int i)); +# endif +_GL_CXXALIASWARN (ffsll); +#elif defined GNULIB_POSIXCHECK +# undef ffsll +# if HAVE_RAW_DECL_FFSLL +_GL_WARN_ON_USE (ffsll, "ffsll is not portable - use the ffsll module"); +# endif +#endif + + +#if @GNULIB_MDA_MEMCCPY@ +/* On native Windows, map 'memccpy' to '_memccpy', so that -loldnames is not + required. In C++ with GNULIB_NAMESPACE, avoid differences between + platforms by defining GNULIB_NAMESPACE::memccpy always. */ +# if defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef memccpy +# define memccpy _memccpy +# endif +_GL_CXXALIAS_MDA (memccpy, void *, + (void *dest, const void *src, int c, size_t n)); +# else +_GL_CXXALIAS_SYS (memccpy, void *, + (void *dest, const void *src, int c, size_t n)); +# endif +_GL_CXXALIASWARN (memccpy); +#endif + + +/* Return the first instance of C within N bytes of S, or NULL. */ +#if @GNULIB_MEMCHR@ +# if @REPLACE_MEMCHR@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef memchr +# define memchr rpl_memchr +# endif +_GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n) + _GL_ATTRIBUTE_PURE + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (memchr, void *, (void const *__s, int __c, size_t __n)); +# else + /* On some systems, this function is defined as an overloaded function: + extern "C" { const void * std::memchr (const void *, int, size_t); } + extern "C++" { void * std::memchr (void *, int, size_t); } */ +_GL_CXXALIAS_SYS_CAST2 (memchr, + void *, (void const *__s, int __c, size_t __n), + void const *, (void const *__s, int __c, size_t __n)); +# endif +# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ + && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \ + || defined __clang__) +_GL_CXXALIASWARN1 (memchr, void *, + (void *__s, int __c, size_t __n) + _GL_ATTRIBUTE_NOTHROW); +_GL_CXXALIASWARN1 (memchr, void const *, + (void const *__s, int __c, size_t __n) + _GL_ATTRIBUTE_NOTHROW); +# elif __GLIBC__ >= 2 +_GL_CXXALIASWARN (memchr); +# endif +#elif defined GNULIB_POSIXCHECK +# undef memchr +/* Assume memchr is always declared. */ +_GL_WARN_ON_USE (memchr, "memchr has platform-specific bugs - " + "use gnulib module memchr for portability" ); +#endif + +/* Return the first occurrence of NEEDLE in HAYSTACK. */ +#if @GNULIB_MEMMEM@ +# if @REPLACE_MEMMEM@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define memmem rpl_memmem +# endif +_GL_FUNCDECL_RPL (memmem, void *, + (void const *__haystack, size_t __haystack_len, + void const *__needle, size_t __needle_len) + _GL_ATTRIBUTE_PURE + _GL_ARG_NONNULL ((1, 3))); +_GL_CXXALIAS_RPL (memmem, void *, + (void const *__haystack, size_t __haystack_len, + void const *__needle, size_t __needle_len)); +# else +# if ! @HAVE_DECL_MEMMEM@ +_GL_FUNCDECL_SYS (memmem, void *, + (void const *__haystack, size_t __haystack_len, + void const *__needle, size_t __needle_len) + _GL_ATTRIBUTE_PURE + _GL_ARG_NONNULL ((1, 3))); +# endif +_GL_CXXALIAS_SYS (memmem, void *, + (void const *__haystack, size_t __haystack_len, + void const *__needle, size_t __needle_len)); +# endif +_GL_CXXALIASWARN (memmem); +#elif defined GNULIB_POSIXCHECK +# undef memmem +# if HAVE_RAW_DECL_MEMMEM +_GL_WARN_ON_USE (memmem, "memmem is unportable and often quadratic - " + "use gnulib module memmem-simple for portability, " + "and module memmem for speed" ); +# endif +#endif + +/* Copy N bytes of SRC to DEST, return pointer to bytes after the + last written byte. */ +#if @GNULIB_MEMPCPY@ +# if @REPLACE_MEMPCPY@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef mempcpy +# define mempcpy rpl_mempcpy +# endif +_GL_FUNCDECL_RPL (mempcpy, void *, + (void *restrict __dest, void const *restrict __src, + size_t __n) + _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (mempcpy, void *, + (void *restrict __dest, void const *restrict __src, + size_t __n)); +# else +# if !@HAVE_MEMPCPY@ +_GL_FUNCDECL_SYS (mempcpy, void *, + (void *restrict __dest, void const *restrict __src, + size_t __n) + _GL_ARG_NONNULL ((1, 2))); +# endif +_GL_CXXALIAS_SYS (mempcpy, void *, + (void *restrict __dest, void const *restrict __src, + size_t __n)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (mempcpy); +# endif +#elif defined GNULIB_POSIXCHECK +# undef mempcpy +# if HAVE_RAW_DECL_MEMPCPY +_GL_WARN_ON_USE (mempcpy, "mempcpy is unportable - " + "use gnulib module mempcpy for portability"); +# endif +#endif + +/* Search backwards through a block for a byte (specified as an int). */ +#if @GNULIB_MEMRCHR@ +# if ! @HAVE_DECL_MEMRCHR@ +_GL_FUNCDECL_SYS (memrchr, void *, (void const *, int, size_t) + _GL_ATTRIBUTE_PURE + _GL_ARG_NONNULL ((1))); +# endif + /* On some systems, this function is defined as an overloaded function: + extern "C++" { const void * std::memrchr (const void *, int, size_t); } + extern "C++" { void * std::memrchr (void *, int, size_t); } */ +_GL_CXXALIAS_SYS_CAST2 (memrchr, + void *, (void const *, int, size_t), + void const *, (void const *, int, size_t)); +# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ + && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \ + || defined __clang__) +_GL_CXXALIASWARN1 (memrchr, void *, + (void *, int, size_t) + _GL_ATTRIBUTE_NOTHROW); +_GL_CXXALIASWARN1 (memrchr, void const *, + (void const *, int, size_t) + _GL_ATTRIBUTE_NOTHROW); +# elif __GLIBC__ >= 2 +_GL_CXXALIASWARN (memrchr); +# endif +#elif defined GNULIB_POSIXCHECK +# undef memrchr +# if HAVE_RAW_DECL_MEMRCHR +_GL_WARN_ON_USE (memrchr, "memrchr is unportable - " + "use gnulib module memrchr for portability"); +# endif +#endif + +/* Overwrite a block of memory. The compiler will not optimize + effects away, even if the block is dead after the call. */ +#if @GNULIB_MEMSET_EXPLICIT@ +# if @REPLACE_MEMSET_EXPLICIT@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef memset_explicit +# define memset_explicit rpl_memset_explicit +# endif +_GL_FUNCDECL_RPL (memset_explicit, void *, + (void *__dest, int __c, size_t __n) _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (memset_explicit, void *, (void *__dest, int __c, size_t __n)); +# else +# if !@HAVE_MEMSET_EXPLICIT@ +_GL_FUNCDECL_SYS (memset_explicit, void *, + (void *__dest, int __c, size_t __n) _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (memset_explicit, void *, (void *__dest, int __c, size_t __n)); +# endif +_GL_CXXALIASWARN (memset_explicit); +#elif defined GNULIB_POSIXCHECK +# undef memset_explicit +# if HAVE_RAW_DECL_MEMSET_EXPLICIT +_GL_WARN_ON_USE (memset_explicit, "memset_explicit is unportable - " + "use gnulib module memset_explicit for portability"); +# endif +#endif + +/* Find the first occurrence of C in S. More efficient than + memchr(S,C,N), at the expense of undefined behavior if C does not + occur within N bytes. */ +#if @GNULIB_RAWMEMCHR@ +# if ! @HAVE_RAWMEMCHR@ +_GL_FUNCDECL_SYS (rawmemchr, void *, (void const *__s, int __c_in) + _GL_ATTRIBUTE_PURE + _GL_ARG_NONNULL ((1))); +# endif + /* On some systems, this function is defined as an overloaded function: + extern "C++" { const void * std::rawmemchr (const void *, int); } + extern "C++" { void * std::rawmemchr (void *, int); } */ +_GL_CXXALIAS_SYS_CAST2 (rawmemchr, + void *, (void const *__s, int __c_in), + void const *, (void const *__s, int __c_in)); +# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ + && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \ + || defined __clang__) +_GL_CXXALIASWARN1 (rawmemchr, void *, + (void *__s, int __c_in) + _GL_ATTRIBUTE_NOTHROW); +_GL_CXXALIASWARN1 (rawmemchr, void const *, + (void const *__s, int __c_in) + _GL_ATTRIBUTE_NOTHROW); +# else +_GL_CXXALIASWARN (rawmemchr); +# endif +#elif defined GNULIB_POSIXCHECK +# undef rawmemchr +# if HAVE_RAW_DECL_RAWMEMCHR +_GL_WARN_ON_USE (rawmemchr, "rawmemchr is unportable - " + "use gnulib module rawmemchr for portability"); +# endif +#endif + +/* Copy SRC to DST, returning the address of the terminating '\0' in DST. */ +#if @GNULIB_STPCPY@ +# if @REPLACE_STPCPY@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef stpcpy +# define stpcpy rpl_stpcpy +# endif +_GL_FUNCDECL_RPL (stpcpy, char *, + (char *restrict __dst, char const *restrict __src) + _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (stpcpy, char *, + (char *restrict __dst, char const *restrict __src)); +# else +# if !@HAVE_STPCPY@ +_GL_FUNCDECL_SYS (stpcpy, char *, + (char *restrict __dst, char const *restrict __src) + _GL_ARG_NONNULL ((1, 2))); +# endif +_GL_CXXALIAS_SYS (stpcpy, char *, + (char *restrict __dst, char const *restrict __src)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (stpcpy); +# endif +#elif defined GNULIB_POSIXCHECK +# undef stpcpy +# if HAVE_RAW_DECL_STPCPY +_GL_WARN_ON_USE (stpcpy, "stpcpy is unportable - " + "use gnulib module stpcpy for portability"); +# endif +#endif + +/* Copy no more than N bytes of SRC to DST, returning a pointer past the + last non-NUL byte written into DST. */ +#if @GNULIB_STPNCPY@ +# if @REPLACE_STPNCPY@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef stpncpy +# define stpncpy rpl_stpncpy +# endif +_GL_FUNCDECL_RPL (stpncpy, char *, + (char *restrict __dst, char const *restrict __src, + size_t __n) + _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (stpncpy, char *, + (char *restrict __dst, char const *restrict __src, + size_t __n)); +# else +# if ! @HAVE_STPNCPY@ +_GL_FUNCDECL_SYS (stpncpy, char *, + (char *restrict __dst, char const *restrict __src, + size_t __n) + _GL_ARG_NONNULL ((1, 2))); +# endif +_GL_CXXALIAS_SYS (stpncpy, char *, + (char *restrict __dst, char const *restrict __src, + size_t __n)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (stpncpy); +# endif +#elif defined GNULIB_POSIXCHECK +# undef stpncpy +# if HAVE_RAW_DECL_STPNCPY +_GL_WARN_ON_USE (stpncpy, "stpncpy is unportable - " + "use gnulib module stpncpy for portability"); +# endif +#endif + +#if defined GNULIB_POSIXCHECK +/* strchr() does not work with multibyte strings if the locale encoding is + GB18030 and the character to be searched is a digit. */ +# undef strchr +/* Assume strchr is always declared. */ +_GL_WARN_ON_USE_CXX (strchr, + const char *, char *, (const char *, int), + "strchr cannot work correctly on character strings " + "in some multibyte locales - " + "use mbschr if you care about internationalization"); +#endif + +/* Find the first occurrence of C in S or the final NUL byte. */ +#if @GNULIB_STRCHRNUL@ +# if @REPLACE_STRCHRNUL@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define strchrnul rpl_strchrnul +# endif +_GL_FUNCDECL_RPL (strchrnul, char *, (const char *__s, int __c_in) + _GL_ATTRIBUTE_PURE + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (strchrnul, char *, + (const char *str, int ch)); +# else +# if ! @HAVE_STRCHRNUL@ +_GL_FUNCDECL_SYS (strchrnul, char *, (char const *__s, int __c_in) + _GL_ATTRIBUTE_PURE + _GL_ARG_NONNULL ((1))); +# endif + /* On some systems, this function is defined as an overloaded function: + extern "C++" { const char * std::strchrnul (const char *, int); } + extern "C++" { char * std::strchrnul (char *, int); } */ +_GL_CXXALIAS_SYS_CAST2 (strchrnul, + char *, (char const *__s, int __c_in), + char const *, (char const *__s, int __c_in)); +# endif +# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ + && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \ + || defined __clang__) +_GL_CXXALIASWARN1 (strchrnul, char *, + (char *__s, int __c_in) + _GL_ATTRIBUTE_NOTHROW); +_GL_CXXALIASWARN1 (strchrnul, char const *, + (char const *__s, int __c_in) + _GL_ATTRIBUTE_NOTHROW); +# elif __GLIBC__ >= 2 +_GL_CXXALIASWARN (strchrnul); +# endif +#elif defined GNULIB_POSIXCHECK +# undef strchrnul +# if HAVE_RAW_DECL_STRCHRNUL +_GL_WARN_ON_USE (strchrnul, "strchrnul is unportable - " + "use gnulib module strchrnul for portability"); +# endif +#endif + +/* Duplicate S, returning an identical malloc'd string. */ +#if @GNULIB_STRDUP@ +# if @REPLACE_STRDUP@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef strdup +# define strdup rpl_strdup +# endif +_GL_FUNCDECL_RPL (strdup, char *, + (char const *__s) + _GL_ARG_NONNULL ((1)) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +_GL_CXXALIAS_RPL (strdup, char *, (char const *__s)); +# elif defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef strdup +# define strdup _strdup +# endif +_GL_CXXALIAS_MDA (strdup, char *, (char const *__s)); +# else +# if defined __cplusplus && defined GNULIB_NAMESPACE && defined strdup + /* strdup exists as a function and as a macro. Get rid of the macro. */ +# undef strdup +# endif +# if (!@HAVE_DECL_STRDUP@ || __GNUC__ >= 11) && !defined strdup +# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 +_GL_FUNCDECL_SYS (strdup, char *, + (char const *__s) + _GL_ATTRIBUTE_NOTHROW + _GL_ARG_NONNULL ((1)) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# else +_GL_FUNCDECL_SYS (strdup, char *, + (char const *__s) + _GL_ARG_NONNULL ((1)) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# endif +# endif +_GL_CXXALIAS_SYS (strdup, char *, (char const *__s)); +# endif +_GL_CXXALIASWARN (strdup); +#else +# if __GNUC__ >= 11 && !defined strdup +/* For -Wmismatched-dealloc: Associate strdup with free or rpl_free. */ +# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 +_GL_FUNCDECL_SYS (strdup, char *, + (char const *__s) + _GL_ATTRIBUTE_NOTHROW + _GL_ARG_NONNULL ((1)) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# else +_GL_FUNCDECL_SYS (strdup, char *, + (char const *__s) + _GL_ARG_NONNULL ((1)) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# endif +# endif +# if defined GNULIB_POSIXCHECK +# undef strdup +# if HAVE_RAW_DECL_STRDUP +_GL_WARN_ON_USE (strdup, "strdup is unportable - " + "use gnulib module strdup for portability"); +# endif +# elif @GNULIB_MDA_STRDUP@ +/* On native Windows, map 'creat' to '_creat', so that -loldnames is not + required. In C++ with GNULIB_NAMESPACE, avoid differences between + platforms by defining GNULIB_NAMESPACE::strdup always. */ +# if defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef strdup +# define strdup _strdup +# endif +_GL_CXXALIAS_MDA (strdup, char *, (char const *__s)); +# else +# if defined __cplusplus && defined GNULIB_NAMESPACE && defined strdup +# undef strdup +# endif +_GL_CXXALIAS_SYS (strdup, char *, (char const *__s)); +# endif +_GL_CXXALIASWARN (strdup); +# endif +#endif + +/* Append no more than N characters from SRC onto DEST. */ +#if @GNULIB_STRNCAT@ +# if @REPLACE_STRNCAT@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef strncat +# define strncat rpl_strncat +# endif +_GL_FUNCDECL_RPL (strncat, char *, + (char *restrict dest, const char *restrict src, size_t n) + _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (strncat, char *, + (char *restrict dest, const char *restrict src, size_t n)); +# else +_GL_CXXALIAS_SYS (strncat, char *, + (char *restrict dest, const char *restrict src, size_t n)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (strncat); +# endif +#elif defined GNULIB_POSIXCHECK +# undef strncat +# if HAVE_RAW_DECL_STRNCAT +_GL_WARN_ON_USE (strncat, "strncat is unportable - " + "use gnulib module strncat for portability"); +# endif +#endif + +/* Return a newly allocated copy of at most N bytes of STRING. */ +#if @GNULIB_STRNDUP@ +# if @REPLACE_STRNDUP@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef strndup +# define strndup rpl_strndup +# endif +_GL_FUNCDECL_RPL (strndup, char *, + (char const *__s, size_t __n) + _GL_ARG_NONNULL ((1)) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +_GL_CXXALIAS_RPL (strndup, char *, (char const *__s, size_t __n)); +# else +# if !@HAVE_DECL_STRNDUP@ || (__GNUC__ >= 11 && !defined strndup) +# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 +_GL_FUNCDECL_SYS (strndup, char *, + (char const *__s, size_t __n) + _GL_ATTRIBUTE_NOTHROW + _GL_ARG_NONNULL ((1)) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# else +_GL_FUNCDECL_SYS (strndup, char *, + (char const *__s, size_t __n) + _GL_ARG_NONNULL ((1)) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# endif +# endif +_GL_CXXALIAS_SYS (strndup, char *, (char const *__s, size_t __n)); +# endif +_GL_CXXALIASWARN (strndup); +#else +# if __GNUC__ >= 11 && !defined strndup +/* For -Wmismatched-dealloc: Associate strndup with free or rpl_free. */ +# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 +_GL_FUNCDECL_SYS (strndup, char *, + (char const *__s, size_t __n) + _GL_ATTRIBUTE_NOTHROW + _GL_ARG_NONNULL ((1)) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# else +_GL_FUNCDECL_SYS (strndup, char *, + (char const *__s, size_t __n) + _GL_ARG_NONNULL ((1)) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# endif +# endif +# if defined GNULIB_POSIXCHECK +# undef strndup +# if HAVE_RAW_DECL_STRNDUP +_GL_WARN_ON_USE (strndup, "strndup is unportable - " + "use gnulib module strndup for portability"); +# endif +# endif +#endif + +/* Find the length (number of bytes) of STRING, but scan at most + MAXLEN bytes. If no '\0' terminator is found in that many bytes, + return MAXLEN. */ +#if @GNULIB_STRNLEN@ +# if @REPLACE_STRNLEN@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef strnlen +# define strnlen rpl_strnlen +# endif +_GL_FUNCDECL_RPL (strnlen, size_t, (char const *__s, size_t __maxlen) + _GL_ATTRIBUTE_PURE + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (strnlen, size_t, (char const *__s, size_t __maxlen)); +# else +# if ! @HAVE_DECL_STRNLEN@ +_GL_FUNCDECL_SYS (strnlen, size_t, (char const *__s, size_t __maxlen) + _GL_ATTRIBUTE_PURE + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (strnlen, size_t, (char const *__s, size_t __maxlen)); +# endif +_GL_CXXALIASWARN (strnlen); +#elif defined GNULIB_POSIXCHECK +# undef strnlen +# if HAVE_RAW_DECL_STRNLEN +_GL_WARN_ON_USE (strnlen, "strnlen is unportable - " + "use gnulib module strnlen for portability"); +# endif +#endif + +#if defined GNULIB_POSIXCHECK +/* strcspn() assumes the second argument is a list of single-byte characters. + Even in this simple case, it does not work with multibyte strings if the + locale encoding is GB18030 and one of the characters to be searched is a + digit. */ +# undef strcspn +/* Assume strcspn is always declared. */ +_GL_WARN_ON_USE (strcspn, "strcspn cannot work correctly on character strings " + "in multibyte locales - " + "use mbscspn if you care about internationalization"); +#endif + +/* Find the first occurrence in S of any character in ACCEPT. */ +#if @GNULIB_STRPBRK@ +# if ! @HAVE_STRPBRK@ +_GL_FUNCDECL_SYS (strpbrk, char *, (char const *__s, char const *__accept) + _GL_ATTRIBUTE_PURE + _GL_ARG_NONNULL ((1, 2))); +# endif + /* On some systems, this function is defined as an overloaded function: + extern "C" { const char * strpbrk (const char *, const char *); } + extern "C++" { char * strpbrk (char *, const char *); } */ +_GL_CXXALIAS_SYS_CAST2 (strpbrk, + char *, (char const *__s, char const *__accept), + const char *, (char const *__s, char const *__accept)); +# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ + && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \ + || defined __clang__) +_GL_CXXALIASWARN1 (strpbrk, char *, + (char *__s, char const *__accept) + _GL_ATTRIBUTE_NOTHROW); +_GL_CXXALIASWARN1 (strpbrk, char const *, + (char const *__s, char const *__accept) + _GL_ATTRIBUTE_NOTHROW); +# elif __GLIBC__ >= 2 +_GL_CXXALIASWARN (strpbrk); +# endif +# if defined GNULIB_POSIXCHECK +/* strpbrk() assumes the second argument is a list of single-byte characters. + Even in this simple case, it does not work with multibyte strings if the + locale encoding is GB18030 and one of the characters to be searched is a + digit. */ +# undef strpbrk +_GL_WARN_ON_USE_CXX (strpbrk, + const char *, char *, (const char *, const char *), + "strpbrk cannot work correctly on character strings " + "in multibyte locales - " + "use mbspbrk if you care about internationalization"); +# endif +#elif defined GNULIB_POSIXCHECK +# undef strpbrk +# if HAVE_RAW_DECL_STRPBRK +_GL_WARN_ON_USE_CXX (strpbrk, + const char *, char *, (const char *, const char *), + "strpbrk is unportable - " + "use gnulib module strpbrk for portability"); +# endif +#endif + +#if defined GNULIB_POSIXCHECK +/* strspn() assumes the second argument is a list of single-byte characters. + Even in this simple case, it cannot work with multibyte strings. */ +# undef strspn +/* Assume strspn is always declared. */ +_GL_WARN_ON_USE (strspn, "strspn cannot work correctly on character strings " + "in multibyte locales - " + "use mbsspn if you care about internationalization"); +#endif + +#if defined GNULIB_POSIXCHECK +/* strrchr() does not work with multibyte strings if the locale encoding is + GB18030 and the character to be searched is a digit. */ +# undef strrchr +/* Assume strrchr is always declared. */ +_GL_WARN_ON_USE_CXX (strrchr, + const char *, char *, (const char *, int), + "strrchr cannot work correctly on character strings " + "in some multibyte locales - " + "use mbsrchr if you care about internationalization"); +#endif + +/* Search the next delimiter (char listed in DELIM) starting at *STRINGP. + If one is found, overwrite it with a NUL, and advance *STRINGP + to point to the next char after it. Otherwise, set *STRINGP to NULL. + If *STRINGP was already NULL, nothing happens. + Return the old value of *STRINGP. + + This is a variant of strtok() that is multithread-safe and supports + empty fields. + + Caveat: It modifies the original string. + Caveat: These functions cannot be used on constant strings. + Caveat: The identity of the delimiting character is lost. + Caveat: It doesn't work with multibyte strings unless all of the delimiter + characters are ASCII characters < 0x30. + + See also strtok_r(). */ +#if @GNULIB_STRSEP@ +# if ! @HAVE_STRSEP@ +_GL_FUNCDECL_SYS (strsep, char *, + (char **restrict __stringp, char const *restrict __delim) + _GL_ARG_NONNULL ((1, 2))); +# endif +_GL_CXXALIAS_SYS (strsep, char *, + (char **restrict __stringp, char const *restrict __delim)); +_GL_CXXALIASWARN (strsep); +# if defined GNULIB_POSIXCHECK +# undef strsep +_GL_WARN_ON_USE (strsep, "strsep cannot work correctly on character strings " + "in multibyte locales - " + "use mbssep if you care about internationalization"); +# endif +#elif defined GNULIB_POSIXCHECK +# undef strsep +# if HAVE_RAW_DECL_STRSEP +_GL_WARN_ON_USE (strsep, "strsep is unportable - " + "use gnulib module strsep for portability"); +# endif +#endif + +#if @GNULIB_STRSTR@ +# if @REPLACE_STRSTR@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define strstr rpl_strstr +# endif +_GL_FUNCDECL_RPL (strstr, char *, (const char *haystack, const char *needle) + _GL_ATTRIBUTE_PURE + _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (strstr, char *, (const char *haystack, const char *needle)); +# else + /* On some systems, this function is defined as an overloaded function: + extern "C++" { const char * strstr (const char *, const char *); } + extern "C++" { char * strstr (char *, const char *); } */ +_GL_CXXALIAS_SYS_CAST2 (strstr, + char *, (const char *haystack, const char *needle), + const char *, (const char *haystack, const char *needle)); +# endif +# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ + && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \ + || defined __clang__) +_GL_CXXALIASWARN1 (strstr, char *, + (char *haystack, const char *needle) + _GL_ATTRIBUTE_NOTHROW); +_GL_CXXALIASWARN1 (strstr, const char *, + (const char *haystack, const char *needle) + _GL_ATTRIBUTE_NOTHROW); +# elif __GLIBC__ >= 2 +_GL_CXXALIASWARN (strstr); +# endif +#elif defined GNULIB_POSIXCHECK +/* strstr() does not work with multibyte strings if the locale encoding is + different from UTF-8: + POSIX says that it operates on "strings", and "string" in POSIX is defined + as a sequence of bytes, not of characters. */ +# undef strstr +/* Assume strstr is always declared. */ +_GL_WARN_ON_USE (strstr, "strstr is quadratic on many systems, and cannot " + "work correctly on character strings in most " + "multibyte locales - " + "use mbsstr if you care about internationalization, " + "or use strstr if you care about speed"); +#endif + +/* Find the first occurrence of NEEDLE in HAYSTACK, using case-insensitive + comparison. */ +#if @GNULIB_STRCASESTR@ +# if @REPLACE_STRCASESTR@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define strcasestr rpl_strcasestr +# endif +_GL_FUNCDECL_RPL (strcasestr, char *, + (const char *haystack, const char *needle) + _GL_ATTRIBUTE_PURE + _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (strcasestr, char *, + (const char *haystack, const char *needle)); +# else +# if ! @HAVE_STRCASESTR@ +_GL_FUNCDECL_SYS (strcasestr, char *, + (const char *haystack, const char *needle) + _GL_ATTRIBUTE_PURE + _GL_ARG_NONNULL ((1, 2))); +# endif + /* On some systems, this function is defined as an overloaded function: + extern "C++" { const char * strcasestr (const char *, const char *); } + extern "C++" { char * strcasestr (char *, const char *); } */ +_GL_CXXALIAS_SYS_CAST2 (strcasestr, + char *, (const char *haystack, const char *needle), + const char *, (const char *haystack, const char *needle)); +# endif +# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ + && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \ + || defined __clang__) +_GL_CXXALIASWARN1 (strcasestr, char *, + (char *haystack, const char *needle) + _GL_ATTRIBUTE_NOTHROW); +_GL_CXXALIASWARN1 (strcasestr, const char *, + (const char *haystack, const char *needle) + _GL_ATTRIBUTE_NOTHROW); +# elif __GLIBC__ >= 2 +_GL_CXXALIASWARN (strcasestr); +# endif +#elif defined GNULIB_POSIXCHECK +/* strcasestr() does not work with multibyte strings: + It is a glibc extension, and glibc implements it only for unibyte + locales. */ +# undef strcasestr +# if HAVE_RAW_DECL_STRCASESTR +_GL_WARN_ON_USE (strcasestr, "strcasestr does work correctly on character " + "strings in multibyte locales - " + "use mbscasestr if you care about " + "internationalization, or use c-strcasestr if you want " + "a locale independent function"); +# endif +#endif + +/* Parse S into tokens separated by characters in DELIM. + If S is NULL, the saved pointer in SAVE_PTR is used as + the next starting point. For example: + char s[] = "-abc-=-def"; + char *sp; + x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def" + x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL + x = strtok_r(NULL, "=", &sp); // x = NULL + // s = "abc\0-def\0" + + This is a variant of strtok() that is multithread-safe. + + For the POSIX documentation for this function, see: + https://pubs.opengroup.org/onlinepubs/9699919799/functions/strtok.html + + Caveat: It modifies the original string. + Caveat: These functions cannot be used on constant strings. + Caveat: The identity of the delimiting character is lost. + Caveat: It doesn't work with multibyte strings unless all of the delimiter + characters are ASCII characters < 0x30. + + See also strsep(). */ +#if @GNULIB_STRTOK_R@ +# if @REPLACE_STRTOK_R@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef strtok_r +# define strtok_r rpl_strtok_r +# endif +_GL_FUNCDECL_RPL (strtok_r, char *, + (char *restrict s, char const *restrict delim, + char **restrict save_ptr) + _GL_ARG_NONNULL ((2, 3))); +_GL_CXXALIAS_RPL (strtok_r, char *, + (char *restrict s, char const *restrict delim, + char **restrict save_ptr)); +# else +# if @UNDEFINE_STRTOK_R@ || defined GNULIB_POSIXCHECK +# undef strtok_r +# endif +# if ! @HAVE_DECL_STRTOK_R@ +_GL_FUNCDECL_SYS (strtok_r, char *, + (char *restrict s, char const *restrict delim, + char **restrict save_ptr) + _GL_ARG_NONNULL ((2, 3))); +# endif +_GL_CXXALIAS_SYS (strtok_r, char *, + (char *restrict s, char const *restrict delim, + char **restrict save_ptr)); +# endif +_GL_CXXALIASWARN (strtok_r); +# if defined GNULIB_POSIXCHECK +_GL_WARN_ON_USE (strtok_r, "strtok_r cannot work correctly on character " + "strings in multibyte locales - " + "use mbstok_r if you care about internationalization"); +# endif +#elif defined GNULIB_POSIXCHECK +# undef strtok_r +# if HAVE_RAW_DECL_STRTOK_R +_GL_WARN_ON_USE (strtok_r, "strtok_r is unportable - " + "use gnulib module strtok_r for portability"); +# endif +#endif + + +/* The following functions are not specified by POSIX. They are gnulib + extensions. */ + +#if @GNULIB_MBSLEN@ +/* Return the number of multibyte characters in the character string STRING. + This considers multibyte characters, unlike strlen, which counts bytes. */ +# ifdef __MirBSD__ /* MirBSD defines mbslen as a macro. Override it. */ +# undef mbslen +# endif +# if @HAVE_MBSLEN@ /* AIX, OSF/1, MirBSD define mbslen already in libc. */ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define mbslen rpl_mbslen +# endif +_GL_FUNCDECL_RPL (mbslen, size_t, (const char *string) + _GL_ATTRIBUTE_PURE + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (mbslen, size_t, (const char *string)); +# else +_GL_FUNCDECL_SYS (mbslen, size_t, (const char *string) + _GL_ATTRIBUTE_PURE + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_SYS (mbslen, size_t, (const char *string)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (mbslen); +# endif +#endif + +#if @GNULIB_MBSNLEN@ +/* Return the number of multibyte characters in the character string starting + at STRING and ending at STRING + LEN. */ +_GL_EXTERN_C size_t mbsnlen (const char *string, size_t len) + _GL_ATTRIBUTE_PURE + _GL_ARG_NONNULL ((1)); +#endif + +#if @GNULIB_MBSCHR@ +/* Locate the first single-byte character C in the character string STRING, + and return a pointer to it. Return NULL if C is not found in STRING. + Unlike strchr(), this function works correctly in multibyte locales with + encodings such as GB18030. */ +# if defined __hpux +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define mbschr rpl_mbschr /* avoid collision with HP-UX function */ +# endif +_GL_FUNCDECL_RPL (mbschr, char *, (const char *string, int c) + _GL_ATTRIBUTE_PURE + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (mbschr, char *, (const char *string, int c)); +# else +_GL_FUNCDECL_SYS (mbschr, char *, (const char *string, int c) + _GL_ATTRIBUTE_PURE + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_SYS (mbschr, char *, (const char *string, int c)); +# endif +_GL_CXXALIASWARN (mbschr); +#endif + +#if @GNULIB_MBSRCHR@ +/* Locate the last single-byte character C in the character string STRING, + and return a pointer to it. Return NULL if C is not found in STRING. + Unlike strrchr(), this function works correctly in multibyte locales with + encodings such as GB18030. */ +# if defined __hpux || defined __INTERIX +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define mbsrchr rpl_mbsrchr /* avoid collision with system function */ +# endif +_GL_FUNCDECL_RPL (mbsrchr, char *, (const char *string, int c) + _GL_ATTRIBUTE_PURE + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (mbsrchr, char *, (const char *string, int c)); +# else +_GL_FUNCDECL_SYS (mbsrchr, char *, (const char *string, int c) + _GL_ATTRIBUTE_PURE + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_SYS (mbsrchr, char *, (const char *string, int c)); +# endif +_GL_CXXALIASWARN (mbsrchr); +#endif + +#if @GNULIB_MBSSTR@ +/* Find the first occurrence of the character string NEEDLE in the character + string HAYSTACK. Return NULL if NEEDLE is not found in HAYSTACK. + Unlike strstr(), this function works correctly in multibyte locales with + encodings different from UTF-8. */ +_GL_EXTERN_C char * mbsstr (const char *haystack, const char *needle) + _GL_ATTRIBUTE_PURE + _GL_ARG_NONNULL ((1, 2)); +#endif + +#if @GNULIB_MBSCASECMP@ +/* Compare the character strings S1 and S2, ignoring case, returning less than, + equal to or greater than zero if S1 is lexicographically less than, equal to + or greater than S2. + Note: This function may, in multibyte locales, return 0 for strings of + different lengths! + Unlike strcasecmp(), this function works correctly in multibyte locales. */ +_GL_EXTERN_C int mbscasecmp (const char *s1, const char *s2) + _GL_ATTRIBUTE_PURE + _GL_ARG_NONNULL ((1, 2)); +#endif + +#if @GNULIB_MBSNCASECMP@ +/* Compare the initial segment of the character string S1 consisting of at most + N characters with the initial segment of the character string S2 consisting + of at most N characters, ignoring case, returning less than, equal to or + greater than zero if the initial segment of S1 is lexicographically less + than, equal to or greater than the initial segment of S2. + Note: This function may, in multibyte locales, return 0 for initial segments + of different lengths! + Unlike strncasecmp(), this function works correctly in multibyte locales. + But beware that N is not a byte count but a character count! */ +_GL_EXTERN_C int mbsncasecmp (const char *s1, const char *s2, size_t n) + _GL_ATTRIBUTE_PURE + _GL_ARG_NONNULL ((1, 2)); +#endif + +#if @GNULIB_MBSPCASECMP@ +/* Compare the initial segment of the character string STRING consisting of + at most mbslen (PREFIX) characters with the character string PREFIX, + ignoring case. If the two match, return a pointer to the first byte + after this prefix in STRING. Otherwise, return NULL. + Note: This function may, in multibyte locales, return non-NULL if STRING + is of smaller length than PREFIX! + Unlike strncasecmp(), this function works correctly in multibyte + locales. */ +_GL_EXTERN_C char * mbspcasecmp (const char *string, const char *prefix) + _GL_ATTRIBUTE_PURE + _GL_ARG_NONNULL ((1, 2)); +#endif + +#if @GNULIB_MBSCASESTR@ +/* Find the first occurrence of the character string NEEDLE in the character + string HAYSTACK, using case-insensitive comparison. + Note: This function may, in multibyte locales, return success even if + strlen (haystack) < strlen (needle) ! + Unlike strcasestr(), this function works correctly in multibyte locales. */ +_GL_EXTERN_C char * mbscasestr (const char *haystack, const char *needle) + _GL_ATTRIBUTE_PURE + _GL_ARG_NONNULL ((1, 2)); +#endif + +#if @GNULIB_MBSCSPN@ +/* Find the first occurrence in the character string STRING of any character + in the character string ACCEPT. Return the number of bytes from the + beginning of the string to this occurrence, or to the end of the string + if none exists. + Unlike strcspn(), this function works correctly in multibyte locales. */ +_GL_EXTERN_C size_t mbscspn (const char *string, const char *accept) + _GL_ATTRIBUTE_PURE + _GL_ARG_NONNULL ((1, 2)); +#endif + +#if @GNULIB_MBSPBRK@ +/* Find the first occurrence in the character string STRING of any character + in the character string ACCEPT. Return the pointer to it, or NULL if none + exists. + Unlike strpbrk(), this function works correctly in multibyte locales. */ +# if defined __hpux +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */ +# endif +_GL_FUNCDECL_RPL (mbspbrk, char *, (const char *string, const char *accept) + _GL_ATTRIBUTE_PURE + _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (mbspbrk, char *, (const char *string, const char *accept)); +# else +_GL_FUNCDECL_SYS (mbspbrk, char *, (const char *string, const char *accept) + _GL_ATTRIBUTE_PURE + _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_SYS (mbspbrk, char *, (const char *string, const char *accept)); +# endif +_GL_CXXALIASWARN (mbspbrk); +#endif + +#if @GNULIB_MBSSPN@ +/* Find the first occurrence in the character string STRING of any character + not in the character string REJECT. Return the number of bytes from the + beginning of the string to this occurrence, or to the end of the string + if none exists. + Unlike strspn(), this function works correctly in multibyte locales. */ +_GL_EXTERN_C size_t mbsspn (const char *string, const char *reject) + _GL_ATTRIBUTE_PURE + _GL_ARG_NONNULL ((1, 2)); +#endif + +#if @GNULIB_MBSSEP@ +/* Search the next delimiter (multibyte character listed in the character + string DELIM) starting at the character string *STRINGP. + If one is found, overwrite it with a NUL, and advance *STRINGP to point + to the next multibyte character after it. Otherwise, set *STRINGP to NULL. + If *STRINGP was already NULL, nothing happens. + Return the old value of *STRINGP. + + This is a variant of mbstok_r() that supports empty fields. + + Caveat: It modifies the original string. + Caveat: These functions cannot be used on constant strings. + Caveat: The identity of the delimiting character is lost. + + See also mbstok_r(). */ +_GL_EXTERN_C char * mbssep (char **stringp, const char *delim) + _GL_ARG_NONNULL ((1, 2)); +#endif + +#if @GNULIB_MBSTOK_R@ +/* Parse the character string STRING into tokens separated by characters in + the character string DELIM. + If STRING is NULL, the saved pointer in SAVE_PTR is used as + the next starting point. For example: + char s[] = "-abc-=-def"; + char *sp; + x = mbstok_r(s, "-", &sp); // x = "abc", sp = "=-def" + x = mbstok_r(NULL, "-=", &sp); // x = "def", sp = NULL + x = mbstok_r(NULL, "=", &sp); // x = NULL + // s = "abc\0-def\0" + + Caveat: It modifies the original string. + Caveat: These functions cannot be used on constant strings. + Caveat: The identity of the delimiting character is lost. + + See also mbssep(). */ +_GL_EXTERN_C char * mbstok_r (char *restrict string, const char *delim, + char **save_ptr) + _GL_ARG_NONNULL ((2, 3)); +#endif + +/* Map any int, typically from errno, into an error message. */ +#if @GNULIB_STRERROR@ +# if @REPLACE_STRERROR@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef strerror +# define strerror rpl_strerror +# endif +_GL_FUNCDECL_RPL (strerror, char *, (int)); +_GL_CXXALIAS_RPL (strerror, char *, (int)); +# else +_GL_CXXALIAS_SYS (strerror, char *, (int)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (strerror); +# endif +#elif defined GNULIB_POSIXCHECK +# undef strerror +/* Assume strerror is always declared. */ +_GL_WARN_ON_USE (strerror, "strerror is unportable - " + "use gnulib module strerror to guarantee non-NULL result"); +#endif + +/* Map any int, typically from errno, into an error message. Multithread-safe. + Uses the POSIX declaration, not the glibc declaration. */ +#if @GNULIB_STRERROR_R@ +# if @REPLACE_STRERROR_R@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef strerror_r +# define strerror_r rpl_strerror_r +# endif +_GL_FUNCDECL_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen) + _GL_ARG_NONNULL ((2))); +_GL_CXXALIAS_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen)); +# else +# if !@HAVE_DECL_STRERROR_R@ +_GL_FUNCDECL_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen) + _GL_ARG_NONNULL ((2))); +# endif +_GL_CXXALIAS_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen)); +# endif +# if __GLIBC__ >= 2 && @HAVE_DECL_STRERROR_R@ +_GL_CXXALIASWARN (strerror_r); +# endif +#elif defined GNULIB_POSIXCHECK +# undef strerror_r +# if HAVE_RAW_DECL_STRERROR_R +_GL_WARN_ON_USE (strerror_r, "strerror_r is unportable - " + "use gnulib module strerror_r-posix for portability"); +# endif +#endif + +/* Return the name of the system error code ERRNUM. */ +#if @GNULIB_STRERRORNAME_NP@ +# if @REPLACE_STRERRORNAME_NP@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef strerrorname_np +# define strerrorname_np rpl_strerrorname_np +# endif +_GL_FUNCDECL_RPL (strerrorname_np, const char *, (int errnum)); +_GL_CXXALIAS_RPL (strerrorname_np, const char *, (int errnum)); +# else +# if !@HAVE_STRERRORNAME_NP@ +_GL_FUNCDECL_SYS (strerrorname_np, const char *, (int errnum)); +# endif +_GL_CXXALIAS_SYS (strerrorname_np, const char *, (int errnum)); +# endif +_GL_CXXALIASWARN (strerrorname_np); +#elif defined GNULIB_POSIXCHECK +# undef strerrorname_np +# if HAVE_RAW_DECL_STRERRORNAME_NP +_GL_WARN_ON_USE (strerrorname_np, "strerrorname_np is unportable - " + "use gnulib module strerrorname_np for portability"); +# endif +#endif + +/* Return an abbreviation string for the signal number SIG. */ +#if @GNULIB_SIGABBREV_NP@ +# if ! @HAVE_SIGABBREV_NP@ +_GL_FUNCDECL_SYS (sigabbrev_np, const char *, (int sig)); +# endif +_GL_CXXALIAS_SYS (sigabbrev_np, const char *, (int sig)); +_GL_CXXALIASWARN (sigabbrev_np); +#elif defined GNULIB_POSIXCHECK +# undef sigabbrev_np +# if HAVE_RAW_DECL_SIGABBREV_NP +_GL_WARN_ON_USE (sigabbrev_np, "sigabbrev_np is unportable - " + "use gnulib module sigabbrev_np for portability"); +# endif +#endif + +/* Return an English description string for the signal number SIG. */ +#if @GNULIB_SIGDESCR_NP@ +# if ! @HAVE_SIGDESCR_NP@ +_GL_FUNCDECL_SYS (sigdescr_np, const char *, (int sig)); +# endif +_GL_CXXALIAS_SYS (sigdescr_np, const char *, (int sig)); +_GL_CXXALIASWARN (sigdescr_np); +#elif defined GNULIB_POSIXCHECK +# undef sigdescr_np +# if HAVE_RAW_DECL_SIGDESCR_NP +_GL_WARN_ON_USE (sigdescr_np, "sigdescr_np is unportable - " + "use gnulib module sigdescr_np for portability"); +# endif +#endif + +#if @GNULIB_STRSIGNAL@ +# if @REPLACE_STRSIGNAL@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define strsignal rpl_strsignal +# endif +_GL_FUNCDECL_RPL (strsignal, char *, (int __sig)); +_GL_CXXALIAS_RPL (strsignal, char *, (int __sig)); +# else +# if ! @HAVE_DECL_STRSIGNAL@ +_GL_FUNCDECL_SYS (strsignal, char *, (int __sig)); +# endif +/* Need to cast, because on Cygwin 1.5.x systems, the return type is + 'const char *'. */ +_GL_CXXALIAS_SYS_CAST (strsignal, char *, (int __sig)); +# endif +_GL_CXXALIASWARN (strsignal); +#elif defined GNULIB_POSIXCHECK +# undef strsignal +# if HAVE_RAW_DECL_STRSIGNAL +_GL_WARN_ON_USE (strsignal, "strsignal is unportable - " + "use gnulib module strsignal for portability"); +# endif +#endif + +#if @GNULIB_STRVERSCMP@ +# if @REPLACE_STRVERSCMP@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define strverscmp rpl_strverscmp +# endif +_GL_FUNCDECL_RPL (strverscmp, int, (const char *, const char *) + _GL_ATTRIBUTE_PURE + _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (strverscmp, int, (const char *, const char *)); +# else +# if !@HAVE_STRVERSCMP@ +_GL_FUNCDECL_SYS (strverscmp, int, (const char *, const char *) + _GL_ATTRIBUTE_PURE + _GL_ARG_NONNULL ((1, 2))); +# endif +_GL_CXXALIAS_SYS (strverscmp, int, (const char *, const char *)); +# endif +_GL_CXXALIASWARN (strverscmp); +#elif defined GNULIB_POSIXCHECK +# undef strverscmp +# if HAVE_RAW_DECL_STRVERSCMP +_GL_WARN_ON_USE (strverscmp, "strverscmp is unportable - " + "use gnulib module strverscmp for portability"); +# endif +#endif + + +#endif /* _@GUARD_PREFIX@_STRING_H */ +#endif /* _@GUARD_PREFIX@_STRING_H */ +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strings.in.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strings.in.h new file mode 100644 index 00000000..2b3e062a --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strings.in.h @@ -0,0 +1,127 @@ +/* A substitute . + + Copyright (C) 2007-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef _@GUARD_PREFIX@_STRINGS_H + +#if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +#endif +@PRAGMA_COLUMNS@ + +/* Minix 3.1.8 has a bug: must be included before . + But avoid namespace pollution on glibc systems. */ +#if defined __minix && !defined __GLIBC__ +# include +#endif + +/* The include_next requires a split double-inclusion guard. */ +#if @HAVE_STRINGS_H@ +# @INCLUDE_NEXT@ @NEXT_STRINGS_H@ +#endif + +#ifndef _@GUARD_PREFIX@_STRINGS_H +#define _@GUARD_PREFIX@_STRINGS_H + +/* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +#if ! @HAVE_DECL_STRNCASECMP@ +/* Get size_t. */ +# include +#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. */ + +#ifdef __cplusplus +extern "C" { +#endif + + + /* Find the index of the least-significant set bit. */ +#if @GNULIB_FFS@ +# if !@HAVE_FFS@ +_GL_FUNCDECL_SYS (ffs, int, (int i)); +# endif +_GL_CXXALIAS_SYS (ffs, int, (int i)); +_GL_CXXALIASWARN (ffs); +#elif defined GNULIB_POSIXCHECK +# undef ffs +# if HAVE_RAW_DECL_FFS +_GL_WARN_ON_USE (ffs, "ffs is not portable - use the ffs module"); +# endif +#endif + +/* Compare strings S1 and S2, ignoring case, returning less than, equal to or + greater than zero if S1 is lexicographically less than, equal to or greater + than S2. + Note: This function does not work in multibyte locales. */ +#if ! @HAVE_STRCASECMP@ +extern int strcasecmp (char const *s1, char const *s2) + _GL_ARG_NONNULL ((1, 2)); +#endif +#if defined GNULIB_POSIXCHECK +/* strcasecmp() does not work with multibyte strings: + POSIX says that it operates on "strings", and "string" in POSIX is defined + as a sequence of bytes, not of characters. */ +# undef strcasecmp +# if HAVE_RAW_DECL_STRCASECMP +_GL_WARN_ON_USE (strcasecmp, "strcasecmp cannot work correctly on character " + "strings in multibyte locales - " + "use mbscasecmp if you care about " + "internationalization, or use c_strcasecmp , " + "gnulib module c-strcase) if you want a locale " + "independent function"); +# endif +#endif + +/* Compare no more than N bytes of strings S1 and S2, ignoring case, + returning less than, equal to or greater than zero if S1 is + lexicographically less than, equal to or greater than S2. + Note: This function cannot work correctly in multibyte locales. */ +#if ! @HAVE_DECL_STRNCASECMP@ +extern int strncasecmp (char const *s1, char const *s2, size_t n) + _GL_ARG_NONNULL ((1, 2)); +#endif +#if defined GNULIB_POSIXCHECK +/* strncasecmp() does not work with multibyte strings: + POSIX says that it operates on "strings", and "string" in POSIX is defined + as a sequence of bytes, not of characters. */ +# undef strncasecmp +# if HAVE_RAW_DECL_STRNCASECMP +_GL_WARN_ON_USE (strncasecmp, "strncasecmp cannot work correctly on character " + "strings in multibyte locales - " + "use mbsncasecmp or mbspcasecmp if you care about " + "internationalization, or use c_strncasecmp , " + "gnulib module c-strcase) if you want a locale " + "independent function"); +# endif +#endif + + +#ifdef __cplusplus +} +#endif + +#endif /* _@GUARD_PREFIX@_STRING_H */ +#endif /* _@GUARD_PREFIX@_STRING_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stripslash.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stripslash.c new file mode 100644 index 00000000..c127ce7e --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/stripslash.c @@ -0,0 +1,45 @@ +/* stripslash.c -- remove redundant trailing slashes from a file name + + Copyright (C) 1990, 2001, 2003-2006, 2009-2024 Free Software Foundation, + Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +#include "dirname.h" + +/* Remove trailing slashes from FILE. Return true if a trailing slash + was removed. This is useful when using file name completion from a + shell that adds a "/" after directory names (such as tcsh and + bash), because on symlinks to directories, several system calls + have different semantics according to whether a trailing slash is + present. */ + +bool +strip_trailing_slashes (char *file) +{ + char *base = last_component (file); + char *base_lim; + bool had_slash; + + /* last_component returns "" for file system roots, but we need to turn + "///" into "/". */ + if (! *base) + base = file; + base_lim = base + base_len (base); + had_slash = (*base_lim != '\0'); + *base_lim = '\0'; + return had_slash; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strncasecmp.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strncasecmp.c new file mode 100644 index 00000000..c79161f3 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strncasecmp.c @@ -0,0 +1,60 @@ +/* strncasecmp.c -- case insensitive string comparator + Copyright (C) 1998-1999, 2005-2007, 2009-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +#include +#include + +/* Compare no more than N bytes of strings S1 and S2, ignoring case, + returning less than, equal to or greater than zero if S1 is + lexicographically less than, equal to or greater than S2. + Note: This function cannot work correctly in multibyte locales. */ + +int +strncasecmp (const char *s1, const char *s2, size_t n) +{ + register const unsigned char *p1 = (const unsigned char *) s1; + register const unsigned char *p2 = (const unsigned char *) s2; + unsigned char c1, c2; + + if (p1 == p2 || n == 0) + return 0; + + do + { + c1 = tolower (*p1); + c2 = tolower (*p2); + + if (--n == 0 || c1 == '\0') + break; + + ++p1; + ++p2; + } + while (c1 == c2); + + if (UCHAR_MAX <= INT_MAX) + return c1 - c2; + else + /* On machines where 'char' and 'int' are types of the same size, the + difference of two 'unsigned char' values - including the sign bit - + doesn't fit in an 'int'. */ + return _GL_CMP (c1, c2); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strnlen.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strnlen.c new file mode 100644 index 00000000..80857ec2 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strnlen.c @@ -0,0 +1,30 @@ +/* Find the length of STRING, but scan at most MAXLEN characters. + Copyright (C) 2005-2007, 2009-2024 Free Software Foundation, Inc. + Written by Simon Josefsson. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +#include + +/* Find the length of STRING, but scan at most MAXLEN characters. + If no '\0' terminator is found in that many characters, return MAXLEN. */ + +size_t +strnlen (const char *string, size_t maxlen) +{ + const char *end = memchr (string, '\0', maxlen); + return end ? (size_t) (end - string) : maxlen; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strnlen1.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strnlen1.c new file mode 100644 index 00000000..27c832ad --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strnlen1.c @@ -0,0 +1,35 @@ +/* Find the length of STRING + 1, but scan at most MAXLEN bytes. + Copyright (C) 2005-2006, 2009-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "strnlen1.h" + +#include + +/* Find the length of STRING + 1, but scan at most MAXLEN bytes. + If no '\0' terminator is found in that many characters, return MAXLEN. */ +/* This is the same as strnlen (string, maxlen - 1) + 1. */ +size_t +strnlen1 (const char *string, size_t maxlen) +{ + const char *end = (const char *) memchr (string, '\0', maxlen); + if (end != NULL) + return end - string + 1; + else + return maxlen; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strnlen1.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strnlen1.h new file mode 100644 index 00000000..8943f3ed --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strnlen1.h @@ -0,0 +1,45 @@ +/* Find the length of STRING + 1, but scan at most MAXLEN bytes. + Copyright (C) 2005, 2009-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef _STRNLEN1_H +#define _STRNLEN1_H + +/* This file uses _GL_ATTRIBUTE_PURE. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +#include + + +#ifdef __cplusplus +extern "C" { +#endif + + +/* Find the length of STRING + 1, but scan at most MAXLEN bytes. + If no '\0' terminator is found in that many characters, return MAXLEN. */ +/* This is the same as strnlen (string, maxlen - 1) + 1. */ +extern size_t strnlen1 (const char *string, size_t maxlen) + _GL_ATTRIBUTE_PURE; + + +#ifdef __cplusplus +} +#endif + + +#endif /* _STRNLEN1_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strptime.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strptime.c new file mode 100644 index 00000000..3039a477 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strptime.c @@ -0,0 +1,1163 @@ +/* Copyright (C) 2002, 2004-2005, 2007, 2009-2024 Free Software Foundation, + Inc. + This file is part of the GNU C Library. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef _LIBC +# include +#endif + +#include + +#include +#include +#ifdef _LIBC +# include +#endif +#include +#include +#include + +#ifdef _LIBC +# include +# include "../locale/localeinfo.h" +#endif + +#ifndef _LIBC +enum ptime_locale_status { not, loc, raw }; +#endif + + + +#define match_char(ch1, ch2) if (ch1 != ch2) return NULL +#if defined _LIBC && defined __GNUC__ && __GNUC__ >= 2 +# define match_string(cs1, s2) \ + ({ size_t len = strlen (cs1); \ + int result = __strncasecmp_l ((cs1), (s2), len, locale) == 0; \ + if (result) (s2) += len; \ + result; }) +#else +/* Oh come on. Get a reasonable compiler. */ +# define match_string(cs1, s2) \ + (strncasecmp ((cs1), (s2), strlen (cs1)) ? 0 : ((s2) += strlen (cs1), 1)) +#endif +/* We intentionally do not use isdigit() for testing because this will + lead to problems with the wide character version. */ +#define get_number(from, to, n) \ + do { \ + int __n = n; \ + val = 0; \ + while (*rp == ' ') \ + ++rp; \ + if (*rp < '0' || *rp > '9') \ + return NULL; \ + do { \ + val *= 10; \ + val += *rp++ - '0'; \ + } while (--__n > 0 && val * 10 <= to && *rp >= '0' && *rp <= '9'); \ + if (val < from || val > to) \ + return NULL; \ + } while (0) +#ifdef _NL_CURRENT +# define get_alt_number(from, to, n) \ + ({ \ + __label__ do_normal; \ + \ + if (*decided != raw) \ + { \ + val = _nl_parse_alt_digit (&rp HELPER_LOCALE_ARG); \ + if (val == -1 && *decided != loc) \ + { \ + *decided = loc; \ + goto do_normal; \ + } \ + if (val < from || val > to) \ + return NULL; \ + } \ + else \ + { \ + do_normal: \ + get_number (from, to, n); \ + } \ + 0; \ + }) +#else +# define get_alt_number(from, to, n) \ + /* We don't have the alternate representation. */ \ + get_number(from, to, n) +#endif +#define recursive(new_fmt) \ + (*(new_fmt) != '\0' \ + && (rp = __strptime_internal (rp, (new_fmt), tm, \ + decided, era_cnt LOCALE_ARG)) != NULL) + + +#ifdef _LIBC +/* This is defined in locale/C-time.c in the GNU libc. */ +extern const struct locale_data _nl_C_LC_TIME attribute_hidden; + +# define weekday_name (&_nl_C_LC_TIME.values[_NL_ITEM_INDEX (DAY_1)].string) +# define ab_weekday_name \ + (&_nl_C_LC_TIME.values[_NL_ITEM_INDEX (ABDAY_1)].string) +# define month_name (&_nl_C_LC_TIME.values[_NL_ITEM_INDEX (MON_1)].string) +# define ab_month_name (&_nl_C_LC_TIME.values[_NL_ITEM_INDEX (ABMON_1)].string) +# define HERE_D_T_FMT (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (D_T_FMT)].string) +# define HERE_D_FMT (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (D_FMT)].string) +# define HERE_AM_STR (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (AM_STR)].string) +# define HERE_PM_STR (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (PM_STR)].string) +# define HERE_T_FMT_AMPM \ + (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (T_FMT_AMPM)].string) +# define HERE_T_FMT (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (T_FMT)].string) + +# define strncasecmp(s1, s2, n) __strncasecmp (s1, s2, n) +#else +static char const weekday_name[][10] = + { + "Sunday", "Monday", "Tuesday", "Wednesday", + "Thursday", "Friday", "Saturday" + }; +static char const ab_weekday_name[][4] = + { + "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" + }; +static char const month_name[][10] = + { + "January", "February", "March", "April", "May", "June", + "July", "August", "September", "October", "November", "December" + }; +static char const ab_month_name[][4] = + { + "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" + }; +# define HERE_D_T_FMT "%a %b %e %H:%M:%S %Y" +# define HERE_D_FMT "%m/%d/%y" +# define HERE_AM_STR "AM" +# define HERE_PM_STR "PM" +# define HERE_T_FMT_AMPM "%I:%M:%S %p" +# define HERE_T_FMT "%H:%M:%S" + +static const unsigned short int __mon_yday[2][13] = + { + /* Normal years. */ + { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 }, + /* Leap years. */ + { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 } + }; +#endif + +#if defined _LIBC +/* We use this code also for the extended locale handling where the + function gets as an additional argument the locale which has to be + used. To access the values we have to redefine the _NL_CURRENT + macro. */ +# define strptime __strptime_l +# undef _NL_CURRENT +# define _NL_CURRENT(category, item) \ + (current->values[_NL_ITEM_INDEX (item)].string) +# undef _NL_CURRENT_WORD +# define _NL_CURRENT_WORD(category, item) \ + (current->values[_NL_ITEM_INDEX (item)].word) +# define LOCALE_PARAM , locale +# define LOCALE_ARG , locale +# define LOCALE_PARAM_PROTO , __locale_t locale +# define LOCALE_PARAM_DECL __locale_t locale; +# define HELPER_LOCALE_ARG , current +# define ISSPACE(Ch) __isspace_l (Ch, locale) +#else +# define LOCALE_PARAM +# define LOCALE_ARG +# define LOCALE_PARAM_DECL +# define LOCALE_PARAM_PROTO +# define HELPER_LOCALE_ARG +# define ISSPACE(Ch) isspace (Ch) +#endif + + + + +#ifndef __isleap +/* Nonzero if YEAR is a leap year (every 4 years, + except every 100th isn't, and every 400th is). */ +# define __isleap(year) \ + ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0)) +#endif + +/* Compute the day of the week. */ +static void +day_of_the_week (struct tm *tm) +{ + /* We know that January 1st 1970 was a Thursday (= 4). Compute the + difference between this data in the one on TM and so determine + the weekday. */ + int corr_year = 1900 + tm->tm_year - (tm->tm_mon < 2); + int corr_quad = corr_year / 4; + int wday = (-473 + + (365 * (tm->tm_year - 70)) + + corr_quad + - ((corr_quad + (corr_quad < 0)) / 25 - (corr_quad < 0)) + + ((corr_quad / 25) / 4) + + __mon_yday[0][tm->tm_mon] + + tm->tm_mday - 1); + tm->tm_wday = ((wday % 7) + 7) % 7; +} + +/* Compute the day of the year. */ +static void +day_of_the_year (struct tm *tm) +{ + tm->tm_yday = (__mon_yday[__isleap (1900 + tm->tm_year)][tm->tm_mon] + + (tm->tm_mday - 1)); +} + + +#ifdef _LIBC +char * +internal_function +#else +static char * +#endif +__strptime_internal (rp, fmt, tm, decided, era_cnt LOCALE_PARAM) + const char *rp; + const char *fmt; + struct tm *tm; + enum ptime_locale_status *decided; + int era_cnt; + LOCALE_PARAM_DECL +{ +#ifdef _LIBC + struct locale_data *const current = locale->__locales[LC_TIME]; +#endif + + int cnt; + size_t val; + int have_I, is_pm; + int century, want_century; + int want_era; + int have_wday, want_xday; + int have_yday; + int have_mon, have_mday; + int have_uweek, have_wweek; + int week_no; +#ifdef _NL_CURRENT + size_t num_eras; + struct era_entry *era = NULL; + const char *rp_backup; +#endif + + have_I = is_pm = 0; + century = -1; + want_century = 0; + want_era = 0; + week_no = 0; + + have_wday = want_xday = have_yday = have_mon = have_mday = have_uweek = 0; + have_wweek = 0; + + while (*fmt != '\0') + { + /* A white space in the format string matches 0 more or white + space in the input string. */ + if (ISSPACE (*fmt)) + { + while (ISSPACE (*rp)) + ++rp; + ++fmt; + continue; + } + + /* Any character but '%' must be matched by the same character + in the input string. */ + if (*fmt != '%') + { + match_char (*fmt++, *rp++); + continue; + } + + ++fmt; +#ifndef _NL_CURRENT + /* We need this for handling the 'E' modifier. */ + start_over: +#else + /* Make back up of current processing pointer. */ + rp_backup = rp; +#endif + + switch (*fmt++) + { + case '%': + /* Match the '%' character itself. */ + match_char ('%', *rp++); + break; + case 'a': + case 'A': + /* Match day of week. */ + for (cnt = 0; cnt < 7; ++cnt) + { +#ifdef _NL_CURRENT + if (*decided !=raw) + { + if (match_string (_NL_CURRENT (LC_TIME, DAY_1 + cnt), rp)) + { + if (*decided == not + && strcmp (_NL_CURRENT (LC_TIME, DAY_1 + cnt), + weekday_name[cnt])) + *decided = loc; + break; + } + if (match_string (_NL_CURRENT (LC_TIME, ABDAY_1 + cnt), rp)) + { + if (*decided == not + && strcmp (_NL_CURRENT (LC_TIME, ABDAY_1 + cnt), + ab_weekday_name[cnt])) + *decided = loc; + break; + } + } +#endif + if (*decided != loc + && (match_string (weekday_name[cnt], rp) + || match_string (ab_weekday_name[cnt], rp))) + { + *decided = raw; + break; + } + } + if (cnt == 7) + /* Does not match a weekday name. */ + return NULL; + tm->tm_wday = cnt; + have_wday = 1; + break; + case 'b': + case 'B': + case 'h': + /* Match month name. */ + for (cnt = 0; cnt < 12; ++cnt) + { +#ifdef _NL_CURRENT + if (*decided !=raw) + { + if (match_string (_NL_CURRENT (LC_TIME, MON_1 + cnt), rp)) + { + if (*decided == not + && strcmp (_NL_CURRENT (LC_TIME, MON_1 + cnt), + month_name[cnt])) + *decided = loc; + break; + } + if (match_string (_NL_CURRENT (LC_TIME, ABMON_1 + cnt), rp)) + { + if (*decided == not + && strcmp (_NL_CURRENT (LC_TIME, ABMON_1 + cnt), + ab_month_name[cnt])) + *decided = loc; + break; + } + } +#endif + if (match_string (month_name[cnt], rp) + || match_string (ab_month_name[cnt], rp)) + { + *decided = raw; + break; + } + } + if (cnt == 12) + /* Does not match a month name. */ + return NULL; + tm->tm_mon = cnt; + want_xday = 1; + break; + case 'c': + /* Match locale's date and time format. */ +#ifdef _NL_CURRENT + if (*decided != raw) + { + if (!recursive (_NL_CURRENT (LC_TIME, D_T_FMT))) + { + if (*decided == loc) + return NULL; + else + rp = rp_backup; + } + else + { + if (*decided == not && + strcmp (_NL_CURRENT (LC_TIME, D_T_FMT), HERE_D_T_FMT)) + *decided = loc; + want_xday = 1; + break; + } + *decided = raw; + } +#endif + if (!recursive (HERE_D_T_FMT)) + return NULL; + want_xday = 1; + break; + case 'C': + /* Match century number. */ +#ifdef _NL_CURRENT + match_century: +#endif + get_number (0, 99, 2); + century = val; + want_xday = 1; + break; + case 'd': + case 'e': + /* Match day of month. */ + get_number (1, 31, 2); + tm->tm_mday = val; + have_mday = 1; + want_xday = 1; + break; + case 'F': + if (!recursive ("%Y-%m-%d")) + return NULL; + want_xday = 1; + break; + case 'x': +#ifdef _NL_CURRENT + if (*decided != raw) + { + if (!recursive (_NL_CURRENT (LC_TIME, D_FMT))) + { + if (*decided == loc) + return NULL; + else + rp = rp_backup; + } + else + { + if (*decided == not + && strcmp (_NL_CURRENT (LC_TIME, D_FMT), HERE_D_FMT)) + *decided = loc; + want_xday = 1; + break; + } + *decided = raw; + } +#endif + /* Fall through. */ + case 'D': + /* Match standard day format. */ + if (!recursive (HERE_D_FMT)) + return NULL; + want_xday = 1; + break; + case 'k': + case 'H': + /* Match hour in 24-hour clock. */ + get_number (0, 23, 2); + tm->tm_hour = val; + have_I = 0; + break; + case 'l': + /* Match hour in 12-hour clock. GNU extension. */ + case 'I': + /* Match hour in 12-hour clock. */ + get_number (1, 12, 2); + tm->tm_hour = val % 12; + have_I = 1; + break; + case 'j': + /* Match day number of year. */ + get_number (1, 366, 3); + tm->tm_yday = val - 1; + have_yday = 1; + break; + case 'm': + /* Match number of month. */ + get_number (1, 12, 2); + tm->tm_mon = val - 1; + have_mon = 1; + want_xday = 1; + break; + case 'M': + /* Match minute. */ + get_number (0, 59, 2); + tm->tm_min = val; + break; + case 'n': + case 't': + /* Match any white space. */ + while (ISSPACE (*rp)) + ++rp; + break; + case 'p': + /* Match locale's equivalent of AM/PM. */ +#ifdef _NL_CURRENT + if (*decided != raw) + { + if (match_string (_NL_CURRENT (LC_TIME, AM_STR), rp)) + { + if (strcmp (_NL_CURRENT (LC_TIME, AM_STR), HERE_AM_STR)) + *decided = loc; + break; + } + if (match_string (_NL_CURRENT (LC_TIME, PM_STR), rp)) + { + if (strcmp (_NL_CURRENT (LC_TIME, PM_STR), HERE_PM_STR)) + *decided = loc; + is_pm = 1; + break; + } + *decided = raw; + } +#endif + if (!match_string (HERE_AM_STR, rp)) + { + if (match_string (HERE_PM_STR, rp)) + is_pm = 1; + else + return NULL; + } + break; + case 'q': + /* Match quarter of year. GNU extension. */ + get_number (1, 4, 1); + tm->tm_mon = (val - 1) * 3; + tm->tm_mday = 1; + have_mon = 1; + have_mday = 1; + want_xday = 1; + break; + case 'r': +#ifdef _NL_CURRENT + if (*decided != raw) + { + if (!recursive (_NL_CURRENT (LC_TIME, T_FMT_AMPM))) + { + if (*decided == loc) + return NULL; + else + rp = rp_backup; + } + else + { + if (*decided == not && + strcmp (_NL_CURRENT (LC_TIME, T_FMT_AMPM), + HERE_T_FMT_AMPM)) + *decided = loc; + break; + } + *decided = raw; + } +#endif + if (!recursive (HERE_T_FMT_AMPM)) + return NULL; + break; + case 'R': + if (!recursive ("%H:%M")) + return NULL; + break; + case 's': + { + /* The number of seconds may be very high so we cannot use + the 'get_number' macro. Instead read the number + character for character and construct the result while + doing this. */ + time_t secs = 0; + if (*rp < '0' || *rp > '9') + /* We need at least one digit. */ + return NULL; + + do + { + secs *= 10; + secs += *rp++ - '0'; + } + while (*rp >= '0' && *rp <= '9'); + + if (localtime_r (&secs, tm) == NULL) + /* Error in function. */ + return NULL; + } + break; + case 'S': + get_number (0, 61, 2); + tm->tm_sec = val; + break; + case 'X': +#ifdef _NL_CURRENT + if (*decided != raw) + { + if (!recursive (_NL_CURRENT (LC_TIME, T_FMT))) + { + if (*decided == loc) + return NULL; + else + rp = rp_backup; + } + else + { + if (strcmp (_NL_CURRENT (LC_TIME, T_FMT), HERE_T_FMT)) + *decided = loc; + break; + } + *decided = raw; + } +#endif + /* Fall through. */ + case 'T': + if (!recursive (HERE_T_FMT)) + return NULL; + break; + case 'u': + get_number (1, 7, 1); + tm->tm_wday = val % 7; + have_wday = 1; + break; + case 'g': + get_number (0, 99, 2); + /* XXX This cannot determine any field in TM. */ + break; + case 'G': + if (*rp < '0' || *rp > '9') + return NULL; + /* XXX Ignore the number since we would need some more + information to compute a real date. */ + do + ++rp; + while (*rp >= '0' && *rp <= '9'); + break; + case 'U': + get_number (0, 53, 2); + week_no = val; + have_uweek = 1; + break; + case 'W': + get_number (0, 53, 2); + week_no = val; + have_wweek = 1; + break; + case 'V': + get_number (0, 53, 2); + /* XXX This cannot determine any field in TM without some + information. */ + break; + case 'w': + /* Match number of weekday. */ + get_number (0, 6, 1); + tm->tm_wday = val; + have_wday = 1; + break; + case 'y': +#ifdef _NL_CURRENT + match_year_in_century: +#endif + /* Match year within century. */ + get_number (0, 99, 2); + /* The "Year 2000: The Millennium Rollover" paper suggests that + values in the range 69-99 refer to the twentieth century. */ + tm->tm_year = val >= 69 ? val : val + 100; + /* Indicate that we want to use the century, if specified. */ + want_century = 1; + want_xday = 1; + break; + case 'Y': + /* Match year including century number. */ + get_number (0, 9999, 4); + tm->tm_year = val - 1900; + want_century = 0; + want_xday = 1; + break; + case 'Z': + /* XXX How to handle this? */ + break; + case 'z': + /* We recognize two formats: if two digits are given, these + specify hours. If fours digits are used, minutes are + also specified. */ + { + _GL_UNUSED bool neg; + int n; + + val = 0; + while (*rp == ' ') + ++rp; + if (*rp != '+' && *rp != '-') + return NULL; + neg = *rp++ == '-'; + n = 0; + while (n < 4 && *rp >= '0' && *rp <= '9') + { + val = val * 10 + *rp++ - '0'; + ++n; + } + if (n == 2) + val *= 100; + else if (n != 4) + /* Only two or four digits recognized. */ + return NULL; + else + { + /* We have to convert the minutes into decimal. */ + if (val % 100 >= 60) + return NULL; + val = (val / 100) * 100 + ((val % 100) * 50) / 30; + } + if (val > 1200) + return NULL; +#if defined _LIBC || HAVE_TM_GMTOFF + tm->tm_gmtoff = (val * 3600) / 100; + if (neg) + tm->tm_gmtoff = -tm->tm_gmtoff; +#endif + } + break; + case 'E': +#ifdef _NL_CURRENT + switch (*fmt++) + { + case 'c': + /* Match locale's alternate date and time format. */ + if (*decided != raw) + { + const char *fmt = _NL_CURRENT (LC_TIME, ERA_D_T_FMT); + + if (*fmt == '\0') + fmt = _NL_CURRENT (LC_TIME, D_T_FMT); + + if (!recursive (fmt)) + { + if (*decided == loc) + return NULL; + else + rp = rp_backup; + } + else + { + if (strcmp (fmt, HERE_D_T_FMT)) + *decided = loc; + want_xday = 1; + break; + } + *decided = raw; + } + /* The C locale has no era information, so use the + normal representation. */ + if (!recursive (HERE_D_T_FMT)) + return NULL; + want_xday = 1; + break; + case 'C': + if (*decided != raw) + { + if (era_cnt >= 0) + { + era = _nl_select_era_entry (era_cnt HELPER_LOCALE_ARG); + if (era != NULL && match_string (era->era_name, rp)) + { + *decided = loc; + break; + } + else + return NULL; + } + + num_eras = _NL_CURRENT_WORD (LC_TIME, + _NL_TIME_ERA_NUM_ENTRIES); + for (era_cnt = 0; era_cnt < (int) num_eras; + ++era_cnt, rp = rp_backup) + { + era = _nl_select_era_entry (era_cnt + HELPER_LOCALE_ARG); + if (era != NULL && match_string (era->era_name, rp)) + { + *decided = loc; + break; + } + } + if (era_cnt != (int) num_eras) + break; + + era_cnt = -1; + if (*decided == loc) + return NULL; + + *decided = raw; + } + /* The C locale has no era information, so use the + normal representation. */ + goto match_century; + case 'y': + if (*decided != raw) + { + get_number(0, 9999, 4); + tm->tm_year = val; + want_era = 1; + want_xday = 1; + want_century = 1; + + if (era_cnt >= 0) + { + assert (*decided == loc); + + era = _nl_select_era_entry (era_cnt HELPER_LOCALE_ARG); + bool match = false; + if (era != NULL) + { + int delta = ((tm->tm_year - era->offset) + * era->absolute_direction); + match = (delta >= 0 + && delta < (((int64_t) era->stop_date[0] + - (int64_t) era->start_date[0]) + * era->absolute_direction)); + } + if (! match) + return NULL; + + break; + } + + num_eras = _NL_CURRENT_WORD (LC_TIME, + _NL_TIME_ERA_NUM_ENTRIES); + for (era_cnt = 0; era_cnt < (int) num_eras; ++era_cnt) + { + era = _nl_select_era_entry (era_cnt + HELPER_LOCALE_ARG); + if (era != NULL) + { + int delta = ((tm->tm_year - era->offset) + * era->absolute_direction); + if (delta >= 0 + && delta < (((int64_t) era->stop_date[0] + - (int64_t) era->start_date[0]) + * era->absolute_direction)) + { + *decided = loc; + break; + } + } + } + if (era_cnt != (int) num_eras) + break; + + era_cnt = -1; + if (*decided == loc) + return NULL; + + *decided = raw; + } + + goto match_year_in_century; + case 'Y': + if (*decided != raw) + { + num_eras = _NL_CURRENT_WORD (LC_TIME, + _NL_TIME_ERA_NUM_ENTRIES); + for (era_cnt = 0; era_cnt < (int) num_eras; + ++era_cnt, rp = rp_backup) + { + era = _nl_select_era_entry (era_cnt HELPER_LOCALE_ARG); + if (era != NULL && recursive (era->era_format)) + break; + } + if (era_cnt == (int) num_eras) + { + era_cnt = -1; + if (*decided == loc) + return NULL; + else + rp = rp_backup; + } + else + { + *decided = loc; + era_cnt = -1; + break; + } + + *decided = raw; + } + get_number (0, 9999, 4); + tm->tm_year = val - 1900; + want_century = 0; + want_xday = 1; + break; + case 'x': + if (*decided != raw) + { + const char *fmt = _NL_CURRENT (LC_TIME, ERA_D_FMT); + + if (*fmt == '\0') + fmt = _NL_CURRENT (LC_TIME, D_FMT); + + if (!recursive (fmt)) + { + if (*decided == loc) + return NULL; + else + rp = rp_backup; + } + else + { + if (strcmp (fmt, HERE_D_FMT)) + *decided = loc; + break; + } + *decided = raw; + } + if (!recursive (HERE_D_FMT)) + return NULL; + break; + case 'X': + if (*decided != raw) + { + const char *fmt = _NL_CURRENT (LC_TIME, ERA_T_FMT); + + if (*fmt == '\0') + fmt = _NL_CURRENT (LC_TIME, T_FMT); + + if (!recursive (fmt)) + { + if (*decided == loc) + return NULL; + else + rp = rp_backup; + } + else + { + if (strcmp (fmt, HERE_T_FMT)) + *decided = loc; + break; + } + *decided = raw; + } + if (!recursive (HERE_T_FMT)) + return NULL; + break; + default: + return NULL; + } + break; +#else + /* We have no information about the era format. Just use + the normal format. */ + if (*fmt != 'c' && *fmt != 'C' && *fmt != 'y' && *fmt != 'Y' + && *fmt != 'x' && *fmt != 'X') + /* This is an illegal format. */ + return NULL; + + goto start_over; +#endif + case 'O': + switch (*fmt++) + { + case 'd': + case 'e': + /* Match day of month using alternate numeric symbols. */ + get_alt_number (1, 31, 2); + tm->tm_mday = val; + have_mday = 1; + want_xday = 1; + break; + case 'H': + /* Match hour in 24-hour clock using alternate numeric + symbols. */ + get_alt_number (0, 23, 2); + tm->tm_hour = val; + have_I = 0; + break; + case 'I': + /* Match hour in 12-hour clock using alternate numeric + symbols. */ + get_alt_number (1, 12, 2); + tm->tm_hour = val % 12; + have_I = 1; + break; + case 'm': + /* Match month using alternate numeric symbols. */ + get_alt_number (1, 12, 2); + tm->tm_mon = val - 1; + have_mon = 1; + want_xday = 1; + break; + case 'M': + /* Match minutes using alternate numeric symbols. */ + get_alt_number (0, 59, 2); + tm->tm_min = val; + break; + case 'q': + /* Match quarter using alternate numeric symbols. */ + get_alt_number (1, 4, 1); + tm->tm_mon = (val - 1) * 3; + tm->tm_mday = 1; + have_mon = 1; + have_mday = 1; + want_xday = 1; + break; + case 'S': + /* Match seconds using alternate numeric symbols. */ + get_alt_number (0, 61, 2); + tm->tm_sec = val; + break; + case 'U': + get_alt_number (0, 53, 2); + week_no = val; + have_uweek = 1; + break; + case 'W': + get_alt_number (0, 53, 2); + week_no = val; + have_wweek = 1; + break; + case 'V': + get_alt_number (0, 53, 2); + /* XXX This cannot determine any field in TM without + further information. */ + break; + case 'w': + /* Match number of weekday using alternate numeric symbols. */ + get_alt_number (0, 6, 1); + tm->tm_wday = val; + have_wday = 1; + break; + case 'y': + /* Match year within century using alternate numeric symbols. */ + get_alt_number (0, 99, 2); + tm->tm_year = val >= 69 ? val : val + 100; + want_xday = 1; + break; + default: + return NULL; + } + break; + default: + return NULL; + } + } + + if (have_I && is_pm) + tm->tm_hour += 12; + + if (century != -1) + { + if (want_century) + tm->tm_year = tm->tm_year % 100 + (century - 19) * 100; + else + /* Only the century, but not the year. Strange, but so be it. */ + tm->tm_year = (century - 19) * 100; + } + + if (era_cnt != -1) + { +#ifdef _NL_CURRENT + era = _nl_select_era_entry (era_cnt HELPER_LOCALE_ARG); + if (era == NULL) + return NULL; + if (want_era) + tm->tm_year = (era->start_date[0] + + ((tm->tm_year - era->offset) + * era->absolute_direction)); + else + /* Era start year assumed. */ + tm->tm_year = era->start_date[0]; +#endif + } + else + if (want_era) + { + /* No era found but we have seen an E modifier. Rectify some + values. */ + if (want_century && century == -1 && tm->tm_year < 69) + tm->tm_year += 100; + } + + if (want_xday && !have_wday) + { + if ( !(have_mon && have_mday) && have_yday) + { + /* We don't have tm_mon and/or tm_mday, compute them. */ + int t_mon = 0; + while (__mon_yday[__isleap(1900 + tm->tm_year)][t_mon] <= tm->tm_yday) + t_mon++; + if (!have_mon) + tm->tm_mon = t_mon - 1; + if (!have_mday) + tm->tm_mday = + (tm->tm_yday + - __mon_yday[__isleap(1900 + tm->tm_year)][t_mon - 1] + 1); + } + day_of_the_week (tm); + } + + if (want_xday && !have_yday) + day_of_the_year (tm); + + if ((have_uweek || have_wweek) && have_wday) + { + int save_wday = tm->tm_wday; + int save_mday = tm->tm_mday; + int save_mon = tm->tm_mon; + int w_offset = have_uweek ? 0 : 1; + + tm->tm_mday = 1; + tm->tm_mon = 0; + day_of_the_week (tm); + if (have_mday) + tm->tm_mday = save_mday; + if (have_mon) + tm->tm_mon = save_mon; + + if (!have_yday) + tm->tm_yday = ((7 - (tm->tm_wday - w_offset)) % 7 + + (week_no - 1) *7 + + save_wday - w_offset); + + if (!have_mday || !have_mon) + { + int t_mon = 0; + while (__mon_yday[__isleap(1900 + tm->tm_year)][t_mon] + <= tm->tm_yday) + t_mon++; + if (!have_mon) + tm->tm_mon = t_mon - 1; + if (!have_mday) + tm->tm_mday = + (tm->tm_yday + - __mon_yday[__isleap(1900 + tm->tm_year)][t_mon - 1] + 1); + } + + tm->tm_wday = save_wday; + } + + return (char *) rp; +} + + +char * +strptime (buf, format, tm LOCALE_PARAM) + const char *restrict buf; + const char *restrict format; + struct tm *restrict tm; + LOCALE_PARAM_DECL +{ + enum ptime_locale_status decided; + +#ifdef _NL_CURRENT + decided = not; +#else + decided = raw; +#endif + return __strptime_internal (buf, format, tm, &decided, -1 LOCALE_ARG); +} + +#ifdef _LIBC +weak_alias (__strptime_l, strptime_l) +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strtoimax.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strtoimax.c new file mode 100644 index 00000000..1bc62621 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strtoimax.c @@ -0,0 +1,70 @@ +/* Convert string representation of a number into an intmax_t value. + + Copyright (C) 1999, 2001-2004, 2006, 2009-2024 Free Software Foundation, + Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Paul Eggert. */ + +#include + +/* Verify interface. */ +#include + +#include + +#ifdef UNSIGNED +# ifndef HAVE_DECL_STRTOULL +"this configure-time declaration test was not run" +# endif +# if !HAVE_DECL_STRTOULL +unsigned long long int strtoull (char const *, char **, int); +# endif + +#else + +# ifndef HAVE_DECL_STRTOLL +"this configure-time declaration test was not run" +# endif +# if !HAVE_DECL_STRTOLL +long long int strtoll (char const *, char **, int); +# endif +#endif + +#ifdef UNSIGNED +# define Int uintmax_t +# define Strtoimax strtoumax +# define Strtol strtoul +# define Strtoll strtoull +# define Unsigned unsigned +#else +# define Int intmax_t +# define Strtoimax strtoimax +# define Strtol strtol +# define Strtoll strtoll +# define Unsigned +#endif + +Int +Strtoimax (char const *ptr, char **endptr, int base) +{ + static_assert (sizeof (Int) == sizeof (Unsigned long int) + || sizeof (Int) == sizeof (Unsigned long long int)); + + if (sizeof (Int) != sizeof (Unsigned long int)) + return Strtoll (ptr, endptr, base); + + return Strtol (ptr, endptr, base); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strtol.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strtol.c new file mode 100644 index 00000000..914cf5b5 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strtol.c @@ -0,0 +1,416 @@ +/* Convert string representation of a number into an integer value. + + Copyright (C) 1991-1992, 1994-1999, 2003, 2005-2007, 2009-2024 Free Software + Foundation, Inc. + + NOTE: The canonical source of this file is maintained with the GNU C + Library. Bugs can be reported to bug-glibc@gnu.org. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifdef _LIBC +# define USE_NUMBER_GROUPING +#else +# include +#endif + +#include +#include +#ifndef __set_errno +# define __set_errno(Val) errno = (Val) +#endif + +#include +#include +#include +#include + +#ifdef USE_NUMBER_GROUPING +# include "../locale/localeinfo.h" +#endif + +/* Nonzero if we are defining 'strtoul' or 'strtoull', operating on + unsigned integers. */ +#ifndef UNSIGNED +# define UNSIGNED 0 +# define INT LONG int +#else +# define INT unsigned LONG int +#endif + +/* Determine the name. */ +#ifdef USE_IN_EXTENDED_LOCALE_MODEL +# undef strtol +# if UNSIGNED +# ifdef USE_WIDE_CHAR +# ifdef QUAD +# define strtol __wcstoull_l +# else +# define strtol __wcstoul_l +# endif +# else +# ifdef QUAD +# define strtol __strtoull_l +# else +# define strtol __strtoul_l +# endif +# endif +# else +# ifdef USE_WIDE_CHAR +# ifdef QUAD +# define strtol __wcstoll_l +# else +# define strtol __wcstol_l +# endif +# else +# ifdef QUAD +# define strtol __strtoll_l +# else +# define strtol __strtol_l +# endif +# endif +# endif +#else +# if UNSIGNED +# undef strtol +# ifdef USE_WIDE_CHAR +# ifdef QUAD +# define strtol wcstoull +# else +# define strtol wcstoul +# endif +# else +# ifdef QUAD +# define strtol strtoull +# else +# define strtol strtoul +# endif +# endif +# else +# ifdef USE_WIDE_CHAR +# undef strtol +# ifdef QUAD +# define strtol wcstoll +# else +# define strtol wcstol +# endif +# else +# ifdef QUAD +# undef strtol +# define strtol strtoll +# endif +# endif +# endif +#endif + +/* If QUAD is defined, we are defining 'strtoll' or 'strtoull', + operating on 'long long int's. */ +#ifdef QUAD +# define LONG long long +# define STRTOL_LONG_MIN LLONG_MIN +# define STRTOL_LONG_MAX LLONG_MAX +# define STRTOL_ULONG_MAX ULLONG_MAX +# if __GNUC__ == 2 && __GNUC_MINOR__ < 7 + /* Work around gcc bug with using this constant. */ + static const unsigned long long int maxquad = ULLONG_MAX; +# undef STRTOL_ULONG_MAX +# define STRTOL_ULONG_MAX maxquad +# endif +#else +# define LONG long +# define STRTOL_LONG_MIN LONG_MIN +# define STRTOL_LONG_MAX LONG_MAX +# define STRTOL_ULONG_MAX ULONG_MAX +#endif + + +#ifdef USE_NUMBER_GROUPING +# define GROUP_PARAM_PROTO , int group +#else +# define GROUP_PARAM_PROTO +#endif + +/* We use this code also for the extended locale handling where the + function gets as an additional argument the locale which has to be + used. To access the values we have to redefine the _NL_CURRENT + macro. */ +#ifdef USE_IN_EXTENDED_LOCALE_MODEL +# undef _NL_CURRENT +# define _NL_CURRENT(category, item) \ + (current->values[_NL_ITEM_INDEX (item)].string) +# define LOCALE_PARAM , loc +# define LOCALE_PARAM_PROTO , __locale_t loc +#else +# define LOCALE_PARAM +# define LOCALE_PARAM_PROTO +#endif + +#ifdef USE_WIDE_CHAR +# include +# include +# define L_(Ch) L##Ch +# define UCHAR_TYPE wint_t +# define STRING_TYPE wchar_t +# ifdef USE_IN_EXTENDED_LOCALE_MODEL +# define ISSPACE(Ch) __iswspace_l ((Ch), loc) +# define ISALPHA(Ch) __iswalpha_l ((Ch), loc) +# define TOUPPER(Ch) __towupper_l ((Ch), loc) +# else +# define ISSPACE(Ch) iswspace (Ch) +# define ISALPHA(Ch) iswalpha (Ch) +# define TOUPPER(Ch) towupper (Ch) +# endif +#else +# define L_(Ch) Ch +# define UCHAR_TYPE unsigned char +# define STRING_TYPE char +# ifdef USE_IN_EXTENDED_LOCALE_MODEL +# define ISSPACE(Ch) __isspace_l ((unsigned char) (Ch), loc) +# define ISALPHA(Ch) __isalpha_l ((unsigned char) (Ch), loc) +# define TOUPPER(Ch) __toupper_l ((unsigned char) (Ch), loc) +# else +# define ISSPACE(Ch) isspace ((unsigned char) (Ch)) +# define ISALPHA(Ch) isalpha ((unsigned char) (Ch)) +# define TOUPPER(Ch) toupper ((unsigned char) (Ch)) +# endif +#endif + +#ifdef USE_NUMBER_GROUPING +# define INTERNAL(X) INTERNAL1(X) +# define INTERNAL1(X) __##X##_internal +# define WEAKNAME(X) WEAKNAME1(X) +#else +# define INTERNAL(X) X +#endif + +#ifdef USE_NUMBER_GROUPING +/* This file defines a function to check for correct grouping. */ +# include "grouping.h" +#endif + + + +/* Convert NPTR to an 'unsigned long int' or 'long int' in base BASE. + If BASE is 0 the base is determined by the presence of a leading + zero, indicating octal or a leading "0x" or "0X", indicating hexadecimal. + If BASE is < 2 or > 36, it is reset to 10. + If ENDPTR is not NULL, a pointer to the character after the last + one converted is stored in *ENDPTR. */ + +INT +INTERNAL (strtol) (const STRING_TYPE *nptr, STRING_TYPE **endptr, + int base GROUP_PARAM_PROTO LOCALE_PARAM_PROTO) +{ + int negative; + register unsigned LONG int cutoff; + register unsigned int cutlim; + register unsigned LONG int i; + register const STRING_TYPE *s; + register UCHAR_TYPE c; + const STRING_TYPE *save, *end; + int overflow; + +#ifdef USE_NUMBER_GROUPING +# ifdef USE_IN_EXTENDED_LOCALE_MODEL + struct locale_data *current = loc->__locales[LC_NUMERIC]; +# endif + /* The thousands character of the current locale. */ + wchar_t thousands = L'\0'; + /* The numeric grouping specification of the current locale, + in the format described in . */ + const char *grouping; + + if (group) + { + grouping = _NL_CURRENT (LC_NUMERIC, GROUPING); + if (*grouping <= 0 || *grouping == CHAR_MAX) + grouping = NULL; + else + { + /* Figure out the thousands separator character. */ +# if defined _LIBC || defined _HAVE_BTOWC + thousands = __btowc (*_NL_CURRENT (LC_NUMERIC, THOUSANDS_SEP)); + if (thousands == WEOF) + thousands = L'\0'; +# endif + if (thousands == L'\0') + grouping = NULL; + } + } + else + grouping = NULL; +#endif + + if (base < 0 || base == 1 || base > 36) + { + __set_errno (EINVAL); + return 0; + } + + save = s = nptr; + + /* Skip white space. */ + while (ISSPACE (*s)) + ++s; + if (*s == L_('\0')) + goto noconv; + + /* Check for a sign. */ + if (*s == L_('-')) + { + negative = 1; + ++s; + } + else if (*s == L_('+')) + { + negative = 0; + ++s; + } + else + negative = 0; + + /* Recognize number prefix and if BASE is zero, figure it out ourselves. */ + if (*s == L_('0')) + { + if ((base == 0 || base == 16) && TOUPPER (s[1]) == L_('X')) + { + s += 2; + base = 16; + } + else if ((base == 0 || base == 2) && TOUPPER (s[1]) == L_('B')) + { + s += 2; + base = 2; + } + else if (base == 0) + base = 8; + } + else if (base == 0) + base = 10; + + /* Save the pointer so we can check later if anything happened. */ + save = s; + +#ifdef USE_NUMBER_GROUPING + if (group) + { + /* Find the end of the digit string and check its grouping. */ + end = s; + for (c = *end; c != L_('\0'); c = *++end) + if ((wchar_t) c != thousands + && ((wchar_t) c < L_('0') || (wchar_t) c > L_('9')) + && (!ISALPHA (c) || (int) (TOUPPER (c) - L_('A') + 10) >= base)) + break; + if (*s == thousands) + end = s; + else + end = correctly_grouped_prefix (s, end, thousands, grouping); + } + else +#endif + end = NULL; + + cutoff = STRTOL_ULONG_MAX / (unsigned LONG int) base; + cutlim = STRTOL_ULONG_MAX % (unsigned LONG int) base; + + overflow = 0; + i = 0; + for (c = *s; c != L_('\0'); c = *++s) + { + if (s == end) + break; + if (c >= L_('0') && c <= L_('9')) + c -= L_('0'); + else if (ISALPHA (c)) + c = TOUPPER (c) - L_('A') + 10; + else + break; + if ((int) c >= base) + break; + /* Check for overflow. */ + if (i > cutoff || (i == cutoff && c > cutlim)) + overflow = 1; + else + { + i *= (unsigned LONG int) base; + i += c; + } + } + + /* Check if anything actually happened. */ + if (s == save) + goto noconv; + + /* Store in ENDPTR the address of one character + past the last character we converted. */ + if (endptr != NULL) + *endptr = (STRING_TYPE *) s; + +#if !UNSIGNED + /* Check for a value that is within the range of + 'unsigned LONG int', but outside the range of 'LONG int'. */ + if (overflow == 0 + && i > (negative + ? -((unsigned LONG int) (STRTOL_LONG_MIN + 1)) + 1 + : (unsigned LONG int) STRTOL_LONG_MAX)) + overflow = 1; +#endif + + if (overflow) + { + __set_errno (ERANGE); +#if UNSIGNED + return STRTOL_ULONG_MAX; +#else + return negative ? STRTOL_LONG_MIN : STRTOL_LONG_MAX; +#endif + } + + /* Return the result of the appropriate sign. */ + return negative ? -i : i; + +noconv: + /* We must handle a special case here: the base is 0 or 16 and the + first two characters are '0' and 'x', but the rest are no + hexadecimal digits. Likewise when the base is 0 or 2 and the + first two characters are '0' and 'b', but the rest are no binary + digits. This is no error case. We return 0 and ENDPTR points to + the 'x' or 'b'. */ + if (endptr != NULL) + { + if (save - nptr >= 2 + && (TOUPPER (save[-1]) == L_('X') || TOUPPER (save[-1]) == L_('B')) + && save[-2] == L_('0')) + *endptr = (STRING_TYPE *) &save[-1]; + else + /* There was no number to convert. */ + *endptr = (STRING_TYPE *) nptr; + } + + return 0L; +} + +#ifdef USE_NUMBER_GROUPING +/* External user entry point. */ + +INT +# ifdef weak_function +weak_function +# endif +strtol (const STRING_TYPE *nptr, STRING_TYPE **endptr, + int base LOCALE_PARAM_PROTO) +{ + return INTERNAL (strtol) (nptr, endptr, base, 0 LOCALE_PARAM); +} +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strtoll.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strtoll.c new file mode 100644 index 00000000..d3f5e47f --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/strtoll.c @@ -0,0 +1,33 @@ +/* Function to parse a 'long long int' from text. + Copyright (C) 1995-1997, 1999, 2001, 2009-2024 Free Software Foundation, + Inc. + This file is part of the GNU C Library. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#define QUAD 1 + +#include + +#ifdef _LIBC +# ifdef SHARED +# include + +# if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_2) +compat_symbol (libc, __strtoll_internal, __strtoq_internal, GLIBC_2_0); +# endif + +# endif +weak_alias (strtoll, strtoq) +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/sys_random.in.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/sys_random.in.h new file mode 100644 index 00000000..22f67b17 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/sys_random.in.h @@ -0,0 +1,105 @@ +/* Substitute for . + Copyright (C) 2020-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +# if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +# endif +@PRAGMA_COLUMNS@ + +#ifndef _@GUARD_PREFIX@_SYS_RANDOM_H + +#if @HAVE_SYS_RANDOM_H@ + +/* On uClibc < 1.0.35, assumes prior inclusion of . + Do not use __UCLIBC__ here, as it might not be defined yet. + But avoid namespace pollution on glibc systems. */ +# ifndef __GLIBC__ +# include +# endif +/* On Mac OS X 10.5, assumes prior inclusion of . + On Max OS X 10.13, assumes prior inclusion of a file that + includes , such as or . */ +# if defined __APPLE__ && defined __MACH__ /* Mac OS X */ +# include +# include +# endif + +/* The include_next requires a split double-inclusion guard. */ +# @INCLUDE_NEXT@ @NEXT_SYS_RANDOM_H@ + +#endif + +#ifndef _@GUARD_PREFIX@_SYS_RANDOM_H +#define _@GUARD_PREFIX@_SYS_RANDOM_H + +/* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +#include + +/* Define the GRND_* constants. */ +#ifndef GRND_NONBLOCK +# define GRND_NONBLOCK 1 +# define GRND_RANDOM 2 +#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. */ + + +/* Declare overridden functions. */ + + +#if @GNULIB_GETRANDOM@ +/* Fill a buffer with random bytes. */ +# if @REPLACE_GETRANDOM@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef getrandom +# define getrandom rpl_getrandom +# endif +_GL_FUNCDECL_RPL (getrandom, ssize_t, + (void *buffer, size_t length, unsigned int flags) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (getrandom, ssize_t, + (void *buffer, size_t length, unsigned int flags)); +# else +# if !@HAVE_GETRANDOM@ +_GL_FUNCDECL_SYS (getrandom, ssize_t, + (void *buffer, size_t length, unsigned int flags) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (getrandom, ssize_t, + (void *buffer, size_t length, unsigned int flags)); +# endif +# if __GLIBC__ + (__GLIBC_MINOR__ >= 25) > 2 +_GL_CXXALIASWARN (getrandom); +# endif +#elif defined GNULIB_POSIXCHECK +# undef getrandom +# if HAVE_RAW_DECL_GETRANDOM +_GL_WARN_ON_USE (getrandom, "getrandom is unportable - " + "use gnulib module getrandom for portability"); +# endif +#endif + + +#endif /* _@GUARD_PREFIX@_SYS_RANDOM_H */ +#endif /* _@GUARD_PREFIX@_SYS_RANDOM_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/sys_stat.in.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/sys_stat.in.h new file mode 100644 index 00000000..bf08f335 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/sys_stat.in.h @@ -0,0 +1,998 @@ +/* Provide a more complete sys/stat.h header file. + Copyright (C) 2005-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Eric Blake, Paul Eggert, and Jim Meyering. */ + +/* This file is supposed to be used on platforms where is + incomplete. It is intended to provide definitions and prototypes + needed by an application. Start with what the system provides. */ + +#if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +#endif +@PRAGMA_COLUMNS@ + +/* This file uses #include_next of a system file that defines time_t. + For the 'year2038' module to work right, needs to have been + included before. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +#if defined __need_system_sys_stat_h +/* Special invocation convention. */ + +#@INCLUDE_NEXT@ @NEXT_SYS_STAT_H@ + +#else +/* Normal invocation convention. */ + +#ifndef _@GUARD_PREFIX@_SYS_STAT_H + +/* Get nlink_t. + May also define off_t to a 64-bit type on native Windows. */ +#include + +/* Get struct timespec. */ +#include + +/* The include_next requires a split double-inclusion guard. */ +#@INCLUDE_NEXT@ @NEXT_SYS_STAT_H@ + +#ifndef _@GUARD_PREFIX@_SYS_STAT_H +#define _@GUARD_PREFIX@_SYS_STAT_H + +/* This file uses _GL_ATTRIBUTE_NOTHROW, GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + + +/* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions. + */ +#ifndef _GL_ATTRIBUTE_NOTHROW +# if defined __cplusplus +# if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major >= 4 +# if __cplusplus >= 201103L +# define _GL_ATTRIBUTE_NOTHROW noexcept (true) +# else +# define _GL_ATTRIBUTE_NOTHROW throw () +# endif +# else +# define _GL_ATTRIBUTE_NOTHROW +# endif +# else +# if (__GNUC__ + (__GNUC_MINOR__ >= 3) > 3) || defined __clang__ +# define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__)) +# else +# define _GL_ATTRIBUTE_NOTHROW +# endif +# endif +#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. */ + + +/* Before doing "#define mknod rpl_mknod" below, we need to include all + headers that may declare mknod(). OS/2 kLIBC declares mknod() in + , not in . */ +#ifdef __KLIBC__ +# include +#endif + +/* Before doing "#define mkdir rpl_mkdir" below, we need to include all + headers that may declare mkdir(). Native Windows platforms declare mkdir + in and/or , not in . */ +#if defined _WIN32 && ! defined __CYGWIN__ +# include /* mingw32, mingw64 */ +# include /* mingw64, MSVC 9 */ +#endif + +/* Native Windows platforms declare umask() in . */ +#if 0 && (defined _WIN32 && ! defined __CYGWIN__) +# include +#endif + +/* Large File Support on native Windows. */ +#if @WINDOWS_64_BIT_ST_SIZE@ +# define stat _stati64 +#endif + +/* Optionally, override 'struct stat' on native Windows. */ +#if @GNULIB_OVERRIDES_STRUCT_STAT@ + +# undef stat +# if @GNULIB_STAT@ +# define stat rpl_stat +# else + /* Provoke a clear link error if stat() is used as a function and + module 'stat' is not in use. */ +# define stat stat_used_without_requesting_gnulib_module_stat +# endif + +# if !GNULIB_defined_struct_stat +struct stat +{ + dev_t st_dev; + ino_t st_ino; + mode_t st_mode; + nlink_t st_nlink; +# if 0 + uid_t st_uid; +# else /* uid_t is not defined by default on native Windows. */ + short st_uid; +# endif +# if 0 + gid_t st_gid; +# else /* gid_t is not defined by default on native Windows. */ + short st_gid; +# endif + dev_t st_rdev; + off_t st_size; +# if 0 + blksize_t st_blksize; + blkcnt_t st_blocks; +# endif + +# if @WINDOWS_STAT_TIMESPEC@ + struct timespec st_atim; + struct timespec st_mtim; + struct timespec st_ctim; +# else + time_t st_atime; + time_t st_mtime; + time_t st_ctime; +# endif +}; +# if @WINDOWS_STAT_TIMESPEC@ +# define st_atime st_atim.tv_sec +# define st_mtime st_mtim.tv_sec +# define st_ctime st_ctim.tv_sec + /* Indicator, for gnulib internal purposes. */ +# define _GL_WINDOWS_STAT_TIMESPEC 1 +# endif +# define GNULIB_defined_struct_stat 1 +# endif + +/* Other possible values of st_mode. */ +# if 0 +# define _S_IFBLK 0x6000 +# endif +# if 0 +# define _S_IFLNK 0xA000 +# endif +# if 0 +# define _S_IFSOCK 0xC000 +# endif + +#endif + +#ifndef S_IFIFO +# ifdef _S_IFIFO +# define S_IFIFO _S_IFIFO +# endif +#endif + +#ifndef S_IFMT +# define S_IFMT 0170000 +#endif + +#if STAT_MACROS_BROKEN +# undef S_ISBLK +# undef S_ISCHR +# undef S_ISDIR +# undef S_ISFIFO +# undef S_ISLNK +# undef S_ISNAM +# undef S_ISMPB +# undef S_ISMPC +# undef S_ISNWK +# undef S_ISREG +# undef S_ISSOCK +#endif + +#ifndef S_ISBLK +# ifdef S_IFBLK +# define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) +# else +# define S_ISBLK(m) 0 +# endif +#endif + +#ifndef S_ISCHR +# ifdef S_IFCHR +# define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) +# else +# define S_ISCHR(m) 0 +# endif +#endif + +#ifndef S_ISDIR +# ifdef S_IFDIR +# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) +# else +# define S_ISDIR(m) 0 +# endif +#endif + +#ifndef S_ISDOOR /* Solaris 2.5 and up */ +# define S_ISDOOR(m) 0 +#endif + +#ifndef S_ISFIFO +# ifdef S_IFIFO +# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) +# else +# define S_ISFIFO(m) 0 +# endif +#endif + +#ifndef S_ISLNK +# ifdef S_IFLNK +# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) +# else +# define S_ISLNK(m) 0 +# endif +#endif + +#ifndef S_ISMPB /* V7 */ +# ifdef S_IFMPB +# define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB) +# define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC) +# else +# define S_ISMPB(m) 0 +# define S_ISMPC(m) 0 +# endif +#endif + +#ifndef S_ISMPX /* AIX */ +# define S_ISMPX(m) 0 +#endif + +#ifndef S_ISNAM /* Xenix */ +# ifdef S_IFNAM +# define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM) +# else +# define S_ISNAM(m) 0 +# endif +#endif + +#ifndef S_ISNWK /* HP/UX */ +# ifdef S_IFNWK +# define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK) +# else +# define S_ISNWK(m) 0 +# endif +#endif + +#ifndef S_ISPORT /* Solaris 10 and up */ +# define S_ISPORT(m) 0 +#endif + +#ifndef S_ISREG +# ifdef S_IFREG +# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) +# else +# define S_ISREG(m) 0 +# endif +#endif + +#ifndef S_ISSOCK +# ifdef S_IFSOCK +# define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) +# else +# define S_ISSOCK(m) 0 +# endif +#endif + + +#ifndef S_TYPEISMQ +# define S_TYPEISMQ(p) 0 +#endif + +#ifndef S_TYPEISTMO +# define S_TYPEISTMO(p) 0 +#endif + + +#ifndef S_TYPEISSEM +# ifdef S_INSEM +# define S_TYPEISSEM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSEM) +# else +# define S_TYPEISSEM(p) 0 +# endif +#endif + +#ifndef S_TYPEISSHM +# ifdef S_INSHD +# define S_TYPEISSHM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSHD) +# else +# define S_TYPEISSHM(p) 0 +# endif +#endif + +/* high performance ("contiguous data") */ +#ifndef S_ISCTG +# define S_ISCTG(p) 0 +#endif + +/* Cray DMF (data migration facility): off line, with data */ +#ifndef S_ISOFD +# define S_ISOFD(p) 0 +#endif + +/* Cray DMF (data migration facility): off line, with no data */ +#ifndef S_ISOFL +# define S_ISOFL(p) 0 +#endif + +/* 4.4BSD whiteout */ +#ifndef S_ISWHT +# define S_ISWHT(m) 0 +#endif + +/* If any of the following are undefined, + define them to their de facto standard values. */ +#if !S_ISUID +# define S_ISUID 04000 +#endif +#if !S_ISGID +# define S_ISGID 02000 +#endif + +/* S_ISVTX is a common extension to POSIX. */ +#ifndef S_ISVTX +# define S_ISVTX 01000 +#endif + +#if !S_IRUSR && S_IREAD +# define S_IRUSR S_IREAD +#endif +#if !S_IRUSR +# define S_IRUSR 00400 +#endif +#if !S_IRGRP +# define S_IRGRP (S_IRUSR >> 3) +#endif +#if !S_IROTH +# define S_IROTH (S_IRUSR >> 6) +#endif + +#if !S_IWUSR && S_IWRITE +# define S_IWUSR S_IWRITE +#endif +#if !S_IWUSR +# define S_IWUSR 00200 +#endif +#if !S_IWGRP +# define S_IWGRP (S_IWUSR >> 3) +#endif +#if !S_IWOTH +# define S_IWOTH (S_IWUSR >> 6) +#endif + +#if !S_IXUSR && S_IEXEC +# define S_IXUSR S_IEXEC +#endif +#if !S_IXUSR +# define S_IXUSR 00100 +#endif +#if !S_IXGRP +# define S_IXGRP (S_IXUSR >> 3) +#endif +#if !S_IXOTH +# define S_IXOTH (S_IXUSR >> 6) +#endif + +#if !S_IRWXU +# define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR) +#endif +#if !S_IRWXG +# define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP) +#endif +#if !S_IRWXO +# define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH) +#endif + +/* Although S_IXUGO and S_IRWXUGO are not specified by POSIX and are + not implemented in GNU/Linux, some Gnulib-using apps use the macros. */ +#if !S_IXUGO +# define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH) +#endif +#ifndef S_IRWXUGO +# define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO) +#endif + +/* Macros for futimens and utimensat. */ +#ifndef UTIME_NOW +# define UTIME_NOW (-1) +# define UTIME_OMIT (-2) +#endif + + +#if @GNULIB_CHMOD@ +# if @REPLACE_CHMOD@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef chmod +# define chmod rpl_chmod +# endif +_GL_FUNCDECL_RPL (chmod, int, (const char *filename, mode_t mode) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (chmod, int, (const char *filename, mode_t mode)); +# elif defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef chmod +# define chmod _chmod +# endif +/* Need to cast, because in mingw the last argument is 'int mode'. */ +_GL_CXXALIAS_MDA_CAST (chmod, int, (const char *filename, mode_t mode)); +# else +_GL_CXXALIAS_SYS (chmod, int, (const char *filename, mode_t mode)); +# endif +_GL_CXXALIASWARN (chmod); +#elif defined GNULIB_POSIXCHECK +# undef chmod +# if HAVE_RAW_DECL_CHMOD +_GL_WARN_ON_USE (chmod, "chmod has portability problems - " + "use gnulib module chmod for portability"); +# endif +#elif @GNULIB_MDA_CHMOD@ +/* On native Windows, map 'chmod' to '_chmod', so that -loldnames is not + required. In C++ with GNULIB_NAMESPACE, avoid differences between + platforms by defining GNULIB_NAMESPACE::chmod always. */ +# if defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef chmod +# define chmod _chmod +# endif +/* Need to cast, because in mingw the last argument is 'int mode'. */ +_GL_CXXALIAS_MDA_CAST (chmod, int, (const char *filename, mode_t mode)); +# else +_GL_CXXALIAS_SYS (chmod, int, (const char *filename, mode_t mode)); +# endif +_GL_CXXALIASWARN (chmod); +#endif + + +#if @GNULIB_FCHMODAT@ +# if @REPLACE_FCHMODAT@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef fchmodat +# define fchmodat rpl_fchmodat +# endif +_GL_FUNCDECL_RPL (fchmodat, int, + (int fd, char const *file, mode_t mode, int flag) + _GL_ARG_NONNULL ((2))); +_GL_CXXALIAS_RPL (fchmodat, int, + (int fd, char const *file, mode_t mode, int flag)); +# else +# if !@HAVE_FCHMODAT@ +_GL_FUNCDECL_SYS (fchmodat, int, + (int fd, char const *file, mode_t mode, int flag) + _GL_ARG_NONNULL ((2))); +# endif +_GL_CXXALIAS_SYS (fchmodat, int, + (int fd, char const *file, mode_t mode, int flag)); +# endif +_GL_CXXALIASWARN (fchmodat); +#elif defined GNULIB_POSIXCHECK +# undef fchmodat +# if HAVE_RAW_DECL_FCHMODAT +_GL_WARN_ON_USE (fchmodat, "fchmodat is not portable - " + "use gnulib module openat for portability"); +# endif +#endif + + +#if @GNULIB_FSTAT@ +# if @REPLACE_FSTAT@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef fstat +# define fstat rpl_fstat +# endif +_GL_FUNCDECL_RPL (fstat, int, (int fd, struct stat *buf) _GL_ARG_NONNULL ((2))); +_GL_CXXALIAS_RPL (fstat, int, (int fd, struct stat *buf)); +# else +_GL_CXXALIAS_SYS (fstat, int, (int fd, struct stat *buf)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (fstat); +# endif +#elif @GNULIB_OVERRIDES_STRUCT_STAT@ +# undef fstat +# define fstat fstat_used_without_requesting_gnulib_module_fstat +#elif @WINDOWS_64_BIT_ST_SIZE@ +/* Above, we define stat to _stati64. */ +# define fstat _fstati64 +#elif defined GNULIB_POSIXCHECK +# undef fstat +# if HAVE_RAW_DECL_FSTAT +_GL_WARN_ON_USE (fstat, "fstat has portability problems - " + "use gnulib module fstat for portability"); +# endif +#endif + + +#if @GNULIB_FSTATAT@ +# if @REPLACE_FSTATAT@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef fstatat +# define fstatat rpl_fstatat +# endif +_GL_FUNCDECL_RPL (fstatat, int, + (int fd, char const *restrict name, struct stat *restrict st, + int flags) + _GL_ARG_NONNULL ((2, 3))); +_GL_CXXALIAS_RPL (fstatat, int, + (int fd, char const *restrict name, struct stat *restrict st, + int flags)); +# else +# if !@HAVE_FSTATAT@ +_GL_FUNCDECL_SYS (fstatat, int, + (int fd, char const *restrict name, struct stat *restrict st, + int flags) + _GL_ARG_NONNULL ((2, 3))); +# endif +_GL_CXXALIAS_SYS (fstatat, int, + (int fd, char const *restrict name, struct stat *restrict st, + int flags)); +# endif +_GL_CXXALIASWARN (fstatat); +#elif @GNULIB_OVERRIDES_STRUCT_STAT@ +# undef fstatat +# define fstatat fstatat_used_without_requesting_gnulib_module_fstatat +#elif defined GNULIB_POSIXCHECK +# undef fstatat +# if HAVE_RAW_DECL_FSTATAT +_GL_WARN_ON_USE (fstatat, "fstatat is not portable - " + "use gnulib module openat for portability"); +# endif +#endif + + +#if @GNULIB_FUTIMENS@ +/* Use the rpl_ prefix also on Solaris <= 9, because on Solaris 9 our futimens + implementation relies on futimesat, which on Solaris 10 makes an invocation + to futimens that is meant to invoke the libc's futimens(), not gnulib's + futimens(). */ +# if @REPLACE_FUTIMENS@ || (!@HAVE_FUTIMENS@ && defined __sun) +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef futimens +# define futimens rpl_futimens +# endif +_GL_FUNCDECL_RPL (futimens, int, (int fd, struct timespec const times[2])); +_GL_CXXALIAS_RPL (futimens, int, (int fd, struct timespec const times[2])); +# else +# if !@HAVE_FUTIMENS@ +_GL_FUNCDECL_SYS (futimens, int, (int fd, struct timespec const times[2])); +# endif +_GL_CXXALIAS_SYS (futimens, int, (int fd, struct timespec const times[2])); +# endif +# if __GLIBC__ >= 2 && @HAVE_FUTIMENS@ +_GL_CXXALIASWARN (futimens); +# endif +#elif defined GNULIB_POSIXCHECK +# undef futimens +# if HAVE_RAW_DECL_FUTIMENS +_GL_WARN_ON_USE (futimens, "futimens is not portable - " + "use gnulib module futimens for portability"); +# endif +#endif + + +#if @GNULIB_GETUMASK@ +# if !@HAVE_GETUMASK@ +# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 +_GL_FUNCDECL_SYS (getumask, mode_t, (void) _GL_ATTRIBUTE_NOTHROW); +# else +_GL_FUNCDECL_SYS (getumask, mode_t, (void)); +# endif +# endif +_GL_CXXALIAS_SYS (getumask, mode_t, (void)); +# if @HAVE_GETUMASK@ +_GL_CXXALIASWARN (getumask); +# endif +#elif defined GNULIB_POSIXCHECK +# undef getumask +# if HAVE_RAW_DECL_GETUMASK +_GL_WARN_ON_USE (getumask, "getumask is not portable - " + "use gnulib module getumask for portability"); +# endif +#endif + + +#if @GNULIB_LCHMOD@ +/* Change the mode of FILENAME to MODE, without dereferencing it if FILENAME + denotes a symbolic link. */ +# if !@HAVE_LCHMOD@ || defined __hpux +_GL_FUNCDECL_SYS (lchmod, int, (const char *filename, mode_t mode) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (lchmod, int, (const char *filename, mode_t mode)); +_GL_CXXALIASWARN (lchmod); +#elif defined GNULIB_POSIXCHECK +# undef lchmod +# if HAVE_RAW_DECL_LCHMOD +_GL_WARN_ON_USE (lchmod, "lchmod is unportable - " + "use gnulib module lchmod for portability"); +# endif +#endif + + +#if @GNULIB_MKDIR@ +# if @REPLACE_MKDIR@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef mkdir +# define mkdir rpl_mkdir +# endif +_GL_FUNCDECL_RPL (mkdir, int, (char const *name, mode_t mode) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode)); +# elif defined _WIN32 && !defined __CYGWIN__ +/* mingw's _mkdir() function has 1 argument, but we pass 2 arguments. + Additionally, it declares _mkdir (and depending on compile flags, an + alias mkdir), only in the nonstandard includes and , + which are included above. */ +# if !GNULIB_defined_rpl_mkdir +static int +rpl_mkdir (char const *name, mode_t mode) +{ + return _mkdir (name); +} +# define GNULIB_defined_rpl_mkdir 1 +# endif +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef mkdir +# define mkdir rpl_mkdir +# endif +_GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode)); +# else +_GL_CXXALIAS_SYS (mkdir, int, (char const *name, mode_t mode)); +# endif +_GL_CXXALIASWARN (mkdir); +#elif defined GNULIB_POSIXCHECK +# undef mkdir +# if HAVE_RAW_DECL_MKDIR +_GL_WARN_ON_USE (mkdir, "mkdir does not always support two parameters - " + "use gnulib module mkdir for portability"); +# endif +#elif @GNULIB_MDA_MKDIR@ +/* On native Windows, map 'mkdir' to '_mkdir', so that -loldnames is not + required. In C++ with GNULIB_NAMESPACE, avoid differences between + platforms by defining GNULIB_NAMESPACE::mkdir always. */ +# if defined _WIN32 && !defined __CYGWIN__ +# if !GNULIB_defined_rpl_mkdir +static int +rpl_mkdir (char const *name, mode_t mode) +{ + return _mkdir (name); +} +# define GNULIB_defined_rpl_mkdir 1 +# endif +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef mkdir +# define mkdir rpl_mkdir +# endif +_GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode)); +# else +_GL_CXXALIAS_SYS (mkdir, int, (char const *name, mode_t mode)); +# endif +_GL_CXXALIASWARN (mkdir); +#endif + + +#if @GNULIB_MKDIRAT@ +# if !@HAVE_MKDIRAT@ +_GL_FUNCDECL_SYS (mkdirat, int, (int fd, char const *file, mode_t mode) + _GL_ARG_NONNULL ((2))); +# endif +_GL_CXXALIAS_SYS (mkdirat, int, (int fd, char const *file, mode_t mode)); +_GL_CXXALIASWARN (mkdirat); +#elif defined GNULIB_POSIXCHECK +# undef mkdirat +# if HAVE_RAW_DECL_MKDIRAT +_GL_WARN_ON_USE (mkdirat, "mkdirat is not portable - " + "use gnulib module openat for portability"); +# endif +#endif + + +#if @GNULIB_MKFIFO@ +# if @REPLACE_MKFIFO@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef mkfifo +# define mkfifo rpl_mkfifo +# endif +_GL_FUNCDECL_RPL (mkfifo, int, (char const *file, mode_t mode) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (mkfifo, int, (char const *file, mode_t mode)); +# else +# if !@HAVE_MKFIFO@ +_GL_FUNCDECL_SYS (mkfifo, int, (char const *file, mode_t mode) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (mkfifo, int, (char const *file, mode_t mode)); +# endif +_GL_CXXALIASWARN (mkfifo); +#elif defined GNULIB_POSIXCHECK +# undef mkfifo +# if HAVE_RAW_DECL_MKFIFO +_GL_WARN_ON_USE (mkfifo, "mkfifo is not portable - " + "use gnulib module mkfifo for portability"); +# endif +#endif + + +#if @GNULIB_MKFIFOAT@ +# if @REPLACE_MKFIFOAT@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef mkfifoat +# define mkfifoat rpl_mkfifoat +# endif +_GL_FUNCDECL_RPL (mkfifoat, int, (int fd, char const *file, mode_t mode) + _GL_ARG_NONNULL ((2))); +_GL_CXXALIAS_RPL (mkfifoat, int, (int fd, char const *file, mode_t mode)); +# else +# if !@HAVE_MKFIFOAT@ +_GL_FUNCDECL_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode) + _GL_ARG_NONNULL ((2))); +# endif +_GL_CXXALIAS_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (mkfifoat); +# endif +#elif defined GNULIB_POSIXCHECK +# undef mkfifoat +# if HAVE_RAW_DECL_MKFIFOAT +_GL_WARN_ON_USE (mkfifoat, "mkfifoat is not portable - " + "use gnulib module mkfifoat for portability"); +# endif +#endif + + +#if @GNULIB_MKNOD@ +# if @REPLACE_MKNOD@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef mknod +# define mknod rpl_mknod +# endif +_GL_FUNCDECL_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev)); +# else +# if !@HAVE_MKNOD@ +_GL_FUNCDECL_SYS (mknod, int, (char const *file, mode_t mode, dev_t dev) + _GL_ARG_NONNULL ((1))); +# endif +/* Need to cast, because on OSF/1 5.1, the third parameter is '...'. */ +_GL_CXXALIAS_SYS_CAST (mknod, int, (char const *file, mode_t mode, dev_t dev)); +# endif +_GL_CXXALIASWARN (mknod); +#elif defined GNULIB_POSIXCHECK +# undef mknod +# if HAVE_RAW_DECL_MKNOD +_GL_WARN_ON_USE (mknod, "mknod is not portable - " + "use gnulib module mknod for portability"); +# endif +#endif + + +#if @GNULIB_MKNODAT@ +# if @REPLACE_MKNODAT@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef mknodat +# define mknodat rpl_mknodat +# endif +_GL_FUNCDECL_RPL (mknodat, int, + (int fd, char const *file, mode_t mode, dev_t dev) + _GL_ARG_NONNULL ((2))); +_GL_CXXALIAS_RPL (mknodat, int, + (int fd, char const *file, mode_t mode, dev_t dev)); +# else +# if !@HAVE_MKNODAT@ +_GL_FUNCDECL_SYS (mknodat, int, + (int fd, char const *file, mode_t mode, dev_t dev) + _GL_ARG_NONNULL ((2))); +# endif +_GL_CXXALIAS_SYS (mknodat, int, + (int fd, char const *file, mode_t mode, dev_t dev)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (mknodat); +# endif +#elif defined GNULIB_POSIXCHECK +# undef mknodat +# if HAVE_RAW_DECL_MKNODAT +_GL_WARN_ON_USE (mknodat, "mknodat is not portable - " + "use gnulib module mkfifoat for portability"); +# endif +#endif + + +#if @GNULIB_STAT@ +# if @REPLACE_STAT@ +# if !@GNULIB_OVERRIDES_STRUCT_STAT@ + /* We can't use the object-like #define stat rpl_stat, because of + struct stat. This means that rpl_stat will not be used if the user + does (stat)(a,b). Oh well. */ +# if defined _AIX && defined stat && defined _LARGE_FILES + /* With _LARGE_FILES defined, AIX (only) defines stat to stat64, + so we have to replace stat64() instead of stat(). */ +# undef stat64 +# define stat64(name, st) rpl_stat (name, st) +# elif @WINDOWS_64_BIT_ST_SIZE@ + /* Above, we define stat to _stati64. */ +# if defined __MINGW32__ && defined _stati64 +# ifndef _USE_32BIT_TIME_T + /* The system headers define _stati64 to _stat64. */ +# undef _stat64 +# define _stat64(name, st) rpl_stat (name, st) +# endif +# elif defined _MSC_VER && defined _stati64 +# ifdef _USE_32BIT_TIME_T + /* The system headers define _stati64 to _stat32i64. */ +# undef _stat32i64 +# define _stat32i64(name, st) rpl_stat (name, st) +# else + /* The system headers define _stati64 to _stat64. */ +# undef _stat64 +# define _stat64(name, st) rpl_stat (name, st) +# endif +# else +# undef _stati64 +# define _stati64(name, st) rpl_stat (name, st) +# endif +# elif defined __MINGW32__ && defined stat +# ifdef _USE_32BIT_TIME_T + /* The system headers define stat to _stat32i64. */ +# undef _stat32i64 +# define _stat32i64(name, st) rpl_stat (name, st) +# else + /* The system headers define stat to _stat64. */ +# undef _stat64 +# define _stat64(name, st) rpl_stat (name, st) +# endif +# elif defined _MSC_VER && defined stat +# ifdef _USE_32BIT_TIME_T + /* The system headers define stat to _stat32. */ +# undef _stat32 +# define _stat32(name, st) rpl_stat (name, st) +# else + /* The system headers define stat to _stat64i32. */ +# undef _stat64i32 +# define _stat64i32(name, st) rpl_stat (name, st) +# endif +# else /* !(_AIX || __MINGW32__ || _MSC_VER) */ +# undef stat +# define stat(name, st) rpl_stat (name, st) +# endif /* !_LARGE_FILES */ +# endif /* !@GNULIB_OVERRIDES_STRUCT_STAT@ */ +_GL_EXTERN_C int stat (const char *restrict name, struct stat *restrict buf) + _GL_ARG_NONNULL ((1, 2)); +# endif +#elif @GNULIB_OVERRIDES_STRUCT_STAT@ +/* see above: + #define stat stat_used_without_requesting_gnulib_module_stat + */ +#elif defined GNULIB_POSIXCHECK +# undef stat +# if HAVE_RAW_DECL_STAT +_GL_WARN_ON_USE (stat, "stat is unportable - " + "use gnulib module stat for portability"); +# endif +#endif + + +#if @GNULIB_LSTAT@ +# if ! @HAVE_LSTAT@ +/* mingw does not support symlinks, therefore it does not have lstat. But + without links, stat does just fine. */ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define lstat stat +# endif +_GL_CXXALIAS_RPL_1 (lstat, stat, int, + (const char *restrict name, struct stat *restrict buf)); +# elif @REPLACE_LSTAT@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef lstat +# define lstat rpl_lstat +# endif +_GL_FUNCDECL_RPL (lstat, int, + (const char *restrict name, struct stat *restrict buf) + _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (lstat, int, + (const char *restrict name, struct stat *restrict buf)); +# else +_GL_CXXALIAS_SYS (lstat, int, + (const char *restrict name, struct stat *restrict buf)); +# endif +# if @HAVE_LSTAT@ +_GL_CXXALIASWARN (lstat); +# endif +#elif @GNULIB_OVERRIDES_STRUCT_STAT@ +# undef lstat +# define lstat lstat_used_without_requesting_gnulib_module_lstat +#elif defined GNULIB_POSIXCHECK +# undef lstat +# if HAVE_RAW_DECL_LSTAT +_GL_WARN_ON_USE (lstat, "lstat is unportable - " + "use gnulib module lstat for portability"); +# endif +#endif + + +#if @GNULIB_MDA_UMASK@ +/* On native Windows, map 'umask' to '_umask', so that -loldnames is not + required. In C++ with GNULIB_NAMESPACE, avoid differences between + platforms by defining GNULIB_NAMESPACE::umask always. */ +# if defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef umask +# define umask _umask +# endif +/* Need to cast, because in mingw the last argument is 'int mode'. */ +_GL_CXXALIAS_MDA_CAST (umask, mode_t, (mode_t mask)); +# else +_GL_CXXALIAS_SYS (umask, mode_t, (mode_t mask)); +# endif +_GL_CXXALIASWARN (umask); +#endif + + +#if @GNULIB_UTIMENSAT@ +/* Use the rpl_ prefix also on Solaris <= 9, because on Solaris 9 our utimensat + implementation relies on futimesat, which on Solaris 10 makes an invocation + to utimensat that is meant to invoke the libc's utimensat(), not gnulib's + utimensat(). */ +# if @REPLACE_UTIMENSAT@ || (!@HAVE_UTIMENSAT@ && defined __sun) +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef utimensat +# define utimensat rpl_utimensat +# endif +_GL_FUNCDECL_RPL (utimensat, int, (int fd, char const *name, + struct timespec const times[2], int flag) + _GL_ARG_NONNULL ((2))); +_GL_CXXALIAS_RPL (utimensat, int, (int fd, char const *name, + struct timespec const times[2], int flag)); +# else +# if !@HAVE_UTIMENSAT@ +_GL_FUNCDECL_SYS (utimensat, int, (int fd, char const *name, + struct timespec const times[2], int flag) + _GL_ARG_NONNULL ((2))); +# endif +_GL_CXXALIAS_SYS (utimensat, int, (int fd, char const *name, + struct timespec const times[2], int flag)); +# endif +# if __GLIBC__ >= 2 && @HAVE_UTIMENSAT@ +_GL_CXXALIASWARN (utimensat); +# endif +#elif defined GNULIB_POSIXCHECK +# undef utimensat +# if HAVE_RAW_DECL_UTIMENSAT +_GL_WARN_ON_USE (utimensat, "utimensat is not portable - " + "use gnulib module utimensat for portability"); +# endif +#endif + + +#endif /* _@GUARD_PREFIX@_SYS_STAT_H */ +#endif /* _@GUARD_PREFIX@_SYS_STAT_H */ +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/sys_time.in.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/sys_time.in.h new file mode 100644 index 00000000..4a301c48 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/sys_time.in.h @@ -0,0 +1,236 @@ +/* Provide a more complete sys/time.h. + + Copyright (C) 2007-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Paul Eggert. */ + +#ifndef _@GUARD_PREFIX@_SYS_TIME_H + +#if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +#endif +@PRAGMA_COLUMNS@ + +/* This file uses #include_next of a system file that defines time_t. + For the 'year2038' module to work right, needs to have been + included before. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +/* On Cygwin and on many BSDish systems, includes itself + recursively via . + Simply delegate to the system's header in this case; it is a no-op. + Without this extra ifdef, the C++ gettimeofday declaration below + would be a forward declaration in gnulib's nested . */ +#if defined _CYGWIN_SYS_TIME_H || defined _SYS_TIME_H || defined _SYS_TIME_H_ +# @INCLUDE_NEXT@ @NEXT_SYS_TIME_H@ +#else + +/* The include_next requires a split double-inclusion guard. */ +#if @HAVE_SYS_TIME_H@ +# @INCLUDE_NEXT@ @NEXT_SYS_TIME_H@ +#endif + +#ifndef _@GUARD_PREFIX@_SYS_TIME_H +#define _@GUARD_PREFIX@_SYS_TIME_H + +/* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +#if ! @HAVE_SYS_TIME_H@ +# include +#endif + +/* On native Windows with MSVC, get the 'struct timeval' type. + Also, on native Windows with a 64-bit time_t, where we are overriding the + 'struct timeval' type, get all declarations of system functions whose + signature contains 'struct timeval'. */ +#if (defined _MSC_VER || @REPLACE_STRUCT_TIMEVAL@) && @HAVE_WINSOCK2_H@ && !defined _GL_INCLUDING_WINSOCK2_H +# define _GL_INCLUDING_WINSOCK2_H +# include +# undef _GL_INCLUDING_WINSOCK2_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. */ + +#ifdef __cplusplus +extern "C" { +#endif + +#if !@HAVE_STRUCT_TIMEVAL@ || @REPLACE_STRUCT_TIMEVAL@ + +# if @REPLACE_STRUCT_TIMEVAL@ +# define timeval rpl_timeval +# endif + +# if !GNULIB_defined_struct_timeval +struct timeval +{ + time_t tv_sec; + long int tv_usec; +}; +# define GNULIB_defined_struct_timeval 1 +# endif + +#endif + +#ifdef __cplusplus +} +#endif + +#if @GNULIB_GETTIMEOFDAY@ +# if @REPLACE_GETTIMEOFDAY@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef gettimeofday +# define gettimeofday rpl_gettimeofday +# endif +_GL_FUNCDECL_RPL (gettimeofday, int, + (struct timeval *restrict, void *restrict) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (gettimeofday, int, + (struct timeval *restrict, void *restrict)); +# else +# if !@HAVE_GETTIMEOFDAY@ +_GL_FUNCDECL_SYS (gettimeofday, int, + (struct timeval *restrict, void *restrict) + _GL_ARG_NONNULL ((1))); +# endif +/* Need to cast, because on glibc systems, by default, the second argument is + struct timezone *. */ +_GL_CXXALIAS_SYS_CAST (gettimeofday, int, + (struct timeval *restrict, void *restrict)); +# endif +_GL_CXXALIASWARN (gettimeofday); +# if defined __cplusplus && defined GNULIB_NAMESPACE +namespace GNULIB_NAMESPACE { + typedef ::timeval +# undef timeval + timeval; +# if @REPLACE_STRUCT_TIMEVAL@ +# define timeval rpl_timeval + typedef ::timeval timeval; +# endif +} +# endif +#elif defined GNULIB_POSIXCHECK +# undef gettimeofday +# if HAVE_RAW_DECL_GETTIMEOFDAY +_GL_WARN_ON_USE (gettimeofday, "gettimeofday is unportable - " + "use gnulib module gettimeofday for portability"); +# endif +#endif + +/* Hide some function declarations from . */ + +#if defined _MSC_VER && @HAVE_WINSOCK2_H@ +# if !defined _@GUARD_PREFIX@_UNISTD_H +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef close +# define close close_used_without_including_unistd_h +# elif !defined __clang__ + _GL_WARN_ON_USE (close, + "close() used without including "); +# endif +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef gethostname +# define gethostname gethostname_used_without_including_unistd_h +# else + _GL_WARN_ON_USE (gethostname, + "gethostname() used without including "); +# endif +# endif +# if !defined _@GUARD_PREFIX@_SYS_SOCKET_H +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef socket +# define socket socket_used_without_including_sys_socket_h +# undef connect +# define connect connect_used_without_including_sys_socket_h +# undef accept +# define accept accept_used_without_including_sys_socket_h +# undef bind +# define bind bind_used_without_including_sys_socket_h +# undef getpeername +# define getpeername getpeername_used_without_including_sys_socket_h +# undef getsockname +# define getsockname getsockname_used_without_including_sys_socket_h +# undef getsockopt +# define getsockopt getsockopt_used_without_including_sys_socket_h +# undef listen +# define listen listen_used_without_including_sys_socket_h +# undef recv +# define recv recv_used_without_including_sys_socket_h +# undef send +# define send send_used_without_including_sys_socket_h +# undef recvfrom +# define recvfrom recvfrom_used_without_including_sys_socket_h +# undef sendto +# define sendto sendto_used_without_including_sys_socket_h +# undef setsockopt +# define setsockopt setsockopt_used_without_including_sys_socket_h +# undef shutdown +# define shutdown shutdown_used_without_including_sys_socket_h +# else + _GL_WARN_ON_USE (socket, + "socket() used without including "); + _GL_WARN_ON_USE (connect, + "connect() used without including "); + _GL_WARN_ON_USE (accept, + "accept() used without including "); + _GL_WARN_ON_USE (bind, + "bind() used without including "); + _GL_WARN_ON_USE (getpeername, + "getpeername() used without including "); + _GL_WARN_ON_USE (getsockname, + "getsockname() used without including "); + _GL_WARN_ON_USE (getsockopt, + "getsockopt() used without including "); + _GL_WARN_ON_USE (listen, + "listen() used without including "); + _GL_WARN_ON_USE (recv, + "recv() used without including "); + _GL_WARN_ON_USE (send, + "send() used without including "); + _GL_WARN_ON_USE (recvfrom, + "recvfrom() used without including "); + _GL_WARN_ON_USE (sendto, + "sendto() used without including "); + _GL_WARN_ON_USE (setsockopt, + "setsockopt() used without including "); + _GL_WARN_ON_USE (shutdown, + "shutdown() used without including "); +# endif +# endif +# if !defined _@GUARD_PREFIX@_SYS_SELECT_H +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef select +# define select select_used_without_including_sys_select_h +# else + _GL_WARN_ON_USE (select, + "select() used without including "); +# endif +# endif +#endif + +#endif /* _@GUARD_PREFIX@_SYS_TIME_H */ +#endif /* _CYGWIN_SYS_TIME_H */ +#endif /* _@GUARD_PREFIX@_SYS_TIME_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/sys_types.in.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/sys_types.in.h new file mode 100644 index 00000000..0a0ccc3c --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/sys_types.in.h @@ -0,0 +1,113 @@ +/* Provide a more complete sys/types.h. + + Copyright (C) 2011-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +#endif +@PRAGMA_COLUMNS@ + +/* This file uses #include_next of a system file that defines time_t. + For the 'year2038' module to work right, needs to have been + included before. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +#if defined _WIN32 && !defined __CYGWIN__ \ + && (defined __need_off_t || defined __need___off64_t \ + || defined __need_ssize_t || defined __need_time_t) + +/* Special invocation convention inside mingw header files. */ + +#@INCLUDE_NEXT@ @NEXT_SYS_TYPES_H@ + +#else +/* Normal invocation convention. */ + +#ifndef _@GUARD_PREFIX@_SYS_TYPES_H + +/* The include_next requires a split double-inclusion guard. */ +# define _GL_INCLUDING_SYS_TYPES_H +#@INCLUDE_NEXT@ @NEXT_SYS_TYPES_H@ +# undef _GL_INCLUDING_SYS_TYPES_H + +#ifndef _@GUARD_PREFIX@_SYS_TYPES_H +#define _@GUARD_PREFIX@_SYS_TYPES_H + +/* Override off_t if Large File Support is requested on native Windows. */ +#if @WINDOWS_64_BIT_OFF_T@ +/* Same as int64_t in . */ +# if defined _MSC_VER +# define off_t __int64 +# else +# define off_t long long int +# endif +/* Indicator, for gnulib internal purposes. */ +# define _GL_WINDOWS_64_BIT_OFF_T 1 +#endif + +/* Override dev_t and ino_t if distinguishable inodes support is requested + on native Windows. */ +#if @WINDOWS_STAT_INODES@ + +# if @WINDOWS_STAT_INODES@ == 2 +/* Experimental, not useful in Windows 10. */ + +/* Define dev_t to a 64-bit type. */ +# if !defined GNULIB_defined_dev_t +typedef unsigned long long int rpl_dev_t; +# undef dev_t +# define dev_t rpl_dev_t +# define GNULIB_defined_dev_t 1 +# endif + +/* Define ino_t to a 128-bit type. */ +# if !defined GNULIB_defined_ino_t +/* MSVC does not have a 128-bit integer type. + GCC has a 128-bit integer type __int128, but only on 64-bit targets. */ +typedef struct { unsigned long long int _gl_ino[2]; } rpl_ino_t; +# undef ino_t +# define ino_t rpl_ino_t +# define GNULIB_defined_ino_t 1 +# endif + +# else /* @WINDOWS_STAT_INODES@ == 1 */ + +/* Define ino_t to a 64-bit type. */ +# if !defined GNULIB_defined_ino_t +typedef unsigned long long int rpl_ino_t; +# undef ino_t +# define ino_t rpl_ino_t +# define GNULIB_defined_ino_t 1 +# endif + +# endif + +/* Indicator, for gnulib internal purposes. */ +# define _GL_WINDOWS_STAT_INODES @WINDOWS_STAT_INODES@ + +#endif + +/* MSVC 9 defines size_t in , not in . */ +/* But avoid namespace pollution on glibc systems. */ +#if (defined _WIN32 && ! defined __CYGWIN__) && ! defined __GLIBC__ +# include +#endif + +#endif /* _@GUARD_PREFIX@_SYS_TYPES_H */ +#endif /* _@GUARD_PREFIX@_SYS_TYPES_H */ +#endif /* __need_XXX */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/sys_wait.in.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/sys_wait.in.h new file mode 100644 index 00000000..0d87631c --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/sys_wait.in.h @@ -0,0 +1,136 @@ +/* A POSIX-like . + Copyright (C) 2001-2003, 2005-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + + +#ifndef _@GUARD_PREFIX@_SYS_WAIT_H + +#if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +#endif +@PRAGMA_COLUMNS@ + +/* The include_next requires a split double-inclusion guard. */ +#if !(defined _WIN32 && ! defined __CYGWIN__) +# @INCLUDE_NEXT@ @NEXT_SYS_WAIT_H@ +#endif + +#ifndef _@GUARD_PREFIX@_SYS_WAIT_H +#define _@GUARD_PREFIX@_SYS_WAIT_H + +/* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +/* Get pid_t. */ +#include + + +/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ + +/* The definition of _GL_WARN_ON_USE is copied here. */ + + +#if !(defined _WIN32 && ! defined __CYGWIN__) +/* Unix API. */ + +/* The following macros apply to an argument x, that is a status of a process, + as returned by waitpid(). + On nearly all systems, including Linux/x86, WEXITSTATUS are bits 15..8 and + WTERMSIG are bits 7..0, while BeOS uses the opposite. Therefore programs + have to use the abstract macros. */ + +/* For valid x, exactly one of WIFSIGNALED(x), WIFEXITED(x), WIFSTOPPED(x) + is true. */ +# ifndef WIFSIGNALED +# define WIFSIGNALED(x) (WTERMSIG (x) != 0 && WTERMSIG(x) != 0x7f) +# endif +# ifndef WIFEXITED +# define WIFEXITED(x) (WTERMSIG (x) == 0) +# endif +# ifndef WIFSTOPPED +# define WIFSTOPPED(x) (WTERMSIG (x) == 0x7f) +# endif + +/* The termination signal. Only to be accessed if WIFSIGNALED(x) is true. */ +# ifndef WTERMSIG +# define WTERMSIG(x) ((x) & 0x7f) +# endif + +/* The exit status. Only to be accessed if WIFEXITED(x) is true. */ +# ifndef WEXITSTATUS +# define WEXITSTATUS(x) (((x) >> 8) & 0xff) +# endif + +/* The stopping signal. Only to be accessed if WIFSTOPPED(x) is true. */ +# ifndef WSTOPSIG +# define WSTOPSIG(x) (((x) >> 8) & 0x7f) +# endif + +/* True if the process dumped core. Not standardized by POSIX. */ +# ifndef WCOREDUMP +# define WCOREDUMP(x) ((x) & 0x80) +# endif + +#else +/* Native Windows API. */ + +# include /* for SIGTERM */ + +/* The following macros apply to an argument x, that is a status of a process, + as returned by waitpid() or, equivalently, _cwait() or GetExitCodeProcess(). + This value is simply an 'int', not composed of bit fields. */ + +/* When an unhandled fatal signal terminates a process, the exit code is 3. */ +# define WIFSIGNALED(x) ((x) == 3) +# define WIFEXITED(x) ((x) != 3) +# define WIFSTOPPED(x) 0 + +/* The signal that terminated a process is not known posthum. */ +# define WTERMSIG(x) SIGTERM + +# define WEXITSTATUS(x) (x) + +/* There are no stopping signals. */ +# define WSTOPSIG(x) 0 + +/* There are no core dumps. */ +# define WCOREDUMP(x) 0 + +#endif + + +/* Declarations of functions. */ + +#if @GNULIB_WAITPID@ +# if defined _WIN32 && ! defined __CYGWIN__ +_GL_FUNCDECL_SYS (waitpid, pid_t, (pid_t pid, int *statusp, int options)); +# endif +/* Need to cast, because on Cygwin, the second parameter is + __wait_status_ptr_t statusp. */ +_GL_CXXALIAS_SYS_CAST (waitpid, pid_t, (pid_t pid, int *statusp, int options)); +_GL_CXXALIASWARN (waitpid); +#elif defined GNULIB_POSIXCHECK +# undef waitpid +# if HAVE_RAW_DECL_WAITPID +_GL_WARN_ON_USE (waitpid, "waitpid is unportable - " + "use gnulib module sys_wait for portability"); +# endif +#endif + + +#endif /* _@GUARD_PREFIX@_SYS_WAIT_H */ +#endif /* _@GUARD_PREFIX@_SYS_WAIT_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/system-quote.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/system-quote.c new file mode 100644 index 00000000..db1c7a32 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/system-quote.c @@ -0,0 +1,310 @@ +/* Quoting for a system command. + Copyright (C) 2012-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2012. + + 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 . */ + +#include + +/* Specification. */ +#include "system-quote.h" + +#include +#include + +#include "sh-quote.h" +#include "xalloc.h" + +#if defined _WIN32 && ! defined __CYGWIN__ + +/* The native Windows CreateProcess() function interprets characters like + ' ', '\t', '\\', '"' (but not '<' and '>') in a special way: + - Space and tab are interpreted as delimiters. They are not treated as + delimiters if they are surrounded by double quotes: "...". + - Unescaped double quotes are removed from the input. Their only effect is + that within double quotes, space and tab are treated like normal + characters. + - Backslashes not followed by double quotes are not special. + - But 2*n+1 backslashes followed by a double quote become + n backslashes followed by a double quote (n >= 0): + \" -> " + \\\" -> \" + \\\\\" -> \\" + - '*', '?' characters may get expanded through wildcard expansion in the + callee: By default, in the callee, the initialization code before main() + takes the result of GetCommandLine(), wildcard-expands it, and passes it + to main(). The exceptions to this rule are: + - programs that inspect GetCommandLine() and ignore argv, + - mingw programs that have a global variable 'int _CRT_glob = 0;', + - Cygwin programs, when invoked from a Cygwin program. + */ +# define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037*?" +# define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" + +/* Copies the quoted string to p and returns the number of bytes needed. + If p is non-NULL, there must be room for system_quote_length (string) + bytes at p. */ +static size_t +windows_createprocess_quote (char *p, const char *string) +{ + size_t len = strlen (string); + bool quote_around = + (len == 0 || strpbrk (string, SHELL_SPECIAL_CHARS) != NULL); + size_t backslashes = 0; + size_t i = 0; +# define STORE(c) \ + do \ + { \ + if (p != NULL) \ + p[i] = (c); \ + i++; \ + } \ + while (0) + + if (quote_around) + STORE ('"'); + for (; len > 0; string++, len--) + { + char c = *string; + + if (c == '"') + { + size_t j; + + for (j = backslashes + 1; j > 0; j--) + STORE ('\\'); + } + STORE (c); + if (c == '\\') + backslashes++; + else + backslashes = 0; + } + if (quote_around) + { + size_t j; + + for (j = backslashes; j > 0; j--) + STORE ('\\'); + STORE ('"'); + } +# undef STORE + return i; +} + +/* The native Windows cmd.exe command interpreter also interprets: + - '\n', '\r' as a command terminator - no way to escape it, + - '<', '>' as redirections, + - '|' as pipe operator, + - '%var%' as a reference to the environment variable VAR (uppercase), + even inside quoted strings, + - '&' '[' ']' '{' '}' '^' '=' ';' '!' '\'' '+' ',' '`' '~' for other + purposes, according to + + We quote a string like '%var%' by putting the '%' characters outside of + double-quotes and the rest of the string inside double-quotes: %"var"%. + This is guaranteed to not be a reference to an environment variable. + */ +# define CMD_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037!%&'*+,;<=>?[]^`{|}~" +# define CMD_FORBIDDEN_CHARS "\n\r" + +/* Copies the quoted string to p and returns the number of bytes needed. + If p is non-NULL, there must be room for system_quote_length (string) + bytes at p. */ +static size_t +windows_cmd_quote (char *p, const char *string) +{ + size_t len = strlen (string); + bool quote_around = + (len == 0 || strpbrk (string, CMD_SPECIAL_CHARS) != NULL); + size_t backslashes = 0; + size_t i = 0; +# define STORE(c) \ + do \ + { \ + if (p != NULL) \ + p[i] = (c); \ + i++; \ + } \ + while (0) + + if (quote_around) + STORE ('"'); + for (; len > 0; string++, len--) + { + char c = *string; + + if (c == '"') + { + size_t j; + + for (j = backslashes + 1; j > 0; j--) + STORE ('\\'); + } + if (c == '%') + { + size_t j; + + for (j = backslashes; j > 0; j--) + STORE ('\\'); + STORE ('"'); + } + STORE (c); + if (c == '%') + STORE ('"'); + if (c == '\\') + backslashes++; + else + backslashes = 0; + } + if (quote_around) + { + size_t j; + + for (j = backslashes; j > 0; j--) + STORE ('\\'); + STORE ('"'); + } + return i; +} + +#endif + +size_t +system_quote_length (enum system_command_interpreter interpreter, + const char *string) +{ + switch (interpreter) + { +#if !(defined _WIN32 && ! defined __CYGWIN__) + case SCI_SYSTEM: +#endif + case SCI_POSIX_SH: + return shell_quote_length (string); + +#if defined _WIN32 && ! defined __CYGWIN__ + case SCI_WINDOWS_CREATEPROCESS: + return windows_createprocess_quote (NULL, string); + + case SCI_SYSTEM: + case SCI_WINDOWS_CMD: + return windows_cmd_quote (NULL, string); +#endif + + default: + /* Invalid interpreter. */ + abort (); + } +} + +char * +system_quote_copy (char *p, + enum system_command_interpreter interpreter, + const char *string) +{ + switch (interpreter) + { +#if !(defined _WIN32 && ! defined __CYGWIN__) + case SCI_SYSTEM: +#endif + case SCI_POSIX_SH: + return shell_quote_copy (p, string); + +#if defined _WIN32 && ! defined __CYGWIN__ + case SCI_WINDOWS_CREATEPROCESS: + p += windows_createprocess_quote (p, string); + *p = '\0'; + return p; + + case SCI_SYSTEM: + case SCI_WINDOWS_CMD: + p += windows_cmd_quote (p, string); + *p = '\0'; + return p; +#endif + + default: + /* Invalid interpreter. */ + abort (); + } +} + +char * +system_quote (enum system_command_interpreter interpreter, + const char *string) +{ + switch (interpreter) + { +#if !(defined _WIN32 && ! defined __CYGWIN__) + case SCI_SYSTEM: +#endif + case SCI_POSIX_SH: + return shell_quote (string); + +#if defined _WIN32 && ! defined __CYGWIN__ + case SCI_WINDOWS_CREATEPROCESS: + case SCI_SYSTEM: + case SCI_WINDOWS_CMD: + { + size_t length = system_quote_length (interpreter, string) + 1; + char *quoted = XNMALLOC (length, char); + system_quote_copy (quoted, interpreter, string); + return quoted; + } +#endif + + default: + /* Invalid interpreter. */ + abort (); + } +} + +char * +system_quote_argv (enum system_command_interpreter interpreter, + char * const *argv) +{ + if (*argv != NULL) + { + char * const *argp; + size_t length; + char *command; + char *p; + + length = 0; + for (argp = argv; ; ) + { + length += system_quote_length (interpreter, *argp) + 1; + argp++; + if (*argp == NULL) + break; + } + + command = XNMALLOC (length, char); + + p = command; + for (argp = argv; ; ) + { + p = system_quote_copy (p, interpreter, *argp); + argp++; + if (*argp == NULL) + break; + *p++ = ' '; + } + *p = '\0'; + + return command; + } + else + return xstrdup (""); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/system-quote.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/system-quote.h new file mode 100644 index 00000000..ba9d7048 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/system-quote.h @@ -0,0 +1,108 @@ +/* Quoting for a system command. + Copyright (C) 2001-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2012. + + 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 . */ + +#ifndef _SYSTEM_QUOTE_H +#define _SYSTEM_QUOTE_H + +/* When passing a command the system's command interpreter, we must quote the + program name and arguments, since + - Unix shells interpret characters like " ", "'", "<", ">", "$", '*', '?' + etc. in a special way, + - Windows CreateProcess() interprets characters like ' ', '\t', '\\', '"' + etc. (but not '<' and '>') in a special way, + - Windows cmd.exe also interprets characters like '<', '>', '&', '%', etc. + in a special way. Note that it is impossible to pass arguments that + contain newlines or carriage return characters to programs through + cmd.exe. + - Windows programs usually perform wildcard expansion when they receive + arguments that contain unquoted '*', '?' characters. + + With this module, you can build a command that will invoke a program with + specific strings as arguments. + + Note: If you want wildcard expansion to happen, you have to first do wildcard + expansion through the 'glob' module, then quote the resulting strings through + this module, and then invoke the system's command interpreter. + + Limitations: + - When invoking native Windows programs on Windows Vista or newer, + wildcard expansion will occur in the invoked program nevertheless. + - On native Windows, for SCI_SYSTEM and SCI_WINDOWS_CMD, newlines and + carriage return characters are not supported. Their undesired effect + is to truncate the entire command line. + */ + +/* This file uses _GL_ATTRIBUTE_MALLOC, _GL_ATTRIBUTE_RETURNS_NONNULL. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Identifier for the kind of interpreter of the command. */ +enum system_command_interpreter +{ + /* The interpreter used by the system() and popen() functions. + This is equivalent to SCI_POSIX_SH on Unix platforms and + SCI_WINDOWS_CMD on native Windows platforms. */ + SCI_SYSTEM = 0 + /* The POSIX /bin/sh. */ + , SCI_POSIX_SH = 1 +#if defined _WIN32 && ! defined __CYGWIN__ + /* The native Windows CreateProcess() function. */ + , SCI_WINDOWS_CREATEPROCESS = 2 + /* The native Windows cmd.exe interpreter. */ + , SCI_WINDOWS_CMD = 3 +#endif +}; + +/* Returns the number of bytes needed for the quoted string. */ +extern size_t + system_quote_length (enum system_command_interpreter interpreter, + const char *string); + +/* Copies the quoted string to p and returns the incremented p. + There must be room for system_quote_length (string) + 1 bytes at p. */ +extern char * + system_quote_copy (char *restrict p, + enum system_command_interpreter interpreter, + const char *string); + +/* Returns the freshly allocated quoted string. */ +extern char * + system_quote (enum system_command_interpreter interpreter, + const char *string) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE + _GL_ATTRIBUTE_RETURNS_NONNULL; + +/* Returns a freshly allocated string containing all argument strings, quoted, + separated through spaces. */ +extern char * + system_quote_argv (enum system_command_interpreter interpreter, + char * const *argv) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE + _GL_ATTRIBUTE_RETURNS_NONNULL; + +#ifdef __cplusplus +} +#endif + +#endif /* _SYSTEM_QUOTE_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/tempname.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/tempname.c new file mode 100644 index 00000000..fec5f7b2 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/tempname.c @@ -0,0 +1,286 @@ +/* Copyright (C) 1991-2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#if !_LIBC +# include +# include "tempname.h" +#endif + +#include + +#include +#ifndef TMP_MAX +# define TMP_MAX 238328 +#endif +#ifndef __GT_FILE +# define __GT_FILE 0 +# define __GT_DIR 1 +# define __GT_NOCREATE 2 +#endif +#if !_LIBC && (GT_FILE != __GT_FILE || GT_DIR != __GT_DIR \ + || GT_NOCREATE != __GT_NOCREATE) +# error report this to bug-gnulib@gnu.org +#endif + +#include +#include + +#include +#include +#include +#include +#include + +#if _LIBC +# define struct_stat64 struct __stat64_t64 +#else +# define struct_stat64 struct stat +# define __gen_tempname gen_tempname +# define __mkdir mkdir +# define __open open +# define __lstat64_time64(file, buf) lstat (file, buf) +# define __getrandom getrandom +# define __clock_gettime64 clock_gettime +# define __timespec64 timespec +#endif + +/* Use getrandom if it works, falling back on a 64-bit linear + congruential generator that starts with Var's value + mixed in with a clock's low-order bits if available. */ +typedef uint_fast64_t random_value; +#define RANDOM_VALUE_MAX UINT_FAST64_MAX +#define BASE_62_DIGITS 10 /* 62**10 < UINT_FAST64_MAX */ +#define BASE_62_POWER (62LL * 62 * 62 * 62 * 62 * 62 * 62 * 62 * 62 * 62) + +/* Return the result of mixing the entropy from R and S. + Assume that R and S are not particularly random, + and that the result should look randomish to an untrained eye. */ + +static random_value +mix_random_values (random_value r, random_value s) +{ + /* As this code is used only when high-quality randomness is neither + available nor necessary, there is no need for fancier polynomials + such as those in the Linux kernel's 'random' driver. */ + return (2862933555777941757 * r + 3037000493) ^ s; +} + +/* Set *R to a random value. + Return true if *R is set to high-quality value taken from getrandom. + Otherwise return false, falling back to a low-quality *R that might + depend on S. + + This function returns false only when getrandom fails. + On GNU systems this should happen only early in the boot process, + when the fallback should be good enough for programs using tempname + because any attacker likely has root privileges already. */ + +static bool +random_bits (random_value *r, random_value s) +{ + /* Without GRND_NONBLOCK it can be blocked for minutes on some systems. */ + if (__getrandom (r, sizeof *r, GRND_NONBLOCK) == sizeof *r) + return true; + + /* If getrandom did not work, use ersatz entropy based on low-order + clock bits. On GNU systems getrandom should fail only + early in booting, when ersatz should be good enough. + Do not use ASLR-based entropy, as that would leak ASLR info into + the resulting file name which is typically public. + + Of course we are in a state of sin here. */ + + random_value v = s; + +#if _LIBC || (defined CLOCK_REALTIME && HAVE_CLOCK_GETTIME) + struct __timespec64 tv; + __clock_gettime64 (CLOCK_REALTIME, &tv); + v = mix_random_values (v, tv.tv_sec); + v = mix_random_values (v, tv.tv_nsec); +#endif + + *r = mix_random_values (v, clock ()); + return false; +} + +#if _LIBC +static int try_tempname_len (char *, int, void *, int (*) (char *, void *), + size_t); +#endif + +static int +try_file (char *tmpl, void *flags) +{ + int *openflags = flags; + return __open (tmpl, + (*openflags & ~O_ACCMODE) + | O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR); +} + +static int +try_dir (char *tmpl, _GL_UNUSED void *flags) +{ + return __mkdir (tmpl, S_IRUSR | S_IWUSR | S_IXUSR); +} + +static int +try_nocreate (char *tmpl, _GL_UNUSED void *flags) +{ + struct_stat64 st; + + if (__lstat64_time64 (tmpl, &st) == 0 || errno == EOVERFLOW) + __set_errno (EEXIST); + return errno == ENOENT ? 0 : -1; +} + +/* These are the characters used in temporary file names. */ +static const char letters[] = +"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; + +/* Generate a temporary file name based on TMPL. TMPL must match the + rules for mk[s]temp (i.e., end in at least X_SUFFIX_LEN "X"s, + possibly with a suffix). + The name constructed does not exist at the time of the call to + this function. TMPL is overwritten with the result. + + KIND may be one of: + __GT_NOCREATE: simply verify that the name does not exist + at the time of the call. + __GT_FILE: create the file using open(O_CREAT|O_EXCL) + and return a read-write fd. The file is mode 0600. + __GT_DIR: create a directory, which will be mode 0700. + + */ +#ifdef _LIBC +static +#endif +int +gen_tempname_len (char *tmpl, int suffixlen, int flags, int kind, + size_t x_suffix_len) +{ + static int (*const tryfunc[]) (char *, void *) = + { + [__GT_FILE] = try_file, + [__GT_DIR] = try_dir, + [__GT_NOCREATE] = try_nocreate + }; + return try_tempname_len (tmpl, suffixlen, &flags, tryfunc[kind], + x_suffix_len); +} + +#ifdef _LIBC +static +#endif +int +try_tempname_len (char *tmpl, int suffixlen, void *args, + int (*tryfunc) (char *, void *), size_t x_suffix_len) +{ + size_t len; + char *XXXXXX; + unsigned int count; + int fd = -1; + int save_errno = errno; + + /* A lower bound on the number of temporary files to attempt to + generate. The maximum total number of temporary file names that + can exist for a given template is 62**6. It should never be + necessary to try all of these combinations. Instead if a reasonable + number of names is tried (we define reasonable as 62**3) fail to + give the system administrator the chance to remove the problems. + This value requires that X_SUFFIX_LEN be at least 3. */ +#define ATTEMPTS_MIN (62 * 62 * 62) + + /* The number of times to attempt to generate a temporary file. To + conform to POSIX, this must be no smaller than TMP_MAX. */ +#if ATTEMPTS_MIN < TMP_MAX + unsigned int attempts = TMP_MAX; +#else + unsigned int attempts = ATTEMPTS_MIN; +#endif + + /* A random variable. */ + random_value v = 0; + + /* A value derived from the random variable, and how many random + base-62 digits can currently be extracted from VDIGBUF. */ + random_value vdigbuf; + int vdigits = 0; + + /* Least biased value for V. If V is less than this, V can generate + BASE_62_DIGITS unbiased digits. Otherwise the digits are biased. */ + random_value const biased_min + = RANDOM_VALUE_MAX - RANDOM_VALUE_MAX % BASE_62_POWER; + + len = strlen (tmpl); + if (len < x_suffix_len + suffixlen + || strspn (&tmpl[len - x_suffix_len - suffixlen], "X") < x_suffix_len) + { + __set_errno (EINVAL); + return -1; + } + + /* This is where the Xs start. */ + XXXXXX = &tmpl[len - x_suffix_len - suffixlen]; + + for (count = 0; count < attempts; ++count) + { + for (size_t i = 0; i < x_suffix_len; i++) + { + if (vdigits == 0) + { + /* Worry about bias only if the bits are high quality. */ + while (random_bits (&v, v) && biased_min <= v) + continue; + + vdigbuf = v; + vdigits = BASE_62_DIGITS; + } + + XXXXXX[i] = letters[vdigbuf % 62]; + vdigbuf /= 62; + vdigits--; + } + + fd = tryfunc (tmpl, args); + if (fd >= 0) + { + __set_errno (save_errno); + return fd; + } + else if (errno != EEXIST) + return -1; + } + + /* We got out of the loop because we ran out of combinations to try. */ + __set_errno (EEXIST); + return -1; +} + +int +__gen_tempname (char *tmpl, int suffixlen, int flags, int kind) +{ + return gen_tempname_len (tmpl, suffixlen, flags, kind, 6); +} + +#if !_LIBC +int +try_tempname (char *tmpl, int suffixlen, void *args, + int (*tryfunc) (char *, void *)) +{ + return try_tempname_len (tmpl, suffixlen, args, tryfunc, 6); +} +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/tempname.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/tempname.h new file mode 100644 index 00000000..7cbdac95 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/tempname.h @@ -0,0 +1,72 @@ +/* Create a temporary file or directory. + + Copyright (C) 2006, 2009-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* header written by Eric Blake */ + +#ifndef GL_TEMPNAME_H +# define GL_TEMPNAME_H + +# include + +# ifdef __GT_FILE +# define GT_FILE __GT_FILE +# define GT_DIR __GT_DIR +# define GT_NOCREATE __GT_NOCREATE +# else +# define GT_FILE 0 +# define GT_DIR 1 +# define GT_NOCREATE 2 +# endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* Generate a temporary file name based on TMPL. TMPL must match the + rules for mk[s]temp (i.e. end in "XXXXXX", possibly with a suffix). + The name constructed does not exist at the time of the call to + gen_tempname. TMPL is overwritten with the result. + + KIND may be one of: + GT_NOCREATE: simply verify that the name does not exist + at the time of the call. + GT_FILE: create a large file using open(O_CREAT|O_EXCL) + and return a read-write fd. The file is mode 0600. + GT_DIR: create a directory, which will be mode 0700. + + */ +extern int gen_tempname (char *tmpl, int suffixlen, int flags, int kind); +/* Similar, except X_SUFFIX_LEN gives the number of Xs. */ +extern int gen_tempname_len (char *tmpl, int suffixlen, int flags, int kind, + size_t x_suffix_len); + +/* Similar to gen_tempname, but TRYFUNC is called for each temporary + name to try. If TRYFUNC returns a non-negative number, TRY_GEN_TEMPNAME + returns with this value. Otherwise, if errno is set to EEXIST, another + name is tried, or else TRY_GEN_TEMPNAME returns -1. */ +extern int try_tempname (char *tmpl, int suffixlen, void *args, + int (*tryfunc) (char *, void *)); +/* Similar, except X_SUFFIX_LEN gives the number of Xs. */ +extern int try_tempname_len (char *tmpl, int suffixlen, void *args, + int (*tryfunc) (char *, void *), + size_t x_suffix_len); + +#ifdef __cplusplus +} +#endif + +#endif /* GL_TEMPNAME_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/time-internal.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/time-internal.h new file mode 100644 index 00000000..816684a1 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/time-internal.h @@ -0,0 +1,49 @@ +/* Time internal interface + + Copyright 2015-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Paul Eggert. */ + +/* A time zone rule. */ +struct tm_zone +{ + /* More abbreviations, should they be needed. Their TZ_IS_SET + members are zero. */ + struct tm_zone *next; + +#if HAVE_TZNAME && !HAVE_STRUCT_TM_TM_ZONE + /* Copies of recent strings taken from tzname[0] and tzname[1]. + The copies are in ABBRS, so that they survive tzset. Null if unknown. */ + char *tzname_copy[2]; +#endif + + /* If nonzero, the rule represents the TZ environment variable set + to the first "abbreviation" (this may be the empty string). + Otherwise, it represents an unset TZ. */ + char tz_is_set; + + /* A sequence of null-terminated strings packed next to each other. + The strings are followed by an extra null byte. If TZ_IS_SET, + there must be at least one string and the first string (which is + actually a TZ environment value) may be empty. Otherwise all + strings must be nonempty. + + Abbreviations are stored here because otherwise the values of + tm_zone and/or tzname would be dead after changing TZ and calling + tzset. Abbreviations never move once allocated, and are live + until tzfree is called. */ + char abbrs[FLEXIBLE_ARRAY_MEMBER]; +}; diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/time.in.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/time.in.h new file mode 100644 index 00000000..df99c8ab --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/time.in.h @@ -0,0 +1,589 @@ +/* A more-standard . + + Copyright (C) 2007-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +#endif +@PRAGMA_COLUMNS@ + +/* This file uses #include_next of a system file that defines time_t. + For the 'year2038' module to work right, needs to have been + included before. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +/* Don't get in the way of glibc when it includes time.h merely to + declare a few standard symbols, rather than to declare all the + symbols. (However, skip this for MinGW as it treats __need_time_t + incompatibly.) Also, Solaris 8 eventually includes itself + recursively; if that is happening, just include the system + without adding our own declarations. */ +#if (((defined __need_time_t || defined __need_clock_t \ + || defined __need_timespec) \ + && !defined __MINGW32__) \ + || defined _@GUARD_PREFIX@_TIME_H) + +# @INCLUDE_NEXT@ @NEXT_TIME_H@ + +#else + +# define _@GUARD_PREFIX@_TIME_H + +/* mingw's provides the functions asctime_r, ctime_r, gmtime_r, + localtime_r only if or has been included before. */ +# if defined __MINGW32__ +# include +# endif + +# @INCLUDE_NEXT@ @NEXT_TIME_H@ + +/* This file uses _GL_ATTRIBUTE_DEPRECATED, GNULIB_POSIXCHECK, + HAVE_RAW_DECL_*. */ +# if !_GL_CONFIG_H_INCLUDED +# error "Please include config.h first." +# endif + +/* NetBSD 5.0 mis-defines NULL. */ +# include + +/* 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. */ + +/* Some systems don't define struct timespec (e.g., AIX 4.1). + Or they define it with the wrong member names or define it in + (e.g., FreeBSD circa 1997). Stock Mingw prior to 3.0 does not define it, + but the pthreads-win32 library defines it in . */ +# if ! @TIME_H_DEFINES_STRUCT_TIMESPEC@ +# if @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@ +# include +# elif @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@ +# include +# elif @UNISTD_H_DEFINES_STRUCT_TIMESPEC@ +# include +# else + +# ifdef __cplusplus +extern "C" { +# endif + +# if !GNULIB_defined_struct_timespec +# undef timespec +# define timespec rpl_timespec +struct timespec +{ + time_t tv_sec; + long int tv_nsec; +}; +# define GNULIB_defined_struct_timespec 1 +# endif + +# ifdef __cplusplus +} +# endif + +# endif +# endif + +# if !GNULIB_defined_struct_time_t_must_be_integral +/* https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_types.h.html + requires time_t to be an integer type, even though C99 permits floating + point. We don't know of any implementation that uses floating + point, and it is much easier to write code that doesn't have to + worry about that corner case, so we force the issue. */ +struct __time_t_must_be_integral { + unsigned int __floating_time_t_unsupported : (time_t) 1; +}; +# define GNULIB_defined_struct_time_t_must_be_integral 1 +# endif + +/* Define TIME_UTC, a positive integer constant used for timespec_get(). */ +# if ! @TIME_H_DEFINES_TIME_UTC@ +# if !GNULIB_defined_TIME_UTC +# define TIME_UTC 1 +# define GNULIB_defined_TIME_UTC 1 +# endif +# endif + +/* Set *TS to the current time, and return BASE. + Upon failure, return 0. */ +# if @GNULIB_TIMESPEC_GET@ +# if @REPLACE_TIMESPEC_GET@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef timespec_get +# define timespec_get rpl_timespec_get +# endif +_GL_FUNCDECL_RPL (timespec_get, int, (struct timespec *ts, int base) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (timespec_get, int, (struct timespec *ts, int base)); +# else +# if !@HAVE_TIMESPEC_GET@ +_GL_FUNCDECL_SYS (timespec_get, int, (struct timespec *ts, int base) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (timespec_get, int, (struct timespec *ts, int base)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (timespec_get); +# endif +# elif defined GNULIB_POSIXCHECK +# undef timespec_get +# if HAVE_RAW_DECL_TIMESPEC_GET +_GL_WARN_ON_USE (timespec_get, "timespec_get is unportable - " + "use gnulib module timespec_get for portability"); +# endif +# endif + +/* Set *TS to the current time resolution, and return BASE. + Upon failure, return 0. */ +# if @GNULIB_TIMESPEC_GETRES@ +# if @REPLACE_TIMESPEC_GETRES@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef timespec_getres +# define timespec_getres rpl_timespec_getres +# endif +_GL_FUNCDECL_RPL (timespec_getres, int, (struct timespec *ts, int base) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (timespec_getres, int, (struct timespec *ts, int base)); +# else +# if !@HAVE_TIMESPEC_GETRES@ +_GL_FUNCDECL_SYS (timespec_getres, int, (struct timespec *ts, int base) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (timespec_getres, int, (struct timespec *ts, int base)); +# endif +_GL_CXXALIASWARN (timespec_getres); +# elif defined GNULIB_POSIXCHECK +# undef timespec_getres +# if HAVE_RAW_DECL_TIMESPEC_GETRES +_GL_WARN_ON_USE (timespec_getres, "timespec_getres is unportable - " + "use gnulib module timespec_getres for portability"); +# endif +# endif + +/* Return the number of seconds that have elapsed since the Epoch. */ +# if @GNULIB_TIME@ +# if @REPLACE_TIME@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define time rpl_time +# endif +_GL_FUNCDECL_RPL (time, time_t, (time_t *__tp)); +_GL_CXXALIAS_RPL (time, time_t, (time_t *__tp)); +# else +_GL_CXXALIAS_SYS (time, time_t, (time_t *__tp)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (time); +# endif +# elif defined GNULIB_POSIXCHECK +# undef time +# if HAVE_RAW_DECL_TIME +_GL_WARN_ON_USE (time, "time has consistency problems - " + "use gnulib module time for portability"); +# endif +# endif + +/* Sleep for at least RQTP seconds unless interrupted, If interrupted, + return -1 and store the remaining time into RMTP. See + . */ +# if @GNULIB_NANOSLEEP@ +# if @REPLACE_NANOSLEEP@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define nanosleep rpl_nanosleep +# endif +_GL_FUNCDECL_RPL (nanosleep, int, + (struct timespec const *__rqtp, struct timespec *__rmtp) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (nanosleep, int, + (struct timespec const *__rqtp, struct timespec *__rmtp)); +# else +# if ! @HAVE_NANOSLEEP@ +_GL_FUNCDECL_SYS (nanosleep, int, + (struct timespec const *__rqtp, struct timespec *__rmtp) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (nanosleep, int, + (struct timespec const *__rqtp, struct timespec *__rmtp)); +# endif +_GL_CXXALIASWARN (nanosleep); +# elif defined GNULIB_POSIXCHECK +# undef nanosleep +# if HAVE_RAW_DECL_NANOSLEEP +_GL_WARN_ON_USE (nanosleep, "nanosleep is unportable - " + "use gnulib module nanosleep for portability"); +# endif +# endif + +/* Initialize time conversion information. */ +# if @GNULIB_TZSET@ +# if @REPLACE_TZSET@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef tzset +# define tzset rpl_tzset +# endif +_GL_FUNCDECL_RPL (tzset, void, (void)); +_GL_CXXALIAS_RPL (tzset, void, (void)); +# elif defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef tzset +# define tzset _tzset +# endif +_GL_CXXALIAS_MDA (tzset, void, (void)); +# else +_GL_CXXALIAS_SYS (tzset, void, (void)); +# endif +_GL_CXXALIASWARN (tzset); +# elif @GNULIB_MDA_TZSET@ +/* On native Windows, map 'tzset' to '_tzset', so that -loldnames is not + required. In C++ with GNULIB_NAMESPACE, avoid differences between + platforms by defining GNULIB_NAMESPACE::tzset always. */ +# if defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef tzset +# define tzset _tzset +# endif +_GL_CXXALIAS_MDA (tzset, void, (void)); +# else +_GL_CXXALIAS_SYS (tzset, void, (void)); +# endif +_GL_CXXALIASWARN (tzset); +# elif defined GNULIB_POSIXCHECK +# undef tzset +# if HAVE_RAW_DECL_TZSET +_GL_WARN_ON_USE (tzset, "tzset has portability problems - " + "use gnulib module tzset for portability"); +# endif +# endif + +/* Return the 'time_t' representation of TP and normalize TP. */ +# if @GNULIB_MKTIME@ +# if @REPLACE_MKTIME@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define mktime rpl_mktime +# endif +_GL_FUNCDECL_RPL (mktime, time_t, (struct tm *__tp) _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (mktime, time_t, (struct tm *__tp)); +# else +_GL_CXXALIAS_SYS (mktime, time_t, (struct tm *__tp)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (mktime); +# endif +# elif defined GNULIB_POSIXCHECK +# undef mktime +# if HAVE_RAW_DECL_MKTIME +_GL_WARN_ON_USE (mktime, "mktime has portability problems - " + "use gnulib module mktime for portability"); +# endif +# endif + +/* Convert TIMER to RESULT, assuming local time and UTC respectively. See + and + . */ +# if @GNULIB_TIME_R@ +# if @REPLACE_LOCALTIME_R@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef localtime_r +# define localtime_r rpl_localtime_r +# endif +_GL_FUNCDECL_RPL (localtime_r, struct tm *, (time_t const *restrict __timer, + struct tm *restrict __result) + _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (localtime_r, struct tm *, (time_t const *restrict __timer, + struct tm *restrict __result)); +# else +# if ! @HAVE_DECL_LOCALTIME_R@ +_GL_FUNCDECL_SYS (localtime_r, struct tm *, (time_t const *restrict __timer, + struct tm *restrict __result) + _GL_ARG_NONNULL ((1, 2))); +# endif +_GL_CXXALIAS_SYS (localtime_r, struct tm *, (time_t const *restrict __timer, + struct tm *restrict __result)); +# endif +# if @HAVE_DECL_LOCALTIME_R@ +_GL_CXXALIASWARN (localtime_r); +# endif +# if @REPLACE_LOCALTIME_R@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef gmtime_r +# define gmtime_r rpl_gmtime_r +# endif +_GL_FUNCDECL_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer, + struct tm *restrict __result) + _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer, + struct tm *restrict __result)); +# else +# if ! @HAVE_DECL_LOCALTIME_R@ +_GL_FUNCDECL_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer, + struct tm *restrict __result) + _GL_ARG_NONNULL ((1, 2))); +# endif +_GL_CXXALIAS_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer, + struct tm *restrict __result)); +# endif +# if @HAVE_DECL_LOCALTIME_R@ +_GL_CXXALIASWARN (gmtime_r); +# endif +# elif defined GNULIB_POSIXCHECK +# undef localtime_r +# if HAVE_RAW_DECL_LOCALTIME_R +_GL_WARN_ON_USE (localtime_r, "localtime_r is unportable - " + "use gnulib module time_r for portability"); +# endif +# undef gmtime_r +# if HAVE_RAW_DECL_GMTIME_R +_GL_WARN_ON_USE (gmtime_r, "gmtime_r is unportable - " + "use gnulib module time_r for portability"); +# endif +# endif + +/* Convert TIMER to RESULT, assuming local time and UTC respectively. See + and + . */ +# if @GNULIB_LOCALTIME@ || @REPLACE_LOCALTIME@ +# if @REPLACE_LOCALTIME@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef localtime +# define localtime rpl_localtime +# endif +_GL_FUNCDECL_RPL (localtime, struct tm *, (time_t const *__timer) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (localtime, struct tm *, (time_t const *__timer)); +# else +_GL_CXXALIAS_SYS (localtime, struct tm *, (time_t const *__timer)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (localtime); +# endif +# elif defined GNULIB_POSIXCHECK +# undef localtime +# if HAVE_RAW_DECL_LOCALTIME +_GL_WARN_ON_USE (localtime, "localtime has portability problems - " + "use gnulib module localtime for portability"); +# endif +# endif + +# if 0 || @REPLACE_GMTIME@ +# if @REPLACE_GMTIME@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef gmtime +# define gmtime rpl_gmtime +# endif +_GL_FUNCDECL_RPL (gmtime, struct tm *, (time_t const *__timer) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (gmtime, struct tm *, (time_t const *__timer)); +# else +_GL_CXXALIAS_SYS (gmtime, struct tm *, (time_t const *__timer)); +# endif +_GL_CXXALIASWARN (gmtime); +# endif + +/* Parse BUF as a timestamp, assuming FORMAT specifies its layout, and store + the resulting broken-down time into TM. See + . */ +# if @GNULIB_STRPTIME@ +# if ! @HAVE_STRPTIME@ +_GL_FUNCDECL_SYS (strptime, char *, (char const *restrict __buf, + char const *restrict __format, + struct tm *restrict __tm) + _GL_ARG_NONNULL ((1, 2, 3))); +# endif +_GL_CXXALIAS_SYS (strptime, char *, (char const *restrict __buf, + char const *restrict __format, + struct tm *restrict __tm)); +_GL_CXXALIASWARN (strptime); +# elif defined GNULIB_POSIXCHECK +# undef strptime +# if HAVE_RAW_DECL_STRPTIME +_GL_WARN_ON_USE (strptime, "strptime is unportable - " + "use gnulib module strptime for portability"); +# endif +# endif + +/* Convert *TP to a date and time string. See + . */ +# if @GNULIB_CTIME@ +# if @REPLACE_CTIME@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define ctime rpl_ctime +# endif +# ifndef __cplusplus +_GL_ATTRIBUTE_DEPRECATED +# endif +_GL_FUNCDECL_RPL (ctime, char *, (time_t const *__tp) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (ctime, char *, (time_t const *__tp)); +# else +_GL_CXXALIAS_SYS (ctime, char *, (time_t const *__tp)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (ctime); +# endif +# elif defined GNULIB_POSIXCHECK +/* No need to warn about portability, as a more serious warning is below. */ +# endif + +/* Convert *TP to a date and time string. See + . */ +# if @GNULIB_STRFTIME@ +# if @REPLACE_STRFTIME@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define strftime rpl_strftime +# endif +_GL_FUNCDECL_RPL (strftime, size_t, + (char *restrict __buf, size_t __bufsize, + const char *restrict __fmt, const struct tm *restrict __tp) + _GL_ARG_NONNULL ((1, 3, 4))); +_GL_CXXALIAS_RPL (strftime, size_t, + (char *restrict __buf, size_t __bufsize, + const char *restrict __fmt, const struct tm *restrict __tp)); +# else +_GL_CXXALIAS_SYS (strftime, size_t, + (char *restrict __buf, size_t __bufsize, + const char *restrict __fmt, const struct tm *restrict __tp)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (strftime); +# endif +# elif defined GNULIB_POSIXCHECK +# undef strftime +# if HAVE_RAW_DECL_STRFTIME +_GL_WARN_ON_USE (strftime, "strftime has portability problems - " + "use gnulib module strftime-fixes for portability"); +# endif +# endif + +# if defined _GNU_SOURCE && @GNULIB_TIME_RZ@ && ! @HAVE_TIMEZONE_T@ +/* Functions that use a first-class time zone data type, instead of + relying on an implicit global time zone. + Inspired by NetBSD. */ + +/* Represents a time zone. + (timezone_t) NULL stands for UTC. */ +typedef struct tm_zone *timezone_t; + +/* tzalloc (name) + Returns a time zone object for the given time zone NAME. This object + represents the time zone that other functions would use it the TZ + environment variable was set to NAME. + If NAME is NULL, the result represents the time zone that other functions + would use it the TZ environment variable was unset. + May return NULL if NAME is invalid (this is platform dependent) or + upon memory allocation failure. */ +_GL_FUNCDECL_SYS (tzalloc, timezone_t, (char const *__name)); +_GL_CXXALIAS_SYS (tzalloc, timezone_t, (char const *__name)); + +/* tzfree (tz) + Frees a time zone object. + The argument must have been returned by tzalloc(). */ +_GL_FUNCDECL_SYS (tzfree, void, (timezone_t __tz)); +_GL_CXXALIAS_SYS (tzfree, void, (timezone_t __tz)); + +/* localtime_rz (tz, &t, &result) + Converts an absolute time T to a broken-down time RESULT, assuming the + time zone TZ. + This function is like 'localtime_r', but relies on the argument TZ instead + of an implicit global time zone. */ +_GL_FUNCDECL_SYS (localtime_rz, struct tm *, + (timezone_t __tz, time_t const *restrict __timer, + struct tm *restrict __result) _GL_ARG_NONNULL ((2, 3))); +_GL_CXXALIAS_SYS (localtime_rz, struct tm *, + (timezone_t __tz, time_t const *restrict __timer, + struct tm *restrict __result)); + +/* mktime_z (tz, &tm) + Normalizes the broken-down time TM and converts it to an absolute time, + assuming the time zone TZ. Returns the absolute time. + This function is like 'mktime', but relies on the argument TZ instead + of an implicit global time zone. */ +_GL_FUNCDECL_SYS (mktime_z, time_t, + (timezone_t __tz, struct tm *restrict __tm) + _GL_ARG_NONNULL ((2))); +_GL_CXXALIAS_SYS (mktime_z, time_t, + (timezone_t __tz, struct tm *restrict __tm)); + +/* Time zone abbreviation strings (returned by 'localtime_rz' or 'mktime_z' + in the 'tm_zone' member of 'struct tm') are valid as long as + - the 'struct tm' argument is not destroyed or overwritten, + and + - the 'timezone_t' argument is not freed through tzfree(). */ + +# endif + +/* Convert TM to a time_t value, assuming UTC. */ +# if @GNULIB_TIMEGM@ +# if @REPLACE_TIMEGM@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef timegm +# define timegm rpl_timegm +# endif +_GL_FUNCDECL_RPL (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (timegm, time_t, (struct tm *__tm)); +# else +# if ! @HAVE_TIMEGM@ +_GL_FUNCDECL_SYS (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (timegm, time_t, (struct tm *__tm)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (timegm); +# endif +# elif defined GNULIB_POSIXCHECK +# undef timegm +# if HAVE_RAW_DECL_TIMEGM +_GL_WARN_ON_USE (timegm, "timegm is unportable - " + "use gnulib module timegm for portability"); +# endif +# endif + +/* Encourage applications to avoid unsafe functions that can overrun + buffers when given outlandish struct tm values. Portable + applications should use strftime (or even sprintf) instead. */ +# if defined GNULIB_POSIXCHECK +# undef asctime +# if HAVE_RAW_DECL_ASCTIME +_GL_WARN_ON_USE (asctime, "asctime can overrun buffers in some cases - " + "better use strftime (or even sprintf) instead"); +# endif +# endif +# if defined GNULIB_POSIXCHECK +# undef asctime_r +# if HAVE_RAW_DECL_ASCTIME_R +_GL_WARN_ON_USE (asctime_r, "asctime_r can overrun buffers in some cases - " + "better use strftime (or even sprintf) instead"); +# endif +# endif +# if defined GNULIB_POSIXCHECK +# undef ctime +# if HAVE_RAW_DECL_CTIME +_GL_WARN_ON_USE (ctime, "ctime can overrun buffers in some cases - " + "better use strftime (or even sprintf) instead"); +# endif +# endif +# if defined GNULIB_POSIXCHECK +# undef ctime_r +# if HAVE_RAW_DECL_CTIME_R +_GL_WARN_ON_USE (ctime_r, "ctime_r can overrun buffers in some cases - " + "better use strftime (or even sprintf) instead"); +# endif +# endif + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/time_r.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/time_r.c new file mode 100644 index 00000000..3ef0b368 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/time_r.c @@ -0,0 +1,44 @@ +/* Reentrant time functions like localtime_r. + + Copyright (C) 2003, 2006-2007, 2010-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Paul Eggert. */ + +#include + +#include + +static struct tm * +copy_tm_result (struct tm *dest, struct tm const *src) +{ + if (! src) + return 0; + *dest = *src; + return dest; +} + + +struct tm * +gmtime_r (time_t const * restrict t, struct tm * restrict tp) +{ + return copy_tm_result (tp, gmtime (t)); +} + +struct tm * +localtime_r (time_t const * restrict t, struct tm * restrict tp) +{ + return copy_tm_result (tp, localtime (t)); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/time_rz.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/time_rz.c new file mode 100644 index 00000000..468d7539 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/time_rz.c @@ -0,0 +1,316 @@ +/* Time zone functions such as tzalloc and localtime_rz + + Copyright 2015-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Paul Eggert. */ + +/* Although this module is not thread-safe, any races should be fairly + rare and reasonably benign. For complete thread-safety, use a C + library with a working timezone_t type, so that this module is not + needed. */ + +#include + +#include + +#include +#include +#include +#include + +#include "flexmember.h" +#include "idx.h" +#include "time-internal.h" + +/* The approximate size to use for small allocation requests. This is + the largest "small" request for the GNU C library malloc. */ +enum { DEFAULT_MXFAST = 64 * sizeof (size_t) / 4 }; + +/* Minimum size of the ABBRS member of struct tm_zone. ABBRS is larger + only in the unlikely case where an abbreviation longer than this is + used. */ +enum { ABBR_SIZE_MIN = DEFAULT_MXFAST - offsetof (struct tm_zone, abbrs) }; + +/* Magic cookie timezone_t value, for local time. It differs from + NULL and from all other timezone_t values. Only the address + matters; the pointer is never dereferenced. */ +static timezone_t const local_tz = (timezone_t) 1; + +/* Copy to ABBRS the abbreviation at ABBR with size ABBR_SIZE (this + includes its trailing null byte). Append an extra null byte to + mark the end of ABBRS. */ +static void +extend_abbrs (char *abbrs, char const *abbr, size_t abbr_size) +{ + memcpy (abbrs, abbr, abbr_size); + abbrs[abbr_size] = '\0'; +} + +/* Return a newly allocated time zone for NAME, or NULL on failure. + A null NAME stands for wall clock time (which is like unset TZ). */ +timezone_t +tzalloc (char const *name) +{ + size_t name_size = name ? strlen (name) + 1 : 0; + size_t abbr_size = name_size < ABBR_SIZE_MIN ? ABBR_SIZE_MIN : name_size + 1; + timezone_t tz = malloc (FLEXSIZEOF (struct tm_zone, abbrs, abbr_size)); + if (tz) + { + tz->next = NULL; +#if HAVE_TZNAME && !HAVE_STRUCT_TM_TM_ZONE + tz->tzname_copy[0] = tz->tzname_copy[1] = NULL; +#endif + tz->tz_is_set = !!name; + tz->abbrs[0] = '\0'; + if (name) + extend_abbrs (tz->abbrs, name, name_size); + } + return tz; +} + +/* Save into TZ any nontrivial time zone abbreviation used by TM, and + update *TM (if HAVE_STRUCT_TM_TM_ZONE) or *TZ (if + !HAVE_STRUCT_TM_TM_ZONE && HAVE_TZNAME) if they use the abbreviation. + Return true if successful, false (setting errno) otherwise. */ +static bool +save_abbr (timezone_t tz, struct tm *tm) +{ +#if HAVE_STRUCT_TM_TM_ZONE || HAVE_TZNAME + char const *zone = NULL; + char *zone_copy = (char *) ""; + +# if HAVE_TZNAME + int tzname_index = -1; +# endif + +# if HAVE_STRUCT_TM_TM_ZONE + zone = tm->tm_zone; +# endif + +# if HAVE_TZNAME + if (! (zone && *zone) && 0 <= tm->tm_isdst) + { + tzname_index = tm->tm_isdst != 0; + zone = tzname[tzname_index]; + } +# endif + + /* No need to replace null zones, or zones within the struct tm. */ + if (!zone || ((char *) tm <= zone && zone < (char *) (tm + 1))) + return true; + + if (*zone) + { + zone_copy = tz->abbrs; + + while (strcmp (zone_copy, zone) != 0) + { + if (! (*zone_copy || (zone_copy == tz->abbrs && tz->tz_is_set))) + { + idx_t zone_size = strlen (zone) + 1; + if (zone_size < tz->abbrs + ABBR_SIZE_MIN - zone_copy) + extend_abbrs (zone_copy, zone, zone_size); + else + { + tz = tz->next = tzalloc (zone); + if (!tz) + return false; + tz->tz_is_set = 0; + zone_copy = tz->abbrs; + } + break; + } + + zone_copy += strlen (zone_copy) + 1; + if (!*zone_copy && tz->next) + { + tz = tz->next; + zone_copy = tz->abbrs; + } + } + } + + /* Replace the zone name so that its lifetime matches that of TZ. */ +# if HAVE_STRUCT_TM_TM_ZONE + tm->tm_zone = zone_copy; +# else + if (0 <= tzname_index) + tz->tzname_copy[tzname_index] = zone_copy; +# endif +#endif + + return true; +} + +/* Free a time zone. */ +void +tzfree (timezone_t tz) +{ + if (tz != local_tz) + while (tz) + { + timezone_t next = tz->next; + free (tz); + tz = next; + } +} + +/* Get and set the TZ environment variable. These functions can be + overridden by programs like Emacs that manage their own environment. */ + +#ifndef getenv_TZ +static char * +getenv_TZ (void) +{ + return getenv ("TZ"); +} +#endif + +#ifndef setenv_TZ +static int +setenv_TZ (char const *tz) +{ + return tz ? setenv ("TZ", tz, 1) : unsetenv ("TZ"); +} +#endif + +/* Change the environment to match the specified timezone_t value. + Return true if successful, false (setting errno) otherwise. */ +static bool +change_env (timezone_t tz) +{ + if (setenv_TZ (tz->tz_is_set ? tz->abbrs : NULL) != 0) + return false; + tzset (); + return true; +} + +/* Temporarily set the time zone to TZ, which must not be null. + Return LOCAL_TZ if the time zone setting is already correct. + Otherwise return a newly allocated time zone representing the old + setting, or NULL (setting errno) on failure. */ +static timezone_t +set_tz (timezone_t tz) +{ + char *env_tz = getenv_TZ (); + if (env_tz + ? tz->tz_is_set && strcmp (tz->abbrs, env_tz) == 0 + : !tz->tz_is_set) + return local_tz; + else + { + timezone_t old_tz = tzalloc (env_tz); + if (!old_tz) + return old_tz; + if (! change_env (tz)) + { + int saved_errno = errno; + tzfree (old_tz); + errno = saved_errno; + return NULL; + } + return old_tz; + } +} + +/* Restore an old setting returned by set_tz. It must not be null. + Return true (preserving errno) if successful, false (setting errno) + otherwise. */ +static bool +revert_tz (timezone_t tz) +{ + if (tz == local_tz) + return true; + else + { + int saved_errno = errno; + bool ok = change_env (tz); + if (!ok) + saved_errno = errno; + tzfree (tz); + errno = saved_errno; + return ok; + } +} + +/* Use time zone TZ to compute localtime_r (T, TM). */ +struct tm * +localtime_rz (timezone_t tz, time_t const *t, struct tm *tm) +{ +#ifdef HAVE_LOCALTIME_INFLOOP_BUG + /* The -67768038400665599 comes from: + https://lists.gnu.org/r/bug-gnulib/2017-07/msg00142.html + On affected platforms the greatest POSIX-compatible time_t value + that could return nonnull is 67768036191766798 (when + TZ="XXX24:59:59" it resolves to the year 2**31 - 1 + 1900, on + 12-31 at 23:59:59), so test for that too while we're in the + neighborhood. */ + if (! (-67768038400665599 <= *t && *t <= 67768036191766798)) + { + errno = EOVERFLOW; + return NULL; + } +#endif + + if (!tz) + return gmtime_r (t, tm); + else + { + timezone_t old_tz = set_tz (tz); + if (old_tz) + { + bool abbr_saved = localtime_r (t, tm) && save_abbr (tz, tm); + if (revert_tz (old_tz) && abbr_saved) + return tm; + } + return NULL; + } +} + +/* Use time zone TZ to compute mktime (TM). */ +time_t +mktime_z (timezone_t tz, struct tm *tm) +{ + if (!tz) + return timegm (tm); + else + { + timezone_t old_tz = set_tz (tz); + if (old_tz) + { + struct tm tm_1; + tm_1.tm_sec = tm->tm_sec; + tm_1.tm_min = tm->tm_min; + tm_1.tm_hour = tm->tm_hour; + tm_1.tm_mday = tm->tm_mday; + tm_1.tm_mon = tm->tm_mon; + tm_1.tm_year = tm->tm_year; + tm_1.tm_yday = -1; + tm_1.tm_isdst = tm->tm_isdst; + time_t t = mktime (&tm_1); + bool ok = 0 <= tm_1.tm_yday; +#if HAVE_STRUCT_TM_TM_ZONE || HAVE_TZNAME + ok = ok && save_abbr (tz, &tm_1); +#endif + if (revert_tz (old_tz) && ok) + { + *tm = tm_1; + return t; + } + } + return -1; + } +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/timegm.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/timegm.c new file mode 100644 index 00000000..b47025a0 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/timegm.c @@ -0,0 +1,58 @@ +/* Convert UTC calendar time to simple time. Like mktime but assumes UTC. + + Copyright (C) 1994-2023 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _LIBC +# include +#endif + +#include +#include + +#include "mktime-internal.h" + +__time64_t +__timegm64 (struct tm *tmp) +{ + static mktime_offset_t gmtime_offset; + tmp->tm_isdst = 0; + return __mktime_internal (tmp, __gmtime64_r, &gmtime_offset); +} + +#if defined _LIBC && __TIMESIZE != 64 + +libc_hidden_def (__timegm64) + +time_t +timegm (struct tm *tmp) +{ + struct tm tm = *tmp; + __time64_t t = __timegm64 (&tm); + if (in_time_t_range (t)) + { + *tmp = tm; + return t; + } + else + { + __set_errno (EOVERFLOW); + return -1; + } +} + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/timespec.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/timespec.c new file mode 100644 index 00000000..8cee9870 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/timespec.c @@ -0,0 +1,21 @@ +/* Inline functions for . + + Copyright (C) 2012-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +#define _GL_TIMESPEC_INLINE _GL_EXTERN_INLINE +#include "timespec.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/timespec.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/timespec.h new file mode 100644 index 00000000..69ce3485 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/timespec.h @@ -0,0 +1,102 @@ +/* timespec -- System time interface + + Copyright (C) 2000, 2002, 2004-2005, 2007, 2009-2024 Free Software + Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#if ! defined TIMESPEC_H +#define TIMESPEC_H + +/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, _GL_ATTRIBUTE_CONST, + _GL_ATTRIBUTE_PURE, _GL_CMP. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +#include + +_GL_INLINE_HEADER_BEGIN +#ifndef _GL_TIMESPEC_INLINE +# define _GL_TIMESPEC_INLINE _GL_INLINE +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#include "arg-nonnull.h" + +/* Inverse resolution of timespec timestamps (in units per second), + and log base 10 of the inverse resolution. */ + +enum { TIMESPEC_HZ = 1000000000 }; +enum { LOG10_TIMESPEC_HZ = 9 }; + +/* Obsolescent names for backward compatibility. + They are misnomers, because TIMESPEC_RESOLUTION is not a resolution. */ + +enum { TIMESPEC_RESOLUTION = TIMESPEC_HZ }; +enum { LOG10_TIMESPEC_RESOLUTION = LOG10_TIMESPEC_HZ }; + +/* Return a timespec with seconds S and nanoseconds NS. */ + +_GL_TIMESPEC_INLINE struct timespec +make_timespec (time_t s, long int ns) +{ + return (struct timespec) { .tv_sec = s, .tv_nsec = ns }; +} + +/* Return negative, zero, positive if A < B, A == B, A > B, respectively. */ + +_GL_TIMESPEC_INLINE int _GL_ATTRIBUTE_PURE +timespec_cmp (struct timespec a, struct timespec b) +{ + return 2 * _GL_CMP (a.tv_sec, b.tv_sec) + _GL_CMP (a.tv_nsec, b.tv_nsec); +} + +/* Return -1, 0, 1, depending on the sign of A. A.tv_nsec must be + nonnegative. */ +_GL_TIMESPEC_INLINE int _GL_ATTRIBUTE_PURE +timespec_sign (struct timespec a) +{ + return _GL_CMP (a.tv_sec, 0) + (!a.tv_sec & !!a.tv_nsec); +} + +struct timespec timespec_add (struct timespec, struct timespec) + _GL_ATTRIBUTE_CONST; +struct timespec timespec_sub (struct timespec, struct timespec) + _GL_ATTRIBUTE_CONST; +struct timespec dtotimespec (double) + _GL_ATTRIBUTE_CONST; + +/* Return an approximation to A, of type 'double'. */ +_GL_TIMESPEC_INLINE double +timespectod (struct timespec a) +{ + return a.tv_sec + a.tv_nsec / 1e9; +} + +long int gettime_res (void); +struct timespec current_timespec (void); +void gettime (struct timespec *) _GL_ARG_NONNULL ((1)); +int settime (struct timespec const *) _GL_ARG_NONNULL ((1)); + +#ifdef __cplusplus +} +#endif + +_GL_INLINE_HEADER_END + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/timespec_get.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/timespec_get.c new file mode 100644 index 00000000..feaf6e63 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/timespec_get.c @@ -0,0 +1,33 @@ +/* timespec_get() function. + Copyright (C) 2021-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +#include "timespec.h" + +int +timespec_get (struct timespec *ts, int base) +{ + if (base == TIME_UTC) + { + gettime (ts); + return base; + } + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/tzset.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/tzset.c new file mode 100644 index 00000000..0eb8c161 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/tzset.c @@ -0,0 +1,66 @@ +/* Provide tzset for systems that don't have it or for which it's broken. + + Copyright (C) 2001-2003, 2005-2007, 2009-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* written by Jim Meyering */ + +#include + +/* Specification. */ +#include + +#include +#include + +void +rpl_tzset (void) +#undef tzset +{ +#if defined _WIN32 && ! defined __CYGWIN__ + /* Rectify the value of the environment variable TZ. + There are four possible kinds of such values: + - Traditional US time zone names, e.g. "PST8PDT". Syntax: see + + - Time zone names based on geography, that contain one or more + slashes, e.g. "Europe/Moscow". + - Time zone names based on geography, without slashes, e.g. + "Singapore". + - Time zone names that contain explicit DST rules. Syntax: see + + The Microsoft CRT understands only the first kind. It produces incorrect + results if the value of TZ is of the other kinds. + But in a Cygwin environment, /etc/profile.d/tzset.sh sets TZ to a value + of the second kind for most geographies, or of the first kind in a few + other geographies. If it is of the second kind, neutralize it. For the + Microsoft CRT, an absent or empty TZ means the time zone that the user + has set in the Windows Control Panel. + If the value of TZ is of the third or fourth kind -- Cygwin programs + understand these syntaxes as well --, it does not matter whether we + neutralize it or not, since these values occur only when a Cygwin user + has set TZ explicitly; this case is 1. rare and 2. under the user's + responsibility. */ + const char *tz = getenv ("TZ"); + if (tz != NULL && strchr (tz, '/') != NULL) + _putenv ("TZ="); + + /* On native Windows, tzset() is deprecated. Use _tzset() instead. See + + */ + _tzset (); +#else + tzset (); +#endif +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/uchar.in.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/uchar.in.h new file mode 100644 index 00000000..166cbecc --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/uchar.in.h @@ -0,0 +1,910 @@ +/* substitute - 16-bit and 32-bit wide character types. + Copyright (C) 2019-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 2019. */ + +/* + * ISO C 23 for platforms that lack it. + */ + +#ifndef _@GUARD_PREFIX@_UCHAR_H + +#if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +#endif +@PRAGMA_COLUMNS@ + +/* The include_next requires a split double-inclusion guard. */ +#if @HAVE_UCHAR_H@ +# if defined __HAIKU__ +/* Work around . */ +# include +# endif +/* On AIX 7.2 with xlclang++, /usr/include/uchar.h produces compilation errors + because it contains typedef definitions of char16_t and char32_t, however + char16_t and char32_t are keywords in this situation. To work around it, + define char16_t and char32_t as macros. */ +# if defined __cplusplus && defined _AIX && defined __ibmxl__ && defined __clang__ +# define char16_t gl_char16_t +# define char32_t gl_char32_t +# endif +# @INCLUDE_NEXT@ @NEXT_UCHAR_H@ +#endif + +#ifndef _@GUARD_PREFIX@_UCHAR_H +#define _@GUARD_PREFIX@_UCHAR_H + +/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, _GL_BEGIN_C_LINKAGE, + _GL_ATTRIBUTE_PURE, GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +/* Get uint_least16_t, uint_least32_t. */ +#include + +/* Get mbstate_t, size_t. */ +#include + +/* For the inline functions. */ +#include +#include + +/* The __attribute__ feature is available in gcc versions 2.5 and later. + The attribute __pure__ was added in gcc 2.96. */ +#ifndef _GL_ATTRIBUTE_PURE +# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined __clang__ +# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) +# else +# define _GL_ATTRIBUTE_PURE /* empty */ +# endif +#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. */ + + +_GL_INLINE_HEADER_BEGIN + + +#if !(@HAVE_UCHAR_H@ || (defined __cplusplus && @CXX_HAS_CHAR8_TYPE@)) + +/* An 8-bit variant of wchar_t. + Note: This type is only mandated by ISO C 23 or newer, and it does + denote UTF-8 units. */ +typedef unsigned char char8_t; + +#elif @GNULIBHEADERS_OVERRIDE_CHAR8_T@ + +typedef unsigned char gl_char8_t; +# define char8_t gl_char8_t + +#endif + +#if !(@HAVE_UCHAR_H@ || (defined __cplusplus && @CXX_HAS_UCHAR_TYPES@)) + +/* A 16-bit variant of wchar_t. + Note: This type is only mandated by ISO C 11 or newer. In ISO C 23 + and newer, it denotes UTF-16 units; in older versions of ISO C it did + so only on platforms on which __STDC_UTF_16__ was defined. */ +typedef uint_least16_t char16_t; + +#elif @GNULIBHEADERS_OVERRIDE_CHAR16_T@ + +typedef uint_least16_t gl_char16_t; +# define char16_t gl_char16_t + +#endif + +#if !(@HAVE_UCHAR_H@ || (defined __cplusplus && @CXX_HAS_UCHAR_TYPES@)) + +/* A 32-bit variant of wchar_t. + Note: This type is only mandated by ISO C 11 or newer. In ISO C 23 + and newer, it denotes UTF-32 code points; in older versions of ISO C + it did so only on platforms on which __STDC_UTF_32__ was defined. + In gnulib, we guarantee that it denotes UTF-32 code points if and + only if the module 'uchar-c23' is in use. */ +typedef uint_least32_t char32_t; + +#elif @GNULIBHEADERS_OVERRIDE_CHAR32_T@ + +typedef uint_least32_t gl_char32_t; +# define char32_t gl_char32_t + +#endif + +/* Define if a 'char32_t' can hold more characters than a 'wchar_t'. */ +#if @SMALL_WCHAR_T@ /* 32-bit AIX, Cygwin, native Windows */ +# define _GL_SMALL_WCHAR_T 1 +#endif + +/* Define if 'wchar_t', like 'char32_t', + - is a 32-bit type, and + - represents Unicode code points. + For this test, we can use __STDC_ISO_10646__ (defined by glibc, musl libc, + Cygwin) but need to consider _GL_SMALL_WCHAR_T, so as to exclude Cygwin. + We cannot use __STDC_UTF_16__ or __STDC_UTF_32__ + - because these macros provide info about char16_t and char32_t (not + wchar_t!), and + - because GCC >= 4.9 defines these macros on all platforms, even on + FreeBSD and Solaris. + We should better not use __STD_UTF_16__, __STD_UTF_32__ either, because + these macros are misspellings, only defined by Android's . */ +#if defined __STDC_ISO_10646__ && !_GL_SMALL_WCHAR_T +/* glibc, musl libc */ +# define _GL_WCHAR_T_IS_UCS4 1 +#endif +#if _GL_WCHAR_T_IS_UCS4 +static_assert (sizeof (char32_t) == sizeof (wchar_t)); +#endif + + +/* Convert a single-byte character to a 32-bit wide character. */ +#if @GNULIB_BTOC32@ +# if _GL_WCHAR_T_IS_UCS4 && !defined IN_BTOC32 +_GL_BEGIN_C_LINKAGE +_GL_INLINE _GL_ATTRIBUTE_PURE wint_t +btoc32 (int c) +{ + return +# if @GNULIB_BTOWC@ && defined __cplusplus && defined GNULIB_NAMESPACE + GNULIB_NAMESPACE:: +# endif + btowc (c); +} +_GL_END_C_LINKAGE +# else +_GL_FUNCDECL_SYS (btoc32, wint_t, (int c) _GL_ATTRIBUTE_PURE); +# endif +_GL_CXXALIAS_SYS (btoc32, wint_t, (int c)); +_GL_CXXALIASWARN (btoc32); +#endif + + +/* Test a specific property of a 32-bit wide character. */ +#if @GNULIB_C32ISALNUM@ +# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISALNUM +_GL_BEGIN_C_LINKAGE +_GL_INLINE int +c32isalnum (wint_t wc) +{ + return +# if defined __cplusplus && defined GNULIB_NAMESPACE + GNULIB_NAMESPACE:: +# endif + iswalnum (wc); +} +_GL_END_C_LINKAGE +# else +_GL_FUNCDECL_SYS (c32isalnum, int, (wint_t wc)); +# endif +_GL_CXXALIAS_SYS (c32isalnum, int, (wint_t wc)); +_GL_CXXALIASWARN (c32isalnum); +#endif +#if @GNULIB_C32ISALPHA@ +# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISALPHA +_GL_BEGIN_C_LINKAGE +_GL_INLINE int +c32isalpha (wint_t wc) +{ + return +# if defined __cplusplus && defined GNULIB_NAMESPACE + GNULIB_NAMESPACE:: +# endif + iswalpha (wc); +} +_GL_END_C_LINKAGE +# else +_GL_FUNCDECL_SYS (c32isalpha, int, (wint_t wc)); +# endif +_GL_CXXALIAS_SYS (c32isalpha, int, (wint_t wc)); +_GL_CXXALIASWARN (c32isalpha); +#endif +#if @GNULIB_C32ISBLANK@ +# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISBLANK +_GL_BEGIN_C_LINKAGE +_GL_INLINE int +c32isblank (wint_t wc) +{ + return +# if defined __cplusplus && defined GNULIB_NAMESPACE + GNULIB_NAMESPACE:: +# endif + iswblank (wc); +} +_GL_END_C_LINKAGE +# else +_GL_FUNCDECL_SYS (c32isblank, int, (wint_t wc)); +# endif +_GL_CXXALIAS_SYS (c32isblank, int, (wint_t wc)); +_GL_CXXALIASWARN (c32isblank); +#endif +#if @GNULIB_C32ISCNTRL@ +# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISCNTRL +_GL_BEGIN_C_LINKAGE +_GL_INLINE int +c32iscntrl (wint_t wc) +{ + return +# if defined __cplusplus && defined GNULIB_NAMESPACE + GNULIB_NAMESPACE:: +# endif + iswcntrl (wc); +} +_GL_END_C_LINKAGE +# else +_GL_FUNCDECL_SYS (c32iscntrl, int, (wint_t wc)); +# endif +_GL_CXXALIAS_SYS (c32iscntrl, int, (wint_t wc)); +_GL_CXXALIASWARN (c32iscntrl); +#endif +#if @GNULIB_C32ISDIGIT@ +# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISDIGIT +_GL_BEGIN_C_LINKAGE +_GL_INLINE int +c32isdigit (wint_t wc) +{ + return +# if @GNULIB_ISWDIGIT@ && defined __cplusplus && defined GNULIB_NAMESPACE + GNULIB_NAMESPACE:: +# endif + iswdigit (wc); +} +_GL_END_C_LINKAGE +# else +_GL_FUNCDECL_SYS (c32isdigit, int, (wint_t wc)); +# endif +_GL_CXXALIAS_SYS (c32isdigit, int, (wint_t wc)); +_GL_CXXALIASWARN (c32isdigit); +#endif +#if @GNULIB_C32ISGRAPH@ +# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISGRAPH +_GL_BEGIN_C_LINKAGE +_GL_INLINE int +c32isgraph (wint_t wc) +{ + return +# if defined __cplusplus && defined GNULIB_NAMESPACE + GNULIB_NAMESPACE:: +# endif + iswgraph (wc); +} +_GL_END_C_LINKAGE +# else +_GL_FUNCDECL_SYS (c32isgraph, int, (wint_t wc)); +# endif +_GL_CXXALIAS_SYS (c32isgraph, int, (wint_t wc)); +_GL_CXXALIASWARN (c32isgraph); +#endif +#if @GNULIB_C32ISLOWER@ +# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISLOWER +_GL_BEGIN_C_LINKAGE +_GL_INLINE int +c32islower (wint_t wc) +{ + return +# if defined __cplusplus && defined GNULIB_NAMESPACE + GNULIB_NAMESPACE:: +# endif + iswlower (wc); +} +_GL_END_C_LINKAGE +# else +_GL_FUNCDECL_SYS (c32islower, int, (wint_t wc)); +# endif +_GL_CXXALIAS_SYS (c32islower, int, (wint_t wc)); +_GL_CXXALIASWARN (c32islower); +#endif +#if @GNULIB_C32ISPRINT@ +# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISPRINT +_GL_BEGIN_C_LINKAGE +_GL_INLINE int +c32isprint (wint_t wc) +{ + return +# if defined __cplusplus && defined GNULIB_NAMESPACE + GNULIB_NAMESPACE:: +# endif + iswprint (wc); +} +_GL_END_C_LINKAGE +# else +_GL_FUNCDECL_SYS (c32isprint, int, (wint_t wc)); +# endif +_GL_CXXALIAS_SYS (c32isprint, int, (wint_t wc)); +_GL_CXXALIASWARN (c32isprint); +#endif +#if @GNULIB_C32ISPUNCT@ +# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISPUNCT +_GL_BEGIN_C_LINKAGE +_GL_INLINE int +c32ispunct (wint_t wc) +{ + return +# if defined __cplusplus && defined GNULIB_NAMESPACE + GNULIB_NAMESPACE:: +# endif + iswpunct (wc); +} +_GL_END_C_LINKAGE +# else +_GL_FUNCDECL_SYS (c32ispunct, int, (wint_t wc)); +# endif +_GL_CXXALIAS_SYS (c32ispunct, int, (wint_t wc)); +_GL_CXXALIASWARN (c32ispunct); +#endif +#if @GNULIB_C32ISSPACE@ +# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISSPACE +_GL_BEGIN_C_LINKAGE +_GL_INLINE int +c32isspace (wint_t wc) +{ + return +# if defined __cplusplus && defined GNULIB_NAMESPACE + GNULIB_NAMESPACE:: +# endif + iswspace (wc); +} +_GL_END_C_LINKAGE +# else +_GL_FUNCDECL_SYS (c32isspace, int, (wint_t wc)); +# endif +_GL_CXXALIAS_SYS (c32isspace, int, (wint_t wc)); +_GL_CXXALIASWARN (c32isspace); +#endif +#if @GNULIB_C32ISUPPER@ +# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISUPPER +_GL_BEGIN_C_LINKAGE +_GL_INLINE int +c32isupper (wint_t wc) +{ + return +# if defined __cplusplus && defined GNULIB_NAMESPACE + GNULIB_NAMESPACE:: +# endif + iswupper (wc); +} +_GL_END_C_LINKAGE +# else +_GL_FUNCDECL_SYS (c32isupper, int, (wint_t wc)); +# endif +_GL_CXXALIAS_SYS (c32isupper, int, (wint_t wc)); +_GL_CXXALIASWARN (c32isupper); +#endif +#if @GNULIB_C32ISXDIGIT@ +# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISXDIGIT +_GL_BEGIN_C_LINKAGE +_GL_INLINE int +c32isxdigit (wint_t wc) +{ + return +# if @GNULIB_ISWXDIGIT@ && defined __cplusplus && defined GNULIB_NAMESPACE + GNULIB_NAMESPACE:: +# endif + iswxdigit (wc); +} +_GL_END_C_LINKAGE +# else +_GL_FUNCDECL_SYS (c32isxdigit, int, (wint_t wc)); +# endif +_GL_CXXALIAS_SYS (c32isxdigit, int, (wint_t wc)); +_GL_CXXALIASWARN (c32isxdigit); +#endif + + +/* Case mapping of a 32-bit wide character. */ +#if @GNULIB_C32TOLOWER@ +# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32TOLOWER +_GL_BEGIN_C_LINKAGE +_GL_INLINE wint_t +c32tolower (wint_t wc) +{ + return +# if defined __cplusplus && defined GNULIB_NAMESPACE + GNULIB_NAMESPACE:: +# endif + towlower (wc); +} +_GL_END_C_LINKAGE +# else +_GL_FUNCDECL_SYS (c32tolower, wint_t, (wint_t wc)); +# endif +_GL_CXXALIAS_SYS (c32tolower, wint_t, (wint_t wc)); +_GL_CXXALIASWARN (c32tolower); +#endif +#if @GNULIB_C32TOUPPER@ +# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32TOUPPER +_GL_BEGIN_C_LINKAGE +_GL_INLINE wint_t +c32toupper (wint_t wc) +{ + return +# if defined __cplusplus && defined GNULIB_NAMESPACE + GNULIB_NAMESPACE:: +# endif + towupper (wc); +} +_GL_END_C_LINKAGE +# else +_GL_FUNCDECL_SYS (c32toupper, wint_t, (wint_t wc)); +# endif +_GL_CXXALIAS_SYS (c32toupper, wint_t, (wint_t wc)); +_GL_CXXALIASWARN (c32toupper); +#endif + + +/* Number of screen columns needed for a 32-bit wide character. */ +#if @GNULIB_C32WIDTH@ +# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32WIDTH +_GL_BEGIN_C_LINKAGE +_GL_INLINE int +c32width (char32_t wc) +{ + return +# if @GNULIB_WCWIDTH@ && defined __cplusplus && defined GNULIB_NAMESPACE + GNULIB_NAMESPACE:: +# endif + wcwidth (wc); +} +_GL_END_C_LINKAGE +# else +_GL_FUNCDECL_SYS (c32width, int, (char32_t wc)); +# endif +_GL_CXXALIAS_SYS (c32width, int, (char32_t wc)); +_GL_CXXALIASWARN (c32width); +#endif + + +/* Converts a 32-bit wide character to a multibyte character. */ +#if @GNULIB_C32RTOMB@ +# if @REPLACE_C32RTOMB@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef c32rtomb +# define c32rtomb rpl_c32rtomb +# endif +_GL_FUNCDECL_RPL (c32rtomb, size_t, (char *s, char32_t wc, mbstate_t *ps)); +_GL_CXXALIAS_RPL (c32rtomb, size_t, (char *s, char32_t wc, mbstate_t *ps)); +# else +# if !@HAVE_C32RTOMB@ +_GL_FUNCDECL_SYS (c32rtomb, size_t, (char *s, char32_t wc, mbstate_t *ps)); +# endif +_GL_CXXALIAS_SYS (c32rtomb, size_t, (char *s, char32_t wc, mbstate_t *ps)); +# endif +# if __GLIBC__ + (__GLIBC_MINOR__ >= 16) > 2 +_GL_CXXALIASWARN (c32rtomb); +# endif +#elif defined GNULIB_POSIXCHECK +# undef c32rtomb +# if HAVE_RAW_DECL_C32RTOMB +_GL_WARN_ON_USE (c32rtomb, "c32rtomb is not portable - " + "use gnulib module c32rtomb for portability"); +# endif +#endif + + +/* Convert a 32-bit wide string to a string. */ +#if @GNULIB_C32SNRTOMBS@ +# if _GL_WCHAR_T_IS_UCS4 && !defined IN_C32SNRTOMBS +_GL_BEGIN_C_LINKAGE +_GL_INLINE _GL_ARG_NONNULL ((2)) size_t +c32snrtombs (char *dest, const char32_t **srcp, size_t srclen, size_t len, + mbstate_t *ps) +{ + return +# if @GNULIB_WCSNRTOMBS@ && defined __cplusplus && defined GNULIB_NAMESPACE + GNULIB_NAMESPACE:: +# endif + wcsnrtombs (dest, (const wchar_t **) srcp, srclen, len, ps); +} +_GL_END_C_LINKAGE +# else +_GL_FUNCDECL_SYS (c32snrtombs, size_t, + (char *dest, const char32_t **srcp, size_t srclen, size_t len, + mbstate_t *ps) + _GL_ARG_NONNULL ((2))); +# endif +_GL_CXXALIAS_SYS (c32snrtombs, size_t, + (char *dest, const char32_t **srcp, size_t srclen, size_t len, + mbstate_t *ps)); +_GL_CXXALIASWARN (c32snrtombs); +#endif + + +/* Convert a 32-bit wide string to a string. */ +#if @GNULIB_C32SRTOMBS@ +# if _GL_WCHAR_T_IS_UCS4 && !defined IN_C32SRTOMBS +_GL_BEGIN_C_LINKAGE +_GL_INLINE _GL_ARG_NONNULL ((2)) size_t +c32srtombs (char *dest, const char32_t **srcp, size_t len, mbstate_t *ps) +{ + return +# if @GNULIB_WCSRTOMBS@ && defined __cplusplus && defined GNULIB_NAMESPACE + GNULIB_NAMESPACE:: +# endif + wcsrtombs (dest, (const wchar_t **) srcp, len, ps); +} +_GL_END_C_LINKAGE +# else +_GL_FUNCDECL_SYS (c32srtombs, size_t, + (char *dest, const char32_t **srcp, size_t len, mbstate_t *ps) + _GL_ARG_NONNULL ((2))); +# endif +_GL_CXXALIAS_SYS (c32srtombs, size_t, + (char *dest, const char32_t **srcp, size_t len, + mbstate_t *ps)); +_GL_CXXALIASWARN (c32srtombs); +#endif + + +/* Convert a 32-bit wide string to a string. */ +#if @GNULIB_C32STOMBS@ +# if _GL_WCHAR_T_IS_UCS4 && !defined IN_C32STOMBS +_GL_BEGIN_C_LINKAGE +_GL_INLINE _GL_ARG_NONNULL ((2)) size_t +c32stombs (char *dest, const char32_t *src, size_t len) +{ + mbstate_t state; + + mbszero (&state); + return c32srtombs (dest, &src, len, &state); +} +_GL_END_C_LINKAGE +# else +_GL_FUNCDECL_SYS (c32stombs, size_t, + (char *dest, const char32_t *src, size_t len) + _GL_ARG_NONNULL ((2))); +# endif +_GL_CXXALIAS_SYS (c32stombs, size_t, + (char *dest, const char32_t *src, size_t len)); +_GL_CXXALIASWARN (c32stombs); +#endif + + +/* Number of screen columns needed for a size-bounded 32-bit wide string. */ +#if @GNULIB_C32SWIDTH@ +# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32SWIDTH +_GL_BEGIN_C_LINKAGE +_GL_INLINE _GL_ARG_NONNULL ((1)) int +c32swidth (const char32_t *s, size_t n) +{ + return +# if @GNULIB_WCSWIDTH@ && defined __cplusplus && defined GNULIB_NAMESPACE + GNULIB_NAMESPACE:: +# endif + wcswidth ((const wchar_t *) s, n); +} +_GL_END_C_LINKAGE +# else +_GL_FUNCDECL_SYS (c32swidth, int, (const char32_t *s, size_t n) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (c32swidth, int, (const char32_t *s, size_t n)); +_GL_CXXALIASWARN (c32swidth); +#endif + + +/* Converts a 32-bit wide character to unibyte character. + Returns the single-byte representation of WC if it exists, + or EOF otherwise. */ +#if @GNULIB_C32TOB@ +# if _GL_WCHAR_T_IS_UCS4 && !defined IN_C32TOB +_GL_BEGIN_C_LINKAGE +_GL_INLINE int +c32tob (wint_t wc) +{ + return +# if @GNULIB_WCTOB@ && defined __cplusplus && defined GNULIB_NAMESPACE + GNULIB_NAMESPACE:: +# endif + wctob (wc); +} +_GL_END_C_LINKAGE +# else +_GL_FUNCDECL_SYS (c32tob, int, (wint_t wc)); +# endif +_GL_CXXALIAS_SYS (c32tob, int, (wint_t wc)); +_GL_CXXALIASWARN (c32tob); +#endif + + +/* Converts a multibyte character to a 32-bit wide character. */ +#if @GNULIB_MBRTOC32@ +# if @REPLACE_MBRTOC32@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef mbrtoc32 +# define mbrtoc32 rpl_mbrtoc32 +# endif +_GL_FUNCDECL_RPL (mbrtoc32, size_t, + (char32_t *pc, const char *s, size_t n, mbstate_t *ps)); +_GL_CXXALIAS_RPL (mbrtoc32, size_t, + (char32_t *pc, const char *s, size_t n, mbstate_t *ps)); +# else +# if !@HAVE_MBRTOC32@ +_GL_FUNCDECL_SYS (mbrtoc32, size_t, + (char32_t *pc, const char *s, size_t n, mbstate_t *ps)); +# endif +_GL_CXXALIAS_SYS (mbrtoc32, size_t, + (char32_t *pc, const char *s, size_t n, mbstate_t *ps)); +# endif +# if __GLIBC__ + (__GLIBC_MINOR__ >= 16) > 2 +_GL_CXXALIASWARN (mbrtoc32); +# endif +#elif defined GNULIB_POSIXCHECK +# undef mbrtoc32 +# if HAVE_RAW_DECL_MBRTOC32 +_GL_WARN_ON_USE (mbrtoc32, "mbrtoc32 is not portable - " + "use gnulib module mbrtoc32 for portability"); +# endif +#endif + + +/* Converts a multibyte character and returns the next 16-bit wide + character. */ +#if @GNULIB_MBRTOC16@ +# if @REPLACE_MBRTOC16@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef mbrtoc16 +# define mbrtoc16 rpl_mbrtoc16 +# endif +_GL_FUNCDECL_RPL (mbrtoc16, size_t, + (char16_t *pc, const char *s, size_t n, mbstate_t *ps)); +_GL_CXXALIAS_RPL (mbrtoc16, size_t, + (char16_t *pc, const char *s, size_t n, mbstate_t *ps)); +# else +# if !@HAVE_MBRTOC32@ +_GL_FUNCDECL_SYS (mbrtoc16, size_t, + (char16_t *pc, const char *s, size_t n, mbstate_t *ps)); +# endif +_GL_CXXALIAS_SYS (mbrtoc16, size_t, + (char16_t *pc, const char *s, size_t n, mbstate_t *ps)); +# endif +# if __GLIBC__ + (__GLIBC_MINOR__ >= 16) > 2 +_GL_CXXALIASWARN (mbrtoc16); +# endif +#elif defined GNULIB_POSIXCHECK +# undef mbrtoc16 +# if HAVE_RAW_DECL_MBRTOC16 +_GL_WARN_ON_USE (mbrtoc16, "mbrtoc16 is not portable - " + "use gnulib module mbrtoc16 for portability"); +# endif +#endif + + +/* Convert a string to a 32-bit wide string. */ +#if @GNULIB_MBSNRTOC32S@ +# if _GL_WCHAR_T_IS_UCS4 && !defined IN_MBSNRTOC32S +_GL_BEGIN_C_LINKAGE +_GL_INLINE _GL_ARG_NONNULL ((2)) size_t +mbsnrtoc32s (char32_t *dest, const char **srcp, size_t srclen, size_t len, + mbstate_t *ps) +{ + return +# if @GNULIB_MBSNRTOWCS@ && defined __cplusplus && defined GNULIB_NAMESPACE + GNULIB_NAMESPACE:: +# endif + mbsnrtowcs ((wchar_t *) dest, srcp, srclen, len, ps); +} +_GL_END_C_LINKAGE +# else +_GL_FUNCDECL_SYS (mbsnrtoc32s, size_t, + (char32_t *dest, const char **srcp, size_t srclen, size_t len, + mbstate_t *ps) + _GL_ARG_NONNULL ((2))); +# endif +_GL_CXXALIAS_SYS (mbsnrtoc32s, size_t, + (char32_t *dest, const char **srcp, size_t srclen, size_t len, + mbstate_t *ps)); +_GL_CXXALIASWARN (mbsnrtoc32s); +#endif + + +/* Convert a string to a 32-bit wide string. */ +#if @GNULIB_MBSRTOC32S@ +# if _GL_WCHAR_T_IS_UCS4 && !defined IN_MBSRTOC32S +_GL_BEGIN_C_LINKAGE +_GL_INLINE _GL_ARG_NONNULL ((2)) size_t +mbsrtoc32s (char32_t *dest, const char **srcp, size_t len, mbstate_t *ps) +{ + return +# if @GNULIB_MBSRTOWCS@ && defined __cplusplus && defined GNULIB_NAMESPACE + GNULIB_NAMESPACE:: +# endif + mbsrtowcs ((wchar_t *) dest, srcp, len, ps); +} +_GL_END_C_LINKAGE +# else +_GL_FUNCDECL_SYS (mbsrtoc32s, size_t, + (char32_t *dest, const char **srcp, size_t len, mbstate_t *ps) + _GL_ARG_NONNULL ((2))); +# endif +_GL_CXXALIAS_SYS (mbsrtoc32s, size_t, + (char32_t *dest, const char **srcp, size_t len, + mbstate_t *ps)); +_GL_CXXALIASWARN (mbsrtoc32s); +#endif + + +/* Convert a string to a 32-bit wide string. */ +#if @GNULIB_MBSTOC32S@ +# if _GL_WCHAR_T_IS_UCS4 && !defined IN_MBSTOC32S +_GL_BEGIN_C_LINKAGE +_GL_INLINE _GL_ARG_NONNULL ((2)) size_t +mbstoc32s (char32_t *dest, const char *src, size_t len) +{ + mbstate_t state; + + mbszero (&state); + return mbsrtoc32s (dest, &src, len, &state); +} +_GL_END_C_LINKAGE +# else +_GL_FUNCDECL_SYS (mbstoc32s, size_t, + (char32_t *dest, const char *src, size_t len) + _GL_ARG_NONNULL ((2))); +# endif +_GL_CXXALIAS_SYS (mbstoc32s, size_t, + (char32_t *dest, const char *src, size_t len)); +_GL_CXXALIASWARN (mbstoc32s); +#endif + + +#if @GNULIB_C32_GET_TYPE_TEST@ || @GNULIB_C32_APPLY_TYPE_TEST@ +/* A scalar type. Instances of this type, other than (c32_type_test_t) 0, + represent a character property, sometimes also viewed as a "character class". + It can be applied to 32-bit wide characters. It is the counterpart of + type 'wctype_t' for wide characters. + To test whether a given character has a certain property, use the function + 'c32_apply_type_test'. */ +# if _GL_WCHAR_T_IS_UCS4 +typedef wctype_t c32_type_test_t; +# else +typedef /*bool*/int (*c32_type_test_t) (wint_t wc); +# endif +#endif + +/* Return a character property with the given name, or (c32_type_test_t) 0 + if the designated property does not exist. + This function is the counterpart of function 'wctype' for wide characters. + */ +#if @GNULIB_C32_GET_TYPE_TEST@ +# if _GL_WCHAR_T_IS_UCS4 && !defined IN_C32_GET_TYPE_TEST +_GL_BEGIN_C_LINKAGE +_GL_INLINE _GL_ARG_NONNULL ((1)) c32_type_test_t +c32_get_type_test (const char *name) +{ + return +# if @GNULIB_WCTYPE@ && defined __cplusplus && defined GNULIB_NAMESPACE + GNULIB_NAMESPACE:: +# endif + wctype (name); +} +_GL_END_C_LINKAGE +# else +_GL_FUNCDECL_SYS (c32_get_type_test, c32_type_test_t, (const char *name) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (c32_get_type_test, c32_type_test_t, (const char *name)); +_GL_CXXALIASWARN (c32_get_type_test); +#endif + +/* Test whether a given 32-bit wide character has the specified character + property. + Return non-zero if true, zero if false or if the argument is WEOF. + This function is the counterpart of function 'iswctype' for wide characters. + */ +#if @GNULIB_C32_APPLY_TYPE_TEST@ +# if _GL_WCHAR_T_IS_UCS4 +# if !defined IN_C32_APPLY_TYPE_TEST +_GL_BEGIN_C_LINKAGE +_GL_INLINE int +c32_apply_type_test (wint_t wc, c32_type_test_t property) +{ + return +# if @GNULIB_ISWCTYPE@ && defined __cplusplus && defined GNULIB_NAMESPACE + GNULIB_NAMESPACE:: +# endif + iswctype (wc, property); +} +_GL_END_C_LINKAGE +# else +_GL_FUNCDECL_SYS (c32_apply_type_test, int, + (wint_t wc, c32_type_test_t property)); +# endif +# else +_GL_FUNCDECL_SYS (c32_apply_type_test, int, + (wint_t wc, c32_type_test_t property) + _GL_ARG_NONNULL ((2))); +# endif +_GL_CXXALIAS_SYS (c32_apply_type_test, int, + (wint_t wc, c32_type_test_t property)); +_GL_CXXALIASWARN (c32_apply_type_test); +#endif + + +#if @GNULIB_C32_GET_MAPPING@ || @GNULIB_C32_APPLY_MAPPING@ +/* A scalar type. Instances of this type, other than (c32_mapping_t) 0, + represent a character mapping. It can be applied to 32-bit wide characters. + It is the counterpart of type 'wctrans_t' for wide characters. + To apply a certain mapping to a given character, use the function + 'c32_apply_mapping'. */ +# if _GL_WCHAR_T_IS_UCS4 +typedef wctrans_t c32_mapping_t; +# else +typedef wint_t (*c32_mapping_t) (wint_t wc); +# endif +#endif + +/* Return a character mapping with the given name, or (c32_mapping_t) 0 + if the designated mapping does not exist. + This function is the counterpart of function 'wctrans' for wide characters. + */ +#if @GNULIB_C32_GET_MAPPING@ +# if _GL_WCHAR_T_IS_UCS4 && !defined IN_C32_GET_MAPPING +_GL_BEGIN_C_LINKAGE +_GL_INLINE _GL_ARG_NONNULL ((1)) c32_mapping_t +c32_get_mapping (const char *name) +{ + return +# if @GNULIB_WCTRANS@ && defined __cplusplus && defined GNULIB_NAMESPACE + GNULIB_NAMESPACE:: +# endif + wctrans (name); +} +_GL_END_C_LINKAGE +# else +_GL_FUNCDECL_SYS (c32_get_mapping, c32_mapping_t, (const char *name) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (c32_get_mapping, c32_mapping_t, (const char *name)); +_GL_CXXALIASWARN (c32_get_mapping); +#endif + +/* Apply the specified character mapping to a given 32-bit wide character. + Return the result of this mapping. Return the WC argument unchanged if it is + WEOF. + This function is the counterpart of function 'towctrans' for wide characters. + */ +#if @GNULIB_C32_APPLY_MAPPING@ +# if _GL_WCHAR_T_IS_UCS4 && !defined IN_C32_APPLY_MAPPING +_GL_BEGIN_C_LINKAGE +_GL_INLINE _GL_ARG_NONNULL ((2)) wint_t +c32_apply_mapping (wint_t wc, c32_mapping_t mapping) +{ + return +# if @GNULIB_TOWCTRANS@ && defined __cplusplus && defined GNULIB_NAMESPACE + GNULIB_NAMESPACE:: +# endif + towctrans (wc, mapping); +} +_GL_END_C_LINKAGE +# else +_GL_FUNCDECL_SYS (c32_apply_mapping, wint_t, + (wint_t wc, c32_mapping_t mapping) + _GL_ARG_NONNULL ((2))); +# endif +_GL_CXXALIAS_SYS (c32_apply_mapping, wint_t, + (wint_t wc, c32_mapping_t mapping)); +_GL_CXXALIASWARN (c32_apply_mapping); +#endif + + +_GL_INLINE_HEADER_END + +#endif /* _@GUARD_PREFIX@_UCHAR_H */ +#endif /* _@GUARD_PREFIX@_UCHAR_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unicase.in.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unicase.in.h new file mode 100644 index 00000000..bd705baf --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unicase.in.h @@ -0,0 +1,471 @@ +/* Unicode character case mappings. + Copyright (C) 2002, 2009-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef _UNICASE_H +#define _UNICASE_H + +#include "unitypes.h" + +/* Get bool. */ +#include + +/* Get size_t. */ +#include + +/* Get uninorm_t. */ +#include "uninorm.h" + +#if @HAVE_UNISTRING_WOE32DLL_H@ +# include +#else +# define LIBUNISTRING_DLL_VARIABLE +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* ========================================================================= */ + +/* Character case mappings. + These mappings are locale and context independent. + WARNING! These functions are not sufficient for languages such as German. + Better use the functions below that treat an entire string at once and are + language aware. */ + +/* Return the uppercase mapping of a Unicode character. */ +extern ucs4_t + uc_toupper (ucs4_t uc) + _UC_ATTRIBUTE_CONST; + +/* Return the lowercase mapping of a Unicode character. */ +extern ucs4_t + uc_tolower (ucs4_t uc) + _UC_ATTRIBUTE_CONST; + +/* Return the titlecase mapping of a Unicode character. */ +extern ucs4_t + uc_totitle (ucs4_t uc) + _UC_ATTRIBUTE_CONST; + +/* ========================================================================= */ + +/* String case mappings. */ + +/* These functions are locale dependent. The iso639_language argument + identifies the language (e.g. "tr" for Turkish). NULL means to use + locale independent case mappings. */ + +/* Return the ISO 639 language code of the current locale. + Return "" if it is unknown, or in the "C" locale. */ +extern const char * + uc_locale_language (void) + _UC_ATTRIBUTE_PURE; + +/* Conventions: + + All functions prefixed with u8_ operate on UTF-8 encoded strings. + Their unit is an uint8_t (1 byte). + + All functions prefixed with u16_ operate on UTF-16 encoded strings. + Their unit is an uint16_t (a 2-byte word). + + All functions prefixed with u32_ operate on UCS-4 encoded strings. + Their unit is an uint32_t (a 4-byte word). + + All argument pairs (s, n) denote a Unicode string s[0..n-1] with exactly + n units. + + Functions returning a string result take a (resultbuf, lengthp) argument + pair. If resultbuf is not NULL and the result fits into *lengthp units, + it is put in resultbuf, and resultbuf is returned. Otherwise, a freshly + allocated string is returned. In both cases, *lengthp is set to the + length (number of units) of the returned string. In case of error, + NULL is returned and errno is set. */ + +/* Return the uppercase mapping of a string. + The nf argument identifies the normalization form to apply after the + case-mapping. It can also be NULL, for no normalization. */ +extern uint8_t * + u8_toupper (const uint8_t *s, size_t n, const char *iso639_language, + uninorm_t nf, + uint8_t *_UC_RESTRICT resultbuf, size_t *lengthp); +extern uint16_t * + u16_toupper (const uint16_t *s, size_t n, const char *iso639_language, + uninorm_t nf, + uint16_t *_UC_RESTRICT resultbuf, size_t *lengthp); +extern uint32_t * + u32_toupper (const uint32_t *s, size_t n, const char *iso639_language, + uninorm_t nf, + uint32_t *_UC_RESTRICT resultbuf, size_t *lengthp); + +/* Return the lowercase mapping of a string. + The nf argument identifies the normalization form to apply after the + case-mapping. It can also be NULL, for no normalization. */ +extern uint8_t * + u8_tolower (const uint8_t *s, size_t n, const char *iso639_language, + uninorm_t nf, + uint8_t *_UC_RESTRICT resultbuf, size_t *lengthp); +extern uint16_t * + u16_tolower (const uint16_t *s, size_t n, const char *iso639_language, + uninorm_t nf, + uint16_t *_UC_RESTRICT resultbuf, size_t *lengthp); +extern uint32_t * + u32_tolower (const uint32_t *s, size_t n, const char *iso639_language, + uninorm_t nf, + uint32_t *_UC_RESTRICT resultbuf, size_t *lengthp); + +/* Return the titlecase mapping of a string. + The nf argument identifies the normalization form to apply after the + case-mapping. It can also be NULL, for no normalization. */ +extern uint8_t * + u8_totitle (const uint8_t *s, size_t n, const char *iso639_language, + uninorm_t nf, + uint8_t *_UC_RESTRICT resultbuf, size_t *lengthp); +extern uint16_t * + u16_totitle (const uint16_t *s, size_t n, const char *iso639_language, + uninorm_t nf, + uint16_t *_UC_RESTRICT resultbuf, size_t *lengthp); +extern uint32_t * + u32_totitle (const uint32_t *s, size_t n, const char *iso639_language, + uninorm_t nf, + uint32_t *_UC_RESTRICT resultbuf, size_t *lengthp); + +/* The case-mapping context given by a prefix string. */ +typedef struct casing_prefix_context + { + /* These fields are private, undocumented. */ + uint32_t last_char_except_ignorable; + uint32_t last_char_normal_or_above; + } + casing_prefix_context_t; +/* The case-mapping context of the empty prefix string. */ +extern @GNULIB_UNICASE_EMPTY_PREFIX_CONTEXT_DLL_VARIABLE@ const casing_prefix_context_t unicase_empty_prefix_context; +/* Return the case-mapping context of a given prefix string. */ +extern casing_prefix_context_t + u8_casing_prefix_context (const uint8_t *s, size_t n); +extern casing_prefix_context_t + u16_casing_prefix_context (const uint16_t *s, size_t n); +extern casing_prefix_context_t + u32_casing_prefix_context (const uint32_t *s, size_t n); +/* Return the case-mapping context of the prefix concat(A, S), given the + case-mapping context of the prefix A. */ +extern casing_prefix_context_t + u8_casing_prefixes_context (const uint8_t *s, size_t n, + casing_prefix_context_t a_context); +extern casing_prefix_context_t + u16_casing_prefixes_context (const uint16_t *s, size_t n, + casing_prefix_context_t a_context); +extern casing_prefix_context_t + u32_casing_prefixes_context (const uint32_t *s, size_t n, + casing_prefix_context_t a_context); + +/* The case-mapping context given by a suffix string. */ +typedef struct casing_suffix_context + { + /* These fields are private, undocumented. */ + uint32_t first_char_except_ignorable; + uint32_t bits; + } + casing_suffix_context_t; +/* The case-mapping context of the empty suffix string. */ +extern @GNULIB_UNICASE_EMPTY_SUFFIX_CONTEXT_DLL_VARIABLE@ const casing_suffix_context_t unicase_empty_suffix_context; +/* Return the case-mapping context of a given suffix string. */ +extern casing_suffix_context_t + u8_casing_suffix_context (const uint8_t *s, size_t n); +extern casing_suffix_context_t + u16_casing_suffix_context (const uint16_t *s, size_t n); +extern casing_suffix_context_t + u32_casing_suffix_context (const uint32_t *s, size_t n); +/* Return the case-mapping context of the suffix concat(S, A), given the + case-mapping context of the suffix A. */ +extern casing_suffix_context_t + u8_casing_suffixes_context (const uint8_t *s, size_t n, + casing_suffix_context_t a_context); +extern casing_suffix_context_t + u16_casing_suffixes_context (const uint16_t *s, size_t n, + casing_suffix_context_t a_context); +extern casing_suffix_context_t + u32_casing_suffixes_context (const uint32_t *s, size_t n, + casing_suffix_context_t a_context); + +/* Return the uppercase mapping of a string that is surrounded by a prefix + and a suffix. */ +extern uint8_t * + u8_ct_toupper (const uint8_t *s, size_t n, + casing_prefix_context_t prefix_context, + casing_suffix_context_t suffix_context, + const char *iso639_language, + uninorm_t nf, + uint8_t *_UC_RESTRICT resultbuf, size_t *lengthp); +extern uint16_t * + u16_ct_toupper (const uint16_t *s, size_t n, + casing_prefix_context_t prefix_context, + casing_suffix_context_t suffix_context, + const char *iso639_language, + uninorm_t nf, + uint16_t *_UC_RESTRICT resultbuf, size_t *lengthp); +extern uint32_t * + u32_ct_toupper (const uint32_t *s, size_t n, + casing_prefix_context_t prefix_context, + casing_suffix_context_t suffix_context, + const char *iso639_language, + uninorm_t nf, + uint32_t *_UC_RESTRICT resultbuf, size_t *lengthp); + +/* Return the lowercase mapping of a string that is surrounded by a prefix + and a suffix. */ +extern uint8_t * + u8_ct_tolower (const uint8_t *s, size_t n, + casing_prefix_context_t prefix_context, + casing_suffix_context_t suffix_context, + const char *iso639_language, + uninorm_t nf, + uint8_t *_UC_RESTRICT resultbuf, size_t *lengthp); +extern uint16_t * + u16_ct_tolower (const uint16_t *s, size_t n, + casing_prefix_context_t prefix_context, + casing_suffix_context_t suffix_context, + const char *iso639_language, + uninorm_t nf, + uint16_t *_UC_RESTRICT resultbuf, size_t *lengthp); +extern uint32_t * + u32_ct_tolower (const uint32_t *s, size_t n, + casing_prefix_context_t prefix_context, + casing_suffix_context_t suffix_context, + const char *iso639_language, + uninorm_t nf, + uint32_t *_UC_RESTRICT resultbuf, size_t *lengthp); + +/* Return the titlecase mapping of a string that is surrounded by a prefix + and a suffix. */ +extern uint8_t * + u8_ct_totitle (const uint8_t *s, size_t n, + casing_prefix_context_t prefix_context, + casing_suffix_context_t suffix_context, + const char *iso639_language, + uninorm_t nf, + uint8_t *_UC_RESTRICT resultbuf, size_t *lengthp); +extern uint16_t * + u16_ct_totitle (const uint16_t *s, size_t n, + casing_prefix_context_t prefix_context, + casing_suffix_context_t suffix_context, + const char *iso639_language, + uninorm_t nf, + uint16_t *_UC_RESTRICT resultbuf, size_t *lengthp); +extern uint32_t * + u32_ct_totitle (const uint32_t *s, size_t n, + casing_prefix_context_t prefix_context, + casing_suffix_context_t suffix_context, + const char *iso639_language, + uninorm_t nf, + uint32_t *_UC_RESTRICT resultbuf, size_t *lengthp); + +/* Return the case folded string. + Comparing uN_casefold (S1) and uN_casefold (S2) with uN_cmp2() is equivalent + to comparing S1 and S2 with uN_casecmp(). + The nf argument identifies the normalization form to apply after the + case-mapping. It can also be NULL, for no normalization. */ +extern uint8_t * + u8_casefold (const uint8_t *s, size_t n, const char *iso639_language, + uninorm_t nf, + uint8_t *_UC_RESTRICT resultbuf, size_t *lengthp); +extern uint16_t * + u16_casefold (const uint16_t *s, size_t n, const char *iso639_language, + uninorm_t nf, + uint16_t *_UC_RESTRICT resultbuf, size_t *lengthp); +extern uint32_t * + u32_casefold (const uint32_t *s, size_t n, const char *iso639_language, + uninorm_t nf, + uint32_t *_UC_RESTRICT resultbuf, size_t *lengthp); +/* Likewise, for a string that is surrounded by a prefix and a suffix. */ +extern uint8_t * + u8_ct_casefold (const uint8_t *s, size_t n, + casing_prefix_context_t prefix_context, + casing_suffix_context_t suffix_context, + const char *iso639_language, + uninorm_t nf, + uint8_t *_UC_RESTRICT resultbuf, size_t *lengthp); +extern uint16_t * + u16_ct_casefold (const uint16_t *s, size_t n, + casing_prefix_context_t prefix_context, + casing_suffix_context_t suffix_context, + const char *iso639_language, + uninorm_t nf, + uint16_t *_UC_RESTRICT resultbuf, size_t *lengthp); +extern uint32_t * + u32_ct_casefold (const uint32_t *s, size_t n, + casing_prefix_context_t prefix_context, + casing_suffix_context_t suffix_context, + const char *iso639_language, + uninorm_t nf, + uint32_t *_UC_RESTRICT resultbuf, size_t *lengthp); + +/* Compare S1 and S2, ignoring differences in case and normalization. + The nf argument identifies the normalization form to apply after the + case-mapping. It can also be NULL, for no normalization. + If successful, set *RESULTP to -1 if S1 < S2, 0 if S1 = S2, 1 if S1 > S2, and + return 0. Upon failure, return -1 with errno set. */ +extern int + u8_casecmp (const uint8_t *s1, size_t n1, + const uint8_t *s2, size_t n2, + const char *iso639_language, uninorm_t nf, int *resultp); +extern int + u16_casecmp (const uint16_t *s1, size_t n1, + const uint16_t *s2, size_t n2, + const char *iso639_language, uninorm_t nf, int *resultp); +extern int + u32_casecmp (const uint32_t *s1, size_t n1, + const uint32_t *s2, size_t n2, + const char *iso639_language, uninorm_t nf, int *resultp); +extern int + ulc_casecmp (const char *s1, size_t n1, + const char *s2, size_t n2, + const char *iso639_language, uninorm_t nf, int *resultp); + +/* Convert the string S of length N to a NUL-terminated byte sequence, in such + a way that comparing uN_casexfrm (S1) and uN_casexfrm (S2) with the gnulib + function memcmp2() is equivalent to comparing S1 and S2 with uN_casecoll(). + NF must be either UNINORM_NFC, UNINORM_NFKC, or NULL for no normalization. */ +extern char * + u8_casexfrm (const uint8_t *s, size_t n, const char *iso639_language, + uninorm_t nf, + char *_UC_RESTRICT resultbuf, size_t *lengthp); +extern char * + u16_casexfrm (const uint16_t *s, size_t n, const char *iso639_language, + uninorm_t nf, + char *_UC_RESTRICT resultbuf, size_t *lengthp); +extern char * + u32_casexfrm (const uint32_t *s, size_t n, const char *iso639_language, + uninorm_t nf, + char *_UC_RESTRICT resultbuf, size_t *lengthp); +extern char * + ulc_casexfrm (const char *s, size_t n, const char *iso639_language, + uninorm_t nf, + char *_UC_RESTRICT resultbuf, size_t *lengthp); + +/* Compare S1 and S2, ignoring differences in case and normalization, using the + collation rules of the current locale. + The nf argument identifies the normalization form to apply after the + case-mapping. It must be either UNINORM_NFC or UNINORM_NFKC. It can also + be NULL, for no normalization. + If successful, set *RESULTP to -1 if S1 < S2, 0 if S1 = S2, 1 if S1 > S2, and + return 0. Upon failure, return -1 with errno set. */ +extern int + u8_casecoll (const uint8_t *s1, size_t n1, + const uint8_t *s2, size_t n2, + const char *iso639_language, uninorm_t nf, int *resultp); +extern int + u16_casecoll (const uint16_t *s1, size_t n1, + const uint16_t *s2, size_t n2, + const char *iso639_language, uninorm_t nf, int *resultp); +extern int + u32_casecoll (const uint32_t *s1, size_t n1, + const uint32_t *s2, size_t n2, + const char *iso639_language, uninorm_t nf, int *resultp); +extern int + ulc_casecoll (const char *s1, size_t n1, + const char *s2, size_t n2, + const char *iso639_language, uninorm_t nf, int *resultp); + + +/* Set *RESULTP to true if mapping NFD(S) to upper case is a no-op, or to false + otherwise, and return 0. Upon failure, return -1 with errno set. */ +extern int + u8_is_uppercase (const uint8_t *s, size_t n, + const char *iso639_language, + bool *resultp); +extern int + u16_is_uppercase (const uint16_t *s, size_t n, + const char *iso639_language, + bool *resultp); +extern int + u32_is_uppercase (const uint32_t *s, size_t n, + const char *iso639_language, + bool *resultp); + +/* Set *RESULTP to true if mapping NFD(S) to lower case is a no-op, or to false + otherwise, and return 0. Upon failure, return -1 with errno set. */ +extern int + u8_is_lowercase (const uint8_t *s, size_t n, + const char *iso639_language, + bool *resultp); +extern int + u16_is_lowercase (const uint16_t *s, size_t n, + const char *iso639_language, + bool *resultp); +extern int + u32_is_lowercase (const uint32_t *s, size_t n, + const char *iso639_language, + bool *resultp); + +/* Set *RESULTP to true if mapping NFD(S) to title case is a no-op, or to false + otherwise, and return 0. Upon failure, return -1 with errno set. */ +extern int + u8_is_titlecase (const uint8_t *s, size_t n, + const char *iso639_language, + bool *resultp); +extern int + u16_is_titlecase (const uint16_t *s, size_t n, + const char *iso639_language, + bool *resultp); +extern int + u32_is_titlecase (const uint32_t *s, size_t n, + const char *iso639_language, + bool *resultp); + +/* Set *RESULTP to true if applying case folding to NFD(S) is a no-op, or to + false otherwise, and return 0. Upon failure, return -1 with errno set. */ +extern int + u8_is_casefolded (const uint8_t *s, size_t n, + const char *iso639_language, + bool *resultp); +extern int + u16_is_casefolded (const uint16_t *s, size_t n, + const char *iso639_language, + bool *resultp); +extern int + u32_is_casefolded (const uint32_t *s, size_t n, + const char *iso639_language, + bool *resultp); + +/* Set *RESULTP to true if case matters for S, that is, if mapping NFD(S) to + either upper case or lower case or title case is not a no-op. + Set *RESULTP to false if NFD(S) maps to itself under the upper case mapping, + under the lower case mapping, and under the title case mapping; in other + words, when NFD(S) consists entirely of caseless characters. + Upon failure, return -1 with errno set. */ +extern int + u8_is_cased (const uint8_t *s, size_t n, + const char *iso639_language, + bool *resultp); +extern int + u16_is_cased (const uint16_t *s, size_t n, + const char *iso639_language, + bool *resultp); +extern int + u32_is_cased (const uint32_t *s, size_t n, + const char *iso639_language, + bool *resultp); + + +/* ========================================================================= */ + +#ifdef __cplusplus +} +#endif + +#endif /* _UNICASE_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unicase/.gitignore b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unicase/.gitignore new file mode 100644 index 00000000..ec75a5ef --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unicase/.gitignore @@ -0,0 +1,3 @@ +/simple-mapping.h +/tolower.c +/tolower.h diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unicase/simple-mapping.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unicase/simple-mapping.h new file mode 100644 index 00000000..6102b768 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unicase/simple-mapping.h @@ -0,0 +1,39 @@ +/* Simple case mapping for Unicode characters. + Copyright (C) 2002, 2006, 2009-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2009. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +ucs4_t +FUNC (ucs4_t uc) +{ + unsigned int index1 = uc >> mapping_header_0; + if (index1 < mapping_header_1) + { + int lookup1 = u_mapping.level1[index1]; + if (lookup1 >= 0) + { + unsigned int index2 = (uc >> mapping_header_2) & mapping_header_3; + int lookup2 = u_mapping.level2[lookup1 + index2]; + if (lookup2 >= 0) + { + unsigned int index3 = (uc & mapping_header_4); + int lookup3 = u_mapping.level3[lookup2 + index3]; + + return uc + lookup3; + } + } + } + return uc; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unicase/tolower.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unicase/tolower.c new file mode 100644 index 00000000..0a62cd50 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unicase/tolower.c @@ -0,0 +1,27 @@ +/* Lowercase mapping for Unicode characters (locale and context independent). + Copyright (C) 2002, 2006, 2009-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2009. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unicase.h" + +/* Define u_mapping table. */ +#include "tolower.h" + +#define FUNC uc_tolower +#include "simple-mapping.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unicase/tolower.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unicase/tolower.h new file mode 100644 index 00000000..6fa031c9 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unicase/tolower.h @@ -0,0 +1,727 @@ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +/* Simple character mapping of Unicode characters. */ +/* Generated automatically by gen-uni-tables.c for Unicode 15.0.0. */ + +/* Copyright (C) 2000-2023 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#define mapping_header_0 16 +#define mapping_header_1 2 +#define mapping_header_2 7 +#define mapping_header_3 511 +#define mapping_header_4 127 +static const +struct + { + int level1[2]; + short level2[2 << 9]; + int level3[35 << 7]; + } +u_mapping = +{ + { 0, 512 }, + { + 0, 128, 256, 384, 512, -1, 640, 768, + 896, 1024, 1152, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, 1280, -1, -1, -1, -1, -1, 1408, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, 1536, -1, -1, 1664, 1792, 1920, 2048, + -1, -1, 2176, 2304, -1, -1, -1, -1, + -1, 2432, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + 2560, 2688, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 2816, 2944, 3072, 3200, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 3328, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + 3456, 3584, 3712, 3840, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, 3968, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, 4096, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 4224, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 4352, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1 + }, + { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 0, + 32, 32, 32, 32, 32, 32, 32, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + -199, 0, 1, 0, 1, 0, 1, 0, + 0, 1, 0, 1, 0, 1, 0, 1, + 0, 1, 0, 1, 0, 1, 0, 1, + 0, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + -121, 1, 0, 1, 0, 1, 0, 0, + 0, 210, 1, 0, 1, 0, 206, 1, + 0, 205, 205, 1, 0, 0, 79, 202, + 203, 1, 0, 205, 207, 0, 211, 209, + 1, 0, 0, 0, 211, 213, 0, 214, + 1, 0, 1, 0, 1, 0, 218, 1, + 0, 218, 0, 0, 1, 0, 218, 1, + 0, 217, 217, 1, 0, 1, 0, 219, + 1, 0, 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 2, 1, 0, 2, + 1, 0, 2, 1, 0, 1, 0, 1, + 0, 1, 0, 1, 0, 1, 0, 1, + 0, 1, 0, 1, 0, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 0, 2, 1, 0, 1, 0, -97, -56, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + -130, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 0, 0, 0, 0, + 0, 0, 10795, 1, 0, -163, 10792, 0, + 0, 1, 0, -195, 69, 71, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 1, 0, 1, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 116, + 0, 0, 0, 0, 0, 0, 38, 0, + 37, 37, 37, 0, 64, 0, 63, 63, + 0, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 0, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 8, + 0, 0, 0, 0, 0, 0, 0, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 0, 0, 0, 0, -60, 0, 0, 1, + 0, -7, 1, 0, 0, -130, -130, -130, + 80, 80, 80, 80, 80, 80, 80, 80, + 80, 80, 80, 80, 80, 80, 80, 80, + 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 15, 1, 0, 1, 0, 1, 0, 1, + 0, 1, 0, 1, 0, 1, 0, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 0, 48, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 48, 48, 48, 48, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 7264, 7264, 7264, 7264, 7264, 7264, 7264, 7264, + 7264, 7264, 7264, 7264, 7264, 7264, 7264, 7264, + 7264, 7264, 7264, 7264, 7264, 7264, 7264, 7264, + 7264, 7264, 7264, 7264, 7264, 7264, 7264, 7264, + 7264, 7264, 7264, 7264, 7264, 7264, 0, 7264, + 0, 0, 0, 0, 0, 7264, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 38864, 38864, 38864, 38864, 38864, 38864, 38864, 38864, + 38864, 38864, 38864, 38864, 38864, 38864, 38864, 38864, + 38864, 38864, 38864, 38864, 38864, 38864, 38864, 38864, + 38864, 38864, 38864, 38864, 38864, 38864, 38864, 38864, + 38864, 38864, 38864, 38864, 38864, 38864, 38864, 38864, + 38864, 38864, 38864, 38864, 38864, 38864, 38864, 38864, + 38864, 38864, 38864, 38864, 38864, 38864, 38864, 38864, + 38864, 38864, 38864, 38864, 38864, 38864, 38864, 38864, + 38864, 38864, 38864, 38864, 38864, 38864, 38864, 38864, + 38864, 38864, 38864, 38864, 38864, 38864, 38864, 38864, + 8, 8, 8, 8, 8, 8, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + -3008, -3008, -3008, -3008, -3008, -3008, -3008, -3008, + -3008, -3008, -3008, -3008, -3008, -3008, -3008, -3008, + -3008, -3008, -3008, -3008, -3008, -3008, -3008, -3008, + -3008, -3008, -3008, -3008, -3008, -3008, -3008, -3008, + -3008, -3008, -3008, -3008, -3008, -3008, -3008, -3008, + -3008, -3008, -3008, 0, 0, -3008, -3008, -3008, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, -7615, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + -8, -8, -8, -8, -8, -8, -8, -8, + 0, 0, 0, 0, 0, 0, 0, 0, + -8, -8, -8, -8, -8, -8, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + -8, -8, -8, -8, -8, -8, -8, -8, + 0, 0, 0, 0, 0, 0, 0, 0, + -8, -8, -8, -8, -8, -8, -8, -8, + 0, 0, 0, 0, 0, 0, 0, 0, + -8, -8, -8, -8, -8, -8, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, -8, 0, -8, 0, -8, 0, -8, + 0, 0, 0, 0, 0, 0, 0, 0, + -8, -8, -8, -8, -8, -8, -8, -8, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + -8, -8, -8, -8, -8, -8, -8, -8, + 0, 0, 0, 0, 0, 0, 0, 0, + -8, -8, -8, -8, -8, -8, -8, -8, + 0, 0, 0, 0, 0, 0, 0, 0, + -8, -8, -8, -8, -8, -8, -8, -8, + 0, 0, 0, 0, 0, 0, 0, 0, + -8, -8, -74, -74, -9, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + -86, -86, -86, -86, -9, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + -8, -8, -100, -100, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + -8, -8, -112, -112, -7, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + -128, -128, -126, -126, -9, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, -7517, 0, + 0, 0, -8383, -8262, 0, 0, 0, 0, + 0, 0, 28, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 48, 48, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 48, 48, 48, 48, 48, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 1, 0, -10743, -3814, -10727, 0, 0, 1, + 0, 1, 0, 1, 0, -10780, -10749, -10783, + -10782, 0, 1, 0, 0, 1, 0, 0, + 0, 0, 0, 0, 0, 0, -10815, -10815, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 1, 0, 1, 0, 0, + 0, 0, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 0, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 0, 1, 0, -35332, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 0, 0, 0, 1, 0, -42280, 0, 0, + 1, 0, 1, 0, 0, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, -42308, -42319, -42315, -42305, -42308, 0, + -42258, -42282, -42261, 928, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, -48, -42307, -35384, 1, + 0, 1, 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 0, 0, 1, 0, + 1, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 39, 39, 39, 39, 39, 39, 39, 39, + 39, 39, 39, 0, 39, 39, 39, 39, + 39, 39, 39, 39, 39, 39, 39, 39, + 39, 39, 39, 0, 39, 39, 39, 39, + 39, 39, 39, 0, 39, 39, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 34, 34, 34, 34, 34, 34, 34, 34, + 34, 34, 34, 34, 34, 34, 34, 34, + 34, 34, 34, 34, 34, 34, 34, 34, + 34, 34, 34, 34, 34, 34, 34, 34, + 34, 34, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0 + } +}; diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype.in.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype.in.h new file mode 100644 index 00000000..52b31c4d --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype.in.h @@ -0,0 +1,1096 @@ +/* Unicode character classification and properties. + Copyright (C) 2002, 2005-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef _UNICTYPE_H +#define _UNICTYPE_H + +#include "unitypes.h" + +/* Get bool. */ +#include + +/* Get size_t. */ +#include + +#if @HAVE_UNISTRING_WOE32DLL_H@ +# include +#else +# define LIBUNISTRING_DLL_VARIABLE +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* ========================================================================= */ + +/* Field 1 of Unicode Character Database: Character name. + See "uniname.h". */ + +/* ========================================================================= */ + +/* Field 2 of Unicode Character Database: General category. */ + +/* Data type denoting a General category value. This is not just a bitmask, + but rather a bitmask and a pointer to the lookup table, so that programs + that use only the predefined bitmasks (i.e. don't combine bitmasks with & + and |) don't have a link-time dependency towards the big general table. */ +typedef struct +{ + uint32_t bitmask : 31; + /*bool*/ unsigned int generic : 1; + union + { + const void *table; /* when generic is 0 */ + bool (*lookup_fn) (ucs4_t uc, uint32_t bitmask); /* when generic is 1 */ + } lookup; +} +uc_general_category_t; + +/* Bits and bit masks denoting General category values. UnicodeData-3.2.0.html + says a 32-bit integer will always suffice to represent them. + These bit masks can only be used with the uc_is_general_category_withtable + function. */ +enum +{ + UC_CATEGORY_MASK_L = 0x0000001f, + UC_CATEGORY_MASK_LC = 0x00000007, + UC_CATEGORY_MASK_Lu = 0x00000001, + UC_CATEGORY_MASK_Ll = 0x00000002, + UC_CATEGORY_MASK_Lt = 0x00000004, + UC_CATEGORY_MASK_Lm = 0x00000008, + UC_CATEGORY_MASK_Lo = 0x00000010, + UC_CATEGORY_MASK_M = 0x000000e0, + UC_CATEGORY_MASK_Mn = 0x00000020, + UC_CATEGORY_MASK_Mc = 0x00000040, + UC_CATEGORY_MASK_Me = 0x00000080, + UC_CATEGORY_MASK_N = 0x00000700, + UC_CATEGORY_MASK_Nd = 0x00000100, + UC_CATEGORY_MASK_Nl = 0x00000200, + UC_CATEGORY_MASK_No = 0x00000400, + UC_CATEGORY_MASK_P = 0x0003f800, + UC_CATEGORY_MASK_Pc = 0x00000800, + UC_CATEGORY_MASK_Pd = 0x00001000, + UC_CATEGORY_MASK_Ps = 0x00002000, + UC_CATEGORY_MASK_Pe = 0x00004000, + UC_CATEGORY_MASK_Pi = 0x00008000, + UC_CATEGORY_MASK_Pf = 0x00010000, + UC_CATEGORY_MASK_Po = 0x00020000, + UC_CATEGORY_MASK_S = 0x003c0000, + UC_CATEGORY_MASK_Sm = 0x00040000, + UC_CATEGORY_MASK_Sc = 0x00080000, + UC_CATEGORY_MASK_Sk = 0x00100000, + UC_CATEGORY_MASK_So = 0x00200000, + UC_CATEGORY_MASK_Z = 0x01c00000, + UC_CATEGORY_MASK_Zs = 0x00400000, + UC_CATEGORY_MASK_Zl = 0x00800000, + UC_CATEGORY_MASK_Zp = 0x01000000, + UC_CATEGORY_MASK_C = 0x3e000000, + UC_CATEGORY_MASK_Cc = 0x02000000, + UC_CATEGORY_MASK_Cf = 0x04000000, + UC_CATEGORY_MASK_Cs = 0x08000000, + UC_CATEGORY_MASK_Co = 0x10000000, + UC_CATEGORY_MASK_Cn = 0x20000000 +}; + +/* Predefined General category values. */ +extern @GNULIB_UNICTYPE_CATEGORY_L_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_L; +extern @GNULIB_UNICTYPE_CATEGORY_LC_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_LC; +extern @GNULIB_UNICTYPE_CATEGORY_LU_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_Lu; +extern @GNULIB_UNICTYPE_CATEGORY_LL_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_Ll; +extern @GNULIB_UNICTYPE_CATEGORY_LT_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_Lt; +extern @GNULIB_UNICTYPE_CATEGORY_LM_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_Lm; +extern @GNULIB_UNICTYPE_CATEGORY_LO_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_Lo; +extern @GNULIB_UNICTYPE_CATEGORY_M_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_M; +extern @GNULIB_UNICTYPE_CATEGORY_MN_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_Mn; +extern @GNULIB_UNICTYPE_CATEGORY_MC_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_Mc; +extern @GNULIB_UNICTYPE_CATEGORY_ME_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_Me; +extern @GNULIB_UNICTYPE_CATEGORY_N_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_N; +extern @GNULIB_UNICTYPE_CATEGORY_ND_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_Nd; +extern @GNULIB_UNICTYPE_CATEGORY_NL_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_Nl; +extern @GNULIB_UNICTYPE_CATEGORY_NO_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_No; +extern @GNULIB_UNICTYPE_CATEGORY_P_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_P; +extern @GNULIB_UNICTYPE_CATEGORY_PC_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_Pc; +extern @GNULIB_UNICTYPE_CATEGORY_PD_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_Pd; +extern @GNULIB_UNICTYPE_CATEGORY_PS_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_Ps; +extern @GNULIB_UNICTYPE_CATEGORY_PE_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_Pe; +extern @GNULIB_UNICTYPE_CATEGORY_PI_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_Pi; +extern @GNULIB_UNICTYPE_CATEGORY_PF_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_Pf; +extern @GNULIB_UNICTYPE_CATEGORY_PO_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_Po; +extern @GNULIB_UNICTYPE_CATEGORY_S_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_S; +extern @GNULIB_UNICTYPE_CATEGORY_SM_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_Sm; +extern @GNULIB_UNICTYPE_CATEGORY_SC_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_Sc; +extern @GNULIB_UNICTYPE_CATEGORY_SK_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_Sk; +extern @GNULIB_UNICTYPE_CATEGORY_SO_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_So; +extern @GNULIB_UNICTYPE_CATEGORY_Z_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_Z; +extern @GNULIB_UNICTYPE_CATEGORY_ZS_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_Zs; +extern @GNULIB_UNICTYPE_CATEGORY_ZL_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_Zl; +extern @GNULIB_UNICTYPE_CATEGORY_ZP_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_Zp; +extern @GNULIB_UNICTYPE_CATEGORY_C_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_C; +extern @GNULIB_UNICTYPE_CATEGORY_CC_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_Cc; +extern @GNULIB_UNICTYPE_CATEGORY_CF_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_Cf; +extern @GNULIB_UNICTYPE_CATEGORY_CS_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_Cs; +extern @GNULIB_UNICTYPE_CATEGORY_CO_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_Co; +extern @GNULIB_UNICTYPE_CATEGORY_CN_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_Cn; +/* Non-public. */ +extern const uc_general_category_t _UC_CATEGORY_NONE; + +/* Alias names for predefined General category values. */ +#define UC_LETTER UC_CATEGORY_L +#define UC_CASED_LETTER UC_CATEGORY_LC +#define UC_UPPERCASE_LETTER UC_CATEGORY_Lu +#define UC_LOWERCASE_LETTER UC_CATEGORY_Ll +#define UC_TITLECASE_LETTER UC_CATEGORY_Lt +#define UC_MODIFIER_LETTER UC_CATEGORY_Lm +#define UC_OTHER_LETTER UC_CATEGORY_Lo +#define UC_MARK UC_CATEGORY_M +#define UC_NON_SPACING_MARK UC_CATEGORY_Mn +#define UC_COMBINING_SPACING_MARK UC_CATEGORY_Mc +#define UC_ENCLOSING_MARK UC_CATEGORY_Me +#define UC_NUMBER UC_CATEGORY_N +#define UC_DECIMAL_DIGIT_NUMBER UC_CATEGORY_Nd +#define UC_LETTER_NUMBER UC_CATEGORY_Nl +#define UC_OTHER_NUMBER UC_CATEGORY_No +#define UC_PUNCTUATION UC_CATEGORY_P +#define UC_CONNECTOR_PUNCTUATION UC_CATEGORY_Pc +#define UC_DASH_PUNCTUATION UC_CATEGORY_Pd +#define UC_OPEN_PUNCTUATION UC_CATEGORY_Ps /* a.k.a. UC_START_PUNCTUATION */ +#define UC_CLOSE_PUNCTUATION UC_CATEGORY_Pe /* a.k.a. UC_END_PUNCTUATION */ +#define UC_INITIAL_QUOTE_PUNCTUATION UC_CATEGORY_Pi +#define UC_FINAL_QUOTE_PUNCTUATION UC_CATEGORY_Pf +#define UC_OTHER_PUNCTUATION UC_CATEGORY_Po +#define UC_SYMBOL UC_CATEGORY_S +#define UC_MATH_SYMBOL UC_CATEGORY_Sm +#define UC_CURRENCY_SYMBOL UC_CATEGORY_Sc +#define UC_MODIFIER_SYMBOL UC_CATEGORY_Sk +#define UC_OTHER_SYMBOL UC_CATEGORY_So +#define UC_SEPARATOR UC_CATEGORY_Z +#define UC_SPACE_SEPARATOR UC_CATEGORY_Zs +#define UC_LINE_SEPARATOR UC_CATEGORY_Zl +#define UC_PARAGRAPH_SEPARATOR UC_CATEGORY_Zp +#define UC_OTHER UC_CATEGORY_C +#define UC_CONTROL UC_CATEGORY_Cc +#define UC_FORMAT UC_CATEGORY_Cf +#define UC_SURROGATE UC_CATEGORY_Cs /* all of them are invalid characters */ +#define UC_PRIVATE_USE UC_CATEGORY_Co +#define UC_UNASSIGNED UC_CATEGORY_Cn /* some of them are invalid characters */ + +/* Return the union of two general categories. + This corresponds to the unions of the two sets of characters. */ +extern uc_general_category_t + uc_general_category_or (uc_general_category_t category1, + uc_general_category_t category2); + +/* Return the intersection of two general categories as bit masks. + This *does*not* correspond to the intersection of the two sets of + characters. */ +extern uc_general_category_t + uc_general_category_and (uc_general_category_t category1, + uc_general_category_t category2); + +/* Return the intersection of a general category with the complement of a + second general category, as bit masks. + This *does*not* correspond to the intersection with complement, when + viewing the categories as sets of characters. */ +extern uc_general_category_t + uc_general_category_and_not (uc_general_category_t category1, + uc_general_category_t category2); + +/* Return the name of a general category. */ +extern const char * + uc_general_category_name (uc_general_category_t category) + _UC_ATTRIBUTE_PURE; + +/* Return the long name of a general category. */ +extern const char * + uc_general_category_long_name (uc_general_category_t category) + _UC_ATTRIBUTE_PURE; + +/* Return the general category given by name, e.g. "Lu", or by long name, + e.g. "Uppercase Letter". */ +extern uc_general_category_t + uc_general_category_byname (const char *category_name) + _UC_ATTRIBUTE_PURE; + +/* Return the general category of a Unicode character. */ +extern uc_general_category_t + uc_general_category (ucs4_t uc) + _UC_ATTRIBUTE_PURE; + +/* Test whether a Unicode character belongs to a given category. + The CATEGORY argument can be the combination of several predefined + general categories. */ +extern bool + uc_is_general_category (ucs4_t uc, uc_general_category_t category) + _UC_ATTRIBUTE_PURE; +/* Likewise. This function uses a big table comprising all categories. */ +extern bool + uc_is_general_category_withtable (ucs4_t uc, uint32_t bitmask) + _UC_ATTRIBUTE_CONST; + +/* ========================================================================= */ + +/* Field 3 of Unicode Character Database: Canonical combining class. */ + +/* The possible results of uc_combining_class (0..255) are described in + UCD.html. The list here is not definitive; more values can be added + in future versions. */ +enum +{ + UC_CCC_NR = 0, /* Not Reordered */ + UC_CCC_OV = 1, /* Overlay */ + UC_CCC_NK = 7, /* Nukta */ + UC_CCC_KV = 8, /* Kana Voicing */ + UC_CCC_VR = 9, /* Virama */ + UC_CCC_ATBL = 200, /* Attached Below Left */ + UC_CCC_ATB = 202, /* Attached Below */ + UC_CCC_ATA = 214, /* Attached Above */ + UC_CCC_ATAR = 216, /* Attached Above Right */ + UC_CCC_BL = 218, /* Below Left */ + UC_CCC_B = 220, /* Below */ + UC_CCC_BR = 222, /* Below Right */ + UC_CCC_L = 224, /* Left */ + UC_CCC_R = 226, /* Right */ + UC_CCC_AL = 228, /* Above Left */ + UC_CCC_A = 230, /* Above */ + UC_CCC_AR = 232, /* Above Right */ + UC_CCC_DB = 233, /* Double Below */ + UC_CCC_DA = 234, /* Double Above */ + UC_CCC_IS = 240 /* Iota Subscript */ +}; + +/* Return the canonical combining class of a Unicode character. */ +extern int + uc_combining_class (ucs4_t uc) + _UC_ATTRIBUTE_CONST; + +/* Return the name of a canonical combining class. */ +extern const char * + uc_combining_class_name (int ccc) + _UC_ATTRIBUTE_CONST; + +/* Return the long name of a canonical combining class. */ +extern const char * + uc_combining_class_long_name (int ccc) + _UC_ATTRIBUTE_CONST; + +/* Return the canonical combining class given by name, e.g. "BL", or by long + name, e.g. "Below Left". */ +extern int + uc_combining_class_byname (const char *ccc_name) + _UC_ATTRIBUTE_PURE; + +/* ========================================================================= */ + +/* Field 4 of Unicode Character Database: Bidi class. + Before Unicode 4.0, this field was called "Bidirectional category". */ + +enum +{ + UC_BIDI_L, /* Left-to-Right */ + UC_BIDI_LRE, /* Left-to-Right Embedding */ + UC_BIDI_LRO, /* Left-to-Right Override */ + UC_BIDI_R, /* Right-to-Left */ + UC_BIDI_AL, /* Right-to-Left Arabic */ + UC_BIDI_RLE, /* Right-to-Left Embedding */ + UC_BIDI_RLO, /* Right-to-Left Override */ + UC_BIDI_PDF, /* Pop Directional Format */ + UC_BIDI_EN, /* European Number */ + UC_BIDI_ES, /* European Number Separator */ + UC_BIDI_ET, /* European Number Terminator */ + UC_BIDI_AN, /* Arabic Number */ + UC_BIDI_CS, /* Common Number Separator */ + UC_BIDI_NSM, /* Non-Spacing Mark */ + UC_BIDI_BN, /* Boundary Neutral */ + UC_BIDI_B, /* Paragraph Separator */ + UC_BIDI_S, /* Segment Separator */ + UC_BIDI_WS, /* Whitespace */ + UC_BIDI_ON, /* Other Neutral */ + UC_BIDI_LRI, /* Left-to-Right Isolate */ + UC_BIDI_RLI, /* Right-to-Left Isolate */ + UC_BIDI_FSI, /* First Strong Isolate */ + UC_BIDI_PDI /* Pop Directional Isolate */ +}; + +/* Return the name of a bidi class. */ +extern const char * + uc_bidi_class_name (int bidi_class) + _UC_ATTRIBUTE_CONST; +/* Same; obsolete function name. */ +extern const char * + uc_bidi_category_name (int category) + _UC_ATTRIBUTE_CONST; + +/* Return the long name of a bidi class. */ +extern const char * + uc_bidi_class_long_name (int bidi_class) + _UC_ATTRIBUTE_CONST; + +/* Return the bidi class given by name, e.g. "LRE", or by long name, e.g. + "Left-to-Right Embedding". */ +extern int + uc_bidi_class_byname (const char *bidi_class_name) + _UC_ATTRIBUTE_PURE; +/* Same; obsolete function name. */ +extern int + uc_bidi_category_byname (const char *category_name) + _UC_ATTRIBUTE_PURE; + +/* Return the bidi class of a Unicode character. */ +extern int + uc_bidi_class (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +/* Same; obsolete function name. */ +extern int + uc_bidi_category (ucs4_t uc) + _UC_ATTRIBUTE_CONST; + +/* Test whether a Unicode character belongs to a given bidi class. */ +extern bool + uc_is_bidi_class (ucs4_t uc, int bidi_class) + _UC_ATTRIBUTE_CONST; +/* Same; obsolete function name. */ +extern bool + uc_is_bidi_category (ucs4_t uc, int category) + _UC_ATTRIBUTE_CONST; + +/* ========================================================================= */ + +/* Field 5 of Unicode Character Database: Character decomposition mapping. + See "uninorm.h". */ + +/* ========================================================================= */ + +/* Field 6 of Unicode Character Database: Decimal digit value. */ + +/* Return the decimal digit value of a Unicode character. */ +extern int + uc_decimal_value (ucs4_t uc) + _UC_ATTRIBUTE_CONST; + +/* ========================================================================= */ + +/* Field 7 of Unicode Character Database: Digit value. */ + +/* Return the digit value of a Unicode character. */ +extern int + uc_digit_value (ucs4_t uc) + _UC_ATTRIBUTE_CONST; + +/* ========================================================================= */ + +/* Field 8 of Unicode Character Database: Numeric value. */ + +/* Return the numeric value of a Unicode character. */ +typedef struct +{ + int numerator; + int denominator; +} +uc_fraction_t; +extern uc_fraction_t + uc_numeric_value (ucs4_t uc) + _UC_ATTRIBUTE_CONST; + +/* ========================================================================= */ + +/* Field 9 of Unicode Character Database: Mirrored. */ + +/* Return the mirrored character of a Unicode character UC in *PUC. */ +extern bool + uc_mirror_char (ucs4_t uc, ucs4_t *puc); + +/* ========================================================================= */ + +/* Field 10 of Unicode Character Database: Unicode 1.0 Name. + Not available in this library. */ + +/* ========================================================================= */ + +/* Field 11 of Unicode Character Database: ISO 10646 comment. + Not available in this library. */ + +/* ========================================================================= */ + +/* Field 12, 13, 14 of Unicode Character Database: Uppercase mapping, + lowercase mapping, titlecase mapping. See "unicase.h". */ + +/* ========================================================================= */ + +/* Field 2 of the file ArabicShaping.txt in the Unicode Character Database. */ + +/* Possible joining types. */ +enum +{ + UC_JOINING_TYPE_U, /* Non_Joining */ + UC_JOINING_TYPE_T, /* Transparent */ + UC_JOINING_TYPE_C, /* Join_Causing */ + UC_JOINING_TYPE_L, /* Left_Joining */ + UC_JOINING_TYPE_R, /* Right_Joining */ + UC_JOINING_TYPE_D /* Dual_Joining */ +}; + +/* Return the name of a joining type. */ +extern const char * + uc_joining_type_name (int joining_type) + _UC_ATTRIBUTE_CONST; + +/* Return the long name of a joining type. */ +extern const char * + uc_joining_type_long_name (int joining_type) + _UC_ATTRIBUTE_CONST; + +/* Return the joining type given by name, e.g. "D", or by long name, e.g. + "Dual Joining". */ +extern int + uc_joining_type_byname (const char *joining_type_name) + _UC_ATTRIBUTE_PURE; + +/* Return the joining type of a Unicode character. */ +extern int + uc_joining_type (ucs4_t uc) + _UC_ATTRIBUTE_CONST; + +/* ========================================================================= */ + +/* Field 3 of the file ArabicShaping.txt in the Unicode Character Database. */ + +/* Possible joining groups. + This enumeration may be extended in the future. */ +enum +{ + UC_JOINING_GROUP_NONE, /* No_Joining_Group */ + UC_JOINING_GROUP_AIN, /* Ain */ + UC_JOINING_GROUP_ALAPH, /* Alaph */ + UC_JOINING_GROUP_ALEF, /* Alef */ + UC_JOINING_GROUP_BEH, /* Beh */ + UC_JOINING_GROUP_BETH, /* Beth */ + UC_JOINING_GROUP_BURUSHASKI_YEH_BARREE, /* Burushaski_Yeh_Barree */ + UC_JOINING_GROUP_DAL, /* Dal */ + UC_JOINING_GROUP_DALATH_RISH, /* Dalath_Rish */ + UC_JOINING_GROUP_E, /* E */ + UC_JOINING_GROUP_FARSI_YEH, /* Farsi_Yeh */ + UC_JOINING_GROUP_FE, /* Fe */ + UC_JOINING_GROUP_FEH, /* Feh */ + UC_JOINING_GROUP_FINAL_SEMKATH, /* Final_Semkath */ + UC_JOINING_GROUP_GAF, /* Gaf */ + UC_JOINING_GROUP_GAMAL, /* Gamal */ + UC_JOINING_GROUP_HAH, /* Hah */ + UC_JOINING_GROUP_HE, /* He */ + UC_JOINING_GROUP_HEH, /* Heh */ + UC_JOINING_GROUP_HEH_GOAL, /* Heh_Goal */ + UC_JOINING_GROUP_HETH, /* Heth */ + UC_JOINING_GROUP_KAF, /* Kaf */ + UC_JOINING_GROUP_KAPH, /* Kaph */ + UC_JOINING_GROUP_KHAPH, /* Khaph */ + UC_JOINING_GROUP_KNOTTED_HEH, /* Knotted_Heh */ + UC_JOINING_GROUP_LAM, /* Lam */ + UC_JOINING_GROUP_LAMADH, /* Lamadh */ + UC_JOINING_GROUP_MEEM, /* Meem */ + UC_JOINING_GROUP_MIM, /* Mim */ + UC_JOINING_GROUP_NOON, /* Noon */ + UC_JOINING_GROUP_NUN, /* Nun */ + UC_JOINING_GROUP_NYA, /* Nya */ + UC_JOINING_GROUP_PE, /* Pe */ + UC_JOINING_GROUP_QAF, /* Qaf */ + UC_JOINING_GROUP_QAPH, /* Qaph */ + UC_JOINING_GROUP_REH, /* Reh */ + UC_JOINING_GROUP_REVERSED_PE, /* Reversed_Pe */ + UC_JOINING_GROUP_SAD, /* Sad */ + UC_JOINING_GROUP_SADHE, /* Sadhe */ + UC_JOINING_GROUP_SEEN, /* Seen */ + UC_JOINING_GROUP_SEMKATH, /* Semkath */ + UC_JOINING_GROUP_SHIN, /* Shin */ + UC_JOINING_GROUP_SWASH_KAF, /* Swash_Kaf */ + UC_JOINING_GROUP_SYRIAC_WAW, /* Syriac_Waw */ + UC_JOINING_GROUP_TAH, /* Tah */ + UC_JOINING_GROUP_TAW, /* Taw */ + UC_JOINING_GROUP_TEH_MARBUTA, /* Teh_Marbuta */ + UC_JOINING_GROUP_TEH_MARBUTA_GOAL, /* Teh_Marbuta_Goal */ + UC_JOINING_GROUP_TETH, /* Teth */ + UC_JOINING_GROUP_WAW, /* Waw */ + UC_JOINING_GROUP_YEH, /* Yeh */ + UC_JOINING_GROUP_YEH_BARREE, /* Yeh_Barree */ + UC_JOINING_GROUP_YEH_WITH_TAIL, /* Yeh_With_Tail */ + UC_JOINING_GROUP_YUDH, /* Yudh */ + UC_JOINING_GROUP_YUDH_HE, /* Yudh_He */ + UC_JOINING_GROUP_ZAIN, /* Zain */ + UC_JOINING_GROUP_ZHAIN, /* Zhain */ + UC_JOINING_GROUP_ROHINGYA_YEH, /* Rohingya_Yeh */ + UC_JOINING_GROUP_STRAIGHT_WAW, /* Straight_Waw */ + UC_JOINING_GROUP_MANICHAEAN_ALEPH, /* Manichaean_Aleph */ + UC_JOINING_GROUP_MANICHAEAN_BETH, /* Manichaean_Beth */ + UC_JOINING_GROUP_MANICHAEAN_GIMEL, /* Manichaean_Gimel */ + UC_JOINING_GROUP_MANICHAEAN_DALETH, /* Manichaean_Daleth */ + UC_JOINING_GROUP_MANICHAEAN_WAW, /* Manichaean_Waw */ + UC_JOINING_GROUP_MANICHAEAN_ZAYIN, /* Manichaean_Zayin */ + UC_JOINING_GROUP_MANICHAEAN_HETH, /* Manichaean_Heth */ + UC_JOINING_GROUP_MANICHAEAN_TETH, /* Manichaean_Teth */ + UC_JOINING_GROUP_MANICHAEAN_YODH, /* Manichaean_Yodh */ + UC_JOINING_GROUP_MANICHAEAN_KAPH, /* Manichaean_Kaph */ + UC_JOINING_GROUP_MANICHAEAN_LAMEDH, /* Manichaean_Lamedh */ + UC_JOINING_GROUP_MANICHAEAN_DHAMEDH, /* Manichaean_Dhamedh */ + UC_JOINING_GROUP_MANICHAEAN_THAMEDH, /* Manichaean_Thamedh */ + UC_JOINING_GROUP_MANICHAEAN_MEM, /* Manichaean_Mem */ + UC_JOINING_GROUP_MANICHAEAN_NUN, /* Manichaean_Nun */ + UC_JOINING_GROUP_MANICHAEAN_SAMEKH, /* Manichaean_Aleph */ + UC_JOINING_GROUP_MANICHAEAN_AYIN, /* Manichaean_Ayin */ + UC_JOINING_GROUP_MANICHAEAN_PE, /* Manichaean_Pe */ + UC_JOINING_GROUP_MANICHAEAN_SADHE, /* Manichaean_Sadhe */ + UC_JOINING_GROUP_MANICHAEAN_QOPH, /* Manichaean_Qoph */ + UC_JOINING_GROUP_MANICHAEAN_RESH, /* Manichaean_Resh */ + UC_JOINING_GROUP_MANICHAEAN_TAW, /* Manichaean_Taw */ + UC_JOINING_GROUP_MANICHAEAN_ONE, /* Manichaean_One */ + UC_JOINING_GROUP_MANICHAEAN_FIVE, /* Manichaean_Five */ + UC_JOINING_GROUP_MANICHAEAN_TEN, /* Manichaean_Ten */ + UC_JOINING_GROUP_MANICHAEAN_TWENTY, /* Manichaean_Twenty */ + UC_JOINING_GROUP_MANICHAEAN_HUNDRED, /* Manichaean_Hundred */ + UC_JOINING_GROUP_AFRICAN_FEH, /* African_Feh */ + UC_JOINING_GROUP_AFRICAN_QAF, /* African_Qaf */ + UC_JOINING_GROUP_AFRICAN_NOON, /* African_Noon */ + UC_JOINING_GROUP_MALAYALAM_NGA, /* Malayalam_Nga */ + UC_JOINING_GROUP_MALAYALAM_JA, /* Malayalam_Ja */ + UC_JOINING_GROUP_MALAYALAM_NYA, /* Malayalam_Nya */ + UC_JOINING_GROUP_MALAYALAM_TTA, /* Malayalam_Tta */ + UC_JOINING_GROUP_MALAYALAM_NNA, /* Malayalam_Nna */ + UC_JOINING_GROUP_MALAYALAM_NNNA, /* Malayalam_Nnna */ + UC_JOINING_GROUP_MALAYALAM_BHA, /* Malayalam_Bha */ + UC_JOINING_GROUP_MALAYALAM_RA, /* Malayalam_Ra */ + UC_JOINING_GROUP_MALAYALAM_LLA, /* Malayalam_Lla */ + UC_JOINING_GROUP_MALAYALAM_LLLA, /* Malayalam_Llla */ + UC_JOINING_GROUP_MALAYALAM_SSA, /* Malayalam_Ssa */ + UC_JOINING_GROUP_HANIFI_ROHINGYA_PA, /* Hanifi_Rohingya_Pa */ + UC_JOINING_GROUP_HANIFI_ROHINGYA_KINNA_YA, /* Hanifi_Rohingya_Kinna_Ya */ + UC_JOINING_GROUP_THIN_YEH, /* Thin_Yeh */ + UC_JOINING_GROUP_VERTICAL_TAIL /* Vertical_Tail */ +}; + +/* Return the name of a joining group. */ +extern const char * + uc_joining_group_name (int joining_group) + _UC_ATTRIBUTE_CONST; + +/* Return the joining group given by name, e.g. "Teh_Marbuta". */ +extern int + uc_joining_group_byname (const char *joining_group_name) + _UC_ATTRIBUTE_PURE; + +/* Return the joining group of a Unicode character. */ +extern int + uc_joining_group (ucs4_t uc) + _UC_ATTRIBUTE_CONST; + +/* ========================================================================= */ + +/* Common API for properties. */ + +/* Data type denoting a property. This is not just a number, but rather a + pointer to the test functions, so that programs that use only few of the + properties don't have a link-time dependency towards all the tables. */ +typedef struct +{ + bool (*test_fn) (ucs4_t uc); +} +uc_property_t; + +/* Predefined properties. */ +/* General. */ +extern @GNULIB_UNICTYPE_PROPERTY_WHITE_SPACE_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_WHITE_SPACE; +extern @GNULIB_UNICTYPE_PROPERTY_ALPHABETIC_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_ALPHABETIC; +extern @GNULIB_UNICTYPE_PROPERTY_OTHER_ALPHABETIC_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_OTHER_ALPHABETIC; +extern @GNULIB_UNICTYPE_PROPERTY_NOT_A_CHARACTER_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_NOT_A_CHARACTER; +extern @GNULIB_UNICTYPE_PROPERTY_DEFAULT_IGNORABLE_CODE_POINT_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_DEFAULT_IGNORABLE_CODE_POINT; +extern @GNULIB_UNICTYPE_PROPERTY_OTHER_DEFAULT_IGNORABLE_CODE_POINT_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_OTHER_DEFAULT_IGNORABLE_CODE_POINT; +extern @GNULIB_UNICTYPE_PROPERTY_DEPRECATED_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_DEPRECATED; +extern @GNULIB_UNICTYPE_PROPERTY_LOGICAL_ORDER_EXCEPTION_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_LOGICAL_ORDER_EXCEPTION; +extern @GNULIB_UNICTYPE_PROPERTY_VARIATION_SELECTOR_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_VARIATION_SELECTOR; +extern @GNULIB_UNICTYPE_PROPERTY_PRIVATE_USE_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_PRIVATE_USE; +extern @GNULIB_UNICTYPE_PROPERTY_UNASSIGNED_CODE_VALUE_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_UNASSIGNED_CODE_VALUE; +/* Case. */ +extern @GNULIB_UNICTYPE_PROPERTY_UPPERCASE_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_UPPERCASE; +extern @GNULIB_UNICTYPE_PROPERTY_OTHER_UPPERCASE_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_OTHER_UPPERCASE; +extern @GNULIB_UNICTYPE_PROPERTY_LOWERCASE_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_LOWERCASE; +extern @GNULIB_UNICTYPE_PROPERTY_OTHER_LOWERCASE_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_OTHER_LOWERCASE; +extern @GNULIB_UNICTYPE_PROPERTY_TITLECASE_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_TITLECASE; +extern @GNULIB_UNICTYPE_PROPERTY_CASED_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_CASED; +extern @GNULIB_UNICTYPE_PROPERTY_CASE_IGNORABLE_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_CASE_IGNORABLE; +extern @GNULIB_UNICTYPE_PROPERTY_CHANGES_WHEN_LOWERCASED_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_CHANGES_WHEN_LOWERCASED; +extern @GNULIB_UNICTYPE_PROPERTY_CHANGES_WHEN_UPPERCASED_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_CHANGES_WHEN_UPPERCASED; +extern @GNULIB_UNICTYPE_PROPERTY_CHANGES_WHEN_TITLECASED_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_CHANGES_WHEN_TITLECASED; +extern @GNULIB_UNICTYPE_PROPERTY_CHANGES_WHEN_CASEFOLDED_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_CHANGES_WHEN_CASEFOLDED; +extern @GNULIB_UNICTYPE_PROPERTY_CHANGES_WHEN_CASEMAPPED_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_CHANGES_WHEN_CASEMAPPED; +extern @GNULIB_UNICTYPE_PROPERTY_SOFT_DOTTED_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_SOFT_DOTTED; +/* Identifiers. */ +extern @GNULIB_UNICTYPE_PROPERTY_ID_START_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_ID_START; +extern @GNULIB_UNICTYPE_PROPERTY_OTHER_ID_START_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_OTHER_ID_START; +extern @GNULIB_UNICTYPE_PROPERTY_ID_CONTINUE_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_ID_CONTINUE; +extern @GNULIB_UNICTYPE_PROPERTY_OTHER_ID_CONTINUE_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_OTHER_ID_CONTINUE; +extern @GNULIB_UNICTYPE_PROPERTY_XID_START_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_XID_START; +extern @GNULIB_UNICTYPE_PROPERTY_XID_CONTINUE_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_XID_CONTINUE; +extern @GNULIB_UNICTYPE_PROPERTY_PATTERN_WHITE_SPACE_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_PATTERN_WHITE_SPACE; +extern @GNULIB_UNICTYPE_PROPERTY_PATTERN_SYNTAX_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_PATTERN_SYNTAX; +/* Shaping and rendering. */ +extern @GNULIB_UNICTYPE_PROPERTY_JOIN_CONTROL_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_JOIN_CONTROL; +extern @GNULIB_UNICTYPE_PROPERTY_GRAPHEME_BASE_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_GRAPHEME_BASE; +extern @GNULIB_UNICTYPE_PROPERTY_GRAPHEME_EXTEND_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_GRAPHEME_EXTEND; +extern @GNULIB_UNICTYPE_PROPERTY_OTHER_GRAPHEME_EXTEND_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_OTHER_GRAPHEME_EXTEND; +extern @GNULIB_UNICTYPE_PROPERTY_GRAPHEME_LINK_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_GRAPHEME_LINK; +/* Bidi. */ +extern @GNULIB_UNICTYPE_PROPERTY_BIDI_CONTROL_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_BIDI_CONTROL; +extern @GNULIB_UNICTYPE_PROPERTY_BIDI_LEFT_TO_RIGHT_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_BIDI_LEFT_TO_RIGHT; +extern @GNULIB_UNICTYPE_PROPERTY_BIDI_HEBREW_RIGHT_TO_LEFT_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_BIDI_HEBREW_RIGHT_TO_LEFT; +extern @GNULIB_UNICTYPE_PROPERTY_BIDI_ARABIC_RIGHT_TO_LEFT_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_BIDI_ARABIC_RIGHT_TO_LEFT; +extern @GNULIB_UNICTYPE_PROPERTY_BIDI_EUROPEAN_DIGIT_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_BIDI_EUROPEAN_DIGIT; +extern @GNULIB_UNICTYPE_PROPERTY_BIDI_EUR_NUM_SEPARATOR_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_BIDI_EUR_NUM_SEPARATOR; +extern @GNULIB_UNICTYPE_PROPERTY_BIDI_EUR_NUM_TERMINATOR_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_BIDI_EUR_NUM_TERMINATOR; +extern @GNULIB_UNICTYPE_PROPERTY_BIDI_ARABIC_DIGIT_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_BIDI_ARABIC_DIGIT; +extern @GNULIB_UNICTYPE_PROPERTY_BIDI_COMMON_SEPARATOR_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_BIDI_COMMON_SEPARATOR; +extern @GNULIB_UNICTYPE_PROPERTY_BIDI_BLOCK_SEPARATOR_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_BIDI_BLOCK_SEPARATOR; +extern @GNULIB_UNICTYPE_PROPERTY_BIDI_SEGMENT_SEPARATOR_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_BIDI_SEGMENT_SEPARATOR; +extern @GNULIB_UNICTYPE_PROPERTY_BIDI_WHITESPACE_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_BIDI_WHITESPACE; +extern @GNULIB_UNICTYPE_PROPERTY_BIDI_NON_SPACING_MARK_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_BIDI_NON_SPACING_MARK; +extern @GNULIB_UNICTYPE_PROPERTY_BIDI_BOUNDARY_NEUTRAL_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_BIDI_BOUNDARY_NEUTRAL; +extern @GNULIB_UNICTYPE_PROPERTY_BIDI_PDF_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_BIDI_PDF; +extern @GNULIB_UNICTYPE_PROPERTY_BIDI_EMBEDDING_OR_OVERRIDE_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_BIDI_EMBEDDING_OR_OVERRIDE; +extern @GNULIB_UNICTYPE_PROPERTY_BIDI_OTHER_NEUTRAL_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_BIDI_OTHER_NEUTRAL; +/* Numeric. */ +extern @GNULIB_UNICTYPE_PROPERTY_HEX_DIGIT_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_HEX_DIGIT; +extern @GNULIB_UNICTYPE_PROPERTY_ASCII_HEX_DIGIT_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_ASCII_HEX_DIGIT; +/* CJK. */ +extern @GNULIB_UNICTYPE_PROPERTY_IDEOGRAPHIC_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_IDEOGRAPHIC; +extern @GNULIB_UNICTYPE_PROPERTY_UNIFIED_IDEOGRAPH_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_UNIFIED_IDEOGRAPH; +extern @GNULIB_UNICTYPE_PROPERTY_RADICAL_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_RADICAL; +extern @GNULIB_UNICTYPE_PROPERTY_IDS_BINARY_OPERATOR_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_IDS_BINARY_OPERATOR; +extern @GNULIB_UNICTYPE_PROPERTY_IDS_TRINARY_OPERATOR_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_IDS_TRINARY_OPERATOR; +/* Emoji. */ +extern @GNULIB_UNICTYPE_PROPERTY_EMOJI_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_EMOJI; +extern @GNULIB_UNICTYPE_PROPERTY_EMOJI_PRESENTATION_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_EMOJI_PRESENTATION; +extern @GNULIB_UNICTYPE_PROPERTY_EMOJI_MODIFIER_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_EMOJI_MODIFIER; +extern @GNULIB_UNICTYPE_PROPERTY_EMOJI_MODIFIER_BASE_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_EMOJI_MODIFIER_BASE; +extern @GNULIB_UNICTYPE_PROPERTY_EMOJI_COMPONENT_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_EMOJI_COMPONENT; +extern @GNULIB_UNICTYPE_PROPERTY_EXTENDED_PICTOGRAPHIC_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_EXTENDED_PICTOGRAPHIC; +/* Misc. */ +extern @GNULIB_UNICTYPE_PROPERTY_ZERO_WIDTH_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_ZERO_WIDTH; +extern @GNULIB_UNICTYPE_PROPERTY_SPACE_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_SPACE; +extern @GNULIB_UNICTYPE_PROPERTY_NON_BREAK_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_NON_BREAK; +extern @GNULIB_UNICTYPE_PROPERTY_ISO_CONTROL_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_ISO_CONTROL; +extern @GNULIB_UNICTYPE_PROPERTY_FORMAT_CONTROL_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_FORMAT_CONTROL; +extern @GNULIB_UNICTYPE_PROPERTY_DASH_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_DASH; +extern @GNULIB_UNICTYPE_PROPERTY_HYPHEN_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_HYPHEN; +extern @GNULIB_UNICTYPE_PROPERTY_PUNCTUATION_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_PUNCTUATION; +extern @GNULIB_UNICTYPE_PROPERTY_LINE_SEPARATOR_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_LINE_SEPARATOR; +extern @GNULIB_UNICTYPE_PROPERTY_PARAGRAPH_SEPARATOR_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_PARAGRAPH_SEPARATOR; +extern @GNULIB_UNICTYPE_PROPERTY_QUOTATION_MARK_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_QUOTATION_MARK; +extern @GNULIB_UNICTYPE_PROPERTY_SENTENCE_TERMINAL_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_SENTENCE_TERMINAL; +extern @GNULIB_UNICTYPE_PROPERTY_TERMINAL_PUNCTUATION_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_TERMINAL_PUNCTUATION; +extern @GNULIB_UNICTYPE_PROPERTY_CURRENCY_SYMBOL_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_CURRENCY_SYMBOL; +extern @GNULIB_UNICTYPE_PROPERTY_MATH_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_MATH; +extern @GNULIB_UNICTYPE_PROPERTY_OTHER_MATH_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_OTHER_MATH; +extern @GNULIB_UNICTYPE_PROPERTY_PAIRED_PUNCTUATION_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_PAIRED_PUNCTUATION; +extern @GNULIB_UNICTYPE_PROPERTY_LEFT_OF_PAIR_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_LEFT_OF_PAIR; +extern @GNULIB_UNICTYPE_PROPERTY_COMBINING_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_COMBINING; +extern @GNULIB_UNICTYPE_PROPERTY_COMPOSITE_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_COMPOSITE; +extern @GNULIB_UNICTYPE_PROPERTY_DECIMAL_DIGIT_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_DECIMAL_DIGIT; +extern @GNULIB_UNICTYPE_PROPERTY_NUMERIC_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_NUMERIC; +extern @GNULIB_UNICTYPE_PROPERTY_DIACRITIC_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_DIACRITIC; +extern @GNULIB_UNICTYPE_PROPERTY_EXTENDER_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_EXTENDER; +extern @GNULIB_UNICTYPE_PROPERTY_IGNORABLE_CONTROL_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_IGNORABLE_CONTROL; +extern @GNULIB_UNICTYPE_PROPERTY_REGIONAL_INDICATOR_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_REGIONAL_INDICATOR; + +/* Return the property given by name, e.g. "White space". */ +extern uc_property_t + uc_property_byname (const char *property_name); + +/* Test whether a property is valid. */ +#define uc_property_is_valid(property) ((property).test_fn != NULL) + +/* Test whether a Unicode character has a given property. */ +extern bool + uc_is_property (ucs4_t uc, uc_property_t property); +extern bool uc_is_property_white_space (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_alphabetic (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_other_alphabetic (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_not_a_character (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_default_ignorable_code_point (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_other_default_ignorable_code_point (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_deprecated (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_logical_order_exception (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_variation_selector (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_private_use (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_unassigned_code_value (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_uppercase (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_other_uppercase (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_lowercase (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_other_lowercase (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_titlecase (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_cased (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_case_ignorable (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_changes_when_lowercased (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_changes_when_uppercased (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_changes_when_titlecased (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_changes_when_casefolded (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_changes_when_casemapped (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_soft_dotted (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_id_start (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_other_id_start (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_id_continue (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_other_id_continue (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_xid_start (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_xid_continue (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_pattern_white_space (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_pattern_syntax (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_join_control (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_grapheme_base (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_grapheme_extend (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_other_grapheme_extend (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_grapheme_link (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_bidi_control (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_bidi_left_to_right (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_bidi_hebrew_right_to_left (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_bidi_arabic_right_to_left (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_bidi_european_digit (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_bidi_eur_num_separator (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_bidi_eur_num_terminator (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_bidi_arabic_digit (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_bidi_common_separator (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_bidi_block_separator (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_bidi_segment_separator (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_bidi_whitespace (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_bidi_non_spacing_mark (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_bidi_boundary_neutral (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_bidi_pdf (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_bidi_embedding_or_override (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_bidi_other_neutral (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_hex_digit (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_ascii_hex_digit (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_ideographic (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_unified_ideograph (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_radical (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_ids_binary_operator (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_ids_trinary_operator (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_emoji (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_emoji_presentation (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_emoji_modifier (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_emoji_modifier_base (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_emoji_component (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_extended_pictographic (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_zero_width (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_space (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_non_break (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_iso_control (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_format_control (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_dash (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_hyphen (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_punctuation (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_line_separator (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_paragraph_separator (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_quotation_mark (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_sentence_terminal (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_terminal_punctuation (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_currency_symbol (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_math (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_other_math (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_paired_punctuation (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_left_of_pair (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_combining (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_composite (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_decimal_digit (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_numeric (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_diacritic (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_extender (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_ignorable_control (ucs4_t uc) + _UC_ATTRIBUTE_CONST; +extern bool uc_is_property_regional_indicator (ucs4_t uc) + _UC_ATTRIBUTE_CONST; + +/* ========================================================================= */ + +/* Subdivision of the Unicode characters into scripts. */ + +typedef struct +{ + unsigned int code : 21; + unsigned int start : 1; + unsigned int end : 1; +} +uc_interval_t; +typedef struct +{ + unsigned int nintervals; + const uc_interval_t *intervals; + const char *name; +} +uc_script_t; + +/* Return the script of a Unicode character. */ +extern const uc_script_t * + uc_script (ucs4_t uc) + _UC_ATTRIBUTE_CONST; + +/* Return the script given by name, e.g. "HAN". */ +extern const uc_script_t * + uc_script_byname (const char *script_name) + _UC_ATTRIBUTE_PURE; + +/* Test whether a Unicode character belongs to a given script. */ +extern bool + uc_is_script (ucs4_t uc, const uc_script_t *script) + _UC_ATTRIBUTE_PURE; + +/* Get the list of all scripts. */ +extern void + uc_all_scripts (const uc_script_t **scripts, size_t *count); + +/* ========================================================================= */ + +/* Subdivision of the Unicode character range into blocks. */ + +typedef struct +{ + ucs4_t start; + ucs4_t end; + const char *name; +} +uc_block_t; + +/* Return the block a character belongs to. */ +extern const uc_block_t * + uc_block (ucs4_t uc) + _UC_ATTRIBUTE_CONST; + +/* Test whether a Unicode character belongs to a given block. */ +extern bool + uc_is_block (ucs4_t uc, const uc_block_t *block) + _UC_ATTRIBUTE_PURE; + +/* Get the list of all blocks. */ +extern void + uc_all_blocks (const uc_block_t **blocks, size_t *count); + +/* ========================================================================= */ + +/* Properties taken from language standards. */ + +/* Test whether a Unicode character is considered whitespace in ISO C 99. */ +extern bool + uc_is_c_whitespace (ucs4_t uc) + _UC_ATTRIBUTE_CONST; + +/* Test whether a Unicode character is considered whitespace in Java. */ +extern bool + uc_is_java_whitespace (ucs4_t uc) + _UC_ATTRIBUTE_CONST; + +enum +{ + UC_IDENTIFIER_START, /* valid as first or subsequent character */ + UC_IDENTIFIER_VALID, /* valid as subsequent character only */ + UC_IDENTIFIER_INVALID, /* not valid */ + UC_IDENTIFIER_IGNORABLE /* ignorable (Java only) */ +}; + +/* Return the categorization of a Unicode character w.r.t. the ISO C 99 + identifier syntax. */ +extern int + uc_c_ident_category (ucs4_t uc) + _UC_ATTRIBUTE_CONST; + +/* Return the categorization of a Unicode character w.r.t. the Java + identifier syntax. */ +extern int + uc_java_ident_category (ucs4_t uc) + _UC_ATTRIBUTE_CONST; + +/* ========================================================================= */ + +/* Like ISO C and . These functions are deprecated, + because this set of functions was designed with ASCII in mind and cannot + reflect the more diverse reality of the Unicode character set. But they + can be a quick-and-dirty porting aid when migrating from wchar_t APIs + to Unicode strings. */ + +/* Test for any character for which 'uc_is_alpha' or 'uc_is_digit' is true. */ +extern bool + uc_is_alnum (ucs4_t uc) + _UC_ATTRIBUTE_CONST; + +/* Test for any character for which 'uc_is_upper' or 'uc_is_lower' is true, + or any character that is one of a locale-specific set of characters for + which none of 'uc_is_cntrl', 'uc_is_digit', 'uc_is_punct', or 'uc_is_space' + is true. */ +extern bool + uc_is_alpha (ucs4_t uc) + _UC_ATTRIBUTE_CONST; + +/* Test for any control character. */ +extern bool + uc_is_cntrl (ucs4_t uc) + _UC_ATTRIBUTE_CONST; + +/* Test for any character that corresponds to a decimal-digit character. */ +extern bool + uc_is_digit (ucs4_t uc) + _UC_ATTRIBUTE_CONST; + +/* Test for any character for which 'uc_is_print' is true and 'uc_is_space' + is false. */ +extern bool + uc_is_graph (ucs4_t uc) + _UC_ATTRIBUTE_CONST; + +/* Test for any character that corresponds to a lowercase letter or is one + of a locale-specific set of characters for which none of 'uc_is_cntrl', + 'uc_is_digit', 'uc_is_punct', or 'uc_is_space' is true. */ +extern bool + uc_is_lower (ucs4_t uc) + _UC_ATTRIBUTE_CONST; + +/* Test for any printing character. */ +extern bool + uc_is_print (ucs4_t uc) + _UC_ATTRIBUTE_CONST; + +/* Test for any printing character that is one of a locale-specific set of + characters for which neither 'uc_is_space' nor 'uc_is_alnum' is true. */ +extern bool + uc_is_punct (ucs4_t uc) + _UC_ATTRIBUTE_CONST; + +/* Test for any character that corresponds to a locale-specific set of + characters for which none of 'uc_is_alnum', 'uc_is_graph', or 'uc_is_punct' + is true. */ +extern bool + uc_is_space (ucs4_t uc) + _UC_ATTRIBUTE_CONST; + +/* Test for any character that corresponds to an uppercase letter or is one + of a locale-specific set of character for which none of 'uc_is_cntrl', + 'uc_is_digit', 'uc_is_punct', or 'uc_is_space' is true. */ +extern bool + uc_is_upper (ucs4_t uc) + _UC_ATTRIBUTE_CONST; + +/* Test for any character that corresponds to a hexadecimal-digit + character. */ +extern bool + uc_is_xdigit (ucs4_t uc) + _UC_ATTRIBUTE_CONST; + +/* GNU extension. */ +/* Test for any character that corresponds to a standard blank character or + a locale-specific set of characters for which 'uc_is_alnum' is false. */ +extern bool + uc_is_blank (ucs4_t uc) + _UC_ATTRIBUTE_CONST; + +/* ========================================================================= */ + +#ifdef __cplusplus +} +#endif + +#endif /* _UNICTYPE_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/.gitignore b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/.gitignore new file mode 100644 index 00000000..0ac94567 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/.gitignore @@ -0,0 +1,25 @@ +/bitmap.h +/ctype_alnum.c +/ctype_alnum.h +/ctype_alpha.c +/ctype_alpha.h +/ctype_blank.c +/ctype_blank.h +/ctype_cntrl.c +/ctype_cntrl.h +/ctype_digit.c +/ctype_digit.h +/ctype_graph.c +/ctype_graph.h +/ctype_lower.c +/ctype_lower.h +/ctype_print.c +/ctype_print.h +/ctype_punct.c +/ctype_punct.h +/ctype_space.c +/ctype_space.h +/ctype_upper.c +/ctype_upper.h +/ctype_xdigit.c +/ctype_xdigit.h diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/bitmap.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/bitmap.h new file mode 100644 index 00000000..dba23655 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/bitmap.h @@ -0,0 +1,48 @@ +/* Three-level bitmap lookup. + Copyright (C) 2000-2002, 2005-2007, 2009-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2000-2002. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +static inline int bitmap_lookup (const void *table, ucs4_t uc); + +/* These values are currently hardcoded into gen-uni-tables.c, function + output_predicate(). */ +#define header_0 16 +#define header_2 9 +#define header_3 127 +#define header_4 15 + +static inline int +bitmap_lookup (const void *table, ucs4_t uc) +{ + unsigned int index1 = uc >> header_0; + if (index1 < ((const int *) table)[0]) + { + int lookup1 = ((const int *) table)[1 + index1]; + if (lookup1 >= 0) + { + unsigned int index2 = (uc >> header_2) & header_3; + int lookup2 = ((const short *) table)[lookup1 + index2]; + if (lookup2 >= 0) + { + unsigned int index3 = (uc >> 5) & header_4; + unsigned int lookup3 = ((const unsigned int *) table)[lookup2 + index3]; + + return (lookup3 >> (uc & 0x1f)) & 1; + } + } + } + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_alnum.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_alnum.c new file mode 100644 index 00000000..1f69c14a --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_alnum.c @@ -0,0 +1,32 @@ +/* ISO C like properties of Unicode characters. + Copyright (C) 2002, 2006-2007, 2009-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2002. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unictype.h" + +#include "bitmap.h" + +/* Define u_is_alnum table. */ +#include "ctype_alnum.h" + +bool +uc_is_alnum (ucs4_t uc) +{ + return bitmap_lookup (&u_is_alnum, uc); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_alnum.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_alnum.h new file mode 100644 index 00000000..46297898 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_alnum.h @@ -0,0 +1,877 @@ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +/* ISO C like properties of Unicode characters. */ +/* Generated automatically by gen-uni-tables.c for Unicode 15.0.0. */ + +/* Copyright (C) 2000-2023 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#define header_0 16 +#define header_2 9 +#define header_3 127 +#define header_4 15 +static const +struct + { + int header[1]; + int level1[4]; + short level2[4 << 7]; + unsigned int level3[80 << 4]; + } +u_is_alnum = +{ + { 4 }, + { + 5 * sizeof (int) / sizeof (short) + 0, + 5 * sizeof (int) / sizeof (short) + 128, + 5 * sizeof (int) / sizeof (short) + 256, + 5 * sizeof (int) / sizeof (short) + 384 + }, + { + 5 + 512 * sizeof (short) / sizeof (int) + 0, + 5 + 512 * sizeof (short) / sizeof (int) + 16, + 5 + 512 * sizeof (short) / sizeof (int) + 32, + 5 + 512 * sizeof (short) / sizeof (int) + 48, + 5 + 512 * sizeof (short) / sizeof (int) + 64, + 5 + 512 * sizeof (short) / sizeof (int) + 80, + 5 + 512 * sizeof (short) / sizeof (int) + 96, + 5 + 512 * sizeof (short) / sizeof (int) + 112, + 5 + 512 * sizeof (short) / sizeof (int) + 128, + 5 + 512 * sizeof (short) / sizeof (int) + 144, + 5 + 512 * sizeof (short) / sizeof (int) + 160, + 5 + 512 * sizeof (short) / sizeof (int) + 176, + 5 + 512 * sizeof (short) / sizeof (int) + 192, + 5 + 512 * sizeof (short) / sizeof (int) + 208, + 5 + 512 * sizeof (short) / sizeof (int) + 224, + 5 + 512 * sizeof (short) / sizeof (int) + 240, + 5 + 512 * sizeof (short) / sizeof (int) + 256, + -1, + 5 + 512 * sizeof (short) / sizeof (int) + 272, + -1, + -1, + -1, + 5 + 512 * sizeof (short) / sizeof (int) + 288, + 5 + 512 * sizeof (short) / sizeof (int) + 304, + 5 + 512 * sizeof (short) / sizeof (int) + 320, + -1, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 352, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 368, + 5 + 512 * sizeof (short) / sizeof (int) + 384, + 5 + 512 * sizeof (short) / sizeof (int) + 400, + 5 + 512 * sizeof (short) / sizeof (int) + 416, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 432, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 5 + 512 * sizeof (short) / sizeof (int) + 448, + 5 + 512 * sizeof (short) / sizeof (int) + 464, + 5 + 512 * sizeof (short) / sizeof (int) + 480, + 5 + 512 * sizeof (short) / sizeof (int) + 496, + 5 + 512 * sizeof (short) / sizeof (int) + 512, + 5 + 512 * sizeof (short) / sizeof (int) + 528, + 5 + 512 * sizeof (short) / sizeof (int) + 544, + 5 + 512 * sizeof (short) / sizeof (int) + 560, + 5 + 512 * sizeof (short) / sizeof (int) + 576, + 5 + 512 * sizeof (short) / sizeof (int) + 592, + 5 + 512 * sizeof (short) / sizeof (int) + 608, + 5 + 512 * sizeof (short) / sizeof (int) + 624, + 5 + 512 * sizeof (short) / sizeof (int) + 640, + 5 + 512 * sizeof (short) / sizeof (int) + 656, + 5 + 512 * sizeof (short) / sizeof (int) + 672, + 5 + 512 * sizeof (short) / sizeof (int) + 688, + 5 + 512 * sizeof (short) / sizeof (int) + 704, + 5 + 512 * sizeof (short) / sizeof (int) + 720, + 5 + 512 * sizeof (short) / sizeof (int) + 736, + 5 + 512 * sizeof (short) / sizeof (int) + 752, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 768, + 5 + 512 * sizeof (short) / sizeof (int) + 784, + -1, + -1, + -1, + -1, + 5 + 512 * sizeof (short) / sizeof (int) + 800, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 816, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 832, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 848, + -1, + 5 + 512 * sizeof (short) / sizeof (int) + 864, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 880, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 896, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 5 + 512 * sizeof (short) / sizeof (int) + 912, + 5 + 512 * sizeof (short) / sizeof (int) + 928, + 5 + 512 * sizeof (short) / sizeof (int) + 944, + -1, + -1, + -1, + -1, + 5 + 512 * sizeof (short) / sizeof (int) + 960, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 5 + 512 * sizeof (short) / sizeof (int) + 976, + 5 + 512 * sizeof (short) / sizeof (int) + 992, + -1, + -1, + -1, + 5 + 512 * sizeof (short) / sizeof (int) + 1008, + 5 + 512 * sizeof (short) / sizeof (int) + 1024, + 5 + 512 * sizeof (short) / sizeof (int) + 1040, + 5 + 512 * sizeof (short) / sizeof (int) + 1056, + 5 + 512 * sizeof (short) / sizeof (int) + 1072, + 5 + 512 * sizeof (short) / sizeof (int) + 1088, + -1, + -1, + 5 + 512 * sizeof (short) / sizeof (int) + 1104, + 5 + 512 * sizeof (short) / sizeof (int) + 1120, + -1, + -1, + -1, + -1, + 5 + 512 * sizeof (short) / sizeof (int) + 1136, + -1, + -1, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 1152, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 1168, + 5 + 512 * sizeof (short) / sizeof (int) + 1184, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 1200, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 1216, + -1, + -1, + -1, + -1, + -1, + -1, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 1232, + -1, + -1, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 1248, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 1264, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + }, + { + 0x00000000U, 0x03FF0000U, 0x07FFFFFEU, 0x07FFFFFEU, + 0x00000000U, 0x04200400U, 0xFF7FFFFFU, 0xFF7FFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0003FFC3U, 0x0000501FU, + 0x00000000U, 0x00000000U, 0x00000020U, 0xBCDF0000U, + 0xFFFFD740U, 0xFFFFFFFBU, 0xFFFFFFFFU, 0xFFBFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFC03U, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFEFFFFU, 0x027FFFFFU, 0xFFFFFFFFU, + 0x000001FFU, 0x00000000U, 0xFFFF0000U, 0x000787FFU, + 0x00000000U, 0xFFFFFFFFU, 0x000007FFU, 0xFFFEC3FFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x002FFFFFU, 0x9FFFC060U, + 0xFFFD0000U, 0x0000FFFFU, 0xFFFFE000U, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0x0002003FU, 0xFFFFFFFFU, 0x043007FFU, + 0x043FFFFFU, 0x00000110U, 0x01FFFFFFU, 0xFFFF07FFU, + 0x00007EFFU, 0xFFFFFFFFU, 0x000003FFU, 0x00000000U, + 0xFFFFFFF0U, 0x23FFFFFFU, 0xFF010000U, 0xFFFEFFC3U, + 0xFFF99FE1U, 0x23C5FDFFU, 0xB0004000U, 0x1003FFC3U, + 0xFFF987E0U, 0x036DFDFFU, 0x5E000000U, 0x001CFFC0U, + 0xFFFBBFE0U, 0x23EDFDFFU, 0x00010000U, 0x0200FFC3U, + 0xFFF99FE0U, 0x23EDFDFFU, 0xB0000000U, 0x0002FFC3U, + 0xD63DC7E8U, 0x03FFC718U, 0x00010000U, 0x0000FFC0U, + 0xFFFDDFE0U, 0x23FFFDFFU, 0x27000000U, 0x0000FFC3U, + 0xFFFDDFE1U, 0x23EFFDFFU, 0x60000000U, 0x0006FFC3U, + 0xFFFDDFF0U, 0x27FFFFFFU, 0x80704000U, 0xFC00FFC3U, + 0xFC7FFFE0U, 0x2FFBFFFFU, 0x0000007FU, 0x0000FFC0U, + 0xFFFFFFFEU, 0x07FF7FFFU, 0x03FF7FBFU, 0x00000000U, + 0xFFFFF7D6U, 0x200DFFAFU, 0xF3FF005FU, 0x00000000U, + 0x00000001U, 0x000003FFU, 0xFFFFFEFFU, 0x00001FFFU, + 0x00001F00U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0x800007FFU, 0x3C3F03FFU, 0xFFE1C062U, + 0x03FF4003U, 0xFFFFFFFFU, 0xFFFF20BFU, 0xF7FFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x3D7F3DFFU, 0xFFFFFFFFU, + 0xFFFF3DFFU, 0x7F3DFFFFU, 0xFF7FFF3DU, 0xFFFFFFFFU, + 0xFF3DFFFFU, 0xFFFFFFFFU, 0x07FFFFFFU, 0x00000000U, + 0x0000FFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x3F3FFFFFU, + 0xFFFFFFFEU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFF9FFFU, + 0x07FFFFFEU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x01FFC7FFU, + 0x8003FFFFU, 0x0003FFFFU, 0x0003FFFFU, 0x0001DFFFU, + 0xFFFFFFFFU, 0x000FFFFFU, 0x10800000U, 0x000003FFU, + 0x03FF0000U, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x01FFFFFFU, + 0xFFFFFF9FU, 0xFFFF05FFU, 0xFFFFFFFFU, 0x003FFFFFU, + 0x7FFFFFFFU, 0x00000000U, 0xFFFFFFC0U, 0x001F3FFFU, + 0xFFFFFFFFU, 0xFFFF0FFFU, 0x03FF03FFU, 0x00000000U, + 0x007FFFFFU, 0xFFFFFFFFU, 0x001FFFFFU, 0x00000000U, + 0x03FF03FFU, 0x00000080U, 0x00000000U, 0x00000000U, + 0xFFFFFFE0U, 0x000FFFFFU, 0x03FF1FE0U, 0x00000000U, + 0xFFFFFFF8U, 0xFFFFC001U, 0xFFFFFFFFU, 0x0000003FU, + 0xFFFFFFFFU, 0x0000000FU, 0xFFFFE3FFU, 0x3FFFFFFFU, + 0xFFFF01FFU, 0xE7FFFFFFU, 0x00000000U, 0x046FDE00U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0x3F3FFFFFU, 0xFFFFFFFFU, 0xAAFF3F3FU, 0x3FFFFFFFU, + 0xFFFFFFFFU, 0x5FDFFFFFU, 0x0FCF1FDCU, 0x1FDC1FFFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x80020000U, + 0x1FFF0000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x3E2FFC84U, 0xF3FFBF50U, 0x000043E0U, 0xFFFFFFFFU, + 0x000001FFU, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xF0000000U, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x000003FFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x000C781FU, + 0xFFFFFFFFU, 0xFFFF20BFU, 0xFFFFFFFFU, 0x000080FFU, + 0x007FFFFFU, 0x7F7F7F7FU, 0x7F7F7F7FU, 0x00000000U, + 0x00000000U, 0x00008000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x000000E0U, 0x1F3E03FEU, 0xFFFFFFFEU, 0xFFFFFFFFU, + 0xE07FFFFFU, 0xFFFFFFFEU, 0xFFFFFFFFU, 0xF7FFFFFFU, + 0xFFFFFFE0U, 0xFFFEFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0x00007FFFU, 0xFFFFFFFFU, 0x00000000U, 0xFFFF0000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0x00001FFFU, 0x00000000U, 0xFFFF0000U, 0x3FFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFF1FFFU, 0x00000FFFU, 0xFFFFFFFFU, 0x80007FFFU, + 0x3FFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0000FFFFU, + 0xFF800000U, 0xFFFFFFFCU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFF9FFU, 0xFFFFFFFFU, 0x03EB07FFU, 0xFFFC0000U, + 0xFFFFF7BBU, 0x00000007U, 0xFFFFFFFFU, 0x000FFFFFU, + 0xFFFFFFFCU, 0x000FFFFFU, 0x03FF0000U, 0x68FC0000U, + 0xFFFFFFFFU, 0xFFFF003FU, 0x0000007FU, 0x1FFFFFFFU, + 0xFFFFFFF0U, 0x0007FFFFU, 0x03FF8000U, 0x7FFFFFDFU, + 0xFFFFFFFFU, 0x000001FFU, 0x03FF0FF7U, 0xC47FFFFFU, + 0xFFFFFFFFU, 0x3E62FFFFU, 0x38000005U, 0x001C07FFU, + 0x007E7E7EU, 0xFFFF7F7FU, 0xF7FFFFFFU, 0xFFFF03FFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x03FF0007U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFF000FU, 0xFFFFF87FU, 0x0FFFFFFFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFF3FFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x03FFFFFFU, 0x00000000U, + 0xA0F8007FU, 0x5F7FFDFFU, 0xFFFFFFDBU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0x0003FFFFU, 0xFFF80000U, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0x3FFFFFFFU, 0xFFFF0000U, 0xFFFFFFFFU, + 0xFFFCFFFFU, 0xFFFFFFFFU, 0x000000FFU, 0x0FFF0000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0xFFDF0000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x1FFFFFFFU, + 0x03FF0000U, 0x07FFFFFEU, 0x07FFFFFEU, 0xFFFFFFC0U, + 0xFFFFFFFFU, 0x7FFFFFFFU, 0x1CFCFCFCU, 0x00000000U, + 0xFFFFEFFFU, 0xB7FFFF7FU, 0x3FFF3FFFU, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x07FFFFFFU, + 0x00000000U, 0x00000000U, 0xFFFFFFFFU, 0x001FFFFFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x1FFFFFFFU, 0xFFFFFFFFU, 0x0001FFFFU, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFE000U, 0xFFFF07FFU, 0x003FFFFFU, + 0x3FFFFFFFU, 0xFFFFFFFFU, 0x003EFF0FU, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0x3FFFFFFFU, 0xFFFF03FFU, 0xFF0FFFFFU, 0x0FFFFFFFU, + 0xFFFFFFFFU, 0xFFFF00FFU, 0xFFFFFFFFU, 0xF7FF000FU, + 0xFFB7F7FFU, 0x1BFBFFFBU, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0x007FFFFFU, 0x003FFFFFU, 0x000000FFU, + 0xFFFFFFBFU, 0x07FDFFFFU, 0x00000000U, 0x00000000U, + 0xFFFFFD3FU, 0x91BFFFFFU, 0x003FFFFFU, 0x007FFFFFU, + 0x7FFFFFFFU, 0x00000000U, 0x00000000U, 0x0037FFFFU, + 0x003FFFFFU, 0x03FFFFFFU, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xC0FFFFFFU, 0x00000000U, 0x00000000U, + 0xFEEF0001U, 0x003FFFFFU, 0x00000000U, 0x1FFFFFFFU, + 0x1FFFFFFFU, 0x00000000U, 0xFFFFFEFFU, 0x0000001FU, + 0xFFFFFFFFU, 0x003FFFFFU, 0x003FFFFFU, 0x0007FFFFU, + 0x0003FFFFU, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x000001FFU, 0x00000000U, + 0xFFFFFFFFU, 0x0007FFFFU, 0xFFFFFFFFU, 0x0007FFFFU, + 0xFFFFFFFFU, 0x03FF000FU, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0x000303FFU, 0x00000000U, 0x00000000U, + 0x1FFFFFFFU, 0xFFFF0080U, 0x0000003FU, 0xFFFF0000U, + 0x00000003U, 0xFFFF0000U, 0x0000001FU, 0x007FFFFFU, + 0xFFFFFFF8U, 0x00FFFFFFU, 0x00000000U, 0x0026FFC0U, + 0xFFFFFFF8U, 0x0000FFFFU, 0xFFFF0000U, 0x03FF01FFU, + 0xFFFFFFF8U, 0xFFC0007FU, 0xFFFF0090U, 0x0047FFFFU, + 0xFFFFFFF8U, 0x0007FFFFU, 0x17FF001EU, 0x00000000U, + 0xFFFBFFFFU, 0x80000FFFU, 0x00000001U, 0x00000000U, + 0xBFFFBD7FU, 0xFFFF01FFU, 0x7FFFFFFFU, 0x03FF0000U, + 0xFFF99FE0U, 0x23EDFDFFU, 0xE0010000U, 0x00000003U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0x001FFFFFU, 0x83FF0780U, 0x00000003U, + 0xFFFFFFFFU, 0x0000FFFFU, 0x03FF00B0U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0x00007FFFU, 0x0F000000U, 0x00000000U, + 0xFFFFFFFFU, 0x0000FFFFU, 0x03FF0010U, 0x00000000U, + 0xFFFFFFFFU, 0x010007FFU, 0x000003FFU, 0x00000000U, + 0x07FFFFFFU, 0x03FF0000U, 0x0000007FU, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0x00000FFFU, 0x00000000U, 0x00000000U, + 0x00000000U, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x800003FFU, + 0xFF6FF27FU, 0x8000FFFFU, 0x03FF0002U, 0x00000000U, + 0x00000000U, 0xFFFFFCFFU, 0x0001FFFFU, 0x0000000AU, + 0xFFFFF801U, 0x0407FFFFU, 0xF0010000U, 0xFFFFFFFFU, + 0x200003FFU, 0xFFFF0000U, 0xFFFFFFFFU, 0x01FFFFFFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFDFFU, 0x00007FFFU, 0x03FF0001U, 0xFFFC0000U, + 0x0000FFFFU, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFB7FU, 0x0001FFFFU, 0x03FF0040U, 0xFFFFFDBFU, + 0x010003FFU, 0x000003FFU, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x0007FFFFU, + 0xFFFDFFF4U, 0x000FFFFFU, 0x03FF0000U, 0x00000000U, + 0x00000000U, 0x00010000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0x03FFFFFFU, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x00007FFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0000000FU, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFF0000U, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0001FFFFU, + 0xFFFFFFFFU, 0x0000FFFFU, 0x0000007EU, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0000007FU, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0x01FFFFFFU, 0x7FFFFFFFU, 0xFFFF03FFU, + 0xFFFFFFFFU, 0x7FFFFFFFU, 0xFFFF03FFU, 0x00003FFFU, + 0xFFFFFFFFU, 0x0000FFFFU, 0x03FF000FU, 0xE0FFFFF8U, + 0x0000FFFFU, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x000107FFU, 0x00000000U, + 0xFFF80000U, 0x00000000U, 0x00000000U, 0x0000000BU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x00FFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x003FFFFFU, 0x00000000U, + 0x000001FFU, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x6FEF0000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0x00040007U, 0x00270000U, 0xFFFF00F0U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0FFFFFFFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x1FFF07FFU, + 0x03FF01FFU, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFDFFFFFU, 0xFFFFFFFFU, + 0xDFFFFFFFU, 0xEBFFDE64U, 0xFFFFFFEFU, 0xFFFFFFFFU, + 0xDFDFE7BFU, 0x7BFFFFFFU, 0xFFFDFC5FU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFF3FU, 0xF7FFFFFDU, 0xF7FFFFFFU, + 0xFFDFFFFFU, 0xFFDFFFFFU, 0xFFFF7FFFU, 0xFFFF7FFFU, + 0xFFFFFDFFU, 0xFFFFFDFFU, 0xFFFFCFF7U, 0xFFFFFFFFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x7FFFFFFFU, 0x000007E0U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0xFFFF0000U, 0xFFFFFFFFU, 0x00003FFFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0x3F801FFFU, 0x000043FFU, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFF0000U, 0x00003FFFU, 0xFFFFFFFFU, 0x03FF0FFFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0xFFFF0000U, 0x03FF0FFFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x7FFF6F7FU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0000001FU, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x03FF080FU, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFEFU, 0x0AF7FE96U, 0xAA96EA84U, 0x5EF7F796U, + 0x0FFFFBFFU, 0x0FFFFBEEU, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFF0000U, 0xFFFF1FFFU, 0xFFFF03FFU, 0xFFFF03FFU, + 0x000007FFU, 0x00000020U, 0x00000000U, 0xFFFFFFC0U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x03FF0000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0x03FFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0x3FFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFF0003U, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x00000001U, + 0x3FFFFFFFU, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFF07FFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0x0000FFFFU, 0x00000000U, 0x00000000U + } +}; diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_alpha.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_alpha.c new file mode 100644 index 00000000..16cddc92 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_alpha.c @@ -0,0 +1,32 @@ +/* ISO C like properties of Unicode characters. + Copyright (C) 2002, 2006-2007, 2009-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2002. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unictype.h" + +#include "bitmap.h" + +/* Define u_is_alpha table. */ +#include "ctype_alpha.h" + +bool +uc_is_alpha (ucs4_t uc) +{ + return bitmap_lookup (&u_is_alpha, uc); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_alpha.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_alpha.h new file mode 100644 index 00000000..91a5e822 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_alpha.h @@ -0,0 +1,877 @@ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +/* ISO C like properties of Unicode characters. */ +/* Generated automatically by gen-uni-tables.c for Unicode 15.0.0. */ + +/* Copyright (C) 2000-2023 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#define header_0 16 +#define header_2 9 +#define header_3 127 +#define header_4 15 +static const +struct + { + int header[1]; + int level1[4]; + short level2[4 << 7]; + unsigned int level3[80 << 4]; + } +u_is_alpha = +{ + { 4 }, + { + 5 * sizeof (int) / sizeof (short) + 0, + 5 * sizeof (int) / sizeof (short) + 128, + 5 * sizeof (int) / sizeof (short) + 256, + 5 * sizeof (int) / sizeof (short) + 384 + }, + { + 5 + 512 * sizeof (short) / sizeof (int) + 0, + 5 + 512 * sizeof (short) / sizeof (int) + 16, + 5 + 512 * sizeof (short) / sizeof (int) + 32, + 5 + 512 * sizeof (short) / sizeof (int) + 48, + 5 + 512 * sizeof (short) / sizeof (int) + 64, + 5 + 512 * sizeof (short) / sizeof (int) + 80, + 5 + 512 * sizeof (short) / sizeof (int) + 96, + 5 + 512 * sizeof (short) / sizeof (int) + 112, + 5 + 512 * sizeof (short) / sizeof (int) + 128, + 5 + 512 * sizeof (short) / sizeof (int) + 144, + 5 + 512 * sizeof (short) / sizeof (int) + 160, + 5 + 512 * sizeof (short) / sizeof (int) + 176, + 5 + 512 * sizeof (short) / sizeof (int) + 192, + 5 + 512 * sizeof (short) / sizeof (int) + 208, + 5 + 512 * sizeof (short) / sizeof (int) + 224, + 5 + 512 * sizeof (short) / sizeof (int) + 240, + 5 + 512 * sizeof (short) / sizeof (int) + 256, + -1, + 5 + 512 * sizeof (short) / sizeof (int) + 272, + -1, + -1, + -1, + 5 + 512 * sizeof (short) / sizeof (int) + 288, + 5 + 512 * sizeof (short) / sizeof (int) + 304, + 5 + 512 * sizeof (short) / sizeof (int) + 320, + -1, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 352, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 368, + 5 + 512 * sizeof (short) / sizeof (int) + 384, + 5 + 512 * sizeof (short) / sizeof (int) + 400, + 5 + 512 * sizeof (short) / sizeof (int) + 416, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 432, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 5 + 512 * sizeof (short) / sizeof (int) + 448, + 5 + 512 * sizeof (short) / sizeof (int) + 464, + 5 + 512 * sizeof (short) / sizeof (int) + 480, + 5 + 512 * sizeof (short) / sizeof (int) + 496, + 5 + 512 * sizeof (short) / sizeof (int) + 512, + 5 + 512 * sizeof (short) / sizeof (int) + 528, + 5 + 512 * sizeof (short) / sizeof (int) + 544, + 5 + 512 * sizeof (short) / sizeof (int) + 560, + 5 + 512 * sizeof (short) / sizeof (int) + 576, + 5 + 512 * sizeof (short) / sizeof (int) + 592, + 5 + 512 * sizeof (short) / sizeof (int) + 608, + 5 + 512 * sizeof (short) / sizeof (int) + 624, + 5 + 512 * sizeof (short) / sizeof (int) + 640, + 5 + 512 * sizeof (short) / sizeof (int) + 656, + 5 + 512 * sizeof (short) / sizeof (int) + 672, + 5 + 512 * sizeof (short) / sizeof (int) + 688, + 5 + 512 * sizeof (short) / sizeof (int) + 704, + 5 + 512 * sizeof (short) / sizeof (int) + 720, + 5 + 512 * sizeof (short) / sizeof (int) + 736, + 5 + 512 * sizeof (short) / sizeof (int) + 752, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 768, + 5 + 512 * sizeof (short) / sizeof (int) + 784, + -1, + -1, + -1, + -1, + 5 + 512 * sizeof (short) / sizeof (int) + 800, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 816, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 832, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 848, + -1, + 5 + 512 * sizeof (short) / sizeof (int) + 864, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 880, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 896, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 5 + 512 * sizeof (short) / sizeof (int) + 912, + 5 + 512 * sizeof (short) / sizeof (int) + 928, + 5 + 512 * sizeof (short) / sizeof (int) + 944, + -1, + -1, + -1, + -1, + 5 + 512 * sizeof (short) / sizeof (int) + 960, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 5 + 512 * sizeof (short) / sizeof (int) + 976, + 5 + 512 * sizeof (short) / sizeof (int) + 992, + -1, + -1, + -1, + 5 + 512 * sizeof (short) / sizeof (int) + 1008, + 5 + 512 * sizeof (short) / sizeof (int) + 1024, + 5 + 512 * sizeof (short) / sizeof (int) + 1040, + 5 + 512 * sizeof (short) / sizeof (int) + 1056, + 5 + 512 * sizeof (short) / sizeof (int) + 1072, + 5 + 512 * sizeof (short) / sizeof (int) + 1088, + -1, + -1, + 5 + 512 * sizeof (short) / sizeof (int) + 1104, + 5 + 512 * sizeof (short) / sizeof (int) + 1120, + -1, + -1, + -1, + -1, + 5 + 512 * sizeof (short) / sizeof (int) + 1136, + -1, + -1, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 1152, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 1168, + 5 + 512 * sizeof (short) / sizeof (int) + 1184, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 1200, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 1216, + -1, + -1, + -1, + -1, + -1, + -1, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 1232, + -1, + -1, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 1248, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 336, + 5 + 512 * sizeof (short) / sizeof (int) + 1264, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + }, + { + 0x00000000U, 0x00000000U, 0x07FFFFFEU, 0x07FFFFFEU, + 0x00000000U, 0x04200400U, 0xFF7FFFFFU, 0xFF7FFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0003FFC3U, 0x0000501FU, + 0x00000000U, 0x00000000U, 0x00000020U, 0xBCDF0000U, + 0xFFFFD740U, 0xFFFFFFFBU, 0xFFFFFFFFU, 0xFFBFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFC03U, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFEFFFFU, 0x027FFFFFU, 0xFFFFFFFFU, + 0x000001FFU, 0x00000000U, 0xFFFF0000U, 0x000787FFU, + 0x00000000U, 0xFFFFFFFFU, 0x000007FFU, 0xFFFEC3FFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x002FFFFFU, 0x9FFFC060U, + 0xFFFD0000U, 0x0000FFFFU, 0xFFFFE000U, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0x0002003FU, 0xFFFFFFFFU, 0x043007FFU, + 0x043FFFFFU, 0x00000110U, 0x01FFFFFFU, 0xFFFF07FFU, + 0x00007EFFU, 0xFFFFFFFFU, 0x000003FFU, 0x00000000U, + 0xFFFFFFF0U, 0x23FFFFFFU, 0xFF010000U, 0xFFFEFFC3U, + 0xFFF99FE1U, 0x23C5FDFFU, 0xB0004000U, 0x1003FFC3U, + 0xFFF987E0U, 0x036DFDFFU, 0x5E000000U, 0x001CFFC0U, + 0xFFFBBFE0U, 0x23EDFDFFU, 0x00010000U, 0x0200FFC3U, + 0xFFF99FE0U, 0x23EDFDFFU, 0xB0000000U, 0x0002FFC3U, + 0xD63DC7E8U, 0x03FFC718U, 0x00010000U, 0x0000FFC0U, + 0xFFFDDFE0U, 0x23FFFDFFU, 0x27000000U, 0x0000FFC3U, + 0xFFFDDFE1U, 0x23EFFDFFU, 0x60000000U, 0x0006FFC3U, + 0xFFFDDFF0U, 0x27FFFFFFU, 0x80704000U, 0xFC00FFC3U, + 0xFC7FFFE0U, 0x2FFBFFFFU, 0x0000007FU, 0x0000FFC0U, + 0xFFFFFFFEU, 0x07FF7FFFU, 0x03FF7FBFU, 0x00000000U, + 0xFFFFF7D6U, 0x200DFFAFU, 0xF3FF005FU, 0x00000000U, + 0x00000001U, 0x000003FFU, 0xFFFFFEFFU, 0x00001FFFU, + 0x00001F00U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0x800007FFU, 0x3C3F03FFU, 0xFFE1C062U, + 0x03FF4003U, 0xFFFFFFFFU, 0xFFFF20BFU, 0xF7FFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x3D7F3DFFU, 0xFFFFFFFFU, + 0xFFFF3DFFU, 0x7F3DFFFFU, 0xFF7FFF3DU, 0xFFFFFFFFU, + 0xFF3DFFFFU, 0xFFFFFFFFU, 0x07FFFFFFU, 0x00000000U, + 0x0000FFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x3F3FFFFFU, + 0xFFFFFFFEU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFF9FFFU, + 0x07FFFFFEU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x01FFC7FFU, + 0x8003FFFFU, 0x0003FFFFU, 0x0003FFFFU, 0x0001DFFFU, + 0xFFFFFFFFU, 0x000FFFFFU, 0x10800000U, 0x000003FFU, + 0x03FF0000U, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x01FFFFFFU, + 0xFFFFFF9FU, 0xFFFF05FFU, 0xFFFFFFFFU, 0x003FFFFFU, + 0x7FFFFFFFU, 0x00000000U, 0xFFFFFFC0U, 0x001F3FFFU, + 0xFFFFFFFFU, 0xFFFF0FFFU, 0x03FF03FFU, 0x00000000U, + 0x007FFFFFU, 0xFFFFFFFFU, 0x001FFFFFU, 0x00000000U, + 0x03FF03FFU, 0x00000080U, 0x00000000U, 0x00000000U, + 0xFFFFFFE0U, 0x000FFFFFU, 0x03FF1FE0U, 0x00000000U, + 0xFFFFFFF8U, 0xFFFFC001U, 0xFFFFFFFFU, 0x0000003FU, + 0xFFFFFFFFU, 0x0000000FU, 0xFFFFE3FFU, 0x3FFFFFFFU, + 0xFFFF01FFU, 0xE7FFFFFFU, 0x00000000U, 0x046FDE00U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0x3F3FFFFFU, 0xFFFFFFFFU, 0xAAFF3F3FU, 0x3FFFFFFFU, + 0xFFFFFFFFU, 0x5FDFFFFFU, 0x0FCF1FDCU, 0x1FDC1FFFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x80020000U, + 0x1FFF0000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x3E2FFC84U, 0xF3FFBF50U, 0x000043E0U, 0xFFFFFFFFU, + 0x000001FFU, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xF0000000U, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x000003FFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x000C781FU, + 0xFFFFFFFFU, 0xFFFF20BFU, 0xFFFFFFFFU, 0x000080FFU, + 0x007FFFFFU, 0x7F7F7F7FU, 0x7F7F7F7FU, 0x00000000U, + 0x00000000U, 0x00008000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x000000E0U, 0x1F3E03FEU, 0xFFFFFFFEU, 0xFFFFFFFFU, + 0xE07FFFFFU, 0xFFFFFFFEU, 0xFFFFFFFFU, 0xF7FFFFFFU, + 0xFFFFFFE0U, 0xFFFEFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0x00007FFFU, 0xFFFFFFFFU, 0x00000000U, 0xFFFF0000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0x00001FFFU, 0x00000000U, 0xFFFF0000U, 0x3FFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFF1FFFU, 0x00000FFFU, 0xFFFFFFFFU, 0x80007FFFU, + 0x3FFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0000FFFFU, + 0xFF800000U, 0xFFFFFFFCU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFF9FFU, 0xFFFFFFFFU, 0x03EB07FFU, 0xFFFC0000U, + 0xFFFFF7BBU, 0x00000007U, 0xFFFFFFFFU, 0x000FFFFFU, + 0xFFFFFFFCU, 0x000FFFFFU, 0x03FF0000U, 0x68FC0000U, + 0xFFFFFFFFU, 0xFFFF003FU, 0x0000007FU, 0x1FFFFFFFU, + 0xFFFFFFF0U, 0x0007FFFFU, 0x03FF8000U, 0x7FFFFFDFU, + 0xFFFFFFFFU, 0x000001FFU, 0x03FF0FF7U, 0xC47FFFFFU, + 0xFFFFFFFFU, 0x3E62FFFFU, 0x38000005U, 0x001C07FFU, + 0x007E7E7EU, 0xFFFF7F7FU, 0xF7FFFFFFU, 0xFFFF03FFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x03FF0007U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFF000FU, 0xFFFFF87FU, 0x0FFFFFFFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFF3FFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x03FFFFFFU, 0x00000000U, + 0xA0F8007FU, 0x5F7FFDFFU, 0xFFFFFFDBU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0x0003FFFFU, 0xFFF80000U, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0x3FFFFFFFU, 0xFFFF0000U, 0xFFFFFFFFU, + 0xFFFCFFFFU, 0xFFFFFFFFU, 0x000000FFU, 0x0FFF0000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0xFFDF0000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x1FFFFFFFU, + 0x03FF0000U, 0x07FFFFFEU, 0x07FFFFFEU, 0xFFFFFFC0U, + 0xFFFFFFFFU, 0x7FFFFFFFU, 0x1CFCFCFCU, 0x00000000U, + 0xFFFFEFFFU, 0xB7FFFF7FU, 0x3FFF3FFFU, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x07FFFFFFU, + 0x00000000U, 0x00000000U, 0xFFFFFFFFU, 0x001FFFFFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x1FFFFFFFU, 0xFFFFFFFFU, 0x0001FFFFU, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFE000U, 0xFFFF07FFU, 0x003FFFFFU, + 0x3FFFFFFFU, 0xFFFFFFFFU, 0x003EFF0FU, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0x3FFFFFFFU, 0xFFFF03FFU, 0xFF0FFFFFU, 0x0FFFFFFFU, + 0xFFFFFFFFU, 0xFFFF00FFU, 0xFFFFFFFFU, 0xF7FF000FU, + 0xFFB7F7FFU, 0x1BFBFFFBU, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0x007FFFFFU, 0x003FFFFFU, 0x000000FFU, + 0xFFFFFFBFU, 0x07FDFFFFU, 0x00000000U, 0x00000000U, + 0xFFFFFD3FU, 0x91BFFFFFU, 0x003FFFFFU, 0x007FFFFFU, + 0x7FFFFFFFU, 0x00000000U, 0x00000000U, 0x0037FFFFU, + 0x003FFFFFU, 0x03FFFFFFU, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xC0FFFFFFU, 0x00000000U, 0x00000000U, + 0xFEEF0001U, 0x003FFFFFU, 0x00000000U, 0x1FFFFFFFU, + 0x1FFFFFFFU, 0x00000000U, 0xFFFFFEFFU, 0x0000001FU, + 0xFFFFFFFFU, 0x003FFFFFU, 0x003FFFFFU, 0x0007FFFFU, + 0x0003FFFFU, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x000001FFU, 0x00000000U, + 0xFFFFFFFFU, 0x0007FFFFU, 0xFFFFFFFFU, 0x0007FFFFU, + 0xFFFFFFFFU, 0x03FF000FU, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0x000303FFU, 0x00000000U, 0x00000000U, + 0x1FFFFFFFU, 0xFFFF0080U, 0x0000003FU, 0xFFFF0000U, + 0x00000003U, 0xFFFF0000U, 0x0000001FU, 0x007FFFFFU, + 0xFFFFFFF8U, 0x00FFFFFFU, 0x00000000U, 0x0026FFC0U, + 0xFFFFFFF8U, 0x0000FFFFU, 0xFFFF0000U, 0x03FF01FFU, + 0xFFFFFFF8U, 0xFFC0007FU, 0xFFFF0090U, 0x0047FFFFU, + 0xFFFFFFF8U, 0x0007FFFFU, 0x17FF001EU, 0x00000000U, + 0xFFFBFFFFU, 0x80000FFFU, 0x00000001U, 0x00000000U, + 0xBFFFBD7FU, 0xFFFF01FFU, 0x7FFFFFFFU, 0x03FF0000U, + 0xFFF99FE0U, 0x23EDFDFFU, 0xE0010000U, 0x00000003U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0x001FFFFFU, 0x83FF0780U, 0x00000003U, + 0xFFFFFFFFU, 0x0000FFFFU, 0x03FF00B0U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0x00007FFFU, 0x0F000000U, 0x00000000U, + 0xFFFFFFFFU, 0x0000FFFFU, 0x03FF0010U, 0x00000000U, + 0xFFFFFFFFU, 0x010007FFU, 0x000003FFU, 0x00000000U, + 0x07FFFFFFU, 0x03FF0000U, 0x0000007FU, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0x00000FFFU, 0x00000000U, 0x00000000U, + 0x00000000U, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x800003FFU, + 0xFF6FF27FU, 0x8000FFFFU, 0x03FF0002U, 0x00000000U, + 0x00000000U, 0xFFFFFCFFU, 0x0001FFFFU, 0x0000000AU, + 0xFFFFF801U, 0x0407FFFFU, 0xF0010000U, 0xFFFFFFFFU, + 0x200003FFU, 0xFFFF0000U, 0xFFFFFFFFU, 0x01FFFFFFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFDFFU, 0x00007FFFU, 0x03FF0001U, 0xFFFC0000U, + 0x0000FFFFU, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFB7FU, 0x0001FFFFU, 0x03FF0040U, 0xFFFFFDBFU, + 0x010003FFU, 0x000003FFU, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x0007FFFFU, + 0xFFFDFFF4U, 0x000FFFFFU, 0x03FF0000U, 0x00000000U, + 0x00000000U, 0x00010000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0x03FFFFFFU, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x00007FFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0000000FU, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFF0000U, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0001FFFFU, + 0xFFFFFFFFU, 0x0000FFFFU, 0x0000007EU, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0000007FU, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0x01FFFFFFU, 0x7FFFFFFFU, 0xFFFF03FFU, + 0xFFFFFFFFU, 0x7FFFFFFFU, 0xFFFF03FFU, 0x00003FFFU, + 0xFFFFFFFFU, 0x0000FFFFU, 0x03FF000FU, 0xE0FFFFF8U, + 0x0000FFFFU, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x000107FFU, 0x00000000U, + 0xFFF80000U, 0x00000000U, 0x00000000U, 0x0000000BU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x00FFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x003FFFFFU, 0x00000000U, + 0x000001FFU, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x6FEF0000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0x00040007U, 0x00270000U, 0xFFFF00F0U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0FFFFFFFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x1FFF07FFU, + 0x03FF01FFU, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFDFFFFFU, 0xFFFFFFFFU, + 0xDFFFFFFFU, 0xEBFFDE64U, 0xFFFFFFEFU, 0xFFFFFFFFU, + 0xDFDFE7BFU, 0x7BFFFFFFU, 0xFFFDFC5FU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFF3FU, 0xF7FFFFFDU, 0xF7FFFFFFU, + 0xFFDFFFFFU, 0xFFDFFFFFU, 0xFFFF7FFFU, 0xFFFF7FFFU, + 0xFFFFFDFFU, 0xFFFFFDFFU, 0xFFFFCFF7U, 0xFFFFFFFFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x7FFFFFFFU, 0x000007E0U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0xFFFF0000U, 0xFFFFFFFFU, 0x00003FFFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0x3F801FFFU, 0x000043FFU, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFF0000U, 0x00003FFFU, 0xFFFFFFFFU, 0x03FF0FFFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0xFFFF0000U, 0x03FF0FFFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x7FFF6F7FU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0000001FU, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x03FF080FU, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFEFU, 0x0AF7FE96U, 0xAA96EA84U, 0x5EF7F796U, + 0x0FFFFBFFU, 0x0FFFFBEEU, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFF0000U, 0xFFFF1FFFU, 0xFFFF03FFU, 0xFFFF03FFU, + 0x000007FFU, 0x00000020U, 0x00000000U, 0xFFFFFFC0U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x03FF0000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0x03FFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0x3FFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFF0003U, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x00000001U, + 0x3FFFFFFFU, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFF07FFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0x0000FFFFU, 0x00000000U, 0x00000000U + } +}; diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_blank.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_blank.c new file mode 100644 index 00000000..cec8e023 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_blank.c @@ -0,0 +1,32 @@ +/* ISO C like properties of Unicode characters. + Copyright (C) 2002, 2006-2007, 2009-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2002. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unictype.h" + +#include "bitmap.h" + +/* Define u_is_blank table. */ +#include "ctype_blank.h" + +bool +uc_is_blank (ucs4_t uc) +{ + return bitmap_lookup (&u_is_blank, uc); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_blank.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_blank.h new file mode 100644 index 00000000..5ed5fbbe --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_blank.h @@ -0,0 +1,184 @@ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +/* ISO C like properties of Unicode characters. */ +/* Generated automatically by gen-uni-tables.c for Unicode 15.0.0. */ + +/* Copyright (C) 2000-2023 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#define header_0 16 +#define header_2 9 +#define header_3 127 +#define header_4 15 +static const +struct + { + int header[1]; + int level1[1]; + short level2[1 << 7]; + unsigned int level3[4 << 4]; + } +u_is_blank = +{ + { 1 }, + { 2 * sizeof (int) / sizeof (short) + 0 }, + { + 2 + 128 * sizeof (short) / sizeof (int) + 0, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 2 + 128 * sizeof (short) / sizeof (int) + 16, + -1, + -1, + -1, + -1, + 2 + 128 * sizeof (short) / sizeof (int) + 32, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 2 + 128 * sizeof (short) / sizeof (int) + 48, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + }, + { + 0x00000200U, 0x00000001U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000001U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x0000077FU, 0x00000000U, 0x80000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000001U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U + } +}; diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_cntrl.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_cntrl.c new file mode 100644 index 00000000..6ed52739 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_cntrl.c @@ -0,0 +1,32 @@ +/* ISO C like properties of Unicode characters. + Copyright (C) 2002, 2006-2007, 2009-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2002. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unictype.h" + +#include "bitmap.h" + +/* Define u_is_cntrl table. */ +#include "ctype_cntrl.h" + +bool +uc_is_cntrl (ucs4_t uc) +{ + return bitmap_lookup (&u_is_cntrl, uc); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_cntrl.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_cntrl.h new file mode 100644 index 00000000..c1c17941 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_cntrl.h @@ -0,0 +1,176 @@ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +/* ISO C like properties of Unicode characters. */ +/* Generated automatically by gen-uni-tables.c for Unicode 15.0.0. */ + +/* Copyright (C) 2000-2023 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#define header_0 16 +#define header_2 9 +#define header_3 127 +#define header_4 15 +static const +struct + { + int header[1]; + int level1[1]; + short level2[1 << 7]; + unsigned int level3[2 << 4]; + } +u_is_cntrl = +{ + { 1 }, + { 2 * sizeof (int) / sizeof (short) + 0 }, + { + 2 + 128 * sizeof (short) / sizeof (int) + 0, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 2 + 128 * sizeof (short) / sizeof (int) + 16, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + }, + { + 0xFFFFFFFFU, 0x00000000U, 0x00000000U, 0x80000000U, + 0xFFFFFFFFU, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000300U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U + } +}; diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_digit.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_digit.c new file mode 100644 index 00000000..906e7375 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_digit.c @@ -0,0 +1,32 @@ +/* ISO C like properties of Unicode characters. + Copyright (C) 2002, 2006-2007, 2009-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2002. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unictype.h" + +#include "bitmap.h" + +/* Define u_is_digit table. */ +#include "ctype_digit.h" + +bool +uc_is_digit (ucs4_t uc) +{ + return bitmap_lookup (&u_is_digit, uc); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_digit.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_digit.h new file mode 100644 index 00000000..3111b9ad --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_digit.h @@ -0,0 +1,172 @@ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +/* ISO C like properties of Unicode characters. */ +/* Generated automatically by gen-uni-tables.c for Unicode 15.0.0. */ + +/* Copyright (C) 2000-2023 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#define header_0 16 +#define header_2 9 +#define header_3 127 +#define header_4 15 +static const +struct + { + int header[1]; + int level1[1]; + short level2[1 << 7]; + unsigned int level3[1 << 4]; + } +u_is_digit = +{ + { 1 }, + { 2 * sizeof (int) / sizeof (short) + 0 }, + { + 2 + 128 * sizeof (short) / sizeof (int) + 0, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + }, + { + 0x00000000U, 0x03FF0000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U + } +}; diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_graph.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_graph.c new file mode 100644 index 00000000..e58f69e4 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_graph.c @@ -0,0 +1,32 @@ +/* ISO C like properties of Unicode characters. + Copyright (C) 2002, 2006-2007, 2009-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2002. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unictype.h" + +#include "bitmap.h" + +/* Define u_is_graph table. */ +#include "ctype_graph.h" + +bool +uc_is_graph (ucs4_t uc) +{ + return bitmap_lookup (&u_is_graph, uc); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_graph.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_graph.h new file mode 100644 index 00000000..d95722e1 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_graph.h @@ -0,0 +1,1182 @@ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +/* ISO C like properties of Unicode characters. */ +/* Generated automatically by gen-uni-tables.c for Unicode 15.0.0. */ + +/* Copyright (C) 2000-2023 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#define header_0 16 +#define header_2 9 +#define header_3 127 +#define header_4 15 +static const +struct + { + int header[1]; + int level1[17]; + short level2[6 << 7]; + unsigned int level3[89 << 4]; + } +u_is_graph = +{ + { 17 }, + { + 18 * sizeof (int) / sizeof (short) + 0, + 18 * sizeof (int) / sizeof (short) + 128, + 18 * sizeof (int) / sizeof (short) + 256, + 18 * sizeof (int) / sizeof (short) + 384, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 18 * sizeof (int) / sizeof (short) + 512, + 18 * sizeof (int) / sizeof (short) + 640, + 18 * sizeof (int) / sizeof (short) + 640 + }, + { + 18 + 768 * sizeof (short) / sizeof (int) + 0, + 18 + 768 * sizeof (short) / sizeof (int) + 16, + 18 + 768 * sizeof (short) / sizeof (int) + 32, + 18 + 768 * sizeof (short) / sizeof (int) + 48, + 18 + 768 * sizeof (short) / sizeof (int) + 64, + 18 + 768 * sizeof (short) / sizeof (int) + 80, + 18 + 768 * sizeof (short) / sizeof (int) + 96, + 18 + 768 * sizeof (short) / sizeof (int) + 112, + 18 + 768 * sizeof (short) / sizeof (int) + 128, + 18 + 768 * sizeof (short) / sizeof (int) + 144, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 176, + 18 + 768 * sizeof (short) / sizeof (int) + 192, + 18 + 768 * sizeof (short) / sizeof (int) + 208, + 18 + 768 * sizeof (short) / sizeof (int) + 224, + 18 + 768 * sizeof (short) / sizeof (int) + 240, + 18 + 768 * sizeof (short) / sizeof (int) + 256, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 272, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 288, + 18 + 768 * sizeof (short) / sizeof (int) + 304, + 18 + 768 * sizeof (short) / sizeof (int) + 320, + 18 + 768 * sizeof (short) / sizeof (int) + 336, + 18 + 768 * sizeof (short) / sizeof (int) + 352, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 368, + 18 + 768 * sizeof (short) / sizeof (int) + 384, + 18 + 768 * sizeof (short) / sizeof (int) + 400, + 18 + 768 * sizeof (short) / sizeof (int) + 416, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 432, + -1, + -1, + -1, + -1, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 448, + 18 + 768 * sizeof (short) / sizeof (int) + 464, + 18 + 768 * sizeof (short) / sizeof (int) + 480, + 18 + 768 * sizeof (short) / sizeof (int) + 496, + 18 + 768 * sizeof (short) / sizeof (int) + 512, + 18 + 768 * sizeof (short) / sizeof (int) + 528, + 18 + 768 * sizeof (short) / sizeof (int) + 544, + 18 + 768 * sizeof (short) / sizeof (int) + 560, + 18 + 768 * sizeof (short) / sizeof (int) + 576, + 18 + 768 * sizeof (short) / sizeof (int) + 592, + 18 + 768 * sizeof (short) / sizeof (int) + 608, + 18 + 768 * sizeof (short) / sizeof (int) + 624, + 18 + 768 * sizeof (short) / sizeof (int) + 640, + 18 + 768 * sizeof (short) / sizeof (int) + 656, + 18 + 768 * sizeof (short) / sizeof (int) + 672, + 18 + 768 * sizeof (short) / sizeof (int) + 688, + 18 + 768 * sizeof (short) / sizeof (int) + 704, + 18 + 768 * sizeof (short) / sizeof (int) + 720, + 18 + 768 * sizeof (short) / sizeof (int) + 736, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 752, + 18 + 768 * sizeof (short) / sizeof (int) + 768, + -1, + -1, + -1, + -1, + 18 + 768 * sizeof (short) / sizeof (int) + 784, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 800, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 816, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 832, + -1, + 18 + 768 * sizeof (short) / sizeof (int) + 848, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 864, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 880, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 18 + 768 * sizeof (short) / sizeof (int) + 896, + 18 + 768 * sizeof (short) / sizeof (int) + 912, + 18 + 768 * sizeof (short) / sizeof (int) + 928, + -1, + -1, + -1, + -1, + 18 + 768 * sizeof (short) / sizeof (int) + 944, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 18 + 768 * sizeof (short) / sizeof (int) + 960, + 18 + 768 * sizeof (short) / sizeof (int) + 976, + 18 + 768 * sizeof (short) / sizeof (int) + 992, + 18 + 768 * sizeof (short) / sizeof (int) + 1008, + 18 + 768 * sizeof (short) / sizeof (int) + 1024, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 1040, + -1, + 18 + 768 * sizeof (short) / sizeof (int) + 1056, + 18 + 768 * sizeof (short) / sizeof (int) + 1072, + 18 + 768 * sizeof (short) / sizeof (int) + 1088, + 18 + 768 * sizeof (short) / sizeof (int) + 1104, + 18 + 768 * sizeof (short) / sizeof (int) + 1120, + 18 + 768 * sizeof (short) / sizeof (int) + 1136, + -1, + 18 + 768 * sizeof (short) / sizeof (int) + 1152, + 18 + 768 * sizeof (short) / sizeof (int) + 1168, + 18 + 768 * sizeof (short) / sizeof (int) + 1184, + 18 + 768 * sizeof (short) / sizeof (int) + 1200, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 1216, + 18 + 768 * sizeof (short) / sizeof (int) + 1232, + 18 + 768 * sizeof (short) / sizeof (int) + 1248, + -1, + -1, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 1264, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 1280, + 18 + 768 * sizeof (short) / sizeof (int) + 1296, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 1312, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 1328, + -1, + -1, + -1, + -1, + -1, + -1, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 1344, + -1, + -1, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 1360, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 1376, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 18 + 768 * sizeof (short) / sizeof (int) + 1392, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 1408 + }, + { + 0x00000000U, 0xFFFFFFFEU, 0xFFFFFFFFU, 0x7FFFFFFFU, + 0x00000000U, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFCFFFFFFU, + 0xFFFFD7F0U, 0xFFFFFFFBU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFEFFFFU, 0xFE7FFFFFU, 0xFFFFFFFFU, + 0xFFFEE7FFU, 0xFFFFFFFFU, 0xFFFF00FFU, 0x001F87FFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFBFFFU, 0xFFFFFFFFU, 0xFFFFE7FFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0x0003FFFFU, 0xFFFFFFFFU, 0xE7FFFFFFU, + 0xFFFFFFFFU, 0x7FFF3FFFU, 0x4FFFFFFFU, 0xFFFF07FFU, + 0xFF037FFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFF99FEFU, 0xF3C5FDFFU, 0xB080799FU, 0x7FFFFFCFU, + 0xFFF987EEU, 0xD36DFDFFU, 0x5E023987U, 0x007FFFC0U, + 0xFFFBBFEEU, 0xF3EDFDFFU, 0x00013BBFU, 0xFE03FFCFU, + 0xFFF99FEEU, 0xF3EDFDFFU, 0xB0E0399FU, 0x00FFFFCFU, + 0xD63DC7ECU, 0xC3FFC718U, 0x00813DC7U, 0x07FFFFC0U, + 0xFFFDDFFFU, 0xF3FFFDFFU, 0x27603DDFU, 0xFF80FFCFU, + 0xFFFDDFFFU, 0xF3EFFDFFU, 0x60603DDFU, 0x000EFFCFU, + 0xFFFDDFFFU, 0xFFFFFFFFU, 0xFFF0FDDFU, 0xFFFFFFCFU, + 0xFC7FFFEEU, 0x2FFBFFFFU, 0xFF5F847FU, 0x001CFFC0U, + 0xFFFFFFFEU, 0x87FFFFFFU, 0x0FFFFFFFU, 0x00000000U, + 0xFFFFF7D6U, 0x3FFFFFAFU, 0xF3FF7F5FU, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFEFFU, 0xFFFE1FFFU, + 0xFEFFFFFFU, 0xDFFFFFFFU, 0x07FFDFFFU, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFF20BFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x3D7F3DFFU, 0xFFFFFFFFU, + 0xFFFF3DFFU, 0x7F3DFFFFU, 0xFF7FFF3DU, 0xFFFFFFFFU, + 0xFF3DFFFFU, 0xFFFFFFFFU, 0xE7FFFFFFU, 0x1FFFFFFFU, + 0x03FFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x3F3FFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0x1FFFFFFEU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x01FFFFFFU, + 0x803FFFFFU, 0x007FFFFFU, 0x000FFFFFU, 0x000DDFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x3FFFFFFFU, 0x03FF03FFU, + 0x03FFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x01FFFFFFU, + 0xFFFFFFFFU, 0xFFFF07FFU, 0xFFFFFFFFU, 0x003FFFFFU, + 0x7FFFFFFFU, 0x0FFF0FFFU, 0xFFFFFFF1U, 0x001F3FFFU, + 0xFFFFFFFFU, 0xFFFF0FFFU, 0xC7FF03FFU, 0xFFFFFFFFU, + 0xCFFFFFFFU, 0xFFFFFFFFU, 0x7FFFFFFFU, 0x9FFFFFFFU, + 0x03FF03FFU, 0xFFFF3FFFU, 0x00007FFFU, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFF1FFFU, 0x7FFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xF00FFFFFU, + 0xFFFFFFFFU, 0xF8FFFFFFU, 0xFFFFE3FFU, 0xFFFFFFFFU, + 0xFFFF01FFU, 0xE7FFFFFFU, 0xFFFF00FFU, 0x07FFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0x3F3FFFFFU, 0xFFFFFFFFU, 0xAAFF3F3FU, 0x3FFFFFFFU, + 0xFFFFFFFFU, 0xFFDFFFFFU, 0xEFCFFFDFU, 0x7FDCFFFFU, + 0xFFFFF880U, 0xFFFFFCFFU, 0x7FFFFFFFU, 0xFFF3FFDFU, + 0x1FFF7FFFU, 0xFFFFFFFFU, 0xFFFF0001U, 0x0001FFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFF0FFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0x0000007FU, 0x000007FFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFCFFFFFU, + 0xFFBFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFE0FFFFFU, + 0xFFFFFFFFU, 0xFFFF20BFU, 0xFFFFFFFFU, 0x800180FFU, + 0x007FFFFFU, 0x7F7F7F7FU, 0x7F7F7F7FU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x3FFFFFFFU, 0x00000000U, + 0xFBFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x000FFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x003FFFFFU, 0x0FFF0000U, + 0xFFFFFFFEU, 0xFFFFFFFFU, 0xFFFFFFFEU, 0xFFFFFFFFU, + 0xFE7FFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFE0U, 0xFFFEFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFF7FFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFF000FU, + 0x7FFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFF1FFFU, 0xFFFFFFFFU, 0xFFFF007FU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0x00000FFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x00FFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x03EB07FFU, 0xFFFC0000U, + 0xFFFFFFFFU, 0x03FF1FFFU, 0xFFFFFFFFU, 0x00FFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x03FFC03FU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x800FFFFFU, 0x1FFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xC3FFBFFFU, 0x7FFFFFFFU, + 0xFFFFFFFFU, 0x007FFFFFU, 0xF3FF3FFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xF8000007U, 0x007FFFFFU, + 0x007E7E7EU, 0xFFFF7F7FU, 0xFFFFFFFFU, 0xFFFF0FFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x03FF3FFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFF000FU, 0xFFFFF87FU, 0x0FFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFF3FFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x03FFFFFFU, 0x00000000U, + 0xE0F8007FU, 0x5F7FFFFFU, 0xFFFFFFDBU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFF80007U, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFCFFFFU, 0xFFFFFFFFU, 0x000080FFU, 0xFFFF0000U, + 0x03FFFFFFU, 0xFFFFFFFFU, 0xFFF7FFFFU, 0xFFDF0F7FU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x9FFFFFFFU, + 0xFFFFFFFEU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0x7FFFFFFFU, 0x1CFCFCFCU, 0x3E007F7FU, + 0xFFFFEFFFU, 0xB7FFFF7FU, 0x3FFF3FFFU, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x07FFFFFFU, + 0xFFFFFF87U, 0xFF8FFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0x1FFF7FFFU, 0x00000001U, 0xFFFF0000U, 0x3FFFFFFFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x1FFFFFFFU, 0xFFFFFFFFU, 0x0001FFFFU, 0x0FFFFFFFU, + 0xFFFFFFFFU, 0xFFFFE00FU, 0xFFFF07FFU, 0x07FFFFFFU, + 0xBFFFFFFFU, 0xFFFFFFFFU, 0x003FFF0FU, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0x3FFFFFFFU, 0xFFFF03FFU, 0xFF0FFFFFU, 0x0FFFFFFFU, + 0xFFFFFFFFU, 0xFFFF00FFU, 0xFFFFFFFFU, 0xF7FF800FU, + 0xFFB7F7FFU, 0x1BFBFFFBU, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0x007FFFFFU, 0x003FFFFFU, 0x000000FFU, + 0xFFFFFFBFU, 0x07FDFFFFU, 0x00000000U, 0x00000000U, + 0xFFFFFD3FU, 0x91BFFFFFU, 0xFFBFFFFFU, 0xFFFFFFFFU, + 0x7FFFFFFFU, 0x0000FF80U, 0x00000000U, 0xF837FFFFU, + 0x8FFFFFFFU, 0x83FFFFFFU, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xF0FFFFFFU, 0xFFFCFFFFU, 0xFFFFFFFFU, + 0xFEEFF06FU, 0x873FFFFFU, 0x01FF01FFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0x00000000U, 0xFFFFFFFFU, 0x007FF87FU, + 0xFFFFFFFFU, 0xFE3FFFFFU, 0xFF3FFFFFU, 0xFF07FFFFU, + 0x1E03FFFFU, 0x0000FE00U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x000001FFU, 0x00000000U, + 0xFFFFFFFFU, 0x0007FFFFU, 0xFFFFFFFFU, 0xFC07FFFFU, + 0xFFFFFFFFU, 0x03FF00FFU, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x7FFFFFFFU, + 0xFFFFFFFFU, 0x00033BFFU, 0x00000000U, 0xE0000000U, + 0xFFFFFFFFU, 0xFFFF00FFU, 0x03FFFFFFU, 0xFFFF0000U, + 0x000003FFU, 0xFFFF0000U, 0x00000FFFU, 0x007FFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFC3FFFU, 0x803FFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFF2007U, 0x03FF01FFU, + 0xFFFFFFFFU, 0xFFDFFFFFU, 0xFFFF00FFU, 0x007FFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x001FFFFEU, + 0xFFFBFFFFU, 0xFFFFFFFFU, 0x00000003U, 0x00000000U, + 0xBFFFBD7FU, 0xFFFF03FFU, 0xFFFFFFFFU, 0x03FF07FFU, + 0xFFF99FEFU, 0xFBEDFDFFU, 0xE081399FU, 0x001F1FCFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xEFFFFFFFU, 0x00000003U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x03FF00FFU, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFF3FFFFFU, 0x3FFFFFFFU, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x03FF001FU, 0x00001FFFU, + 0xFFFFFFFFU, 0x03FFFFFFU, 0x000003FFU, 0x00000000U, + 0xE7FFFFFFU, 0xFFFF0FFFU, 0x0000007FU, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0x0FFFFFFFU, 0x00000000U, 0x00000000U, + 0x00000000U, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x8007FFFFU, + 0xFF6FF27FU, 0xF9BFFFFFU, 0x03FF007FU, 0x00000000U, + 0x00000000U, 0xFFFFFCFFU, 0xFCFFFFFFU, 0x0000001FU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFF00FFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFF0007U, 0xFFFFFFFFU, 0x01FFFFFFU, + 0x000003FFU, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFDFFU, 0xFF7FFFFFU, 0xFFFF003FU, 0xFFFF1FFFU, + 0xFFFCFFFFU, 0x007FFEFFU, 0x00000000U, 0x00000000U, + 0xFFFFFB7FU, 0xB47FFFFFU, 0x03FF00FFU, 0xFFFFFDBFU, + 0x01FB7FFFU, 0x000003FFU, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x01FFFFFFU, + 0xFFFDFFFFU, 0xC7FFFFFFU, 0x03FFFFFFU, 0x00000000U, + 0x00000000U, 0x00010000U, 0xFFFFFFFFU, 0x8003FFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0x03FFFFFFU, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x001F7FFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0000000FU, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFF0000U, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0007FFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x003FFFFFU, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0000007FU, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0x01FFFFFFU, 0x7FFFFFFFU, 0xFFFFC3FFU, + 0xFFFFFFFFU, 0x7FFFFFFFU, 0xFFFF03FFU, 0x003F3FFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFBFF003FU, 0xE0FFFFFBU, + 0x0000FFFFU, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0x07FFFFFFU, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFF87FFU, 0xFFFFFFFFU, + 0xFFFF80FFU, 0x00000000U, 0x00000000U, 0x0003001FU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x00FFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x003FFFFFU, 0x00000000U, + 0x000001FFU, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x6FEF0000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0x00040007U, 0x00270000U, 0xFFFF00F0U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0FFFFFFFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x1FFF07FFU, + 0xF3FF01FFU, 0x0000000FU, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFF3FFFU, 0xFFFF007FU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0000000FU, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x003FFFFFU, + 0xFFFFFFFFU, 0xFFFFFE7FU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x000007FFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0000003FU, 0x00000000U, + 0x00000000U, 0x00000000U, 0x000FFFFFU, 0x000FFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x007FFFFFU, 0x01FFFFFFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFDFFFFFU, 0xFFFFFFFFU, + 0xDFFFFFFFU, 0xEBFFDE64U, 0xFFFFFFEFU, 0xFFFFFFFFU, + 0xDFDFE7BFU, 0x7BFFFFFFU, 0xFFFDFC5FU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFF3FU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFCFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xF8000FFFU, 0x0000FFFEU, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x7FFFFFFFU, 0x000007E0U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xF9FFFF7FU, 0xFFFF07DBU, 0xFFFFFFFFU, 0x00003FFFU, + 0x00008000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0x3FFF1FFFU, 0x0000C3FFU, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFF0000U, 0x00007FFFU, 0xFFFFFFFFU, 0x83FFFFFFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0xFFFF0000U, 0x03FFFFFFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x7FFF6F7FU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x007FFF9FU, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xC3FF0FFFU, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0xFFFE0000U, + 0xFFFFFFFFU, 0x001FFFFFU, 0x00000000U, 0x00000000U, + 0xFFFFFFFEU, 0x3FFFFFFFU, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFEFU, 0x0AF7FE96U, 0xAA96EA84U, 0x5EF7F796U, + 0x0FFFFBFFU, 0x0FFFFBEEU, 0x00000000U, 0x00030000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFF0FFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0x000FFFFFU, 0xFFFE7FFFU, 0xFFFEFFFEU, 0x003FFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0x00003FFFU, 0x00000000U, 0xFFFFFFC0U, + 0xFFFF0007U, 0x0FFFFFFFU, 0x000301FFU, 0x0000003FU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xF0FFFFFFU, 0x1FFF1FFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xF87FFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x03FFFFFFU, 0x00010FFFU, + 0xFFFF0FFFU, 0xFFFFFFFFU, 0x03FF00FFU, 0xFFFFFFFFU, + 0xFFFF00FFU, 0x00033FFFU, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x000FFFFFU, 0x1FFF3FFFU, + 0xFFFF01FFU, 0xBFFFFFFFU, 0x0FFFC03FU, 0x01FF01FFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFF7FFFFU, 0xFFFFFFFFU, 0x000007FFU, 0x03FF0000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0x03FFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0x3FFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFF0003U, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x00000001U, + 0x3FFFFFFFU, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFF07FFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0x0000FFFFU, 0x00000000U, 0x00000000U, + 0x00000002U, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0000FFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x3FFFFFFFU + } +}; diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_lower.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_lower.c new file mode 100644 index 00000000..76c67635 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_lower.c @@ -0,0 +1,32 @@ +/* ISO C like properties of Unicode characters. + Copyright (C) 2002, 2006-2007, 2009-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2002. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unictype.h" + +#include "bitmap.h" + +/* Define u_is_lower table. */ +#include "ctype_lower.h" + +bool +uc_is_lower (ucs4_t uc) +{ + return bitmap_lookup (&u_is_lower, uc); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_lower.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_lower.h new file mode 100644 index 00000000..c487a169 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_lower.h @@ -0,0 +1,371 @@ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +/* ISO C like properties of Unicode characters. */ +/* Generated automatically by gen-uni-tables.c for Unicode 15.0.0. */ + +/* Copyright (C) 2000-2023 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#define header_0 16 +#define header_2 9 +#define header_3 127 +#define header_4 15 +static const +struct + { + int header[1]; + int level1[2]; + short level2[2 << 7]; + unsigned int level3[18 << 4]; + } +u_is_lower = +{ + { 2 }, + { + 3 * sizeof (int) / sizeof (short) + 0, + 3 * sizeof (int) / sizeof (short) + 128 + }, + { + 3 + 256 * sizeof (short) / sizeof (int) + 0, + 3 + 256 * sizeof (short) / sizeof (int) + 16, + 3 + 256 * sizeof (short) / sizeof (int) + 32, + -1, + -1, + -1, + -1, + -1, + 3 + 256 * sizeof (short) / sizeof (int) + 48, + 3 + 256 * sizeof (short) / sizeof (int) + 64, + -1, + -1, + -1, + -1, + 3 + 256 * sizeof (short) / sizeof (int) + 80, + 3 + 256 * sizeof (short) / sizeof (int) + 96, + 3 + 256 * sizeof (short) / sizeof (int) + 112, + -1, + 3 + 256 * sizeof (short) / sizeof (int) + 128, + -1, + -1, + -1, + 3 + 256 * sizeof (short) / sizeof (int) + 144, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 3 + 256 * sizeof (short) / sizeof (int) + 160, + -1, + 3 + 256 * sizeof (short) / sizeof (int) + 176, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 3 + 256 * sizeof (short) / sizeof (int) + 192, + -1, + -1, + 3 + 256 * sizeof (short) / sizeof (int) + 208, + -1, + -1, + -1, + 3 + 256 * sizeof (short) / sizeof (int) + 224, + -1, + -1, + -1, + -1, + -1, + 3 + 256 * sizeof (short) / sizeof (int) + 240, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 3 + 256 * sizeof (short) / sizeof (int) + 256, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 3 + 256 * sizeof (short) / sizeof (int) + 272, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + }, + { + 0x00000000U, 0x00000000U, 0x00000000U, 0x07FFFFFEU, + 0x00000000U, 0x00200000U, 0x80000000U, 0xFF7FFFFFU, + 0xAAAAAAAAU, 0x54AAAAAAU, 0xAAAAA955U, 0xD4AAAAAAU, + 0x46241129U, 0xA251212AU, 0xB5555B60U, 0xAA2CAAAAU, + 0xAAAAAAAAU, 0x900AAAA8U, 0x1ADFAA85U, 0x20269F6BU, + 0x60041F8DU, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000020U, 0x388A0000U, + 0x00000000U, 0xFFFEF000U, 0xAAE37FFFU, 0x092FAAAAU, + 0x00000000U, 0xFFFF0000U, 0xFFFFFFFFU, 0xAAAAAAAAU, + 0xAAAAA802U, 0xAAAAAAAAU, 0xAAAAD554U, 0xAAAAAAAAU, + 0xAAAAAAAAU, 0x0000AAAAU, 0x00000000U, 0xFFFFFFFEU, + 0x0000007FU, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0xFFFF0000U, 0xE7FFFFFFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x3F000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x000001FFU, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x22000000U, + 0x00004000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xAAAAAAAAU, 0xAAAAAAAAU, 0xAAAAAAAAU, 0xAAAAAAAAU, + 0x082AAAAAU, 0xAAAAAAAAU, 0xAAAAAAAAU, 0xAAAAAAAAU, + 0x003F00FFU, 0x00FF00FFU, 0x00AA003FU, 0x3FFF00FFU, + 0x00FF00FFU, 0x400B00FFU, 0x00030008U, 0x00080023U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00004000U, 0xFFFF0000U, + 0x00000010U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0xFFFF0000U, 0x000003FFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0xFFFF0000U, 0xFFFFFFFFU, 0x00481562U, + 0xAAAAAAAAU, 0xAAAAAAAAU, 0xAAAAAAAAU, 0x0008500AU, + 0xFFFFFFFFU, 0x000020BFU, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0xAAAAAAAAU, 0x00002AAAU, + 0x0AAAAAAAU, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0xAAA8AAA8U, 0xAAAAAAAAU, 0x9400AAAAU, + 0xAA9A10AAU, 0xAAA002AAU, 0x0282050AU, 0x00400000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00080000U, 0xFFFF0000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x07FFFFFEU, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0xFFFFFF00U, 0x0000FFFFU, 0x00000000U, + 0x00000000U, 0x00000000U, 0xFF000000U, 0x0FFFFFFFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFF800000U, 0x1BFBFFFBU, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0xFFFFFFFFU, 0x0007FFFFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0xFFFFFFFFU, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0xFFFFFFFFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0xFFFFFFFCU, 0x0000000FU, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U + } +}; diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_print.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_print.c new file mode 100644 index 00000000..5e73e42d --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_print.c @@ -0,0 +1,32 @@ +/* ISO C like properties of Unicode characters. + Copyright (C) 2002, 2006-2007, 2009-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2002. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unictype.h" + +#include "bitmap.h" + +/* Define u_is_print table. */ +#include "ctype_print.h" + +bool +uc_is_print (ucs4_t uc) +{ + return bitmap_lookup (&u_is_print, uc); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_print.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_print.h new file mode 100644 index 00000000..7dce963e --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_print.h @@ -0,0 +1,1182 @@ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +/* ISO C like properties of Unicode characters. */ +/* Generated automatically by gen-uni-tables.c for Unicode 15.0.0. */ + +/* Copyright (C) 2000-2023 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#define header_0 16 +#define header_2 9 +#define header_3 127 +#define header_4 15 +static const +struct + { + int header[1]; + int level1[17]; + short level2[6 << 7]; + unsigned int level3[89 << 4]; + } +u_is_print = +{ + { 17 }, + { + 18 * sizeof (int) / sizeof (short) + 0, + 18 * sizeof (int) / sizeof (short) + 128, + 18 * sizeof (int) / sizeof (short) + 256, + 18 * sizeof (int) / sizeof (short) + 384, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 18 * sizeof (int) / sizeof (short) + 512, + 18 * sizeof (int) / sizeof (short) + 640, + 18 * sizeof (int) / sizeof (short) + 640 + }, + { + 18 + 768 * sizeof (short) / sizeof (int) + 0, + 18 + 768 * sizeof (short) / sizeof (int) + 16, + 18 + 768 * sizeof (short) / sizeof (int) + 32, + 18 + 768 * sizeof (short) / sizeof (int) + 48, + 18 + 768 * sizeof (short) / sizeof (int) + 64, + 18 + 768 * sizeof (short) / sizeof (int) + 80, + 18 + 768 * sizeof (short) / sizeof (int) + 96, + 18 + 768 * sizeof (short) / sizeof (int) + 112, + 18 + 768 * sizeof (short) / sizeof (int) + 128, + 18 + 768 * sizeof (short) / sizeof (int) + 144, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 176, + 18 + 768 * sizeof (short) / sizeof (int) + 192, + 18 + 768 * sizeof (short) / sizeof (int) + 208, + 18 + 768 * sizeof (short) / sizeof (int) + 224, + 18 + 768 * sizeof (short) / sizeof (int) + 240, + 18 + 768 * sizeof (short) / sizeof (int) + 256, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 272, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 288, + 18 + 768 * sizeof (short) / sizeof (int) + 304, + 18 + 768 * sizeof (short) / sizeof (int) + 320, + 18 + 768 * sizeof (short) / sizeof (int) + 336, + 18 + 768 * sizeof (short) / sizeof (int) + 352, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 368, + 18 + 768 * sizeof (short) / sizeof (int) + 384, + 18 + 768 * sizeof (short) / sizeof (int) + 400, + 18 + 768 * sizeof (short) / sizeof (int) + 416, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 432, + -1, + -1, + -1, + -1, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 448, + 18 + 768 * sizeof (short) / sizeof (int) + 464, + 18 + 768 * sizeof (short) / sizeof (int) + 480, + 18 + 768 * sizeof (short) / sizeof (int) + 496, + 18 + 768 * sizeof (short) / sizeof (int) + 512, + 18 + 768 * sizeof (short) / sizeof (int) + 528, + 18 + 768 * sizeof (short) / sizeof (int) + 544, + 18 + 768 * sizeof (short) / sizeof (int) + 560, + 18 + 768 * sizeof (short) / sizeof (int) + 576, + 18 + 768 * sizeof (short) / sizeof (int) + 592, + 18 + 768 * sizeof (short) / sizeof (int) + 608, + 18 + 768 * sizeof (short) / sizeof (int) + 624, + 18 + 768 * sizeof (short) / sizeof (int) + 640, + 18 + 768 * sizeof (short) / sizeof (int) + 656, + 18 + 768 * sizeof (short) / sizeof (int) + 672, + 18 + 768 * sizeof (short) / sizeof (int) + 688, + 18 + 768 * sizeof (short) / sizeof (int) + 704, + 18 + 768 * sizeof (short) / sizeof (int) + 720, + 18 + 768 * sizeof (short) / sizeof (int) + 736, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 752, + 18 + 768 * sizeof (short) / sizeof (int) + 768, + -1, + -1, + -1, + -1, + 18 + 768 * sizeof (short) / sizeof (int) + 784, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 800, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 816, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 832, + -1, + 18 + 768 * sizeof (short) / sizeof (int) + 848, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 864, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 880, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 18 + 768 * sizeof (short) / sizeof (int) + 896, + 18 + 768 * sizeof (short) / sizeof (int) + 912, + 18 + 768 * sizeof (short) / sizeof (int) + 928, + -1, + -1, + -1, + -1, + 18 + 768 * sizeof (short) / sizeof (int) + 944, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 18 + 768 * sizeof (short) / sizeof (int) + 960, + 18 + 768 * sizeof (short) / sizeof (int) + 976, + 18 + 768 * sizeof (short) / sizeof (int) + 992, + 18 + 768 * sizeof (short) / sizeof (int) + 1008, + 18 + 768 * sizeof (short) / sizeof (int) + 1024, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 1040, + -1, + 18 + 768 * sizeof (short) / sizeof (int) + 1056, + 18 + 768 * sizeof (short) / sizeof (int) + 1072, + 18 + 768 * sizeof (short) / sizeof (int) + 1088, + 18 + 768 * sizeof (short) / sizeof (int) + 1104, + 18 + 768 * sizeof (short) / sizeof (int) + 1120, + 18 + 768 * sizeof (short) / sizeof (int) + 1136, + -1, + 18 + 768 * sizeof (short) / sizeof (int) + 1152, + 18 + 768 * sizeof (short) / sizeof (int) + 1168, + 18 + 768 * sizeof (short) / sizeof (int) + 1184, + 18 + 768 * sizeof (short) / sizeof (int) + 1200, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 1216, + 18 + 768 * sizeof (short) / sizeof (int) + 1232, + 18 + 768 * sizeof (short) / sizeof (int) + 1248, + -1, + -1, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 1264, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 1280, + 18 + 768 * sizeof (short) / sizeof (int) + 1296, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 1312, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 1328, + -1, + -1, + -1, + -1, + -1, + -1, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 1344, + -1, + -1, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 1360, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 1376, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 18 + 768 * sizeof (short) / sizeof (int) + 1392, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 160, + 18 + 768 * sizeof (short) / sizeof (int) + 1408 + }, + { + 0x00000000U, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x7FFFFFFFU, + 0x00000000U, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFCFFFFFFU, + 0xFFFFD7F0U, 0xFFFFFFFBU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFEFFFFU, 0xFE7FFFFFU, 0xFFFFFFFFU, + 0xFFFEE7FFU, 0xFFFFFFFFU, 0xFFFF00FFU, 0x001F87FFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFBFFFU, 0xFFFFFFFFU, 0xFFFFE7FFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0x0003FFFFU, 0xFFFFFFFFU, 0xE7FFFFFFU, + 0xFFFFFFFFU, 0x7FFF3FFFU, 0x4FFFFFFFU, 0xFFFF07FFU, + 0xFF037FFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFF99FEFU, 0xF3C5FDFFU, 0xB080799FU, 0x7FFFFFCFU, + 0xFFF987EEU, 0xD36DFDFFU, 0x5E023987U, 0x007FFFC0U, + 0xFFFBBFEEU, 0xF3EDFDFFU, 0x00013BBFU, 0xFE03FFCFU, + 0xFFF99FEEU, 0xF3EDFDFFU, 0xB0E0399FU, 0x00FFFFCFU, + 0xD63DC7ECU, 0xC3FFC718U, 0x00813DC7U, 0x07FFFFC0U, + 0xFFFDDFFFU, 0xF3FFFDFFU, 0x27603DDFU, 0xFF80FFCFU, + 0xFFFDDFFFU, 0xF3EFFDFFU, 0x60603DDFU, 0x000EFFCFU, + 0xFFFDDFFFU, 0xFFFFFFFFU, 0xFFF0FDDFU, 0xFFFFFFCFU, + 0xFC7FFFEEU, 0x2FFBFFFFU, 0xFF5F847FU, 0x001CFFC0U, + 0xFFFFFFFEU, 0x87FFFFFFU, 0x0FFFFFFFU, 0x00000000U, + 0xFFFFF7D6U, 0x3FFFFFAFU, 0xF3FF7F5FU, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFEFFU, 0xFFFE1FFFU, + 0xFEFFFFFFU, 0xDFFFFFFFU, 0x07FFDFFFU, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFF20BFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x3D7F3DFFU, 0xFFFFFFFFU, + 0xFFFF3DFFU, 0x7F3DFFFFU, 0xFF7FFF3DU, 0xFFFFFFFFU, + 0xFF3DFFFFU, 0xFFFFFFFFU, 0xE7FFFFFFU, 0x1FFFFFFFU, + 0x03FFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x3F3FFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0x1FFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x01FFFFFFU, + 0x803FFFFFU, 0x007FFFFFU, 0x000FFFFFU, 0x000DDFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x3FFFFFFFU, 0x03FF03FFU, + 0x03FFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x01FFFFFFU, + 0xFFFFFFFFU, 0xFFFF07FFU, 0xFFFFFFFFU, 0x003FFFFFU, + 0x7FFFFFFFU, 0x0FFF0FFFU, 0xFFFFFFF1U, 0x001F3FFFU, + 0xFFFFFFFFU, 0xFFFF0FFFU, 0xC7FF03FFU, 0xFFFFFFFFU, + 0xCFFFFFFFU, 0xFFFFFFFFU, 0x7FFFFFFFU, 0x9FFFFFFFU, + 0x03FF03FFU, 0xFFFF3FFFU, 0x00007FFFU, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFF1FFFU, 0x7FFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xF00FFFFFU, + 0xFFFFFFFFU, 0xF8FFFFFFU, 0xFFFFE3FFU, 0xFFFFFFFFU, + 0xFFFF01FFU, 0xE7FFFFFFU, 0xFFFF00FFU, 0x07FFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0x3F3FFFFFU, 0xFFFFFFFFU, 0xAAFF3F3FU, 0x3FFFFFFFU, + 0xFFFFFFFFU, 0xFFDFFFFFU, 0xEFCFFFDFU, 0x7FDCFFFFU, + 0xFFFFFFFFU, 0xFFFFFCFFU, 0xFFFFFFFFU, 0xFFF3FFDFU, + 0x1FFF7FFFU, 0xFFFFFFFFU, 0xFFFF0001U, 0x0001FFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFF0FFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0x0000007FU, 0x000007FFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFCFFFFFU, + 0xFFBFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFE0FFFFFU, + 0xFFFFFFFFU, 0xFFFF20BFU, 0xFFFFFFFFU, 0x800180FFU, + 0x007FFFFFU, 0x7F7F7F7FU, 0x7F7F7F7FU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x3FFFFFFFU, 0x00000000U, + 0xFBFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x000FFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x003FFFFFU, 0x0FFF0000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFEU, 0xFFFFFFFFU, + 0xFE7FFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFE0U, 0xFFFEFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFF7FFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFF000FU, + 0x7FFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFF1FFFU, 0xFFFFFFFFU, 0xFFFF007FU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0x00000FFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x00FFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x03EB07FFU, 0xFFFC0000U, + 0xFFFFFFFFU, 0x03FF1FFFU, 0xFFFFFFFFU, 0x00FFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x03FFC03FU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x800FFFFFU, 0x1FFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xC3FFBFFFU, 0x7FFFFFFFU, + 0xFFFFFFFFU, 0x007FFFFFU, 0xF3FF3FFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xF8000007U, 0x007FFFFFU, + 0x007E7E7EU, 0xFFFF7F7FU, 0xFFFFFFFFU, 0xFFFF0FFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x03FF3FFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFF000FU, 0xFFFFF87FU, 0x0FFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFF3FFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x03FFFFFFU, 0x00000000U, + 0xE0F8007FU, 0x5F7FFFFFU, 0xFFFFFFDBU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFF80007U, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFCFFFFU, 0xFFFFFFFFU, 0x000080FFU, 0xFFFF0000U, + 0x03FFFFFFU, 0xFFFFFFFFU, 0xFFF7FFFFU, 0xFFDF0F7FU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x9FFFFFFFU, + 0xFFFFFFFEU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0x7FFFFFFFU, 0x1CFCFCFCU, 0x3E007F7FU, + 0xFFFFEFFFU, 0xB7FFFF7FU, 0x3FFF3FFFU, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x07FFFFFFU, + 0xFFFFFF87U, 0xFF8FFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0x1FFF7FFFU, 0x00000001U, 0xFFFF0000U, 0x3FFFFFFFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x1FFFFFFFU, 0xFFFFFFFFU, 0x0001FFFFU, 0x0FFFFFFFU, + 0xFFFFFFFFU, 0xFFFFE00FU, 0xFFFF07FFU, 0x07FFFFFFU, + 0xBFFFFFFFU, 0xFFFFFFFFU, 0x003FFF0FU, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0x3FFFFFFFU, 0xFFFF03FFU, 0xFF0FFFFFU, 0x0FFFFFFFU, + 0xFFFFFFFFU, 0xFFFF00FFU, 0xFFFFFFFFU, 0xF7FF800FU, + 0xFFB7F7FFU, 0x1BFBFFFBU, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0x007FFFFFU, 0x003FFFFFU, 0x000000FFU, + 0xFFFFFFBFU, 0x07FDFFFFU, 0x00000000U, 0x00000000U, + 0xFFFFFD3FU, 0x91BFFFFFU, 0xFFBFFFFFU, 0xFFFFFFFFU, + 0x7FFFFFFFU, 0x0000FF80U, 0x00000000U, 0xF837FFFFU, + 0x8FFFFFFFU, 0x83FFFFFFU, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xF0FFFFFFU, 0xFFFCFFFFU, 0xFFFFFFFFU, + 0xFEEFF06FU, 0x873FFFFFU, 0x01FF01FFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0x00000000U, 0xFFFFFFFFU, 0x007FF87FU, + 0xFFFFFFFFU, 0xFE3FFFFFU, 0xFF3FFFFFU, 0xFF07FFFFU, + 0x1E03FFFFU, 0x0000FE00U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x000001FFU, 0x00000000U, + 0xFFFFFFFFU, 0x0007FFFFU, 0xFFFFFFFFU, 0xFC07FFFFU, + 0xFFFFFFFFU, 0x03FF00FFU, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x7FFFFFFFU, + 0xFFFFFFFFU, 0x00033BFFU, 0x00000000U, 0xE0000000U, + 0xFFFFFFFFU, 0xFFFF00FFU, 0x03FFFFFFU, 0xFFFF0000U, + 0x000003FFU, 0xFFFF0000U, 0x00000FFFU, 0x007FFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFC3FFFU, 0x803FFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFF2007U, 0x03FF01FFU, + 0xFFFFFFFFU, 0xFFDFFFFFU, 0xFFFF00FFU, 0x007FFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x001FFFFEU, + 0xFFFBFFFFU, 0xFFFFFFFFU, 0x00000003U, 0x00000000U, + 0xBFFFBD7FU, 0xFFFF03FFU, 0xFFFFFFFFU, 0x03FF07FFU, + 0xFFF99FEFU, 0xFBEDFDFFU, 0xE081399FU, 0x001F1FCFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xEFFFFFFFU, 0x00000003U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x03FF00FFU, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFF3FFFFFU, 0x3FFFFFFFU, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x03FF001FU, 0x00001FFFU, + 0xFFFFFFFFU, 0x03FFFFFFU, 0x000003FFU, 0x00000000U, + 0xE7FFFFFFU, 0xFFFF0FFFU, 0x0000007FU, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0x0FFFFFFFU, 0x00000000U, 0x00000000U, + 0x00000000U, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x8007FFFFU, + 0xFF6FF27FU, 0xF9BFFFFFU, 0x03FF007FU, 0x00000000U, + 0x00000000U, 0xFFFFFCFFU, 0xFCFFFFFFU, 0x0000001FU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFF00FFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFF0007U, 0xFFFFFFFFU, 0x01FFFFFFU, + 0x000003FFU, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFDFFU, 0xFF7FFFFFU, 0xFFFF003FU, 0xFFFF1FFFU, + 0xFFFCFFFFU, 0x007FFEFFU, 0x00000000U, 0x00000000U, + 0xFFFFFB7FU, 0xB47FFFFFU, 0x03FF00FFU, 0xFFFFFDBFU, + 0x01FB7FFFU, 0x000003FFU, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x01FFFFFFU, + 0xFFFDFFFFU, 0xC7FFFFFFU, 0x03FFFFFFU, 0x00000000U, + 0x00000000U, 0x00010000U, 0xFFFFFFFFU, 0x8003FFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0x03FFFFFFU, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x001F7FFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0000000FU, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFF0000U, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0007FFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x003FFFFFU, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0000007FU, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0x01FFFFFFU, 0x7FFFFFFFU, 0xFFFFC3FFU, + 0xFFFFFFFFU, 0x7FFFFFFFU, 0xFFFF03FFU, 0x003F3FFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFBFF003FU, 0xE0FFFFFBU, + 0x0000FFFFU, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0x07FFFFFFU, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFF87FFU, 0xFFFFFFFFU, + 0xFFFF80FFU, 0x00000000U, 0x00000000U, 0x0003001FU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x00FFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x003FFFFFU, 0x00000000U, + 0x000001FFU, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x6FEF0000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0x00040007U, 0x00270000U, 0xFFFF00F0U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0FFFFFFFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x1FFF07FFU, + 0xF3FF01FFU, 0x0000000FU, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFF3FFFU, 0xFFFF007FU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0000000FU, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x003FFFFFU, + 0xFFFFFFFFU, 0xFFFFFE7FU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x000007FFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0000003FU, 0x00000000U, + 0x00000000U, 0x00000000U, 0x000FFFFFU, 0x000FFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x007FFFFFU, 0x01FFFFFFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFDFFFFFU, 0xFFFFFFFFU, + 0xDFFFFFFFU, 0xEBFFDE64U, 0xFFFFFFEFU, 0xFFFFFFFFU, + 0xDFDFE7BFU, 0x7BFFFFFFU, 0xFFFDFC5FU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFF3FU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFCFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xF8000FFFU, 0x0000FFFEU, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x7FFFFFFFU, 0x000007E0U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xF9FFFF7FU, 0xFFFF07DBU, 0xFFFFFFFFU, 0x00003FFFU, + 0x00008000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0x3FFF1FFFU, 0x0000C3FFU, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFF0000U, 0x00007FFFU, 0xFFFFFFFFU, 0x83FFFFFFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0xFFFF0000U, 0x03FFFFFFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x7FFF6F7FU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x007FFF9FU, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xC3FF0FFFU, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0xFFFE0000U, + 0xFFFFFFFFU, 0x001FFFFFU, 0x00000000U, 0x00000000U, + 0xFFFFFFFEU, 0x3FFFFFFFU, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFEFU, 0x0AF7FE96U, 0xAA96EA84U, 0x5EF7F796U, + 0x0FFFFBFFU, 0x0FFFFBEEU, 0x00000000U, 0x00030000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFF0FFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0x000FFFFFU, 0xFFFE7FFFU, 0xFFFEFFFEU, 0x003FFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0x00003FFFU, 0x00000000U, 0xFFFFFFC0U, + 0xFFFF0007U, 0x0FFFFFFFU, 0x000301FFU, 0x0000003FU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xF0FFFFFFU, 0x1FFF1FFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xF87FFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x03FFFFFFU, 0x00010FFFU, + 0xFFFF0FFFU, 0xFFFFFFFFU, 0x03FF00FFU, 0xFFFFFFFFU, + 0xFFFF00FFU, 0x00033FFFU, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x000FFFFFU, 0x1FFF3FFFU, + 0xFFFF01FFU, 0xBFFFFFFFU, 0x0FFFC03FU, 0x01FF01FFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFF7FFFFU, 0xFFFFFFFFU, 0x000007FFU, 0x03FF0000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0x03FFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0x3FFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFF0003U, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x00000001U, + 0x3FFFFFFFU, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFF07FFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0x0000FFFFU, 0x00000000U, 0x00000000U, + 0x00000002U, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0000FFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x3FFFFFFFU + } +}; diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_punct.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_punct.c new file mode 100644 index 00000000..3991feed --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_punct.c @@ -0,0 +1,32 @@ +/* ISO C like properties of Unicode characters. + Copyright (C) 2002, 2006-2007, 2009-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2002. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unictype.h" + +#include "bitmap.h" + +/* Define u_is_punct table. */ +#include "ctype_punct.h" + +bool +uc_is_punct (ucs4_t uc) +{ + return bitmap_lookup (&u_is_punct, uc); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_punct.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_punct.h new file mode 100644 index 00000000..22f66f01 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_punct.h @@ -0,0 +1,858 @@ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +/* ISO C like properties of Unicode characters. */ +/* Generated automatically by gen-uni-tables.c for Unicode 15.0.0. */ + +/* Copyright (C) 2000-2023 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#define header_0 16 +#define header_2 9 +#define header_3 127 +#define header_4 15 +static const +struct + { + int header[1]; + int level1[17]; + short level2[4 << 7]; + unsigned int level3[72 << 4]; + } +u_is_punct = +{ + { 17 }, + { + 18 * sizeof (int) / sizeof (short) + 0, + 18 * sizeof (int) / sizeof (short) + 128, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 18 * sizeof (int) / sizeof (short) + 256, + 18 * sizeof (int) / sizeof (short) + 384, + 18 * sizeof (int) / sizeof (short) + 384 + }, + { + 18 + 512 * sizeof (short) / sizeof (int) + 0, + 18 + 512 * sizeof (short) / sizeof (int) + 16, + 18 + 512 * sizeof (short) / sizeof (int) + 32, + 18 + 512 * sizeof (short) / sizeof (int) + 48, + 18 + 512 * sizeof (short) / sizeof (int) + 64, + 18 + 512 * sizeof (short) / sizeof (int) + 80, + 18 + 512 * sizeof (short) / sizeof (int) + 96, + 18 + 512 * sizeof (short) / sizeof (int) + 112, + 18 + 512 * sizeof (short) / sizeof (int) + 128, + 18 + 512 * sizeof (short) / sizeof (int) + 144, + 18 + 512 * sizeof (short) / sizeof (int) + 160, + 18 + 512 * sizeof (short) / sizeof (int) + 176, + 18 + 512 * sizeof (short) / sizeof (int) + 192, + 18 + 512 * sizeof (short) / sizeof (int) + 208, + 18 + 512 * sizeof (short) / sizeof (int) + 224, + 18 + 512 * sizeof (short) / sizeof (int) + 240, + 18 + 512 * sizeof (short) / sizeof (int) + 256, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 288, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 304, + 18 + 512 * sizeof (short) / sizeof (int) + 320, + 18 + 512 * sizeof (short) / sizeof (int) + 336, + 18 + 512 * sizeof (short) / sizeof (int) + 352, + 18 + 512 * sizeof (short) / sizeof (int) + 368, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 18 + 512 * sizeof (short) / sizeof (int) + 384, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 18 + 512 * sizeof (short) / sizeof (int) + 400, + 18 + 512 * sizeof (short) / sizeof (int) + 416, + 18 + 512 * sizeof (short) / sizeof (int) + 432, + 18 + 512 * sizeof (short) / sizeof (int) + 448, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 464, + 18 + 512 * sizeof (short) / sizeof (int) + 480, + 18 + 512 * sizeof (short) / sizeof (int) + 496, + 18 + 512 * sizeof (short) / sizeof (int) + 512, + 18 + 512 * sizeof (short) / sizeof (int) + 528, + 18 + 512 * sizeof (short) / sizeof (int) + 544, + 18 + 512 * sizeof (short) / sizeof (int) + 560, + -1, + 18 + 512 * sizeof (short) / sizeof (int) + 576, + 18 + 512 * sizeof (short) / sizeof (int) + 592, + 18 + 512 * sizeof (short) / sizeof (int) + 608, + 18 + 512 * sizeof (short) / sizeof (int) + 624, + 18 + 512 * sizeof (short) / sizeof (int) + 640, + 18 + 512 * sizeof (short) / sizeof (int) + 656, + 18 + 512 * sizeof (short) / sizeof (int) + 672, + 18 + 512 * sizeof (short) / sizeof (int) + 688, + 18 + 512 * sizeof (short) / sizeof (int) + 704, + 18 + 512 * sizeof (short) / sizeof (int) + 720, + 18 + 512 * sizeof (short) / sizeof (int) + 736, + 18 + 512 * sizeof (short) / sizeof (int) + 752, + -1, + -1, + 18 + 512 * sizeof (short) / sizeof (int) + 768, + -1, + -1, + -1, + -1, + 18 + 512 * sizeof (short) / sizeof (int) + 784, + -1, + -1, + 18 + 512 * sizeof (short) / sizeof (int) + 800, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 18 + 512 * sizeof (short) / sizeof (int) + 816, + -1, + 18 + 512 * sizeof (short) / sizeof (int) + 832, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 18 + 512 * sizeof (short) / sizeof (int) + 848, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 18 + 512 * sizeof (short) / sizeof (int) + 864, + 18 + 512 * sizeof (short) / sizeof (int) + 880, + 18 + 512 * sizeof (short) / sizeof (int) + 896, + -1, + 18 + 512 * sizeof (short) / sizeof (int) + 912, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 928, + -1, + -1, + 18 + 512 * sizeof (short) / sizeof (int) + 944, + 18 + 512 * sizeof (short) / sizeof (int) + 960, + 18 + 512 * sizeof (short) / sizeof (int) + 976, + -1, + 18 + 512 * sizeof (short) / sizeof (int) + 992, + -1, + 18 + 512 * sizeof (short) / sizeof (int) + 1008, + 18 + 512 * sizeof (short) / sizeof (int) + 1024, + 18 + 512 * sizeof (short) / sizeof (int) + 1040, + 18 + 512 * sizeof (short) / sizeof (int) + 1056, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 1072, + 18 + 512 * sizeof (short) / sizeof (int) + 1088, + 18 + 512 * sizeof (short) / sizeof (int) + 1104, + -1, + -1, + 18 + 512 * sizeof (short) / sizeof (int) + 1120, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 272, + 18 + 512 * sizeof (short) / sizeof (int) + 1136 + }, + { + 0x00000000U, 0xFC00FFFEU, 0xF8000001U, 0x78000001U, + 0x00000000U, 0xFBDFFBFFU, 0x00800000U, 0x00800000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0xFFFC003CU, 0xFFFFAFE0U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFDFU, 0x4020FFFFU, + 0x000000B0U, 0x00000000U, 0x00000000U, 0x00400000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x000003FCU, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0xFC000000U, 0x00000000U, + 0xFFFEE600U, 0xFFFFFFFFU, 0x000000FFU, 0x00180000U, + 0xFFFFFFFFU, 0x00000000U, 0xFFFFF800U, 0x00013C00U, + 0x00000000U, 0x00000000U, 0xFFD00000U, 0x60003F9FU, + 0x0002BFFFU, 0xFFFF0000U, 0x000007FFU, 0x00000000U, + 0x00000000U, 0x0001FFC0U, 0x00000000U, 0xE3CFF800U, + 0xFBC00000U, 0x7FFF3EEFU, 0x4E000000U, 0x00000000U, + 0xFF030100U, 0x00000000U, 0xFFFFFC00U, 0xFFFFFFFFU, + 0x0000000FU, 0xDC000000U, 0x00FEFFFFU, 0x0001003CU, + 0x0000000EU, 0xD0000000U, 0x0080399FU, 0x6FFC000CU, + 0x0000000EU, 0xD0000000U, 0x00023987U, 0x00630000U, + 0x0000000EU, 0xD0000000U, 0x00003BBFU, 0xFC03000CU, + 0x0000000EU, 0xD0000000U, 0x00E0399FU, 0x00FD000CU, + 0x00000004U, 0xC0000000U, 0x00803DC7U, 0x07FF0000U, + 0x0000001FU, 0xD0000000U, 0x00603DDFU, 0xFF80000CU, + 0x0000001EU, 0xD0000000U, 0x00603DDFU, 0x0008000CU, + 0x0000000FU, 0xD8000000U, 0x7F80BDDFU, 0x03FF000CU, + 0x0000000EU, 0x00000000U, 0xFF5F8400U, 0x001C0000U, + 0x00000000U, 0x80008000U, 0x0C008040U, 0x00000000U, + 0x00000000U, 0x1FF20000U, 0x00007F00U, 0x00000000U, + 0xFFFFFFFEU, 0xFFFFFC00U, 0x00000000U, 0xFFFE0000U, + 0xFEFFE0FFU, 0xDFFFFFFFU, 0x07FFDFFFU, 0x00000000U, + 0x00000000U, 0x7FFFF800U, 0xC3C0FC00U, 0x001E3F9DU, + 0xFC00BFFCU, 0x00000000U, 0x00000000U, 0x08000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0xE0000000U, 0x1FFFFFFFU, + 0x03FF0000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000001U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00006000U, + 0x18000000U, 0x00000000U, 0x00000000U, 0x00003800U, + 0x003C0000U, 0x007C0000U, 0x000C0000U, 0x000C0000U, + 0x00000000U, 0xFFF00000U, 0x2F7FFFFFU, 0x03FF0000U, + 0x0000FFFFU, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000060U, 0x00000200U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x0FFF0FFFU, 0x00000031U, 0x00000000U, + 0x00000000U, 0x00000000U, 0xC4000000U, 0xFFFFFFFFU, + 0xCF800000U, 0x00000000U, 0x7FE00000U, 0x9FFFFFFFU, + 0x00000000U, 0xFFFF3F7FU, 0x00007FFFU, 0x00000000U, + 0x0000001FU, 0xFFF00000U, 0xFC00001FU, 0x7FFFFFFFU, + 0x00000007U, 0x00003FFEU, 0x00000000U, 0xF00FFFC0U, + 0x00000000U, 0xF8FFFFF0U, 0x00000000U, 0xC0000000U, + 0x00000000U, 0x00000000U, 0xFFFF00FFU, 0x039021FFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0xA0000000U, 0xE000E003U, 0x6000E000U, + 0xFFFFF880U, 0xFFFFFCFFU, 0x7FFFFFFFU, 0x7FF1FFDFU, + 0x00007FFFU, 0xFFFFFFFFU, 0xFFFF0001U, 0x0001FFFFU, + 0xC1D0037BU, 0x0C0040AFU, 0xFFFFBC1FU, 0x00000000U, + 0xFFFF0E00U, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0x0000007FU, 0x000007FFU, 0xFFFFFFFFU, + 0x0FFFFFFFU, 0x00000000U, 0x00000000U, 0xFFFFFC00U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFCFFFFFU, + 0xFFBFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0xFE0387E0U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x80010000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFF7FFFU, 0x3FFFFFFFU, 0x00000000U, + 0xFBFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x000FFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x003FFFFFU, 0x0FFF0000U, + 0xFFFFFF1EU, 0xE0C1FC01U, 0x00000000U, 0x00000000U, + 0x1E000000U, 0x00000001U, 0x00000000U, 0x08000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFF0000U, 0x00000000U, 0xFFFFFFFFU, 0x0000000FU, + 0x7FFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFF0000U, 0xFFFFFFFFU, 0x0000007FU, 0xC0000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x0000E000U, 0x00000000U, 0x00000000U, 0x7FFF8000U, + 0xC0000000U, 0x00000000U, 0x00000000U, 0x00FF0000U, + 0x007FFFFFU, 0x00000003U, 0x00000000U, 0x00000000U, + 0x00000600U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000844U, 0x03FF1FF8U, 0x00000000U, 0x00F00000U, + 0x00000003U, 0xFFF00000U, 0x0000C03FU, 0x9703FFFFU, + 0x00000000U, 0x0000FFC0U, 0x800FFF80U, 0x00000000U, + 0x0000000FU, 0xFFF80000U, 0xC0003FFFU, 0x00000020U, + 0x00000000U, 0x007FFE00U, 0xF0003008U, 0x3B800000U, + 0x00000000U, 0xC19D0000U, 0xC0000002U, 0x0063F800U, + 0x00000000U, 0x00000000U, 0x08000000U, 0x00000C00U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00003FF8U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x40000000U, 0x00000200U, 0x00000000U, 0x00000000U, + 0x00000000U, 0xFFFC0000U, 0x00000007U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0xC0000000U, 0x0000FFFFU, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00008000U, 0xF0000000U, + 0x03FFFFFFU, 0xFFFFFFFFU, 0xFFF7FFFFU, 0x00000F7FU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x80000000U, + 0xFC00FFFEU, 0xF8000001U, 0xF8000001U, 0x0000003FU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x3E007F7FU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFF87U, 0xFF8FFFFFU, 0x00000000U, 0xFFE00000U, + 0x1FFF7FFFU, 0x00000001U, 0xFFFF0000U, 0x3FFFFFFFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x0FFFFFFFU, + 0x00000000U, 0x0000000FU, 0x00000000U, 0x07C00000U, + 0x80000000U, 0x00000000U, 0x00010000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00008000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0xFF800000U, 0xFF800000U, + 0x00000000U, 0x0000FF80U, 0x00000000U, 0xF8000000U, + 0x8FC00000U, 0x80000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x30000000U, 0xFFFCFFFFU, 0xFFFFFFFFU, + 0x0000F06EU, 0x87000000U, 0x01FF01FFU, 0xE0000000U, + 0xE0000000U, 0x00000000U, 0x00000100U, 0x007FF860U, + 0x00000000U, 0xFE000000U, 0xFF000000U, 0xFF000000U, + 0x1E000000U, 0x0000FE00U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0xFC000000U, + 0x00000000U, 0x000000F0U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x7FFFFFFFU, + 0x00000000U, 0x00003800U, 0x00000000U, 0xE0000000U, + 0xE0000000U, 0x0000007FU, 0x03FFFFC0U, 0x00000000U, + 0x000003FCU, 0x00000000U, 0x00000FE0U, 0x00000000U, + 0x00000007U, 0xFF000000U, 0xFFFC3FFFU, 0x8019003FU, + 0x00000007U, 0xFFFF0000U, 0x00002007U, 0x00000000U, + 0x00000007U, 0x001FFF80U, 0x0000006FU, 0x00380000U, + 0x00000007U, 0xFFF80000U, 0xE800FFE1U, 0x001FFFFEU, + 0x00000000U, 0x7FFFF000U, 0x00000002U, 0x00000000U, + 0x00000000U, 0x00000200U, 0x80000000U, 0x000007FFU, + 0x0000000FU, 0xD8000000U, 0x0080399FU, 0x001F1FCCU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0xFFE00000U, 0x6C00F87FU, 0x00000000U, + 0x00000000U, 0xFFFF0000U, 0x0000004FU, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0xFF3F8000U, 0x30FFFFFFU, 0x00000000U, + 0x00000000U, 0xFFFF0000U, 0x0000000FU, 0x00001FFFU, + 0x00000000U, 0x02FFF800U, 0x00000000U, 0x00000000U, + 0xE0000000U, 0xFC000FFFU, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x0FFFF000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x0007FC00U, + 0x00000000U, 0x79BF0000U, 0x0000007DU, 0x00000000U, + 0x00000000U, 0x00000000U, 0xFCFE0000U, 0x00000015U, + 0x000007FEU, 0xFBF80000U, 0x0FFE00FFU, 0x00000000U, + 0xDFFFFC00U, 0x00000007U, 0x00000000U, 0x00000000U, + 0x000003FFU, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0xFF7F8000U, 0xFC00003EU, 0x00031FFFU, + 0xFFFC0000U, 0x007FFEFFU, 0x00000000U, 0x00000000U, + 0x00000000U, 0xB47E0000U, 0x000000BFU, 0x00000000U, + 0x00FB7C00U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x01F80000U, + 0x0000000BU, 0xC7F00000U, 0x0000FFFFU, 0x00000000U, + 0x00000000U, 0x00000000U, 0xFFFFFFFFU, 0x8003FFFFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x001F0000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00060000U, + 0x00000000U, 0xFFFF0000U, 0x003FFF81U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x0000C000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x003F0000U, + 0x00000000U, 0xFFFF0000U, 0xF8000030U, 0x00000003U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x07FFFFFFU, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0xFFFE8000U, 0xFFFFFFFFU, + 0x000780FFU, 0x00000000U, 0x00000000U, 0x00030014U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xF0000000U, 0x0000000FU, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFF3FFFU, 0xFFFF007FU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0000000FU, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x003FFFFFU, + 0xFFFFFFFFU, 0xFFFFFE7FU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x000007FFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0000003FU, 0x00000000U, + 0x00000000U, 0x00000000U, 0x000FFFFFU, 0x000FFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x007FFFFFU, 0x01FFFFFFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x08000002U, 0x08000000U, + 0x00200000U, 0x00200000U, 0x00008000U, 0x00008000U, + 0x00000200U, 0x00000200U, 0x00000008U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xF8000FFFU, 0x0000FFFEU, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xF9FFFF7FU, 0x000007DBU, 0x00000000U, 0x00000000U, + 0x00008000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x007F0000U, 0x00008000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00004000U, 0x00000000U, 0x8000F000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x0000F000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x007FFF80U, 0x00000000U, + 0x00000000U, 0x00000000U, 0xC00007F0U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0xFFFE0000U, + 0xFFFFFFFFU, 0x001FFFFFU, 0x00000000U, 0x00000000U, + 0xFFFFFFFEU, 0x3FFFFFFFU, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00030000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFF0FFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0x000FFFFFU, 0xFFFE7FFFU, 0xFFFEFFFEU, 0x003FFFFFU, + 0x0000FFFFU, 0x0000E000U, 0x0000FC00U, 0x0000FC00U, + 0xFFFFF800U, 0x00003FDFU, 0x00000000U, 0x00000000U, + 0xFFFF0007U, 0x0FFFFFFFU, 0x000301FFU, 0x0000003FU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xF0FFFFFFU, 0x1FFF1FFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xF87FFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x03FFFFFFU, 0x00010FFFU, + 0xFFFF0FFFU, 0xFFFFFFFFU, 0x03FF00FFU, 0xFFFFFFFFU, + 0xFFFF00FFU, 0x00033FFFU, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x000FFFFFU, 0x1FFF3FFFU, + 0xFFFF01FFU, 0xBFFFFFFFU, 0x0FFFC03FU, 0x01FF01FFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFF7FFFFU, 0xFFFFFFFFU, 0x000007FFU, 0x00000000U, + 0x00000002U, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0000FFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x3FFFFFFFU + } +}; diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_space.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_space.c new file mode 100644 index 00000000..cdfe54d9 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_space.c @@ -0,0 +1,32 @@ +/* ISO C like properties of Unicode characters. + Copyright (C) 2002, 2006-2007, 2009-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2002. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unictype.h" + +#include "bitmap.h" + +/* Define u_is_space table. */ +#include "ctype_space.h" + +bool +uc_is_space (ucs4_t uc) +{ + return bitmap_lookup (&u_is_space, uc); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_space.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_space.h new file mode 100644 index 00000000..69521a5a --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_space.h @@ -0,0 +1,184 @@ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +/* ISO C like properties of Unicode characters. */ +/* Generated automatically by gen-uni-tables.c for Unicode 15.0.0. */ + +/* Copyright (C) 2000-2023 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#define header_0 16 +#define header_2 9 +#define header_3 127 +#define header_4 15 +static const +struct + { + int header[1]; + int level1[1]; + short level2[1 << 7]; + unsigned int level3[4 << 4]; + } +u_is_space = +{ + { 1 }, + { 2 * sizeof (int) / sizeof (short) + 0 }, + { + 2 + 128 * sizeof (short) / sizeof (int) + 0, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 2 + 128 * sizeof (short) / sizeof (int) + 16, + -1, + -1, + -1, + -1, + 2 + 128 * sizeof (short) / sizeof (int) + 32, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 2 + 128 * sizeof (short) / sizeof (int) + 48, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + }, + { + 0x00003E00U, 0x00000001U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000001U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x0000077FU, 0x00000300U, 0x80000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000001U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U + } +}; diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_upper.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_upper.c new file mode 100644 index 00000000..02110cc6 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_upper.c @@ -0,0 +1,32 @@ +/* ISO C like properties of Unicode characters. + Copyright (C) 2002, 2006-2007, 2009-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2002. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unictype.h" + +#include "bitmap.h" + +/* Define u_is_upper table. */ +#include "ctype_upper.h" + +bool +uc_is_upper (ucs4_t uc) +{ + return bitmap_lookup (&u_is_upper, uc); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_upper.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_upper.h new file mode 100644 index 00000000..dbe1da4d --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_upper.h @@ -0,0 +1,367 @@ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +/* ISO C like properties of Unicode characters. */ +/* Generated automatically by gen-uni-tables.c for Unicode 15.0.0. */ + +/* Copyright (C) 2000-2023 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#define header_0 16 +#define header_2 9 +#define header_3 127 +#define header_4 15 +static const +struct + { + int header[1]; + int level1[2]; + short level2[2 << 7]; + unsigned int level3[17 << 4]; + } +u_is_upper = +{ + { 2 }, + { + 3 * sizeof (int) / sizeof (short) + 0, + 3 * sizeof (int) / sizeof (short) + 128 + }, + { + 3 + 256 * sizeof (short) / sizeof (int) + 0, + 3 + 256 * sizeof (short) / sizeof (int) + 16, + 3 + 256 * sizeof (short) / sizeof (int) + 32, + -1, + -1, + -1, + -1, + -1, + 3 + 256 * sizeof (short) / sizeof (int) + 48, + 3 + 256 * sizeof (short) / sizeof (int) + 64, + -1, + -1, + -1, + -1, + 3 + 256 * sizeof (short) / sizeof (int) + 80, + 3 + 256 * sizeof (short) / sizeof (int) + 96, + 3 + 256 * sizeof (short) / sizeof (int) + 112, + -1, + 3 + 256 * sizeof (short) / sizeof (int) + 128, + -1, + -1, + -1, + 3 + 256 * sizeof (short) / sizeof (int) + 144, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 3 + 256 * sizeof (short) / sizeof (int) + 160, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 3 + 256 * sizeof (short) / sizeof (int) + 176, + -1, + -1, + 3 + 256 * sizeof (short) / sizeof (int) + 192, + -1, + -1, + -1, + 3 + 256 * sizeof (short) / sizeof (int) + 208, + -1, + -1, + -1, + -1, + -1, + 3 + 256 * sizeof (short) / sizeof (int) + 224, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 3 + 256 * sizeof (short) / sizeof (int) + 240, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 3 + 256 * sizeof (short) / sizeof (int) + 256, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + }, + { + 0x00000000U, 0x00000000U, 0x07FFFFFEU, 0x00000000U, + 0x00000000U, 0x00000000U, 0x7F7FFFFFU, 0x00000000U, + 0x55555555U, 0xAA555555U, 0x555554AAU, 0x2B555555U, + 0xB1DBCED6U, 0x11AED2D5U, 0x4AAAADB0U, 0x55D65555U, + 0x55555555U, 0x6C055555U, 0x0000557AU, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x80450000U, + 0xFFFED740U, 0x00000FFBU, 0x55008000U, 0xE6905555U, + 0xFFFFFFFFU, 0x0000FFFFU, 0x00000000U, 0x55555555U, + 0x55555401U, 0x55555555U, 0x55552AABU, 0x55555555U, + 0x55555555U, 0xFFFE5555U, 0x007FFFFFU, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0xFFFFFFFFU, 0x000020BFU, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x003FFFFFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFF0000U, 0xE7FFFFFFU, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x55555555U, 0x55555555U, 0x55555555U, 0x55555555U, + 0x40155555U, 0x55555555U, 0x55555555U, 0x55555555U, + 0x3F00FF00U, 0xFF00FF00U, 0xAA003F00U, 0x0000FF00U, + 0xFF00FF00U, 0x1F00FF00U, 0x0F001F00U, 0x1F001F00U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00040C40U, 0x00000000U, 0x0000FFFFU, + 0x00000008U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0xFFC00000U, 0x0000FFFFU, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0x0000FFFFU, 0x00000000U, 0xC025EA9DU, + 0x55555555U, 0x55555555U, 0x55555555U, 0x00042805U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x55555555U, 0x00001555U, + 0x05555555U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x55545554U, 0x55555555U, 0x6A005555U, + 0x55452855U, 0x555F7D55U, 0x014102F5U, 0x00200000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x07FFFFFEU, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0x000000FFU, 0x00000000U, 0x00000000U, + 0x00000000U, 0xFFFF0000U, 0x000FFFFFU, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0xF7FF0000U, + 0x0037F7FFU, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0x0007FFFFU, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0xFFFFFFFFU, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0xFFFFFFFFU, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0x00000003U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U + } +}; diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_xdigit.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_xdigit.c new file mode 100644 index 00000000..1e5a1627 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_xdigit.c @@ -0,0 +1,32 @@ +/* ISO C like properties of Unicode characters. + Copyright (C) 2002, 2006-2007, 2009-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2002. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unictype.h" + +#include "bitmap.h" + +/* Define u_is_xdigit table. */ +#include "ctype_xdigit.h" + +bool +uc_is_xdigit (ucs4_t uc) +{ + return bitmap_lookup (&u_is_xdigit, uc); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_xdigit.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_xdigit.h new file mode 100644 index 00000000..1438f94f --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unictype/ctype_xdigit.h @@ -0,0 +1,172 @@ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +/* ISO C like properties of Unicode characters. */ +/* Generated automatically by gen-uni-tables.c for Unicode 15.0.0. */ + +/* Copyright (C) 2000-2023 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#define header_0 16 +#define header_2 9 +#define header_3 127 +#define header_4 15 +static const +struct + { + int header[1]; + int level1[1]; + short level2[1 << 7]; + unsigned int level3[1 << 4]; + } +u_is_xdigit = +{ + { 1 }, + { 2 * sizeof (int) / sizeof (short) + 0 }, + { + 2 + 128 * sizeof (short) / sizeof (int) + 0, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + }, + { + 0x00000000U, 0x03FF0000U, 0x0000007EU, 0x0000007EU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U + } +}; diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/uninorm.in.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/uninorm.in.h new file mode 100644 index 00000000..a7f6ec3a --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/uninorm.in.h @@ -0,0 +1,255 @@ +/* Normalization forms (composition and decomposition) of Unicode strings. + Copyright (C) 2001-2002, 2009-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2009. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef _UNINORM_H +#define _UNINORM_H + +/* Get size_t. */ +#include + +#include "unitypes.h" + +#if @HAVE_UNISTRING_WOE32DLL_H@ +# include +#else +# define LIBUNISTRING_DLL_VARIABLE +#endif + + +#ifdef __cplusplus +extern "C" { +#endif + + +/* Conventions: + + All functions prefixed with u8_ operate on UTF-8 encoded strings. + Their unit is an uint8_t (1 byte). + + All functions prefixed with u16_ operate on UTF-16 encoded strings. + Their unit is an uint16_t (a 2-byte word). + + All functions prefixed with u32_ operate on UCS-4 encoded strings. + Their unit is an uint32_t (a 4-byte word). + + All argument pairs (s, n) denote a Unicode string s[0..n-1] with exactly + n units. + + Functions returning a string result take a (resultbuf, lengthp) argument + pair. If resultbuf is not NULL and the result fits into *lengthp units, + it is put in resultbuf, and resultbuf is returned. Otherwise, a freshly + allocated string is returned. In both cases, *lengthp is set to the + length (number of units) of the returned string. In case of error, + NULL is returned and errno is set. */ + + +enum +{ + UC_DECOMP_CANONICAL,/* Canonical decomposition. */ + UC_DECOMP_FONT, /* A font variant (e.g. a blackletter form). */ + UC_DECOMP_NOBREAK, /* A no-break version of a space or hyphen. */ + UC_DECOMP_INITIAL, /* An initial presentation form (Arabic). */ + UC_DECOMP_MEDIAL, /* A medial presentation form (Arabic). */ + UC_DECOMP_FINAL, /* A final presentation form (Arabic). */ + UC_DECOMP_ISOLATED,/* An isolated presentation form (Arabic). */ + UC_DECOMP_CIRCLE, /* An encircled form. */ + UC_DECOMP_SUPER, /* A superscript form. */ + UC_DECOMP_SUB, /* A subscript form. */ + UC_DECOMP_VERTICAL,/* A vertical layout presentation form. */ + UC_DECOMP_WIDE, /* A wide (or zenkaku) compatibility character. */ + UC_DECOMP_NARROW, /* A narrow (or hankaku) compatibility character. */ + UC_DECOMP_SMALL, /* A small variant form (CNS compatibility). */ + UC_DECOMP_SQUARE, /* A CJK squared font variant. */ + UC_DECOMP_FRACTION,/* A vulgar fraction form. */ + UC_DECOMP_COMPAT /* Otherwise unspecified compatibility character. */ +}; + +/* Maximum size of decomposition of a single Unicode character. */ +#define UC_DECOMPOSITION_MAX_LENGTH 32 + +/* Return the character decomposition mapping of a Unicode character. + DECOMPOSITION must point to an array of at least UC_DECOMPOSITION_MAX_LENGTH + ucs_t elements. + When a decomposition exists, DECOMPOSITION[0..N-1] and *DECOMP_TAG are + filled and N is returned. Otherwise -1 is returned. */ +extern int + uc_decomposition (ucs4_t uc, int *decomp_tag, ucs4_t *decomposition); + +/* Return the canonical character decomposition mapping of a Unicode character. + DECOMPOSITION must point to an array of at least UC_DECOMPOSITION_MAX_LENGTH + ucs_t elements. + When a decomposition exists, DECOMPOSITION[0..N-1] is filled and N is + returned. Otherwise -1 is returned. */ +extern int + uc_canonical_decomposition (ucs4_t uc, ucs4_t *decomposition); + + +/* Attempt to combine the Unicode characters uc1, uc2. + uc1 is known to have canonical combining class 0. + Return the combination of uc1 and uc2, if it exists. + Return 0 otherwise. + Not all decompositions can be recombined using this function. See the + Unicode file CompositionExclusions.txt for details. */ +extern ucs4_t + uc_composition (ucs4_t uc1, ucs4_t uc2) + _UC_ATTRIBUTE_CONST; + + +/* An object of type uninorm_t denotes a Unicode normalization form. */ +struct unicode_normalization_form; +typedef const struct unicode_normalization_form *uninorm_t; + +/* UNINORM_NFD: Normalization form D: canonical decomposition. */ +extern @GNULIB_UNINORM_NFD_DLL_VARIABLE@ const struct unicode_normalization_form uninorm_nfd; +#define UNINORM_NFD (&uninorm_nfd) + +/* UNINORM_NFC: Normalization form C: canonical decomposition, then + canonical composition. */ +extern @GNULIB_UNINORM_NFC_DLL_VARIABLE@ const struct unicode_normalization_form uninorm_nfc; +#define UNINORM_NFC (&uninorm_nfc) + +/* UNINORM_NFKD: Normalization form KD: compatibility decomposition. */ +extern @GNULIB_UNINORM_NFKD_DLL_VARIABLE@ const struct unicode_normalization_form uninorm_nfkd; +#define UNINORM_NFKD (&uninorm_nfkd) + +/* UNINORM_NFKC: Normalization form KC: compatibility decomposition, then + canonical composition. */ +extern @GNULIB_UNINORM_NFKC_DLL_VARIABLE@ const struct unicode_normalization_form uninorm_nfkc; +#define UNINORM_NFKC (&uninorm_nfkc) + +/* Test whether a normalization form does compatibility decomposition. */ +#define uninorm_is_compat_decomposing(nf) \ + ((* (const unsigned int *) (nf) >> 0) & 1) + +/* Test whether a normalization form includes canonical composition. */ +#define uninorm_is_composing(nf) \ + ((* (const unsigned int *) (nf) >> 1) & 1) + +/* Return the decomposing variant of a normalization form. + This maps NFC,NFD -> NFD and NFKC,NFKD -> NFKD. */ +extern uninorm_t + uninorm_decomposing_form (uninorm_t nf) + _UC_ATTRIBUTE_PURE; + + +/* Return the specified normalization form of a string. */ +extern uint8_t * + u8_normalize (uninorm_t nf, const uint8_t *s, size_t n, + uint8_t *_UC_RESTRICT resultbuf, size_t *lengthp); +extern uint16_t * + u16_normalize (uninorm_t nf, const uint16_t *s, size_t n, + uint16_t *_UC_RESTRICT resultbuf, size_t *lengthp); +extern uint32_t * + u32_normalize (uninorm_t nf, const uint32_t *s, size_t n, + uint32_t *_UC_RESTRICT resultbuf, size_t *lengthp); + + +/* Compare S1 and S2, ignoring differences in normalization. + NF must be either UNINORM_NFD or UNINORM_NFKD. + If successful, set *RESULTP to -1 if S1 < S2, 0 if S1 = S2, 1 if S1 > S2, and + return 0. Upon failure, return -1 with errno set. */ +extern int + u8_normcmp (const uint8_t *s1, size_t n1, const uint8_t *s2, size_t n2, + uninorm_t nf, int *resultp); +extern int + u16_normcmp (const uint16_t *s1, size_t n1, const uint16_t *s2, size_t n2, + uninorm_t nf, int *resultp); +extern int + u32_normcmp (const uint32_t *s1, size_t n1, const uint32_t *s2, size_t n2, + uninorm_t nf, int *resultp); + + +/* Converts the string S of length N to a NUL-terminated byte sequence, in such + a way that comparing uN_normxfrm (S1) and uN_normxfrm (S2) with uN_cmp2() is + equivalent to comparing S1 and S2 with uN_normcoll(). + NF must be either UNINORM_NFC or UNINORM_NFKC. */ +extern char * + u8_normxfrm (const uint8_t *s, size_t n, uninorm_t nf, + char *resultbuf, size_t *lengthp); +extern char * + u16_normxfrm (const uint16_t *s, size_t n, uninorm_t nf, + char *resultbuf, size_t *lengthp); +extern char * + u32_normxfrm (const uint32_t *s, size_t n, uninorm_t nf, + char *resultbuf, size_t *lengthp); + + +/* Compare S1 and S2, ignoring differences in normalization, using the + collation rules of the current locale. + NF must be either UNINORM_NFC or UNINORM_NFKC. + If successful, set *RESULTP to -1 if S1 < S2, 0 if S1 = S2, 1 if S1 > S2, and + return 0. Upon failure, return -1 with errno set. */ +extern int + u8_normcoll (const uint8_t *s1, size_t n1, const uint8_t *s2, size_t n2, + uninorm_t nf, int *resultp); +extern int + u16_normcoll (const uint16_t *s1, size_t n1, const uint16_t *s2, size_t n2, + uninorm_t nf, int *resultp); +extern int + u32_normcoll (const uint32_t *s1, size_t n1, const uint32_t *s2, size_t n2, + uninorm_t nf, int *resultp); + + +/* Normalization of a stream of Unicode characters. + + A "stream of Unicode characters" is essentially a function that accepts an + ucs4_t argument repeatedly, optionally combined with a function that + "flushes" the stream. */ + +/* Data type of a stream of Unicode characters that normalizes its input + according to a given normalization form and passes the normalized character + sequence to the encapsulated stream of Unicode characters. */ +struct uninorm_filter; + +/* Bring data buffered in the filter to its destination, the encapsulated + stream, then close and free the filter. + Return 0 if successful, or -1 with errno set upon failure. */ +extern int + uninorm_filter_free (struct uninorm_filter *filter); + +/* Create and return a normalization filter for Unicode characters. + The pair (stream_func, stream_data) is the encapsulated stream. + stream_func (stream_data, uc) receives the Unicode character uc + and returns 0 if successful, or -1 with errno set upon failure. + Return the new filter, or NULL with errno set upon failure. */ +extern struct uninorm_filter * + uninorm_filter_create (uninorm_t nf, + int (*stream_func) (void *stream_data, ucs4_t uc), + void *stream_data) + _GL_ATTRIBUTE_DEALLOC (uninorm_filter_free, 1); + +/* Stuff a Unicode character into a normalizing filter. + Return 0 if successful, or -1 with errno set upon failure. */ +extern int + uninorm_filter_write (struct uninorm_filter *filter, ucs4_t uc); + +/* Bring data buffered in the filter to its destination, the encapsulated + stream. + Return 0 if successful, or -1 with errno set upon failure. + Note! If after calling this function, additional characters are written + into the filter, the resulting character sequence in the encapsulated stream + will not necessarily be normalized. */ +extern int + uninorm_filter_flush (struct uninorm_filter *filter); + + +#ifdef __cplusplus +} +#endif + + +#endif /* _UNINORM_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistd--.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistd--.h new file mode 100644 index 00000000..4c555d49 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistd--.h @@ -0,0 +1,32 @@ +/* Like unistd.h, but redefine some names to avoid glitches. + + Copyright (C) 2005, 2009-2024 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 . */ + +/* Written by Paul Eggert. */ + +#include +#include "unistd-safer.h" + +#undef dup +#define dup dup_safer + +#undef pipe +#define pipe pipe_safer + +#if GNULIB_PIPE2_SAFER +# undef pipe2 +# define pipe2 pipe2_safer +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistd-safer.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistd-safer.h new file mode 100644 index 00000000..c1179267 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistd-safer.h @@ -0,0 +1,31 @@ +/* Invoke unistd-like functions, but avoid some glitches. + + Copyright (C) 2001, 2003, 2005, 2009-2024 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 . */ + +/* Written by Paul Eggert and Eric Blake. */ + +int dup_safer (int); +int fd_safer (int); +int pipe_safer (int[2]); + +#if GNULIB_FD_SAFER_FLAG +int dup_safer_flag (int, int); +int fd_safer_flag (int, int); +#endif + +#if GNULIB_PIPE2_SAFER +int pipe2_safer (int[2], int); +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistd.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistd.c new file mode 100644 index 00000000..f3b3f7bd --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistd.c @@ -0,0 +1,22 @@ +/* Inline functions for . + + Copyright (C) 2012-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +#define _GL_UNISTD_INLINE _GL_EXTERN_INLINE +#include +typedef int dummy; diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistd.in.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistd.in.h new file mode 100644 index 00000000..b4129663 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistd.in.h @@ -0,0 +1,2419 @@ +/* Substitute for and wrapper around . + Copyright (C) 2003-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef _@GUARD_PREFIX@_UNISTD_H + +#if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +#endif +@PRAGMA_COLUMNS@ + +#if @HAVE_UNISTD_H@ && defined _GL_INCLUDING_UNISTD_H +/* Special invocation convention: + - On Mac OS X 10.3.9 we have a sequence of nested includes + -> -> -> + In this situation, the functions are not yet declared, therefore we cannot + provide the C++ aliases. */ + +#@INCLUDE_NEXT@ @NEXT_UNISTD_H@ + +#else +/* Normal invocation convention. */ + +/* The include_next requires a split double-inclusion guard. */ +#if @HAVE_UNISTD_H@ +# define _GL_INCLUDING_UNISTD_H +# @INCLUDE_NEXT@ @NEXT_UNISTD_H@ +# undef _GL_INCLUDING_UNISTD_H +#endif + +/* Avoid lseek bugs in FreeBSD, macOS . + This bug is fixed after FreeBSD 13; see . + Use macOS "9999" to stand for a future fixed macOS version. */ +#if defined __FreeBSD__ && __FreeBSD__ < 14 +# undef SEEK_DATA +# undef SEEK_HOLE +#elif defined __APPLE__ && defined __MACH__ && defined SEEK_DATA +# ifdef __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ +# include +# endif +# if (!defined MAC_OS_X_VERSION_MIN_REQUIRED \ + || MAC_OS_X_VERSION_MIN_REQUIRED < 99990000) +# include /* It also defines the two macros. */ +# undef SEEK_DATA +# undef SEEK_HOLE +# endif +#endif + +/* Get all possible declarations of gethostname(). */ +#if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ \ + && !defined _GL_INCLUDING_WINSOCK2_H +# define _GL_INCLUDING_WINSOCK2_H +# include +# undef _GL_INCLUDING_WINSOCK2_H +#endif + +#if !defined _@GUARD_PREFIX@_UNISTD_H && !defined _GL_INCLUDING_WINSOCK2_H +#define _@GUARD_PREFIX@_UNISTD_H + +/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, GNULIB_POSIXCHECK, + HAVE_RAW_DECL_*. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +/* NetBSD 5.0 mis-defines NULL. Also get size_t. */ +/* But avoid namespace pollution on glibc systems. */ +#ifndef __GLIBC__ +# include +#endif + +/* mingw doesn't define the SEEK_* or *_FILENO macros in . */ +/* MSVC declares 'unlink' in , not in . We must include + it before we #define unlink rpl_unlink. */ +/* Cygwin 1.7.1 declares symlinkat in , not in . */ +/* But avoid namespace pollution on glibc systems. */ +#if (!(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET) \ + || ((@GNULIB_UNLINK@ || defined GNULIB_POSIXCHECK) \ + && (defined _WIN32 && ! defined __CYGWIN__)) \ + || ((@GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK) \ + && defined __CYGWIN__)) \ + && ! defined __GLIBC__ +# include +#endif + +/* Cygwin 1.7.1 and Android 4.3 declare unlinkat in , not in + . */ +/* But avoid namespace pollution on glibc systems. */ +#if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) \ + && (defined __CYGWIN__ || defined __ANDROID__) \ + && ! defined __GLIBC__ +# include +#endif + +/* mingw fails to declare _exit in . */ +/* mingw, MSVC, BeOS, Haiku declare environ in , not in + . */ +/* Solaris declares getcwd not only in but also in . */ +/* OSF Tru64 Unix cannot see gnulib rpl_strtod when system is + included here. */ +/* But avoid namespace pollution on glibc systems. */ +#if !defined __GLIBC__ && !defined __osf__ +# define __need_system_stdlib_h +# include +# undef __need_system_stdlib_h +#endif + +/* Native Windows platforms declare _chdir, _getcwd, _rmdir in + and/or , not in . + They also declare _access(), _chmod(), _close(), _dup(), _dup2(), _isatty(), + _lseek(), _read(), _unlink(), _write() in . */ +#if defined _WIN32 && !defined __CYGWIN__ +# include +# include +#endif + +/* Native Windows platforms declare _execl*, _execv* in . */ +#if defined _WIN32 && !defined __CYGWIN__ +# include +#endif + +/* AIX and OSF/1 5.1 declare getdomainname in , not in . + NonStop Kernel declares gethostname in , not in . */ +/* But avoid namespace pollution on glibc systems. */ +#if ((@GNULIB_GETDOMAINNAME@ && (defined _AIX || defined __osf__)) \ + || (@GNULIB_GETHOSTNAME@ && defined __TANDEM)) \ + && !defined __GLIBC__ +# include +#endif + +/* Mac OS X 10.13, Solaris 11.4, and Android 9.0 declare getentropy in + , not in . */ +/* But avoid namespace pollution on glibc systems. */ +#if (@GNULIB_GETENTROPY@ || defined GNULIB_POSIXCHECK) \ + && ((defined __APPLE__ && defined __MACH__) || defined __sun \ + || defined __ANDROID__) \ + && @UNISTD_H_HAVE_SYS_RANDOM_H@ \ + && !defined __GLIBC__ +# include +#endif + +/* Android 4.3 declares fchownat in , not in . */ +/* But avoid namespace pollution on glibc systems. */ +#if (@GNULIB_FCHOWNAT@ || defined GNULIB_POSIXCHECK) && defined __ANDROID__ \ + && !defined __GLIBC__ +# include +#endif + +/* MSVC defines off_t in . + May also define off_t to a 64-bit type on native Windows. */ +/* Get off_t, ssize_t, mode_t. */ +#include + +/* 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. */ + + +/* Get getopt(), optarg, optind, opterr, optopt. */ +#if @GNULIB_GETOPT_POSIX@ && @GNULIB_UNISTD_H_GETOPT@ && !defined _GL_SYSTEM_GETOPT +# include +# include +#endif + +_GL_INLINE_HEADER_BEGIN +#ifndef _GL_UNISTD_INLINE +# define _GL_UNISTD_INLINE _GL_INLINE +#endif + +/* Hide some function declarations from . */ + +#if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ +# if !defined _@GUARD_PREFIX@_SYS_SOCKET_H +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef socket +# define socket socket_used_without_including_sys_socket_h +# undef connect +# define connect connect_used_without_including_sys_socket_h +# undef accept +# define accept accept_used_without_including_sys_socket_h +# undef bind +# define bind bind_used_without_including_sys_socket_h +# undef getpeername +# define getpeername getpeername_used_without_including_sys_socket_h +# undef getsockname +# define getsockname getsockname_used_without_including_sys_socket_h +# undef getsockopt +# define getsockopt getsockopt_used_without_including_sys_socket_h +# undef listen +# define listen listen_used_without_including_sys_socket_h +# undef recv +# define recv recv_used_without_including_sys_socket_h +# undef send +# define send send_used_without_including_sys_socket_h +# undef recvfrom +# define recvfrom recvfrom_used_without_including_sys_socket_h +# undef sendto +# define sendto sendto_used_without_including_sys_socket_h +# undef setsockopt +# define setsockopt setsockopt_used_without_including_sys_socket_h +# undef shutdown +# define shutdown shutdown_used_without_including_sys_socket_h +# else + _GL_WARN_ON_USE (socket, + "socket() used without including "); + _GL_WARN_ON_USE (connect, + "connect() used without including "); + _GL_WARN_ON_USE (accept, + "accept() used without including "); + _GL_WARN_ON_USE (bind, + "bind() used without including "); + _GL_WARN_ON_USE (getpeername, + "getpeername() used without including "); + _GL_WARN_ON_USE (getsockname, + "getsockname() used without including "); + _GL_WARN_ON_USE (getsockopt, + "getsockopt() used without including "); + _GL_WARN_ON_USE (listen, + "listen() used without including "); + _GL_WARN_ON_USE (recv, + "recv() used without including "); + _GL_WARN_ON_USE (send, + "send() used without including "); + _GL_WARN_ON_USE (recvfrom, + "recvfrom() used without including "); + _GL_WARN_ON_USE (sendto, + "sendto() used without including "); + _GL_WARN_ON_USE (setsockopt, + "setsockopt() used without including "); + _GL_WARN_ON_USE (shutdown, + "shutdown() used without including "); +# endif +# endif +# if !defined _@GUARD_PREFIX@_SYS_SELECT_H +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef select +# define select select_used_without_including_sys_select_h +# else + _GL_WARN_ON_USE (select, + "select() used without including "); +# endif +# endif +#endif + + +/* OS/2 EMX lacks these macros. */ +#ifndef STDIN_FILENO +# define STDIN_FILENO 0 +#endif +#ifndef STDOUT_FILENO +# define STDOUT_FILENO 1 +#endif +#ifndef STDERR_FILENO +# define STDERR_FILENO 2 +#endif + +/* Ensure *_OK macros exist. */ +#ifndef F_OK +# define F_OK 0 +# define X_OK 1 +# define W_OK 2 +# define R_OK 4 +#endif + + +/* Declare overridden functions. */ + + +#if @GNULIB_ACCESS@ +# if @REPLACE_ACCESS@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef access +# define access rpl_access +# endif +_GL_FUNCDECL_RPL (access, int, (const char *file, int mode) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (access, int, (const char *file, int mode)); +# elif defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef access +# define access _access +# endif +_GL_CXXALIAS_MDA (access, int, (const char *file, int mode)); +# else +_GL_CXXALIAS_SYS (access, int, (const char *file, int mode)); +# endif +_GL_CXXALIASWARN (access); +#elif defined GNULIB_POSIXCHECK +# undef access +# if HAVE_RAW_DECL_ACCESS +/* The access() function is a security risk. */ +_GL_WARN_ON_USE (access, "access does not always support X_OK - " + "use gnulib module access for portability; " + "also, this function is a security risk - " + "use the gnulib module faccessat instead"); +# endif +#elif @GNULIB_MDA_ACCESS@ +/* On native Windows, map 'access' to '_access', so that -loldnames is not + required. In C++ with GNULIB_NAMESPACE, avoid differences between + platforms by defining GNULIB_NAMESPACE::access always. */ +# if defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef access +# define access _access +# endif +_GL_CXXALIAS_MDA (access, int, (const char *file, int mode)); +# else +_GL_CXXALIAS_SYS (access, int, (const char *file, int mode)); +# endif +_GL_CXXALIASWARN (access); +#endif + + +#if @GNULIB_CHDIR@ +# if defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef chdir +# define chdir _chdir +# endif +_GL_CXXALIAS_MDA (chdir, int, (const char *file)); +# else +_GL_CXXALIAS_SYS (chdir, int, (const char *file) _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIASWARN (chdir); +#elif defined GNULIB_POSIXCHECK +# undef chdir +# if HAVE_RAW_DECL_CHDIR +_GL_WARN_ON_USE (chown, "chdir is not always in - " + "use gnulib module chdir for portability"); +# endif +#elif @GNULIB_MDA_CHDIR@ +/* On native Windows, map 'chdir' to '_chdir', so that -loldnames is not + required. In C++ with GNULIB_NAMESPACE, avoid differences between + platforms by defining GNULIB_NAMESPACE::chdir always. */ +# if defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef chdir +# define chdir _chdir +# endif +_GL_CXXALIAS_MDA (chdir, int, (const char *file)); +# else +_GL_CXXALIAS_SYS (chdir, int, (const char *file) _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIASWARN (chdir); +#endif + + +#if @GNULIB_CHOWN@ +/* Change the owner of FILE to UID (if UID is not -1) and the group of FILE + to GID (if GID is not -1). Follow symbolic links. + Return 0 if successful, otherwise -1 and errno set. + See the POSIX:2008 specification + . */ +# if @REPLACE_DUP2@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define dup2 rpl_dup2 +# endif +_GL_FUNCDECL_RPL (dup2, int, (int oldfd, int newfd)); +_GL_CXXALIAS_RPL (dup2, int, (int oldfd, int newfd)); +# elif defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef dup2 +# define dup2 _dup2 +# endif +_GL_CXXALIAS_MDA (dup2, int, (int oldfd, int newfd)); +# else +_GL_CXXALIAS_SYS (dup2, int, (int oldfd, int newfd)); +# endif +_GL_CXXALIASWARN (dup2); +#elif defined GNULIB_POSIXCHECK +# undef dup2 +# if HAVE_RAW_DECL_DUP2 +_GL_WARN_ON_USE (dup2, "dup2 is unportable - " + "use gnulib module dup2 for portability"); +# endif +#elif @GNULIB_MDA_DUP2@ +/* On native Windows, map 'dup2' to '_dup2', so that -loldnames is not + required. In C++ with GNULIB_NAMESPACE, avoid differences between + platforms by defining GNULIB_NAMESPACE::dup2 always. */ +# if defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef dup2 +# define dup2 _dup2 +# endif +_GL_CXXALIAS_MDA (dup2, int, (int oldfd, int newfd)); +# else +_GL_CXXALIAS_SYS (dup2, int, (int oldfd, int newfd)); +# endif +_GL_CXXALIASWARN (dup2); +#endif + + +#if @GNULIB_DUP3@ +/* Copy the file descriptor OLDFD into file descriptor NEWFD, with the + specified flags. + The flags are a bitmask, possibly including O_CLOEXEC (defined in ) + and O_TEXT, O_BINARY (defined in "binary-io.h"). + Close NEWFD first if it is open. + Return newfd if successful, otherwise -1 and errno set. + See the Linux man page at + . */ +# if @REPLACE_DUP3@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef dup3 +# define dup3 rpl_dup3 +# endif +_GL_FUNCDECL_RPL (dup3, int, (int oldfd, int newfd, int flags)); +_GL_CXXALIAS_RPL (dup3, int, (int oldfd, int newfd, int flags)); +# else +# if !@HAVE_DUP3@ +_GL_FUNCDECL_SYS (dup3, int, (int oldfd, int newfd, int flags)); +# endif +_GL_CXXALIAS_SYS (dup3, int, (int oldfd, int newfd, int flags)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (dup3); +# endif +#elif defined GNULIB_POSIXCHECK +# undef dup3 +# if HAVE_RAW_DECL_DUP3 +_GL_WARN_ON_USE (dup3, "dup3 is unportable - " + "use gnulib module dup3 for portability"); +# endif +#endif + + +#if @GNULIB_ENVIRON@ +# if defined __CYGWIN__ && !defined __i386__ +/* The 'environ' variable is defined in a DLL. Therefore its declaration needs + the '__declspec(dllimport)' attribute, but the system's lacks it. + This leads to a link error on 64-bit Cygwin when the option + -Wl,--disable-auto-import is in use. */ +_GL_EXTERN_C __declspec(dllimport) char **environ; +# endif +# if !@HAVE_DECL_ENVIRON@ +/* Set of environment variables and values. An array of strings of the form + "VARIABLE=VALUE", terminated with a NULL. */ +# if defined __APPLE__ && defined __MACH__ +# include +# if !TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR +# define _GL_USE_CRT_EXTERNS +# endif +# endif +# ifdef _GL_USE_CRT_EXTERNS +# include +# define environ (*_NSGetEnviron ()) +# else +# ifdef __cplusplus +extern "C" { +# endif +extern char **environ; +# ifdef __cplusplus +} +# endif +# endif +# endif +#elif defined GNULIB_POSIXCHECK +# if HAVE_RAW_DECL_ENVIRON +_GL_UNISTD_INLINE char *** +_GL_WARN_ON_USE_ATTRIBUTE ("environ is unportable - " + "use gnulib module environ for portability") +rpl_environ (void) +{ + return &environ; +} +# undef environ +# define environ (*rpl_environ ()) +# endif +#endif + + +#if @GNULIB_EUIDACCESS@ +/* Like access(), except that it uses the effective user id and group id of + the current process. */ +# if !@HAVE_EUIDACCESS@ +_GL_FUNCDECL_SYS (euidaccess, int, (const char *filename, int mode) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (euidaccess, int, (const char *filename, int mode)); +_GL_CXXALIASWARN (euidaccess); +# if defined GNULIB_POSIXCHECK +/* Like access(), this function is a security risk. */ +_GL_WARN_ON_USE (euidaccess, "the euidaccess function is a security risk - " + "use the gnulib module faccessat instead"); +# endif +#elif defined GNULIB_POSIXCHECK +# undef euidaccess +# if HAVE_RAW_DECL_EUIDACCESS +_GL_WARN_ON_USE (euidaccess, "euidaccess is unportable - " + "use gnulib module euidaccess for portability"); +# endif +#endif + + +#if @GNULIB_EXECL@ +# if @REPLACE_EXECL@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef execl +# define execl rpl_execl +# endif +_GL_FUNCDECL_RPL (execl, int, (const char *program, const char *arg, ...) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (execl, int, (const char *program, const char *arg, ...)); +# else +_GL_CXXALIAS_SYS (execl, int, (const char *program, const char *arg, ...)); +# endif +_GL_CXXALIASWARN (execl); +#elif defined GNULIB_POSIXCHECK +# undef execl +# if HAVE_RAW_DECL_EXECL +_GL_WARN_ON_USE (execl, "execl behaves very differently on mingw - " + "use gnulib module execl for portability"); +# endif +#elif @GNULIB_MDA_EXECL@ +/* On native Windows, map 'execl' to '_execl', so that -loldnames is not + required. In C++ with GNULIB_NAMESPACE, avoid differences between + platforms by defining GNULIB_NAMESPACE::execl always. */ +# if defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef execl +# define execl _execl +# endif +_GL_CXXALIAS_MDA (execl, intptr_t, (const char *program, const char *arg, ...)); +# else +_GL_CXXALIAS_SYS (execl, int, (const char *program, const char *arg, ...)); +# endif +_GL_CXXALIASWARN (execl); +#endif + +#if @GNULIB_EXECLE@ +# if @REPLACE_EXECLE@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef execle +# define execle rpl_execle +# endif +_GL_FUNCDECL_RPL (execle, int, (const char *program, const char *arg, ...) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (execle, int, (const char *program, const char *arg, ...)); +# else +_GL_CXXALIAS_SYS (execle, int, (const char *program, const char *arg, ...)); +# endif +_GL_CXXALIASWARN (execle); +#elif defined GNULIB_POSIXCHECK +# undef execle +# if HAVE_RAW_DECL_EXECLE +_GL_WARN_ON_USE (execle, "execle behaves very differently on mingw - " + "use gnulib module execle for portability"); +# endif +#elif @GNULIB_MDA_EXECLE@ +/* On native Windows, map 'execle' to '_execle', so that -loldnames is not + required. In C++ with GNULIB_NAMESPACE, avoid differences between + platforms by defining GNULIB_NAMESPACE::execle always. */ +# if defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef execle +# define execle _execle +# endif +_GL_CXXALIAS_MDA (execle, intptr_t, + (const char *program, const char *arg, ...)); +# else +_GL_CXXALIAS_SYS (execle, int, (const char *program, const char *arg, ...)); +# endif +_GL_CXXALIASWARN (execle); +#endif + +#if @GNULIB_EXECLP@ +# if @REPLACE_EXECLP@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef execlp +# define execlp rpl_execlp +# endif +_GL_FUNCDECL_RPL (execlp, int, (const char *program, const char *arg, ...) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (execlp, int, (const char *program, const char *arg, ...)); +# else +_GL_CXXALIAS_SYS (execlp, int, (const char *program, const char *arg, ...)); +# endif +_GL_CXXALIASWARN (execlp); +#elif defined GNULIB_POSIXCHECK +# undef execlp +# if HAVE_RAW_DECL_EXECLP +_GL_WARN_ON_USE (execlp, "execlp behaves very differently on mingw - " + "use gnulib module execlp for portability"); +# endif +#elif @GNULIB_MDA_EXECLP@ +/* On native Windows, map 'execlp' to '_execlp', so that -loldnames is not + required. In C++ with GNULIB_NAMESPACE, avoid differences between + platforms by defining GNULIB_NAMESPACE::execlp always. */ +# if defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef execlp +# define execlp _execlp +# endif +_GL_CXXALIAS_MDA (execlp, intptr_t, + (const char *program, const char *arg, ...)); +# else +_GL_CXXALIAS_SYS (execlp, int, (const char *program, const char *arg, ...)); +# endif +_GL_CXXALIASWARN (execlp); +#endif + + +#if @GNULIB_EXECV@ +# if @REPLACE_EXECV@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef execv +# define execv rpl_execv +# endif +_GL_FUNCDECL_RPL (execv, int, (const char *program, char * const *argv) + _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (execv, int, (const char *program, char * const *argv)); +# else +_GL_CXXALIAS_SYS (execv, int, (const char *program, char * const *argv)); +# endif +_GL_CXXALIASWARN (execv); +#elif defined GNULIB_POSIXCHECK +# undef execv +# if HAVE_RAW_DECL_EXECV +_GL_WARN_ON_USE (execv, "execv behaves very differently on mingw - " + "use gnulib module execv for portability"); +# endif +#elif @GNULIB_MDA_EXECV@ +/* On native Windows, map 'execv' to '_execv', so that -loldnames is not + required. In C++ with GNULIB_NAMESPACE, avoid differences between + platforms by defining GNULIB_NAMESPACE::execv always. */ +# if defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef execv +# define execv _execv +# endif +_GL_CXXALIAS_MDA_CAST (execv, intptr_t, + (const char *program, char * const *argv)); +# else +_GL_CXXALIAS_SYS (execv, int, (const char *program, char * const *argv)); +# endif +_GL_CXXALIASWARN (execv); +#endif + +#if @GNULIB_EXECVE@ +# if @REPLACE_EXECVE@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef execve +# define execve rpl_execve +# endif +_GL_FUNCDECL_RPL (execve, int, + (const char *program, char * const *argv, char * const *env) + _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (execve, int, + (const char *program, char * const *argv, char * const *env)); +# else +_GL_CXXALIAS_SYS (execve, int, + (const char *program, char * const *argv, char * const *env)); +# endif +_GL_CXXALIASWARN (execve); +#elif defined GNULIB_POSIXCHECK +# undef execve +# if HAVE_RAW_DECL_EXECVE +_GL_WARN_ON_USE (execve, "execve behaves very differently on mingw - " + "use gnulib module execve for portability"); +# endif +#elif @GNULIB_MDA_EXECVE@ +/* On native Windows, map 'execve' to '_execve', so that -loldnames is not + required. In C++ with GNULIB_NAMESPACE, avoid differences between + platforms by defining GNULIB_NAMESPACE::execve always. */ +# if defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef execve +# define execve _execve +# endif +_GL_CXXALIAS_MDA_CAST (execve, intptr_t, + (const char *program, char * const *argv, + char * const *env)); +# else +_GL_CXXALIAS_SYS (execve, int, + (const char *program, char * const *argv, char * const *env)); +# endif +_GL_CXXALIASWARN (execve); +#endif + +#if @GNULIB_EXECVP@ +# if @REPLACE_EXECVP@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef execvp +# define execvp rpl_execvp +# endif +_GL_FUNCDECL_RPL (execvp, int, (const char *program, char * const *argv) + _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (execvp, int, (const char *program, char * const *argv)); +# else +_GL_CXXALIAS_SYS (execvp, int, (const char *program, char * const *argv)); +# endif +_GL_CXXALIASWARN (execvp); +#elif defined GNULIB_POSIXCHECK +# undef execvp +# if HAVE_RAW_DECL_EXECVP +_GL_WARN_ON_USE (execvp, "execvp behaves very differently on mingw - " + "use gnulib module execvp for portability"); +# endif +#elif @GNULIB_MDA_EXECVP@ +/* On native Windows, map 'execvp' to '_execvp', so that -loldnames is not + required. In C++ with GNULIB_NAMESPACE, avoid differences between + platforms by defining GNULIB_NAMESPACE::execvp always. */ +# if defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef execvp +# define execvp _execvp +# endif +_GL_CXXALIAS_MDA_CAST (execvp, intptr_t, + (const char *program, char * const *argv)); +# else +_GL_CXXALIAS_SYS (execvp, int, (const char *program, char * const *argv)); +# endif +_GL_CXXALIASWARN (execvp); +#endif + +#if @GNULIB_EXECVPE@ +# if @REPLACE_EXECVPE@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef execvpe +# define execvpe rpl_execvpe +# endif +_GL_FUNCDECL_RPL (execvpe, int, + (const char *program, char * const *argv, char * const *env) + _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (execvpe, int, + (const char *program, char * const *argv, char * const *env)); +# else +# if !@HAVE_DECL_EXECVPE@ +_GL_FUNCDECL_SYS (execvpe, int, + (const char *program, char * const *argv, char * const *env) + _GL_ARG_NONNULL ((1, 2))); +# endif +_GL_CXXALIAS_SYS (execvpe, int, + (const char *program, char * const *argv, char * const *env)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (execvpe); +# endif +#elif defined GNULIB_POSIXCHECK +# undef execvpe +# if HAVE_RAW_DECL_EXECVPE +_GL_WARN_ON_USE (execvpe, "execvpe behaves very differently on mingw - " + "use gnulib module execvpe for portability"); +# endif +#elif @GNULIB_MDA_EXECVPE@ +/* On native Windows, map 'execvpe' to '_execvpe', so that -loldnames is not + required. In C++ with GNULIB_NAMESPACE, avoid differences between + platforms by defining GNULIB_NAMESPACE::execvpe on all platforms that have + it. */ +# if defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef execvpe +# define execvpe _execvpe +# endif +_GL_CXXALIAS_MDA_CAST (execvpe, intptr_t, + (const char *program, char * const *argv, + char * const *env)); +# elif @HAVE_EXECVPE@ +# if !@HAVE_DECL_EXECVPE@ +_GL_FUNCDECL_SYS (execvpe, int, + (const char *program, char * const *argv, char * const *env) + _GL_ARG_NONNULL ((1, 2))); +# endif +_GL_CXXALIAS_SYS (execvpe, int, + (const char *program, char * const *argv, char * const *env)); +# endif +# if (defined _WIN32 && !defined __CYGWIN__) || @HAVE_EXECVPE@ +_GL_CXXALIASWARN (execvpe); +# endif +#endif + + +#if @GNULIB_FACCESSAT@ +# if @REPLACE_FACCESSAT@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef faccessat +# define faccessat rpl_faccessat +# endif +_GL_FUNCDECL_RPL (faccessat, int, + (int fd, char const *name, int mode, int flag) + _GL_ARG_NONNULL ((2))); +_GL_CXXALIAS_RPL (faccessat, int, + (int fd, char const *name, int mode, int flag)); +# else +# if !@HAVE_FACCESSAT@ +_GL_FUNCDECL_SYS (faccessat, int, + (int fd, char const *file, int mode, int flag) + _GL_ARG_NONNULL ((2))); +# endif +_GL_CXXALIAS_SYS (faccessat, int, + (int fd, char const *file, int mode, int flag)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (faccessat); +# endif +#elif defined GNULIB_POSIXCHECK +# undef faccessat +# if HAVE_RAW_DECL_FACCESSAT +_GL_WARN_ON_USE (faccessat, "faccessat is not portable - " + "use gnulib module faccessat for portability"); +# endif +#endif + + +#if @GNULIB_FCHDIR@ +/* Change the process' current working directory to the directory on which + the given file descriptor is open. + Return 0 if successful, otherwise -1 and errno set. + See the POSIX:2008 specification + . */ +# if @REPLACE_FCHDIR@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef fchdir +# define fchdir rpl_fchdir +# endif +_GL_FUNCDECL_RPL (fchdir, int, (int /*fd*/)); +_GL_CXXALIAS_RPL (fchdir, int, (int /*fd*/)); +# else +# if !@HAVE_FCHDIR@ || !@HAVE_DECL_FCHDIR@ +_GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/)); +# endif +_GL_CXXALIAS_SYS (fchdir, int, (int /*fd*/)); +# endif +_GL_CXXALIASWARN (fchdir); +# if @REPLACE_FCHDIR@ || !@HAVE_FCHDIR@ +/* Gnulib internal hooks needed to maintain the fchdir metadata. */ +_GL_EXTERN_C int _gl_register_fd (int fd, const char *filename) + _GL_ARG_NONNULL ((2)); +_GL_EXTERN_C void _gl_unregister_fd (int fd); +_GL_EXTERN_C int _gl_register_dup (int oldfd, int newfd); +_GL_EXTERN_C const char *_gl_directory_name (int fd); +# endif +#elif defined GNULIB_POSIXCHECK +# undef fchdir +# if HAVE_RAW_DECL_FCHDIR +_GL_WARN_ON_USE (fchdir, "fchdir is unportable - " + "use gnulib module fchdir for portability"); +# endif +#endif + + +#if @GNULIB_FCHOWNAT@ +# if @REPLACE_FCHOWNAT@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef fchownat +# define fchownat rpl_fchownat +# endif +_GL_FUNCDECL_RPL (fchownat, int, (int fd, char const *file, + uid_t owner, gid_t group, int flag) + _GL_ARG_NONNULL ((2))); +_GL_CXXALIAS_RPL (fchownat, int, (int fd, char const *file, + uid_t owner, gid_t group, int flag)); +# else +# if !@HAVE_FCHOWNAT@ +_GL_FUNCDECL_SYS (fchownat, int, (int fd, char const *file, + uid_t owner, gid_t group, int flag) + _GL_ARG_NONNULL ((2))); +# endif +_GL_CXXALIAS_SYS (fchownat, int, (int fd, char const *file, + uid_t owner, gid_t group, int flag)); +# endif +_GL_CXXALIASWARN (fchownat); +#elif defined GNULIB_POSIXCHECK +# undef fchownat +# if HAVE_RAW_DECL_FCHOWNAT +_GL_WARN_ON_USE (fchownat, "fchownat is not portable - " + "use gnulib module fchownat for portability"); +# endif +#endif + + +#if @GNULIB_FDATASYNC@ +/* Synchronize changes to a file. + Return 0 if successful, otherwise -1 and errno set. + See POSIX:2008 specification + . */ +# if @REPLACE_FDATASYNC@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef fdatasync +# define fdatasync rpl_fdatasync +# endif +_GL_FUNCDECL_RPL (fdatasync, int, (int fd)); +_GL_CXXALIAS_RPL (fdatasync, int, (int fd)); +# else +# if !@HAVE_FDATASYNC@|| !@HAVE_DECL_FDATASYNC@ +_GL_FUNCDECL_SYS (fdatasync, int, (int fd)); +# endif +_GL_CXXALIAS_SYS (fdatasync, int, (int fd)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (fdatasync); +# endif +#elif defined GNULIB_POSIXCHECK +# undef fdatasync +# if HAVE_RAW_DECL_FDATASYNC +_GL_WARN_ON_USE (fdatasync, "fdatasync is unportable - " + "use gnulib module fdatasync for portability"); +# endif +#endif + + +#if @GNULIB_FSYNC@ +/* Synchronize changes, including metadata, to a file. + Return 0 if successful, otherwise -1 and errno set. + See POSIX:2008 specification + . */ +# if !@HAVE_FSYNC@ +_GL_FUNCDECL_SYS (fsync, int, (int fd)); +# endif +_GL_CXXALIAS_SYS (fsync, int, (int fd)); +_GL_CXXALIASWARN (fsync); +#elif defined GNULIB_POSIXCHECK +# undef fsync +# if HAVE_RAW_DECL_FSYNC +_GL_WARN_ON_USE (fsync, "fsync is unportable - " + "use gnulib module fsync for portability"); +# endif +#endif + + +#if @GNULIB_FTRUNCATE@ +/* Change the size of the file to which FD is opened to become equal to LENGTH. + Return 0 if successful, otherwise -1 and errno set. + See the POSIX:2008 specification + . */ +# if @REPLACE_FTRUNCATE@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef ftruncate +# define ftruncate rpl_ftruncate +# endif +_GL_FUNCDECL_RPL (ftruncate, int, (int fd, off_t length)); +_GL_CXXALIAS_RPL (ftruncate, int, (int fd, off_t length)); +# else +# if !@HAVE_FTRUNCATE@ +_GL_FUNCDECL_SYS (ftruncate, int, (int fd, off_t length)); +# endif +_GL_CXXALIAS_SYS (ftruncate, int, (int fd, off_t length)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (ftruncate); +# endif +#elif defined GNULIB_POSIXCHECK +# undef ftruncate +# if HAVE_RAW_DECL_FTRUNCATE +_GL_WARN_ON_USE (ftruncate, "ftruncate is unportable - " + "use gnulib module ftruncate for portability"); +# endif +#endif + + +#if @GNULIB_GETCWD@ +/* Get the name of the current working directory, and put it in SIZE bytes + of BUF. + Return BUF if successful, or NULL if the directory couldn't be determined + or SIZE was too small. + See the POSIX:2008 specification + . + Additionally, the gnulib module 'getcwd' or 'getcwd-lgpl' guarantees the + following GNU extension: If BUF is NULL, an array is allocated with + 'malloc'; the array is SIZE bytes long, unless SIZE == 0, in which case + it is as big as necessary. */ +# if @REPLACE_GETCWD@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define getcwd rpl_getcwd +# endif +_GL_FUNCDECL_RPL (getcwd, char *, (char *buf, size_t size)); +_GL_CXXALIAS_RPL (getcwd, char *, (char *buf, size_t size)); +# elif defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef getcwd +# define getcwd _getcwd +# endif +_GL_CXXALIAS_MDA (getcwd, char *, (char *buf, size_t size)); +# else +/* Need to cast, because on mingw, the second parameter is + int size. */ +_GL_CXXALIAS_SYS_CAST (getcwd, char *, (char *buf, size_t size)); +# endif +_GL_CXXALIASWARN (getcwd); +#elif defined GNULIB_POSIXCHECK +# undef getcwd +# if HAVE_RAW_DECL_GETCWD +_GL_WARN_ON_USE (getcwd, "getcwd is unportable - " + "use gnulib module getcwd for portability"); +# endif +#elif @GNULIB_MDA_GETCWD@ +/* On native Windows, map 'getcwd' to '_getcwd', so that -loldnames is not + required. In C++ with GNULIB_NAMESPACE, avoid differences between + platforms by defining GNULIB_NAMESPACE::getcwd always. */ +# if defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef getcwd +# define getcwd _getcwd +# endif +/* Need to cast, because on mingw, the second parameter is either + 'int size' or 'size_t size'. */ +_GL_CXXALIAS_MDA_CAST (getcwd, char *, (char *buf, size_t size)); +# else +_GL_CXXALIAS_SYS_CAST (getcwd, char *, (char *buf, size_t size)); +# endif +_GL_CXXALIASWARN (getcwd); +#endif + + +#if @GNULIB_GETDOMAINNAME@ +/* Return the NIS domain name of the machine. + WARNING! The NIS domain name is unrelated to the fully qualified host name + of the machine. It is also unrelated to email addresses. + WARNING! The NIS domain name is usually the empty string or "(none)" when + not using NIS. + + Put up to LEN bytes of the NIS domain name into NAME. + Null terminate it if the name is shorter than LEN. + If the NIS domain name is longer than LEN, set errno = EINVAL and return -1. + Return 0 if successful, otherwise set errno and return -1. */ +# if @REPLACE_GETDOMAINNAME@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef getdomainname +# define getdomainname rpl_getdomainname +# endif +_GL_FUNCDECL_RPL (getdomainname, int, (char *name, size_t len) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (getdomainname, int, (char *name, size_t len)); +# else +# if !@HAVE_DECL_GETDOMAINNAME@ +_GL_FUNCDECL_SYS (getdomainname, int, (char *name, size_t len) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (getdomainname, int, (char *name, size_t len)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (getdomainname); +# endif +#elif defined GNULIB_POSIXCHECK +# undef getdomainname +# if HAVE_RAW_DECL_GETDOMAINNAME +_GL_WARN_ON_USE (getdomainname, "getdomainname is unportable - " + "use gnulib module getdomainname for portability"); +# endif +#endif + + +#if @GNULIB_GETDTABLESIZE@ +/* Return the maximum number of file descriptors in the current process. + In POSIX, this is same as sysconf (_SC_OPEN_MAX). */ +# if @REPLACE_GETDTABLESIZE@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef getdtablesize +# define getdtablesize rpl_getdtablesize +# endif +_GL_FUNCDECL_RPL (getdtablesize, int, (void)); +_GL_CXXALIAS_RPL (getdtablesize, int, (void)); +# else +# if !@HAVE_GETDTABLESIZE@ +_GL_FUNCDECL_SYS (getdtablesize, int, (void)); +# endif +/* Need to cast, because on AIX, the parameter list is + (...). */ +_GL_CXXALIAS_SYS_CAST (getdtablesize, int, (void)); +# endif +_GL_CXXALIASWARN (getdtablesize); +#elif defined GNULIB_POSIXCHECK +# undef getdtablesize +# if HAVE_RAW_DECL_GETDTABLESIZE +_GL_WARN_ON_USE (getdtablesize, "getdtablesize is unportable - " + "use gnulib module getdtablesize for portability"); +# endif +#endif + + +#if @GNULIB_GETENTROPY@ +/* Fill a buffer with random bytes. */ +# if @REPLACE_GETENTROPY@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef getentropy +# define getentropy rpl_getentropy +# endif +_GL_FUNCDECL_RPL (getentropy, int, (void *buffer, size_t length)); +_GL_CXXALIAS_RPL (getentropy, int, (void *buffer, size_t length)); +# else +# if !@HAVE_GETENTROPY@ +_GL_FUNCDECL_SYS (getentropy, int, (void *buffer, size_t length)); +# endif +_GL_CXXALIAS_SYS (getentropy, int, (void *buffer, size_t length)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (getentropy); +# endif +#elif defined GNULIB_POSIXCHECK +# undef getentropy +# if HAVE_RAW_DECL_GETENTROPY +_GL_WARN_ON_USE (getentropy, "getentropy is unportable - " + "use gnulib module getentropy for portability"); +# endif +#endif + + +#if @GNULIB_GETGROUPS@ +/* Return the supplemental groups that the current process belongs to. + It is unspecified whether the effective group id is in the list. + If N is 0, return the group count; otherwise, N describes how many + entries are available in GROUPS. Return -1 and set errno if N is + not 0 and not large enough. Fails with ENOSYS on some systems. */ +# if @REPLACE_GETGROUPS@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef getgroups +# define getgroups rpl_getgroups +# endif +_GL_FUNCDECL_RPL (getgroups, int, (int n, gid_t *groups)); +_GL_CXXALIAS_RPL (getgroups, int, (int n, gid_t *groups)); +# else +# if !@HAVE_GETGROUPS@ +_GL_FUNCDECL_SYS (getgroups, int, (int n, gid_t *groups)); +# endif +_GL_CXXALIAS_SYS (getgroups, int, (int n, gid_t *groups)); +# endif +_GL_CXXALIASWARN (getgroups); +#elif defined GNULIB_POSIXCHECK +# undef getgroups +# if HAVE_RAW_DECL_GETGROUPS +_GL_WARN_ON_USE (getgroups, "getgroups is unportable - " + "use gnulib module getgroups for portability"); +# endif +#endif + + +#if @GNULIB_GETHOSTNAME@ +/* Return the standard host name of the machine. + WARNING! The host name may or may not be fully qualified. + + Put up to LEN bytes of the host name into NAME. + Null terminate it if the name is shorter than LEN. + If the host name is longer than LEN, set errno = EINVAL and return -1. + Return 0 if successful, otherwise set errno and return -1. */ +# if @UNISTD_H_HAVE_WINSOCK2_H@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef gethostname +# define gethostname rpl_gethostname +# endif +_GL_FUNCDECL_RPL (gethostname, int, (char *name, size_t len) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (gethostname, int, (char *name, size_t len)); +# else +# if !@HAVE_GETHOSTNAME@ +_GL_FUNCDECL_SYS (gethostname, int, (char *name, size_t len) + _GL_ARG_NONNULL ((1))); +# endif +/* Need to cast, because on Solaris 10 and OSF/1 5.1 systems, the second + parameter is + int len. */ +_GL_CXXALIAS_SYS_CAST (gethostname, int, (char *name, size_t len)); +# endif +_GL_CXXALIASWARN (gethostname); +#elif @UNISTD_H_HAVE_WINSOCK2_H@ +# undef gethostname +# define gethostname gethostname_used_without_requesting_gnulib_module_gethostname +#elif defined GNULIB_POSIXCHECK +# undef gethostname +# if HAVE_RAW_DECL_GETHOSTNAME +_GL_WARN_ON_USE (gethostname, "gethostname is unportable - " + "use gnulib module gethostname for portability"); +# endif +#endif + + +#if @GNULIB_GETLOGIN@ +/* Returns the user's login name, or NULL if it cannot be found. Upon error, + returns NULL with errno set. + + See . + + Most programs don't need to use this function, because the information is + available through environment variables: + ${LOGNAME-$USER} on Unix platforms, + $USERNAME on native Windows platforms. + */ +# if !@HAVE_DECL_GETLOGIN@ +_GL_FUNCDECL_SYS (getlogin, char *, (void)); +# endif +_GL_CXXALIAS_SYS (getlogin, char *, (void)); +_GL_CXXALIASWARN (getlogin); +#elif defined GNULIB_POSIXCHECK +# undef getlogin +# if HAVE_RAW_DECL_GETLOGIN +_GL_WARN_ON_USE (getlogin, "getlogin is unportable - " + "use gnulib module getlogin for portability"); +# endif +#endif + + +#if @GNULIB_GETLOGIN_R@ +/* Copies the user's login name to NAME. + The array pointed to by NAME has room for SIZE bytes. + + Returns 0 if successful. Upon error, an error number is returned, or -1 in + the case that the login name cannot be found but no specific error is + provided (this case is hopefully rare but is left open by the POSIX spec). + + See . + + Most programs don't need to use this function, because the information is + available through environment variables: + ${LOGNAME-$USER} on Unix platforms, + $USERNAME on native Windows platforms. + */ +# if @REPLACE_GETLOGIN_R@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define getlogin_r rpl_getlogin_r +# endif +_GL_FUNCDECL_RPL (getlogin_r, int, (char *name, size_t size) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (getlogin_r, int, (char *name, size_t size)); +# else +# if !@HAVE_DECL_GETLOGIN_R@ +_GL_FUNCDECL_SYS (getlogin_r, int, (char *name, size_t size) + _GL_ARG_NONNULL ((1))); +# endif +/* Need to cast, because on Solaris 10 systems, the second argument is + int size. */ +_GL_CXXALIAS_SYS_CAST (getlogin_r, int, (char *name, size_t size)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (getlogin_r); +# endif +#elif defined GNULIB_POSIXCHECK +# undef getlogin_r +# if HAVE_RAW_DECL_GETLOGIN_R +_GL_WARN_ON_USE (getlogin_r, "getlogin_r is unportable - " + "use gnulib module getlogin_r for portability"); +# endif +#endif + + +#if @GNULIB_GETPAGESIZE@ +# if @REPLACE_GETPAGESIZE@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define getpagesize rpl_getpagesize +# endif +_GL_FUNCDECL_RPL (getpagesize, int, (void)); +_GL_CXXALIAS_RPL (getpagesize, int, (void)); +# else +/* On HP-UX, getpagesize exists, but it is not declared in even if + the compiler options -D_HPUX_SOURCE -D_XOPEN_SOURCE=600 are used. */ +# if defined __hpux +_GL_FUNCDECL_SYS (getpagesize, int, (void)); +# endif +# if !@HAVE_GETPAGESIZE@ +# if !defined getpagesize +/* This is for POSIX systems. */ +# if !defined _gl_getpagesize && defined _SC_PAGESIZE +# if ! (defined __VMS && __VMS_VER < 70000000) +# define _gl_getpagesize() sysconf (_SC_PAGESIZE) +# endif +# endif +/* This is for older VMS. */ +# if !defined _gl_getpagesize && defined __VMS +# ifdef __ALPHA +# define _gl_getpagesize() 8192 +# else +# define _gl_getpagesize() 512 +# endif +# endif +/* This is for BeOS. */ +# if !defined _gl_getpagesize && @HAVE_OS_H@ +# include +# if defined B_PAGE_SIZE +# define _gl_getpagesize() B_PAGE_SIZE +# endif +# endif +/* This is for AmigaOS4.0. */ +# if !defined _gl_getpagesize && defined __amigaos4__ +# define _gl_getpagesize() 2048 +# endif +/* This is for older Unix systems. */ +# if !defined _gl_getpagesize && @HAVE_SYS_PARAM_H@ +# include +# ifdef EXEC_PAGESIZE +# define _gl_getpagesize() EXEC_PAGESIZE +# else +# ifdef NBPG +# ifndef CLSIZE +# define CLSIZE 1 +# endif +# define _gl_getpagesize() (NBPG * CLSIZE) +# else +# ifdef NBPC +# define _gl_getpagesize() NBPC +# endif +# endif +# endif +# endif +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define getpagesize() _gl_getpagesize () +# else +# if !GNULIB_defined_getpagesize_function +_GL_UNISTD_INLINE int +getpagesize () +{ + return _gl_getpagesize (); +} +# define GNULIB_defined_getpagesize_function 1 +# endif +# endif +# endif +# endif +/* Need to cast, because on Cygwin 1.5.x systems, the return type is size_t. */ +_GL_CXXALIAS_SYS_CAST (getpagesize, int, (void)); +# endif +# if @HAVE_DECL_GETPAGESIZE@ +_GL_CXXALIASWARN (getpagesize); +# endif +#elif defined GNULIB_POSIXCHECK +# undef getpagesize +# if HAVE_RAW_DECL_GETPAGESIZE +_GL_WARN_ON_USE (getpagesize, "getpagesize is unportable - " + "use gnulib module getpagesize for portability"); +# endif +#endif + + +#if @GNULIB_GETPASS@ +/* Function getpass() from module 'getpass': + Read a password from /dev/tty or stdin. + Function getpass() from module 'getpass-gnu': + Read a password of arbitrary length from /dev/tty or stdin. */ +# if (@GNULIB_GETPASS@ && @REPLACE_GETPASS@) \ + || (@GNULIB_GETPASS_GNU@ && @REPLACE_GETPASS_FOR_GETPASS_GNU@) +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef getpass +# define getpass rpl_getpass +# endif +_GL_FUNCDECL_RPL (getpass, char *, (const char *prompt) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (getpass, char *, (const char *prompt)); +# else +# if !@HAVE_GETPASS@ +_GL_FUNCDECL_SYS (getpass, char *, (const char *prompt) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (getpass, char *, (const char *prompt)); +# endif +_GL_CXXALIASWARN (getpass); +#elif defined GNULIB_POSIXCHECK +# undef getpass +# if HAVE_RAW_DECL_GETPASS +_GL_WARN_ON_USE (getpass, "getpass is unportable - " + "use gnulib module getpass or getpass-gnu for portability"); +# endif +#endif + + +#if @GNULIB_MDA_GETPID@ +/* On native Windows, map 'getpid' to '_getpid', so that -loldnames is not + required. In C++ with GNULIB_NAMESPACE, avoid differences between + platforms by defining GNULIB_NAMESPACE::getpid always. */ +# if defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef getpid +# define getpid _getpid +# endif +_GL_CXXALIAS_MDA (getpid, int, (void)); +# else +_GL_CXXALIAS_SYS (getpid, pid_t, (void)); +# endif +_GL_CXXALIASWARN (getpid); +#endif + + +#if @GNULIB_GETUSERSHELL@ +/* Return the next valid login shell on the system, or NULL when the end of + the list has been reached. */ +# if !@HAVE_DECL_GETUSERSHELL@ +_GL_FUNCDECL_SYS (getusershell, char *, (void)); +# endif +_GL_CXXALIAS_SYS (getusershell, char *, (void)); +_GL_CXXALIASWARN (getusershell); +#elif defined GNULIB_POSIXCHECK +# undef getusershell +# if HAVE_RAW_DECL_GETUSERSHELL +_GL_WARN_ON_USE (getusershell, "getusershell is unportable - " + "use gnulib module getusershell for portability"); +# endif +#endif + +#if @GNULIB_GETUSERSHELL@ +/* Rewind to pointer that is advanced at each getusershell() call. */ +# if !@HAVE_DECL_GETUSERSHELL@ +_GL_FUNCDECL_SYS (setusershell, void, (void)); +# endif +_GL_CXXALIAS_SYS (setusershell, void, (void)); +_GL_CXXALIASWARN (setusershell); +#elif defined GNULIB_POSIXCHECK +# undef setusershell +# if HAVE_RAW_DECL_SETUSERSHELL +_GL_WARN_ON_USE (setusershell, "setusershell is unportable - " + "use gnulib module getusershell for portability"); +# endif +#endif + +#if @GNULIB_GETUSERSHELL@ +/* Free the pointer that is advanced at each getusershell() call and + associated resources. */ +# if !@HAVE_DECL_GETUSERSHELL@ +_GL_FUNCDECL_SYS (endusershell, void, (void)); +# endif +_GL_CXXALIAS_SYS (endusershell, void, (void)); +_GL_CXXALIASWARN (endusershell); +#elif defined GNULIB_POSIXCHECK +# undef endusershell +# if HAVE_RAW_DECL_ENDUSERSHELL +_GL_WARN_ON_USE (endusershell, "endusershell is unportable - " + "use gnulib module getusershell for portability"); +# endif +#endif + + +#if @GNULIB_GROUP_MEMBER@ +/* Determine whether group id is in calling user's group list. */ +# if !@HAVE_GROUP_MEMBER@ +_GL_FUNCDECL_SYS (group_member, int, (gid_t gid)); +# endif +_GL_CXXALIAS_SYS (group_member, int, (gid_t gid)); +_GL_CXXALIASWARN (group_member); +#elif defined GNULIB_POSIXCHECK +# undef group_member +# if HAVE_RAW_DECL_GROUP_MEMBER +_GL_WARN_ON_USE (group_member, "group_member is unportable - " + "use gnulib module group-member for portability"); +# endif +#endif + + +#if @GNULIB_ISATTY@ +# if @REPLACE_ISATTY@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef isatty +# define isatty rpl_isatty +# endif +# define GNULIB_defined_isatty 1 +_GL_FUNCDECL_RPL (isatty, int, (int fd)); +_GL_CXXALIAS_RPL (isatty, int, (int fd)); +# elif defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef isatty +# define isatty _isatty +# endif +_GL_CXXALIAS_MDA (isatty, int, (int fd)); +# else +_GL_CXXALIAS_SYS (isatty, int, (int fd)); +# endif +_GL_CXXALIASWARN (isatty); +#elif defined GNULIB_POSIXCHECK +# undef isatty +# if HAVE_RAW_DECL_ISATTY +_GL_WARN_ON_USE (isatty, "isatty has portability problems on native Windows - " + "use gnulib module isatty for portability"); +# endif +#elif @GNULIB_MDA_ISATTY@ +/* On native Windows, map 'isatty' to '_isatty', so that -loldnames is not + required. In C++ with GNULIB_NAMESPACE, avoid differences between + platforms by defining GNULIB_NAMESPACE::isatty always. */ +# if defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef isatty +# define isatty _isatty +# endif +_GL_CXXALIAS_MDA (isatty, int, (int fd)); +# else +_GL_CXXALIAS_SYS (isatty, int, (int fd)); +# endif +_GL_CXXALIASWARN (isatty); +#endif + + +#if @GNULIB_LCHOWN@ +/* Change the owner of FILE to UID (if UID is not -1) and the group of FILE + to GID (if GID is not -1). Do not follow symbolic links. + Return 0 if successful, otherwise -1 and errno set. + See the POSIX:2008 specification + . */ +# if @REPLACE_LCHOWN@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef lchown +# define lchown rpl_lchown +# endif +_GL_FUNCDECL_RPL (lchown, int, (char const *file, uid_t owner, gid_t group) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (lchown, int, (char const *file, uid_t owner, gid_t group)); +# else +# if !@HAVE_LCHOWN@ +_GL_FUNCDECL_SYS (lchown, int, (char const *file, uid_t owner, gid_t group) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (lchown, int, (char const *file, uid_t owner, gid_t group)); +# endif +_GL_CXXALIASWARN (lchown); +#elif defined GNULIB_POSIXCHECK +# undef lchown +# if HAVE_RAW_DECL_LCHOWN +_GL_WARN_ON_USE (lchown, "lchown is unportable to pre-POSIX.1-2001 systems - " + "use gnulib module lchown for portability"); +# endif +#endif + + +#if @GNULIB_LINK@ +/* Create a new hard link for an existing file. + Return 0 if successful, otherwise -1 and errno set. + See POSIX:2008 specification + . */ +# if @REPLACE_LINK@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define link rpl_link +# endif +_GL_FUNCDECL_RPL (link, int, (const char *path1, const char *path2) + _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (link, int, (const char *path1, const char *path2)); +# else +# if !@HAVE_LINK@ +_GL_FUNCDECL_SYS (link, int, (const char *path1, const char *path2) + _GL_ARG_NONNULL ((1, 2))); +# endif +_GL_CXXALIAS_SYS (link, int, (const char *path1, const char *path2)); +# endif +_GL_CXXALIASWARN (link); +#elif defined GNULIB_POSIXCHECK +# undef link +# if HAVE_RAW_DECL_LINK +_GL_WARN_ON_USE (link, "link is unportable - " + "use gnulib module link for portability"); +# endif +#endif + + +#if @GNULIB_LINKAT@ +/* Create a new hard link for an existing file, relative to two + directories. FLAG controls whether symlinks are followed. + Return 0 if successful, otherwise -1 and errno set. */ +# if @REPLACE_LINKAT@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef linkat +# define linkat rpl_linkat +# endif +_GL_FUNCDECL_RPL (linkat, int, + (int fd1, const char *path1, int fd2, const char *path2, + int flag) + _GL_ARG_NONNULL ((2, 4))); +_GL_CXXALIAS_RPL (linkat, int, + (int fd1, const char *path1, int fd2, const char *path2, + int flag)); +# else +# if !@HAVE_LINKAT@ +_GL_FUNCDECL_SYS (linkat, int, + (int fd1, const char *path1, int fd2, const char *path2, + int flag) + _GL_ARG_NONNULL ((2, 4))); +# endif +_GL_CXXALIAS_SYS (linkat, int, + (int fd1, const char *path1, int fd2, const char *path2, + int flag)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (linkat); +# endif +#elif defined GNULIB_POSIXCHECK +# undef linkat +# if HAVE_RAW_DECL_LINKAT +_GL_WARN_ON_USE (linkat, "linkat is unportable - " + "use gnulib module linkat for portability"); +# endif +#endif + + +#if @GNULIB_LSEEK@ +/* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END. + Return the new offset if successful, otherwise -1 and errno set. + See the POSIX:2008 specification + . */ +# if @REPLACE_LSEEK@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define lseek rpl_lseek +# endif +_GL_FUNCDECL_RPL (lseek, off_t, (int fd, off_t offset, int whence)); +_GL_CXXALIAS_RPL (lseek, off_t, (int fd, off_t offset, int whence)); +# elif defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef lseek +# define lseek _lseek +# endif +_GL_CXXALIAS_MDA (lseek, off_t, (int fd, off_t offset, int whence)); +# else +_GL_CXXALIAS_SYS (lseek, off_t, (int fd, off_t offset, int whence)); +# endif +_GL_CXXALIASWARN (lseek); +#elif defined GNULIB_POSIXCHECK +# undef lseek +# if HAVE_RAW_DECL_LSEEK +_GL_WARN_ON_USE (lseek, "lseek does not fail with ESPIPE on pipes on some " + "systems - use gnulib module lseek for portability"); +# endif +#elif @GNULIB_MDA_LSEEK@ +/* On native Windows, map 'lseek' to '_lseek', so that -loldnames is not + required. In C++ with GNULIB_NAMESPACE, avoid differences between + platforms by defining GNULIB_NAMESPACE::lseek always. */ +# if defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef lseek +# define lseek _lseek +# endif +_GL_CXXALIAS_MDA (lseek, long, (int fd, long offset, int whence)); +# else +_GL_CXXALIAS_SYS (lseek, off_t, (int fd, off_t offset, int whence)); +# endif +_GL_CXXALIASWARN (lseek); +#endif + + +#if @GNULIB_PIPE@ +/* Create a pipe, defaulting to O_BINARY mode. + Store the read-end as fd[0] and the write-end as fd[1]. + Return 0 upon success, or -1 with errno set upon failure. */ +# if !@HAVE_PIPE@ +_GL_FUNCDECL_SYS (pipe, int, (int fd[2]) _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (pipe, int, (int fd[2])); +_GL_CXXALIASWARN (pipe); +#elif defined GNULIB_POSIXCHECK +# undef pipe +# if HAVE_RAW_DECL_PIPE +_GL_WARN_ON_USE (pipe, "pipe is unportable - " + "use gnulib module pipe-posix for portability"); +# endif +#endif + + +#if @GNULIB_PIPE2@ +/* Create a pipe, applying the given flags when opening the read-end of the + pipe and the write-end of the pipe. + The flags are a bitmask, possibly including O_CLOEXEC (defined in ) + and O_TEXT, O_BINARY (defined in "binary-io.h"). + Store the read-end as fd[0] and the write-end as fd[1]. + Return 0 upon success, or -1 with errno set upon failure. + See also the Linux man page at + . */ +# if @REPLACE_PIPE2@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pipe2 +# define pipe2 rpl_pipe2 +# endif +_GL_FUNCDECL_RPL (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (pipe2, int, (int fd[2], int flags)); +# else +_GL_FUNCDECL_SYS (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_SYS (pipe2, int, (int fd[2], int flags)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (pipe2); +# endif +#elif defined GNULIB_POSIXCHECK +# undef pipe2 +# if HAVE_RAW_DECL_PIPE2 +_GL_WARN_ON_USE (pipe2, "pipe2 is unportable - " + "use gnulib module pipe2 for portability"); +# endif +#endif + + +#if @GNULIB_PREAD@ +/* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET. + Return the number of bytes placed into BUF if successful, otherwise + set errno and return -1. 0 indicates EOF. + See the POSIX:2008 specification + . */ +# if @REPLACE_PREAD@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pread +# define pread rpl_pread +# endif +_GL_FUNCDECL_RPL (pread, ssize_t, + (int fd, void *buf, size_t bufsize, off_t offset) + _GL_ARG_NONNULL ((2))); +_GL_CXXALIAS_RPL (pread, ssize_t, + (int fd, void *buf, size_t bufsize, off_t offset)); +# else +# if !@HAVE_PREAD@ +_GL_FUNCDECL_SYS (pread, ssize_t, + (int fd, void *buf, size_t bufsize, off_t offset) + _GL_ARG_NONNULL ((2))); +# endif +_GL_CXXALIAS_SYS (pread, ssize_t, + (int fd, void *buf, size_t bufsize, off_t offset)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (pread); +# endif +#elif defined GNULIB_POSIXCHECK +# undef pread +# if HAVE_RAW_DECL_PREAD +_GL_WARN_ON_USE (pread, "pread is unportable - " + "use gnulib module pread for portability"); +# endif +#endif + + +#if @GNULIB_PWRITE@ +/* Write at most BUFSIZE bytes from BUF into FD, starting at OFFSET. + Return the number of bytes written if successful, otherwise + set errno and return -1. 0 indicates nothing written. See the + POSIX:2008 specification + . */ +# if @REPLACE_PWRITE@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pwrite +# define pwrite rpl_pwrite +# endif +_GL_FUNCDECL_RPL (pwrite, ssize_t, + (int fd, const void *buf, size_t bufsize, off_t offset) + _GL_ARG_NONNULL ((2))); +_GL_CXXALIAS_RPL (pwrite, ssize_t, + (int fd, const void *buf, size_t bufsize, off_t offset)); +# else +# if !@HAVE_PWRITE@ +_GL_FUNCDECL_SYS (pwrite, ssize_t, + (int fd, const void *buf, size_t bufsize, off_t offset) + _GL_ARG_NONNULL ((2))); +# endif +_GL_CXXALIAS_SYS (pwrite, ssize_t, + (int fd, const void *buf, size_t bufsize, off_t offset)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (pwrite); +# endif +#elif defined GNULIB_POSIXCHECK +# undef pwrite +# if HAVE_RAW_DECL_PWRITE +_GL_WARN_ON_USE (pwrite, "pwrite is unportable - " + "use gnulib module pwrite for portability"); +# endif +#endif + + +#if @GNULIB_READ@ +/* Read up to COUNT bytes from file descriptor FD into the buffer starting + at BUF. See the POSIX:2008 specification + . */ +# if @REPLACE_READ@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef read +# define read rpl_read +# endif +_GL_FUNCDECL_RPL (read, ssize_t, (int fd, void *buf, size_t count) + _GL_ARG_NONNULL ((2))); +_GL_CXXALIAS_RPL (read, ssize_t, (int fd, void *buf, size_t count)); +# elif defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef read +# define read _read +# endif +_GL_CXXALIAS_MDA (read, ssize_t, (int fd, void *buf, size_t count)); +# else +_GL_CXXALIAS_SYS (read, ssize_t, (int fd, void *buf, size_t count)); +# endif +_GL_CXXALIASWARN (read); +#elif @GNULIB_MDA_READ@ +/* On native Windows, map 'read' to '_read', so that -loldnames is not + required. In C++ with GNULIB_NAMESPACE, avoid differences between + platforms by defining GNULIB_NAMESPACE::read always. */ +# if defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef read +# define read _read +# endif +# ifdef __MINGW32__ +_GL_CXXALIAS_MDA (read, int, (int fd, void *buf, unsigned int count)); +# else +_GL_CXXALIAS_MDA (read, ssize_t, (int fd, void *buf, unsigned int count)); +# endif +# else +_GL_CXXALIAS_SYS (read, ssize_t, (int fd, void *buf, size_t count)); +# endif +_GL_CXXALIASWARN (read); +#endif + + +#if @GNULIB_READLINK@ +/* Read the contents of the symbolic link FILE and place the first BUFSIZE + bytes of it into BUF. Return the number of bytes placed into BUF if + successful, otherwise -1 and errno set. + See the POSIX:2008 specification + . */ +# if @REPLACE_READLINK@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define readlink rpl_readlink +# endif +_GL_FUNCDECL_RPL (readlink, ssize_t, + (const char *restrict file, + char *restrict buf, size_t bufsize) + _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (readlink, ssize_t, + (const char *restrict file, + char *restrict buf, size_t bufsize)); +# else +# if !@HAVE_READLINK@ +_GL_FUNCDECL_SYS (readlink, ssize_t, + (const char *restrict file, + char *restrict buf, size_t bufsize) + _GL_ARG_NONNULL ((1, 2))); +# endif +_GL_CXXALIAS_SYS (readlink, ssize_t, + (const char *restrict file, + char *restrict buf, size_t bufsize)); +# endif +_GL_CXXALIASWARN (readlink); +#elif defined GNULIB_POSIXCHECK +# undef readlink +# if HAVE_RAW_DECL_READLINK +_GL_WARN_ON_USE (readlink, "readlink is unportable - " + "use gnulib module readlink for portability"); +# endif +#endif + + +#if @GNULIB_READLINKAT@ +# if @REPLACE_READLINKAT@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define readlinkat rpl_readlinkat +# endif +_GL_FUNCDECL_RPL (readlinkat, ssize_t, + (int fd, char const *restrict file, + char *restrict buf, size_t len) + _GL_ARG_NONNULL ((2, 3))); +_GL_CXXALIAS_RPL (readlinkat, ssize_t, + (int fd, char const *restrict file, + char *restrict buf, size_t len)); +# else +# if !@HAVE_READLINKAT@ +_GL_FUNCDECL_SYS (readlinkat, ssize_t, + (int fd, char const *restrict file, + char *restrict buf, size_t len) + _GL_ARG_NONNULL ((2, 3))); +# endif +_GL_CXXALIAS_SYS (readlinkat, ssize_t, + (int fd, char const *restrict file, + char *restrict buf, size_t len)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (readlinkat); +# endif +#elif defined GNULIB_POSIXCHECK +# undef readlinkat +# if HAVE_RAW_DECL_READLINKAT +_GL_WARN_ON_USE (readlinkat, "readlinkat is not portable - " + "use gnulib module readlinkat for portability"); +# endif +#endif + + +#if @GNULIB_RMDIR@ +/* Remove the directory DIR. */ +# if @REPLACE_RMDIR@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define rmdir rpl_rmdir +# endif +_GL_FUNCDECL_RPL (rmdir, int, (char const *name) _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (rmdir, int, (char const *name)); +# elif defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef rmdir +# define rmdir _rmdir +# endif +_GL_CXXALIAS_MDA (rmdir, int, (char const *name)); +# else +_GL_CXXALIAS_SYS (rmdir, int, (char const *name)); +# endif +_GL_CXXALIASWARN (rmdir); +#elif defined GNULIB_POSIXCHECK +# undef rmdir +# if HAVE_RAW_DECL_RMDIR +_GL_WARN_ON_USE (rmdir, "rmdir is unportable - " + "use gnulib module rmdir for portability"); +# endif +#elif @GNULIB_MDA_RMDIR@ +/* On native Windows, map 'rmdir' to '_rmdir', so that -loldnames is not + required. In C++ with GNULIB_NAMESPACE, avoid differences between + platforms by defining GNULIB_NAMESPACE::rmdir always. */ +# if defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef rmdir +# define rmdir _rmdir +# endif +_GL_CXXALIAS_MDA (rmdir, int, (char const *name)); +# else +_GL_CXXALIAS_SYS (rmdir, int, (char const *name)); +# endif +_GL_CXXALIASWARN (rmdir); +#endif + + +#if @GNULIB_SETHOSTNAME@ +/* Set the host name of the machine. + The host name may or may not be fully qualified. + + Put LEN bytes of NAME into the host name. + Return 0 if successful, otherwise, set errno and return -1. + + Platforms with no ability to set the hostname return -1 and set + errno = ENOSYS. */ +# if @REPLACE_SETHOSTNAME@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef sethostname +# define sethostname rpl_sethostname +# endif +_GL_FUNCDECL_RPL (sethostname, int, (const char *name, size_t len) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (sethostname, int, (const char *name, size_t len)); +# else +# if !@HAVE_SETHOSTNAME@ || !@HAVE_DECL_SETHOSTNAME@ +_GL_FUNCDECL_SYS (sethostname, int, (const char *name, size_t len) + _GL_ARG_NONNULL ((1))); +# endif +/* Need to cast, because on Solaris 11 2011-10, Mac OS X 10.5, IRIX 6.5 + and FreeBSD 6.4 the second parameter is int. On Solaris 11 + 2011-10, the first parameter is not const. */ +_GL_CXXALIAS_SYS_CAST (sethostname, int, (const char *name, size_t len)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (sethostname); +# endif +#elif defined GNULIB_POSIXCHECK +# undef sethostname +# if HAVE_RAW_DECL_SETHOSTNAME +_GL_WARN_ON_USE (sethostname, "sethostname is unportable - " + "use gnulib module sethostname for portability"); +# endif +#endif + + +#if @GNULIB_SLEEP@ +/* Pause the execution of the current thread for N seconds. + Returns the number of seconds left to sleep. + See the POSIX:2008 specification + . */ +# if @REPLACE_SLEEP@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef sleep +# define sleep rpl_sleep +# endif +_GL_FUNCDECL_RPL (sleep, unsigned int, (unsigned int n)); +_GL_CXXALIAS_RPL (sleep, unsigned int, (unsigned int n)); +# else +# if !@HAVE_SLEEP@ +_GL_FUNCDECL_SYS (sleep, unsigned int, (unsigned int n)); +# endif +_GL_CXXALIAS_SYS (sleep, unsigned int, (unsigned int n)); +# endif +_GL_CXXALIASWARN (sleep); +#elif defined GNULIB_POSIXCHECK +# undef sleep +# if HAVE_RAW_DECL_SLEEP +_GL_WARN_ON_USE (sleep, "sleep is unportable - " + "use gnulib module sleep for portability"); +# endif +#endif + + +#if @GNULIB_MDA_SWAB@ +/* On native Windows, map 'swab' to '_swab', so that -loldnames is not + required. In C++ with GNULIB_NAMESPACE, avoid differences between + platforms by defining GNULIB_NAMESPACE::swab always. */ +# if defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef swab +# define swab _swab +# endif +/* Need to cast, because in old mingw the arguments are + (const char *from, char *to, size_t n). */ +_GL_CXXALIAS_MDA_CAST (swab, void, (char *from, char *to, int n)); +# else +# if defined __hpux /* HP-UX */ +_GL_CXXALIAS_SYS (swab, void, (const char *from, char *to, int n)); +# elif defined __sun && (defined __SunOS_5_10 || defined __XOPEN_OR_POSIX) && !defined _XPG4 /* Solaris */ +_GL_CXXALIAS_SYS (swab, void, (const char *from, char *to, ssize_t n)); +# else +_GL_CXXALIAS_SYS (swab, void, (const void *from, void *to, ssize_t n)); +# endif +# endif +_GL_CXXALIASWARN (swab); +#endif + + +#if @GNULIB_SYMLINK@ +# if @REPLACE_SYMLINK@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef symlink +# define symlink rpl_symlink +# endif +_GL_FUNCDECL_RPL (symlink, int, (char const *contents, char const *file) + _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (symlink, int, (char const *contents, char const *file)); +# else +# if !@HAVE_SYMLINK@ +_GL_FUNCDECL_SYS (symlink, int, (char const *contents, char const *file) + _GL_ARG_NONNULL ((1, 2))); +# endif +_GL_CXXALIAS_SYS (symlink, int, (char const *contents, char const *file)); +# endif +_GL_CXXALIASWARN (symlink); +#elif defined GNULIB_POSIXCHECK +# undef symlink +# if HAVE_RAW_DECL_SYMLINK +_GL_WARN_ON_USE (symlink, "symlink is not portable - " + "use gnulib module symlink for portability"); +# endif +#endif + + +#if @GNULIB_SYMLINKAT@ +# if @REPLACE_SYMLINKAT@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef symlinkat +# define symlinkat rpl_symlinkat +# endif +_GL_FUNCDECL_RPL (symlinkat, int, + (char const *contents, int fd, char const *file) + _GL_ARG_NONNULL ((1, 3))); +_GL_CXXALIAS_RPL (symlinkat, int, + (char const *contents, int fd, char const *file)); +# else +# if !@HAVE_SYMLINKAT@ +_GL_FUNCDECL_SYS (symlinkat, int, + (char const *contents, int fd, char const *file) + _GL_ARG_NONNULL ((1, 3))); +# endif +_GL_CXXALIAS_SYS (symlinkat, int, + (char const *contents, int fd, char const *file)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (symlinkat); +# endif +#elif defined GNULIB_POSIXCHECK +# undef symlinkat +# if HAVE_RAW_DECL_SYMLINKAT +_GL_WARN_ON_USE (symlinkat, "symlinkat is not portable - " + "use gnulib module symlinkat for portability"); +# endif +#endif + + +#if @GNULIB_TRUNCATE@ +/* Change the size of the file designated by FILENAME to become equal to LENGTH. + Return 0 if successful, otherwise -1 and errno set. + See the POSIX:2008 specification + . */ +# if @REPLACE_TRUNCATE@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef truncate +# define truncate rpl_truncate +# endif +_GL_FUNCDECL_RPL (truncate, int, (const char *filename, off_t length) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (truncate, int, (const char *filename, off_t length)); +# else +# if !@HAVE_DECL_TRUNCATE@ +_GL_FUNCDECL_SYS (truncate, int, (const char *filename, off_t length) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (truncate, int, (const char *filename, off_t length)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (truncate); +# endif +#elif defined GNULIB_POSIXCHECK +# undef truncate +# if HAVE_RAW_DECL_TRUNCATE +_GL_WARN_ON_USE (truncate, "truncate is unportable - " + "use gnulib module truncate for portability"); +# endif +#endif + + +#if @GNULIB_TTYNAME_R@ +/* Store at most BUFLEN characters of the pathname of the terminal FD is + open on in BUF. Return 0 on success, otherwise an error number. */ +# if @REPLACE_TTYNAME_R@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef ttyname_r +# define ttyname_r rpl_ttyname_r +# endif +_GL_FUNCDECL_RPL (ttyname_r, int, + (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2))); +_GL_CXXALIAS_RPL (ttyname_r, int, + (int fd, char *buf, size_t buflen)); +# else +# if !@HAVE_DECL_TTYNAME_R@ +_GL_FUNCDECL_SYS (ttyname_r, int, + (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2))); +# endif +_GL_CXXALIAS_SYS (ttyname_r, int, + (int fd, char *buf, size_t buflen)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (ttyname_r); +# endif +#elif defined GNULIB_POSIXCHECK +# undef ttyname_r +# if HAVE_RAW_DECL_TTYNAME_R +_GL_WARN_ON_USE (ttyname_r, "ttyname_r is not portable - " + "use gnulib module ttyname_r for portability"); +# endif +#endif + + +#if @GNULIB_UNLINK@ +# if @REPLACE_UNLINK@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef unlink +# define unlink rpl_unlink +# endif +_GL_FUNCDECL_RPL (unlink, int, (char const *file) _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (unlink, int, (char const *file)); +# elif defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef unlink +# define unlink _unlink +# endif +_GL_CXXALIAS_MDA (unlink, int, (char const *file)); +# else +_GL_CXXALIAS_SYS (unlink, int, (char const *file)); +# endif +_GL_CXXALIASWARN (unlink); +#elif defined GNULIB_POSIXCHECK +# undef unlink +# if HAVE_RAW_DECL_UNLINK +_GL_WARN_ON_USE (unlink, "unlink is not portable - " + "use gnulib module unlink for portability"); +# endif +#elif @GNULIB_MDA_UNLINK@ +/* On native Windows, map 'unlink' to '_unlink', so that -loldnames is not + required. In C++ with GNULIB_NAMESPACE, avoid differences between + platforms by defining GNULIB_NAMESPACE::unlink always. */ +# if defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef unlink +# define unlink _unlink +# endif +_GL_CXXALIAS_MDA (unlink, int, (char const *file)); +# else +_GL_CXXALIAS_SYS (unlink, int, (char const *file)); +# endif +_GL_CXXALIASWARN (unlink); +#endif + + +#if @GNULIB_UNLINKAT@ +# if @REPLACE_UNLINKAT@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef unlinkat +# define unlinkat rpl_unlinkat +# endif +_GL_FUNCDECL_RPL (unlinkat, int, (int fd, char const *file, int flag) + _GL_ARG_NONNULL ((2))); +_GL_CXXALIAS_RPL (unlinkat, int, (int fd, char const *file, int flag)); +# else +# if !@HAVE_UNLINKAT@ +_GL_FUNCDECL_SYS (unlinkat, int, (int fd, char const *file, int flag) + _GL_ARG_NONNULL ((2))); +# endif +_GL_CXXALIAS_SYS (unlinkat, int, (int fd, char const *file, int flag)); +# endif +_GL_CXXALIASWARN (unlinkat); +#elif defined GNULIB_POSIXCHECK +# undef unlinkat +# if HAVE_RAW_DECL_UNLINKAT +_GL_WARN_ON_USE (unlinkat, "unlinkat is not portable - " + "use gnulib module unlinkat for portability"); +# endif +#endif + + +#if @GNULIB_USLEEP@ +/* Pause the execution of the current thread for N microseconds. + Returns 0 on completion, or -1 on range error. + See the POSIX:2001 specification + . */ +# if @REPLACE_USLEEP@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef usleep +# define usleep rpl_usleep +# endif +_GL_FUNCDECL_RPL (usleep, int, (useconds_t n)); +_GL_CXXALIAS_RPL (usleep, int, (useconds_t n)); +# else +# if !@HAVE_USLEEP@ +_GL_FUNCDECL_SYS (usleep, int, (useconds_t n)); +# endif +/* Need to cast, because on Haiku, the first parameter is + unsigned int n. */ +_GL_CXXALIAS_SYS_CAST (usleep, int, (useconds_t n)); +# endif +_GL_CXXALIASWARN (usleep); +#elif defined GNULIB_POSIXCHECK +# undef usleep +# if HAVE_RAW_DECL_USLEEP +_GL_WARN_ON_USE (usleep, "usleep is unportable - " + "use gnulib module usleep for portability"); +# endif +#endif + + +#if @GNULIB_WRITE@ +/* Write up to COUNT bytes starting at BUF to file descriptor FD. + See the POSIX:2008 specification + . */ +# if @REPLACE_WRITE@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef write +# define write rpl_write +# endif +_GL_FUNCDECL_RPL (write, ssize_t, (int fd, const void *buf, size_t count) + _GL_ARG_NONNULL ((2))); +_GL_CXXALIAS_RPL (write, ssize_t, (int fd, const void *buf, size_t count)); +# elif defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef write +# define write _write +# endif +_GL_CXXALIAS_MDA (write, ssize_t, (int fd, const void *buf, size_t count)); +# else +_GL_CXXALIAS_SYS (write, ssize_t, (int fd, const void *buf, size_t count)); +# endif +_GL_CXXALIASWARN (write); +#elif @GNULIB_MDA_WRITE@ +/* On native Windows, map 'write' to '_write', so that -loldnames is not + required. In C++ with GNULIB_NAMESPACE, avoid differences between + platforms by defining GNULIB_NAMESPACE::write always. */ +# if defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef write +# define write _write +# endif +# ifdef __MINGW32__ +_GL_CXXALIAS_MDA (write, int, (int fd, const void *buf, unsigned int count)); +# else +_GL_CXXALIAS_MDA (write, ssize_t, (int fd, const void *buf, unsigned int count)); +# endif +# else +_GL_CXXALIAS_SYS (write, ssize_t, (int fd, const void *buf, size_t count)); +# endif +_GL_CXXALIASWARN (write); +#endif + +_GL_INLINE_HEADER_END + +#endif /* _@GUARD_PREFIX@_UNISTD_H */ +#endif /* _GL_INCLUDING_UNISTD_H */ +#endif /* _@GUARD_PREFIX@_UNISTD_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistr.in.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistr.in.h new file mode 100644 index 00000000..424678fc --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistr.in.h @@ -0,0 +1,762 @@ +/* Elementary Unicode string functions. + Copyright (C) 2001-2002, 2005-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef _UNISTR_H +#define _UNISTR_H + +#include "unitypes.h" + +/* Get bool. */ +#include + +/* Get size_t, ptrdiff_t. */ +#include + +/* Get free(). */ +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +/* Conventions: + + All functions prefixed with u8_ operate on UTF-8 encoded strings. + Their unit is an uint8_t (1 byte). + + All functions prefixed with u16_ operate on UTF-16 encoded strings. + Their unit is an uint16_t (a 2-byte word). + + All functions prefixed with u32_ operate on UCS-4 encoded strings. + Their unit is an uint32_t (a 4-byte word). + + All argument pairs (s, n) denote a Unicode string s[0..n-1] with exactly + n units. + + All arguments starting with "str" and the arguments of functions starting + with u8_str/u16_str/u32_str denote a NUL terminated string, i.e. a string + which terminates at the first NUL unit. This termination unit is + considered part of the string for all memory allocation purposes, but + is not considered part of the string for all other logical purposes. + + Functions returning a string result take a (resultbuf, lengthp) argument + pair. If resultbuf is not NULL and the result fits into *lengthp units, + it is put in resultbuf, and resultbuf is returned. Otherwise, a freshly + allocated string is returned. In both cases, *lengthp is set to the + length (number of units) of the returned string. In case of error, + NULL is returned and errno is set. */ + + +/* Elementary string checks. */ + +/* Check whether an UTF-8 string is well-formed. + Return NULL if valid, or a pointer to the first invalid unit otherwise. */ +extern const uint8_t * + u8_check (const uint8_t *s, size_t n) + _UC_ATTRIBUTE_PURE; + +/* Check whether an UTF-16 string is well-formed. + Return NULL if valid, or a pointer to the first invalid unit otherwise. */ +extern const uint16_t * + u16_check (const uint16_t *s, size_t n) + _UC_ATTRIBUTE_PURE; + +/* Check whether an UCS-4 string is well-formed. + Return NULL if valid, or a pointer to the first invalid unit otherwise. */ +extern const uint32_t * + u32_check (const uint32_t *s, size_t n) + _UC_ATTRIBUTE_PURE; + + +/* Elementary string conversions. */ + +/* Convert an UTF-8 string to an UTF-16 string. */ +extern uint16_t * + u8_to_u16 (const uint8_t *s, size_t n, uint16_t *resultbuf, + size_t *lengthp); + +/* Convert an UTF-8 string to an UCS-4 string. */ +extern uint32_t * + u8_to_u32 (const uint8_t *s, size_t n, uint32_t *resultbuf, + size_t *lengthp); + +/* Convert an UTF-16 string to an UTF-8 string. */ +extern uint8_t * + u16_to_u8 (const uint16_t *s, size_t n, uint8_t *resultbuf, + size_t *lengthp); + +/* Convert an UTF-16 string to an UCS-4 string. */ +extern uint32_t * + u16_to_u32 (const uint16_t *s, size_t n, uint32_t *resultbuf, + size_t *lengthp); + +/* Convert an UCS-4 string to an UTF-8 string. */ +extern uint8_t * + u32_to_u8 (const uint32_t *s, size_t n, uint8_t *resultbuf, + size_t *lengthp); + +/* Convert an UCS-4 string to an UTF-16 string. */ +extern uint16_t * + u32_to_u16 (const uint32_t *s, size_t n, uint16_t *resultbuf, + size_t *lengthp); + + +/* Elementary string functions. */ + +/* Return the length (number of units) of the first character in S, which is + no longer than N. Return 0 if it is the NUL character. Return -1 upon + failure. */ +/* Similar to mblen(), except that s must not be NULL. */ +extern int + u8_mblen (const uint8_t *s, size_t n) + _UC_ATTRIBUTE_PURE; +extern int + u16_mblen (const uint16_t *s, size_t n) + _UC_ATTRIBUTE_PURE; +extern int + u32_mblen (const uint32_t *s, size_t n) + _UC_ATTRIBUTE_PURE; + +/* Return the length (number of units) of the first character in S, putting + its 'ucs4_t' representation in *PUC. Upon failure, *PUC is set to 0xfffd, + and an appropriate number of units is returned. + The number of available units, N, must be > 0. */ +/* Similar to mbtowc(), except that puc and s must not be NULL, n must be > 0, + and the NUL character is not treated specially. */ +/* The variants with _unsafe suffix are for backward compatibility with + libunistring versions < 0.9.7. */ + +#if GNULIB_UNISTR_U8_MBTOUC_UNSAFE || HAVE_LIBUNISTRING +# if !HAVE_INLINE +extern int + u8_mbtouc_unsafe (ucs4_t *puc, const uint8_t *s, size_t n); +# else +extern int + u8_mbtouc_unsafe_aux (ucs4_t *puc, const uint8_t *s, size_t n); +static inline int +u8_mbtouc_unsafe (ucs4_t *puc, const uint8_t *s, size_t n) +{ + uint8_t c = *s; + + if (c < 0x80) + { + *puc = c; + return 1; + } + else + return u8_mbtouc_unsafe_aux (puc, s, n); +} +# endif +#endif + +#if GNULIB_UNISTR_U16_MBTOUC_UNSAFE || HAVE_LIBUNISTRING +# if !HAVE_INLINE +extern int + u16_mbtouc_unsafe (ucs4_t *puc, const uint16_t *s, size_t n); +# else +extern int + u16_mbtouc_unsafe_aux (ucs4_t *puc, const uint16_t *s, size_t n); +static inline int +u16_mbtouc_unsafe (ucs4_t *puc, const uint16_t *s, size_t n) +{ + uint16_t c = *s; + + if (c < 0xd800 || c >= 0xe000) + { + *puc = c; + return 1; + } + else + return u16_mbtouc_unsafe_aux (puc, s, n); +} +# endif +#endif + +#if GNULIB_UNISTR_U32_MBTOUC_UNSAFE || HAVE_LIBUNISTRING +# if !HAVE_INLINE +extern int + u32_mbtouc_unsafe (ucs4_t *puc, const uint32_t *s, size_t n); +# else +static inline int +u32_mbtouc_unsafe (ucs4_t *puc, + const uint32_t *s, _GL_ATTRIBUTE_MAYBE_UNUSED size_t n) +{ + uint32_t c = *s; + + if (c < 0xd800 || (c >= 0xe000 && c < 0x110000)) + *puc = c; + else + /* invalid multibyte character */ + *puc = 0xfffd; + return 1; +} +# endif +#endif + +#if GNULIB_UNISTR_U8_MBTOUC || HAVE_LIBUNISTRING +# if !HAVE_INLINE +extern int + u8_mbtouc (ucs4_t *puc, const uint8_t *s, size_t n); +# else +extern int + u8_mbtouc_aux (ucs4_t *puc, const uint8_t *s, size_t n); +static inline int +u8_mbtouc (ucs4_t *puc, const uint8_t *s, size_t n) +{ + uint8_t c = *s; + + if (c < 0x80) + { + *puc = c; + return 1; + } + else + return u8_mbtouc_aux (puc, s, n); +} +# endif +#endif + +#if GNULIB_UNISTR_U16_MBTOUC || HAVE_LIBUNISTRING +# if !HAVE_INLINE +extern int + u16_mbtouc (ucs4_t *puc, const uint16_t *s, size_t n); +# else +extern int + u16_mbtouc_aux (ucs4_t *puc, const uint16_t *s, size_t n); +static inline int +u16_mbtouc (ucs4_t *puc, const uint16_t *s, size_t n) +{ + uint16_t c = *s; + + if (c < 0xd800 || c >= 0xe000) + { + *puc = c; + return 1; + } + else + return u16_mbtouc_aux (puc, s, n); +} +# endif +#endif + +#if GNULIB_UNISTR_U32_MBTOUC || HAVE_LIBUNISTRING +# if !HAVE_INLINE +extern int + u32_mbtouc (ucs4_t *puc, const uint32_t *s, size_t n); +# else +static inline int +u32_mbtouc (ucs4_t *puc, const uint32_t *s, + _GL_ATTRIBUTE_MAYBE_UNUSED size_t n) +{ + uint32_t c = *s; + + if (c < 0xd800 || (c >= 0xe000 && c < 0x110000)) + *puc = c; + else + /* invalid multibyte character */ + *puc = 0xfffd; + return 1; +} +# endif +#endif + +/* Return the length (number of units) of the first character in S, putting + its 'ucs4_t' representation in *PUC. Upon failure, *PUC is set to 0xfffd, + and -1 is returned for an invalid sequence of units, -2 is returned for an + incomplete sequence of units. + The number of available units, N, must be > 0. */ +/* Similar to u*_mbtouc(), except that the return value gives more details + about the failure, similar to mbrtowc(). */ + +#if GNULIB_UNISTR_U8_MBTOUCR || HAVE_LIBUNISTRING +extern int + u8_mbtoucr (ucs4_t *puc, const uint8_t *s, size_t n); +#endif + +#if GNULIB_UNISTR_U16_MBTOUCR || HAVE_LIBUNISTRING +extern int + u16_mbtoucr (ucs4_t *puc, const uint16_t *s, size_t n); +#endif + +#if GNULIB_UNISTR_U32_MBTOUCR || HAVE_LIBUNISTRING +extern int + u32_mbtoucr (ucs4_t *puc, const uint32_t *s, size_t n); +#endif + +/* Put the multibyte character represented by UC in S, returning its + length. Return -1 upon failure, -2 if the number of available units, N, + is too small. The latter case cannot occur if N >= 6/2/1, respectively. */ +/* Similar to wctomb(), except that s must not be NULL, and the argument n + must be specified. */ + +#if GNULIB_UNISTR_U8_UCTOMB || HAVE_LIBUNISTRING +/* Auxiliary function, also used by u8_chr, u8_strchr, u8_strrchr. */ +extern int + u8_uctomb_aux (uint8_t *s, ucs4_t uc, ptrdiff_t n); +# if !HAVE_INLINE +extern int + u8_uctomb (uint8_t *s, ucs4_t uc, ptrdiff_t n); +# else +static inline int +u8_uctomb (uint8_t *s, ucs4_t uc, ptrdiff_t n) +{ + if (uc < 0x80 && n > 0) + { + s[0] = uc; + return 1; + } + else + return u8_uctomb_aux (s, uc, n); +} +# endif +#endif + +#if GNULIB_UNISTR_U16_UCTOMB || HAVE_LIBUNISTRING +/* Auxiliary function, also used by u16_chr, u16_strchr, u16_strrchr. */ +extern int + u16_uctomb_aux (uint16_t *s, ucs4_t uc, ptrdiff_t n); +# if !HAVE_INLINE +extern int + u16_uctomb (uint16_t *s, ucs4_t uc, ptrdiff_t n); +# else +static inline int +u16_uctomb (uint16_t *s, ucs4_t uc, ptrdiff_t n) +{ + if (uc < 0xd800 && n > 0) + { + s[0] = uc; + return 1; + } + else + return u16_uctomb_aux (s, uc, n); +} +# endif +#endif + +#if GNULIB_UNISTR_U32_UCTOMB || HAVE_LIBUNISTRING +# if !HAVE_INLINE +extern int + u32_uctomb (uint32_t *s, ucs4_t uc, ptrdiff_t n); +# else +static inline int +u32_uctomb (uint32_t *s, ucs4_t uc, ptrdiff_t n) +{ + if (uc < 0xd800 || (uc >= 0xe000 && uc < 0x110000)) + { + if (n > 0) + { + *s = uc; + return 1; + } + else + return -2; + } + else + return -1; +} +# endif +#endif + +/* Copy N units from SRC to DEST. */ +/* Similar to memcpy(). */ +extern uint8_t * + u8_cpy (uint8_t *_UC_RESTRICT dest, const uint8_t *src, size_t n); +extern uint16_t * + u16_cpy (uint16_t *_UC_RESTRICT dest, const uint16_t *src, size_t n); +extern uint32_t * + u32_cpy (uint32_t *_UC_RESTRICT dest, const uint32_t *src, size_t n); + +/* Copy N units from SRC to DEST, returning pointer after last written unit. */ +/* Similar to mempcpy(). */ +extern uint8_t * + u8_pcpy (uint8_t *_UC_RESTRICT dest, const uint8_t *src, size_t n); +extern uint16_t * + u16_pcpy (uint16_t *_UC_RESTRICT dest, const uint16_t *src, size_t n); +extern uint32_t * + u32_pcpy (uint32_t *_UC_RESTRICT dest, const uint32_t *src, size_t n); + +/* Copy N units from SRC to DEST, guaranteeing correct behavior for + overlapping memory areas. */ +/* Similar to memmove(). */ +extern uint8_t * + u8_move (uint8_t *dest, const uint8_t *src, size_t n); +extern uint16_t * + u16_move (uint16_t *dest, const uint16_t *src, size_t n); +extern uint32_t * + u32_move (uint32_t *dest, const uint32_t *src, size_t n); + +/* Set the first N characters of S to UC. UC should be a character that + occupies only 1 unit. */ +/* Similar to memset(). */ +extern uint8_t * + u8_set (uint8_t *s, ucs4_t uc, size_t n); +extern uint16_t * + u16_set (uint16_t *s, ucs4_t uc, size_t n); +extern uint32_t * + u32_set (uint32_t *s, ucs4_t uc, size_t n); + +/* Compare S1 and S2, each of length N. */ +/* Similar to memcmp(). */ +extern int + u8_cmp (const uint8_t *s1, const uint8_t *s2, size_t n) + _UC_ATTRIBUTE_PURE; +extern int + u16_cmp (const uint16_t *s1, const uint16_t *s2, size_t n) + _UC_ATTRIBUTE_PURE; +extern int + u32_cmp (const uint32_t *s1, const uint32_t *s2, size_t n) + _UC_ATTRIBUTE_PURE; + +/* Compare S1 and S2. */ +/* Similar to the gnulib function memcmp2(). */ +extern int + u8_cmp2 (const uint8_t *s1, size_t n1, const uint8_t *s2, size_t n2) + _UC_ATTRIBUTE_PURE; +extern int + u16_cmp2 (const uint16_t *s1, size_t n1, const uint16_t *s2, size_t n2) + _UC_ATTRIBUTE_PURE; +extern int + u32_cmp2 (const uint32_t *s1, size_t n1, const uint32_t *s2, size_t n2) + _UC_ATTRIBUTE_PURE; + +/* Search the string at S for UC. */ +/* Similar to memchr(). */ +extern uint8_t * + u8_chr (const uint8_t *s, size_t n, ucs4_t uc) + _UC_ATTRIBUTE_PURE; +extern uint16_t * + u16_chr (const uint16_t *s, size_t n, ucs4_t uc) + _UC_ATTRIBUTE_PURE; +extern uint32_t * + u32_chr (const uint32_t *s, size_t n, ucs4_t uc) + _UC_ATTRIBUTE_PURE; + +/* Count the number of Unicode characters in the N units from S. */ +/* Similar to mbsnlen(). */ +extern size_t + u8_mbsnlen (const uint8_t *s, size_t n) + _UC_ATTRIBUTE_PURE; +extern size_t + u16_mbsnlen (const uint16_t *s, size_t n) + _UC_ATTRIBUTE_PURE; +extern size_t + u32_mbsnlen (const uint32_t *s, size_t n) + _UC_ATTRIBUTE_PURE; + +/* Elementary string functions with memory allocation. */ + +/* Make a freshly allocated copy of S, of length N. */ +extern uint8_t * + u8_cpy_alloc (const uint8_t *s, size_t n); +extern uint16_t * + u16_cpy_alloc (const uint16_t *s, size_t n); +extern uint32_t * + u32_cpy_alloc (const uint32_t *s, size_t n); + +/* Elementary string functions on NUL terminated strings. */ + +/* Return the length (number of units) of the first character in S. + Return 0 if it is the NUL character. Return -1 upon failure. */ +extern int + u8_strmblen (const uint8_t *s) + _UC_ATTRIBUTE_PURE; +extern int + u16_strmblen (const uint16_t *s) + _UC_ATTRIBUTE_PURE; +extern int + u32_strmblen (const uint32_t *s) + _UC_ATTRIBUTE_PURE; + +/* Return the length (number of units) of the first character in S, putting + its 'ucs4_t' representation in *PUC. Return 0 if it is the NUL + character. Return -1 upon failure. */ +extern int + u8_strmbtouc (ucs4_t *puc, const uint8_t *s); +extern int + u16_strmbtouc (ucs4_t *puc, const uint16_t *s); +extern int + u32_strmbtouc (ucs4_t *puc, const uint32_t *s); + +/* Forward iteration step. Advances the pointer past the next character, + or returns NULL if the end of the string has been reached. Puts the + character's 'ucs4_t' representation in *PUC. */ +extern const uint8_t * + u8_next (ucs4_t *puc, const uint8_t *s); +extern const uint16_t * + u16_next (ucs4_t *puc, const uint16_t *s); +extern const uint32_t * + u32_next (ucs4_t *puc, const uint32_t *s); + +/* Backward iteration step. Advances the pointer to point to the previous + character, or returns NULL if the beginning of the string had been reached. + Puts the character's 'ucs4_t' representation in *PUC. */ +extern const uint8_t * + u8_prev (ucs4_t *puc, const uint8_t *s, const uint8_t *start); +extern const uint16_t * + u16_prev (ucs4_t *puc, const uint16_t *s, const uint16_t *start); +extern const uint32_t * + u32_prev (ucs4_t *puc, const uint32_t *s, const uint32_t *start); + +/* Return the number of units in S. */ +/* Similar to strlen(), wcslen(). */ +extern size_t + u8_strlen (const uint8_t *s) + _UC_ATTRIBUTE_PURE; +extern size_t + u16_strlen (const uint16_t *s) + _UC_ATTRIBUTE_PURE; +extern size_t + u32_strlen (const uint32_t *s) + _UC_ATTRIBUTE_PURE; + +/* Return the number of units in S, but at most MAXLEN. */ +/* Similar to strnlen(), wcsnlen(). */ +extern size_t + u8_strnlen (const uint8_t *s, size_t maxlen) + _UC_ATTRIBUTE_PURE; +extern size_t + u16_strnlen (const uint16_t *s, size_t maxlen) + _UC_ATTRIBUTE_PURE; +extern size_t + u32_strnlen (const uint32_t *s, size_t maxlen) + _UC_ATTRIBUTE_PURE; + +/* Copy SRC to DEST. */ +/* Similar to strcpy(), wcscpy(). */ +extern uint8_t * + u8_strcpy (uint8_t *_UC_RESTRICT dest, const uint8_t *src); +extern uint16_t * + u16_strcpy (uint16_t *_UC_RESTRICT dest, const uint16_t *src); +extern uint32_t * + u32_strcpy (uint32_t *_UC_RESTRICT dest, const uint32_t *src); + +/* Copy SRC to DEST, returning the address of the terminating NUL in DEST. */ +/* Similar to stpcpy(). */ +extern uint8_t * + u8_stpcpy (uint8_t *_UC_RESTRICT dest, const uint8_t *src); +extern uint16_t * + u16_stpcpy (uint16_t *_UC_RESTRICT dest, const uint16_t *src); +extern uint32_t * + u32_stpcpy (uint32_t *_UC_RESTRICT dest, const uint32_t *src); + +/* Copy no more than N units of SRC to DEST. */ +/* Similar to strncpy(), wcsncpy(). */ +extern uint8_t * + u8_strncpy (uint8_t *_UC_RESTRICT dest, const uint8_t *src, size_t n); +extern uint16_t * + u16_strncpy (uint16_t *_UC_RESTRICT dest, const uint16_t *src, size_t n); +extern uint32_t * + u32_strncpy (uint32_t *_UC_RESTRICT dest, const uint32_t *src, size_t n); + +/* Copy no more than N units of SRC to DEST. Return a pointer past the last + non-NUL unit written into DEST. */ +/* Similar to stpncpy(). */ +extern uint8_t * + u8_stpncpy (uint8_t *_UC_RESTRICT dest, const uint8_t *src, size_t n); +extern uint16_t * + u16_stpncpy (uint16_t *_UC_RESTRICT dest, const uint16_t *src, size_t n); +extern uint32_t * + u32_stpncpy (uint32_t *_UC_RESTRICT dest, const uint32_t *src, size_t n); + +/* Append SRC onto DEST. */ +/* Similar to strcat(), wcscat(). */ +extern uint8_t * + u8_strcat (uint8_t *_UC_RESTRICT dest, const uint8_t *src); +extern uint16_t * + u16_strcat (uint16_t *_UC_RESTRICT dest, const uint16_t *src); +extern uint32_t * + u32_strcat (uint32_t *_UC_RESTRICT dest, const uint32_t *src); + +/* Append no more than N units of SRC onto DEST. */ +/* Similar to strncat(), wcsncat(). */ +extern uint8_t * + u8_strncat (uint8_t *_UC_RESTRICT dest, const uint8_t *src, size_t n); +extern uint16_t * + u16_strncat (uint16_t *_UC_RESTRICT dest, const uint16_t *src, size_t n); +extern uint32_t * + u32_strncat (uint32_t *_UC_RESTRICT dest, const uint32_t *src, size_t n); + +/* Compare S1 and S2. */ +/* Similar to strcmp(), wcscmp(). */ +#ifdef __sun +/* Avoid a collision with the u8_strcmp() function in Solaris 11 libc. */ +extern int + u8_strcmp_gnu (const uint8_t *s1, const uint8_t *s2) + _UC_ATTRIBUTE_PURE; +# define u8_strcmp u8_strcmp_gnu +#else +extern int + u8_strcmp (const uint8_t *s1, const uint8_t *s2) + _UC_ATTRIBUTE_PURE; +#endif +extern int + u16_strcmp (const uint16_t *s1, const uint16_t *s2) + _UC_ATTRIBUTE_PURE; +extern int + u32_strcmp (const uint32_t *s1, const uint32_t *s2) + _UC_ATTRIBUTE_PURE; + +/* Compare S1 and S2 using the collation rules of the current locale. + Return -1 if S1 < S2, 0 if S1 = S2, 1 if S1 > S2. + Upon failure, set errno and return any value. */ +/* Similar to strcoll(), wcscoll(). */ +extern int + u8_strcoll (const uint8_t *s1, const uint8_t *s2); +extern int + u16_strcoll (const uint16_t *s1, const uint16_t *s2); +extern int + u32_strcoll (const uint32_t *s1, const uint32_t *s2); + +/* Compare no more than N units of S1 and S2. */ +/* Similar to strncmp(), wcsncmp(). */ +extern int + u8_strncmp (const uint8_t *s1, const uint8_t *s2, size_t n) + _UC_ATTRIBUTE_PURE; +extern int + u16_strncmp (const uint16_t *s1, const uint16_t *s2, size_t n) + _UC_ATTRIBUTE_PURE; +extern int + u32_strncmp (const uint32_t *s1, const uint32_t *s2, size_t n) + _UC_ATTRIBUTE_PURE; + +/* Duplicate S, returning an identical malloc'd string. */ +/* Similar to strdup(), wcsdup(). */ +extern uint8_t * + u8_strdup (const uint8_t *s) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE; +extern uint16_t * + u16_strdup (const uint16_t *s) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE; +extern uint32_t * + u32_strdup (const uint32_t *s) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE; + +/* Find the first occurrence of UC in STR. */ +/* Similar to strchr(), wcschr(). */ +extern uint8_t * + u8_strchr (const uint8_t *str, ucs4_t uc) + _UC_ATTRIBUTE_PURE; +extern uint16_t * + u16_strchr (const uint16_t *str, ucs4_t uc) + _UC_ATTRIBUTE_PURE; +extern uint32_t * + u32_strchr (const uint32_t *str, ucs4_t uc) + _UC_ATTRIBUTE_PURE; + +/* Find the last occurrence of UC in STR. */ +/* Similar to strrchr(), wcsrchr(). */ +extern uint8_t * + u8_strrchr (const uint8_t *str, ucs4_t uc) + _UC_ATTRIBUTE_PURE; +extern uint16_t * + u16_strrchr (const uint16_t *str, ucs4_t uc) + _UC_ATTRIBUTE_PURE; +extern uint32_t * + u32_strrchr (const uint32_t *str, ucs4_t uc) + _UC_ATTRIBUTE_PURE; + +/* Return the length of the initial segment of STR which consists entirely + of Unicode characters not in REJECT. */ +/* Similar to strcspn(), wcscspn(). */ +extern size_t + u8_strcspn (const uint8_t *str, const uint8_t *reject) + _UC_ATTRIBUTE_PURE; +extern size_t + u16_strcspn (const uint16_t *str, const uint16_t *reject) + _UC_ATTRIBUTE_PURE; +extern size_t + u32_strcspn (const uint32_t *str, const uint32_t *reject) + _UC_ATTRIBUTE_PURE; + +/* Return the length of the initial segment of STR which consists entirely + of Unicode characters in ACCEPT. */ +/* Similar to strspn(), wcsspn(). */ +extern size_t + u8_strspn (const uint8_t *str, const uint8_t *accept) + _UC_ATTRIBUTE_PURE; +extern size_t + u16_strspn (const uint16_t *str, const uint16_t *accept) + _UC_ATTRIBUTE_PURE; +extern size_t + u32_strspn (const uint32_t *str, const uint32_t *accept) + _UC_ATTRIBUTE_PURE; + +/* Find the first occurrence in STR of any character in ACCEPT. */ +/* Similar to strpbrk(), wcspbrk(). */ +extern uint8_t * + u8_strpbrk (const uint8_t *str, const uint8_t *accept) + _UC_ATTRIBUTE_PURE; +extern uint16_t * + u16_strpbrk (const uint16_t *str, const uint16_t *accept) + _UC_ATTRIBUTE_PURE; +extern uint32_t * + u32_strpbrk (const uint32_t *str, const uint32_t *accept) + _UC_ATTRIBUTE_PURE; + +/* Find the first occurrence of NEEDLE in HAYSTACK. */ +/* Similar to strstr(), wcsstr(). */ +extern uint8_t * + u8_strstr (const uint8_t *haystack, const uint8_t *needle) + _UC_ATTRIBUTE_PURE; +extern uint16_t * + u16_strstr (const uint16_t *haystack, const uint16_t *needle) + _UC_ATTRIBUTE_PURE; +extern uint32_t * + u32_strstr (const uint32_t *haystack, const uint32_t *needle) + _UC_ATTRIBUTE_PURE; + +/* Test whether STR starts with PREFIX. */ +extern bool + u8_startswith (const uint8_t *str, const uint8_t *prefix) + _UC_ATTRIBUTE_PURE; +extern bool + u16_startswith (const uint16_t *str, const uint16_t *prefix) + _UC_ATTRIBUTE_PURE; +extern bool + u32_startswith (const uint32_t *str, const uint32_t *prefix) + _UC_ATTRIBUTE_PURE; + +/* Test whether STR ends with SUFFIX. */ +extern bool + u8_endswith (const uint8_t *str, const uint8_t *suffix) + _UC_ATTRIBUTE_PURE; +extern bool + u16_endswith (const uint16_t *str, const uint16_t *suffix) + _UC_ATTRIBUTE_PURE; +extern bool + u32_endswith (const uint32_t *str, const uint32_t *suffix) + _UC_ATTRIBUTE_PURE; + +/* Divide STR into tokens separated by characters in DELIM. + This interface is actually more similar to wcstok than to strtok. */ +/* Similar to strtok_r(), wcstok(). */ +extern uint8_t * + u8_strtok (uint8_t *_UC_RESTRICT str, const uint8_t *delim, + uint8_t **ptr); +extern uint16_t * + u16_strtok (uint16_t *_UC_RESTRICT str, const uint16_t *delim, + uint16_t **ptr); +extern uint32_t * + u32_strtok (uint32_t *_UC_RESTRICT str, const uint32_t *delim, + uint32_t **ptr); + + +#ifdef __cplusplus +} +#endif + +#endif /* _UNISTR_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistr/.gitignore b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistr/.gitignore new file mode 100644 index 00000000..ccbc8da0 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistr/.gitignore @@ -0,0 +1,9 @@ +/u-cpy.h +/u-pcpy.h +/u-strcat.h +/u-strlen.h +/u32-chr.c +/u32-cpy.c +/u32-pcpy.c +/u32-strcat.c +/u32-strlen.c diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistr/u-cpy.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistr/u-cpy.h new file mode 100644 index 00000000..4848c146 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistr/u-cpy.h @@ -0,0 +1,33 @@ +/* Copy piece of UTF-8/UTF-16/UTF-32 string. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2002. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +UNIT * +FUNC (UNIT *dest, const UNIT *src, size_t n) +{ +#if 0 + UNIT *destptr = dest; + + for (; n > 0; n--) + *destptr++ = *src++; +#else + if (n > 0) + memcpy ((char *) dest, (const char *) src, n * sizeof (UNIT)); +#endif + return dest; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistr/u-pcpy.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistr/u-pcpy.h new file mode 100644 index 00000000..81241975 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistr/u-pcpy.h @@ -0,0 +1,22 @@ +/* Copy piece of UTF-8/16/32 string, return pointer after last written unit. + Copyright (C) 2020-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2023. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +UNIT * +FUNC (UNIT *dest, const UNIT *src, size_t n) +{ + return U_CPY (dest, src, n) + n; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistr/u-strcat.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistr/u-strcat.h new file mode 100644 index 00000000..a4a4e931 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistr/u-strcat.h @@ -0,0 +1,26 @@ +/* Concatenate UTF-8/UTF-16/UTF-32 strings. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2002. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +UNIT * +FUNC (UNIT *dest, const UNIT *src) +{ + UNIT *destptr = dest + U_STRLEN (dest); + + for (; (*destptr = *src) != 0; src++, destptr++) + ; + return dest; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistr/u-strlen.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistr/u-strlen.h new file mode 100644 index 00000000..03106a15 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistr/u-strlen.h @@ -0,0 +1,26 @@ +/* Determine length of UTF-8/UTF-16/UTF-32 string. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2002. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +size_t +FUNC (const UNIT *s) +{ + const UNIT *ptr; + + for (ptr = s; *ptr != 0; ptr++) + ; + return ptr - s; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistr/u32-chr.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistr/u32-chr.c new file mode 100644 index 00000000..65500d83 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistr/u32-chr.c @@ -0,0 +1,32 @@ +/* Search character in piece of UTF-32 string. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2002. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unistr.h" + +uint32_t * +u32_chr (const uint32_t *s, size_t n, ucs4_t uc) +{ + for (; n > 0; s++, n--) + { + if (*s == uc) + return (uint32_t *) s; + } + return NULL; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistr/u32-cpy.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistr/u32-cpy.c new file mode 100644 index 00000000..a1a840f7 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistr/u32-cpy.c @@ -0,0 +1,25 @@ +/* Copy piece of UTF-32 string. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2002. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unistr.h" + +#define FUNC u32_cpy +#define UNIT uint32_t +#include "u-cpy.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistr/u32-pcpy.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistr/u32-pcpy.c new file mode 100644 index 00000000..922f704c --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistr/u32-pcpy.c @@ -0,0 +1,26 @@ +/* Copy piece of UTF-32 string, return pointer after last written unit. + Copyright (C) 2020-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2023. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unistr.h" + +#define FUNC u32_pcpy +#define UNIT uint32_t +#define U_CPY u32_cpy +#include "u-pcpy.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistr/u32-strcat.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistr/u32-strcat.c new file mode 100644 index 00000000..2da08b18 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistr/u32-strcat.c @@ -0,0 +1,26 @@ +/* Concatenate UTF-32 strings. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2002. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unistr.h" + +#define FUNC u32_strcat +#define UNIT uint32_t +#define U_STRLEN u32_strlen +#include "u-strcat.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistr/u32-strlen.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistr/u32-strlen.c new file mode 100644 index 00000000..1c43a30a --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unistr/u32-strlen.c @@ -0,0 +1,25 @@ +/* Determine length of UTF-32 string. + Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2002. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unistr.h" + +#define FUNC u32_strlen +#define UNIT uint32_t +#include "u-strlen.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unitypes.in.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unitypes.in.h new file mode 100644 index 00000000..1b14d3b6 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unitypes.in.h @@ -0,0 +1,61 @@ +/* Elementary types and macros for the GNU UniString library. + Copyright (C) 2002, 2005-2006, 2009-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef _UNITYPES_H +#define _UNITYPES_H + +/* Get uint8_t, uint16_t, uint32_t. */ +#include + +/* Type representing a Unicode character. */ +typedef uint32_t ucs4_t; + +/* Attribute of a function whose result depends only on the arguments + (not pointers!) and which has no side effects. */ +#ifndef _UC_ATTRIBUTE_CONST +# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) || defined __clang__ +# define _UC_ATTRIBUTE_CONST __attribute__ ((__const__)) +# else +# define _UC_ATTRIBUTE_CONST +# endif +#endif + +/* Attribute of a function whose result depends only on the arguments + (possibly pointers) and global memory, and which has no side effects. */ +#ifndef _UC_ATTRIBUTE_PURE +# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined __clang__ +# define _UC_ATTRIBUTE_PURE __attribute__ ((__pure__)) +# else +# define _UC_ATTRIBUTE_PURE +# endif +#endif + +/* Qualifier in a function declaration, that asserts that the caller must + pass a pointer to a different object in the specified pointer argument + than in the other pointer arguments. */ +#ifndef _UC_RESTRICT +# if defined __restrict \ + || 2 < __GNUC__ + (95 <= __GNUC_MINOR__) \ + || __clang_major__ >= 3 +# define _UC_RESTRICT __restrict +# elif 199901L <= __STDC_VERSION__ || defined restrict +# define _UC_RESTRICT restrict +# else +# define _UC_RESTRICT +# endif +#endif + +#endif /* _UNITYPES_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/uniwidth.in.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/uniwidth.in.h new file mode 100644 index 00000000..58bfe9c1 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/uniwidth.in.h @@ -0,0 +1,72 @@ +/* Display width functions. + Copyright (C) 2001-2002, 2005, 2007, 2009-2024 Free Software Foundation, + Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef _UNIWIDTH_H +#define _UNIWIDTH_H + +#include "unitypes.h" + +/* Get size_t. */ +#include + +/* Get locale_charset() declaration. */ +#include "localcharset.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +/* Display width. */ + +/* These functions are locale dependent. The encoding argument identifies + the encoding (e.g. "ISO-8859-2" for Polish). */ + +/* Determine number of column positions required for UC. */ +extern int + uc_width (ucs4_t uc, const char *encoding) + _UC_ATTRIBUTE_PURE; + +/* Determine number of column positions required for first N units + (or fewer if S ends before this) in S. */ +extern int + u8_width (const uint8_t *s, size_t n, const char *encoding) + _UC_ATTRIBUTE_PURE; +extern int + u16_width (const uint16_t *s, size_t n, const char *encoding) + _UC_ATTRIBUTE_PURE; +extern int + u32_width (const uint32_t *s, size_t n, const char *encoding) + _UC_ATTRIBUTE_PURE; + +/* Determine number of column positions required for S. */ +extern int + u8_strwidth (const uint8_t *s, const char *encoding) + _UC_ATTRIBUTE_PURE; +extern int + u16_strwidth (const uint16_t *s, const char *encoding) + _UC_ATTRIBUTE_PURE; +extern int + u32_strwidth (const uint32_t *s, const char *encoding) + _UC_ATTRIBUTE_PURE; + + +#ifdef __cplusplus +} +#endif + +#endif /* _UNIWIDTH_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/uniwidth/.gitignore b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/uniwidth/.gitignore new file mode 100644 index 00000000..ba2320c6 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/uniwidth/.gitignore @@ -0,0 +1,4 @@ +/cjk.h +/width.c +/width0.h +/width2.h diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/uniwidth/cjk.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/uniwidth/cjk.h new file mode 100644 index 00000000..5fab365f --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/uniwidth/cjk.h @@ -0,0 +1,37 @@ +/* Test for CJK encoding. + Copyright (C) 2001-2002, 2005-2007, 2009-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2002. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include "streq.h" + +static int +is_cjk_encoding (const char *encoding) +{ + if (0 + /* Legacy Japanese encodings */ + || STREQ_OPT (encoding, "EUC-JP", 'E', 'U', 'C', '-', 'J', 'P', 0, 0, 0) + /* Legacy Chinese encodings */ + || STREQ_OPT (encoding, "GB2312", 'G', 'B', '2', '3', '1', '2', 0, 0, 0) + || STREQ_OPT (encoding, "GBK", 'G', 'B', 'K', 0, 0, 0, 0, 0, 0) + || STREQ_OPT (encoding, "EUC-TW", 'E', 'U', 'C', '-', 'T', 'W', 0, 0, 0) + || STREQ_OPT (encoding, "BIG5", 'B', 'I', 'G', '5', 0, 0, 0, 0, 0) + /* Legacy Korean encodings */ + || STREQ_OPT (encoding, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0) + || STREQ_OPT (encoding, "CP949", 'C', 'P', '9', '4', '9', 0, 0, 0, 0) + || STREQ_OPT (encoding, "JOHAB", 'J', 'O', 'H', 'A', 'B', 0, 0, 0, 0)) + return 1; + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/uniwidth/width.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/uniwidth/width.c new file mode 100644 index 00000000..4942aa1e --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/uniwidth/width.c @@ -0,0 +1,95 @@ +/* Determine display width of Unicode character. + Copyright (C) 2001-2002, 2006-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2002. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "uniwidth.h" + +#include "cjk.h" + +/* The non-spacing attribute table consists of: + * Non-spacing characters; generated from PropList.txt or + "grep '^[^;]*;[^;]*;[^;]*;[^;]*;NSM;' UnicodeData.txt" + * Format control characters; generated from + "grep '^[^;]*;[^;]*;Cf;' UnicodeData.txt" + * Zero width characters; generated from + "grep '^[^;]*;ZERO WIDTH ' UnicodeData.txt" + * Hangul Jamo characters that have conjoining behaviour: + - jungseong = syllable-middle vowels + - jongseong = syllable-final consonants + Rationale: + 1) These characters act like combining characters. They have no + equivalent in legacy character sets. Therefore the EastAsianWidth.txt + file does not really matter for them; UAX #11 East Asian Width + makes it clear that it focus + is on compatibility with traditional Japanese layout. + By contrast, the same glyphs without conjoining behaviour are available + in the U+3130..U+318F block, and these characters are mapped to legacy + character sets, and traditional Japanese layout matters for them. + 2) glibc does the same thing, see + + + */ +#include "uniwidth/width0.h" + +#include "uniwidth/width2.h" +#include "unictype/bitmap.h" + +#define SIZEOF(a) (sizeof(a) / sizeof(a[0])) + + +/* Determine number of column positions required for UC. */ +int +uc_width (ucs4_t uc, const char *encoding) +{ + /* Test for non-spacing or control character. */ + if ((uc >> 9) < SIZEOF (nonspacing_table_ind)) + { + int ind = nonspacing_table_ind[uc >> 9]; + if (ind >= 0) + if ((nonspacing_table_data[64*ind + ((uc >> 3) & 63)] >> (uc & 7)) & 1) + { + if (uc > 0 && uc < 0xa0) + return -1; + else + return 0; + } + } + else if ((uc >> 9) == (0xe0000 >> 9)) + { + if (uc >= 0xe0100) + { + if (uc <= 0xe01ef) + return 0; + } + else + { + if (uc >= 0xe0020 ? uc <= 0xe007f : uc == 0xe0001) + return 0; + } + } + /* Test for double-width character. */ + if (bitmap_lookup (&u_width2, uc)) + return 2; + /* In ancient CJK encodings, Cyrillic and most other characters are + double-width as well. */ + if (uc >= 0x00A1 && uc < 0xFF61 && uc != 0x20A9 + && is_cjk_encoding (encoding)) + return 2; + return 1; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/uniwidth/width0.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/uniwidth/width0.h new file mode 100644 index 00000000..0c1713ac --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/uniwidth/width0.h @@ -0,0 +1,486 @@ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +/* Table of non-spacing or control characters. */ +/* Generated automatically by gen-uni-tables.c for Unicode 15.0.0. */ + +/* Copyright (C) 2000-2022 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +static const unsigned char nonspacing_table_data[48*64] = { + /* 0x0000-0x01ff */ + 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, /* 0x0000-0x003f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, /* 0x0040-0x007f */ + 0xff, 0xff, 0xff, 0xff, 0x00, 0x20, 0x00, 0x00, /* 0x0080-0x00bf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00c0-0x00ff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0100-0x013f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0140-0x017f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0180-0x01bf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x01c0-0x01ff */ + /* 0x0200-0x03ff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0200-0x023f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0240-0x027f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0280-0x02bf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x02c0-0x02ff */ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x0300-0x033f */ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, /* 0x0340-0x037f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0380-0x03bf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x03c0-0x03ff */ + /* 0x0400-0x05ff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0400-0x043f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0440-0x047f */ + 0xf8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0480-0x04bf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x04c0-0x04ff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0500-0x053f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0540-0x057f */ + 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xbf, /* 0x0580-0x05bf */ + 0xb6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x05c0-0x05ff */ + /* 0x0600-0x07ff */ + 0x3f, 0x00, 0xff, 0x17, 0x00, 0x00, 0x00, 0x00, /* 0x0600-0x063f */ + 0x00, 0xf8, 0xff, 0xff, 0x00, 0x00, 0x01, 0x00, /* 0x0640-0x067f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0680-0x06bf */ + 0x00, 0x00, 0xc0, 0xbf, 0x9f, 0x3d, 0x00, 0x00, /* 0x06c0-0x06ff */ + 0x00, 0x80, 0x02, 0x00, 0x00, 0x00, 0xff, 0xff, /* 0x0700-0x073f */ + 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0740-0x077f */ + 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x01, 0x00, /* 0x0780-0x07bf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x0f, 0x20, /* 0x07c0-0x07ff */ + /* 0x0800-0x09ff */ + 0x00, 0x00, 0xc0, 0xfb, 0xef, 0x3e, 0x00, 0x00, /* 0x0800-0x083f */ + 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, /* 0x0840-0x087f */ + 0x00, 0x00, 0x03, 0xff, 0x00, 0x00, 0x00, 0x00, /* 0x0880-0x08bf */ + 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x08c0-0x08ff */ + 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, /* 0x0900-0x093f */ + 0xfe, 0x21, 0xfe, 0x00, 0x0c, 0x00, 0x00, 0x00, /* 0x0940-0x097f */ + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, /* 0x0980-0x09bf */ + 0x1e, 0x20, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x40, /* 0x09c0-0x09ff */ + /* 0x0a00-0x0bff */ + 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, /* 0x0a00-0x0a3f */ + 0x86, 0x39, 0x02, 0x00, 0x00, 0x00, 0x23, 0x00, /* 0x0a40-0x0a7f */ + 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, /* 0x0a80-0x0abf */ + 0xbe, 0x21, 0x00, 0x00, 0x0c, 0x00, 0x00, 0xfc, /* 0x0ac0-0x0aff */ + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, /* 0x0b00-0x0b3f */ + 0x1e, 0x20, 0x60, 0x00, 0x0c, 0x00, 0x00, 0x00, /* 0x0b40-0x0b7f */ + 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0b80-0x0bbf */ + 0x01, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0bc0-0x0bff */ + /* 0x0c00-0x0dff */ + 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd0, /* 0x0c00-0x0c3f */ + 0xc1, 0x3d, 0x60, 0x00, 0x0c, 0x00, 0x00, 0x00, /* 0x0c40-0x0c7f */ + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, /* 0x0c80-0x0cbf */ + 0x00, 0x30, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, /* 0x0cc0-0x0cff */ + 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, /* 0x0d00-0x0d3f */ + 0x1e, 0x20, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, /* 0x0d40-0x0d7f */ + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0d80-0x0dbf */ + 0x00, 0x04, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0dc0-0x0dff */ + /* 0x0e00-0x0fff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2, 0x07, /* 0x0e00-0x0e3f */ + 0x80, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0e40-0x0e7f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2, 0x1f, /* 0x0e80-0x0ebf */ + 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0ec0-0x0eff */ + 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0xa0, 0x02, /* 0x0f00-0x0f3f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x7f, /* 0x0f40-0x0f7f */ + 0xdf, 0xe0, 0xff, 0xfe, 0xff, 0xff, 0xff, 0x1f, /* 0x0f80-0x0fbf */ + 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0fc0-0x0fff */ + /* 0x1000-0x11ff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xfd, 0x66, /* 0x1000-0x103f */ + 0x00, 0x00, 0x00, 0xc3, 0x01, 0x00, 0x1e, 0x00, /* 0x1040-0x107f */ + 0x64, 0x20, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, /* 0x1080-0x10bf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10c0-0x10ff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1100-0x113f */ + 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, /* 0x1140-0x117f */ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x1180-0x11bf */ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x11c0-0x11ff */ + /* 0x1200-0x13ff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1200-0x123f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1240-0x127f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1280-0x12bf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x12c0-0x12ff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1300-0x133f */ + 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, /* 0x1340-0x137f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1380-0x13bf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x13c0-0x13ff */ + /* 0x1600-0x17ff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1600-0x163f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1640-0x167f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1680-0x16bf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16c0-0x16ff */ + 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x0c, 0x00, /* 0x1700-0x173f */ + 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x0c, 0x00, /* 0x1740-0x177f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb0, 0x3f, /* 0x1780-0x17bf */ + 0x40, 0xfe, 0x0f, 0x20, 0x00, 0x00, 0x00, 0x00, /* 0x17c0-0x17ff */ + /* 0x1800-0x19ff */ + 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1800-0x183f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1840-0x187f */ + 0x60, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, /* 0x1880-0x18bf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18c0-0x18ff */ + 0x00, 0x00, 0x00, 0x00, 0x87, 0x01, 0x04, 0x0e, /* 0x1900-0x193f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1940-0x197f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1980-0x19bf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x19c0-0x19ff */ + /* 0x1a00-0x1bff */ + 0x00, 0x00, 0x80, 0x09, 0x00, 0x00, 0x00, 0x00, /* 0x1a00-0x1a3f */ + 0x00, 0x00, 0x40, 0x7f, 0xe5, 0x1f, 0xf8, 0x9f, /* 0x1a40-0x1a7f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, /* 0x1a80-0x1abf */ + 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1ac0-0x1aff */ + 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd0, 0x17, /* 0x1b00-0x1b3f */ + 0x04, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x0f, 0x00, /* 0x1b40-0x1b7f */ + 0x03, 0x00, 0x00, 0x00, 0x3c, 0x3b, 0x00, 0x00, /* 0x1b80-0x1bbf */ + 0x00, 0x00, 0x00, 0x00, 0x40, 0xa3, 0x03, 0x00, /* 0x1bc0-0x1bff */ + /* 0x1c00-0x1dff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xcf, 0x00, /* 0x1c00-0x1c3f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1c40-0x1c7f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1c80-0x1cbf */ + 0x00, 0x00, 0xf7, 0xff, 0xfd, 0x21, 0x10, 0x03, /* 0x1cc0-0x1cff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d00-0x1d3f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d40-0x1d7f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d80-0x1dbf */ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x1dc0-0x1dff */ + /* 0x2000-0x21ff */ + 0x00, 0xf8, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, /* 0x2000-0x203f */ + 0x00, 0x00, 0x00, 0x00, 0xdf, 0xff, 0x00, 0x00, /* 0x2040-0x207f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2080-0x20bf */ + 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, /* 0x20c0-0x20ff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2100-0x213f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2140-0x217f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2180-0x21bf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x21c0-0x21ff */ + /* 0x2c00-0x2dff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2c00-0x2c3f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2c40-0x2c7f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2c80-0x2cbf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x03, 0x00, /* 0x2cc0-0x2cff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2d00-0x2d3f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, /* 0x2d40-0x2d7f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2d80-0x2dbf */ + 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, /* 0x2dc0-0x2dff */ + /* 0x3000-0x31ff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, /* 0x3000-0x303f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x3040-0x307f */ + 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, /* 0x3080-0x30bf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30c0-0x30ff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x3100-0x313f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x3140-0x317f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x3180-0x31bf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x31c0-0x31ff */ + /* 0xa600-0xa7ff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa600-0xa63f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xf7, 0x3f, /* 0xa640-0xa67f */ + 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, /* 0xa680-0xa6bf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, /* 0xa6c0-0xa6ff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa700-0xa73f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa740-0xa77f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa780-0xa7bf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa7c0-0xa7ff */ + /* 0xa800-0xa9ff */ + 0x44, 0x08, 0x00, 0x00, 0x60, 0x10, 0x00, 0x00, /* 0xa800-0xa83f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa840-0xa87f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa880-0xa8bf */ + 0x30, 0x00, 0x00, 0x00, 0xff, 0xff, 0x03, 0x80, /* 0xa8c0-0xa8ff */ + 0x00, 0x00, 0x00, 0x00, 0xc0, 0x3f, 0x00, 0x00, /* 0xa900-0xa93f */ + 0x80, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa940-0xa97f */ + 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc8, 0x33, /* 0xa980-0xa9bf */ + 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, /* 0xa9c0-0xa9ff */ + /* 0xaa00-0xabff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x66, 0x00, /* 0xaa00-0xaa3f */ + 0x08, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, /* 0xaa40-0xaa7f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9d, 0xc1, /* 0xaa80-0xaabf */ + 0x02, 0x00, 0x00, 0x00, 0x00, 0x30, 0x40, 0x00, /* 0xaac0-0xaaff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xab00-0xab3f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xab40-0xab7f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xab80-0xabbf */ + 0x00, 0x00, 0x00, 0x00, 0x20, 0x21, 0x00, 0x00, /* 0xabc0-0xabff */ + /* 0xd600-0xd7ff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd600-0xd63f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd640-0xd67f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd680-0xd6bf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd6c0-0xd6ff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd700-0xd73f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd740-0xd77f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, /* 0xd780-0xd7bf */ + 0x7f, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, /* 0xd7c0-0xd7ff */ + /* 0xfa00-0xfbff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfa00-0xfa3f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfa40-0xfa7f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfa80-0xfabf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfac0-0xfaff */ + 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, /* 0xfb00-0xfb3f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfb40-0xfb7f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfb80-0xfbbf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfbc0-0xfbff */ + /* 0xfe00-0xffff */ + 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, /* 0xfe00-0xfe3f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfe40-0xfe7f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfe80-0xfebf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, /* 0xfec0-0xfeff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xff00-0xff3f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xff40-0xff7f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xff80-0xffbf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, /* 0xffc0-0xffff */ + /* 0x10000-0x101ff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10000-0x1003f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10040-0x1007f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10080-0x100bf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x100c0-0x100ff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10100-0x1013f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10140-0x1017f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10180-0x101bf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, /* 0x101c0-0x101ff */ + /* 0x10200-0x103ff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10200-0x1023f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10240-0x1027f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10280-0x102bf */ + 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, /* 0x102c0-0x102ff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10300-0x1033f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x07, /* 0x10340-0x1037f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10380-0x103bf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x103c0-0x103ff */ + /* 0x10a00-0x10bff */ + 0x6e, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x87, /* 0x10a00-0x10a3f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10a40-0x10a7f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10a80-0x10abf */ + 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, /* 0x10ac0-0x10aff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10b00-0x10b3f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10b40-0x10b7f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10b80-0x10bbf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10bc0-0x10bff */ + /* 0x10c00-0x10dff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10c00-0x10c3f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10c40-0x10c7f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10c80-0x10cbf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10cc0-0x10cff */ + 0x00, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, /* 0x10d00-0x10d3f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10d40-0x10d7f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10d80-0x10dbf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10dc0-0x10dff */ + /* 0x10e00-0x10fff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10e00-0x10e3f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10e40-0x10e7f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, /* 0x10e80-0x10ebf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, /* 0x10ec0-0x10eff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10f00-0x10f3f */ + 0xc0, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10f40-0x10f7f */ + 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10f80-0x10fbf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10fc0-0x10fff */ + /* 0x11000-0x111ff */ + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, /* 0x11000-0x1103f */ + 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x19, 0x80, /* 0x11040-0x1107f */ + 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x26, /* 0x11080-0x110bf */ + 0x04, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x110c0-0x110ff */ + 0x07, 0x00, 0x00, 0x00, 0x80, 0xef, 0x1f, 0x00, /* 0x11100-0x1113f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, /* 0x11140-0x1117f */ + 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x7f, /* 0x11180-0x111bf */ + 0x00, 0x9e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x111c0-0x111ff */ + /* 0x11200-0x113ff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xd3, 0x40, /* 0x11200-0x1123f */ + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11240-0x1127f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11280-0x112bf */ + 0x00, 0x00, 0x00, 0x80, 0xf8, 0x07, 0x00, 0x00, /* 0x112c0-0x112ff */ + 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, /* 0x11300-0x1133f */ + 0x01, 0x00, 0x00, 0x00, 0xc0, 0x1f, 0x1f, 0x00, /* 0x11340-0x1137f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11380-0x113bf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x113c0-0x113ff */ + /* 0x11400-0x115ff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, /* 0x11400-0x1143f */ + 0x5c, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, /* 0x11440-0x1147f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x85, /* 0x11480-0x114bf */ + 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x114c0-0x114ff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11500-0x1153f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11540-0x1157f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0xb0, /* 0x11580-0x115bf */ + 0x01, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, /* 0x115c0-0x115ff */ + /* 0x11600-0x117ff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xa7, /* 0x11600-0x1163f */ + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11640-0x1167f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0xbf, 0x00, /* 0x11680-0x116bf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x116c0-0x116ff */ + 0x00, 0x00, 0x00, 0xe0, 0xbc, 0x0f, 0x00, 0x00, /* 0x11700-0x1173f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11740-0x1177f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11780-0x117bf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x117c0-0x117ff */ + /* 0x11800-0x119ff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0x06, /* 0x11800-0x1183f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11840-0x1187f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11880-0x118bf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x118c0-0x118ff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x58, /* 0x11900-0x1193f */ + 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11940-0x1197f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11980-0x119bf */ + 0x00, 0x00, 0xf0, 0x0c, 0x01, 0x00, 0x00, 0x00, /* 0x119c0-0x119ff */ + /* 0x11a00-0x11bff */ + 0x7e, 0x06, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x79, /* 0x11a00-0x11a3f */ + 0x80, 0x00, 0x7e, 0x0e, 0x00, 0x00, 0x00, 0x00, /* 0x11a40-0x11a7f */ + 0x00, 0xfc, 0x7f, 0x03, 0x00, 0x00, 0x00, 0x00, /* 0x11a80-0x11abf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11ac0-0x11aff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11b00-0x11b3f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11b40-0x11b7f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11b80-0x11bbf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11bc0-0x11bff */ + /* 0x11c00-0x11dff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x3f, /* 0x11c00-0x11c3f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11c40-0x11c7f */ + 0x00, 0x00, 0xfc, 0xff, 0xff, 0xfc, 0x6d, 0x00, /* 0x11c80-0x11cbf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11cc0-0x11cff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0xb4, /* 0x11d00-0x11d3f */ + 0xbf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11d40-0x11d7f */ + 0x00, 0x00, 0xa3, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11d80-0x11dbf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11dc0-0x11dff */ + /* 0x11e00-0x11fff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11e00-0x11e3f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11e40-0x11e7f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11e80-0x11ebf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, /* 0x11ec0-0x11eff */ + 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x07, /* 0x11f00-0x11f3f */ + 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11f40-0x11f7f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11f80-0x11fbf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11fc0-0x11fff */ + /* 0x13400-0x135ff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, /* 0x13400-0x1343f */ + 0x81, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x13440-0x1347f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x13480-0x134bf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x134c0-0x134ff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x13500-0x1353f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x13540-0x1357f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x13580-0x135bf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x135c0-0x135ff */ + /* 0x16a00-0x16bff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16a00-0x16a3f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16a40-0x16a7f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16a80-0x16abf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, /* 0x16ac0-0x16aff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x00, /* 0x16b00-0x16b3f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16b40-0x16b7f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16b80-0x16bbf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16bc0-0x16bff */ + /* 0x16e00-0x16fff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16e00-0x16e3f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16e40-0x16e7f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16e80-0x16ebf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16ec0-0x16eff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16f00-0x16f3f */ + 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16f40-0x16f7f */ + 0x00, 0x80, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16f80-0x16fbf */ + 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, /* 0x16fc0-0x16fff */ + /* 0x1bc00-0x1bdff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1bc00-0x1bc3f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1bc40-0x1bc7f */ + 0x00, 0x00, 0x00, 0x60, 0x0f, 0x00, 0x00, 0x00, /* 0x1bc80-0x1bcbf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1bcc0-0x1bcff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1bd00-0x1bd3f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1bd40-0x1bd7f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1bd80-0x1bdbf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1bdc0-0x1bdff */ + /* 0x1ce00-0x1cfff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1ce00-0x1ce3f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1ce40-0x1ce7f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1ce80-0x1cebf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1cec0-0x1ceff */ + 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, /* 0x1cf00-0x1cf3f */ + 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1cf40-0x1cf7f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1cf80-0x1cfbf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1cfc0-0x1cfff */ + /* 0x1d000-0x1d1ff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d000-0x1d03f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d040-0x1d07f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d080-0x1d0bf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d0c0-0x1d0ff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d100-0x1d13f */ + 0x00, 0x00, 0x00, 0x00, 0x80, 0x03, 0xf8, 0xff, /* 0x1d140-0x1d17f */ + 0xe7, 0x0f, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, /* 0x1d180-0x1d1bf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d1c0-0x1d1ff */ + /* 0x1d200-0x1d3ff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d200-0x1d23f */ + 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d240-0x1d27f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d280-0x1d2bf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d2c0-0x1d2ff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d300-0x1d33f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d340-0x1d37f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d380-0x1d3bf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d3c0-0x1d3ff */ + /* 0x1da00-0x1dbff */ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xf8, /* 0x1da00-0x1da3f */ + 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x20, 0x00, /* 0x1da40-0x1da7f */ + 0x10, 0x00, 0x00, 0xf8, 0xfe, 0xff, 0x00, 0x00, /* 0x1da80-0x1dabf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1dac0-0x1daff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1db00-0x1db3f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1db40-0x1db7f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1db80-0x1dbbf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1dbc0-0x1dbff */ + /* 0x1e000-0x1e1ff */ + 0x7f, 0xff, 0xff, 0xf9, 0xdb, 0x07, 0x00, 0x00, /* 0x1e000-0x1e03f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e040-0x1e07f */ + 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e080-0x1e0bf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e0c0-0x1e0ff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x00, /* 0x1e100-0x1e13f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e140-0x1e17f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e180-0x1e1bf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e1c0-0x1e1ff */ + /* 0x1e200-0x1e3ff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e200-0x1e23f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e240-0x1e27f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, /* 0x1e280-0x1e2bf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, /* 0x1e2c0-0x1e2ff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e300-0x1e33f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e340-0x1e37f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e380-0x1e3bf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e3c0-0x1e3ff */ + /* 0x1e400-0x1e5ff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e400-0x1e43f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e440-0x1e47f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e480-0x1e4bf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, /* 0x1e4c0-0x1e4ff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e500-0x1e53f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e540-0x1e57f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e580-0x1e5bf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e5c0-0x1e5ff */ + /* 0x1e800-0x1e9ff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e800-0x1e83f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e840-0x1e87f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e880-0x1e8bf */ + 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e8c0-0x1e8ff */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e900-0x1e93f */ + 0xf0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e940-0x1e97f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e980-0x1e9bf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 /* 0x1e9c0-0x1e9ff */ +}; +static const signed char nonspacing_table_ind[248] = { + 0, 1, 2, 3, 4, 5, 6, 7, /* 0x0000-0x0fff */ + 8, 9, -1, 10, 11, 12, 13, -1, /* 0x1000-0x1fff */ + 14, -1, -1, -1, -1, -1, 15, -1, /* 0x2000-0x2fff */ + 16, -1, -1, -1, -1, -1, -1, -1, /* 0x3000-0x3fff */ + -1, -1, -1, -1, -1, -1, -1, -1, /* 0x4000-0x4fff */ + -1, -1, -1, -1, -1, -1, -1, -1, /* 0x5000-0x5fff */ + -1, -1, -1, -1, -1, -1, -1, -1, /* 0x6000-0x6fff */ + -1, -1, -1, -1, -1, -1, -1, -1, /* 0x7000-0x7fff */ + -1, -1, -1, -1, -1, -1, -1, -1, /* 0x8000-0x8fff */ + -1, -1, -1, -1, -1, -1, -1, -1, /* 0x9000-0x9fff */ + -1, -1, -1, 17, 18, 19, -1, -1, /* 0xa000-0xafff */ + -1, -1, -1, -1, -1, -1, -1, -1, /* 0xb000-0xbfff */ + -1, -1, -1, -1, -1, -1, -1, -1, /* 0xc000-0xcfff */ + -1, -1, -1, 20, -1, -1, -1, -1, /* 0xd000-0xdfff */ + -1, -1, -1, -1, -1, -1, -1, -1, /* 0xe000-0xefff */ + -1, -1, -1, -1, -1, 21, -1, 22, /* 0xf000-0xffff */ + 23, 24, -1, -1, -1, 25, 26, 27, /* 0x10000-0x10fff */ + 28, 29, 30, 31, 32, 33, 34, 35, /* 0x11000-0x11fff */ + -1, -1, -1, -1, -1, -1, -1, -1, /* 0x12000-0x12fff */ + -1, -1, 36, -1, -1, -1, -1, -1, /* 0x13000-0x13fff */ + -1, -1, -1, -1, -1, -1, -1, -1, /* 0x14000-0x14fff */ + -1, -1, -1, -1, -1, -1, -1, -1, /* 0x15000-0x15fff */ + -1, -1, -1, -1, -1, 37, -1, 38, /* 0x16000-0x16fff */ + -1, -1, -1, -1, -1, -1, -1, -1, /* 0x17000-0x17fff */ + -1, -1, -1, -1, -1, -1, -1, -1, /* 0x18000-0x18fff */ + -1, -1, -1, -1, -1, -1, -1, -1, /* 0x19000-0x19fff */ + -1, -1, -1, -1, -1, -1, -1, -1, /* 0x1a000-0x1afff */ + -1, -1, -1, -1, -1, -1, 39, -1, /* 0x1b000-0x1bfff */ + -1, -1, -1, -1, -1, -1, -1, 40, /* 0x1c000-0x1cfff */ + 41, 42, -1, -1, -1, 43, -1, -1, /* 0x1d000-0x1dfff */ + 44, 45, 46, -1, 47, -1, -1, -1 /* 0x1e000-0x1efff */ +}; diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/uniwidth/width2.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/uniwidth/width2.h new file mode 100644 index 00000000..19c8c02a --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/uniwidth/width2.h @@ -0,0 +1,541 @@ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +/* Width 2 property of Unicode characters. */ +/* Generated automatically by gen-uni-tables.c for Unicode 15.0.0. */ + +/* Copyright (C) 2000-2022 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#define header_0 16 +#define header_2 9 +#define header_3 127 +#define header_4 15 +static const +struct + { + int header[1]; + int level1[4]; + short level2[3 << 7]; + unsigned int level3[28 << 4]; + } +u_width2 = +{ + { 4 }, + { + 5 * sizeof (int) / sizeof (short) + 0, + 5 * sizeof (int) / sizeof (short) + 128, + 5 * sizeof (int) / sizeof (short) + 256, + 5 * sizeof (int) / sizeof (short) + 256 + }, + { + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 5 + 384 * sizeof (short) / sizeof (int) + 0, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 5 + 384 * sizeof (short) / sizeof (int) + 16, + 5 + 384 * sizeof (short) / sizeof (int) + 32, + 5 + 384 * sizeof (short) / sizeof (int) + 48, + -1, + 5 + 384 * sizeof (short) / sizeof (int) + 64, + -1, + 5 + 384 * sizeof (short) / sizeof (int) + 80, + 5 + 384 * sizeof (short) / sizeof (int) + 96, + 5 + 384 * sizeof (short) / sizeof (int) + 112, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 144, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 160, + -1, + 5 + 384 * sizeof (short) / sizeof (int) + 176, + -1, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 192, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 5 + 384 * sizeof (short) / sizeof (int) + 208, + 5 + 384 * sizeof (short) / sizeof (int) + 224, + -1, + 5 + 384 * sizeof (short) / sizeof (int) + 240, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 5 + 384 * sizeof (short) / sizeof (int) + 256, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 272, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 288, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 5 + 384 * sizeof (short) / sizeof (int) + 304, + 5 + 384 * sizeof (short) / sizeof (int) + 320, + 5 + 384 * sizeof (short) / sizeof (int) + 336, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 5 + 384 * sizeof (short) / sizeof (int) + 352, + 5 + 384 * sizeof (short) / sizeof (int) + 368, + 5 + 384 * sizeof (short) / sizeof (int) + 384, + 5 + 384 * sizeof (short) / sizeof (int) + 400, + 5 + 384 * sizeof (short) / sizeof (int) + 416, + 5 + 384 * sizeof (short) / sizeof (int) + 432, + -1, + -1, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128, + 5 + 384 * sizeof (short) / sizeof (int) + 128 + }, + { + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x0C000000U, 0x00000600U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00091E00U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x60000000U, + 0x00300000U, 0x00000000U, 0x000FFF00U, 0x80000000U, + 0x00080000U, 0x60000C02U, 0x00104030U, 0x242C0400U, + 0x00000C20U, 0x00000100U, 0x00B85000U, 0x00000000U, + 0x00E00000U, 0x80010000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x18000000U, 0x00000000U, 0x00210000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0x7FFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFF00FFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0000FFFFU, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x1FFFFFFFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0x0000000FU, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFF0000U, 0xFFFF0000U, 0xFFFFFFFFU, 0x0000FFFFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x00000001U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x0000007FU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x0003000FU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x00FFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x003FFFFFU, 0x00000000U, + 0x000001FFU, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x6FEF0000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0x00000007U, 0x00070000U, 0xFFFF00F0U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0FFFFFFFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000010U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00008000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x07FE4000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFBFE001U, 0xFFFFFFFFU, 0xDFFFFFFFU, + 0x000FFFFFU, 0xFFFFFFFFU, 0x000F87FFU, 0xFF11FFFFU, + 0xFFFFFFFFU, 0x7FFFFFFFU, 0xFFFFFFFDU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x9FFFFFFFU, + 0xFFFFFFFFU, 0x3FFFFFFFU, 0xFFFF7800U, 0x040000FFU, + 0x00600000U, 0x00000010U, 0x00000000U, 0xF8000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0000FFFFU, 0x00000000U, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xE0E7103FU, 0x1FF01800U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00010FFFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0xFFFFF000U, 0xF7FFFFFFU, 0xFFFFFFBFU, 0xFFFFFFFFU, + 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x1F1F0000U, + 0xFFFF007FU, 0x07FF1FFFU, 0x03FF003FU, 0x007F00FFU, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, + 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U + } +}; diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unlocked-io.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unlocked-io.h new file mode 100644 index 00000000..0cd9bbf3 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unlocked-io.h @@ -0,0 +1,141 @@ +/* Prefer faster, non-thread-safe stdio functions if available. + + Copyright (C) 2001-2004, 2009-2024 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 . */ + +/* Written by Jim Meyering. */ + +#ifndef UNLOCKED_IO_H +# define UNLOCKED_IO_H 1 + +/* These are wrappers for functions/macros from the GNU C library, and + from other C libraries supporting POSIX's optional thread-safe functions. + + The standard I/O functions are thread-safe. These *_unlocked ones are + more efficient but not thread-safe. That they're not thread-safe is + fine since all of the applications in this package are single threaded. + + Also, some code that is shared with the GNU C library may invoke + the *_unlocked functions directly. On hosts that lack those + functions, invoke the non-thread-safe versions instead. */ + +/* This file uses HAVE_DECL_*_UNLOCKED. */ +# if !_GL_CONFIG_H_INCLUDED +# error "Please include config.h first." +# endif + +# include + +# if HAVE_DECL_CLEARERR_UNLOCKED || defined clearerr_unlocked +# undef clearerr +# define clearerr(x) clearerr_unlocked (x) +# else +# define clearerr_unlocked(x) clearerr (x) +# endif + +# if HAVE_DECL_FEOF_UNLOCKED || defined feof_unlocked +# undef feof +# define feof(x) feof_unlocked (x) +# else +# define feof_unlocked(x) feof (x) +# endif + +# if HAVE_DECL_FERROR_UNLOCKED || defined ferror_unlocked +# undef ferror +# define ferror(x) ferror_unlocked (x) +# else +# define ferror_unlocked(x) ferror (x) +# endif + +# if HAVE_DECL_FFLUSH_UNLOCKED || defined fflush_unlocked +# undef fflush +# define fflush(x) fflush_unlocked (x) +# else +# define fflush_unlocked(x) fflush (x) +# endif + +# if HAVE_DECL_FGETS_UNLOCKED || defined fgets_unlocked +# undef fgets +# define fgets(x,y,z) fgets_unlocked (x,y,z) +# else +# define fgets_unlocked(x,y,z) fgets (x,y,z) +# endif + +# if HAVE_DECL_FPUTC_UNLOCKED || defined fputc_unlocked +# undef fputc +# define fputc(x,y) fputc_unlocked (x,y) +# else +# define fputc_unlocked(x,y) fputc (x,y) +# endif + +# if HAVE_DECL_FPUTS_UNLOCKED || defined fputs_unlocked +# undef fputs +# define fputs(x,y) fputs_unlocked (x,y) +# else +# define fputs_unlocked(x,y) fputs (x,y) +# endif + +# if HAVE_DECL_FREAD_UNLOCKED || defined fread_unlocked +# undef fread +# define fread(w,x,y,z) fread_unlocked (w,x,y,z) +# else +# define fread_unlocked(w,x,y,z) fread (w,x,y,z) +# endif + +# if HAVE_DECL_FWRITE_UNLOCKED || defined fwrite_unlocked +# undef fwrite +# define fwrite(w,x,y,z) fwrite_unlocked (w,x,y,z) +# else +# define fwrite_unlocked(w,x,y,z) fwrite (w,x,y,z) +# endif + +# if HAVE_DECL_GETC_UNLOCKED || defined getc_unlocked +# undef getc +# define getc(x) getc_unlocked (x) +# else +# define getc_unlocked(x) getc (x) +# endif + +# if HAVE_DECL_GETCHAR_UNLOCKED || defined getchar_unlocked +# undef getchar +# define getchar() getchar_unlocked () +# else +# define getchar_unlocked() getchar () +# endif + +# if HAVE_DECL_PUTC_UNLOCKED || defined putc_unlocked +# undef putc +# define putc(x,y) putc_unlocked (x,y) +# else +# define putc_unlocked(x,y) putc (x,y) +# endif + +# if HAVE_DECL_PUTCHAR_UNLOCKED || defined putchar_unlocked +# undef putchar +# define putchar(x) putchar_unlocked (x) +# else +# define putchar_unlocked(x) putchar (x) +# endif + +# undef flockfile +# define flockfile(x) ((void) 0) + +# undef ftrylockfile +# define ftrylockfile(x) 0 + +# undef funlockfile +# define funlockfile(x) ((void) 0) + +#endif /* UNLOCKED_IO_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unsetenv.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unsetenv.c new file mode 100644 index 00000000..d8ada2aa --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/unsetenv.c @@ -0,0 +1,127 @@ +/* Copyright (C) 1992, 1995-2002, 2005-2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc + optimizes away the name == NULL test below. */ +#define _GL_ARG_NONNULL(params) + +#include + +/* Specification. */ +#include + +#include +#if !_LIBC +# define __set_errno(ev) ((errno) = (ev)) +#endif + +#include +#include + +#if !_LIBC +# define __environ environ +#endif + +#if _LIBC +/* This lock protects against simultaneous modifications of 'environ'. */ +# include +__libc_lock_define_initialized (static, envlock) +# define LOCK __libc_lock_lock (envlock) +# define UNLOCK __libc_lock_unlock (envlock) +#else +# define LOCK +# define UNLOCK +#endif + +/* In the GNU C library we must keep the namespace clean. */ +#ifdef _LIBC +# define unsetenv __unsetenv +#endif + +#if _LIBC || !HAVE_UNSETENV + +int +unsetenv (const char *name) +{ + size_t len; + char **ep; + + if (name == NULL || *name == '\0' || strchr (name, '=') != NULL) + { + __set_errno (EINVAL); + return -1; + } + + len = strlen (name); + + LOCK; + + ep = __environ; + while (*ep != NULL) + if (!strncmp (*ep, name, len) && (*ep)[len] == '=') + { + /* Found it. Remove this pointer by moving later ones back. */ + char **dp = ep; + + do + dp[0] = dp[1]; + while (*dp++); + /* Continue the loop in case NAME appears again. */ + } + else + ++ep; + + UNLOCK; + + return 0; +} + +#ifdef _LIBC +# undef unsetenv +weak_alias (__unsetenv, unsetenv) +#endif + +#else /* HAVE_UNSETENV */ + +# undef unsetenv +# if !HAVE_DECL_UNSETENV +# if VOID_UNSETENV +extern void unsetenv (const char *); +# else +extern int unsetenv (const char *); +# endif +# endif + +/* Call the underlying unsetenv, in case there is hidden bookkeeping + that needs updating beyond just modifying environ. */ +int +rpl_unsetenv (const char *name) +{ + int result = 0; + if (!name || !*name || strchr (name, '=')) + { + errno = EINVAL; + return -1; + } + while (getenv (name)) +# if !VOID_UNSETENV + result = +# endif + unsetenv (name); + return result; +} + +#endif /* HAVE_UNSETENV */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/verify.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/verify.h new file mode 100644 index 00000000..08268c24 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/verify.h @@ -0,0 +1,375 @@ +/* Compile-time assert-like macros. + + Copyright (C) 2005-2006, 2009-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Paul Eggert, Bruno Haible, and Jim Meyering. */ + +#ifndef _GL_VERIFY_H +#define _GL_VERIFY_H + + +/* Define _GL_HAVE__STATIC_ASSERT to 1 if _Static_assert (R, DIAGNOSTIC) + works as per C11. This is supported by GCC 4.6.0+ and by clang 4+. + + Define _GL_HAVE__STATIC_ASSERT1 to 1 if _Static_assert (R) works as + per C23. This is supported by GCC 9.1+. + + Support compilers claiming conformance to the relevant standard, + and also support GCC when not pedantic. If we were willing to slow + 'configure' down we could also use it with other compilers, but + since this affects only the quality of diagnostics, why bother? */ +#ifndef __cplusplus +# if (201112 <= __STDC_VERSION__ \ + || (!defined __STRICT_ANSI__ \ + && (4 < __GNUC__ + (6 <= __GNUC_MINOR__) || 5 <= __clang_major__))) +# define _GL_HAVE__STATIC_ASSERT 1 +# endif +# if (202311 <= __STDC_VERSION__ \ + || (!defined __STRICT_ANSI__ && 9 <= __GNUC__)) +# define _GL_HAVE__STATIC_ASSERT1 1 +# endif +#endif + +/* FreeBSD 9.1 , included by and lots of other + system headers, defines a conflicting _Static_assert that is no + better than ours; override it. */ +#ifndef _GL_HAVE__STATIC_ASSERT +# include +# undef _Static_assert +#endif + +/* Each of these macros verifies that its argument R is nonzero. To + be portable, R should be an integer constant expression. Unlike + assert (R), there is no run-time overhead. + + If _Static_assert works, verify (R) uses it directly. Similarly, + _GL_VERIFY_TRUE works by packaging a _Static_assert inside a struct + that is an operand of sizeof. + + The code below uses several ideas for C++ compilers, and for C + compilers that do not support _Static_assert: + + * The first step is ((R) ? 1 : -1). Given an expression R, of + integral or boolean or floating-point type, this yields an + expression of integral type, whose value is later verified to be + constant and nonnegative. + + * Next this expression W is wrapped in a type + struct _gl_verify_type { + unsigned int _gl_verify_error_if_negative: W; + }. + If W is negative, this yields a compile-time error. No compiler can + deal with a bit-field of negative size. + + One might think that an array size check would have the same + effect, that is, that the type struct { unsigned int dummy[W]; } + would work as well. However, inside a function, some compilers + (such as C++ compilers and GNU C) allow local parameters and + variables inside array size expressions. With these compilers, + an array size check would not properly diagnose this misuse of + the verify macro: + + void function (int n) { verify (n < 0); } + + * For the verify macro, the struct _gl_verify_type will need to + somehow be embedded into a declaration. To be portable, this + declaration must declare an object, a constant, a function, or a + typedef name. If the declared entity uses the type directly, + such as in + + struct dummy {...}; + typedef struct {...} dummy; + extern struct {...} *dummy; + extern void dummy (struct {...} *); + extern struct {...} *dummy (void); + + two uses of the verify macro would yield colliding declarations + if the entity names are not disambiguated. A workaround is to + attach the current line number to the entity name: + + #define _GL_CONCAT0(x, y) x##y + #define _GL_CONCAT(x, y) _GL_CONCAT0 (x, y) + extern struct {...} * _GL_CONCAT (dummy, __LINE__); + + But this has the problem that two invocations of verify from + within the same macro would collide, since the __LINE__ value + would be the same for both invocations. (The GCC __COUNTER__ + macro solves this problem, but is not portable.) + + A solution is to use the sizeof operator. It yields a number, + getting rid of the identity of the type. Declarations like + + extern int dummy [sizeof (struct {...})]; + extern void dummy (int [sizeof (struct {...})]); + extern int (*dummy (void)) [sizeof (struct {...})]; + + can be repeated. + + * Should the implementation use a named struct or an unnamed struct? + Which of the following alternatives can be used? + + extern int dummy [sizeof (struct {...})]; + extern int dummy [sizeof (struct _gl_verify_type {...})]; + extern void dummy (int [sizeof (struct {...})]); + extern void dummy (int [sizeof (struct _gl_verify_type {...})]); + extern int (*dummy (void)) [sizeof (struct {...})]; + extern int (*dummy (void)) [sizeof (struct _gl_verify_type {...})]; + + In the second and sixth case, the struct type is exported to the + outer scope; two such declarations therefore collide. GCC warns + about the first, third, and fourth cases. So the only remaining + possibility is the fifth case: + + extern int (*dummy (void)) [sizeof (struct {...})]; + + * GCC warns about duplicate declarations of the dummy function if + -Wredundant-decls is used. GCC 4.3 and later have a builtin + __COUNTER__ macro that can let us generate unique identifiers for + each dummy function, to suppress this warning. + + * This implementation exploits the fact that older versions of GCC, + which do not support _Static_assert, also do not warn about the + last declaration mentioned above. + + * GCC warns if -Wnested-externs is enabled and 'verify' is used + within a function body; but inside a function, you can always + arrange to use verify_expr instead. + + * In C++, any struct definition inside sizeof is invalid. + Use a template type to work around the problem. */ + +/* Concatenate two preprocessor tokens. */ +#define _GL_CONCAT(x, y) _GL_CONCAT0 (x, y) +#define _GL_CONCAT0(x, y) x##y + +/* _GL_COUNTER is an integer, preferably one that changes each time we + use it. Use __COUNTER__ if it works, falling back on __LINE__ + otherwise. __LINE__ isn't perfect, but it's better than a + constant. */ +#if defined __COUNTER__ && __COUNTER__ != __COUNTER__ +# define _GL_COUNTER __COUNTER__ +#else +# define _GL_COUNTER __LINE__ +#endif + +/* Generate a symbol with the given prefix, making it unique if + possible. */ +#define _GL_GENSYM(prefix) _GL_CONCAT (prefix, _GL_COUNTER) + +/* Verify requirement R at compile-time, as an integer constant expression + that returns 1. If R is false, fail at compile-time, preferably + with a diagnostic that includes the string-literal DIAGNOSTIC. */ + +#define _GL_VERIFY_TRUE(R, DIAGNOSTIC) \ + (!!sizeof (_GL_VERIFY_TYPE (R, DIAGNOSTIC))) + +#ifdef __cplusplus +# if !GNULIB_defined_struct__gl_verify_type +template + struct _gl_verify_type { + unsigned int _gl_verify_error_if_negative: w; + }; +# define GNULIB_defined_struct__gl_verify_type 1 +# endif +# define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \ + _gl_verify_type<(R) ? 1 : -1> +#elif defined _GL_HAVE__STATIC_ASSERT +# define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \ + struct { \ + _Static_assert (R, DIAGNOSTIC); \ + int _gl_dummy; \ + } +#else +# define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \ + struct { unsigned int _gl_verify_error_if_negative: (R) ? 1 : -1; } +#endif + +/* Verify requirement R at compile-time, as a declaration without a + trailing ';'. If R is false, fail at compile-time. + + This macro requires three or more arguments but uses at most the first + two, so that the _Static_assert macro optionally defined below supports + both the C11 two-argument syntax and the C23 one-argument syntax. + + Unfortunately, unlike C11, this implementation must appear as an + ordinary declaration, and cannot appear inside struct { ... }. */ + +#if 202311 <= __STDC_VERSION__ || 200410 <= __cpp_static_assert +# define _GL_VERIFY(R, DIAGNOSTIC, ...) static_assert (R, DIAGNOSTIC) +#elif defined _GL_HAVE__STATIC_ASSERT +# define _GL_VERIFY(R, DIAGNOSTIC, ...) _Static_assert (R, DIAGNOSTIC) +#else +# define _GL_VERIFY(R, DIAGNOSTIC, ...) \ + extern int (*_GL_GENSYM (_gl_verify_function) (void)) \ + [_GL_VERIFY_TRUE (R, DIAGNOSTIC)] +# if 4 < __GNUC__ + (6 <= __GNUC_MINOR__) +# pragma GCC diagnostic ignored "-Wnested-externs" +# endif +#endif + +/* _GL_STATIC_ASSERT_H is defined if this code is copied into assert.h. */ +#ifdef _GL_STATIC_ASSERT_H +/* Define _Static_assert if needed. */ +/* With clang ≥ 3.8.0 in C++ mode, _Static_assert already works and accepts + 1 or 2 arguments. We better don't override it, because clang's standard + C++ library uses static_assert inside classes in several places, and our + replacement via _GL_VERIFY does not work in these contexts. */ +# if (defined __cplusplus && defined __clang__ \ + && (4 <= __clang_major__ + (8 <= __clang_minor__))) +# if 5 <= __clang_major__ +/* Avoid "warning: 'static_assert' with no message is a C++17 extension". */ +# pragma clang diagnostic ignored "-Wc++17-extensions" +# else +/* Avoid "warning: static_assert with no message is a C++1z extension". */ +# pragma clang diagnostic ignored "-Wc++1z-extensions" +# endif +# elif !defined _GL_HAVE__STATIC_ASSERT1 && !defined _Static_assert +# if !defined _MSC_VER || defined __clang__ +# define _Static_assert(...) \ + _GL_VERIFY (__VA_ARGS__, "static assertion failed", -) +# else +# if defined __cplusplus && _MSC_VER >= 1910 + /* In MSVC 14.1 or newer, static_assert accepts one or two arguments, + but _Static_assert is not defined. */ +# define _Static_assert static_assert +# else + /* Work around MSVC preprocessor incompatibility with ISO C; see + . */ +# define _Static_assert(R, ...) \ + _GL_VERIFY ((R), "static assertion failed", -) +# endif +# endif +# endif +/* Define static_assert if needed. */ +# if (!defined static_assert \ + && __STDC_VERSION__ < 202311 \ + && (!defined __cplusplus \ + || (__cpp_static_assert < 201411 \ + && __GNUG__ < 6 && __clang_major__ < 6 && _MSC_VER < 1910))) +# if defined __cplusplus && _MSC_VER >= 1900 && !defined __clang__ +/* MSVC 14 in C++ mode supports the two-arguments static_assert but not + the one-argument static_assert, and it does not support _Static_assert. + We have to play preprocessor tricks to distinguish the two cases. + Since the MSVC preprocessor is not ISO C compliant (see above),. + the solution is specific to MSVC. */ +# define _GL_EXPAND(x) x +# define _GL_SA1(a1) static_assert ((a1), "static assertion failed") +# define _GL_SA2 static_assert +# define _GL_SA3 static_assert +# define _GL_SA_PICK(x1,x2,x3,x4,...) x4 +# define static_assert(...) _GL_EXPAND(_GL_SA_PICK(__VA_ARGS__,_GL_SA3,_GL_SA2,_GL_SA1)) (__VA_ARGS__) +/* Avoid "fatal error C1189: #error: The C++ Standard Library forbids macroizing keywords." */ +# define _ALLOW_KEYWORD_MACROS 1 +# else +# define static_assert _Static_assert /* C11 requires this #define. */ +# endif +# endif +#endif + +/* @assert.h omit start@ */ + +#if defined __clang_major__ && __clang_major__ < 5 +# define _GL_HAS_BUILTIN_TRAP 0 +#elif 3 < __GNUC__ + (3 < __GNUC_MINOR__ + (4 <= __GNUC_PATCHLEVEL__)) +# define _GL_HAS_BUILTIN_TRAP 1 +#elif defined __has_builtin +# define _GL_HAS_BUILTIN_TRAP __has_builtin (__builtin_trap) +#else +# define _GL_HAS_BUILTIN_TRAP 0 +#endif + +#ifndef _GL_HAS_BUILTIN_UNREACHABLE +# if defined __clang_major__ && __clang_major__ < 5 +# define _GL_HAS_BUILTIN_UNREACHABLE 0 +# elif 4 < __GNUC__ + (5 <= __GNUC_MINOR__) +# define _GL_HAS_BUILTIN_UNREACHABLE 1 +# elif defined __has_builtin +# define _GL_HAS_BUILTIN_UNREACHABLE __has_builtin (__builtin_unreachable) +# else +# define _GL_HAS_BUILTIN_UNREACHABLE 0 +# endif +#endif + +/* Each of these macros verifies that its argument R is nonzero. To + be portable, R should be an integer constant expression. Unlike + assert (R), there is no run-time overhead. + + There are two macros, since no single macro can be used in all + contexts in C. verify_expr (R, E) is for scalar contexts, including + integer constant expression contexts. verify (R) is for declaration + contexts, e.g., the top level. */ + +/* Verify requirement R at compile-time. Return the value of the + expression E. */ + +#define verify_expr(R, E) \ + (_GL_VERIFY_TRUE (R, "verify_expr (" #R ", " #E ")") ? (E) : (E)) + +/* Verify requirement R at compile-time, as a declaration without a + trailing ';'. verify (R) acts like static_assert (R) except that + it is portable to C11/C++14 and earlier, it can issue better + diagnostics, and its name is shorter and may be more convenient. */ + +#ifdef __PGI +/* PGI barfs if R is long. */ +# define verify(R) _GL_VERIFY (R, "verify (...)", -) +#else +# define verify(R) _GL_VERIFY (R, "verify (" #R ")", -) +#endif + +/* Assume that R always holds. Behavior is undefined if R is false, + fails to evaluate, or has side effects. + + 'assume (R)' is a directive from the programmer telling the + compiler that R is true so the compiler needn't generate code to + test R. This is why 'assume' is in verify.h: it's related to + static checking (in this case, static checking done by the + programmer), not dynamic checking. + + 'assume (R)' can affect compilation of all the code, not just code + that happens to be executed after the assume (R) is "executed". + For example, if the code mistakenly does 'assert (R); assume (R);' + the compiler is entitled to optimize away the 'assert (R)'. + + Although assuming R can help a compiler generate better code or + diagnostics, performance can suffer if R uses hard-to-optimize + features such as function calls not inlined by the compiler. + + Avoid Clang's __builtin_assume, as it breaks GNU Emacs master + as of 2020-08-23T21:09:49Z!eggert@cs.ucla.edu; see + . It's not known whether this breakage + is a Clang bug or an Emacs bug; play it safe for now. */ + +#if _GL_HAS_BUILTIN_UNREACHABLE +# define assume(R) ((R) ? (void) 0 : __builtin_unreachable ()) +#elif 1200 <= _MSC_VER +# define assume(R) __assume (R) +#elif 202311 <= __STDC_VERSION__ +# include +# define assume(R) ((R) ? (void) 0 : unreachable ()) +#elif (defined GCC_LINT || defined lint) && _GL_HAS_BUILTIN_TRAP + /* Doing it this way helps various packages when configured with + --enable-gcc-warnings, which compiles with -Dlint. It's nicer + if 'assume' silences warnings with GCC 3.4 through GCC 4.4.7 (2012). */ +# define assume(R) ((R) ? (void) 0 : __builtin_trap ()) +#else + /* Some older tools grok NOTREACHED, e.g., Oracle Studio 12.6 (2017). */ +# define assume(R) ((R) ? (void) 0 : /*NOTREACHED*/ (void) 0) +#endif + +/* @assert.h omit end@ */ + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/version-etc-fsf.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/version-etc-fsf.c new file mode 100644 index 00000000..894b1c3f --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/version-etc-fsf.c @@ -0,0 +1,30 @@ +/* Variable with FSF copyright information, for version-etc. + Copyright (C) 1999-2006, 2009-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Jim Meyering. */ + +#include + +/* Specification. */ +#include "version-etc.h" + +/* Default copyright goes to the FSF. */ + +const char version_etc_copyright[] = + /* Do *not* mark this string for translation. %s is a copyright + symbol suitable for this locale, and %d is the copyright + year. */ + "Copyright %s %d Free Software Foundation, Inc."; diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/version-etc.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/version-etc.c new file mode 100644 index 00000000..45d0c93c --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/version-etc.c @@ -0,0 +1,262 @@ +/* Print --version and bug-reporting information in a consistent format. + Copyright (C) 1999-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Jim Meyering. */ + +#include + +/* Specification. */ +#include "version-etc.h" + +#include +#include + +#if USE_UNLOCKED_IO +# include "unlocked-io.h" +#endif + +#include "gettext.h" +#define _(msgid) gettext (msgid) + +/* If you use AM_INIT_AUTOMAKE's no-define option, + PACKAGE is not defined. Use PACKAGE_TARNAME instead. */ +#if ! defined PACKAGE && defined PACKAGE_TARNAME +# define PACKAGE PACKAGE_TARNAME +#endif + +enum { COPYRIGHT_YEAR = 2024 }; + +/* The three functions below display the --version information the + standard way. + + If COMMAND_NAME is NULL, the PACKAGE is assumed to be the name of + the program. The formats are therefore: + + PACKAGE VERSION + + or + + COMMAND_NAME (PACKAGE) VERSION. + + The functions differ in the way they are passed author names. */ + +/* Display the --version information the standard way. + + Author names are given in the array AUTHORS. N_AUTHORS is the + number of elements in the array. */ +void +version_etc_arn (FILE *stream, + const char *command_name, const char *package, + const char *version, + const char * const * authors, size_t n_authors) +{ + if (command_name) + fprintf (stream, "%s (%s) %s\n", command_name, package, version); + else + fprintf (stream, "%s %s\n", package, version); + +#ifdef PACKAGE_PACKAGER +# ifdef PACKAGE_PACKAGER_VERSION + fprintf (stream, _("Packaged by %s (%s)\n"), PACKAGE_PACKAGER, + PACKAGE_PACKAGER_VERSION); +# else + fprintf (stream, _("Packaged by %s\n"), PACKAGE_PACKAGER); +# endif +#endif + + /* TRANSLATORS: Translate "(C)" to the copyright symbol + (C-in-a-circle), if this symbol is available in the user's + locale. Otherwise, do not translate "(C)"; leave it as-is. */ + fprintf (stream, version_etc_copyright, _("(C)"), COPYRIGHT_YEAR); + + fputs ("\n", stream); + + /* TRANSLATORS: The %s placeholder is the web address of the GPL license. */ + fprintf (stream, _("\ +License GPLv3+: GNU GPL version 3 or later <%s>.\n\ +This is free software: you are free to change and redistribute it.\n\ +There is NO WARRANTY, to the extent permitted by law.\n\ +"), + "https://gnu.org/licenses/gpl.html"); + + fputs ("\n", stream); + + switch (n_authors) + { + case 0: + /* No authors are given. The caller should output authorship + info after calling this function. */ + break; + case 1: + /* TRANSLATORS: %s denotes an author name. */ + fprintf (stream, _("Written by %s.\n"), authors[0]); + break; + case 2: + /* TRANSLATORS: Each %s denotes an author name. */ + fprintf (stream, _("Written by %s and %s.\n"), authors[0], authors[1]); + break; + case 3: + /* TRANSLATORS: Each %s denotes an author name. */ + fprintf (stream, _("Written by %s, %s, and %s.\n"), + authors[0], authors[1], authors[2]); + break; + case 4: + /* TRANSLATORS: Each %s denotes an author name. + You can use line breaks, estimating that each author name occupies + ca. 16 screen columns and that a screen line has ca. 80 columns. */ + fprintf (stream, _("Written by %s, %s, %s,\nand %s.\n"), + authors[0], authors[1], authors[2], authors[3]); + break; + case 5: + /* TRANSLATORS: Each %s denotes an author name. + You can use line breaks, estimating that each author name occupies + ca. 16 screen columns and that a screen line has ca. 80 columns. */ + fprintf (stream, _("Written by %s, %s, %s,\n%s, and %s.\n"), + authors[0], authors[1], authors[2], authors[3], authors[4]); + break; + case 6: + /* TRANSLATORS: Each %s denotes an author name. + You can use line breaks, estimating that each author name occupies + ca. 16 screen columns and that a screen line has ca. 80 columns. */ + fprintf (stream, _("Written by %s, %s, %s,\n%s, %s, and %s.\n"), + authors[0], authors[1], authors[2], authors[3], authors[4], + authors[5]); + break; + case 7: + /* TRANSLATORS: Each %s denotes an author name. + You can use line breaks, estimating that each author name occupies + ca. 16 screen columns and that a screen line has ca. 80 columns. */ + fprintf (stream, _("Written by %s, %s, %s,\n%s, %s, %s, and %s.\n"), + authors[0], authors[1], authors[2], authors[3], authors[4], + authors[5], authors[6]); + break; + case 8: + /* TRANSLATORS: Each %s denotes an author name. + You can use line breaks, estimating that each author name occupies + ca. 16 screen columns and that a screen line has ca. 80 columns. */ + fprintf (stream, _("\ +Written by %s, %s, %s,\n%s, %s, %s, %s,\nand %s.\n"), + authors[0], authors[1], authors[2], authors[3], authors[4], + authors[5], authors[6], authors[7]); + break; + case 9: + /* TRANSLATORS: Each %s denotes an author name. + You can use line breaks, estimating that each author name occupies + ca. 16 screen columns and that a screen line has ca. 80 columns. */ + fprintf (stream, _("\ +Written by %s, %s, %s,\n%s, %s, %s, %s,\n%s, and %s.\n"), + authors[0], authors[1], authors[2], authors[3], authors[4], + authors[5], authors[6], authors[7], authors[8]); + break; + default: + /* 10 or more authors. Use an abbreviation, since the human reader + will probably not want to read the entire list anyway. */ + /* TRANSLATORS: Each %s denotes an author name. + You can use line breaks, estimating that each author name occupies + ca. 16 screen columns and that a screen line has ca. 80 columns. */ + fprintf (stream, _("\ +Written by %s, %s, %s,\n%s, %s, %s, %s,\n%s, %s, and others.\n"), + authors[0], authors[1], authors[2], authors[3], authors[4], + authors[5], authors[6], authors[7], authors[8]); + break; + } +} + +/* Display the --version information the standard way. See the initial + comment to this module, for more information. + + Author names are given in the NULL-terminated array AUTHORS. */ +void +version_etc_ar (FILE *stream, + const char *command_name, const char *package, + const char *version, const char * const * authors) +{ + size_t n_authors; + + for (n_authors = 0; authors[n_authors]; n_authors++) + ; + version_etc_arn (stream, command_name, package, version, authors, n_authors); +} + +/* Display the --version information the standard way. See the initial + comment to this module, for more information. + + Author names are given in the NULL-terminated va_list AUTHORS. */ +void +version_etc_va (FILE *stream, + const char *command_name, const char *package, + const char *version, va_list authors) +{ + size_t n_authors; + const char *authtab[10]; + + for (n_authors = 0; + n_authors < 10 + && (authtab[n_authors] = va_arg (authors, const char *)) != NULL; + n_authors++) + ; + version_etc_arn (stream, command_name, package, version, + authtab, n_authors); +} + + +/* Display the --version information the standard way. + + If COMMAND_NAME is NULL, the PACKAGE is assumed to be the name of + the program. The formats are therefore: + + PACKAGE VERSION + + or + + COMMAND_NAME (PACKAGE) VERSION. + + The authors names are passed as separate arguments, with an additional + NULL argument at the end. */ +void +version_etc (FILE *stream, + const char *command_name, const char *package, + const char *version, /* const char *author1, ...*/ ...) +{ + va_list authors; + + va_start (authors, version); + version_etc_va (stream, command_name, package, version, authors); + va_end (authors); +} + +void +emit_bug_reporting_address (void) +{ + fputs ("\n", stdout); + /* TRANSLATORS: The placeholder indicates the bug-reporting address + for this package. Please add _another line_ saying + "Report translation bugs to <...>\n" with the address for translation + bugs (typically your translation team's web or email address). */ + printf (_("Report bugs to: %s\n"), PACKAGE_BUGREPORT); +#ifdef PACKAGE_PACKAGER_BUG_REPORTS + printf (_("Report %s bugs to: %s\n"), PACKAGE_PACKAGER, + PACKAGE_PACKAGER_BUG_REPORTS); +#endif +#ifdef PACKAGE_URL + printf (_("%s home page: <%s>\n"), PACKAGE_NAME, PACKAGE_URL); +#else + printf (_("%s home page: <%s>\n"), + PACKAGE_NAME, "https://www.gnu.org/software/" PACKAGE "/"); +#endif + printf (_("General help using GNU software: <%s>\n"), + "https://www.gnu.org/gethelp/"); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/version-etc.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/version-etc.h new file mode 100644 index 00000000..505d2fa7 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/version-etc.h @@ -0,0 +1,83 @@ +/* Print --version and bug-reporting information in a consistent format. + Copyright (C) 1999, 2003, 2005, 2009-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Jim Meyering. */ + +#ifndef VERSION_ETC_H +# define VERSION_ETC_H 1 + +/* This file uses _GL_ATTRIBUTE_SENTINEL. */ +# if !_GL_CONFIG_H_INCLUDED +# error "Please include config.h first." +# endif + +# include +# include + +# ifdef __cplusplus +extern "C" +{ +# endif + +extern const char version_etc_copyright[]; + +/* The three functions below display the --version information in the + standard way: command and package names, package version, followed + by a short GPLv3+ notice and a list of up to 10 author names. + + If COMMAND_NAME is NULL, the PACKAGE is assumed to be the name of + the program. The formats are therefore: + + PACKAGE VERSION + + or + + COMMAND_NAME (PACKAGE) VERSION. + + The functions differ in the way they are passed author names: */ + +/* N_AUTHORS names are supplied in array AUTHORS. */ +extern void version_etc_arn (FILE *stream, + const char *command_name, const char *package, + const char *version, + const char * const * authors, size_t n_authors); + +/* Names are passed in the NULL-terminated array AUTHORS. */ +extern void version_etc_ar (FILE *stream, + const char *command_name, const char *package, + const char *version, const char * const * authors); + +/* Names are passed in the NULL-terminated va_list. */ +extern void version_etc_va (FILE *stream, + const char *command_name, const char *package, + const char *version, va_list authors); + +/* Names are passed as separate arguments, with an additional + NULL argument at the end. */ +extern void version_etc (FILE *stream, + const char *command_name, const char *package, + const char *version, + /* const char *author1, ..., NULL */ ...) + _GL_ATTRIBUTE_SENTINEL ((0)); + +/* Display the usual "Report bugs to" stanza. */ +extern void emit_bug_reporting_address (void); + +# ifdef __cplusplus +} +# endif + +#endif /* VERSION_ETC_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/warn-on-use.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/warn-on-use.h new file mode 100644 index 00000000..8f4d40dc --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/warn-on-use.h @@ -0,0 +1,149 @@ +/* A C macro for emitting warnings if a function is used. + Copyright (C) 2010-2024 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* _GL_WARN_ON_USE (function, "literal string") issues a declaration + for FUNCTION which will then trigger a compiler warning containing + the text of "literal string" anywhere that function is called, if + supported by the compiler. If the compiler does not support this + feature, the macro expands to an unused extern declaration. + + _GL_WARN_ON_USE_ATTRIBUTE ("literal string") expands to the + attribute used in _GL_WARN_ON_USE. If the compiler does not support + this feature, it expands to empty. + + These macros are useful for marking a function as a potential + portability trap, with the intent that "literal string" include + instructions on the replacement function that should be used + instead. + _GL_WARN_ON_USE is for functions with 'extern' linkage. + _GL_WARN_ON_USE_ATTRIBUTE is for functions with 'static' or 'inline' + linkage. + + However, one of the reasons that a function is a portability trap is + if it has the wrong signature. Declaring FUNCTION with a different + signature in C is a compilation error, so this macro must use the + same type as any existing declaration so that programs that avoid + the problematic FUNCTION do not fail to compile merely because they + included a header that poisoned the function. But this implies that + _GL_WARN_ON_USE is only safe to use if FUNCTION is known to already + have a declaration. Use of this macro implies that there must not + be any other macro hiding the declaration of FUNCTION; but + undefining FUNCTION first is part of the poisoning process anyway + (although for symbols that are provided only via a macro, the result + is a compilation error rather than a warning containing + "literal string"). Also note that in C++, it is only safe to use if + FUNCTION has no overloads. + + For an example, it is possible to poison 'getline' by: + - adding a call to gl_WARN_ON_USE_PREPARE([[#include ]], + [getline]) in configure.ac, which potentially defines + HAVE_RAW_DECL_GETLINE + - adding this code to a header that wraps the system : + #undef getline + #if HAVE_RAW_DECL_GETLINE + _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but" + "not universally present; use the gnulib module getline"); + #endif + + It is not possible to directly poison global variables. But it is + possible to write a wrapper accessor function, and poison that + (less common usage, like &environ, will cause a compilation error + rather than issue the nice warning, but the end result of informing + the developer about their portability problem is still achieved): + #if HAVE_RAW_DECL_ENVIRON + static char *** + rpl_environ (void) { return &environ; } + _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared"); + # undef environ + # define environ (*rpl_environ ()) + #endif + or better (avoiding contradictory use of 'static' and 'extern'): + #if HAVE_RAW_DECL_ENVIRON + static char *** + _GL_WARN_ON_USE_ATTRIBUTE ("environ is not always properly declared") + rpl_environ (void) { return &environ; } + # undef environ + # define environ (*rpl_environ ()) + #endif + */ +#ifndef _GL_WARN_ON_USE + +# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) +/* A compiler attribute is available in gcc versions 4.3.0 and later. */ +# define _GL_WARN_ON_USE(function, message) \ +_GL_WARN_EXTERN_C __typeof__ (function) function __attribute__ ((__warning__ (message))) +# define _GL_WARN_ON_USE_ATTRIBUTE(message) \ + __attribute__ ((__warning__ (message))) +# elif __clang_major__ >= 4 +/* Another compiler attribute is available in clang. */ +# define _GL_WARN_ON_USE(function, message) \ +_GL_WARN_EXTERN_C __typeof__ (function) function \ + __attribute__ ((__diagnose_if__ (1, message, "warning"))) +# define _GL_WARN_ON_USE_ATTRIBUTE(message) \ + __attribute__ ((__diagnose_if__ (1, message, "warning"))) +# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING +/* Verify the existence of the function. */ +# define _GL_WARN_ON_USE(function, message) \ +_GL_WARN_EXTERN_C __typeof__ (function) function +# define _GL_WARN_ON_USE_ATTRIBUTE(message) +# else /* Unsupported. */ +# define _GL_WARN_ON_USE(function, message) \ +_GL_WARN_EXTERN_C int _gl_warn_on_use +# define _GL_WARN_ON_USE_ATTRIBUTE(message) +# endif +#endif + +/* _GL_WARN_ON_USE_CXX (function, rettype_gcc, rettype_clang, parameters_and_attributes, "message") + is like _GL_WARN_ON_USE (function, "message"), except that in C++ mode the + function is declared with the given prototype, consisting of return type, + parameters, and attributes. + This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does + not work in this case. */ +#ifndef _GL_WARN_ON_USE_CXX +# if !defined __cplusplus +# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \ + _GL_WARN_ON_USE (function, msg) +# else +# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) +/* A compiler attribute is available in gcc versions 4.3.0 and later. */ +# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \ +extern rettype_gcc function parameters_and_attributes \ + __attribute__ ((__warning__ (msg))) +# elif __clang_major__ >= 4 +/* Another compiler attribute is available in clang. */ +# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \ +extern rettype_clang function parameters_and_attributes \ + __attribute__ ((__diagnose_if__ (1, msg, "warning"))) +# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING +/* Verify the existence of the function. */ +# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \ +extern rettype_gcc function parameters_and_attributes +# else /* Unsupported. */ +# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \ +_GL_WARN_EXTERN_C int _gl_warn_on_use +# endif +# endif +#endif + +/* _GL_WARN_EXTERN_C declaration; + performs the declaration with C linkage. */ +#ifndef _GL_WARN_EXTERN_C +# if defined __cplusplus +# define _GL_WARN_EXTERN_C extern "C" +# else +# define _GL_WARN_EXTERN_C extern +# endif +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/wchar.in.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/wchar.in.h new file mode 100644 index 00000000..a33a10f7 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/wchar.in.h @@ -0,0 +1,1707 @@ +/* A substitute for ISO C99 , for platforms that have issues. + + Copyright (C) 2007-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Eric Blake. */ + +/* + * ISO C 99 for platforms that have issues. + * + * + * For now, this just ensures proper prerequisite inclusion order and + * the declaration of wcwidth(). + */ + +#if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +#endif +@PRAGMA_COLUMNS@ + +#if (((defined __need_mbstate_t || defined __need_wint_t) \ + && !defined __MINGW32__) \ + || (defined __hpux \ + && ((defined _INTTYPES_INCLUDED \ + && !defined _GL_FINISHED_INCLUDING_SYSTEM_INTTYPES_H) \ + || defined _GL_JUST_INCLUDE_SYSTEM_WCHAR_H)) \ + || (defined __MINGW32__ && defined __STRING_H_SOURCED__) \ + || defined _GL_ALREADY_INCLUDING_WCHAR_H) +/* Special invocation convention: + - Inside glibc and uClibc header files, but not MinGW. + - On HP-UX 11.00 we have a sequence of nested includes + -> -> , and the latter includes , + once indirectly -> -> -> + and once directly. In both situations 'wint_t' is not yet defined, + therefore we cannot provide the function overrides; instead include only + the system's . + - With MinGW 3.22, when includes , only some part of + is actually processed, and that doesn't include 'mbstate_t'. + - On IRIX 6.5, similarly, we have an include -> , and + the latter includes . But here, we have no way to detect whether + is completely included or is still being included. */ + +#@INCLUDE_NEXT@ @NEXT_WCHAR_H@ + +#else +/* Normal invocation convention. */ + +#ifndef _@GUARD_PREFIX@_WCHAR_H + +#define _GL_ALREADY_INCLUDING_WCHAR_H + +#if @HAVE_FEATURES_H@ +# include /* for __GLIBC__ */ +#endif + +/* In some builds of uClibc, is nonexistent and wchar_t is defined + by . + But avoid namespace pollution on glibc systems. */ +#if !(defined __GLIBC__ && !defined __UCLIBC__) +# include +#endif + +/* Include the original if it exists. + Some builds of uClibc lack it. */ +/* The include_next requires a split double-inclusion guard. */ +#if @HAVE_WCHAR_H@ +# @INCLUDE_NEXT@ @NEXT_WCHAR_H@ +#endif + +#undef _GL_ALREADY_INCLUDING_WCHAR_H + +#ifndef _@GUARD_PREFIX@_WCHAR_H +#define _@GUARD_PREFIX@_WCHAR_H + +/* This file uses _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_MALLOC, + _GL_ATTRIBUTE_NOTHROW, _GL_ATTRIBUTE_PURE, GNULIB_POSIXCHECK, + HAVE_RAW_DECL_*. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers + that can be freed by passing them as the Ith argument to the + function F. */ +#ifndef _GL_ATTRIBUTE_DEALLOC +# if __GNUC__ >= 11 +# define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i))) +# else +# define _GL_ATTRIBUTE_DEALLOC(f, i) +# endif +#endif + +/* _GL_ATTRIBUTE_DEALLOC_FREE declares that the function returns pointers that + can be freed via 'free'; it can be used only after declaring 'free'. */ +/* Applies to: functions. Cannot be used on inline functions. */ +#ifndef _GL_ATTRIBUTE_DEALLOC_FREE +# if defined __cplusplus && defined __GNUC__ && !defined __clang__ +/* Work around GCC bug */ +# define _GL_ATTRIBUTE_DEALLOC_FREE \ + _GL_ATTRIBUTE_DEALLOC ((void (*) (void *)) free, 1) +# else +# define _GL_ATTRIBUTE_DEALLOC_FREE \ + _GL_ATTRIBUTE_DEALLOC (free, 1) +# endif +#endif + +/* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly + allocated memory. */ +/* Applies to: functions. */ +#ifndef _GL_ATTRIBUTE_MALLOC +# if __GNUC__ >= 3 || defined __clang__ +# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__)) +# else +# define _GL_ATTRIBUTE_MALLOC +# endif +#endif + +/* The __attribute__ feature is available in gcc versions 2.5 and later. + The attribute __pure__ was added in gcc 2.96. */ +#ifndef _GL_ATTRIBUTE_PURE +# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined __clang__ +# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) +# else +# define _GL_ATTRIBUTE_PURE /* empty */ +# endif +#endif + +/* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions. + */ +#ifndef _GL_ATTRIBUTE_NOTHROW +# if defined __cplusplus +# if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major >= 4 +# if __cplusplus >= 201103L +# define _GL_ATTRIBUTE_NOTHROW noexcept (true) +# else +# define _GL_ATTRIBUTE_NOTHROW throw () +# endif +# else +# define _GL_ATTRIBUTE_NOTHROW +# endif +# else +# if (__GNUC__ + (__GNUC_MINOR__ >= 3) > 3) || defined __clang__ +# define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__)) +# else +# define _GL_ATTRIBUTE_NOTHROW +# endif +# endif +#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. */ + + +/* Define wint_t and WEOF. (Also done in wctype.in.h.) */ +#if !@HAVE_WINT_T@ && !defined wint_t +# define wint_t int +# ifndef WEOF +# define WEOF -1 +# endif +#else +/* mingw and MSVC define wint_t as 'unsigned short' in or + . This is too small: ISO C 99 section 7.24.1.(2) says that + wint_t must be "unchanged by default argument promotions". Override it. */ +# if @GNULIBHEADERS_OVERRIDE_WINT_T@ +# if !GNULIB_defined_wint_t +# if @HAVE_CRTDEFS_H@ +# include +# else +# include +# endif +typedef unsigned int rpl_wint_t; +# undef wint_t +# define wint_t rpl_wint_t +# define GNULIB_defined_wint_t 1 +# endif +# endif +# ifndef WEOF +# define WEOF ((wint_t) -1) +# endif +#endif + + +/* Override mbstate_t if it is too small. + On IRIX 6.5, sizeof (mbstate_t) == 1, which is not sufficient for + implementing mbrtowc for encodings like UTF-8. + On AIX and MSVC, mbrtowc needs to be overridden, but mbstate_t exists and is + large enough and overriding it would cause problems in C++ mode. */ +#if !(((defined _WIN32 && !defined __CYGWIN__) || @HAVE_MBSINIT@) && @HAVE_MBRTOWC@) || @REPLACE_MBSTATE_T@ +# if !GNULIB_defined_mbstate_t +# if !(defined _AIX || defined _MSC_VER) +typedef int rpl_mbstate_t; +# undef mbstate_t +# define mbstate_t rpl_mbstate_t +# endif +# define GNULIB_defined_mbstate_t 1 +# endif +#endif + +/* Make _GL_ATTRIBUTE_DEALLOC_FREE work, even though may not have + been included yet. */ +#if @GNULIB_FREE_POSIX@ +# if (@REPLACE_FREE@ && !defined free \ + && !(defined __cplusplus && defined GNULIB_NAMESPACE)) +/* We can't do '#define free rpl_free' here. */ +# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2) +_GL_EXTERN_C void rpl_free (void *) _GL_ATTRIBUTE_NOTHROW; +# else +_GL_EXTERN_C void rpl_free (void *); +# endif +# undef _GL_ATTRIBUTE_DEALLOC_FREE +# define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (rpl_free, 1) +# else +# if defined _MSC_VER && !defined free +_GL_EXTERN_C +# if defined _DLL + __declspec (dllimport) +# endif + void __cdecl free (void *); +# else +# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2) +_GL_EXTERN_C void free (void *) _GL_ATTRIBUTE_NOTHROW; +# else +_GL_EXTERN_C void free (void *); +# endif +# endif +# endif +#else +# if defined _MSC_VER && !defined free +_GL_EXTERN_C +# if defined _DLL + __declspec (dllimport) +# endif + void __cdecl free (void *); +# else +# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2) +_GL_EXTERN_C void free (void *) _GL_ATTRIBUTE_NOTHROW; +# else +_GL_EXTERN_C void free (void *); +# endif +# endif +#endif + + +#if @GNULIB_MBSZERO@ +/* Get memset(). */ +# include +#endif + + +/* Convert a single-byte character to a wide character. */ +#if @GNULIB_BTOWC@ +# if @REPLACE_BTOWC@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef btowc +# define btowc rpl_btowc +# endif +_GL_FUNCDECL_RPL (btowc, wint_t, (int c) _GL_ATTRIBUTE_PURE); +_GL_CXXALIAS_RPL (btowc, wint_t, (int c)); +# else +# if !@HAVE_BTOWC@ +_GL_FUNCDECL_SYS (btowc, wint_t, (int c) _GL_ATTRIBUTE_PURE); +# endif +/* Need to cast, because on mingw, the return type is 'unsigned short'. */ +_GL_CXXALIAS_SYS_CAST (btowc, wint_t, (int c)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (btowc); +# endif +#elif defined GNULIB_POSIXCHECK +# undef btowc +# if HAVE_RAW_DECL_BTOWC +_GL_WARN_ON_USE (btowc, "btowc is unportable - " + "use gnulib module btowc for portability"); +# endif +#endif + + +/* Convert a wide character to a single-byte character. */ +#if @GNULIB_WCTOB@ +# if @REPLACE_WCTOB@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef wctob +# define wctob rpl_wctob +# endif +_GL_FUNCDECL_RPL (wctob, int, (wint_t wc) _GL_ATTRIBUTE_PURE); +_GL_CXXALIAS_RPL (wctob, int, (wint_t wc)); +# else +# if !defined wctob && !@HAVE_DECL_WCTOB@ +/* wctob is provided by gnulib, or wctob exists but is not declared. */ +_GL_FUNCDECL_SYS (wctob, int, (wint_t wc) _GL_ATTRIBUTE_PURE); +# endif +_GL_CXXALIAS_SYS (wctob, int, (wint_t wc)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (wctob); +# endif +#elif defined GNULIB_POSIXCHECK +# undef wctob +# if HAVE_RAW_DECL_WCTOB +_GL_WARN_ON_USE (wctob, "wctob is unportable - " + "use gnulib module wctob for portability"); +# endif +#endif + + +/* Test whether *PS is in an initial state. */ +#if @GNULIB_MBSINIT@ +# if @REPLACE_MBSINIT@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef mbsinit +# define mbsinit rpl_mbsinit +# endif +_GL_FUNCDECL_RPL (mbsinit, int, (const mbstate_t *ps)); +_GL_CXXALIAS_RPL (mbsinit, int, (const mbstate_t *ps)); +# else +# if !@HAVE_MBSINIT@ +_GL_FUNCDECL_SYS (mbsinit, int, (const mbstate_t *ps)); +# endif +_GL_CXXALIAS_SYS (mbsinit, int, (const mbstate_t *ps)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (mbsinit); +# endif +#elif defined GNULIB_POSIXCHECK +# undef mbsinit +# if HAVE_RAW_DECL_MBSINIT +_GL_WARN_ON_USE (mbsinit, "mbsinit is unportable - " + "use gnulib module mbsinit for portability"); +# endif +#endif + + +/* Put *PS into an initial state. */ +#if @GNULIB_MBSZERO@ +/* ISO C 23 § 7.31.6.(3) says that zeroing an mbstate_t is a way to put the + mbstate_t into an initial state. However, on many platforms an mbstate_t + is large, and it is possible - as an optimization - to get away with zeroing + only part of it. So, instead of + + mbstate_t state = { 0 }; + + or + + mbstate_t state; + memset (&state, 0, sizeof (mbstate_t)); + + we can write this faster code: + + mbstate_t state; + mbszero (&state); + */ +/* _GL_MBSTATE_INIT_SIZE describes how mbsinit() behaves: It is the number of + bytes at the beginning of an mbstate_t that need to be zero, for mbsinit() + to return true. + _GL_MBSTATE_ZERO_SIZE is the number of bytes at the beginning of an mbstate_t + that need to be zero, + - for mbsinit() to return true, and + - for all other multibyte-aware functions to operate properly. + 0 < _GL_MBSTATE_INIT_SIZE <= _GL_MBSTATE_ZERO_SIZE <= sizeof (mbstate_t). + These values are determined by source code inspection, where possible, and + by running the gnulib unit tests. + We need _GL_MBSTATE_INIT_SIZE because if we define _GL_MBSTATE_ZERO_SIZE + without considering what mbsinit() does, we get test failures such as + assertion "mbsinit (&iter->state)" failed + */ +# if GNULIB_defined_mbstate_t /* AIX, IRIX */ +/* mbstate_t has at least 4 bytes. They are used as coded in + gnulib/lib/mbrtowc.c. */ +# define _GL_MBSTATE_INIT_SIZE 1 +/* define _GL_MBSTATE_ZERO_SIZE 4 + does not work: it causes test failures. + So, use the safe fallback value, below. */ +# elif __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 /* glibc */ +/* mbstate_t is defined in . + For more details, see glibc/iconv/skeleton.c. */ +# define _GL_MBSTATE_INIT_SIZE 4 /* sizeof (((mbstate_t) {0}).__count) */ +# define _GL_MBSTATE_ZERO_SIZE /* 8 */ sizeof (mbstate_t) +# elif defined MUSL_LIBC /* musl libc */ +/* mbstate_t is defined in . + It is an opaque aligned 8-byte struct, of which at most the first + 4 bytes are used. + For more details, see src/multibyte/mbrtowc.c. */ +# define _GL_MBSTATE_INIT_SIZE 4 /* sizeof (unsigned) */ +# define _GL_MBSTATE_ZERO_SIZE 4 +# elif defined __APPLE__ && defined __MACH__ /* macOS */ +/* On macOS, mbstate_t is defined in . + It is an opaque aligned 128-byte struct, of which at most the first + 12 bytes are used. + For more details, see the __mbsinit implementations in + Libc-/locale/FreeBSD/ + {ascii,none,euc,mskanji,big5,gb2312,gbk,gb18030,utf8,utf2}.c. */ +/* File INIT_SIZE ZERO_SIZE + ascii.c 0 0 + none.c 0 0 + euc.c 12 12 + mskanji.c 4 4 + big5.c 4 4 + gb2312.c 4 6 + gbk.c 4 4 + gb18030.c 4 8 + utf8.c 8 10 + utf2.c 8 12 */ +# define _GL_MBSTATE_INIT_SIZE 12 +# define _GL_MBSTATE_ZERO_SIZE 12 +# elif defined __FreeBSD__ /* FreeBSD */ +/* On FreeBSD, mbstate_t is defined in src/sys/sys/_types.h. + It is an opaque aligned 128-byte struct, of which at most the first + 12 bytes are used. + For more details, see the __mbsinit implementations in + src/lib/libc/locale/ + {ascii,none,euc,mskanji,big5,gb2312,gbk,gb18030,utf8}.c. */ +/* File INIT_SIZE ZERO_SIZE + ascii.c 0 0 + none.c 0 0 + euc.c 12 12 + mskanji.c 4 4 + big5.c 4 4 + gb2312.c 4 6 + gbk.c 4 4 + gb18030.c 4 8 + utf8.c 8 12 */ +# define _GL_MBSTATE_INIT_SIZE 12 +# define _GL_MBSTATE_ZERO_SIZE 12 +# elif defined __NetBSD__ /* NetBSD */ +/* On NetBSD, mbstate_t is defined in src/sys/sys/ansi.h. + It is an opaque aligned 128-byte struct, of which at most the first + 28 bytes are used. + For more details, see the *State types in + src/lib/libc/citrus/modules/citrus_*.c + (ignoring citrus_{hz,iso2022,utf7,viqr,zw}.c, since these implement + stateful encodings, not usable as locale encodings). */ +/* File ZERO_SIZE + citrus/citrus_none.c 0 + citrus/modules/citrus_euc.c 8 + citrus/modules/citrus_euctw.c 8 + citrus/modules/citrus_mskanji.c 8 + citrus/modules/citrus_big5.c 8 + citrus/modules/citrus_gbk2k.c 8 + citrus/modules/citrus_dechanyu.c 8 + citrus/modules/citrus_johab.c 6 + citrus/modules/citrus_utf8.c 12 */ +/* But 12 is not the correct value for _GL_MBSTATE_ZERO_SIZE: we get test + failures for values < 28. */ +# define _GL_MBSTATE_ZERO_SIZE 28 +# elif defined __OpenBSD__ /* OpenBSD */ +/* On OpenBSD, mbstate_t is defined in src/sys/sys/_types.h. + It is an opaque aligned 128-byte struct, of which at most the first + 12 bytes are used. + For more details, see src/lib/libc/citrus/citrus_*.c. */ +/* File INIT_SIZE ZERO_SIZE + citrus_none.c 0 0 + citrus_utf8.c 12 12 */ +# define _GL_MBSTATE_INIT_SIZE 12 +# define _GL_MBSTATE_ZERO_SIZE 12 +# elif defined __minix /* Minix */ +/* On Minix, mbstate_t is defined in sys/sys/ansi.h. + It is an opaque aligned 128-byte struct. + For more details, see the *State types in + lib/libc/citrus/citrus_*.c. */ +/* File INIT_SIZE ZERO_SIZE + citrus_none.c 0 0 */ +/* But 1 is not the correct value for _GL_MBSTATE_ZERO_SIZE: we get test + failures for values < 4. */ +# define _GL_MBSTATE_ZERO_SIZE 4 +# elif defined __sun /* Solaris */ +/* On Solaris, mbstate_t is defined in . + It is an opaque aligned 24-byte or 32-byte struct, of which at most the first + 20 or 28 bytes are used. + For more details on OpenSolaris derivatives, see the *State types in + illumos-gate/usr/src/lib/libc/port/locale/ + {none,euc,mskanji,big5,gb2312,gbk,gb18030,utf8}.c. */ +/* File INIT_SIZE ZERO_SIZE + none.c 0 0 + euc.c 12 12 + mskanji.c 4 4 + big5.c 4 4 + gb2312.c 4 6 + gbk.c 4 4 + gb18030.c 4 8 + utf8.c 12 12 */ +/* But 12 is not the correct value for _GL_MBSTATE_ZERO_SIZE: we get test + failures + - in OpenIndiana and OmniOS: for values < 16, + - in Solaris 10 and 11: for values < 20 (in 32-bit mode) + or < 28 (in 64-bit mode). + Since we don't have a good way to distinguish the OpenSolaris derivatives + from the proprietary Solaris versions, and can't inspect the Solaris source + code, use the safe fallback values, below. */ +# elif defined __CYGWIN__ /* Cygwin */ +/* On Cygwin, mbstate_t is defined in . + For more details, see newlib/libc/stdlib/mbtowc_r.c and + winsup/cygwin/strfuncs.cc. */ +# define _GL_MBSTATE_INIT_SIZE 4 /* sizeof (int) */ +# define _GL_MBSTATE_ZERO_SIZE 8 +# elif defined _WIN32 && !defined __CYGWIN__ /* Native Windows. */ +/* MSVC defines 'mbstate_t' as an aligned 8-byte struct. + On mingw, 'mbstate_t' is sometimes defined as 'int', sometimes defined + as an aligned 8-byte struct, of which the first 4 bytes matter. + Use the safe values, below. */ +# elif defined __ANDROID__ /* Android */ +/* Android defines 'mbstate_t' in . + It is an opaque 4-byte or 8-byte struct. + For more details, see + bionic/libc/private/bionic_mbstate.h + bionic/libc/bionic/mbrtoc32.cpp + bionic/libc/bionic/mbrtoc16.cpp + */ +# define _GL_MBSTATE_INIT_SIZE 4 +# define _GL_MBSTATE_ZERO_SIZE 4 +# endif +/* Use safe values as defaults. */ +# ifndef _GL_MBSTATE_INIT_SIZE +# define _GL_MBSTATE_INIT_SIZE sizeof (mbstate_t) +# endif +# ifndef _GL_MBSTATE_ZERO_SIZE +# define _GL_MBSTATE_ZERO_SIZE sizeof (mbstate_t) +# endif +_GL_BEGIN_C_LINKAGE +# if defined IN_MBSZERO +_GL_EXTERN_INLINE +# else +_GL_INLINE +# endif +_GL_ARG_NONNULL ((1)) void +mbszero (mbstate_t *ps) +{ + memset (ps, 0, _GL_MBSTATE_ZERO_SIZE); +} +_GL_END_C_LINKAGE +_GL_CXXALIAS_SYS (mbszero, void, (mbstate_t *ps)); +_GL_CXXALIASWARN (mbszero); +#endif + + +/* Convert a multibyte character to a wide character. */ +#if @GNULIB_MBRTOWC@ +# if @REPLACE_MBRTOWC@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef mbrtowc +# define mbrtowc rpl_mbrtowc +# endif +_GL_FUNCDECL_RPL (mbrtowc, size_t, + (wchar_t *restrict pwc, const char *restrict s, size_t n, + mbstate_t *restrict ps)); +_GL_CXXALIAS_RPL (mbrtowc, size_t, + (wchar_t *restrict pwc, const char *restrict s, size_t n, + mbstate_t *restrict ps)); +# else +# if !@HAVE_MBRTOWC@ +_GL_FUNCDECL_SYS (mbrtowc, size_t, + (wchar_t *restrict pwc, const char *restrict s, size_t n, + mbstate_t *restrict ps)); +# endif +_GL_CXXALIAS_SYS (mbrtowc, size_t, + (wchar_t *restrict pwc, const char *restrict s, size_t n, + mbstate_t *restrict ps)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (mbrtowc); +# endif +#elif defined GNULIB_POSIXCHECK +# undef mbrtowc +# if HAVE_RAW_DECL_MBRTOWC +_GL_WARN_ON_USE (mbrtowc, "mbrtowc is unportable - " + "use gnulib module mbrtowc for portability"); +# endif +#endif + + +/* Recognize a multibyte character. */ +#if @GNULIB_MBRLEN@ +# if @REPLACE_MBRLEN@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef mbrlen +# define mbrlen rpl_mbrlen +# endif +_GL_FUNCDECL_RPL (mbrlen, size_t, + (const char *restrict s, size_t n, mbstate_t *restrict ps)); +_GL_CXXALIAS_RPL (mbrlen, size_t, + (const char *restrict s, size_t n, mbstate_t *restrict ps)); +# else +# if !@HAVE_MBRLEN@ +_GL_FUNCDECL_SYS (mbrlen, size_t, + (const char *restrict s, size_t n, mbstate_t *restrict ps)); +# endif +_GL_CXXALIAS_SYS (mbrlen, size_t, + (const char *restrict s, size_t n, mbstate_t *restrict ps)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (mbrlen); +# endif +#elif defined GNULIB_POSIXCHECK +# undef mbrlen +# if HAVE_RAW_DECL_MBRLEN +_GL_WARN_ON_USE (mbrlen, "mbrlen is unportable - " + "use gnulib module mbrlen for portability"); +# endif +#endif + + +/* Convert a string to a wide string. */ +#if @GNULIB_MBSRTOWCS@ +# if @REPLACE_MBSRTOWCS@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef mbsrtowcs +# define mbsrtowcs rpl_mbsrtowcs +# endif +_GL_FUNCDECL_RPL (mbsrtowcs, size_t, + (wchar_t *restrict dest, + const char **restrict srcp, size_t len, + mbstate_t *restrict ps) + _GL_ARG_NONNULL ((2))); +_GL_CXXALIAS_RPL (mbsrtowcs, size_t, + (wchar_t *restrict dest, + const char **restrict srcp, size_t len, + mbstate_t *restrict ps)); +# else +# if !@HAVE_MBSRTOWCS@ +_GL_FUNCDECL_SYS (mbsrtowcs, size_t, + (wchar_t *restrict dest, + const char **restrict srcp, size_t len, + mbstate_t *restrict ps) + _GL_ARG_NONNULL ((2))); +# endif +_GL_CXXALIAS_SYS (mbsrtowcs, size_t, + (wchar_t *restrict dest, + const char **restrict srcp, size_t len, + mbstate_t *restrict ps)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (mbsrtowcs); +# endif +#elif defined GNULIB_POSIXCHECK +# undef mbsrtowcs +# if HAVE_RAW_DECL_MBSRTOWCS +_GL_WARN_ON_USE (mbsrtowcs, "mbsrtowcs is unportable - " + "use gnulib module mbsrtowcs for portability"); +# endif +#endif + + +/* Convert a string to a wide string. */ +#if @GNULIB_MBSNRTOWCS@ +# if @REPLACE_MBSNRTOWCS@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef mbsnrtowcs +# define mbsnrtowcs rpl_mbsnrtowcs +# endif +_GL_FUNCDECL_RPL (mbsnrtowcs, size_t, + (wchar_t *restrict dest, + const char **restrict srcp, size_t srclen, size_t len, + mbstate_t *restrict ps) + _GL_ARG_NONNULL ((2))); +_GL_CXXALIAS_RPL (mbsnrtowcs, size_t, + (wchar_t *restrict dest, + const char **restrict srcp, size_t srclen, size_t len, + mbstate_t *restrict ps)); +# else +# if !@HAVE_MBSNRTOWCS@ +_GL_FUNCDECL_SYS (mbsnrtowcs, size_t, + (wchar_t *restrict dest, + const char **restrict srcp, size_t srclen, size_t len, + mbstate_t *restrict ps) + _GL_ARG_NONNULL ((2))); +# endif +_GL_CXXALIAS_SYS (mbsnrtowcs, size_t, + (wchar_t *restrict dest, + const char **restrict srcp, size_t srclen, size_t len, + mbstate_t *restrict ps)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (mbsnrtowcs); +# endif +#elif defined GNULIB_POSIXCHECK +# undef mbsnrtowcs +# if HAVE_RAW_DECL_MBSNRTOWCS +_GL_WARN_ON_USE (mbsnrtowcs, "mbsnrtowcs is unportable - " + "use gnulib module mbsnrtowcs for portability"); +# endif +#endif + + +/* Convert a wide character to a multibyte character. */ +#if @GNULIB_WCRTOMB@ +# if @REPLACE_WCRTOMB@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef wcrtomb +# define wcrtomb rpl_wcrtomb +# endif +_GL_FUNCDECL_RPL (wcrtomb, size_t, + (char *restrict s, wchar_t wc, mbstate_t *restrict ps)); +_GL_CXXALIAS_RPL (wcrtomb, size_t, + (char *restrict s, wchar_t wc, mbstate_t *restrict ps)); +# else +# if !@HAVE_WCRTOMB@ +_GL_FUNCDECL_SYS (wcrtomb, size_t, + (char *restrict s, wchar_t wc, mbstate_t *restrict ps)); +# endif +_GL_CXXALIAS_SYS (wcrtomb, size_t, + (char *restrict s, wchar_t wc, mbstate_t *restrict ps)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (wcrtomb); +# endif +#elif defined GNULIB_POSIXCHECK +# undef wcrtomb +# if HAVE_RAW_DECL_WCRTOMB +_GL_WARN_ON_USE (wcrtomb, "wcrtomb is unportable - " + "use gnulib module wcrtomb for portability"); +# endif +#endif + + +/* Convert a wide string to a string. */ +#if @GNULIB_WCSRTOMBS@ +# if @REPLACE_WCSRTOMBS@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef wcsrtombs +# define wcsrtombs rpl_wcsrtombs +# endif +_GL_FUNCDECL_RPL (wcsrtombs, size_t, + (char *restrict dest, const wchar_t **restrict srcp, + size_t len, + mbstate_t *restrict ps) + _GL_ARG_NONNULL ((2))); +_GL_CXXALIAS_RPL (wcsrtombs, size_t, + (char *restrict dest, const wchar_t **restrict srcp, + size_t len, + mbstate_t *restrict ps)); +# else +# if !@HAVE_WCSRTOMBS@ +_GL_FUNCDECL_SYS (wcsrtombs, size_t, + (char *restrict dest, const wchar_t **restrict srcp, + size_t len, + mbstate_t *restrict ps) + _GL_ARG_NONNULL ((2))); +# endif +_GL_CXXALIAS_SYS (wcsrtombs, size_t, + (char *restrict dest, const wchar_t **restrict srcp, + size_t len, + mbstate_t *restrict ps)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (wcsrtombs); +# endif +#elif defined GNULIB_POSIXCHECK +# undef wcsrtombs +# if HAVE_RAW_DECL_WCSRTOMBS +_GL_WARN_ON_USE (wcsrtombs, "wcsrtombs is unportable - " + "use gnulib module wcsrtombs for portability"); +# endif +#endif + + +/* Convert a wide string to a string. */ +#if @GNULIB_WCSNRTOMBS@ +# if @REPLACE_WCSNRTOMBS@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef wcsnrtombs +# define wcsnrtombs rpl_wcsnrtombs +# endif +_GL_FUNCDECL_RPL (wcsnrtombs, size_t, + (char *restrict dest, + const wchar_t **restrict srcp, size_t srclen, + size_t len, + mbstate_t *restrict ps) + _GL_ARG_NONNULL ((2))); +_GL_CXXALIAS_RPL (wcsnrtombs, size_t, + (char *restrict dest, + const wchar_t **restrict srcp, size_t srclen, + size_t len, + mbstate_t *restrict ps)); +# else +# if !@HAVE_WCSNRTOMBS@ || (defined __cplusplus && defined __sun) +_GL_FUNCDECL_SYS (wcsnrtombs, size_t, + (char *restrict dest, + const wchar_t **restrict srcp, size_t srclen, + size_t len, + mbstate_t *restrict ps) + _GL_ARG_NONNULL ((2))); +# endif +_GL_CXXALIAS_SYS (wcsnrtombs, size_t, + (char *restrict dest, + const wchar_t **restrict srcp, size_t srclen, + size_t len, + mbstate_t *restrict ps)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (wcsnrtombs); +# endif +#elif defined GNULIB_POSIXCHECK +# undef wcsnrtombs +# if HAVE_RAW_DECL_WCSNRTOMBS +_GL_WARN_ON_USE (wcsnrtombs, "wcsnrtombs is unportable - " + "use gnulib module wcsnrtombs for portability"); +# endif +#endif + + +/* Return the number of screen columns needed for WC. */ +#if @GNULIB_WCWIDTH@ +# if @REPLACE_WCWIDTH@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef wcwidth +# define wcwidth rpl_wcwidth +# endif +_GL_FUNCDECL_RPL (wcwidth, int, (wchar_t) _GL_ATTRIBUTE_PURE); +_GL_CXXALIAS_RPL (wcwidth, int, (wchar_t)); +# else +# if !@HAVE_DECL_WCWIDTH@ +/* wcwidth exists but is not declared. */ +_GL_FUNCDECL_SYS (wcwidth, int, (wchar_t) _GL_ATTRIBUTE_PURE); +# endif +_GL_CXXALIAS_SYS (wcwidth, int, (wchar_t)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (wcwidth); +# endif +#elif defined GNULIB_POSIXCHECK +# undef wcwidth +# if HAVE_RAW_DECL_WCWIDTH +_GL_WARN_ON_USE (wcwidth, "wcwidth is unportable - " + "use gnulib module wcwidth for portability"); +# endif +#endif + + +/* Search N wide characters of S for C. */ +#if @GNULIB_WMEMCHR@ +# if !@HAVE_WMEMCHR@ +_GL_FUNCDECL_SYS (wmemchr, wchar_t *, (const wchar_t *s, wchar_t c, size_t n) + _GL_ATTRIBUTE_PURE); +# endif + /* On some systems, this function is defined as an overloaded function: + extern "C++" { + const wchar_t * std::wmemchr (const wchar_t *, wchar_t, size_t); + wchar_t * std::wmemchr (wchar_t *, wchar_t, size_t); + } */ +_GL_CXXALIAS_SYS_CAST2 (wmemchr, + wchar_t *, (const wchar_t *, wchar_t, size_t), + const wchar_t *, (const wchar_t *, wchar_t, size_t)); +# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ + && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) +_GL_CXXALIASWARN1 (wmemchr, wchar_t *, (wchar_t *s, wchar_t c, size_t n)); +_GL_CXXALIASWARN1 (wmemchr, const wchar_t *, + (const wchar_t *s, wchar_t c, size_t n)); +# elif __GLIBC__ >= 2 +_GL_CXXALIASWARN (wmemchr); +# endif +#elif defined GNULIB_POSIXCHECK +# undef wmemchr +# if HAVE_RAW_DECL_WMEMCHR +_GL_WARN_ON_USE (wmemchr, "wmemchr is unportable - " + "use gnulib module wmemchr for portability"); +# endif +#endif + + +/* Compare N wide characters of S1 and S2. */ +#if @GNULIB_WMEMCMP@ +# if @REPLACE_WMEMCMP@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef wmemcmp +# define wmemcmp rpl_wmemcmp +# endif +_GL_FUNCDECL_RPL (wmemcmp, int, + (const wchar_t *s1, const wchar_t *s2, size_t n) + _GL_ATTRIBUTE_PURE); +_GL_CXXALIAS_RPL (wmemcmp, int, + (const wchar_t *s1, const wchar_t *s2, size_t n)); +# else +# if !@HAVE_WMEMCMP@ +_GL_FUNCDECL_SYS (wmemcmp, int, + (const wchar_t *s1, const wchar_t *s2, size_t n) + _GL_ATTRIBUTE_PURE); +# endif +_GL_CXXALIAS_SYS (wmemcmp, int, + (const wchar_t *s1, const wchar_t *s2, size_t n)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (wmemcmp); +# endif +#elif defined GNULIB_POSIXCHECK +# undef wmemcmp +# if HAVE_RAW_DECL_WMEMCMP +_GL_WARN_ON_USE (wmemcmp, "wmemcmp is unportable - " + "use gnulib module wmemcmp for portability"); +# endif +#endif + + +/* Copy N wide characters of SRC to DEST. */ +#if @GNULIB_WMEMCPY@ +# if !@HAVE_WMEMCPY@ +_GL_FUNCDECL_SYS (wmemcpy, wchar_t *, + (wchar_t *restrict dest, + const wchar_t *restrict src, size_t n)); +# endif +_GL_CXXALIAS_SYS (wmemcpy, wchar_t *, + (wchar_t *restrict dest, + const wchar_t *restrict src, size_t n)); +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (wmemcpy); +# endif +#elif defined GNULIB_POSIXCHECK +# undef wmemcpy +# if HAVE_RAW_DECL_WMEMCPY +_GL_WARN_ON_USE (wmemcpy, "wmemcpy is unportable - " + "use gnulib module wmemcpy for portability"); +# endif +#endif + + +/* Copy N wide characters of SRC to DEST, guaranteeing correct behavior for + overlapping memory areas. */ +#if @GNULIB_WMEMMOVE@ +# if !@HAVE_WMEMMOVE@ +_GL_FUNCDECL_SYS (wmemmove, wchar_t *, + (wchar_t *dest, const wchar_t *src, size_t n)); +# endif +_GL_CXXALIAS_SYS (wmemmove, wchar_t *, + (wchar_t *dest, const wchar_t *src, size_t n)); +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (wmemmove); +# endif +#elif defined GNULIB_POSIXCHECK +# undef wmemmove +# if HAVE_RAW_DECL_WMEMMOVE +_GL_WARN_ON_USE (wmemmove, "wmemmove is unportable - " + "use gnulib module wmemmove for portability"); +# endif +#endif + + +/* Copy N wide characters of SRC to DEST. + Return pointer to wide characters after the last written wide character. */ +#if @GNULIB_WMEMPCPY@ +# if @REPLACE_WMEMPCPY@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef wmempcpy +# define wmempcpy rpl_wmempcpy +# endif +_GL_FUNCDECL_RPL (wmempcpy, wchar_t *, + (wchar_t *restrict dest, + const wchar_t *restrict src, size_t n)); +_GL_CXXALIAS_RPL (wmempcpy, wchar_t *, + (wchar_t *restrict dest, + const wchar_t *restrict src, size_t n)); +# else +# if !@HAVE_WMEMPCPY@ +_GL_FUNCDECL_SYS (wmempcpy, wchar_t *, + (wchar_t *restrict dest, + const wchar_t *restrict src, size_t n)); +# endif +_GL_CXXALIAS_SYS (wmempcpy, wchar_t *, + (wchar_t *restrict dest, + const wchar_t *restrict src, size_t n)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (wmempcpy); +# endif +#elif defined GNULIB_POSIXCHECK +# undef wmempcpy +# if HAVE_RAW_DECL_WMEMPCPY +_GL_WARN_ON_USE (wmempcpy, "wmempcpy is unportable - " + "use gnulib module wmempcpy for portability"); +# endif +#endif + + +/* Set N wide characters of S to C. */ +#if @GNULIB_WMEMSET@ +# if !@HAVE_WMEMSET@ +_GL_FUNCDECL_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n)); +# endif +_GL_CXXALIAS_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n)); +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (wmemset); +# endif +#elif defined GNULIB_POSIXCHECK +# undef wmemset +# if HAVE_RAW_DECL_WMEMSET +_GL_WARN_ON_USE (wmemset, "wmemset is unportable - " + "use gnulib module wmemset for portability"); +# endif +#endif + + +/* Return the number of wide characters in S. */ +#if @GNULIB_WCSLEN@ +# if !@HAVE_WCSLEN@ +_GL_FUNCDECL_SYS (wcslen, size_t, (const wchar_t *s) _GL_ATTRIBUTE_PURE); +# endif +_GL_CXXALIAS_SYS (wcslen, size_t, (const wchar_t *s)); +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (wcslen); +# endif +#elif defined GNULIB_POSIXCHECK +# undef wcslen +# if HAVE_RAW_DECL_WCSLEN +_GL_WARN_ON_USE (wcslen, "wcslen is unportable - " + "use gnulib module wcslen for portability"); +# endif +#endif + + +/* Return the number of wide characters in S, but at most MAXLEN. */ +#if @GNULIB_WCSNLEN@ +/* On Solaris 11.3, the header files declare the function in the std:: + namespace, not in the global namespace. So, force a declaration in + the global namespace. */ +# if !@HAVE_WCSNLEN@ || (defined __sun && defined __cplusplus) +_GL_FUNCDECL_SYS (wcsnlen, size_t, (const wchar_t *s, size_t maxlen) + _GL_ATTRIBUTE_PURE); +# endif +_GL_CXXALIAS_SYS (wcsnlen, size_t, (const wchar_t *s, size_t maxlen)); +_GL_CXXALIASWARN (wcsnlen); +#elif defined GNULIB_POSIXCHECK +# undef wcsnlen +# if HAVE_RAW_DECL_WCSNLEN +_GL_WARN_ON_USE (wcsnlen, "wcsnlen is unportable - " + "use gnulib module wcsnlen for portability"); +# endif +#endif + + +/* Copy SRC to DEST. */ +#if @GNULIB_WCSCPY@ +# if !@HAVE_WCSCPY@ +_GL_FUNCDECL_SYS (wcscpy, wchar_t *, + (wchar_t *restrict dest, const wchar_t *restrict src)); +# endif +_GL_CXXALIAS_SYS (wcscpy, wchar_t *, + (wchar_t *restrict dest, const wchar_t *restrict src)); +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (wcscpy); +# endif +#elif defined GNULIB_POSIXCHECK +# undef wcscpy +# if HAVE_RAW_DECL_WCSCPY +_GL_WARN_ON_USE (wcscpy, "wcscpy is unportable - " + "use gnulib module wcscpy for portability"); +# endif +#endif + + +/* Copy SRC to DEST, returning the address of the terminating L'\0' in DEST. */ +#if @GNULIB_WCPCPY@ +/* On Solaris 11.3, the header files declare the function in the std:: + namespace, not in the global namespace. So, force a declaration in + the global namespace. */ +# if !@HAVE_WCPCPY@ || (defined __sun && defined __cplusplus) +_GL_FUNCDECL_SYS (wcpcpy, wchar_t *, + (wchar_t *restrict dest, const wchar_t *restrict src)); +# endif +_GL_CXXALIAS_SYS (wcpcpy, wchar_t *, + (wchar_t *restrict dest, const wchar_t *restrict src)); +_GL_CXXALIASWARN (wcpcpy); +#elif defined GNULIB_POSIXCHECK +# undef wcpcpy +# if HAVE_RAW_DECL_WCPCPY +_GL_WARN_ON_USE (wcpcpy, "wcpcpy is unportable - " + "use gnulib module wcpcpy for portability"); +# endif +#endif + + +/* Copy no more than N wide characters of SRC to DEST. */ +#if @GNULIB_WCSNCPY@ +# if !@HAVE_WCSNCPY@ +_GL_FUNCDECL_SYS (wcsncpy, wchar_t *, + (wchar_t *restrict dest, + const wchar_t *restrict src, size_t n)); +# endif +_GL_CXXALIAS_SYS (wcsncpy, wchar_t *, + (wchar_t *restrict dest, + const wchar_t *restrict src, size_t n)); +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (wcsncpy); +# endif +#elif defined GNULIB_POSIXCHECK +# undef wcsncpy +# if HAVE_RAW_DECL_WCSNCPY +_GL_WARN_ON_USE (wcsncpy, "wcsncpy is unportable - " + "use gnulib module wcsncpy for portability"); +# endif +#endif + + +/* Copy no more than N characters of SRC to DEST, returning the address of + the last character written into DEST. */ +#if @GNULIB_WCPNCPY@ +/* On Solaris 11.3, the header files declare the function in the std:: + namespace, not in the global namespace. So, force a declaration in + the global namespace. */ +# if !@HAVE_WCPNCPY@ || (defined __sun && defined __cplusplus) +_GL_FUNCDECL_SYS (wcpncpy, wchar_t *, + (wchar_t *restrict dest, + const wchar_t *restrict src, size_t n)); +# endif +_GL_CXXALIAS_SYS (wcpncpy, wchar_t *, + (wchar_t *restrict dest, + const wchar_t *restrict src, size_t n)); +_GL_CXXALIASWARN (wcpncpy); +#elif defined GNULIB_POSIXCHECK +# undef wcpncpy +# if HAVE_RAW_DECL_WCPNCPY +_GL_WARN_ON_USE (wcpncpy, "wcpncpy is unportable - " + "use gnulib module wcpncpy for portability"); +# endif +#endif + + +/* Append SRC onto DEST. */ +#if @GNULIB_WCSCAT@ +# if !@HAVE_WCSCAT@ +_GL_FUNCDECL_SYS (wcscat, wchar_t *, + (wchar_t *restrict dest, const wchar_t *restrict src)); +# endif +_GL_CXXALIAS_SYS (wcscat, wchar_t *, + (wchar_t *restrict dest, const wchar_t *restrict src)); +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (wcscat); +# endif +#elif defined GNULIB_POSIXCHECK +# undef wcscat +# if HAVE_RAW_DECL_WCSCAT +_GL_WARN_ON_USE (wcscat, "wcscat is unportable - " + "use gnulib module wcscat for portability"); +# endif +#endif + + +/* Append no more than N wide characters of SRC onto DEST. */ +#if @GNULIB_WCSNCAT@ +# if !@HAVE_WCSNCAT@ +_GL_FUNCDECL_SYS (wcsncat, wchar_t *, + (wchar_t *restrict dest, const wchar_t *restrict src, + size_t n)); +# endif +_GL_CXXALIAS_SYS (wcsncat, wchar_t *, + (wchar_t *restrict dest, const wchar_t *restrict src, + size_t n)); +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (wcsncat); +# endif +#elif defined GNULIB_POSIXCHECK +# undef wcsncat +# if HAVE_RAW_DECL_WCSNCAT +_GL_WARN_ON_USE (wcsncat, "wcsncat is unportable - " + "use gnulib module wcsncat for portability"); +# endif +#endif + + +/* Compare S1 and S2. */ +#if @GNULIB_WCSCMP@ +# if @REPLACE_WCSCMP@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef wcscmp +# define wcscmp rpl_wcscmp +# endif +_GL_FUNCDECL_RPL (wcscmp, int, (const wchar_t *s1, const wchar_t *s2) + _GL_ATTRIBUTE_PURE); +_GL_CXXALIAS_RPL (wcscmp, int, (const wchar_t *s1, const wchar_t *s2)); +# else +# if !@HAVE_WCSCMP@ +_GL_FUNCDECL_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2) + _GL_ATTRIBUTE_PURE); +# endif +_GL_CXXALIAS_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (wcscmp); +# endif +#elif defined GNULIB_POSIXCHECK +# undef wcscmp +# if HAVE_RAW_DECL_WCSCMP +_GL_WARN_ON_USE (wcscmp, "wcscmp is unportable - " + "use gnulib module wcscmp for portability"); +# endif +#endif + + +/* Compare no more than N wide characters of S1 and S2. */ +#if @GNULIB_WCSNCMP@ +# if @REPLACE_WCSNCMP@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef wcsncmp +# define wcsncmp rpl_wcsncmp +# endif +_GL_FUNCDECL_RPL (wcsncmp, int, + (const wchar_t *s1, const wchar_t *s2, size_t n) + _GL_ATTRIBUTE_PURE); +_GL_CXXALIAS_RPL (wcsncmp, int, + (const wchar_t *s1, const wchar_t *s2, size_t n)); +# else +# if !@HAVE_WCSNCMP@ +_GL_FUNCDECL_SYS (wcsncmp, int, + (const wchar_t *s1, const wchar_t *s2, size_t n) + _GL_ATTRIBUTE_PURE); +# endif +_GL_CXXALIAS_SYS (wcsncmp, int, + (const wchar_t *s1, const wchar_t *s2, size_t n)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (wcsncmp); +# endif +#elif defined GNULIB_POSIXCHECK +# undef wcsncmp +# if HAVE_RAW_DECL_WCSNCMP +_GL_WARN_ON_USE (wcsncmp, "wcsncmp is unportable - " + "use gnulib module wcsncmp for portability"); +# endif +#endif + + +/* Compare S1 and S2, ignoring case. */ +#if @GNULIB_WCSCASECMP@ +/* On Solaris 11.3, the header files declare the function in the std:: + namespace, not in the global namespace. So, force a declaration in + the global namespace. */ +# if !@HAVE_WCSCASECMP@ || (defined __sun && defined __cplusplus) +_GL_FUNCDECL_SYS (wcscasecmp, int, (const wchar_t *s1, const wchar_t *s2) + _GL_ATTRIBUTE_PURE); +# endif +_GL_CXXALIAS_SYS (wcscasecmp, int, (const wchar_t *s1, const wchar_t *s2)); +_GL_CXXALIASWARN (wcscasecmp); +#elif defined GNULIB_POSIXCHECK +# undef wcscasecmp +# if HAVE_RAW_DECL_WCSCASECMP +_GL_WARN_ON_USE (wcscasecmp, "wcscasecmp is unportable - " + "use gnulib module wcscasecmp for portability"); +# endif +#endif + + +/* Compare no more than N chars of S1 and S2, ignoring case. */ +#if @GNULIB_WCSNCASECMP@ +/* On Solaris 11.3, the header files declare the function in the std:: + namespace, not in the global namespace. So, force a declaration in + the global namespace. */ +# if !@HAVE_WCSNCASECMP@ || (defined __sun && defined __cplusplus) +_GL_FUNCDECL_SYS (wcsncasecmp, int, + (const wchar_t *s1, const wchar_t *s2, size_t n) + _GL_ATTRIBUTE_PURE); +# endif +_GL_CXXALIAS_SYS (wcsncasecmp, int, + (const wchar_t *s1, const wchar_t *s2, size_t n)); +_GL_CXXALIASWARN (wcsncasecmp); +#elif defined GNULIB_POSIXCHECK +# undef wcsncasecmp +# if HAVE_RAW_DECL_WCSNCASECMP +_GL_WARN_ON_USE (wcsncasecmp, "wcsncasecmp is unportable - " + "use gnulib module wcsncasecmp for portability"); +# endif +#endif + + +/* Compare S1 and S2, both interpreted as appropriate to the LC_COLLATE + category of the current locale. */ +#if @GNULIB_WCSCOLL@ +# if !@HAVE_WCSCOLL@ +_GL_FUNCDECL_SYS (wcscoll, int, (const wchar_t *s1, const wchar_t *s2)); +# endif +_GL_CXXALIAS_SYS (wcscoll, int, (const wchar_t *s1, const wchar_t *s2)); +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (wcscoll); +# endif +#elif defined GNULIB_POSIXCHECK +# undef wcscoll +# if HAVE_RAW_DECL_WCSCOLL +_GL_WARN_ON_USE (wcscoll, "wcscoll is unportable - " + "use gnulib module wcscoll for portability"); +# endif +#endif + + +/* Transform S2 into array pointed to by S1 such that if wcscmp is applied + to two transformed strings the result is the as applying 'wcscoll' to the + original strings. */ +#if @GNULIB_WCSXFRM@ +# if !@HAVE_WCSXFRM@ +_GL_FUNCDECL_SYS (wcsxfrm, size_t, + (wchar_t *restrict s1, const wchar_t *restrict s2, size_t n)); +# endif +_GL_CXXALIAS_SYS (wcsxfrm, size_t, + (wchar_t *restrict s1, const wchar_t *restrict s2, size_t n)); +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (wcsxfrm); +# endif +#elif defined GNULIB_POSIXCHECK +# undef wcsxfrm +# if HAVE_RAW_DECL_WCSXFRM +_GL_WARN_ON_USE (wcsxfrm, "wcsxfrm is unportable - " + "use gnulib module wcsxfrm for portability"); +# endif +#endif + + +/* Duplicate S, returning an identical malloc'd string. */ +#if @GNULIB_WCSDUP@ +# if defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef wcsdup +# define wcsdup _wcsdup +# endif +_GL_CXXALIAS_MDA (wcsdup, wchar_t *, (const wchar_t *s)); +# else +/* On Solaris 11.3, the header files declare the function in the std:: + namespace, not in the global namespace. So, force a declaration in + the global namespace. */ +# if !@HAVE_WCSDUP@ || (defined __sun && defined __cplusplus) || __GNUC__ >= 11 +# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 +_GL_FUNCDECL_SYS (wcsdup, wchar_t *, + (const wchar_t *s) + _GL_ATTRIBUTE_NOTHROW + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# else +_GL_FUNCDECL_SYS (wcsdup, wchar_t *, + (const wchar_t *s) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# endif +# endif +_GL_CXXALIAS_SYS (wcsdup, wchar_t *, (const wchar_t *s)); +# endif +_GL_CXXALIASWARN (wcsdup); +#else +# if __GNUC__ >= 11 && !defined wcsdup +/* For -Wmismatched-dealloc: Associate wcsdup with free or rpl_free. */ +# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 +_GL_FUNCDECL_SYS (wcsdup, wchar_t *, + (const wchar_t *s) + _GL_ATTRIBUTE_NOTHROW + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# else +_GL_FUNCDECL_SYS (wcsdup, wchar_t *, + (const wchar_t *s) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# endif +# endif +# if defined GNULIB_POSIXCHECK +# undef wcsdup +# if HAVE_RAW_DECL_WCSDUP +_GL_WARN_ON_USE (wcsdup, "wcsdup is unportable - " + "use gnulib module wcsdup for portability"); +# endif +# elif @GNULIB_MDA_WCSDUP@ +/* On native Windows, map 'wcsdup' to '_wcsdup', so that -loldnames is not + required. In C++ with GNULIB_NAMESPACE, avoid differences between + platforms by defining GNULIB_NAMESPACE::wcsdup always. */ +# if defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef wcsdup +# define wcsdup _wcsdup +# endif +_GL_CXXALIAS_MDA (wcsdup, wchar_t *, (const wchar_t *s)); +# else +# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 +_GL_FUNCDECL_SYS (wcsdup, wchar_t *, + (const wchar_t *s) + _GL_ATTRIBUTE_NOTHROW + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# else +_GL_FUNCDECL_SYS (wcsdup, wchar_t *, + (const wchar_t *s) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); +# endif +# if @HAVE_DECL_WCSDUP@ +_GL_CXXALIAS_SYS (wcsdup, wchar_t *, (const wchar_t *s)); +# endif +# endif +# if (defined _WIN32 && !defined __CYGWIN__) || @HAVE_DECL_WCSDUP@ +_GL_CXXALIASWARN (wcsdup); +# endif +# endif +#endif + + +/* Find the first occurrence of WC in WCS. */ +#if @GNULIB_WCSCHR@ +# if !@HAVE_WCSCHR@ +_GL_FUNCDECL_SYS (wcschr, wchar_t *, (const wchar_t *wcs, wchar_t wc) + _GL_ATTRIBUTE_PURE); +# endif + /* On some systems, this function is defined as an overloaded function: + extern "C++" { + const wchar_t * std::wcschr (const wchar_t *, wchar_t); + wchar_t * std::wcschr (wchar_t *, wchar_t); + } */ +_GL_CXXALIAS_SYS_CAST2 (wcschr, + wchar_t *, (const wchar_t *, wchar_t), + const wchar_t *, (const wchar_t *, wchar_t)); +# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ + && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) +_GL_CXXALIASWARN1 (wcschr, wchar_t *, (wchar_t *wcs, wchar_t wc)); +_GL_CXXALIASWARN1 (wcschr, const wchar_t *, (const wchar_t *wcs, wchar_t wc)); +# elif __GLIBC__ >= 2 +_GL_CXXALIASWARN (wcschr); +# endif +#elif defined GNULIB_POSIXCHECK +# undef wcschr +# if HAVE_RAW_DECL_WCSCHR +_GL_WARN_ON_USE (wcschr, "wcschr is unportable - " + "use gnulib module wcschr for portability"); +# endif +#endif + + +/* Find the last occurrence of WC in WCS. */ +#if @GNULIB_WCSRCHR@ +# if !@HAVE_WCSRCHR@ +_GL_FUNCDECL_SYS (wcsrchr, wchar_t *, (const wchar_t *wcs, wchar_t wc) + _GL_ATTRIBUTE_PURE); +# endif + /* On some systems, this function is defined as an overloaded function: + extern "C++" { + const wchar_t * std::wcsrchr (const wchar_t *, wchar_t); + wchar_t * std::wcsrchr (wchar_t *, wchar_t); + } */ +_GL_CXXALIAS_SYS_CAST2 (wcsrchr, + wchar_t *, (const wchar_t *, wchar_t), + const wchar_t *, (const wchar_t *, wchar_t)); +# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ + && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) +_GL_CXXALIASWARN1 (wcsrchr, wchar_t *, (wchar_t *wcs, wchar_t wc)); +_GL_CXXALIASWARN1 (wcsrchr, const wchar_t *, (const wchar_t *wcs, wchar_t wc)); +# elif __GLIBC__ >= 2 +_GL_CXXALIASWARN (wcsrchr); +# endif +#elif defined GNULIB_POSIXCHECK +# undef wcsrchr +# if HAVE_RAW_DECL_WCSRCHR +_GL_WARN_ON_USE (wcsrchr, "wcsrchr is unportable - " + "use gnulib module wcsrchr for portability"); +# endif +#endif + + +/* Return the length of the initial segment of WCS which consists entirely + of wide characters not in REJECT. */ +#if @GNULIB_WCSCSPN@ +# if !@HAVE_WCSCSPN@ +_GL_FUNCDECL_SYS (wcscspn, size_t, (const wchar_t *wcs, const wchar_t *reject) + _GL_ATTRIBUTE_PURE); +# endif +_GL_CXXALIAS_SYS (wcscspn, size_t, (const wchar_t *wcs, const wchar_t *reject)); +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (wcscspn); +# endif +#elif defined GNULIB_POSIXCHECK +# undef wcscspn +# if HAVE_RAW_DECL_WCSCSPN +_GL_WARN_ON_USE (wcscspn, "wcscspn is unportable - " + "use gnulib module wcscspn for portability"); +# endif +#endif + + +/* Return the length of the initial segment of WCS which consists entirely + of wide characters in ACCEPT. */ +#if @GNULIB_WCSSPN@ +# if !@HAVE_WCSSPN@ +_GL_FUNCDECL_SYS (wcsspn, size_t, (const wchar_t *wcs, const wchar_t *accept) + _GL_ATTRIBUTE_PURE); +# endif +_GL_CXXALIAS_SYS (wcsspn, size_t, (const wchar_t *wcs, const wchar_t *accept)); +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (wcsspn); +# endif +#elif defined GNULIB_POSIXCHECK +# undef wcsspn +# if HAVE_RAW_DECL_WCSSPN +_GL_WARN_ON_USE (wcsspn, "wcsspn is unportable - " + "use gnulib module wcsspn for portability"); +# endif +#endif + + +/* Find the first occurrence in WCS of any character in ACCEPT. */ +#if @GNULIB_WCSPBRK@ +# if !@HAVE_WCSPBRK@ +_GL_FUNCDECL_SYS (wcspbrk, wchar_t *, + (const wchar_t *wcs, const wchar_t *accept) + _GL_ATTRIBUTE_PURE); +# endif + /* On some systems, this function is defined as an overloaded function: + extern "C++" { + const wchar_t * std::wcspbrk (const wchar_t *, const wchar_t *); + wchar_t * std::wcspbrk (wchar_t *, const wchar_t *); + } */ +_GL_CXXALIAS_SYS_CAST2 (wcspbrk, + wchar_t *, (const wchar_t *, const wchar_t *), + const wchar_t *, (const wchar_t *, const wchar_t *)); +# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ + && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) +_GL_CXXALIASWARN1 (wcspbrk, wchar_t *, + (wchar_t *wcs, const wchar_t *accept)); +_GL_CXXALIASWARN1 (wcspbrk, const wchar_t *, + (const wchar_t *wcs, const wchar_t *accept)); +# elif __GLIBC__ >= 2 +_GL_CXXALIASWARN (wcspbrk); +# endif +#elif defined GNULIB_POSIXCHECK +# undef wcspbrk +# if HAVE_RAW_DECL_WCSPBRK +_GL_WARN_ON_USE (wcspbrk, "wcspbrk is unportable - " + "use gnulib module wcspbrk for portability"); +# endif +#endif + + +/* Find the first occurrence of NEEDLE in HAYSTACK. */ +#if @GNULIB_WCSSTR@ +# if @REPLACE_WCSSTR@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef wcsstr +# define wcsstr rpl_wcsstr +# endif +_GL_FUNCDECL_RPL (wcsstr, wchar_t *, + (const wchar_t *restrict haystack, + const wchar_t *restrict needle) + _GL_ATTRIBUTE_PURE); +_GL_CXXALIAS_RPL (wcsstr, wchar_t *, + (const wchar_t *restrict haystack, + const wchar_t *restrict needle)); +# else +# if !@HAVE_WCSSTR@ +_GL_FUNCDECL_SYS (wcsstr, wchar_t *, + (const wchar_t *restrict haystack, + const wchar_t *restrict needle) + _GL_ATTRIBUTE_PURE); +# endif + /* On some systems, this function is defined as an overloaded function: + extern "C++" { + const wchar_t * std::wcsstr (const wchar_t *, const wchar_t *); + wchar_t * std::wcsstr (wchar_t *, const wchar_t *); + } */ +_GL_CXXALIAS_SYS_CAST2 (wcsstr, + wchar_t *, + (const wchar_t *restrict, const wchar_t *restrict), + const wchar_t *, + (const wchar_t *restrict, const wchar_t *restrict)); +# endif +# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ + && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) +_GL_CXXALIASWARN1 (wcsstr, wchar_t *, + (wchar_t *restrict haystack, + const wchar_t *restrict needle)); +_GL_CXXALIASWARN1 (wcsstr, const wchar_t *, + (const wchar_t *restrict haystack, + const wchar_t *restrict needle)); +# elif __GLIBC__ >= 2 +_GL_CXXALIASWARN (wcsstr); +# endif +#elif defined GNULIB_POSIXCHECK +# undef wcsstr +# if HAVE_RAW_DECL_WCSSTR +_GL_WARN_ON_USE (wcsstr, "wcsstr is unportable - " + "use gnulib module wcsstr for portability"); +# endif +#endif + + +/* Divide WCS into tokens separated by characters in DELIM. */ +#if @GNULIB_WCSTOK@ +# if @REPLACE_WCSTOK@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef wcstok +# define wcstok rpl_wcstok +# endif +_GL_FUNCDECL_RPL (wcstok, wchar_t *, + (wchar_t *restrict wcs, const wchar_t *restrict delim, + wchar_t **restrict ptr)); +_GL_CXXALIAS_RPL (wcstok, wchar_t *, + (wchar_t *restrict wcs, const wchar_t *restrict delim, + wchar_t **restrict ptr)); +# else +# if !@HAVE_WCSTOK@ +_GL_FUNCDECL_SYS (wcstok, wchar_t *, + (wchar_t *restrict wcs, const wchar_t *restrict delim, + wchar_t **restrict ptr)); +# endif +_GL_CXXALIAS_SYS (wcstok, wchar_t *, + (wchar_t *restrict wcs, const wchar_t *restrict delim, + wchar_t **restrict ptr)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (wcstok); +# endif +#elif defined GNULIB_POSIXCHECK +# undef wcstok +# if HAVE_RAW_DECL_WCSTOK +_GL_WARN_ON_USE (wcstok, "wcstok is unportable - " + "use gnulib module wcstok for portability"); +# endif +#endif + + +/* Determine number of column positions required for first N wide + characters (or fewer if S ends before this) in S. */ +#if @GNULIB_WCSWIDTH@ +# if @REPLACE_WCSWIDTH@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef wcswidth +# define wcswidth rpl_wcswidth +# endif +_GL_FUNCDECL_RPL (wcswidth, int, (const wchar_t *s, size_t n) + _GL_ATTRIBUTE_PURE); +_GL_CXXALIAS_RPL (wcswidth, int, (const wchar_t *s, size_t n)); +# else +# if !@HAVE_WCSWIDTH@ +_GL_FUNCDECL_SYS (wcswidth, int, (const wchar_t *s, size_t n) + _GL_ATTRIBUTE_PURE); +# endif +_GL_CXXALIAS_SYS (wcswidth, int, (const wchar_t *s, size_t n)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (wcswidth); +# endif +#elif defined GNULIB_POSIXCHECK +# undef wcswidth +# if HAVE_RAW_DECL_WCSWIDTH +_GL_WARN_ON_USE (wcswidth, "wcswidth is unportable - " + "use gnulib module wcswidth for portability"); +# endif +#endif + + +/* Convert *TP to a date and time wide string. See + . */ +#if @GNULIB_WCSFTIME@ +# if @REPLACE_WCSFTIME@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef wcsftime +# define wcsftime rpl_wcsftime +# endif +_GL_FUNCDECL_RPL (wcsftime, size_t, + (wchar_t *restrict __buf, size_t __bufsize, + const wchar_t *restrict __fmt, + const struct tm *restrict __tp) + _GL_ARG_NONNULL ((1, 3, 4))); +_GL_CXXALIAS_RPL (wcsftime, size_t, + (wchar_t *restrict __buf, size_t __bufsize, + const wchar_t *restrict __fmt, + const struct tm *restrict __tp)); +# else +# if !@HAVE_WCSFTIME@ +_GL_FUNCDECL_SYS (wcsftime, size_t, + (wchar_t *restrict __buf, size_t __bufsize, + const wchar_t *restrict __fmt, + const struct tm *restrict __tp) + _GL_ARG_NONNULL ((1, 3, 4))); +# endif +_GL_CXXALIAS_SYS (wcsftime, size_t, + (wchar_t *restrict __buf, size_t __bufsize, + const wchar_t *restrict __fmt, + const struct tm *restrict __tp)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (wcsftime); +# endif +#elif defined GNULIB_POSIXCHECK +# undef wcsftime +# if HAVE_RAW_DECL_WCSFTIME +_GL_WARN_ON_USE (wcsftime, "wcsftime is unportable - " + "use gnulib module wcsftime for portability"); +# endif +#endif + + +#if @GNULIB_WGETCWD@ && (defined _WIN32 && !defined __CYGWIN__) +/* Gets the name of the current working directory. + (a) If BUF is non-NULL, it is assumed to have room for SIZE wide characters. + This function stores the working directory (NUL-terminated) in BUF and + returns BUF. + (b) If BUF is NULL, an array is allocated with 'malloc'. The array is SIZE + wide characters long, unless SIZE == 0, in which case it is as big as + necessary. + If the directory couldn't be determined or SIZE was too small, this function + returns NULL and sets errno. For a directory of length LEN, SIZE should be + >= LEN + 3 in case (a) or >= LEN + 1 in case (b). + Possible errno values include: + - ERANGE if SIZE is too small. + - ENOMEM if the memory could no be allocated. */ +_GL_FUNCDECL_SYS (wgetcwd, wchar_t *, (wchar_t *buf, size_t size)); +#endif + + +#endif /* _@GUARD_PREFIX@_WCHAR_H */ +#endif /* _@GUARD_PREFIX@_WCHAR_H */ +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/wcrtomb.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/wcrtomb.c new file mode 100644 index 00000000..197b020e --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/wcrtomb.c @@ -0,0 +1,80 @@ +/* Convert wide character to multibyte character. + Copyright (C) 2008-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2008. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +#include +#include + + +size_t +wcrtomb (char *s, wchar_t wc, mbstate_t *ps) +#undef wcrtomb +{ + /* This implementation of wcrtomb supports only stateless encodings. + ps must be in an initial state. */ + if (ps != NULL && !mbsinit (ps)) + { + errno = EINVAL; + return (size_t)(-1); + } + +#if !HAVE_WCRTOMB /* IRIX 6.5 */ \ + || WCRTOMB_RETVAL_BUG /* Solaris 11.3, MSVC */ \ + || WCRTOMB_C_LOCALE_BUG /* Android */ + if (s == NULL) + /* We know the NUL wide character corresponds to the NUL character. */ + return 1; + else +#endif + { +#if HAVE_WCRTOMB +# if WCRTOMB_C_LOCALE_BUG /* Android */ + /* Implement consistently with mbrtowc(): through a 1:1 correspondence, + as in ISO-8859-1. */ + if (wc >= 0 && wc <= 0xff) + { + *s = (unsigned char) wc; + return 1; + } + else + { + errno = EILSEQ; + return (size_t)(-1); + } +# else + return wcrtomb (s, wc, ps); +# endif +#else /* IRIX 6.5 */ + /* Fallback for platforms that don't have wcrtomb(). + Implement on top of wctomb(). + This code is not multithread-safe. */ + int ret = wctomb (s, wc); + + if (ret >= 0) + return ret; + else + { + errno = EILSEQ; + return (size_t)(-1); + } +#endif + } +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/wctype-h.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/wctype-h.c new file mode 100644 index 00000000..7e4ff13a --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/wctype-h.c @@ -0,0 +1,23 @@ +/* Inline functions for . + + Copyright (C) 2012-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Normally this would be wctype.c, but that name's already taken. */ + +#include + +#define _GL_WCTYPE_INLINE _GL_EXTERN_INLINE +#include diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/wctype-impl.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/wctype-impl.h new file mode 100644 index 00000000..26d68b41 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/wctype-impl.h @@ -0,0 +1,96 @@ +/* Get descriptor for a wide character property. + Copyright (C) 2011-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2011. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +wctype_t +wctype (const char* name) +{ + switch (name[0]) + { + case 'a': + switch (name[1]) + { + case 'l': + switch (name[2]) + { + case 'n': + if (strcmp (name + 3, "um") == 0) + return (wctype_t) iswalnum; + break; + case 'p': + if (strcmp (name + 3, "ha") == 0) + return (wctype_t) iswalpha; + break; + default: + break; + } + break; + default: + break; + } + break; + case 'b': + if (strcmp (name + 1, "lank") == 0) + return (wctype_t) iswblank; + break; + case 'c': + if (strcmp (name + 1, "ntrl") == 0) + return (wctype_t) iswcntrl; + break; + case 'd': + if (strcmp (name + 1, "igit") == 0) + return (wctype_t) iswdigit; + break; + case 'g': + if (strcmp (name + 1, "raph") == 0) + return (wctype_t) iswgraph; + break; + case 'l': + if (strcmp (name + 1, "ower") == 0) + return (wctype_t) iswlower; + break; + case 'p': + switch (name[1]) + { + case 'r': + if (strcmp (name + 2, "int") == 0) + return (wctype_t) iswprint; + break; + case 'u': + if (strcmp (name + 2, "nct") == 0) + return (wctype_t) iswpunct; + break; + default: + break; + } + break; + case 's': + if (strcmp (name + 1, "pace") == 0) + return (wctype_t) iswspace; + break; + case 'u': + if (strcmp (name + 1, "pper") == 0) + return (wctype_t) iswupper; + break; + case 'x': + if (strcmp (name + 1, "digit") == 0) + return (wctype_t) iswxdigit; + break; + default: + break; + } + return NULL; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/wctype.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/wctype.c new file mode 100644 index 00000000..914f6847 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/wctype.c @@ -0,0 +1,25 @@ +/* Get descriptor for a wide character property. + Copyright (C) 2011-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2011. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +#include + +#include "wctype-impl.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/wctype.in.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/wctype.in.h new file mode 100644 index 00000000..851c4f4e --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/wctype.in.h @@ -0,0 +1,797 @@ +/* A substitute for ISO C99 , for platforms that lack it. + + Copyright (C) 2006-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible and Paul Eggert. */ + +/* + * ISO C 99 for platforms that lack it. + * + * + * iswctype, towctrans, towlower, towupper, wctrans, wctype, + * wctrans_t, and wctype_t are not yet implemented. + */ + +#if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +#endif +@PRAGMA_COLUMNS@ + +#if (defined __MINGW32__ && defined __CTYPE_H_SOURCED__) + +/* Special invocation convention: + - With MinGW 3.22, when includes , only some part of + is being processed, which doesn't include the idempotency + guard. */ + +#@INCLUDE_NEXT@ @NEXT_WCTYPE_H@ + +#else +/* Normal invocation convention. */ + +#ifndef _@GUARD_PREFIX@_WCTYPE_H + +/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, GNULIB_POSIXCHECK, + HAVE_RAW_DECL_*. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +#if @HAVE_WINT_T@ +/* Solaris 2.5 has a bug: must be included before . */ +# include +#endif + +/* Native Windows (mingw, MSVC) have declarations of towupper, towlower, and + isw* functions in , as well as in . Include + , in advance to avoid rpl_ prefix being added to the + declarations. */ +#if defined _WIN32 && ! defined __CYGWIN__ +# include +# include +#endif + +/* Include the original if it exists. + BeOS 5 has the functions but no . */ +/* The include_next requires a split double-inclusion guard. */ +#if @HAVE_WCTYPE_H@ +# @INCLUDE_NEXT@ @NEXT_WCTYPE_H@ +#endif + +#ifndef _@GUARD_PREFIX@_WCTYPE_H +#define _@GUARD_PREFIX@_WCTYPE_H + +_GL_INLINE_HEADER_BEGIN +#ifndef _GL_WCTYPE_INLINE +# define _GL_WCTYPE_INLINE _GL_INLINE +#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. */ + +/* Solaris 2.6 includes which includes which + #defines a number of identifiers in the application namespace. Revert + these #defines. */ +#ifdef __sun +# undef multibyte +# undef eucw1 +# undef eucw2 +# undef eucw3 +# undef scrw1 +# undef scrw2 +# undef scrw3 +#endif + +/* Define wint_t and WEOF. (Also done in wchar.in.h.) */ +#if !@HAVE_WINT_T@ && !defined wint_t +# define wint_t int +# ifndef WEOF +# define WEOF -1 +# endif +#else +/* mingw and MSVC define wint_t as 'unsigned short' in or + . This is too small: ISO C 99 section 7.24.1.(2) says that + wint_t must be "unchanged by default argument promotions". Override it. */ +# if @GNULIBHEADERS_OVERRIDE_WINT_T@ +# if !GNULIB_defined_wint_t +# if @HAVE_CRTDEFS_H@ +# include +# else +# include +# endif +typedef unsigned int rpl_wint_t; +# undef wint_t +# define wint_t rpl_wint_t +# define GNULIB_defined_wint_t 1 +# endif +# endif +# ifndef WEOF +# define WEOF ((wint_t) -1) +# endif +#endif + + +#if !GNULIB_defined_wctype_functions + +/* FreeBSD 4.4 to 4.11 has but lacks the functions. + Linux libc5 has and the functions but they are broken. + mingw and MSVC have and the functions but they take a wchar_t + as argument, not an rpl_wint_t. Additionally, the mingw iswprint function + and the Android iswpunct function are broken. + Assume all 11 functions (all isw* except iswblank) are implemented the + same way, or not at all. */ +# if ! @HAVE_ISWCNTRL@ || @REPLACE_ISWCNTRL@ + +# if @GNULIBHEADERS_OVERRIDE_WINT_T@ /* implies @REPLACE_ISWCNTRL@ */ + +_GL_WCTYPE_INLINE int +rpl_iswalnum (wint_t wc) +{ + return ((wchar_t) wc == wc ? iswalnum ((wchar_t) wc) : 0); +} + +_GL_WCTYPE_INLINE int +rpl_iswalpha (wint_t wc) +{ + return ((wchar_t) wc == wc ? iswalpha ((wchar_t) wc) : 0); +} + +_GL_WCTYPE_INLINE int +rpl_iswblank (wint_t wc) +{ + return ((wchar_t) wc == wc ? iswblank ((wchar_t) wc) : 0); +} + +_GL_WCTYPE_INLINE int +rpl_iswcntrl (wint_t wc) +{ + return ((wchar_t) wc == wc ? iswcntrl ((wchar_t) wc) : 0); +} + +_GL_WCTYPE_INLINE int +rpl_iswdigit (wint_t wc) +{ + return ((wchar_t) wc == wc ? wc >= '0' && wc <= '9' : 0); +} + +_GL_WCTYPE_INLINE int +rpl_iswgraph (wint_t wc) +{ + return ((wchar_t) wc == wc ? iswgraph ((wchar_t) wc) : 0); +} + +_GL_WCTYPE_INLINE int +rpl_iswlower (wint_t wc) +{ + return ((wchar_t) wc == wc ? iswlower ((wchar_t) wc) : 0); +} + +_GL_WCTYPE_INLINE int +rpl_iswprint (wint_t wc) +{ +# ifdef __MINGW32__ + return ((wchar_t) wc == wc ? wc == ' ' || iswgraph ((wchar_t) wc) : 0); +# else + return ((wchar_t) wc == wc ? iswprint ((wchar_t) wc) : 0); +# endif +} + +_GL_WCTYPE_INLINE int +rpl_iswpunct (wint_t wc) +{ + return ((wchar_t) wc == wc ? iswpunct ((wchar_t) wc) : 0); +} + +_GL_WCTYPE_INLINE int +rpl_iswspace (wint_t wc) +{ + return ((wchar_t) wc == wc ? iswspace ((wchar_t) wc) : 0); +} + +_GL_WCTYPE_INLINE int +rpl_iswupper (wint_t wc) +{ + return ((wchar_t) wc == wc ? iswupper ((wchar_t) wc) : 0); +} + +_GL_WCTYPE_INLINE int +rpl_iswxdigit (wint_t wc) +{ + return ((wchar_t) wc == wc + ? (wc >= '0' && wc <= '9') + || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'F') + : 0); +} + +_GL_WCTYPE_INLINE wint_t +rpl_towlower (wint_t wc) +{ + return ((wchar_t) wc == wc ? (wchar_t) towlower ((wchar_t) wc) : wc); +} + +_GL_WCTYPE_INLINE wint_t +rpl_towupper (wint_t wc) +{ + return ((wchar_t) wc == wc ? (wchar_t) towupper ((wchar_t) wc) : wc); +} + +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef iswalnum +# undef iswalpha +# undef iswblank +# undef iswcntrl +# undef iswdigit +# undef iswgraph +# undef iswlower +# undef iswprint +# undef iswpunct +# undef iswspace +# undef iswupper +# undef iswxdigit +# undef towlower +# undef towupper +# define iswalnum rpl_iswalnum +# define iswalpha rpl_iswalpha +# define iswblank rpl_iswblank +# define iswcntrl rpl_iswcntrl +# define iswdigit rpl_iswdigit +# define iswgraph rpl_iswgraph +# define iswlower rpl_iswlower +# define iswprint rpl_iswprint +# define iswpunct rpl_iswpunct +# define iswspace rpl_iswspace +# define iswupper rpl_iswupper +# define iswxdigit rpl_iswxdigit +# define towlower rpl_towlower +# define towupper rpl_towupper +# endif + +# else + +/* IRIX 5.3 has macros but no functions, its isw* macros refer to an + undefined variable _ctmp_ and to macros like _P, and they + refer to system functions like _iswctype that are not in the + standard C library. Rather than try to get ancient buggy + implementations like this to work, just disable them. */ +# undef iswalnum +# undef iswalpha +# undef iswblank +# undef iswcntrl +# undef iswdigit +# undef iswgraph +# undef iswlower +# undef iswprint +# undef iswpunct +# undef iswspace +# undef iswupper +# undef iswxdigit +# undef towlower +# undef towupper + +/* Linux libc5 has and the functions but they are broken. */ +# if @REPLACE_ISWCNTRL@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define iswalnum rpl_iswalnum +# define iswalpha rpl_iswalpha +# define iswblank rpl_iswblank +# define iswcntrl rpl_iswcntrl +# define iswdigit rpl_iswdigit +# define iswgraph rpl_iswgraph +# define iswlower rpl_iswlower +# define iswprint rpl_iswprint +# define iswpunct rpl_iswpunct +# define iswspace rpl_iswspace +# define iswupper rpl_iswupper +# define iswxdigit rpl_iswxdigit +# endif +# endif +# if @REPLACE_TOWLOWER@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define towlower rpl_towlower +# define towupper rpl_towupper +# endif +# endif + +_GL_WCTYPE_INLINE int +# if @REPLACE_ISWCNTRL@ +rpl_iswalnum +# else +iswalnum +# endif + (wint_t wc) +{ + return ((wc >= '0' && wc <= '9') + || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z')); +} + +_GL_WCTYPE_INLINE int +# if @REPLACE_ISWCNTRL@ +rpl_iswalpha +# else +iswalpha +# endif + (wint_t wc) +{ + return (wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z'; +} + +_GL_WCTYPE_INLINE int +# if @REPLACE_ISWCNTRL@ +rpl_iswblank +# else +iswblank +# endif + (wint_t wc) +{ + return wc == ' ' || wc == '\t'; +} + +_GL_WCTYPE_INLINE int +# if @REPLACE_ISWCNTRL@ +rpl_iswcntrl +# else +iswcntrl +# endif + (wint_t wc) +{ + return (wc & ~0x1f) == 0 || wc == 0x7f; +} + +_GL_WCTYPE_INLINE int +# if @REPLACE_ISWDIGIT@ +rpl_iswdigit +# else +iswdigit +# endif + (wint_t wc) +{ + return wc >= '0' && wc <= '9'; +} + +_GL_WCTYPE_INLINE int +# if @REPLACE_ISWCNTRL@ +rpl_iswgraph +# else +iswgraph +# endif + (wint_t wc) +{ + return wc >= '!' && wc <= '~'; +} + +_GL_WCTYPE_INLINE int +# if @REPLACE_ISWCNTRL@ +rpl_iswlower +# else +iswlower +# endif + (wint_t wc) +{ + return wc >= 'a' && wc <= 'z'; +} + +_GL_WCTYPE_INLINE int +# if @REPLACE_ISWCNTRL@ +rpl_iswprint +# else +iswprint +# endif + (wint_t wc) +{ + return wc >= ' ' && wc <= '~'; +} + +_GL_WCTYPE_INLINE int +# if @REPLACE_ISWCNTRL@ +rpl_iswpunct +# else +iswpunct +# endif + (wint_t wc) +{ + return (wc >= '!' && wc <= '~' + && !((wc >= '0' && wc <= '9') + || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z'))); +} + +_GL_WCTYPE_INLINE int +# if @REPLACE_ISWCNTRL@ +rpl_iswspace +# else +iswspace +# endif + (wint_t wc) +{ + return (wc == ' ' || wc == '\t' + || wc == '\n' || wc == '\v' || wc == '\f' || wc == '\r'); +} + +_GL_WCTYPE_INLINE int +# if @REPLACE_ISWCNTRL@ +rpl_iswupper +# else +iswupper +# endif + (wint_t wc) +{ + return wc >= 'A' && wc <= 'Z'; +} + +_GL_WCTYPE_INLINE int +# if @REPLACE_ISWXDIGIT@ +rpl_iswxdigit +# else +iswxdigit +# endif + (wint_t wc) +{ + return ((wc >= '0' && wc <= '9') + || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'F')); +} + +_GL_WCTYPE_INLINE wint_t +# if @REPLACE_TOWLOWER@ +rpl_towlower +# else +towlower +# endif + (wint_t wc) +{ + return (wc >= 'A' && wc <= 'Z' ? wc - 'A' + 'a' : wc); +} + +_GL_WCTYPE_INLINE wint_t +# if @REPLACE_TOWLOWER@ +rpl_towupper +# else +towupper +# endif + (wint_t wc) +{ + return (wc >= 'a' && wc <= 'z' ? wc - 'a' + 'A' : wc); +} + +# endif + +# else +/* Only some of the functions are missing or broken. */ + +# if @GNULIB_ISWBLANK@ && (! @HAVE_ISWBLANK@ || @REPLACE_ISWBLANK@) +/* Only the iswblank function is missing. */ +# if @REPLACE_ISWBLANK@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define iswblank rpl_iswblank +# endif +_GL_FUNCDECL_RPL (iswblank, int, (wint_t wc)); +# else +_GL_FUNCDECL_SYS (iswblank, int, (wint_t wc)); +# endif +# endif + +# if @GNULIB_ISWDIGIT@ +# if @REPLACE_ISWDIGIT@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef iswdigit +# define iswdigit rpl_iswdigit +# endif +_GL_FUNCDECL_RPL (iswdigit, int, (wint_t wc)); +# endif +# endif + +# if @GNULIB_ISWPUNCT@ +# if @REPLACE_ISWPUNCT@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef iswpunct +# define iswpunct rpl_iswpunct +# endif +_GL_FUNCDECL_RPL (iswpunct, int, (wint_t wc)); +# endif +# endif + +# if @GNULIB_ISWXDIGIT@ +# if @REPLACE_ISWXDIGIT@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef iswxdigit +# define iswxdigit rpl_iswxdigit +# endif +_GL_FUNCDECL_RPL (iswxdigit, int, (wint_t wc)); +# endif +# endif + +# endif + +# if defined __MINGW32__ && !@GNULIBHEADERS_OVERRIDE_WINT_T@ + +/* On native Windows, wchar_t is uint16_t, and wint_t is uint32_t. + The functions towlower and towupper are implemented in the MSVCRT library + to take a wchar_t argument and return a wchar_t result. mingw declares + these functions to take a wint_t argument and return a wint_t result. + This means that: + 1. When the user passes an argument outside the range 0x0000..0xFFFF, the + function will look only at the lower 16 bits. This is allowed according + to POSIX. + 2. The return value is returned in the lower 16 bits of the result register. + The upper 16 bits are random: whatever happened to be in that part of the + result register. We need to fix this by adding a zero-extend from + wchar_t to wint_t after the call. */ + +_GL_WCTYPE_INLINE wint_t +rpl_towlower (wint_t wc) +{ + return (wint_t) (wchar_t) towlower (wc); +} +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define towlower rpl_towlower +# endif + +_GL_WCTYPE_INLINE wint_t +rpl_towupper (wint_t wc) +{ + return (wint_t) (wchar_t) towupper (wc); +} +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define towupper rpl_towupper +# endif + +# endif /* __MINGW32__ && !@GNULIBHEADERS_OVERRIDE_WINT_T@ */ + +# define GNULIB_defined_wctype_functions 1 +#endif + +#if @REPLACE_ISWCNTRL@ +_GL_CXXALIAS_RPL (iswalnum, int, (wint_t wc)); +#else +_GL_CXXALIAS_SYS (iswalnum, int, (wint_t wc)); +#endif +#if @REPLACE_ISWCNTRL@ +_GL_CXXALIAS_RPL (iswalpha, int, (wint_t wc)); +#else +_GL_CXXALIAS_SYS (iswalpha, int, (wint_t wc)); +#endif +#if @REPLACE_ISWCNTRL@ +_GL_CXXALIAS_RPL (iswcntrl, int, (wint_t wc)); +#else +_GL_CXXALIAS_SYS (iswcntrl, int, (wint_t wc)); +#endif +#if @GNULIB_ISWDIGIT@ +# if @REPLACE_ISWDIGIT@ +_GL_CXXALIAS_RPL (iswdigit, int, (wint_t wc)); +# else +_GL_CXXALIAS_SYS (iswdigit, int, (wint_t wc)); +# endif +#endif +#if @REPLACE_ISWCNTRL@ +_GL_CXXALIAS_RPL (iswgraph, int, (wint_t wc)); +#else +_GL_CXXALIAS_SYS (iswgraph, int, (wint_t wc)); +#endif +#if @REPLACE_ISWCNTRL@ +_GL_CXXALIAS_RPL (iswlower, int, (wint_t wc)); +#else +_GL_CXXALIAS_SYS (iswlower, int, (wint_t wc)); +#endif +#if @REPLACE_ISWCNTRL@ +_GL_CXXALIAS_RPL (iswprint, int, (wint_t wc)); +#else +_GL_CXXALIAS_SYS (iswprint, int, (wint_t wc)); +#endif +#if @REPLACE_ISWCNTRL@ +_GL_CXXALIAS_RPL (iswpunct, int, (wint_t wc)); +#else +_GL_CXXALIAS_SYS (iswpunct, int, (wint_t wc)); +#endif +#if @REPLACE_ISWCNTRL@ +_GL_CXXALIAS_RPL (iswspace, int, (wint_t wc)); +#else +_GL_CXXALIAS_SYS (iswspace, int, (wint_t wc)); +#endif +#if @REPLACE_ISWCNTRL@ +_GL_CXXALIAS_RPL (iswupper, int, (wint_t wc)); +#else +_GL_CXXALIAS_SYS (iswupper, int, (wint_t wc)); +#endif +#if @GNULIB_ISWXDIGIT@ +# if @REPLACE_ISWXDIGIT@ +_GL_CXXALIAS_RPL (iswxdigit, int, (wint_t wc)); +# else +_GL_CXXALIAS_SYS (iswxdigit, int, (wint_t wc)); +# endif +#endif +#if __GLIBC__ >= 2 +_GL_CXXALIASWARN (iswalnum); +_GL_CXXALIASWARN (iswalpha); +_GL_CXXALIASWARN (iswcntrl); +_GL_CXXALIASWARN (iswdigit); +_GL_CXXALIASWARN (iswgraph); +_GL_CXXALIASWARN (iswlower); +_GL_CXXALIASWARN (iswprint); +_GL_CXXALIASWARN (iswpunct); +_GL_CXXALIASWARN (iswspace); +_GL_CXXALIASWARN (iswupper); +_GL_CXXALIASWARN (iswxdigit); +#endif + +#if @GNULIB_ISWBLANK@ +# if @REPLACE_ISWCNTRL@ || @REPLACE_ISWBLANK@ +_GL_CXXALIAS_RPL (iswblank, int, (wint_t wc)); +# else +_GL_CXXALIAS_SYS (iswblank, int, (wint_t wc)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (iswblank); +# endif +#endif + +#if !@HAVE_WCTYPE_T@ +# if !GNULIB_defined_wctype_t +typedef void * wctype_t; +# define GNULIB_defined_wctype_t 1 +# endif +#elif @REPLACE_WCTYPE@ +# if !GNULIB_defined_wctype_t +typedef void *rpl_wctype_t; +# undef wctype_t +# define wctype_t rpl_wctype_t +# define GNULIB_defined_wctype_t 1 +# endif +#endif + +/* Get a descriptor for a wide character property. */ +#if @GNULIB_WCTYPE@ +# if @REPLACE_WCTYPE@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef wctype +# define wctype rpl_wctype +# endif +_GL_FUNCDECL_RPL (wctype, wctype_t, (const char *name) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (wctype, wctype_t, (const char *name)); +# else +# if !@HAVE_WCTYPE_T@ +_GL_FUNCDECL_SYS (wctype, wctype_t, (const char *name) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (wctype, wctype_t, (const char *name)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (wctype); +# endif +#elif defined GNULIB_POSIXCHECK +# undef wctype +# if HAVE_RAW_DECL_WCTYPE +_GL_WARN_ON_USE (wctype, "wctype is unportable - " + "use gnulib module wctype for portability"); +# endif +#endif + +/* Test whether a wide character has a given property. + The argument WC must be either a wchar_t value or WEOF. + The argument DESC must have been returned by the wctype() function. */ +#if @GNULIB_ISWCTYPE@ +# if @GNULIBHEADERS_OVERRIDE_WINT_T@ || @REPLACE_WCTYPE@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef iswctype +# define iswctype rpl_iswctype +# endif +_GL_FUNCDECL_RPL (iswctype, int, (wint_t wc, wctype_t desc)); +_GL_CXXALIAS_RPL (iswctype, int, (wint_t wc, wctype_t desc)); +# else +# if !@HAVE_WCTYPE_T@ +_GL_FUNCDECL_SYS (iswctype, int, (wint_t wc, wctype_t desc)); +# endif +_GL_CXXALIAS_SYS (iswctype, int, (wint_t wc, wctype_t desc)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (iswctype); +# endif +#elif defined GNULIB_POSIXCHECK +# undef iswctype +# if HAVE_RAW_DECL_ISWCTYPE +_GL_WARN_ON_USE (iswctype, "iswctype is unportable - " + "use gnulib module iswctype for portability"); +# endif +#endif + +#if @REPLACE_TOWLOWER@ || defined __MINGW32__ +_GL_CXXALIAS_RPL (towlower, wint_t, (wint_t wc)); +_GL_CXXALIAS_RPL (towupper, wint_t, (wint_t wc)); +#else +_GL_CXXALIAS_SYS (towlower, wint_t, (wint_t wc)); +_GL_CXXALIAS_SYS (towupper, wint_t, (wint_t wc)); +#endif +#if __GLIBC__ >= 2 +_GL_CXXALIASWARN (towlower); +_GL_CXXALIASWARN (towupper); +#endif + +#if !@HAVE_WCTRANS_T@ +# if !GNULIB_defined_wctrans_t +typedef void * wctrans_t; +# define GNULIB_defined_wctrans_t 1 +# endif +#elif @REPLACE_WCTRANS@ +# if !GNULIB_defined_wctrans_t +typedef void *rpl_wctrans_t; +# undef wctrans_t +# define wctrans_t rpl_wctrans_t +# define GNULIB_defined_wctrans_t 1 +# endif +#endif + +/* Get a descriptor for a wide character case conversion. */ +#if @GNULIB_WCTRANS@ +# if @REPLACE_WCTRANS@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef wctrans +# define wctrans rpl_wctrans +# endif +_GL_FUNCDECL_RPL (wctrans, wctrans_t, (const char *name) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (wctrans, wctrans_t, (const char *name)); +# else +# if !@HAVE_WCTRANS_T@ +_GL_FUNCDECL_SYS (wctrans, wctrans_t, (const char *name) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (wctrans, wctrans_t, (const char *name)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (wctrans); +# endif +#elif defined GNULIB_POSIXCHECK +# undef wctrans +# if HAVE_RAW_DECL_WCTRANS +_GL_WARN_ON_USE (wctrans, "wctrans is unportable - " + "use gnulib module wctrans for portability"); +# endif +#endif + +/* Perform a given case conversion on a wide character. + The argument WC must be either a wchar_t value or WEOF. + The argument DESC must have been returned by the wctrans() function. */ +#if @GNULIB_TOWCTRANS@ +# if @REPLACE_WCTRANS@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef towctrans +# define towctrans rpl_towctrans +# endif +_GL_FUNCDECL_RPL (towctrans, wint_t, (wint_t wc, wctrans_t desc)); +_GL_CXXALIAS_RPL (towctrans, wint_t, (wint_t wc, wctrans_t desc)); +# else +# if !@HAVE_WCTRANS_T@ +_GL_FUNCDECL_SYS (towctrans, wint_t, (wint_t wc, wctrans_t desc)); +# endif +_GL_CXXALIAS_SYS (towctrans, wint_t, (wint_t wc, wctrans_t desc)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (towctrans); +# endif +#elif defined GNULIB_POSIXCHECK +# undef towctrans +# if HAVE_RAW_DECL_TOWCTRANS +_GL_WARN_ON_USE (towctrans, "towctrans is unportable - " + "use gnulib module towctrans for portability"); +# endif +#endif + +_GL_INLINE_HEADER_END + +#endif /* _@GUARD_PREFIX@_WCTYPE_H */ +#endif /* _@GUARD_PREFIX@_WCTYPE_H */ +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/wcwidth.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/wcwidth.c new file mode 100644 index 00000000..328a8930 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/wcwidth.c @@ -0,0 +1,73 @@ +/* Determine the number of screen columns needed for a character. + Copyright (C) 2006-2007, 2010-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +/* Get iswprint. */ +#include + +#include "localcharset.h" +#include "streq.h" +#include "uniwidth.h" + +/* Returns 1 if the current locale is an UTF-8 locale, 0 otherwise. */ +static inline int +is_locale_utf8 (void) +{ + const char *encoding = locale_charset (); + return STREQ_OPT (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0, 0); +} + +#if GNULIB_WCHAR_SINGLE_LOCALE +/* When we know that the locale does not change, provide a speedup by + caching the value of is_locale_utf8. */ +static int cached_is_locale_utf8 = -1; +static inline int +is_locale_utf8_cached (void) +{ + if (cached_is_locale_utf8 < 0) + cached_is_locale_utf8 = is_locale_utf8 (); + return cached_is_locale_utf8; +} +#else +/* By default, don't make assumptions, hence no caching. */ +# define is_locale_utf8_cached is_locale_utf8 +#endif + +int +wcwidth (wchar_t wc) +#undef wcwidth +{ + /* In UTF-8 locales, use a Unicode aware width function. */ + if (is_locale_utf8_cached ()) + { + /* We assume that in a UTF-8 locale, a wide character is the same as a + Unicode character. */ + return uc_width (wc, "UTF-8"); + } + else + { + /* Otherwise, fall back to the system's wcwidth function. */ +#if HAVE_WCWIDTH + return wcwidth (wc); +#else + return wc == 0 ? 0 : iswprint (wc) ? 1 : -1; +#endif + } +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/windows-initguard.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/windows-initguard.h new file mode 100644 index 00000000..6bace3f0 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/windows-initguard.h @@ -0,0 +1,35 @@ +/* Init guards, somewhat like spinlocks (native Windows implementation). + Copyright (C) 2005-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 2005. + Based on GCC's gthr-win32.h. */ + +#ifndef _WINDOWS_INITGUARD_H +#define _WINDOWS_INITGUARD_H + +#define WIN32_LEAN_AND_MEAN /* avoid including junk */ +#include + +typedef struct + { + volatile int done; + volatile LONG started; + } + glwthread_initguard_t; + +#define GLWTHREAD_INITGUARD_INIT { 0, -1 } + +#endif /* _WINDOWS_INITGUARD_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/windows-mutex.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/windows-mutex.c new file mode 100644 index 00000000..b112e13b --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/windows-mutex.c @@ -0,0 +1,95 @@ +/* Plain mutexes (native Windows implementation). + Copyright (C) 2005-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 2005. + Based on GCC's gthr-win32.h. */ + +#include + +/* Specification. */ +#include "windows-mutex.h" + +#include + +void +glwthread_mutex_init (glwthread_mutex_t *mutex) +{ + InitializeCriticalSection (&mutex->lock); + mutex->guard.done = 1; +} + +int +glwthread_mutex_lock (glwthread_mutex_t *mutex) +{ + if (!mutex->guard.done) + { + if (InterlockedIncrement (&mutex->guard.started) == 0) + /* This thread is the first one to need this mutex. Initialize it. */ + glwthread_mutex_init (mutex); + else + { + /* Don't let mutex->guard.started grow and wrap around. */ + InterlockedDecrement (&mutex->guard.started); + /* Yield the CPU while waiting for another thread to finish + initializing this mutex. */ + while (!mutex->guard.done) + Sleep (0); + } + } + EnterCriticalSection (&mutex->lock); + return 0; +} + +int +glwthread_mutex_trylock (glwthread_mutex_t *mutex) +{ + if (!mutex->guard.done) + { + if (InterlockedIncrement (&mutex->guard.started) == 0) + /* This thread is the first one to need this mutex. Initialize it. */ + glwthread_mutex_init (mutex); + else + { + /* Don't let mutex->guard.started grow and wrap around. */ + InterlockedDecrement (&mutex->guard.started); + /* Let another thread finish initializing this mutex, and let it also + lock this mutex. */ + return EBUSY; + } + } + if (!TryEnterCriticalSection (&mutex->lock)) + return EBUSY; + return 0; +} + +int +glwthread_mutex_unlock (glwthread_mutex_t *mutex) +{ + if (!mutex->guard.done) + return EINVAL; + LeaveCriticalSection (&mutex->lock); + return 0; +} + +int +glwthread_mutex_destroy (glwthread_mutex_t *mutex) +{ + if (!mutex->guard.done) + return EINVAL; + DeleteCriticalSection (&mutex->lock); + mutex->guard.done = 0; + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/windows-mutex.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/windows-mutex.h new file mode 100644 index 00000000..88de4bdc --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/windows-mutex.h @@ -0,0 +1,51 @@ +/* Plain mutexes (native Windows implementation). + Copyright (C) 2005-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 2005. + Based on GCC's gthr-win32.h. */ + +#ifndef _WINDOWS_MUTEX_H +#define _WINDOWS_MUTEX_H + +#define WIN32_LEAN_AND_MEAN /* avoid including junk */ +#include + +#include "windows-initguard.h" + +typedef struct + { + glwthread_initguard_t guard; /* protects the initialization */ + CRITICAL_SECTION lock; + } + glwthread_mutex_t; + +#define GLWTHREAD_MUTEX_INIT { GLWTHREAD_INITGUARD_INIT } + +#ifdef __cplusplus +extern "C" { +#endif + +extern void glwthread_mutex_init (glwthread_mutex_t *mutex); +extern int glwthread_mutex_lock (glwthread_mutex_t *mutex); +extern int glwthread_mutex_trylock (glwthread_mutex_t *mutex); +extern int glwthread_mutex_unlock (glwthread_mutex_t *mutex); +extern int glwthread_mutex_destroy (glwthread_mutex_t *mutex); + +#ifdef __cplusplus +} +#endif + +#endif /* _WINDOWS_MUTEX_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/windows-once.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/windows-once.c new file mode 100644 index 00000000..17854f5c --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/windows-once.c @@ -0,0 +1,62 @@ +/* Once-only control (native Windows implementation). + Copyright (C) 2005-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 2005. + Based on GCC's gthr-win32.h. */ + +#include + +/* Specification. */ +#include "windows-once.h" + +#include + +void +glwthread_once (glwthread_once_t *once_control, void (*initfunction) (void)) +{ + if (once_control->inited <= 0) + { + if (InterlockedIncrement (&once_control->started) == 0) + { + /* This thread is the first one to come to this once_control. */ + InitializeCriticalSection (&once_control->lock); + EnterCriticalSection (&once_control->lock); + once_control->inited = 0; + initfunction (); + once_control->inited = 1; + LeaveCriticalSection (&once_control->lock); + } + else + { + /* Don't let once_control->started grow and wrap around. */ + InterlockedDecrement (&once_control->started); + /* Some other thread has already started the initialization. + Yield the CPU while waiting for the other thread to finish + initializing and taking the lock. */ + while (once_control->inited < 0) + Sleep (0); + if (once_control->inited <= 0) + { + /* Take the lock. This blocks until the other thread has + finished calling the initfunction. */ + EnterCriticalSection (&once_control->lock); + LeaveCriticalSection (&once_control->lock); + if (!(once_control->inited > 0)) + abort (); + } + } + } +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/windows-once.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/windows-once.h new file mode 100644 index 00000000..c5bbcd57 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/windows-once.h @@ -0,0 +1,47 @@ +/* Once-only control (native Windows implementation). + Copyright (C) 2005-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 2005. + Based on GCC's gthr-win32.h. */ + +#ifndef _WINDOWS_ONCE_H +#define _WINDOWS_ONCE_H + +#define WIN32_LEAN_AND_MEAN /* avoid including junk */ +#include + +typedef struct + { + volatile int inited; + volatile LONG started; + CRITICAL_SECTION lock; + } + glwthread_once_t; + +#define GLWTHREAD_ONCE_INIT { -1, -1 } + +#ifdef __cplusplus +extern "C" { +#endif + +extern void glwthread_once (glwthread_once_t *once_control, + void (*initfunction) (void)); + +#ifdef __cplusplus +} +#endif + +#endif /* _WINDOWS_ONCE_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/windows-recmutex.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/windows-recmutex.c new file mode 100644 index 00000000..e5672baf --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/windows-recmutex.c @@ -0,0 +1,127 @@ +/* Plain recursive mutexes (native Windows implementation). + Copyright (C) 2005-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 2005. + Based on GCC's gthr-win32.h. */ + +#include + +/* Specification. */ +#include "windows-recmutex.h" + +#include + +void +glwthread_recmutex_init (glwthread_recmutex_t *mutex) +{ + mutex->owner = 0; + mutex->depth = 0; + InitializeCriticalSection (&mutex->lock); + mutex->guard.done = 1; +} + +int +glwthread_recmutex_lock (glwthread_recmutex_t *mutex) +{ + if (!mutex->guard.done) + { + if (InterlockedIncrement (&mutex->guard.started) == 0) + /* This thread is the first one to need this mutex. Initialize it. */ + glwthread_recmutex_init (mutex); + else + { + /* Don't let mutex->guard.started grow and wrap around. */ + InterlockedDecrement (&mutex->guard.started); + /* Yield the CPU while waiting for another thread to finish + initializing this mutex. */ + while (!mutex->guard.done) + Sleep (0); + } + } + { + DWORD self = GetCurrentThreadId (); + if (mutex->owner != self) + { + EnterCriticalSection (&mutex->lock); + mutex->owner = self; + } + if (++(mutex->depth) == 0) /* wraparound? */ + { + mutex->depth--; + return EAGAIN; + } + } + return 0; +} + +int +glwthread_recmutex_trylock (glwthread_recmutex_t *mutex) +{ + if (!mutex->guard.done) + { + if (InterlockedIncrement (&mutex->guard.started) == 0) + /* This thread is the first one to need this mutex. Initialize it. */ + glwthread_recmutex_init (mutex); + else + { + /* Don't let mutex->guard.started grow and wrap around. */ + InterlockedDecrement (&mutex->guard.started); + /* Let another thread finish initializing this mutex, and let it also + lock this mutex. */ + return EBUSY; + } + } + { + DWORD self = GetCurrentThreadId (); + if (mutex->owner != self) + { + if (!TryEnterCriticalSection (&mutex->lock)) + return EBUSY; + mutex->owner = self; + } + if (++(mutex->depth) == 0) /* wraparound? */ + { + mutex->depth--; + return EAGAIN; + } + } + return 0; +} + +int +glwthread_recmutex_unlock (glwthread_recmutex_t *mutex) +{ + if (mutex->owner != GetCurrentThreadId ()) + return EPERM; + if (mutex->depth == 0) + return EINVAL; + if (--(mutex->depth) == 0) + { + mutex->owner = 0; + LeaveCriticalSection (&mutex->lock); + } + return 0; +} + +int +glwthread_recmutex_destroy (glwthread_recmutex_t *mutex) +{ + if (mutex->owner != 0) + return EBUSY; + DeleteCriticalSection (&mutex->lock); + mutex->guard.done = 0; + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/windows-recmutex.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/windows-recmutex.h new file mode 100644 index 00000000..9fa445b3 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/windows-recmutex.h @@ -0,0 +1,57 @@ +/* Plain recursive mutexes (native Windows implementation). + Copyright (C) 2005-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 2005. + Based on GCC's gthr-win32.h. */ + +#ifndef _WINDOWS_RECMUTEX_H +#define _WINDOWS_RECMUTEX_H + +#define WIN32_LEAN_AND_MEAN /* avoid including junk */ +#include + +#include "windows-initguard.h" + +/* The native Windows documentation says that CRITICAL_SECTION already + implements a recursive lock. But we need not rely on it: It's easy to + implement a recursive lock without this assumption. */ + +typedef struct + { + glwthread_initguard_t guard; /* protects the initialization */ + DWORD owner; + unsigned long depth; + CRITICAL_SECTION lock; + } + glwthread_recmutex_t; + +#define GLWTHREAD_RECMUTEX_INIT { GLWTHREAD_INITGUARD_INIT, 0, 0 } + +#ifdef __cplusplus +extern "C" { +#endif + +extern void glwthread_recmutex_init (glwthread_recmutex_t *mutex); +extern int glwthread_recmutex_lock (glwthread_recmutex_t *mutex); +extern int glwthread_recmutex_trylock (glwthread_recmutex_t *mutex); +extern int glwthread_recmutex_unlock (glwthread_recmutex_t *mutex); +extern int glwthread_recmutex_destroy (glwthread_recmutex_t *mutex); + +#ifdef __cplusplus +} +#endif + +#endif /* _WINDOWS_RECMUTEX_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/windows-rwlock.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/windows-rwlock.c new file mode 100644 index 00000000..e60c4efc --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/windows-rwlock.c @@ -0,0 +1,377 @@ +/* Read-write locks (native Windows implementation). + Copyright (C) 2005-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 2005. + Based on GCC's gthr-win32.h. */ + +#include + +/* Specification. */ +#include "windows-rwlock.h" + +#include +#include + +/* Don't assume that UNICODE is not defined. */ +#undef CreateEvent +#define CreateEvent CreateEventA + +/* In this file, the waitqueues are implemented as circular arrays. */ +#define glwthread_waitqueue_t glwthread_carray_waitqueue_t + +static void +glwthread_waitqueue_init (glwthread_waitqueue_t *wq) +{ + wq->array = NULL; + wq->count = 0; + wq->alloc = 0; + wq->offset = 0; +} + +/* Enqueues the current thread, represented by an event, in a wait queue. + Returns INVALID_HANDLE_VALUE if an allocation failure occurs. */ +static HANDLE +glwthread_waitqueue_add (glwthread_waitqueue_t *wq) +{ + HANDLE event; + unsigned int index; + + if (wq->count == wq->alloc) + { + unsigned int new_alloc = 2 * wq->alloc + 1; + HANDLE *new_array = + (HANDLE *) realloc (wq->array, new_alloc * sizeof (HANDLE)); + if (new_array == NULL) + /* No more memory. */ + return INVALID_HANDLE_VALUE; + /* Now is a good opportunity to rotate the array so that its contents + starts at offset 0. */ + if (wq->offset > 0) + { + unsigned int old_count = wq->count; + unsigned int old_alloc = wq->alloc; + unsigned int old_offset = wq->offset; + unsigned int i; + if (old_offset + old_count > old_alloc) + { + unsigned int limit = old_offset + old_count - old_alloc; + for (i = 0; i < limit; i++) + new_array[old_alloc + i] = new_array[i]; + } + for (i = 0; i < old_count; i++) + new_array[i] = new_array[old_offset + i]; + wq->offset = 0; + } + wq->array = new_array; + wq->alloc = new_alloc; + } + /* Whether the created event is a manual-reset one or an auto-reset one, + does not matter, since we will wait on it only once. */ + event = CreateEvent (NULL, TRUE, FALSE, NULL); + if (event == INVALID_HANDLE_VALUE) + /* No way to allocate an event. */ + return INVALID_HANDLE_VALUE; + index = wq->offset + wq->count; + if (index >= wq->alloc) + index -= wq->alloc; + wq->array[index] = event; + wq->count++; + return event; +} + +/* Notifies the first thread from a wait queue and dequeues it. */ +static void +glwthread_waitqueue_notify_first (glwthread_waitqueue_t *wq) +{ + SetEvent (wq->array[wq->offset + 0]); + wq->offset++; + wq->count--; + if (wq->count == 0 || wq->offset == wq->alloc) + wq->offset = 0; +} + +/* Notifies all threads from a wait queue and dequeues them all. */ +static void +glwthread_waitqueue_notify_all (glwthread_waitqueue_t *wq) +{ + unsigned int i; + + for (i = 0; i < wq->count; i++) + { + unsigned int index = wq->offset + i; + if (index >= wq->alloc) + index -= wq->alloc; + SetEvent (wq->array[index]); + } + wq->count = 0; + wq->offset = 0; +} + +void +glwthread_rwlock_init (glwthread_rwlock_t *lock) +{ + InitializeCriticalSection (&lock->lock); + glwthread_waitqueue_init (&lock->waiting_readers); + glwthread_waitqueue_init (&lock->waiting_writers); + lock->runcount = 0; + lock->guard.done = 1; +} + +int +glwthread_rwlock_rdlock (glwthread_rwlock_t *lock) +{ + if (!lock->guard.done) + { + if (InterlockedIncrement (&lock->guard.started) == 0) + /* This thread is the first one to need this lock. Initialize it. */ + glwthread_rwlock_init (lock); + else + { + /* Don't let lock->guard.started grow and wrap around. */ + InterlockedDecrement (&lock->guard.started); + /* Yield the CPU while waiting for another thread to finish + initializing this lock. */ + while (!lock->guard.done) + Sleep (0); + } + } + EnterCriticalSection (&lock->lock); + /* 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". */ + if (!(lock->runcount + 1 > 0 && lock->waiting_writers.count == 0)) + { + /* This thread has to wait for a while. Enqueue it among the + waiting_readers. */ + HANDLE event = glwthread_waitqueue_add (&lock->waiting_readers); + if (event != INVALID_HANDLE_VALUE) + { + DWORD result; + LeaveCriticalSection (&lock->lock); + /* Wait until another thread signals this event. */ + result = WaitForSingleObject (event, INFINITE); + if (result == WAIT_FAILED || result == WAIT_TIMEOUT) + abort (); + CloseHandle (event); + /* The thread which signalled the event already did the bookkeeping: + removed us from the waiting_readers, incremented lock->runcount. */ + if (!(lock->runcount > 0)) + abort (); + return 0; + } + else + { + /* Allocation failure. Weird. */ + do + { + LeaveCriticalSection (&lock->lock); + Sleep (1); + EnterCriticalSection (&lock->lock); + } + while (!(lock->runcount + 1 > 0)); + } + } + lock->runcount++; + LeaveCriticalSection (&lock->lock); + return 0; +} + +int +glwthread_rwlock_wrlock (glwthread_rwlock_t *lock) +{ + if (!lock->guard.done) + { + if (InterlockedIncrement (&lock->guard.started) == 0) + /* This thread is the first one to need this lock. Initialize it. */ + glwthread_rwlock_init (lock); + else + { + /* Don't let lock->guard.started grow and wrap around. */ + InterlockedDecrement (&lock->guard.started); + /* Yield the CPU while waiting for another thread to finish + initializing this lock. */ + while (!lock->guard.done) + Sleep (0); + } + } + EnterCriticalSection (&lock->lock); + /* Test whether no readers or writers are currently running. */ + if (!(lock->runcount == 0)) + { + /* This thread has to wait for a while. Enqueue it among the + waiting_writers. */ + HANDLE event = glwthread_waitqueue_add (&lock->waiting_writers); + if (event != INVALID_HANDLE_VALUE) + { + DWORD result; + LeaveCriticalSection (&lock->lock); + /* Wait until another thread signals this event. */ + result = WaitForSingleObject (event, INFINITE); + if (result == WAIT_FAILED || result == WAIT_TIMEOUT) + abort (); + CloseHandle (event); + /* The thread which signalled the event already did the bookkeeping: + removed us from the waiting_writers, set lock->runcount = -1. */ + if (!(lock->runcount == -1)) + abort (); + return 0; + } + else + { + /* Allocation failure. Weird. */ + do + { + LeaveCriticalSection (&lock->lock); + Sleep (1); + EnterCriticalSection (&lock->lock); + } + while (!(lock->runcount == 0)); + } + } + lock->runcount--; /* runcount becomes -1 */ + LeaveCriticalSection (&lock->lock); + return 0; +} + +int +glwthread_rwlock_tryrdlock (glwthread_rwlock_t *lock) +{ + if (!lock->guard.done) + { + if (InterlockedIncrement (&lock->guard.started) == 0) + /* This thread is the first one to need this lock. Initialize it. */ + glwthread_rwlock_init (lock); + else + { + /* Don't let lock->guard.started grow and wrap around. */ + InterlockedDecrement (&lock->guard.started); + /* Yield the CPU while waiting for another thread to finish + initializing this lock. */ + while (!lock->guard.done) + Sleep (0); + } + } + /* It's OK to wait for this critical section, because it is never taken for a + long time. */ + EnterCriticalSection (&lock->lock); + /* 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". */ + if (!(lock->runcount + 1 > 0 && lock->waiting_writers.count == 0)) + { + /* This thread would have to wait for a while. Return instead. */ + LeaveCriticalSection (&lock->lock); + return EBUSY; + } + lock->runcount++; + LeaveCriticalSection (&lock->lock); + return 0; +} + +int +glwthread_rwlock_trywrlock (glwthread_rwlock_t *lock) +{ + if (!lock->guard.done) + { + if (InterlockedIncrement (&lock->guard.started) == 0) + /* This thread is the first one to need this lock. Initialize it. */ + glwthread_rwlock_init (lock); + else + { + /* Don't let lock->guard.started grow and wrap around. */ + InterlockedDecrement (&lock->guard.started); + /* Yield the CPU while waiting for another thread to finish + initializing this lock. */ + while (!lock->guard.done) + Sleep (0); + } + } + /* It's OK to wait for this critical section, because it is never taken for a + long time. */ + EnterCriticalSection (&lock->lock); + /* Test whether no readers or writers are currently running. */ + if (!(lock->runcount == 0)) + { + /* This thread would have to wait for a while. Return instead. */ + LeaveCriticalSection (&lock->lock); + return EBUSY; + } + lock->runcount--; /* runcount becomes -1 */ + LeaveCriticalSection (&lock->lock); + return 0; +} + +int +glwthread_rwlock_unlock (glwthread_rwlock_t *lock) +{ + if (!lock->guard.done) + return EINVAL; + EnterCriticalSection (&lock->lock); + if (lock->runcount < 0) + { + /* Drop a writer lock. */ + if (!(lock->runcount == -1)) + abort (); + lock->runcount = 0; + } + else + { + /* Drop a reader lock. */ + if (!(lock->runcount > 0)) + { + LeaveCriticalSection (&lock->lock); + return EPERM; + } + 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. */ + lock->runcount--; + glwthread_waitqueue_notify_first (&lock->waiting_writers); + } + else + { + /* Wake up all waiting readers. */ + lock->runcount += lock->waiting_readers.count; + glwthread_waitqueue_notify_all (&lock->waiting_readers); + } + } + LeaveCriticalSection (&lock->lock); + return 0; +} + +int +glwthread_rwlock_destroy (glwthread_rwlock_t *lock) +{ + if (!lock->guard.done) + return EINVAL; + if (lock->runcount != 0) + return EBUSY; + DeleteCriticalSection (&lock->lock); + if (lock->waiting_readers.array != NULL) + free (lock->waiting_readers.array); + if (lock->waiting_writers.array != NULL) + free (lock->waiting_writers.array); + lock->guard.done = 0; + return 0; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/windows-rwlock.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/windows-rwlock.h new file mode 100644 index 00000000..08d67750 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/windows-rwlock.h @@ -0,0 +1,68 @@ +/* Read-write locks (native Windows implementation). + Copyright (C) 2005-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 2005. + Based on GCC's gthr-win32.h. */ + +#ifndef _WINDOWS_RWLOCK_H +#define _WINDOWS_RWLOCK_H + +#define WIN32_LEAN_AND_MEAN /* avoid including junk */ +#include + +#include "windows-initguard.h" + +/* It is impossible to implement read-write locks using plain locks, without + introducing an extra thread dedicated to managing read-write locks. + Therefore here we need to use the low-level Event type. */ + +typedef struct + { + HANDLE *array; /* array of waiting threads, each represented by an event */ + unsigned int count; /* number of waiting threads */ + unsigned int alloc; /* length of allocated array */ + unsigned int offset; /* index of first waiting thread in array */ + } + glwthread_carray_waitqueue_t; +typedef struct + { + glwthread_initguard_t guard; /* protects the initialization */ + CRITICAL_SECTION lock; /* protects the remaining fields */ + glwthread_carray_waitqueue_t waiting_readers; /* waiting readers */ + glwthread_carray_waitqueue_t waiting_writers; /* waiting writers */ + int runcount; /* number of readers running, or -1 when a writer runs */ + } + glwthread_rwlock_t; + +#define GLWTHREAD_RWLOCK_INIT { GLWTHREAD_INITGUARD_INIT } + +#ifdef __cplusplus +extern "C" { +#endif + +extern void glwthread_rwlock_init (glwthread_rwlock_t *lock); +extern int glwthread_rwlock_rdlock (glwthread_rwlock_t *lock); +extern int glwthread_rwlock_wrlock (glwthread_rwlock_t *lock); +extern int glwthread_rwlock_tryrdlock (glwthread_rwlock_t *lock); +extern int glwthread_rwlock_trywrlock (glwthread_rwlock_t *lock); +extern int glwthread_rwlock_unlock (glwthread_rwlock_t *lock); +extern int glwthread_rwlock_destroy (glwthread_rwlock_t *lock); + +#ifdef __cplusplus +} +#endif + +#endif /* _WINDOWS_RWLOCK_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/wmemchr-impl.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/wmemchr-impl.h new file mode 100644 index 00000000..0cdecb8a --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/wmemchr-impl.h @@ -0,0 +1,27 @@ +/* Search wide character array for a wide character. + Copyright (C) 1999, 2011-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 1999. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +wchar_t * +wmemchr (const wchar_t *s, wchar_t c, size_t n) +{ + for (; n > 0; s++, n--) + { + if (*s == c) + return (wchar_t *) s; + } + return NULL; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/wmemchr.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/wmemchr.c new file mode 100644 index 00000000..268d81b1 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/wmemchr.c @@ -0,0 +1,23 @@ +/* Search wide character array for a wide character. + Copyright (C) 2011-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2011. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +#include "wmemchr-impl.h" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/wmempcpy.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/wmempcpy.c new file mode 100644 index 00000000..d0163f52 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/wmempcpy.c @@ -0,0 +1,28 @@ +/* Copy wide character array, return pointer after last written wide character. + Copyright (C) 2020-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +/* Copy N wide characters of SRC to DEST. + Return pointer to wide characters after the last written wide character. */ +wchar_t * +wmempcpy (wchar_t *dest, const wchar_t *src, size_t n) +{ + return wmemcpy (dest, src, n) + n; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/xalloc-die.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/xalloc-die.c new file mode 100644 index 00000000..c053c7a8 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/xalloc-die.c @@ -0,0 +1,41 @@ +/* Report a memory allocation failure and exit. + + Copyright (C) 1997-2000, 2002-2004, 2006, 2009-2024 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 . */ + +#include + +#include "xalloc.h" + +#include + +#include +#include "exitfail.h" + +#include "gettext.h" +#define _(msgid) gettext (msgid) + +void +xalloc_die (void) +{ + error (exit_failure, 0, "%s", _("memory exhausted")); + + /* _Noreturn cannot be given to error, since it may return if + its first argument is 0. To help compilers understand the + xalloc_die does not return, call abort. Also, the abort is a + safety feature if exit_failure is 0 (which shouldn't happen). */ + abort (); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/xalloc-oversized.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/xalloc-oversized.h new file mode 100644 index 00000000..0b7bb2ce --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/xalloc-oversized.h @@ -0,0 +1,65 @@ +/* xalloc-oversized.h -- memory allocation size checking + + Copyright (C) 1990-2000, 2003-2004, 2006-2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifndef XALLOC_OVERSIZED_H_ +#define XALLOC_OVERSIZED_H_ + +#include +#include + +/* True if N * S does not fit into both ptrdiff_t and size_t. + N and S should be nonnegative and free of side effects. + This expands to a constant expression if N and S are both constants. + By gnulib convention, SIZE_MAX represents overflow in size_t + calculations, so the conservative size_t-based dividend to use here + is SIZE_MAX - 1. */ +#define __xalloc_oversized(n, s) \ + ((s) != 0 \ + && ((size_t) (PTRDIFF_MAX < SIZE_MAX ? PTRDIFF_MAX : SIZE_MAX - 1) / (s) \ + < (n))) + +/* Return 1 if and only if an array of N objects, each of size S, + cannot exist reliably because its total size in bytes would exceed + MIN (PTRDIFF_MAX, SIZE_MAX - 1). + + N and S should be nonnegative and free of side effects. + + Warning: (xalloc_oversized (N, S) ? NULL : malloc (N * S)) can + misbehave if N and S are both narrower than ptrdiff_t and size_t, + and can be rewritten as (xalloc_oversized (N, S) ? NULL + : malloc (N * (size_t) S)). + + This is a macro, not a function, so that it works even if an + argument exceeds MAX (PTRDIFF_MAX, SIZE_MAX). */ +#if 7 <= __GNUC__ && !defined __clang__ && PTRDIFF_MAX < SIZE_MAX +# define xalloc_oversized(n, s) \ + __builtin_mul_overflow_p (n, s, (ptrdiff_t) 1) +#elif 5 <= __GNUC__ && !defined __ICC && PTRDIFF_MAX < SIZE_MAX +# define xalloc_oversized(n, s) \ + (__builtin_constant_p (n) && __builtin_constant_p (s) \ + ? __xalloc_oversized (n, s) \ + : __extension__ \ + ({ ptrdiff_t __xalloc_count; \ + __builtin_mul_overflow (n, s, &__xalloc_count); })) + +/* Other compilers use integer division; this may be slower but is + more portable. */ +#else +# define xalloc_oversized(n, s) __xalloc_oversized (n, s) +#endif + +#endif /* !XALLOC_OVERSIZED_H_ */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/xalloc.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/xalloc.h new file mode 100644 index 00000000..75a5db30 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/xalloc.h @@ -0,0 +1,215 @@ +/* xalloc.h -- malloc with out-of-memory checking + + Copyright (C) 1990-2000, 2003-2004, 2006-2024 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 . */ + +#ifndef XALLOC_H_ +#define XALLOC_H_ + +/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, _Noreturn, + _GL_ATTRIBUTE_ALLOC_SIZE, _GL_ATTRIBUTE_MALLOC, + _GL_ATTRIBUTE_RETURNS_NONNULL. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +#include +#include + +#if GNULIB_XALLOC +# include "idx.h" +#endif + +_GL_INLINE_HEADER_BEGIN +#ifndef XALLOC_INLINE +# define XALLOC_INLINE _GL_INLINE +#endif + + +#ifdef __cplusplus +extern "C" { +#endif + + +#if GNULIB_XALLOC_DIE + +/* This function is always triggered when memory is exhausted. + It must be defined by the application, either explicitly + or by using gnulib's xalloc-die module. This is the + function to call when one wants the program to die because of a + memory allocation failure. */ +_Noreturn void xalloc_die (void); + +#endif /* GNULIB_XALLOC_DIE */ + +#if GNULIB_XALLOC + +void *xmalloc (size_t s) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE + _GL_ATTRIBUTE_ALLOC_SIZE ((1)) _GL_ATTRIBUTE_RETURNS_NONNULL; +void *ximalloc (idx_t s) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE + _GL_ATTRIBUTE_ALLOC_SIZE ((1)) _GL_ATTRIBUTE_RETURNS_NONNULL; +void *xinmalloc (idx_t n, idx_t s) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE + _GL_ATTRIBUTE_ALLOC_SIZE ((1, 2)) _GL_ATTRIBUTE_RETURNS_NONNULL; +void *xzalloc (size_t s) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE + _GL_ATTRIBUTE_ALLOC_SIZE ((1)) _GL_ATTRIBUTE_RETURNS_NONNULL; +void *xizalloc (idx_t s) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE + _GL_ATTRIBUTE_ALLOC_SIZE ((1)) _GL_ATTRIBUTE_RETURNS_NONNULL; +void *xcalloc (size_t n, size_t s) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE + _GL_ATTRIBUTE_ALLOC_SIZE ((1, 2)) _GL_ATTRIBUTE_RETURNS_NONNULL; +void *xicalloc (idx_t n, idx_t s) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE + _GL_ATTRIBUTE_ALLOC_SIZE ((1, 2)) _GL_ATTRIBUTE_RETURNS_NONNULL; +void *xrealloc (void *p, size_t s) + _GL_ATTRIBUTE_ALLOC_SIZE ((2)); +void *xirealloc (void *p, idx_t s) + _GL_ATTRIBUTE_ALLOC_SIZE ((2)) _GL_ATTRIBUTE_RETURNS_NONNULL; +void *xreallocarray (void *p, size_t n, size_t s) + _GL_ATTRIBUTE_ALLOC_SIZE ((2, 3)); +void *xireallocarray (void *p, idx_t n, idx_t s) + _GL_ATTRIBUTE_ALLOC_SIZE ((2, 3)) _GL_ATTRIBUTE_RETURNS_NONNULL; +void *x2realloc (void *p, size_t *ps) /* superseded by xpalloc */ + _GL_ATTRIBUTE_RETURNS_NONNULL; +void *x2nrealloc (void *p, size_t *pn, size_t s) /* superseded by xpalloc */ + _GL_ATTRIBUTE_RETURNS_NONNULL; +void *xpalloc (void *pa, idx_t *pn, idx_t n_incr_min, ptrdiff_t n_max, idx_t s) + _GL_ATTRIBUTE_RETURNS_NONNULL; +void *xmemdup (void const *p, size_t s) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE + _GL_ATTRIBUTE_ALLOC_SIZE ((2)) _GL_ATTRIBUTE_RETURNS_NONNULL; +void *ximemdup (void const *p, idx_t s) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE + _GL_ATTRIBUTE_ALLOC_SIZE ((2)) _GL_ATTRIBUTE_RETURNS_NONNULL; +char *ximemdup0 (void const *p, idx_t s) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE + _GL_ATTRIBUTE_RETURNS_NONNULL; +char *xstrdup (char const *str) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE + _GL_ATTRIBUTE_RETURNS_NONNULL; + +/* In the following macros, T must be an elementary or structure/union or + typedef'ed type, or a pointer to such a type. To apply one of the + following macros to a function pointer or array type, you need to typedef + it first and use the typedef name. */ + +/* Allocate an object of type T dynamically, with error checking. */ +/* extern t *XMALLOC (typename t); */ +# define XMALLOC(t) ((t *) xmalloc (sizeof (t))) + +/* Allocate memory for N elements of type T, with error checking. */ +/* extern t *XNMALLOC (size_t n, typename t); */ +# define XNMALLOC(n, t) \ + ((t *) (sizeof (t) == 1 ? xmalloc (n) : xnmalloc (n, sizeof (t)))) + +/* Allocate an object of type T dynamically, with error checking, + and zero it. */ +/* extern t *XZALLOC (typename t); */ +# define XZALLOC(t) ((t *) xzalloc (sizeof (t))) + +/* Allocate memory for N elements of type T, with error checking, + and zero it. */ +/* extern t *XCALLOC (size_t n, typename t); */ +# define XCALLOC(n, t) \ + ((t *) (sizeof (t) == 1 ? xzalloc (n) : xcalloc (n, sizeof (t)))) + + +/* Allocate an array of N objects, each with S bytes of memory, + dynamically, with error checking. S must be nonzero. */ + +void *xnmalloc (size_t n, size_t s) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE + _GL_ATTRIBUTE_ALLOC_SIZE ((1, 2)) _GL_ATTRIBUTE_RETURNS_NONNULL; + +/* FIXME: Deprecate this in favor of xreallocarray? */ +/* Change the size of an allocated block of memory P to an array of N + objects each of S bytes, with error checking. S must be nonzero. */ + +XALLOC_INLINE void *xnrealloc (void *p, size_t n, size_t s) + _GL_ATTRIBUTE_ALLOC_SIZE ((2, 3)); +XALLOC_INLINE void * +xnrealloc (void *p, size_t n, size_t s) +{ + return xreallocarray (p, n, s); +} + +/* Return a pointer to a new buffer of N bytes. This is like xmalloc, + except it returns char *. */ + +char *xcharalloc (size_t n) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE + _GL_ATTRIBUTE_ALLOC_SIZE ((1)) _GL_ATTRIBUTE_RETURNS_NONNULL; + +#endif /* GNULIB_XALLOC */ + + +#ifdef __cplusplus +} +#endif + + +#if GNULIB_XALLOC && defined __cplusplus + +/* C++ does not allow conversions from void * to other pointer types + without a cast. Use templates to work around the problem when + possible. */ + +template inline T * +xrealloc (T *p, size_t s) +{ + return (T *) xrealloc ((void *) p, s); +} + +template inline T * +xreallocarray (T *p, size_t n, size_t s) +{ + return (T *) xreallocarray ((void *) p, n, s); +} + +/* FIXME: Deprecate this in favor of xreallocarray? */ +template inline T * +xnrealloc (T *p, size_t n, size_t s) +{ + return xreallocarray (p, n, s); +} + +template inline T * +x2realloc (T *p, size_t *pn) +{ + return (T *) x2realloc ((void *) p, pn); +} + +template inline T * +x2nrealloc (T *p, size_t *pn, size_t s) +{ + return (T *) x2nrealloc ((void *) p, pn, s); +} + +template inline T * +xmemdup (T const *p, size_t s) +{ + return (T *) xmemdup ((void const *) p, s); +} + +#endif /* GNULIB_XALLOC && C++ */ + + +_GL_INLINE_HEADER_END + +#endif /* !XALLOC_H_ */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/xfreopen.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/xfreopen.c new file mode 100644 index 00000000..8289d34c --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/xfreopen.c @@ -0,0 +1,41 @@ +/* Open a file, reusing a given stream, with error checking. + Copyright (C) 2008-2024 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 . */ + +#include +#include "xfreopen.h" + +#include +#include +#include "exitfail.h" +#include "quote.h" + +#include "gettext.h" +#define _(msgid) gettext (msgid) + +void +xfreopen (char const *filename, char const *mode, FILE *fp) +{ + if (!freopen (filename, mode, fp)) + { + char const *f = (filename ? filename + : (fp == stdin ? _("stdin") + : (fp == stdout ? _("stdout") + : (fp == stderr ? _("stderr") + : _("unknown stream"))))); + error (exit_failure, errno, _("failed to reopen %s with mode %s"), + quote_n (0, f), quote_n (1, mode)); + } +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/xfreopen.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/xfreopen.h new file mode 100644 index 00000000..03cf68d3 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/xfreopen.h @@ -0,0 +1,29 @@ +/* Open a file, reusing a given stream, with error checking. + Copyright (C) 2009-2024 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 the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + This file 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 . */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Opens the file FILENAME with mode MODE, reusing the given stream FP. + Upon failure, emits an error message and exits the program. */ +void xfreopen (char const *filename, char const *mode, FILE *fp); + +#ifdef __cplusplus +} +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/xmalloc.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/xmalloc.c new file mode 100644 index 00000000..82e54ef1 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/xmalloc.c @@ -0,0 +1,340 @@ +/* xmalloc.c -- malloc with out of memory checking + + Copyright (C) 1990-2000, 2002-2006, 2008-2024 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 . */ + +#include + +#define XALLOC_INLINE _GL_EXTERN_INLINE + +#include "xalloc.h" + +#include "ialloc.h" +#include "minmax.h" + +#include +#include +#include +#include + +static void * _GL_ATTRIBUTE_PURE +nonnull (void *p) +{ + if (!p) + xalloc_die (); + return p; +} + +/* Allocate S bytes of memory dynamically, with error checking. */ + +void * +xmalloc (size_t s) +{ + return nonnull (malloc (s)); +} + +void * +ximalloc (idx_t s) +{ + return nonnull (imalloc (s)); +} + +char * +xcharalloc (size_t n) +{ + return XNMALLOC (n, char); +} + +/* Change the size of an allocated block of memory P to S bytes, + with error checking. */ + +void * +xrealloc (void *p, size_t s) +{ + void *r = realloc (p, s); + if (!r && (!p || s)) + xalloc_die (); + return r; +} + +void * +xirealloc (void *p, idx_t s) +{ + return nonnull (irealloc (p, s)); +} + +/* Change the size of an allocated block of memory P to an array of N + objects each of S bytes, with error checking. */ + +void * +xreallocarray (void *p, size_t n, size_t s) +{ + void *r = reallocarray (p, n, s); + if (!r && (!p || (n && s))) + xalloc_die (); + return r; +} + +void * +xireallocarray (void *p, idx_t n, idx_t s) +{ + return nonnull (ireallocarray (p, n, s)); +} + +/* Allocate an array of N objects, each with S bytes of memory, + dynamically, with error checking. S must be nonzero. */ + +void * +xnmalloc (size_t n, size_t s) +{ + return xreallocarray (NULL, n, s); +} + +void * +xinmalloc (idx_t n, idx_t s) +{ + return xireallocarray (NULL, n, s); +} + +/* If P is null, allocate a block of at least *PS bytes; otherwise, + reallocate P so that it contains more than *PS bytes. *PS must be + nonzero unless P is null. Set *PS to the new block's size, and + return the pointer to the new block. *PS is never set to zero, and + the returned pointer is never null. */ + +void * +x2realloc (void *p, size_t *ps) +{ + return x2nrealloc (p, ps, 1); +} + +/* If P is null, allocate a block of at least *PN such objects; + otherwise, reallocate P so that it contains more than *PN objects + each of S bytes. S must be nonzero. Set *PN to the new number of + objects, and return the pointer to the new block. *PN is never set + to zero, and the returned pointer is never null. + + Repeated reallocations are guaranteed to make progress, either by + allocating an initial block with a nonzero size, or by allocating a + larger block. + + In the following implementation, nonzero sizes are increased by a + factor of approximately 1.5 so that repeated reallocations have + O(N) overall cost rather than O(N**2) cost, but the + specification for this function does not guarantee that rate. + + Here is an example of use: + + int *p = NULL; + size_t used = 0; + size_t allocated = 0; + + void + append_int (int value) + { + if (used == allocated) + p = x2nrealloc (p, &allocated, sizeof *p); + p[used++] = value; + } + + This causes x2nrealloc to allocate a block of some nonzero size the + first time it is called. + + To have finer-grained control over the initial size, set *PN to a + nonzero value before calling this function with P == NULL. For + example: + + int *p = NULL; + size_t used = 0; + size_t allocated = 0; + size_t allocated1 = 1000; + + void + append_int (int value) + { + if (used == allocated) + { + p = x2nrealloc (p, &allocated1, sizeof *p); + allocated = allocated1; + } + p[used++] = value; + } + + */ + +void * +x2nrealloc (void *p, size_t *pn, size_t s) +{ + size_t n = *pn; + + if (! p) + { + if (! n) + { + /* The approximate size to use for initial small allocation + requests, when the invoking code specifies an old size of + zero. This is the largest "small" request for the GNU C + library malloc. */ + enum { DEFAULT_MXFAST = 64 * sizeof (size_t) / 4 }; + + n = DEFAULT_MXFAST / s; + n += !n; + } + } + else + { + /* Set N = floor (1.5 * N) + 1 to make progress even if N == 0. */ + if (ckd_add (&n, n, (n >> 1) + 1)) + xalloc_die (); + } + + p = xreallocarray (p, n, s); + *pn = n; + return p; +} + +/* Grow PA, which points to an array of *PN items, and return the + location of the reallocated array, updating *PN to reflect its + new size. The new array will contain at least N_INCR_MIN more + items, but will not contain more than N_MAX items total. + S is the size of each item, in bytes. + + S and N_INCR_MIN must be positive. *PN must be + nonnegative. If N_MAX is -1, it is treated as if it were + infinity. + + If PA is null, then allocate a new array instead of reallocating + the old one. + + Thus, to grow an array A without saving its old contents, do + { free (A); A = xpalloc (NULL, &AITEMS, ...); }. */ + +void * +xpalloc (void *pa, idx_t *pn, idx_t n_incr_min, ptrdiff_t n_max, idx_t s) +{ + idx_t n0 = *pn; + + /* The approximate size to use for initial small allocation + requests. This is the largest "small" request for the GNU C + library malloc. */ + enum { DEFAULT_MXFAST = 64 * sizeof (size_t) / 4 }; + + /* If the array is tiny, grow it to about (but no greater than) + DEFAULT_MXFAST bytes. Otherwise, grow it by about 50%. + Adjust the growth according to three constraints: N_INCR_MIN, + N_MAX, and what the C language can represent safely. */ + + idx_t n; + if (ckd_add (&n, n0, n0 >> 1)) + n = IDX_MAX; + if (0 <= n_max && n_max < n) + n = n_max; + + /* NBYTES is of a type suitable for holding the count of bytes in an object. + This is typically idx_t, but it should be size_t on (theoretical?) + platforms where SIZE_MAX < IDX_MAX so xpalloc does not pass + values greater than SIZE_MAX to xrealloc. */ +#if IDX_MAX <= SIZE_MAX + idx_t nbytes; +#else + size_t nbytes; +#endif + idx_t adjusted_nbytes + = (ckd_mul (&nbytes, n, s) + ? MIN (IDX_MAX, SIZE_MAX) + : nbytes < DEFAULT_MXFAST ? DEFAULT_MXFAST : 0); + if (adjusted_nbytes) + { + n = adjusted_nbytes / s; + nbytes = adjusted_nbytes - adjusted_nbytes % s; + } + + if (! pa) + *pn = 0; + if (n - n0 < n_incr_min + && (ckd_add (&n, n0, n_incr_min) + || (0 <= n_max && n_max < n) + || ckd_mul (&nbytes, n, s))) + xalloc_die (); + pa = xrealloc (pa, nbytes); + *pn = n; + return pa; +} + +/* Allocate S bytes of zeroed memory dynamically, with error checking. + There's no need for xnzalloc (N, S), since it would be equivalent + to xcalloc (N, S). */ + +void * +xzalloc (size_t s) +{ + return xcalloc (s, 1); +} + +void * +xizalloc (idx_t s) +{ + return xicalloc (s, 1); +} + +/* Allocate zeroed memory for N elements of S bytes, with error + checking. S must be nonzero. */ + +void * +xcalloc (size_t n, size_t s) +{ + return nonnull (calloc (n, s)); +} + +void * +xicalloc (idx_t n, idx_t s) +{ + return nonnull (icalloc (n, s)); +} + +/* Clone an object P of size S, with error checking. There's no need + for xnmemdup (P, N, S), since xmemdup (P, N * S) works without any + need for an arithmetic overflow check. */ + +void * +xmemdup (void const *p, size_t s) +{ + return memcpy (xmalloc (s), p, s); +} + +void * +ximemdup (void const *p, idx_t s) +{ + return memcpy (ximalloc (s), p, s); +} + +/* Clone an object P of size S, with error checking. Append + a terminating NUL byte. */ + +char * +ximemdup0 (void const *p, idx_t s) +{ + char *result = ximalloc (s + 1); + result[s] = 0; + return memcpy (result, p, s); +} + +/* Clone STRING. */ + +char * +xstrdup (char const *string) +{ + return xmemdup (string, strlen (string) + 1); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/xmalloca.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/xmalloca.c new file mode 100644 index 00000000..e1bc54d9 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/xmalloca.c @@ -0,0 +1,38 @@ +/* Safe automatic memory allocation with out of memory checking. + Copyright (C) 2003, 2006-2007, 2009-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2003. + + 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 . */ + +#include + +/* Specification. */ +#include "xmalloca.h" + +#include "xalloc.h" + +#if HAVE_ALLOCA + +void * +xmmalloca (size_t n) +{ + void *p; + + p = mmalloca (n); + if (p == NULL) + xalloc_die (); + return p; +} + +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/xmalloca.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/xmalloca.h new file mode 100644 index 00000000..a096511b --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/xmalloca.h @@ -0,0 +1,77 @@ +/* Safe automatic memory allocation with out of memory checking. + Copyright (C) 2003, 2005, 2007, 2009-2024 Free Software Foundation, Inc. + Written by Bruno Haible , 2003. + + 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 . */ + +#ifndef _XMALLOCA_H +#define _XMALLOCA_H + +/* This file uses _GL_ATTRIBUTE_ALLOC_SIZE, _GL_ATTRIBUTE_DEALLOC, + _GL_ATTRIBUTE_MALLOC, _GL_ATTRIBUTE_RETURNS_NONNULL, HAVE_ALLOCA. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +#include "malloca.h" +#include "xalloc.h" +#include "xalloc-oversized.h" + + +#ifdef __cplusplus +extern "C" { +#endif + + +/* xmalloca(N) is a checking safe variant of alloca(N). It allocates N bytes + of memory allocated on the stack, that must be freed using freea() before + the function returns. N should not have side effects. + Upon failure, it exits with an error message. */ +#if HAVE_ALLOCA +# define xmalloca(N) \ + ((N) < 4032 - (2 * sa_alignment_max - 1) \ + ? (void *) (((uintptr_t) (char *) alloca ((N) + 2 * sa_alignment_max - 1) \ + + (2 * sa_alignment_max - 1)) \ + & ~(uintptr_t)(2 * sa_alignment_max - 1)) \ + : xmmalloca (N)) +extern void * xmmalloca (size_t n) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC (freea, 1) + _GL_ATTRIBUTE_ALLOC_SIZE ((1)) _GL_ATTRIBUTE_RETURNS_NONNULL; +#else +# define xmalloca(N) \ + xmalloc (N) +#endif + +/* xnmalloca(N,S) is an overflow-safe variant of xmalloca (N * S). + It allocates an array of N objects, each with S bytes of memory, + on the stack. S must be positive and N must be nonnegative, + and S and N should not have side effects. + The array must be freed using freea() before the function returns. + Upon failure, it exits with an error message. */ +#if HAVE_ALLOCA +/* Rely on xmalloca (SIZE_MAX) calling xalloc_die (). */ +# define xnmalloca(n, s) \ + xmalloca (xalloc_oversized (n, s) ? (size_t) (-1) : (n) * (size_t) (s)) +#else +# define xnmalloca(n, s) \ + xnmalloc (n, s) +#endif + + +#ifdef __cplusplus +} +#endif + + +#endif /* _XMALLOCA_H */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/xstdopen.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/xstdopen.c new file mode 100644 index 00000000..3d15c261 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/xstdopen.c @@ -0,0 +1,35 @@ +/* Ensure that stdin, stdout, stderr are open. + Copyright (C) 2019-2024 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 . */ + +#include + +/* Specification. */ +#include "xstdopen.h" + +#include "stdopen.h" +#include +#include "exitfail.h" + +#include "gettext.h" +#define _(msgid) gettext (msgid) + +void +xstdopen (void) +{ + int stdopen_errno = stdopen (); + if (stdopen_errno != 0) + error (exit_failure, stdopen_errno, _("standard file descriptors")); +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/xstdopen.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/xstdopen.h new file mode 100644 index 00000000..bb168729 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/xstdopen.h @@ -0,0 +1,28 @@ +/* Ensure that stdin, stdout, stderr are open. + Copyright (C) 2019-2024 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 . */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Ensures that the file descriptors of stdin, stdout, stderr (0, 1, 2) are + open. Exits the program with an error message upon failure; the error + message may not appear if stderr is closed. */ +extern void xstdopen (void); + +#ifdef __cplusplus +} +#endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/xstrtoimax.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/xstrtoimax.c new file mode 100644 index 00000000..72a0aae2 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/xstrtoimax.c @@ -0,0 +1,24 @@ +/* A more useful interface to strtoimax. + + Copyright (C) 2001-2024 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 the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + This file 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 . */ + +#define __strtol strtoimax +#define __strtol_t intmax_t +#define __xstrtol xstrtoimax +#define STRTOL_T_MINIMUM INTMAX_MIN +#define STRTOL_T_MAXIMUM INTMAX_MAX +#define XSTRTOL_INCLUDE_INTTYPES_H 1 +#include "xstrtol.c" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/xstrtol.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/xstrtol.c new file mode 100644 index 00000000..e4bce436 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/xstrtol.c @@ -0,0 +1,247 @@ +/* A more useful interface to strtol. + + Copyright (C) 1995-1996, 1998-2001, 2003-2007, 2009-2024 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 . */ + +/* Written by Jim Meyering. */ + +#ifndef __strtol +# define __strtol strtol +# define __strtol_t long int +# define __xstrtol xstrtol +# define STRTOL_T_MINIMUM LONG_MIN +# define STRTOL_T_MAXIMUM LONG_MAX +#endif + +#include + +#include "xstrtol.h" + +/* Some pre-ANSI implementations (e.g. SunOS 4) + need stderr defined if assertion checking is enabled. */ +#include + +#include +#include +#include +#include +#include +#include + +#if XSTRTOL_INCLUDE_INTTYPES_H +# include +#endif + +#include "assure.h" +#include "intprops.h" + +static strtol_error +bkm_scale (__strtol_t *x, int scale_factor) +{ + __strtol_t scaled; + if (ckd_mul (&scaled, *x, scale_factor)) + { + *x = *x < 0 ? TYPE_MINIMUM (__strtol_t) : TYPE_MAXIMUM (__strtol_t); + return LONGINT_OVERFLOW; + } + + *x = scaled; + + return LONGINT_OK; +} + +static strtol_error +bkm_scale_by_power (__strtol_t *x, int base, int power) +{ + strtol_error err = LONGINT_OK; + while (power--) + err |= bkm_scale (x, base); + return err; +} + +/* FIXME: comment. */ + +strtol_error +__xstrtol (const char *s, char **ptr, int strtol_base, + __strtol_t *val, const char *valid_suffixes) +{ + char *t_ptr; + char **p; + __strtol_t tmp; + strtol_error err = LONGINT_OK; + + assure (0 <= strtol_base && strtol_base <= 36); + + p = (ptr ? ptr : &t_ptr); + + errno = 0; + + if (! TYPE_SIGNED (__strtol_t)) + { + const char *q = s; + unsigned char ch = *q; + while (isspace (ch)) + ch = *++q; + if (ch == '-') + return LONGINT_INVALID; + } + + tmp = __strtol (s, p, strtol_base); + + if (*p == s) + { + /* If there is no number but there is a valid suffix, assume the + number is 1. The string is invalid otherwise. */ + if (valid_suffixes && **p && strchr (valid_suffixes, **p)) + tmp = 1; + else + return LONGINT_INVALID; + } + else if (errno != 0) + { + if (errno != ERANGE) + return LONGINT_INVALID; + err = LONGINT_OVERFLOW; + } + + /* Let valid_suffixes == NULL mean "allow any suffix". */ + /* FIXME: update all callers except the ones that allow suffixes + after the number, changing last parameter NULL to "". */ + if (!valid_suffixes) + { + *val = tmp; + return err; + } + + if (**p != '\0') + { + int base = 1024; + int suffixes = 1; + strtol_error overflow; + + if (!strchr (valid_suffixes, **p)) + { + *val = tmp; + return err | LONGINT_INVALID_SUFFIX_CHAR; + } + + switch (**p) + { + case 'E': case 'G': case 'g': case 'k': case 'K': case 'M': case 'm': + case 'P': case 'Q': case 'R': case 'T': case 't': case 'Y': case 'Z': + + /* The "valid suffix" '0' is a special flag meaning that + an optional second suffix is allowed, which can change + the base. A suffix "B" (e.g. "100MB") stands for a power + of 1000, whereas a suffix "iB" (e.g. "100MiB") stands for + a power of 1024. If no suffix (e.g. "100M"), assume + power-of-1024. */ + + if (strchr (valid_suffixes, '0')) + switch (p[0][1]) + { + case 'i': + if (p[0][2] == 'B') + suffixes += 2; + break; + + case 'B': + case 'D': /* 'D' is obsolescent */ + base = 1000; + suffixes++; + break; + } + } + + switch (**p) + { + case 'b': + overflow = bkm_scale (&tmp, 512); + break; + + case 'B': + /* This obsolescent first suffix is distinct from the 'B' + second suffix above. E.g., 'tar -L 1000B' means change + the tape after writing 1000 KiB of data. */ + overflow = bkm_scale (&tmp, 1024); + break; + + case 'c': + overflow = LONGINT_OK; + break; + + case 'E': /* exa or exbi */ + overflow = bkm_scale_by_power (&tmp, base, 6); + break; + + case 'G': /* giga or gibi */ + case 'g': /* 'g' is undocumented; for compatibility only */ + overflow = bkm_scale_by_power (&tmp, base, 3); + break; + + case 'k': /* kilo */ + case 'K': /* kibi */ + overflow = bkm_scale_by_power (&tmp, base, 1); + break; + + case 'M': /* mega or mebi */ + case 'm': /* 'm' is undocumented; for compatibility only */ + overflow = bkm_scale_by_power (&tmp, base, 2); + break; + + case 'P': /* peta or pebi */ + overflow = bkm_scale_by_power (&tmp, base, 5); + break; + + case 'Q': /* quetta or 2**100 */ + overflow = bkm_scale_by_power (&tmp, base, 10); + break; + + case 'R': /* ronna or 2**90 */ + overflow = bkm_scale_by_power (&tmp, base, 9); + break; + + case 'T': /* tera or tebi */ + case 't': /* 't' is undocumented; for compatibility only */ + overflow = bkm_scale_by_power (&tmp, base, 4); + break; + + case 'w': + overflow = bkm_scale (&tmp, 2); + break; + + case 'Y': /* yotta or 2**80 */ + overflow = bkm_scale_by_power (&tmp, base, 8); + break; + + case 'Z': /* zetta or 2**70 */ + overflow = bkm_scale_by_power (&tmp, base, 7); + break; + + default: + *val = tmp; + return err | LONGINT_INVALID_SUFFIX_CHAR; + } + + err |= overflow; + *p += suffixes; + if (**p) + err |= LONGINT_INVALID_SUFFIX_CHAR; + } + + *val = tmp; + return err; +} diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/xstrtol.h b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/xstrtol.h new file mode 100644 index 00000000..44b1cb47 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/xstrtol.h @@ -0,0 +1,51 @@ +/* A more useful interface to strtol. + + Copyright (C) 1995-1996, 1998-1999, 2001-2004, 2006-2024 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 . */ + +#ifndef XSTRTOL_H_ +# define XSTRTOL_H_ 1 + +/* Get intmax_t, uintmax_t. */ +# include + +# ifndef _STRTOL_ERROR +enum strtol_error + { + LONGINT_OK = 0, + + /* These two values can be ORed together, to indicate that both + errors occurred. */ + LONGINT_OVERFLOW = 1, + LONGINT_INVALID_SUFFIX_CHAR = 2, + + LONGINT_INVALID_SUFFIX_CHAR_WITH_OVERFLOW = (LONGINT_INVALID_SUFFIX_CHAR + | LONGINT_OVERFLOW), + LONGINT_INVALID = 4 + }; +typedef enum strtol_error strtol_error; +# endif + +# define _DECLARE_XSTRTOL(name, type) \ + strtol_error name (const char *, char **, int, type *, const char *); +_DECLARE_XSTRTOL (xstrtol, long int) +_DECLARE_XSTRTOL (xstrtoul, unsigned long int) +_DECLARE_XSTRTOL (xstrtoll, long long int) +_DECLARE_XSTRTOL (xstrtoull, unsigned long long int) +_DECLARE_XSTRTOL (xstrtoimax, intmax_t) +_DECLARE_XSTRTOL (xstrtoumax, uintmax_t) + +#endif /* not XSTRTOL_H_ */ diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/xstrtoul.c b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/xstrtoul.c new file mode 100644 index 00000000..6162af40 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/lib/xstrtoul.c @@ -0,0 +1,23 @@ +/* Convert string to 'unsigned long', with error checking. + + Copyright (C) 1994-2024 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 the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + This file 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 . */ + +#define __strtol strtoul +#define __strtol_t unsigned long int +#define __xstrtol xstrtoul +#define STRTOL_T_MINIMUM 0 +#define STRTOL_T_MAXIMUM ULONG_MAX +#include "xstrtol.c" diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/.gitignore b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/.gitignore new file mode 100644 index 00000000..85fc9f50 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/.gitignore @@ -0,0 +1,282 @@ +/iconv.m4 +/xsize.m4 +/wint_t.m4 +/wchar_t.m4 +/visibility.m4 +/uintmax_t.m4 +/threadlib.m4 +/stdint_h.m4 +/size_max.m4 +/progtest.m4 +/printf-posix.m4 +/po.m4 +/nls.m4 +/longlong.m4 +/lock.m4 +/lib-prefix.m4 +/lib-link.m4 +/lib-ld.m4 +/lcmessage.m4 +/inttypes_h.m4 +/inttypes-pri.m4 +/intmax.m4 +/intlmacosx.m4 +/intldir.m4 +/intl.m4 +/intdiv0.m4 +/glibc21.m4 +/glibc2.m4 +/gettext.m4 +/fcntl-o.m4 +/extern-inline.m4 +/codeset.m4 +/00gnulib.m4 +/__inline.m4 +/absolute-header.m4 +/alloca.m4 +/arpa_inet_h.m4 +/asm-underscore.m4 +/assert_h.m4 +/atoll.m4 +/btowc.m4 +/builtin-expect.m4 +/c-bool.m4 +/c-stack.m4 +/calloc.m4 +/clock_time.m4 +/close.m4 +/config-h.m4 +/ctype_h.m4 +/double-slash-root.m4 +/dup2.m4 +/eealloc.m4 +/environ.m4 +/errno_h.m4 +/error.m4 +/error_h.m4 +/exponentd.m4 +/extensions.m4 +/fclose.m4 +/fcntl.m4 +/fcntl_h.m4 +/fdopen.m4 +/fflush.m4 +/filenamecat.m4 +/flexmember.m4 +/float_h.m4 +/fnmatch.m4 +/fnmatch_h.m4 +/fopen.m4 +/fpieee.m4 +/free.m4 +/freopen.m4 +/fstat.m4 +/ftruncate.m4 +/getcwd.m4 +/getdtablesize.m4 +/getopt.m4 +/getpagesize.m4 +/getprogname.m4 +/getrandom.m4 +/gettime.m4 +/gettimeofday.m4 +/gnu-make.m4 +/gnulib-common.m4 +/gnulib-comp.m4 +/gnulib-tool.m4 +/host-cpu-c-abi.m4 +/include_next.m4 +/inet_pton.m4 +/intl-thread-locale.m4 +/intmax_t.m4 +/inttostr.m4 +/inttypes.m4 +/ioctl.m4 +/isblank.m4 +/iswblank.m4 +/iswdigit.m4 +/iswxdigit.m4 +/langinfo_h.m4 +/largefile.m4 +/libsigsegv.m4 +/libunistring-base.m4 +/limits-h.m4 +/localcharset.m4 +/locale-fr.m4 +/locale-ja.m4 +/locale-tr.m4 +/locale-zh.m4 +/locale_h.m4 +/localeconv.m4 +/lstat.m4 +/malloc.m4 +/malloca.m4 +/manywarnings-c++.m4 +/manywarnings.m4 +/math_h.m4 +/mbchar.m4 +/mbiter.m4 +/mbrtowc.m4 +/mbsinit.m4 +/mbsrtowcs.m4 +/mbstate_t.m4 +/mbtowc.m4 +/memchr.m4 +/mempcpy.m4 +/minmax.m4 +/mkdir.m4 +/mkstemp.m4 +/mktime.m4 +/mmap-anon.m4 +/mode_t.m4 +/msvc-inval.m4 +/msvc-nothrow.m4 +/multiarch.m4 +/musl.m4 +/nanosleep.m4 +/netinet_in_h.m4 +/nl_langinfo.m4 +/nocrash.m4 +/nstrftime.m4 +/nullptr.m4 +/off_t.m4 +/open-cloexec.m4 +/open-slash.m4 +/open.m4 +/pathmax.m4 +/perl.m4 +/perror.m4 +/pid_t.m4 +/pipe.m4 +/printf.m4 +/pselect.m4 +/pthread-thread.m4 +/pthread_h.m4 +/pthread_rwlock_rdlock.m4 +/pthread_sigmask.m4 +/putenv.m4 +/quote.m4 +/quotearg.m4 +/raise.m4 +/rawmemchr.m4 +/realloc.m4 +/reallocarray.m4 +/regex.m4 +/sched_h.m4 +/select.m4 +/setenv.m4 +/setlocale_null.m4 +/sigaltstack.m4 +/signal_h.m4 +/signalblocking.m4 +/sigsegv.m4 +/sleep.m4 +/snprintf.m4 +/socketlib.m4 +/sockets.m4 +/socklen.m4 +/sockpfaf.m4 +/ssize_t.m4 +/stack-direction.m4 +/stat-time.m4 +/stat.m4 +/std-gnu11.m4 +/stdalign.m4 +/stdarg.m4 +/stddef_h.m4 +/stdint.m4 +/stdio_h.m4 +/stdlib_h.m4 +/stpcpy.m4 +/strcase.m4 +/strerror.m4 +/strerror_r.m4 +/string_h.m4 +/strings_h.m4 +/strnlen.m4 +/strptime.m4 +/strtoimax.m4 +/strtoll.m4 +/symlink.m4 +/sys_ioctl_h.m4 +/sys_random_h.m4 +/sys_select_h.m4 +/sys_socket_h.m4 +/sys_stat_h.m4 +/sys_time_h.m4 +/sys_types_h.m4 +/sys_uio_h.m4 +/sys_wait_h.m4 +/tempname.m4 +/thread.m4 +/time.m4 +/time_h.m4 +/time_r.m4 +/time_rz.m4 +/timegm.m4 +/timespec.m4 +/tm_gmtoff.m4 +/tzset.m4 +/unistd_h.m4 +/unlocked-io.m4 +/vararrays.m4 +/vasnprintf.m4 +/version-etc.m4 +/warn-on-use.m4 +/warnings.m4 +/wchar_h.m4 +/wcrtomb.m4 +/wctob.m4 +/wctomb.m4 +/wctype_h.m4 +/wcwidth.m4 +/wmemchr.m4 +/wmempcpy.m4 +/xalloc.m4 +/xstrtol.m4 +/zzgnulib.m4 +/c32rtomb.m4 +/mbrtoc32.m4 +/uchar_h.m4 +/chdir-long.m4 +/closedir.m4 +/dirent_h.m4 +/dirfd.m4 +/dup.m4 +/fchdir.m4 +/fdopendir.m4 +/fstatat.m4 +/inline.m4 +/memrchr.m4 +/openat.m4 +/opendir.m4 +/save-cwd.m4 +/strdup.m4 +/timespec_get.m4 +/unicase_h.m4 +/unictype_h.m4 +/uninorm_h.m4 +/unistd-safer.m4 +/priv-set.m4 +/readlink.m4 +/readlinkat.m4 +/rmdir.m4 +/sigaction.m4 +/symlinkat.m4 +/unlink.m4 +/unlinkat.m4 +/unlinkdir.m4 +/pclose.m4 +/popen.m4 +/readdir.m4 +/exponentf.m4 +/exponentl.m4 +/isnand.m4 +/isnanf.m4 +/isnanl.m4 +/iswctype.m4 +/iswpunct.m4 +/nan-mips.m4 +/signbit.m4 +/snan.m4 +/wctype.m4 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/.gitignore~ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/.gitignore~ new file mode 100644 index 00000000..04ff0db2 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/.gitignore~ @@ -0,0 +1,271 @@ +/iconv.m4 +/xsize.m4 +/wint_t.m4 +/wchar_t.m4 +/visibility.m4 +/uintmax_t.m4 +/threadlib.m4 +/stdint_h.m4 +/size_max.m4 +/progtest.m4 +/printf-posix.m4 +/po.m4 +/nls.m4 +/longlong.m4 +/lock.m4 +/lib-prefix.m4 +/lib-link.m4 +/lib-ld.m4 +/lcmessage.m4 +/inttypes_h.m4 +/inttypes-pri.m4 +/intmax.m4 +/intlmacosx.m4 +/intldir.m4 +/intl.m4 +/intdiv0.m4 +/glibc21.m4 +/glibc2.m4 +/gettext.m4 +/fcntl-o.m4 +/extern-inline.m4 +/codeset.m4 +/00gnulib.m4 +/__inline.m4 +/absolute-header.m4 +/alloca.m4 +/arpa_inet_h.m4 +/asm-underscore.m4 +/assert_h.m4 +/atoll.m4 +/btowc.m4 +/builtin-expect.m4 +/c-bool.m4 +/c-stack.m4 +/calloc.m4 +/clock_time.m4 +/close.m4 +/config-h.m4 +/ctype_h.m4 +/double-slash-root.m4 +/dup2.m4 +/eealloc.m4 +/environ.m4 +/errno_h.m4 +/error.m4 +/error_h.m4 +/exponentd.m4 +/extensions.m4 +/fclose.m4 +/fcntl.m4 +/fcntl_h.m4 +/fdopen.m4 +/fflush.m4 +/filenamecat.m4 +/flexmember.m4 +/float_h.m4 +/fnmatch.m4 +/fnmatch_h.m4 +/fopen.m4 +/fpieee.m4 +/free.m4 +/freopen.m4 +/fstat.m4 +/ftruncate.m4 +/getcwd.m4 +/getdtablesize.m4 +/getopt.m4 +/getpagesize.m4 +/getprogname.m4 +/getrandom.m4 +/gettime.m4 +/gettimeofday.m4 +/gnu-make.m4 +/gnulib-common.m4 +/gnulib-comp.m4 +/gnulib-tool.m4 +/host-cpu-c-abi.m4 +/include_next.m4 +/inet_pton.m4 +/intl-thread-locale.m4 +/intmax_t.m4 +/inttostr.m4 +/inttypes.m4 +/ioctl.m4 +/isblank.m4 +/iswblank.m4 +/iswdigit.m4 +/iswxdigit.m4 +/langinfo_h.m4 +/largefile.m4 +/libsigsegv.m4 +/libunistring-base.m4 +/limits-h.m4 +/localcharset.m4 +/locale-fr.m4 +/locale-ja.m4 +/locale-tr.m4 +/locale-zh.m4 +/locale_h.m4 +/localeconv.m4 +/lstat.m4 +/malloc.m4 +/malloca.m4 +/manywarnings-c++.m4 +/manywarnings.m4 +/math_h.m4 +/mbchar.m4 +/mbiter.m4 +/mbrtowc.m4 +/mbsinit.m4 +/mbsrtowcs.m4 +/mbstate_t.m4 +/mbtowc.m4 +/memchr.m4 +/mempcpy.m4 +/minmax.m4 +/mkdir.m4 +/mkstemp.m4 +/mktime.m4 +/mmap-anon.m4 +/mode_t.m4 +/msvc-inval.m4 +/msvc-nothrow.m4 +/multiarch.m4 +/musl.m4 +/nanosleep.m4 +/netinet_in_h.m4 +/nl_langinfo.m4 +/nocrash.m4 +/nstrftime.m4 +/nullptr.m4 +/off_t.m4 +/open-cloexec.m4 +/open-slash.m4 +/open.m4 +/pathmax.m4 +/perl.m4 +/perror.m4 +/pid_t.m4 +/pipe.m4 +/printf.m4 +/pselect.m4 +/pthread-thread.m4 +/pthread_h.m4 +/pthread_rwlock_rdlock.m4 +/pthread_sigmask.m4 +/putenv.m4 +/quote.m4 +/quotearg.m4 +/raise.m4 +/rawmemchr.m4 +/realloc.m4 +/reallocarray.m4 +/regex.m4 +/sched_h.m4 +/select.m4 +/setenv.m4 +/setlocale_null.m4 +/sigaltstack.m4 +/signal_h.m4 +/signalblocking.m4 +/sigsegv.m4 +/sleep.m4 +/snprintf.m4 +/socketlib.m4 +/sockets.m4 +/socklen.m4 +/sockpfaf.m4 +/ssize_t.m4 +/stack-direction.m4 +/stat-time.m4 +/stat.m4 +/std-gnu11.m4 +/stdalign.m4 +/stdarg.m4 +/stddef_h.m4 +/stdint.m4 +/stdio_h.m4 +/stdlib_h.m4 +/stpcpy.m4 +/strcase.m4 +/strerror.m4 +/strerror_r.m4 +/string_h.m4 +/strings_h.m4 +/strnlen.m4 +/strptime.m4 +/strtoimax.m4 +/strtoll.m4 +/symlink.m4 +/sys_ioctl_h.m4 +/sys_random_h.m4 +/sys_select_h.m4 +/sys_socket_h.m4 +/sys_stat_h.m4 +/sys_time_h.m4 +/sys_types_h.m4 +/sys_uio_h.m4 +/sys_wait_h.m4 +/tempname.m4 +/thread.m4 +/time.m4 +/time_h.m4 +/time_r.m4 +/time_rz.m4 +/timegm.m4 +/timespec.m4 +/tm_gmtoff.m4 +/tzset.m4 +/unistd_h.m4 +/unlocked-io.m4 +/vararrays.m4 +/vasnprintf.m4 +/version-etc.m4 +/warn-on-use.m4 +/warnings.m4 +/wchar_h.m4 +/wcrtomb.m4 +/wctob.m4 +/wctomb.m4 +/wctype_h.m4 +/wcwidth.m4 +/wmemchr.m4 +/wmempcpy.m4 +/xalloc.m4 +/xstrtol.m4 +/zzgnulib.m4 +/c32rtomb.m4 +/mbrtoc32.m4 +/uchar_h.m4 +/chdir-long.m4 +/closedir.m4 +/dirent_h.m4 +/dirfd.m4 +/dup.m4 +/fchdir.m4 +/fdopendir.m4 +/fstatat.m4 +/inline.m4 +/memrchr.m4 +/openat.m4 +/opendir.m4 +/save-cwd.m4 +/strdup.m4 +/timespec_get.m4 +/unicase_h.m4 +/unictype_h.m4 +/uninorm_h.m4 +/unistd-safer.m4 +/priv-set.m4 +/readlink.m4 +/readlinkat.m4 +/rmdir.m4 +/sigaction.m4 +/symlinkat.m4 +/unlink.m4 +/unlinkat.m4 +/unlinkdir.m4 +/pclose.m4 +/popen.m4 +/readdir.m4 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/00gnulib.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/00gnulib.m4 new file mode 100644 index 00000000..3448c40b --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/00gnulib.m4 @@ -0,0 +1,85 @@ +# 00gnulib.m4 serial 8 +dnl Copyright (C) 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl This file must be named something that sorts before all other +dnl gnulib-provided .m4 files. It is needed until the clang fix has +dnl been included in Autoconf. + +# The following definitions arrange to use a compiler option +# -Werror=implicit-function-declaration in AC_CHECK_DECL, when the +# compiler is clang. Without it, clang implicitly declares "known" +# library functions in C mode, but not in C++ mode, which would cause +# Gnulib to omit a declaration and thus later produce an error in C++ +# mode. As of clang 9.0, these "known" functions are identified through +# LIBBUILTIN invocations in the LLVM source file +# llvm/tools/clang/include/clang/Basic/Builtins.def. +# It's not possible to AC_REQUIRE the extra tests from AC_CHECK_DECL, +# because AC_CHECK_DECL, like other Autoconf built-ins, is not supposed +# to AC_REQUIRE anything: some configure.ac files have their first +# AC_CHECK_DECL executed conditionally. Therefore append the extra tests +# to AC_PROG_CC. +AC_DEFUN([gl_COMPILER_CLANG], +[ +dnl AC_REQUIRE([AC_PROG_CC]) + AC_CACHE_CHECK([whether the compiler is clang], + [gl_cv_compiler_clang], + [dnl Use _AC_COMPILE_IFELSE instead of AC_EGREP_CPP, to avoid error + dnl "circular dependency of AC_LANG_COMPILER(C)" if AC_PROG_CC has + dnl not yet been invoked. + _AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[ + #ifdef __clang__ + barfbarf + #endif + ]],[[]]) + ], + [gl_cv_compiler_clang=no], + [gl_cv_compiler_clang=yes]) + ]) +]) +AC_DEFUN([gl_COMPILER_PREPARE_CHECK_DECL], +[ +dnl AC_REQUIRE([AC_PROG_CC]) +dnl AC_REQUIRE([gl_COMPILER_CLANG]) + AC_CACHE_CHECK([for compiler option needed when checking for declarations], + [gl_cv_compiler_check_decl_option], + [if test $gl_cv_compiler_clang = yes; then + dnl Test whether the compiler supports the option + dnl '-Werror=implicit-function-declaration'. + save_ac_compile="$ac_compile" + ac_compile="$ac_compile -Werror=implicit-function-declaration" + dnl Use _AC_COMPILE_IFELSE instead of AC_COMPILE_IFELSE, to avoid a + dnl warning "AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS". + _AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]],[[]])], + [gl_cv_compiler_check_decl_option='-Werror=implicit-function-declaration'], + [gl_cv_compiler_check_decl_option=none]) + ac_compile="$save_ac_compile" + else + gl_cv_compiler_check_decl_option=none + fi + ]) + if test "x$gl_cv_compiler_check_decl_option" != xnone; then + ac_compile_for_check_decl="$ac_compile $gl_cv_compiler_check_decl_option" + else + ac_compile_for_check_decl="$ac_compile" + fi +]) +dnl Redefine _AC_CHECK_DECL_BODY so that it references ac_compile_for_check_decl +dnl instead of ac_compile. If, for whatever reason, the override of AC_PROG_CC +dnl in zzgnulib.m4 is inactive, use the original ac_compile. +m4_define([_AC_CHECK_DECL_BODY], +[ ac_save_ac_compile="$ac_compile" + if test -n "$ac_compile_for_check_decl"; then + ac_compile="$ac_compile_for_check_decl" + fi] +m4_defn([_AC_CHECK_DECL_BODY])[ ac_compile="$ac_save_ac_compile" +]) + +# gl_00GNULIB +# ----------- +# Witness macro that this file has been included. Needed to force +# Automake to include this file prior to all other gnulib .m4 files. +AC_DEFUN([gl_00GNULIB]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/__inline.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/__inline.m4 new file mode 100644 index 00000000..992e16f4 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/__inline.m4 @@ -0,0 +1,22 @@ +# Test for __inline keyword +dnl Copyright 2017-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl___INLINE], +[ + AC_CACHE_CHECK([whether the compiler supports the __inline keyword], + [gl_cv_c___inline], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[typedef int foo_t; + static __inline foo_t foo (void) { return 0; }]], + [[return foo ();]])], + [gl_cv_c___inline=yes], + [gl_cv_c___inline=no])]) + if test $gl_cv_c___inline = yes; then + AC_DEFINE([HAVE___INLINE], [1], + [Define to 1 if the compiler supports the keyword '__inline'.]) + fi +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/absolute-header.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/absolute-header.m4 new file mode 100644 index 00000000..0e9f9ba7 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/absolute-header.m4 @@ -0,0 +1,100 @@ +# absolute-header.m4 serial 18 +dnl Copyright (C) 2006-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Derek Price. + +# gl_ABSOLUTE_HEADER(HEADER1 HEADER2 ...) +# --------------------------------------- +# Find the absolute name of a header file, testing first if the header exists. +# If the header were sys/inttypes.h, this macro would define +# ABSOLUTE_SYS_INTTYPES_H to the '""' quoted absolute name of sys/inttypes.h +# in config.h +# (e.g. '#define ABSOLUTE_SYS_INTTYPES_H "///usr/include/sys/inttypes.h"'). +# The three "///" are to pacify Sun C 5.8, which otherwise would say +# "warning: #include of /usr/include/... may be non-portable". +# Use '""', not '<>', so that the /// cannot be confused with a C99 comment. +# Note: This macro assumes that the header file is not empty after +# preprocessing, i.e. it does not only define preprocessor macros but also +# provides some type/enum definitions or function/variable declarations. +AC_DEFUN([gl_ABSOLUTE_HEADER], +[AC_REQUIRE([AC_CANONICAL_HOST]) +AC_LANG_PREPROC_REQUIRE()dnl +m4_foreach_w([gl_HEADER_NAME], [$1], + [AS_VAR_PUSHDEF([gl_absolute_header], + [gl_cv_absolute_]m4_defn([gl_HEADER_NAME]))dnl + AC_CACHE_CHECK([absolute name of <]m4_defn([gl_HEADER_NAME])[>], + [gl_absolute_header], + [AS_VAR_PUSHDEF([ac_header_exists], + [ac_cv_header_]m4_defn([gl_HEADER_NAME]))dnl + AC_CHECK_HEADERS_ONCE(m4_defn([gl_HEADER_NAME]))dnl + if test AS_VAR_GET([ac_header_exists]) = yes; then + gl_ABSOLUTE_HEADER_ONE(m4_defn([gl_HEADER_NAME])) + fi + AS_VAR_POPDEF([ac_header_exists])dnl + ])dnl + AC_DEFINE_UNQUOTED(AS_TR_CPP([ABSOLUTE_]m4_defn([gl_HEADER_NAME])), + ["AS_VAR_GET([gl_absolute_header])"], + [Define this to an absolute name of <]m4_defn([gl_HEADER_NAME])[>.]) + AS_VAR_POPDEF([gl_absolute_header])dnl +])dnl +])# gl_ABSOLUTE_HEADER + +# gl_ABSOLUTE_HEADER_ONE(HEADER) +# ------------------------------ +# Like gl_ABSOLUTE_HEADER, except that: +# - it assumes that the header exists, +# - it uses the current CPPFLAGS, +# - it does not cache the result, +# - it is silent. +AC_DEFUN([gl_ABSOLUTE_HEADER_ONE], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_LANG_CONFTEST([AC_LANG_SOURCE([[#include <]]m4_dquote([$1])[[>]])]) + dnl AIX "xlc -E" and "cc -E" omit #line directives for header files + dnl that contain only a #include of other header files and no + dnl non-comment tokens of their own. This leads to a failure to + dnl detect the absolute name of , , + dnl and others. The workaround is to force preservation of comments + dnl through option -C. This ensures all necessary #line directives + dnl are present. GCC supports option -C as well. + case "$host_os" in + aix*) gl_absname_cpp="$ac_cpp -C" ;; + *) gl_absname_cpp="$ac_cpp" ;; + esac +changequote(,) + case "$host_os" in + mingw* | windows*) + dnl For the sake of native Windows compilers (excluding gcc), + dnl treat backslash as a directory separator, like /. + dnl Actually, these compilers use a double-backslash as + dnl directory separator, inside the + dnl # line "filename" + dnl directives. + gl_dirsep_regex='[/\\]' + ;; + *) + gl_dirsep_regex='\/' + ;; + esac + dnl A sed expression that turns a string into a basic regular + dnl expression, for use within "/.../". + gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g' + gl_header_literal_regex=`echo '$1' \ + | sed -e "$gl_make_literal_regex_sed"` + gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{ + s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/ + s|^/[^/]|//&| + p + q + }' +changequote([,]) + dnl eval is necessary to expand gl_absname_cpp. + dnl Ultrix and Pyramid sh refuse to redirect output of eval, + dnl so use subshell. + AS_VAR_SET([gl_cv_absolute_]AS_TR_SH([[$1]]), +[`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD | + sed -n "$gl_absolute_header_sed"`]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/alloca.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/alloca.m4 new file mode 100644 index 00000000..90960215 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/alloca.m4 @@ -0,0 +1,106 @@ +# alloca.m4 serial 21 +dnl Copyright (C) 2002-2004, 2006-2007, 2009-2024 Free Software Foundation, +dnl Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_ALLOCA], +[ + AC_REQUIRE([AC_FUNC_ALLOCA]) + if test $ac_cv_func_alloca_works = no; then + gl_PREREQ_ALLOCA + fi + + # Define an additional variable used in the Makefile substitution. + if test $ac_cv_working_alloca_h = yes; then + AC_CACHE_CHECK([for alloca as a compiler built-in], [gl_cv_rpl_alloca], [ + AC_EGREP_CPP([Need own alloca], [ +#if defined __GNUC__ || defined _AIX || defined _MSC_VER + Need own alloca +#endif + ], [gl_cv_rpl_alloca=yes], [gl_cv_rpl_alloca=no]) + ]) + if test $gl_cv_rpl_alloca = yes; then + dnl OK, alloca can be implemented through a compiler built-in. + AC_DEFINE([HAVE_ALLOCA], [1], + [Define to 1 if you have 'alloca' after including , + a header that may be supplied by this distribution.]) + GL_GENERATE_ALLOCA_H=true + else + dnl alloca exists as a library function, i.e. it is slow and probably + dnl a memory leak. Don't define HAVE_ALLOCA in this case. + GL_GENERATE_ALLOCA_H=false + fi + else + GL_GENERATE_ALLOCA_H=true + fi + + if test $ac_cv_working_alloca_h = yes; then + HAVE_ALLOCA_H=1 + else + HAVE_ALLOCA_H=0 + fi + AC_SUBST([HAVE_ALLOCA_H]) +]) + +# Prerequisites of lib/alloca.c. +# STACK_DIRECTION is already handled by AC_FUNC_ALLOCA. +AC_DEFUN([gl_PREREQ_ALLOCA], [:]) + +m4_version_prereq([2.70], [], [ + +# This works around a bug in autoconf <= 2.68 and has simplifications +# from 2.70. See: +# https://lists.gnu.org/r/bug-gnulib/2011-06/msg00277.html +# https://git.savannah.gnu.org/cgit/autoconf.git/commit/?id=6cd9f12520b0d6f76d3230d7565feba1ecf29497 +# https://git.savannah.gnu.org/cgit/autoconf.git/commit/?id=15edf7fd8094fd14a89d9891dd72a9624762597a + +# _AC_LIBOBJ_ALLOCA +# ----------------- +# Set up the LIBOBJ replacement of 'alloca'. Well, not exactly +# AC_LIBOBJ since we actually set the output variable 'ALLOCA'. +# Nevertheless, for Automake, AC_LIBSOURCES it. +m4_define([_AC_LIBOBJ_ALLOCA], +[# The SVR3 libPW and SVR4 libucb both contain incompatible functions +# that cause trouble. Some versions do not even contain alloca or +# contain a buggy version. If you still want to use their alloca, +# use ar to extract alloca.o from them instead of compiling alloca.c. +AC_LIBSOURCES(alloca.c) +AC_SUBST([ALLOCA], [\${LIBOBJDIR}alloca.$ac_objext])dnl +AC_DEFINE(C_ALLOCA, 1, [Define to 1 if using 'alloca.c'.]) + +AC_CACHE_CHECK([stack direction for C alloca], + [ac_cv_c_stack_direction], +[AC_RUN_IFELSE([AC_LANG_SOURCE( +[AC_INCLUDES_DEFAULT +int +find_stack_direction (int *addr, int depth) +{ + int dir, dummy = 0; + if (! addr) + addr = &dummy; + *addr = addr < &dummy ? 1 : addr == &dummy ? 0 : -1; + dir = depth ? find_stack_direction (addr, depth - 1) : 0; + return dir + dummy; +} + +int +main (int argc, char **argv) +{ + return find_stack_direction (0, argc + !argv + 20) < 0; +}])], + [ac_cv_c_stack_direction=1], + [ac_cv_c_stack_direction=-1], + [ac_cv_c_stack_direction=0])]) +AH_VERBATIM([STACK_DIRECTION], +[/* If using the C implementation of alloca, define if you know the + direction of stack growth for your system; otherwise it will be + automatically deduced at runtime. + STACK_DIRECTION > 0 => grows toward higher addresses + STACK_DIRECTION < 0 => grows toward lower addresses + STACK_DIRECTION = 0 => direction of growth unknown */ +#undef STACK_DIRECTION])dnl +AC_DEFINE_UNQUOTED(STACK_DIRECTION, $ac_cv_c_stack_direction) +])# _AC_LIBOBJ_ALLOCA +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/arpa_inet_h.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/arpa_inet_h.m4 new file mode 100644 index 00000000..754b38eb --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/arpa_inet_h.m4 @@ -0,0 +1,74 @@ +# arpa_inet_h.m4 serial 17 +dnl Copyright (C) 2006, 2008-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl Written by Simon Josefsson and Bruno Haible + +AC_DEFUN_ONCE([gl_ARPA_INET_H], +[ + dnl Ensure to expand the default settings once only, before all statements + dnl that occur in other macros. + AC_REQUIRE([gl_ARPA_INET_H_DEFAULTS]) + + AC_CHECK_HEADERS_ONCE([arpa/inet.h]) + if test $ac_cv_header_arpa_inet_h = yes; then + HAVE_ARPA_INET_H=1 + else + HAVE_ARPA_INET_H=0 + fi + AC_SUBST([HAVE_ARPA_INET_H]) + dnl is always overridden, because of GNULIB_POSIXCHECK. + gl_CHECK_NEXT_HEADERS([arpa/inet.h]) + + AC_REQUIRE([gl_FEATURES_H]) + + gl_PREREQ_SYS_H_WS2TCPIP + + dnl Check for declarations of anything we want to poison if the + dnl corresponding gnulib module is not in use. + gl_WARN_ON_USE_PREPARE([[ +/* On some systems, this header is not self-consistent. */ +#if !(defined __GLIBC__ || defined __UCLIBC__) +# include +#endif +#ifdef __TANDEM +# include +#endif +#include + ]], [inet_ntop inet_pton]) +]) + +# gl_ARPA_INET_MODULE_INDICATOR([modulename]) +# sets the shell variable that indicates the presence of the given module +# to a C preprocessor expression that will evaluate to 1. +# This macro invocation must not occur in macros that are AC_REQUIREd. +AC_DEFUN([gl_ARPA_INET_MODULE_INDICATOR], +[ + dnl Ensure to expand the default settings once only. + gl_ARPA_INET_H_REQUIRE_DEFAULTS + gl_MODULE_INDICATOR_SET_VARIABLE([$1]) +]) + +# Initializes the default values for AC_SUBSTed shell variables. +# This macro must not be AC_REQUIREd. It must only be invoked, and only +# outside of macros or in macros that are not AC_REQUIREd. +AC_DEFUN([gl_ARPA_INET_H_REQUIRE_DEFAULTS], +[ + m4_defun(GL_MODULE_INDICATOR_PREFIX[_ARPA_INET_H_MODULE_INDICATOR_DEFAULTS], [ + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_INET_NTOP]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_INET_PTON]) + ]) + m4_require(GL_MODULE_INDICATOR_PREFIX[_ARPA_INET_H_MODULE_INDICATOR_DEFAULTS]) + AC_REQUIRE([gl_ARPA_INET_H_DEFAULTS]) +]) + +AC_DEFUN([gl_ARPA_INET_H_DEFAULTS], +[ + dnl Assume proper GNU behavior unless another module says otherwise. + HAVE_DECL_INET_NTOP=1; AC_SUBST([HAVE_DECL_INET_NTOP]) + HAVE_DECL_INET_PTON=1; AC_SUBST([HAVE_DECL_INET_PTON]) + REPLACE_INET_NTOP=0; AC_SUBST([REPLACE_INET_NTOP]) + REPLACE_INET_PTON=0; AC_SUBST([REPLACE_INET_PTON]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/asm-underscore.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/asm-underscore.m4 new file mode 100644 index 00000000..cc63465f --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/asm-underscore.m4 @@ -0,0 +1,83 @@ +# asm-underscore.m4 serial 5 +dnl Copyright (C) 2010-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. Based on as-underscore.m4 in GNU clisp. + +# gl_ASM_SYMBOL_PREFIX +# Tests for the prefix of C symbols at the assembly language level and the +# linker level. This prefix is either an underscore or empty. Defines the +# C macro USER_LABEL_PREFIX to this prefix, and sets ASM_SYMBOL_PREFIX to +# a stringified variant of this prefix. + +AC_DEFUN([gl_ASM_SYMBOL_PREFIX], +[ + AC_REQUIRE([AC_PROG_EGREP]) + dnl We don't use GCC's __USER_LABEL_PREFIX__ here, because + dnl 1. It works only for GCC. + dnl 2. It is incorrectly defined on some platforms, in some GCC versions. + AC_REQUIRE([gl_C_ASM]) + AC_CACHE_CHECK( + [whether C symbols are prefixed with underscore at the linker level], + [gl_cv_prog_as_underscore], + [cat > conftest.c </dev/null 2>&1 + if LC_ALL=C $EGREP '(^|[[^a-zA-Z0-9_]])_foo([[^a-zA-Z0-9_]]|$)' conftest.$gl_asmext >/dev/null; then + gl_cv_prog_as_underscore=yes + else + gl_cv_prog_as_underscore=no + fi + rm -f conftest* + ]) + if test $gl_cv_prog_as_underscore = yes; then + USER_LABEL_PREFIX=_ + else + USER_LABEL_PREFIX= + fi + AC_DEFINE_UNQUOTED([USER_LABEL_PREFIX], [$USER_LABEL_PREFIX], + [Define to the prefix of C symbols at the assembler and linker level, + either an underscore or empty.]) + ASM_SYMBOL_PREFIX='"'${USER_LABEL_PREFIX}'"' + AC_SUBST([ASM_SYMBOL_PREFIX]) +]) + +# gl_C_ASM +# Determines how to produce an assembly language file from C source code. +# Sets the variables: +# gl_asmext - the extension of assembly language output, +# gl_c_asm_opt - the C compiler option that produces assembly language output. + +AC_DEFUN([gl_C_ASM], +[ + AC_EGREP_CPP([MicrosoftCompiler], + [ +#ifdef _MSC_VER +MicrosoftCompiler +#endif + ], + [dnl Microsoft's 'cl' and 'clang-cl' produce an .asm file, whereas 'clang' + dnl produces a .s file. Need to distinguish 'clang' and 'clang-cl'. + rm -f conftest* + echo 'int dummy;' > conftest.c + AC_TRY_COMMAND(${CC-cc} $CFLAGS $CPPFLAGS -c conftest.c) >/dev/null 2>&1 + if test -f conftest.o; then + gl_asmext='s' + gl_c_asm_opt='-S' + else + gl_asmext='asm' + gl_c_asm_opt='-c -Fa' + fi + rm -f conftest* + ], + [gl_asmext='s' + gl_c_asm_opt='-S' + ]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/assert_h.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/assert_h.m4 new file mode 100644 index 00000000..a73e45f0 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/assert_h.m4 @@ -0,0 +1,73 @@ +# assert-h.m4 +dnl Copyright (C) 2011-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Paul Eggert. + +AC_DEFUN([gl_ASSERT_H], +[ + AC_CACHE_CHECK([for static_assert], [gl_cv_static_assert], + [gl_save_CFLAGS=$CFLAGS + for gl_working in "yes, a keyword" "yes, an macro"; do + AS_CASE([$gl_working], + [*assert.h*], [CFLAGS="$gl_save_CFLAGS -DINCLUDE_ASSERT_H"]) + + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#if defined __clang__ && __STDC_VERSION__ < 202311 + #pragma clang diagnostic error "-Wc2x-extensions" + #pragma clang diagnostic error "-Wc++1z-extensions" + #endif + #ifdef INCLUDE_ASSERT_H + #include + #endif + static_assert (2 + 2 == 4, "arithmetic does not work"); + static_assert (2 + 2 == 4); + ]], + [[ + static_assert (sizeof (char) == 1, "sizeof does not work"); + static_assert (sizeof (char) == 1); + ]])], + [gl_cv_static_assert=$gl_working], + [gl_cv_static_assert=no]) + CFLAGS=$gl_save_CFLAGS + test "$gl_cv_static_assert" != no && break + done]) + + GL_GENERATE_ASSERT_H=false + AS_CASE([$gl_cv_static_assert], + [yes*keyword*], + [AC_DEFINE([HAVE_C_STATIC_ASSERT], [1], + [Define to 1 if the static_assert keyword works.])], + [no], + [GL_GENERATE_ASSERT_H=true + gl_NEXT_HEADERS([assert.h])]) + + dnl The "zz" puts this toward config.h's end, to avoid potential + dnl collisions with other definitions. + dnl #undef assert so that programs are not tempted to use it without + dnl specifically including assert.h. + dnl #undef __ASSERT_H__ so that on IRIX, when programs later include + dnl , this include actually defines assert. + dnl Break the #undef_s apart with a comment so that 'configure' does + dnl not comment them out. + AH_VERBATIM([zzstatic_assert], +[#if (!defined HAVE_C_STATIC_ASSERT && !defined assert \ + && (!defined __cplusplus \ + || (__cpp_static_assert < 201411 \ + && __GNUG__ < 6 && __clang_major__ < 6))) + #include + #undef/**/assert + #ifdef __sgi + #undef/**/__ASSERT_H__ + #endif + /* Solaris 11.4 defines static_assert as a macro with 2 arguments. + We need it also to be invocable with a single argument. */ + #if defined __sun && (__STDC_VERSION__ - 0 >= 201112L) && !defined __cplusplus + #undef/**/static_assert + #define static_assert _Static_assert + #endif +#endif]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/atoll.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/atoll.m4 new file mode 100644 index 00000000..5123a92d --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/atoll.m4 @@ -0,0 +1,19 @@ +# atoll.m4 serial 3 +dnl Copyright (C) 2008-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_ATOLL], +[ + AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) + AC_CHECK_FUNCS([atoll]) + if test $ac_cv_func_atoll = no; then + HAVE_ATOLL=0 + fi +]) + +# Prerequisites of lib/atoll.c. +AC_DEFUN([gl_PREREQ_ATOLL], [ + : +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/btowc.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/btowc.m4 new file mode 100644 index 00000000..8bb55dc8 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/btowc.m4 @@ -0,0 +1,161 @@ +# btowc.m4 serial 14 +dnl Copyright (C) 2008-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_BTOWC], +[ + AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) + + dnl Check whether is usable at all, first. Otherwise the test + dnl program below may lead to an endless loop. See + dnl . + AC_REQUIRE([gl_WCHAR_H_INLINE_OK]) + + AC_CHECK_FUNCS_ONCE([btowc]) + if test $ac_cv_func_btowc = no; then + HAVE_BTOWC=0 + else + + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([gt_LOCALE_FR]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + + dnl Cygwin 1.7.2 btowc('\0') is WEOF, not 0. + AC_CACHE_CHECK([whether btowc(0) is correct], + [gl_cv_func_btowc_nul], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +int main () +{ + if (btowc ('\0') != 0) + return 1; + return 0; +}]])], + [gl_cv_func_btowc_nul=yes], + [gl_cv_func_btowc_nul=no], + [ +changequote(,)dnl + case "$host_os" in + # Guess no on Cygwin. + cygwin*) gl_cv_func_btowc_nul="guessing no" ;; + # Guess yes on native Windows. + mingw* | windows*) gl_cv_func_btowc_nul="guessing yes" ;; + # Guess yes otherwise. + *) gl_cv_func_btowc_nul="guessing yes" ;; + esac +changequote([,])dnl + ]) + ]) + + dnl IRIX 6.5 btowc(EOF) is 0xFF, not WEOF. + AC_CACHE_CHECK([whether btowc(EOF) is correct], + [gl_cv_func_btowc_eof], + [ + dnl Initial guess, used when cross-compiling or when no suitable locale + dnl is present. +changequote(,)dnl + case "$host_os" in + # Guess no on IRIX. + irix*) gl_cv_func_btowc_eof="guessing no" ;; + # Guess yes on native Windows. + mingw* | windows*) gl_cv_func_btowc_eof="guessing yes" ;; + # Guess yes otherwise. + *) gl_cv_func_btowc_eof="guessing yes" ;; + esac +changequote([,])dnl + if test $LOCALE_FR != none; then + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +#include +int main () +{ + if (setlocale (LC_ALL, "$LOCALE_FR") != NULL) + { + if (btowc (EOF) != WEOF) + return 1; + } + return 0; +}]])], + [gl_cv_func_btowc_eof=yes], + [gl_cv_func_btowc_eof=no], + [:]) + fi + ]) + + dnl On mingw, in the C locale, btowc is inconsistent with mbrtowc: + dnl mbrtowc avoids calling MultiByteToWideChar when MB_CUR_MAX is 1 and + dnl ___lc_codepage_func() is 0, but btowc is lacking this special case. + AC_CHECK_FUNCS_ONCE([mbrtowc]) + AC_CACHE_CHECK([whether btowc is consistent with mbrtowc in the C locale], + [gl_cv_func_btowc_consistent], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +#include +int main () +{ +#if HAVE_MBRTOWC + wint_t wc1 = btowc (0x80); + wchar_t wc2 = (wchar_t) 0xbadface; + char buf[1] = { 0x80 }; + mbstate_t state; + memset (&state, 0, sizeof (mbstate_t)); + if (mbrtowc (&wc2, buf, 1, &state) != 1 || wc1 != wc2) + return 1; +#endif + return 0; +}]])], + [gl_cv_func_btowc_consistent=yes], + [gl_cv_func_btowc_consistent=no], + [case "$host_os" in + # Guess no on mingw. + mingw* | windows*) + AC_EGREP_CPP([Problem], [ +#ifdef __MINGW32__ + Problem +#endif + ], + [gl_cv_func_btowc_consistent="guessing no"], + [gl_cv_func_btowc_consistent="guessing yes"]) + ;; + # Guess yes otherwise. + *) gl_cv_func_btowc_consistent="guessing yes" ;; + esac + ]) + ]) + + case "$gl_cv_func_btowc_nul" in + *yes) ;; + *) REPLACE_BTOWC=1 ;; + esac + case "$gl_cv_func_btowc_eof" in + *yes) ;; + *) REPLACE_BTOWC=1 ;; + esac + case "$gl_cv_func_btowc_consistent" in + *yes) ;; + *) REPLACE_BTOWC=1 ;; + esac + if test $REPLACE_BTOWC = 0; then + gl_MBRTOWC_C_LOCALE + case "$gl_cv_func_mbrtowc_C_locale_sans_EILSEQ" in + *yes) ;; + *) REPLACE_BTOWC=1 ;; + esac + fi + fi +]) + +# Prerequisites of lib/btowc.c. +AC_DEFUN([gl_PREREQ_BTOWC], [ + : + AC_CHECK_FUNCS_ONCE([mbrtowc]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/builtin-expect.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/builtin-expect.m4 new file mode 100644 index 00000000..8faffc50 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/builtin-expect.m4 @@ -0,0 +1,49 @@ +dnl Check for __builtin_expect. + +dnl Copyright 2016-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl Written by Paul Eggert. + +AC_DEFUN([gl___BUILTIN_EXPECT], +[ + AC_CACHE_CHECK([for __builtin_expect], + [gl_cv___builtin_expect], + [AC_LINK_IFELSE( + [AC_LANG_SOURCE([[ + int + main (int argc, char **argv) + { + argc = __builtin_expect (argc, 100); + return argv[argc != 100][0]; + }]])], + [gl_cv___builtin_expect=yes], + [AC_LINK_IFELSE( + [AC_LANG_SOURCE([[ + #include + int + main (int argc, char **argv) + { + argc = __builtin_expect (argc, 100); + return argv[argc != 100][0]; + }]])], + [gl_cv___builtin_expect="in "], + [gl_cv___builtin_expect=no])])]) + if test "$gl_cv___builtin_expect" = yes; then + AC_DEFINE([HAVE___BUILTIN_EXPECT], [1]) + elif test "$gl_cv___builtin_expect" = "in "; then + AC_DEFINE([HAVE___BUILTIN_EXPECT], [2]) + fi + AH_VERBATIM([HAVE___BUILTIN_EXPECT], + [/* Define to 1 if the compiler supports __builtin_expect, + and to 2 if does. */ +#undef HAVE___BUILTIN_EXPECT +#ifndef HAVE___BUILTIN_EXPECT +# define __builtin_expect(e, c) (e) +#elif HAVE___BUILTIN_EXPECT == 2 +# include +#endif + ]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/c-bool.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/c-bool.m4 new file mode 100644 index 00000000..44fba3c0 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/c-bool.m4 @@ -0,0 +1,51 @@ +# Check for bool that conforms to C2023. + +dnl Copyright 2022-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_C_BOOL], +[ + AC_CACHE_CHECK([for bool, true, false], [gl_cv_c_bool], + [AC_COMPILE_IFELSE( + [AC_LANG_SOURCE([[ + #if true == false + #error "true == false" + #endif + extern bool b; + bool b = true == false;]])], + [gl_cv_c_bool=yes], + [gl_cv_c_bool=no])]) + if test "$gl_cv_c_bool" = yes; then + AC_DEFINE([HAVE_C_BOOL], [1], + [Define to 1 if bool, true and false work as per C2023.]) + fi + + AC_CHECK_HEADERS_ONCE([stdbool.h]) + + dnl The "zz" puts this toward config.h's end, to avoid potential + dnl collisions with other definitions. + dnl If 'bool', 'true' and 'false' do not work, arrange for them to work. + dnl In C, this means including if it is not already included. + dnl However, if the preprocessor mistakenly treats 'true' as 0, + dnl define it to a bool expression equal to 1; this is needed in + dnl Sun C++ 5.11 (Oracle Solaris Studio 12.2, 2010) and older. + AH_VERBATIM([zzbool], +[#ifndef HAVE_C_BOOL +# if !defined __cplusplus && !defined __bool_true_false_are_defined +# if HAVE_STDBOOL_H +# include +# else +# if defined __SUNPRO_C +# error " is not usable with this configuration. To make it usable, add -D_STDC_C99= to $CC." +# else +# error " does not exist on this platform. Use gnulib module 'stdbool-c99' instead of gnulib module 'stdbool'." +# endif +# endif +# endif +# if !true +# define true (!false) +# endif +#endif]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/c-stack.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/c-stack.m4 new file mode 100644 index 00000000..99c04cdf --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/c-stack.m4 @@ -0,0 +1,20 @@ +# Check prerequisites for compiling lib/c-stack.c. + +# Copyright (C) 2002-2004, 2008-2024 Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# Written by Paul Eggert. + +# serial 25 + +AC_DEFUN([gl_C_STACK], +[ + dnl 'c-stack' needs -lsigsegv if and only if the 'sigsegv' module needs it. + AC_REQUIRE([gl_SIGSEGV]) + if test $gl_sigsegv_uses_libsigsegv = yes; then + AC_SUBST([LIBCSTACK], [$LIBSIGSEGV]) + AC_SUBST([LTLIBCSTACK], [$LTLIBSIGSEGV]) + fi +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/c32rtomb.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/c32rtomb.m4 new file mode 100644 index 00000000..56faaa57 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/c32rtomb.m4 @@ -0,0 +1,88 @@ +# c32rtomb.m4 serial 7 +dnl Copyright (C) 2020-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_C32RTOMB], +[ + AC_REQUIRE([gl_UCHAR_H_DEFAULTS]) + AC_REQUIRE([AC_CANONICAL_HOST]) + + AC_REQUIRE([gl_MBRTOC32_SANITYCHECK]) + + dnl Cf. gl_CHECK_FUNCS_ANDROID + AC_CHECK_DECL([c32rtomb], , , + [[#ifdef __HAIKU__ + #include + #endif + #include + ]]) + if test $ac_cv_have_decl_c32rtomb = yes; then + dnl We can't use AC_CHECK_FUNC here, because c32rtomb() is defined as a + dnl static inline function on Haiku 2020. + AC_CACHE_CHECK([for c32rtomb], [gl_cv_func_c32rtomb], + [AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include + #ifdef __HAIKU__ + #include + #endif + #include + ]], + [[char buf[8]; + return c32rtomb (buf, 0, NULL) == 0; + ]]) + ], + [gl_cv_func_c32rtomb=yes], + [gl_cv_func_c32rtomb=no]) + ]) + else + gl_cv_func_c32rtomb=no + fi + if test $gl_cv_func_c32rtomb = no; then + HAVE_C32RTOMB=0 + else + dnl When we override mbrtoc32, redefining the meaning of the char32_t + dnl values, we need to override c32rtomb as well, for consistency. + if test $HAVE_WORKING_MBRTOC32 = 0; then + REPLACE_C32RTOMB=1 + fi + AC_CACHE_CHECK([whether c32rtomb return value is correct], + [gl_cv_func_c32rtomb_retval], + [ + dnl Initial guess, used when cross-compiling. +changequote(,)dnl + case "$host_os" in + # Guess no on AIX. + aix*) gl_cv_func_c32rtomb_retval="guessing no" ;; + # Guess yes otherwise. + *) gl_cv_func_c32rtomb_retval="guessing yes" ;; + esac +changequote([,])dnl + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#ifdef __HAIKU__ + #include +#endif +#include +int main () +{ + int result = 0; + if (c32rtomb (NULL, 0, NULL) != 1) + result |= 1; + return result; +}]])], + [gl_cv_func_c32rtomb_retval=yes], + [gl_cv_func_c32rtomb_retval=no], + [:]) + ]) + case "$gl_cv_func_c32rtomb_retval" in + *yes) ;; + *) AC_DEFINE([C32RTOMB_RETVAL_BUG], [1], + [Define if the c32rtomb function has an incorrect return value.]) + REPLACE_C32RTOMB=1 ;; + esac + fi +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/calloc.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/calloc.m4 new file mode 100644 index 00000000..49303d96 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/calloc.m4 @@ -0,0 +1,83 @@ +# calloc.m4 serial 31 + +# Copyright (C) 2004-2024 Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# Written by Jim Meyering. + +# Determine whether calloc (N, S) returns non-NULL when N*S is zero, +# and returns NULL when N*S overflows. +# If so, define HAVE_CALLOC. Otherwise, define calloc to rpl_calloc +# and arrange to use a calloc wrapper function that does work in that case. + +# _AC_FUNC_CALLOC_IF([IF-WORKS], [IF-NOT]) +# ------------------------------------- +# If calloc is compatible with GNU calloc, run IF-WORKS, otherwise, IF-NOT. +AC_DEFUN([_AC_FUNC_CALLOC_IF], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether calloc (0, n) and calloc (n, 0) return nonnull], + [ac_cv_func_calloc_0_nonnull], + [if test $cross_compiling != yes; then + ac_cv_func_calloc_0_nonnull=yes + AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [AC_INCLUDES_DEFAULT], + [[int result = 0; + char * volatile p = calloc (0, 0); + if (!p) + result |= 1; + free (p); + return result; + ]])], + [], + [ac_cv_func_calloc_0_nonnull=no]) + else + case "$host_os" in + # Guess yes on glibc systems. + *-gnu* | gnu*) ac_cv_func_calloc_0_nonnull="guessing yes" ;; + # Guess yes on musl systems. + *-musl* | midipix*) ac_cv_func_calloc_0_nonnull="guessing yes" ;; + # Guess yes on native Windows. + mingw* | windows*) ac_cv_func_calloc_0_nonnull="guessing yes" ;; + # If we don't know, obey --enable-cross-guesses. + *) ac_cv_func_calloc_0_nonnull="$gl_cross_guess_normal" ;; + esac + fi + ]) + AS_CASE([$ac_cv_func_calloc_0_nonnull], [*yes], [$1], [$2]) +]) + + +# gl_FUNC_CALLOC_GNU +# ------------------ +# Replace calloc if it is not compatible with GNU libc. +AC_DEFUN([gl_FUNC_CALLOC_GNU], +[ + AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) + AC_REQUIRE([gl_FUNC_CALLOC_POSIX]) + REPLACE_CALLOC_FOR_CALLOC_GNU="$REPLACE_CALLOC_FOR_CALLOC_POSIX" + if test $REPLACE_CALLOC_FOR_CALLOC_GNU = 0; then + _AC_FUNC_CALLOC_IF([], [REPLACE_CALLOC_FOR_CALLOC_GNU=1]) + fi +])# gl_FUNC_CALLOC_GNU + +# gl_FUNC_CALLOC_POSIX +# -------------------- +# Test whether 'calloc' is POSIX compliant (sets errno to ENOMEM when it +# fails, and doesn't mess up with ptrdiff_t or size_t overflow), +# and replace calloc if it is not. +AC_DEFUN([gl_FUNC_CALLOC_POSIX], +[ + AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) + AC_REQUIRE([gl_FUNC_MALLOC_POSIX]) + if test $REPLACE_MALLOC_FOR_MALLOC_POSIX = 1; then + REPLACE_CALLOC_FOR_CALLOC_POSIX=1 + fi + dnl Although in theory we should also test for size_t overflow, + dnl in practice testing for ptrdiff_t overflow suffices + dnl since PTRDIFF_MAX <= SIZE_MAX on all known Gnulib porting targets. + dnl A separate size_t test would slow down 'configure'. +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/chdir-long.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/chdir-long.m4 new file mode 100644 index 00000000..62c7a79c --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/chdir-long.m4 @@ -0,0 +1,30 @@ +#serial 17 + +# Use Gnulib's robust chdir function. +# It can handle arbitrarily long directory names, which means +# that when it is given the name of an existing directory, it +# never fails with ENAMETOOLONG. +# Arrange to compile chdir-long.c only on systems that define PATH_MAX. + +dnl Copyright (C) 2004-2007, 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +# Written by Jim Meyering. + +AC_DEFUN([gl_FUNC_CHDIR_LONG], +[ + AC_REQUIRE([gl_PATHMAX_SNIPPET_PREREQ]) + AC_CACHE_CHECK([whether this system supports file names of any length], + [gl_cv_have_unlimited_file_name_length], + [AC_EGREP_CPP([have_arbitrary_file_name_length_limit], + gl_PATHMAX_SNIPPET[ +#ifdef PATH_MAX +have_arbitrary_file_name_length_limit +#endif], + [gl_cv_have_unlimited_file_name_length=no], + [gl_cv_have_unlimited_file_name_length=yes])]) +]) + +AC_DEFUN([gl_PREREQ_CHDIR_LONG], [:]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/clock_time.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/clock_time.m4 new file mode 100644 index 00000000..c016575c --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/clock_time.m4 @@ -0,0 +1,53 @@ +# clock_time.m4 serial 14 +dnl Copyright (C) 2002-2006, 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +# Check for clock_getres, clock_gettime and clock_settime, +# and set CLOCK_TIME_LIB. +# For a program named, say foo, you should add a line like the following +# in the corresponding Makefile.am file: +# foo_LDADD = $(LDADD) $(CLOCK_TIME_LIB) + +AC_DEFUN([gl_CLOCK_TIME], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) + + dnl Persuade glibc and Solaris to declare these functions. + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + + # On mingw, these functions are defined in the libwinpthread library, + # which is better avoided. In fact, the clock_gettime function is buggy + # in 32-bit mingw, when -D__MINGW_USE_VC2005_COMPAT is used (which Gnulib's + # year2038 module does): It leaves the upper 32 bits of the tv_sec field + # of the result uninitialized. + + # Solaris 2.5.1 needs -lposix4 to get the clock_gettime function. + # Solaris 7 prefers the library name -lrt to the obsolescent name -lposix4. + + # Save and restore LIBS so e.g., -lrt, isn't added to it. Otherwise, *all* + # programs in the package would end up linked with that potentially-shared + # library, inducing unnecessary run-time overhead. + CLOCK_TIME_LIB= + AC_SUBST([CLOCK_TIME_LIB]) + case "$host_os" in + mingw* | windows*) + ac_cv_func_clock_getres=no + ac_cv_func_clock_gettime=no + ac_cv_func_clock_settime=no + ;; + *) + gl_saved_libs=$LIBS + AC_SEARCH_LIBS([clock_gettime], [rt posix4], + [test "$ac_cv_search_clock_gettime" = "none required" || + CLOCK_TIME_LIB=$ac_cv_search_clock_gettime]) + AC_CHECK_FUNCS([clock_getres clock_gettime clock_settime]) + LIBS=$gl_saved_libs + ;; + esac + + # For backward compatibility. + LIB_CLOCK_GETTIME="$CLOCK_TIME_LIB" + AC_SUBST([LIB_CLOCK_GETTIME]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/close.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/close.m4 new file mode 100644 index 00000000..6b6d3821 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/close.m4 @@ -0,0 +1,35 @@ +# close.m4 serial 10 +dnl Copyright (C) 2008-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN_ONCE([gl_FUNC_CLOSE], +[ + AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) + m4_ifdef([gl_MSVC_INVAL], [ + AC_REQUIRE([gl_MSVC_INVAL]) + if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then + REPLACE_CLOSE=1 + fi + ]) + m4_ifdef([gl_PREREQ_SYS_H_WINSOCK2], [ + gl_PREREQ_SYS_H_WINSOCK2 + if test $UNISTD_H_HAVE_WINSOCK2_H = 1; then + dnl Even if the 'socket' module is not used here, another part of the + dnl application may use it and pass file descriptors that refer to + dnl sockets to the close() function. So enable the support for sockets. + REPLACE_CLOSE=1 + fi + ]) + dnl Replace close() for supporting the gnulib-defined fchdir() function, + dnl to keep fchdir's bookkeeping up-to-date. + m4_ifdef([gl_FUNC_FCHDIR], [ + if test $REPLACE_CLOSE = 0; then + gl_TEST_FCHDIR + if test $HAVE_FCHDIR = 0; then + REPLACE_CLOSE=1 + fi + fi + ]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/closedir.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/closedir.m4 new file mode 100644 index 00000000..3774806f --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/closedir.m4 @@ -0,0 +1,31 @@ +# closedir.m4 serial 8 +dnl Copyright (C) 2011-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_CLOSEDIR], +[ + AC_REQUIRE([gl_DIRENT_H_DEFAULTS]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + + AC_CHECK_FUNCS([closedir]) + if test $ac_cv_func_closedir = no; then + HAVE_CLOSEDIR=0 + else + dnl Replace closedir() on native Windows and OS/2 kLIBC, + dnl to support fdopendir(). + AC_REQUIRE([gl_DIRENT_DIR]) + if test $DIR_HAS_FD_MEMBER = 0; then + REPLACE_CLOSEDIR=1 + fi + dnl Replace closedir() for supporting the gnulib-defined fchdir() function, + dnl to keep fchdir's bookkeeping up-to-date. + m4_ifdef([gl_FUNC_FCHDIR], [ + gl_TEST_FCHDIR + if test $HAVE_FCHDIR = 0; then + REPLACE_CLOSEDIR=1 + fi + ]) + fi +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/codeset.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/codeset.m4 new file mode 100644 index 00000000..94dccce7 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/codeset.m4 @@ -0,0 +1,24 @@ +# codeset.m4 serial 5 (gettext-0.18.2) +dnl Copyright (C) 2000-2002, 2006, 2008-2014, 2016, 2019-2024 Free Software +dnl Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. + +AC_DEFUN([AM_LANGINFO_CODESET], +[ + AC_CACHE_CHECK([for nl_langinfo and CODESET], [am_cv_langinfo_codeset], + [AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include ]], + [[char* cs = nl_langinfo(CODESET); return !cs;]])], + [am_cv_langinfo_codeset=yes], + [am_cv_langinfo_codeset=no]) + ]) + if test $am_cv_langinfo_codeset = yes; then + AC_DEFINE([HAVE_LANGINFO_CODESET], [1], + [Define if you have and nl_langinfo(CODESET).]) + fi +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/config-h.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/config-h.m4 new file mode 100644 index 00000000..9f3ab6ae --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/config-h.m4 @@ -0,0 +1,13 @@ +# Say that -DHAVE_CONFIG_H is not needed. + +dnl Copyright (C) 2006, 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl Written by Paul Eggert. + +# This package's source files all include config.h unconditionally, +# so there's no need to pass -DHAVE_CONFIG_H to the compiler. +AC_DEFUN([gl_CONFIG_H], + [AC_CONFIG_COMMANDS_PRE([test "X$DEFS" = X-DHAVE_CONFIG_H && DEFS=])]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/ctype_h.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/ctype_h.m4 new file mode 100644 index 00000000..ef0ee7f2 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/ctype_h.m4 @@ -0,0 +1,47 @@ +# ctype_h.m4 serial 9 +dnl Copyright (C) 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN_ONCE([gl_CTYPE_H], +[ + AC_REQUIRE([gl_CTYPE_H_DEFAULTS]) + + dnl is always overridden, because of GNULIB_POSIXCHECK. + gl_NEXT_HEADERS([ctype.h]) + + dnl Check for declarations of anything we want to poison if the + dnl corresponding gnulib module is not in use. + gl_WARN_ON_USE_PREPARE([[#include + ]], [isblank]) +]) + +# gl_CTYPE_MODULE_INDICATOR([modulename]) +# sets the shell variable that indicates the presence of the given module +# to a C preprocessor expression that will evaluate to 1. +# This macro invocation must not occur in macros that are AC_REQUIREd. +AC_DEFUN([gl_CTYPE_MODULE_INDICATOR], +[ + dnl Ensure to expand the default settings once only. + gl_CTYPE_H_REQUIRE_DEFAULTS + gl_MODULE_INDICATOR_SET_VARIABLE([$1]) +]) + +# Initializes the default values for AC_SUBSTed shell variables. +# This macro must not be AC_REQUIREd. It must only be invoked, and only +# outside of macros or in macros that are not AC_REQUIREd. +AC_DEFUN([gl_CTYPE_H_REQUIRE_DEFAULTS], +[ + m4_defun(GL_MODULE_INDICATOR_PREFIX[_CTYPE_H_MODULE_INDICATOR_DEFAULTS], [ + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISBLANK]) + ]) + m4_require(GL_MODULE_INDICATOR_PREFIX[_CTYPE_H_MODULE_INDICATOR_DEFAULTS]) + AC_REQUIRE([gl_CTYPE_H_DEFAULTS]) +]) + +AC_DEFUN([gl_CTYPE_H_DEFAULTS], +[ + dnl Assume proper GNU behavior unless another module says otherwise. + HAVE_ISBLANK=1; AC_SUBST([HAVE_ISBLANK]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/dirent_h.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/dirent_h.m4 new file mode 100644 index 00000000..3e3d967f --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/dirent_h.m4 @@ -0,0 +1,97 @@ +# dirent_h.m4 serial 22 +dnl Copyright (C) 2008-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl Written by Bruno Haible. + +AC_DEFUN_ONCE([gl_DIRENT_H], +[ + dnl Ensure to expand the default settings once only, before all statements + dnl that occur in other macros. + AC_REQUIRE([gl_DIRENT_H_DEFAULTS]) + + dnl is always overridden, because of GNULIB_POSIXCHECK. + gl_CHECK_NEXT_HEADERS([dirent.h]) + if test $ac_cv_header_dirent_h = yes; then + HAVE_DIRENT_H=1 + else + HAVE_DIRENT_H=0 + fi + AC_SUBST([HAVE_DIRENT_H]) + + gl_DIRENT_DIR + + dnl Check for declarations of anything we want to poison if the + dnl corresponding gnulib module is not in use. + gl_WARN_ON_USE_PREPARE([[#include + ]], [alphasort closedir dirfd fdopendir opendir readdir rewinddir scandir]) +]) + +dnl Determine whether needs to override the DIR type. +AC_DEFUN_ONCE([gl_DIRENT_DIR], +[ + dnl Set DIR_HAS_FD_MEMBER if dirfd() works, i.e. not always returns -1. + dnl We could use the findings from gl_FUNC_DIRFD and gl_PREREQ_DIRFD, but + dnl it's simpler since we know the affected platforms. + AC_REQUIRE([AC_CANONICAL_HOST]) + case "$host_os" in + mingw* | windows* | os2*) DIR_HAS_FD_MEMBER=0 ;; + *) DIR_HAS_FD_MEMBER=1 ;; + esac + AC_SUBST([DIR_HAS_FD_MEMBER]) +]) + +# gl_DIRENT_MODULE_INDICATOR([modulename]) +# sets the shell variable that indicates the presence of the given module +# to a C preprocessor expression that will evaluate to 1. +# This macro invocation must not occur in macros that are AC_REQUIREd. +AC_DEFUN([gl_DIRENT_MODULE_INDICATOR], +[ + dnl Ensure to expand the default settings once only. + gl_DIRENT_H_REQUIRE_DEFAULTS + gl_MODULE_INDICATOR_SET_VARIABLE([$1]) + dnl Define it also as a C macro, for the benefit of the unit tests. + gl_MODULE_INDICATOR_FOR_TESTS([$1]) +]) + +# Initializes the default values for AC_SUBSTed shell variables. +# This macro must not be AC_REQUIREd. It must only be invoked, and only +# outside of macros or in macros that are not AC_REQUIREd. +AC_DEFUN([gl_DIRENT_H_REQUIRE_DEFAULTS], +[ + m4_defun(GL_MODULE_INDICATOR_PREFIX[_DIRENT_H_MODULE_INDICATOR_DEFAULTS], [ + gl_UNISTD_H_REQUIRE_DEFAULTS dnl for REPLACE_FCHDIR + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_OPENDIR]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_READDIR]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REWINDDIR]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CLOSEDIR]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_DIRFD]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FDOPENDIR]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SCANDIR]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ALPHASORT]) + ]) + m4_require(GL_MODULE_INDICATOR_PREFIX[_DIRENT_H_MODULE_INDICATOR_DEFAULTS]) + AC_REQUIRE([gl_DIRENT_H_DEFAULTS]) +]) + +AC_DEFUN([gl_DIRENT_H_DEFAULTS], +[ + dnl Assume proper GNU behavior unless another module says otherwise. + HAVE_OPENDIR=1; AC_SUBST([HAVE_OPENDIR]) + HAVE_READDIR=1; AC_SUBST([HAVE_READDIR]) + HAVE_REWINDDIR=1; AC_SUBST([HAVE_REWINDDIR]) + HAVE_CLOSEDIR=1; AC_SUBST([HAVE_CLOSEDIR]) + HAVE_DECL_DIRFD=1; AC_SUBST([HAVE_DECL_DIRFD]) + HAVE_DECL_FDOPENDIR=1;AC_SUBST([HAVE_DECL_FDOPENDIR]) + HAVE_FDOPENDIR=1; AC_SUBST([HAVE_FDOPENDIR]) + HAVE_SCANDIR=1; AC_SUBST([HAVE_SCANDIR]) + HAVE_ALPHASORT=1; AC_SUBST([HAVE_ALPHASORT]) + REPLACE_OPENDIR=0; AC_SUBST([REPLACE_OPENDIR]) + REPLACE_READDIR=0; AC_SUBST([REPLACE_READDIR]) + REPLACE_REWINDDIR=0; AC_SUBST([REPLACE_REWINDDIR]) + REPLACE_CLOSEDIR=0; AC_SUBST([REPLACE_CLOSEDIR]) + REPLACE_DIRFD=0; AC_SUBST([REPLACE_DIRFD]) + REPLACE_FDOPENDIR=0; AC_SUBST([REPLACE_FDOPENDIR]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/dirfd.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/dirfd.m4 new file mode 100644 index 00000000..d4c4e6be --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/dirfd.m4 @@ -0,0 +1,88 @@ +# serial 29 -*- Autoconf -*- + +dnl Find out how to get the file descriptor associated with an open DIR*. + +# Copyright (C) 2001-2006, 2008-2024 Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +dnl From Jim Meyering + +AC_DEFUN([gl_FUNC_DIRFD], +[ + AC_REQUIRE([gl_DIRENT_H_DEFAULTS]) + AC_REQUIRE([AC_CANONICAL_HOST]) + + dnl Persuade glibc to declare dirfd(). + AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) + + AC_CHECK_FUNCS([dirfd]) + AC_CHECK_DECLS([dirfd], , , + [[#include + #include ]]) + if test $ac_cv_have_decl_dirfd = no; then + HAVE_DECL_DIRFD=0 + fi + + AC_CACHE_CHECK([whether dirfd is a macro], + [gl_cv_func_dirfd_macro], + [AC_EGREP_CPP([dirent_header_defines_dirfd], [ +#include +#include +#ifdef dirfd + dirent_header_defines_dirfd +#endif], + [gl_cv_func_dirfd_macro=yes], + [gl_cv_func_dirfd_macro=no])]) + + if test $ac_cv_func_dirfd = no && test $gl_cv_func_dirfd_macro = no; then + HAVE_DIRFD=0 + else + HAVE_DIRFD=1 + dnl Replace dirfd() on native Windows and OS/2 kLIBC, + dnl to support fdopendir(). + AC_REQUIRE([gl_DIRENT_DIR]) + if test $DIR_HAS_FD_MEMBER = 0; then + REPLACE_DIRFD=1 + fi + fi +]) + +dnl Prerequisites of lib/dirfd.c. +AC_DEFUN([gl_PREREQ_DIRFD], +[ + AC_CACHE_CHECK([how to get the file descriptor associated with an open DIR*], + [gl_cv_sys_dir_fd_member_name], + [ + dirfd_save_CFLAGS=$CFLAGS + for ac_expr in d_fd dd_fd; do + + CFLAGS="$CFLAGS -DDIR_FD_MEMBER_NAME=$ac_expr" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #include + #include ]], + [[DIR *dir_p = opendir("."); (void) dir_p->DIR_FD_MEMBER_NAME;]])], + [dir_fd_found=yes] + ) + CFLAGS=$dirfd_save_CFLAGS + test "$dir_fd_found" = yes && break + done + test "$dir_fd_found" = yes || ac_expr=no_such_member + + gl_cv_sys_dir_fd_member_name=$ac_expr + ] + ) + if test $gl_cv_sys_dir_fd_member_name != no_such_member; then + AC_DEFINE_UNQUOTED([DIR_FD_MEMBER_NAME], + [$gl_cv_sys_dir_fd_member_name], + [the name of the file descriptor member of DIR]) + fi + AH_VERBATIM([DIR_TO_FD], + [#ifdef DIR_FD_MEMBER_NAME +# define DIR_TO_FD(Dir_p) ((Dir_p)->DIR_FD_MEMBER_NAME) +#else +# define DIR_TO_FD(Dir_p) -1 +#endif +]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/double-slash-root.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/double-slash-root.m4 new file mode 100644 index 00000000..00f23a70 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/double-slash-root.m4 @@ -0,0 +1,38 @@ +# double-slash-root.m4 serial 4 -*- Autoconf -*- +dnl Copyright (C) 2006, 2008-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_DOUBLE_SLASH_ROOT], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_CACHE_CHECK([whether // is distinct from /], [gl_cv_double_slash_root], + [ if test x"$cross_compiling" = xyes ; then + # When cross-compiling, there is no way to tell whether // is special + # short of a list of hosts. However, the only known hosts to date + # that have a distinct // are Apollo DomainOS (too old to port to), + # Cygwin, and z/OS. If anyone knows of another system for which // has + # special semantics and is distinct from /, please report it to + # . + case $host in + *-cygwin | i370-ibm-openedition) + gl_cv_double_slash_root=yes ;; + *) + # Be optimistic and assume that / and // are the same when we + # don't know. + gl_cv_double_slash_root='unknown, assuming no' ;; + esac + else + set x `ls -di / // 2>/dev/null` + if test "$[2]" = "$[4]" && wc //dev/null >/dev/null 2>&1; then + gl_cv_double_slash_root=no + else + gl_cv_double_slash_root=yes + fi + fi]) + if test "$gl_cv_double_slash_root" = yes; then + AC_DEFINE([DOUBLE_SLASH_IS_DISTINCT_ROOT], [1], + [Define to 1 if // is a file system root distinct from /.]) + fi +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/dup.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/dup.m4 new file mode 100644 index 00000000..eafef02c --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/dup.m4 @@ -0,0 +1,54 @@ +# dup.m4 serial 8 +dnl Copyright (C) 2011-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_DUP], +[ + AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + m4_ifdef([gl_MSVC_INVAL], [ + AC_REQUIRE([gl_MSVC_INVAL]) + if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then + REPLACE_DUP=1 + fi + ]) + dnl Replace dup() for supporting the gnulib-defined fchdir() function, + dnl to keep fchdir's bookkeeping up-to-date. + m4_ifdef([gl_FUNC_FCHDIR], [ + gl_TEST_FCHDIR + if test $HAVE_FCHDIR = 0; then + REPLACE_DUP=1 + fi + ]) + AC_CACHE_CHECK([whether dup works], [gl_cv_func_dup_works], + [AC_RUN_IFELSE( + [AC_LANG_PROGRAM([[#include + #include + #include + ]GL_MDA_DEFINES], + [[/* On OS/2 kLIBC, dup does not work on a directory fd. */ + int fd = open (".", O_RDONLY); + return fd < 0 ? 1 : dup (fd) < 0 ? 2 : 0; + ]]) + ], + [gl_cv_func_dup_works=yes], + [gl_cv_func_dup_works=no], + [case "$host_os" in + # Guess no on native Windows. + mingw* | windows*) gl_cv_func_dup_works="guessing no" ;; + *) gl_cv_func_dup_works="guessing yes" ;; + esac + ]) + ]) + case "$gl_cv_func_dup_works" in + *yes) ;; + *) + REPLACE_DUP=1 + ;; + esac +]) + +# Prerequisites of lib/dup.c. +AC_DEFUN([gl_PREREQ_DUP], [:]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/dup2.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/dup2.m4 new file mode 100644 index 00000000..f6759b64 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/dup2.m4 @@ -0,0 +1,105 @@ +#serial 28 +dnl Copyright (C) 2002, 2005, 2007, 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_DUP2], +[ + AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_CACHE_CHECK([whether dup2 works], [gl_cv_func_dup2_works], + [AC_RUN_IFELSE([ + AC_LANG_PROGRAM( + [[#include + #include + #include + #include + #include + ]GL_MDA_DEFINES[ + #ifndef RLIM_SAVED_CUR + # define RLIM_SAVED_CUR RLIM_INFINITY + #endif + #ifndef RLIM_SAVED_MAX + # define RLIM_SAVED_MAX RLIM_INFINITY + #endif + ]], + [[int result = 0; + int bad_fd = INT_MAX; + struct rlimit rlim; + if (getrlimit (RLIMIT_NOFILE, &rlim) == 0 + && 0 <= rlim.rlim_cur && rlim.rlim_cur <= INT_MAX + && rlim.rlim_cur != RLIM_INFINITY + && rlim.rlim_cur != RLIM_SAVED_MAX + && rlim.rlim_cur != RLIM_SAVED_CUR) + bad_fd = rlim.rlim_cur; + #ifdef FD_CLOEXEC + if (fcntl (1, F_SETFD, FD_CLOEXEC) == -1) + result |= 1; + #endif + if (dup2 (1, 1) != 1) + result |= 2; + #ifdef FD_CLOEXEC + if (fcntl (1, F_GETFD) != FD_CLOEXEC) + result |= 4; + #endif + close (0); + if (dup2 (0, 0) != -1) + result |= 8; + /* Many gnulib modules require POSIX conformance of EBADF. */ + if (dup2 (2, bad_fd) == -1 && errno != EBADF) + result |= 16; + /* Flush out some cygwin core dumps. */ + if (dup2 (2, -1) != -1 || errno != EBADF) + result |= 32; + dup2 (2, 255); + dup2 (2, 256); + /* On OS/2 kLIBC, dup2() does not work on a directory fd. */ + { + int fd = open (".", O_RDONLY); + if (fd == -1) + result |= 64; + else if (dup2 (fd, fd + 1) == -1) + result |= 128; + close (fd); + } + return result;]]) + ], + [gl_cv_func_dup2_works=yes], [gl_cv_func_dup2_works=no], + [case "$host_os" in + mingw* | windows*) # on this platform, dup2 always returns 0 for success + gl_cv_func_dup2_works="guessing no" ;; + cygwin*) # on cygwin 1.5.x, dup2(1,1) returns 0 + gl_cv_func_dup2_works="guessing no" ;; + aix* | freebsd*) + # on AIX 7.1 and FreeBSD 6.1, dup2 (1,toobig) gives EMFILE, + # not EBADF. + gl_cv_func_dup2_works="guessing no" ;; + haiku*) # on Haiku alpha 2, dup2(1, 1) resets FD_CLOEXEC. + gl_cv_func_dup2_works="guessing no" ;; + *-android*) # implemented using dup3(), which fails if oldfd == newfd + gl_cv_func_dup2_works="guessing no" ;; + os2*) # on OS/2 kLIBC, dup2() does not work on a directory fd. + gl_cv_func_dup2_works="guessing no" ;; + *) gl_cv_func_dup2_works="guessing yes" ;; + esac]) + ]) + case "$gl_cv_func_dup2_works" in + *yes) ;; + *) + REPLACE_DUP2=1 + AC_CHECK_FUNCS([setdtablesize]) + ;; + esac + dnl Replace dup2() for supporting the gnulib-defined fchdir() function, + dnl to keep fchdir's bookkeeping up-to-date. + m4_ifdef([gl_FUNC_FCHDIR], [ + gl_TEST_FCHDIR + if test $HAVE_FCHDIR = 0; then + REPLACE_DUP2=1 + fi + ]) +]) + +# Prerequisites of lib/dup2.c. +AC_DEFUN([gl_PREREQ_DUP2], []) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/eealloc.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/eealloc.m4 new file mode 100644 index 00000000..d8862a1e --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/eealloc.m4 @@ -0,0 +1,31 @@ +# eealloc.m4 serial 3 +dnl Copyright (C) 2003, 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_EEALLOC], +[ + AC_REQUIRE([gl_EEMALLOC]) + AC_REQUIRE([gl_EEREALLOC]) +]) + +AC_DEFUN([gl_EEMALLOC], +[ + _AC_FUNC_MALLOC_IF( + [gl_cv_func_malloc_0_nonnull=1], + [gl_cv_func_malloc_0_nonnull=0]) + AC_DEFINE_UNQUOTED([MALLOC_0_IS_NONNULL], [$gl_cv_func_malloc_0_nonnull], + [If malloc(0) is != NULL, define this to 1. Otherwise define this + to 0.]) +]) + +AC_DEFUN([gl_EEREALLOC], +[ + _AC_FUNC_REALLOC_IF( + [gl_cv_func_realloc_0_nonnull=1], + [gl_cv_func_realloc_0_nonnull=0]) + AC_DEFINE_UNQUOTED([REALLOC_0_IS_NONNULL], [$gl_cv_func_realloc_0_nonnull], + [If realloc(NULL,0) is != NULL, define this to 1. Otherwise define this + to 0.]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/environ.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/environ.m4 new file mode 100644 index 00000000..5b9e06b0 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/environ.m4 @@ -0,0 +1,46 @@ +# environ.m4 serial 8 +dnl Copyright (C) 2001-2004, 2006-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN_ONCE([gl_ENVIRON], +[ + AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) + dnl Persuade glibc to declare environ. + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + + AC_CHECK_HEADERS_ONCE([unistd.h]) + gt_CHECK_VAR_DECL( + [#if HAVE_UNISTD_H + #include + #endif + /* mingw, BeOS, Haiku declare environ in , not in . */ + #include + ], + [environ]) + if test $gt_cv_var_environ_declaration != yes; then + HAVE_DECL_ENVIRON=0 + fi +]) + +# Check if a variable is properly declared. +# gt_CHECK_VAR_DECL(includes,variable) +AC_DEFUN([gt_CHECK_VAR_DECL], +[ + define([gt_cv_var], [gt_cv_var_]$2[_declaration]) + AC_CACHE_CHECK([if $2 is properly declared], [gt_cv_var], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[$1 + typedef struct { int foo; } foo_t; + extern foo_t $2;]], + [[$2.foo = 1;]])], + [gt_cv_var=no], + [gt_cv_var=yes])]) + if test $gt_cv_var = yes; then + AC_DEFINE([HAVE_]m4_translit($2, [a-z], [A-Z])[_DECL], 1, + [Define if you have the declaration of $2.]) + fi + undefine([gt_cv_var]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/errno_h.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/errno_h.m4 new file mode 100644 index 00000000..8900d6c7 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/errno_h.m4 @@ -0,0 +1,131 @@ +# errno_h.m4 serial 14 +dnl Copyright (C) 2004, 2006, 2008-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_PREREQ([2.61]) + +AC_DEFUN_ONCE([gl_HEADER_ERRNO_H], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_CACHE_CHECK([for complete errno.h], [gl_cv_header_errno_h_complete], [ + AC_EGREP_CPP([booboo],[ +#include +#if !defined ETXTBSY +booboo +#endif +#if !defined ENOMSG +booboo +#endif +#if !defined EIDRM +booboo +#endif +#if !defined ENOLINK +booboo +#endif +#if !defined EPROTO +booboo +#endif +#if !defined EMULTIHOP +booboo +#endif +#if !defined EBADMSG +booboo +#endif +#if !defined EOVERFLOW +booboo +#endif +#if !defined ENOTSUP +booboo +#endif +#if !defined ENETRESET +booboo +#endif +#if !defined ECONNABORTED +booboo +#endif +#if !defined ESTALE +booboo +#endif +#if !defined EDQUOT +booboo +#endif +#if !defined ECANCELED +booboo +#endif +#if !defined EOWNERDEAD +booboo +#endif +#if !defined ENOTRECOVERABLE +booboo +#endif +#if !defined EILSEQ +booboo +#endif + ], + [gl_cv_header_errno_h_complete=no], + [gl_cv_header_errno_h_complete=yes]) + ]) + if test $gl_cv_header_errno_h_complete = yes; then + GL_GENERATE_ERRNO_H=false + else + gl_NEXT_HEADERS([errno.h]) + GL_GENERATE_ERRNO_H=true + fi + gl_REPLACE_ERRNO_VALUE([EMULTIHOP]) + gl_REPLACE_ERRNO_VALUE([ENOLINK]) + gl_REPLACE_ERRNO_VALUE([EOVERFLOW]) +]) + +# Assuming $1 = EOVERFLOW. +# The EOVERFLOW errno value ought to be defined in , according to +# POSIX. But some systems (like OpenBSD 4.0 or AIX 3) don't define it, and +# some systems (like OSF/1) define it when _XOPEN_SOURCE_EXTENDED is defined. +# Check for the value of EOVERFLOW. +# Set the variables EOVERFLOW_HIDDEN and EOVERFLOW_VALUE. +AC_DEFUN([gl_REPLACE_ERRNO_VALUE], +[ + if $GL_GENERATE_ERRNO_H; then + AC_CACHE_CHECK([for ]$1[ value], [gl_cv_header_errno_h_]$1, [ + AC_EGREP_CPP([yes],[ +#include +#ifdef ]$1[ +yes +#endif + ], + [gl_cv_header_errno_h_]$1[=yes], + [gl_cv_header_errno_h_]$1[=no]) + if test $gl_cv_header_errno_h_]$1[ = no; then + AC_EGREP_CPP([yes],[ +#define _XOPEN_SOURCE_EXTENDED 1 +#include +#ifdef ]$1[ +yes +#endif + ], [gl_cv_header_errno_h_]$1[=hidden]) + if test $gl_cv_header_errno_h_]$1[ = hidden; then + dnl The macro exists but is hidden. + dnl Define it to the same value. + AC_COMPUTE_INT([gl_cv_header_errno_h_]$1, $1, [ +#define _XOPEN_SOURCE_EXTENDED 1 +#include +/* The following two lines are a workaround against an autoconf-2.52 bug. */ +#include +#include +]) + fi + fi + ]) + case $gl_cv_header_errno_h_]$1[ in + yes | no) + ]$1[_HIDDEN=0; ]$1[_VALUE= + ;; + *) + ]$1[_HIDDEN=1; ]$1[_VALUE="$gl_cv_header_errno_h_]$1[" + ;; + esac + AC_SUBST($1[_HIDDEN]) + AC_SUBST($1[_VALUE]) + fi +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/error.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/error.m4 new file mode 100644 index 00000000..5688afcf --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/error.m4 @@ -0,0 +1,22 @@ +#serial 16 + +# Copyright (C) 1996-1998, 2001-2004, 2009-2024 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_ERROR], +[ +]) + +# Prerequisites of lib/error.c. +AC_DEFUN([gl_PREREQ_ERROR], +[ + dnl Use system extensions on Android, so that AC_FUNC_STRERROR_R + dnl discovers the GNU API for strerror_r on Android API level 23 and later. + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + + AC_REQUIRE([AC_FUNC_STRERROR_R]) + : +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/error_h.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/error_h.m4 new file mode 100644 index 00000000..006770c4 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/error_h.m4 @@ -0,0 +1,124 @@ +# error_h.m4 serial 4 +dnl Copyright (C) 1996-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. +dnl Provide a working . + +AC_DEFUN_ONCE([gl_ERROR_H], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + + gl_CHECK_NEXT_HEADERS([error.h]) + if test $ac_cv_header_error_h = yes; then + HAVE_ERROR_H=1 + else + HAVE_ERROR_H=0 + fi + AC_SUBST([HAVE_ERROR_H]) + + REPLACE_ERROR=0 + + gl_CHECK_FUNCS_ANDROID([error], [[#include ]]) + if test $ac_cv_func_error = yes; then + HAVE_ERROR=1 + else + HAVE_ERROR=0 + case "$gl_cv_onwards_func_error" in + future*) REPLACE_ERROR=1 ;; + esac + fi + + dnl We don't use AC_FUNC_ERROR_AT_LINE any more, because it is no longer + dnl maintained in Autoconf and because it invokes AC_LIBOBJ. + dnl We need to notice a missing declaration, like gl_CHECK_FUNCS_ANDROID does. + AC_CHECK_DECL([error_at_line], , , [[#include ]]) + if test $ac_cv_have_decl_error_at_line = yes; then + AC_CACHE_CHECK([for error_at_line], [ac_cv_lib_error_at_line], + [AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include ]], + [[error_at_line (0, 0, "", 0, "an error occurred");]])], + [ac_cv_lib_error_at_line=yes], + [ac_cv_lib_error_at_line=no])]) + else + ac_cv_lib_error_at_line=no + fi + if test $ac_cv_lib_error_at_line = yes; then + HAVE_ERROR_AT_LINE=1 + else + HAVE_ERROR_AT_LINE=0 + fi + REPLACE_ERROR_AT_LINE=0 + + if test $ac_cv_func_error = yes && test $ac_cv_lib_error_at_line = yes; then + dnl On Android 11, when error_print_progname is set, the output of the + dnl error() function contains an extra space. + AC_CACHE_CHECK([for working error function], + [gl_cv_func_working_error], + [if test $cross_compiling != yes; then + AC_LINK_IFELSE( + [AC_LANG_PROGRAM([[ + #include + static void print_no_progname (void) {} + ]], [[ + error_print_progname = print_no_progname; + error (0, 0, "foo"); + ]]) + ], + [rm -f conftest.out + if test -s conftest$ac_exeext \ + && ./conftest$ac_exeext 2> conftest.out; then + if grep ' ' conftest.out >/dev/null; then + gl_cv_func_working_error=no + else + gl_cv_func_working_error=yes + fi + else + gl_cv_func_working_error=no + fi + rm -f conftest.out + ], + [gl_cv_func_working_error=no]) + else + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[ + #include + ]], [[ + error (0, 0, "foo"); + ]]) + ], + [case "$host_os" in + # Guess yes on glibc systems. + *-gnu* | gnu*) gl_cv_func_working_error="guessing yes" ;; + # Guess no on Android. + linux*-android*) gl_cv_func_working_error="guessing no" ;; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_working_error="$gl_cross_guess_normal" ;; + esac + ], + [gl_cv_func_working_error=no]) + fi + ]) + case "$gl_cv_func_working_error" in + *no) + REPLACE_ERROR=1 + REPLACE_ERROR_AT_LINE=1 + ;; + esac + fi + + if test $HAVE_ERROR = 0 || test $REPLACE_ERROR = 1 \ + || test $HAVE_ERROR_AT_LINE = 0 || test $REPLACE_ERROR_AT_LINE = 1; then + COMPILE_ERROR_C=1 + else + COMPILE_ERROR_C=0 + fi + + AC_SUBST([HAVE_ERROR]) + AC_SUBST([HAVE_ERROR_AT_LINE]) + AC_SUBST([REPLACE_ERROR]) + AC_SUBST([REPLACE_ERROR_AT_LINE]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/exponentd.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/exponentd.m4 new file mode 100644 index 00000000..0a4b1b6c --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/exponentd.m4 @@ -0,0 +1,116 @@ +# exponentd.m4 serial 4 +dnl Copyright (C) 2007-2008, 2010-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. +AC_DEFUN_ONCE([gl_DOUBLE_EXPONENT_LOCATION], +[ + AC_CACHE_CHECK([where to find the exponent in a 'double'], + [gl_cv_cc_double_expbit0], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +#include +#include +#define NWORDS \ + ((sizeof (double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) +typedef union { double value; unsigned int word[NWORDS]; } memory_double; +static unsigned int ored_words[NWORDS]; +static unsigned int anded_words[NWORDS]; +static void add_to_ored_words (double x) +{ + memory_double m; + size_t i; + /* Clear it first, in case sizeof (double) < sizeof (memory_double). */ + memset (&m, 0, sizeof (memory_double)); + m.value = x; + for (i = 0; i < NWORDS; i++) + { + ored_words[i] |= m.word[i]; + anded_words[i] &= m.word[i]; + } +} +int main () +{ + size_t j; + FILE *fp = fopen ("conftest.out", "w"); + if (fp == NULL) + return 1; + for (j = 0; j < NWORDS; j++) + anded_words[j] = ~ (unsigned int) 0; + add_to_ored_words (0.25); + add_to_ored_words (0.5); + add_to_ored_words (1.0); + add_to_ored_words (2.0); + add_to_ored_words (4.0); + /* Remove bits that are common (e.g. if representation of the first mantissa + bit is explicit). */ + for (j = 0; j < NWORDS; j++) + ored_words[j] &= ~anded_words[j]; + /* Now find the nonzero word. */ + for (j = 0; j < NWORDS; j++) + if (ored_words[j] != 0) + break; + if (j < NWORDS) + { + size_t i; + for (i = j + 1; i < NWORDS; i++) + if (ored_words[i] != 0) + { + fprintf (fp, "unknown"); + return (fclose (fp) != 0); + } + for (i = 0; ; i++) + if ((ored_words[j] >> i) & 1) + { + fprintf (fp, "word %d bit %d", (int) j, (int) i); + return (fclose (fp) != 0); + } + } + fprintf (fp, "unknown"); + return (fclose (fp) != 0); +} + ]])], + [gl_cv_cc_double_expbit0=`cat conftest.out`], + [gl_cv_cc_double_expbit0="unknown"], + [ + dnl On ARM, there are two 'double' floating-point formats, used by + dnl different sets of instructions: The older FPA instructions assume + dnl that they are stored in big-endian word order, while the words + dnl (like integer types) are stored in little-endian byte order. + dnl The newer VFP instructions assume little-endian order + dnl consistently. + AC_EGREP_CPP([mixed_endianness], [ +#if defined arm || defined __arm || defined __arm__ + mixed_endianness +#endif + ], + [gl_cv_cc_double_expbit0="unknown"], + [ + pushdef([AC_MSG_CHECKING],[:])dnl + pushdef([AC_MSG_RESULT],[:])dnl + pushdef([AC_MSG_RESULT_UNQUOTED],[:])dnl + AC_C_BIGENDIAN( + [gl_cv_cc_double_expbit0="word 0 bit 20"], + [gl_cv_cc_double_expbit0="word 1 bit 20"], + [gl_cv_cc_double_expbit0="unknown"]) + popdef([AC_MSG_RESULT_UNQUOTED])dnl + popdef([AC_MSG_RESULT])dnl + popdef([AC_MSG_CHECKING])dnl + ]) + ]) + rm -f conftest.out + ]) + case "$gl_cv_cc_double_expbit0" in + word*bit*) + word=`echo "$gl_cv_cc_double_expbit0" | sed -e 's/word //' -e 's/ bit.*//'` + bit=`echo "$gl_cv_cc_double_expbit0" | sed -e 's/word.*bit //'` + AC_DEFINE_UNQUOTED([DBL_EXPBIT0_WORD], [$word], + [Define as the word index where to find the exponent of 'double'.]) + AC_DEFINE_UNQUOTED([DBL_EXPBIT0_BIT], [$bit], + [Define as the bit index in the word where to find bit 0 of the exponent of 'double'.]) + ;; + esac +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/exponentf.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/exponentf.m4 new file mode 100644 index 00000000..a46eee29 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/exponentf.m4 @@ -0,0 +1,92 @@ +# exponentf.m4 serial 3 +dnl Copyright (C) 2007-2008, 2010-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. +AC_DEFUN_ONCE([gl_FLOAT_EXPONENT_LOCATION], +[ + AC_CACHE_CHECK([where to find the exponent in a 'float'], + [gl_cv_cc_float_expbit0], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +#include +#include +#define NWORDS \ + ((sizeof (float) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) +typedef union { float value; unsigned int word[NWORDS]; } memory_float; +static unsigned int ored_words[NWORDS]; +static unsigned int anded_words[NWORDS]; +static void add_to_ored_words (float x) +{ + memory_float m; + size_t i; + /* Clear it first, in case + sizeof (float) < sizeof (memory_float). */ + memset (&m, 0, sizeof (memory_float)); + m.value = x; + for (i = 0; i < NWORDS; i++) + { + ored_words[i] |= m.word[i]; + anded_words[i] &= m.word[i]; + } +} +int main () +{ + size_t j; + FILE *fp = fopen ("conftest.out", "w"); + if (fp == NULL) + return 1; + for (j = 0; j < NWORDS; j++) + anded_words[j] = ~ (unsigned int) 0; + add_to_ored_words (0.25f); + add_to_ored_words (0.5f); + add_to_ored_words (1.0f); + add_to_ored_words (2.0f); + add_to_ored_words (4.0f); + /* Remove bits that are common (e.g. if representation of the first mantissa + bit is explicit). */ + for (j = 0; j < NWORDS; j++) + ored_words[j] &= ~anded_words[j]; + /* Now find the nonzero word. */ + for (j = 0; j < NWORDS; j++) + if (ored_words[j] != 0) + break; + if (j < NWORDS) + { + size_t i; + for (i = j + 1; i < NWORDS; i++) + if (ored_words[i] != 0) + { + fprintf (fp, "unknown"); + return (fclose (fp) != 0); + } + for (i = 0; ; i++) + if ((ored_words[j] >> i) & 1) + { + fprintf (fp, "word %d bit %d", (int) j, (int) i); + return (fclose (fp) != 0); + } + } + fprintf (fp, "unknown"); + return (fclose (fp) != 0); +} + ]])], + [gl_cv_cc_float_expbit0=`cat conftest.out`], + [gl_cv_cc_float_expbit0="unknown"], + [gl_cv_cc_float_expbit0="word 0 bit 23"]) + rm -f conftest.out + ]) + case "$gl_cv_cc_float_expbit0" in + word*bit*) + word=`echo "$gl_cv_cc_float_expbit0" | sed -e 's/word //' -e 's/ bit.*//'` + bit=`echo "$gl_cv_cc_float_expbit0" | sed -e 's/word.*bit //'` + AC_DEFINE_UNQUOTED([FLT_EXPBIT0_WORD], [$word], + [Define as the word index where to find the exponent of 'float'.]) + AC_DEFINE_UNQUOTED([FLT_EXPBIT0_BIT], [$bit], + [Define as the bit index in the word where to find bit 0 of the exponent of 'float'.]) + ;; + esac +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/exponentl.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/exponentl.m4 new file mode 100644 index 00000000..06c8ae3f --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/exponentl.m4 @@ -0,0 +1,113 @@ +# exponentl.m4 serial 7 +dnl Copyright (C) 2007-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. +AC_DEFUN_ONCE([gl_LONG_DOUBLE_EXPONENT_LOCATION], +[ + AC_REQUIRE([gl_BIGENDIAN]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([where to find the exponent in a 'long double'], + [gl_cv_cc_long_double_expbit0], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +#include +#include +#define NWORDS \ + ((sizeof (long double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) +typedef union { long double value; unsigned int word[NWORDS]; } + memory_long_double; +static unsigned int ored_words[NWORDS]; +static unsigned int anded_words[NWORDS]; +static void add_to_ored_words (long double *x) +{ + memory_long_double m; + size_t i; + /* Clear it first, in case + sizeof (long double) < sizeof (memory_long_double). */ + memset (&m, 0, sizeof (memory_long_double)); + m.value = *x; + for (i = 0; i < NWORDS; i++) + { + ored_words[i] |= m.word[i]; + anded_words[i] &= m.word[i]; + } +} +int main () +{ + static long double samples[5] = { 0.25L, 0.5L, 1.0L, 2.0L, 4.0L }; + size_t j; + FILE *fp = fopen ("conftest.out", "w"); + if (fp == NULL) + return 1; + for (j = 0; j < NWORDS; j++) + anded_words[j] = ~ (unsigned int) 0; + for (j = 0; j < 5; j++) + add_to_ored_words (&samples[j]); + /* Remove bits that are common (e.g. if representation of the first mantissa + bit is explicit). */ + for (j = 0; j < NWORDS; j++) + ored_words[j] &= ~anded_words[j]; + /* Now find the nonzero word. */ + for (j = 0; j < NWORDS; j++) + if (ored_words[j] != 0) + break; + if (j < NWORDS) + { + size_t i; + for (i = j + 1; i < NWORDS; i++) + if (ored_words[i] != 0) + { + fprintf (fp, "unknown"); + return (fclose (fp) != 0); + } + for (i = 0; ; i++) + if ((ored_words[j] >> i) & 1) + { + fprintf (fp, "word %d bit %d", (int) j, (int) i); + return (fclose (fp) != 0); + } + } + fprintf (fp, "unknown"); + return (fclose (fp) != 0); +} + ]])], + [gl_cv_cc_long_double_expbit0=`cat conftest.out`], + [gl_cv_cc_long_double_expbit0="unknown"], + [ + dnl When cross-compiling, in general we don't know. It depends on the + dnl ABI and compiler version. There are too many cases. + gl_cv_cc_long_double_expbit0="unknown" + case "$host_os" in + mingw* | windows*) + # On native Windows (little-endian), we know the result + # in two cases: mingw, MSVC. + AC_EGREP_CPP([Known], [ +#ifdef __MINGW32__ + Known +#endif + ], [gl_cv_cc_long_double_expbit0="word 2 bit 0"]) + AC_EGREP_CPP([Known], [ +#ifdef _MSC_VER + Known +#endif + ], [gl_cv_cc_long_double_expbit0="word 1 bit 20"]) + ;; + esac + ]) + rm -f conftest.out + ]) + case "$gl_cv_cc_long_double_expbit0" in + word*bit*) + word=`echo "$gl_cv_cc_long_double_expbit0" | sed -e 's/word //' -e 's/ bit.*//'` + bit=`echo "$gl_cv_cc_long_double_expbit0" | sed -e 's/word.*bit //'` + AC_DEFINE_UNQUOTED([LDBL_EXPBIT0_WORD], [$word], + [Define as the word index where to find the exponent of 'long double'.]) + AC_DEFINE_UNQUOTED([LDBL_EXPBIT0_BIT], [$bit], + [Define as the bit index in the word where to find bit 0 of the exponent of 'long double'.]) + ;; + esac +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/extensions.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/extensions.m4 new file mode 100644 index 00000000..6fc2e300 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/extensions.m4 @@ -0,0 +1,232 @@ +# serial 23 -*- Autoconf -*- +# Enable extensions on systems that normally disable them. + +# Copyright (C) 2003, 2006-2024 Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +dnl Define to empty for the benefit of Autoconf 2.69 and earlier, so that +dnl AC_USE_SYSTEM_EXTENSIONS (below) can be used unchanged from Autoconf 2.70+. +m4_ifndef([AC_CHECK_INCLUDES_DEFAULT], + [AC_DEFUN([AC_CHECK_INCLUDES_DEFAULT], [])]) + +# This definition of AC_USE_SYSTEM_EXTENSIONS is stolen from git +# Autoconf. Perhaps we can remove this once we can assume Autoconf +# is recent-enough everywhere, but since Autoconf mutates rapidly +# enough in this area it's likely we'll need to redefine +# AC_USE_SYSTEM_EXTENSIONS for quite some time. + +# If autoconf reports a warning +# warning: AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS +# or warning: AC_RUN_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS +# the fix is +# 1) to ensure that AC_USE_SYSTEM_EXTENSIONS is never directly invoked +# but always AC_REQUIREd, +# 2) to ensure that for each occurrence of +# AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) +# or +# AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) +# the corresponding gnulib module description has 'extensions' among +# its dependencies. This will ensure that the gl_USE_SYSTEM_EXTENSIONS +# invocation occurs in gl_EARLY, not in gl_INIT. + +m4_version_prereq([2.72], [], [ + +# AC_USE_SYSTEM_EXTENSIONS +# ------------------------ +# Enable extensions on systems that normally disable them, +# typically due to standards-conformance issues. +# We unconditionally define as many of the known feature-enabling +# as possible, reserving conditional behavior for macros that are +# known to cause problems on some platforms (such as __EXTENSIONS__). +AC_DEFUN_ONCE([AC_USE_SYSTEM_EXTENSIONS], +[AC_BEFORE([$0], [AC_PREPROC_IFELSE])dnl +AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl +AC_BEFORE([$0], [AC_LINK_IFELSE])dnl +AC_BEFORE([$0], [AC_RUN_IFELSE])dnl +AC_BEFORE([$0], [AC_CHECK_INCLUDES_DEFAULT])dnl +dnl #undef in AH_VERBATIM gets replaced with #define by AC_DEFINE. +dnl Use a different key than __EXTENSIONS__, as that name broke existing +dnl configure.ac when using autoheader 2.62. +dnl The macros below are in alphabetical order ignoring leading _ or __ +dnl prefixes. +AH_VERBATIM([USE_SYSTEM_EXTENSIONS], +[/* Enable extensions on AIX 3, Interix. */ +#ifndef _ALL_SOURCE +# undef _ALL_SOURCE +#endif +/* Enable general extensions on macOS. */ +#ifndef _DARWIN_C_SOURCE +# undef _DARWIN_C_SOURCE +#endif +/* Enable general extensions on Solaris. */ +#ifndef __EXTENSIONS__ +# undef __EXTENSIONS__ +#endif +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +# undef _GNU_SOURCE +#endif +/* Enable X/Open compliant socket functions that do not require linking + with -lxnet on HP-UX 11.11. */ +#ifndef _HPUX_ALT_XOPEN_SOCKET_API +# undef _HPUX_ALT_XOPEN_SOCKET_API +#endif +/* Identify the host operating system as Minix. + This macro does not affect the system headers' behavior. + A future release of Autoconf may stop defining this macro. */ +#ifndef _MINIX +# undef _MINIX +#endif +/* Enable general extensions on NetBSD. + Enable NetBSD compatibility extensions on Minix. */ +#ifndef _NETBSD_SOURCE +# undef _NETBSD_SOURCE +#endif +/* Enable OpenBSD compatibility extensions on NetBSD. + Oddly enough, this does nothing on OpenBSD. */ +#ifndef _OPENBSD_SOURCE +# undef _OPENBSD_SOURCE +#endif +/* Define to 1 if needed for POSIX-compatible behavior. */ +#ifndef _POSIX_SOURCE +# undef _POSIX_SOURCE +#endif +/* Define to 2 if needed for POSIX-compatible behavior. */ +#ifndef _POSIX_1_SOURCE +# undef _POSIX_1_SOURCE +#endif +/* Enable POSIX-compatible threading on Solaris. */ +#ifndef _POSIX_PTHREAD_SEMANTICS +# undef _POSIX_PTHREAD_SEMANTICS +#endif +/* Enable extensions specified by ISO/IEC TS 18661-5:2014. */ +#ifndef __STDC_WANT_IEC_60559_ATTRIBS_EXT__ +# undef __STDC_WANT_IEC_60559_ATTRIBS_EXT__ +#endif +/* Enable extensions specified by ISO/IEC TS 18661-1:2014. */ +#ifndef __STDC_WANT_IEC_60559_BFP_EXT__ +# undef __STDC_WANT_IEC_60559_BFP_EXT__ +#endif +/* Enable extensions specified by ISO/IEC TS 18661-2:2015. */ +#ifndef __STDC_WANT_IEC_60559_DFP_EXT__ +# undef __STDC_WANT_IEC_60559_DFP_EXT__ +#endif +/* Enable extensions specified by C23 Annex F. */ +#ifndef __STDC_WANT_IEC_60559_EXT__ +# undef __STDC_WANT_IEC_60559_EXT__ +#endif +/* Enable extensions specified by ISO/IEC TS 18661-4:2015. */ +#ifndef __STDC_WANT_IEC_60559_FUNCS_EXT__ +# undef __STDC_WANT_IEC_60559_FUNCS_EXT__ +#endif +/* Enable extensions specified by C23 Annex H and ISO/IEC TS 18661-3:2015. */ +#ifndef __STDC_WANT_IEC_60559_TYPES_EXT__ +# undef __STDC_WANT_IEC_60559_TYPES_EXT__ +#endif +/* Enable extensions specified by ISO/IEC TR 24731-2:2010. */ +#ifndef __STDC_WANT_LIB_EXT2__ +# undef __STDC_WANT_LIB_EXT2__ +#endif +/* Enable extensions specified by ISO/IEC 24747:2009. */ +#ifndef __STDC_WANT_MATH_SPEC_FUNCS__ +# undef __STDC_WANT_MATH_SPEC_FUNCS__ +#endif +/* Enable extensions on HP NonStop. */ +#ifndef _TANDEM_SOURCE +# undef _TANDEM_SOURCE +#endif +/* Enable X/Open extensions. Define to 500 only if necessary + to make mbstate_t available. */ +#ifndef _XOPEN_SOURCE +# undef _XOPEN_SOURCE +#endif +])dnl + + AC_REQUIRE([AC_CHECK_INCLUDES_DEFAULT])dnl + _AC_CHECK_HEADER_ONCE([wchar.h]) + _AC_CHECK_HEADER_ONCE([minix/config.h]) + +dnl Defining __EXTENSIONS__ may break the system headers on some systems. +dnl (FIXME: Which ones?) + AC_CACHE_CHECK([whether it is safe to define __EXTENSIONS__], + [ac_cv_safe_to_define___extensions__], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[ +# define __EXTENSIONS__ 1 + ]AC_INCLUDES_DEFAULT])], + [ac_cv_safe_to_define___extensions__=yes], + [ac_cv_safe_to_define___extensions__=no])]) + +dnl HP-UX 11.11 defines mbstate_t only if _XOPEN_SOURCE is defined to +dnl 500, regardless of whether compiling with -Ae or -D_HPUX_SOURCE=1. +dnl But defining _XOPEN_SOURCE may turn *off* extensions on platforms +dnl not covered by turn-on-extensions macros (notably Dragonfly, Free, +dnl and OpenBSD, which don't have any equivalent of _NETBSD_SOURCE) so +dnl it should only be defined when necessary. + AC_CACHE_CHECK([whether _XOPEN_SOURCE should be defined], + [ac_cv_should_define__xopen_source], + [ac_cv_should_define__xopen_source=no + AS_IF([test $ac_cv_header_wchar_h = yes], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[ + #include + mbstate_t x;]])], + [], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[ + #define _XOPEN_SOURCE 500 + #include + mbstate_t x;]])], + [ac_cv_should_define__xopen_source=yes])])])]) + + AC_DEFINE([_ALL_SOURCE]) + AC_DEFINE([_DARWIN_C_SOURCE]) + AC_DEFINE([_GNU_SOURCE]) + AC_DEFINE([_HPUX_ALT_XOPEN_SOCKET_API]) + AC_DEFINE([_NETBSD_SOURCE]) + AC_DEFINE([_OPENBSD_SOURCE]) + AC_DEFINE([_POSIX_PTHREAD_SEMANTICS]) + AC_DEFINE([__STDC_WANT_IEC_60559_ATTRIBS_EXT__]) + AC_DEFINE([__STDC_WANT_IEC_60559_BFP_EXT__]) + AC_DEFINE([__STDC_WANT_IEC_60559_DFP_EXT__]) + AC_DEFINE([__STDC_WANT_IEC_60559_EXT__]) + AC_DEFINE([__STDC_WANT_IEC_60559_FUNCS_EXT__]) + AC_DEFINE([__STDC_WANT_IEC_60559_TYPES_EXT__]) + AC_DEFINE([__STDC_WANT_LIB_EXT2__]) + AC_DEFINE([__STDC_WANT_MATH_SPEC_FUNCS__]) + AC_DEFINE([_TANDEM_SOURCE]) + AS_IF([test $ac_cv_header_minix_config_h = yes], + [MINIX=yes + AC_DEFINE([_MINIX]) + AC_DEFINE([_POSIX_SOURCE]) + AC_DEFINE([_POSIX_1_SOURCE], [2])], + [MINIX=]) + AS_IF([test $ac_cv_safe_to_define___extensions__ = yes], + [AC_DEFINE([__EXTENSIONS__])]) + AS_IF([test $ac_cv_should_define__xopen_source = yes], + [AC_DEFINE([_XOPEN_SOURCE], [500])]) +])# AC_USE_SYSTEM_EXTENSIONS +]) + +# gl_USE_SYSTEM_EXTENSIONS +# ------------------------ +# Enable extensions on systems that normally disable them, +# typically due to standards-conformance issues. +AC_DEFUN_ONCE([gl_USE_SYSTEM_EXTENSIONS], +[ + AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) + + dnl On OpenBSD 6.8 with GCC, the include files contain a couple of + dnl definitions that are only activated with an explicit -D_ISOC11_SOURCE. + dnl That's because this version of GCC (4.2.1) supports the option + dnl '-std=gnu99' but not the option '-std=gnu11'. + AC_REQUIRE([AC_CANONICAL_HOST]) + case "$host_os" in + openbsd*) + AC_DEFINE([_ISOC11_SOURCE], [1], + [Define to enable the declarations of ISO C 11 types and functions.]) + ;; + esac +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/extern-inline.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/extern-inline.m4 new file mode 100644 index 00000000..680250ec --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/extern-inline.m4 @@ -0,0 +1,132 @@ +dnl 'extern inline' a la ISO C99. + +dnl Copyright 2012-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_EXTERN_INLINE], +[ + AC_CACHE_CHECK([whether ctype.h defines __header_inline], + [gl_cv_have___header_inline], + [AC_PREPROC_IFELSE( + [AC_LANG_SOURCE([[#include + #ifndef __header_inline + #error " does not define __header_inline" + #endif + ]])], + [gl_cv_have___header_inline=yes], + [gl_cv_have___header_inline=no])]) + if test "$gl_cv_have___header_inline" = yes; then + AC_DEFINE([HAVE___HEADER_INLINE], [1], + [Define to 1 if ctype.h defines __header_inline.]) + fi + + AH_VERBATIM([HAVE___HEADER_INLINE_1], +[/* Please see the Gnulib manual for how to use these macros. + + Suppress extern inline with HP-UX cc, as it appears to be broken; see + . + + Suppress extern inline with Sun C in standards-conformance mode, as it + mishandles inline functions that call each other. E.g., for 'inline void f + (void) { } inline void g (void) { f (); }', c99 incorrectly complains + 'reference to static identifier "f" in extern inline function'. + This bug was observed with Oracle Developer Studio 12.6 + (Sun C 5.15 SunOS_sparc 2017/05/30). + + Suppress extern inline (with or without __attribute__ ((__gnu_inline__))) + on configurations that mistakenly use 'static inline' to implement + functions or macros in standard C headers like . For example, + if isdigit is mistakenly implemented via a static inline function, + a program containing an extern inline function that calls isdigit + may not work since the C standard prohibits extern inline functions + from calling static functions (ISO C 99 section 6.7.4.(3). + This bug is known to occur on: + + OS X 10.8 and earlier; see: + https://lists.gnu.org/r/bug-gnulib/2012-12/msg00023.html + + DragonFly; see + http://muscles.dragonflybsd.org/bulk/clang-master-potential/20141111_102002/logs/ah-tty-0.3.12.log + + FreeBSD; see: + https://lists.gnu.org/r/bug-gnulib/2014-07/msg00104.html + + OS X 10.9 has a macro __header_inline indicating the bug is fixed for C and + for clang but remains for g++; see . + Assume DragonFly and FreeBSD will be similar. + + GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99 + inline semantics, unless -fgnu89-inline is used. It defines a macro + __GNUC_STDC_INLINE__ to indicate this situation or a macro + __GNUC_GNU_INLINE__ to indicate the opposite situation. + GCC 4.2 with -std=c99 or -std=gnu99 implements the GNU C inline + semantics but warns, unless -fgnu89-inline is used: + warning: C99 inline functions are not supported; using GNU89 + warning: to disable this warning use -fgnu89-inline or the gnu_inline function attribute + It defines a macro __GNUC_GNU_INLINE__ to indicate this situation. + */ +#if (((defined __APPLE__ && defined __MACH__) \ + || defined __DragonFly__ || defined __FreeBSD__) \ + && (defined HAVE___HEADER_INLINE \ + ? (defined __cplusplus && defined __GNUC_STDC_INLINE__ \ + && ! defined __clang__) \ + : ((! defined _DONT_USE_CTYPE_INLINE_ \ + && (defined __GNUC__ || defined __cplusplus)) \ + || (defined _FORTIFY_SOURCE && 0 < _FORTIFY_SOURCE \ + && defined __GNUC__ && ! defined __cplusplus)))) +# define _GL_EXTERN_INLINE_STDHEADER_BUG +#endif +#if ((__GNUC__ \ + ? (defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ \ + && !defined __PCC__) \ + : (199901L <= __STDC_VERSION__ \ + && !defined __HP_cc \ + && !defined __PGI \ + && !(defined __SUNPRO_C && __STDC__))) \ + && !defined _GL_EXTERN_INLINE_STDHEADER_BUG) +# define _GL_INLINE inline +# define _GL_EXTERN_INLINE extern inline +# define _GL_EXTERN_INLINE_IN_USE +#elif (2 < __GNUC__ + (7 <= __GNUC_MINOR__) && !defined __STRICT_ANSI__ \ + && !defined __PCC__ \ + && !defined _GL_EXTERN_INLINE_STDHEADER_BUG) +# if defined __GNUC_GNU_INLINE__ && __GNUC_GNU_INLINE__ + /* __gnu_inline__ suppresses a GCC 4.2 diagnostic. */ +# define _GL_INLINE extern inline __attribute__ ((__gnu_inline__)) +# else +# define _GL_INLINE extern inline +# endif +# define _GL_EXTERN_INLINE extern +# define _GL_EXTERN_INLINE_IN_USE +#else +# define _GL_INLINE _GL_UNUSED static +# define _GL_EXTERN_INLINE _GL_UNUSED static +#endif + +/* In GCC 4.6 (inclusive) to 5.1 (exclusive), + suppress bogus "no previous prototype for 'FOO'" + and "no previous declaration for 'FOO'" diagnostics, + when FOO is an inline function in the header; see + and + . */ +#if __GNUC__ == 4 && 6 <= __GNUC_MINOR__ +# if defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ +# define _GL_INLINE_HEADER_CONST_PRAGMA +# else +# define _GL_INLINE_HEADER_CONST_PRAGMA \ + _Pragma ("GCC diagnostic ignored \"-Wsuggest-attribute=const\"") +# endif +# define _GL_INLINE_HEADER_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wmissing-prototypes\"") \ + _Pragma ("GCC diagnostic ignored \"-Wmissing-declarations\"") \ + _GL_INLINE_HEADER_CONST_PRAGMA +# define _GL_INLINE_HEADER_END \ + _Pragma ("GCC diagnostic pop") +#else +# define _GL_INLINE_HEADER_BEGIN +# define _GL_INLINE_HEADER_END +#endif]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/fchdir.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/fchdir.m4 new file mode 100644 index 00000000..fc0ed337 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/fchdir.m4 @@ -0,0 +1,76 @@ +# fchdir.m4 serial 32 +dnl Copyright (C) 2006-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_FCHDIR], +[ + AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) + AC_REQUIRE([gl_DIRENT_H_DEFAULTS]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + + AC_CHECK_DECLS_ONCE([fchdir]) + if test $ac_cv_have_decl_fchdir = no; then + HAVE_DECL_FCHDIR=0 + fi + + AC_REQUIRE([gl_TEST_FCHDIR]) + if test $HAVE_FCHDIR = 1; then + AC_REQUIRE([gl_DIRENT_DIR]) + if test $DIR_HAS_FD_MEMBER = 0; then + dnl fchdir() should be replaced if dirfd() does not work. + REPLACE_FCHDIR=1 + fi + fi + + if test $HAVE_FCHDIR = 0 || test $REPLACE_FCHDIR = 1; then + AC_DEFINE([REPLACE_FCHDIR], [1], + [Define to 1 if gnulib's fchdir() replacement is used.]) + dnl We must also replace anything that can manipulate a directory fd, + dnl to keep our bookkeeping up-to-date. We don't have to replace + dnl fstatat, since no platform has fstatat but lacks fchdir. + AC_CACHE_CHECK([whether open can visit directories], + [gl_cv_func_open_directory_works], + [AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [[#include + ]GL_MDA_DEFINES], + [[return open(".", O_RDONLY) < 0;]])], + [gl_cv_func_open_directory_works=yes], + [gl_cv_func_open_directory_works=no], + [case "$host_os" in + # Guess yes on Linux systems. + linux-* | linux) gl_cv_func_open_directory_works="guessing yes" ;; + # Guess yes on systems that emulate the Linux system calls. + midipix*) gl_cv_func_open_directory_works="guessing yes" ;; + # Guess yes on glibc systems. + *-gnu* | gnu*) gl_cv_func_open_directory_works="guessing yes" ;; + # Guess no on native Windows. + mingw* | windows*) gl_cv_func_open_directory_works="guessing no" ;; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_open_directory_works="$gl_cross_guess_normal" ;; + esac + ])]) + case "$gl_cv_func_open_directory_works" in + *yes) ;; + *) + AC_DEFINE([REPLACE_OPEN_DIRECTORY], [1], [Define to 1 if open() should +work around the inability to open a directory.]) + ;; + esac + fi +]) + +# Determine whether to use the overrides in lib/fchdir.c. +AC_DEFUN([gl_TEST_FCHDIR], +[ + AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) + AC_CHECK_FUNCS_ONCE([fchdir]) + if test $ac_cv_func_fchdir = no; then + HAVE_FCHDIR=0 + fi +]) + +# Prerequisites of lib/fchdir.c. +AC_DEFUN([gl_PREREQ_FCHDIR], [:]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/fclose.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/fclose.m4 new file mode 100644 index 00000000..9547f03e --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/fclose.m4 @@ -0,0 +1,98 @@ +# fclose.m4 serial 12 +dnl Copyright (C) 2008-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN_ONCE([gl_FUNC_FCLOSE], +[ + AC_REQUIRE([gl_STDIO_H_DEFAULTS]) + AC_REQUIRE([AC_CANONICAL_HOST]) + + gl_FUNC_FFLUSH_STDIN + case "$gl_cv_func_fflush_stdin" in + *yes) ;; + *) REPLACE_FCLOSE=1 ;; + esac + + AC_REQUIRE([gl_FUNC_CLOSE]) + if test $REPLACE_CLOSE = 1; then + REPLACE_FCLOSE=1 + fi + + case "$host_os" in + openedition) REPLACE_FCLOSE=1 ;; + esac + + if test $REPLACE_FCLOSE = 0; then + gl_FUNC_FCLOSE_STDIN + case "$gl_cv_func_fclose_stdin" in + *yes) ;; + *) REPLACE_FCLOSE=1 ;; + esac + fi +]) + +dnl Determine whether fclose works on input streams. +dnl Sets gl_cv_func_fclose_stdin. + +AC_DEFUN([gl_FUNC_FCLOSE_STDIN], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CHECK_HEADERS_ONCE([unistd.h]) + AC_CACHE_CHECK([whether fclose works on input streams], + [gl_cv_func_fclose_stdin], + [echo hello world > conftest.txt + AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [[#include + #include + #if HAVE_UNISTD_H + # include + #else /* on Windows with MSVC */ + # include + #endif + ]GL_MDA_DEFINES], + [[int fd; + int fd2; + FILE *fp; + fd = open ("conftest.txt", O_RDONLY); + if (fd < 0) + return 1; + if (lseek (fd, 1, SEEK_SET) != 1) + return 2; + fd2 = dup (fd); + if (fd2 < 0) + return 3; + fp = fdopen (fd2, "r"); + if (fp == NULL) + return 4; + if (fgetc (fp) != 'e') + { fclose (fp); return 5; } + /* This fclose() call should reposition the underlying file + descriptor. */ + if (fclose (fp) != 0) + return 6; + if (lseek (fd2, 0, SEEK_CUR) != -1) /* should fail with EBADF */ + return 7; + /* Verify the file position. */ + if (lseek (fd, 0, SEEK_CUR) != 2) + return 8; + return 0; + ]])], + [gl_cv_func_fclose_stdin=yes], + [gl_cv_func_fclose_stdin=no], + [case "$host_os" in + # Guess no on glibc systems. + *-gnu* | gnu*) gl_cv_func_fclose_stdin="guessing no" ;; + # Guess yes on musl systems. + *-musl* | midipix*) gl_cv_func_fclose_stdin="guessing yes" ;; + # Guess no on native Windows. + mingw* | windows*) gl_cv_func_fclose_stdin="guessing no" ;; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_fclose_stdin="$gl_cross_guess_normal" ;; + esac + ]) + rm conftest.txt + ]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/fcntl-o.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/fcntl-o.m4 new file mode 100644 index 00000000..49ab34d8 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/fcntl-o.m4 @@ -0,0 +1,140 @@ +# fcntl-o.m4 serial 8 +dnl Copyright (C) 2006, 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl Written by Paul Eggert. + +AC_PREREQ([2.60]) + +# Test whether the flags O_NOATIME and O_NOFOLLOW actually work. +# Define HAVE_WORKING_O_NOATIME to 1 if O_NOATIME works, or to 0 otherwise. +# Define HAVE_WORKING_O_NOFOLLOW to 1 if O_NOFOLLOW works, or to 0 otherwise. +AC_DEFUN([gl_FCNTL_O_FLAGS], +[ + dnl Persuade glibc to define O_NOATIME and O_NOFOLLOW. + AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) + + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CHECK_HEADERS_ONCE([unistd.h]) + AC_CHECK_FUNCS_ONCE([symlink]) + AC_CACHE_CHECK([for working fcntl.h], [gl_cv_header_working_fcntl_h], + [AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [[#include + #include + #if HAVE_UNISTD_H + # include + #else /* on Windows with MSVC */ + # include + # include + # defined sleep(n) _sleep ((n) * 1000) + #endif + #include + ]GL_MDA_DEFINES[ + #ifndef O_NOATIME + #define O_NOATIME 0 + #endif + #ifndef O_NOFOLLOW + #define O_NOFOLLOW 0 + #endif + static int const constants[] = + { + O_CREAT, O_EXCL, O_NOCTTY, O_TRUNC, O_APPEND, + O_NONBLOCK, O_SYNC, O_ACCMODE, O_RDONLY, O_RDWR, O_WRONLY + }; + ]], + [[ + int result = !constants; + #if HAVE_SYMLINK + { + static char const sym[] = "conftest.sym"; + if (symlink ("/dev/null", sym) != 0) + result |= 2; + else + { + int fd = open (sym, O_WRONLY | O_NOFOLLOW | O_CREAT, 0); + if (fd >= 0) + { + close (fd); + result |= 4; + } + } + if (unlink (sym) != 0 || symlink (".", sym) != 0) + result |= 2; + else + { + int fd = open (sym, O_RDONLY | O_NOFOLLOW); + if (fd >= 0) + { + close (fd); + result |= 4; + } + } + unlink (sym); + } + #endif + { + static char const file[] = "confdefs.h"; + int fd = open (file, O_RDONLY | O_NOATIME); + if (fd < 0) + result |= 8; + else + { + struct stat st0; + if (fstat (fd, &st0) != 0) + result |= 16; + else + { + char c; + sleep (1); + if (read (fd, &c, 1) != 1) + result |= 24; + else + { + if (close (fd) != 0) + result |= 32; + else + { + struct stat st1; + if (stat (file, &st1) != 0) + result |= 40; + else + if (st0.st_atime != st1.st_atime) + result |= 64; + } + } + } + } + } + return result;]])], + [gl_cv_header_working_fcntl_h=yes], + [case $? in #( + 4) gl_cv_header_working_fcntl_h='no (bad O_NOFOLLOW)';; #( + 64) gl_cv_header_working_fcntl_h='no (bad O_NOATIME)';; #( + 68) gl_cv_header_working_fcntl_h='no (bad O_NOATIME, O_NOFOLLOW)';; #( + *) gl_cv_header_working_fcntl_h='no';; + esac], + [case "$host_os" in + # Guess 'no' on native Windows. + mingw* | windows*) gl_cv_header_working_fcntl_h='no' ;; + *) gl_cv_header_working_fcntl_h=cross-compiling ;; + esac + ]) + ]) + + case $gl_cv_header_working_fcntl_h in #( + *O_NOATIME* | no | cross-compiling) ac_val=0;; #( + *) ac_val=1;; + esac + AC_DEFINE_UNQUOTED([HAVE_WORKING_O_NOATIME], [$ac_val], + [Define to 1 if O_NOATIME works.]) + + case $gl_cv_header_working_fcntl_h in #( + *O_NOFOLLOW* | no | cross-compiling) ac_val=0;; #( + *) ac_val=1;; + esac + AC_DEFINE_UNQUOTED([HAVE_WORKING_O_NOFOLLOW], [$ac_val], + [Define to 1 if O_NOFOLLOW works.]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/fcntl.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/fcntl.m4 new file mode 100644 index 00000000..02b93f83 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/fcntl.m4 @@ -0,0 +1,151 @@ +# fcntl.m4 serial 11 +dnl Copyright (C) 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +# For now, this module ensures that fcntl() +# - supports F_DUPFD correctly +# - supports or emulates F_DUPFD_CLOEXEC +# - supports F_GETFD +# Still to be ported to mingw: +# - F_SETFD +# - F_GETFL, F_SETFL +# - F_GETOWN, F_SETOWN +# - F_GETLK, F_SETLK, F_SETLKW +AC_DEFUN([gl_FUNC_FCNTL], +[ + dnl Persuade glibc to expose F_DUPFD_CLOEXEC. + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + AC_REQUIRE([gl_FCNTL_H_DEFAULTS]) + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_CHECK_FUNCS_ONCE([fcntl]) + if test $ac_cv_func_fcntl = no; then + gl_REPLACE_FCNTL + else + dnl cygwin 1.5.x F_DUPFD has wrong errno, and allows negative target + dnl haiku alpha 2 F_DUPFD has wrong errno + AC_CACHE_CHECK([whether fcntl handles F_DUPFD correctly], + [gl_cv_func_fcntl_f_dupfd_works], + [AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [[#include + #include + #include + #include + #include + ]GL_MDA_DEFINES[ + #ifndef RLIM_SAVED_CUR + # define RLIM_SAVED_CUR RLIM_INFINITY + #endif + #ifndef RLIM_SAVED_MAX + # define RLIM_SAVED_MAX RLIM_INFINITY + #endif + ]], + [[int result = 0; + int bad_fd = INT_MAX; + struct rlimit rlim; + if (getrlimit (RLIMIT_NOFILE, &rlim) == 0 + && 0 <= rlim.rlim_cur && rlim.rlim_cur <= INT_MAX + && rlim.rlim_cur != RLIM_INFINITY + && rlim.rlim_cur != RLIM_SAVED_MAX + && rlim.rlim_cur != RLIM_SAVED_CUR) + bad_fd = rlim.rlim_cur; + if (fcntl (0, F_DUPFD, -1) != -1) result |= 1; + if (errno != EINVAL) result |= 2; + if (fcntl (0, F_DUPFD, bad_fd) != -1) result |= 4; + if (errno != EINVAL) result |= 8; + /* On OS/2 kLIBC, F_DUPFD does not work on a directory fd */ + { + int fd; + fd = open (".", O_RDONLY); + if (fd == -1) + result |= 16; + else if (fcntl (fd, F_DUPFD, STDERR_FILENO + 1) == -1) + result |= 32; + + close (fd); + } + return result;]])], + [gl_cv_func_fcntl_f_dupfd_works=yes], + [gl_cv_func_fcntl_f_dupfd_works=no], + [case $host_os in + aix* | cygwin* | haiku*) + gl_cv_func_fcntl_f_dupfd_works="guessing no" ;; + *) gl_cv_func_fcntl_f_dupfd_works="guessing yes" ;; + esac])]) + case $gl_cv_func_fcntl_f_dupfd_works in + *yes) ;; + *) gl_REPLACE_FCNTL + AC_DEFINE([FCNTL_DUPFD_BUGGY], [1], [Define this to 1 if F_DUPFD + behavior does not match POSIX]) ;; + esac + + dnl Many systems lack F_DUPFD_CLOEXEC. + dnl NetBSD 9.0 declares F_DUPFD_CLOEXEC but it works only like F_DUPFD. + AC_CACHE_CHECK([whether fcntl understands F_DUPFD_CLOEXEC], + [gl_cv_func_fcntl_f_dupfd_cloexec], + [AC_RUN_IFELSE( + [AC_LANG_SOURCE( + [[#include + #include + int main (int argc, char *argv[]) + { + if (argc == 1) + /* parent process */ + { + if (fcntl (1, F_DUPFD_CLOEXEC, 10) < 0) + return 1; + return execl ("./conftest", "./conftest", "child", NULL); + } + else + /* child process */ + return (fcntl (10, F_GETFL) < 0 ? 0 : 42); + } + ]]) + ], + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#ifdef __linux__ +/* The Linux kernel only added F_DUPFD_CLOEXEC in 2.6.24, so we always replace + it to support the semantics on older kernels that failed with EINVAL. */ +choke me +#endif + ]])], + [gl_cv_func_fcntl_f_dupfd_cloexec=yes], + [gl_cv_func_fcntl_f_dupfd_cloexec="needs runtime check"]) + ], + [gl_cv_func_fcntl_f_dupfd_cloexec=no], + [case "$host_os" in + # Guess no on NetBSD. + netbsd*) gl_cv_func_fcntl_f_dupfd_cloexec="guessing no" ;; + *) gl_cv_func_fcntl_f_dupfd_cloexec="$gl_cross_guess_normal" ;; + esac + ]) + ]) + case "$gl_cv_func_fcntl_f_dupfd_cloexec" in + *yes) ;; + *) gl_REPLACE_FCNTL + dnl No witness macro needed for this bug. + ;; + esac + fi + dnl Replace fcntl() for supporting the gnulib-defined fchdir() function, + dnl to keep fchdir's bookkeeping up-to-date. + m4_ifdef([gl_FUNC_FCHDIR], [ + gl_TEST_FCHDIR + if test $HAVE_FCHDIR = 0; then + gl_REPLACE_FCNTL + fi + ]) +]) + +AC_DEFUN([gl_REPLACE_FCNTL], +[ + AC_REQUIRE([gl_FCNTL_H_DEFAULTS]) + AC_CHECK_FUNCS_ONCE([fcntl]) + if test $ac_cv_func_fcntl = no; then + HAVE_FCNTL=0 + else + REPLACE_FCNTL=1 + fi +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/fcntl_h.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/fcntl_h.m4 new file mode 100644 index 00000000..ba4eb449 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/fcntl_h.m4 @@ -0,0 +1,70 @@ +# serial 20 +# Configure fcntl.h. +dnl Copyright (C) 2006-2007, 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl Written by Paul Eggert. + +AC_DEFUN_ONCE([gl_FCNTL_H], +[ + AC_REQUIRE([gl_FCNTL_H_DEFAULTS]) + AC_REQUIRE([gl_FCNTL_O_FLAGS]) + gl_NEXT_HEADERS([fcntl.h]) + + dnl Ensure the type pid_t gets defined. + AC_REQUIRE([AC_TYPE_PID_T]) + + dnl Ensure the type mode_t gets defined. + AC_REQUIRE([AC_TYPE_MODE_T]) + + dnl Check for declarations of anything we want to poison if the + dnl corresponding gnulib module is not in use, if it is not common + dnl enough to be declared everywhere. + gl_WARN_ON_USE_PREPARE([[#include + ]], [fcntl openat]) +]) + +# gl_FCNTL_MODULE_INDICATOR([modulename]) +# sets the shell variable that indicates the presence of the given module +# to a C preprocessor expression that will evaluate to 1. +# This macro invocation must not occur in macros that are AC_REQUIREd. +AC_DEFUN([gl_FCNTL_MODULE_INDICATOR], +[ + dnl Ensure to expand the default settings once only. + gl_FCNTL_H_REQUIRE_DEFAULTS + gl_MODULE_INDICATOR_SET_VARIABLE([$1]) + dnl Define it also as a C macro, for the benefit of the unit tests. + gl_MODULE_INDICATOR_FOR_TESTS([$1]) +]) + +# Initializes the default values for AC_SUBSTed shell variables. +# This macro must not be AC_REQUIREd. It must only be invoked, and only +# outside of macros or in macros that are not AC_REQUIREd. +AC_DEFUN([gl_FCNTL_H_REQUIRE_DEFAULTS], +[ + m4_defun(GL_MODULE_INDICATOR_PREFIX[_FCNTL_H_MODULE_INDICATOR_DEFAULTS], [ + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CREAT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FCNTL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_NONBLOCKING]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_OPEN]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_OPENAT]) + dnl Support Microsoft deprecated alias function names by default. + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_CREAT], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_OPEN], [1]) + ]) + m4_require(GL_MODULE_INDICATOR_PREFIX[_FCNTL_H_MODULE_INDICATOR_DEFAULTS]) + AC_REQUIRE([gl_FCNTL_H_DEFAULTS]) +]) + +AC_DEFUN([gl_FCNTL_H_DEFAULTS], +[ + dnl Assume proper GNU behavior unless another module says otherwise. + HAVE_FCNTL=1; AC_SUBST([HAVE_FCNTL]) + HAVE_OPENAT=1; AC_SUBST([HAVE_OPENAT]) + REPLACE_CREAT=0; AC_SUBST([REPLACE_CREAT]) + REPLACE_FCNTL=0; AC_SUBST([REPLACE_FCNTL]) + REPLACE_OPEN=0; AC_SUBST([REPLACE_OPEN]) + REPLACE_OPENAT=0; AC_SUBST([REPLACE_OPENAT]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/fdopen.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/fdopen.m4 new file mode 100644 index 00000000..5b94047e --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/fdopen.m4 @@ -0,0 +1,51 @@ +# fdopen.m4 serial 6 +dnl Copyright (C) 2011-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_FDOPEN], +[ + AC_REQUIRE([gl_STDIO_H_DEFAULTS]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + m4_ifdef([gl_MSVC_INVAL], [ + AC_REQUIRE([gl_MSVC_INVAL]) + if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then + REPLACE_FDOPEN=1 + fi + ]) + if test $REPLACE_FDOPEN = 0; then + dnl Test whether fdopen() sets errno when it fails due to a bad fd argument. + AC_CACHE_CHECK([whether fdopen sets errno], [gl_cv_func_fdopen_works], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +]GL_MDA_DEFINES[ +int +main (void) +{ + FILE *fp; + errno = 0; + fp = fdopen (-1, "r"); + if (fp == NULL && errno == 0) + return 1; + return 0; +}]])], + [gl_cv_func_fdopen_works=yes], + [gl_cv_func_fdopen_works=no], + [case "$host_os" in + mingw* | windows*) gl_cv_func_fdopen_works="guessing no" ;; + *) gl_cv_func_fdopen_works="guessing yes" ;; + esac + ]) + ]) + case "$gl_cv_func_fdopen_works" in + *no) REPLACE_FDOPEN=1 ;; + esac + fi +]) + +dnl Prerequisites of lib/fdopen.c. +AC_DEFUN([gl_PREREQ_FDOPEN], []) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/fdopendir.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/fdopendir.m4 new file mode 100644 index 00000000..bf361ff1 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/fdopendir.m4 @@ -0,0 +1,67 @@ +# serial 15 +# See if we need to provide fdopendir. + +dnl Copyright (C) 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +# Written by Eric Blake. + +AC_DEFUN([gl_FUNC_FDOPENDIR], +[ + AC_REQUIRE([gl_DIRENT_H_DEFAULTS]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + + dnl FreeBSD 7.3 has the function, but failed to declare it. + AC_CHECK_DECLS([fdopendir], [], [HAVE_DECL_FDOPENDIR=0], [[ +#include + ]]) + AC_CHECK_FUNCS_ONCE([fdopendir]) + if test $ac_cv_func_fdopendir = no; then + HAVE_FDOPENDIR=0 + else + AC_CACHE_CHECK([whether fdopendir works], + [gl_cv_func_fdopendir_works], + [AC_RUN_IFELSE( + [AC_LANG_PROGRAM([[ +#include +#include +#include +]GL_MDA_DEFINES[ +#if !HAVE_DECL_FDOPENDIR +extern +# ifdef __cplusplus +"C" +# endif +DIR *fdopendir (int); +#endif +]], + [[int result = 0; + int fd = open ("conftest.c", O_RDONLY); + if (fd < 0) result |= 1; + if (fdopendir (fd)) result |= 2; + if (close (fd)) result |= 4; + return result; + ]])], + [gl_cv_func_fdopendir_works=yes], + [gl_cv_func_fdopendir_works=no], + [case "$host_os" in + # Guess yes on glibc systems. + *-gnu*) gl_cv_func_fdopendir_works="guessing yes" ;; + # Guess yes on musl systems. + *-musl* | midipix*) gl_cv_func_fdopendir_works="guessing yes" ;; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_fdopendir_works="$gl_cross_guess_normal" ;; + esac + ])]) + case "$gl_cv_func_fdopendir_works" in + *yes) ;; + *) + REPLACE_FDOPENDIR=1 + ;; + esac + fi +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/fflush.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/fflush.m4 new file mode 100644 index 00000000..85cf3be2 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/fflush.m4 @@ -0,0 +1,100 @@ +# fflush.m4 serial 19 + +# Copyright (C) 2007-2024 Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +dnl From Eric Blake + +dnl Find out how to obey POSIX semantics of fflush(stdin) discarding +dnl unread input on seekable streams, rather than C99 undefined semantics. + +AC_DEFUN([gl_FUNC_FFLUSH], +[ + AC_REQUIRE([gl_STDIO_H_DEFAULTS]) + gl_FUNC_FFLUSH_STDIN + case "$gl_cv_func_fflush_stdin" in + *yes) ;; + *) REPLACE_FFLUSH=1 ;; + esac +]) + +dnl Determine whether fflush works on input streams. +dnl Sets gl_cv_func_fflush_stdin. + +AC_DEFUN([gl_FUNC_FFLUSH_STDIN], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CHECK_HEADERS_ONCE([unistd.h]) + AC_CACHE_CHECK([whether fflush works on input streams], + [gl_cv_func_fflush_stdin], + [echo hello world > conftest.txt + AC_RUN_IFELSE([AC_LANG_PROGRAM( + [[ +#include +#if HAVE_UNISTD_H +# include +#else /* on Windows with MSVC */ +# include +#endif + ]GL_MDA_DEFINES], + [[FILE *f = fopen ("conftest.txt", "r"); + char buffer[10]; + int fd; + int c; + if (f == NULL) + return 1; + fd = fileno (f); + if (fd < 0 || fread (buffer, 1, 5, f) != 5) + { fclose (f); return 2; } + /* For deterministic results, ensure f read a bigger buffer. */ + if (lseek (fd, 0, SEEK_CUR) == 5) + { fclose (f); return 3; } + /* POSIX requires fflush-fseek to set file offset of fd. This fails + on BSD systems and on mingw. */ + if (fflush (f) != 0 || fseek (f, 0, SEEK_CUR) != 0) + { fclose (f); return 4; } + if (lseek (fd, 0, SEEK_CUR) != 5) + { fclose (f); return 5; } + /* Verify behaviour of fflush after ungetc. See + */ + /* Verify behaviour of fflush after a backup ungetc. This fails on + mingw. */ + c = fgetc (f); + ungetc (c, f); + fflush (f); + if (fgetc (f) != c) + { fclose (f); return 6; } + /* Verify behaviour of fflush after a non-backup ungetc. This fails + on glibc 2.8 and on BSD systems. */ + c = fgetc (f); + ungetc ('@', f); + fflush (f); + if (fgetc (f) != c) + { fclose (f); return 7; } + fclose (f); + return 0; + ]])], + [gl_cv_func_fflush_stdin=yes], + [gl_cv_func_fflush_stdin=no], + [case "$host_os" in + # Guess no on native Windows. + mingw* | windows*) gl_cv_func_fflush_stdin="guessing no" ;; + *) gl_cv_func_fflush_stdin=cross ;; + esac + ]) + rm conftest.txt + ]) + case "$gl_cv_func_fflush_stdin" in + *yes) gl_func_fflush_stdin=1 ;; + *no) gl_func_fflush_stdin=0 ;; + *) gl_func_fflush_stdin='(-1)' ;; + esac + AC_DEFINE_UNQUOTED([FUNC_FFLUSH_STDIN], [$gl_func_fflush_stdin], + [Define to 1 if fflush is known to work on stdin as per POSIX.1-2008, + 0 if fflush is known to not work, -1 if unknown.]) +]) + +# Prerequisites of lib/fflush.c. +AC_DEFUN([gl_PREREQ_FFLUSH], [:]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/filenamecat.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/filenamecat.m4 new file mode 100644 index 00000000..7feb7f8c --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/filenamecat.m4 @@ -0,0 +1,16 @@ +# filenamecat.m4 serial 12 +dnl Copyright (C) 2002-2006, 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FILE_NAME_CONCAT], +[ + AC_REQUIRE([gl_FILE_NAME_CONCAT_LGPL]) +]) + +AC_DEFUN([gl_FILE_NAME_CONCAT_LGPL], +[ + dnl Prerequisites of lib/filenamecat-lgpl.c. + gl_CHECK_FUNCS_ANDROID([mempcpy], [[#include ]]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/flexmember.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/flexmember.m4 new file mode 100644 index 00000000..9df6c03c --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/flexmember.m4 @@ -0,0 +1,44 @@ +# serial 5 +# Check for flexible array member support. + +# Copyright (C) 2006, 2009-2024 Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# Written by Paul Eggert. + +AC_DEFUN([AC_C_FLEXIBLE_ARRAY_MEMBER], +[ + AC_CACHE_CHECK([for flexible array member], + ac_cv_c_flexmember, + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include + #include + #include + struct m { struct m *next, **list; char name[]; }; + struct s { struct s *p; struct m *m; int n; double d[]; };]], + [[int m = getchar (); + size_t nbytes = offsetof (struct s, d) + m * sizeof (double); + nbytes += sizeof (struct s) - 1; + nbytes -= nbytes % sizeof (struct s); + struct s *p = malloc (nbytes); + p->p = p; + p->m = NULL; + p->d[0] = 0.0; + return p->d != (double *) NULL;]])], + [ac_cv_c_flexmember=yes], + [ac_cv_c_flexmember=no])]) + if test $ac_cv_c_flexmember = yes; then + AC_DEFINE([FLEXIBLE_ARRAY_MEMBER], [], + [Define to nothing if C supports flexible array members, and to + 1 if it does not. That way, with a declaration like 'struct s + { int n; short d@<:@FLEXIBLE_ARRAY_MEMBER@:>@; };', the struct hack + can be used with pre-C99 compilers. + Use 'FLEXSIZEOF (struct s, d, N * sizeof (short))' to calculate + the size in bytes of such a struct containing an N-element array.]) + else + AC_DEFINE([FLEXIBLE_ARRAY_MEMBER], [1]) + fi +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/float_h.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/float_h.m4 new file mode 100644 index 00000000..60e81447 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/float_h.m4 @@ -0,0 +1,108 @@ +# float_h.m4 serial 14 +dnl Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FLOAT_H], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) + GL_GENERATE_FLOAT_H=false + REPLACE_FLOAT_LDBL=0 + case "$host_os" in + aix* | beos* | openbsd* | mirbsd* | irix*) + GL_GENERATE_FLOAT_H=true + ;; + freebsd* | dragonfly*) + case "$host_cpu" in +changequote(,)dnl + i[34567]86 ) +changequote([,])dnl + GL_GENERATE_FLOAT_H=true + ;; + x86_64 ) + # On x86_64 systems, the C compiler may still be generating + # 32-bit code. + AC_COMPILE_IFELSE( + [AC_LANG_SOURCE( + [[#if defined __LP64__ || defined __x86_64__ || defined __amd64__ + int ok; + #else + error fail + #endif + ]])], + [], + [GL_GENERATE_FLOAT_H=true]) + ;; + esac + ;; + linux*) + case "$host_cpu" in + powerpc*) + GL_GENERATE_FLOAT_H=true + ;; + esac + ;; + esac + case "$host_os" in + aix* | freebsd* | dragonfly* | linux*) + if $GL_GENERATE_FLOAT_H; then + REPLACE_FLOAT_LDBL=1 + fi + ;; + esac + + dnl Test against glibc-2.7 Linux/SPARC64 bug. + REPLACE_ITOLD=0 + AC_CACHE_CHECK([whether conversion from 'int' to 'long double' works], + [gl_cv_func_itold_works], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +int i = -1; +volatile long double ld; +int main () +{ + ld += i * 1.0L; + if (ld > 0) + return 1; + return 0; +}]])], + [gl_cv_func_itold_works=yes], + [gl_cv_func_itold_works=no], + [case "$host" in + sparc*-*-linux*) + AC_COMPILE_IFELSE( + [AC_LANG_SOURCE( + [[#if defined __LP64__ || defined __arch64__ + int ok; + #else + error fail + #endif + ]])], + [gl_cv_func_itold_works="guessing no"], + [gl_cv_func_itold_works="guessing yes"]) + ;; + # Guess yes on native Windows. + mingw* | windows*) + gl_cv_func_itold_works="guessing yes" ;; + *) + gl_cv_func_itold_works="guessing yes" ;; + esac + ]) + ]) + case "$gl_cv_func_itold_works" in + *no) + REPLACE_ITOLD=1 + dnl We add the workaround to but also to , + dnl to increase the chances that the fix function gets pulled in. + GL_GENERATE_FLOAT_H=true + ;; + esac + + if $GL_GENERATE_FLOAT_H; then + gl_NEXT_HEADERS([float.h]) + fi + AC_SUBST([REPLACE_ITOLD]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/fnmatch.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/fnmatch.m4 new file mode 100644 index 00000000..54d5c7bb --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/fnmatch.m4 @@ -0,0 +1,209 @@ +# Check for fnmatch - serial 20 -*- coding: utf-8 -*- + +# Copyright (C) 2000-2007, 2009-2024 Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# Autoconf defines AC_FUNC_FNMATCH, but that is obsolescent. +# New applications should use the macros below instead. + +# Request a POSIX compliant fnmatch function. +AC_DEFUN([gl_FUNC_FNMATCH_POSIX], +[ + m4_divert_text([DEFAULTS], [gl_fnmatch_required=POSIX]) + + AC_REQUIRE([gl_FNMATCH_H]) + AC_REQUIRE([AC_CANONICAL_HOST]) + gl_fnmatch_required_lowercase=` + echo $gl_fnmatch_required | LC_ALL=C tr '[[A-Z]]' '[[a-z]]' + ` + AC_CHECK_FUNCS_ONCE([fnmatch]) + if test $ac_cv_func_fnmatch = no; then + HAVE_FNMATCH=0 + else + gl_fnmatch_cache_var="gl_cv_func_fnmatch_${gl_fnmatch_required_lowercase}" + AC_CACHE_CHECK([for working $gl_fnmatch_required fnmatch], + [$gl_fnmatch_cache_var], + [dnl Some versions of Solaris, SCO, and the GNU C Library + dnl have a broken or incompatible fnmatch. + dnl So we run a test program. If we are cross-compiling, take no chance. + dnl Thanks to John Oleynick, François Pinard, and Paul Eggert for this + dnl test. + if test $gl_fnmatch_required = GNU; then + gl_fnmatch_gnu_start= + gl_fnmatch_gnu_end= + else + gl_fnmatch_gnu_start='#if 0' + gl_fnmatch_gnu_end='#endif' + fi + AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [[#include + #include + #include + static int + y (char const *pattern, char const *string, int flags) + { + return fnmatch (pattern, string, flags) == 0; + } + static int + n (char const *pattern, char const *string, int flags) + { + return fnmatch (pattern, string, flags) == FNM_NOMATCH; + } + ]], + [[char const *Apat = 'A' < '\\\\' ? "[A-\\\\\\\\]" : "[\\\\\\\\-A]"; + char const *apat = 'a' < '\\\\' ? "[a-\\\\\\\\]" : "[\\\\\\\\-a]"; + static char const A_1[] = { 'A' - 1, 0 }; + static char const A01[] = { 'A' + 1, 0 }; + static char const a_1[] = { 'a' - 1, 0 }; + static char const a01[] = { 'a' + 1, 0 }; + static char const bs_1[] = { '\\\\' - 1, 0 }; + static char const bs01[] = { '\\\\' + 1, 0 }; + int result = 0; + /* ==== Start of tests in the "C" locale ==== */ + /* These are sanity checks. They all succeed on current platforms. */ + if (!n ("a*", "", 0)) + return 1; + if (!y ("a*", "abc", 0)) + return 1; + if (!n ("d*/*1", "d/s/1", FNM_PATHNAME)) + return 1; + if (!y ("a\\\\bc", "abc", 0)) + return 1; + if (!n ("a\\\\bc", "abc", FNM_NOESCAPE)) + return 1; + if (!y ("*x", ".x", 0)) + return 1; + if (!n ("*x", ".x", FNM_PERIOD)) + return 1; + /* glibc bug + exists in glibc 2.3.3, fixed in glibc 2.5. */ + if (!y (Apat, "\\\\", 0)) + result |= 2; + if (!y (Apat, "A", 0)) + result |= 2; + if (!y (apat, "\\\\", 0)) + result |= 2; + if (!y (apat, "a", 0)) + result |= 2; + if (!(n (Apat, A_1, 0) == ('A' < '\\\\'))) + result |= 2; + if (!(n (apat, a_1, 0) == ('a' < '\\\\'))) + result |= 2; + if (!(y (Apat, A01, 0) == ('A' < '\\\\'))) + result |= 2; + if (!(y (apat, a01, 0) == ('a' < '\\\\'))) + result |= 2; + if (!(y (Apat, bs_1, 0) == ('A' < '\\\\'))) + result |= 2; + if (!(y (apat, bs_1, 0) == ('a' < '\\\\'))) + result |= 2; + if (!(n (Apat, bs01, 0) == ('A' < '\\\\'))) + result |= 2; + if (!(n (apat, bs01, 0) == ('a' < '\\\\'))) + result |= 2; + /* glibc bug + exists in glibc 2.12, fixed in glibc 2.13. */ + if (!y ("[/b", "[/b", 0)) /*"]]"*/ + result |= 4; + /* glibc bug + is fixed in glibc 2.20. + glibc bugs + + are fixed in glibc 2.22. + These bugs are not easy to test for reliably (without mmap), + therefore test the glibc version. */ + #if defined __GLIBC__ + if (__GLIBC__ == 2 && __GLIBC_MINOR__ < 22) + result |= 4; + #endif + /* This test fails on FreeBSD 13.2, NetBSD 9.3, Cygwin 3.4.6. */ + if (!y ("[[:alnum:]]", "a", 0)) + result |= 8; + $gl_fnmatch_gnu_start /* ==== Start of GNU extensions tests ==== */ + /* Sanity checks, mainly to check the presence of the FNM_* macros. */ + if (!y ("xxXX", "xXxX", FNM_CASEFOLD)) + result |= 64; + if (!y ("a++(x|yy)b", "a+xyyyyxb", FNM_EXTMATCH)) + result |= 64; + if (!n ("d*/*1", "d/s/1", FNM_FILE_NAME)) + result |= 64; + if (!y ("*", "x", FNM_FILE_NAME | FNM_LEADING_DIR)) + result |= 64; + if (!y ("x*", "x/y/z", FNM_FILE_NAME | FNM_LEADING_DIR)) + result |= 64; + if (!y ("*c*", "c/x", FNM_FILE_NAME | FNM_LEADING_DIR)) + result |= 64; + $gl_fnmatch_gnu_end /* ==== End of GNU extensions tests ==== */ + /* ==== End of tests in the "C" locale ==== */ + /* ==== Start of tests that require a specific locale ==== */ + /* This test fails on Solaris 11.4. */ + if (setlocale (LC_ALL, "en_US.UTF-8") != NULL) + { + if (!n ("[!a-z]", "", 0)) + result |= 16; + } + /* This test fails on NetBSD 9.3, Android 13. */ + if (setlocale (LC_ALL, "C.UTF-8") != NULL) + { + if (!y ("x?y", "x\\303\\274y", 0)) + result |= 32; + } + /* ==== End of tests that require a specific locale ==== */ + return result; + ]])], + [eval "$gl_fnmatch_cache_var=yes"], + [eval "$gl_fnmatch_cache_var=no"], + [case "$host_os" in + # Guess yes on musl systems. + *-musl* | midipix*) eval "$gl_fnmatch_cache_var=\"guessing yes\"" ;; + # Guess no otherwise, even on glibc systems. + *) eval "$gl_fnmatch_cache_var=\"guessing no\"" ;; + esac + ]) + ]) + eval "gl_fnmatch_result=\"\$$gl_fnmatch_cache_var\"" + case "$gl_fnmatch_result" in + *yes) ;; + *) REPLACE_FNMATCH=1 ;; + esac + dnl On AIX 7.2 in 32-bit mode, fnmatch()'s only POSIX compliance problem is + dnl that is does not support characters outside the Unicode BMP correctly. + dnl Test case: fnmatch ("x?y", "x\360\237\230\213y", 0) == 0 + dnl This is due to wchar_t being only 16 bits wide. + AC_REQUIRE([gl_UCHAR_H]) + if test $SMALL_WCHAR_T = 1; then + case "$host_os" in + cygwin*) + dnl On Cygwin < 3.5.0, the above $gl_fnmatch_result came out as 'no', + dnl On Cygwin >= 3.5.0, fnmatch supports all Unicode characters, + dnl despite wchar_t being only 16 bits wide (because internally it + dnl works on wint_t values). + ;; + *) + REPLACE_FNMATCH=1 + ;; + esac + fi + fi + if test $HAVE_FNMATCH = 0 || test $REPLACE_FNMATCH = 1; then + gl_REPLACE_FNMATCH_H + fi +]) + +# Request a POSIX compliant fnmatch function with GNU extensions. +AC_DEFUN([gl_FUNC_FNMATCH_GNU], +[ + m4_divert_text([INIT_PREPARE], [gl_fnmatch_required=GNU]) + + AC_REQUIRE([gl_FUNC_FNMATCH_POSIX]) +]) + +AC_DEFUN([gl_PREREQ_FNMATCH], +[ + dnl Prerequisites of lib/fnmatch.c. + AC_REQUIRE([AC_TYPE_MBSTATE_T]) + AC_CHECK_FUNCS_ONCE([mbsrtowcs]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/fnmatch_h.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/fnmatch_h.m4 new file mode 100644 index 00000000..58cd7dcb --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/fnmatch_h.m4 @@ -0,0 +1,87 @@ +# fnmatch_h.m4 serial 8 +dnl Copyright (C) 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. + +AC_DEFUN_ONCE([gl_FNMATCH_H], +[ + AC_REQUIRE([gl_FNMATCH_H_DEFAULTS]) + m4_ifdef([gl_ANSI_CXX], [AC_REQUIRE([gl_ANSI_CXX])]) + AC_CHECK_HEADERS_ONCE([fnmatch.h]) + gl_CHECK_NEXT_HEADERS([fnmatch.h]) + + dnl Persuade glibc to declare FNM_CASEFOLD etc. + dnl This is only needed if gl_fnmatch_required = GNU. It would be possible + dnl to avoid this dependency for gl_FUNC_FNMATCH_POSIX by putting + dnl gl_FUNC_FNMATCH_GNU into a separate .m4 file. + AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) + + if test $ac_cv_header_fnmatch_h = yes; then + HAVE_FNMATCH_H=1 + else + HAVE_FNMATCH_H=0 + fi + AC_SUBST([HAVE_FNMATCH_H]) + + m4_ifdef([gl_POSIXCHECK], + [GL_GENERATE_FNMATCH_H=true], + [GL_GENERATE_FNMATCH_H=false + if m4_ifdef([gl_ANSI_CXX], [test "$CXX" != no], [false]); then + dnl Override always, to support the C++ GNULIB_NAMESPACE. + GL_GENERATE_FNMATCH_H=true + else + if test $ac_cv_header_fnmatch_h != yes; then + dnl Provide a substitute file. + GL_GENERATE_FNMATCH_H=true + fi + fi + ]) + + dnl Check for declarations of anything we want to poison if the + dnl corresponding gnulib module is not in use. + gl_WARN_ON_USE_PREPARE([[#include + ]], + [fnmatch]) +]) + +dnl Unconditionally enables the replacement of . +AC_DEFUN([gl_REPLACE_FNMATCH_H], +[ + gl_FNMATCH_H_REQUIRE_DEFAULTS + GL_GENERATE_FNMATCH_H=true +]) + +# gl_FNMATCH_MODULE_INDICATOR([modulename]) +# sets the shell variable that indicates the presence of the given module +# to a C preprocessor expression that will evaluate to 1. +# This macro invocation must not occur in macros that are AC_REQUIREd. +AC_DEFUN([gl_FNMATCH_MODULE_INDICATOR], +[ + dnl Ensure to expand the default settings once only. + gl_FNMATCH_H_REQUIRE_DEFAULTS + gl_MODULE_INDICATOR_SET_VARIABLE([$1]) + dnl Define it also as a C macro, for the benefit of the unit tests. + gl_MODULE_INDICATOR_FOR_TESTS([$1]) +]) + +# Initializes the default values for AC_SUBSTed shell variables. +# This macro must not be AC_REQUIREd. It must only be invoked, and only +# outside of macros or in macros that are not AC_REQUIREd. +AC_DEFUN([gl_FNMATCH_H_REQUIRE_DEFAULTS], +[ + m4_defun(GL_MODULE_INDICATOR_PREFIX[_FNMATCH_H_MODULE_INDICATOR_DEFAULTS], [ + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FNMATCH]) + ]) + m4_require(GL_MODULE_INDICATOR_PREFIX[_FNMATCH_H_MODULE_INDICATOR_DEFAULTS]) + AC_REQUIRE([gl_FNMATCH_H_DEFAULTS]) +]) + +AC_DEFUN([gl_FNMATCH_H_DEFAULTS], +[ + dnl Assume POSIX behavior unless another module says otherwise. + HAVE_FNMATCH=1; AC_SUBST([HAVE_FNMATCH]) + REPLACE_FNMATCH=0; AC_SUBST([REPLACE_FNMATCH]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/fopen.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/fopen.m4 new file mode 100644 index 00000000..1fcffa40 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/fopen.m4 @@ -0,0 +1,158 @@ +# fopen.m4 serial 16 +dnl Copyright (C) 2007-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_FOPEN_ITSELF], +[ + AC_REQUIRE([gl_STDIO_H_DEFAULTS]) + AC_REQUIRE([AC_CANONICAL_HOST]) + case "$host_os" in + mingw* | windows* | pw*) + dnl Replace fopen, for handling of "/dev/null". + REPLACE_FOPEN=1 + dnl fopen on mingw also has the trailing slash bug. + gl_cv_func_fopen_slash="guessing no" + ;; + *) + dnl fopen("foo/", "w") should not create a file when the file name has a + dnl trailing slash. + AC_CACHE_CHECK([whether fopen recognizes a trailing slash], + [gl_cv_func_fopen_slash], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +int main () +{ + FILE *fp = fopen ("conftest.sl/", "w"); + int result = (fp != NULL); + if (fp != NULL) + fclose (fp); + return result; +}]])], + [gl_cv_func_fopen_slash=yes], + [gl_cv_func_fopen_slash=no], + [ +changequote(,)dnl + case "$host_os" in + aix* | hpux* | solaris2.[0-9] | solaris2.[0-9].*) + gl_cv_func_fopen_slash="guessing no" ;; + *) + gl_cv_func_fopen_slash="guessing yes" ;; + esac +changequote([,])dnl + ]) + rm -f conftest.sl + ]) + ;; + esac + case "$gl_cv_func_fopen_slash" in + *no) + AC_DEFINE([FOPEN_TRAILING_SLASH_BUG], [1], + [Define to 1 if fopen() fails to recognize a trailing slash.]) + REPLACE_FOPEN=1 + ;; + esac +]) + +AC_DEFUN([gl_FUNC_FOPEN], +[ + AC_REQUIRE([gl_FUNC_FOPEN_ITSELF]) + AC_REQUIRE([gl_FUNC_FCLOSE]) + if test $REPLACE_FCLOSE = 1; then + REPLACE_FOPEN=1 + fi +]) + +AC_DEFUN([gl_FUNC_FOPEN_GNU], +[ + AC_REQUIRE([gl_FUNC_FOPEN]) + AC_CACHE_CHECK([whether fopen supports the mode character 'x'], + [gl_cv_func_fopen_mode_x], + [rm -f conftest.x + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +int main () +{ + FILE *fp; + fp = fopen ("conftest.x", "w"); + fclose (fp); + fp = fopen ("conftest.x", "wx"); + if (fp != NULL) + /* 'x' ignored */ + return 1; + else if (errno == EEXIST) + return 0; + else + /* 'x' rejected */ + return 2; +}]])], + [gl_cv_func_fopen_mode_x=yes], + [gl_cv_func_fopen_mode_x=no], + [case "$host_os" in + # Guess yes on glibc and musl systems. + linux*-gnu* | gnu* | kfreebsd*-gnu | *-musl* | midipix*) + gl_cv_func_fopen_mode_x="guessing yes" ;; + # If we don't know, obey --enable-cross-guesses. + *) + gl_cv_func_fopen_mode_x="$gl_cross_guess_normal" ;; + esac + ]) + rm -f conftest.x + ]) + AC_CACHE_CHECK([whether fopen supports the mode character 'e'], + [gl_cv_func_fopen_mode_e], + [echo foo > conftest.x + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +#include +]GL_MDA_DEFINES[ +int main () +{ + FILE *fp = fopen ("conftest.x", "re"); + if (fp != NULL) + { + if (fcntl (fileno (fp), F_GETFD) & FD_CLOEXEC) + return 0; + else + /* 'e' ignored */ + return 1; + } + else + /* 'e' rejected */ + return 2; +}]])], + [gl_cv_func_fopen_mode_e=yes], + [gl_cv_func_fopen_mode_e=no], + [case "$host_os" in + # Guess yes on glibc and musl systems. + linux*-gnu* | gnu* | kfreebsd*-gnu | *-musl* | midipix*) + gl_cv_func_fopen_mode_e="guessing yes" ;; + # Guess no on native Windows. + mingw* | windows*) + gl_cv_func_fopen_mode_e="guessing no" ;; + # If we don't know, obey --enable-cross-guesses. + *) + gl_cv_func_fopen_mode_e="$gl_cross_guess_normal" ;; + esac + ]) + rm -f conftest.x + ]) + REPLACE_FOPEN_FOR_FOPEN_GNU="$REPLACE_FOPEN" + case "$gl_cv_func_fopen_mode_x" in + *no) REPLACE_FOPEN_FOR_FOPEN_GNU=1 ;; + esac + case "$gl_cv_func_fopen_mode_e" in + *no) REPLACE_FOPEN_FOR_FOPEN_GNU=1 ;; + esac +]) + +# Prerequisites of lib/fopen.c. +AC_DEFUN([gl_PREREQ_FOPEN], [:]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/fpieee.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/fpieee.m4 new file mode 100644 index 00000000..239cf4a7 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/fpieee.m4 @@ -0,0 +1,54 @@ +# fpieee.m4 serial 2 -*- coding: utf-8 -*- +dnl Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl IEEE 754 standardized three items: +dnl - The formats of single-float and double-float - nowadays commonly +dnl available as 'float' and 'double' in C and C++. +dnl No autoconf test needed. +dnl - The overflow and division by zero behaviour: The result are values +dnl '±Inf' and 'NaN', rather than exceptions as it was before. +dnl This file provides an autoconf macro for ensuring this behaviour of +dnl floating-point operations. +dnl - A set of conditions (overflow, underflow, inexact, etc.) which can +dnl be configured to trigger an exception. +dnl This cannot be done in a portable way: it depends on the compiler, +dnl libc, kernel, and CPU. No autoconf macro is provided for this. + +dnl Ensure non-trapping behaviour of floating-point overflow and +dnl floating-point division by zero. +dnl (For integer overflow, see gcc's -ftrapv option; for integer division by +dnl zero, see the autoconf macro in intdiv0.m4.) + +AC_DEFUN([gl_FP_IEEE], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) + # IEEE behaviour is the default on all CPUs except Alpha and SH + # (according to the test results of Bruno Haible's ieeefp/fenv_default.m4 + # and the GCC 4.1.2 manual). + case "$host_cpu" in + alpha*) + # On Alpha systems, a compiler option provides the behaviour. + # See the ieee(3) manual page, also available at + # + if test -n "$GCC"; then + # GCC has the option -mieee. + # For full IEEE compliance (rarely needed), use option -mieee-with-inexact. + CPPFLAGS="$CPPFLAGS -mieee" + else + # Compaq (ex-DEC) C has the option -ieee, equivalent to -ieee_with_no_inexact. + # For full IEEE compliance (rarely needed), use option -ieee_with_inexact. + CPPFLAGS="$CPPFLAGS -ieee" + fi + ;; + sh*) + if test -n "$GCC"; then + # GCC has the option -mieee. + CPPFLAGS="$CPPFLAGS -mieee" + fi + ;; + esac +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/free.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/free.m4 new file mode 100644 index 00000000..4f6dc2e2 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/free.m4 @@ -0,0 +1,52 @@ +# free.m4 serial 6 +# Copyright (C) 2003-2005, 2009-2024 Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# Written by Paul Eggert and Bruno Haible. + +AC_DEFUN([gl_FUNC_FREE], +[ + AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) + + dnl In the next release of POSIX, free must preserve errno. + dnl https://www.austingroupbugs.net/view.php?id=385 + dnl https://sourceware.org/bugzilla/show_bug.cgi?id=17924 + dnl So far, we know of three platforms that do this: + dnl * glibc >= 2.33, thanks to the fix for this bug: + dnl + dnl * OpenBSD >= 4.5, thanks to this commit: + dnl + dnl * Solaris, because its malloc() implementation is based on brk(), + dnl not mmap(); hence its free() implementation makes no system calls. + dnl For other platforms, you can only be sure if they state it in their + dnl documentation, or by code inspection of the free() implementation in libc. + AC_CACHE_CHECK([whether free is known to preserve errno], + [gl_cv_func_free_preserves_errno], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include + ]], + [[#if 2 < __GLIBC__ + (33 <= __GLIBC_MINOR__) + #elif defined __OpenBSD__ + #elif defined __sun + #else + #error "'free' is not known to preserve errno" + #endif + ]])], + [gl_cv_func_free_preserves_errno=yes], + [gl_cv_func_free_preserves_errno=no]) + ]) + + case $gl_cv_func_free_preserves_errno in + *yes) + AC_DEFINE([HAVE_FREE_POSIX], [1], + [Define if the 'free' function is guaranteed to preserve errno.]) + ;; + *) REPLACE_FREE=1 ;; + esac +]) + +# Prerequisites of lib/free.c. +AC_DEFUN([gl_PREREQ_FREE], [:]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/freopen.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/freopen.m4 new file mode 100644 index 00000000..2edf10fc --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/freopen.m4 @@ -0,0 +1,40 @@ +# freopen.m4 serial 8 +dnl Copyright (C) 2007-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_FREOPEN], +[ + AC_REQUIRE([gl_STDIO_H_DEFAULTS]) + AC_REQUIRE([AC_CANONICAL_HOST]) + case "$host_os" in + mingw* | windows* | pw* | os2*) + REPLACE_FREOPEN=1 + ;; + *) + AC_CACHE_CHECK([whether freopen works on closed fds], + [gl_cv_func_freopen_works_on_closed], + [AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [[#include + #include + ]GL_MDA_DEFINES], + [[close (0); + return !(freopen ("/dev/null", "r", stdin) + && getchar () == EOF + && !ferror (stdin) && feof (stdin));]])], + [gl_cv_func_freopen_works_on_closed=yes], + [gl_cv_func_freopen_works_on_closed=no], + [case $host_os in + *gnu*) gl_cv_func_freopen_works_on_closed="guessing no" ;; + *) gl_cv_func_freopen_works_on_closed="guessing yes";; + esac])]) + case $gl_cv_func_freopen_works_on_closed in + *no) REPLACE_FREOPEN=1;; + esac + esac +]) + +# Prerequisites of lib/freopen.c. +AC_DEFUN([gl_PREREQ_FREOPEN], [:]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/fstat.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/fstat.m4 new file mode 100644 index 00000000..5e73b4ed --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/fstat.m4 @@ -0,0 +1,40 @@ +# fstat.m4 serial 10 +dnl Copyright (C) 2011-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_FSTAT], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS]) + + case "$host_os" in + darwin* | mingw* | windows* | solaris*) + dnl macOS and Solaris stat can return a negative tv_nsec. + dnl On MinGW, the original stat() returns st_atime, st_mtime, + dnl st_ctime values that are affected by the time zone. + REPLACE_FSTAT=1 + ;; + esac + + dnl Replace fstat() for supporting the gnulib-defined open() on directories. + m4_ifdef([gl_FUNC_FCHDIR], [ + gl_TEST_FCHDIR + if test $HAVE_FCHDIR = 0; then + case "$gl_cv_func_open_directory_works" in + *yes) ;; + *) + REPLACE_FSTAT=1 + ;; + esac + fi + ]) +]) + +# Prerequisites of lib/fstat.c and lib/stat-w32.c. +AC_DEFUN([gl_PREREQ_FSTAT], [ + AC_REQUIRE([gl_SYS_STAT_H]) + AC_REQUIRE([gl_PREREQ_STAT_W32]) + : +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/fstatat.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/fstatat.m4 new file mode 100644 index 00000000..c22569b7 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/fstatat.m4 @@ -0,0 +1,65 @@ +# fstatat.m4 serial 5 +dnl Copyright (C) 2004-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +# Written by Jim Meyering. + +# If we have the fstatat function, and it has the bug (in AIX 7.1) +# that it does not fill in st_size correctly, use the replacement function. +AC_DEFUN([gl_FUNC_FSTATAT], +[ + AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS]) + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + AC_REQUIRE([gl_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK]) + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_CHECK_FUNCS_ONCE([fstatat]) + + if test $ac_cv_func_fstatat = no; then + HAVE_FSTATAT=0 + else + dnl Test for an AIX 7.1 bug; see + dnl . + AC_CACHE_CHECK([whether fstatat (..., 0) works], + [gl_cv_func_fstatat_zero_flag], + [AC_RUN_IFELSE( + [AC_LANG_SOURCE( + [[ + #include + #include + int + main (void) + { + struct stat a; + return fstatat (AT_FDCWD, ".", &a, 0) != 0; + } + ]])], + [gl_cv_func_fstatat_zero_flag=yes], + [gl_cv_func_fstatat_zero_flag=no], + [case "$host_os" in + aix*) gl_cv_func_fstatat_zero_flag="guessing no";; + *) gl_cv_func_fstatat_zero_flag="guessing yes";; + esac + ]) + ]) + + case $gl_cv_func_fstatat_zero_flag+$gl_cv_func_lstat_dereferences_slashed_symlink in + *yes+*yes) ;; + *) REPLACE_FSTATAT=1 ;; + esac + + case $host_os in + darwin* | solaris*) + REPLACE_FSTATAT=1 ;; + esac + + case $REPLACE_FSTATAT,$gl_cv_func_fstatat_zero_flag in + 1,*yes) + AC_DEFINE([HAVE_WORKING_FSTATAT_ZERO_FLAG], [1], + [Define to 1 if fstatat (..., 0) works. + For example, it does not work in AIX 7.1.]) + ;; + esac + fi +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/ftruncate.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/ftruncate.m4 new file mode 100644 index 00000000..f547a95d --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/ftruncate.m4 @@ -0,0 +1,43 @@ +# serial 24 + +# See if we need to emulate a missing ftruncate function using _chsize. + +# Copyright (C) 2000-2001, 2003-2007, 2009-2024 Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_FTRUNCATE], +[ + AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) + gl_CHECK_FUNCS_ANDROID([ftruncate], [[#include ]]) + if test $ac_cv_func_ftruncate = yes; then + m4_ifdef([gl_LARGEFILE], [ + AC_REQUIRE([AC_CANONICAL_HOST]) + case "$host_os" in + mingw* | windows*) + dnl Native Windows, and Large File Support is requested. + dnl The MSVCRT _chsize() function only accepts a 32-bit file size, + dnl and the mingw64 ftruncate64() function is unreliable (it may + dnl delete the file, see + dnl ). + dnl Use gnulib's ftruncate() implementation instead. + REPLACE_FTRUNCATE=1 + ;; + esac + ], [ + : + ]) + else + HAVE_FTRUNCATE=0 + case "$gl_cv_onwards_func_ftruncate" in + future*) REPLACE_FTRUNCATE=1 ;; + esac + fi +]) + +# Prerequisites of lib/ftruncate.c. +AC_DEFUN([gl_PREREQ_FTRUNCATE], +[ + AC_CHECK_FUNCS([_chsize]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/getcwd.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/getcwd.m4 new file mode 100644 index 00000000..558a032f --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/getcwd.m4 @@ -0,0 +1,168 @@ +# getcwd.m4 - check for working getcwd that is compatible with glibc + +# Copyright (C) 2001, 2003-2007, 2009-2024 Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# Written by Paul Eggert. +# serial 21 + +AC_DEFUN([gl_FUNC_GETCWD_NULL], + [ + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CHECK_HEADERS_ONCE([unistd.h]) + AC_CACHE_CHECK([whether getcwd (NULL, 0) allocates memory for result], + [gl_cv_func_getcwd_null], + [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ +# include +# if HAVE_UNISTD_H +# include +# else /* on Windows with MSVC */ +# include +# endif + ]GL_MDA_DEFINES[ +# ifndef getcwd + char *getcwd (); +# endif +]], [[ +#if defined _WIN32 && ! defined __CYGWIN__ +/* mingw cwd does not start with '/', but _getcwd does allocate. + However, mingw fails to honor non-zero size. */ +#else + if (chdir ("/") != 0) + return 1; + else + { + char *f = getcwd (NULL, 0); + if (! f) + return 2; + if (f[0] != '/') + { free (f); return 3; } + if (f[1] != '\0') + { free (f); return 4; } + free (f); + return 0; + } +#endif + ]])], + [gl_cv_func_getcwd_null=yes], + [gl_cv_func_getcwd_null=no], + [[case "$host_os" in + # Guess yes on glibc systems. + *-gnu* | gnu*) gl_cv_func_getcwd_null="guessing yes";; + # Guess yes on musl systems. + *-musl*) gl_cv_func_getcwd_null="guessing yes";; + # Guess yes on systems that emulate the Linux system calls. + midipix*) gl_cv_func_getcwd_null="guessing yes";; + # Guess yes on Cygwin. + cygwin*) gl_cv_func_getcwd_null="guessing yes";; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_getcwd_null="$gl_cross_guess_normal";; + esac + ]])]) +]) + +AC_DEFUN([gl_FUNC_GETCWD_SIGNATURE], +[ + AC_CACHE_CHECK([for getcwd with POSIX signature], + [gl_cv_func_getcwd_posix_signature], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include + ]GL_MDA_DEFINES], + [[extern + #ifdef __cplusplus + "C" + #endif + char *getcwd (char *, size_t); + ]]) + ], + [gl_cv_func_getcwd_posix_signature=yes], + [gl_cv_func_getcwd_posix_signature=no]) + ]) +]) + +dnl Guarantee that getcwd will malloc with a NULL first argument. Assumes +dnl that either the system getcwd is robust, or that calling code is okay +dnl with spurious failures when run from a directory with an absolute name +dnl larger than 4k bytes. +dnl +dnl Assumes that getcwd exists; if you are worried about obsolete +dnl platforms that lacked getcwd(), then you need to use the GPL module. +AC_DEFUN([gl_FUNC_GETCWD_LGPL], +[ + AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) + AC_REQUIRE([gl_FUNC_GETCWD_NULL]) + AC_REQUIRE([gl_FUNC_GETCWD_SIGNATURE]) + + case $gl_cv_func_getcwd_null,$gl_cv_func_getcwd_posix_signature in + *yes,yes) ;; + *) + dnl Minimal replacement lib/getcwd-lgpl.c. + REPLACE_GETCWD=1 + ;; + esac +]) + +dnl Check for all known getcwd bugs; useful for a program likely to be +dnl executed from an arbitrary location. +AC_DEFUN([gl_FUNC_GETCWD], +[ + AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) + AC_REQUIRE([gl_FUNC_GETCWD_NULL]) + AC_REQUIRE([gl_FUNC_GETCWD_SIGNATURE]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + + gl_abort_bug=no + case "$host_os" in + mingw* | windows*) + gl_cv_func_getcwd_path_max=yes + ;; + *) + gl_FUNC_GETCWD_PATH_MAX + case "$gl_cv_func_getcwd_null" in + *yes) + gl_FUNC_GETCWD_ABORT_BUG([gl_abort_bug=yes]) + ;; + esac + ;; + esac + dnl Define HAVE_MINIMALLY_WORKING_GETCWD and HAVE_PARTLY_WORKING_GETCWD + dnl if appropriate. + case "$gl_cv_func_getcwd_path_max" in + *"no" | *"no, it has the AIX bug") ;; + *) + AC_DEFINE([HAVE_MINIMALLY_WORKING_GETCWD], [1], + [Define to 1 if getcwd minimally works, that is, its result can be + trusted when it succeeds.]) + ;; + esac + case "$gl_cv_func_getcwd_path_max" in + *"no, but it is partly working") + AC_DEFINE([HAVE_PARTLY_WORKING_GETCWD], [1], + [Define to 1 if getcwd works, except it sometimes fails when it + shouldn't, setting errno to ERANGE, ENAMETOOLONG, or ENOENT.]) + ;; + *"yes, but with shorter paths") + AC_DEFINE([HAVE_GETCWD_SHORTER], [1], + [Define to 1 if getcwd works, but with shorter paths + than is generally tested with the replacement.]) + ;; + esac + + if { case "$gl_cv_func_getcwd_null" in *yes) false;; *) true;; esac; } \ + || test $gl_cv_func_getcwd_posix_signature != yes \ + || { case "$gl_cv_func_getcwd_path_max" in *yes*) false;; *) true;; esac; } \ + || test $gl_abort_bug = yes; then + REPLACE_GETCWD=1 + fi +]) + +# Prerequisites of lib/getcwd.c, when full replacement is in effect. +AC_DEFUN([gl_PREREQ_GETCWD], +[ + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + AC_REQUIRE([gl_CHECK_TYPE_STRUCT_DIRENT_D_INO]) + : +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/getdtablesize.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/getdtablesize.m4 new file mode 100644 index 00000000..3b89456b --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/getdtablesize.m4 @@ -0,0 +1,63 @@ +# getdtablesize.m4 serial 8 +dnl Copyright (C) 2008-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_GETDTABLESIZE], +[ + AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_CHECK_FUNCS_ONCE([getdtablesize]) + AC_CHECK_DECLS_ONCE([getdtablesize]) + if test $ac_cv_func_getdtablesize = yes && + test $ac_cv_have_decl_getdtablesize = yes; then + AC_CACHE_CHECK([whether getdtablesize works], + [gl_cv_func_getdtablesize_works], + [dnl There are two concepts: the "maximum possible file descriptor value + 1" + dnl and the "maximum number of open file descriptors in a process". + dnl Per SUSv2 and POSIX, getdtablesize() should return the first one. + dnl On most platforms, the first and the second concept are the same. + dnl On OpenVMS, however, they are different and getdtablesize() returns + dnl the second one; thus the test below fails. But we don't care + dnl because there's no good way to write a replacement getdtablesize(). + case "$host_os" in + vms*) gl_cv_func_getdtablesize_works="no (limitation)" ;; + *) + dnl Cygwin 1.7.25 automatically increases the RLIMIT_NOFILE soft + dnl limit up to an unchangeable hard limit; all other platforms + dnl correctly require setrlimit before getdtablesize() can report + dnl a larger value. + AC_RUN_IFELSE([ + AC_LANG_PROGRAM( + [[#include ] + GL_MDA_DEFINES + ], + [[int size = getdtablesize(); + if (dup2 (0, getdtablesize()) != -1) + return 1; + if (size != getdtablesize()) + return 2; + ]])], + [gl_cv_func_getdtablesize_works=yes], + [gl_cv_func_getdtablesize_works=no], + [case "$host_os" in + cygwin*) # on cygwin 1.5.25, getdtablesize() automatically grows + gl_cv_func_getdtablesize_works="guessing no" ;; + *) gl_cv_func_getdtablesize_works="guessing yes" ;; + esac + ]) + ;; + esac + ]) + case "$gl_cv_func_getdtablesize_works" in + *yes | "no (limitation)") ;; + *) REPLACE_GETDTABLESIZE=1 ;; + esac + else + HAVE_GETDTABLESIZE=0 + fi +]) + +# Prerequisites of lib/getdtablesize.c. +AC_DEFUN([gl_PREREQ_GETDTABLESIZE], [:]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/getopt.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/getopt.m4 new file mode 100644 index 00000000..be812d84 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/getopt.m4 @@ -0,0 +1,381 @@ +# getopt.m4 serial 49 +dnl Copyright (C) 2002-2006, 2008-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +# Request a POSIX compliant getopt function. +AC_DEFUN([gl_FUNC_GETOPT_POSIX], +[ + m4_divert_text([DEFAULTS], [gl_getopt_required=POSIX]) + AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) + AC_REQUIRE([gl_GETOPT_CHECK_HEADERS]) + dnl Other modules can request the gnulib implementation of the getopt + dnl functions unconditionally, by defining gl_REPLACE_GETOPT_ALWAYS. + dnl argp.m4 does this. + m4_ifdef([gl_REPLACE_GETOPT_ALWAYS], [ + REPLACE_GETOPT=1 + ], [ + REPLACE_GETOPT=0 + if test -n "$gl_replace_getopt"; then + REPLACE_GETOPT=1 + fi + ]) + GL_GENERATE_GETOPT_H=false + GL_GENERATE_GETOPT_CDEFS_H=false + if test $REPLACE_GETOPT = 1; then + dnl Arrange for getopt.h to be created. + gl_GETOPT_SUBSTITUTE_HEADER + fi +]) + +# Request a POSIX compliant getopt function with GNU extensions (such as +# options with optional arguments) and the functions getopt_long, +# getopt_long_only. +AC_DEFUN([gl_FUNC_GETOPT_GNU], +[ + dnl Set the variable gl_getopt_required, so that all invocations of + dnl gl_GETOPT_CHECK_HEADERS in the scope of the current configure file + dnl will check for getopt with GNU extensions. + dnl This means that if one gnulib-tool invocation requests getopt-posix + dnl and another gnulib-tool invocation requests getopt-gnu, it is as if + dnl both had requested getopt-gnu. + m4_divert_text([INIT_PREPARE], [gl_getopt_required=GNU]) + + dnl No need to invoke gl_FUNC_GETOPT_POSIX here; this is automatically + dnl done through the module dependency getopt-gnu -> getopt-posix. +]) + +# Determine whether to replace the entire getopt facility. +AC_DEFUN([gl_GETOPT_CHECK_HEADERS], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_REQUIRE([AC_PROG_AWK]) dnl for awk that supports ENVIRON + + dnl Persuade Solaris to declare optarg, optind, opterr, optopt. + AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) + + gl_CHECK_NEXT_HEADERS([getopt.h]) + if test $ac_cv_header_getopt_h = yes; then + HAVE_GETOPT_H=1 + else + HAVE_GETOPT_H=0 + fi + AC_SUBST([HAVE_GETOPT_H]) + + gl_replace_getopt= + + dnl Test whether is available. + if test -z "$gl_replace_getopt" && test $gl_getopt_required = GNU; then + AC_CHECK_HEADERS([getopt.h], [], [gl_replace_getopt=yes]) + fi + + dnl Test whether the function getopt_long is available. + if test -z "$gl_replace_getopt" && test $gl_getopt_required = GNU; then + AC_CHECK_FUNCS([getopt_long_only], [], [gl_replace_getopt=yes]) + fi + + dnl POSIX 2008 does not specify leading '+' behavior, but see + dnl http://austingroupbugs.net/view.php?id=191 for a recommendation on + dnl the next version of POSIX. For now, we only guarantee leading '+' + dnl behavior with getopt-gnu. + if test -z "$gl_replace_getopt"; then + AC_CACHE_CHECK([whether getopt is POSIX compatible], + [gl_cv_func_getopt_posix], + [ + dnl Merging these three different test programs into a single one + dnl would require a reset mechanism. On BSD systems, it can be done + dnl through 'optreset'; on some others (glibc), it can be done by + dnl setting 'optind' to 0; on others again (HP-UX, IRIX, OSF/1, + dnl Solaris 9, musl libc), there is no such mechanism. + if test $cross_compiling = no; then + dnl Sanity check. Succeeds everywhere (except on MSVC, + dnl which lacks and getopt() entirely). + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +#include + +int +main () +{ + static char program[] = "program"; + static char a[] = "-a"; + static char foo[] = "foo"; + static char bar[] = "bar"; + char *argv[] = { program, a, foo, bar, NULL }; + int c; + + c = getopt (4, argv, "ab"); + if (!(c == 'a')) + return 1; + c = getopt (4, argv, "ab"); + if (!(c == -1)) + return 2; + if (!(optind == 2)) + return 3; + return 0; +} +]])], + [gl_cv_func_getopt_posix=maybe], + [gl_cv_func_getopt_posix=no]) + if test $gl_cv_func_getopt_posix = maybe; then + dnl Sanity check with '+'. Succeeds everywhere (except on MSVC, + dnl which lacks and getopt() entirely). + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +#include + +int +main () +{ + static char program[] = "program"; + static char donald[] = "donald"; + static char p[] = "-p"; + static char billy[] = "billy"; + static char duck[] = "duck"; + static char a[] = "-a"; + static char bar[] = "bar"; + char *argv[] = { program, donald, p, billy, duck, a, bar, NULL }; + int c; + + c = getopt (7, argv, "+abp:q:"); + if (!(c == -1)) + return 4; + if (!(strcmp (argv[0], "program") == 0)) + return 5; + if (!(strcmp (argv[1], "donald") == 0)) + return 6; + if (!(strcmp (argv[2], "-p") == 0)) + return 7; + if (!(strcmp (argv[3], "billy") == 0)) + return 8; + if (!(strcmp (argv[4], "duck") == 0)) + return 9; + if (!(strcmp (argv[5], "-a") == 0)) + return 10; + if (!(strcmp (argv[6], "bar") == 0)) + return 11; + if (!(optind == 1)) + return 12; + return 0; +} +]])], + [gl_cv_func_getopt_posix=maybe], + [gl_cv_func_getopt_posix=no]) + fi + if test $gl_cv_func_getopt_posix = maybe; then + dnl Detect Mac OS X 10.5, AIX 7.1, mingw bug. + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +#include + +int +main () +{ + static char program[] = "program"; + static char ab[] = "-ab"; + char *argv[3] = { program, ab, NULL }; + if (getopt (2, argv, "ab:") != 'a') + return 13; + if (getopt (2, argv, "ab:") != '?') + return 14; + if (optopt != 'b') + return 15; + if (optind != 2) + return 16; + return 0; +} +]])], + [gl_cv_func_getopt_posix=yes], + [gl_cv_func_getopt_posix=no]) + fi + else + case "$host_os" in + darwin* | aix* | mingw* | windows*) gl_cv_func_getopt_posix="guessing no";; + *) gl_cv_func_getopt_posix="guessing yes";; + esac + fi + ]) + case "$gl_cv_func_getopt_posix" in + *no) gl_replace_getopt=yes ;; + esac + fi + + if test -z "$gl_replace_getopt" && test $gl_getopt_required = GNU; then + AC_CACHE_CHECK([for working GNU getopt function], [gl_cv_func_getopt_gnu], + [# Even with POSIXLY_CORRECT, the GNU extension of leading '-' in the + # optstring is necessary for programs like m4 that have POSIX-mandated + # semantics for supporting options interspersed with files. + # Also, since getopt_long is a GNU extension, we require optind=0. + # Bash ties 'set -o posix' to a non-exported POSIXLY_CORRECT; + # so take care to revert to the correct (non-)export state. +dnl GNU Coding Standards currently allow awk but not env; besides, env +dnl is ambiguous with environment values that contain newlines. + gl_awk_probe='BEGIN { if ("POSIXLY_CORRECT" in ENVIRON) print "x" }' + case ${POSIXLY_CORRECT+x}`$AWK "$gl_awk_probe" + #include + #include + ]GL_NOCRASH[ + ]], [[ + int result = 0; + + nocrash_init(); + + /* This code succeeds on glibc 2.8, OpenBSD 4.0, Cygwin, mingw, + and fails on Mac OS X 10.5, AIX 5.2, HP-UX 11, IRIX 6.5, + OSF/1 5.1, Solaris 10. */ + { + static char conftest[] = "conftest"; + static char plus[] = "-+"; + char *argv[3] = { conftest, plus, NULL }; + opterr = 0; + if (getopt (2, argv, "+a") != '?') + result |= 1; + } + /* This code succeeds on glibc 2.8, mingw, + and fails on Mac OS X 10.5, OpenBSD 4.0, AIX 5.2, HP-UX 11, + IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin 1.5.x. */ + { + static char program[] = "program"; + static char p[] = "-p"; + static char foo[] = "foo"; + static char bar[] = "bar"; + char *argv[] = { program, p, foo, bar, NULL }; + + optind = 1; + if (getopt (4, argv, "p::") != 'p') + result |= 2; + else if (optarg != NULL) + result |= 4; + else if (getopt (4, argv, "p::") != -1) + result |= 6; + else if (optind != 2) + result |= 8; + } + /* This code succeeds on glibc 2.8 and fails on Cygwin 1.7.0. */ + { + static char program[] = "program"; + static char foo[] = "foo"; + static char p[] = "-p"; + char *argv[] = { program, foo, p, NULL }; + optind = 0; + if (getopt (3, argv, "-p") != 1) + result |= 16; + else if (getopt (3, argv, "-p") != 'p') + result |= 16; + } + /* This code fails on glibc 2.11. */ + { + static char program[] = "program"; + static char b[] = "-b"; + static char a[] = "-a"; + char *argv[] = { program, b, a, NULL }; + optind = opterr = 0; + if (getopt (3, argv, "+:a:b") != 'b') + result |= 32; + else if (getopt (3, argv, "+:a:b") != ':') + result |= 32; + } + /* This code dumps core on glibc 2.14. */ + { + static char program[] = "program"; + static char w[] = "-W"; + static char dummy[] = "dummy"; + char *argv[] = { program, w, dummy, NULL }; + optind = opterr = 1; + if (getopt (3, argv, "W;") != 'W') + result |= 64; + } + return result; + ]])], + [gl_cv_func_getopt_gnu=yes], + [gl_cv_func_getopt_gnu=no], + [dnl Cross compiling. + dnl Assume the worst, even on glibc platforms. + dnl But obey --enable-cross-guesses. + gl_cv_func_getopt_gnu="$gl_cross_guess_normal" + ]) + case $gl_had_POSIXLY_CORRECT in + exported) ;; + yes) AS_UNSET([POSIXLY_CORRECT]); POSIXLY_CORRECT=1 ;; + *) AS_UNSET([POSIXLY_CORRECT]) ;; + esac + ]) + if test "$gl_cv_func_getopt_gnu" != yes; then + gl_replace_getopt=yes + else + AC_CACHE_CHECK([for working GNU getopt_long function], + [gl_cv_func_getopt_long_gnu], + [AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [[#include + #include + #include + ]], + [[static const struct option long_options[] = + { + { "xtremely-",no_argument, NULL, 1003 }, + { "xtra", no_argument, NULL, 1001 }, + { "xtreme", no_argument, NULL, 1002 }, + { "xtremely", no_argument, NULL, 1003 }, + { NULL, 0, NULL, 0 } + }; + /* This code fails on OpenBSD 5.0. */ + { + static char program[] = "program"; + static char xtremel[] = "--xtremel"; + char *argv[] = { program, xtremel, NULL }; + int option_index; + optind = 1; opterr = 0; + if (getopt_long (2, argv, "", long_options, &option_index) != 1003) + return 1; + } + return 0; + ]])], + [gl_cv_func_getopt_long_gnu=yes], + [gl_cv_func_getopt_long_gnu=no], + [dnl Cross compiling. Guess no on OpenBSD, yes otherwise. + case "$host_os" in + openbsd*) gl_cv_func_getopt_long_gnu="guessing no";; + *) gl_cv_func_getopt_long_gnu="guessing yes";; + esac + ]) + ]) + case "$gl_cv_func_getopt_long_gnu" in + *yes) ;; + *) gl_replace_getopt=yes ;; + esac + fi + fi +]) + +AC_DEFUN([gl_GETOPT_SUBSTITUTE_HEADER], +[ + AC_CHECK_HEADERS_ONCE([sys/cdefs.h]) + if test $ac_cv_header_sys_cdefs_h = yes; then + HAVE_SYS_CDEFS_H=1 + else + HAVE_SYS_CDEFS_H=0 + fi + AC_SUBST([HAVE_SYS_CDEFS_H]) + + AC_DEFINE([__GETOPT_PREFIX], [[rpl_]], + [Define to rpl_ if the getopt replacement functions and variables + should be used.]) + GL_GENERATE_GETOPT_H=true + GL_GENERATE_GETOPT_CDEFS_H=true +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/getpagesize.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/getpagesize.m4 new file mode 100644 index 00000000..35dc257b --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/getpagesize.m4 @@ -0,0 +1,49 @@ +# getpagesize.m4 serial 11 +dnl Copyright (C) 2002, 2004-2005, 2007, 2009-2024 Free Software Foundation, +dnl Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_GETPAGESIZE], +[ + AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) + AC_REQUIRE([AC_CANONICAL_HOST]) + gl_CHECK_FUNC_GETPAGESIZE + if test $gl_cv_func_getpagesize = no; then + HAVE_GETPAGESIZE=0 + AC_CHECK_HEADERS([OS.h]) + if test $ac_cv_header_OS_h = yes; then + HAVE_OS_H=1 + fi + AC_CHECK_HEADERS([sys/param.h]) + if test $ac_cv_header_sys_param_h = yes; then + HAVE_SYS_PARAM_H=1 + fi + fi + case "$host_os" in + mingw* | windows*) + REPLACE_GETPAGESIZE=1 + ;; + esac + dnl Also check whether it's declared. + dnl mingw has getpagesize() in libgcc.a but doesn't declare it. + AC_CHECK_DECL([getpagesize], , [HAVE_DECL_GETPAGESIZE=0]) +]) + +dnl Tests whether the function getpagesize() exists. +dnl Sets gl_cv_func_getpagesize. +AC_DEFUN([gl_CHECK_FUNC_GETPAGESIZE], +[ + dnl We can't use AC_CHECK_FUNC here, because getpagesize() is defined as a + dnl static inline function when compiling for Android 4.4 or older. + AC_CACHE_CHECK([for getpagesize], [gl_cv_func_getpagesize], + [AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include ]], + [[return getpagesize();]]) + ], + [gl_cv_func_getpagesize=yes], + [gl_cv_func_getpagesize=no]) + ]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/getprogname.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/getprogname.m4 new file mode 100644 index 00000000..b8f9f230 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/getprogname.m4 @@ -0,0 +1,60 @@ +# getprogname.m4 - check for getprogname or replacements for it + +# Copyright (C) 2016-2024 Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 8 + +AC_DEFUN([gl_FUNC_GETPROGNAME], +[ + AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + gl_CHECK_FUNCS_ANDROID([getprogname], [[#include ]]) + if test $ac_cv_func_getprogname = no; then + HAVE_GETPROGNAME=0 + case "$gl_cv_onwards_func_getprogname" in + future*) REPLACE_GETPROGNAME=1 ;; + esac + fi + AC_CHECK_DECLS([program_invocation_name], + [], + [HAVE_DECL_PROGRAM_INVOCATION_NAME=0], + [[#include ]]) +]) + +AC_DEFUN([gl_PREREQ_GETPROGNAME], +[ + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + AC_CHECK_FUNCS_ONCE([getexecname]) + ac_found=0 + AC_CHECK_DECLS([program_invocation_name], [ac_found=1], [], + [#include ]) + AC_CHECK_DECLS([program_invocation_short_name], [ac_found=1], [], + [#include ]) + AC_CHECK_DECLS([__argv], [ac_found=1], [], [#include ]) + + # Incur the cost of this test only if none of the above worked. + if test $ac_found = 0; then + # On OpenBSD 5.1, using the global __progname variable appears to be + # the only way to implement getprogname. + AC_CACHE_CHECK([whether __progname is defined in default libraries], + [gl_cv_var___progname], + [ + gl_cv_var___progname= + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[extern char *__progname;]], + [[return *__progname;]] + )], + [gl_cv_var___progname=yes] + ) + ] + ) + if test "$gl_cv_var___progname" = yes; then + AC_DEFINE([HAVE_VAR___PROGNAME], 1, + [Define if you have a global __progname variable]) + fi + fi +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/getrandom.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/getrandom.m4 new file mode 100644 index 00000000..55be445c --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/getrandom.m4 @@ -0,0 +1,82 @@ +# getrandom.m4 serial 13 +dnl Copyright 2020-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl Written by Paul Eggert. + +AC_DEFUN([gl_FUNC_GETRANDOM], +[ + AC_REQUIRE([gl_SYS_RANDOM_H_DEFAULTS]) + AC_REQUIRE([AC_CANONICAL_HOST]) + + gl_CHECK_FUNCS_ANDROID([getrandom], + [[/* Additional includes are needed before on uClibc + and Mac OS X. */ + #include + #include + #include + ]]) + if test "$ac_cv_func_getrandom" != yes; then + HAVE_GETRANDOM=0 + case "$gl_cv_onwards_func_getrandom" in + future*) REPLACE_GETRANDOM=1 ;; + esac + else + dnl On Solaris 11.4 the return type is 'int', not 'ssize_t'. + AC_CACHE_CHECK([whether getrandom is compatible with its GNU+BSD signature], + [gl_cv_func_getrandom_ok], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[/* Additional includes are needed before on uClibc + and Mac OS X. */ + #include + #include + #include + ssize_t getrandom (void *, size_t, unsigned int); + ]], + [[]]) + ], + [gl_cv_func_getrandom_ok=yes], + [gl_cv_func_getrandom_ok=no]) + ]) + if test $gl_cv_func_getrandom_ok = no; then + REPLACE_GETRANDOM=1 + fi + fi + + case "$host_os" in + mingw* | windows*) + AC_CHECK_HEADERS([bcrypt.h], [], [], + [[#include + ]]) + AC_CACHE_CHECK([whether the bcrypt library is guaranteed to be present], + [gl_cv_lib_assume_bcrypt], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include ]], + [[#if !(_WIN32_WINNT >= _WIN32_WINNT_WIN7) + cannot assume it + #endif + ]]) + ], + [gl_cv_lib_assume_bcrypt=yes], + [gl_cv_lib_assume_bcrypt=no]) + ]) + if test $gl_cv_lib_assume_bcrypt = yes; then + AC_DEFINE([HAVE_LIB_BCRYPT], [1], + [Define to 1 if the bcrypt library is guaranteed to be present.]) + GETRANDOM_LIB='-lbcrypt' + else + GETRANDOM_LIB='-ladvapi32' + fi + ;; + *) + GETRANDOM_LIB= ;; + esac + AC_SUBST([GETRANDOM_LIB]) + dnl For backward compatibility. + LIB_GETRANDOM="$GETRANDOM_LIB" + AC_SUBST([LIB_GETRANDOM]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/gettime.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/gettime.m4 new file mode 100644 index 00000000..1ec018d5 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/gettime.m4 @@ -0,0 +1,68 @@ +# gettime.m4 serial 15 +dnl Copyright (C) 2002, 2004-2006, 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_GETTIME], +[ + dnl Prerequisites of lib/gettime.c. + AC_REQUIRE([gl_CLOCK_TIME]) + AC_REQUIRE([gl_TIMESPEC]) + + AC_REQUIRE([gl_CHECK_FUNC_TIMESPEC_GET]) + if test $gl_cv_func_timespec_get = yes; then + AC_DEFINE([HAVE_TIMESPEC_GET], [1], + [Define if you have the timespec_get function.]) + fi +]) + +dnl Tests whether the function timespec_get exists. +dnl Sets gl_cv_func_timespec_get and gl_cv_onwards_func_timespec_get. +AC_DEFUN([gl_CHECK_FUNC_TIMESPEC_GET], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) + + dnl Persuade OpenBSD to declare timespec_get(). + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + + dnl We can't use AC_CHECK_FUNC here, because timespec_get() is defined as a + dnl static inline function in on MSVC 14. + dnl But at the same time, we need to notice a missing declaration, like + dnl gl_CHECK_FUNCS_ANDROID does. + AC_CHECK_DECL([timespec_get], , , [[#include ]]) + AC_CACHE_CHECK([for timespec_get], [gl_cv_onwards_func_timespec_get], + [if test $ac_cv_have_decl_timespec_get = yes; then + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include + struct timespec ts; + ]], + [[return timespec_get (&ts, 0);]]) + ], + [gl_cv_onwards_func_timespec_get=yes], + [gl_cv_onwards_func_timespec_get=no]) + else + gl_cv_onwards_func_timespec_get=no + fi + case "$host_os" in + linux*-android*) + if test $gl_cv_onwards_func_timespec_get = no; then + gl_cv_onwards_func_timespec_get='future OS version' + fi + ;; + esac + ]) + case "$gl_cv_onwards_func_timespec_get" in + future*) gl_cv_func_timespec_get=no ;; + *) gl_cv_func_timespec_get=$gl_cv_onwards_func_timespec_get ;; + esac +]) + +AC_DEFUN([gl_GETTIME_RES], +[ + dnl Prerequisites of lib/gettime-res.c. + AC_REQUIRE([gl_CLOCK_TIME]) + AC_REQUIRE([gl_TIMESPEC]) + gl_CHECK_FUNCS_ANDROID([timespec_getres], [[#include ]]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/gettimeofday.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/gettimeofday.m4 new file mode 100644 index 00000000..35269914 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/gettimeofday.m4 @@ -0,0 +1,69 @@ +# serial 30 + +# Copyright (C) 2001-2003, 2005, 2007, 2009-2024 Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +dnl From Jim Meyering. + +AC_DEFUN([gl_FUNC_GETTIMEOFDAY], +[ + AC_REQUIRE([gl_SYS_TIME_H_DEFAULTS]) + AC_REQUIRE([AC_C_RESTRICT]) + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_REQUIRE([gl_SYS_TIME_H]) + AC_CHECK_FUNCS_ONCE([gettimeofday]) + + gl_gettimeofday_timezone=void + if test $ac_cv_func_gettimeofday != yes; then + HAVE_GETTIMEOFDAY=0 + else + AC_CACHE_CHECK([for gettimeofday with POSIX signature], + [gl_cv_func_gettimeofday_posix_signature], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include + struct timeval c; + int gettimeofday (struct timeval *restrict, void *restrict); + ]], + [[/* glibc uses struct timezone * rather than the POSIX void * + if _GNU_SOURCE is defined. However, since the only portable + use of gettimeofday uses NULL as the second parameter, and + since the glibc definition is actually more typesafe, it is + not worth wrapping this to get a compliant signature. */ + int (*f) (struct timeval *restrict, void *restrict) + = gettimeofday; + int x = f (&c, 0); + return !(x | c.tv_sec | c.tv_usec); + ]])], + [gl_cv_func_gettimeofday_posix_signature=yes], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include +int gettimeofday (struct timeval *restrict, struct timezone *restrict); + ]])], + [gl_cv_func_gettimeofday_posix_signature=almost], + [gl_cv_func_gettimeofday_posix_signature=no])])]) + if test $gl_cv_func_gettimeofday_posix_signature = almost; then + gl_gettimeofday_timezone='struct timezone' + elif test $gl_cv_func_gettimeofday_posix_signature != yes; then + REPLACE_GETTIMEOFDAY=1 + fi + dnl If we override 'struct timeval', we also have to override gettimeofday. + if test $REPLACE_STRUCT_TIMEVAL = 1; then + REPLACE_GETTIMEOFDAY=1 + fi + dnl On mingw, the original gettimeofday has only a precision of 15.6 + dnl milliseconds. So override it. + case "$host_os" in + mingw* | windows*) REPLACE_GETTIMEOFDAY=1 ;; + esac + fi + AC_DEFINE_UNQUOTED([GETTIMEOFDAY_TIMEZONE], [$gl_gettimeofday_timezone], + [Define this to 'void' or 'struct timezone' to match the system's + declaration of the second argument to gettimeofday.]) +]) + +# Prerequisites of lib/gettimeofday.c. +AC_DEFUN([gl_PREREQ_GETTIMEOFDAY], [:]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/gnu-make.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/gnu-make.m4 new file mode 100644 index 00000000..c8831a98 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/gnu-make.m4 @@ -0,0 +1,17 @@ +# Determine whether recent-enough GNU Make is being used. + +# Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc. + +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# Written by Paul Eggert. + +# Set GNU_MAKE if we are using a recent-enough version of GNU make. + +AC_DEFUN([gl_GNU_MAKE], +[ + AM_CONDITIONAL([GNU_MAKE], + [LC_ALL=C ${MAKE-make} --version 2>/dev/null | sed -e '2,$d' | grep GNU >/dev/null]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/gnulib-cache.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/gnulib-cache.m4 new file mode 100644 index 00000000..4ce12835 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/gnulib-cache.m4 @@ -0,0 +1,260 @@ +# Copyright (C) 2002-2024 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 +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This file 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 file. If not, see . +# +# As a special exception to the GNU General Public License, +# this file may be distributed as part of a program that +# contains a configuration script generated by Autoconf, under +# the same distribution terms as the rest of that program. +# +# Generated by gnulib-tool. +# +# This file represents the specification of how gnulib-tool is used. +# It acts as a cache: It is written and read by gnulib-tool. +# In projects that use version control, this file is meant to be put under +# version control, like the configure.ac and various Makefile.am files. + + +# Specification in the form of a command-line invocation: +# gnulib-tool --import \ +# --local-dir=gl \ +# --lib=libdiffutils \ +# --source-base=lib \ +# --m4-base=m4 \ +# --doc-base=doc \ +# --tests-base=gnulib-tests \ +# --aux-dir=build-aux \ +# --with-tests \ +# --makefile-name=gnulib.mk \ +# --no-conditional-dependencies \ +# --no-libtool \ +# --macro-prefix=gl \ +# --avoid=localename \ +# --avoid=lock-tests \ +# --avoid=setlocale \ +# announce-gen \ +# argmatch \ +# assert-h \ +# attribute \ +# binary-io \ +# builtin-expect \ +# c-ctype \ +# c-stack \ +# c32isspace \ +# c32tolower \ +# c32width \ +# careadlinkat \ +# config-h \ +# count-leading-zeros \ +# diffseq \ +# dirname \ +# do-release-commit-and-tag \ +# dup2 \ +# error \ +# exclude \ +# exitfail \ +# extensions \ +# extern-inline \ +# fcntl \ +# fdopendir \ +# file-type \ +# filenamecat \ +# flexmember \ +# fnmatch-gnu \ +# fstatat \ +# getopt-gnu \ +# gettext-h \ +# git-version-gen \ +# gitlog-to-changelog \ +# gnu-make \ +# gnu-web-doc-update \ +# gnumakefile \ +# gnupload \ +# hard-locale \ +# ialloc \ +# idx \ +# intprops \ +# inttypes \ +# isblank \ +# largefile \ +# lstat \ +# maintainer-makefile \ +# manywarnings \ +# mbrtoc32 \ +# mempcpy \ +# minmax \ +# mkstemp \ +# mktime \ +# nstrftime \ +# nullptr \ +# openat \ +# pclose \ +# perl \ +# popen \ +# progname \ +# propername-lite \ +# raise \ +# rawmemchr \ +# readdir \ +# readlinkat \ +# readme-release \ +# regex \ +# same-inode \ +# sh-quote \ +# sigaction \ +# signal \ +# sigprocmask \ +# stat \ +# stat-macros \ +# stat-time \ +# stdbool \ +# stdckdint \ +# stdint \ +# stpcpy \ +# strcase \ +# strptime \ +# strtoimax \ +# sys_wait \ +# system-quote \ +# time_rz \ +# timespec \ +# timespec_get \ +# unistd \ +# unlocked-io \ +# update-copyright \ +# verify \ +# version-etc \ +# version-etc-fsf \ +# xalloc \ +# xfreopen \ +# xmalloca \ +# xstdopen \ +# xstrtoimax \ +# year2038 + +# Specification in the form of a few gnulib-tool.m4 macro invocations: +gl_LOCAL_DIR([gl]) +gl_MODULES([ + announce-gen + argmatch + assert-h + attribute + binary-io + builtin-expect + c-ctype + c-stack + c32isspace + c32tolower + c32width + careadlinkat + config-h + count-leading-zeros + diffseq + dirname + do-release-commit-and-tag + dup2 + error + exclude + exitfail + extensions + extern-inline + fcntl + fdopendir + file-type + filenamecat + flexmember + fnmatch-gnu + fstatat + getopt-gnu + gettext-h + git-version-gen + gitlog-to-changelog + gnu-make + gnu-web-doc-update + gnumakefile + gnupload + hard-locale + ialloc + idx + intprops + inttypes + isblank + largefile + lstat + maintainer-makefile + manywarnings + mbrtoc32 + mempcpy + minmax + mkstemp + mktime + nstrftime + nullptr + openat + pclose + perl + popen + progname + propername-lite + raise + rawmemchr + readdir + readlinkat + readme-release + regex + same-inode + sh-quote + sigaction + signal + sigprocmask + stat + stat-macros + stat-time + stdbool + stdckdint + stdint + stpcpy + strcase + strptime + strtoimax + sys_wait + system-quote + time_rz + timespec + timespec_get + unistd + unlocked-io + update-copyright + verify + version-etc + version-etc-fsf + xalloc + xfreopen + xmalloca + xstdopen + xstrtoimax + year2038 +]) +gl_AVOID([localename lock-tests setlocale]) +gl_SOURCE_BASE([lib]) +gl_M4_BASE([m4]) +gl_PO_BASE([]) +gl_DOC_BASE([doc]) +gl_TESTS_BASE([gnulib-tests]) +gl_WITH_TESTS +gl_LIB([libdiffutils]) +gl_MAKEFILE_NAME([gnulib.mk]) +gl_MACRO_PREFIX([gl]) +gl_PO_DOMAIN([]) +gl_WITNESS_C_MACRO([]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/gnulib-cache.m4~ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/gnulib-cache.m4~ new file mode 100644 index 00000000..de176c13 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/gnulib-cache.m4~ @@ -0,0 +1,245 @@ +# Copyright (C) 2002-2023 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 +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This file 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 file. If not, see . +# +# As a special exception to the GNU General Public License, +# this file may be distributed as part of a program that +# contains a configuration script generated by Autoconf, under +# the same distribution terms as the rest of that program. +# +# Generated by gnulib-tool. +# +# This file represents the specification of how gnulib-tool is used. +# It acts as a cache: It is written and read by gnulib-tool. +# In projects that use version control, this file is meant to be put under +# version control, like the configure.ac and various Makefile.am files. + + +# Specification in the form of a command-line invocation: +# gnulib-tool --import --local-dir=gl \ +# --lib=libdiffutils \ +# --source-base=lib \ +# --m4-base=m4 \ +# --doc-base=doc \ +# --tests-base=gnulib-tests \ +# --aux-dir=build-aux \ +# --with-tests \ +# --makefile-name=gnulib.mk \ +# --no-conditional-dependencies \ +# --no-libtool \ +# --macro-prefix=gl \ +# --avoid=localename \ +# --avoid=lock-tests \ +# --avoid=setlocale \ +# announce-gen \ +# argmatch \ +# assert-h \ +# attribute \ +# binary-io \ +# builtin-expect \ +# c-ctype \ +# c-stack \ +# c32isspace \ +# c32tolower \ +# c32width \ +# config-h \ +# count-leading-zeros \ +# diffseq \ +# dirname \ +# do-release-commit-and-tag \ +# dup2 \ +# error \ +# exclude \ +# exitfail \ +# extensions \ +# extern-inline \ +# fcntl \ +# fdopendir \ +# file-type \ +# filenamecat \ +# flexmember \ +# fnmatch-gnu \ +# getopt-gnu \ +# gettext-h \ +# git-version-gen \ +# gitlog-to-changelog \ +# gnu-make \ +# gnu-web-doc-update \ +# gnumakefile \ +# gnupload \ +# hard-locale \ +# ialloc \ +# idx \ +# intprops \ +# inttypes \ +# isblank \ +# largefile \ +# lstat \ +# maintainer-makefile \ +# manywarnings \ +# mbrtoc32 \ +# mempcpy \ +# minmax \ +# mkstemp \ +# mktime \ +# nstrftime \ +# nullptr \ +# perl \ +# progname \ +# propername-lite \ +# raise \ +# rawmemchr \ +# readme-release \ +# regex \ +# same-inode \ +# sh-quote \ +# signal \ +# sigprocmask \ +# stat \ +# stat-macros \ +# stat-time \ +# stdbool \ +# stdckdint \ +# stdint \ +# stpcpy \ +# strcase \ +# strptime \ +# strtoimax \ +# sys_wait \ +# system-quote \ +# time_rz \ +# timespec \ +# timespec_get \ +# unistd \ +# unlocked-io \ +# update-copyright \ +# verify \ +# version-etc \ +# version-etc-fsf \ +# xalloc \ +# xfreopen \ +# xmalloca \ +# xreadlink \ +# xstdopen \ +# xstrtoimax \ +# year2038 + +# Specification in the form of a few gnulib-tool.m4 macro invocations: +gl_LOCAL_DIR([gl]) +gl_MODULES([ + announce-gen + argmatch + assert-h + attribute + binary-io + builtin-expect + c-ctype + c-stack + c32isspace + c32tolower + c32width + config-h + count-leading-zeros + diffseq + dirname + do-release-commit-and-tag + dup2 + error + exclude + exitfail + extensions + extern-inline + fcntl + fdopendir + file-type + filenamecat + flexmember + fnmatch-gnu + getopt-gnu + gettext-h + git-version-gen + gitlog-to-changelog + gnu-make + gnu-web-doc-update + gnumakefile + gnupload + hard-locale + ialloc + idx + intprops + inttypes + isblank + largefile + lstat + maintainer-makefile + manywarnings + mbrtoc32 + mempcpy + minmax + mkstemp + mktime + nstrftime + nullptr + perl + progname + propername-lite + raise + rawmemchr + readme-release + regex + same-inode + sh-quote + signal + sigprocmask + stat + stat-macros + stat-time + stdbool + stdckdint + stdint + stpcpy + strcase + strptime + strtoimax + sys_wait + system-quote + time_rz + timespec + timespec_get + unistd + unlocked-io + update-copyright + verify + version-etc + version-etc-fsf + xalloc + xfreopen + xmalloca + xreadlink + xstdopen + xstrtoimax + year2038 +]) +gl_AVOID([ localename lock-tests setlocale]) +gl_SOURCE_BASE([lib]) +gl_M4_BASE([m4]) +gl_PO_BASE([]) +gl_DOC_BASE([doc]) +gl_TESTS_BASE([gnulib-tests]) +gl_WITH_TESTS +gl_LIB([libdiffutils]) +gl_MAKEFILE_NAME([gnulib.mk]) +gl_MACRO_PREFIX([gl]) +gl_PO_DOMAIN([]) +gl_WITNESS_C_MACRO([]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/gnulib-common.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/gnulib-common.m4 new file mode 100644 index 00000000..bba6d600 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/gnulib-common.m4 @@ -0,0 +1,1462 @@ +# gnulib-common.m4 serial 89.2 +dnl Copyright (C) 2007-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_PREREQ([2.62]) + +# gl_COMMON +# is expanded unconditionally through gnulib-tool magic. +AC_DEFUN([gl_COMMON], [ + dnl Use AC_REQUIRE here, so that the code is expanded once only. + AC_REQUIRE([gl_00GNULIB]) + AC_REQUIRE([gl_COMMON_BODY]) + AC_REQUIRE([gl_ZZGNULIB]) +]) +AC_DEFUN([gl_COMMON_BODY], [ + AH_VERBATIM([0witness], +[/* Witness that has been included. */ +#define _GL_CONFIG_H_INCLUDED 1 +]) + AH_VERBATIM([_GL_GNUC_PREREQ], +[/* True if the compiler says it groks GNU C version MAJOR.MINOR. */ +#if defined __GNUC__ && defined __GNUC_MINOR__ +# define _GL_GNUC_PREREQ(major, minor) \ + ((major) < __GNUC__ + ((minor) <= __GNUC_MINOR__)) +#else +# define _GL_GNUC_PREREQ(major, minor) 0 +#endif +]) + AH_VERBATIM([_Noreturn], +[/* The _Noreturn keyword of C11. */ +#ifndef _Noreturn +# if (defined __cplusplus \ + && ((201103 <= __cplusplus && !(__GNUC__ == 4 && __GNUC_MINOR__ == 7)) \ + || (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 __clang__ && __clang_major__ < 16 \ + && defined _GL_WORK_AROUND_LLVM_BUG_59792) + /* Compile with -D_GL_WORK_AROUND_LLVM_BUG_59792 to work around + that rare LLVM bug, though you may get many false-alarm warnings. */ +# define _Noreturn +# elif ((!defined __cplusplus || defined __clang__) \ + && (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \ + || (!defined __STRICT_ANSI__ \ + && (_GL_GNUC_PREREQ (4, 7) \ + || (defined __apple_build_version__ \ + ? 6000000 <= __apple_build_version__ \ + : 3 < __clang_major__ + (5 <= __clang_minor__)))))) + /* _Noreturn works as-is. */ +# elif _GL_GNUC_PREREQ (2, 8) || defined __clang__ || 0x5110 <= __SUNPRO_C +# define _Noreturn __attribute__ ((__noreturn__)) +# elif 1200 <= (defined _MSC_VER ? _MSC_VER : 0) +# define _Noreturn __declspec (noreturn) +# else +# define _Noreturn +# endif +#endif +]) + AH_VERBATIM([isoc99_inline], +[/* Work around a bug in Apple GCC 4.0.1 build 5465: In C99 mode, it supports + the ISO C 99 semantics of 'extern inline' (unlike the GNU C semantics of + earlier versions), but does not display it by setting __GNUC_STDC_INLINE__. + __APPLE__ && __MACH__ test for Mac OS X. + __APPLE_CC__ tests for the Apple compiler and its version. + __STDC_VERSION__ tests for the C99 mode. */ +#if defined __APPLE__ && defined __MACH__ && __APPLE_CC__ >= 5465 && !defined __cplusplus && __STDC_VERSION__ >= 199901L && !defined __GNUC_STDC_INLINE__ +# define __GNUC_STDC_INLINE__ 1 +#endif]) + AH_VERBATIM([attribute], +[/* Attributes. */ +/* Define _GL_HAS_ATTRIBUTE only once, because on FreeBSD, with gcc < 5, if + gets included once again after , __has_attribute(x) + expands to 0 always, and redefining _GL_HAS_ATTRIBUTE would turn off all + attributes. */ +#ifndef _GL_HAS_ATTRIBUTE +# if (defined __has_attribute \ + && (!defined __clang_minor__ \ + || (defined __apple_build_version__ \ + ? 7000000 <= __apple_build_version__ \ + : 5 <= __clang_major__))) +# define _GL_HAS_ATTRIBUTE(attr) __has_attribute (__##attr##__) +# else +# define _GL_HAS_ATTRIBUTE(attr) _GL_ATTR_##attr +# define _GL_ATTR_alloc_size _GL_GNUC_PREREQ (4, 3) +# define _GL_ATTR_always_inline _GL_GNUC_PREREQ (3, 2) +# define _GL_ATTR_artificial _GL_GNUC_PREREQ (4, 3) +# define _GL_ATTR_cold _GL_GNUC_PREREQ (4, 3) +# define _GL_ATTR_const _GL_GNUC_PREREQ (2, 95) +# define _GL_ATTR_deprecated _GL_GNUC_PREREQ (3, 1) +# define _GL_ATTR_diagnose_if 0 +# define _GL_ATTR_error _GL_GNUC_PREREQ (4, 3) +# define _GL_ATTR_externally_visible _GL_GNUC_PREREQ (4, 1) +# define _GL_ATTR_fallthrough _GL_GNUC_PREREQ (7, 0) +# define _GL_ATTR_format _GL_GNUC_PREREQ (2, 7) +# define _GL_ATTR_leaf _GL_GNUC_PREREQ (4, 6) +# define _GL_ATTR_malloc _GL_GNUC_PREREQ (3, 0) +# ifdef _ICC +# define _GL_ATTR_may_alias 0 +# else +# define _GL_ATTR_may_alias _GL_GNUC_PREREQ (3, 3) +# endif +# define _GL_ATTR_noinline _GL_GNUC_PREREQ (3, 1) +# define _GL_ATTR_nonnull _GL_GNUC_PREREQ (3, 3) +# define _GL_ATTR_nonstring _GL_GNUC_PREREQ (8, 0) +# define _GL_ATTR_nothrow _GL_GNUC_PREREQ (3, 3) +# define _GL_ATTR_packed _GL_GNUC_PREREQ (2, 7) +# define _GL_ATTR_pure _GL_GNUC_PREREQ (2, 96) +# define _GL_ATTR_returns_nonnull _GL_GNUC_PREREQ (4, 9) +# define _GL_ATTR_sentinel _GL_GNUC_PREREQ (4, 0) +# define _GL_ATTR_unused _GL_GNUC_PREREQ (2, 7) +# define _GL_ATTR_warn_unused_result _GL_GNUC_PREREQ (3, 4) +# endif +#endif + +/* Use __has_c_attribute if available. However, do not use with + pre-C23 GCC, which can issue false positives if -Wpedantic. */ +#if (defined __has_c_attribute \ + && ! (_GL_GNUC_PREREQ (4, 6) \ + && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) <= 201710)) +# define _GL_HAVE___HAS_C_ATTRIBUTE 1 +#else +# define _GL_HAVE___HAS_C_ATTRIBUTE 0 +#endif + +/* Define if, in a function declaration, the attributes in bracket syntax + [[...]] must come before the attributes in __attribute__((...)) syntax. + If this is defined, it is best to avoid the bracket syntax, so that the + various _GL_ATTRIBUTE_* can be cumulated on the same declaration in any + order. */ +#ifdef __cplusplus +# if defined __clang__ +# define _GL_BRACKET_BEFORE_ATTRIBUTE 1 +# endif +#else +# if defined __GNUC__ && !defined __clang__ +# define _GL_BRACKET_BEFORE_ATTRIBUTE 1 +# endif +#endif +]dnl There is no _GL_ATTRIBUTE_ALIGNED; use stdalign's alignas instead. +[ +/* _GL_ATTRIBUTE_ALLOC_SIZE ((N)) declares that the Nth argument of the function + is the size of the returned memory block. + _GL_ATTRIBUTE_ALLOC_SIZE ((M, N)) declares that the Mth argument multiplied + by the Nth argument of the function is the size of the returned memory block. + */ +/* Applies to: function, pointer to function, function types. */ +#ifndef _GL_ATTRIBUTE_ALLOC_SIZE +# if _GL_HAS_ATTRIBUTE (alloc_size) +# define _GL_ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args)) +# else +# define _GL_ATTRIBUTE_ALLOC_SIZE(args) +# endif +#endif + +/* _GL_ATTRIBUTE_ALWAYS_INLINE tells that the compiler should always inline the + function and report an error if it cannot do so. */ +/* Applies to: function. */ +#ifndef _GL_ATTRIBUTE_ALWAYS_INLINE +# if _GL_HAS_ATTRIBUTE (always_inline) +# define _GL_ATTRIBUTE_ALWAYS_INLINE __attribute__ ((__always_inline__)) +# else +# define _GL_ATTRIBUTE_ALWAYS_INLINE +# endif +#endif + +/* _GL_ATTRIBUTE_ARTIFICIAL declares that the function is not important to show + in stack traces when debugging. The compiler should omit the function from + stack traces. */ +/* Applies to: function. */ +#ifndef _GL_ATTRIBUTE_ARTIFICIAL +# if _GL_HAS_ATTRIBUTE (artificial) +# define _GL_ATTRIBUTE_ARTIFICIAL __attribute__ ((__artificial__)) +# else +# define _GL_ATTRIBUTE_ARTIFICIAL +# endif +#endif + +/* _GL_ATTRIBUTE_COLD declares that the function is rarely executed. */ +/* Applies to: functions. */ +/* Avoid __attribute__ ((cold)) on MinGW; see thread starting at + . + Also, Oracle Studio 12.6 requires 'cold' not '__cold__'. */ +#ifndef _GL_ATTRIBUTE_COLD +# if _GL_HAS_ATTRIBUTE (cold) && !defined __MINGW32__ +# ifndef __SUNPRO_C +# define _GL_ATTRIBUTE_COLD __attribute__ ((__cold__)) +# else +# define _GL_ATTRIBUTE_COLD __attribute__ ((cold)) +# endif +# else +# define _GL_ATTRIBUTE_COLD +# endif +#endif + +/* _GL_ATTRIBUTE_CONST declares that it is OK for a compiler to omit duplicate + calls to the function with the same arguments. + This attribute is safe for a function that neither depends on nor affects + observable state, and always returns exactly once - e.g., does not loop + forever, and does not call longjmp. + (This attribute is stricter than _GL_ATTRIBUTE_PURE.) */ +/* Applies to: functions. */ +#ifndef _GL_ATTRIBUTE_CONST +# if _GL_HAS_ATTRIBUTE (const) +# define _GL_ATTRIBUTE_CONST __attribute__ ((__const__)) +# else +# define _GL_ATTRIBUTE_CONST +# endif +#endif + +/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers + that can be freed by passing them as the Ith argument to the + function F. + _GL_ATTRIBUTE_DEALLOC_FREE declares that the function returns pointers that + can be freed via 'free'; it can be used only after declaring 'free'. */ +/* Applies to: functions. Cannot be used on inline functions. */ +#ifndef _GL_ATTRIBUTE_DEALLOC +# if _GL_GNUC_PREREQ (11, 0) +# define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i))) +# else +# define _GL_ATTRIBUTE_DEALLOC(f, i) +# endif +#endif +/* If gnulib's or has already defined this macro, continue + to use this earlier definition, since may not have been included + yet. */ +#ifndef _GL_ATTRIBUTE_DEALLOC_FREE +# if defined __cplusplus && defined __GNUC__ && !defined __clang__ +/* Work around GCC bug */ +# define _GL_ATTRIBUTE_DEALLOC_FREE \ + _GL_ATTRIBUTE_DEALLOC ((void (*) (void *)) free, 1) +# else +# define _GL_ATTRIBUTE_DEALLOC_FREE \ + _GL_ATTRIBUTE_DEALLOC (free, 1) +# endif +#endif + +/* _GL_ATTRIBUTE_DEPRECATED: Declares that an entity is deprecated. + The compiler may warn if the entity is used. */ +/* Applies to: + - function, variable, + - struct, union, struct/union member, + - enumeration, enumeration item, + - typedef, + in C++ also: namespace, class, template specialization. */ +#ifndef _GL_ATTRIBUTE_DEPRECATED +# ifndef _GL_BRACKET_BEFORE_ATTRIBUTE +# if _GL_HAVE___HAS_C_ATTRIBUTE +# if __has_c_attribute (__deprecated__) +# define _GL_ATTRIBUTE_DEPRECATED [[__deprecated__]] +# endif +# endif +# endif +# if !defined _GL_ATTRIBUTE_DEPRECATED && _GL_HAS_ATTRIBUTE (deprecated) +# define _GL_ATTRIBUTE_DEPRECATED __attribute__ ((__deprecated__)) +# endif +# ifndef _GL_ATTRIBUTE_DEPRECATED +# define _GL_ATTRIBUTE_DEPRECATED +# endif +#endif + +/* _GL_ATTRIBUTE_ERROR(msg) requests an error if a function is called and + the function call is not optimized away. + _GL_ATTRIBUTE_WARNING(msg) requests a warning if a function is called and + the function call is not optimized away. */ +/* Applies to: functions. */ +#if !(defined _GL_ATTRIBUTE_ERROR && defined _GL_ATTRIBUTE_WARNING) +# if _GL_HAS_ATTRIBUTE (error) +# define _GL_ATTRIBUTE_ERROR(msg) __attribute__ ((__error__ (msg))) +# define _GL_ATTRIBUTE_WARNING(msg) __attribute__ ((__warning__ (msg))) +# elif _GL_HAS_ATTRIBUTE (diagnose_if) +# define _GL_ATTRIBUTE_ERROR(msg) __attribute__ ((__diagnose_if__ (1, msg, "error"))) +# define _GL_ATTRIBUTE_WARNING(msg) __attribute__ ((__diagnose_if__ (1, msg, "warning"))) +# else +# define _GL_ATTRIBUTE_ERROR(msg) +# define _GL_ATTRIBUTE_WARNING(msg) +# endif +#endif + +/* _GL_ATTRIBUTE_EXTERNALLY_VISIBLE declares that the entity should remain + visible to debuggers etc., even with '-fwhole-program'. */ +/* Applies to: functions, variables. */ +#ifndef _GL_ATTRIBUTE_EXTERNALLY_VISIBLE +# if _GL_HAS_ATTRIBUTE (externally_visible) +# define _GL_ATTRIBUTE_EXTERNALLY_VISIBLE __attribute__ ((externally_visible)) +# else +# define _GL_ATTRIBUTE_EXTERNALLY_VISIBLE +# endif +#endif + +/* _GL_ATTRIBUTE_FALLTHROUGH declares that it is not a programming mistake if + the control flow falls through to the immediately following 'case' or + 'default' label. The compiler should not warn in this case. */ +/* Applies to: Empty statement (;), inside a 'switch' statement. */ +/* Always expands to something. */ +#ifndef _GL_ATTRIBUTE_FALLTHROUGH +# if _GL_HAVE___HAS_C_ATTRIBUTE +# if __has_c_attribute (__fallthrough__) +# define _GL_ATTRIBUTE_FALLTHROUGH [[__fallthrough__]] +# endif +# endif +# if !defined _GL_ATTRIBUTE_FALLTHROUGH && _GL_HAS_ATTRIBUTE (fallthrough) +# define _GL_ATTRIBUTE_FALLTHROUGH __attribute__ ((__fallthrough__)) +# endif +# ifndef _GL_ATTRIBUTE_FALLTHROUGH +# define _GL_ATTRIBUTE_FALLTHROUGH ((void) 0) +# endif +#endif + +/* _GL_ATTRIBUTE_FORMAT ((ARCHETYPE, STRING-INDEX, FIRST-TO-CHECK)) + declares that the STRING-INDEXth function argument is a format string of + style ARCHETYPE, which is one of: + printf, gnu_printf + scanf, gnu_scanf, + strftime, gnu_strftime, + strfmon, + or the same thing prefixed and suffixed with '__'. + If FIRST-TO-CHECK is not 0, arguments starting at FIRST-TO_CHECK + are suitable for the format string. */ +/* Applies to: functions. */ +#ifndef _GL_ATTRIBUTE_FORMAT +# if _GL_HAS_ATTRIBUTE (format) +# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec)) +# else +# define _GL_ATTRIBUTE_FORMAT(spec) +# endif +#endif + +/* _GL_ATTRIBUTE_LEAF declares that if the function is called from some other + compilation unit, it executes code from that unit only by return or by + exception handling. This declaration lets the compiler optimize that unit + more aggressively. */ +/* Applies to: functions. */ +#ifndef _GL_ATTRIBUTE_LEAF +# if _GL_HAS_ATTRIBUTE (leaf) +# define _GL_ATTRIBUTE_LEAF __attribute__ ((__leaf__)) +# else +# define _GL_ATTRIBUTE_LEAF +# endif +#endif + +/* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly + allocated memory. */ +/* Applies to: functions. */ +#ifndef _GL_ATTRIBUTE_MALLOC +# if _GL_HAS_ATTRIBUTE (malloc) +# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__)) +# else +# define _GL_ATTRIBUTE_MALLOC +# endif +#endif + +/* _GL_ATTRIBUTE_MAY_ALIAS declares that pointers to the type may point to the + same storage as pointers to other types. Thus this declaration disables + strict aliasing optimization. */ +/* Applies to: types. */ +/* Oracle Studio 12.6 mishandles may_alias despite __has_attribute OK. */ +#ifndef _GL_ATTRIBUTE_MAY_ALIAS +# if _GL_HAS_ATTRIBUTE (may_alias) && !defined __SUNPRO_C +# define _GL_ATTRIBUTE_MAY_ALIAS __attribute__ ((__may_alias__)) +# else +# define _GL_ATTRIBUTE_MAY_ALIAS +# endif +#endif + +/* _GL_ATTRIBUTE_MAYBE_UNUSED declares that it is not a programming mistake if + the entity is not used. The compiler should not warn if the entity is not + used. */ +/* Applies to: + - function, variable, + - struct, union, struct/union member, + - enumeration, enumeration item, + - typedef, + in C++ also: class. */ +/* In C++ and C23, this is spelled [[__maybe_unused__]]. + GCC's syntax is __attribute__ ((__unused__)). + clang supports both syntaxes. Except that with clang ≥ 6, < 10, in C++ mode, + __has_c_attribute (__maybe_unused__) yields true but the use of + [[__maybe_unused__]] nevertheless produces a warning. */ +#ifndef _GL_ATTRIBUTE_MAYBE_UNUSED +# ifndef _GL_BRACKET_BEFORE_ATTRIBUTE +# if defined __clang__ && defined __cplusplus +# if !defined __apple_build_version__ && __clang_major__ >= 10 +# define _GL_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]] +# endif +# elif _GL_HAVE___HAS_C_ATTRIBUTE +# if __has_c_attribute (__maybe_unused__) +# define _GL_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]] +# endif +# endif +# endif +# ifndef _GL_ATTRIBUTE_MAYBE_UNUSED +# define _GL_ATTRIBUTE_MAYBE_UNUSED _GL_ATTRIBUTE_UNUSED +# endif +#endif +/* Alternative spelling of this macro, for convenience and for + compatibility with glibc/include/libc-symbols.h. */ +#define _GL_UNUSED _GL_ATTRIBUTE_MAYBE_UNUSED +/* Earlier spellings of this macro. */ +#define _UNUSED_PARAMETER_ _GL_ATTRIBUTE_MAYBE_UNUSED + +/* _GL_ATTRIBUTE_NODISCARD declares that the caller of the function should not + discard the return value. The compiler may warn if the caller does not use + the return value, unless the caller uses something like ignore_value. */ +/* Applies to: function, enumeration, class. */ +#ifndef _GL_ATTRIBUTE_NODISCARD +# ifndef _GL_BRACKET_BEFORE_ATTRIBUTE +# if defined __clang__ && defined __cplusplus + /* With clang up to 15.0.6 (at least), in C++ mode, [[__nodiscard__]] produces + a warning. + The 1000 below means a yet unknown threshold. When clang++ version X + starts supporting [[__nodiscard__]] without warning about it, you can + replace the 1000 with X. */ +# if __clang_major__ >= 1000 +# define _GL_ATTRIBUTE_NODISCARD [[__nodiscard__]] +# endif +# elif _GL_HAVE___HAS_C_ATTRIBUTE +# if __has_c_attribute (__nodiscard__) +# define _GL_ATTRIBUTE_NODISCARD [[__nodiscard__]] +# endif +# endif +# endif +# if !defined _GL_ATTRIBUTE_NODISCARD && _GL_HAS_ATTRIBUTE (warn_unused_result) +# define _GL_ATTRIBUTE_NODISCARD __attribute__ ((__warn_unused_result__)) +# endif +# ifndef _GL_ATTRIBUTE_NODISCARD +# define _GL_ATTRIBUTE_NODISCARD +# endif +#endif + +/* _GL_ATTRIBUTE_NOINLINE tells that the compiler should not inline the + function. */ +/* Applies to: functions. */ +#ifndef _GL_ATTRIBUTE_NOINLINE +# if _GL_HAS_ATTRIBUTE (noinline) +# define _GL_ATTRIBUTE_NOINLINE __attribute__ ((__noinline__)) +# else +# define _GL_ATTRIBUTE_NOINLINE +# endif +#endif + +/* _GL_ATTRIBUTE_NONNULL ((N1, N2,...)) declares that the arguments N1, N2,... + must not be NULL. + _GL_ATTRIBUTE_NONNULL () declares that all pointer arguments must not be + null. */ +/* Applies to: functions. */ +#ifndef _GL_ATTRIBUTE_NONNULL +# if _GL_HAS_ATTRIBUTE (nonnull) +# define _GL_ATTRIBUTE_NONNULL(args) __attribute__ ((__nonnull__ args)) +# else +# define _GL_ATTRIBUTE_NONNULL(args) +# endif +#endif + +/* _GL_ATTRIBUTE_NONSTRING declares that the contents of a character array is + not meant to be NUL-terminated. */ +/* Applies to: struct/union members and variables that are arrays of element + type '[[un]signed] char'. */ +#ifndef _GL_ATTRIBUTE_NONSTRING +# if _GL_HAS_ATTRIBUTE (nonstring) +# define _GL_ATTRIBUTE_NONSTRING __attribute__ ((__nonstring__)) +# else +# define _GL_ATTRIBUTE_NONSTRING +# endif +#endif + +/* There is no _GL_ATTRIBUTE_NORETURN; use _Noreturn instead. */ + +/* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions. + */ +/* Applies to: functions. */ +/* After a function's parameter list, this attribute must come first, before + other attributes. */ +#ifndef _GL_ATTRIBUTE_NOTHROW +# if defined __cplusplus +# if _GL_GNUC_PREREQ (2, 8) || __clang_major >= 4 +# if __cplusplus >= 201103L +# define _GL_ATTRIBUTE_NOTHROW noexcept (true) +# else +# define _GL_ATTRIBUTE_NOTHROW throw () +# endif +# else +# define _GL_ATTRIBUTE_NOTHROW +# endif +# else +# if _GL_HAS_ATTRIBUTE (nothrow) +# define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__)) +# else +# define _GL_ATTRIBUTE_NOTHROW +# endif +# endif +#endif + +/* _GL_ATTRIBUTE_PACKED declares: + For struct members: The member has the smallest possible alignment. + For struct, union, class: All members have the smallest possible alignment, + minimizing the memory required. */ +/* Applies to: struct members, struct, union, + in C++ also: class. */ +#ifndef _GL_ATTRIBUTE_PACKED +# if _GL_HAS_ATTRIBUTE (packed) +# define _GL_ATTRIBUTE_PACKED __attribute__ ((__packed__)) +# else +# define _GL_ATTRIBUTE_PACKED +# endif +#endif + +/* _GL_ATTRIBUTE_PURE declares that It is OK for a compiler to omit duplicate + calls to the function with the same arguments if observable state is not + changed between calls. + This attribute is safe for a function that does not affect + observable state, and always returns exactly once. + (This attribute is looser than _GL_ATTRIBUTE_CONST.) */ +/* Applies to: functions. */ +#ifndef _GL_ATTRIBUTE_PURE +# if _GL_HAS_ATTRIBUTE (pure) +# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) +# else +# define _GL_ATTRIBUTE_PURE +# endif +#endif + +/* _GL_ATTRIBUTE_RETURNS_NONNULL declares that the function's return value is + a non-NULL pointer. */ +/* Applies to: functions. */ +#ifndef _GL_ATTRIBUTE_RETURNS_NONNULL +# if _GL_HAS_ATTRIBUTE (returns_nonnull) +# define _GL_ATTRIBUTE_RETURNS_NONNULL __attribute__ ((__returns_nonnull__)) +# else +# define _GL_ATTRIBUTE_RETURNS_NONNULL +# endif +#endif + +/* _GL_ATTRIBUTE_SENTINEL(pos) declares that the variadic function expects a + trailing NULL argument. + _GL_ATTRIBUTE_SENTINEL () - The last argument is NULL (requires C99). + _GL_ATTRIBUTE_SENTINEL ((N)) - The (N+1)st argument from the end is NULL. */ +/* Applies to: functions. */ +#ifndef _GL_ATTRIBUTE_SENTINEL +# if _GL_HAS_ATTRIBUTE (sentinel) +# define _GL_ATTRIBUTE_SENTINEL(pos) __attribute__ ((__sentinel__ pos)) +# else +# define _GL_ATTRIBUTE_SENTINEL(pos) +# endif +#endif + +/* A helper macro. Don't use it directly. */ +#ifndef _GL_ATTRIBUTE_UNUSED +# if _GL_HAS_ATTRIBUTE (unused) +# define _GL_ATTRIBUTE_UNUSED __attribute__ ((__unused__)) +# else +# define _GL_ATTRIBUTE_UNUSED +# endif +#endif + +]dnl There is no _GL_ATTRIBUTE_VISIBILITY; see m4/visibility.m4 instead. +[ +/* _GL_UNUSED_LABEL; declares that it is not a programming mistake if the + immediately preceding label is not used. The compiler should not warn + if the label is not used. */ +/* Applies to: label (both in C and C++). */ +/* Note that g++ < 4.5 does not support the '__attribute__ ((__unused__)) ;' + syntax. But clang does. */ +#ifndef _GL_UNUSED_LABEL +# if !(defined __cplusplus && !_GL_GNUC_PREREQ (4, 5)) || defined __clang__ +# define _GL_UNUSED_LABEL _GL_ATTRIBUTE_UNUSED +# else +# define _GL_UNUSED_LABEL +# endif +#endif +]) + AH_VERBATIM([c_linkage], +[/* In C++, there is the concept of "language linkage", that encompasses + name mangling and function calling conventions. + The following macros start and end a block of "C" linkage. */ +#ifdef __cplusplus +# define _GL_BEGIN_C_LINKAGE extern "C" { +# define _GL_END_C_LINKAGE } +#else +# define _GL_BEGIN_C_LINKAGE +# define _GL_END_C_LINKAGE +#endif +]) + AH_VERBATIM([async_safe], +[/* The _GL_ASYNC_SAFE marker should be attached to functions that are + signal handlers (for signals other than SIGABRT, SIGPIPE) or can be + invoked from such signal handlers. Such functions have some restrictions: + * All functions that it calls should be marked _GL_ASYNC_SAFE as well, + or should be listed as async-signal-safe in POSIX + + section 2.4.3. Note that malloc(), sprintf(), and fwrite(), in + particular, are NOT async-signal-safe. + * All memory locations (variables and struct fields) that these functions + access must be marked 'volatile'. This holds for both read and write + accesses. Otherwise the compiler might optimize away stores to and + reads from such locations that occur in the program, depending on its + data flow analysis. For example, when the program contains a loop + that is intended to inspect a variable set from within a signal handler + while (!signal_occurred) + ; + the compiler is allowed to transform this into an endless loop if the + variable 'signal_occurred' is not declared 'volatile'. + Additionally, recall that: + * A signal handler should not modify errno (except if it is a handler + for a fatal signal and ends by raising the same signal again, thus + provoking the termination of the process). If it invokes a function + that may clobber errno, it needs to save and restore the value of + errno. */ +#define _GL_ASYNC_SAFE +]) + AH_VERBATIM([micro_optimizations], +[/* _GL_CMP (n1, n2) performs a three-valued comparison on n1 vs. n2, where + n1 and n2 are expressions without side effects, that evaluate to real + numbers (excluding NaN). + It returns + 1 if n1 > n2 + 0 if n1 == n2 + -1 if n1 < n2 + The naïve code (n1 > n2 ? 1 : n1 < n2 ? -1 : 0) produces a conditional + jump with nearly all GCC versions up to GCC 10. + This variant (n1 < n2 ? -1 : n1 > n2) produces a conditional with many + GCC versions up to GCC 9. + The better code (n1 > n2) - (n1 < n2) from Hacker's Delight § 2-9 + avoids conditional jumps in all GCC versions >= 3.4. */ +#define _GL_CMP(n1, n2) (((n1) > (n2)) - ((n1) < (n2))) +]) + dnl Hint which direction to take regarding cross-compilation guesses: + dnl When a user installs a program on a platform they are not intimately + dnl familiar with, --enable-cross-guesses=conservative is the appropriate + dnl choice. It implements the "If we don't know, assume the worst" principle. + dnl However, when an operating system developer (on a platform which is not + dnl yet known to gnulib) builds packages for their platform, they want to + dnl expose, not hide, possible platform bugs; in this case, + dnl --enable-cross-guesses=risky is the appropriate choice. + dnl Sets the variables + dnl gl_cross_guess_normal (to be used when 'yes' is good and 'no' is bad), + dnl gl_cross_guess_inverted (to be used when 'no' is good and 'yes' is bad). + AC_ARG_ENABLE([cross-guesses], + [AS_HELP_STRING([[--enable-cross-guesses={conservative|risky}]], + [specify policy for cross-compilation guesses])], + [if test "x$enableval" != xconservative && test "x$enableval" != xrisky; then + AC_MSG_WARN([invalid argument supplied to --enable-cross-guesses]) + enableval=conservative + fi + gl_cross_guesses="$enableval"], + [gl_cross_guesses=conservative]) + if test $gl_cross_guesses = risky; then + gl_cross_guess_normal="guessing yes" + gl_cross_guess_inverted="guessing no" + else + gl_cross_guess_normal="guessing no" + gl_cross_guess_inverted="guessing yes" + fi + dnl Preparation for running test programs: + dnl Tell glibc to write diagnostics from -D_FORTIFY_SOURCE=2 to stderr, not + dnl to /dev/tty, so they can be redirected to log files. Such diagnostics + dnl arise e.g., in the macros gl_PRINTF_DIRECTIVE_N, gl_SNPRINTF_DIRECTIVE_N. + LIBC_FATAL_STDERR_=1 + export LIBC_FATAL_STDERR_ +]) + +# gl_MODULE_INDICATOR_INIT_VARIABLE([variablename]) +# gl_MODULE_INDICATOR_INIT_VARIABLE([variablename], [initialvalue]) +# initializes the shell variable that indicates the presence of the given module +# as a C preprocessor expression. +AC_DEFUN([gl_MODULE_INDICATOR_INIT_VARIABLE], +[ + GL_MODULE_INDICATOR_PREFIX[]_[$1]=m4_if([$2], , [0], [$2]) + AC_SUBST(GL_MODULE_INDICATOR_PREFIX[]_[$1]) +]) + +# gl_MODULE_INDICATOR_CONDITION +# expands to a C preprocessor expression that evaluates to 1 or 0, depending +# whether a gnulib module that has been requested shall be considered present +# or not. +m4_define([gl_MODULE_INDICATOR_CONDITION], [1]) + +# gl_MODULE_INDICATOR_SET_VARIABLE([modulename]) +# sets the shell variable that indicates the presence of the given module to +# a C preprocessor expression that will evaluate to 1. +AC_DEFUN([gl_MODULE_INDICATOR_SET_VARIABLE], +[ + gl_MODULE_INDICATOR_SET_VARIABLE_AUX( + [GL_MODULE_INDICATOR_PREFIX[]_GNULIB_[]m4_translit([[$1]], + [abcdefghijklmnopqrstuvwxyz./-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])], + [gl_MODULE_INDICATOR_CONDITION]) +]) + +# gl_MODULE_INDICATOR_SET_VARIABLE_AUX([variable]) +# modifies the shell variable to include the gl_MODULE_INDICATOR_CONDITION. +# The shell variable's value is a C preprocessor expression that evaluates +# to 0 or 1. +AC_DEFUN([gl_MODULE_INDICATOR_SET_VARIABLE_AUX], +[ + m4_if(m4_defn([gl_MODULE_INDICATOR_CONDITION]), [1], + [ + dnl Simplify the expression VALUE || 1 to 1. + $1=1 + ], + [gl_MODULE_INDICATOR_SET_VARIABLE_AUX_OR([$1], + [gl_MODULE_INDICATOR_CONDITION])]) +]) + +# gl_MODULE_INDICATOR_SET_VARIABLE_AUX_OR([variable], [condition]) +# modifies the shell variable to include the given condition. The shell +# variable's value is a C preprocessor expression that evaluates to 0 or 1. +AC_DEFUN([gl_MODULE_INDICATOR_SET_VARIABLE_AUX_OR], +[ + dnl Simplify the expression 1 || CONDITION to 1. + if test "$[]$1" != 1; then + dnl Simplify the expression 0 || CONDITION to CONDITION. + if test "$[]$1" = 0; then + $1=$2 + else + $1="($[]$1 || $2)" + fi + fi +]) + +# gl_MODULE_INDICATOR([modulename]) +# defines a C macro indicating the presence of the given module +# in a location where it can be used. +# | Value | Value | +# | in lib/ | in tests/ | +# --------------------------------------------+---------+-----------+ +# Module present among main modules: | 1 | 1 | +# --------------------------------------------+---------+-----------+ +# Module present among tests-related modules: | 0 | 1 | +# --------------------------------------------+---------+-----------+ +# Module not present at all: | 0 | 0 | +# --------------------------------------------+---------+-----------+ +AC_DEFUN([gl_MODULE_INDICATOR], +[ + AC_DEFINE_UNQUOTED([GNULIB_]m4_translit([[$1]], + [abcdefghijklmnopqrstuvwxyz./-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ___]), + [gl_MODULE_INDICATOR_CONDITION], + [Define to a C preprocessor expression that evaluates to 1 or 0, + depending whether the gnulib module $1 shall be considered present.]) +]) + +# gl_MODULE_INDICATOR_FOR_TESTS([modulename]) +# defines a C macro indicating the presence of the given module +# in lib or tests. This is useful to determine whether the module +# should be tested. +# | Value | Value | +# | in lib/ | in tests/ | +# --------------------------------------------+---------+-----------+ +# Module present among main modules: | 1 | 1 | +# --------------------------------------------+---------+-----------+ +# Module present among tests-related modules: | 1 | 1 | +# --------------------------------------------+---------+-----------+ +# Module not present at all: | 0 | 0 | +# --------------------------------------------+---------+-----------+ +AC_DEFUN([gl_MODULE_INDICATOR_FOR_TESTS], +[ + AC_DEFINE([GNULIB_TEST_]m4_translit([[$1]], + [abcdefghijklmnopqrstuvwxyz./-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ___]), [1], + [Define to 1 when the gnulib module $1 should be tested.]) +]) + +# gl_ASSERT_NO_GNULIB_POSIXCHECK +# asserts that there will never be a need to #define GNULIB_POSIXCHECK. +# and thereby enables an optimization of configure and config.h. +# Used by Emacs. +AC_DEFUN([gl_ASSERT_NO_GNULIB_POSIXCHECK], +[ + dnl Override gl_WARN_ON_USE_PREPARE. + dnl But hide this definition from 'aclocal'. + AC_DEFUN([gl_W][ARN_ON_USE_PREPARE], []) +]) + +# gl_ASSERT_NO_GNULIB_TESTS +# asserts that there will be no gnulib tests in the scope of the configure.ac +# and thereby enables an optimization of config.h. +# Used by Emacs. +AC_DEFUN([gl_ASSERT_NO_GNULIB_TESTS], +[ + dnl Override gl_MODULE_INDICATOR_FOR_TESTS. + AC_DEFUN([gl_MODULE_INDICATOR_FOR_TESTS], []) +]) + +# Test whether exists. +# Set HAVE_FEATURES_H. +AC_DEFUN([gl_FEATURES_H], +[ + AC_CHECK_HEADERS_ONCE([features.h]) + if test $ac_cv_header_features_h = yes; then + HAVE_FEATURES_H=1 + else + HAVE_FEATURES_H=0 + fi + AC_SUBST([HAVE_FEATURES_H]) +]) + +# gl_PROG_CC_C99 +# Modifies the value of the shell variable CC in an attempt to make $CC +# understand ISO C99 source code. +AC_DEFUN([gl_PROG_CC_C99], +[ + dnl Just use AC_PROG_CC_C99. + dnl When AC_PROG_CC_C99 and AC_PROG_CC_STDC are used together, the substituted + dnl value of CC will contain the C99 enabling options twice. But this is only + dnl a cosmetic problem. + dnl With Autoconf >= 2.70, use AC_PROG_CC since it implies AC_PROG_CC_C99; + dnl this avoids a "warning: The macro `AC_PROG_CC_C99' is obsolete." + m4_version_prereq([2.70], + [AC_REQUIRE([AC_PROG_CC])], + [AC_REQUIRE([AC_PROG_CC_C99])]) +]) + +# gl_PROG_AR_RANLIB +# Determines the values for AR, ARFLAGS, RANLIB that fit with the compiler. +# The user can set the variables AR, ARFLAGS, RANLIB if he wants to override +# the values. +AC_DEFUN([gl_PROG_AR_RANLIB], +[ + dnl Minix 3 comes with two toolchains: The Amsterdam Compiler Kit compiler + dnl as "cc", and GCC as "gcc". They have different object file formats and + dnl library formats. In particular, the GNU binutils programs ar and ranlib + dnl produce libraries that work only with gcc, not with cc. + AC_REQUIRE([AC_PROG_CC]) + dnl The '][' hides this use from 'aclocal'. + AC_BEFORE([$0], [A][M_PROG_AR]) + AC_CACHE_CHECK([for Minix Amsterdam compiler], [gl_cv_c_amsterdam_compiler], + [ + AC_EGREP_CPP([Amsterdam], + [ +#ifdef __ACK__ +Amsterdam +#endif + ], + [gl_cv_c_amsterdam_compiler=yes], + [gl_cv_c_amsterdam_compiler=no]) + ]) + + dnl Don't compete with AM_PROG_AR's decision about AR/ARFLAGS if we are not + dnl building with __ACK__. + if test $gl_cv_c_amsterdam_compiler = yes; then + if test -z "$AR"; then + AR='cc -c.a' + fi + if test -z "$ARFLAGS"; then + ARFLAGS='-o' + fi + else + dnl AM_PROG_AR was added in automake v1.11.2. AM_PROG_AR does not AC_SUBST + dnl ARFLAGS variable (it is filed into Makefile.in directly by automake + dnl script on-demand, if not specified by ./configure of course). + dnl Don't AC_REQUIRE the AM_PROG_AR otherwise the code for __ACK__ above + dnl will be ignored. Also, pay attention to call AM_PROG_AR in else block + dnl because AM_PROG_AR is written so it could re-set AR variable even for + dnl __ACK__. It may seem like its easier to avoid calling the macro here, + dnl but we need to AC_SUBST both AR/ARFLAGS (thus those must have some good + dnl default value and automake should usually know them). + dnl + dnl The '][' hides this use from 'aclocal'. + m4_ifdef([A][M_PROG_AR], [A][M_PROG_AR], [:]) + fi + + dnl In case the code above has not helped with setting AR/ARFLAGS, use + dnl Automake-documented default values for AR and ARFLAGS, but prefer + dnl ${host}-ar over ar (useful for cross-compiling). + AC_CHECK_TOOL([AR], [ar], [ar]) + if test -z "$ARFLAGS"; then + ARFLAGS='cr' + fi + + AC_SUBST([AR]) + AC_SUBST([ARFLAGS]) + if test -z "$RANLIB"; then + if test $gl_cv_c_amsterdam_compiler = yes; then + RANLIB=':' + else + dnl Use the ranlib program if it is available. + AC_PROG_RANLIB + fi + fi + AC_SUBST([RANLIB]) +]) + +# AC_C_RESTRICT +# This definition is copied from post-2.70 Autoconf and overrides the +# AC_C_RESTRICT macro from autoconf 2.60..2.70. +m4_version_prereq([2.70.1], [], [ +AC_DEFUN([AC_C_RESTRICT], +[AC_CACHE_CHECK([for C/C++ restrict keyword], [ac_cv_c_restrict], + [ac_cv_c_restrict=no + # Put '__restrict__' first, to avoid problems with glibc and non-GCC; see: + # https://lists.gnu.org/archive/html/bug-autoconf/2016-02/msg00006.html + # Put 'restrict' last, because C++ lacks it. + for ac_kw in __restrict__ __restrict _Restrict restrict; do + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[typedef int *int_ptr; + int foo (int_ptr $ac_kw ip) { return ip[0]; } + int bar (int [$ac_kw]); /* Catch GCC bug 14050. */ + int bar (int ip[$ac_kw]) { return ip[0]; } + ]], + [[int s[1]; + int *$ac_kw t = s; + t[0] = 0; + return foo (t) + bar (t); + ]])], + [ac_cv_c_restrict=$ac_kw]) + test "$ac_cv_c_restrict" != no && break + done + ]) + AH_VERBATIM([restrict], +[/* Define to the equivalent of the C99 'restrict' keyword, or to + nothing if this is not supported. Do not define if restrict is + supported only directly. */ +#undef restrict +/* Work around a bug in older versions of Sun C++, which did not + #define __restrict__ or support _Restrict or __restrict__ + even though the corresponding Sun C compiler ended up with + "#define restrict _Restrict" or "#define restrict __restrict__" + in the previous line. This workaround can be removed once + we assume Oracle Developer Studio 12.5 (2016) or later. */ +#if defined __SUNPRO_CC && !defined __RESTRICT && !defined __restrict__ +# define _Restrict +# define __restrict__ +#endif]) + case $ac_cv_c_restrict in + restrict) ;; + no) AC_DEFINE([restrict], []) ;; + *) AC_DEFINE_UNQUOTED([restrict], [$ac_cv_c_restrict]) ;; + esac +])# AC_C_RESTRICT +]) + +# gl_BIGENDIAN +# is like AC_C_BIGENDIAN, except that it can be AC_REQUIREd. +# Note that AC_REQUIRE([AC_C_BIGENDIAN]) does not work reliably because some +# macros invoke AC_C_BIGENDIAN with arguments. +AC_DEFUN([gl_BIGENDIAN], +[ + AC_C_BIGENDIAN +]) + +# A temporary file descriptor. +# Must be less than 10, because dash 0.5.8 does not support redirections +# with multi-digit file descriptors. +m4_define([GL_TMP_FD], 9) + +# gl_SILENT(command) +# executes command, but without the normal configure output. +# This is useful when you want to invoke AC_CACHE_CHECK (or AC_CHECK_FUNC etc.) +# inside another AC_CACHE_CHECK. +AC_DEFUN([gl_SILENT], +[ + exec GL_TMP_FD>&AS_MESSAGE_FD AS_MESSAGE_FD>/dev/null + $1 + exec AS_MESSAGE_FD>&GL_TMP_FD GL_TMP_FD>&- +]) + +# gl_CACHE_VAL_SILENT(cache-id, command-to-set-it) +# is like AC_CACHE_VAL(cache-id, command-to-set-it), except that it does not +# output a spurious "(cached)" mark in the midst of other configure output. +# This macro should be used instead of AC_CACHE_VAL when it is not surrounded +# by an AC_MSG_CHECKING/AC_MSG_RESULT pair. +AC_DEFUN([gl_CACHE_VAL_SILENT], +[ + gl_SILENT([ + AC_CACHE_VAL([$1], [$2]) + ]) +]) + +# gl_CONDITIONAL(conditional, condition) +# is like AM_CONDITIONAL(conditional, condition), except that it does not +# produce an error +# configure: error: conditional "..." was never defined. +# Usually this means the macro was only invoked conditionally. +# when only invoked conditionally. Instead, in that case, both the _TRUE +# and the _FALSE case are disabled. +AC_DEFUN([gl_CONDITIONAL], +[ + pushdef([AC_CONFIG_COMMANDS_PRE], [:])dnl + AM_CONDITIONAL([$1], [$2]) + popdef([AC_CONFIG_COMMANDS_PRE])dnl + if test -z "${[$1]_TRUE}" && test -z "${[$1]_FALSE}"; then + [$1]_TRUE='#' + [$1]_FALSE='#' + fi +]) + +# gl_CC_ALLOW_WARNINGS +# sets and substitutes a variable GL_CFLAG_ALLOW_WARNINGS, to a $(CC) option +# that reverts a preceding '-Werror' option, if available. +# This is expected to be '-Wno-error' on gcc, clang (except clang/MSVC), xlclang +# and empty otherwise. +AC_DEFUN([gl_CC_ALLOW_WARNINGS], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_CACHE_CHECK([for C compiler option to allow warnings], + [gl_cv_cc_wallow], + [rm -f conftest* + echo 'int dummy;' > conftest.c + AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -c conftest.c 2>conftest1.err]) >/dev/null + AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -Wno-error -c conftest.c 2>conftest2.err]) >/dev/null + dnl Test the number of error output lines, because AIX xlc accepts the + dnl option '-Wno-error', just to produce a warning + dnl "Option -Wno-error was incorrectly specified. The option will be ignored." + dnl afterwards. + if test $? = 0 && test `wc -l < conftest1.err` = `wc -l < conftest2.err`; then + gl_cv_cc_wallow='-Wno-error' + else + gl_cv_cc_wallow=none + fi + rm -f conftest* + ]) + case "$gl_cv_cc_wallow" in + none) GL_CFLAG_ALLOW_WARNINGS='' ;; + *) GL_CFLAG_ALLOW_WARNINGS="$gl_cv_cc_wallow" ;; + esac + AC_SUBST([GL_CFLAG_ALLOW_WARNINGS]) +]) + +# gl_CXX_ALLOW_WARNINGS +# sets and substitutes a variable GL_CXXFLAG_ALLOW_WARNINGS, to a $(CC) option +# that reverts a preceding '-Werror' option, if available. +AC_DEFUN([gl_CXX_ALLOW_WARNINGS], +[ + dnl Requires AC_PROG_CXX or gl_PROG_ANSI_CXX. + if test -n "$CXX" && test "$CXX" != no; then + AC_CACHE_CHECK([for C++ compiler option to allow warnings], + [gl_cv_cxx_wallow], + [rm -f conftest* + echo 'int dummy;' > conftest.cc + AC_TRY_COMMAND([${CXX-c++} $CXXFLAGS $CPPFLAGS -c conftest.cc 2>conftest1.err]) >/dev/null + AC_TRY_COMMAND([${CXX-c++} $CXXFLAGS $CPPFLAGS -Wno-error -c conftest.cc 2>conftest2.err]) >/dev/null + dnl Test the number of error output lines, because AIX xlC accepts the + dnl option '-Wno-error', just to produce a warning + dnl "Option -Wno-error was incorrectly specified. The option will be ignored." + dnl afterwards. + if test $? = 0 && test `wc -l < conftest1.err` = `wc -l < conftest2.err`; then + gl_cv_cxx_wallow='-Wno-error' + else + gl_cv_cxx_wallow=none + fi + rm -f conftest* + ]) + case "$gl_cv_cxx_wallow" in + none) GL_CXXFLAG_ALLOW_WARNINGS='' ;; + *) GL_CXXFLAG_ALLOW_WARNINGS="$gl_cv_cxx_wallow" ;; + esac + else + GL_CXXFLAG_ALLOW_WARNINGS='' + fi + AC_SUBST([GL_CXXFLAG_ALLOW_WARNINGS]) +]) + +# gl_CC_GNULIB_WARNINGS +# sets and substitutes a variable GL_CFLAG_GNULIB_WARNINGS, to a $(CC) option +# set that enables or disables warnings as suitable for the Gnulib coding style. +AC_DEFUN([gl_CC_GNULIB_WARNINGS], +[ + AC_REQUIRE([gl_CC_ALLOW_WARNINGS]) + dnl Assume that the compiler supports -Wno-* options only if it also supports + dnl -Wno-error. + GL_CFLAG_GNULIB_WARNINGS='' + if test -n "$GL_CFLAG_ALLOW_WARNINGS"; then + dnl Enable these warning options: + dnl + dnl GCC clang + dnl -Wno-cast-qual >= 3 >= 3.9 + dnl -Wno-conversion >= 3 >= 3.9 + dnl -Wno-float-conversion >= 4.9 >= 3.9 + dnl -Wno-float-equal >= 3 >= 3.9 + dnl -Wimplicit-fallthrough >= 7 >= 3.9 + dnl -Wno-pedantic >= 4.8 >= 3.9 + dnl -Wno-sign-compare >= 3 >= 3.9 + dnl -Wno-sign-conversion >= 4.3 >= 3.9 + dnl -Wno-tautological-out-of-range-compare - >= 3.9 + dnl -Wno-type-limits >= 4.3 >= 3.9 + dnl -Wno-undef >= 3 >= 3.9 + dnl -Wno-unsuffixed-float-constants >= 4.5 + dnl -Wno-unused-function >= 3 >= 3.9 + dnl -Wno-unused-parameter >= 3 >= 3.9 + dnl + cat > conftest.c <<\EOF + #if __GNUC__ >= 3 || (__clang_major__ + (__clang_minor__ >= 9) > 3) + -Wno-cast-qual + -Wno-conversion + -Wno-float-equal + -Wno-sign-compare + -Wno-undef + -Wno-unused-function + -Wno-unused-parameter + #endif + #if __GNUC__ + (__GNUC_MINOR__ >= 9) > 4 || (__clang_major__ + (__clang_minor__ >= 9) > 3) + -Wno-float-conversion + #endif + #if __GNUC__ >= 7 || (__clang_major__ + (__clang_minor__ >= 9) > 3) + -Wimplicit-fallthrough + #endif + #if __GNUC__ + (__GNUC_MINOR__ >= 8) > 4 || (__clang_major__ + (__clang_minor__ >= 9) > 3) + -Wno-pedantic + #endif + #if 3 < __clang_major__ + (9 <= __clang_minor__) + -Wno-tautological-constant-out-of-range-compare + #endif + #if __GNUC__ + (__GNUC_MINOR__ >= 3) > 4 || (__clang_major__ + (__clang_minor__ >= 9) > 3) + -Wno-sign-conversion + -Wno-type-limits + #endif + #if __GNUC__ + (__GNUC_MINOR__ >= 5) > 4 + -Wno-unsuffixed-float-constants + #endif +EOF + gl_command="$CC $CFLAGS $CPPFLAGS -E conftest.c > conftest.out" + if AC_TRY_EVAL([gl_command]); then + gl_options=`grep -v '#' conftest.out` + for word in $gl_options; do + GL_CFLAG_GNULIB_WARNINGS="$GL_CFLAG_GNULIB_WARNINGS $word" + done + fi + rm -f conftest.c conftest.out + fi + AC_SUBST([GL_CFLAG_GNULIB_WARNINGS]) +]) + +dnl gl_CONDITIONAL_HEADER([foo.h]) +dnl takes a shell variable GL_GENERATE_FOO_H (with value true or false) as input +dnl and produces +dnl - an AC_SUBSTed variable FOO_H that is either a file name or empty, based +dnl on whether GL_GENERATE_FOO_H is true or false, +dnl - an Automake conditional GL_GENERATE_FOO_H that evaluates to the value of +dnl the shell variable GL_GENERATE_FOO_H. +AC_DEFUN([gl_CONDITIONAL_HEADER], +[ + m4_pushdef([gl_header_name], AS_TR_SH(m4_toupper($1))) + m4_pushdef([gl_generate_var], [GL_GENERATE_]AS_TR_SH(m4_toupper($1))) + m4_pushdef([gl_generate_cond], [GL_GENERATE_]AS_TR_SH(m4_toupper($1))) + case "$gl_generate_var" in + false) gl_header_name='' ;; + true) + dnl It is OK to use a .h file in lib/ from within tests/, but not vice + dnl versa. + if test -z "$gl_header_name"; then + gl_header_name="${gl_source_base_prefix}$1" + fi + ;; + *) echo "*** gl_generate_var is not set correctly" 1>&2; exit 1 ;; + esac + AC_SUBST(gl_header_name) + gl_CONDITIONAL(gl_generate_cond, [$gl_generate_var]) + m4_popdef([gl_generate_cond]) + m4_popdef([gl_generate_var]) + m4_popdef([gl_header_name]) +]) + +dnl Preparations for gl_CHECK_FUNCS_MACOS. +AC_DEFUN([gl_PREPARE_CHECK_FUNCS_MACOS], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_REQUIRE([gl_COMPILER_CLANG]) + AC_CACHE_CHECK([for compiler option needed when checking for future declarations], + [gl_cv_compiler_check_future_option], + [case "$host_os" in + dnl This is only needed on macOS. + darwin*) + if test $gl_cv_compiler_clang = yes; then + dnl Test whether the compiler supports the option + dnl '-Werror=unguarded-availability-new'. + save_ac_compile="$ac_compile" + ac_compile="$ac_compile -Werror=unguarded-availability-new" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]],[[]])], + [gl_cv_compiler_check_future_option='-Werror=unguarded-availability-new'], + [gl_cv_compiler_check_future_option=none]) + ac_compile="$save_ac_compile" + else + gl_cv_compiler_check_future_option=none + fi + ;; + *) gl_cv_compiler_check_future_option=none ;; + esac + ]) +]) + +dnl Pieces of the expansion of +dnl gl_CHECK_FUNCS_ANDROID +dnl gl_CHECK_FUNCS_MACOS +dnl gl_CHECK_FUNCS_ANDROID_MACOS + +AC_DEFUN([gl_CHECK_FUNCS_DEFAULT_CASE], +[ + *) + AC_CHECK_FUNC([$1]) + [gl_cv_onwards_func_][$1]=$[ac_cv_func_][$1] + ;; +]) + +AC_DEFUN([gl_CHECK_FUNCS_CASE_FOR_ANDROID], +[ + linux*-android*) + AC_CHECK_DECL([$1], , , [$2]) + if test $[ac_cv_have_decl_][$1] = yes; then + AC_CHECK_FUNC([[$1]]) + if test $[ac_cv_func_][$1] = yes; then + [gl_cv_onwards_func_][$1]=yes + else + dnl The function is declared but does not exist. This should not + dnl happen normally. But anyway, we know that a future version + dnl of Android will have the function. + [gl_cv_onwards_func_][$1]='future OS version' + fi + else + [gl_cv_onwards_func_][$1]='future OS version' + fi + ;; +]) + +AC_DEFUN([gl_CHECK_FUNCS_CASE_FOR_MACOS], +[ + darwin*) + if test "x$gl_cv_compiler_check_future_option" != "xnone"; then + dnl Use a compile test, not a link test. + save_ac_compile="$ac_compile" + ac_compile="$ac_compile $gl_cv_compiler_check_future_option" + save_ac_compile_for_check_decl="$ac_compile_for_check_decl" + ac_compile_for_check_decl="$ac_compile_for_check_decl $gl_cv_compiler_check_future_option" + unset [ac_cv_have_decl_][$1] + AC_CHECK_DECL([$1], , , [$2]) + ac_compile="$save_ac_compile" + ac_compile_for_check_decl="$save_ac_compile_for_check_decl" + [ac_cv_func_][$1]="$[ac_cv_have_decl_][$1]" + if test $[ac_cv_func_][$1] = yes; then + [gl_cv_onwards_func_][$1]=yes + else + unset [ac_cv_have_decl_][$1] + AC_CHECK_DECL([$1], , , [$2]) + if test $[ac_cv_have_decl_][$1] = yes; then + [gl_cv_onwards_func_][$1]='future OS version' + else + [gl_cv_onwards_func_][$1]=no + fi + fi + else + AC_CHECK_FUNC([$1]) + [gl_cv_onwards_func_][$1]=$[ac_cv_func_][$1] + fi + ;; +]) + +AC_DEFUN([gl_CHECK_FUNCS_SET_RESULTS], +[ + case "$[gl_cv_onwards_func_][$1]" in + future*) [ac_cv_func_][$1]=no ;; + *) [ac_cv_func_][$1]=$[gl_cv_onwards_func_][$1] ;; + esac + if test $[ac_cv_func_][$1] = yes; then + AC_DEFINE([HAVE_]m4_translit([[$1]], + [abcdefghijklmnopqrstuvwxyz], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ]), + [1], [Define to 1 if you have the `$1' function.]) + fi +]) + +dnl gl_CHECK_FUNCS_ANDROID([func], [[#include ]]) +dnl is like AC_CHECK_FUNCS([func]), taking into account a portability problem +dnl on Android. +dnl +dnl When code is compiled on Android, it is in the context of a certain +dnl "Android API level", which indicates the minimum version of Android on +dnl which the app can be installed. In other words, you don't compile for a +dnl specific version of Android. You compile for all versions of Android, +dnl onwards from the given API level. +dnl Thus, the question "does the OS have the function func" has three possible +dnl answers: +dnl - yes, in all versions starting from the given API level, +dnl - no, in no version, +dnl - not in the given API level, but in a later version of Android. +dnl +dnl In detail, this works as follows: +dnl If func was added to Android API level, say, 28, then the libc.so has the +dnl symbol func always, whereas the header file declares func +dnl conditionally: +dnl #if __ANDROID_API__ >= 28 +dnl ... func (...) __INTRODUCED_IN(28); +dnl #endif +dnl Thus, when compiling with "clang -target armv7a-unknown-linux-android28", +dnl the function func is declared and exists in libc. +dnl Whereas when compiling with "clang -target armv7a-unknown-linux-android27", +dnl the function func is not declared but exists in libc. +dnl +dnl This macro sets two variables: +dnl - gl_cv_onwards_func_ to yes / no / "future OS version" +dnl - ac_cv_func_ to yes / no / no +dnl The first variable allows to distinguish all three cases. +dnl The second variable is set, so that an invocation +dnl gl_CHECK_FUNCS_ANDROID([func], [[#include ]]) +dnl can be used as a drop-in replacement for +dnl AC_CHECK_FUNCS([func]). +AC_DEFUN([gl_CHECK_FUNCS_ANDROID], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_CACHE_CHECK([for [$1]], + [[gl_cv_onwards_func_][$1]], + [gl_SILENT([ + case "$host_os" in + gl_CHECK_FUNCS_CASE_FOR_ANDROID([$1], [$2]) + gl_CHECK_FUNCS_DEFAULT_CASE([$1]) + esac + ]) + ]) + gl_CHECK_FUNCS_SET_RESULTS([$1]) +]) + +dnl gl_CHECK_FUNCS_MACOS([func], [[#include ]]) +dnl is like AC_CHECK_FUNCS([func]), taking into account a portability problem +dnl on macOS. +dnl +dnl When code is compiled on macOS, it is in the context of a certain minimum +dnl macOS version, that can be set through the option '-mmacosx-version-min='. +dnl In other words, you don't compile for a specific version of macOS. You +dnl compile for all versions of macOS, onwards from the given version. +dnl Thus, the question "does the OS have the function func" has three possible +dnl answers: +dnl - yes, in all versions starting from the given version, +dnl - no, in no version, +dnl - not in the given version, but in a later version of macOS. +dnl +dnl In detail, this works as follows: +dnl If func was added to, say, macOS version 13, then the libc has the +dnl symbol func always, whereas the header file declares func +dnl conditionally with a special availability attribute: +dnl ... func (...) __attribute__((availability(macos,introduced=13.0))); +dnl Thus, when compiling with "clang mmacosx-version-min=13", there is no +dnl warning about the use of func, and the resulting binary +dnl - runs fine on macOS 13, +dnl - aborts with a dyld "Symbol not found" message on macOS 12. +dnl Whereas, when compiling with "clang mmacosx-version-min=12", there is a +dnl warning: 'func' is only available on macOS 13.0 or newer +dnl [-Wunguarded-availability-new], +dnl and the resulting binary +dnl - runs fine on macOS 13, +dnl - crashes with a SIGSEGV (signal 11) on macOS 12. +dnl +dnl This macro sets two variables: +dnl - gl_cv_onwards_func_ to yes / no / "future OS version" +dnl - ac_cv_func_ to yes / no / no +dnl The first variable allows to distinguish all three cases. +dnl The second variable is set, so that an invocation +dnl gl_CHECK_FUNCS_MACOS([func], [[#include ]]) +dnl can be used as a drop-in replacement for +dnl AC_CHECK_FUNCS([func]). +AC_DEFUN([gl_CHECK_FUNCS_MACOS], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_REQUIRE([gl_PREPARE_CHECK_FUNCS_MACOS]) + AC_CACHE_CHECK([for [$1]], + [[gl_cv_onwards_func_][$1]], + [gl_SILENT([ + case "$host_os" in + gl_CHECK_FUNCS_CASE_FOR_MACOS([$1], [$2]) + gl_CHECK_FUNCS_DEFAULT_CASE([$1]) + esac + ]) + ]) + gl_CHECK_FUNCS_SET_RESULTS([$1]) +]) + +dnl gl_CHECK_FUNCS_ANDROID_MACOS([func], [[#include ]]) +dnl is like AC_CHECK_FUNCS([func]), taking into account a portability problem +dnl on Android and on macOS. +dnl It is the combination of gl_CHECK_FUNCS_ANDROID and gl_CHECK_FUNCS_MACOS. +AC_DEFUN([gl_CHECK_FUNCS_ANDROID_MACOS], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_REQUIRE([gl_PREPARE_CHECK_FUNCS_MACOS]) + AC_CACHE_CHECK([for [$1]], + [[gl_cv_onwards_func_][$1]], + [gl_SILENT([ + case "$host_os" in + gl_CHECK_FUNCS_CASE_FOR_ANDROID([$1], [$2]) + gl_CHECK_FUNCS_CASE_FOR_MACOS([$1], [$2]) + gl_CHECK_FUNCS_DEFAULT_CASE([$1]) + esac + ]) + ]) + gl_CHECK_FUNCS_SET_RESULTS([$1]) +]) + +dnl Expands to some code for use in .c programs that, on native Windows, defines +dnl the Microsoft deprecated alias function names to the underscore-prefixed +dnl actual function names. With this macro, these function names are available +dnl without linking with '-loldnames' and without generating warnings. +dnl Usage: Use it after all system header files are included. +dnl #include <...> +dnl #include <...> +dnl ]GL_MDA_DEFINES[ +dnl ... +AC_DEFUN([GL_MDA_DEFINES],[ +AC_REQUIRE([_GL_MDA_DEFINES]) +[$gl_mda_defines] +]) +AC_DEFUN([_GL_MDA_DEFINES], +[gl_mda_defines=' +#if defined _WIN32 && !defined __CYGWIN__ +#define access _access +#define chdir _chdir +#define chmod _chmod +#define close _close +#define creat _creat +#define dup _dup +#define dup2 _dup2 +#define ecvt _ecvt +#define execl _execl +#define execle _execle +#define execlp _execlp +#define execv _execv +#define execve _execve +#define execvp _execvp +#define execvpe _execvpe +#define fcloseall _fcloseall +#define fcvt _fcvt +#define fdopen _fdopen +#define fileno _fileno +#define gcvt _gcvt +#define getcwd _getcwd +#define getpid _getpid +#define getw _getw +#define isatty _isatty +#define j0 _j0 +#define j1 _j1 +#define jn _jn +#define lfind _lfind +#define lsearch _lsearch +#define lseek _lseek +#define memccpy _memccpy +#define mkdir _mkdir +#define mktemp _mktemp +#define open _open +#define putenv _putenv +#define putw _putw +#define read _read +#define rmdir _rmdir +#define strdup _strdup +#define swab _swab +#define tempnam _tempnam +#define tzset _tzset +#define umask _umask +#define unlink _unlink +#define utime _utime +#define wcsdup _wcsdup +#define write _write +#define y0 _y0 +#define y1 _y1 +#define yn _yn +#endif +' +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/gnulib-comp.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/gnulib-comp.m4 new file mode 100644 index 00000000..27c4e1ae --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/gnulib-comp.m4 @@ -0,0 +1,3391 @@ +# DO NOT EDIT! GENERATED AUTOMATICALLY! +# Copyright (C) 2002-2024 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 +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This file 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 file. If not, see . +# +# As a special exception to the GNU General Public License, +# this file may be distributed as part of a program that +# contains a configuration script generated by Autoconf, under +# the same distribution terms as the rest of that program. +# +# Generated by gnulib-tool. +# +# This file represents the compiled summary of the specification in +# gnulib-cache.m4. It lists the computed macro invocations that need +# to be invoked from configure.ac. +# In projects that use version control, this file can be treated like +# other built files. + + +# This macro should be invoked from ./configure.ac, in the section +# "Checks for programs", right after AC_PROG_CC, and certainly before +# any checks for libraries, header files, types and library functions. +AC_DEFUN([gl_EARLY], +[ + m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace + m4_pattern_allow([^gl_ES$])dnl a valid locale name + m4_pattern_allow([^gl_LIBOBJS$])dnl a variable + m4_pattern_allow([^gl_LTLIBOBJS$])dnl a variable + + # Pre-early section. + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + AC_REQUIRE([gl_PROG_AR_RANLIB]) + + # Code from module absolute-header: + # Code from module accept: + # Code from module accept-tests: + # Code from module alignasof: + # Code from module alignasof-tests: + # Code from module alloca: + # Code from module alloca-opt: + # Code from module alloca-opt-tests: + # Code from module allocator: + # Code from module announce-gen: + # Code from module argmatch: + # Code from module argmatch-tests: + # Code from module arpa_inet: + # Code from module arpa_inet-tests: + # Code from module assert-h: + # Code from module assert-h-tests: + # Code from module assure: + # Code from module at-internal: + # Code from module atoll: + # Code from module attribute: + # Code from module basename-lgpl: + # Code from module binary-io: + # Code from module binary-io-tests: + # Code from module bind: + # Code from module bind-tests: + # Code from module bitrotate: + # Code from module bitrotate-tests: + # Code from module btoc32: + # Code from module btoc32-tests: + # Code from module btowc: + # Code from module btowc-tests: + # Code from module builtin-expect: + # Code from module c-ctype: + # Code from module c-ctype-tests: + # Code from module c-file-type: + # Code from module c-stack: + # Code from module c-stack-tests: + # Code from module c-strcase: + # Code from module c-strcase-tests: + # Code from module c-strcaseeq: + # Code from module c-strcasestr: + # Code from module c-strcasestr-tests: + # Code from module c32_apply_type_test: + # Code from module c32_apply_type_test-tests: + # Code from module c32_get_type_test: + # Code from module c32_get_type_test-tests: + # Code from module c32isalnum: + # Code from module c32isalnum-tests: + # Code from module c32isalpha: + # Code from module c32isalpha-tests: + # Code from module c32isblank: + # Code from module c32isblank-tests: + # Code from module c32iscntrl: + # Code from module c32iscntrl-tests: + # Code from module c32isdigit: + # Code from module c32isdigit-tests: + # Code from module c32isgraph: + # Code from module c32isgraph-tests: + # Code from module c32islower: + # Code from module c32islower-tests: + # Code from module c32isprint: + # Code from module c32isprint-tests: + # Code from module c32ispunct: + # Code from module c32ispunct-tests: + # Code from module c32isspace: + # Code from module c32isspace-tests: + # Code from module c32isupper: + # Code from module c32isupper-tests: + # Code from module c32isxdigit: + # Code from module c32isxdigit-tests: + # Code from module c32rtomb: + # Code from module c32rtomb-tests: + # Code from module c32tob: + # Code from module c32tolower: + # Code from module c32tolower-tests: + # Code from module c32width: + # Code from module c32width-tests: + # Code from module c99: + # Code from module calloc-gnu: + # Code from module calloc-gnu-tests: + # Code from module calloc-posix: + # Code from module careadlinkat: + # Code from module chdir: + # Code from module chdir-long: + # Code from module chdir-tests: + # Code from module clock-time: + # Code from module cloexec: + # Code from module cloexec-tests: + # Code from module close: + # Code from module close-tests: + # Code from module closedir: + # Code from module config-h: + # Code from module connect: + # Code from module connect-tests: + # Code from module count-leading-zeros: + # Code from module count-leading-zeros-tests: + # Code from module ctype: + # Code from module ctype-tests: + # Code from module diffseq: + # Code from module dirent: + # Code from module dirent-tests: + # Code from module dirfd: + # Code from module dirfd-tests: + # Code from module dirname: + # Code from module dirname-lgpl: + # Code from module dirname-tests: + # Code from module do-release-commit-and-tag: + # Code from module double-slash-root: + # Code from module dtotimespec: + # Code from module dup: + # Code from module dup-tests: + # Code from module dup2: + # Code from module dup2-tests: + # Code from module environ: + # Code from module environ-tests: + # Code from module errno: + # Code from module errno-tests: + # Code from module error: + # Code from module error-h: + # Code from module error-tests: + # Code from module exclude: + # Code from module exclude-tests: + # Code from module exitfail: + # Code from module extensions: + # Code from module extern-inline: + # Code from module fchdir: + # Code from module fchdir-tests: + # Code from module fcntl: + # Code from module fcntl-h: + # Code from module fcntl-h-tests: + # Code from module fcntl-tests: + # Code from module fd-hook: + # Code from module fd-safer-flag: + # Code from module fdopen: + # Code from module fdopen-tests: + # Code from module fdopendir: + # Code from module fdopendir-tests: + # Code from module fgetc-tests: + # Code from module file-type: + # Code from module filename: + # Code from module filenamecat: + # Code from module filenamecat-lgpl: + # Code from module filenamecat-tests: + # Code from module flexmember: + # Code from module float: + # Code from module float-tests: + # Code from module fnmatch: + # Code from module fnmatch-gnu: + # Code from module fnmatch-h: + # Code from module fnmatch-h-tests: + # Code from module fnmatch-tests: + # Code from module fopen: + # Code from module fopen-gnu: + # Code from module fopen-gnu-tests: + # Code from module fopen-tests: + # Code from module fpieee: + AC_REQUIRE([gl_FP_IEEE]) + # Code from module fpucw: + # Code from module fputc-tests: + # Code from module fread-tests: + # Code from module free-posix: + # Code from module free-posix-tests: + # Code from module freopen: + # Code from module freopen-tests: + # Code from module fstat: + # Code from module fstat-tests: + # Code from module fstatat: + # Code from module fstatat-tests: + # Code from module ftruncate: + # Code from module ftruncate-tests: + # Code from module fwrite-tests: + # Code from module gen-header: + # Code from module gendocs: + # Code from module getcwd-lgpl: + # Code from module getcwd-lgpl-tests: + # Code from module getdtablesize: + # Code from module getdtablesize-tests: + # Code from module getopt-gnu: + # Code from module getopt-gnu-tests: + # Code from module getopt-posix: + # Code from module getopt-posix-tests: + # Code from module getpagesize: + # Code from module getprogname: + # Code from module getprogname-tests: + # Code from module getrandom: + # Code from module getrandom-tests: + # Code from module gettext-h: + # Code from module gettime: + # Code from module gettimeofday: + # Code from module gettimeofday-tests: + # Code from module git-version-gen: + # Code from module gitlog-to-changelog: + # Code from module glibc-internal/dynarray: + # Code from module glibc-internal/dynarray-tests: + # Code from module gnu-make: + # Code from module gnu-web-doc-update: + # Code from module gnumakefile: + # Code from module gnupload: + # Code from module hard-locale: + # Code from module hard-locale-tests: + # Code from module hash: + # Code from module hash-pjw: + # Code from module hash-tests: + # Code from module havelib: + # Code from module host-cpu-c-abi: + # Code from module ialloc: + # Code from module idx: + # Code from module ignore-value: + # Code from module ignore-value-tests: + # Code from module include_next: + # Code from module inet_pton: + # Code from module inet_pton-tests: + # Code from module inline: + # Code from module intprops: + # Code from module intprops-tests: + # Code from module inttostr: + # Code from module inttostr-tests: + # Code from module inttypes: + # Code from module inttypes-incomplete: + # Code from module inttypes-tests: + # Code from module ioctl: + # Code from module ioctl-tests: + # Code from module isblank: + # Code from module isblank-tests: + # Code from module isnand-nolibm: + # Code from module isnand-nolibm-tests: + # Code from module isnanf-nolibm: + # Code from module isnanf-nolibm-tests: + # Code from module isnanl-nolibm: + # Code from module isnanl-nolibm-tests: + # Code from module iswblank: + # Code from module iswblank-tests: + # Code from module iswctype: + # Code from module iswctype-tests: + # Code from module iswdigit: + # Code from module iswdigit-tests: + # Code from module iswpunct: + # Code from module iswpunct-tests: + # Code from module iswxdigit: + # Code from module iswxdigit-tests: + # Code from module langinfo: + # Code from module langinfo-tests: + # Code from module largefile: + AC_REQUIRE([AC_SYS_LARGEFILE]) + # Code from module largefile-tests: + # Code from module libc-config: + # Code from module limits-h: + # Code from module limits-h-tests: + # Code from module listen: + # Code from module listen-tests: + # Code from module localcharset: + # Code from module localcharset-tests: + # Code from module locale: + # Code from module locale-tests: + # Code from module localeconv: + # Code from module localeconv-tests: + # Code from module lock: + # Code from module lstat: + # Code from module lstat-tests: + # Code from module maintainer-makefile: + # Code from module malloc-gnu: + # Code from module malloc-gnu-tests: + # Code from module malloc-posix: + # Code from module malloca: + # Code from module malloca-tests: + # Code from module manywarnings: + # Code from module math: + # Code from module math-tests: + # Code from module mbchar: + # Code from module mbrtoc32: + # Code from module mbrtoc32-tests: + # Code from module mbrtowc: + # Code from module mbrtowc-tests: + # Code from module mbscasecmp: + # Code from module mbscasecmp-tests: + # Code from module mbsinit: + # Code from module mbsinit-tests: + # Code from module mbsrtoc32s: + # Code from module mbsrtoc32s-tests: + # Code from module mbsrtowcs: + # Code from module mbsrtowcs-tests: + # Code from module mbszero: + # Code from module mbtowc: + # Code from module mbuiter: + # Code from module mbuiterf: + # Code from module memchr: + # Code from module memchr-tests: + # Code from module mempcpy: + # Code from module memrchr: + # Code from module memrchr-tests: + # Code from module minmax: + # Code from module mkdir: + # Code from module mkdir-tests: + # Code from module mkstemp: + # Code from module mktime: + # Code from module mktime-internal: + # Code from module msvc-inval: + # Code from module msvc-nothrow: + # Code from module multiarch: + # Code from module nan: + # Code from module nanosleep: + # Code from module nanosleep-tests: + # Code from module netinet_in: + # Code from module netinet_in-tests: + # Code from module nl_langinfo: + # Code from module nl_langinfo-tests: + # Code from module nocrash: + # Code from module nstrftime: + # Code from module nstrftime-tests: + # Code from module nullptr: + # Code from module nullptr-tests: + # Code from module open: + # Code from module open-tests: + # Code from module openat: + # Code from module openat-die: + # Code from module openat-h: + # Code from module openat-tests: + # Code from module opendir: + # Code from module pathmax: + # Code from module pathmax-tests: + # Code from module pclose: + # Code from module pclose-tests: + # Code from module perl: + # Code from module perror: + # Code from module perror-tests: + # Code from module pipe-posix: + # Code from module pipe-posix-tests: + # Code from module popen: + # Code from module popen-tests: + # Code from module priv-set: + # Code from module priv-set-tests: + # Code from module progname: + # Code from module propername-lite: + # Code from module pselect: + # Code from module pselect-tests: + # Code from module pthread-h: + gl_ANYTHREADLIB_EARLY + # Code from module pthread-h-tests: + # Code from module pthread-thread: + # Code from module pthread-thread-tests: + # Code from module pthread_sigmask: + # Code from module pthread_sigmask-tests: + # Code from module putenv: + # Code from module quote: + # Code from module quotearg: + # Code from module quotearg-simple: + # Code from module quotearg-simple-tests: + # Code from module raise: + # Code from module raise-tests: + # Code from module rawmemchr: + # Code from module rawmemchr-tests: + # Code from module readdir: + # Code from module readlink: + # Code from module readlink-tests: + # Code from module readlinkat: + # Code from module readlinkat-tests: + # Code from module readme-release: + # Code from module realloc-gnu: + # Code from module realloc-gnu-tests: + # Code from module realloc-posix: + # Code from module reallocarray: + # Code from module reallocarray-tests: + # Code from module regex: + # Code from module regex-tests: + # Code from module rmdir: + # Code from module rmdir-tests: + # Code from module root-uid: + # Code from module same-inode: + # Code from module save-cwd: + # Code from module sched: + # Code from module sched-tests: + # Code from module select: + # Code from module select-tests: + # Code from module setenv: + # Code from module setenv-tests: + # Code from module setlocale-null: + # Code from module setlocale-null-tests: + # Code from module setsockopt: + # Code from module setsockopt-tests: + # Code from module sh-quote: + # Code from module sh-quote-tests: + # Code from module sigaction: + # Code from module sigaction-tests: + # Code from module signal: + # Code from module signal-h: + # Code from module signal-h-tests: + # Code from module signbit: + # Code from module signbit-tests: + # Code from module signed-nan: + # Code from module signed-snan: + # Code from module sigprocmask: + # Code from module sigprocmask-tests: + # Code from module sigsegv: + # Code from module sigsegv-tests: + # Code from module size_max: + # Code from module sleep: + # Code from module sleep-tests: + # Code from module snan: + # Code from module snippet/_Noreturn: + # Code from module snippet/arg-nonnull: + # Code from module snippet/c++defs: + # Code from module snippet/warn-on-use: + # Code from module snprintf: + # Code from module snprintf-tests: + # Code from module socket: + # Code from module socketlib: + # Code from module sockets: + # Code from module sockets-tests: + # Code from module socklen: + # Code from module ssize_t: + # Code from module stat: + # Code from module stat-macros: + # Code from module stat-tests: + # Code from module stat-time: + # Code from module stat-time-tests: + # Code from module std-gnu11: + # Code from module stdarg: + dnl Some compilers (e.g., AIX 5.3 cc) need to be in c99 mode + dnl for the builtin va_copy to work. gl_PROG_CC_C99 arranges for this. + gl_PROG_CC_C99 + # Code from module stdarg-tests: + # Code from module stdbool: + # Code from module stdbool-tests: + # Code from module stdckdint: + # Code from module stdckdint-tests: + # Code from module stddef: + # Code from module stddef-tests: + # Code from module stdint: + # Code from module stdint-tests: + # Code from module stdio: + gl_STDIO_H_EARLY + # Code from module stdio-tests: + # Code from module stdlib: + # Code from module stdlib-tests: + # Code from module stdopen: + # Code from module stpcpy: + # Code from module strcase: + # Code from module strdup-posix: + # Code from module streq: + # Code from module strerror: + # Code from module strerror-override: + # Code from module strerror-tests: + # Code from module strerror_r-posix: + # Code from module strerror_r-posix-tests: + # Code from module string: + # Code from module string-tests: + # Code from module strings: + # Code from module strings-tests: + # Code from module strnlen: + # Code from module strnlen-tests: + # Code from module strnlen1: + # Code from module strptime: + # Code from module strtoimax: + # Code from module strtoimax-tests: + # Code from module strtoll: + # Code from module strtoll-tests: + # Code from module symlink: + # Code from module symlink-tests: + # Code from module symlinkat: + # Code from module symlinkat-tests: + # Code from module sys_ioctl: + # Code from module sys_ioctl-tests: + # Code from module sys_random: + # Code from module sys_random-tests: + # Code from module sys_select: + # Code from module sys_select-tests: + # Code from module sys_socket: + # Code from module sys_socket-tests: + # Code from module sys_stat: + # Code from module sys_stat-tests: + # Code from module sys_time: + # Code from module sys_time-tests: + # Code from module sys_types: + # Code from module sys_types-tests: + # Code from module sys_uio: + # Code from module sys_uio-tests: + # Code from module sys_wait: + # Code from module sys_wait-tests: + # Code from module system-quote: + # Code from module tempname: + # Code from module test-framework-sh: + # Code from module test-framework-sh-tests: + # Code from module thread: + # Code from module thread-tests: + # Code from module threadlib: + gl_THREADLIB_EARLY + # Code from module time: + # Code from module time-h: + # Code from module time-h-tests: + # Code from module time-tests: + # Code from module time_r: + # Code from module time_rz: + # Code from module timegm: + # Code from module timespec: + # Code from module timespec-add: + # Code from module timespec-sub: + # Code from module timespec-tests: + # Code from module timespec_get: + # Code from module timespec_get-tests: + # Code from module tzset: + # Code from module uchar: + # Code from module uchar-tests: + # Code from module unicase/base: + # Code from module unicase/tolower: + # Code from module unicase/tolower-tests: + # Code from module unictype/base: + # Code from module unictype/ctype-alnum: + # Code from module unictype/ctype-alnum-tests: + # Code from module unictype/ctype-alpha: + # Code from module unictype/ctype-alpha-tests: + # Code from module unictype/ctype-blank: + # Code from module unictype/ctype-blank-tests: + # Code from module unictype/ctype-cntrl: + # Code from module unictype/ctype-cntrl-tests: + # Code from module unictype/ctype-digit: + # Code from module unictype/ctype-digit-tests: + # Code from module unictype/ctype-graph: + # Code from module unictype/ctype-graph-tests: + # Code from module unictype/ctype-lower: + # Code from module unictype/ctype-lower-tests: + # Code from module unictype/ctype-print: + # Code from module unictype/ctype-print-tests: + # Code from module unictype/ctype-punct: + # Code from module unictype/ctype-punct-tests: + # Code from module unictype/ctype-space: + # Code from module unictype/ctype-space-tests: + # Code from module unictype/ctype-upper: + # Code from module unictype/ctype-upper-tests: + # Code from module unictype/ctype-xdigit: + # Code from module unictype/ctype-xdigit-tests: + # Code from module uninorm/base: + # Code from module unistd: + # Code from module unistd-safer: + # Code from module unistd-safer-tests: + # Code from module unistd-tests: + # Code from module unistr/base: + # Code from module unistr/u32-chr: + # Code from module unistr/u32-chr-tests: + # Code from module unistr/u32-cpy: + # Code from module unistr/u32-cpy-tests: + # Code from module unistr/u32-pcpy: + # Code from module unistr/u32-pcpy-tests: + # Code from module unistr/u32-set: + # Code from module unistr/u32-set-tests: + # Code from module unistr/u32-strcat: + # Code from module unistr/u32-strcat-tests: + # Code from module unistr/u32-strlen: + # Code from module unistr/u32-strlen-tests: + # Code from module unitypes: + # Code from module uniwidth/base: + # Code from module uniwidth/width: + # Code from module uniwidth/width-tests: + # Code from module unlink: + # Code from module unlink-tests: + # Code from module unlinkat: + # Code from module unlinkat-tests: + # Code from module unlinkdir: + # Code from module unlocked-io: + # Code from module unlocked-io-internal: + # Code from module unsetenv: + # Code from module unsetenv-tests: + # Code from module update-copyright: + # Code from module update-copyright-tests: + # Code from module useless-if-before-free: + # Code from module vararrays: + # Code from module vasnprintf: + # Code from module vasnprintf-tests: + # Code from module vc-list-files: + # Code from module vc-list-files-tests: + # Code from module verify: + # Code from module verify-tests: + # Code from module version-etc: + # Code from module version-etc-fsf: + # Code from module version-etc-tests: + # Code from module warnings: + # Code from module wchar: + # Code from module wchar-tests: + # Code from module wcrtomb: + # Code from module wcrtomb-tests: + # Code from module wctob: + # Code from module wctomb: + # Code from module wctype: + # Code from module wctype-h: + # Code from module wctype-h-tests: + # Code from module wctype-tests: + # Code from module wcwidth: + # Code from module wcwidth-tests: + # Code from module windows-mutex: + # Code from module windows-once: + # Code from module windows-recmutex: + # Code from module windows-rwlock: + # Code from module windows-thread: + # Code from module windows-tls: + # Code from module wmemchr: + # Code from module wmempcpy: + # Code from module xalloc: + # Code from module xalloc-die: + # Code from module xalloc-die-tests: + # Code from module xalloc-oversized: + # Code from module xfreopen: + # Code from module xmalloca: + # Code from module xsize: + # Code from module xstdopen: + # Code from module xstdopen-tests: + # Code from module xstrtoimax: + # Code from module xstrtoimax-tests: + # Code from module xstrtol: + # Code from module xstrtol-error: + # Code from module xstrtol-tests: + # Code from module year2038: + AC_REQUIRE([AC_SYS_YEAR2038]) + # Code from module year2038-tests: +]) + +# This macro should be invoked from ./configure.ac, in the section +# "Check for header files, types and library functions". +AC_DEFUN([gl_INIT], +[ + AC_CONFIG_LIBOBJ_DIR([gnulib-tests]) + AM_CONDITIONAL([GL_COND_LIBTOOL], [false]) + gl_cond_libtool=false + gl_libdeps= + gl_ltlibdeps= + gl_m4_base='m4' + m4_pushdef([AC_LIBOBJ], m4_defn([gl_LIBOBJ])) + m4_pushdef([AC_REPLACE_FUNCS], m4_defn([gl_REPLACE_FUNCS])) + m4_pushdef([AC_LIBSOURCES], m4_defn([gl_LIBSOURCES])) + m4_pushdef([gl_LIBSOURCES_LIST], []) + m4_pushdef([gl_LIBSOURCES_DIR], []) + m4_pushdef([GL_MACRO_PREFIX], [gl]) + m4_pushdef([GL_MODULE_INDICATOR_PREFIX], [GL]) + gl_COMMON + gl_source_base='lib' + gl_source_base_prefix= + gl_FUNC_ALLOCA + gl_CONDITIONAL_HEADER([alloca.h]) + AC_PROG_MKDIR_P + gl_ASSERT_H + gl_CONDITIONAL_HEADER([assert.h]) + AC_PROG_MKDIR_P + AC_REQUIRE([AC_CANONICAL_HOST]) + gl_UCHAR_MODULE_INDICATOR([btoc32]) + gl_FUNC_BTOWC + gl_CONDITIONAL([GL_COND_OBJ_BTOWC], + [test $HAVE_BTOWC = 0 || test $REPLACE_BTOWC = 1]) + AM_COND_IF([GL_COND_OBJ_BTOWC], [ + gl_PREREQ_BTOWC + ]) + gl_WCHAR_MODULE_INDICATOR([btowc]) + gl___BUILTIN_EXPECT + gl_C_STACK + gl_UCHAR_MODULE_INDICATOR([c32_apply_type_test]) + gl_UCHAR_MODULE_INDICATOR([c32_get_type_test]) + AC_REQUIRE([gl_UCHAR_H]) + dnl Determine REPLACE_MBSTATE_T, from which GNULIB_defined_mbstate_t is + dnl determined. It describes how mbrtoc32 is implemented. + AC_REQUIRE([gl_MBSTATE_T_BROKEN]) + AC_REQUIRE([gl_MBRTOC32_SANITYCHECK]) + gl_UCHAR_MODULE_INDICATOR([c32isalnum]) + AC_REQUIRE([gl_UCHAR_H]) + dnl Determine REPLACE_MBSTATE_T, from which GNULIB_defined_mbstate_t is + dnl determined. It describes how mbrtoc32 is implemented. + AC_REQUIRE([gl_MBSTATE_T_BROKEN]) + AC_REQUIRE([gl_MBRTOC32_SANITYCHECK]) + gl_UCHAR_MODULE_INDICATOR([c32isalpha]) + AC_REQUIRE([gl_UCHAR_H]) + dnl Determine REPLACE_MBSTATE_T, from which GNULIB_defined_mbstate_t is + dnl determined. It describes how mbrtoc32 is implemented. + AC_REQUIRE([gl_MBSTATE_T_BROKEN]) + AC_REQUIRE([gl_MBRTOC32_SANITYCHECK]) + gl_UCHAR_MODULE_INDICATOR([c32isblank]) + AC_REQUIRE([gl_UCHAR_H]) + dnl Determine REPLACE_MBSTATE_T, from which GNULIB_defined_mbstate_t is + dnl determined. It describes how mbrtoc32 is implemented. + AC_REQUIRE([gl_MBSTATE_T_BROKEN]) + AC_REQUIRE([gl_MBRTOC32_SANITYCHECK]) + gl_UCHAR_MODULE_INDICATOR([c32iscntrl]) + AC_REQUIRE([gl_UCHAR_H]) + dnl Determine REPLACE_MBSTATE_T, from which GNULIB_defined_mbstate_t is + dnl determined. It describes how mbrtoc32 is implemented. + AC_REQUIRE([gl_MBSTATE_T_BROKEN]) + AC_REQUIRE([gl_MBRTOC32_SANITYCHECK]) + gl_UCHAR_MODULE_INDICATOR([c32isdigit]) + AC_REQUIRE([gl_UCHAR_H]) + dnl Determine REPLACE_MBSTATE_T, from which GNULIB_defined_mbstate_t is + dnl determined. It describes how mbrtoc32 is implemented. + AC_REQUIRE([gl_MBSTATE_T_BROKEN]) + AC_REQUIRE([gl_MBRTOC32_SANITYCHECK]) + gl_UCHAR_MODULE_INDICATOR([c32isgraph]) + AC_REQUIRE([gl_UCHAR_H]) + dnl Determine REPLACE_MBSTATE_T, from which GNULIB_defined_mbstate_t is + dnl determined. It describes how mbrtoc32 is implemented. + AC_REQUIRE([gl_MBSTATE_T_BROKEN]) + AC_REQUIRE([gl_MBRTOC32_SANITYCHECK]) + gl_UCHAR_MODULE_INDICATOR([c32islower]) + AC_REQUIRE([gl_UCHAR_H]) + dnl Determine REPLACE_MBSTATE_T, from which GNULIB_defined_mbstate_t is + dnl determined. It describes how mbrtoc32 is implemented. + AC_REQUIRE([gl_MBSTATE_T_BROKEN]) + AC_REQUIRE([gl_MBRTOC32_SANITYCHECK]) + gl_UCHAR_MODULE_INDICATOR([c32isprint]) + AC_REQUIRE([gl_UCHAR_H]) + dnl Determine REPLACE_MBSTATE_T, from which GNULIB_defined_mbstate_t is + dnl determined. It describes how mbrtoc32 is implemented. + AC_REQUIRE([gl_MBSTATE_T_BROKEN]) + AC_REQUIRE([gl_MBRTOC32_SANITYCHECK]) + gl_UCHAR_MODULE_INDICATOR([c32ispunct]) + AC_REQUIRE([gl_UCHAR_H]) + dnl Determine REPLACE_MBSTATE_T, from which GNULIB_defined_mbstate_t is + dnl determined. It describes how mbrtoc32 is implemented. + AC_REQUIRE([gl_MBSTATE_T_BROKEN]) + AC_REQUIRE([gl_MBRTOC32_SANITYCHECK]) + gl_UCHAR_MODULE_INDICATOR([c32isspace]) + AC_REQUIRE([gl_UCHAR_H]) + dnl Determine REPLACE_MBSTATE_T, from which GNULIB_defined_mbstate_t is + dnl determined. It describes how mbrtoc32 is implemented. + AC_REQUIRE([gl_MBSTATE_T_BROKEN]) + AC_REQUIRE([gl_MBRTOC32_SANITYCHECK]) + gl_UCHAR_MODULE_INDICATOR([c32isupper]) + AC_REQUIRE([gl_UCHAR_H]) + dnl Determine REPLACE_MBSTATE_T, from which GNULIB_defined_mbstate_t is + dnl determined. It describes how mbrtoc32 is implemented. + AC_REQUIRE([gl_MBSTATE_T_BROKEN]) + AC_REQUIRE([gl_MBRTOC32_SANITYCHECK]) + gl_UCHAR_MODULE_INDICATOR([c32isxdigit]) + AC_REQUIRE([gl_UCHAR_H]) + dnl Determine REPLACE_MBSTATE_T, from which GNULIB_defined_mbstate_t is + dnl determined. It describes how mbrtoc32 is implemented. + AC_REQUIRE([gl_MBSTATE_T_BROKEN]) + AC_REQUIRE([gl_MBRTOC32_SANITYCHECK]) + gl_UCHAR_MODULE_INDICATOR([c32tolower]) + AC_REQUIRE([gl_UCHAR_H]) + dnl Determine REPLACE_MBSTATE_T, from which GNULIB_defined_mbstate_t is + dnl determined. It describes how mbrtoc32 is implemented. + AC_REQUIRE([gl_MBSTATE_T_BROKEN]) + AC_REQUIRE([gl_MBRTOC32_SANITYCHECK]) + gl_UCHAR_MODULE_INDICATOR([c32width]) + gl_FUNC_CALLOC_GNU + if test $REPLACE_CALLOC_FOR_CALLOC_GNU = 1; then + AC_LIBOBJ([calloc]) + fi + gl_STDLIB_MODULE_INDICATOR([calloc-gnu]) + gl_FUNC_CALLOC_POSIX + if test $REPLACE_CALLOC_FOR_CALLOC_POSIX = 1; then + AC_LIBOBJ([calloc]) + fi + gl_STDLIB_MODULE_INDICATOR([calloc-posix]) + AC_REQUIRE([AC_C_RESTRICT]) + gl_CHECK_FUNCS_ANDROID([readlinkat], [[#include ]]) + gl_UNISTD_MODULE_INDICATOR([chdir]) + gl_FUNC_CHDIR_LONG + gl_CONDITIONAL([GL_COND_OBJ_CHDIR_LONG], + [test $gl_cv_have_unlimited_file_name_length = no]) + AM_COND_IF([GL_COND_OBJ_CHDIR_LONG], [ + gl_PREREQ_CHDIR_LONG + ]) + gl_CLOCK_TIME + gl_MODULE_INDICATOR_FOR_TESTS([cloexec]) + gl_FUNC_CLOSE + gl_CONDITIONAL([GL_COND_OBJ_CLOSE], [test $REPLACE_CLOSE = 1]) + gl_UNISTD_MODULE_INDICATOR([close]) + gl_FUNC_CLOSEDIR + gl_CONDITIONAL([GL_COND_OBJ_CLOSEDIR], + [test $HAVE_CLOSEDIR = 0 || test $REPLACE_CLOSEDIR = 1]) + gl_DIRENT_MODULE_INDICATOR([closedir]) + gl_CONFIG_H + gl_CTYPE_H + gl_CTYPE_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_DIRENT_H + gl_DIRENT_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_FUNC_DIRFD + gl_CONDITIONAL([GL_COND_OBJ_DIRFD], + [test $HAVE_DIRFD = 0 || test $REPLACE_DIRFD = 1]) + AM_COND_IF([GL_COND_OBJ_DIRFD], [ + gl_PREREQ_DIRFD + ]) + gl_DIRENT_MODULE_INDICATOR([dirfd]) + gl_MODULE_INDICATOR([dirname]) + gl_DOUBLE_SLASH_ROOT + gl_FUNC_DUP + gl_CONDITIONAL([GL_COND_OBJ_DUP], [test $REPLACE_DUP = 1]) + AM_COND_IF([GL_COND_OBJ_DUP], [ + gl_PREREQ_DUP + ]) + gl_UNISTD_MODULE_INDICATOR([dup]) + gl_FUNC_DUP2 + gl_CONDITIONAL([GL_COND_OBJ_DUP2], [test $REPLACE_DUP2 = 1]) + AM_COND_IF([GL_COND_OBJ_DUP2], [ + gl_PREREQ_DUP2 + ]) + gl_UNISTD_MODULE_INDICATOR([dup2]) + gl_ENVIRON + gl_UNISTD_MODULE_INDICATOR([environ]) + gl_HEADER_ERRNO_H + gl_CONDITIONAL_HEADER([errno.h]) + AC_PROG_MKDIR_P + AC_REQUIRE([gl_ERROR_H]) + gl_ERROR + gl_CONDITIONAL([GL_COND_OBJ_ERROR], [test $COMPILE_ERROR_C = 1]) + AM_COND_IF([GL_COND_OBJ_ERROR], [ + gl_PREREQ_ERROR + ]) + m4_ifdef([AM_XGETTEXT_OPTION], + [AM_][XGETTEXT_OPTION([--flag=error:3:c-format]) + AM_][XGETTEXT_OPTION([--flag=error_at_line:5:c-format])]) + gl_ERROR_H + AC_PROG_MKDIR_P + AC_REQUIRE([gl_EXTERN_INLINE]) + gl_FUNC_FCHDIR + gl_CONDITIONAL([GL_COND_OBJ_FCHDIR], + [test $HAVE_FCHDIR = 0 || test $REPLACE_FCHDIR = 1]) + AM_COND_IF([GL_COND_OBJ_FCHDIR], [ + gl_PREREQ_FCHDIR + ]) + gl_UNISTD_MODULE_INDICATOR([fchdir]) + gl_FUNC_FCNTL + gl_CONDITIONAL([GL_COND_OBJ_FCNTL], + [test $HAVE_FCNTL = 0 || test $REPLACE_FCNTL = 1]) + gl_FCNTL_MODULE_INDICATOR([fcntl]) + gl_FCNTL_H + gl_FCNTL_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_MODULE_INDICATOR([fd-safer-flag]) + gl_FUNC_FDOPENDIR + gl_CONDITIONAL([GL_COND_OBJ_FDOPENDIR], + [test $HAVE_FDOPENDIR = 0 || test $REPLACE_FDOPENDIR = 1]) + gl_DIRENT_MODULE_INDICATOR([fdopendir]) + gl_MODULE_INDICATOR([fdopendir]) + gl_FILE_NAME_CONCAT + gl_MODULE_INDICATOR([filenamecat]) + gl_FILE_NAME_CONCAT_LGPL + AC_C_FLEXIBLE_ARRAY_MEMBER + gl_FUNC_FNMATCH_POSIX + dnl Because of gl_REPLACE_FNMATCH_H: + gl_CONDITIONAL_HEADER([fnmatch.h]) + if test $HAVE_FNMATCH = 0 || test $REPLACE_FNMATCH = 1; then + AC_LIBOBJ([fnmatch]) + gl_PREREQ_FNMATCH + fi + gl_FNMATCH_MODULE_INDICATOR([fnmatch]) + gl_FUNC_FNMATCH_GNU + if test $HAVE_FNMATCH = 0 || test $REPLACE_FNMATCH = 1; then + AC_LIBOBJ([fnmatch]) + gl_PREREQ_FNMATCH + fi + gl_MODULE_INDICATOR([fnmatch-gnu]) + gl_FNMATCH_H + gl_FNMATCH_H_REQUIRE_DEFAULTS + gl_CONDITIONAL_HEADER([fnmatch.h]) + AC_PROG_MKDIR_P + gl_FUNC_FOPEN + if test $REPLACE_FOPEN = 1; then + AC_LIBOBJ([fopen]) + gl_PREREQ_FOPEN + fi + gl_STDIO_MODULE_INDICATOR([fopen]) + gl_FUNC_FOPEN_GNU + if test $REPLACE_FOPEN_FOR_FOPEN_GNU = 1; then + AC_LIBOBJ([fopen]) + gl_PREREQ_FOPEN + fi + gl_MODULE_INDICATOR([fopen-gnu]) + gl_STDIO_MODULE_INDICATOR([fopen-gnu]) + gl_FUNC_FREE + gl_CONDITIONAL([GL_COND_OBJ_FREE], [test $REPLACE_FREE = 1]) + AM_COND_IF([GL_COND_OBJ_FREE], [ + gl_PREREQ_FREE + ]) + gl_STDLIB_MODULE_INDICATOR([free-posix]) + gl_FUNC_FREOPEN + gl_CONDITIONAL([GL_COND_OBJ_FREOPEN], [test $REPLACE_FREOPEN = 1]) + AM_COND_IF([GL_COND_OBJ_FREOPEN], [ + gl_PREREQ_FREOPEN + ]) + gl_STDIO_MODULE_INDICATOR([freopen]) + gl_FUNC_FSTAT + gl_CONDITIONAL([GL_COND_OBJ_FSTAT], [test $REPLACE_FSTAT = 1]) + AM_COND_IF([GL_COND_OBJ_FSTAT], [ + case "$host_os" in + mingw* | windows*) + AC_LIBOBJ([stat-w32]) + ;; + esac + gl_PREREQ_FSTAT + ]) + gl_SYS_STAT_MODULE_INDICATOR([fstat]) + gl_FUNC_FSTATAT + gl_CONDITIONAL([GL_COND_OBJ_FSTATAT], + [test $HAVE_FSTATAT = 0 || test $REPLACE_FSTATAT = 1]) + gl_SYS_STAT_MODULE_INDICATOR([fstatat]) + gl_FUNC_GETCWD_LGPL + gl_CONDITIONAL([GL_COND_OBJ_GETCWD_LGPL], [test $REPLACE_GETCWD = 1]) + gl_UNISTD_MODULE_INDICATOR([getcwd]) + gl_FUNC_GETDTABLESIZE + gl_CONDITIONAL([GL_COND_OBJ_GETDTABLESIZE], + [test $HAVE_GETDTABLESIZE = 0 || test $REPLACE_GETDTABLESIZE = 1]) + AM_COND_IF([GL_COND_OBJ_GETDTABLESIZE], [ + gl_PREREQ_GETDTABLESIZE + ]) + gl_UNISTD_MODULE_INDICATOR([getdtablesize]) + gl_FUNC_GETOPT_GNU + dnl Because of the way gl_FUNC_GETOPT_GNU is implemented (the gl_getopt_required + dnl mechanism), there is no need to do any AC_LIBOBJ or AC_SUBST here; they are + dnl done in the getopt-posix module. + gl_FUNC_GETOPT_POSIX + gl_CONDITIONAL_HEADER([getopt.h]) + gl_CONDITIONAL_HEADER([getopt-cdefs.h]) + AC_PROG_MKDIR_P + gl_CONDITIONAL([GL_COND_OBJ_GETOPT], [test $REPLACE_GETOPT = 1]) + AM_COND_IF([GL_COND_OBJ_GETOPT], [ + dnl Define the substituted variable GNULIB_UNISTD_H_GETOPT to 1. + gl_UNISTD_H_REQUIRE_DEFAULTS + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNISTD_H_GETOPT], [1]) + ]) + gl_UNISTD_MODULE_INDICATOR([getopt-posix]) + gl_FUNC_GETPAGESIZE + gl_CONDITIONAL([GL_COND_OBJ_GETPAGESIZE], [test $REPLACE_GETPAGESIZE = 1]) + gl_UNISTD_MODULE_INDICATOR([getpagesize]) + gl_FUNC_GETPROGNAME + gl_CONDITIONAL([GL_COND_OBJ_GETPROGNAME], + [test $HAVE_GETPROGNAME = 0 || test $REPLACE_GETPROGNAME = 1]) + AM_COND_IF([GL_COND_OBJ_GETPROGNAME], [ + gl_PREREQ_GETPROGNAME + ]) + gl_STDLIB_MODULE_INDICATOR([getprogname]) + AC_REQUIRE([AC_CANONICAL_HOST]) + gl_FUNC_GETRANDOM + gl_CONDITIONAL([GL_COND_OBJ_GETRANDOM], + [test $HAVE_GETRANDOM = 0 || test $REPLACE_GETRANDOM = 1]) + gl_SYS_RANDOM_MODULE_INDICATOR([getrandom]) + AC_SUBST([LIBINTL]) + AC_SUBST([LTLIBINTL]) + gl_GETTIME + gl_FUNC_GETTIMEOFDAY + gl_CONDITIONAL([GL_COND_OBJ_GETTIMEOFDAY], + [test $HAVE_GETTIMEOFDAY = 0 || test $REPLACE_GETTIMEOFDAY = 1]) + AM_COND_IF([GL_COND_OBJ_GETTIMEOFDAY], [ + gl_PREREQ_GETTIMEOFDAY + ]) + gl_SYS_TIME_MODULE_INDICATOR([gettimeofday]) + AC_PROG_MKDIR_P + gl_GNU_MAKE + # Autoconf 2.61a.99 and earlier don't support linking a file only + # in VPATH builds. But since GNUmakefile is for maintainer use + # only, it does not matter if we skip the link with older autoconf. + # Automake 1.10.1 and earlier try to remove GNUmakefile in non-VPATH + # builds, so use a shell variable to bypass this. + GNUmakefile=GNUmakefile + m4_if(m4_version_compare([2.61a.100], + m4_defn([m4_PACKAGE_VERSION])), [1], [], + [AC_CONFIG_LINKS([$GNUmakefile:$GNUmakefile], [], + [GNUmakefile=$GNUmakefile])]) + AC_REQUIRE([gl_FUNC_SETLOCALE_NULL]) + HARD_LOCALE_LIB="$SETLOCALE_NULL_LIB" + AC_SUBST([HARD_LOCALE_LIB]) + dnl For backward compatibility. + LIB_HARD_LOCALE="$HARD_LOCALE_LIB" + AC_SUBST([LIB_HARD_LOCALE]) + AC_DEFUN([gl_HAVE_MODULE_HAVELIB]) + AC_REQUIRE([gl_HOST_CPU_C_ABI]) + gl_INLINE + gl_INTTYPES_H + gl_INTTYPES_INCOMPLETE + gl_INTTYPES_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_FUNC_ISBLANK + gl_CONDITIONAL([GL_COND_OBJ_ISBLANK], [test $HAVE_ISBLANK = 0]) + gl_MODULE_INDICATOR([isblank]) + gl_CTYPE_MODULE_INDICATOR([isblank]) + gl_FUNC_ISWBLANK + gl_CONDITIONAL([GL_COND_OBJ_ISWBLANK], + [! { test $HAVE_ISWCNTRL = 0 || test $REPLACE_ISWCNTRL = 1; } && { test $HAVE_ISWBLANK = 0 || test $REPLACE_ISWBLANK = 1; }]) + gl_WCTYPE_MODULE_INDICATOR([iswblank]) + gl_FUNC_ISWCTYPE + gl_CONDITIONAL([GL_COND_OBJ_ISWCTYPE], + [test $HAVE_WCTYPE_T = 0 || test $GNULIBHEADERS_OVERRIDE_WINT_T = 1 || test $REPLACE_WCTYPE = 1]) + gl_WCTYPE_MODULE_INDICATOR([iswctype]) + gl_FUNC_ISWDIGIT + gl_CONDITIONAL([GL_COND_OBJ_ISWDIGIT], + [! { test $HAVE_ISWCNTRL = 0 || test $REPLACE_ISWCNTRL = 1; } && test $REPLACE_ISWDIGIT = 1]) + gl_WCTYPE_MODULE_INDICATOR([iswdigit]) + gl_FUNC_ISWPUNCT + gl_CONDITIONAL([GL_COND_OBJ_ISWPUNCT], + [! { test $HAVE_ISWCNTRL = 0 || test $REPLACE_ISWCNTRL = 1; } && test $REPLACE_ISWPUNCT = 1]) + gl_WCTYPE_MODULE_INDICATOR([iswpunct]) + gl_FUNC_ISWXDIGIT + gl_CONDITIONAL([GL_COND_OBJ_ISWXDIGIT], + [! { test $HAVE_ISWCNTRL = 0 || test $REPLACE_ISWCNTRL = 1; } && test $REPLACE_ISWXDIGIT = 1]) + gl_WCTYPE_MODULE_INDICATOR([iswxdigit]) + gl_LANGINFO_H + gl_LANGINFO_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + AC_REQUIRE([gl_LARGEFILE]) + gl___INLINE + gl_LIMITS_H + gl_CONDITIONAL_HEADER([limits.h]) + AC_PROG_MKDIR_P + gl_LOCALCHARSET + dnl For backward compatibility. Some packages still use this. + LOCALCHARSET_TESTS_ENVIRONMENT= + AC_SUBST([LOCALCHARSET_TESTS_ENVIRONMENT]) + gl_LOCALE_H + gl_LOCALE_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_FUNC_LOCALECONV + gl_CONDITIONAL([GL_COND_OBJ_LOCALECONV], [test $REPLACE_LOCALECONV = 1]) + AM_COND_IF([GL_COND_OBJ_LOCALECONV], [ + gl_PREREQ_LOCALECONV + ]) + gl_LOCALE_MODULE_INDICATOR([localeconv]) + gl_LOCK + gl_MODULE_INDICATOR([lock]) + gl_FUNC_LSTAT + gl_CONDITIONAL([GL_COND_OBJ_LSTAT], [test $REPLACE_LSTAT = 1]) + AM_COND_IF([GL_COND_OBJ_LSTAT], [ + gl_PREREQ_LSTAT + ]) + gl_SYS_STAT_MODULE_INDICATOR([lstat]) + AC_CONFIG_COMMANDS_PRE([m4_ifdef([AH_HEADER], + [AC_SUBST([CONFIG_INCLUDE], m4_defn([AH_HEADER]))])]) + AC_REQUIRE([AC_PROG_SED]) + AC_REQUIRE([AC_PROG_GREP]) + gl_FUNC_MALLOC_GNU + if test $REPLACE_MALLOC_FOR_MALLOC_GNU = 1; then + AC_LIBOBJ([malloc]) + fi + gl_STDLIB_MODULE_INDICATOR([malloc-gnu]) + AC_REQUIRE([gl_FUNC_MALLOC_POSIX]) + if test $REPLACE_MALLOC_FOR_MALLOC_POSIX = 1; then + AC_LIBOBJ([malloc]) + fi + gl_STDLIB_MODULE_INDICATOR([malloc-posix]) + gl_MALLOCA + gl_MBCHAR + gl_FUNC_MBRTOC32 + gl_CONDITIONAL([GL_COND_OBJ_MBRTOC32], + [test $HAVE_MBRTOC32 = 0 || test $REPLACE_MBRTOC32 = 1]) + AM_COND_IF([GL_COND_OBJ_MBRTOC32], [ + if test $REPLACE_MBSTATE_T = 1; then + AC_LIBOBJ([lc-charset-dispatch]) + AC_LIBOBJ([mbtowc-lock]) + gl_PREREQ_MBTOWC_LOCK + fi + gl_PREREQ_MBRTOC32 + ]) + gl_UCHAR_MODULE_INDICATOR([mbrtoc32]) + gl_FUNC_MBRTOWC + gl_CONDITIONAL([GL_COND_OBJ_MBRTOWC], + [test $HAVE_MBRTOWC = 0 || test $REPLACE_MBRTOWC = 1]) + AM_COND_IF([GL_COND_OBJ_MBRTOWC], [ + if test $REPLACE_MBSTATE_T = 1; then + AC_LIBOBJ([lc-charset-dispatch]) + AC_LIBOBJ([mbtowc-lock]) + gl_PREREQ_MBTOWC_LOCK + fi + gl_PREREQ_MBRTOWC + ]) + gl_WCHAR_MODULE_INDICATOR([mbrtowc]) + gl_STRING_MODULE_INDICATOR([mbscasecmp]) + gl_FUNC_MBSINIT + gl_CONDITIONAL([GL_COND_OBJ_MBSINIT], + [test $HAVE_MBSINIT = 0 || test $REPLACE_MBSINIT = 1]) + AM_COND_IF([GL_COND_OBJ_MBSINIT], [ + gl_PREREQ_MBSINIT + ]) + gl_WCHAR_MODULE_INDICATOR([mbsinit]) + AC_REQUIRE([gl_UCHAR_H]) + AC_LIBOBJ([mbsrtoc32s-state]) + gl_UCHAR_MODULE_INDICATOR([mbsrtoc32s]) + gl_FUNC_MBSRTOWCS + gl_CONDITIONAL([GL_COND_OBJ_MBSRTOWCS], + [test $HAVE_MBSRTOWCS = 0 || test $REPLACE_MBSRTOWCS = 1]) + AM_COND_IF([GL_COND_OBJ_MBSRTOWCS], [ + AC_LIBOBJ([mbsrtowcs-state]) + gl_PREREQ_MBSRTOWCS + ]) + gl_WCHAR_MODULE_INDICATOR([mbsrtowcs]) + AC_REQUIRE([AC_TYPE_MBSTATE_T]) + gl_MBSTATE_T_BROKEN + gl_MUSL_LIBC + gl_WCHAR_MODULE_INDICATOR([mbszero]) + gl_FUNC_MBTOWC + gl_CONDITIONAL([GL_COND_OBJ_MBTOWC], + [test $HAVE_MBTOWC = 0 || test $REPLACE_MBTOWC = 1]) + AM_COND_IF([GL_COND_OBJ_MBTOWC], [ + gl_PREREQ_MBTOWC + ]) + gl_STDLIB_MODULE_INDICATOR([mbtowc]) + gl_MBITER + gl_MBITER + gl_FUNC_MEMCHR + gl_CONDITIONAL([GL_COND_OBJ_MEMCHR], [test $REPLACE_MEMCHR = 1]) + AM_COND_IF([GL_COND_OBJ_MEMCHR], [ + gl_PREREQ_MEMCHR + ]) + gl_STRING_MODULE_INDICATOR([memchr]) + gl_FUNC_MEMPCPY + gl_CONDITIONAL([GL_COND_OBJ_MEMPCPY], + [test $HAVE_MEMPCPY = 0 || test $REPLACE_MEMPCPY = 1]) + AM_COND_IF([GL_COND_OBJ_MEMPCPY], [ + gl_PREREQ_MEMPCPY + ]) + gl_STRING_MODULE_INDICATOR([mempcpy]) + gl_FUNC_MEMRCHR + gl_CONDITIONAL([GL_COND_OBJ_MEMRCHR], [test $ac_cv_func_memrchr = no]) + AM_COND_IF([GL_COND_OBJ_MEMRCHR], [ + gl_PREREQ_MEMRCHR + ]) + gl_STRING_MODULE_INDICATOR([memrchr]) + gl_MINMAX + gl_FUNC_MKDIR + gl_CONDITIONAL([GL_COND_OBJ_MKDIR], [test $REPLACE_MKDIR = 1]) + gl_SYS_STAT_MODULE_INDICATOR([mkdir]) + gl_FUNC_MKSTEMP + gl_CONDITIONAL([GL_COND_OBJ_MKSTEMP], + [test $HAVE_MKSTEMP = 0 || test $REPLACE_MKSTEMP = 1]) + AM_COND_IF([GL_COND_OBJ_MKSTEMP], [ + gl_PREREQ_MKSTEMP + ]) + gl_STDLIB_MODULE_INDICATOR([mkstemp]) + gl_FUNC_MKTIME + if test $REPLACE_MKTIME = 1; then + AC_LIBOBJ([mktime]) + gl_PREREQ_MKTIME + fi + gl_TIME_MODULE_INDICATOR([mktime]) + gl_FUNC_MKTIME_INTERNAL + if test $WANT_MKTIME_INTERNAL = 1; then + AC_LIBOBJ([mktime]) + gl_PREREQ_MKTIME + fi + AC_REQUIRE([gl_MSVC_INVAL]) + gl_CONDITIONAL([GL_COND_OBJ_MSVC_INVAL], + [test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1]) + AC_REQUIRE([gl_MSVC_NOTHROW]) + gl_CONDITIONAL([GL_COND_OBJ_MSVC_NOTHROW], + [test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1]) + gl_MODULE_INDICATOR([msvc-nothrow]) + gl_MULTIARCH + gl_FUNC_NL_LANGINFO + gl_CONDITIONAL([GL_COND_OBJ_NL_LANGINFO], + [test $HAVE_NL_LANGINFO = 0 || test $REPLACE_NL_LANGINFO = 1]) + gl_CONDITIONAL([GL_COND_OBJ_NL_LANGINFO_LOCK], + [test $REPLACE_NL_LANGINFO = 1 && test $NL_LANGINFO_MTSAFE = 0]) + if test $REPLACE_NL_LANGINFO = 1 && test $NL_LANGINFO_MTSAFE = 0; then + gl_PREREQ_NL_LANGINFO_LOCK + fi + gl_LANGINFO_MODULE_INDICATOR([nl_langinfo]) + gl_FUNC_GNU_STRFTIME + gl_NULLPTR + gl_FUNC_OPEN + gl_CONDITIONAL([GL_COND_OBJ_OPEN], [test $REPLACE_OPEN = 1]) + AM_COND_IF([GL_COND_OBJ_OPEN], [ + gl_PREREQ_OPEN + ]) + gl_FCNTL_MODULE_INDICATOR([open]) + gl_FUNC_OPENAT + gl_CONDITIONAL([GL_COND_OBJ_OPENAT], + [test $HAVE_OPENAT = 0 || test $REPLACE_OPENAT = 1]) + AM_COND_IF([GL_COND_OBJ_OPENAT], [ + gl_PREREQ_OPENAT + ]) + gl_MODULE_INDICATOR([openat]) dnl for lib/getcwd.c + gl_FCNTL_MODULE_INDICATOR([openat]) + gl_FUNC_OPENDIR + gl_CONDITIONAL([GL_COND_OBJ_OPENDIR], + [test $HAVE_OPENDIR = 0 || test $REPLACE_OPENDIR = 1]) + gl_DIRENT_MODULE_INDICATOR([opendir]) + gl_PATHMAX + gl_FUNC_PCLOSE + gl_CONDITIONAL([GL_COND_OBJ_PCLOSE], [test $HAVE_PCLOSE = 0]) + AM_COND_IF([GL_COND_OBJ_PCLOSE], [ + gl_PREREQ_PCLOSE + ]) + gl_STDIO_MODULE_INDICATOR([pclose]) + gl_PERL + gl_FUNC_PIPE + gl_CONDITIONAL([GL_COND_OBJ_PIPE], [test $HAVE_PIPE = 0]) + gl_UNISTD_MODULE_INDICATOR([pipe]) + gl_FUNC_POPEN + gl_CONDITIONAL([GL_COND_OBJ_POPEN], + [test $HAVE_POPEN = 0 || test $REPLACE_POPEN = 1]) + AM_COND_IF([GL_COND_OBJ_POPEN], [ + gl_PREREQ_POPEN + ]) + gl_STDIO_MODULE_INDICATOR([popen]) + AC_CHECK_DECLS([program_invocation_name], [], [], [#include ]) + AC_CHECK_DECLS([program_invocation_short_name], [], [], [#include ]) + m4_ifdef([AM_XGETTEXT_OPTION], + [AM_][XGETTEXT_OPTION([--keyword='proper_name_lite:1,\"This is a proper name. See the gettext manual, section Names.\"'])]) + gl_QUOTE + gl_QUOTEARG + gl_FUNC_RAISE + gl_CONDITIONAL([GL_COND_OBJ_RAISE], + [test $HAVE_RAISE = 0 || test $REPLACE_RAISE = 1]) + AM_COND_IF([GL_COND_OBJ_RAISE], [ + gl_PREREQ_RAISE + ]) + gl_SIGNAL_MODULE_INDICATOR([raise]) + gl_FUNC_RAWMEMCHR + gl_CONDITIONAL([GL_COND_OBJ_RAWMEMCHR], [test $HAVE_RAWMEMCHR = 0]) + AM_COND_IF([GL_COND_OBJ_RAWMEMCHR], [ + gl_PREREQ_RAWMEMCHR + ]) + gl_STRING_MODULE_INDICATOR([rawmemchr]) + gl_FUNC_READDIR + gl_CONDITIONAL([GL_COND_OBJ_READDIR], + [test $HAVE_READDIR = 0 || test $REPLACE_READDIR = 1]) + gl_DIRENT_MODULE_INDICATOR([readdir]) + gl_FUNC_READLINK + gl_CONDITIONAL([GL_COND_OBJ_READLINK], + [test $HAVE_READLINK = 0 || test $REPLACE_READLINK = 1]) + AM_COND_IF([GL_COND_OBJ_READLINK], [ + gl_PREREQ_READLINK + ]) + gl_UNISTD_MODULE_INDICATOR([readlink]) + gl_FUNC_READLINKAT + gl_CONDITIONAL([GL_COND_OBJ_READLINKAT], + [test $HAVE_READLINKAT = 0 || test $REPLACE_READLINKAT = 1]) + gl_UNISTD_MODULE_INDICATOR([readlinkat]) + gl_FUNC_REALLOC_GNU + if test $REPLACE_REALLOC_FOR_REALLOC_GNU = 1; then + AC_LIBOBJ([realloc]) + fi + gl_STDLIB_MODULE_INDICATOR([realloc-gnu]) + gl_FUNC_REALLOC_POSIX + if test $REPLACE_REALLOC_FOR_REALLOC_POSIX = 1; then + AC_LIBOBJ([realloc]) + fi + gl_STDLIB_MODULE_INDICATOR([realloc-posix]) + gl_FUNC_REALLOCARRAY + gl_CONDITIONAL([GL_COND_OBJ_REALLOCARRAY], + [test $HAVE_REALLOCARRAY = 0 || test $REPLACE_REALLOCARRAY = 1]) + AM_COND_IF([GL_COND_OBJ_REALLOCARRAY], [ + gl_PREREQ_REALLOCARRAY + ]) + gl_MODULE_INDICATOR([reallocarray]) + gl_STDLIB_MODULE_INDICATOR([reallocarray]) + gl_REGEX + gl_CONDITIONAL([GL_COND_OBJ_REGEX], [test $ac_use_included_regex = yes]) + AM_COND_IF([GL_COND_OBJ_REGEX], [ + gl_PREREQ_REGEX + ]) + gl_SAVE_CWD + gl_FUNC_SETENV + gl_CONDITIONAL([GL_COND_OBJ_SETENV], + [test $HAVE_SETENV = 0 || test $REPLACE_SETENV = 1]) + gl_STDLIB_MODULE_INDICATOR([setenv]) + gl_FUNC_SETLOCALE_NULL + gl_CONDITIONAL([GL_COND_OBJ_SETLOCALE_LOCK], + [test $SETLOCALE_NULL_ALL_MTSAFE = 0 || test $SETLOCALE_NULL_ONE_MTSAFE = 0]) + AM_COND_IF([GL_COND_OBJ_SETLOCALE_LOCK], [ + gl_PREREQ_SETLOCALE_LOCK + ]) + gl_LOCALE_MODULE_INDICATOR([setlocale_null]) + AC_REQUIRE([AC_C_RESTRICT]) + gl_SIGACTION + gl_CONDITIONAL([GL_COND_OBJ_SIGACTION], [test $HAVE_SIGACTION = 0]) + AM_COND_IF([GL_COND_OBJ_SIGACTION], [ + gl_PREREQ_SIGACTION + ]) + gl_SIGNAL_MODULE_INDICATOR([sigaction]) + gl_SIGNAL_H + gl_SIGNAL_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_SIGNALBLOCKING + gl_CONDITIONAL([GL_COND_OBJ_SIGPROCMASK], [test $HAVE_POSIX_SIGNALBLOCKING = 0]) + AM_COND_IF([GL_COND_OBJ_SIGPROCMASK], [ + gl_PREREQ_SIGPROCMASK + ]) + gl_SIGNAL_MODULE_INDICATOR([sigprocmask]) + AC_REQUIRE([gl_SIGSEGV]) + if test $gl_sigsegv_uses_libsigsegv = yes; then + GL_GENERATE_SIGSEGV_H=false + else + GL_GENERATE_SIGSEGV_H=true + fi + gl_CONDITIONAL_HEADER([sigsegv.h]) + AC_PROG_MKDIR_P + if $GL_GENERATE_SIGSEGV_H; then + dnl Persuade glibc to declare macros designating register + dnl indices: REG_RSP on x86_64, REG_ESP on i386. + dnl Persuade Solaris OpenIndiana to include , + dnl which declares macros designating register indices, such as ESP on i386. + dnl Persuade Solaris OpenIndiana to declare mincore(). + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + gl_MUSL_LIBC + AC_REQUIRE([AC_CANONICAL_HOST]) + case "$host_os" in + solaris2.11) + AC_DEFINE([SOLARIS11], [1], [Define on Solaris 11 and its derivates.]) + ;; + esac + gl_FUNC_MMAP_ANON + dnl Stack direction. + SV_STACK_DIRECTION + dnl Catching stack overflow requires an alternate signal stack. + dnl The old "install a guard page" trick would be unreliable, because + dnl we don't know where exactly to place the guard page. + SV_SIGALTSTACK + AC_CHECK_FUNCS_ONCE([getrlimit]) + fi + gt_TYPE_SSIZE_T + gl_FUNC_STAT + gl_CONDITIONAL([GL_COND_OBJ_STAT], [test $REPLACE_STAT = 1]) + AM_COND_IF([GL_COND_OBJ_STAT], [ + case "$host_os" in + mingw* | windows*) + AC_LIBOBJ([stat-w32]) + ;; + esac + gl_PREREQ_STAT + ]) + gl_SYS_STAT_MODULE_INDICATOR([stat]) + gl_STAT_TIME + gl_STAT_BIRTHTIME + gl_STDARG_H + gl_CONDITIONAL_HEADER([stdarg.h]) + AC_PROG_MKDIR_P + gl_C_BOOL + AC_CHECK_HEADERS_ONCE([stdckdint.h]) + if test $ac_cv_header_stdckdint_h = yes; then + GL_GENERATE_STDCKDINT_H=false + else + GL_GENERATE_STDCKDINT_H=true + fi + gl_CONDITIONAL_HEADER([stdckdint.h]) + AC_PROG_MKDIR_P + gl_STDDEF_H + gl_STDDEF_H_REQUIRE_DEFAULTS + gl_CONDITIONAL_HEADER([stddef.h]) + AC_PROG_MKDIR_P + gl_STDINT_H + gl_CONDITIONAL_HEADER([stdint.h]) + dnl Because of gl_REPLACE_LIMITS_H: + gl_CONDITIONAL_HEADER([limits.h]) + AC_PROG_MKDIR_P + gl_STDIO_H + gl_STDIO_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_CONDITIONAL([GL_COND_OBJ_STDIO_READ], [test $REPLACE_STDIO_READ_FUNCS = 1]) + gl_CONDITIONAL([GL_COND_OBJ_STDIO_WRITE], [test $REPLACE_STDIO_WRITE_FUNCS = 1]) + dnl No need to create extra modules for these functions. Everyone who uses + dnl likely needs them. + gl_STDIO_MODULE_INDICATOR([fscanf]) + gl_MODULE_INDICATOR([fscanf]) + gl_STDIO_MODULE_INDICATOR([scanf]) + gl_MODULE_INDICATOR([scanf]) + gl_STDIO_MODULE_INDICATOR([fgetc]) + gl_STDIO_MODULE_INDICATOR([getc]) + gl_STDIO_MODULE_INDICATOR([getchar]) + gl_STDIO_MODULE_INDICATOR([fgets]) + gl_STDIO_MODULE_INDICATOR([fread]) + dnl No need to create extra modules for these functions. Everyone who uses + dnl likely needs them. + gl_STDIO_MODULE_INDICATOR([fprintf]) + gl_STDIO_MODULE_INDICATOR([printf]) + gl_STDIO_MODULE_INDICATOR([vfprintf]) + gl_STDIO_MODULE_INDICATOR([vprintf]) + gl_STDIO_MODULE_INDICATOR([fputc]) + gl_STDIO_MODULE_INDICATOR([putc]) + gl_STDIO_MODULE_INDICATOR([putchar]) + gl_STDIO_MODULE_INDICATOR([fputs]) + gl_STDIO_MODULE_INDICATOR([puts]) + gl_STDIO_MODULE_INDICATOR([fwrite]) + gl_STDLIB_H + gl_STDLIB_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_FUNC_STPCPY + gl_CONDITIONAL([GL_COND_OBJ_STPCPY], + [test $HAVE_STPCPY = 0 || test $REPLACE_STPCPY = 1]) + AM_COND_IF([GL_COND_OBJ_STPCPY], [ + gl_PREREQ_STPCPY + ]) + gl_STRING_MODULE_INDICATOR([stpcpy]) + gl_STRCASE + gl_CONDITIONAL([GL_COND_OBJ_STRCASECMP], [test $HAVE_STRCASECMP = 0]) + AM_COND_IF([GL_COND_OBJ_STRCASECMP], [ + gl_PREREQ_STRCASECMP + ]) + gl_CONDITIONAL([GL_COND_OBJ_STRNCASECMP], [test $HAVE_STRNCASECMP = 0]) + AM_COND_IF([GL_COND_OBJ_STRNCASECMP], [ + gl_PREREQ_STRNCASECMP + ]) + gl_FUNC_STRDUP_POSIX + gl_CONDITIONAL([GL_COND_OBJ_STRDUP], [test $REPLACE_STRDUP = 1]) + AM_COND_IF([GL_COND_OBJ_STRDUP], [ + gl_PREREQ_STRDUP + ]) + gl_STRING_MODULE_INDICATOR([strdup]) + gl_FUNC_STRERROR + gl_CONDITIONAL([GL_COND_OBJ_STRERROR], [test $REPLACE_STRERROR = 1]) + gl_MODULE_INDICATOR([strerror]) + gl_STRING_MODULE_INDICATOR([strerror]) + AC_REQUIRE([gl_HEADER_ERRNO_H]) + AC_REQUIRE([gl_FUNC_STRERROR_0]) + gl_CONDITIONAL([GL_COND_OBJ_STRERROR_OVERRIDE], + [test -n "$ERRNO_H" || test $REPLACE_STRERROR_0 = 1]) + AM_COND_IF([GL_COND_OBJ_STRERROR_OVERRIDE], [ + gl_PREREQ_SYS_H_WINSOCK2 + ]) + gl_STRING_H + gl_STRING_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_STRINGS_H + gl_STRINGS_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_FUNC_STRNLEN + gl_CONDITIONAL([GL_COND_OBJ_STRNLEN], + [test $HAVE_DECL_STRNLEN = 0 || test $REPLACE_STRNLEN = 1]) + AM_COND_IF([GL_COND_OBJ_STRNLEN], [ + gl_PREREQ_STRNLEN + ]) + gl_STRING_MODULE_INDICATOR([strnlen]) + gl_FUNC_STRPTIME + gl_CONDITIONAL([GL_COND_OBJ_STRPTIME], [test $HAVE_STRPTIME = 0]) + AM_COND_IF([GL_COND_OBJ_STRPTIME], [ + gl_PREREQ_STRPTIME + ]) + gl_TIME_MODULE_INDICATOR([strptime]) + gl_FUNC_STRTOIMAX + gl_CONDITIONAL([GL_COND_OBJ_STRTOIMAX], + [test $HAVE_DECL_STRTOIMAX = 0 || test $REPLACE_STRTOIMAX = 1]) + AM_COND_IF([GL_COND_OBJ_STRTOIMAX], [ + gl_PREREQ_STRTOIMAX + ]) + gl_INTTYPES_MODULE_INDICATOR([strtoimax]) + gl_FUNC_STRTOLL + gl_CONDITIONAL([GL_COND_OBJ_STRTOLL], + [test $HAVE_STRTOLL = 0 || test $REPLACE_STRTOLL = 1]) + AM_COND_IF([GL_COND_OBJ_STRTOLL], [ + gl_PREREQ_STRTOLL + ]) + gl_STDLIB_MODULE_INDICATOR([strtoll]) + gl_SYS_RANDOM_H + gl_SYS_RANDOM_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_SYS_STAT_H + gl_SYS_STAT_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_SYS_TIME_H + gl_SYS_TIME_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_SYS_TYPES_H + gl_SYS_TYPES_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_SYS_WAIT_H + gl_SYS_WAIT_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + AC_REQUIRE([AC_C_RESTRICT]) + gl_FUNC_GEN_TEMPNAME + gl_MODULE_INDICATOR([tempname]) + AC_REQUIRE([gl_THREADLIB]) + gl_TIME_H + gl_TIME_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_TIME_R + gl_CONDITIONAL([GL_COND_OBJ_TIME_R], + [test $HAVE_LOCALTIME_R = 0 || test $REPLACE_LOCALTIME_R = 1]) + AM_COND_IF([GL_COND_OBJ_TIME_R], [ + gl_PREREQ_TIME_R + ]) + gl_TIME_MODULE_INDICATOR([time_r]) + gl_TIME_RZ + gl_CONDITIONAL([GL_COND_OBJ_TIME_RZ], [test $HAVE_TIMEZONE_T = 0]) + gl_TIME_MODULE_INDICATOR([time_rz]) + gl_FUNC_TIMEGM + gl_CONDITIONAL([GL_COND_OBJ_TIMEGM], + [test $HAVE_TIMEGM = 0 || test $REPLACE_TIMEGM = 1]) + AM_COND_IF([GL_COND_OBJ_TIMEGM], [ + gl_PREREQ_TIMEGM + ]) + gl_TIME_MODULE_INDICATOR([timegm]) + gl_TIMESPEC + gl_FUNC_TIMESPEC_GET + gl_CONDITIONAL([GL_COND_OBJ_TIMESPEC_GET], + [test $HAVE_TIMESPEC_GET = 0 || test $REPLACE_TIMESPEC_GET = 1]) + gl_TIME_MODULE_INDICATOR([timespec_get]) + gl_FUNC_TZSET + gl_CONDITIONAL([GL_COND_OBJ_TZSET], [test $REPLACE_TZSET = 1]) + gl_TIME_MODULE_INDICATOR([tzset]) + gl_UCHAR_H + gl_UCHAR_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_LIBUNISTRING_LIBHEADER([1.2], [unicase.h]) + gl_UNICASE_H + gl_UNICASE_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_LIBUNISTRING_MODULE([0.9.11], [unicase/tolower]) + gl_LIBUNISTRING_LIBHEADER([1.2], [unictype.h]) + gl_UNICTYPE_H + gl_UNICTYPE_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + AC_REQUIRE([AC_C_INLINE]) + gl_LIBUNISTRING_MODULE([1.1], [unictype/ctype-alnum]) + AC_REQUIRE([AC_C_INLINE]) + gl_LIBUNISTRING_MODULE([1.1], [unictype/ctype-alpha]) + AC_REQUIRE([AC_C_INLINE]) + gl_LIBUNISTRING_MODULE([0.9.8], [unictype/ctype-blank]) + AC_REQUIRE([AC_C_INLINE]) + gl_LIBUNISTRING_MODULE([0.9.8], [unictype/ctype-cntrl]) + AC_REQUIRE([AC_C_INLINE]) + gl_LIBUNISTRING_MODULE([0.9.8], [unictype/ctype-digit]) + AC_REQUIRE([AC_C_INLINE]) + gl_LIBUNISTRING_MODULE([1.1], [unictype/ctype-graph]) + AC_REQUIRE([AC_C_INLINE]) + gl_LIBUNISTRING_MODULE([0.9.11], [unictype/ctype-lower]) + AC_REQUIRE([AC_C_INLINE]) + gl_LIBUNISTRING_MODULE([1.1], [unictype/ctype-print]) + AC_REQUIRE([AC_C_INLINE]) + gl_LIBUNISTRING_MODULE([1.1], [unictype/ctype-punct]) + AC_REQUIRE([AC_C_INLINE]) + gl_LIBUNISTRING_MODULE([0.9.8], [unictype/ctype-space]) + AC_REQUIRE([AC_C_INLINE]) + gl_LIBUNISTRING_MODULE([0.9.11], [unictype/ctype-upper]) + AC_REQUIRE([AC_C_INLINE]) + gl_LIBUNISTRING_MODULE([0.9.8], [unictype/ctype-xdigit]) + gl_LIBUNISTRING_LIBHEADER([1.2], [uninorm.h]) + gl_UNINORM_H + gl_UNINORM_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_UNISTD_H + gl_UNISTD_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_UNISTD_SAFER + gl_LIBUNISTRING_LIBHEADER([1.2], [unistr.h]) + AC_PROG_MKDIR_P + gl_LIBUNISTRING_MODULE([0.9], [unistr/u32-chr]) + gl_LIBUNISTRING_MODULE([0.9], [unistr/u32-cpy]) + gl_LIBUNISTRING_MODULE([1.2], [unistr/u32-pcpy]) + gl_LIBUNISTRING_MODULE([0.9], [unistr/u32-strcat]) + gl_LIBUNISTRING_MODULE([0.9], [unistr/u32-strlen]) + gl_LIBUNISTRING_LIBHEADER([0.9.11], [unitypes.h]) + AC_PROG_MKDIR_P + AH_VERBATIM([unitypes_restrict], [ + /* This definition is a duplicate of the one in unitypes.h. + It is here so that we can cope with an older version of unitypes.h + that does not contain this definition and that is pre-installed among + the public header files. */ + # if defined __restrict \ + || 2 < __GNUC__ + (95 <= __GNUC_MINOR__) \ + || __clang_major__ >= 3 + # define _UC_RESTRICT __restrict + # elif 199901L <= __STDC_VERSION__ || defined restrict + # define _UC_RESTRICT restrict + # else + # define _UC_RESTRICT + # endif + ]) + gl_LIBUNISTRING_LIBHEADER([0.9.11], [uniwidth.h]) + AC_PROG_MKDIR_P + gl_LIBUNISTRING_MODULE([1.1], [uniwidth/width]) + AC_DEFINE([GNULIB_STDIO_SINGLE_THREAD], [1], + [Define to 1 if you want the FILE stream functions getc, putc, etc. + to use unlocked I/O if available, throughout the package. + Unlocked I/O can improve performance, sometimes dramatically. + But unlocked I/O is safe only in single-threaded programs, + as well as in multithreaded programs for which you can guarantee that + every FILE stream, including stdin, stdout, stderr, is used only + in a single thread.]) + AC_DEFINE([USE_UNLOCKED_IO], [GNULIB_STDIO_SINGLE_THREAD], + [An alias of GNULIB_STDIO_SINGLE_THREAD.]) + gl_FUNC_GLIBC_UNLOCKED_IO + gl_FUNC_UNSETENV + gl_CONDITIONAL([GL_COND_OBJ_UNSETENV], + [test $HAVE_UNSETENV = 0 || test $REPLACE_UNSETENV = 1]) + AM_COND_IF([GL_COND_OBJ_UNSETENV], [ + gl_PREREQ_UNSETENV + ]) + gl_STDLIB_MODULE_INDICATOR([unsetenv]) + AC_C_VARARRAYS + gl_VERSION_ETC + gl_WCHAR_H + gl_WCHAR_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_FUNC_WCRTOMB + gl_CONDITIONAL([GL_COND_OBJ_WCRTOMB], + [test $HAVE_WCRTOMB = 0 || test $REPLACE_WCRTOMB = 1]) + AM_COND_IF([GL_COND_OBJ_WCRTOMB], [ + gl_PREREQ_WCRTOMB + ]) + gl_WCHAR_MODULE_INDICATOR([wcrtomb]) + gl_FUNC_WCTYPE + gl_CONDITIONAL([GL_COND_OBJ_WCTYPE], [test $HAVE_WCTYPE = 0 || test $REPLACE_WCTYPE = 1]) + gl_WCTYPE_MODULE_INDICATOR([wctype]) + gl_WCTYPE_H + gl_WCTYPE_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_FUNC_WCWIDTH + gl_CONDITIONAL([GL_COND_OBJ_WCWIDTH], + [test $HAVE_WCWIDTH = 0 || test $REPLACE_WCWIDTH = 1]) + AM_COND_IF([GL_COND_OBJ_WCWIDTH], [ + gl_PREREQ_WCWIDTH + ]) + gl_WCHAR_MODULE_INDICATOR([wcwidth]) + AC_REQUIRE([AC_CANONICAL_HOST]) + gl_CONDITIONAL([GL_COND_OBJ_WINDOWS_MUTEX], + [case "$host_os" in mingw* | windows*) true;; *) false;; esac]) + AC_REQUIRE([AC_CANONICAL_HOST]) + gl_CONDITIONAL([GL_COND_OBJ_WINDOWS_ONCE], + [case "$host_os" in mingw* | windows*) true;; *) false;; esac]) + AC_REQUIRE([AC_CANONICAL_HOST]) + gl_CONDITIONAL([GL_COND_OBJ_WINDOWS_RECMUTEX], + [case "$host_os" in mingw* | windows*) true;; *) false;; esac]) + AC_REQUIRE([AC_CANONICAL_HOST]) + gl_CONDITIONAL([GL_COND_OBJ_WINDOWS_RWLOCK], + [case "$host_os" in mingw* | windows*) true;; *) false;; esac]) + gl_FUNC_WMEMCHR + gl_CONDITIONAL([GL_COND_OBJ_WMEMCHR], [test $HAVE_WMEMCHR = 0]) + gl_WCHAR_MODULE_INDICATOR([wmemchr]) + gl_FUNC_WMEMPCPY + gl_CONDITIONAL([GL_COND_OBJ_WMEMPCPY], + [test $HAVE_WMEMPCPY = 0 || test $REPLACE_WMEMPCPY = 1]) + gl_WCHAR_MODULE_INDICATOR([wmempcpy]) + gl_XALLOC + gl_MODULE_INDICATOR([xalloc]) + gl_MODULE_INDICATOR([xalloc-die]) + gl_XSTRTOL + # End of code from modules + m4_ifval(gl_LIBSOURCES_LIST, [ + m4_syscmd([test ! -d ]m4_defn([gl_LIBSOURCES_DIR])[ || + for gl_file in ]gl_LIBSOURCES_LIST[ ; do + if test ! -r ]m4_defn([gl_LIBSOURCES_DIR])[/$gl_file ; then + echo "missing file ]m4_defn([gl_LIBSOURCES_DIR])[/$gl_file" >&2 + exit 1 + fi + done])dnl + m4_if(m4_sysval, [0], [], + [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])]) + ]) + m4_popdef([GL_MODULE_INDICATOR_PREFIX]) + m4_popdef([GL_MACRO_PREFIX]) + m4_popdef([gl_LIBSOURCES_DIR]) + m4_popdef([gl_LIBSOURCES_LIST]) + m4_popdef([AC_LIBSOURCES]) + m4_popdef([AC_REPLACE_FUNCS]) + m4_popdef([AC_LIBOBJ]) + AC_CONFIG_COMMANDS_PRE([ + gl_libobjs= + gl_ltlibobjs= + gl_libobjdeps= + if test -n "$gl_LIBOBJS"; then + # Remove the extension. +changequote(,)dnl + sed_drop_objext='s/\.o$//;s/\.obj$//' + sed_dirname1='s,//*,/,g' + sed_dirname2='s,\(.\)/$,\1,' + sed_dirname3='s,^[^/]*$,.,' + sed_dirname4='s,\(.\)/[^/]*$,\1,' + sed_basename1='s,.*/,,' +changequote([, ])dnl + for i in `for i in $gl_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do + gl_libobjs="$gl_libobjs $i.$ac_objext" + gl_ltlibobjs="$gl_ltlibobjs $i.lo" + i_dir=`echo "$i" | sed -e "$sed_dirname1" -e "$sed_dirname2" -e "$sed_dirname3" -e "$sed_dirname4"` + i_base=`echo "$i" | sed -e "$sed_basename1"` + gl_libobjdeps="$gl_libobjdeps $i_dir/\$(DEPDIR)/$i_base.Po" + done + fi + AC_SUBST([gl_LIBOBJS], [$gl_libobjs]) + AC_SUBST([gl_LTLIBOBJS], [$gl_ltlibobjs]) + AC_SUBST([gl_LIBOBJDEPS], [$gl_libobjdeps]) + ]) + gltests_libdeps= + gltests_ltlibdeps= + m4_pushdef([AC_LIBOBJ], m4_defn([gltests_LIBOBJ])) + m4_pushdef([AC_REPLACE_FUNCS], m4_defn([gltests_REPLACE_FUNCS])) + m4_pushdef([AC_LIBSOURCES], m4_defn([gltests_LIBSOURCES])) + m4_pushdef([gltests_LIBSOURCES_LIST], []) + m4_pushdef([gltests_LIBSOURCES_DIR], []) + m4_pushdef([GL_MACRO_PREFIX], [gltests]) + m4_pushdef([GL_MODULE_INDICATOR_PREFIX], [GL]) + gl_COMMON + AC_REQUIRE([gl_CC_ALLOW_WARNINGS]) + AC_REQUIRE([gl_CXX_ALLOW_WARNINGS]) + gl_source_base='gnulib-tests' + gl_source_base_prefix= +changequote(,)dnl + gltests_WITNESS=IN_`echo "${PACKAGE-$PACKAGE_TARNAME}" | LC_ALL=C tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ | LC_ALL=C sed -e 's/[^A-Z0-9_]/_/g'`_GNULIB_TESTS +changequote([, ])dnl + AC_SUBST([gltests_WITNESS]) + gl_module_indicator_condition=$gltests_WITNESS + m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [$gl_module_indicator_condition]) + AC_REQUIRE([gl_SYS_SOCKET_H]) + gl_CONDITIONAL([GL_COND_OBJ_ACCEPT], [test "$ac_cv_header_winsock2_h" = yes]) + gl_SYS_SOCKET_MODULE_INDICATOR([accept]) + gl_ALIGNASOF + gl_ARPA_INET_H + gl_ARPA_INET_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_FUNC_ATOLL + gl_CONDITIONAL([GL_COND_OBJ_ATOLL], [test $HAVE_ATOLL = 0]) + AM_COND_IF([GL_COND_OBJ_ATOLL], [ + gl_PREREQ_ATOLL + ]) + gl_STDLIB_MODULE_INDICATOR([atoll]) + AC_REQUIRE([gl_SYS_SOCKET_H]) + gl_CONDITIONAL([GL_COND_OBJ_BIND], [test "$ac_cv_header_winsock2_h" = yes]) + gl_SYS_SOCKET_MODULE_INDICATOR([bind]) + gt_LOCALE_FR + gt_LOCALE_FR_UTF8 + gt_LOCALE_FR + gt_LOCALE_FR_UTF8 + gt_LOCALE_FR + gt_LOCALE_TR_UTF8 + gt_LOCALE_FR + gt_LOCALE_FR_UTF8 + gt_LOCALE_JA + gt_LOCALE_ZH_CN + gt_LOCALE_FR + gt_LOCALE_FR_UTF8 + gt_LOCALE_JA + gt_LOCALE_ZH_CN + gl_MUSL_LIBC + gt_LOCALE_FR + gt_LOCALE_FR_UTF8 + gt_LOCALE_JA + gt_LOCALE_ZH_CN + gt_LOCALE_FR + gt_LOCALE_FR_UTF8 + gt_LOCALE_JA + gt_LOCALE_ZH_CN + gl_MUSL_LIBC + gt_LOCALE_FR + gt_LOCALE_FR_UTF8 + gt_LOCALE_JA + gt_LOCALE_ZH_CN + gt_LOCALE_FR + gt_LOCALE_FR_UTF8 + gt_LOCALE_JA + gt_LOCALE_ZH_CN + gl_MUSL_LIBC + gt_LOCALE_FR + gt_LOCALE_FR_UTF8 + gt_LOCALE_JA + gt_LOCALE_ZH_CN + gl_MUSL_LIBC + gt_LOCALE_FR + gt_LOCALE_FR_UTF8 + gt_LOCALE_JA + gt_LOCALE_ZH_CN + gl_MUSL_LIBC + gt_LOCALE_FR + gt_LOCALE_FR_UTF8 + gt_LOCALE_JA + gt_LOCALE_ZH_CN + gt_LOCALE_FR + gt_LOCALE_FR_UTF8 + gt_LOCALE_JA + gt_LOCALE_ZH_CN + gt_LOCALE_FR + gt_LOCALE_FR_UTF8 + gt_LOCALE_JA + gt_LOCALE_ZH_CN + gt_LOCALE_FR + gt_LOCALE_FR_UTF8 + gt_LOCALE_JA + gt_LOCALE_ZH_CN + gl_FUNC_C32RTOMB + gl_CONDITIONAL([GL_COND_OBJ_C32RTOMB], + [test $HAVE_C32RTOMB = 0 || test $REPLACE_C32RTOMB = 1]) + gl_UCHAR_MODULE_INDICATOR([c32rtomb]) + gt_LOCALE_FR + gt_LOCALE_FR_UTF8 + gt_LOCALE_JA + gt_LOCALE_ZH_CN + AC_REQUIRE([gl_MBRTOC32_SANITYCHECK]) + gl_UCHAR_MODULE_INDICATOR([c32tob]) + gt_LOCALE_FR + gt_LOCALE_FR_UTF8 + gt_LOCALE_JA + gt_LOCALE_ZH_CN + AC_REQUIRE([gl_SYS_SOCKET_H]) + gl_CONDITIONAL([GL_COND_OBJ_CONNECT], [test "$ac_cv_header_winsock2_h" = yes]) + gl_SYS_SOCKET_MODULE_INDICATOR([connect]) + gl_FUNC_FDOPEN + gl_CONDITIONAL([GL_COND_OBJ_FDOPEN], [test $REPLACE_FDOPEN = 1]) + AM_COND_IF([GL_COND_OBJ_FDOPEN], [ + gl_PREREQ_FDOPEN + ]) + gl_STDIO_MODULE_INDICATOR([fdopen]) + gl_FLOAT_H + gl_CONDITIONAL_HEADER([float.h]) + AC_PROG_MKDIR_P + gl_CONDITIONAL([GL_COND_OBJ_FLOAT], [test $REPLACE_FLOAT_LDBL = 1]) + gl_CONDITIONAL([GL_COND_OBJ_ITOLD], [test $REPLACE_ITOLD = 1]) + gt_LOCALE_FR + gt_LOCALE_FR_UTF8 + gt_LOCALE_JA + gt_LOCALE_ZH_CN + gl_FUNC_FTRUNCATE + gl_CONDITIONAL([GL_COND_OBJ_FTRUNCATE], + [test $HAVE_FTRUNCATE = 0 || test $REPLACE_FTRUNCATE = 1]) + AM_COND_IF([GL_COND_OBJ_FTRUNCATE], [ + gl_PREREQ_FTRUNCATE + ]) + gl_UNISTD_MODULE_INDICATOR([ftruncate]) + gl_MUSL_LIBC + dnl Distinguish OpenBSD >= 6.2 from OpenBSD < 6.2. + gl_CHECK_FUNCS_ANDROID([duplocale], [[#include ]]) + gl_FUNC_INET_PTON + gl_CONDITIONAL([GL_COND_OBJ_INET_PTON], + [test $HAVE_INET_PTON = 0 || test $REPLACE_INET_PTON = 1]) + AM_COND_IF([GL_COND_OBJ_INET_PTON], [ + gl_PREREQ_INET_PTON + ]) + gl_ARPA_INET_MODULE_INDICATOR([inet_pton]) + AC_C_BIGENDIAN + gl_INTTOSTR + gl_FUNC_IOCTL + gl_CONDITIONAL([GL_COND_OBJ_IOCTL], + [test $HAVE_IOCTL = 0 || test $REPLACE_IOCTL = 1]) + gl_SYS_IOCTL_MODULE_INDICATOR([ioctl]) + gl_FUNC_ISNAND_NO_LIBM + if test $gl_func_isnand_no_libm != yes; then + AC_LIBOBJ([isnand]) + gl_PREREQ_ISNAND + fi + gl_FUNC_ISNANF_NO_LIBM + if test $gl_func_isnanf_no_libm != yes; then + AC_LIBOBJ([isnanf]) + gl_PREREQ_ISNANF + fi + gl_FUNC_ISNANL_NO_LIBM + if test $gl_func_isnanl_no_libm != yes; then + AC_LIBOBJ([isnanl]) + gl_PREREQ_ISNANL + fi + AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE]) + gt_LOCALE_FR + gt_LOCALE_FR_UTF8 + gt_LOCALE_JA + gt_LOCALE_ZH_CN + gt_LOCALE_FR + gt_LOCALE_FR_UTF8 + gt_LOCALE_JA + gt_LOCALE_ZH_CN + AC_REQUIRE([gl_SYS_SOCKET_H]) + gl_CONDITIONAL([GL_COND_OBJ_LISTEN], [test "$ac_cv_header_winsock2_h" = yes]) + gl_SYS_SOCKET_MODULE_INDICATOR([listen]) + gl_CHECK_FUNCS_ANDROID([newlocale], [[#include ]]) + gl_MATH_H + gl_MATH_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gt_LOCALE_FR + gt_LOCALE_FR_UTF8 + gt_LOCALE_JA + gt_LOCALE_ZH_CN + gt_LOCALE_FR + gt_LOCALE_FR_UTF8 + gt_LOCALE_JA + gt_LOCALE_ZH_CN + gt_LOCALE_TR_UTF8 + gt_LOCALE_FR_UTF8 + gt_LOCALE_FR + gt_LOCALE_FR_UTF8 + gt_LOCALE_JA + gt_LOCALE_ZH_CN + gt_LOCALE_FR + gt_LOCALE_FR_UTF8 + gt_LOCALE_JA + gt_LOCALE_ZH_CN + dnl Check for prerequisites for memory fence checks. + gl_FUNC_MMAP_ANON + AC_CHECK_HEADERS_ONCE([sys/mman.h]) + AC_CHECK_FUNCS_ONCE([mprotect]) + gl_FUNC_MMAP_ANON + AC_CHECK_HEADERS_ONCE([sys/mman.h]) + AC_CHECK_FUNCS_ONCE([mprotect]) + gl_FUNC_NANOSLEEP + gl_CONDITIONAL([GL_COND_OBJ_NANOSLEEP], + [test $HAVE_NANOSLEEP = 0 || test $REPLACE_NANOSLEEP = 1]) + gl_TIME_MODULE_INDICATOR([nanosleep]) + AC_CHECK_DECLS_ONCE([alarm]) + gl_HEADER_NETINET_IN + gl_CONDITIONAL_HEADER([netinet/in.h]) + AC_PROG_MKDIR_P + gt_LOCALE_FR + gt_LOCALE_FR_UTF8 + gt_FUNC_USELOCALE + gl_MUSL_LIBC + gl_FUNC_PERROR + gl_CONDITIONAL([GL_COND_OBJ_PERROR], [test $REPLACE_PERROR = 1]) + gl_STRING_MODULE_INDICATOR([perror]) + gl_PRIV_SET + gl_FUNC_PSELECT + gl_CONDITIONAL([GL_COND_OBJ_PSELECT], + [test $HAVE_PSELECT = 0 || test $REPLACE_PSELECT = 1]) + gl_SYS_SELECT_MODULE_INDICATOR([pselect]) + AC_CHECK_HEADERS_ONCE([sys/wait.h]) + gl_PTHREAD_H + gl_PTHREAD_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_PTHREAD_THREAD + gl_CONDITIONAL([GL_COND_OBJ_PTHREAD_THREAD], + [test $HAVE_PTHREAD_CREATE = 0 || test $REPLACE_PTHREAD_CREATE = 1]) + gl_PTHREAD_MODULE_INDICATOR([pthread-thread]) + gl_FUNC_PTHREAD_SIGMASK + gl_CONDITIONAL([GL_COND_OBJ_PTHREAD_SIGMASK], + [test $HAVE_PTHREAD_SIGMASK = 0 || test $REPLACE_PTHREAD_SIGMASK = 1]) + AM_COND_IF([GL_COND_OBJ_PTHREAD_SIGMASK], [ + gl_PREREQ_PTHREAD_SIGMASK + ]) + gl_SIGNAL_MODULE_INDICATOR([pthread_sigmask]) + gl_FUNC_PUTENV + gl_CONDITIONAL([GL_COND_OBJ_PUTENV], [test $REPLACE_PUTENV = 1]) + AM_COND_IF([GL_COND_OBJ_PUTENV], [ + gl_PREREQ_PUTENV + ]) + gl_STDLIB_MODULE_INDICATOR([putenv]) + dnl Check for prerequisites for memory fence checks. + dnl FIXME: zerosize-ptr.h requires these: make a module for it + gl_FUNC_MMAP_ANON + AC_CHECK_HEADERS_ONCE([sys/mman.h]) + AC_CHECK_FUNCS_ONCE([mprotect]) + dnl Check for prerequisites for memory fence checks. + gl_FUNC_MMAP_ANON + AC_CHECK_HEADERS_ONCE([sys/mman.h]) + AC_CHECK_FUNCS_ONCE([mprotect]) + gl_FUNC_RMDIR + gl_CONDITIONAL([GL_COND_OBJ_RMDIR], [test $REPLACE_RMDIR = 1]) + gl_UNISTD_MODULE_INDICATOR([rmdir]) + gl_SCHED_H + gl_SCHED_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_FUNC_SELECT + gl_CONDITIONAL([GL_COND_OBJ_SELECT], [test $REPLACE_SELECT = 1]) + gl_SYS_SELECT_MODULE_INDICATOR([select]) + AC_CHECK_HEADERS_ONCE([sys/wait.h]) + AC_REQUIRE([gl_SYS_SOCKET_H]) + gl_CONDITIONAL([GL_COND_OBJ_SETSOCKOPT], + [test "$ac_cv_header_winsock2_h" = yes]) + gl_SYS_SOCKET_MODULE_INDICATOR([setsockopt]) + gl_SIGNBIT + gl_CONDITIONAL([GL_COND_OBJ_SIGNBIT3], [test $REPLACE_SIGNBIT = 1]) + gl_MATH_MODULE_INDICATOR([signbit]) + AC_CHECK_FUNCS_ONCE([setrlimit]) + gl_FUNC_MMAP_ANON + gl_SIZE_MAX + gl_FUNC_SLEEP + gl_CONDITIONAL([GL_COND_OBJ_SLEEP], + [test $HAVE_SLEEP = 0 || test $REPLACE_SLEEP = 1]) + gl_UNISTD_MODULE_INDICATOR([sleep]) + AC_CHECK_DECLS_ONCE([alarm]) + gl_SNAN + gl_NAN_MIPS + gl_FUNC_SNPRINTF + gl_STDIO_MODULE_INDICATOR([snprintf]) + gl_MODULE_INDICATOR([snprintf]) + AC_REQUIRE([gl_SYS_SOCKET_H]) + gl_CONDITIONAL([GL_COND_OBJ_SOCKET], [test "$ac_cv_header_winsock2_h" = yes]) + # When this module is used, sockets may actually occur as file descriptors, + # hence it is worth warning if the modules 'close' and 'ioctl' are not used. + m4_ifdef([gl_UNISTD_H_DEFAULTS], [gl_UNISTD_H_REQUIRE_DEFAULTS]) + m4_ifdef([gl_SYS_IOCTL_H_DEFAULTS], [gl_SYS_IOCTL_H_REQUIRE_DEFAULTS]) + AC_REQUIRE([gl_PREREQ_SYS_H_WINSOCK2]) + if test "$ac_cv_header_winsock2_h" = yes; then + UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS=1 + SYS_IOCTL_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS=1 + fi + gl_SYS_SOCKET_MODULE_INDICATOR([socket]) + AC_REQUIRE([gl_SOCKETLIB]) + AC_REQUIRE([gl_SOCKETS]) + gl_TYPE_SOCKLEN_T + AC_REQUIRE([gt_TYPE_WCHAR_T]) + AC_REQUIRE([gt_TYPE_WINT_T]) + gl_DOUBLE_EXPONENT_LOCATION + gl_FUNC_STRERROR_R + AS_IF([test $HAVE_DECL_STRERROR_R = 0 || test $REPLACE_STRERROR_R = 1], [ + AC_LIBOBJ([strerror_r]) + gl_PREREQ_STRERROR_R + ]) + gl_STRING_MODULE_INDICATOR([strerror_r]) + dnl For the modules argp, error, xstrerror. + gl_MODULE_INDICATOR([strerror_r-posix]) + dnl Check for prerequisites for memory fence checks. + gl_FUNC_MMAP_ANON + AC_CHECK_HEADERS_ONCE([sys/mman.h]) + AC_CHECK_FUNCS_ONCE([mprotect]) + gl_FUNC_SYMLINK + gl_CONDITIONAL([GL_COND_OBJ_SYMLINK], + [test $HAVE_SYMLINK = 0 || test $REPLACE_SYMLINK = 1]) + gl_UNISTD_MODULE_INDICATOR([symlink]) + gl_FUNC_SYMLINKAT + gl_CONDITIONAL([GL_COND_OBJ_SYMLINKAT], + [test $HAVE_SYMLINKAT = 0 || test $REPLACE_SYMLINKAT = 1]) + gl_UNISTD_MODULE_INDICATOR([symlinkat]) + gl_SYS_IOCTL_H + gl_SYS_IOCTL_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_SYS_SELECT_H + gl_SYS_SELECT_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_SYS_SOCKET_H + gl_SYS_SOCKET_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + AC_CHECK_FUNCS_ONCE([shutdown]) + gl_SYS_UIO_H + gl_SYS_UIO_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_THREAD + gl_FUNC_TIME + gl_CONDITIONAL([GL_COND_OBJ_TIME], [test $REPLACE_TIME = 1]) + AM_COND_IF([GL_COND_OBJ_TIME], [ + gl_PREREQ_TIME + ]) + gl_TIME_MODULE_INDICATOR([time]) + gl_FUNC_MMAP_ANON + AC_CHECK_HEADERS_ONCE([sys/mman.h]) + AC_CHECK_FUNCS_ONCE([mprotect]) + gl_LIBUNISTRING_MODULE([0.9], [unistr/u32-set]) + gl_FUNC_UNLINK + gl_CONDITIONAL([GL_COND_OBJ_UNLINK], [test $REPLACE_UNLINK = 1]) + gl_UNISTD_MODULE_INDICATOR([unlink]) + gl_FUNC_UNLINKAT + gl_CONDITIONAL([GL_COND_OBJ_UNLINKAT], + [test $HAVE_UNLINKAT = 0 || test $REPLACE_UNLINKAT = 1]) + gl_UNISTD_MODULE_INDICATOR([unlinkat]) + gl_UNLINKDIR + abs_aux_dir=`cd "$ac_aux_dir"; pwd` + AC_SUBST([abs_aux_dir]) + AC_REQUIRE([AC_C_RESTRICT]) + gl_FUNC_VASNPRINTF + abs_aux_dir=`cd "$ac_aux_dir"; pwd` + AC_SUBST([abs_aux_dir]) + gt_LOCALE_FR + gt_LOCALE_FR_UTF8 + gt_LOCALE_JA + gt_LOCALE_ZH_CN + gl_FUNC_WCTOB + gl_CONDITIONAL([GL_COND_OBJ_WCTOB], + [test $HAVE_WCTOB = 0 || test $REPLACE_WCTOB = 1]) + AM_COND_IF([GL_COND_OBJ_WCTOB], [ + gl_PREREQ_WCTOB + ]) + gl_WCHAR_MODULE_INDICATOR([wctob]) + gl_FUNC_WCTOMB + gl_CONDITIONAL([GL_COND_OBJ_WCTOMB], [test $REPLACE_WCTOMB = 1]) + AM_COND_IF([GL_COND_OBJ_WCTOMB], [ + gl_PREREQ_WCTOMB + ]) + gl_STDLIB_MODULE_INDICATOR([wctomb]) + AC_REQUIRE([AC_CANONICAL_HOST]) + gl_CONDITIONAL([GL_COND_OBJ_WINDOWS_THREAD], + [case "$host_os" in mingw* | windows*) true;; *) false;; esac]) + AC_REQUIRE([AC_CANONICAL_HOST]) + gl_CONDITIONAL([GL_COND_OBJ_WINDOWS_TLS], + [case "$host_os" in mingw* | windows*) true;; *) false;; esac]) + gl_XSIZE + m4_popdef([gl_MODULE_INDICATOR_CONDITION]) + m4_ifval(gltests_LIBSOURCES_LIST, [ + m4_syscmd([test ! -d ]m4_defn([gltests_LIBSOURCES_DIR])[ || + for gl_file in ]gltests_LIBSOURCES_LIST[ ; do + if test ! -r ]m4_defn([gltests_LIBSOURCES_DIR])[/$gl_file ; then + echo "missing file ]m4_defn([gltests_LIBSOURCES_DIR])[/$gl_file" >&2 + exit 1 + fi + done])dnl + m4_if(m4_sysval, [0], [], + [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])]) + ]) + m4_popdef([GL_MODULE_INDICATOR_PREFIX]) + m4_popdef([GL_MACRO_PREFIX]) + m4_popdef([gltests_LIBSOURCES_DIR]) + m4_popdef([gltests_LIBSOURCES_LIST]) + m4_popdef([AC_LIBSOURCES]) + m4_popdef([AC_REPLACE_FUNCS]) + m4_popdef([AC_LIBOBJ]) + AC_CONFIG_COMMANDS_PRE([ + gltests_libobjs= + gltests_ltlibobjs= + gltests_libobjdeps= + if test -n "$gltests_LIBOBJS"; then + # Remove the extension. +changequote(,)dnl + sed_drop_objext='s/\.o$//;s/\.obj$//' + sed_dirname1='s,//*,/,g' + sed_dirname2='s,\(.\)/$,\1,' + sed_dirname3='s,^[^/]*$,.,' + sed_dirname4='s,\(.\)/[^/]*$,\1,' + sed_basename1='s,.*/,,' +changequote([, ])dnl + for i in `for i in $gltests_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do + gltests_libobjs="$gltests_libobjs $i.$ac_objext" + gltests_ltlibobjs="$gltests_ltlibobjs $i.lo" + i_dir=`echo "$i" | sed -e "$sed_dirname1" -e "$sed_dirname2" -e "$sed_dirname3" -e "$sed_dirname4"` + i_base=`echo "$i" | sed -e "$sed_basename1"` + gltests_libobjdeps="$gltests_libobjdeps $i_dir/\$(DEPDIR)/$i_base.Po" + done + fi + AC_SUBST([gltests_LIBOBJS], [$gltests_libobjs]) + AC_SUBST([gltests_LTLIBOBJS], [$gltests_ltlibobjs]) + AC_SUBST([gltests_LIBOBJDEPS], [$gltests_libobjdeps]) + ]) + AC_REQUIRE([gl_CC_GNULIB_WARNINGS]) + LIBDIFFUTILS_LIBDEPS="$gl_libdeps" + AC_SUBST([LIBDIFFUTILS_LIBDEPS]) + LIBDIFFUTILS_LTLIBDEPS="$gl_ltlibdeps" + AC_SUBST([LIBDIFFUTILS_LTLIBDEPS]) + LIBTESTS_LIBDEPS="$gltests_libdeps" + AC_SUBST([LIBTESTS_LIBDEPS]) +]) + +# Like AC_LIBOBJ, except that the module name goes +# into gl_LIBOBJS instead of into LIBOBJS. +AC_DEFUN([gl_LIBOBJ], [ + AS_LITERAL_IF([$1], [gl_LIBSOURCES([$1.c])])dnl + gl_LIBOBJS="$gl_LIBOBJS $1.$ac_objext" +]) + +# Like AC_REPLACE_FUNCS, except that the module name goes +# into gl_LIBOBJS instead of into LIBOBJS. +AC_DEFUN([gl_REPLACE_FUNCS], [ + m4_foreach_w([gl_NAME], [$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl + AC_CHECK_FUNCS([$1], , [gl_LIBOBJ($ac_func)]) +]) + +# Like AC_LIBSOURCES, except the directory where the source file is +# expected is derived from the gnulib-tool parameterization, +# and alloca is special cased (for the alloca-opt module). +# We could also entirely rely on EXTRA_lib..._SOURCES. +AC_DEFUN([gl_LIBSOURCES], [ + m4_foreach([_gl_NAME], [$1], [ + m4_if(_gl_NAME, [alloca.c], [], [ + m4_define([gl_LIBSOURCES_DIR], [lib]) + m4_append([gl_LIBSOURCES_LIST], _gl_NAME, [ ]) + ]) + ]) +]) + +# Like AC_LIBOBJ, except that the module name goes +# into gltests_LIBOBJS instead of into LIBOBJS. +AC_DEFUN([gltests_LIBOBJ], [ + AS_LITERAL_IF([$1], [gltests_LIBSOURCES([$1.c])])dnl + gltests_LIBOBJS="$gltests_LIBOBJS $1.$ac_objext" +]) + +# Like AC_REPLACE_FUNCS, except that the module name goes +# into gltests_LIBOBJS instead of into LIBOBJS. +AC_DEFUN([gltests_REPLACE_FUNCS], [ + m4_foreach_w([gl_NAME], [$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl + AC_CHECK_FUNCS([$1], , [gltests_LIBOBJ($ac_func)]) +]) + +# Like AC_LIBSOURCES, except the directory where the source file is +# expected is derived from the gnulib-tool parameterization, +# and alloca is special cased (for the alloca-opt module). +# We could also entirely rely on EXTRA_lib..._SOURCES. +AC_DEFUN([gltests_LIBSOURCES], [ + m4_foreach([_gl_NAME], [$1], [ + m4_if(_gl_NAME, [alloca.c], [], [ + m4_define([gltests_LIBSOURCES_DIR], [gnulib-tests]) + m4_append([gltests_LIBSOURCES_LIST], _gl_NAME, [ ]) + ]) + ]) +]) + +# This macro records the list of files which have been installed by +# gnulib-tool and may be removed by future gnulib-tool invocations. +AC_DEFUN([gl_FILE_LIST], [ + build-aux/announce-gen + build-aux/config.rpath + build-aux/do-release-commit-and-tag + build-aux/gendocs.sh + build-aux/git-version-gen + build-aux/gitlog-to-changelog + build-aux/gnu-web-doc-update + build-aux/gnupload + build-aux/update-copyright + build-aux/useless-if-before-free + build-aux/vc-list-files + doc/gendocs_template + doc/gendocs_template_min + lib/_Noreturn.h + lib/alloca.in.h + lib/allocator.c + lib/allocator.h + lib/arg-nonnull.h + lib/argmatch.c + lib/argmatch.h + lib/assert.in.h + lib/assure.h + lib/at-func.c + lib/attribute.h + lib/basename-lgpl.c + lib/basename-lgpl.h + lib/basename.c + lib/binary-io.c + lib/binary-io.h + lib/bitrotate.c + lib/bitrotate.h + lib/btoc32.c + lib/btowc.c + lib/c++defs.h + lib/c-ctype.c + lib/c-ctype.h + lib/c-file-type.c + lib/c-stack.c + lib/c-stack.h + lib/c-strcase.h + lib/c-strcasecmp.c + lib/c-strcaseeq.h + lib/c-strncasecmp.c + lib/c32_apply_type_test.c + lib/c32_get_type_test.c + lib/c32is-impl.h + lib/c32isalnum.c + lib/c32isalpha.c + lib/c32isblank.c + lib/c32iscntrl.c + lib/c32isdigit.c + lib/c32isgraph.c + lib/c32islower.c + lib/c32isprint.c + lib/c32ispunct.c + lib/c32isspace.c + lib/c32isupper.c + lib/c32isxdigit.c + lib/c32to-impl.h + lib/c32tolower.c + lib/c32width.c + lib/calloc.c + lib/careadlinkat.c + lib/careadlinkat.h + lib/cdefs.h + lib/chdir-long.c + lib/chdir-long.h + lib/cloexec.c + lib/cloexec.h + lib/close.c + lib/closedir.c + lib/count-leading-zeros.c + lib/count-leading-zeros.h + lib/ctype.in.h + lib/diffseq.h + lib/dirent-private.h + lib/dirent.in.h + lib/dirfd.c + lib/dirname-lgpl.c + lib/dirname.c + lib/dirname.h + lib/dup-safer-flag.c + lib/dup-safer.c + lib/dup.c + lib/dup2.c + lib/dynarray.h + lib/errno.in.h + lib/error.c + lib/error.in.h + lib/exclude.c + lib/exclude.h + lib/exitfail.c + lib/exitfail.h + lib/fchdir.c + lib/fcntl.c + lib/fcntl.in.h + lib/fd-hook.c + lib/fd-hook.h + lib/fd-safer-flag.c + lib/fd-safer.c + lib/fdopendir.c + lib/file-type.c + lib/file-type.h + lib/filename.h + lib/filenamecat-lgpl.c + lib/filenamecat.c + lib/filenamecat.h + lib/flexmember.h + lib/fnmatch.c + lib/fnmatch.in.h + lib/fnmatch_loop.c + lib/fopen.c + lib/free.c + lib/freopen.c + lib/fstat.c + lib/fstatat.c + lib/getcwd-lgpl.c + lib/getdtablesize.c + lib/getopt-cdefs.in.h + lib/getopt-core.h + lib/getopt-ext.h + lib/getopt-pfx-core.h + lib/getopt-pfx-ext.h + lib/getopt.c + lib/getopt.in.h + lib/getopt1.c + lib/getopt_int.h + lib/getpagesize.c + lib/getprogname.c + lib/getprogname.h + lib/getrandom.c + lib/gettext.h + lib/gettime.c + lib/gettimeofday.c + lib/glthread/lock.c + lib/glthread/lock.h + lib/glthread/threadlib.c + lib/hard-locale.c + lib/hard-locale.h + lib/hash.c + lib/hash.h + lib/ialloc.c + lib/ialloc.h + lib/idx.h + lib/ignore-value.h + lib/intprops-internal.h + lib/intprops.h + lib/inttypes.in.h + lib/isblank.c + lib/iswblank.c + lib/iswctype-impl.h + lib/iswctype.c + lib/iswdigit.c + lib/iswpunct.c + lib/iswxdigit.c + lib/langinfo.in.h + lib/lc-charset-dispatch.c + lib/lc-charset-dispatch.h + lib/libc-config.h + lib/limits.in.h + lib/localcharset.c + lib/localcharset.h + lib/locale.in.h + lib/localeconv.c + lib/lstat.c + lib/malloc.c + lib/malloc/dynarray-skeleton.c + lib/malloc/dynarray.h + lib/malloc/dynarray_at_failure.c + lib/malloc/dynarray_emplace_enlarge.c + lib/malloc/dynarray_finalize.c + lib/malloc/dynarray_resize.c + lib/malloc/dynarray_resize_clear.c + lib/malloca.c + lib/malloca.h + lib/mbchar.c + lib/mbchar.h + lib/mbrtoc32.c + lib/mbrtowc-impl-utf8.h + lib/mbrtowc-impl.h + lib/mbrtowc.c + lib/mbscasecmp.c + lib/mbsinit.c + lib/mbsrtoc32s-state.c + lib/mbsrtoc32s.c + lib/mbsrtowcs-impl.h + lib/mbsrtowcs-state.c + lib/mbsrtowcs.c + lib/mbszero.c + lib/mbtowc-impl.h + lib/mbtowc-lock.c + lib/mbtowc-lock.h + lib/mbtowc.c + lib/mbuiter.c + lib/mbuiter.h + lib/mbuiterf.c + lib/mbuiterf.h + lib/memchr.c + lib/memchr.valgrind + lib/mempcpy.c + lib/memrchr.c + lib/minmax.h + lib/mkdir.c + lib/mkstemp.c + lib/mktime-internal.h + lib/mktime.c + lib/msvc-inval.c + lib/msvc-inval.h + lib/msvc-nothrow.c + lib/msvc-nothrow.h + lib/nl_langinfo-lock.c + lib/nl_langinfo.c + lib/nstrftime.c + lib/open.c + lib/openat-die.c + lib/openat-priv.h + lib/openat-proc.c + lib/openat.c + lib/openat.h + lib/opendir.c + lib/pathmax.h + lib/pclose.c + lib/pipe-safer.c + lib/pipe.c + lib/popen.c + lib/progname.c + lib/progname.h + lib/propername-lite.c + lib/propername.h + lib/quote.h + lib/quotearg.c + lib/quotearg.h + lib/raise.c + lib/rawmemchr.c + lib/rawmemchr.valgrind + lib/readdir.c + lib/readlink.c + lib/readlinkat.c + lib/realloc.c + lib/reallocarray.c + lib/regcomp.c + lib/regex.c + lib/regex.h + lib/regex_internal.c + lib/regex_internal.h + lib/regexec.c + lib/same-inode.c + lib/same-inode.h + lib/save-cwd.c + lib/save-cwd.h + lib/setenv.c + lib/setlocale-lock.c + lib/setlocale_null.c + lib/setlocale_null.h + lib/sh-quote.c + lib/sh-quote.h + lib/sig-handler.c + lib/sig-handler.h + lib/sigaction.c + lib/signal.in.h + lib/sigprocmask.c + lib/sigsegv.c + lib/sigsegv.in.h + lib/stackvma.c + lib/stackvma.h + lib/stat-macros.h + lib/stat-time.c + lib/stat-time.h + lib/stat-w32.c + lib/stat-w32.h + lib/stat.c + lib/stdarg.in.h + lib/stdckdint.in.h + lib/stddef.in.h + lib/stdint.in.h + lib/stdio-read.c + lib/stdio-write.c + lib/stdio.in.h + lib/stdlib.in.h + lib/stdopen.c + lib/stdopen.h + lib/stpcpy.c + lib/strcasecmp.c + lib/strdup.c + lib/streq.h + lib/strerror-override.c + lib/strerror-override.h + lib/strerror.c + lib/strftime.h + lib/string.in.h + lib/strings.in.h + lib/stripslash.c + lib/strncasecmp.c + lib/strnlen.c + lib/strnlen1.c + lib/strnlen1.h + lib/strptime.c + lib/strtoimax.c + lib/strtol.c + lib/strtoll.c + lib/sys_random.in.h + lib/sys_stat.in.h + lib/sys_time.in.h + lib/sys_types.in.h + lib/sys_wait.in.h + lib/system-quote.c + lib/system-quote.h + lib/tempname.c + lib/tempname.h + lib/time-internal.h + lib/time.in.h + lib/time_r.c + lib/time_rz.c + lib/timegm.c + lib/timespec.c + lib/timespec.h + lib/timespec_get.c + lib/tzset.c + lib/uchar.in.h + lib/unicase.in.h + lib/unicase/simple-mapping.h + lib/unicase/tolower.c + lib/unicase/tolower.h + lib/unictype.in.h + lib/unictype/bitmap.h + lib/unictype/ctype_alnum.c + lib/unictype/ctype_alnum.h + lib/unictype/ctype_alpha.c + lib/unictype/ctype_alpha.h + lib/unictype/ctype_blank.c + lib/unictype/ctype_blank.h + lib/unictype/ctype_cntrl.c + lib/unictype/ctype_cntrl.h + lib/unictype/ctype_digit.c + lib/unictype/ctype_digit.h + lib/unictype/ctype_graph.c + lib/unictype/ctype_graph.h + lib/unictype/ctype_lower.c + lib/unictype/ctype_lower.h + lib/unictype/ctype_print.c + lib/unictype/ctype_print.h + lib/unictype/ctype_punct.c + lib/unictype/ctype_punct.h + lib/unictype/ctype_space.c + lib/unictype/ctype_space.h + lib/unictype/ctype_upper.c + lib/unictype/ctype_upper.h + lib/unictype/ctype_xdigit.c + lib/unictype/ctype_xdigit.h + lib/uninorm.in.h + lib/unistd--.h + lib/unistd-safer.h + lib/unistd.c + lib/unistd.in.h + lib/unistr.in.h + lib/unistr/u-cpy.h + lib/unistr/u-pcpy.h + lib/unistr/u-strcat.h + lib/unistr/u-strlen.h + lib/unistr/u32-chr.c + lib/unistr/u32-cpy.c + lib/unistr/u32-pcpy.c + lib/unistr/u32-strcat.c + lib/unistr/u32-strlen.c + lib/unitypes.in.h + lib/uniwidth.in.h + lib/uniwidth/cjk.h + lib/uniwidth/width.c + lib/uniwidth/width0.h + lib/uniwidth/width2.h + lib/unlocked-io.h + lib/unsetenv.c + lib/verify.h + lib/version-etc-fsf.c + lib/version-etc.c + lib/version-etc.h + lib/warn-on-use.h + lib/wchar.in.h + lib/wcrtomb.c + lib/wctype-h.c + lib/wctype-impl.h + lib/wctype.c + lib/wctype.in.h + lib/wcwidth.c + lib/windows-initguard.h + 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 + lib/wmemchr-impl.h + lib/wmemchr.c + lib/wmempcpy.c + lib/xalloc-die.c + lib/xalloc-oversized.h + lib/xalloc.h + lib/xfreopen.c + lib/xfreopen.h + lib/xmalloc.c + lib/xmalloca.c + lib/xmalloca.h + lib/xstdopen.c + lib/xstdopen.h + lib/xstrtoimax.c + lib/xstrtol.c + lib/xstrtol.h + lib/xstrtoul.c + m4/00gnulib.m4 + m4/__inline.m4 + m4/absolute-header.m4 + m4/alloca.m4 + m4/arpa_inet_h.m4 + m4/asm-underscore.m4 + m4/assert_h.m4 + m4/atoll.m4 + m4/btowc.m4 + m4/builtin-expect.m4 + m4/c-bool.m4 + m4/c-stack.m4 + m4/c32rtomb.m4 + m4/calloc.m4 + m4/chdir-long.m4 + m4/clock_time.m4 + m4/close.m4 + m4/closedir.m4 + m4/codeset.m4 + m4/config-h.m4 + m4/ctype_h.m4 + m4/dirent_h.m4 + m4/dirfd.m4 + m4/double-slash-root.m4 + m4/dup.m4 + m4/dup2.m4 + m4/eealloc.m4 + m4/environ.m4 + m4/errno_h.m4 + m4/error.m4 + m4/error_h.m4 + m4/exponentd.m4 + m4/exponentf.m4 + m4/exponentl.m4 + m4/extensions.m4 + m4/extern-inline.m4 + m4/fchdir.m4 + m4/fclose.m4 + m4/fcntl-o.m4 + m4/fcntl.m4 + m4/fcntl_h.m4 + m4/fdopen.m4 + m4/fdopendir.m4 + m4/fflush.m4 + m4/filenamecat.m4 + m4/flexmember.m4 + m4/float_h.m4 + m4/fnmatch.m4 + m4/fnmatch_h.m4 + m4/fopen.m4 + m4/fpieee.m4 + m4/free.m4 + m4/freopen.m4 + m4/fstat.m4 + m4/fstatat.m4 + m4/ftruncate.m4 + m4/getcwd.m4 + m4/getdtablesize.m4 + m4/getopt.m4 + m4/getpagesize.m4 + m4/getprogname.m4 + m4/getrandom.m4 + m4/gettime.m4 + m4/gettimeofday.m4 + m4/gnu-make.m4 + m4/gnulib-common.m4 + m4/host-cpu-c-abi.m4 + m4/include_next.m4 + m4/inet_pton.m4 + m4/inline.m4 + m4/intl-thread-locale.m4 + m4/intmax_t.m4 + m4/inttostr.m4 + m4/inttypes.m4 + m4/inttypes_h.m4 + m4/ioctl.m4 + m4/isblank.m4 + m4/isnand.m4 + m4/isnanf.m4 + m4/isnanl.m4 + m4/iswblank.m4 + m4/iswctype.m4 + m4/iswdigit.m4 + m4/iswpunct.m4 + m4/iswxdigit.m4 + m4/langinfo_h.m4 + m4/largefile.m4 + m4/lib-ld.m4 + m4/lib-link.m4 + m4/lib-prefix.m4 + m4/libsigsegv.m4 + m4/libunistring-base.m4 + m4/limits-h.m4 + m4/localcharset.m4 + m4/locale-fr.m4 + m4/locale-ja.m4 + m4/locale-tr.m4 + m4/locale-zh.m4 + m4/locale_h.m4 + m4/localeconv.m4 + m4/lock.m4 + m4/lstat.m4 + m4/malloc.m4 + m4/malloca.m4 + m4/manywarnings-c++.m4 + m4/manywarnings.m4 + m4/math_h.m4 + m4/mbchar.m4 + m4/mbiter.m4 + m4/mbrtoc32.m4 + m4/mbrtowc.m4 + m4/mbsinit.m4 + m4/mbsrtowcs.m4 + m4/mbstate_t.m4 + m4/mbtowc.m4 + m4/memchr.m4 + m4/mempcpy.m4 + m4/memrchr.m4 + m4/minmax.m4 + m4/mkdir.m4 + m4/mkstemp.m4 + m4/mktime.m4 + m4/mmap-anon.m4 + m4/mode_t.m4 + m4/msvc-inval.m4 + m4/msvc-nothrow.m4 + m4/multiarch.m4 + m4/musl.m4 + m4/nan-mips.m4 + m4/nanosleep.m4 + m4/netinet_in_h.m4 + m4/nl_langinfo.m4 + m4/nocrash.m4 + m4/nstrftime.m4 + m4/nullptr.m4 + m4/off_t.m4 + m4/open-cloexec.m4 + m4/open-slash.m4 + m4/open.m4 + m4/openat.m4 + m4/opendir.m4 + m4/pathmax.m4 + m4/pclose.m4 + m4/perl.m4 + m4/perror.m4 + m4/pid_t.m4 + m4/pipe.m4 + m4/popen.m4 + m4/printf.m4 + m4/priv-set.m4 + m4/pselect.m4 + m4/pthread-thread.m4 + m4/pthread_h.m4 + m4/pthread_rwlock_rdlock.m4 + m4/pthread_sigmask.m4 + m4/putenv.m4 + m4/quote.m4 + m4/quotearg.m4 + m4/raise.m4 + m4/rawmemchr.m4 + m4/readdir.m4 + m4/readlink.m4 + m4/readlinkat.m4 + m4/realloc.m4 + m4/reallocarray.m4 + m4/regex.m4 + m4/rmdir.m4 + m4/save-cwd.m4 + m4/sched_h.m4 + m4/select.m4 + m4/setenv.m4 + m4/setlocale_null.m4 + m4/sigaction.m4 + m4/sigaltstack.m4 + m4/signal_h.m4 + m4/signalblocking.m4 + m4/signbit.m4 + m4/sigsegv.m4 + m4/size_max.m4 + m4/sleep.m4 + m4/snan.m4 + m4/snprintf.m4 + m4/socketlib.m4 + m4/sockets.m4 + m4/socklen.m4 + m4/sockpfaf.m4 + m4/ssize_t.m4 + m4/stack-direction.m4 + m4/stat-time.m4 + m4/stat.m4 + m4/std-gnu11.m4 + m4/stdalign.m4 + m4/stdarg.m4 + m4/stddef_h.m4 + m4/stdint.m4 + m4/stdint_h.m4 + m4/stdio_h.m4 + m4/stdlib_h.m4 + m4/stpcpy.m4 + m4/strcase.m4 + m4/strdup.m4 + m4/strerror.m4 + m4/strerror_r.m4 + m4/string_h.m4 + m4/strings_h.m4 + m4/strnlen.m4 + m4/strptime.m4 + m4/strtoimax.m4 + m4/strtoll.m4 + m4/symlink.m4 + m4/symlinkat.m4 + m4/sys_ioctl_h.m4 + m4/sys_random_h.m4 + m4/sys_select_h.m4 + m4/sys_socket_h.m4 + m4/sys_stat_h.m4 + m4/sys_time_h.m4 + m4/sys_types_h.m4 + m4/sys_uio_h.m4 + m4/sys_wait_h.m4 + m4/tempname.m4 + m4/thread.m4 + m4/threadlib.m4 + m4/time.m4 + m4/time_h.m4 + m4/time_r.m4 + m4/time_rz.m4 + m4/timegm.m4 + m4/timespec.m4 + m4/timespec_get.m4 + m4/tm_gmtoff.m4 + m4/tzset.m4 + m4/uchar_h.m4 + m4/unicase_h.m4 + m4/unictype_h.m4 + m4/uninorm_h.m4 + m4/unistd-safer.m4 + m4/unistd_h.m4 + m4/unlink.m4 + m4/unlinkat.m4 + m4/unlinkdir.m4 + m4/unlocked-io.m4 + m4/vararrays.m4 + m4/vasnprintf.m4 + m4/version-etc.m4 + m4/visibility.m4 + m4/warn-on-use.m4 + m4/warnings.m4 + m4/wchar_h.m4 + m4/wchar_t.m4 + m4/wcrtomb.m4 + m4/wctob.m4 + m4/wctomb.m4 + m4/wctype.m4 + m4/wctype_h.m4 + m4/wcwidth.m4 + m4/wint_t.m4 + m4/wmemchr.m4 + m4/wmempcpy.m4 + m4/xalloc.m4 + m4/xsize.m4 + m4/xstrtol.m4 + m4/zzgnulib.m4 + tests/altstack-util.h + tests/infinity.h + tests/init.sh + tests/locale.c + tests/macros.h + tests/minus-zero.h + tests/mmap-anon-util.h + tests/nap.h + tests/signature.h + tests/test-accept.c + tests/test-alignasof.c + tests/test-alloca-opt.c + tests/test-argmatch.c + tests/test-arpa_inet.c + tests/test-assert.c + tests/test-binary-io.c + tests/test-binary-io.sh + tests/test-bind.c + tests/test-bitrotate.c + tests/test-btoc32-1.sh + tests/test-btoc32-2.sh + tests/test-btoc32-3.sh + tests/test-btoc32.c + tests/test-btowc-1.sh + tests/test-btowc-2.sh + tests/test-btowc-3.sh + tests/test-btowc.c + tests/test-c-ctype.c + tests/test-c-stack.c + tests/test-c-stack.sh + tests/test-c-stack2.sh + tests/test-c-strcase.sh + tests/test-c-strcasecmp.c + tests/test-c-strcasestr.c + tests/test-c-strncasecmp.c + tests/test-c32_apply_type_test.c + tests/test-c32_get_type_test.c + tests/test-c32isalnum.c + tests/test-c32isalnum.sh + tests/test-c32isalpha.c + tests/test-c32isalpha.sh + tests/test-c32isblank.c + tests/test-c32isblank.sh + tests/test-c32iscntrl.c + tests/test-c32iscntrl.sh + tests/test-c32isdigit.c + tests/test-c32isdigit.sh + tests/test-c32isgraph.c + tests/test-c32isgraph.sh + tests/test-c32islower.c + tests/test-c32islower.sh + tests/test-c32isprint.c + tests/test-c32isprint.sh + tests/test-c32ispunct.c + tests/test-c32ispunct.sh + tests/test-c32isspace.c + tests/test-c32isspace.sh + tests/test-c32isupper.c + tests/test-c32isupper.sh + tests/test-c32isxdigit.c + tests/test-c32isxdigit.sh + tests/test-c32rtomb-w32-2.sh + tests/test-c32rtomb-w32-3.sh + tests/test-c32rtomb-w32-4.sh + tests/test-c32rtomb-w32-5.sh + tests/test-c32rtomb-w32-6.sh + tests/test-c32rtomb-w32-7.sh + tests/test-c32rtomb-w32-8.sh + tests/test-c32rtomb-w32.c + tests/test-c32rtomb.c + tests/test-c32rtomb.sh + tests/test-c32tolower.c + tests/test-c32tolower.sh + tests/test-c32width.c + tests/test-calloc-gnu.c + tests/test-chdir.c + tests/test-cloexec.c + tests/test-close.c + tests/test-connect.c + tests/test-count-leading-zeros.c + tests/test-ctype.c + tests/test-dirent.c + tests/test-dirfd.c + tests/test-dirname.c + tests/test-dup-safer.c + tests/test-dup.c + tests/test-dup2.c + tests/test-dynarray.c + tests/test-environ.c + tests/test-errno.c + tests/test-error.c + tests/test-error.sh + tests/test-exclude.c + tests/test-exclude1.sh + tests/test-exclude2.sh + tests/test-exclude3.sh + tests/test-exclude4.sh + tests/test-exclude5.sh + tests/test-exclude6.sh + tests/test-exclude7.sh + tests/test-exclude8.sh + tests/test-fchdir.c + tests/test-fcntl-h.c + tests/test-fcntl.c + tests/test-fdopen.c + tests/test-fdopendir.c + tests/test-fgetc.c + tests/test-filenamecat.c + tests/test-float.c + tests/test-fnmatch-1.sh + tests/test-fnmatch-2.sh + tests/test-fnmatch-3.sh + tests/test-fnmatch-4.sh + tests/test-fnmatch-5.sh + tests/test-fnmatch-h.c + tests/test-fnmatch-w32-2.sh + tests/test-fnmatch-w32-3.sh + tests/test-fnmatch-w32-4.sh + tests/test-fnmatch-w32-5.sh + tests/test-fnmatch-w32-6.sh + tests/test-fnmatch-w32-7.sh + tests/test-fnmatch-w32-8.sh + tests/test-fnmatch-w32.c + tests/test-fnmatch.c + tests/test-fopen-gnu.c + tests/test-fopen.c + tests/test-fopen.h + tests/test-fputc.c + tests/test-fread.c + tests/test-free.c + tests/test-freopen.c + tests/test-fstat.c + tests/test-fstatat.c + tests/test-ftruncate.c + tests/test-ftruncate.sh + tests/test-fwrite.c + tests/test-getcwd-lgpl.c + tests/test-getdtablesize.c + tests/test-getopt-gnu.c + tests/test-getopt-main.h + tests/test-getopt-posix.c + tests/test-getopt.h + tests/test-getopt_long.h + tests/test-getprogname.c + tests/test-getrandom.c + tests/test-gettimeofday.c + tests/test-hard-locale.c + tests/test-hash.c + tests/test-ignore-value.c + tests/test-inet_pton.c + tests/test-init.sh + tests/test-intprops.c + tests/test-inttostr.c + tests/test-inttypes.c + tests/test-ioctl.c + tests/test-isblank.c + tests/test-isnand-nolibm.c + tests/test-isnand.h + tests/test-isnanf-nolibm.c + tests/test-isnanf.h + tests/test-isnanl-nolibm.c + tests/test-isnanl.h + tests/test-iswblank.c + tests/test-iswctype.c + tests/test-iswdigit.c + tests/test-iswdigit.sh + tests/test-iswpunct.c + tests/test-iswpunct.sh + tests/test-iswxdigit.c + tests/test-iswxdigit.sh + tests/test-langinfo.c + tests/test-largefile.c + tests/test-limits-h.c + tests/test-listen.c + tests/test-localcharset.c + tests/test-locale.c + tests/test-localeconv.c + tests/test-lstat.c + tests/test-lstat.h + tests/test-malloc-gnu.c + tests/test-malloca.c + tests/test-math.c + tests/test-mbrtoc32-1.sh + tests/test-mbrtoc32-2.sh + tests/test-mbrtoc32-3.sh + tests/test-mbrtoc32-4.sh + tests/test-mbrtoc32-5.sh + tests/test-mbrtoc32-w32-2.sh + tests/test-mbrtoc32-w32-3.sh + tests/test-mbrtoc32-w32-4.sh + tests/test-mbrtoc32-w32-5.sh + tests/test-mbrtoc32-w32-6.sh + tests/test-mbrtoc32-w32-7.sh + tests/test-mbrtoc32-w32-8.sh + tests/test-mbrtoc32-w32.c + tests/test-mbrtoc32.c + tests/test-mbrtowc-1.sh + tests/test-mbrtowc-2.sh + tests/test-mbrtowc-3.sh + tests/test-mbrtowc-4.sh + tests/test-mbrtowc-5.sh + tests/test-mbrtowc-w32-2.sh + tests/test-mbrtowc-w32-3.sh + tests/test-mbrtowc-w32-4.sh + tests/test-mbrtowc-w32-5.sh + tests/test-mbrtowc-w32-6.sh + tests/test-mbrtowc-w32-7.sh + tests/test-mbrtowc-w32-8.sh + tests/test-mbrtowc-w32.c + tests/test-mbrtowc.c + tests/test-mbscasecmp.c + tests/test-mbscasecmp.sh + tests/test-mbsinit.c + tests/test-mbsinit.sh + tests/test-mbsrtoc32s-1.sh + tests/test-mbsrtoc32s-2.sh + tests/test-mbsrtoc32s-3.sh + tests/test-mbsrtoc32s-4.sh + tests/test-mbsrtoc32s-5.sh + tests/test-mbsrtoc32s.c + tests/test-mbsrtowcs-1.sh + tests/test-mbsrtowcs-2.sh + tests/test-mbsrtowcs-3.sh + tests/test-mbsrtowcs-4.sh + tests/test-mbsrtowcs-5.sh + tests/test-mbsrtowcs.c + tests/test-memchr.c + tests/test-memrchr.c + tests/test-mkdir.c + tests/test-mkdir.h + tests/test-nanosleep.c + tests/test-netinet_in.c + tests/test-nl_langinfo-mt.c + tests/test-nl_langinfo1.c + tests/test-nl_langinfo1.sh + tests/test-nl_langinfo2.c + tests/test-nl_langinfo2.sh + tests/test-nstrftime.c + tests/test-nullptr.c + tests/test-open.c + tests/test-open.h + tests/test-openat.c + tests/test-pathmax.c + tests/test-perror.c + tests/test-perror.sh + tests/test-perror2.c + tests/test-pipe.c + tests/test-popen.c + tests/test-popen.h + tests/test-priv-set.c + tests/test-pselect.c + tests/test-pthread-thread.c + tests/test-pthread.c + tests/test-pthread_sigmask1.c + tests/test-pthread_sigmask2.c + tests/test-quotearg-simple.c + tests/test-quotearg.h + tests/test-raise.c + tests/test-rawmemchr.c + tests/test-readlink.c + tests/test-readlink.h + tests/test-readlinkat.c + tests/test-realloc-gnu.c + tests/test-reallocarray.c + tests/test-regex.c + tests/test-rmdir.c + tests/test-rmdir.h + tests/test-sched.c + tests/test-select-fd.c + tests/test-select-in.sh + tests/test-select-out.sh + tests/test-select-stdin.c + tests/test-select.c + tests/test-select.h + tests/test-setenv.c + tests/test-setlocale_null-mt-all.c + tests/test-setlocale_null-mt-one.c + tests/test-setlocale_null.c + tests/test-setsockopt.c + tests/test-sh-quote.c + tests/test-sigaction.c + tests/test-signal-h.c + tests/test-signbit.c + tests/test-sigprocmask.c + tests/test-sigsegv-catch-segv1.c + tests/test-sigsegv-catch-segv2.c + tests/test-sigsegv-catch-stackoverflow1.c + tests/test-sigsegv-catch-stackoverflow2.c + tests/test-sleep.c + tests/test-snprintf.c + tests/test-sockets.c + tests/test-stat-time.c + tests/test-stat.c + tests/test-stat.h + tests/test-stdbool.c + tests/test-stdckdint.c + tests/test-stddef.c + tests/test-stdint.c + tests/test-stdio.c + tests/test-stdlib.c + tests/test-strerror.c + tests/test-strerror_r.c + tests/test-string.c + tests/test-strings.c + tests/test-strnlen.c + tests/test-strtoimax.c + tests/test-strtoll.c + tests/test-symlink.c + tests/test-symlink.h + tests/test-symlinkat.c + tests/test-sys_ioctl.c + tests/test-sys_random.c + tests/test-sys_select.c + tests/test-sys_socket.c + tests/test-sys_stat.c + tests/test-sys_time.c + tests/test-sys_types.c + tests/test-sys_uio.c + tests/test-sys_wait.c + tests/test-sys_wait.h + tests/test-thread_create.c + tests/test-thread_self.c + tests/test-time-h.c + tests/test-time.c + tests/test-timespec.c + tests/test-timespec_get.c + tests/test-uchar.c + tests/test-unistd.c + tests/test-unlink.c + tests/test-unlink.h + tests/test-unlinkat.c + tests/test-unsetenv.c + tests/test-update-copyright.sh + tests/test-vasnprintf.c + tests/test-vc-list-files-cvs.sh + tests/test-vc-list-files-git.sh + tests/test-verify-try.c + tests/test-verify.c + tests/test-verify.sh + tests/test-version-etc.c + tests/test-version-etc.sh + tests/test-wchar.c + tests/test-wcrtomb-w32-2.sh + tests/test-wcrtomb-w32-3.sh + tests/test-wcrtomb-w32-4.sh + tests/test-wcrtomb-w32-5.sh + tests/test-wcrtomb-w32-6.sh + tests/test-wcrtomb-w32-7.sh + tests/test-wcrtomb-w32-8.sh + tests/test-wcrtomb-w32.c + tests/test-wcrtomb.c + tests/test-wcrtomb.sh + tests/test-wctype-h.c + tests/test-wctype.c + tests/test-wcwidth.c + tests/test-xalloc-die.c + tests/test-xalloc-die.sh + tests/test-xstdopen.c + tests/test-xstdopen.sh + tests/test-xstrtoimax.c + tests/test-xstrtoimax.sh + tests/test-xstrtol.c + tests/test-xstrtol.sh + tests/test-xstrtoul.c + tests/test-year2038.c + tests/unicase/test-mapping-part1.h + tests/unicase/test-mapping-part2.h + tests/unicase/test-uc_tolower.c + tests/unictype/test-ctype_alnum.c + tests/unictype/test-ctype_alpha.c + tests/unictype/test-ctype_blank.c + tests/unictype/test-ctype_cntrl.c + tests/unictype/test-ctype_digit.c + tests/unictype/test-ctype_graph.c + tests/unictype/test-ctype_lower.c + tests/unictype/test-ctype_print.c + tests/unictype/test-ctype_punct.c + tests/unictype/test-ctype_space.c + tests/unictype/test-ctype_upper.c + tests/unictype/test-ctype_xdigit.c + tests/unictype/test-predicate-part1.h + tests/unictype/test-predicate-part2.h + tests/unistr/test-chr.h + tests/unistr/test-cpy.h + tests/unistr/test-pcpy.h + tests/unistr/test-set.h + tests/unistr/test-strcat.h + tests/unistr/test-u32-chr.c + tests/unistr/test-u32-cpy.c + tests/unistr/test-u32-pcpy.c + tests/unistr/test-u32-set.c + tests/unistr/test-u32-strcat.c + tests/unistr/test-u32-strlen.c + tests/uniwidth/test-uc_width.c + tests/uniwidth/test-uc_width2.c + tests/uniwidth/test-uc_width2.sh + tests/zerosize-ptr.h + tests=lib/_Noreturn.h + tests=lib/accept.c + tests=lib/alloca.c + tests=lib/anytostr.c + tests=lib/arg-nonnull.h + tests=lib/arpa_inet.in.h + tests=lib/asnprintf.c + tests=lib/at-func.c + tests=lib/atoll.c + tests=lib/bind.c + tests=lib/c++defs.h + tests=lib/c-strcasestr.c + tests=lib/c-strcasestr.h + tests=lib/c32rtomb.c + tests=lib/c32tob.c + tests=lib/connect.c + tests=lib/dtotimespec.c + tests=lib/fdopen.c + tests=lib/float+.h + tests=lib/float.c + tests=lib/float.in.h + tests=lib/fpucw.h + tests=lib/ftruncate.c + tests=lib/glthread/thread.c + tests=lib/glthread/thread.h + tests=lib/hash-pjw.c + tests=lib/hash-pjw.h + tests=lib/imaxtostr.c + tests=lib/inet_pton.c + tests=lib/inttostr.c + tests=lib/inttostr.h + tests=lib/ioctl.c + tests=lib/isnan.c + tests=lib/isnand-nolibm.h + tests=lib/isnand.c + tests=lib/isnanf-nolibm.h + tests=lib/isnanf.c + tests=lib/isnanl-nolibm.h + tests=lib/isnanl.c + tests=lib/itold.c + tests=lib/listen.c + tests=lib/math.c + tests=lib/math.in.h + tests=lib/nan.h + tests=lib/nanosleep.c + tests=lib/netinet_in.in.h + tests=lib/offtostr.c + tests=lib/perror.c + tests=lib/printf-args.c + tests=lib/printf-args.h + tests=lib/printf-parse.c + tests=lib/printf-parse.h + tests=lib/priv-set.c + tests=lib/priv-set.h + tests=lib/pselect.c + tests=lib/pthread-thread.c + tests=lib/pthread.in.h + tests=lib/pthread_sigmask.c + tests=lib/putenv.c + tests=lib/rmdir.c + tests=lib/root-uid.h + tests=lib/sched.in.h + tests=lib/select.c + tests=lib/setsockopt.c + tests=lib/signbitd.c + tests=lib/signbitf.c + tests=lib/signbitl.c + tests=lib/signed-nan.h + tests=lib/signed-snan.h + tests=lib/size_max.h + tests=lib/sleep.c + tests=lib/snan.h + tests=lib/snprintf.c + tests=lib/socket.c + tests=lib/sockets.c + tests=lib/sockets.h + tests=lib/str-two-way.h + tests=lib/strerror_r.c + tests=lib/symlink.c + tests=lib/symlinkat.c + tests=lib/sys_ioctl.in.h + tests=lib/sys_select.in.h + tests=lib/sys_socket.c + tests=lib/sys_socket.in.h + tests=lib/sys_uio.in.h + tests=lib/time.c + tests=lib/timespec-add.c + tests=lib/timespec-sub.c + tests=lib/uinttostr.c + tests=lib/umaxtostr.c + tests=lib/unistr/u-set.h + tests=lib/unistr/u32-set.c + tests=lib/unlink.c + tests=lib/unlinkat.c + tests=lib/unlinkdir.c + tests=lib/unlinkdir.h + tests=lib/vasnprintf.c + tests=lib/vasnprintf.h + tests=lib/w32sock.h + tests=lib/warn-on-use.h + tests=lib/wctob.c + tests=lib/wctomb-impl.h + tests=lib/wctomb.c + tests=lib/windows-thread.c + tests=lib/windows-thread.h + tests=lib/windows-tls.c + tests=lib/windows-tls.h + tests=lib/xsize.c + tests=lib/xsize.h + tests=lib/xstrtol-error.c + tests=lib/xstrtol-error.h + top/GNUmakefile + top/README-release + top/maint.mk +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/gnulib-comp.m4~ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/gnulib-comp.m4~ new file mode 100644 index 00000000..b7e7819c --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/gnulib-comp.m4~ @@ -0,0 +1,2831 @@ +# DO NOT EDIT! GENERATED AUTOMATICALLY! +# Copyright (C) 2002-2023 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 +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This file 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 file. If not, see . +# +# As a special exception to the GNU General Public License, +# this file may be distributed as part of a program that +# contains a configuration script generated by Autoconf, under +# the same distribution terms as the rest of that program. +# +# Generated by gnulib-tool. +# +# This file represents the compiled summary of the specification in +# gnulib-cache.m4. It lists the computed macro invocations that need +# to be invoked from configure.ac. +# In projects that use version control, this file can be treated like +# other built files. + + +# This macro should be invoked from ./configure.ac, in the section +# "Checks for programs", right after AC_PROG_CC, and certainly before +# any checks for libraries, header files, types and library functions. +AC_DEFUN([gl_EARLY], +[ + m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace + m4_pattern_allow([^gl_ES$])dnl a valid locale name + m4_pattern_allow([^gl_LIBOBJS$])dnl a variable + m4_pattern_allow([^gl_LTLIBOBJS$])dnl a variable + + # Pre-early section. + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + AC_REQUIRE([gl_PROG_AR_RANLIB]) + + # Code from module absolute-header: + # Code from module accept: + # Code from module accept-tests: + # Code from module alignasof: + # Code from module alignasof-tests: + # Code from module alloca: + # Code from module alloca-opt: + # Code from module alloca-opt-tests: + # Code from module allocator: + # Code from module announce-gen: + # Code from module areadlink: + # Code from module areadlink-tests: + # Code from module argmatch: + # Code from module argmatch-tests: + # Code from module arpa_inet: + # Code from module arpa_inet-tests: + # Code from module assert-h: + # Code from module assert-h-tests: + # Code from module assure: + # Code from module at-internal: + # Code from module atoll: + # Code from module attribute: + # Code from module basename-lgpl: + # Code from module binary-io: + # Code from module binary-io-tests: + # Code from module bind: + # Code from module bind-tests: + # Code from module bitrotate: + # Code from module bitrotate-tests: + # Code from module btoc32: + # Code from module btoc32-tests: + # Code from module btowc: + # Code from module btowc-tests: + # Code from module builtin-expect: + # Code from module c-ctype: + # Code from module c-ctype-tests: + # Code from module c-stack: + # Code from module c-stack-tests: + # Code from module c-strcase: + # Code from module c-strcase-tests: + # Code from module c-strcaseeq: + # Code from module c-strcasestr: + # Code from module c-strcasestr-tests: + # Code from module c32isspace: + # Code from module c32isspace-tests: + # Code from module c32rtomb: + # Code from module c32rtomb-tests: + # Code from module c32tob: + # Code from module c32tolower: + # Code from module c32tolower-tests: + # Code from module c32width: + # Code from module c32width-tests: + # Code from module c99: + # Code from module calloc-gnu: + # Code from module calloc-gnu-tests: + # Code from module calloc-posix: + # Code from module careadlinkat: + # Code from module chdir: + # Code from module chdir-long: + # Code from module chdir-tests: + # Code from module clock-time: + # Code from module cloexec: + # Code from module cloexec-tests: + # Code from module close: + # Code from module close-tests: + # Code from module closedir: + # Code from module config-h: + # Code from module connect: + # Code from module connect-tests: + # Code from module count-leading-zeros: + # Code from module count-leading-zeros-tests: + # Code from module ctype: + # Code from module ctype-tests: + # Code from module diffseq: + # Code from module dirent: + # Code from module dirent-tests: + # Code from module dirfd: + # Code from module dirfd-tests: + # Code from module dirname: + # Code from module dirname-lgpl: + # Code from module dirname-tests: + # Code from module do-release-commit-and-tag: + # Code from module double-slash-root: + # Code from module dtotimespec: + # Code from module dup: + # Code from module dup-tests: + # Code from module dup2: + # Code from module dup2-tests: + # Code from module environ: + # Code from module environ-tests: + # Code from module errno: + # Code from module errno-tests: + # Code from module error: + # Code from module error-h: + # Code from module error-tests: + # Code from module exclude: + # Code from module exclude-tests: + # Code from module exitfail: + # Code from module extensions: + # Code from module extern-inline: + # Code from module fchdir: + # Code from module fchdir-tests: + # Code from module fcntl: + # Code from module fcntl-h: + # Code from module fcntl-h-tests: + # Code from module fcntl-tests: + # Code from module fd-hook: + # Code from module fd-safer-flag: + # Code from module fdopen: + # Code from module fdopen-tests: + # Code from module fdopendir: + # Code from module fdopendir-tests: + # Code from module fgetc-tests: + # Code from module file-type: + # Code from module filename: + # Code from module filenamecat: + # Code from module filenamecat-lgpl: + # Code from module filenamecat-tests: + # Code from module flexmember: + # Code from module float: + # Code from module float-tests: + # Code from module fnmatch: + # Code from module fnmatch-gnu: + # Code from module fnmatch-h: + # Code from module fnmatch-h-tests: + # Code from module fnmatch-tests: + # Code from module fopen: + # Code from module fopen-gnu: + # Code from module fopen-gnu-tests: + # Code from module fopen-tests: + # Code from module fpieee: + AC_REQUIRE([gl_FP_IEEE]) + # Code from module fpucw: + # Code from module fputc-tests: + # Code from module fread-tests: + # Code from module free-posix: + # Code from module free-posix-tests: + # Code from module freopen: + # Code from module freopen-tests: + # Code from module fstat: + # Code from module fstat-tests: + # Code from module ftruncate: + # Code from module ftruncate-tests: + # Code from module fwrite-tests: + # Code from module gen-header: + # Code from module gendocs: + # Code from module getcwd-lgpl: + # Code from module getcwd-lgpl-tests: + # Code from module getdtablesize: + # Code from module getdtablesize-tests: + # Code from module getopt-gnu: + # Code from module getopt-gnu-tests: + # Code from module getopt-posix: + # Code from module getopt-posix-tests: + # Code from module getpagesize: + # Code from module getprogname: + # Code from module getprogname-tests: + # Code from module getrandom: + # Code from module getrandom-tests: + # Code from module gettext-h: + # Code from module gettime: + # Code from module gettimeofday: + # Code from module gettimeofday-tests: + # Code from module git-version-gen: + # Code from module gitlog-to-changelog: + # Code from module glibc-internal/dynarray: + # Code from module glibc-internal/dynarray-tests: + # Code from module gnu-make: + # Code from module gnu-web-doc-update: + # Code from module gnumakefile: + # Code from module gnupload: + # Code from module hard-locale: + # Code from module hard-locale-tests: + # Code from module hash: + # Code from module hash-pjw: + # Code from module hash-tests: + # Code from module havelib: + # Code from module host-cpu-c-abi: + # Code from module ialloc: + # Code from module idx: + # Code from module ignore-value: + # Code from module ignore-value-tests: + # Code from module include_next: + # Code from module inet_pton: + # Code from module inet_pton-tests: + # Code from module intprops: + # Code from module intprops-tests: + # Code from module inttostr: + # Code from module inttostr-tests: + # Code from module inttypes: + # Code from module inttypes-incomplete: + # Code from module inttypes-tests: + # Code from module ioctl: + # Code from module ioctl-tests: + # Code from module isblank: + # Code from module isblank-tests: + # Code from module iswblank: + # Code from module iswblank-tests: + # Code from module iswdigit: + # Code from module iswdigit-tests: + # Code from module iswxdigit: + # Code from module iswxdigit-tests: + # Code from module langinfo: + # Code from module langinfo-tests: + # Code from module largefile: + AC_REQUIRE([AC_SYS_LARGEFILE]) + # Code from module largefile-tests: + # Code from module libc-config: + # Code from module limits-h: + # Code from module limits-h-tests: + # Code from module listen: + # Code from module listen-tests: + # Code from module localcharset: + # Code from module localcharset-tests: + # Code from module locale: + # Code from module locale-tests: + # Code from module localeconv: + # Code from module localeconv-tests: + # Code from module lock: + # Code from module lstat: + # Code from module lstat-tests: + # Code from module maintainer-makefile: + # Code from module malloc-gnu: + # Code from module malloc-gnu-tests: + # Code from module malloc-posix: + # Code from module malloca: + # Code from module malloca-tests: + # Code from module manywarnings: + # Code from module mbchar: + # Code from module mbrtoc32: + # Code from module mbrtoc32-tests: + # Code from module mbrtowc: + # Code from module mbrtowc-tests: + # Code from module mbscasecmp: + # Code from module mbscasecmp-tests: + # Code from module mbsinit: + # Code from module mbsinit-tests: + # Code from module mbsrtowcs: + # Code from module mbsrtowcs-tests: + # Code from module mbtowc: + # Code from module mbuiter: + # Code from module memchr: + # Code from module memchr-tests: + # Code from module mempcpy: + # Code from module memrchr: + # Code from module memrchr-tests: + # Code from module minmax: + # Code from module mkdir: + # Code from module mkdir-tests: + # Code from module mkstemp: + # Code from module mktime: + # Code from module mktime-internal: + # Code from module msvc-inval: + # Code from module msvc-nothrow: + # Code from module multiarch: + # Code from module nanosleep: + # Code from module nanosleep-tests: + # Code from module netinet_in: + # Code from module netinet_in-tests: + # Code from module nl_langinfo: + # Code from module nl_langinfo-tests: + # Code from module nocrash: + # Code from module nstrftime: + # Code from module nstrftime-tests: + # Code from module nullptr: + # Code from module nullptr-tests: + # Code from module open: + # Code from module open-tests: + # Code from module openat: + # Code from module openat-die: + # Code from module openat-h: + # Code from module openat-tests: + # Code from module opendir: + # Code from module pathmax: + # Code from module pathmax-tests: + # Code from module perl: + # Code from module perror: + # Code from module perror-tests: + # Code from module pipe-posix: + # Code from module pipe-posix-tests: + # Code from module progname: + # Code from module propername-lite: + # Code from module pselect: + # Code from module pselect-tests: + # Code from module pthread-h: + gl_ANYTHREADLIB_EARLY + # Code from module pthread-h-tests: + # Code from module pthread-thread: + # Code from module pthread-thread-tests: + # Code from module pthread_sigmask: + # Code from module pthread_sigmask-tests: + # Code from module putenv: + # Code from module quote: + # Code from module quotearg: + # Code from module quotearg-simple: + # Code from module quotearg-simple-tests: + # Code from module raise: + # Code from module raise-tests: + # Code from module rawmemchr: + # Code from module rawmemchr-tests: + # Code from module readlink: + # Code from module readlink-tests: + # Code from module readme-release: + # Code from module realloc-gnu: + # Code from module realloc-gnu-tests: + # Code from module realloc-posix: + # Code from module reallocarray: + # Code from module reallocarray-tests: + # Code from module regex: + # Code from module regex-tests: + # Code from module same-inode: + # Code from module save-cwd: + # Code from module sched: + # Code from module sched-tests: + # Code from module select: + # Code from module select-tests: + # Code from module setenv: + # Code from module setenv-tests: + # Code from module setlocale-null: + # Code from module setlocale-null-tests: + # Code from module setsockopt: + # Code from module setsockopt-tests: + # Code from module sh-quote: + # Code from module sh-quote-tests: + # Code from module signal: + # Code from module signal-h: + # Code from module signal-h-tests: + # Code from module sigprocmask: + # Code from module sigprocmask-tests: + # Code from module sigsegv: + # Code from module sigsegv-tests: + # Code from module size_max: + # Code from module sleep: + # Code from module sleep-tests: + # Code from module snippet/_Noreturn: + # Code from module snippet/arg-nonnull: + # Code from module snippet/c++defs: + # Code from module snippet/warn-on-use: + # Code from module snprintf: + # Code from module snprintf-tests: + # Code from module socket: + # Code from module socketlib: + # Code from module sockets: + # Code from module sockets-tests: + # Code from module socklen: + # Code from module ssize_t: + # Code from module stat: + # Code from module stat-macros: + # Code from module stat-tests: + # Code from module stat-time: + # Code from module stat-time-tests: + # Code from module std-gnu11: + # Code from module stdarg: + dnl Some compilers (e.g., AIX 5.3 cc) need to be in c99 mode + dnl for the builtin va_copy to work. gl_PROG_CC_C99 arranges for this. + gl_PROG_CC_C99 + # Code from module stdarg-tests: + # Code from module stdbool: + # Code from module stdbool-tests: + # Code from module stdckdint: + # Code from module stdckdint-tests: + # Code from module stddef: + # Code from module stddef-tests: + # Code from module stdint: + # Code from module stdint-tests: + # Code from module stdio: + gl_STDIO_H_EARLY + # Code from module stdio-tests: + # Code from module stdlib: + # Code from module stdlib-tests: + # Code from module stdopen: + # Code from module stpcpy: + # Code from module strcase: + # Code from module strdup-posix: + # Code from module streq: + # Code from module strerror: + # Code from module strerror-override: + # Code from module strerror-tests: + # Code from module strerror_r-posix: + # Code from module strerror_r-posix-tests: + # Code from module string: + # Code from module string-tests: + # Code from module strings: + # Code from module strings-tests: + # Code from module strnlen: + # Code from module strnlen-tests: + # Code from module strnlen1: + # Code from module strptime: + # Code from module strtoimax: + # Code from module strtoimax-tests: + # Code from module strtoll: + # Code from module strtoll-tests: + # Code from module symlink: + # Code from module symlink-tests: + # Code from module sys_ioctl: + # Code from module sys_ioctl-tests: + # Code from module sys_random: + # Code from module sys_random-tests: + # Code from module sys_select: + # Code from module sys_select-tests: + # Code from module sys_socket: + # Code from module sys_socket-tests: + # Code from module sys_stat: + # Code from module sys_stat-tests: + # Code from module sys_time: + # Code from module sys_time-tests: + # Code from module sys_types: + # Code from module sys_types-tests: + # Code from module sys_uio: + # Code from module sys_uio-tests: + # Code from module sys_wait: + # Code from module sys_wait-tests: + # Code from module system-quote: + # Code from module tempname: + # Code from module test-framework-sh: + # Code from module test-framework-sh-tests: + # Code from module thread: + # Code from module thread-tests: + # Code from module threadlib: + gl_THREADLIB_EARLY + # Code from module time: + # Code from module time-h: + # Code from module time-h-tests: + # Code from module time-tests: + # Code from module time_r: + # Code from module time_rz: + # Code from module timegm: + # Code from module timespec: + # Code from module timespec-add: + # Code from module timespec-sub: + # Code from module timespec-tests: + # Code from module timespec_get: + # Code from module timespec_get-tests: + # Code from module tzset: + # Code from module uchar: + # Code from module uchar-tests: + # Code from module unicase/base: + # Code from module unicase/tolower: + # Code from module unicase/tolower-tests: + # Code from module unictype/base: + # Code from module unictype/ctype-space: + # Code from module unictype/ctype-space-tests: + # Code from module uninorm/base: + # Code from module unistd: + # Code from module unistd-safer: + # Code from module unistd-safer-tests: + # Code from module unistd-tests: + # Code from module unitypes: + # Code from module uniwidth/base: + # Code from module uniwidth/width: + # Code from module uniwidth/width-tests: + # Code from module unlocked-io: + # Code from module unlocked-io-internal: + # Code from module unsetenv: + # Code from module unsetenv-tests: + # Code from module update-copyright: + # Code from module update-copyright-tests: + # Code from module useless-if-before-free: + # Code from module vararrays: + # Code from module vasnprintf: + # Code from module vasnprintf-tests: + # Code from module vc-list-files: + # Code from module vc-list-files-tests: + # Code from module verify: + # Code from module verify-tests: + # Code from module version-etc: + # Code from module version-etc-fsf: + # Code from module version-etc-tests: + # Code from module warnings: + # Code from module wchar: + # Code from module wchar-tests: + # Code from module wcrtomb: + # Code from module wcrtomb-tests: + # Code from module wctob: + # Code from module wctomb: + # Code from module wctype-h: + # Code from module wctype-h-tests: + # Code from module wcwidth: + # Code from module wcwidth-tests: + # Code from module windows-mutex: + # Code from module windows-once: + # Code from module windows-recmutex: + # Code from module windows-rwlock: + # Code from module windows-thread: + # Code from module windows-tls: + # Code from module wmemchr: + # Code from module wmempcpy: + # Code from module xalloc: + # Code from module xalloc-die: + # Code from module xalloc-die-tests: + # Code from module xalloc-oversized: + # Code from module xfreopen: + # Code from module xmalloca: + # Code from module xreadlink: + # Code from module xsize: + # Code from module xstdopen: + # Code from module xstdopen-tests: + # Code from module xstrtoimax: + # Code from module xstrtoimax-tests: + # Code from module xstrtol: + # Code from module xstrtol-error: + # Code from module xstrtol-tests: + # Code from module year2038: + AC_REQUIRE([AC_SYS_YEAR2038]) + # Code from module year2038-tests: +]) + +# This macro should be invoked from ./configure.ac, in the section +# "Check for header files, types and library functions". +AC_DEFUN([gl_INIT], +[ + AC_CONFIG_LIBOBJ_DIR([gnulib-tests]) + AM_CONDITIONAL([GL_COND_LIBTOOL], [false]) + gl_cond_libtool=false + gl_libdeps= + gl_ltlibdeps= + gl_m4_base='m4' + m4_pushdef([AC_LIBOBJ], m4_defn([gl_LIBOBJ])) + m4_pushdef([AC_REPLACE_FUNCS], m4_defn([gl_REPLACE_FUNCS])) + m4_pushdef([AC_LIBSOURCES], m4_defn([gl_LIBSOURCES])) + m4_pushdef([gl_LIBSOURCES_LIST], []) + m4_pushdef([gl_LIBSOURCES_DIR], []) + m4_pushdef([GL_MACRO_PREFIX], [gl]) + m4_pushdef([GL_MODULE_INDICATOR_PREFIX], [GL]) + gl_COMMON + gl_source_base='lib' + gl_source_base_prefix= + gl_ALIGNASOF + gl_FUNC_ALLOCA + gl_CONDITIONAL_HEADER([alloca.h]) + AC_PROG_MKDIR_P + gl_ASSERT_H + gl_CONDITIONAL_HEADER([assert.h]) + AC_PROG_MKDIR_P + AC_REQUIRE([AC_CANONICAL_HOST]) + gl_FUNC_BTOWC + gl_CONDITIONAL([GL_COND_OBJ_BTOWC], + [test $HAVE_BTOWC = 0 || test $REPLACE_BTOWC = 1]) + AM_COND_IF([GL_COND_OBJ_BTOWC], [ + gl_PREREQ_BTOWC + ]) + gl_WCHAR_MODULE_INDICATOR([btowc]) + gl___BUILTIN_EXPECT + gl_C_STACK + AC_REQUIRE([gl_UCHAR_H]) + dnl Determine REPLACE_MBSTATE_T, from which GNULIB_defined_mbstate_t is + dnl determined. It describes how mbrtoc32 is implemented. + AC_REQUIRE([gl_MBSTATE_T_BROKEN]) + AC_REQUIRE([gl_MBRTOC32_SANITYCHECK]) + gl_UCHAR_MODULE_INDICATOR([c32isspace]) + AC_REQUIRE([gl_UCHAR_H]) + dnl Determine REPLACE_MBSTATE_T, from which GNULIB_defined_mbstate_t is + dnl determined. It describes how mbrtoc32 is implemented. + AC_REQUIRE([gl_MBSTATE_T_BROKEN]) + AC_REQUIRE([gl_MBRTOC32_SANITYCHECK]) + gl_UCHAR_MODULE_INDICATOR([c32tolower]) + AC_REQUIRE([gl_UCHAR_H]) + dnl Determine REPLACE_MBSTATE_T, from which GNULIB_defined_mbstate_t is + dnl determined. It describes how mbrtoc32 is implemented. + AC_REQUIRE([gl_MBSTATE_T_BROKEN]) + AC_REQUIRE([gl_MBRTOC32_SANITYCHECK]) + gl_UCHAR_MODULE_INDICATOR([c32width]) + gl_FUNC_CALLOC_GNU + if test $REPLACE_CALLOC_FOR_CALLOC_GNU = 1; then + AC_LIBOBJ([calloc]) + fi + gl_STDLIB_MODULE_INDICATOR([calloc-gnu]) + gl_FUNC_CALLOC_POSIX + if test $REPLACE_CALLOC_FOR_CALLOC_POSIX = 1; then + AC_LIBOBJ([calloc]) + fi + gl_STDLIB_MODULE_INDICATOR([calloc-posix]) + AC_REQUIRE([AC_C_RESTRICT]) + gl_CHECK_FUNCS_ANDROID([readlinkat], [[#include ]]) + gl_UNISTD_MODULE_INDICATOR([chdir]) + gl_FUNC_CHDIR_LONG + gl_CONDITIONAL([GL_COND_OBJ_CHDIR_LONG], + [test $gl_cv_have_unlimited_file_name_length = no]) + AM_COND_IF([GL_COND_OBJ_CHDIR_LONG], [ + gl_PREREQ_CHDIR_LONG + ]) + gl_CLOCK_TIME + gl_MODULE_INDICATOR_FOR_TESTS([cloexec]) + gl_FUNC_CLOSE + gl_CONDITIONAL([GL_COND_OBJ_CLOSE], [test $REPLACE_CLOSE = 1]) + gl_UNISTD_MODULE_INDICATOR([close]) + gl_FUNC_CLOSEDIR + gl_CONDITIONAL([GL_COND_OBJ_CLOSEDIR], + [test $HAVE_CLOSEDIR = 0 || test $REPLACE_CLOSEDIR = 1]) + gl_DIRENT_MODULE_INDICATOR([closedir]) + gl_CONFIG_H + gl_CTYPE_H + gl_CTYPE_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_DIRENT_H + gl_DIRENT_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_FUNC_DIRFD + gl_CONDITIONAL([GL_COND_OBJ_DIRFD], + [test $HAVE_DIRFD = 0 || test $REPLACE_DIRFD = 1]) + AM_COND_IF([GL_COND_OBJ_DIRFD], [ + gl_PREREQ_DIRFD + ]) + gl_DIRENT_MODULE_INDICATOR([dirfd]) + gl_MODULE_INDICATOR([dirname]) + gl_DOUBLE_SLASH_ROOT + gl_FUNC_DUP + gl_CONDITIONAL([GL_COND_OBJ_DUP], [test $REPLACE_DUP = 1]) + AM_COND_IF([GL_COND_OBJ_DUP], [ + gl_PREREQ_DUP + ]) + gl_UNISTD_MODULE_INDICATOR([dup]) + gl_FUNC_DUP2 + gl_CONDITIONAL([GL_COND_OBJ_DUP2], [test $REPLACE_DUP2 = 1]) + AM_COND_IF([GL_COND_OBJ_DUP2], [ + gl_PREREQ_DUP2 + ]) + gl_UNISTD_MODULE_INDICATOR([dup2]) + gl_ENVIRON + gl_UNISTD_MODULE_INDICATOR([environ]) + gl_HEADER_ERRNO_H + gl_CONDITIONAL_HEADER([errno.h]) + AC_PROG_MKDIR_P + AC_REQUIRE([gl_ERROR_H]) + gl_ERROR + gl_CONDITIONAL([GL_COND_OBJ_ERROR], [test $COMPILE_ERROR_C = 1]) + AM_COND_IF([GL_COND_OBJ_ERROR], [ + gl_PREREQ_ERROR + ]) + m4_ifdef([AM_XGETTEXT_OPTION], + [AM_][XGETTEXT_OPTION([--flag=error:3:c-format]) + AM_][XGETTEXT_OPTION([--flag=error_at_line:5:c-format])]) + gl_ERROR_H + AC_PROG_MKDIR_P + AC_REQUIRE([gl_EXTERN_INLINE]) + gl_FUNC_FCHDIR + gl_CONDITIONAL([GL_COND_OBJ_FCHDIR], [test $HAVE_FCHDIR = 0]) + AM_COND_IF([GL_COND_OBJ_FCHDIR], [ + gl_PREREQ_FCHDIR + ]) + gl_UNISTD_MODULE_INDICATOR([fchdir]) + gl_FUNC_FCNTL + gl_CONDITIONAL([GL_COND_OBJ_FCNTL], + [test $HAVE_FCNTL = 0 || test $REPLACE_FCNTL = 1]) + gl_FCNTL_MODULE_INDICATOR([fcntl]) + gl_FCNTL_H + gl_FCNTL_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_MODULE_INDICATOR([fd-safer-flag]) + gl_FUNC_FDOPENDIR + gl_CONDITIONAL([GL_COND_OBJ_FDOPENDIR], + [test $HAVE_FDOPENDIR = 0 || test $REPLACE_FDOPENDIR = 1]) + gl_DIRENT_MODULE_INDICATOR([fdopendir]) + gl_MODULE_INDICATOR([fdopendir]) + gl_FILE_NAME_CONCAT + gl_MODULE_INDICATOR([filenamecat]) + gl_FILE_NAME_CONCAT_LGPL + AC_C_FLEXIBLE_ARRAY_MEMBER + gl_FUNC_FNMATCH_POSIX + dnl Because of gl_REPLACE_FNMATCH_H: + gl_CONDITIONAL_HEADER([fnmatch.h]) + if test $HAVE_FNMATCH = 0 || test $REPLACE_FNMATCH = 1; then + AC_LIBOBJ([fnmatch]) + gl_PREREQ_FNMATCH + fi + gl_FNMATCH_MODULE_INDICATOR([fnmatch]) + gl_FUNC_FNMATCH_GNU + if test $HAVE_FNMATCH = 0 || test $REPLACE_FNMATCH = 1; then + AC_LIBOBJ([fnmatch]) + gl_PREREQ_FNMATCH + fi + gl_MODULE_INDICATOR([fnmatch-gnu]) + gl_FNMATCH_H + gl_FNMATCH_H_REQUIRE_DEFAULTS + gl_CONDITIONAL_HEADER([fnmatch.h]) + AC_PROG_MKDIR_P + gl_FUNC_FOPEN + if test $REPLACE_FOPEN = 1; then + AC_LIBOBJ([fopen]) + gl_PREREQ_FOPEN + fi + gl_STDIO_MODULE_INDICATOR([fopen]) + gl_FUNC_FOPEN_GNU + if test $REPLACE_FOPEN_FOR_FOPEN_GNU = 1; then + AC_LIBOBJ([fopen]) + gl_PREREQ_FOPEN + fi + gl_MODULE_INDICATOR([fopen-gnu]) + gl_STDIO_MODULE_INDICATOR([fopen-gnu]) + gl_FUNC_FREE + gl_CONDITIONAL([GL_COND_OBJ_FREE], [test $REPLACE_FREE = 1]) + AM_COND_IF([GL_COND_OBJ_FREE], [ + gl_PREREQ_FREE + ]) + gl_STDLIB_MODULE_INDICATOR([free-posix]) + gl_FUNC_FREOPEN + gl_CONDITIONAL([GL_COND_OBJ_FREOPEN], [test $REPLACE_FREOPEN = 1]) + AM_COND_IF([GL_COND_OBJ_FREOPEN], [ + gl_PREREQ_FREOPEN + ]) + gl_STDIO_MODULE_INDICATOR([freopen]) + gl_FUNC_FSTAT + gl_CONDITIONAL([GL_COND_OBJ_FSTAT], [test $REPLACE_FSTAT = 1]) + AM_COND_IF([GL_COND_OBJ_FSTAT], [ + case "$host_os" in + mingw*) + AC_LIBOBJ([stat-w32]) + ;; + esac + gl_PREREQ_FSTAT + ]) + gl_SYS_STAT_MODULE_INDICATOR([fstat]) + gl_FUNC_GETCWD_LGPL + gl_CONDITIONAL([GL_COND_OBJ_GETCWD_LGPL], [test $REPLACE_GETCWD = 1]) + gl_UNISTD_MODULE_INDICATOR([getcwd]) + gl_FUNC_GETDTABLESIZE + gl_CONDITIONAL([GL_COND_OBJ_GETDTABLESIZE], + [test $HAVE_GETDTABLESIZE = 0 || test $REPLACE_GETDTABLESIZE = 1]) + AM_COND_IF([GL_COND_OBJ_GETDTABLESIZE], [ + gl_PREREQ_GETDTABLESIZE + ]) + gl_UNISTD_MODULE_INDICATOR([getdtablesize]) + gl_FUNC_GETOPT_GNU + dnl Because of the way gl_FUNC_GETOPT_GNU is implemented (the gl_getopt_required + dnl mechanism), there is no need to do any AC_LIBOBJ or AC_SUBST here; they are + dnl done in the getopt-posix module. + gl_FUNC_GETOPT_POSIX + gl_CONDITIONAL_HEADER([getopt.h]) + gl_CONDITIONAL_HEADER([getopt-cdefs.h]) + AC_PROG_MKDIR_P + gl_CONDITIONAL([GL_COND_OBJ_GETOPT], [test $REPLACE_GETOPT = 1]) + AM_COND_IF([GL_COND_OBJ_GETOPT], [ + dnl Define the substituted variable GNULIB_UNISTD_H_GETOPT to 1. + gl_UNISTD_H_REQUIRE_DEFAULTS + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNISTD_H_GETOPT], [1]) + ]) + gl_UNISTD_MODULE_INDICATOR([getopt-posix]) + gl_FUNC_GETPAGESIZE + gl_CONDITIONAL([GL_COND_OBJ_GETPAGESIZE], [test $REPLACE_GETPAGESIZE = 1]) + gl_UNISTD_MODULE_INDICATOR([getpagesize]) + gl_FUNC_GETPROGNAME + gl_CONDITIONAL([GL_COND_OBJ_GETPROGNAME], + [test $HAVE_GETPROGNAME = 0 || test $REPLACE_GETPROGNAME = 1]) + AM_COND_IF([GL_COND_OBJ_GETPROGNAME], [ + gl_PREREQ_GETPROGNAME + ]) + gl_STDLIB_MODULE_INDICATOR([getprogname]) + AC_REQUIRE([AC_CANONICAL_HOST]) + gl_FUNC_GETRANDOM + gl_CONDITIONAL([GL_COND_OBJ_GETRANDOM], + [test $HAVE_GETRANDOM = 0 || test $REPLACE_GETRANDOM = 1]) + gl_SYS_RANDOM_MODULE_INDICATOR([getrandom]) + AC_SUBST([LIBINTL]) + AC_SUBST([LTLIBINTL]) + gl_GETTIME + gl_FUNC_GETTIMEOFDAY + gl_CONDITIONAL([GL_COND_OBJ_GETTIMEOFDAY], + [test $HAVE_GETTIMEOFDAY = 0 || test $REPLACE_GETTIMEOFDAY = 1]) + AM_COND_IF([GL_COND_OBJ_GETTIMEOFDAY], [ + gl_PREREQ_GETTIMEOFDAY + ]) + gl_SYS_TIME_MODULE_INDICATOR([gettimeofday]) + AC_PROG_MKDIR_P + gl_GNU_MAKE + # Autoconf 2.61a.99 and earlier don't support linking a file only + # in VPATH builds. But since GNUmakefile is for maintainer use + # only, it does not matter if we skip the link with older autoconf. + # Automake 1.10.1 and earlier try to remove GNUmakefile in non-VPATH + # builds, so use a shell variable to bypass this. + GNUmakefile=GNUmakefile + m4_if(m4_version_compare([2.61a.100], + m4_defn([m4_PACKAGE_VERSION])), [1], [], + [AC_CONFIG_LINKS([$GNUmakefile:$GNUmakefile], [], + [GNUmakefile=$GNUmakefile])]) + AC_REQUIRE([gl_FUNC_SETLOCALE_NULL]) + HARD_LOCALE_LIB="$SETLOCALE_NULL_LIB" + AC_SUBST([HARD_LOCALE_LIB]) + dnl For backward compatibility. + LIB_HARD_LOCALE="$HARD_LOCALE_LIB" + AC_SUBST([LIB_HARD_LOCALE]) + AC_DEFUN([gl_HAVE_MODULE_HAVELIB]) + AC_REQUIRE([gl_HOST_CPU_C_ABI]) + gl_INTTYPES_H + gl_INTTYPES_INCOMPLETE + gl_INTTYPES_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_FUNC_ISBLANK + gl_CONDITIONAL([GL_COND_OBJ_ISBLANK], [test $HAVE_ISBLANK = 0]) + gl_MODULE_INDICATOR([isblank]) + gl_CTYPE_MODULE_INDICATOR([isblank]) + gl_FUNC_ISWBLANK + gl_CONDITIONAL([GL_COND_OBJ_ISWBLANK], + [! { test $HAVE_ISWCNTRL = 0 || test $REPLACE_ISWCNTRL = 1; } && { test $HAVE_ISWBLANK = 0 || test $REPLACE_ISWBLANK = 1; }]) + gl_WCTYPE_MODULE_INDICATOR([iswblank]) + gl_FUNC_ISWDIGIT + gl_CONDITIONAL([GL_COND_OBJ_ISWDIGIT], + [! { test $HAVE_ISWCNTRL = 0 || test $REPLACE_ISWCNTRL = 1; } && test $REPLACE_ISWDIGIT = 1]) + gl_WCTYPE_MODULE_INDICATOR([iswdigit]) + gl_FUNC_ISWXDIGIT + gl_CONDITIONAL([GL_COND_OBJ_ISWXDIGIT], + [! { test $HAVE_ISWCNTRL = 0 || test $REPLACE_ISWCNTRL = 1; } && test $REPLACE_ISWXDIGIT = 1]) + gl_WCTYPE_MODULE_INDICATOR([iswxdigit]) + gl_LANGINFO_H + gl_LANGINFO_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + AC_REQUIRE([gl_LARGEFILE]) + gl___INLINE + gl_LIMITS_H + gl_CONDITIONAL_HEADER([limits.h]) + AC_PROG_MKDIR_P + gl_LOCALCHARSET + dnl For backward compatibility. Some packages still use this. + LOCALCHARSET_TESTS_ENVIRONMENT= + AC_SUBST([LOCALCHARSET_TESTS_ENVIRONMENT]) + gl_LOCALE_H + gl_LOCALE_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_FUNC_LOCALECONV + gl_CONDITIONAL([GL_COND_OBJ_LOCALECONV], [test $REPLACE_LOCALECONV = 1]) + AM_COND_IF([GL_COND_OBJ_LOCALECONV], [ + gl_PREREQ_LOCALECONV + ]) + gl_LOCALE_MODULE_INDICATOR([localeconv]) + gl_LOCK + gl_MODULE_INDICATOR([lock]) + gl_FUNC_LSTAT + gl_CONDITIONAL([GL_COND_OBJ_LSTAT], [test $REPLACE_LSTAT = 1]) + AM_COND_IF([GL_COND_OBJ_LSTAT], [ + gl_PREREQ_LSTAT + ]) + gl_SYS_STAT_MODULE_INDICATOR([lstat]) + AC_CONFIG_COMMANDS_PRE([m4_ifdef([AH_HEADER], + [AC_SUBST([CONFIG_INCLUDE], m4_defn([AH_HEADER]))])]) + AC_REQUIRE([AC_PROG_SED]) + AC_REQUIRE([AC_PROG_GREP]) + gl_FUNC_MALLOC_GNU + if test $REPLACE_MALLOC_FOR_MALLOC_GNU = 1; then + AC_LIBOBJ([malloc]) + fi + gl_STDLIB_MODULE_INDICATOR([malloc-gnu]) + AC_REQUIRE([gl_FUNC_MALLOC_POSIX]) + if test $REPLACE_MALLOC_FOR_MALLOC_POSIX = 1; then + AC_LIBOBJ([malloc]) + fi + gl_STDLIB_MODULE_INDICATOR([malloc-posix]) + gl_MALLOCA + gl_MBCHAR + gl_FUNC_MBRTOC32 + gl_CONDITIONAL([GL_COND_OBJ_MBRTOC32], + [test $HAVE_MBRTOC32 = 0 || test $REPLACE_MBRTOC32 = 1]) + AM_COND_IF([GL_COND_OBJ_MBRTOC32], [ + if test $REPLACE_MBSTATE_T = 1; then + AC_LIBOBJ([lc-charset-dispatch]) + AC_LIBOBJ([mbtowc-lock]) + gl_PREREQ_MBTOWC_LOCK + fi + gl_PREREQ_MBRTOC32 + ]) + gl_UCHAR_MODULE_INDICATOR([mbrtoc32]) + gl_FUNC_MBRTOWC + gl_CONDITIONAL([GL_COND_OBJ_MBRTOWC], + [test $HAVE_MBRTOWC = 0 || test $REPLACE_MBRTOWC = 1]) + AM_COND_IF([GL_COND_OBJ_MBRTOWC], [ + if test $REPLACE_MBSTATE_T = 1; then + AC_LIBOBJ([lc-charset-dispatch]) + AC_LIBOBJ([mbtowc-lock]) + gl_PREREQ_MBTOWC_LOCK + fi + gl_PREREQ_MBRTOWC + ]) + gl_WCHAR_MODULE_INDICATOR([mbrtowc]) + gl_STRING_MODULE_INDICATOR([mbscasecmp]) + gl_FUNC_MBSINIT + gl_CONDITIONAL([GL_COND_OBJ_MBSINIT], + [test $HAVE_MBSINIT = 0 || test $REPLACE_MBSINIT = 1]) + AM_COND_IF([GL_COND_OBJ_MBSINIT], [ + gl_PREREQ_MBSINIT + ]) + gl_WCHAR_MODULE_INDICATOR([mbsinit]) + gl_FUNC_MBSRTOWCS + gl_CONDITIONAL([GL_COND_OBJ_MBSRTOWCS], + [test $HAVE_MBSRTOWCS = 0 || test $REPLACE_MBSRTOWCS = 1]) + AM_COND_IF([GL_COND_OBJ_MBSRTOWCS], [ + AC_LIBOBJ([mbsrtowcs-state]) + gl_PREREQ_MBSRTOWCS + ]) + gl_WCHAR_MODULE_INDICATOR([mbsrtowcs]) + gl_FUNC_MBTOWC + gl_CONDITIONAL([GL_COND_OBJ_MBTOWC], + [test $HAVE_MBTOWC = 0 || test $REPLACE_MBTOWC = 1]) + AM_COND_IF([GL_COND_OBJ_MBTOWC], [ + gl_PREREQ_MBTOWC + ]) + gl_STDLIB_MODULE_INDICATOR([mbtowc]) + gl_MBITER + gl_FUNC_MEMCHR + gl_CONDITIONAL([GL_COND_OBJ_MEMCHR], [test $REPLACE_MEMCHR = 1]) + AM_COND_IF([GL_COND_OBJ_MEMCHR], [ + gl_PREREQ_MEMCHR + ]) + gl_STRING_MODULE_INDICATOR([memchr]) + gl_FUNC_MEMPCPY + gl_CONDITIONAL([GL_COND_OBJ_MEMPCPY], + [test $HAVE_MEMPCPY = 0 || test $REPLACE_MEMPCPY = 1]) + AM_COND_IF([GL_COND_OBJ_MEMPCPY], [ + gl_PREREQ_MEMPCPY + ]) + gl_STRING_MODULE_INDICATOR([mempcpy]) + gl_FUNC_MEMRCHR + gl_CONDITIONAL([GL_COND_OBJ_MEMRCHR], [test $ac_cv_func_memrchr = no]) + AM_COND_IF([GL_COND_OBJ_MEMRCHR], [ + gl_PREREQ_MEMRCHR + ]) + gl_STRING_MODULE_INDICATOR([memrchr]) + gl_MINMAX + gl_FUNC_MKDIR + gl_CONDITIONAL([GL_COND_OBJ_MKDIR], [test $REPLACE_MKDIR = 1]) + gl_SYS_STAT_MODULE_INDICATOR([mkdir]) + gl_FUNC_MKSTEMP + gl_CONDITIONAL([GL_COND_OBJ_MKSTEMP], + [test $HAVE_MKSTEMP = 0 || test $REPLACE_MKSTEMP = 1]) + AM_COND_IF([GL_COND_OBJ_MKSTEMP], [ + gl_PREREQ_MKSTEMP + ]) + gl_STDLIB_MODULE_INDICATOR([mkstemp]) + gl_FUNC_MKTIME + if test $REPLACE_MKTIME = 1; then + AC_LIBOBJ([mktime]) + gl_PREREQ_MKTIME + fi + gl_TIME_MODULE_INDICATOR([mktime]) + gl_FUNC_MKTIME_INTERNAL + if test $WANT_MKTIME_INTERNAL = 1; then + AC_LIBOBJ([mktime]) + gl_PREREQ_MKTIME + fi + AC_REQUIRE([gl_MSVC_INVAL]) + gl_CONDITIONAL([GL_COND_OBJ_MSVC_INVAL], + [test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1]) + AC_REQUIRE([gl_MSVC_NOTHROW]) + gl_CONDITIONAL([GL_COND_OBJ_MSVC_NOTHROW], + [test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1]) + gl_MODULE_INDICATOR([msvc-nothrow]) + gl_MULTIARCH + gl_FUNC_NL_LANGINFO + gl_CONDITIONAL([GL_COND_OBJ_NL_LANGINFO], + [test $HAVE_NL_LANGINFO = 0 || test $REPLACE_NL_LANGINFO = 1]) + gl_CONDITIONAL([GL_COND_OBJ_NL_LANGINFO_LOCK], + [test $REPLACE_NL_LANGINFO = 1 && test $NL_LANGINFO_MTSAFE = 0]) + if test $REPLACE_NL_LANGINFO = 1 && test $NL_LANGINFO_MTSAFE = 0; then + gl_PREREQ_NL_LANGINFO_LOCK + fi + gl_LANGINFO_MODULE_INDICATOR([nl_langinfo]) + gl_FUNC_GNU_STRFTIME + gl_NULLPTR + gl_FUNC_OPEN + gl_CONDITIONAL([GL_COND_OBJ_OPEN], [test $REPLACE_OPEN = 1]) + AM_COND_IF([GL_COND_OBJ_OPEN], [ + gl_PREREQ_OPEN + ]) + gl_FCNTL_MODULE_INDICATOR([open]) + gl_FUNC_OPENAT + gl_CONDITIONAL([GL_COND_OBJ_OPENAT], + [test $HAVE_OPENAT = 0 || test $REPLACE_OPENAT = 1]) + AM_COND_IF([GL_COND_OBJ_OPENAT], [ + gl_PREREQ_OPENAT + ]) + gl_MODULE_INDICATOR([openat]) dnl for lib/getcwd.c + gl_FCNTL_MODULE_INDICATOR([openat]) + gl_FUNC_OPENDIR + gl_CONDITIONAL([GL_COND_OBJ_OPENDIR], + [test $HAVE_OPENDIR = 0 || test $REPLACE_OPENDIR = 1]) + gl_DIRENT_MODULE_INDICATOR([opendir]) + gl_PATHMAX + gl_PERL + gl_FUNC_PIPE + gl_CONDITIONAL([GL_COND_OBJ_PIPE], [test $HAVE_PIPE = 0]) + gl_UNISTD_MODULE_INDICATOR([pipe]) + AC_CHECK_DECLS([program_invocation_name], [], [], [#include ]) + AC_CHECK_DECLS([program_invocation_short_name], [], [], [#include ]) + m4_ifdef([AM_XGETTEXT_OPTION], + [AM_][XGETTEXT_OPTION([--keyword='proper_name_lite:1,\"This is a proper name. See the gettext manual, section Names.\"'])]) + gl_QUOTE + gl_QUOTEARG + gl_FUNC_RAISE + gl_CONDITIONAL([GL_COND_OBJ_RAISE], + [test $HAVE_RAISE = 0 || test $REPLACE_RAISE = 1]) + AM_COND_IF([GL_COND_OBJ_RAISE], [ + gl_PREREQ_RAISE + ]) + gl_SIGNAL_MODULE_INDICATOR([raise]) + gl_FUNC_RAWMEMCHR + gl_CONDITIONAL([GL_COND_OBJ_RAWMEMCHR], [test $HAVE_RAWMEMCHR = 0]) + AM_COND_IF([GL_COND_OBJ_RAWMEMCHR], [ + gl_PREREQ_RAWMEMCHR + ]) + gl_STRING_MODULE_INDICATOR([rawmemchr]) + gl_FUNC_READLINK + gl_CONDITIONAL([GL_COND_OBJ_READLINK], + [test $HAVE_READLINK = 0 || test $REPLACE_READLINK = 1]) + AM_COND_IF([GL_COND_OBJ_READLINK], [ + gl_PREREQ_READLINK + ]) + gl_UNISTD_MODULE_INDICATOR([readlink]) + gl_FUNC_REALLOC_GNU + if test $REPLACE_REALLOC_FOR_REALLOC_GNU = 1; then + AC_LIBOBJ([realloc]) + fi + gl_STDLIB_MODULE_INDICATOR([realloc-gnu]) + gl_FUNC_REALLOC_POSIX + if test $REPLACE_REALLOC_FOR_REALLOC_POSIX = 1; then + AC_LIBOBJ([realloc]) + fi + gl_STDLIB_MODULE_INDICATOR([realloc-posix]) + gl_FUNC_REALLOCARRAY + gl_CONDITIONAL([GL_COND_OBJ_REALLOCARRAY], + [test $HAVE_REALLOCARRAY = 0 || test $REPLACE_REALLOCARRAY = 1]) + AM_COND_IF([GL_COND_OBJ_REALLOCARRAY], [ + gl_PREREQ_REALLOCARRAY + ]) + gl_MODULE_INDICATOR([reallocarray]) + gl_STDLIB_MODULE_INDICATOR([reallocarray]) + gl_REGEX + gl_CONDITIONAL([GL_COND_OBJ_REGEX], [test $ac_use_included_regex = yes]) + AM_COND_IF([GL_COND_OBJ_REGEX], [ + gl_PREREQ_REGEX + ]) + gl_SAVE_CWD + gl_FUNC_SETENV + gl_CONDITIONAL([GL_COND_OBJ_SETENV], + [test $HAVE_SETENV = 0 || test $REPLACE_SETENV = 1]) + gl_STDLIB_MODULE_INDICATOR([setenv]) + gl_FUNC_SETLOCALE_NULL + gl_CONDITIONAL([GL_COND_OBJ_SETLOCALE_LOCK], + [test $SETLOCALE_NULL_ALL_MTSAFE = 0 || test $SETLOCALE_NULL_ONE_MTSAFE = 0]) + AM_COND_IF([GL_COND_OBJ_SETLOCALE_LOCK], [ + gl_PREREQ_SETLOCALE_LOCK + ]) + gl_LOCALE_MODULE_INDICATOR([setlocale_null]) + AC_REQUIRE([AC_C_RESTRICT]) + gl_SIGNAL_H + gl_SIGNAL_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_SIGNALBLOCKING + gl_CONDITIONAL([GL_COND_OBJ_SIGPROCMASK], [test $HAVE_POSIX_SIGNALBLOCKING = 0]) + AM_COND_IF([GL_COND_OBJ_SIGPROCMASK], [ + gl_PREREQ_SIGPROCMASK + ]) + gl_SIGNAL_MODULE_INDICATOR([sigprocmask]) + AC_REQUIRE([gl_SIGSEGV]) + if test $gl_sigsegv_uses_libsigsegv = yes; then + GL_GENERATE_SIGSEGV_H=false + else + GL_GENERATE_SIGSEGV_H=true + fi + gl_CONDITIONAL_HEADER([sigsegv.h]) + AC_PROG_MKDIR_P + if $GL_GENERATE_SIGSEGV_H; then + dnl Persuade glibc to declare macros designating register + dnl indices: REG_RSP on x86_64, REG_ESP on i386. + dnl Persuade Solaris OpenIndiana to include , + dnl which declares macros designating register indices, such as ESP on i386. + dnl Persuade Solaris OpenIndiana to declare mincore(). + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + gl_MUSL_LIBC + AC_REQUIRE([AC_CANONICAL_HOST]) + case "$host_os" in + solaris2.11) + AC_DEFINE([SOLARIS11], [1], [Define on Solaris 11 and its derivates.]) + ;; + esac + gl_FUNC_MMAP_ANON + dnl Stack direction. + SV_STACK_DIRECTION + dnl Catching stack overflow requires an alternate signal stack. + dnl The old "install a guard page" trick would be unreliable, because + dnl we don't know where exactly to place the guard page. + SV_SIGALTSTACK + AC_CHECK_FUNCS_ONCE([getrlimit]) + fi + gt_TYPE_SSIZE_T + gl_FUNC_STAT + gl_CONDITIONAL([GL_COND_OBJ_STAT], [test $REPLACE_STAT = 1]) + AM_COND_IF([GL_COND_OBJ_STAT], [ + case "$host_os" in + mingw*) + AC_LIBOBJ([stat-w32]) + ;; + esac + gl_PREREQ_STAT + ]) + gl_SYS_STAT_MODULE_INDICATOR([stat]) + gl_STAT_TIME + gl_STAT_BIRTHTIME + gl_STDARG_H + gl_CONDITIONAL_HEADER([stdarg.h]) + AC_PROG_MKDIR_P + gl_C_BOOL + AC_CHECK_HEADERS_ONCE([stdckdint.h]) + if test $ac_cv_header_stdckdint_h = yes; then + GL_GENERATE_STDCKDINT_H=false + else + GL_GENERATE_STDCKDINT_H=true + fi + gl_CONDITIONAL_HEADER([stdckdint.h]) + AC_PROG_MKDIR_P + gl_STDDEF_H + gl_STDDEF_H_REQUIRE_DEFAULTS + gl_CONDITIONAL_HEADER([stddef.h]) + AC_PROG_MKDIR_P + gl_STDINT_H + gl_CONDITIONAL_HEADER([stdint.h]) + dnl Because of gl_REPLACE_LIMITS_H: + gl_CONDITIONAL_HEADER([limits.h]) + AC_PROG_MKDIR_P + gl_STDIO_H + gl_STDIO_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_CONDITIONAL([GL_COND_OBJ_STDIO_READ], [test $REPLACE_STDIO_READ_FUNCS = 1]) + gl_CONDITIONAL([GL_COND_OBJ_STDIO_WRITE], [test $REPLACE_STDIO_WRITE_FUNCS = 1]) + dnl No need to create extra modules for these functions. Everyone who uses + dnl likely needs them. + gl_STDIO_MODULE_INDICATOR([fscanf]) + gl_MODULE_INDICATOR([fscanf]) + gl_STDIO_MODULE_INDICATOR([scanf]) + gl_MODULE_INDICATOR([scanf]) + gl_STDIO_MODULE_INDICATOR([fgetc]) + gl_STDIO_MODULE_INDICATOR([getc]) + gl_STDIO_MODULE_INDICATOR([getchar]) + gl_STDIO_MODULE_INDICATOR([fgets]) + gl_STDIO_MODULE_INDICATOR([fread]) + dnl No need to create extra modules for these functions. Everyone who uses + dnl likely needs them. + gl_STDIO_MODULE_INDICATOR([fprintf]) + gl_STDIO_MODULE_INDICATOR([printf]) + gl_STDIO_MODULE_INDICATOR([vfprintf]) + gl_STDIO_MODULE_INDICATOR([vprintf]) + gl_STDIO_MODULE_INDICATOR([fputc]) + gl_STDIO_MODULE_INDICATOR([putc]) + gl_STDIO_MODULE_INDICATOR([putchar]) + gl_STDIO_MODULE_INDICATOR([fputs]) + gl_STDIO_MODULE_INDICATOR([puts]) + gl_STDIO_MODULE_INDICATOR([fwrite]) + gl_STDLIB_H + gl_STDLIB_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_FUNC_STPCPY + gl_CONDITIONAL([GL_COND_OBJ_STPCPY], + [test $HAVE_STPCPY = 0 || test $REPLACE_STPCPY = 1]) + AM_COND_IF([GL_COND_OBJ_STPCPY], [ + gl_PREREQ_STPCPY + ]) + gl_STRING_MODULE_INDICATOR([stpcpy]) + gl_STRCASE + gl_CONDITIONAL([GL_COND_OBJ_STRCASECMP], [test $HAVE_STRCASECMP = 0]) + AM_COND_IF([GL_COND_OBJ_STRCASECMP], [ + gl_PREREQ_STRCASECMP + ]) + gl_CONDITIONAL([GL_COND_OBJ_STRNCASECMP], [test $HAVE_STRNCASECMP = 0]) + AM_COND_IF([GL_COND_OBJ_STRNCASECMP], [ + gl_PREREQ_STRNCASECMP + ]) + gl_FUNC_STRDUP_POSIX + gl_CONDITIONAL([GL_COND_OBJ_STRDUP], [test $REPLACE_STRDUP = 1]) + AM_COND_IF([GL_COND_OBJ_STRDUP], [ + gl_PREREQ_STRDUP + ]) + gl_STRING_MODULE_INDICATOR([strdup]) + gl_FUNC_STRERROR + gl_CONDITIONAL([GL_COND_OBJ_STRERROR], [test $REPLACE_STRERROR = 1]) + gl_MODULE_INDICATOR([strerror]) + gl_STRING_MODULE_INDICATOR([strerror]) + AC_REQUIRE([gl_HEADER_ERRNO_H]) + AC_REQUIRE([gl_FUNC_STRERROR_0]) + gl_CONDITIONAL([GL_COND_OBJ_STRERROR_OVERRIDE], + [test -n "$ERRNO_H" || test $REPLACE_STRERROR_0 = 1]) + AM_COND_IF([GL_COND_OBJ_STRERROR_OVERRIDE], [ + gl_PREREQ_SYS_H_WINSOCK2 + ]) + gl_STRING_H + gl_STRING_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_STRINGS_H + gl_STRINGS_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_FUNC_STRNLEN + gl_CONDITIONAL([GL_COND_OBJ_STRNLEN], + [test $HAVE_DECL_STRNLEN = 0 || test $REPLACE_STRNLEN = 1]) + AM_COND_IF([GL_COND_OBJ_STRNLEN], [ + gl_PREREQ_STRNLEN + ]) + gl_STRING_MODULE_INDICATOR([strnlen]) + gl_FUNC_STRPTIME + gl_CONDITIONAL([GL_COND_OBJ_STRPTIME], [test $HAVE_STRPTIME = 0]) + AM_COND_IF([GL_COND_OBJ_STRPTIME], [ + gl_PREREQ_STRPTIME + ]) + gl_TIME_MODULE_INDICATOR([strptime]) + gl_FUNC_STRTOIMAX + gl_CONDITIONAL([GL_COND_OBJ_STRTOIMAX], + [test $HAVE_DECL_STRTOIMAX = 0 || test $REPLACE_STRTOIMAX = 1]) + AM_COND_IF([GL_COND_OBJ_STRTOIMAX], [ + gl_PREREQ_STRTOIMAX + ]) + gl_INTTYPES_MODULE_INDICATOR([strtoimax]) + gl_FUNC_STRTOLL + gl_CONDITIONAL([GL_COND_OBJ_STRTOLL], + [test $HAVE_STRTOLL = 0 || test $REPLACE_STRTOLL = 1]) + AM_COND_IF([GL_COND_OBJ_STRTOLL], [ + gl_PREREQ_STRTOLL + ]) + gl_STDLIB_MODULE_INDICATOR([strtoll]) + gl_SYS_RANDOM_H + gl_SYS_RANDOM_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_SYS_STAT_H + gl_SYS_STAT_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_SYS_TIME_H + gl_SYS_TIME_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_SYS_TYPES_H + gl_SYS_TYPES_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_SYS_WAIT_H + gl_SYS_WAIT_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + AC_REQUIRE([AC_C_RESTRICT]) + gl_FUNC_GEN_TEMPNAME + gl_MODULE_INDICATOR([tempname]) + AC_REQUIRE([gl_THREADLIB]) + gl_TIME_H + gl_TIME_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_TIME_R + gl_CONDITIONAL([GL_COND_OBJ_TIME_R], + [test $HAVE_LOCALTIME_R = 0 || test $REPLACE_LOCALTIME_R = 1]) + AM_COND_IF([GL_COND_OBJ_TIME_R], [ + gl_PREREQ_TIME_R + ]) + gl_TIME_MODULE_INDICATOR([time_r]) + gl_TIME_RZ + gl_CONDITIONAL([GL_COND_OBJ_TIME_RZ], [test $HAVE_TIMEZONE_T = 0]) + gl_TIME_MODULE_INDICATOR([time_rz]) + gl_FUNC_TIMEGM + gl_CONDITIONAL([GL_COND_OBJ_TIMEGM], + [test $HAVE_TIMEGM = 0 || test $REPLACE_TIMEGM = 1]) + AM_COND_IF([GL_COND_OBJ_TIMEGM], [ + gl_PREREQ_TIMEGM + ]) + gl_TIME_MODULE_INDICATOR([timegm]) + gl_TIMESPEC + gl_FUNC_TIMESPEC_GET + gl_CONDITIONAL([GL_COND_OBJ_TIMESPEC_GET], + [test $HAVE_TIMESPEC_GET = 0 || test $REPLACE_TIMESPEC_GET = 1]) + gl_TIME_MODULE_INDICATOR([timespec_get]) + gl_FUNC_TZSET + gl_CONDITIONAL([GL_COND_OBJ_TZSET], [test $REPLACE_TZSET = 1]) + gl_TIME_MODULE_INDICATOR([tzset]) + gl_UCHAR_H + gl_UCHAR_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_LIBUNISTRING_LIBHEADER([1.2], [unicase.h]) + gl_UNICASE_H + gl_UNICASE_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_LIBUNISTRING_MODULE([0.9.11], [unicase/tolower]) + gl_LIBUNISTRING_LIBHEADER([1.2], [unictype.h]) + gl_UNICTYPE_H + gl_UNICTYPE_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + AC_REQUIRE([AC_C_INLINE]) + gl_LIBUNISTRING_MODULE([0.9.8], [unictype/ctype-space]) + gl_LIBUNISTRING_LIBHEADER([1.2], [uninorm.h]) + gl_UNINORM_H + gl_UNINORM_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_UNISTD_H + gl_UNISTD_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_UNISTD_SAFER + gl_LIBUNISTRING_LIBHEADER([0.9.11], [unitypes.h]) + AC_PROG_MKDIR_P + AH_VERBATIM([unitypes_restrict], [ + /* This definition is a duplicate of the one in unitypes.h. + It is here so that we can cope with an older version of unitypes.h + that does not contain this definition and that is pre-installed among + the public header files. */ + # if defined __restrict \ + || 2 < __GNUC__ + (95 <= __GNUC_MINOR__) \ + || __clang_major__ >= 3 + # define _UC_RESTRICT __restrict + # elif 199901L <= __STDC_VERSION__ || defined restrict + # define _UC_RESTRICT restrict + # else + # define _UC_RESTRICT + # endif + ]) + gl_LIBUNISTRING_LIBHEADER([0.9.11], [uniwidth.h]) + AC_PROG_MKDIR_P + gl_LIBUNISTRING_MODULE([1.1], [uniwidth/width]) + AC_DEFINE([GNULIB_STDIO_SINGLE_THREAD], [1], + [Define to 1 if you want the FILE stream functions getc, putc, etc. + to use unlocked I/O if available, throughout the package. + Unlocked I/O can improve performance, sometimes dramatically. + But unlocked I/O is safe only in single-threaded programs, + as well as in multithreaded programs for which you can guarantee that + every FILE stream, including stdin, stdout, stderr, is used only + in a single thread.]) + AC_DEFINE([USE_UNLOCKED_IO], [GNULIB_STDIO_SINGLE_THREAD], + [An alias of GNULIB_STDIO_SINGLE_THREAD.]) + gl_FUNC_GLIBC_UNLOCKED_IO + gl_FUNC_UNSETENV + gl_CONDITIONAL([GL_COND_OBJ_UNSETENV], + [test $HAVE_UNSETENV = 0 || test $REPLACE_UNSETENV = 1]) + AM_COND_IF([GL_COND_OBJ_UNSETENV], [ + gl_PREREQ_UNSETENV + ]) + gl_STDLIB_MODULE_INDICATOR([unsetenv]) + AC_C_VARARRAYS + gl_VERSION_ETC + gl_WCHAR_H + gl_WCHAR_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_FUNC_WCRTOMB + gl_CONDITIONAL([GL_COND_OBJ_WCRTOMB], + [test $HAVE_WCRTOMB = 0 || test $REPLACE_WCRTOMB = 1]) + AM_COND_IF([GL_COND_OBJ_WCRTOMB], [ + gl_PREREQ_WCRTOMB + ]) + gl_WCHAR_MODULE_INDICATOR([wcrtomb]) + gl_WCTYPE_H + gl_WCTYPE_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_FUNC_WCWIDTH + gl_CONDITIONAL([GL_COND_OBJ_WCWIDTH], + [test $HAVE_WCWIDTH = 0 || test $REPLACE_WCWIDTH = 1]) + AM_COND_IF([GL_COND_OBJ_WCWIDTH], [ + gl_PREREQ_WCWIDTH + ]) + gl_WCHAR_MODULE_INDICATOR([wcwidth]) + AC_REQUIRE([AC_CANONICAL_HOST]) + gl_CONDITIONAL([GL_COND_OBJ_WINDOWS_MUTEX], + [case "$host_os" in mingw*) true;; *) false;; esac]) + AC_REQUIRE([AC_CANONICAL_HOST]) + gl_CONDITIONAL([GL_COND_OBJ_WINDOWS_ONCE], + [case "$host_os" in mingw*) true;; *) false;; esac]) + AC_REQUIRE([AC_CANONICAL_HOST]) + gl_CONDITIONAL([GL_COND_OBJ_WINDOWS_RECMUTEX], + [case "$host_os" in mingw*) true;; *) false;; esac]) + AC_REQUIRE([AC_CANONICAL_HOST]) + gl_CONDITIONAL([GL_COND_OBJ_WINDOWS_RWLOCK], + [case "$host_os" in mingw*) true;; *) false;; esac]) + gl_FUNC_WMEMCHR + gl_CONDITIONAL([GL_COND_OBJ_WMEMCHR], [test $HAVE_WMEMCHR = 0]) + gl_WCHAR_MODULE_INDICATOR([wmemchr]) + gl_FUNC_WMEMPCPY + gl_CONDITIONAL([GL_COND_OBJ_WMEMPCPY], + [test $HAVE_WMEMPCPY = 0 || test $REPLACE_WMEMPCPY = 1]) + gl_WCHAR_MODULE_INDICATOR([wmempcpy]) + gl_XALLOC + gl_MODULE_INDICATOR([xalloc]) + gl_MODULE_INDICATOR([xalloc-die]) + gl_XSTRTOL + # End of code from modules + m4_ifval(gl_LIBSOURCES_LIST, [ + m4_syscmd([test ! -d ]m4_defn([gl_LIBSOURCES_DIR])[ || + for gl_file in ]gl_LIBSOURCES_LIST[ ; do + if test ! -r ]m4_defn([gl_LIBSOURCES_DIR])[/$gl_file ; then + echo "missing file ]m4_defn([gl_LIBSOURCES_DIR])[/$gl_file" >&2 + exit 1 + fi + done])dnl + m4_if(m4_sysval, [0], [], + [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])]) + ]) + m4_popdef([GL_MODULE_INDICATOR_PREFIX]) + m4_popdef([GL_MACRO_PREFIX]) + m4_popdef([gl_LIBSOURCES_DIR]) + m4_popdef([gl_LIBSOURCES_LIST]) + m4_popdef([AC_LIBSOURCES]) + m4_popdef([AC_REPLACE_FUNCS]) + m4_popdef([AC_LIBOBJ]) + AC_CONFIG_COMMANDS_PRE([ + gl_libobjs= + gl_ltlibobjs= + gl_libobjdeps= + if test -n "$gl_LIBOBJS"; then + # Remove the extension. +changequote(,)dnl + sed_drop_objext='s/\.o$//;s/\.obj$//' + sed_dirname1='s,//*,/,g' + sed_dirname2='s,\(.\)/$,\1,' + sed_dirname3='s,^[^/]*$,.,' + sed_dirname4='s,\(.\)/[^/]*$,\1,' + sed_basename1='s,.*/,,' +changequote([, ])dnl + for i in `for i in $gl_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do + gl_libobjs="$gl_libobjs $i.$ac_objext" + gl_ltlibobjs="$gl_ltlibobjs $i.lo" + i_dir=`echo "$i" | sed -e "$sed_dirname1" -e "$sed_dirname2" -e "$sed_dirname3" -e "$sed_dirname4"` + i_base=`echo "$i" | sed -e "$sed_basename1"` + gl_libobjdeps="$gl_libobjdeps $i_dir/\$(DEPDIR)/$i_base.Po" + done + fi + AC_SUBST([gl_LIBOBJS], [$gl_libobjs]) + AC_SUBST([gl_LTLIBOBJS], [$gl_ltlibobjs]) + AC_SUBST([gl_LIBOBJDEPS], [$gl_libobjdeps]) + ]) + gltests_libdeps= + gltests_ltlibdeps= + m4_pushdef([AC_LIBOBJ], m4_defn([gltests_LIBOBJ])) + m4_pushdef([AC_REPLACE_FUNCS], m4_defn([gltests_REPLACE_FUNCS])) + m4_pushdef([AC_LIBSOURCES], m4_defn([gltests_LIBSOURCES])) + m4_pushdef([gltests_LIBSOURCES_LIST], []) + m4_pushdef([gltests_LIBSOURCES_DIR], []) + m4_pushdef([GL_MACRO_PREFIX], [gltests]) + m4_pushdef([GL_MODULE_INDICATOR_PREFIX], [GL]) + gl_COMMON + AC_REQUIRE([gl_CC_ALLOW_WARNINGS]) + AC_REQUIRE([gl_CXX_ALLOW_WARNINGS]) + gl_source_base='gnulib-tests' + gl_source_base_prefix= +changequote(,)dnl + gltests_WITNESS=IN_`echo "${PACKAGE-$PACKAGE_TARNAME}" | LC_ALL=C tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ | LC_ALL=C sed -e 's/[^A-Z0-9_]/_/g'`_GNULIB_TESTS +changequote([, ])dnl + AC_SUBST([gltests_WITNESS]) + gl_module_indicator_condition=$gltests_WITNESS + m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [$gl_module_indicator_condition]) + AC_REQUIRE([gl_SYS_SOCKET_H]) + gl_CONDITIONAL([GL_COND_OBJ_ACCEPT], [test "$ac_cv_header_winsock2_h" = yes]) + gl_SYS_SOCKET_MODULE_INDICATOR([accept]) + gl_ARPA_INET_H + gl_ARPA_INET_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_FUNC_ATOLL + gl_CONDITIONAL([GL_COND_OBJ_ATOLL], [test $HAVE_ATOLL = 0]) + AM_COND_IF([GL_COND_OBJ_ATOLL], [ + gl_PREREQ_ATOLL + ]) + gl_STDLIB_MODULE_INDICATOR([atoll]) + AC_REQUIRE([gl_SYS_SOCKET_H]) + gl_CONDITIONAL([GL_COND_OBJ_BIND], [test "$ac_cv_header_winsock2_h" = yes]) + gl_SYS_SOCKET_MODULE_INDICATOR([bind]) + gl_UCHAR_MODULE_INDICATOR([btoc32]) + gt_LOCALE_FR + gt_LOCALE_FR_UTF8 + gt_LOCALE_FR + gt_LOCALE_FR_UTF8 + gt_LOCALE_FR + gt_LOCALE_TR_UTF8 + gt_LOCALE_FR + gt_LOCALE_FR_UTF8 + gt_LOCALE_JA + gt_LOCALE_ZH_CN + gl_FUNC_C32RTOMB + gl_CONDITIONAL([GL_COND_OBJ_C32RTOMB], + [test $HAVE_C32RTOMB = 0 || test $REPLACE_C32RTOMB = 1]) + gl_UCHAR_MODULE_INDICATOR([c32rtomb]) + gt_LOCALE_FR + gt_LOCALE_FR_UTF8 + gt_LOCALE_JA + gt_LOCALE_ZH_CN + AC_REQUIRE([gl_MBRTOC32_SANITYCHECK]) + gl_UCHAR_MODULE_INDICATOR([c32tob]) + gt_LOCALE_FR + gt_LOCALE_FR_UTF8 + gt_LOCALE_JA + gt_LOCALE_ZH_CN + AC_REQUIRE([gl_SYS_SOCKET_H]) + gl_CONDITIONAL([GL_COND_OBJ_CONNECT], [test "$ac_cv_header_winsock2_h" = yes]) + gl_SYS_SOCKET_MODULE_INDICATOR([connect]) + gl_FUNC_FDOPEN + gl_CONDITIONAL([GL_COND_OBJ_FDOPEN], [test $REPLACE_FDOPEN = 1]) + AM_COND_IF([GL_COND_OBJ_FDOPEN], [ + gl_PREREQ_FDOPEN + ]) + gl_STDIO_MODULE_INDICATOR([fdopen]) + gl_FLOAT_H + gl_CONDITIONAL_HEADER([float.h]) + AC_PROG_MKDIR_P + gl_CONDITIONAL([GL_COND_OBJ_FLOAT], [test $REPLACE_FLOAT_LDBL = 1]) + gl_CONDITIONAL([GL_COND_OBJ_ITOLD], [test $REPLACE_ITOLD = 1]) + gl_FUNC_FTRUNCATE + gl_CONDITIONAL([GL_COND_OBJ_FTRUNCATE], + [test $HAVE_FTRUNCATE = 0 || test $REPLACE_FTRUNCATE = 1]) + AM_COND_IF([GL_COND_OBJ_FTRUNCATE], [ + gl_PREREQ_FTRUNCATE + ]) + gl_UNISTD_MODULE_INDICATOR([ftruncate]) + gl_MUSL_LIBC + dnl Distinguish OpenBSD >= 6.2 from OpenBSD < 6.2. + gl_CHECK_FUNCS_ANDROID([duplocale], [[#include ]]) + gl_FUNC_INET_PTON + gl_CONDITIONAL([GL_COND_OBJ_INET_PTON], + [test $HAVE_INET_PTON = 0 || test $REPLACE_INET_PTON = 1]) + AM_COND_IF([GL_COND_OBJ_INET_PTON], [ + gl_PREREQ_INET_PTON + ]) + gl_ARPA_INET_MODULE_INDICATOR([inet_pton]) + AC_C_BIGENDIAN + gl_INTTOSTR + gl_FUNC_IOCTL + gl_CONDITIONAL([GL_COND_OBJ_IOCTL], + [test $HAVE_IOCTL = 0 || test $REPLACE_IOCTL = 1]) + gl_SYS_IOCTL_MODULE_INDICATOR([ioctl]) + gt_LOCALE_FR + gt_LOCALE_FR_UTF8 + gt_LOCALE_JA + gt_LOCALE_ZH_CN + gt_LOCALE_FR + gt_LOCALE_FR_UTF8 + gt_LOCALE_JA + gt_LOCALE_ZH_CN + AC_REQUIRE([gl_SYS_SOCKET_H]) + gl_CONDITIONAL([GL_COND_OBJ_LISTEN], [test "$ac_cv_header_winsock2_h" = yes]) + gl_SYS_SOCKET_MODULE_INDICATOR([listen]) + gl_CHECK_FUNCS_ANDROID([newlocale], [[#include ]]) + gt_LOCALE_FR + gt_LOCALE_FR_UTF8 + gt_LOCALE_JA + gt_LOCALE_ZH_CN + gt_LOCALE_FR + gt_LOCALE_FR_UTF8 + gt_LOCALE_JA + gt_LOCALE_ZH_CN + gt_LOCALE_TR_UTF8 + gt_LOCALE_FR_UTF8 + gt_LOCALE_FR + gt_LOCALE_FR_UTF8 + gt_LOCALE_JA + gt_LOCALE_ZH_CN + dnl Check for prerequisites for memory fence checks. + gl_FUNC_MMAP_ANON + AC_CHECK_HEADERS_ONCE([sys/mman.h]) + AC_CHECK_FUNCS_ONCE([mprotect]) + gl_FUNC_MMAP_ANON + AC_CHECK_HEADERS_ONCE([sys/mman.h]) + AC_CHECK_FUNCS_ONCE([mprotect]) + gl_FUNC_NANOSLEEP + gl_CONDITIONAL([GL_COND_OBJ_NANOSLEEP], + [test $HAVE_NANOSLEEP = 0 || test $REPLACE_NANOSLEEP = 1]) + gl_TIME_MODULE_INDICATOR([nanosleep]) + AC_CHECK_DECLS_ONCE([alarm]) + gl_HEADER_NETINET_IN + gl_CONDITIONAL_HEADER([netinet/in.h]) + AC_PROG_MKDIR_P + gt_LOCALE_FR + gt_LOCALE_FR_UTF8 + gt_FUNC_USELOCALE + gl_FUNC_PERROR + gl_CONDITIONAL([GL_COND_OBJ_PERROR], [test $REPLACE_PERROR = 1]) + gl_STRING_MODULE_INDICATOR([perror]) + gl_FUNC_PSELECT + gl_CONDITIONAL([GL_COND_OBJ_PSELECT], + [test $HAVE_PSELECT = 0 || test $REPLACE_PSELECT = 1]) + gl_SYS_SELECT_MODULE_INDICATOR([pselect]) + AC_CHECK_HEADERS_ONCE([sys/wait.h]) + gl_PTHREAD_H + gl_PTHREAD_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_PTHREAD_THREAD + gl_CONDITIONAL([GL_COND_OBJ_PTHREAD_THREAD], + [test $HAVE_PTHREAD_CREATE = 0 || test $REPLACE_PTHREAD_CREATE = 1]) + gl_PTHREAD_MODULE_INDICATOR([pthread-thread]) + gl_FUNC_PTHREAD_SIGMASK + gl_CONDITIONAL([GL_COND_OBJ_PTHREAD_SIGMASK], + [test $HAVE_PTHREAD_SIGMASK = 0 || test $REPLACE_PTHREAD_SIGMASK = 1]) + AM_COND_IF([GL_COND_OBJ_PTHREAD_SIGMASK], [ + gl_PREREQ_PTHREAD_SIGMASK + ]) + gl_SIGNAL_MODULE_INDICATOR([pthread_sigmask]) + gl_FUNC_PUTENV + gl_CONDITIONAL([GL_COND_OBJ_PUTENV], [test $REPLACE_PUTENV = 1]) + AM_COND_IF([GL_COND_OBJ_PUTENV], [ + gl_PREREQ_PUTENV + ]) + gl_STDLIB_MODULE_INDICATOR([putenv]) + dnl Check for prerequisites for memory fence checks. + dnl FIXME: zerosize-ptr.h requires these: make a module for it + gl_FUNC_MMAP_ANON + AC_CHECK_HEADERS_ONCE([sys/mman.h]) + AC_CHECK_FUNCS_ONCE([mprotect]) + dnl Check for prerequisites for memory fence checks. + gl_FUNC_MMAP_ANON + AC_CHECK_HEADERS_ONCE([sys/mman.h]) + AC_CHECK_FUNCS_ONCE([mprotect]) + gl_SCHED_H + gl_SCHED_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_FUNC_SELECT + gl_CONDITIONAL([GL_COND_OBJ_SELECT], [test $REPLACE_SELECT = 1]) + gl_SYS_SELECT_MODULE_INDICATOR([select]) + AC_CHECK_HEADERS_ONCE([sys/wait.h]) + AC_REQUIRE([gl_SYS_SOCKET_H]) + gl_CONDITIONAL([GL_COND_OBJ_SETSOCKOPT], + [test "$ac_cv_header_winsock2_h" = yes]) + gl_SYS_SOCKET_MODULE_INDICATOR([setsockopt]) + AC_CHECK_FUNCS_ONCE([setrlimit]) + gl_FUNC_MMAP_ANON + gl_SIZE_MAX + gl_FUNC_SLEEP + gl_CONDITIONAL([GL_COND_OBJ_SLEEP], + [test $HAVE_SLEEP = 0 || test $REPLACE_SLEEP = 1]) + gl_UNISTD_MODULE_INDICATOR([sleep]) + AC_CHECK_DECLS_ONCE([alarm]) + gl_FUNC_SNPRINTF + gl_STDIO_MODULE_INDICATOR([snprintf]) + gl_MODULE_INDICATOR([snprintf]) + AC_REQUIRE([gl_SYS_SOCKET_H]) + gl_CONDITIONAL([GL_COND_OBJ_SOCKET], [test "$ac_cv_header_winsock2_h" = yes]) + # When this module is used, sockets may actually occur as file descriptors, + # hence it is worth warning if the modules 'close' and 'ioctl' are not used. + m4_ifdef([gl_UNISTD_H_DEFAULTS], [gl_UNISTD_H_REQUIRE_DEFAULTS]) + m4_ifdef([gl_SYS_IOCTL_H_DEFAULTS], [gl_SYS_IOCTL_H_REQUIRE_DEFAULTS]) + AC_REQUIRE([gl_PREREQ_SYS_H_WINSOCK2]) + if test "$ac_cv_header_winsock2_h" = yes; then + UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS=1 + SYS_IOCTL_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS=1 + fi + gl_SYS_SOCKET_MODULE_INDICATOR([socket]) + AC_REQUIRE([gl_SOCKETLIB]) + AC_REQUIRE([gl_SOCKETS]) + gl_TYPE_SOCKLEN_T + AC_REQUIRE([gt_TYPE_WCHAR_T]) + AC_REQUIRE([gt_TYPE_WINT_T]) + gl_DOUBLE_EXPONENT_LOCATION + gl_FUNC_STRERROR_R + AS_IF([test $HAVE_DECL_STRERROR_R = 0 || test $REPLACE_STRERROR_R = 1], [ + AC_LIBOBJ([strerror_r]) + gl_PREREQ_STRERROR_R + ]) + gl_STRING_MODULE_INDICATOR([strerror_r]) + dnl For the modules argp, error. + gl_MODULE_INDICATOR([strerror_r-posix]) + dnl Check for prerequisites for memory fence checks. + gl_FUNC_MMAP_ANON + AC_CHECK_HEADERS_ONCE([sys/mman.h]) + AC_CHECK_FUNCS_ONCE([mprotect]) + gl_FUNC_SYMLINK + gl_CONDITIONAL([GL_COND_OBJ_SYMLINK], + [test $HAVE_SYMLINK = 0 || test $REPLACE_SYMLINK = 1]) + gl_UNISTD_MODULE_INDICATOR([symlink]) + gl_SYS_IOCTL_H + gl_SYS_IOCTL_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_SYS_SELECT_H + gl_SYS_SELECT_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_SYS_SOCKET_H + gl_SYS_SOCKET_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + AC_CHECK_FUNCS_ONCE([shutdown]) + gl_SYS_UIO_H + gl_SYS_UIO_H_REQUIRE_DEFAULTS + AC_PROG_MKDIR_P + gl_THREAD + gl_FUNC_TIME + gl_CONDITIONAL([GL_COND_OBJ_TIME], [test $REPLACE_TIME = 1]) + AM_COND_IF([GL_COND_OBJ_TIME], [ + gl_PREREQ_TIME + ]) + gl_TIME_MODULE_INDICATOR([time]) + abs_aux_dir=`cd "$ac_aux_dir"; pwd` + AC_SUBST([abs_aux_dir]) + AC_REQUIRE([AC_C_RESTRICT]) + gl_FUNC_VASNPRINTF + abs_aux_dir=`cd "$ac_aux_dir"; pwd` + AC_SUBST([abs_aux_dir]) + gt_LOCALE_FR + gt_LOCALE_FR_UTF8 + gt_LOCALE_JA + gt_LOCALE_ZH_CN + gl_FUNC_WCTOB + gl_CONDITIONAL([GL_COND_OBJ_WCTOB], + [test $HAVE_WCTOB = 0 || test $REPLACE_WCTOB = 1]) + AM_COND_IF([GL_COND_OBJ_WCTOB], [ + gl_PREREQ_WCTOB + ]) + gl_WCHAR_MODULE_INDICATOR([wctob]) + gl_FUNC_WCTOMB + gl_CONDITIONAL([GL_COND_OBJ_WCTOMB], [test $REPLACE_WCTOMB = 1]) + AM_COND_IF([GL_COND_OBJ_WCTOMB], [ + gl_PREREQ_WCTOMB + ]) + gl_STDLIB_MODULE_INDICATOR([wctomb]) + AC_REQUIRE([AC_CANONICAL_HOST]) + gl_CONDITIONAL([GL_COND_OBJ_WINDOWS_THREAD], + [case "$host_os" in mingw*) true;; *) false;; esac]) + AC_REQUIRE([AC_CANONICAL_HOST]) + gl_CONDITIONAL([GL_COND_OBJ_WINDOWS_TLS], + [case "$host_os" in mingw*) true;; *) false;; esac]) + gl_XSIZE + m4_popdef([gl_MODULE_INDICATOR_CONDITION]) + m4_ifval(gltests_LIBSOURCES_LIST, [ + m4_syscmd([test ! -d ]m4_defn([gltests_LIBSOURCES_DIR])[ || + for gl_file in ]gltests_LIBSOURCES_LIST[ ; do + if test ! -r ]m4_defn([gltests_LIBSOURCES_DIR])[/$gl_file ; then + echo "missing file ]m4_defn([gltests_LIBSOURCES_DIR])[/$gl_file" >&2 + exit 1 + fi + done])dnl + m4_if(m4_sysval, [0], [], + [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])]) + ]) + m4_popdef([GL_MODULE_INDICATOR_PREFIX]) + m4_popdef([GL_MACRO_PREFIX]) + m4_popdef([gltests_LIBSOURCES_DIR]) + m4_popdef([gltests_LIBSOURCES_LIST]) + m4_popdef([AC_LIBSOURCES]) + m4_popdef([AC_REPLACE_FUNCS]) + m4_popdef([AC_LIBOBJ]) + AC_CONFIG_COMMANDS_PRE([ + gltests_libobjs= + gltests_ltlibobjs= + gltests_libobjdeps= + if test -n "$gltests_LIBOBJS"; then + # Remove the extension. +changequote(,)dnl + sed_drop_objext='s/\.o$//;s/\.obj$//' + sed_dirname1='s,//*,/,g' + sed_dirname2='s,\(.\)/$,\1,' + sed_dirname3='s,^[^/]*$,.,' + sed_dirname4='s,\(.\)/[^/]*$,\1,' + sed_basename1='s,.*/,,' +changequote([, ])dnl + for i in `for i in $gltests_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do + gltests_libobjs="$gltests_libobjs $i.$ac_objext" + gltests_ltlibobjs="$gltests_ltlibobjs $i.lo" + i_dir=`echo "$i" | sed -e "$sed_dirname1" -e "$sed_dirname2" -e "$sed_dirname3" -e "$sed_dirname4"` + i_base=`echo "$i" | sed -e "$sed_basename1"` + gltests_libobjdeps="$gltests_libobjdeps $i_dir/\$(DEPDIR)/$i_base.Po" + done + fi + AC_SUBST([gltests_LIBOBJS], [$gltests_libobjs]) + AC_SUBST([gltests_LTLIBOBJS], [$gltests_ltlibobjs]) + AC_SUBST([gltests_LIBOBJDEPS], [$gltests_libobjdeps]) + ]) + AC_REQUIRE([gl_CC_GNULIB_WARNINGS]) + LIBDIFFUTILS_LIBDEPS="$gl_libdeps" + AC_SUBST([LIBDIFFUTILS_LIBDEPS]) + LIBDIFFUTILS_LTLIBDEPS="$gl_ltlibdeps" + AC_SUBST([LIBDIFFUTILS_LTLIBDEPS]) + LIBTESTS_LIBDEPS="$gltests_libdeps" + AC_SUBST([LIBTESTS_LIBDEPS]) +]) + +# Like AC_LIBOBJ, except that the module name goes +# into gl_LIBOBJS instead of into LIBOBJS. +AC_DEFUN([gl_LIBOBJ], [ + AS_LITERAL_IF([$1], [gl_LIBSOURCES([$1.c])])dnl + gl_LIBOBJS="$gl_LIBOBJS $1.$ac_objext" +]) + +# Like AC_REPLACE_FUNCS, except that the module name goes +# into gl_LIBOBJS instead of into LIBOBJS. +AC_DEFUN([gl_REPLACE_FUNCS], [ + m4_foreach_w([gl_NAME], [$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl + AC_CHECK_FUNCS([$1], , [gl_LIBOBJ($ac_func)]) +]) + +# Like AC_LIBSOURCES, except the directory where the source file is +# expected is derived from the gnulib-tool parameterization, +# and alloca is special cased (for the alloca-opt module). +# We could also entirely rely on EXTRA_lib..._SOURCES. +AC_DEFUN([gl_LIBSOURCES], [ + m4_foreach([_gl_NAME], [$1], [ + m4_if(_gl_NAME, [alloca.c], [], [ + m4_define([gl_LIBSOURCES_DIR], [lib]) + m4_append([gl_LIBSOURCES_LIST], _gl_NAME, [ ]) + ]) + ]) +]) + +# Like AC_LIBOBJ, except that the module name goes +# into gltests_LIBOBJS instead of into LIBOBJS. +AC_DEFUN([gltests_LIBOBJ], [ + AS_LITERAL_IF([$1], [gltests_LIBSOURCES([$1.c])])dnl + gltests_LIBOBJS="$gltests_LIBOBJS $1.$ac_objext" +]) + +# Like AC_REPLACE_FUNCS, except that the module name goes +# into gltests_LIBOBJS instead of into LIBOBJS. +AC_DEFUN([gltests_REPLACE_FUNCS], [ + m4_foreach_w([gl_NAME], [$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl + AC_CHECK_FUNCS([$1], , [gltests_LIBOBJ($ac_func)]) +]) + +# Like AC_LIBSOURCES, except the directory where the source file is +# expected is derived from the gnulib-tool parameterization, +# and alloca is special cased (for the alloca-opt module). +# We could also entirely rely on EXTRA_lib..._SOURCES. +AC_DEFUN([gltests_LIBSOURCES], [ + m4_foreach([_gl_NAME], [$1], [ + m4_if(_gl_NAME, [alloca.c], [], [ + m4_define([gltests_LIBSOURCES_DIR], [gnulib-tests]) + m4_append([gltests_LIBSOURCES_LIST], _gl_NAME, [ ]) + ]) + ]) +]) + +# This macro records the list of files which have been installed by +# gnulib-tool and may be removed by future gnulib-tool invocations. +AC_DEFUN([gl_FILE_LIST], [ + build-aux/announce-gen + build-aux/config.rpath + build-aux/do-release-commit-and-tag + build-aux/gendocs.sh + build-aux/git-version-gen + build-aux/gitlog-to-changelog + build-aux/gnu-web-doc-update + build-aux/gnupload + build-aux/update-copyright + build-aux/useless-if-before-free + build-aux/vc-list-files + doc/gendocs_template + doc/gendocs_template_min + lib/_Noreturn.h + lib/alloca.in.h + lib/allocator.c + lib/allocator.h + lib/areadlink.c + lib/areadlink.h + lib/arg-nonnull.h + lib/argmatch.c + lib/argmatch.h + lib/assert.in.h + lib/assure.h + lib/attribute.h + lib/basename-lgpl.c + lib/basename-lgpl.h + lib/basename.c + lib/binary-io.c + lib/binary-io.h + lib/bitrotate.c + lib/bitrotate.h + lib/btowc.c + lib/c++defs.h + lib/c-ctype.c + lib/c-ctype.h + lib/c-stack.c + lib/c-stack.h + lib/c-strcase.h + lib/c-strcasecmp.c + lib/c-strcaseeq.h + lib/c-strncasecmp.c + lib/c32is-impl.h + lib/c32isspace.c + lib/c32to-impl.h + lib/c32tolower.c + lib/c32width.c + lib/calloc.c + lib/careadlinkat.c + lib/careadlinkat.h + lib/cdefs.h + lib/chdir-long.c + lib/chdir-long.h + lib/cloexec.c + lib/cloexec.h + lib/close.c + lib/closedir.c + lib/count-leading-zeros.c + lib/count-leading-zeros.h + lib/ctype.in.h + lib/diffseq.h + lib/dirent-private.h + lib/dirent.in.h + lib/dirfd.c + lib/dirname-lgpl.c + lib/dirname.c + lib/dirname.h + lib/dup-safer-flag.c + lib/dup-safer.c + lib/dup.c + lib/dup2.c + lib/dynarray.h + lib/errno.in.h + lib/error.c + lib/error.in.h + lib/exclude.c + lib/exclude.h + lib/exitfail.c + lib/exitfail.h + lib/fchdir.c + lib/fcntl.c + lib/fcntl.in.h + lib/fd-hook.c + lib/fd-hook.h + lib/fd-safer-flag.c + lib/fd-safer.c + lib/fdopendir.c + lib/file-type.c + lib/file-type.h + lib/filename.h + lib/filenamecat-lgpl.c + lib/filenamecat.c + lib/filenamecat.h + lib/flexmember.h + lib/fnmatch.c + lib/fnmatch.in.h + lib/fnmatch_loop.c + lib/fopen.c + lib/free.c + lib/freopen.c + lib/fstat.c + lib/getcwd-lgpl.c + lib/getdtablesize.c + lib/getopt-cdefs.in.h + lib/getopt-core.h + lib/getopt-ext.h + lib/getopt-pfx-core.h + lib/getopt-pfx-ext.h + lib/getopt.c + lib/getopt.in.h + lib/getopt1.c + lib/getopt_int.h + lib/getpagesize.c + lib/getprogname.c + lib/getprogname.h + lib/getrandom.c + lib/gettext.h + lib/gettime.c + lib/gettimeofday.c + lib/glthread/lock.c + lib/glthread/lock.h + lib/glthread/threadlib.c + lib/hard-locale.c + lib/hard-locale.h + lib/hash.c + lib/hash.h + lib/ialloc.c + lib/ialloc.h + lib/idx.h + lib/ignore-value.h + lib/intprops-internal.h + lib/intprops.h + lib/inttypes.in.h + lib/isblank.c + lib/iswblank.c + lib/iswdigit.c + lib/iswxdigit.c + lib/langinfo.in.h + lib/lc-charset-dispatch.c + lib/lc-charset-dispatch.h + lib/libc-config.h + lib/limits.in.h + lib/localcharset.c + lib/localcharset.h + lib/locale.in.h + lib/localeconv.c + lib/lstat.c + lib/malloc.c + lib/malloc/dynarray-skeleton.c + lib/malloc/dynarray.h + lib/malloc/dynarray_at_failure.c + lib/malloc/dynarray_emplace_enlarge.c + lib/malloc/dynarray_finalize.c + lib/malloc/dynarray_resize.c + lib/malloc/dynarray_resize_clear.c + lib/malloca.c + lib/malloca.h + lib/mbchar.c + lib/mbchar.h + lib/mbrtoc32.c + lib/mbrtowc-impl-utf8.h + lib/mbrtowc-impl.h + lib/mbrtowc.c + lib/mbscasecmp.c + lib/mbsinit.c + lib/mbsrtowcs-impl.h + lib/mbsrtowcs-state.c + lib/mbsrtowcs.c + lib/mbtowc-impl.h + lib/mbtowc-lock.c + lib/mbtowc-lock.h + lib/mbtowc.c + lib/mbuiter.c + lib/mbuiter.h + lib/memchr.c + lib/memchr.valgrind + lib/mempcpy.c + lib/memrchr.c + lib/minmax.h + lib/mkdir.c + lib/mkstemp.c + lib/mktime-internal.h + lib/mktime.c + lib/msvc-inval.c + lib/msvc-inval.h + lib/msvc-nothrow.c + lib/msvc-nothrow.h + lib/nl_langinfo-lock.c + lib/nl_langinfo.c + lib/nstrftime.c + lib/open.c + lib/openat-die.c + lib/openat-priv.h + lib/openat-proc.c + lib/openat.c + lib/openat.h + lib/opendir.c + lib/pathmax.h + lib/pipe-safer.c + lib/pipe.c + lib/progname.c + lib/progname.h + lib/propername-lite.c + lib/propername.h + lib/quote.h + lib/quotearg.c + lib/quotearg.h + lib/raise.c + lib/rawmemchr.c + lib/rawmemchr.valgrind + lib/readlink.c + lib/realloc.c + lib/reallocarray.c + lib/regcomp.c + lib/regex.c + lib/regex.h + lib/regex_internal.c + lib/regex_internal.h + lib/regexec.c + lib/same-inode.h + lib/save-cwd.c + lib/save-cwd.h + lib/setenv.c + lib/setlocale-lock.c + lib/setlocale_null.c + lib/setlocale_null.h + lib/sh-quote.c + lib/sh-quote.h + lib/signal.in.h + lib/sigprocmask.c + lib/sigsegv.c + lib/sigsegv.in.h + lib/stackvma.c + lib/stackvma.h + lib/stat-macros.h + lib/stat-time.c + lib/stat-time.h + lib/stat-w32.c + lib/stat-w32.h + lib/stat.c + lib/stdarg.in.h + lib/stdckdint.in.h + lib/stddef.in.h + lib/stdint.in.h + lib/stdio-read.c + lib/stdio-write.c + lib/stdio.in.h + lib/stdlib.in.h + lib/stdopen.c + lib/stdopen.h + lib/stpcpy.c + lib/strcasecmp.c + lib/strdup.c + lib/streq.h + lib/strerror-override.c + lib/strerror-override.h + lib/strerror.c + lib/strftime.h + lib/string.in.h + lib/strings.in.h + lib/stripslash.c + lib/strncasecmp.c + lib/strnlen.c + lib/strnlen1.c + lib/strnlen1.h + lib/strptime.c + lib/strtoimax.c + lib/strtol.c + lib/strtoll.c + lib/sys_random.in.h + lib/sys_stat.in.h + lib/sys_time.in.h + lib/sys_types.in.h + lib/sys_wait.in.h + lib/system-quote.c + lib/system-quote.h + lib/tempname.c + lib/tempname.h + lib/time-internal.h + lib/time.in.h + lib/time_r.c + lib/time_rz.c + lib/timegm.c + lib/timespec.c + lib/timespec.h + lib/timespec_get.c + lib/tzset.c + lib/uchar.in.h + lib/unicase.in.h + lib/unicase/simple-mapping.h + lib/unicase/tolower.c + lib/unicase/tolower.h + lib/unictype.in.h + lib/unictype/bitmap.h + lib/unictype/ctype_space.c + lib/unictype/ctype_space.h + lib/uninorm.in.h + lib/unistd--.h + lib/unistd-safer.h + lib/unistd.c + lib/unistd.in.h + lib/unitypes.in.h + lib/uniwidth.in.h + lib/uniwidth/cjk.h + lib/uniwidth/width.c + lib/uniwidth/width0.h + lib/uniwidth/width2.h + lib/unlocked-io.h + lib/unsetenv.c + lib/verify.h + lib/version-etc-fsf.c + lib/version-etc.c + lib/version-etc.h + lib/warn-on-use.h + lib/wchar.in.h + lib/wcrtomb.c + lib/wctype-h.c + lib/wctype.in.h + lib/wcwidth.c + lib/windows-initguard.h + 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 + lib/wmemchr-impl.h + lib/wmemchr.c + lib/wmempcpy.c + lib/xalloc-die.c + lib/xalloc-oversized.h + lib/xalloc.h + lib/xfreopen.c + lib/xfreopen.h + lib/xmalloc.c + lib/xmalloca.c + lib/xmalloca.h + lib/xreadlink.c + lib/xreadlink.h + lib/xstdopen.c + lib/xstdopen.h + lib/xstrtoimax.c + lib/xstrtol.c + lib/xstrtol.h + lib/xstrtoul.c + m4/00gnulib.m4 + m4/__inline.m4 + m4/absolute-header.m4 + m4/alloca.m4 + m4/arpa_inet_h.m4 + m4/asm-underscore.m4 + m4/assert_h.m4 + m4/atoll.m4 + m4/btowc.m4 + m4/builtin-expect.m4 + m4/c-bool.m4 + m4/c-stack.m4 + m4/c32rtomb.m4 + m4/calloc.m4 + m4/chdir-long.m4 + m4/clock_time.m4 + m4/close.m4 + m4/closedir.m4 + m4/codeset.m4 + m4/config-h.m4 + m4/ctype_h.m4 + m4/dirent_h.m4 + m4/dirfd.m4 + m4/double-slash-root.m4 + m4/dup.m4 + m4/dup2.m4 + m4/eealloc.m4 + m4/environ.m4 + m4/errno_h.m4 + m4/error.m4 + m4/error_h.m4 + m4/exponentd.m4 + m4/extensions.m4 + m4/extern-inline.m4 + m4/fchdir.m4 + m4/fclose.m4 + m4/fcntl-o.m4 + m4/fcntl.m4 + m4/fcntl_h.m4 + m4/fdopen.m4 + m4/fdopendir.m4 + m4/fflush.m4 + m4/filenamecat.m4 + m4/flexmember.m4 + m4/float_h.m4 + m4/fnmatch.m4 + m4/fnmatch_h.m4 + m4/fopen.m4 + m4/fpieee.m4 + m4/free.m4 + m4/freopen.m4 + m4/fstat.m4 + m4/ftruncate.m4 + m4/getcwd.m4 + m4/getdtablesize.m4 + m4/getopt.m4 + m4/getpagesize.m4 + m4/getprogname.m4 + m4/getrandom.m4 + m4/gettime.m4 + m4/gettimeofday.m4 + m4/gnu-make.m4 + m4/gnulib-common.m4 + m4/host-cpu-c-abi.m4 + m4/include_next.m4 + m4/inet_pton.m4 + m4/intl-thread-locale.m4 + m4/intmax_t.m4 + m4/inttostr.m4 + m4/inttypes.m4 + m4/inttypes_h.m4 + m4/ioctl.m4 + m4/isblank.m4 + m4/iswblank.m4 + m4/iswdigit.m4 + m4/iswxdigit.m4 + m4/langinfo_h.m4 + m4/largefile.m4 + m4/lib-ld.m4 + m4/lib-link.m4 + m4/lib-prefix.m4 + m4/libsigsegv.m4 + m4/libunistring-base.m4 + m4/limits-h.m4 + m4/localcharset.m4 + m4/locale-fr.m4 + m4/locale-ja.m4 + m4/locale-tr.m4 + m4/locale-zh.m4 + m4/locale_h.m4 + m4/localeconv.m4 + m4/lock.m4 + m4/lstat.m4 + m4/malloc.m4 + m4/malloca.m4 + m4/manywarnings-c++.m4 + m4/manywarnings.m4 + m4/math_h.m4 + m4/mbchar.m4 + m4/mbiter.m4 + m4/mbrtoc32.m4 + m4/mbrtowc.m4 + m4/mbsinit.m4 + m4/mbsrtowcs.m4 + m4/mbstate_t.m4 + m4/mbtowc.m4 + m4/memchr.m4 + m4/mempcpy.m4 + m4/memrchr.m4 + m4/minmax.m4 + m4/mkdir.m4 + m4/mkstemp.m4 + m4/mktime.m4 + m4/mmap-anon.m4 + m4/mode_t.m4 + m4/msvc-inval.m4 + m4/msvc-nothrow.m4 + m4/multiarch.m4 + m4/musl.m4 + m4/nanosleep.m4 + m4/netinet_in_h.m4 + m4/nl_langinfo.m4 + m4/nocrash.m4 + m4/nstrftime.m4 + m4/nullptr.m4 + m4/off_t.m4 + m4/open-cloexec.m4 + m4/open-slash.m4 + m4/open.m4 + m4/openat.m4 + m4/opendir.m4 + m4/pathmax.m4 + m4/perl.m4 + m4/perror.m4 + m4/pid_t.m4 + m4/pipe.m4 + m4/printf.m4 + m4/pselect.m4 + m4/pthread-thread.m4 + m4/pthread_h.m4 + m4/pthread_rwlock_rdlock.m4 + m4/pthread_sigmask.m4 + m4/putenv.m4 + m4/quote.m4 + m4/quotearg.m4 + m4/raise.m4 + m4/rawmemchr.m4 + m4/readlink.m4 + m4/realloc.m4 + m4/reallocarray.m4 + m4/regex.m4 + m4/save-cwd.m4 + m4/sched_h.m4 + m4/select.m4 + m4/setenv.m4 + m4/setlocale_null.m4 + m4/sigaltstack.m4 + m4/signal_h.m4 + m4/signalblocking.m4 + m4/sigsegv.m4 + m4/size_max.m4 + m4/sleep.m4 + m4/snprintf.m4 + m4/socketlib.m4 + m4/sockets.m4 + m4/socklen.m4 + m4/sockpfaf.m4 + m4/ssize_t.m4 + m4/stack-direction.m4 + m4/stat-time.m4 + m4/stat.m4 + m4/std-gnu11.m4 + m4/stdalign.m4 + m4/stdarg.m4 + m4/stddef_h.m4 + m4/stdint.m4 + m4/stdint_h.m4 + m4/stdio_h.m4 + m4/stdlib_h.m4 + m4/stpcpy.m4 + m4/strcase.m4 + m4/strdup.m4 + m4/strerror.m4 + m4/strerror_r.m4 + m4/string_h.m4 + m4/strings_h.m4 + m4/strnlen.m4 + m4/strptime.m4 + m4/strtoimax.m4 + m4/strtoll.m4 + m4/symlink.m4 + m4/sys_ioctl_h.m4 + m4/sys_random_h.m4 + m4/sys_select_h.m4 + m4/sys_socket_h.m4 + m4/sys_stat_h.m4 + m4/sys_time_h.m4 + m4/sys_types_h.m4 + m4/sys_uio_h.m4 + m4/sys_wait_h.m4 + m4/tempname.m4 + m4/thread.m4 + m4/threadlib.m4 + m4/time.m4 + m4/time_h.m4 + m4/time_r.m4 + m4/time_rz.m4 + m4/timegm.m4 + m4/timespec.m4 + m4/timespec_get.m4 + m4/tm_gmtoff.m4 + m4/tzset.m4 + m4/uchar_h.m4 + m4/unicase_h.m4 + m4/unictype_h.m4 + m4/uninorm_h.m4 + m4/unistd-safer.m4 + m4/unistd_h.m4 + m4/unlocked-io.m4 + m4/vararrays.m4 + m4/vasnprintf.m4 + m4/version-etc.m4 + m4/visibility.m4 + m4/warn-on-use.m4 + m4/warnings.m4 + m4/wchar_h.m4 + m4/wchar_t.m4 + m4/wcrtomb.m4 + m4/wctob.m4 + m4/wctomb.m4 + m4/wctype_h.m4 + m4/wcwidth.m4 + m4/wint_t.m4 + m4/wmemchr.m4 + m4/wmempcpy.m4 + m4/xalloc.m4 + m4/xsize.m4 + m4/xstrtol.m4 + m4/zzgnulib.m4 + tests/altstack-util.h + tests/init.sh + tests/locale.c + tests/macros.h + tests/mmap-anon-util.h + tests/nan.h + tests/nap.h + tests/signature.h + tests/test-accept.c + tests/test-alignasof.c + tests/test-alloca-opt.c + tests/test-areadlink.c + tests/test-areadlink.h + tests/test-argmatch.c + tests/test-arpa_inet.c + tests/test-assert.c + tests/test-binary-io.c + tests/test-binary-io.sh + tests/test-bind.c + tests/test-bitrotate.c + tests/test-btoc32-1.sh + tests/test-btoc32-2.sh + tests/test-btoc32-3.sh + tests/test-btoc32.c + tests/test-btowc.c + tests/test-btowc1.sh + tests/test-btowc2.sh + tests/test-btowc3.sh + tests/test-c-ctype.c + tests/test-c-stack.c + tests/test-c-stack.sh + tests/test-c-stack2.sh + tests/test-c-strcase.sh + tests/test-c-strcasecmp.c + tests/test-c-strcasestr.c + tests/test-c-strncasecmp.c + tests/test-c32isspace.c + tests/test-c32isspace.sh + tests/test-c32rtomb-w32-1.sh + tests/test-c32rtomb-w32-2.sh + tests/test-c32rtomb-w32-3.sh + tests/test-c32rtomb-w32-4.sh + tests/test-c32rtomb-w32-5.sh + tests/test-c32rtomb-w32-6.sh + tests/test-c32rtomb-w32-7.sh + tests/test-c32rtomb-w32.c + tests/test-c32rtomb.c + tests/test-c32rtomb.sh + tests/test-c32tolower.c + tests/test-c32tolower.sh + tests/test-c32width.c + tests/test-calloc-gnu.c + tests/test-chdir.c + tests/test-cloexec.c + tests/test-close.c + tests/test-connect.c + tests/test-count-leading-zeros.c + tests/test-ctype.c + tests/test-dirent.c + tests/test-dirfd.c + tests/test-dirname.c + tests/test-dup-safer.c + tests/test-dup.c + tests/test-dup2.c + tests/test-dynarray.c + tests/test-environ.c + tests/test-errno.c + tests/test-error.c + tests/test-error.sh + tests/test-exclude.c + tests/test-exclude1.sh + tests/test-exclude2.sh + tests/test-exclude3.sh + tests/test-exclude4.sh + tests/test-exclude5.sh + tests/test-exclude6.sh + tests/test-exclude7.sh + tests/test-exclude8.sh + tests/test-fchdir.c + tests/test-fcntl-h.c + tests/test-fcntl.c + tests/test-fdopen.c + tests/test-fdopendir.c + tests/test-fgetc.c + tests/test-filenamecat.c + tests/test-float.c + tests/test-fnmatch-h.c + tests/test-fnmatch.c + tests/test-fopen-gnu.c + tests/test-fopen.c + tests/test-fopen.h + tests/test-fputc.c + tests/test-fread.c + tests/test-free.c + tests/test-freopen.c + tests/test-fstat.c + tests/test-ftruncate.c + tests/test-ftruncate.sh + tests/test-fwrite.c + tests/test-getcwd-lgpl.c + tests/test-getdtablesize.c + tests/test-getopt-gnu.c + tests/test-getopt-main.h + tests/test-getopt-posix.c + tests/test-getopt.h + tests/test-getopt_long.h + tests/test-getprogname.c + tests/test-getrandom.c + tests/test-gettimeofday.c + tests/test-hard-locale.c + tests/test-hash.c + tests/test-ignore-value.c + tests/test-inet_pton.c + tests/test-init.sh + tests/test-intprops.c + tests/test-inttostr.c + tests/test-inttypes.c + tests/test-ioctl.c + tests/test-isblank.c + tests/test-iswblank.c + tests/test-iswdigit.c + tests/test-iswdigit.sh + tests/test-iswxdigit.c + tests/test-iswxdigit.sh + tests/test-langinfo.c + tests/test-largefile.c + tests/test-limits-h.c + tests/test-listen.c + tests/test-localcharset.c + tests/test-locale.c + tests/test-localeconv.c + tests/test-lstat.c + tests/test-lstat.h + tests/test-malloc-gnu.c + tests/test-malloca.c + tests/test-mbrtoc32-1.sh + tests/test-mbrtoc32-2.sh + tests/test-mbrtoc32-3.sh + tests/test-mbrtoc32-4.sh + tests/test-mbrtoc32-5.sh + tests/test-mbrtoc32-w32-1.sh + tests/test-mbrtoc32-w32-2.sh + tests/test-mbrtoc32-w32-3.sh + tests/test-mbrtoc32-w32-4.sh + tests/test-mbrtoc32-w32-5.sh + tests/test-mbrtoc32-w32-6.sh + tests/test-mbrtoc32-w32-7.sh + tests/test-mbrtoc32-w32.c + tests/test-mbrtoc32.c + tests/test-mbrtowc-w32-1.sh + tests/test-mbrtowc-w32-2.sh + tests/test-mbrtowc-w32-3.sh + tests/test-mbrtowc-w32-4.sh + tests/test-mbrtowc-w32-5.sh + tests/test-mbrtowc-w32-6.sh + tests/test-mbrtowc-w32-7.sh + tests/test-mbrtowc-w32.c + tests/test-mbrtowc.c + tests/test-mbrtowc1.sh + tests/test-mbrtowc2.sh + tests/test-mbrtowc3.sh + tests/test-mbrtowc4.sh + tests/test-mbrtowc5.sh + tests/test-mbscasecmp.c + tests/test-mbscasecmp.sh + tests/test-mbsinit.c + tests/test-mbsinit.sh + tests/test-mbsrtowcs.c + tests/test-mbsrtowcs1.sh + tests/test-mbsrtowcs2.sh + tests/test-mbsrtowcs3.sh + tests/test-mbsrtowcs4.sh + tests/test-mbsrtowcs5.sh + tests/test-memchr.c + tests/test-memrchr.c + tests/test-mkdir.c + tests/test-mkdir.h + tests/test-nanosleep.c + tests/test-netinet_in.c + tests/test-nl_langinfo-mt.c + tests/test-nl_langinfo1.c + tests/test-nl_langinfo1.sh + tests/test-nl_langinfo2.c + tests/test-nl_langinfo2.sh + tests/test-nstrftime.c + tests/test-nullptr.c + tests/test-open.c + tests/test-open.h + tests/test-openat.c + tests/test-pathmax.c + tests/test-perror.c + tests/test-perror.sh + tests/test-perror2.c + tests/test-pipe.c + tests/test-pselect.c + tests/test-pthread-thread.c + tests/test-pthread.c + tests/test-pthread_sigmask1.c + tests/test-pthread_sigmask2.c + tests/test-quotearg-simple.c + tests/test-quotearg.h + tests/test-raise.c + tests/test-rawmemchr.c + tests/test-readlink.c + tests/test-readlink.h + tests/test-realloc-gnu.c + tests/test-reallocarray.c + tests/test-regex.c + tests/test-sched.c + tests/test-select-fd.c + tests/test-select-in.sh + tests/test-select-out.sh + tests/test-select-stdin.c + tests/test-select.c + tests/test-select.h + tests/test-setenv.c + tests/test-setlocale_null-mt-all.c + tests/test-setlocale_null-mt-one.c + tests/test-setlocale_null.c + tests/test-setsockopt.c + tests/test-sh-quote.c + tests/test-signal-h.c + tests/test-sigprocmask.c + tests/test-sigsegv-catch-segv1.c + tests/test-sigsegv-catch-segv2.c + tests/test-sigsegv-catch-stackoverflow1.c + tests/test-sigsegv-catch-stackoverflow2.c + tests/test-sleep.c + tests/test-snprintf.c + tests/test-sockets.c + tests/test-stat-time.c + tests/test-stat.c + tests/test-stat.h + tests/test-stdbool.c + tests/test-stdckdint.c + tests/test-stddef.c + tests/test-stdint.c + tests/test-stdio.c + tests/test-stdlib.c + tests/test-strerror.c + tests/test-strerror_r.c + tests/test-string.c + tests/test-strings.c + tests/test-strnlen.c + tests/test-strtoimax.c + tests/test-strtoll.c + tests/test-symlink.c + tests/test-symlink.h + tests/test-sys_ioctl.c + tests/test-sys_random.c + tests/test-sys_select.c + tests/test-sys_socket.c + tests/test-sys_stat.c + tests/test-sys_time.c + tests/test-sys_types.c + tests/test-sys_uio.c + tests/test-sys_wait.c + tests/test-sys_wait.h + tests/test-thread_create.c + tests/test-thread_self.c + tests/test-time-h.c + tests/test-time.c + tests/test-timespec.c + tests/test-timespec_get.c + tests/test-uchar.c + tests/test-unistd.c + tests/test-unsetenv.c + tests/test-update-copyright.sh + tests/test-vasnprintf.c + tests/test-vc-list-files-cvs.sh + tests/test-vc-list-files-git.sh + tests/test-verify-try.c + tests/test-verify.c + tests/test-verify.sh + tests/test-version-etc.c + tests/test-version-etc.sh + tests/test-wchar.c + tests/test-wcrtomb-w32-1.sh + tests/test-wcrtomb-w32-2.sh + tests/test-wcrtomb-w32-3.sh + tests/test-wcrtomb-w32-4.sh + tests/test-wcrtomb-w32-5.sh + tests/test-wcrtomb-w32-6.sh + tests/test-wcrtomb-w32-7.sh + tests/test-wcrtomb-w32.c + tests/test-wcrtomb.c + tests/test-wcrtomb.sh + tests/test-wctype-h.c + tests/test-wcwidth.c + tests/test-xalloc-die.c + tests/test-xalloc-die.sh + tests/test-xstdopen.c + tests/test-xstdopen.sh + tests/test-xstrtoimax.c + tests/test-xstrtoimax.sh + tests/test-xstrtol.c + tests/test-xstrtol.sh + tests/test-xstrtoul.c + tests/test-year2038.c + tests/unicase/test-mapping-part1.h + tests/unicase/test-mapping-part2.h + tests/unicase/test-uc_tolower.c + tests/unictype/test-ctype_space.c + tests/unictype/test-predicate-part1.h + tests/unictype/test-predicate-part2.h + tests/uniwidth/test-uc_width.c + tests/uniwidth/test-uc_width2.c + tests/uniwidth/test-uc_width2.sh + tests/zerosize-ptr.h + tests=lib/_Noreturn.h + tests=lib/accept.c + tests=lib/alloca.c + tests=lib/anytostr.c + tests=lib/arg-nonnull.h + tests=lib/arpa_inet.in.h + tests=lib/asnprintf.c + tests=lib/atoll.c + tests=lib/bind.c + tests=lib/btoc32.c + tests=lib/c++defs.h + tests=lib/c-strcasestr.c + tests=lib/c-strcasestr.h + tests=lib/c32rtomb.c + tests=lib/c32tob.c + tests=lib/connect.c + tests=lib/dtotimespec.c + tests=lib/fdopen.c + tests=lib/float+.h + tests=lib/float.c + tests=lib/float.in.h + tests=lib/fpucw.h + tests=lib/ftruncate.c + tests=lib/glthread/thread.c + tests=lib/glthread/thread.h + tests=lib/hash-pjw.c + tests=lib/hash-pjw.h + tests=lib/imaxtostr.c + tests=lib/inet_pton.c + tests=lib/inttostr.c + tests=lib/inttostr.h + tests=lib/ioctl.c + tests=lib/itold.c + tests=lib/listen.c + tests=lib/nanosleep.c + tests=lib/netinet_in.in.h + tests=lib/offtostr.c + tests=lib/perror.c + tests=lib/printf-args.c + tests=lib/printf-args.h + tests=lib/printf-parse.c + tests=lib/printf-parse.h + tests=lib/pselect.c + tests=lib/pthread-thread.c + tests=lib/pthread.in.h + tests=lib/pthread_sigmask.c + tests=lib/putenv.c + tests=lib/sched.in.h + tests=lib/select.c + tests=lib/setsockopt.c + tests=lib/size_max.h + tests=lib/sleep.c + tests=lib/snprintf.c + tests=lib/socket.c + tests=lib/sockets.c + tests=lib/sockets.h + tests=lib/str-two-way.h + tests=lib/strerror_r.c + tests=lib/symlink.c + tests=lib/sys_ioctl.in.h + tests=lib/sys_select.in.h + tests=lib/sys_socket.c + tests=lib/sys_socket.in.h + tests=lib/sys_uio.in.h + tests=lib/time.c + tests=lib/timespec-add.c + tests=lib/timespec-sub.c + tests=lib/uinttostr.c + tests=lib/umaxtostr.c + tests=lib/vasnprintf.c + tests=lib/vasnprintf.h + tests=lib/w32sock.h + tests=lib/warn-on-use.h + tests=lib/wctob.c + tests=lib/wctomb-impl.h + tests=lib/wctomb.c + tests=lib/windows-thread.c + tests=lib/windows-thread.h + tests=lib/windows-tls.c + tests=lib/windows-tls.h + tests=lib/xsize.c + tests=lib/xsize.h + tests=lib/xstrtol-error.c + tests=lib/xstrtol-error.h + top/GNUmakefile + top/README-release + top/maint.mk +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/gnulib-tool.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/gnulib-tool.m4 new file mode 100644 index 00000000..ccf619d6 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/gnulib-tool.m4 @@ -0,0 +1,63 @@ +# gnulib-tool.m4 serial 4 +dnl Copyright (C) 2004-2005, 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl The following macros need not be invoked explicitly. +dnl Invoking them does nothing except to declare default arguments +dnl for "gnulib-tool --import". + +dnl Usage: gl_LOCAL_DIR([DIR]) +AC_DEFUN([gl_LOCAL_DIR], []) + +dnl Usage: gl_MODULES([module1 module2 ...]) +AC_DEFUN([gl_MODULES], []) + +dnl Usage: gl_AVOID([module1 module2 ...]) +AC_DEFUN([gl_AVOID], []) + +dnl Usage: gl_SOURCE_BASE([DIR]) +AC_DEFUN([gl_SOURCE_BASE], []) + +dnl Usage: gl_M4_BASE([DIR]) +AC_DEFUN([gl_M4_BASE], []) + +dnl Usage: gl_PO_BASE([DIR]) +AC_DEFUN([gl_PO_BASE], []) + +dnl Usage: gl_DOC_BASE([DIR]) +AC_DEFUN([gl_DOC_BASE], []) + +dnl Usage: gl_TESTS_BASE([DIR]) +AC_DEFUN([gl_TESTS_BASE], []) + +dnl Usage: gl_WITH_TESTS +AC_DEFUN([gl_WITH_TESTS], []) + +dnl Usage: gl_LIB([LIBNAME]) +AC_DEFUN([gl_LIB], []) + +dnl Usage: gl_LGPL or gl_LGPL([VERSION]) +AC_DEFUN([gl_LGPL], []) + +dnl Usage: gl_MAKEFILE_NAME([FILENAME]) +AC_DEFUN([gl_MAKEFILE_NAME], []) + +dnl Usage: gl_TESTS_MAKEFILE_NAME([FILENAME]) +AC_DEFUN([gl_TESTS_MAKEFILE_NAME], []) + +dnl Usage: gl_AUTOMAKE_SUBDIR +AC_DEFUN([gl_AUTOMAKE_SUBDIR], []) + +dnl Usage: gl_LIBTOOL +AC_DEFUN([gl_LIBTOOL], []) + +dnl Usage: gl_MACRO_PREFIX([PREFIX]) +AC_DEFUN([gl_MACRO_PREFIX], []) + +dnl Usage: gl_PO_DOMAIN([DOMAIN]) +AC_DEFUN([gl_PO_DOMAIN], []) + +dnl Usage: gl_VC_FILES([BOOLEAN]) +AC_DEFUN([gl_VC_FILES], []) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/host-cpu-c-abi.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/host-cpu-c-abi.m4 new file mode 100644 index 00000000..e860a19e --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/host-cpu-c-abi.m4 @@ -0,0 +1,527 @@ +# host-cpu-c-abi.m4 serial 17 +dnl Copyright (C) 2002-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible and Sam Steingold. + +dnl Sets the HOST_CPU variable to the canonical name of the CPU. +dnl Sets the HOST_CPU_C_ABI variable to the canonical name of the CPU with its +dnl C language ABI (application binary interface). +dnl Also defines __${HOST_CPU}__ and __${HOST_CPU_C_ABI}__ as C macros in +dnl config.h. +dnl +dnl This canonical name can be used to select a particular assembly language +dnl source file that will interoperate with C code on the given host. +dnl +dnl For example: +dnl * 'i386' and 'sparc' are different canonical names, because code for i386 +dnl will not run on SPARC CPUs and vice versa. They have different +dnl instruction sets. +dnl * 'sparc' and 'sparc64' are different canonical names, because code for +dnl 'sparc' and code for 'sparc64' cannot be linked together: 'sparc' code +dnl contains 32-bit instructions, whereas 'sparc64' code contains 64-bit +dnl instructions. A process on a SPARC CPU can be in 32-bit mode or in 64-bit +dnl mode, but not both. +dnl * 'mips' and 'mipsn32' are different canonical names, because they use +dnl different argument passing and return conventions for C functions, and +dnl although the instruction set of 'mips' is a large subset of the +dnl instruction set of 'mipsn32'. +dnl * 'mipsn32' and 'mips64' are different canonical names, because they use +dnl different sizes for the C types like 'int' and 'void *', and although +dnl the instruction sets of 'mipsn32' and 'mips64' are the same. +dnl * The same canonical name is used for different endiannesses. You can +dnl determine the endianness through preprocessor symbols: +dnl - 'arm': test __ARMEL__. +dnl - 'mips', 'mipsn32', 'mips64': test _MIPSEB vs. _MIPSEL. +dnl - 'powerpc64': test _BIG_ENDIAN vs. _LITTLE_ENDIAN. +dnl * The same name 'i386' is used for CPUs of type i386, i486, i586 +dnl (Pentium), AMD K7, Pentium II, Pentium IV, etc., because +dnl - Instructions that do not exist on all of these CPUs (cmpxchg, +dnl MMX, SSE, SSE2, 3DNow! etc.) are not frequently used. If your +dnl assembly language source files use such instructions, you will +dnl need to make the distinction. +dnl - Speed of execution of the common instruction set is reasonable across +dnl the entire family of CPUs. If you have assembly language source files +dnl that are optimized for particular CPU types (like GNU gmp has), you +dnl will need to make the distinction. +dnl See . +AC_DEFUN([gl_HOST_CPU_C_ABI], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_REQUIRE([gl_C_ASM]) + AC_CACHE_CHECK([host CPU and C ABI], [gl_cv_host_cpu_c_abi], + [case "$host_cpu" in + +changequote(,)dnl + i[34567]86 ) +changequote([,])dnl + gl_cv_host_cpu_c_abi=i386 + ;; + + x86_64 ) + # On x86_64 systems, the C compiler may be generating code in one of + # these ABIs: + # - 64-bit instruction set, 64-bit pointers, 64-bit 'long': x86_64. + # - 64-bit instruction set, 64-bit pointers, 32-bit 'long': x86_64 + # with native Windows (mingw, MSVC). + # - 64-bit instruction set, 32-bit pointers, 32-bit 'long': x86_64-x32. + # - 32-bit instruction set, 32-bit pointers, 32-bit 'long': i386. + AC_COMPILE_IFELSE( + [AC_LANG_SOURCE( + [[#if (defined __x86_64__ || defined __amd64__ \ + || defined _M_X64 || defined _M_AMD64) + int ok; + #else + error fail + #endif + ]])], + [AC_COMPILE_IFELSE( + [AC_LANG_SOURCE( + [[#if defined __ILP32__ || defined _ILP32 + int ok; + #else + error fail + #endif + ]])], + [gl_cv_host_cpu_c_abi=x86_64-x32], + [gl_cv_host_cpu_c_abi=x86_64])], + [gl_cv_host_cpu_c_abi=i386]) + ;; + +changequote(,)dnl + alphaev[4-8] | alphaev56 | alphapca5[67] | alphaev6[78] ) +changequote([,])dnl + gl_cv_host_cpu_c_abi=alpha + ;; + + arm* | aarch64 ) + # Assume arm with EABI. + # On arm64 systems, the C compiler may be generating code in one of + # these ABIs: + # - aarch64 instruction set, 64-bit pointers, 64-bit 'long': arm64. + # - aarch64 instruction set, 32-bit pointers, 32-bit 'long': arm64-ilp32. + # - 32-bit instruction set, 32-bit pointers, 32-bit 'long': arm or armhf. + AC_COMPILE_IFELSE( + [AC_LANG_SOURCE( + [[#ifdef __aarch64__ + int ok; + #else + error fail + #endif + ]])], + [AC_COMPILE_IFELSE( + [AC_LANG_SOURCE( + [[#if defined __ILP32__ || defined _ILP32 + int ok; + #else + error fail + #endif + ]])], + [gl_cv_host_cpu_c_abi=arm64-ilp32], + [gl_cv_host_cpu_c_abi=arm64])], + [# Don't distinguish little-endian and big-endian arm, since they + # don't require different machine code for simple operations and + # since the user can distinguish them through the preprocessor + # defines __ARMEL__ vs. __ARMEB__. + # But distinguish arm which passes floating-point arguments and + # return values in integer registers (r0, r1, ...) - this is + # gcc -mfloat-abi=soft or gcc -mfloat-abi=softfp - from arm which + # passes them in float registers (s0, s1, ...) and double registers + # (d0, d1, ...) - this is gcc -mfloat-abi=hard. GCC 4.6 or newer + # sets the preprocessor defines __ARM_PCS (for the first case) and + # __ARM_PCS_VFP (for the second case), but older GCC does not. + echo 'double ddd; void func (double dd) { ddd = dd; }' > conftest.c + # Look for a reference to the register d0 in the .s file. + AC_TRY_COMMAND(${CC-cc} $CFLAGS $CPPFLAGS $gl_c_asm_opt conftest.c) >/dev/null 2>&1 + if LC_ALL=C grep 'd0,' conftest.$gl_asmext >/dev/null; then + gl_cv_host_cpu_c_abi=armhf + else + gl_cv_host_cpu_c_abi=arm + fi + rm -f conftest* + ]) + ;; + + hppa1.0 | hppa1.1 | hppa2.0* | hppa64 ) + # On hppa, the C compiler may be generating 32-bit code or 64-bit + # code. In the latter case, it defines _LP64 and __LP64__. + AC_COMPILE_IFELSE( + [AC_LANG_SOURCE( + [[#ifdef __LP64__ + int ok; + #else + error fail + #endif + ]])], + [gl_cv_host_cpu_c_abi=hppa64], + [gl_cv_host_cpu_c_abi=hppa]) + ;; + + ia64* ) + # On ia64 on HP-UX, the C compiler may be generating 64-bit code or + # 32-bit code. In the latter case, it defines _ILP32. + AC_COMPILE_IFELSE( + [AC_LANG_SOURCE( + [[#ifdef _ILP32 + int ok; + #else + error fail + #endif + ]])], + [gl_cv_host_cpu_c_abi=ia64-ilp32], + [gl_cv_host_cpu_c_abi=ia64]) + ;; + + mips* ) + # We should also check for (_MIPS_SZPTR == 64), but gcc keeps this + # at 32. + AC_COMPILE_IFELSE( + [AC_LANG_SOURCE( + [[#if defined _MIPS_SZLONG && (_MIPS_SZLONG == 64) + int ok; + #else + error fail + #endif + ]])], + [gl_cv_host_cpu_c_abi=mips64], + [# In the n32 ABI, _ABIN32 is defined, _ABIO32 is not defined (but + # may later get defined by ), and _MIPS_SIM == _ABIN32. + # In the 32 ABI, _ABIO32 is defined, _ABIN32 is not defined (but + # may later get defined by ), and _MIPS_SIM == _ABIO32. + AC_COMPILE_IFELSE( + [AC_LANG_SOURCE( + [[#if (_MIPS_SIM == _ABIN32) + int ok; + #else + error fail + #endif + ]])], + [gl_cv_host_cpu_c_abi=mipsn32], + [gl_cv_host_cpu_c_abi=mips])]) + ;; + + powerpc* ) + # Different ABIs are in use on AIX vs. Mac OS X vs. Linux,*BSD. + # No need to distinguish them here; the caller may distinguish + # them based on the OS. + # On powerpc64 systems, the C compiler may still be generating + # 32-bit code. And on powerpc-ibm-aix systems, the C compiler may + # be generating 64-bit code. + AC_COMPILE_IFELSE( + [AC_LANG_SOURCE( + [[#if defined __powerpc64__ || defined __LP64__ + int ok; + #else + error fail + #endif + ]])], + [# On powerpc64, there are two ABIs on Linux: The AIX compatible + # one and the ELFv2 one. The latter defines _CALL_ELF=2. + AC_COMPILE_IFELSE( + [AC_LANG_SOURCE( + [[#if defined _CALL_ELF && _CALL_ELF == 2 + int ok; + #else + error fail + #endif + ]])], + [gl_cv_host_cpu_c_abi=powerpc64-elfv2], + [gl_cv_host_cpu_c_abi=powerpc64]) + ], + [gl_cv_host_cpu_c_abi=powerpc]) + ;; + + rs6000 ) + gl_cv_host_cpu_c_abi=powerpc + ;; + + riscv32 | riscv64 ) + # There are 2 architectures (with variants): rv32* and rv64*. + AC_COMPILE_IFELSE( + [AC_LANG_SOURCE( + [[#if __riscv_xlen == 64 + int ok; + #else + error fail + #endif + ]])], + [cpu=riscv64], + [cpu=riscv32]) + # There are 6 ABIs: ilp32, ilp32f, ilp32d, lp64, lp64f, lp64d. + # Size of 'long' and 'void *': + AC_COMPILE_IFELSE( + [AC_LANG_SOURCE( + [[#if defined __LP64__ + int ok; + #else + error fail + #endif + ]])], + [main_abi=lp64], + [main_abi=ilp32]) + # Float ABIs: + # __riscv_float_abi_double: + # 'float' and 'double' are passed in floating-point registers. + # __riscv_float_abi_single: + # 'float' are passed in floating-point registers. + # __riscv_float_abi_soft: + # No values are passed in floating-point registers. + AC_COMPILE_IFELSE( + [AC_LANG_SOURCE( + [[#if defined __riscv_float_abi_double + int ok; + #else + error fail + #endif + ]])], + [float_abi=d], + [AC_COMPILE_IFELSE( + [AC_LANG_SOURCE( + [[#if defined __riscv_float_abi_single + int ok; + #else + error fail + #endif + ]])], + [float_abi=f], + [float_abi='']) + ]) + gl_cv_host_cpu_c_abi="${cpu}-${main_abi}${float_abi}" + ;; + + s390* ) + # On s390x, the C compiler may be generating 64-bit (= s390x) code + # or 31-bit (= s390) code. + AC_COMPILE_IFELSE( + [AC_LANG_SOURCE( + [[#if defined __LP64__ || defined __s390x__ + int ok; + #else + error fail + #endif + ]])], + [gl_cv_host_cpu_c_abi=s390x], + [gl_cv_host_cpu_c_abi=s390]) + ;; + + sparc | sparc64 ) + # UltraSPARCs running Linux have `uname -m` = "sparc64", but the + # C compiler still generates 32-bit code. + AC_COMPILE_IFELSE( + [AC_LANG_SOURCE( + [[#if defined __sparcv9 || defined __arch64__ + int ok; + #else + error fail + #endif + ]])], + [gl_cv_host_cpu_c_abi=sparc64], + [gl_cv_host_cpu_c_abi=sparc]) + ;; + + *) + gl_cv_host_cpu_c_abi="$host_cpu" + ;; + esac + ]) + + dnl In most cases, $HOST_CPU and $HOST_CPU_C_ABI are the same. + HOST_CPU=`echo "$gl_cv_host_cpu_c_abi" | sed -e 's/-.*//'` + HOST_CPU_C_ABI="$gl_cv_host_cpu_c_abi" + AC_SUBST([HOST_CPU]) + AC_SUBST([HOST_CPU_C_ABI]) + + # This was + # AC_DEFINE_UNQUOTED([__${HOST_CPU}__]) + # AC_DEFINE_UNQUOTED([__${HOST_CPU_C_ABI}__]) + # earlier, but KAI C++ 3.2d doesn't like this. + sed -e 's/-/_/g' >> confdefs.h <. + dnl Additionally, with this same compiler, include_next is a no-op when + dnl used in a header file that was included by specifying its absolute + dnl file name. Despite these two bugs, include_next is used in the + dnl compiler's . By virtue of the second bug, we need to use + dnl include_next as well in this case. + cat < conftestd1a/conftest.h +#define DEFINED_IN_CONFTESTD1 +#include_next +#ifdef DEFINED_IN_CONFTESTD2 +int foo; +#else +#error "include_next doesn't work" +#endif +EOF + cat < conftestd1b/conftest.h +#define DEFINED_IN_CONFTESTD1 +#include +#include_next +#ifdef DEFINED_IN_CONFTESTD2 +int foo; +#else +#error "include_next doesn't work" +#endif +EOF + cat < conftestd2/conftest.h +#ifndef DEFINED_IN_CONFTESTD1 +#error "include_next test doesn't work" +#endif +#define DEFINED_IN_CONFTESTD2 +EOF + gl_save_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1b -Iconftestd2" +dnl We intentionally avoid using AC_LANG_SOURCE here. + AC_COMPILE_IFELSE([AC_LANG_DEFINES_PROVIDED[#include ]], + [gl_cv_have_include_next=yes], + [CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1a -Iconftestd2" + AC_COMPILE_IFELSE([AC_LANG_DEFINES_PROVIDED[#include ]], + [gl_cv_have_include_next=buggy], + [gl_cv_have_include_next=no]) + ]) + CPPFLAGS="$gl_save_CPPFLAGS" + rm -rf conftestd1a conftestd1b conftestd2 + ]) + PRAGMA_SYSTEM_HEADER= + if test $gl_cv_have_include_next = yes; then + INCLUDE_NEXT=include_next + INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include_next + if test -n "$GCC"; then + PRAGMA_SYSTEM_HEADER='#pragma GCC system_header' + fi + else + if test $gl_cv_have_include_next = buggy; then + INCLUDE_NEXT=include + INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include_next + else + INCLUDE_NEXT=include + INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include + fi + fi + AC_SUBST([INCLUDE_NEXT]) + AC_SUBST([INCLUDE_NEXT_AS_FIRST_DIRECTIVE]) + AC_SUBST([PRAGMA_SYSTEM_HEADER]) + + dnl HP NonStop systems, which define __TANDEM, limit the line length + dnl after including some system header files. + AC_CACHE_CHECK([whether source code line length is unlimited], + [gl_cv_source_line_length_unlimited], + [AC_EGREP_CPP([choke me], + [ +#ifdef __TANDEM +choke me +#endif + ], + [gl_cv_source_line_length_unlimited=no], + [gl_cv_source_line_length_unlimited=yes]) + ]) + if test $gl_cv_source_line_length_unlimited = no; then + PRAGMA_COLUMNS="#pragma COLUMNS 10000" + else + PRAGMA_COLUMNS= + fi + AC_SUBST([PRAGMA_COLUMNS]) +]) + +# gl_CHECK_NEXT_HEADERS(HEADER1 HEADER2 ...) +# ------------------------------------------ +# For each arg foo.h, if #include_next works, define NEXT_FOO_H to be +# ''; otherwise define it to be +# '"///usr/include/foo.h"', or whatever other absolute file name is suitable. +# Also, if #include_next works as first preprocessing directive in a file, +# define NEXT_AS_FIRST_DIRECTIVE_FOO_H to be ''; otherwise define it to +# be +# '"///usr/include/foo.h"', or whatever other absolute file name is suitable. +# That way, a header file with the following line: +# #@INCLUDE_NEXT@ @NEXT_FOO_H@ +# or +# #@INCLUDE_NEXT_AS_FIRST_DIRECTIVE@ @NEXT_AS_FIRST_DIRECTIVE_FOO_H@ +# behaves (after sed substitution) as if it contained +# #include_next +# even if the compiler does not support include_next. +# The three "///" are to pacify Sun C 5.8, which otherwise would say +# "warning: #include of /usr/include/... may be non-portable". +# Use '""', not '<>', so that the /// cannot be confused with a C99 comment. +# Note: This macro assumes that the header file is not empty after +# preprocessing, i.e. it does not only define preprocessor macros but also +# provides some type/enum definitions or function/variable declarations. +# +# This macro also checks whether each header exists, by invoking +# AC_CHECK_HEADERS_ONCE or AC_CHECK_HEADERS on each argument. +AC_DEFUN([gl_CHECK_NEXT_HEADERS], +[ + gl_NEXT_HEADERS_INTERNAL([$1], [check]) +]) + +# gl_NEXT_HEADERS(HEADER1 HEADER2 ...) +# ------------------------------------ +# Like gl_CHECK_NEXT_HEADERS, except do not check whether the headers exist. +# This is suitable for headers like that are standardized by C89 +# and therefore can be assumed to exist. +AC_DEFUN([gl_NEXT_HEADERS], +[ + gl_NEXT_HEADERS_INTERNAL([$1], [assume]) +]) + +# The guts of gl_CHECK_NEXT_HEADERS and gl_NEXT_HEADERS. +AC_DEFUN([gl_NEXT_HEADERS_INTERNAL], +[ + AC_REQUIRE([gl_INCLUDE_NEXT]) + AC_REQUIRE([AC_CANONICAL_HOST]) + + m4_if([$2], [check], + [AC_CHECK_HEADERS_ONCE([$1]) + ]) + + m4_foreach_w([gl_HEADER_NAME], [$1], + [AS_VAR_PUSHDEF([gl_next_header], + [gl_cv_next_]m4_defn([gl_HEADER_NAME])) + if test $gl_cv_have_include_next = yes; then + AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>']) + else + AC_CACHE_CHECK( + [absolute name of <]m4_defn([gl_HEADER_NAME])[>], + [gl_next_header], + [m4_if([$2], [check], + [AS_VAR_PUSHDEF([gl_header_exists], + [ac_cv_header_]m4_defn([gl_HEADER_NAME])) + if test AS_VAR_GET([gl_header_exists]) = yes; then + AS_VAR_POPDEF([gl_header_exists]) + ]) + gl_ABSOLUTE_HEADER_ONE(gl_HEADER_NAME) + AS_VAR_COPY([gl_header], [gl_cv_absolute_]AS_TR_SH(gl_HEADER_NAME)) + AS_VAR_SET([gl_next_header], ['"'$gl_header'"']) + m4_if([$2], [check], + [else + AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>']) + fi + ]) + ]) + fi + AC_SUBST( + AS_TR_CPP([NEXT_]m4_defn([gl_HEADER_NAME])), + [AS_VAR_GET([gl_next_header])]) + if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then + # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' + gl_next_as_first_directive='<'gl_HEADER_NAME'>' + else + # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' + gl_next_as_first_directive=AS_VAR_GET([gl_next_header]) + fi + AC_SUBST( + AS_TR_CPP([NEXT_AS_FIRST_DIRECTIVE_]m4_defn([gl_HEADER_NAME])), + [$gl_next_as_first_directive]) + AS_VAR_POPDEF([gl_next_header])]) +]) + +# Autoconf 2.68 added warnings for our use of AC_COMPILE_IFELSE; +# this fallback is safe for all earlier autoconf versions. +m4_define_default([AC_LANG_DEFINES_PROVIDED]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/inet_pton.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/inet_pton.m4 new file mode 100644 index 00000000..2035feac --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/inet_pton.m4 @@ -0,0 +1,70 @@ +# inet_pton.m4 serial 19 +dnl Copyright (C) 2006, 2008-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_INET_PTON], +[ + AC_REQUIRE([gl_ARPA_INET_H_DEFAULTS]) + + dnl Persuade Solaris to declare inet_pton. + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + + AC_REQUIRE([AC_C_RESTRICT]) + + dnl Most platforms that provide inet_pton define it in libc. + dnl Solaris 8..10 provide inet_pton in libnsl instead. + dnl Solaris 2.6..7 provide inet_pton in libresolv instead. + dnl Haiku provides it in -lnetwork. + dnl Native Windows provides it in -lws2_32 instead, with a declaration in + dnl , and it uses stdcall calling convention, not cdecl + dnl (hence we cannot use AC_CHECK_FUNCS, AC_SEARCH_LIBS to find it). + HAVE_INET_PTON=1 + INET_PTON_LIB= + gl_PREREQ_SYS_H_WINSOCK2 + if test $HAVE_WINSOCK2_H = 1; then + dnl It needs to be overridden, because the stdcall calling convention + dnl is not compliant with POSIX. Set REPLACE_INET_PTON in order to avoid + dnl a name conflict at the linker level, even though the header file + dnl declares inet_pton only if _WIN32_WINNT >= 0x0600. + REPLACE_INET_PTON=1 + AC_CHECK_DECLS([inet_pton],,, [[#include ]]) + if test $ac_cv_have_decl_inet_pton = yes; then + INET_PTON_LIB="-lws2_32" + else + HAVE_DECL_INET_PTON=0 + fi + else + gl_save_LIBS=$LIBS + AC_SEARCH_LIBS([inet_pton], [nsl resolv network], [], + [AC_CHECK_FUNCS([inet_pton]) + if test $ac_cv_func_inet_pton = no; then + HAVE_INET_PTON=0 + fi + ]) + LIBS=$gl_save_LIBS + + if test "$ac_cv_search_inet_pton" != "no" \ + && test "$ac_cv_search_inet_pton" != "none required"; then + INET_PTON_LIB="$ac_cv_search_inet_pton" + fi + + AC_CHECK_HEADERS_ONCE([netdb.h]) + AC_CHECK_DECLS([inet_pton],,, + [[#include + #if HAVE_NETDB_H + # include + #endif + ]]) + if test $ac_cv_have_decl_inet_pton = no; then + HAVE_DECL_INET_PTON=0 + fi + fi + AC_SUBST([INET_PTON_LIB]) +]) + +# Prerequisites of lib/inet_pton.c. +AC_DEFUN([gl_PREREQ_INET_PTON], [ + AC_REQUIRE([gl_SOCKET_FAMILIES]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/inline.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/inline.m4 new file mode 100644 index 00000000..208f7423 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/inline.m4 @@ -0,0 +1,40 @@ +# inline.m4 serial 4 +dnl Copyright (C) 2006, 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl Test for the 'inline' keyword or equivalent. +dnl Define 'inline' to a supported equivalent, or to nothing if not supported, +dnl like AC_C_INLINE does. Also, define HAVE_INLINE if 'inline' or an +dnl equivalent is effectively supported, i.e. if the compiler is likely to +dnl drop unused 'static inline' functions. +AC_DEFUN([gl_INLINE], +[ + AC_REQUIRE([AC_C_INLINE]) + AC_CACHE_CHECK([whether the compiler generally respects inline], + [gl_cv_c_inline_effective], + [if test $ac_cv_c_inline = no; then + gl_cv_c_inline_effective=no + else + dnl GCC defines __NO_INLINE__ if not optimizing or if -fno-inline is + dnl specified. + dnl Use AC_COMPILE_IFELSE here, not AC_EGREP_CPP, because the result + dnl depends on optimization flags, which can be in CFLAGS. + dnl (AC_EGREP_CPP looks only at the CPPFLAGS.) + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[]], + [[#ifdef __NO_INLINE__ + #error "inline is not effective" + #endif]])], + [gl_cv_c_inline_effective=yes], + [gl_cv_c_inline_effective=no]) + fi + ]) + if test $gl_cv_c_inline_effective = yes; then + AC_DEFINE([HAVE_INLINE], [1], + [Define to 1 if the compiler supports one of the keywords + 'inline', '__inline__', '__inline' and effectively inlines + functions marked as such.]) + fi +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/intl-thread-locale.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/intl-thread-locale.m4 new file mode 100644 index 00000000..74a2654b --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/intl-thread-locale.m4 @@ -0,0 +1,219 @@ +# intl-thread-locale.m4 serial 10 +dnl Copyright (C) 2015-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. +dnl +dnl This file can be used in projects which are not available under +dnl the GNU General Public License or the GNU Lesser General Public +dnl License but which still want to provide support for the GNU gettext +dnl functionality. +dnl Please note that the actual code of the GNU gettext library is covered +dnl by the GNU Lesser General Public License, and the rest of the GNU +dnl gettext package is covered by the GNU General Public License. +dnl They are *not* in the public domain. + +dnl Check how to retrieve the name of a per-thread locale (POSIX locale_t). +dnl Sets gt_nameless_locales. +AC_DEFUN([gt_INTL_THREAD_LOCALE_NAME], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) + + dnl Persuade Solaris to define 'locale_t'. + AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) + + dnl Test whether uselocale() exists and works at all. + gt_FUNC_USELOCALE + + dnl On OpenBSD >= 6.2, the locale_t type and the uselocale(), newlocale(), + dnl duplocale(), freelocale() functions exist but are effectively useless, + dnl because the locale_t value depends only on the LC_CTYPE category of the + dnl locale and furthermore contains only one bit of information (it + dnl distinguishes the "C" locale from the *.UTF-8 locales). See + dnl . + dnl In the setlocale() implementation they have thought about the programs + dnl that use the API ("Even though only LC_CTYPE has any effect in the + dnl OpenBSD base system, store complete information about the global locale, + dnl such that third-party software can access it"), but for uselocale() + dnl they did not think about the programs. + dnl In this situation, even the HAVE_NAMELESS_LOCALES support does not work. + dnl So, define HAVE_FAKE_LOCALES and disable all locale_t support. + case "$gt_cv_func_uselocale_works" in + *yes) + AC_CHECK_HEADERS_ONCE([xlocale.h]) + AC_CACHE_CHECK([for fake locale system (OpenBSD)], + [gt_cv_locale_fake], + [AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#if HAVE_XLOCALE_H +# include +#endif +int main () +{ + locale_t loc1, loc2; + if (setlocale (LC_ALL, "de_DE.UTF-8") == NULL) return 1; + if (setlocale (LC_ALL, "fr_FR.UTF-8") == NULL) return 1; + loc1 = newlocale (LC_ALL_MASK, "de_DE.UTF-8", (locale_t)0); + loc2 = newlocale (LC_ALL_MASK, "fr_FR.UTF-8", (locale_t)0); + return !(loc1 == loc2); +}]])], + [gt_cv_locale_fake=yes], + [gt_cv_locale_fake=no], + [dnl Guess the locale system is fake only on OpenBSD. + case "$host_os" in + openbsd*) gt_cv_locale_fake="guessing yes" ;; + *) gt_cv_locale_fake="guessing no" ;; + esac + ]) + ]) + ;; + *) gt_cv_locale_fake=no ;; + esac + case "$gt_cv_locale_fake" in + *yes) + gt_fake_locales=yes + AC_DEFINE([HAVE_FAKE_LOCALES], [1], + [Define if the locale_t type contains insufficient information, as on OpenBSD.]) + ;; + *) + gt_fake_locales=no + ;; + esac + + case "$gt_cv_func_uselocale_works" in + *yes) + AC_CACHE_CHECK([for Solaris 11.4 locale system], + [gt_cv_locale_solaris114], + [case "$host_os" in + solaris*) + dnl Test whether defines locale_t as a typedef of + dnl 'struct _LC_locale_t **' (whereas Illumos defines it as a + dnl typedef of 'struct _locale *'). + dnl Another possible test would be to include + dnl and test whether it defines the _LC_core_data_locale_t type. + dnl This type was added in Solaris 11.4. + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[ + #include + struct _LC_locale_t *x; + locale_t y; + ]], + [[*y = x;]])], + [gt_cv_locale_solaris114=yes], + [gt_cv_locale_solaris114=no]) + ;; + *) gt_cv_locale_solaris114=no ;; + esac + ]) + ;; + *) gt_cv_locale_solaris114=no ;; + esac + if test $gt_cv_locale_solaris114 = yes; then + AC_DEFINE([HAVE_SOLARIS114_LOCALES], [1], + [Define if the locale_t type is as on Solaris 11.4.]) + fi + + dnl Solaris 12 will maybe provide getlocalename_l. If it does, it will + dnl improve the implementation of gl_locale_name_thread(), by removing + dnl the use of undocumented structures. + case "$gt_cv_func_uselocale_works" in + *yes) + AC_CHECK_FUNCS([getlocalename_l]) + ;; + esac + + dnl This code is for platforms where the locale_t type does not provide access + dnl to the name of each locale category. This code has the drawback that it + dnl requires the gnulib overrides of 'newlocale', 'duplocale', 'freelocale', + dnl which is a problem for GNU libunistring. Therefore try hard to avoid + dnl enabling this code! + gt_nameless_locales=no + case "$host_os" in + dnl It's needed on AIX 7.2. + aix*) + gt_nameless_locales=yes + AC_DEFINE([HAVE_NAMELESS_LOCALES], [1], + [Define if the locale_t type does not contain the name of each locale category.]) + ;; + esac + + dnl We cannot support uselocale() on platforms where the locale_t type is + dnl fake. So, set + dnl gt_good_uselocale = gt_working_uselocale && !gt_fake_locales. + if test $gt_working_uselocale = yes && test $gt_fake_locales = no; then + gt_good_uselocale=yes + AC_DEFINE([HAVE_GOOD_USELOCALE], [1], + [Define if the uselocale exists, may be safely called, and returns sufficient information.]) + else + gt_good_uselocale=no + fi + + dnl Set gt_localename_enhances_locale_funcs to indicate whether localename.c + dnl overrides newlocale(), duplocale(), freelocale() to keep track of locale + dnl names. + if test $gt_good_uselocale = yes && test $gt_nameless_locales = yes; then + gt_localename_enhances_locale_funcs=yes + LOCALENAME_ENHANCE_LOCALE_FUNCS=1 + AC_DEFINE([LOCALENAME_ENHANCE_LOCALE_FUNCS], [1], + [Define if localename.c overrides newlocale(), duplocale(), freelocale().]) + else + gt_localename_enhances_locale_funcs=no + fi +]) + +dnl Tests whether uselocale() exists and is usable. +dnl Sets gt_working_uselocale and defines HAVE_WORKING_USELOCALE. +AC_DEFUN([gt_FUNC_USELOCALE], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + + dnl Persuade glibc and Solaris to define 'locale_t'. + AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) + + gl_CHECK_FUNCS_ANDROID([uselocale], [[#include ]]) + + dnl On AIX 7.2, the uselocale() function is not documented and leads to + dnl crashes in subsequent setlocale() invocations. + dnl In 2019, some versions of z/OS lack the locale_t type and have a broken + dnl uselocale function. + if test $ac_cv_func_uselocale = yes; then + AC_CHECK_HEADERS_ONCE([xlocale.h]) + AC_CACHE_CHECK([whether uselocale works], + [gt_cv_func_uselocale_works], + [AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#if HAVE_XLOCALE_H +# include +#endif +locale_t loc1; +int main () +{ + uselocale (NULL); + setlocale (LC_ALL, "en_US.UTF-8"); + return 0; +}]])], + [gt_cv_func_uselocale_works=yes], + [gt_cv_func_uselocale_works=no], + [# Guess no on AIX and z/OS, yes otherwise. + case "$host_os" in + aix* | openedition*) gt_cv_func_uselocale_works="guessing no" ;; + *) gt_cv_func_uselocale_works="guessing yes" ;; + esac + ]) + ]) + else + gt_cv_func_uselocale_works=no + fi + case "$gt_cv_func_uselocale_works" in + *yes) + gt_working_uselocale=yes + AC_DEFINE([HAVE_WORKING_USELOCALE], [1], + [Define if the uselocale function exists and may safely be called.]) + ;; + *) + gt_working_uselocale=no + ;; + esac +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/intmax_t.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/intmax_t.m4 new file mode 100644 index 00000000..d3d21201 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/intmax_t.m4 @@ -0,0 +1,59 @@ +# intmax_t.m4 serial 9 +dnl Copyright (C) 1997-2004, 2006-2007, 2009-2024 Free Software Foundation, +dnl Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Paul Eggert. + +AC_PREREQ([2.53]) + +# Define intmax_t to 'long' or 'long long' +# if it is not already defined in or . + +AC_DEFUN([gl_AC_TYPE_INTMAX_T], +[ + dnl For simplicity, we assume that a header file defines 'intmax_t' if and + dnl only if it defines 'uintmax_t'. + AC_REQUIRE([gl_AC_HEADER_INTTYPES_H]) + AC_REQUIRE([gl_AC_HEADER_STDINT_H]) + if test $gl_cv_header_inttypes_h = no && test $gl_cv_header_stdint_h = no; then + AC_DEFINE_UNQUOTED([intmax_t], [long long], + [Define to long or long long if and don't define.]) + else + AC_DEFINE([HAVE_INTMAX_T], [1], + [Define if you have the 'intmax_t' type in or .]) + fi +]) + +dnl An alternative would be to explicitly test for 'intmax_t'. + +AC_DEFUN([gt_AC_TYPE_INTMAX_T], +[ + AC_REQUIRE([gl_AC_HEADER_INTTYPES_H]) + AC_REQUIRE([gl_AC_HEADER_STDINT_H]) + AC_CACHE_CHECK([for intmax_t], [gt_cv_c_intmax_t], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[ +#include +#include +#if HAVE_STDINT_H_WITH_UINTMAX +#include +#endif +#if HAVE_INTTYPES_H_WITH_UINTMAX +#include +#endif + ]], + [[intmax_t x = -1; return !x;]])], + [gt_cv_c_intmax_t=yes], + [gt_cv_c_intmax_t=no])]) + if test $gt_cv_c_intmax_t = yes; then + AC_DEFINE([HAVE_INTMAX_T], [1], + [Define if you have the 'intmax_t' type in or .]) + else + AC_DEFINE_UNQUOTED([intmax_t], [long long], + [Define to long or long long if and don't define.]) + fi +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/inttostr.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/inttostr.m4 new file mode 100644 index 00000000..9dadae52 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/inttostr.m4 @@ -0,0 +1,32 @@ +#serial 8 +dnl Copyright (C) 2004-2006, 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_INTTOSTR], +[ + gl_PREREQ_INTTOSTR + gl_PREREQ_IMAXTOSTR + gl_PREREQ_OFFTOSTR + gl_PREREQ_UMAXTOSTR + gl_PREREQ_UINTTOSTR +]) + +# Prerequisites of lib/inttostr.h. +AC_DEFUN([gl_PREREQ_INTTOSTR], [ + AC_REQUIRE([AC_TYPE_OFF_T]) + : +]) + +# Prerequisites of lib/imaxtostr.c. +AC_DEFUN([gl_PREREQ_IMAXTOSTR], [:]) + +# Prerequisites of lib/offtostr.c. +AC_DEFUN([gl_PREREQ_OFFTOSTR], [:]) + +# Prerequisites of lib/umaxtostr.c. +AC_DEFUN([gl_PREREQ_UMAXTOSTR], [:]) + +# Prerequisites of lib/uinttostr.c. +AC_DEFUN([gl_PREREQ_UINTTOSTR], [:]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/inttypes.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/inttypes.m4 new file mode 100644 index 00000000..6abf9dbe --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/inttypes.m4 @@ -0,0 +1,184 @@ +# inttypes.m4 serial 37 +dnl Copyright (C) 2006-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Derek Price, Bruno Haible. +dnl Test whether is supported or must be substituted. + +AC_DEFUN_ONCE([gl_INTTYPES_H], +[ + AC_REQUIRE([gl_INTTYPES_INCOMPLETE]) + gl_INTTYPES_PRI_SCN +]) + +AC_DEFUN_ONCE([gl_INTTYPES_INCOMPLETE], +[ + AC_REQUIRE([gl_STDINT_H]) + AC_CHECK_HEADERS_ONCE([inttypes.h]) + + dnl Override always, so that the portability warnings work. + AC_REQUIRE([gl_INTTYPES_H_DEFAULTS]) + gl_CHECK_NEXT_HEADERS([inttypes.h]) + + AC_REQUIRE([gl_MULTIARCH]) + + dnl Check for declarations of anything we want to poison if the + dnl corresponding gnulib module is not in use. + gl_WARN_ON_USE_PREPARE([[#include + ]], [imaxabs imaxdiv strtoimax strtoumax]) + + AC_REQUIRE([AC_C_RESTRICT]) +]) + +# Ensure that the PRI* and SCN* macros are defined appropriately. +AC_DEFUN([gl_INTTYPES_PRI_SCN], +[ + PRIPTR_PREFIX= + if $GL_GENERATE_STDINT_H; then + dnl Using the gnulib . It defines intptr_t to 'long' or + dnl 'long long', depending on _WIN64. + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[ + #ifdef _WIN64 + LLP64 + #endif + ]]) + ], + [PRIPTR_PREFIX='"l"'], + [PRIPTR_PREFIX='"ll"']) + else + dnl Using the system's . + for glpfx in '' l ll I64; do + case $glpfx in + '') gltype1='int';; + l) gltype1='long int';; + ll) gltype1='long long int';; + I64) gltype1='__int64';; + esac + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#include + extern intptr_t foo; + extern $gltype1 foo;]])], + [PRIPTR_PREFIX='"'$glpfx'"']) + test -n "$PRIPTR_PREFIX" && break + done + fi + AC_SUBST([PRIPTR_PREFIX]) + + gl_INTTYPES_CHECK_LONG_LONG_INT_CONDITION( + [INT32_MAX_LT_INTMAX_MAX], + [defined INT32_MAX && defined INTMAX_MAX], + [INT32_MAX < INTMAX_MAX], + [sizeof (int) < sizeof (long long int)]) + if test $APPLE_UNIVERSAL_BUILD = 0; then + gl_INTTYPES_CHECK_LONG_LONG_INT_CONDITION( + [INT64_MAX_EQ_LONG_MAX], + [defined INT64_MAX], + [INT64_MAX == LONG_MAX], + [sizeof (long long int) == sizeof (long int)]) + else + INT64_MAX_EQ_LONG_MAX=-1 + fi + gl_INTTYPES_CHECK_LONG_LONG_INT_CONDITION( + [UINT32_MAX_LT_UINTMAX_MAX], + [defined UINT32_MAX && defined UINTMAX_MAX], + [UINT32_MAX < UINTMAX_MAX], + [sizeof (unsigned int) < sizeof (unsigned long long int)]) + if test $APPLE_UNIVERSAL_BUILD = 0; then + gl_INTTYPES_CHECK_LONG_LONG_INT_CONDITION( + [UINT64_MAX_EQ_ULONG_MAX], + [defined UINT64_MAX], + [UINT64_MAX == ULONG_MAX], + [sizeof (unsigned long long int) == sizeof (unsigned long int)]) + else + UINT64_MAX_EQ_ULONG_MAX=-1 + fi +]) + +# Define the symbol $1 to be 1 if the condition is true, 0 otherwise. +# If $2 is true, the condition is $3; otherwise if long long int is supported +# approximate the condition with $4; otherwise, assume the condition is false. +# The condition should work on all C99 platforms; the approximations should be +# good enough to work on all practical pre-C99 platforms. +# $2 is evaluated by the C preprocessor, $3 and $4 as compile-time constants. +AC_DEFUN([gl_INTTYPES_CHECK_LONG_LONG_INT_CONDITION], +[ + AC_CACHE_CHECK([whether $3], + [gl_cv_test_$1], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[/* Work also in C++ mode. */ + #define __STDC_LIMIT_MACROS 1 + + /* Work if build is not clean. */ + #define _GL_JUST_INCLUDE_SYSTEM_STDINT_H + + #include + #if HAVE_STDINT_H + #include + #endif + + #if $2 + #define CONDITION ($3) + #else + #define CONDITION ($4) + #endif + int test[CONDITION ? 1 : -1];]])], + [gl_cv_test_$1=yes], + [gl_cv_test_$1=no])]) + if test $gl_cv_test_$1 = yes; then + $1=1; + else + $1=0; + fi + AC_SUBST([$1]) +]) + +# gl_INTTYPES_MODULE_INDICATOR([modulename]) +# sets the shell variable that indicates the presence of the given module +# to a C preprocessor expression that will evaluate to 1. +# This macro invocation must not occur in macros that are AC_REQUIREd. +AC_DEFUN([gl_INTTYPES_MODULE_INDICATOR], +[ + dnl Ensure to expand the default settings once only. + gl_INTTYPES_H_REQUIRE_DEFAULTS + gl_MODULE_INDICATOR_SET_VARIABLE([$1]) +]) + +# Initializes the default values for AC_SUBSTed shell variables. +# This macro must not be AC_REQUIREd. It must only be invoked, and only +# outside of macros or in macros that are not AC_REQUIREd. +AC_DEFUN([gl_INTTYPES_H_REQUIRE_DEFAULTS], +[ + m4_defun(GL_MODULE_INDICATOR_PREFIX[_INTTYPES_H_MODULE_INDICATOR_DEFAULTS], [ + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_IMAXABS]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_IMAXDIV]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOIMAX]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOUMAX]) + ]) + m4_require(GL_MODULE_INDICATOR_PREFIX[_INTTYPES_H_MODULE_INDICATOR_DEFAULTS]) + AC_REQUIRE([gl_INTTYPES_H_DEFAULTS]) +]) + +AC_DEFUN([gl_INTTYPES_H_DEFAULTS], +[ + dnl Assume proper GNU behavior unless another module says otherwise. + HAVE_DECL_IMAXABS=1; AC_SUBST([HAVE_DECL_IMAXABS]) + HAVE_DECL_IMAXDIV=1; AC_SUBST([HAVE_DECL_IMAXDIV]) + HAVE_DECL_STRTOIMAX=1; AC_SUBST([HAVE_DECL_STRTOIMAX]) + HAVE_DECL_STRTOUMAX=1; AC_SUBST([HAVE_DECL_STRTOUMAX]) + HAVE_IMAXDIV_T=1; AC_SUBST([HAVE_IMAXDIV_T]) + HAVE_IMAXABS=1; AC_SUBST([HAVE_IMAXABS]) + HAVE_IMAXDIV=1; AC_SUBST([HAVE_IMAXDIV]) + REPLACE_IMAXABS=0; AC_SUBST([REPLACE_IMAXABS]) + REPLACE_IMAXDIV=0; AC_SUBST([REPLACE_IMAXDIV]) + REPLACE_STRTOIMAX=0; AC_SUBST([REPLACE_STRTOIMAX]) + REPLACE_STRTOUMAX=0; AC_SUBST([REPLACE_STRTOUMAX]) + INT32_MAX_LT_INTMAX_MAX=1; AC_SUBST([INT32_MAX_LT_INTMAX_MAX]) + INT64_MAX_EQ_LONG_MAX='defined _LP64'; AC_SUBST([INT64_MAX_EQ_LONG_MAX]) + PRIPTR_PREFIX=__PRIPTR_PREFIX; AC_SUBST([PRIPTR_PREFIX]) + UINT32_MAX_LT_UINTMAX_MAX=1; AC_SUBST([UINT32_MAX_LT_UINTMAX_MAX]) + UINT64_MAX_EQ_ULONG_MAX='defined _LP64'; AC_SUBST([UINT64_MAX_EQ_ULONG_MAX]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/inttypes_h.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/inttypes_h.m4 new file mode 100644 index 00000000..ae0a00f0 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/inttypes_h.m4 @@ -0,0 +1,29 @@ +# inttypes_h.m4 serial 10 +dnl Copyright (C) 1997-2004, 2006, 2008-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Paul Eggert. + +# Define HAVE_INTTYPES_H_WITH_UINTMAX if exists, +# doesn't clash with , and declares uintmax_t. + +AC_DEFUN([gl_AC_HEADER_INTTYPES_H], +[ + AC_CACHE_CHECK([for inttypes.h], [gl_cv_header_inttypes_h], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[ +#include +#include + ]], + [[uintmax_t i = (uintmax_t) -1; return !i;]])], + [gl_cv_header_inttypes_h=yes], + [gl_cv_header_inttypes_h=no])]) + if test $gl_cv_header_inttypes_h = yes; then + AC_DEFINE_UNQUOTED([HAVE_INTTYPES_H_WITH_UINTMAX], [1], + [Define if exists, doesn't clash with , + and declares uintmax_t. ]) + fi +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/ioctl.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/ioctl.m4 new file mode 100644 index 00000000..42788830 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/ioctl.m4 @@ -0,0 +1,44 @@ +# ioctl.m4 serial 6 +dnl Copyright (C) 2008-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_IOCTL], +[ + AC_REQUIRE([gl_SYS_IOCTL_H_DEFAULTS]) + AC_REQUIRE([gl_SYS_SOCKET_H]) + HAVE_IOCTL=1 + if test "$ac_cv_header_winsock2_h" = yes; then + dnl Even if the 'socket' module is not used here, another part of the + dnl application may use it and pass file descriptors that refer to + dnl sockets to the ioctl() function. So enable the support for sockets. + HAVE_IOCTL=0 + else + AC_CHECK_FUNCS([ioctl]) + dnl On glibc systems, the second parameter is 'unsigned long int request', + dnl not 'int request'. We cannot simply cast the function pointer, but + dnl instead need a wrapper. + AC_CACHE_CHECK([for ioctl with POSIX signature], + [gl_cv_func_ioctl_posix_signature], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include + /* On some platforms, ioctl() is declared in . */ + #include + ]], + [[extern + #ifdef __cplusplus + "C" + #endif + int ioctl (int, int, ...); + ]]) + ], + [gl_cv_func_ioctl_posix_signature=yes], + [gl_cv_func_ioctl_posix_signature=no]) + ]) + if test $gl_cv_func_ioctl_posix_signature != yes; then + REPLACE_IOCTL=1 + fi + fi +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/isblank.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/isblank.m4 new file mode 100644 index 00000000..d07472cd --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/isblank.m4 @@ -0,0 +1,17 @@ +# isblank.m4 serial 3 +dnl Copyright (C) 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_ISBLANK], +[ + dnl Persuade glibc to declare isblank(). + AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) + + AC_REQUIRE([gl_CTYPE_H_DEFAULTS]) + AC_CHECK_FUNCS_ONCE([isblank]) + if test $ac_cv_func_isblank = no; then + HAVE_ISBLANK=0 + fi +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/isnand.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/isnand.m4 new file mode 100644 index 00000000..8cd04903 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/isnand.m4 @@ -0,0 +1,95 @@ +# isnand.m4 serial 13 +dnl Copyright (C) 2007-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl Check how to get or define isnand(). + +AC_DEFUN([gl_FUNC_ISNAND], +[ + AC_REQUIRE([gl_MATH_H_DEFAULTS]) + ISNAND_LIBM= + gl_HAVE_ISNAND_NO_LIBM + if test $gl_cv_func_isnand_no_libm = no; then + gl_HAVE_ISNAND_IN_LIBM + if test $gl_cv_func_isnand_in_libm = yes; then + ISNAND_LIBM=-lm + fi + fi + dnl The variable gl_func_isnand set here is used by isnan.m4. + if test $gl_cv_func_isnand_no_libm = yes || test -n "$ISNAND_LIBM"; then + gl_func_isnand=yes + else + gl_func_isnand=no + HAVE_ISNAND=0 + fi + AC_SUBST([ISNAND_LIBM]) +]) + +dnl Check how to get or define isnand() without linking with libm. + +AC_DEFUN([gl_FUNC_ISNAND_NO_LIBM], +[ + gl_HAVE_ISNAND_NO_LIBM + gl_func_isnand_no_libm=$gl_cv_func_isnand_no_libm + if test $gl_cv_func_isnand_no_libm = yes; then + AC_DEFINE([HAVE_ISNAND_IN_LIBC], [1], + [Define if the isnan(double) function is available in libc.]) + fi +]) + +dnl Prerequisites of replacement isnand definition. It does not need -lm. +AC_DEFUN([gl_PREREQ_ISNAND], +[ + AC_REQUIRE([gl_DOUBLE_EXPONENT_LOCATION]) +]) + +dnl Test whether isnand() can be used with libm. + +AC_DEFUN([gl_HAVE_ISNAND_IN_LIBM], +[ + AC_CACHE_CHECK([whether isnan(double) can be used with libm], + [gl_cv_func_isnand_in_libm], + [ + save_LIBS="$LIBS" + LIBS="$LIBS -lm" + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include + #if (__GNUC__ >= 4) || (__clang_major__ >= 4) + # undef isnand + # define isnand(x) __builtin_isnan ((double)(x)) + #elif defined isnan + # undef isnand + # define isnand(x) isnan ((double)(x)) + #endif + double x;]], + [[return isnand (x);]])], + [gl_cv_func_isnand_in_libm=yes], + [gl_cv_func_isnand_in_libm=no]) + LIBS="$save_LIBS" + ]) +]) + +AC_DEFUN([gl_HAVE_ISNAND_NO_LIBM], +[ + AC_CACHE_CHECK([whether isnan(double) can be used without linking with libm], + [gl_cv_func_isnand_no_libm], + [ + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include + #if (__GNUC__ >= 4) || (__clang_major__ >= 4) + # undef isnand + # define isnand(x) __builtin_isnan ((double)(x)) + #else + # undef isnand + # define isnand(x) isnan ((double)(x)) + #endif + double x;]], + [[return isnand (x);]])], + [gl_cv_func_isnand_no_libm=yes], + [gl_cv_func_isnand_no_libm=no]) + ]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/isnanf.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/isnanf.m4 new file mode 100644 index 00000000..689fb621 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/isnanf.m4 @@ -0,0 +1,196 @@ +# isnanf.m4 serial 20 +dnl Copyright (C) 2007-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl Check how to get or define isnanf(). + +AC_DEFUN([gl_FUNC_ISNANF], +[ + AC_REQUIRE([gl_MATH_H_DEFAULTS]) + ISNANF_LIBM= + gl_HAVE_ISNANF_NO_LIBM + if test $gl_cv_func_isnanf_no_libm = no; then + gl_HAVE_ISNANF_IN_LIBM + if test $gl_cv_func_isnanf_in_libm = yes; then + ISNANF_LIBM=-lm + fi + fi + dnl The variable gl_func_isnanf set here is used by isnan.m4. + if test $gl_cv_func_isnanf_no_libm = yes || test -n "$ISNANF_LIBM"; then + save_LIBS="$LIBS" + LIBS="$LIBS $ISNANF_LIBM" + gl_ISNANF_WORKS + LIBS="$save_LIBS" + case "$gl_cv_func_isnanf_works" in + *yes) gl_func_isnanf=yes ;; + *) gl_func_isnanf=no; ISNANF_LIBM= ;; + esac + else + gl_func_isnanf=no + fi + if test $gl_func_isnanf != yes; then + HAVE_ISNANF=0 + fi + AC_SUBST([ISNANF_LIBM]) +]) + +dnl Check how to get or define isnanf() without linking with libm. + +AC_DEFUN([gl_FUNC_ISNANF_NO_LIBM], +[ + gl_HAVE_ISNANF_NO_LIBM + if test $gl_cv_func_isnanf_no_libm = yes; then + gl_ISNANF_WORKS + fi + if test $gl_cv_func_isnanf_no_libm = yes \ + && { case "$gl_cv_func_isnanf_works" in + *yes) true;; + *) false;; + esac + }; then + gl_func_isnanf_no_libm=yes + AC_DEFINE([HAVE_ISNANF_IN_LIBC], [1], + [Define if the isnan(float) function is available in libc.]) + else + gl_func_isnanf_no_libm=no + fi +]) + +dnl Prerequisites of replacement isnanf definition. It does not need -lm. +AC_DEFUN([gl_PREREQ_ISNANF], +[ + gl_FLOAT_EXPONENT_LOCATION +]) + +dnl Test whether isnanf() can be used without libm. +AC_DEFUN([gl_HAVE_ISNANF_NO_LIBM], +[ + AC_CACHE_CHECK([whether isnan(float) can be used without linking with libm], + [gl_cv_func_isnanf_no_libm], + [ + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include + #if (__GNUC__ >= 4) || (__clang_major__ >= 4) + # undef isnanf + # define isnanf(x) __builtin_isnan ((float)(x)) + #elif defined isnan + # undef isnanf + # define isnanf(x) isnan ((float)(x)) + #endif + float x;]], + [[return isnanf (x);]])], + [gl_cv_func_isnanf_no_libm=yes], + [gl_cv_func_isnanf_no_libm=no]) + ]) +]) + +dnl Test whether isnanf() can be used with libm. +AC_DEFUN([gl_HAVE_ISNANF_IN_LIBM], +[ + AC_CACHE_CHECK([whether isnan(float) can be used with libm], + [gl_cv_func_isnanf_in_libm], + [ + save_LIBS="$LIBS" + LIBS="$LIBS -lm" + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include + #if (__GNUC__ >= 4) || (__clang_major__ >= 4) + # undef isnanf + # define isnanf(x) __builtin_isnan ((float)(x)) + #elif defined isnan + # undef isnanf + # define isnanf(x) isnan ((float)(x)) + #endif + float x;]], + [[return isnanf (x);]])], + [gl_cv_func_isnanf_in_libm=yes], + [gl_cv_func_isnanf_in_libm=no]) + LIBS="$save_LIBS" + ]) +]) + +dnl Test whether isnanf() rejects Infinity (this fails on Solaris 2.5.1), +dnl recognizes a NaN (this fails on IRIX 6.5 with cc), and recognizes a NaN +dnl with in-memory representation 0x7fbfffff (this fails on IRIX 6.5). +AC_DEFUN([gl_ISNANF_WORKS], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_REQUIRE([gl_FLOAT_EXPONENT_LOCATION]) + AC_CACHE_CHECK([whether isnan(float) works], [gl_cv_func_isnanf_works], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#if (__GNUC__ >= 4) || (__clang_major__ >= 4) +# undef isnanf +# define isnanf(x) __builtin_isnan ((float)(x)) +#elif defined isnan +# undef isnanf +# define isnanf(x) isnan ((float)(x)) +#endif +/* The Compaq (ex-DEC) C 6.4 compiler chokes on the expression 0.0 / 0.0. */ +#ifdef __DECC +static float +NaN () +{ + static float zero = 0.0f; + return zero / zero; +} +#else +# define NaN() (0.0f / 0.0f) +#endif +#define NWORDS \ + ((sizeof (float) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) +typedef union { unsigned int word[NWORDS]; float value; } memory_float; +int main() +{ + int result = 0; + + if (isnanf (1.0f / 0.0f)) + result |= 1; + + if (!isnanf (NaN ())) + result |= 2; + +#if defined FLT_EXPBIT0_WORD && defined FLT_EXPBIT0_BIT + /* The isnanf function should be immune against changes in the sign bit and + in the mantissa bits. The xor operation twiddles a bit that can only be + a sign bit or a mantissa bit. */ + if (FLT_EXPBIT0_WORD == 0 && FLT_EXPBIT0_BIT > 0) + { + memory_float m; + + m.value = NaN (); + /* Set the bits below the exponent to 01111...111. */ + m.word[0] &= -1U << FLT_EXPBIT0_BIT; + m.word[0] |= (1U << (FLT_EXPBIT0_BIT - 1)) - 1; + if (!isnanf (m.value)) + result |= 4; + } +#endif + + return result; +}]])], + [gl_cv_func_isnanf_works=yes], + [gl_cv_func_isnanf_works=no], + [case "$host_os" in + irix* | solaris*) gl_cv_func_isnanf_works="guessing no" ;; + mingw* | windows*) # Guess yes on mingw, no on MSVC. + AC_EGREP_CPP([Known], [ +#ifdef __MINGW32__ + Known +#endif + ], + [gl_cv_func_isnanf_works="guessing yes"], + [gl_cv_func_isnanf_works="guessing no"]) + ;; + *) gl_cv_func_isnanf_works="guessing yes" ;; + esac + ]) + ]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/isnanl.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/isnanl.m4 new file mode 100644 index 00000000..f0a30c0a --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/isnanl.m4 @@ -0,0 +1,247 @@ +# isnanl.m4 serial 24 +dnl Copyright (C) 2007-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_ISNANL], +[ + AC_REQUIRE([gl_MATH_H_DEFAULTS]) + ISNANL_LIBM= + gl_HAVE_ISNANL_NO_LIBM + if test $gl_cv_func_isnanl_no_libm = no; then + gl_HAVE_ISNANL_IN_LIBM + if test $gl_cv_func_isnanl_in_libm = yes; then + ISNANL_LIBM=-lm + fi + fi + dnl The variable gl_func_isnanl set here is used by isnan.m4. + if test $gl_cv_func_isnanl_no_libm = yes || test -n "$ISNANL_LIBM"; then + save_LIBS="$LIBS" + LIBS="$LIBS $ISNANL_LIBM" + gl_FUNC_ISNANL_WORKS + LIBS="$save_LIBS" + case "$gl_cv_func_isnanl_works" in + *yes) gl_func_isnanl=yes ;; + *) gl_func_isnanl=no; ISNANL_LIBM= ;; + esac + else + gl_func_isnanl=no + fi + if test $gl_func_isnanl != yes; then + HAVE_ISNANL=0 + fi + AC_SUBST([ISNANL_LIBM]) +]) + +AC_DEFUN([gl_FUNC_ISNANL_NO_LIBM], +[ + gl_HAVE_ISNANL_NO_LIBM + gl_func_isnanl_no_libm=$gl_cv_func_isnanl_no_libm + if test $gl_func_isnanl_no_libm = yes; then + gl_FUNC_ISNANL_WORKS + case "$gl_cv_func_isnanl_works" in + *yes) ;; + *) gl_func_isnanl_no_libm=no ;; + esac + fi + if test $gl_func_isnanl_no_libm = yes; then + AC_DEFINE([HAVE_ISNANL_IN_LIBC], [1], + [Define if the isnan(long double) function is available in libc.]) + fi +]) + +dnl Prerequisites of replacement isnanl definition. It does not need -lm. +AC_DEFUN([gl_PREREQ_ISNANL], +[ + gl_LONG_DOUBLE_EXPONENT_LOCATION + AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE]) +]) + +dnl Test whether isnanl() can be used without libm. +AC_DEFUN([gl_HAVE_ISNANL_NO_LIBM], +[ + AC_CACHE_CHECK([whether isnan(long double) can be used without linking with libm], + [gl_cv_func_isnanl_no_libm], + [ + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include + #if (__GNUC__ >= 4) || (__clang_major__ >= 4) + # undef isnanl + # define isnanl(x) __builtin_isnan ((long double)(x)) + #elif defined isnan + # undef isnanl + # define isnanl(x) isnan ((long double)(x)) + #endif + long double x;]], + [[return isnanl (x);]])], + [gl_cv_func_isnanl_no_libm=yes], + [gl_cv_func_isnanl_no_libm=no]) + ]) +]) + +dnl Test whether isnanl() can be used with libm. +AC_DEFUN([gl_HAVE_ISNANL_IN_LIBM], +[ + AC_CACHE_CHECK([whether isnan(long double) can be used with libm], + [gl_cv_func_isnanl_in_libm], + [ + save_LIBS="$LIBS" + LIBS="$LIBS -lm" + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include + #if (__GNUC__ >= 4) || (__clang_major__ >= 4) + # undef isnanl + # define isnanl(x) __builtin_isnan ((long double)(x)) + #elif defined isnan + # undef isnanl + # define isnanl(x) isnan ((long double)(x)) + #endif + long double x;]], + [[return isnanl (x);]])], + [gl_cv_func_isnanl_in_libm=yes], + [gl_cv_func_isnanl_in_libm=no]) + LIBS="$save_LIBS" + ]) +]) + +dnl Test whether isnanl() recognizes all canonical numbers which are neither +dnl finite nor infinite. +AC_DEFUN([gl_FUNC_ISNANL_WORKS], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([gl_BIGENDIAN]) + AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether isnanl works], [gl_cv_func_isnanl_works], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +#include +#if (__GNUC__ >= 4) || (__clang_major__ >= 4) +# undef isnanl +# define isnanl(x) __builtin_isnan ((long double)(x)) +#elif defined isnan +# undef isnanl +# define isnanl(x) isnan ((long double)(x)) +#endif +#define NWORDS \ + ((sizeof (long double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) +typedef union { unsigned int word[NWORDS]; long double value; } + memory_long_double; +/* On Irix 6.5, gcc 3.4.3 can't compute compile-time NaN, and needs the + runtime type conversion. */ +#ifdef __sgi +static long double NaNl () +{ + double zero = 0.0; + return zero / zero; +} +#else +# define NaNl() (0.0L / 0.0L) +#endif +int main () +{ + int result = 0; + + if (!isnanl (NaNl ())) + result |= 1; + + { + memory_long_double m; + unsigned int i; + + /* The isnanl function should be immune against changes in the sign bit and + in the mantissa bits. The xor operation twiddles a bit that can only be + a sign bit or a mantissa bit (since the exponent never extends to + bit 31). */ + m.value = NaNl (); + m.word[NWORDS / 2] ^= (unsigned int) 1 << (sizeof (unsigned int) * CHAR_BIT - 1); + for (i = 0; i < NWORDS; i++) + m.word[i] |= 1; + if (!isnanl (m.value)) + result |= 1; + } + +#if ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_)) && !HAVE_SAME_LONG_DOUBLE_AS_DOUBLE +/* Representation of an 80-bit 'long double' as an initializer for a sequence + of 'unsigned int' words. */ +# ifdef WORDS_BIGENDIAN +# define LDBL80_WORDS(exponent,manthi,mantlo) \ + { ((unsigned int) (exponent) << 16) | ((unsigned int) (manthi) >> 16), \ + ((unsigned int) (manthi) << 16) | ((unsigned int) (mantlo) >> 16), \ + (unsigned int) (mantlo) << 16 \ + } +# else +# define LDBL80_WORDS(exponent,manthi,mantlo) \ + { mantlo, manthi, exponent } +# endif + { /* Quiet NaN. */ + static memory_long_double x = + { LDBL80_WORDS (0xFFFF, 0xC3333333, 0x00000000) }; + if (!isnanl (x.value)) + result |= 2; + } + { + /* Signalling NaN. */ + static memory_long_double x = + { LDBL80_WORDS (0xFFFF, 0x83333333, 0x00000000) }; + if (!isnanl (x.value)) + result |= 2; + } + /* isnanl should return something even for noncanonical values. */ + { /* Pseudo-NaN. */ + static memory_long_double x = + { LDBL80_WORDS (0xFFFF, 0x40000001, 0x00000000) }; + if (isnanl (x.value) && !isnanl (x.value)) + result |= 4; + } + { /* Pseudo-Infinity. */ + static memory_long_double x = + { LDBL80_WORDS (0xFFFF, 0x00000000, 0x00000000) }; + if (isnanl (x.value) && !isnanl (x.value)) + result |= 8; + } + { /* Pseudo-Zero. */ + static memory_long_double x = + { LDBL80_WORDS (0x4004, 0x00000000, 0x00000000) }; + if (isnanl (x.value) && !isnanl (x.value)) + result |= 16; + } + { /* Unnormalized number. */ + static memory_long_double x = + { LDBL80_WORDS (0x4000, 0x63333333, 0x00000000) }; + if (isnanl (x.value) && !isnanl (x.value)) + result |= 32; + } + { /* Pseudo-Denormal. */ + static memory_long_double x = + { LDBL80_WORDS (0x0000, 0x83333333, 0x00000000) }; + if (isnanl (x.value) && !isnanl (x.value)) + result |= 64; + } +#endif + + return result; +}]])], + [gl_cv_func_isnanl_works=yes], + [gl_cv_func_isnanl_works=no], + [case "$host_os" in + mingw* | windows*) # Guess yes on mingw, no on MSVC. + AC_EGREP_CPP([Known], [ +#ifdef __MINGW32__ + Known +#endif + ], + [gl_cv_func_isnanl_works="guessing yes"], + [gl_cv_func_isnanl_works="guessing no"]) + ;; + *) gl_cv_func_isnanl_works="guessing yes" ;; + esac + ]) + ]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/iswblank.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/iswblank.m4 new file mode 100644 index 00000000..e450f0bd --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/iswblank.m4 @@ -0,0 +1,38 @@ +# iswblank.m4 serial 7 +dnl Copyright (C) 2011-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_ISWBLANK], +[ + AC_REQUIRE([gl_WCTYPE_H_DEFAULTS]) + AC_REQUIRE([gl_WCTYPE_H]) + dnl Persuade glibc to declare iswblank(). + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + gl_CHECK_FUNCS_ANDROID([iswblank], [[#include ]]) + AC_CHECK_DECLS([iswblank], , , [[ + #include + #include + ]]) + if test $ac_cv_func_iswblank = no; then + HAVE_ISWBLANK=0 + if test $ac_cv_have_decl_iswblank = yes \ + || case "$gl_cv_onwards_func_iswblank" in \ + future*) true ;; \ + *) false ;; \ + esac; then + REPLACE_ISWBLANK=1 + fi + fi + if test $HAVE_ISWCNTRL = 0 || test $REPLACE_ISWCNTRL = 1; then + dnl Redefine all of iswcntrl, ..., towupper in . + : + else + if test $HAVE_ISWBLANK = 0 || test $REPLACE_ISWBLANK = 1; then + dnl Redefine only iswblank. + : + fi + fi + +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/iswctype.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/iswctype.m4 new file mode 100644 index 00000000..775f2227 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/iswctype.m4 @@ -0,0 +1,13 @@ +# iswctype.m4 serial 3 +dnl Copyright (C) 2011-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_ISWCTYPE], +[ + AC_REQUIRE([gl_WCTYPE_H_DEFAULTS]) + AC_REQUIRE([gl_WCTYPE_H]) + dnl Determine REPLACE_WCTYPE. + AC_REQUIRE([gl_FUNC_WCTYPE]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/iswdigit.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/iswdigit.m4 new file mode 100644 index 00000000..d13c1ae9 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/iswdigit.m4 @@ -0,0 +1,120 @@ +# iswdigit.m4 serial 6 +dnl Copyright (C) 2020-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_ISWDIGIT], +[ + AC_REQUIRE([gl_WCTYPE_H_DEFAULTS]) + AC_REQUIRE([gl_WCTYPE_H]) + AC_REQUIRE([gt_LOCALE_FR]) + AC_REQUIRE([gt_LOCALE_JA]) + AC_REQUIRE([gt_LOCALE_FR_UTF8]) + AC_REQUIRE([gt_LOCALE_ZH_CN]) + AC_REQUIRE([AC_CANONICAL_HOST]) + + if test $HAVE_ISWCNTRL = 0 || test $REPLACE_ISWCNTRL = 1; then + dnl redefines iswdigit already. + REPLACE_ISWDIGIT="$REPLACE_ISWCNTRL" + else + AC_CACHE_CHECK([whether iswdigit is ISO C compliant], + [gl_cv_func_iswdigit_works], + [ + dnl Initial guess, used when cross-compiling or when no suitable locale + dnl is present. +changequote(,)dnl + case "$host_os" in + # Guess no on FreeBSD, NetBSD, Solaris, native Windows. + freebsd* | dragonfly* | netbsd* | solaris* | mingw* | windows*) + gl_cv_func_iswdigit_works="guessing no" ;; + # Guess yes otherwise. + *) gl_cv_func_iswdigit_works="guessing yes" ;; + esac +changequote([,])dnl + if test $LOCALE_FR != none || test $LOCALE_JA != none || test $LOCALE_FR_UTF8 != none || test $LOCALE_ZH_CN != none; then + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +#include +#include +#include + +/* Returns the value of iswdigit for the multibyte character s[0..n-1]. */ +static int +for_character (const char *s, size_t n) +{ + mbstate_t state; + wchar_t wc; + size_t ret; + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, s, n, &state); + if (ret != n) + abort (); + + return iswdigit (wc); +} + +int +main (int argc, char *argv[]) +{ + int is; + int result = 0; + + if (strcmp ("$LOCALE_FR", "none") != 0 + && setlocale (LC_ALL, "$LOCALE_FR") != NULL) + { + /* This fails on mingw, MSVC 14. */ + /* U+00B2 SUPERSCRIPT TWO */ + is = for_character ("\262", 1); + if (!(is == 0)) + result |= 1; + } + if (strcmp ("$LOCALE_JA", "none") != 0 + && setlocale (LC_ALL, "$LOCALE_JA") != NULL) + { + /* This fails on NetBSD 8.0. */ + /* U+FF11 FULLWIDTH DIGIT ONE */ + is = for_character ("\243\261", 2); + if (!(is == 0)) + result |= 2; + } + if (strcmp ("$LOCALE_FR_UTF8", "none") != 0 + && setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL) + { + /* This fails on FreeBSD 13.0, NetBSD 8.0, MSVC 14. */ + /* U+0663 ARABIC-INDIC DIGIT THREE */ + is = for_character ("\331\243", 2); + if (!(is == 0)) + result |= 4; + /* This fails on FreeBSD 13.0, NetBSD 8.0, MSVC 14. */ + /* U+FF11 FULLWIDTH DIGIT ONE */ + is = for_character ("\357\274\221", 3); + if (!(is == 0)) + result |= 8; + } + if (strcmp ("$LOCALE_ZH_CN", "none") != 0 + && setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL) + { + /* This fails on NetBSD 8.0, Solaris 10, Solaris 11.4. */ + /* U+FF11 FULLWIDTH DIGIT ONE */ + is = for_character ("\243\261", 2); + if (!(is == 0)) + result |= 16; + } + return result; +}]])], + [gl_cv_func_iswdigit_works=yes], + [gl_cv_func_iswdigit_works=no], + [:]) + fi + ]) + case "$gl_cv_func_iswdigit_works" in + *yes) ;; + *) REPLACE_ISWDIGIT=1 ;; + esac + fi +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/iswpunct.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/iswpunct.m4 new file mode 100644 index 00000000..2be15aba --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/iswpunct.m4 @@ -0,0 +1,48 @@ +# iswpunct.m4 serial 2 +dnl Copyright (C) 2023-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_ISWPUNCT], +[ + AC_REQUIRE([gl_WCTYPE_H_DEFAULTS]) + AC_REQUIRE([gl_WCTYPE_H]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + + if test $HAVE_ISWCNTRL = 0 || test $REPLACE_ISWCNTRL = 1; then + dnl redefines iswpunct already. + REPLACE_ISWPUNCT="$REPLACE_ISWCNTRL" + else + AC_CACHE_CHECK([whether iswpunct is consistent with ispunct], + [gl_cv_func_iswpunct_works], + [AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +#include +int +main (int argc, char *argv[]) +{ + int result = 0; + /* This fails on Android 11. */ + if ((! iswpunct ('\`')) != (! ispunct ('\`'))) + result |= 1; + return result; +}]])], + [gl_cv_func_iswpunct_works=yes], + [gl_cv_func_iswpunct_works=no], + [case "$host_os" in + # Guess no on Android. + android*) gl_cv_func_iswpunct_works="guessing no" ;; + # Guess yes otherwise. + *) gl_cv_func_iswpunct_works="guessing yes" ;; + esac + ]) + ]) + case "$gl_cv_func_iswpunct_works" in + *yes) ;; + *) REPLACE_ISWPUNCT=1 ;; + esac + fi +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/iswxdigit.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/iswxdigit.m4 new file mode 100644 index 00000000..d42f0d13 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/iswxdigit.m4 @@ -0,0 +1,110 @@ +# iswxdigit.m4 serial 6 +dnl Copyright (C) 2020-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_ISWXDIGIT], +[ + AC_REQUIRE([gl_WCTYPE_H_DEFAULTS]) + AC_REQUIRE([gl_WCTYPE_H]) + AC_REQUIRE([gt_LOCALE_JA]) + AC_REQUIRE([gt_LOCALE_FR_UTF8]) + AC_REQUIRE([gt_LOCALE_ZH_CN]) + AC_REQUIRE([AC_CANONICAL_HOST]) + + if test $HAVE_ISWCNTRL = 0 || test $REPLACE_ISWCNTRL = 1; then + dnl redefines iswxdigit already. + REPLACE_ISWXDIGIT="$REPLACE_ISWCNTRL" + else + AC_CACHE_CHECK([whether iswxdigit is ISO C compliant], + [gl_cv_func_iswxdigit_works], + [ + dnl Initial guess, used when cross-compiling or when no suitable locale + dnl is present. +changequote(,)dnl + case "$host_os" in + # Guess no on FreeBSD, NetBSD, Solaris, native Windows. + freebsd* | dragonfly* | netbsd* | solaris* | mingw* | windows*) + gl_cv_func_iswxdigit_works="guessing no" ;; + # Guess yes otherwise. + *) gl_cv_func_iswxdigit_works="guessing yes" ;; + esac +changequote([,])dnl + if test $LOCALE_JA != none || test $LOCALE_FR_UTF8 != none || test $LOCALE_ZH_CN != none; then + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +#include +#include +#include + +/* Returns the value of iswxdigit for the multibyte character s[0..n-1]. */ +static int +for_character (const char *s, size_t n) +{ + mbstate_t state; + wchar_t wc; + size_t ret; + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, s, n, &state); + if (ret != n) + abort (); + + return iswxdigit (wc); +} + +int +main (int argc, char *argv[]) +{ + int is; + int result = 0; + + if (strcmp ("$LOCALE_JA", "none") != 0 + && setlocale (LC_ALL, "$LOCALE_JA") != NULL) + { + /* This fails on NetBSD 8.0. */ + /* U+FF21 FULLWIDTH LATIN CAPITAL LETTER A */ + is = for_character ("\243\301", 2); + if (!(is == 0)) + result |= 1; + } + if (strcmp ("$LOCALE_FR_UTF8", "none") != 0 + && setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL) + { + /* This fails on FreeBSD 13.0. */ + /* U+0663 ARABIC-INDIC DIGIT THREE */ + is = for_character ("\331\243", 2); + if (!(is == 0)) + result |= 2; + /* This fails on MSVC 14. */ + /* U+FF21 FULLWIDTH LATIN CAPITAL LETTER A */ + is = for_character ("\357\274\241", 3); + if (!(is == 0)) + result |= 4; + } + if (strcmp ("$LOCALE_ZH_CN", "none") != 0 + && setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL) + { + /* This fails on Solaris 10, Solaris 11.4. */ + /* U+FF11 FULLWIDTH DIGIT ONE */ + is = for_character ("\243\261", 2); + if (!(is == 0)) + result |= 8; + } + return result; +}]])], + [gl_cv_func_iswxdigit_works=yes], + [gl_cv_func_iswxdigit_works=no], + [:]) + fi + ]) + case "$gl_cv_func_iswxdigit_works" in + *yes) ;; + *) REPLACE_ISWXDIGIT=1 ;; + esac + fi +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/langinfo_h.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/langinfo_h.m4 new file mode 100644 index 00000000..888b1612 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/langinfo_h.m4 @@ -0,0 +1,137 @@ +# langinfo_h.m4 serial 12 +dnl Copyright (C) 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN_ONCE([gl_LANGINFO_H], +[ + AC_REQUIRE([gl_LANGINFO_H_DEFAULTS]) + + dnl Persuade glibc-2.0.6 to define CODESET. + AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) + + dnl is always overridden, because of GNULIB_POSIXCHECK. + gl_CHECK_NEXT_HEADERS([langinfo.h]) + + dnl Determine whether exists. It is missing on mingw and BeOS. + HAVE_LANGINFO_CODESET=0 + HAVE_LANGINFO_T_FMT_AMPM=0 + HAVE_LANGINFO_ALTMON=0 + HAVE_LANGINFO_ERA=0 + HAVE_LANGINFO_YESEXPR=0 + AC_CHECK_HEADERS_ONCE([langinfo.h]) + if test $ac_cv_header_langinfo_h = yes; then + HAVE_LANGINFO_H=1 + dnl Determine what defines. + dnl CODESET is missing on OpenBSD 3.8. + dnl ERA etc. are missing on OpenBSD 6.7. + dnl T_FMT_AMPM and YESEXPR, NOEXPR are missing on IRIX 5.3. + dnl ALTMON_* are missing on glibc 2.26 and many other systems. + AC_CACHE_CHECK([whether langinfo.h defines CODESET], + [gl_cv_header_langinfo_codeset], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#include +int a = CODESET; +]])], + [gl_cv_header_langinfo_codeset=yes], + [gl_cv_header_langinfo_codeset=no]) + ]) + if test $gl_cv_header_langinfo_codeset = yes; then + HAVE_LANGINFO_CODESET=1 + fi + AC_CACHE_CHECK([whether langinfo.h defines T_FMT_AMPM], + [gl_cv_header_langinfo_t_fmt_ampm], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#include +int a = T_FMT_AMPM; +]])], + [gl_cv_header_langinfo_t_fmt_ampm=yes], + [gl_cv_header_langinfo_t_fmt_ampm=no]) + ]) + if test $gl_cv_header_langinfo_t_fmt_ampm = yes; then + HAVE_LANGINFO_T_FMT_AMPM=1 + fi + AC_CACHE_CHECK([whether langinfo.h defines ALTMON_1], + [gl_cv_header_langinfo_altmon], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#include +int a = ALTMON_1; +]])], + [gl_cv_header_langinfo_altmon=yes], + [gl_cv_header_langinfo_altmon=no]) + ]) + if test $gl_cv_header_langinfo_altmon = yes; then + HAVE_LANGINFO_ALTMON=1 + fi + AC_CACHE_CHECK([whether langinfo.h defines ERA], + [gl_cv_header_langinfo_era], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#include +int a = ERA; +]])], + [gl_cv_header_langinfo_era=yes], + [gl_cv_header_langinfo_era=no]) + ]) + if test $gl_cv_header_langinfo_era = yes; then + HAVE_LANGINFO_ERA=1 + fi + AC_CACHE_CHECK([whether langinfo.h defines YESEXPR], + [gl_cv_header_langinfo_yesexpr], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#include +int a = YESEXPR; +]])], + [gl_cv_header_langinfo_yesexpr=yes], + [gl_cv_header_langinfo_yesexpr=no]) + ]) + if test $gl_cv_header_langinfo_yesexpr = yes; then + HAVE_LANGINFO_YESEXPR=1 + fi + else + HAVE_LANGINFO_H=0 + fi + AC_SUBST([HAVE_LANGINFO_H]) + AC_SUBST([HAVE_LANGINFO_CODESET]) + AC_SUBST([HAVE_LANGINFO_T_FMT_AMPM]) + AC_SUBST([HAVE_LANGINFO_ALTMON]) + AC_SUBST([HAVE_LANGINFO_ERA]) + AC_SUBST([HAVE_LANGINFO_YESEXPR]) + + dnl Check for declarations of anything we want to poison if the + dnl corresponding gnulib module is not in use. + gl_WARN_ON_USE_PREPARE([[#include + ]], [nl_langinfo]) +]) + +# gl_LANGINFO_MODULE_INDICATOR([modulename]) +# sets the shell variable that indicates the presence of the given module +# to a C preprocessor expression that will evaluate to 1. +# This macro invocation must not occur in macros that are AC_REQUIREd. +AC_DEFUN([gl_LANGINFO_MODULE_INDICATOR], +[ + dnl Ensure to expand the default settings once only. + gl_LANGINFO_H_REQUIRE_DEFAULTS + gl_MODULE_INDICATOR_SET_VARIABLE([$1]) + dnl Define it also as a C macro, for the benefit of the unit tests. + gl_MODULE_INDICATOR_FOR_TESTS([$1]) +]) + +# Initializes the default values for AC_SUBSTed shell variables. +# This macro must not be AC_REQUIREd. It must only be invoked, and only +# outside of macros or in macros that are not AC_REQUIREd. +AC_DEFUN([gl_LANGINFO_H_REQUIRE_DEFAULTS], +[ + m4_defun(GL_MODULE_INDICATOR_PREFIX[_LANGINFO_H_MODULE_INDICATOR_DEFAULTS], [ + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_NL_LANGINFO]) + ]) + m4_require(GL_MODULE_INDICATOR_PREFIX[_LANGINFO_H_MODULE_INDICATOR_DEFAULTS]) + AC_REQUIRE([gl_LANGINFO_H_DEFAULTS]) +]) + +AC_DEFUN([gl_LANGINFO_H_DEFAULTS], +[ + dnl Assume proper GNU behavior unless another module says otherwise. + HAVE_NL_LANGINFO=1; AC_SUBST([HAVE_NL_LANGINFO]) + REPLACE_NL_LANGINFO=0; AC_SUBST([REPLACE_NL_LANGINFO]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/largefile.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/largefile.m4 new file mode 100644 index 00000000..cbe9bc1f --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/largefile.m4 @@ -0,0 +1,358 @@ +# Enable large files on systems where this is not the default. +# Enable support for files on Linux file systems with 64-bit inode numbers. + +# Copyright 1992-1996, 1998-2024 Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# The following macro works around a problem in Autoconf's AC_FUNC_FSEEKO: +# It does not set _LARGEFILE_SOURCE=1 on HP-UX/ia64 32-bit, although this +# setting of _LARGEFILE_SOURCE is needed so that declares fseeko +# and ftello in C++ mode as well. +# This problem occurs in Autoconf 2.71 and earlier, which lack AC_SYS_YEAR2038. +AC_DEFUN([gl_SET_LARGEFILE_SOURCE], + m4_ifndef([AC_SYS_YEAR2038], [[ + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_FUNC_FSEEKO + case "$host_os" in + hpux*) + AC_DEFINE([_LARGEFILE_SOURCE], [1], + [Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2).]) + ;; + esac + ]]) +) + +m4_ifndef([AC_SYS_YEAR2038_RECOMMENDED], [ +# Support AC_SYS_YEAR2038_RECOMMENDED and related macros, even if +# Autoconf 2.71 or earlier. This code is taken from Autoconf master. + +# _AC_SYS_YEAR2038_TEST_CODE +# -------------------------- +# C code used to probe for time_t that can represent time points more +# than 2**31 - 1 seconds after the epoch. With the usual Unix epoch, +# these correspond to dates after 2038-01-18 22:14:07 +0000 (Gregorian), +# hence the name. +AC_DEFUN([_AC_SYS_YEAR2038_TEST_CODE], +[[ + #include + /* Check that time_t can represent 2**32 - 1 correctly. */ + #define LARGE_TIME_T \\ + ((time_t) (((time_t) 1 << 30) - 1 + 3 * ((time_t) 1 << 30))) + int verify_time_t_range[(LARGE_TIME_T / 65537 == 65535 + && LARGE_TIME_T % 65537 == 0) + ? 1 : -1]; +]]) + +# _AC_SYS_YEAR2038_OPTIONS +# ------------------------ +# List of known ways to enable support for large time_t. If you change +# this list you probably also need to change the AS_CASE at the end of +# _AC_SYS_YEAR2038_PROBE. +m4_define([_AC_SYS_YEAR2038_OPTIONS], m4_normalize( + ["none needed"] dnl 64-bit and newer 32-bit Unix + ["-D_TIME_BITS=64"] dnl glibc 2.34 with some 32-bit ABIs + ["-D__MINGW_USE_VC2005_COMPAT"] dnl 32-bit MinGW + ["-U_USE_32_BIT_TIME_T -D__MINGW_USE_VC2005_COMPAT"] + dnl 32-bit MinGW (misconfiguration) +)) + +# _AC_SYS_YEAR2038_PROBE +# ---------------------- +# Subroutine of AC_SYS_YEAR2038. Probe for time_t that can represent +# time points more than 2**31 - 1 seconds after the epoch (dates after +# 2038-01-18, see above) and set the cache variable ac_cv_sys_year2038_opts +# to one of the values in the _AC_SYS_YEAR2038_OPTIONS list, or to +# "support not detected" if none of them worked. Then, set compilation +# options and #defines as necessary to enable large time_t support. +# +# Note that we do not test whether mktime, localtime, etc. handle +# large values of time_t correctly, as that would require use of +# AC_TRY_RUN. Note also that some systems only support large time_t +# together with large off_t. +# +# If you change this macro you may also need to change +# _AC_SYS_YEAR2038_OPTIONS. +AC_DEFUN([_AC_SYS_YEAR2038_PROBE], +[AC_CACHE_CHECK([for $CC option for timestamps after 2038], + [ac_cv_sys_year2038_opts], + [ac_save_CPPFLAGS="$CPPFLAGS" + ac_opt_found=no + for ac_opt in _AC_SYS_YEAR2038_OPTIONS; do + AS_IF([test x"$ac_opt" != x"none needed"], + [CPPFLAGS="$ac_save_CPPFLAGS $ac_opt"]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([_AC_SYS_YEAR2038_TEST_CODE])], + [ac_cv_sys_year2038_opts="$ac_opt" + ac_opt_found=yes]) + test $ac_opt_found = no || break + done + CPPFLAGS="$ac_save_CPPFLAGS" + test $ac_opt_found = yes || ac_cv_sys_year2038_opts="support not detected"]) + +ac_have_year2038=yes +AS_CASE([$ac_cv_sys_year2038_opts], + ["none needed"], [], + ["support not detected"], + [ac_have_year2038=no], + + ["-D_TIME_BITS=64"], + [AC_DEFINE([_TIME_BITS], [64], + [Number of bits in time_t, on hosts where this is settable.])], + + ["-D__MINGW_USE_VC2005_COMPAT"], + [AC_DEFINE([__MINGW_USE_VC2005_COMPAT], [1], + [Define to 1 on platforms where this makes time_t a 64-bit type.])], + + ["-U_USE_32_BIT_TIME_T"*], + [AC_MSG_FAILURE(m4_text_wrap( + [the 'time_t' type is currently forced to be 32-bit. + It will stop working after mid-January 2038. + Remove _USE_32BIT_TIME_T from the compiler flags.], + [], [], [55]))], + + [AC_MSG_ERROR( + [internal error: bad value for \$ac_cv_sys_year2038_opts])]) +]) + +# _AC_SYS_YEAR2038_ENABLE +# ----------------------- +# Depending on which of the YEAR2038 macros was used, add either an +# --enable-year2038 or a --disable-year2038 to +# the configure script. This is expanded very late and +# therefore there cannot be any code in the AC_ARG_ENABLE. The +# default value for 'enable_year2038' is emitted unconditionally +# because the generated code always looks at this variable. +m4_define([_AC_SYS_YEAR2038_ENABLE], +[m4_divert_text([DEFAULTS], + m4_provide_if([AC_SYS_YEAR2038], + [enable_year2038=yes], + [enable_year2038=no]))]dnl +[AC_ARG_ENABLE([year2038], + m4_provide_if([AC_SYS_YEAR2038], + [AS_HELP_STRING([--disable-year2038], + [don't support timestamps after 2038])], + [AS_HELP_STRING([--enable-year2038], + [support timestamps after 2038])]))]) + +# AC_SYS_YEAR2038 +# --------------- +# Attempt to detect and activate support for large time_t. +# On systems where time_t is not always 64 bits, this probe can be +# skipped by passing the --disable-year2038 option to configure. +AC_DEFUN([AC_SYS_YEAR2038], +[AC_REQUIRE([AC_SYS_LARGEFILE])dnl +AS_IF([test "$enable_year2038,$ac_have_year2038,$cross_compiling" = yes,no,no], + [# If we're not cross compiling and 'touch' works with a large + # timestamp, then we can presume the system supports wider time_t + # *somehow* and we just weren't able to detect it. One common + # case that we deliberately *don't* probe for is a system that + # supports both 32- and 64-bit ABIs but only the 64-bit ABI offers + # wide time_t. (It would be inappropriate for us to override an + # intentional use of -m32.) Error out, demanding use of + # --disable-year2038 if this is intentional. + AS_IF([TZ=UTC0 touch -t 210602070628.15 conftest.time 2>/dev/null], + [AS_CASE([`TZ=UTC0 LC_ALL=C ls -l conftest.time 2>/dev/null`], + [*'Feb 7 2106'* | *'Feb 7 17:10'*], + [AC_MSG_FAILURE(m4_text_wrap( + [this system appears to support timestamps after mid-January 2038, + but no mechanism for enabling wide 'time_t' was detected. + Did you mean to build a 64-bit binary? (E.g., 'CC="${CC} -m64"'.) + To proceed with 32-bit time_t, configure with '--disable-year2038'.], + [], [], [55]))])])])]) + +# AC_SYS_YEAR2038_RECOMMENDED +# --------------------------- +# Same as AC_SYS_YEAR2038, but recommend support for large time_t. +# If we cannot find any way to make time_t capable of representing +# values larger than 2**31 - 1, error out unless --disable-year2038 is given. +AC_DEFUN([AC_SYS_YEAR2038_RECOMMENDED], +[AC_REQUIRE([AC_SYS_YEAR2038])dnl +AS_IF([test "$enable_year2038,$ac_have_year2038" = yes,no], + [AC_MSG_FAILURE(m4_text_wrap( + [could not enable timestamps after mid-January 2038. + This package recommends support for these later timestamps. + However, to proceed with signed 32-bit time_t even though it + will fail then, configure with '--disable-year2038'.], + [], [], [55]))])]) + +# _AC_SYS_LARGEFILE_TEST_CODE +# --------------------------- +# C code used to probe for large file support. +m4_define([_AC_SYS_LARGEFILE_TEST_CODE], +[@%:@include +@%:@ifndef FTYPE +@%:@ define FTYPE off_t +@%:@endif + /* Check that FTYPE can represent 2**63 - 1 correctly. + We can't simply define LARGE_FTYPE to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +@%:@define LARGE_FTYPE (((FTYPE) 1 << 31 << 31) - 1 + ((FTYPE) 1 << 31 << 31)) + int FTYPE_is_large[[(LARGE_FTYPE % 2147483629 == 721 + && LARGE_FTYPE % 2147483647 == 1) + ? 1 : -1]];[]dnl +]) +# Defined by Autoconf 2.71 and circa 2022 Gnulib unwisely depended on it. +m4_define([_AC_SYS_LARGEFILE_TEST_INCLUDES], [_AC_SYS_LARGEFILE_TEST_CODE]) + +# _AC_SYS_LARGEFILE_OPTIONS +# ------------------------- +# List of known ways to enable support for large files. If you change +# this list you probably also need to change the AS_CASE at the end of +# _AC_SYS_LARGEFILE_PROBE. +m4_define([_AC_SYS_LARGEFILE_OPTIONS], m4_normalize( + ["none needed"] dnl Most current systems + ["-D_FILE_OFFSET_BITS=64"] dnl X/Open LFS spec + ["-D_LARGE_FILES=1"] dnl 32-bit AIX 4.2.1+, 32-bit z/OS + ["-n32"] dnl 32-bit IRIX 6, SGI cc (obsolete) +)) + +# _AC_SYS_LARGEFILE_PROBE +# ----------------------- +# Subroutine of AC_SYS_LARGEFILE. Probe for large file support and set +# the cache variable ac_cv_sys_largefile_opts to one of the values in +# the _AC_SYS_LARGEFILE_OPTIONS list, or to "support not detected" if +# none of the options in that list worked. Then, set compilation +# options and #defines as necessary to enable large file support. +# +# If large file support is not detected, the behavior depends on which of +# the top-level AC_SYS_LARGEFILE macros was used (see below). +# +# If you change this macro you may also need to change +# _AC_SYS_LARGEFILE_OPTIONS. +AC_DEFUN([_AC_SYS_LARGEFILE_PROBE], +[AC_CACHE_CHECK([for $CC option to enable large file support], + [ac_cv_sys_largefile_opts], + [ac_save_CC="$CC" + ac_opt_found=no + for ac_opt in _AC_SYS_LARGEFILE_OPTIONS; do + AS_IF([test x"$ac_opt" != x"none needed"], + [CC="$ac_save_CC $ac_opt"]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([_AC_SYS_LARGEFILE_TEST_CODE])], + [AS_IF([test x"$ac_opt" = x"none needed"], + [# GNU/Linux s390x and alpha need _FILE_OFFSET_BITS=64 for wide ino_t. + CC="$CC -DFTYPE=ino_t" + AC_COMPILE_IFELSE([], [], + [CC="$CC -D_FILE_OFFSET_BITS=64" + AC_COMPILE_IFELSE([], [ac_opt='-D_FILE_OFFSET_BITS=64'])])]) + ac_cv_sys_largefile_opts=$ac_opt + ac_opt_found=yes]) + test $ac_opt_found = no || break + done + CC="$ac_save_CC" + dnl Gnulib implements large file support for native Windows, based on the + dnl variables WINDOWS_64_BIT_OFF_T, WINDOWS_64_BIT_ST_SIZE. + m4_ifdef([gl_LARGEFILE], [ + AC_REQUIRE([AC_CANONICAL_HOST]) + if test $ac_opt_found != yes; then + AS_CASE([$host_os], + [mingw* | windows*], + [ac_cv_sys_largefile_opts="supported through gnulib" + ac_opt_found=yes] + ) + fi + ]) + test $ac_opt_found = yes || ac_cv_sys_largefile_opts="support not detected"]) + +ac_have_largefile=yes +AS_CASE([$ac_cv_sys_largefile_opts], + ["none needed"], [], + ["supported through gnulib"], [], + ["support not detected"], + [ac_have_largefile=no], + + ["-D_FILE_OFFSET_BITS=64"], + [AC_DEFINE([_FILE_OFFSET_BITS], [64], + [Number of bits in a file offset, on hosts where this is settable.])], + + ["-D_LARGE_FILES=1"], + [AC_DEFINE([_LARGE_FILES], [1], + [Define to 1 on platforms where this makes off_t a 64-bit type.])], + + ["-n32"], + [CC="$CC -n32"], + + [AC_MSG_ERROR( + [internal error: bad value for \$ac_cv_sys_largefile_opts])]) + +AS_IF([test "$enable_year2038" != no], + [_AC_SYS_YEAR2038_PROBE]) +AC_CONFIG_COMMANDS_PRE([_AC_SYS_YEAR2038_ENABLE])]) + +# AC_SYS_LARGEFILE +# ---------------- +# By default, many hosts won't let programs access large files; +# one must use special compiler options to get large-file access to work. +# For more details about this brain damage please see: +# http://www.unix.org/version2/whatsnew/lfs20mar.html +# Additionally, on Linux file systems with 64-bit inodes a file that happens +# to have a 64-bit inode number cannot be accessed by 32-bit applications on +# Linux x86/x86_64. This can occur with file systems such as XFS and NFS. +AC_DEFUN([AC_SYS_LARGEFILE], +[AC_ARG_ENABLE([largefile], + [AS_HELP_STRING([--disable-largefile], + [omit support for large files])])dnl +AS_IF([test "$enable_largefile,$enable_year2038" != no,no], + [_AC_SYS_LARGEFILE_PROBE])]) +])# m4_ifndef AC_SYS_YEAR2038_RECOMMENDED + +# Enable large files on systems where this is implemented by Gnulib, not by the +# system headers. +# Set the variables WINDOWS_64_BIT_OFF_T, WINDOWS_64_BIT_ST_SIZE if Gnulib +# overrides ensure that off_t or 'struct size.st_size' are 64-bit, respectively. +AC_DEFUN([gl_LARGEFILE], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) + case "$host_os" in + mingw* | windows*) + dnl Native Windows. + dnl mingw64 defines off_t to a 64-bit type already, if + dnl _FILE_OFFSET_BITS=64, which is ensured by AC_SYS_LARGEFILE. + AC_CACHE_CHECK([for 64-bit off_t], [gl_cv_type_off_t_64], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include + int verify_off_t_size[sizeof (off_t) >= 8 ? 1 : -1]; + ]], + [[]])], + [gl_cv_type_off_t_64=yes], [gl_cv_type_off_t_64=no]) + ]) + if test $gl_cv_type_off_t_64 = no; then + WINDOWS_64_BIT_OFF_T=1 + else + WINDOWS_64_BIT_OFF_T=0 + fi + dnl Some mingw versions define, if _FILE_OFFSET_BITS=64, 'struct stat' + dnl to 'struct _stat32i64' or 'struct _stat64' (depending on + dnl _USE_32BIT_TIME_T), which has a 32-bit st_size member. + AC_CACHE_CHECK([for 64-bit st_size], [gl_cv_member_st_size_64], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include + struct stat buf; + int verify_st_size_size[sizeof (buf.st_size) >= 8 ? 1 : -1]; + ]], + [[]])], + [gl_cv_member_st_size_64=yes], [gl_cv_member_st_size_64=no]) + ]) + if test $gl_cv_member_st_size_64 = no; then + WINDOWS_64_BIT_ST_SIZE=1 + else + WINDOWS_64_BIT_ST_SIZE=0 + fi + ;; + *) + dnl Nothing to do on gnulib's side. + dnl A 64-bit off_t is + dnl - already the default on Mac OS X, FreeBSD, NetBSD, OpenBSD, IRIX, + dnl OSF/1, Cygwin, + dnl - enabled by _FILE_OFFSET_BITS=64 (ensured by AC_SYS_LARGEFILE) on + dnl glibc, HP-UX, Solaris, + dnl - enabled by _LARGE_FILES=1 (ensured by AC_SYS_LARGEFILE) on AIX, + dnl - impossible to achieve on Minix 3.1.8. + WINDOWS_64_BIT_OFF_T=0 + WINDOWS_64_BIT_ST_SIZE=0 + ;; + esac +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/lib-ld.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/lib-ld.m4 new file mode 100644 index 00000000..f0793329 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/lib-ld.m4 @@ -0,0 +1,168 @@ +# lib-ld.m4 serial 12 +dnl Copyright (C) 1996-2003, 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl Subroutines of libtool.m4, +dnl with replacements s/_*LT_PATH/AC_LIB_PROG/ and s/lt_/acl_/ to avoid +dnl collision with libtool.m4. + +dnl From libtool-2.4. Sets the variable with_gnu_ld to yes or no. +AC_DEFUN([AC_LIB_PROG_LD_GNU], +[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], [acl_cv_prog_gnu_ld], +[# I'd rather use --version here, but apparently some GNU lds only accept -v. +case `$LD -v 2>&1 /dev/null 2>&1 \ + && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ + || PATH_SEPARATOR=';' + } +fi + +if test -n "$LD"; then + AC_MSG_CHECKING([for ld]) +elif test "$GCC" = yes; then + AC_MSG_CHECKING([for ld used by $CC]) +elif test "$with_gnu_ld" = yes; then + AC_MSG_CHECKING([for GNU ld]) +else + AC_MSG_CHECKING([for non-GNU ld]) +fi +if test -n "$LD"; then + # Let the user override the test with a path. + : +else + AC_CACHE_VAL([acl_cv_path_LD], + [ + acl_cv_path_LD= # Final result of this test + ac_prog=ld # Program to search in $PATH + if test "$GCC" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + case $host in + *-*-mingw* | windows*) + # gcc leaves a trailing carriage return which upsets mingw + acl_output=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; + *) + acl_output=`($CC -print-prog-name=ld) 2>&5` ;; + esac + case $acl_output in + # Accept absolute paths. + [[\\/]]* | ?:[[\\/]]*) + re_direlt='/[[^/]][[^/]]*/\.\./' + # Canonicalize the pathname of ld + acl_output=`echo "$acl_output" | sed 's%\\\\%/%g'` + while echo "$acl_output" | grep "$re_direlt" > /dev/null 2>&1; do + acl_output=`echo $acl_output | sed "s%$re_direlt%/%"` + done + # Got the pathname. No search in PATH is needed. + acl_cv_path_LD="$acl_output" + ac_prog= + ;; + "") + # If it fails, then pretend we aren't using GCC. + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac + fi + if test -n "$ac_prog"; then + # Search for $ac_prog in $PATH. + acl_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH; do + IFS="$acl_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + acl_cv_path_LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some variants of GNU ld only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + case `"$acl_cv_path_LD" -v 2>&1 conftest.sh + . ./conftest.sh + rm -f ./conftest.sh + acl_cv_rpath=done + ]) + wl="$acl_cv_wl" + acl_libext="$acl_cv_libext" + acl_shlibext="$acl_cv_shlibext" + acl_libname_spec="$acl_cv_libname_spec" + acl_library_names_spec="$acl_cv_library_names_spec" + acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec" + acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator" + acl_hardcode_direct="$acl_cv_hardcode_direct" + acl_hardcode_minus_L="$acl_cv_hardcode_minus_L" + dnl Determine whether the user wants rpath handling at all. + AC_ARG_ENABLE([rpath], + [ --disable-rpath do not hardcode runtime library paths], + :, enable_rpath=yes) +]) + +dnl AC_LIB_FROMPACKAGE(name, package) +dnl declares that libname comes from the given package. The configure file +dnl will then not have a --with-libname-prefix option but a +dnl --with-package-prefix option. Several libraries can come from the same +dnl package. This declaration must occur before an AC_LIB_LINKFLAGS or similar +dnl macro call that searches for libname. +AC_DEFUN([AC_LIB_FROMPACKAGE], +[ + pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) + define([acl_frompackage_]NAME, [$2]) + popdef([NAME]) + pushdef([PACK],[$2]) + pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) + define([acl_libsinpackage_]PACKUP, + m4_ifdef([acl_libsinpackage_]PACKUP, [m4_defn([acl_libsinpackage_]PACKUP)[, ]],)[lib$1]) + popdef([PACKUP]) + popdef([PACK]) +]) + +dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and +dnl the libraries corresponding to explicit and implicit dependencies. +dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables. +dnl Also, sets the LIB${NAME}_PREFIX variable to nonempty if libname was found +dnl in ${LIB${NAME}_PREFIX}/$acl_libdirstem. +AC_DEFUN([AC_LIB_LINKFLAGS_BODY], +[ + AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) + pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) + pushdef([PACK],[m4_ifdef([acl_frompackage_]NAME, [acl_frompackage_]NAME, lib[$1])]) + pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) + pushdef([PACKLIBS],[m4_ifdef([acl_frompackage_]NAME, [acl_libsinpackage_]PACKUP, lib[$1])]) + dnl By default, look in $includedir and $libdir. + use_additional=yes + AC_LIB_WITH_FINAL_PREFIX([ + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + eval additional_libdir2=\"$exec_prefix/$acl_libdirstem2\" + eval additional_libdir3=\"$exec_prefix/$acl_libdirstem3\" + ]) + AC_ARG_WITH(PACK[-prefix], +[[ --with-]]PACK[[-prefix[=DIR] search for ]]PACKLIBS[[ in DIR/include and DIR/lib + --without-]]PACK[[-prefix don't search for ]]PACKLIBS[[ in includedir and libdir]], +[ + if test "X$withval" = "Xno"; then + use_additional=no + else + if test "X$withval" = "X"; then + AC_LIB_WITH_FINAL_PREFIX([ + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + eval additional_libdir2=\"$exec_prefix/$acl_libdirstem2\" + eval additional_libdir3=\"$exec_prefix/$acl_libdirstem3\" + ]) + else + additional_includedir="$withval/include" + additional_libdir="$withval/$acl_libdirstem" + additional_libdir2="$withval/$acl_libdirstem2" + additional_libdir3="$withval/$acl_libdirstem3" + fi + fi +]) + if test "X$additional_libdir2" = "X$additional_libdir"; then + additional_libdir2= + fi + if test "X$additional_libdir3" = "X$additional_libdir"; then + additional_libdir3= + fi + dnl Search the library and its dependencies in $additional_libdir and + dnl $LDFLAGS. Use breadth-first search. + LIB[]NAME= + LTLIB[]NAME= + INC[]NAME= + LIB[]NAME[]_PREFIX= + dnl HAVE_LIB${NAME} is an indicator that LIB${NAME}, LTLIB${NAME} have been + dnl computed. So it has to be reset here. + HAVE_LIB[]NAME= + rpathdirs= + ltrpathdirs= + names_already_handled= + names_next_round='$1 $2' + while test -n "$names_next_round"; do + names_this_round="$names_next_round" + names_next_round= + for name in $names_this_round; do + already_handled= + for n in $names_already_handled; do + if test "$n" = "$name"; then + already_handled=yes + break + fi + done + if test -z "$already_handled"; then + names_already_handled="$names_already_handled $name" + dnl See if it was already located by an earlier AC_LIB_LINKFLAGS + dnl or AC_LIB_HAVE_LINKFLAGS call. + uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./+-|ABCDEFGHIJKLMNOPQRSTUVWXYZ____|'` + eval value=\"\$HAVE_LIB$uppername\" + if test -n "$value"; then + if test "$value" = yes; then + eval value=\"\$LIB$uppername\" + test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value" + eval value=\"\$LTLIB$uppername\" + test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value" + else + dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined + dnl that this library doesn't exist. So just drop it. + : + fi + else + dnl Search the library lib$name in $additional_libdir and $LDFLAGS + dnl and the already constructed $LIBNAME/$LTLIBNAME. + found_dir= + found_la= + found_so= + found_a= + eval libname=\"$acl_libname_spec\" # typically: libname=lib$name + if test -n "$acl_shlibext"; then + shrext=".$acl_shlibext" # typically: shrext=.so + else + shrext= + fi + if test $use_additional = yes; then + for additional_libdir_variable in additional_libdir additional_libdir2 additional_libdir3; do + if test "X$found_dir" = "X"; then + eval dir=\$$additional_libdir_variable + if test -n "$dir"; then + dnl The same code as in the loop below: + dnl First look for a shared library. + if test -n "$acl_shlibext"; then + if test -f "$dir/$libname$shrext" && acl_is_expected_elfclass < "$dir/$libname$shrext"; then + found_dir="$dir" + found_so="$dir/$libname$shrext" + else + if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then + ver=`(cd "$dir" && \ + for f in "$libname$shrext".*; do echo "$f"; done \ + | sed -e "s,^$libname$shrext\\\\.,," \ + | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ + | sed 1q ) 2>/dev/null` + if test -n "$ver" && test -f "$dir/$libname$shrext.$ver" && acl_is_expected_elfclass < "$dir/$libname$shrext.$ver"; then + found_dir="$dir" + found_so="$dir/$libname$shrext.$ver" + fi + else + eval library_names=\"$acl_library_names_spec\" + for f in $library_names; do + if test -f "$dir/$f" && acl_is_expected_elfclass < "$dir/$f"; then + found_dir="$dir" + found_so="$dir/$f" + break + fi + done + fi + fi + fi + dnl Then look for a static library. + if test "X$found_dir" = "X"; then + if test -f "$dir/$libname.$acl_libext" && ${AR-ar} -p "$dir/$libname.$acl_libext" | acl_is_expected_elfclass; then + found_dir="$dir" + found_a="$dir/$libname.$acl_libext" + fi + fi + if test "X$found_dir" != "X"; then + if test -f "$dir/$libname.la"; then + found_la="$dir/$libname.la" + fi + fi + fi + fi + done + fi + if test "X$found_dir" = "X"; then + for x in $LDFLAGS $LTLIB[]NAME; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + case "$x" in + -L*) + dir=`echo "X$x" | sed -e 's/^X-L//'` + dnl First look for a shared library. + if test -n "$acl_shlibext"; then + if test -f "$dir/$libname$shrext" && acl_is_expected_elfclass < "$dir/$libname$shrext"; then + found_dir="$dir" + found_so="$dir/$libname$shrext" + else + if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then + ver=`(cd "$dir" && \ + for f in "$libname$shrext".*; do echo "$f"; done \ + | sed -e "s,^$libname$shrext\\\\.,," \ + | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ + | sed 1q ) 2>/dev/null` + if test -n "$ver" && test -f "$dir/$libname$shrext.$ver" && acl_is_expected_elfclass < "$dir/$libname$shrext.$ver"; then + found_dir="$dir" + found_so="$dir/$libname$shrext.$ver" + fi + else + eval library_names=\"$acl_library_names_spec\" + for f in $library_names; do + if test -f "$dir/$f" && acl_is_expected_elfclass < "$dir/$f"; then + found_dir="$dir" + found_so="$dir/$f" + break + fi + done + fi + fi + fi + dnl Then look for a static library. + if test "X$found_dir" = "X"; then + if test -f "$dir/$libname.$acl_libext" && ${AR-ar} -p "$dir/$libname.$acl_libext" | acl_is_expected_elfclass; then + found_dir="$dir" + found_a="$dir/$libname.$acl_libext" + fi + fi + if test "X$found_dir" != "X"; then + if test -f "$dir/$libname.la"; then + found_la="$dir/$libname.la" + fi + fi + ;; + esac + if test "X$found_dir" != "X"; then + break + fi + done + fi + if test "X$found_dir" != "X"; then + dnl Found the library. + LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name" + if test "X$found_so" != "X"; then + dnl Linking with a shared library. We attempt to hardcode its + dnl directory into the executable's runpath, unless it's the + dnl standard /usr/lib. + if test "$enable_rpath" = no \ + || test "X$found_dir" = "X/usr/$acl_libdirstem" \ + || test "X$found_dir" = "X/usr/$acl_libdirstem2" \ + || test "X$found_dir" = "X/usr/$acl_libdirstem3"; then + dnl No hardcoding is needed. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" + else + dnl Use an explicit option to hardcode DIR into the resulting + dnl binary. + dnl Potentially add DIR to ltrpathdirs. + dnl The ltrpathdirs will be appended to $LTLIBNAME at the end. + haveit= + for x in $ltrpathdirs; do + if test "X$x" = "X$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + ltrpathdirs="$ltrpathdirs $found_dir" + fi + dnl The hardcoding into $LIBNAME is system dependent. + if test "$acl_hardcode_direct" = yes; then + dnl Using DIR/libNAME.so during linking hardcodes DIR into the + dnl resulting binary. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" + else + if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then + dnl Use an explicit option to hardcode DIR into the resulting + dnl binary. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" + dnl Potentially add DIR to rpathdirs. + dnl The rpathdirs will be appended to $LIBNAME at the end. + haveit= + for x in $rpathdirs; do + if test "X$x" = "X$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + rpathdirs="$rpathdirs $found_dir" + fi + else + dnl Rely on "-L$found_dir". + dnl But don't add it if it's already contained in the LDFLAGS + dnl or the already constructed $LIBNAME + haveit= + for x in $LDFLAGS $LIB[]NAME; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-L$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir" + fi + if test "$acl_hardcode_minus_L" != no; then + dnl FIXME: Not sure whether we should use + dnl "-L$found_dir -l$name" or "-L$found_dir $found_so" + dnl here. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" + else + dnl We cannot use $acl_hardcode_runpath_var and LD_RUN_PATH + dnl here, because this doesn't fit in flags passed to the + dnl compiler. So give up. No hardcoding. This affects only + dnl very old systems. + dnl FIXME: Not sure whether we should use + dnl "-L$found_dir -l$name" or "-L$found_dir $found_so" + dnl here. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name" + fi + fi + fi + fi + else + if test "X$found_a" != "X"; then + dnl Linking with a static library. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a" + else + dnl We shouldn't come here, but anyway it's good to have a + dnl fallback. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name" + fi + fi + dnl Assume the include files are nearby. + additional_includedir= + case "$found_dir" in + */$acl_libdirstem | */$acl_libdirstem/) + basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'` + if test "$name" = '$1'; then + LIB[]NAME[]_PREFIX="$basedir" + fi + additional_includedir="$basedir/include" + ;; + */$acl_libdirstem2 | */$acl_libdirstem2/) + basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'` + if test "$name" = '$1'; then + LIB[]NAME[]_PREFIX="$basedir" + fi + additional_includedir="$basedir/include" + ;; + */$acl_libdirstem3 | */$acl_libdirstem3/) + basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem3/"'*$,,'` + if test "$name" = '$1'; then + LIB[]NAME[]_PREFIX="$basedir" + fi + additional_includedir="$basedir/include" + ;; + esac + if test "X$additional_includedir" != "X"; then + dnl Potentially add $additional_includedir to $INCNAME. + dnl But don't add it + dnl 1. if it's the standard /usr/include, + dnl 2. if it's /usr/local/include and we are using GCC on Linux, + dnl 3. if it's already present in $CPPFLAGS or the already + dnl constructed $INCNAME, + dnl 4. if it doesn't exist as a directory. + if test "X$additional_includedir" != "X/usr/include"; then + haveit= + if test "X$additional_includedir" = "X/usr/local/include"; then + if test -n "$GCC"; then + case $host_os in + linux* | gnu* | k*bsd*-gnu) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + for x in $CPPFLAGS $INC[]NAME; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-I$additional_includedir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_includedir"; then + dnl Really add $additional_includedir to $INCNAME. + INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir" + fi + fi + fi + fi + fi + dnl Look for dependencies. + if test -n "$found_la"; then + dnl Read the .la file. It defines the variables + dnl dlname, library_names, old_library, dependency_libs, current, + dnl age, revision, installed, dlopen, dlpreopen, libdir. + save_libdir="$libdir" + case "$found_la" in + */* | *\\*) . "$found_la" ;; + *) . "./$found_la" ;; + esac + libdir="$save_libdir" + dnl We use only dependency_libs. + for dep in $dependency_libs; do + case "$dep" in + -L*) + dependency_libdir=`echo "X$dep" | sed -e 's/^X-L//'` + dnl Potentially add $dependency_libdir to $LIBNAME and $LTLIBNAME. + dnl But don't add it + dnl 1. if it's the standard /usr/lib, + dnl 2. if it's /usr/local/lib and we are using GCC on Linux, + dnl 3. if it's already present in $LDFLAGS or the already + dnl constructed $LIBNAME, + dnl 4. if it doesn't exist as a directory. + if test "X$dependency_libdir" != "X/usr/$acl_libdirstem" \ + && test "X$dependency_libdir" != "X/usr/$acl_libdirstem2" \ + && test "X$dependency_libdir" != "X/usr/$acl_libdirstem3"; then + haveit= + if test "X$dependency_libdir" = "X/usr/local/$acl_libdirstem" \ + || test "X$dependency_libdir" = "X/usr/local/$acl_libdirstem2" \ + || test "X$dependency_libdir" = "X/usr/local/$acl_libdirstem3"; then + if test -n "$GCC"; then + case $host_os in + linux* | gnu* | k*bsd*-gnu) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + haveit= + for x in $LDFLAGS $LIB[]NAME; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-L$dependency_libdir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$dependency_libdir"; then + dnl Really add $dependency_libdir to $LIBNAME. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$dependency_libdir" + fi + fi + haveit= + for x in $LDFLAGS $LTLIB[]NAME; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-L$dependency_libdir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$dependency_libdir"; then + dnl Really add $dependency_libdir to $LTLIBNAME. + LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$dependency_libdir" + fi + fi + fi + fi + ;; + -R*) + dir=`echo "X$dep" | sed -e 's/^X-R//'` + if test "$enable_rpath" != no; then + dnl Potentially add DIR to rpathdirs. + dnl The rpathdirs will be appended to $LIBNAME at the end. + haveit= + for x in $rpathdirs; do + if test "X$x" = "X$dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + rpathdirs="$rpathdirs $dir" + fi + dnl Potentially add DIR to ltrpathdirs. + dnl The ltrpathdirs will be appended to $LTLIBNAME at the end. + haveit= + for x in $ltrpathdirs; do + if test "X$x" = "X$dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + ltrpathdirs="$ltrpathdirs $dir" + fi + fi + ;; + -l*) + dnl Handle this in the next round. + dnl But on GNU systems, ignore -lc options, because + dnl - linking with libc is the default anyway, + dnl - linking with libc.a may produce an error + dnl "/usr/bin/ld: dynamic STT_GNU_IFUNC symbol `strcmp' with pointer equality in `/usr/lib/libc.a(strcmp.o)' can not be used when making an executable; recompile with -fPIE and relink with -pie" + dnl or may produce an executable that always crashes, see + dnl . + dep=`echo "X$dep" | sed -e 's/^X-l//'` + if test "X$dep" != Xc \ + || case $host_os in + linux* | gnu* | k*bsd*-gnu) false ;; + *) true ;; + esac; then + names_next_round="$names_next_round $dep" + fi + ;; + *.la) + dnl Handle this in the next round. Throw away the .la's + dnl directory; it is already contained in a preceding -L + dnl option. + names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'` + ;; + *) + dnl Most likely an immediate library name. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep" + LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep" + ;; + esac + done + fi + else + dnl Didn't find the library; assume it is in the system directories + dnl known to the linker and runtime loader. (All the system + dnl directories known to the linker should also be known to the + dnl runtime loader, otherwise the system is severely misconfigured.) + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name" + LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name" + fi + fi + fi + done + done + if test "X$rpathdirs" != "X"; then + if test -n "$acl_hardcode_libdir_separator"; then + dnl Weird platform: only the last -rpath option counts, the user must + dnl pass all path elements in one option. We can arrange that for a + dnl single library, but not when more than one $LIBNAMEs are used. + alldirs= + for found_dir in $rpathdirs; do + alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir" + done + dnl Note: acl_hardcode_libdir_flag_spec uses $libdir and $wl. + acl_save_libdir="$libdir" + libdir="$alldirs" + eval flag=\"$acl_hardcode_libdir_flag_spec\" + libdir="$acl_save_libdir" + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" + else + dnl The -rpath options are cumulative. + for found_dir in $rpathdirs; do + acl_save_libdir="$libdir" + libdir="$found_dir" + eval flag=\"$acl_hardcode_libdir_flag_spec\" + libdir="$acl_save_libdir" + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" + done + fi + fi + if test "X$ltrpathdirs" != "X"; then + dnl When using libtool, the option that works for both libraries and + dnl executables is -R. The -R options are cumulative. + for found_dir in $ltrpathdirs; do + LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir" + done + fi + popdef([PACKLIBS]) + popdef([PACKUP]) + popdef([PACK]) + popdef([NAME]) +]) + +dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR, +dnl unless already present in VAR. +dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes +dnl contains two or three consecutive elements that belong together. +AC_DEFUN([AC_LIB_APPENDTOVAR], +[ + for element in [$2]; do + haveit= + for x in $[$1]; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X$element"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + [$1]="${[$1]}${[$1]:+ }$element" + fi + done +]) + +dnl For those cases where a variable contains several -L and -l options +dnl referring to unknown libraries and directories, this macro determines the +dnl necessary additional linker options for the runtime path. +dnl AC_LIB_LINKFLAGS_FROM_LIBS([LDADDVAR], [LIBSVALUE], [USE-LIBTOOL]) +dnl sets LDADDVAR to linker options needed together with LIBSVALUE. +dnl If USE-LIBTOOL evaluates to non-empty, linking with libtool is assumed, +dnl otherwise linking without libtool is assumed. +AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS], +[ + AC_REQUIRE([AC_LIB_RPATH]) + AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) + $1= + if test "$enable_rpath" != no; then + if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then + dnl Use an explicit option to hardcode directories into the resulting + dnl binary. + rpathdirs= + next= + for opt in $2; do + if test -n "$next"; then + dir="$next" + dnl No need to hardcode the standard /usr/lib. + if test "X$dir" != "X/usr/$acl_libdirstem" \ + && test "X$dir" != "X/usr/$acl_libdirstem2" \ + && test "X$dir" != "X/usr/$acl_libdirstem3"; then + rpathdirs="$rpathdirs $dir" + fi + next= + else + case $opt in + -L) next=yes ;; + -L*) dir=`echo "X$opt" | sed -e 's,^X-L,,'` + dnl No need to hardcode the standard /usr/lib. + if test "X$dir" != "X/usr/$acl_libdirstem" \ + && test "X$dir" != "X/usr/$acl_libdirstem2" \ + && test "X$dir" != "X/usr/$acl_libdirstem3"; then + rpathdirs="$rpathdirs $dir" + fi + next= ;; + *) next= ;; + esac + fi + done + if test "X$rpathdirs" != "X"; then + if test -n ""$3""; then + dnl libtool is used for linking. Use -R options. + for dir in $rpathdirs; do + $1="${$1}${$1:+ }-R$dir" + done + else + dnl The linker is used for linking directly. + if test -n "$acl_hardcode_libdir_separator"; then + dnl Weird platform: only the last -rpath option counts, the user + dnl must pass all path elements in one option. + alldirs= + for dir in $rpathdirs; do + alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$dir" + done + acl_save_libdir="$libdir" + libdir="$alldirs" + eval flag=\"$acl_hardcode_libdir_flag_spec\" + libdir="$acl_save_libdir" + $1="$flag" + else + dnl The -rpath options are cumulative. + for dir in $rpathdirs; do + acl_save_libdir="$libdir" + libdir="$dir" + eval flag=\"$acl_hardcode_libdir_flag_spec\" + libdir="$acl_save_libdir" + $1="${$1}${$1:+ }$flag" + done + fi + fi + fi + fi + fi + AC_SUBST([$1]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/lib-prefix.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/lib-prefix.m4 new file mode 100644 index 00000000..d597553b --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/lib-prefix.m4 @@ -0,0 +1,323 @@ +# lib-prefix.m4 serial 20 +dnl Copyright (C) 2001-2005, 2008-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. + +dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed +dnl to access previously installed libraries. The basic assumption is that +dnl a user will want packages to use other packages he previously installed +dnl with the same --prefix option. +dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate +dnl libraries, but is otherwise very convenient. +AC_DEFUN([AC_LIB_PREFIX], +[ + AC_BEFORE([$0], [AC_LIB_LINKFLAGS]) + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) + AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) + dnl By default, look in $includedir and $libdir. + use_additional=yes + AC_LIB_WITH_FINAL_PREFIX([ + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + ]) + AC_ARG_WITH([lib-prefix], +[[ --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib + --without-lib-prefix don't search for libraries in includedir and libdir]], +[ + if test "X$withval" = "Xno"; then + use_additional=no + else + if test "X$withval" = "X"; then + AC_LIB_WITH_FINAL_PREFIX([ + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + ]) + else + additional_includedir="$withval/include" + additional_libdir="$withval/$acl_libdirstem" + fi + fi +]) + if test $use_additional = yes; then + dnl Potentially add $additional_includedir to $CPPFLAGS. + dnl But don't add it + dnl 1. if it's the standard /usr/include, + dnl 2. if it's already present in $CPPFLAGS, + dnl 3. if it's /usr/local/include and we are using GCC on Linux, + dnl 4. if it doesn't exist as a directory. + if test "X$additional_includedir" != "X/usr/include"; then + haveit= + for x in $CPPFLAGS; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-I$additional_includedir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test "X$additional_includedir" = "X/usr/local/include"; then + if test -n "$GCC"; then + case $host_os in + linux* | gnu* | k*bsd*-gnu) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + if test -d "$additional_includedir"; then + dnl Really add $additional_includedir to $CPPFLAGS. + CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir" + fi + fi + fi + fi + dnl Potentially add $additional_libdir to $LDFLAGS. + dnl But don't add it + dnl 1. if it's the standard /usr/lib, + dnl 2. if it's already present in $LDFLAGS, + dnl 3. if it's /usr/local/lib and we are using GCC on Linux, + dnl 4. if it doesn't exist as a directory. + if test "X$additional_libdir" != "X/usr/$acl_libdirstem"; then + haveit= + for x in $LDFLAGS; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-L$additional_libdir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem"; then + if test -n "$GCC"; then + case $host_os in + linux*) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + if test -d "$additional_libdir"; then + dnl Really add $additional_libdir to $LDFLAGS. + LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir" + fi + fi + fi + fi + fi +]) + +dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix, +dnl acl_final_exec_prefix, containing the values to which $prefix and +dnl $exec_prefix will expand at the end of the configure script. +AC_DEFUN([AC_LIB_PREPARE_PREFIX], +[ + dnl Unfortunately, prefix and exec_prefix get only finally determined + dnl at the end of configure. + if test "X$prefix" = "XNONE"; then + acl_final_prefix="$ac_default_prefix" + else + acl_final_prefix="$prefix" + fi + if test "X$exec_prefix" = "XNONE"; then + acl_final_exec_prefix='${prefix}' + else + acl_final_exec_prefix="$exec_prefix" + fi + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + eval acl_final_exec_prefix=\"$acl_final_exec_prefix\" + prefix="$acl_save_prefix" +]) + +dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the +dnl variables prefix and exec_prefix bound to the values they will have +dnl at the end of the configure script. +AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX], +[ + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + $1 + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" +]) + +dnl AC_LIB_PREPARE_MULTILIB creates +dnl - a function acl_is_expected_elfclass, that tests whether standard input +dn; has a 32-bit or 64-bit ELF header, depending on the host CPU ABI, +dnl - 3 variables acl_libdirstem, acl_libdirstem2, acl_libdirstem3, containing +dnl the basename of the libdir to try in turn, either "lib" or "lib64" or +dnl "lib/64" or "lib32" or "lib/sparcv9" or "lib/amd64" or similar. +AC_DEFUN([AC_LIB_PREPARE_MULTILIB], +[ + dnl There is no formal standard regarding lib, lib32, and lib64. + dnl On most glibc systems, the current practice is that on a system supporting + dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under + dnl $prefix/lib64 and 32-bit libraries go under $prefix/lib. However, on + dnl Arch Linux based distributions, it's the opposite: 32-bit libraries go + dnl under $prefix/lib32 and 64-bit libraries go under $prefix/lib. + dnl We determine the compiler's default mode by looking at the compiler's + dnl library search path. If at least one of its elements ends in /lib64 or + dnl points to a directory whose absolute pathname ends in /lib64, we use that + dnl for 64-bit ABIs. Similarly for 32-bit ABIs. Otherwise we use the default, + dnl namely "lib". + dnl On Solaris systems, the current practice is that on a system supporting + dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under + dnl $prefix/lib/64 (which is a symlink to either $prefix/lib/sparcv9 or + dnl $prefix/lib/amd64) and 32-bit libraries go under $prefix/lib. + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_REQUIRE([gl_HOST_CPU_C_ABI_32BIT]) + + AC_CACHE_CHECK([for ELF binary format], [gl_cv_elf], + [AC_EGREP_CPP([Extensible Linking Format], + [#if defined __ELF__ || (defined __linux__ && defined __EDG__) + Extensible Linking Format + #endif + ], + [gl_cv_elf=yes], + [gl_cv_elf=no]) + ]) + if test $gl_cv_elf = yes; then + # Extract the ELF class of a file (5th byte) in decimal. + # Cf. https://en.wikipedia.org/wiki/Executable_and_Linkable_Format#File_header + if od -A x < /dev/null >/dev/null 2>/dev/null; then + # Use POSIX od. + func_elfclass () + { + od -A n -t d1 -j 4 -N 1 + } + else + # Use BSD hexdump. + func_elfclass () + { + dd bs=1 count=1 skip=4 2>/dev/null | hexdump -e '1/1 "%3d "' + echo + } + fi + # Use 'expr', not 'test', to compare the values of func_elfclass, because on + # Solaris 11 OpenIndiana and Solaris 11 OmniOS, the result is 001 or 002, + # not 1 or 2. +changequote(,)dnl + case $HOST_CPU_C_ABI_32BIT in + yes) + # 32-bit ABI. + acl_is_expected_elfclass () + { + expr "`func_elfclass | sed -e 's/[ ]//g'`" = 1 > /dev/null + } + ;; + no) + # 64-bit ABI. + acl_is_expected_elfclass () + { + expr "`func_elfclass | sed -e 's/[ ]//g'`" = 2 > /dev/null + } + ;; + *) + # Unknown. + acl_is_expected_elfclass () + { + : + } + ;; + esac +changequote([,])dnl + else + acl_is_expected_elfclass () + { + : + } + fi + + dnl Allow the user to override the result by setting acl_cv_libdirstems. + AC_CACHE_CHECK([for the common suffixes of directories in the library search path], + [acl_cv_libdirstems], + [dnl Try 'lib' first, because that's the default for libdir in GNU, see + dnl . + acl_libdirstem=lib + acl_libdirstem2= + acl_libdirstem3= + case "$host_os" in + solaris*) + dnl See Solaris 10 Software Developer Collection > Solaris 64-bit Developer's Guide > The Development Environment + dnl . + dnl "Portable Makefiles should refer to any library directories using the 64 symbolic link." + dnl But we want to recognize the sparcv9 or amd64 subdirectory also if the + dnl symlink is missing, so we set acl_libdirstem2 too. + if test $HOST_CPU_C_ABI_32BIT = no; then + acl_libdirstem2=lib/64 + case "$host_cpu" in + sparc*) acl_libdirstem3=lib/sparcv9 ;; + i*86 | x86_64) acl_libdirstem3=lib/amd64 ;; + esac + fi + ;; + *) + dnl If $CC generates code for a 32-bit ABI, the libraries are + dnl surely under $prefix/lib or $prefix/lib32, not $prefix/lib64. + dnl Similarly, if $CC generates code for a 64-bit ABI, the libraries + dnl are surely under $prefix/lib or $prefix/lib64, not $prefix/lib32. + dnl Find the compiler's search path. However, non-system compilers + dnl sometimes have odd library search paths. But we can't simply invoke + dnl '/usr/bin/gcc -print-search-dirs' because that would not take into + dnl account the -m32/-m31 or -m64 options from the $CC or $CFLAGS. + searchpath=`(LC_ALL=C $CC $CPPFLAGS $CFLAGS -print-search-dirs) 2>/dev/null \ + | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'` + if test $HOST_CPU_C_ABI_32BIT != no; then + # 32-bit or unknown ABI. + if test -d /usr/lib32; then + acl_libdirstem2=lib32 + fi + fi + if test $HOST_CPU_C_ABI_32BIT != yes; then + # 64-bit or unknown ABI. + if test -d /usr/lib64; then + acl_libdirstem3=lib64 + fi + fi + if test -n "$searchpath"; then + acl_save_IFS="${IFS= }"; IFS=":" + for searchdir in $searchpath; do + if test -d "$searchdir"; then + case "$searchdir" in + */lib32/ | */lib32 ) acl_libdirstem2=lib32 ;; + */lib64/ | */lib64 ) acl_libdirstem3=lib64 ;; + */../ | */.. ) + # Better ignore directories of this form. They are misleading. + ;; + *) searchdir=`cd "$searchdir" && pwd` + case "$searchdir" in + */lib32 ) acl_libdirstem2=lib32 ;; + */lib64 ) acl_libdirstem3=lib64 ;; + esac ;; + esac + fi + done + IFS="$acl_save_IFS" + if test $HOST_CPU_C_ABI_32BIT = yes; then + # 32-bit ABI. + acl_libdirstem3= + fi + if test $HOST_CPU_C_ABI_32BIT = no; then + # 64-bit ABI. + acl_libdirstem2= + fi + fi + ;; + esac + test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem" + test -n "$acl_libdirstem3" || acl_libdirstem3="$acl_libdirstem" + acl_cv_libdirstems="$acl_libdirstem,$acl_libdirstem2,$acl_libdirstem3" + ]) + dnl Decompose acl_cv_libdirstems into acl_libdirstem, acl_libdirstem2, and + dnl acl_libdirstem3. +changequote(,)dnl + acl_libdirstem=`echo "$acl_cv_libdirstems" | sed -e 's/,.*//'` + acl_libdirstem2=`echo "$acl_cv_libdirstems" | sed -e 's/^[^,]*,//' -e 's/,.*//'` + acl_libdirstem3=`echo "$acl_cv_libdirstems" | sed -e 's/^[^,]*,[^,]*,//' -e 's/,.*//'` +changequote([,])dnl +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/libsigsegv.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/libsigsegv.m4 new file mode 100644 index 00000000..f225b833 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/libsigsegv.m4 @@ -0,0 +1,16 @@ +# libsigsegv.m4 serial 4 +dnl Copyright (C) 2002-2003, 2008-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible, Sam Steingold. + +AC_DEFUN([gl_LIBSIGSEGV], +[ + AC_LIB_HAVE_LINKFLAGS([sigsegv], [], + [#include ], [sigsegv_deinstall_handler();], + [no, consider installing GNU libsigsegv]) + dnl Some other autoconf macros and clisp's configure use this variable. + gl_cv_lib_sigsegv="$ac_cv_libsigsegv" +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/libunistring-base.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/libunistring-base.m4 new file mode 100644 index 00000000..7c3f65ea --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/libunistring-base.m4 @@ -0,0 +1,196 @@ +# libunistring-base.m4 serial 8 +dnl Copyright (C) 2010-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Paolo Bonzini and Bruno Haible. + +dnl gl_LIBUNISTRING_MODULE([VERSION], [Module]) +dnl Declares that the source files of Module should be compiled, unless we +dnl are linking with libunistring and its version is >= the given VERSION. +dnl Defines an automake conditional LIBUNISTRING_COMPILE_$MODULE that is +dnl true if the source files of Module should be compiled. +dnl This macro is to be used for public libunistring API, not for +dnl undocumented API. +dnl +dnl You have to bump the VERSION argument to the next projected version +dnl number each time you make a change that affects the behaviour of the +dnl functions defined in Module (even if the sources of Module itself do not +dnl change). +dnl +dnl This macro invocation must not occur in macros that are AC_REQUIREd. + +AC_DEFUN([gl_LIBUNISTRING_MODULE], +[ + AC_REQUIRE([gl_LIBUNISTRING_LIB_PREPARE]) + dnl Use the variables HAVE_LIBUNISTRING, LIBUNISTRING_VERSION from + dnl gl_LIBUNISTRING_CORE if that macro has been run. + gl_CONDITIONAL(AS_TR_CPP([LIBUNISTRING_COMPILE_$2]), + [gl_LIBUNISTRING_VERSION_CMP([$1])]) +]) + +dnl gl_LIBUNISTRING_MODULE_WITH_VARIABLE([VERSION], [Module]) +dnl is like gl_LIBUNISTRING_MODULE([VERSION], [Module]), except that it also +dnl defines an AC_SUBSTed autoconf variable GNULIB_$MODULE_DLL_VARIABLE. +dnl What's the expansion of this autoconf variable? +dnl - When building libunistring, it expands to LIBUNISTRING_DLL_VARIABLE. +dnl (This is necessary because this token must be present in the .h files +dnl when the .h files get installed.) +dnl - When building gnulib or application code it expands to +dnl - LIBUNISTRING_DLL_VARIABLE by default, +dnl - empty if the automake conditional LIBUNISTRING_COMPILE_$MODULE +dnl evaluates to true. +dnl (This is necessary because when the conditional evaluates to false, +dnl the application code expects to use the declared variable from the +dnl installed libunistring; it's in this case that the +dnl LIBUNISTRING_DLL_VARIABLE macro from the installed +dnl must be used.) +dnl +dnl This macro invocation must not occur in macros that are AC_REQUIREd. + +AC_DEFUN([gl_LIBUNISTRING_MODULE_WITH_VARIABLE], +[ + gl_LIBUNISTRING_MODULE([$1], [$2]) + m4_ifndef([gl_IN_LIBUNISTRING], + [if test -z "${AS_TR_CPP([LIBUNISTRING_COMPILE_$2])_TRUE}"; then + GL_MODULE_INDICATOR_PREFIX[]_GNULIB_[]AS_TR_CPP([$2_DLL_VARIABLE])= + fi + ]) +]) + +dnl gl_LIBUNISTRING_LIBHEADER([VERSION], [HeaderFile]) +dnl Declares that HeaderFile should be created, unless we are linking +dnl with libunistring and its version is >= the given VERSION. +dnl HeaderFile should be relative to the lib directory and end in '.h'. +dnl Prepares for substituting LIBUNISTRING_HEADERFILE (to HeaderFile or empty). +dnl +dnl When we are linking with the already installed libunistring and its version +dnl is < VERSION, we create HeaderFile here, because we may compile functions +dnl (via gl_LIBUNISTRING_MODULE above) that are not contained in the installed +dnl version. +dnl When we are linking with the already installed libunistring and its version +dnl is > VERSION, we don't create HeaderFile here: it could cause compilation +dnl errors in other libunistring header files if some types are missing. +dnl +dnl You have to bump the VERSION argument to the next projected version +dnl number each time you make a non-comment change to the HeaderFile. + +AC_DEFUN([gl_LIBUNISTRING_LIBHEADER], +[ + AC_REQUIRE([gl_LIBUNISTRING_LIB_PREPARE]) + dnl Use the variables HAVE_LIBUNISTRING, LIBUNISTRING_VERSION from + dnl gl_LIBUNISTRING_CORE if that macro has been run. + if gl_LIBUNISTRING_VERSION_CMP([$1]); then + dnl It is OK to use a .h file in lib/ from within tests/, but not vice + dnl versa. + if test -z "$LIBUNISTRING_[]AS_TR_CPP([$2])"; then + LIBUNISTRING_[]AS_TR_CPP([$2])="${gl_source_base_prefix}$2" + fi + else + LIBUNISTRING_[]AS_TR_CPP([$2])= + fi + AC_SUBST([LIBUNISTRING_]AS_TR_CPP([$2])) +]) + +dnl Miscellaneous preparations/initializations. + +AC_DEFUN([gl_LIBUNISTRING_LIB_PREPARE], +[ + dnl Ensure that HAVE_LIBUNISTRING is fully determined at this point. + m4_ifdef([gl_LIBUNISTRING], [AC_REQUIRE([gl_LIBUNISTRING])]) + + AC_REQUIRE([AC_PROG_AWK]) + +dnl Sed expressions to extract the parts of a version number. +changequote(,) +gl_libunistring_sed_extract_major='/^[0-9]/{s/^\([0-9]*\).*/\1/p;q;} +i\ +0 +q +' +gl_libunistring_sed_extract_minor='/^[0-9][0-9]*[.][0-9]/{s/^[0-9]*[.]\([0-9]*\).*/\1/p;q;} +i\ +0 +q +' +gl_libunistring_sed_extract_subminor='/^[0-9][0-9]*[.][0-9][0-9]*[.][0-9]/{s/^[0-9]*[.][0-9]*[.]\([0-9]*\).*/\1/p;q;} +i\ +0 +q +' +changequote([,]) + + if test "$HAVE_LIBUNISTRING" = yes; then + LIBUNISTRING_VERSION_MAJOR=`echo "$LIBUNISTRING_VERSION" | sed -n -e "$gl_libunistring_sed_extract_major"` + LIBUNISTRING_VERSION_MINOR=`echo "$LIBUNISTRING_VERSION" | sed -n -e "$gl_libunistring_sed_extract_minor"` + LIBUNISTRING_VERSION_SUBMINOR=`echo "$LIBUNISTRING_VERSION" | sed -n -e "$gl_libunistring_sed_extract_subminor"` + fi + + dnl Determine whether from an installed libunistring + dnl is available. + m4_ifdef([gl_IN_LIBUNISTRING], + [dnl In libunistring, all .h files that declare variables need to + dnl #include . This references the file + dnl unistring/woe32dll.h in libunistring. + HAVE_UNISTRING_WOE32DLL_H=1 + ], + [dnl In gnulib or in applications, we need a #include + dnl if and only if an installed libunistring is available. + if test "$HAVE_LIBUNISTRING" = yes; then + AC_CHECK_HEADERS([unistring/woe32dll.h], + [HAVE_UNISTRING_WOE32DLL_H=1], + [HAVE_UNISTRING_WOE32DLL_H=0]) + else + HAVE_UNISTRING_WOE32DLL_H=0 + fi + ]) + AC_SUBST([HAVE_UNISTRING_WOE32DLL_H]) +]) + +dnl gl_LIBUNISTRING_VERSION_CMP([VERSION]) +dnl Expands to a shell statement that evaluates to true if LIBUNISTRING_VERSION +dnl is less than the VERSION argument. +AC_DEFUN([gl_LIBUNISTRING_VERSION_CMP], +[ { test "$HAVE_LIBUNISTRING" != yes \ + || { + dnl AS_LITERAL_IF exists and works fine since autoconf-2.59 at least. + AS_LITERAL_IF([$1], + [dnl This is the optimized variant, that assumes the argument is a literal: + m4_pushdef([requested_version_major], + [gl_LIBUNISTRING_ARG_OR_ZERO(m4_bpatsubst([$1], [^\([0-9]*\).*], [\1]), [])]) + m4_pushdef([requested_version_minor], + [gl_LIBUNISTRING_ARG_OR_ZERO(m4_bpatsubst([$1], [^[0-9]*[.]\([0-9]*\).*], [\1]), [$1])]) + m4_pushdef([requested_version_subminor], + [gl_LIBUNISTRING_ARG_OR_ZERO(m4_bpatsubst([$1], [^[0-9]*[.][0-9]*[.]\([0-9]*\).*], [\1]), [$1])]) + test $LIBUNISTRING_VERSION_MAJOR -lt requested_version_major \ + || { test $LIBUNISTRING_VERSION_MAJOR -eq requested_version_major \ + && { test $LIBUNISTRING_VERSION_MINOR -lt requested_version_minor \ + || { test $LIBUNISTRING_VERSION_MINOR -eq requested_version_minor \ + && test $LIBUNISTRING_VERSION_SUBMINOR -lt requested_version_subminor + } + } + } + m4_popdef([requested_version_subminor]) + m4_popdef([requested_version_minor]) + m4_popdef([requested_version_major]) + ], + [dnl This is the unoptimized variant: + requested_version_major=`echo '$1' | sed -n -e "$gl_libunistring_sed_extract_major"` + requested_version_minor=`echo '$1' | sed -n -e "$gl_libunistring_sed_extract_minor"` + requested_version_subminor=`echo '$1' | sed -n -e "$gl_libunistring_sed_extract_subminor"` + test $LIBUNISTRING_VERSION_MAJOR -lt $requested_version_major \ + || { test $LIBUNISTRING_VERSION_MAJOR -eq $requested_version_major \ + && { test $LIBUNISTRING_VERSION_MINOR -lt $requested_version_minor \ + || { test $LIBUNISTRING_VERSION_MINOR -eq $requested_version_minor \ + && test $LIBUNISTRING_VERSION_SUBMINOR -lt $requested_version_subminor + } + } + } + ]) + } + }]) + +dnl gl_LIBUNISTRING_ARG_OR_ZERO([ARG], [ORIG]) expands to ARG if it is not the +dnl same as ORIG, otherwise to 0. +m4_define([gl_LIBUNISTRING_ARG_OR_ZERO], [m4_if([$1], [$2], [0], [$1])]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/limits-h.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/limits-h.m4 new file mode 100644 index 00000000..18253283 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/limits-h.m4 @@ -0,0 +1,54 @@ +dnl Check whether limits.h has needed features. + +dnl Copyright 2016-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Paul Eggert. + +AC_DEFUN_ONCE([gl_LIMITS_H], +[ + gl_CHECK_NEXT_HEADERS([limits.h]) + + AC_CACHE_CHECK([whether limits.h has WORD_BIT, BOOL_WIDTH etc.], + [gl_cv_header_limits_width], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#ifndef __STDC_WANT_IEC_60559_BFP_EXT__ + #define __STDC_WANT_IEC_60559_BFP_EXT__ 1 + #endif + #include + long long llm = LLONG_MAX; + int wb = WORD_BIT; + int ullw = ULLONG_WIDTH; + int bw = BOOL_WIDTH; + int bm = BOOL_MAX; + int mblm = MB_LEN_MAX; + ]])], + [gl_cv_header_limits_width=yes], + [gl_cv_header_limits_width=no])]) + GL_GENERATE_LIMITS_H=true + AS_IF([test "$gl_cv_header_limits_width" = yes], + [AC_CACHE_CHECK([whether limits.h has SSIZE_MAX], + [gl_cv_header_limits_ssize_max], + [AC_COMPILE_IFELSE( + [AC_LANG_SOURCE( + [[#include + #ifndef SSIZE_MAX + #error "SSIZE_MAX is not defined" + #endif + ]])], + [gl_cv_header_limits_ssize_max=yes], + [gl_cv_header_limits_ssize_max=no])]) + if test "$gl_cv_header_limits_ssize_max" = yes; then + GL_GENERATE_LIMITS_H=false + fi]) +]) + +dnl Unconditionally enables the replacement of . +AC_DEFUN([gl_REPLACE_LIMITS_H], +[ + AC_REQUIRE([gl_LIMITS_H]) + GL_GENERATE_LIMITS_H=true +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/localcharset.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/localcharset.m4 new file mode 100644 index 00000000..abf07dc3 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/localcharset.m4 @@ -0,0 +1,11 @@ +# localcharset.m4 serial 8 +dnl Copyright (C) 2002, 2004, 2006, 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_LOCALCHARSET], +[ + dnl Prerequisites of lib/localcharset.c. + AC_REQUIRE([AM_LANGINFO_CODESET]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/locale-fr.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/locale-fr.m4 new file mode 100644 index 00000000..c9528562 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/locale-fr.m4 @@ -0,0 +1,300 @@ +# locale-fr.m4 serial 23 +dnl Copyright (C) 2003, 2005-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. + +dnl Determine the name of a french locale with traditional encoding. +AC_DEFUN_ONCE([gt_LOCALE_FR], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_REQUIRE([AM_LANGINFO_CODESET]) + AC_CACHE_CHECK([for a traditional french locale], [gt_cv_locale_fr], [ + AC_LANG_CONFTEST([AC_LANG_SOURCE([[ +#include +#include +#if HAVE_LANGINFO_CODESET +# include +#endif +#include +#include +struct tm t; +char buf[16]; +int main () { + /* On BeOS and Haiku, locales are not implemented in libc. Rather, libintl + imitates locale dependent behaviour by looking at the environment + variables, and all locales use the UTF-8 encoding. */ +#if defined __BEOS__ || defined __HAIKU__ + return 1; +#else + /* Check whether the given locale name is recognized by the system. */ +# if defined _WIN32 && !defined __CYGWIN__ + /* On native Windows, setlocale(category, "") looks at the system settings, + not at the environment variables. Also, when an encoding suffix such + as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE + category of the locale to "C". */ + if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL + || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0) + return 1; +# else + if (setlocale (LC_ALL, "") == NULL) return 1; +# endif + /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646". + On Mac OS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET) + is empty, and the behaviour of Tcl 8.4 in this locale is not useful. + On OpenBSD 4.0, when an unsupported locale is specified, setlocale() + succeeds but then nl_langinfo(CODESET) is "646". In this situation, + some unit tests fail. + On MirBSD 10, when an unsupported locale is specified, setlocale() + succeeds but then nl_langinfo(CODESET) is "UTF-8". */ +# if HAVE_LANGINFO_CODESET + { + const char *cs = nl_langinfo (CODESET); + if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0 + || strcmp (cs, "UTF-8") == 0) + return 1; + } +# endif +# ifdef __CYGWIN__ + /* On Cygwin, avoid locale names without encoding suffix, because the + locale_charset() function relies on the encoding suffix. Note that + LC_ALL is set on the command line. */ + if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1; +# endif + /* Check whether in the abbreviation of the second month, the second + character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is only + one byte long. This excludes the UTF-8 encoding. */ + t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4; + if (strftime (buf, sizeof (buf), "%b", &t) < 3 || buf[2] != 'v') return 1; +# if !defined __BIONIC__ /* Bionic libc's 'struct lconv' is just a dummy. */ + /* Check whether the decimal separator is a comma. + On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point + are nl_langinfo(RADIXCHAR) are both ".". */ + if (localeconv () ->decimal_point[0] != ',') return 1; +# endif + return 0; +#endif +} + ]])]) + if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then + case "$host_os" in + # Handle native Windows specially, because there setlocale() interprets + # "ar" as "Arabic" or "Arabic_Saudi Arabia.1256", + # "fr" or "fra" as "French" or "French_France.1252", + # "ge"(!) or "deu"(!) as "German" or "German_Germany.1252", + # "ja" as "Japanese" or "Japanese_Japan.932", + # and similar. + mingw* | windows*) + # Test for the native Windows locale name. + if (LC_ALL=French_France.1252 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then + gt_cv_locale_fr=French_France.1252 + else + # None found. + gt_cv_locale_fr=none + fi + ;; + *) + # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because + # otherwise on Mac OS X 10.3.5 the LC_TIME=C from the beginning of the + # configure script would override the LC_ALL setting. Likewise for + # LC_CTYPE, which is also set at the beginning of the configure script. + # Test for the usual locale name. + if (LC_ALL=fr_FR LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then + gt_cv_locale_fr=fr_FR + else + # Test for the locale name with explicit encoding suffix. + if (LC_ALL=fr_FR.ISO-8859-1 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then + gt_cv_locale_fr=fr_FR.ISO-8859-1 + else + # Test for the AIX, OSF/1, FreeBSD, NetBSD, OpenBSD locale name. + if (LC_ALL=fr_FR.ISO8859-1 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then + gt_cv_locale_fr=fr_FR.ISO8859-1 + else + # Test for the HP-UX locale name. + if (LC_ALL=fr_FR.iso88591 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then + gt_cv_locale_fr=fr_FR.iso88591 + else + # Test for the Solaris 7 locale name. + if (LC_ALL=fr LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then + gt_cv_locale_fr=fr + else + # None found. + gt_cv_locale_fr=none + fi + fi + fi + fi + fi + ;; + esac + fi + rm -fr conftest* + ]) + LOCALE_FR=$gt_cv_locale_fr + case $LOCALE_FR in #( + '' | *[[[:space:]\"\$\'*@<:@]]*) + dnl This locale name might cause trouble with sh or make. + AC_MSG_WARN([invalid locale "$LOCALE_FR"; assuming "none"]) + LOCALE_FR=none;; + esac + AC_SUBST([LOCALE_FR]) +]) + +dnl Determine the name of a french locale with UTF-8 encoding. +AC_DEFUN_ONCE([gt_LOCALE_FR_UTF8], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_REQUIRE([AM_LANGINFO_CODESET]) + AC_CACHE_CHECK([for a french Unicode locale], [gt_cv_locale_fr_utf8], [ + case "$host_os" in + *-musl* | midipix*) + dnl On musl libc, all kinds of ll_CC.UTF-8 locales exist, even without + dnl any locale file on disk. But they are effectively equivalent to the + dnl C.UTF-8 locale, except for locale categories (such as LC_MESSSAGES) + dnl for which localizations (.mo files) have been installed. + gt_cv_locale_fr_utf8=fr_FR.UTF-8 + ;; + *) + AC_LANG_CONFTEST([AC_LANG_SOURCE([[ +#include +#include +#if HAVE_LANGINFO_CODESET +# include +#endif +#include +#include +struct tm t; +char buf[16]; +int main () { + /* On BeOS and Haiku, locales are not implemented in libc. Rather, libintl + imitates locale dependent behaviour by looking at the environment + variables, and all locales use the UTF-8 encoding. */ +#if !(defined __BEOS__ || defined __HAIKU__) + /* Check whether the given locale name is recognized by the system. */ +# if defined _WIN32 && !defined __CYGWIN__ + /* On native Windows, setlocale(category, "") looks at the system settings, + not at the environment variables. Also, when an encoding suffix such + as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE + category of the locale to "C". */ + if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL + || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0) + return 1; +# else + if (setlocale (LC_ALL, "") == NULL) return 1; +# endif + /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646". + On Mac OS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET) + is empty, and the behaviour of Tcl 8.4 in this locale is not useful. + On OpenBSD 4.0, when an unsupported locale is specified, setlocale() + succeeds but then nl_langinfo(CODESET) is "646". In this situation, + some unit tests fail. */ +# if HAVE_LANGINFO_CODESET + { + const char *cs = nl_langinfo (CODESET); + if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0) + return 1; + } +# endif +# ifdef __CYGWIN__ + /* On Cygwin, avoid locale names without encoding suffix, because the + locale_charset() function relies on the encoding suffix. Note that + LC_ALL is set on the command line. */ + if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1; +# endif + /* Check whether in the abbreviation of the second month, the second + character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is + two bytes long, with UTF-8 encoding. */ + t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4; + if (strftime (buf, sizeof (buf), "%b", &t) < 4 + || buf[1] != (char) 0xc3 || buf[2] != (char) 0xa9 || buf[3] != 'v') + return 1; +#endif +#if !defined __BIONIC__ /* Bionic libc's 'struct lconv' is just a dummy. */ + /* Check whether the decimal separator is a comma. + On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point + are nl_langinfo(RADIXCHAR) are both ".". */ + if (localeconv () ->decimal_point[0] != ',') return 1; +#endif + return 0; +} + ]])]) + if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then + case "$host_os" in + # Handle native Windows specially, because there setlocale() interprets + # "ar" as "Arabic" or "Arabic_Saudi Arabia.1256", + # "fr" or "fra" as "French" or "French_France.1252", + # "ge"(!) or "deu"(!) as "German" or "German_Germany.1252", + # "ja" as "Japanese" or "Japanese_Japan.932", + # and similar. + mingw* | windows*) + # Test for the hypothetical native Windows locale name. + if (LC_ALL=French_France.65001 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then + gt_cv_locale_fr_utf8=French_France.65001 + else + # None found. + gt_cv_locale_fr_utf8=none + fi + ;; + *) + # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because + # otherwise on Mac OS X 10.3.5 the LC_TIME=C from the beginning of the + # configure script would override the LC_ALL setting. Likewise for + # LC_CTYPE, which is also set at the beginning of the configure script. + # Test for the usual locale name. + if (LC_ALL=fr_FR LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then + gt_cv_locale_fr_utf8=fr_FR + else + # Test for the locale name with explicit encoding suffix. + if (LC_ALL=fr_FR.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then + gt_cv_locale_fr_utf8=fr_FR.UTF-8 + else + # Test for the Solaris 7 locale name. + if (LC_ALL=fr.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then + gt_cv_locale_fr_utf8=fr.UTF-8 + else + # None found. + gt_cv_locale_fr_utf8=none + fi + fi + fi + ;; + esac + fi + rm -fr conftest* + ;; + esac + ]) + LOCALE_FR_UTF8=$gt_cv_locale_fr_utf8 + case $LOCALE_FR_UTF8 in #( + '' | *[[[:space:]\"\$\'*@<:@]]*) + dnl This locale name might cause trouble with sh or make. + AC_MSG_WARN([invalid locale "$LOCALE_FR_UTF8"; assuming "none"]) + LOCALE_FR_UTF8=none;; + esac + AC_SUBST([LOCALE_FR_UTF8]) + + dnl Users of $LOCALE_FR_UTF8 need to know which of the locale categories they + dnl can rely on. + case "$host_os" in + *-musl* | midipix*) + dnl On musl libc, locale categories other than LC_CTYPE and LC_MESSAGES + dnl are effectively unimplemented. + LC_COLLATE_IMPLEMENTED=false + LC_NUMERIC_IMPLEMENTED=false + LC_TIME_IMPLEMENTED=false + LC_MONETARY_IMPLEMENTED=false + ;; + *) + LC_COLLATE_IMPLEMENTED=true + LC_NUMERIC_IMPLEMENTED=true + LC_TIME_IMPLEMENTED=true + LC_MONETARY_IMPLEMENTED=true + ;; + esac + AC_SUBST([LC_COLLATE_IMPLEMENTED]) + AC_SUBST([LC_NUMERIC_IMPLEMENTED]) + AC_SUBST([LC_TIME_IMPLEMENTED]) + AC_SUBST([LC_MONETARY_IMPLEMENTED]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/locale-ja.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/locale-ja.m4 new file mode 100644 index 00000000..71a9863b --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/locale-ja.m4 @@ -0,0 +1,149 @@ +# locale-ja.m4 serial 18 +dnl Copyright (C) 2003, 2005-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. + +dnl Determine the name of a japanese locale with EUC-JP encoding. +AC_DEFUN_ONCE([gt_LOCALE_JA], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_REQUIRE([AM_LANGINFO_CODESET]) + AC_CACHE_CHECK([for a traditional japanese locale], [gt_cv_locale_ja], [ + AC_LANG_CONFTEST([AC_LANG_SOURCE([[ +#include +#include +#if HAVE_LANGINFO_CODESET +# include +#endif +#include +#include +struct tm t; +char buf[16]; +int main () +{ + /* On BeOS and Haiku, locales are not implemented in libc. Rather, libintl + imitates locale dependent behaviour by looking at the environment + variables, and all locales use the UTF-8 encoding. */ +#if defined __BEOS__ || defined __HAIKU__ + return 1; +#else + /* Check whether the given locale name is recognized by the system. */ +# if defined _WIN32 && !defined __CYGWIN__ + /* On native Windows, setlocale(category, "") looks at the system settings, + not at the environment variables. Also, when an encoding suffix such + as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE + category of the locale to "C". */ + if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL + || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0) + return 1; +# else + if (setlocale (LC_ALL, "") == NULL) return 1; +# endif + /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646". + On Mac OS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET) + is empty, and the behaviour of Tcl 8.4 in this locale is not useful. + On OpenBSD 4.0, when an unsupported locale is specified, setlocale() + succeeds but then nl_langinfo(CODESET) is "646". In this situation, + some unit tests fail. + On MirBSD 10, when an unsupported locale is specified, setlocale() + succeeds but then nl_langinfo(CODESET) is "UTF-8". */ +# if HAVE_LANGINFO_CODESET + { + const char *cs = nl_langinfo (CODESET); + if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0 + || strcmp (cs, "UTF-8") == 0) + return 1; + } +# endif +# ifdef __CYGWIN__ + /* On Cygwin, avoid locale names without encoding suffix, because the + locale_charset() function relies on the encoding suffix. Note that + LC_ALL is set on the command line. */ + if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1; +# endif + /* Check whether MB_CUR_MAX is > 1. This excludes the dysfunctional locales + on Cygwin 1.5.x. */ + if (MB_CUR_MAX == 1) + return 1; + /* Check whether in a month name, no byte in the range 0x80..0x9F occurs. + This excludes the UTF-8 encoding (except on MirBSD). */ + { + const char *p; + t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4; + if (strftime (buf, sizeof (buf), "%B", &t) < 2) return 1; + for (p = buf; *p != '\0'; p++) + if ((unsigned char) *p >= 0x80 && (unsigned char) *p < 0xa0) + return 1; + } + return 0; +#endif +} + ]])]) + if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then + case "$host_os" in + # Handle native Windows specially, because there setlocale() interprets + # "ar" as "Arabic" or "Arabic_Saudi Arabia.1256", + # "fr" or "fra" as "French" or "French_France.1252", + # "ge"(!) or "deu"(!) as "German" or "German_Germany.1252", + # "ja" as "Japanese" or "Japanese_Japan.932", + # and similar. + mingw* | windows*) + # Note that on native Windows, the Japanese locale is + # Japanese_Japan.932, and CP932 is very different from EUC-JP, so we + # cannot use it here. + gt_cv_locale_ja=none + ;; + *) + # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because + # otherwise on Mac OS X 10.3.5 the LC_TIME=C from the beginning of the + # configure script would override the LC_ALL setting. Likewise for + # LC_CTYPE, which is also set at the beginning of the configure script. + # Test for the AIX locale name. + if (LC_ALL=ja_JP LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then + gt_cv_locale_ja=ja_JP + else + # Test for the locale name with explicit encoding suffix. + if (LC_ALL=ja_JP.EUC-JP LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then + gt_cv_locale_ja=ja_JP.EUC-JP + else + # Test for the HP-UX, OSF/1, NetBSD locale name. + if (LC_ALL=ja_JP.eucJP LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then + gt_cv_locale_ja=ja_JP.eucJP + else + # Test for the IRIX, FreeBSD locale name. + if (LC_ALL=ja_JP.EUC LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then + gt_cv_locale_ja=ja_JP.EUC + else + # Test for the Solaris 7 locale name. + if (LC_ALL=ja LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then + gt_cv_locale_ja=ja + else + # Special test for NetBSD 1.6. + if test -f /usr/share/locale/ja_JP.eucJP/LC_CTYPE; then + gt_cv_locale_ja=ja_JP.eucJP + else + # None found. + gt_cv_locale_ja=none + fi + fi + fi + fi + fi + fi + ;; + esac + fi + rm -fr conftest* + ]) + LOCALE_JA=$gt_cv_locale_ja + case $LOCALE_JA in #( + '' | *[[[:space:]\"\$\'*@<:@]]*) + dnl This locale name might cause trouble with sh or make. + AC_MSG_WARN([invalid locale "$LOCALE_JA"; assuming "none"]) + LOCALE_JA=none;; + esac + AC_SUBST([LOCALE_JA]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/locale-tr.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/locale-tr.m4 new file mode 100644 index 00000000..b68e429a --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/locale-tr.m4 @@ -0,0 +1,132 @@ +# locale-tr.m4 serial 15 +dnl Copyright (C) 2003, 2005-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. + +dnl Determine the name of a turkish locale with UTF-8 encoding. +AC_DEFUN_ONCE([gt_LOCALE_TR_UTF8], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_REQUIRE([AM_LANGINFO_CODESET]) + AC_CACHE_CHECK([for a turkish Unicode locale], [gt_cv_locale_tr_utf8], [ + AC_LANG_CONFTEST([AC_LANG_SOURCE([[ +#include +#include +#if HAVE_LANGINFO_CODESET +# include +#endif +#include +#include +#include +struct tm t; +char buf[16]; +int main () { + /* On BeOS, locales are not implemented in libc. Rather, libintl + imitates locale dependent behaviour by looking at the environment + variables, and all locales use the UTF-8 encoding. But BeOS does not + implement the Turkish upper-/lowercase mappings. Therefore, let this + program return 1 on BeOS. */ + /* Check whether the given locale name is recognized by the system. */ +#if defined _WIN32 && !defined __CYGWIN__ + /* On native Windows, setlocale(category, "") looks at the system settings, + not at the environment variables. Also, when an encoding suffix such + as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE + category of the locale to "C". */ + if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL + || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0) + return 1; +#else + if (setlocale (LC_ALL, "") == NULL) return 1; +#endif + /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646". + On Mac OS X 10.3.5 (Darwin 7.5) in the tr_TR locale, nl_langinfo(CODESET) + is empty, and the behaviour of Tcl 8.4 in this locale is not useful. + On OpenBSD 4.0, when an unsupported locale is specified, setlocale() + succeeds but then nl_langinfo(CODESET) is "646". In this situation, + some unit tests fail. */ +#if HAVE_LANGINFO_CODESET + { + const char *cs = nl_langinfo (CODESET); + if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0) + return 1; + } +#endif +#ifdef __CYGWIN__ + /* On Cygwin, avoid locale names without encoding suffix, because the + locale_charset() function relies on the encoding suffix. Note that + LC_ALL is set on the command line. */ + if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1; +#endif + /* Check whether in the abbreviation of the eighth month, the second + character (should be U+011F: LATIN SMALL LETTER G WITH BREVE) is + two bytes long, with UTF-8 encoding. */ + t.tm_year = 1992 - 1900; t.tm_mon = 8 - 1; t.tm_mday = 19; + if (strftime (buf, sizeof (buf), "%b", &t) < 4 + || buf[1] != (char) 0xc4 || buf[2] != (char) 0x9f) + return 1; + /* Check whether the upper-/lowercase mappings are as expected for + Turkish. */ + if (towupper ('i') != 0x0130 || towlower (0x0130) != 'i' + || towupper(0x0131) != 'I' || towlower ('I') != 0x0131) + return 1; + return 0; +} + ]])]) + if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then + case "$host_os" in + # Handle native Windows specially, because there setlocale() interprets + # "ar" as "Arabic" or "Arabic_Saudi Arabia.1256", + # "fr" or "fra" as "French" or "French_France.1252", + # "ge"(!) or "deu"(!) as "German" or "German_Germany.1252", + # "ja" as "Japanese" or "Japanese_Japan.932", + # and similar. + mingw* | windows*) + # Test for the hypothetical native Windows locale name. + if (LC_ALL=Turkish_Turkey.65001 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then + gt_cv_locale_tr_utf8=Turkish_Turkey.65001 + else + # None found. + gt_cv_locale_tr_utf8=none + fi + ;; + *) + # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because + # otherwise on Mac OS X 10.3.5 the LC_TIME=C from the beginning of the + # configure script would override the LC_ALL setting. Likewise for + # LC_CTYPE, which is also set at the beginning of the configure script. + # Test for the usual locale name. + if (LC_ALL=tr_TR LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then + gt_cv_locale_tr_utf8=tr_TR + else + # Test for the locale name with explicit encoding suffix. + if (LC_ALL=tr_TR.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then + gt_cv_locale_tr_utf8=tr_TR.UTF-8 + else + # Test for the Solaris 7 locale name. + if (LC_ALL=tr.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then + gt_cv_locale_tr_utf8=tr.UTF-8 + else + # None found. + gt_cv_locale_tr_utf8=none + fi + fi + fi + ;; + esac + else + gt_cv_locale_tr_utf8=none + fi + rm -fr conftest* + ]) + LOCALE_TR_UTF8=$gt_cv_locale_tr_utf8 + case $LOCALE_TR_UTF8 in #( + '' | *[[[:space:]\"\$\'*@<:@]]*) + dnl This locale name might cause trouble with sh or make. + AC_MSG_WARN([invalid locale "$LOCALE_TR_UTF8"; assuming "none"]) + LOCALE_TR_UTF8=none;; + esac + AC_SUBST([LOCALE_TR_UTF8]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/locale-zh.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/locale-zh.m4 new file mode 100644 index 00000000..f1a58c63 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/locale-zh.m4 @@ -0,0 +1,143 @@ +# locale-zh.m4 serial 18 +dnl Copyright (C) 2003, 2005-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. + +dnl Determine the name of a chinese locale with GB18030 encoding. +AC_DEFUN_ONCE([gt_LOCALE_ZH_CN], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_REQUIRE([AM_LANGINFO_CODESET]) + AC_CACHE_CHECK([for a transitional chinese locale], [gt_cv_locale_zh_CN], [ + AC_LANG_CONFTEST([AC_LANG_SOURCE([[ +#include +#include +#include +#if HAVE_LANGINFO_CODESET +# include +#endif +#include +#include +struct tm t; +char buf[16]; +int main () +{ + /* On BeOS and Haiku, locales are not implemented in libc. Rather, libintl + imitates locale dependent behaviour by looking at the environment + variables, and all locales use the UTF-8 encoding. */ +#if defined __BEOS__ || defined __HAIKU__ + return 1; +#else + /* Check whether the given locale name is recognized by the system. */ +# if defined _WIN32 && !defined __CYGWIN__ + /* On native Windows, setlocale(category, "") looks at the system settings, + not at the environment variables. Also, when an encoding suffix such + as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE + category of the locale to "C". */ + if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL + || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0) + return 1; +# else + if (setlocale (LC_ALL, "") == NULL) return 1; +# endif + /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646". + On Mac OS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET) + is empty, and the behaviour of Tcl 8.4 in this locale is not useful. + On OpenBSD 4.0, when an unsupported locale is specified, setlocale() + succeeds but then nl_langinfo(CODESET) is "646". In this situation, + some unit tests fail. + On MirBSD 10, when an unsupported locale is specified, setlocale() + succeeds but then nl_langinfo(CODESET) is "UTF-8". */ +# if HAVE_LANGINFO_CODESET + { + const char *cs = nl_langinfo (CODESET); + if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0 + || strcmp (cs, "UTF-8") == 0) + return 1; + } +# endif +# ifdef __CYGWIN__ + /* On Cygwin, avoid locale names without encoding suffix, because the + locale_charset() function relies on the encoding suffix. Note that + LC_ALL is set on the command line. */ + if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1; +# endif + /* Check whether in a month name, no byte in the range 0x80..0x9F occurs. + This excludes the UTF-8 encoding (except on MirBSD). */ + { + const char *p; + t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4; + if (strftime (buf, sizeof (buf), "%B", &t) < 2) return 1; + for (p = buf; *p != '\0'; p++) + if ((unsigned char) *p >= 0x80 && (unsigned char) *p < 0xa0) + return 1; + } + /* Check whether a typical GB18030 multibyte sequence is recognized as a + single wide character. This excludes the GB2312 and GBK encodings. */ + if (mblen ("\203\062\332\066", 5) != 4) + return 1; + return 0; +#endif +} + ]])]) + if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then + case "$host_os" in + # Handle native Windows specially, because there setlocale() interprets + # "ar" as "Arabic" or "Arabic_Saudi Arabia.1256", + # "fr" or "fra" as "French" or "French_France.1252", + # "ge"(!) or "deu"(!) as "German" or "German_Germany.1252", + # "ja" as "Japanese" or "Japanese_Japan.932", + # and similar. + mingw* | windows*) + # Test for the hypothetical native Windows locale name. + if (LC_ALL=Chinese_China.54936 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then + gt_cv_locale_zh_CN=Chinese_China.54936 + else + # None found. + gt_cv_locale_zh_CN=none + fi + ;; + solaris2.8) + # On Solaris 8, the locales zh_CN.GB18030, zh_CN.GBK, zh.GBK are + # broken. One witness is the test case in gl_MBRTOWC_SANITYCHECK. + # Another witness is that "LC_ALL=zh_CN.GB18030 bash -c true" dumps core. + gt_cv_locale_zh_CN=none + ;; + *) + # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because + # otherwise on Mac OS X 10.3.5 the LC_TIME=C from the beginning of the + # configure script would override the LC_ALL setting. Likewise for + # LC_CTYPE, which is also set at the beginning of the configure script. + # Test for the locale name without encoding suffix. + if (LC_ALL=zh_CN LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then + gt_cv_locale_zh_CN=zh_CN + else + # Test for the locale name with explicit encoding suffix. + if (LC_ALL=zh_CN.GB18030 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then + gt_cv_locale_zh_CN=zh_CN.GB18030 + else + # None found. + gt_cv_locale_zh_CN=none + fi + fi + ;; + esac + else + # If there was a link error, due to mblen(), the system is so old that + # it certainly doesn't have a chinese locale. + gt_cv_locale_zh_CN=none + fi + rm -fr conftest* + ]) + LOCALE_ZH_CN=$gt_cv_locale_zh_CN + case $LOCALE_ZH_CN in #( + '' | *[[[:space:]\"\$\'*@<:@]]*) + dnl This locale name might cause trouble with sh or make. + AC_MSG_WARN([invalid locale "$LOCALE_ZH_CN"; assuming "none"]) + LOCALE_ZH_CN=none;; + esac + AC_SUBST([LOCALE_ZH_CN]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/locale_h.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/locale_h.m4 new file mode 100644 index 00000000..4e8e3adf --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/locale_h.m4 @@ -0,0 +1,176 @@ +# locale_h.m4 serial 30 +dnl Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN_ONCE([gl_LOCALE_H], +[ + dnl Ensure to expand the default settings once only, before all statements + dnl that occur in other macros. + AC_REQUIRE([gl_LOCALE_H_DEFAULTS]) + + dnl Persuade glibc to define locale_t and the int_p_*, int_n_* + dnl members of 'struct lconv'. + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + + dnl If is replaced, then must also be replaced. + AC_REQUIRE([gl_STDDEF_H]) + + AC_REQUIRE([gl_LOCALE_T]) + + dnl Solaris 11.0 defines the int_p_*, int_n_* members of 'struct lconv' + dnl only if _LCONV_C99 is defined. + AC_REQUIRE([AC_CANONICAL_HOST]) + case "$host_os" in + solaris*) + AC_DEFINE([_LCONV_C99], [1], [Define to 1 on Solaris.]) + ;; + esac + + AC_CACHE_CHECK([whether locale.h conforms to POSIX:2001], + [gl_cv_header_locale_h_posix2001], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include + int x = LC_MESSAGES; + int y = sizeof (((struct lconv *) 0)->decimal_point);]], + [[]])], + [gl_cv_header_locale_h_posix2001=yes], + [gl_cv_header_locale_h_posix2001=no])]) + + dnl Check whether 'struct lconv' is complete. + dnl Bionic libc's 'struct lconv' is just a dummy. + dnl On OpenBSD 4.9, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 9, Cygwin 1.5.x, + dnl mingw, MSVC 9, it lacks the int_p_* and int_n_* members. + AC_CACHE_CHECK([whether struct lconv is properly defined], + [gl_cv_sys_struct_lconv_ok], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include + struct lconv l; + int x = sizeof (l.decimal_point); + int y = sizeof (l.int_p_cs_precedes);]], + [[]])], + [gl_cv_sys_struct_lconv_ok=yes], + [gl_cv_sys_struct_lconv_ok=no]) + ]) + if test $gl_cv_sys_struct_lconv_ok = no; then + dnl On native Windows with MSVC, merely define these member names as macros. + dnl This avoids trouble in C++ mode. + case "$host_os" in + windows*-msvc*) + ;; + mingw* | windows*) + AC_EGREP_CPP([Special], [ +#ifdef _MSC_VER + Special +#endif + ], + [], + [REPLACE_STRUCT_LCONV=1]) + ;; + *) REPLACE_STRUCT_LCONV=1 ;; + esac + fi + + dnl is always overridden, because of GNULIB_POSIXCHECK. + gl_NEXT_HEADERS([locale.h]) + + dnl Check for declarations of anything we want to poison if the + dnl corresponding gnulib module is not in use. + gl_WARN_ON_USE_PREPARE([[#include +/* Some systems provide declarations in a non-standard header. */ +#if HAVE_XLOCALE_H +# include +#endif + ]], + [setlocale newlocale duplocale freelocale]) +]) + +dnl Checks to determine whether the system has the locale_t type, +dnl and how to obtain it. +AC_DEFUN([gl_LOCALE_T], +[ + dnl Persuade glibc and Solaris to define locale_t. + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + + dnl Check whether use of locale_t requires inclusion of , + dnl e.g. on Mac OS X 10.5. If does not define locale_t by + dnl itself, we assume that will do so. + AC_CACHE_CHECK([whether locale.h defines locale_t], + [gl_cv_header_locale_has_locale_t], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include + locale_t x;]], + [[]])], + [gl_cv_header_locale_has_locale_t=yes], + [gl_cv_header_locale_has_locale_t=no]) + ]) + + dnl Check for . + AC_CHECK_HEADERS_ONCE([xlocale.h]) + if test $ac_cv_header_xlocale_h = yes; then + HAVE_XLOCALE_H=1 + if test $gl_cv_header_locale_has_locale_t = yes; then + gl_cv_header_locale_h_needs_xlocale_h=no + else + gl_cv_header_locale_h_needs_xlocale_h=yes + fi + HAVE_LOCALE_T=1 + else + HAVE_XLOCALE_H=0 + gl_cv_header_locale_h_needs_xlocale_h=no + if test $gl_cv_header_locale_has_locale_t = yes; then + HAVE_LOCALE_T=1 + else + HAVE_LOCALE_T=0 + fi + fi + AC_SUBST([HAVE_XLOCALE_H]) +]) + +# gl_LOCALE_MODULE_INDICATOR([modulename]) +# sets the shell variable that indicates the presence of the given module +# to a C preprocessor expression that will evaluate to 1. +# This macro invocation must not occur in macros that are AC_REQUIREd. +AC_DEFUN([gl_LOCALE_MODULE_INDICATOR], +[ + dnl Ensure to expand the default settings once only. + gl_LOCALE_H_REQUIRE_DEFAULTS + gl_MODULE_INDICATOR_SET_VARIABLE([$1]) + dnl Define it also as a C macro, for the benefit of the unit tests. + gl_MODULE_INDICATOR_FOR_TESTS([$1]) +]) + +# Initializes the default values for AC_SUBSTed shell variables. +# This macro must not be AC_REQUIREd. It must only be invoked, and only +# outside of macros or in macros that are not AC_REQUIREd. +AC_DEFUN([gl_LOCALE_H_REQUIRE_DEFAULTS], +[ + m4_defun(GL_MODULE_INDICATOR_PREFIX[_LOCALE_H_MODULE_INDICATOR_DEFAULTS], [ + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOCALECONV]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SETLOCALE]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SETLOCALE_NULL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_DUPLOCALE]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOCALENAME]) + ]) + m4_require(GL_MODULE_INDICATOR_PREFIX[_LOCALE_H_MODULE_INDICATOR_DEFAULTS]) + AC_REQUIRE([gl_LOCALE_H_DEFAULTS]) +]) + +AC_DEFUN([gl_LOCALE_H_DEFAULTS], +[ + dnl Assume proper GNU behavior unless another module says otherwise. + HAVE_NEWLOCALE=1; AC_SUBST([HAVE_NEWLOCALE]) + HAVE_DUPLOCALE=1; AC_SUBST([HAVE_DUPLOCALE]) + HAVE_FREELOCALE=1; AC_SUBST([HAVE_FREELOCALE]) + REPLACE_LOCALECONV=0; AC_SUBST([REPLACE_LOCALECONV]) + REPLACE_SETLOCALE=0; AC_SUBST([REPLACE_SETLOCALE]) + REPLACE_NEWLOCALE=0; AC_SUBST([REPLACE_NEWLOCALE]) + REPLACE_DUPLOCALE=0; AC_SUBST([REPLACE_DUPLOCALE]) + REPLACE_FREELOCALE=0; AC_SUBST([REPLACE_FREELOCALE]) + REPLACE_STRUCT_LCONV=0; AC_SUBST([REPLACE_STRUCT_LCONV]) + LOCALENAME_ENHANCE_LOCALE_FUNCS=0; AC_SUBST([LOCALENAME_ENHANCE_LOCALE_FUNCS]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/localeconv.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/localeconv.m4 new file mode 100644 index 00000000..351b4e1b --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/localeconv.m4 @@ -0,0 +1,59 @@ +# localeconv.m4 serial 3 +dnl Copyright (C) 2012-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_LOCALECONV], +[ + AC_REQUIRE([gl_LOCALE_H_DEFAULTS]) + AC_REQUIRE([gl_LOCALE_H]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + + if test $REPLACE_STRUCT_LCONV = 1; then + REPLACE_LOCALECONV=1 + fi + if test $REPLACE_LOCALECONV = 0; then + dnl Test whether fields of type 'char' are filled correctly. + dnl This test fails on mingw 5.0.3. + AC_CACHE_CHECK([whether localeconv works], + [gl_cv_func_localeconv_works], + [AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ + #include + #include + int main () + { + struct lconv *l = localeconv (); + return l->frac_digits != CHAR_MAX && l->frac_digits < 0; + } + ]])], + [gl_cv_func_localeconv_works=yes], + [gl_cv_func_localeconv_works=no], + [case "$host_os" in + # Guess yes on glibc systems. + *-gnu* | gnu*) gl_cv_func_localeconv_works="guessing yes" ;; + # Guess yes on musl systems. + *-musl* | midipix*) gl_cv_func_localeconv_works="guessing yes" ;; + # Guess no on native Windows. + mingw* | windows*) gl_cv_func_localeconv_works="guessing no" ;; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_localeconv_works="$gl_cross_guess_normal" ;; + esac + ]) + ]) + case "$gl_cv_func_localeconv_works" in + *yes) ;; + *) REPLACE_LOCALECONV=1 ;; + esac + fi +]) + +# Prerequisites of lib/localeconv.c. +AC_DEFUN([gl_PREREQ_LOCALECONV], +[ + AC_CHECK_MEMBERS([struct lconv.decimal_point], [], [], + [[#include ]]) + AC_CHECK_MEMBERS([struct lconv.int_p_cs_precedes], [], [], + [[#include ]]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/lock.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/lock.m4 new file mode 100644 index 00000000..2ca3bf2f --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/lock.m4 @@ -0,0 +1,47 @@ +# lock.m4 serial 14 +dnl Copyright (C) 2005-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. + +AC_DEFUN([gl_LOCK], +[ + AC_REQUIRE([gl_THREADLIB]) + if test "$gl_threads_api" = posix; then + # OSF/1 4.0 and Mac OS X 10.1 lack the pthread_rwlock_t type and the + # pthread_rwlock_* functions. + has_rwlock=false + AC_CHECK_TYPE([pthread_rwlock_t], + [has_rwlock=true + AC_DEFINE([HAVE_PTHREAD_RWLOCK], [1], + [Define if the POSIX multithreading library has read/write locks.])], + [], + [#include ]) + if $has_rwlock; then + gl_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER + fi + # glibc defines PTHREAD_MUTEX_RECURSIVE as enum, not as a macro. + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM( + [[#include ]], + [[ +#if __FreeBSD__ == 4 +error "No, in FreeBSD 4.0 recursive mutexes actually don't work." +#elif (defined __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ \ + && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1070) +error "No, in Mac OS X < 10.7 recursive mutexes actually don't work." +#else +int x = (int)PTHREAD_MUTEX_RECURSIVE; +return !x; +#endif + ]])], + [AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE], [1], + [Define if the defines PTHREAD_MUTEX_RECURSIVE.])]) + fi + gl_PREREQ_LOCK +]) + +# Prerequisites of lib/glthread/lock.c. +AC_DEFUN([gl_PREREQ_LOCK], [:]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/lstat.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/lstat.m4 new file mode 100644 index 00000000..48cc8653 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/lstat.m4 @@ -0,0 +1,82 @@ +# serial 36 + +# Copyright (C) 1997-2001, 2003-2024 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +dnl From Jim Meyering. + +AC_DEFUN([gl_FUNC_LSTAT], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS]) + dnl If lstat does not exist, the replacement does + dnl "#define lstat stat", and lstat.c is a no-op. + AC_CHECK_FUNCS_ONCE([lstat]) + if test $ac_cv_func_lstat = yes; then + AC_REQUIRE([gl_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK]) + case $host_os,$gl_cv_func_lstat_dereferences_slashed_symlink in + darwin* | solaris* | *no) + REPLACE_LSTAT=1 + ;; + esac + else + HAVE_LSTAT=0 + fi +]) + +# Prerequisites of lib/lstat.c. +AC_DEFUN([gl_PREREQ_LSTAT], [:]) + +AC_DEFUN([gl_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK], +[ + dnl We don't use AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK any more, because it + dnl is no longer maintained in Autoconf and because it invokes AC_LIBOBJ. + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether lstat correctly handles trailing slash], + [gl_cv_func_lstat_dereferences_slashed_symlink], + [rm -f conftest.sym conftest.file + echo >conftest.file + AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [AC_INCLUDES_DEFAULT], + [[struct stat sbuf; + if (symlink ("conftest.file", "conftest.sym") != 0) + return 1; + /* Linux will dereference the symlink and fail, as required by + POSIX. That is better in the sense that it means we will not + have to compile and use the lstat wrapper. */ + return lstat ("conftest.sym/", &sbuf) == 0; + ]])], + [gl_cv_func_lstat_dereferences_slashed_symlink=yes], + [gl_cv_func_lstat_dereferences_slashed_symlink=no], + [case "$host_os" in + linux-* | linux) + # Guess yes on Linux systems. + gl_cv_func_lstat_dereferences_slashed_symlink="guessing yes" ;; + midipix*) + # Guess yes on systems that emulate the Linux system calls. + gl_cv_func_lstat_dereferences_slashed_symlink="guessing yes" ;; + *-gnu* | gnu*) + # Guess yes on glibc systems. + gl_cv_func_lstat_dereferences_slashed_symlink="guessing yes" ;; + mingw* | windows*) + # Guess no on native Windows. + gl_cv_func_lstat_dereferences_slashed_symlink="guessing no" ;; + *) + # If we don't know, obey --enable-cross-guesses. + gl_cv_func_lstat_dereferences_slashed_symlink="$gl_cross_guess_normal" ;; + esac + ]) + rm -f conftest.sym conftest.file + ]) + case "$gl_cv_func_lstat_dereferences_slashed_symlink" in + *yes) + AC_DEFINE_UNQUOTED([LSTAT_FOLLOWS_SLASHED_SYMLINK], [1], + [Define to 1 if 'lstat' dereferences a symlink specified + with a trailing slash.]) + ;; + esac +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/malloc.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/malloc.m4 new file mode 100644 index 00000000..635d6726 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/malloc.m4 @@ -0,0 +1,176 @@ +# malloc.m4 serial 31 +dnl Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +# This is adapted with modifications from upstream Autoconf here: +# https://git.savannah.gnu.org/cgit/autoconf.git/tree/lib/autoconf/functions.m4?id=v2.70#n949 +AC_DEFUN([_AC_FUNC_MALLOC_IF], +[ + AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles + AC_CACHE_CHECK([whether malloc (0) returns nonnull], + [ac_cv_func_malloc_0_nonnull], + [AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [[#include + ]], + [[void *p = malloc (0); + void * volatile vp = p; + int result = !vp; + free (p); + return result;]]) + ], + [ac_cv_func_malloc_0_nonnull=yes], + [ac_cv_func_malloc_0_nonnull=no], + [case "$host_os" in + # Guess yes on platforms where we know the result. + *-gnu* | freebsd* | netbsd* | openbsd* | bitrig* \ + | gnu* | *-musl* | midipix* | midnightbsd* \ + | hpux* | solaris* | cygwin* | mingw* | windows* | msys* ) + ac_cv_func_malloc_0_nonnull="guessing yes" ;; + # If we don't know, obey --enable-cross-guesses. + *) ac_cv_func_malloc_0_nonnull="$gl_cross_guess_normal" ;; + esac + ]) + ]) + AS_CASE([$ac_cv_func_malloc_0_nonnull], [*yes], [$1], [$2]) +])# _AC_FUNC_MALLOC_IF + +# gl_FUNC_MALLOC_GNU +# ------------------ +# Replace malloc if it is not compatible with GNU libc. +AC_DEFUN([gl_FUNC_MALLOC_GNU], +[ + AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) + AC_REQUIRE([gl_FUNC_MALLOC_POSIX]) + REPLACE_MALLOC_FOR_MALLOC_GNU="$REPLACE_MALLOC_FOR_MALLOC_POSIX" + if test $REPLACE_MALLOC_FOR_MALLOC_GNU = 0; then + _AC_FUNC_MALLOC_IF([], [REPLACE_MALLOC_FOR_MALLOC_GNU=1]) + fi +]) + +# gl_FUNC_MALLOC_PTRDIFF +# ---------------------- +# Test whether malloc (N) reliably fails when N exceeds PTRDIFF_MAX, +# and replace malloc otherwise. +AC_DEFUN([gl_FUNC_MALLOC_PTRDIFF], +[ + AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) + AC_REQUIRE([gl_CHECK_MALLOC_PTRDIFF]) + test "$gl_cv_malloc_ptrdiff" = yes || REPLACE_MALLOC_FOR_MALLOC_POSIX=1 +]) + +# Test whether malloc, realloc, calloc refuse to create objects +# larger than what can be expressed in ptrdiff_t. +# Set gl_cv_func_malloc_gnu to yes or no accordingly. +AC_DEFUN([gl_CHECK_MALLOC_PTRDIFF], +[ + AC_CACHE_CHECK([whether malloc is ptrdiff_t safe], + [gl_cv_malloc_ptrdiff], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include + ]], + [[/* 64-bit ptrdiff_t is so wide that no practical platform + can exceed it. */ + #define WIDE_PTRDIFF (PTRDIFF_MAX >> 31 >> 31 != 0) + + /* On rare machines where size_t fits in ptrdiff_t there + is no problem. */ + #define NARROW_SIZE (SIZE_MAX <= PTRDIFF_MAX) + + /* glibc 2.30 and later malloc refuses to exceed ptrdiff_t + bounds even on 32-bit platforms. We don't know which + non-glibc systems are safe. */ + #define KNOWN_SAFE (2 < __GLIBC__ + (30 <= __GLIBC_MINOR__)) + + #if WIDE_PTRDIFF || NARROW_SIZE || KNOWN_SAFE + return 0; + #else + #error "malloc might not be ptrdiff_t safe" + syntax error + #endif + ]])], + [gl_cv_malloc_ptrdiff=yes], + [gl_cv_malloc_ptrdiff=no]) + ]) +]) + +# gl_FUNC_MALLOC_POSIX +# -------------------- +# Test whether 'malloc' is POSIX compliant (sets errno to ENOMEM when it +# fails, and doesn't mess up with ptrdiff_t overflow), and replace +# malloc if it is not. +AC_DEFUN([gl_FUNC_MALLOC_POSIX], +[ + AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) + AC_REQUIRE([gl_FUNC_MALLOC_PTRDIFF]) + AC_REQUIRE([gl_CHECK_MALLOC_POSIX]) + if test "$gl_cv_func_malloc_posix" = yes; then + AC_DEFINE([HAVE_MALLOC_POSIX], [1], + [Define if malloc, realloc, and calloc set errno on allocation failure.]) + else + REPLACE_MALLOC_FOR_MALLOC_POSIX=1 + fi +]) + +# Test whether malloc, realloc, calloc set errno to ENOMEM on failure. +# Set gl_cv_func_malloc_posix to yes or no accordingly. +AC_DEFUN([gl_CHECK_MALLOC_POSIX], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_CACHE_CHECK([whether malloc, realloc, calloc set errno on failure], + [gl_cv_func_malloc_posix], + [ + dnl It is too dangerous to try to allocate a large amount of memory: + dnl some systems go to their knees when you do that. So assume that + dnl all Unix implementations of the function set errno on failure, + dnl except on those platforms where we have seen 'test-malloc-gnu', + dnl 'test-realloc-gnu', 'test-calloc-gnu' fail. + case "$host_os" in + mingw* | windows*) + gl_cv_func_malloc_posix=no ;; + irix* | solaris*) + dnl On IRIX 6.5, the three functions return NULL with errno unset + dnl when the argument is larger than PTRDIFF_MAX. + dnl On Solaris 11.3, the three functions return NULL with errno set + dnl to EAGAIN, not ENOMEM, when the argument is larger than + dnl PTRDIFF_MAX. + dnl Here is a test program: +m4_divert_push([KILL]) +#include +#include +#include +#define ptrdiff_t long +#ifndef PTRDIFF_MAX +# define PTRDIFF_MAX ((ptrdiff_t) ((1UL << (8 * sizeof (ptrdiff_t) - 1)) - 1)) +#endif + +int main () +{ + void *p; + + fprintf (stderr, "PTRDIFF_MAX = %lu\n", (unsigned long) PTRDIFF_MAX); + + errno = 0; + p = malloc ((unsigned long) PTRDIFF_MAX + 1); + fprintf (stderr, "p=%p errno=%d\n", p, errno); + + errno = 0; + p = calloc (PTRDIFF_MAX / 2 + 1, 2); + fprintf (stderr, "p=%p errno=%d\n", p, errno); + + errno = 0; + p = realloc (NULL, (unsigned long) PTRDIFF_MAX + 1); + fprintf (stderr, "p=%p errno=%d\n", p, errno); + + return 0; +} +m4_divert_pop([KILL]) + gl_cv_func_malloc_posix=no ;; + *) + gl_cv_func_malloc_posix=yes ;; + esac + ]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/malloca.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/malloca.m4 new file mode 100644 index 00000000..77e15959 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/malloca.m4 @@ -0,0 +1,14 @@ +# malloca.m4 serial 2 +dnl Copyright (C) 2003-2004, 2006-2007, 2009-2024 Free Software Foundation, +dnl Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_MALLOCA], +[ + dnl Use the autoconf tests for alloca(), but not the AC_SUBSTed variables + dnl @ALLOCA@ and @LTALLOCA@. + dnl gl_FUNC_ALLOCA dnl Already brought in by the module dependencies. + AC_REQUIRE([gl_EEMALLOC]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/manywarnings-c++.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/manywarnings-c++.m4 new file mode 100644 index 00000000..aa6a31cb --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/manywarnings-c++.m4 @@ -0,0 +1,243 @@ +# manywarnings-c++.m4 serial 3 +dnl Copyright (C) 2008-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +# Implementation of the specialization of gl_MANYWARN_ALL_GCC +# for _AC_LANG = C++. +AC_DEFUN([gl_MANYWARN_ALL_GCC_CXX_IMPL], +[ + AC_LANG_PUSH([C++]) + + dnl First, check for some issues that only occur when combining multiple + dnl gcc warning categories. + AC_REQUIRE([AC_PROG_CXX]) + if test -n "$GXX"; then + + dnl Check if -W -Werror -Wno-missing-field-initializers is supported + dnl with the current $CXX $CXXFLAGS $CPPFLAGS. + AC_CACHE_CHECK([whether -Wno-missing-field-initializers is supported], + [gl_cv_cxx_nomfi_supported], + [gl_save_CXXFLAGS="$CXXFLAGS" + CXXFLAGS="$CXXFLAGS -W -Werror -Wno-missing-field-initializers" + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[]], [[]])], + [gl_cv_cxx_nomfi_supported=yes], + [gl_cv_cxx_nomfi_supported=no]) + CXXFLAGS="$gl_save_CXXFLAGS" + ]) + + if test "$gl_cv_cxx_nomfi_supported" = yes; then + dnl Now check whether -Wno-missing-field-initializers is needed + dnl for the { 0, } construct. + AC_CACHE_CHECK([whether -Wno-missing-field-initializers is needed], + [gl_cv_cxx_nomfi_needed], + [gl_save_CXXFLAGS="$CXXFLAGS" + CXXFLAGS="$CXXFLAGS -W -Werror" + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[int f (void) + { + typedef struct { int a; int b; } s_t; + s_t s1 = { 0, }; + return s1.b; + } + ]], + [[]])], + [gl_cv_cxx_nomfi_needed=no], + [gl_cv_cxx_nomfi_needed=yes]) + CXXFLAGS="$gl_save_CXXFLAGS" + ]) + fi + + dnl Next, check if -Werror -Wuninitialized is useful with the + dnl user's choice of $CXXFLAGS; some versions of gcc warn that it + dnl has no effect if -O is not also used + AC_CACHE_CHECK([whether -Wuninitialized is supported], + [gl_cv_cxx_uninitialized_supported], + [gl_save_CXXFLAGS="$CXXFLAGS" + CXXFLAGS="$CXXFLAGS -Werror -Wuninitialized" + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[]], [[]])], + [gl_cv_cxx_uninitialized_supported=yes], + [gl_cv_cxx_uninitialized_supported=no]) + CXXFLAGS="$gl_save_CXXFLAGS" + ]) + + fi + + # List all gcc warning categories. + # To compare this list to your installed GCC's, run this Bash command: + # + # comm -3 \ + # <(sed -n 's/^ *\(-[^ ]*\) .*/\1/p' manywarnings-c++.m4 | sort) \ + # <(gcc --help=warnings | sed -n 's/^ \(-[^ ]*\) .*/\1/p' | sort | + # grep -v -x -f <( + # awk '/^[^#]/ {print $1}' ../build-aux/g++-warning.spec)) + + gl_manywarn_set= + for gl_manywarn_item in \ + -W \ + -Wabi-tag \ + -Waddress \ + -Waggressive-loop-optimizations \ + -Wall \ + -Wattributes \ + -Wbool-compare \ + -Wbuiltin-macro-redefined \ + -Wcast-align \ + -Wchar-subscripts \ + -Wclobbered \ + -Wcomment \ + -Wcomments \ + -Wconditionally-supported \ + -Wconversion-null \ + -Wcoverage-mismatch \ + -Wcpp \ + -Wctor-dtor-privacy \ + -Wdate-time \ + -Wdelete-incomplete \ + -Wdelete-non-virtual-dtor \ + -Wdeprecated \ + -Wdeprecated-declarations \ + -Wdisabled-optimization \ + -Wdiv-by-zero \ + -Wdouble-promotion \ + -Weffc++ \ + -Wempty-body \ + -Wendif-labels \ + -Wenum-compare \ + -Wextra \ + -Wformat-contains-nul \ + -Wformat-extra-args \ + -Wformat-nonliteral \ + -Wformat-security \ + -Wformat-signedness \ + -Wformat-y2k \ + -Wformat-zero-length \ + -Wfree-nonheap-object \ + -Wignored-qualifiers \ + -Winherited-variadic-ctor \ + -Winit-self \ + -Winline \ + -Wint-to-pointer-cast \ + -Winvalid-memory-model \ + -Winvalid-offsetof \ + -Winvalid-pch \ + -Wliteral-suffix \ + -Wlogical-not-parentheses \ + -Wlogical-op \ + -Wmain \ + -Wmaybe-uninitialized \ + -Wmemset-transposed-args \ + -Wmissing-braces \ + -Wmissing-declarations \ + -Wmissing-field-initializers \ + -Wmissing-include-dirs \ + -Wmultichar \ + -Wnarrowing \ + -Wnoexcept \ + -Wnon-template-friend \ + -Wnon-virtual-dtor \ + -Wnonnull \ + -Wodr \ + -Wold-style-cast \ + -Wopenmp-simd \ + -Woverflow \ + -Woverlength-strings \ + -Woverloaded-virtual \ + -Wpacked \ + -Wpacked-bitfield-compat \ + -Wparentheses \ + -Wpmf-conversions \ + -Wpointer-arith \ + -Wpragmas \ + -Wreorder \ + -Wreturn-local-addr \ + -Wreturn-type \ + -Wsequence-point \ + -Wshadow \ + -Wshift-count-negative \ + -Wshift-count-overflow \ + -Wsign-promo \ + -Wsized-deallocation \ + -Wsizeof-array-argument \ + -Wsizeof-pointer-memaccess \ + -Wstack-protector \ + -Wstrict-aliasing \ + -Wstrict-null-sentinel \ + -Wstrict-overflow \ + -Wsuggest-attribute=const \ + -Wsuggest-attribute=format \ + -Wsuggest-attribute=noreturn \ + -Wsuggest-attribute=pure \ + -Wsuggest-final-methods \ + -Wsuggest-final-types \ + -Wsuggest-override \ + -Wswitch \ + -Wswitch-bool \ + -Wsync-nand \ + -Wsystem-headers \ + -Wtrampolines \ + -Wtrigraphs \ + -Wtype-limits \ + -Wuninitialized \ + -Wunknown-pragmas \ + -Wunsafe-loop-optimizations \ + -Wunused \ + -Wunused-but-set-parameter \ + -Wunused-but-set-variable \ + -Wunused-function \ + -Wunused-label \ + -Wunused-local-typedefs \ + -Wunused-macros \ + -Wunused-parameter \ + -Wunused-result \ + -Wunused-value \ + -Wunused-variable \ + -Wuseless-cast \ + -Wvarargs \ + -Wvariadic-macros \ + -Wvector-operation-performance \ + -Wvirtual-move-assign \ + -Wvla \ + -Wvolatile-register-var \ + -Wwrite-strings \ + -Wzero-as-null-pointer-constant \ + \ + ; do + gl_manywarn_set="$gl_manywarn_set $gl_manywarn_item" + done + + # gcc --help=warnings outputs an unusual form for these options; list + # them here so that the above 'comm' command doesn't report a false match. + gl_manywarn_set="$gl_manywarn_set -Warray-bounds=2" + gl_manywarn_set="$gl_manywarn_set -Wnormalized=nfc" + gl_manywarn_set="$gl_manywarn_set -Wshift-overflow=2" + gl_manywarn_set="$gl_manywarn_set -Wunused-const-variable=2" + + # These are needed for older GCC versions. + if test -n "$GXX"; then + case `($CXX --version) 2>/dev/null` in + 'g++ (GCC) '[[0-3]].* | \ + 'g++ (GCC) '4.[[0-7]].*) + gl_manywarn_set="$gl_manywarn_set -fdiagnostics-show-option" + gl_manywarn_set="$gl_manywarn_set -funit-at-a-time" + ;; + esac + fi + + # Disable specific options as needed. + if test "$gl_cv_cxx_nomfi_needed" = yes; then + gl_manywarn_set="$gl_manywarn_set -Wno-missing-field-initializers" + fi + + if test "$gl_cv_cxx_uninitialized_supported" = no; then + gl_manywarn_set="$gl_manywarn_set -Wno-uninitialized" + fi + + $1=$gl_manywarn_set + + AC_LANG_POP([C++]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/manywarnings.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/manywarnings.m4 new file mode 100644 index 00000000..4d44f3aa --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/manywarnings.m4 @@ -0,0 +1,206 @@ +# manywarnings.m4 serial 24 +dnl Copyright (C) 2008-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Simon Josefsson + +AC_PREREQ([2.64]) + +# gl_MANYWARN_COMPLEMENT(OUTVAR, LISTVAR, REMOVEVAR) +# -------------------------------------------------- +# Copy LISTVAR to OUTVAR except for the entries in REMOVEVAR. +# Elements separated by whitespace. In set logic terms, the function +# does OUTVAR = LISTVAR \ REMOVEVAR. +AC_DEFUN([gl_MANYWARN_COMPLEMENT], +[ + gl_warn_set= + set x $2; shift + for gl_warn_item + do + case " $3 " in + *" $gl_warn_item "*) + ;; + *) + AS_VAR_APPEND([gl_warn_set], [" $gl_warn_item"]) + ;; + esac + done + $1=$gl_warn_set +]) + +# gl_MANYWARN_ALL_GCC(VARIABLE) +# ----------------------------- +# Add all documented GCC warning parameters to variable VARIABLE. +# Note that you need to test them using gl_WARN_ADD if you want to +# make sure your gcc understands it. +# +# The effects of this macro depend on the current language (_AC_LANG). +AC_DEFUN([gl_MANYWARN_ALL_GCC], +[_AC_LANG_DISPATCH([$0], _AC_LANG, $@)]) + +# Specialization for _AC_LANG = C. +AC_DEFUN([gl_MANYWARN_ALL_GCC(C)], +[ + AC_LANG_PUSH([C]) + + dnl First, check for some issues that only occur when combining multiple + dnl gcc warning categories. + AC_REQUIRE([AC_PROG_CC]) + AS_IF([test -n "$GCC"], [ + AC_CACHE_CHECK([whether -Wno-missing-field-initializers is needed], + [gl_cv_cc_nomfi_needed], + [gl_cv_cc_nomfi_needed=no + gl_save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -Wextra -Werror" + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[struct file_data { int desc, name; }; + struct cmp { struct file_data file[1]; }; + void f (struct cmp *r) + { + typedef struct { int a; int b; } s_t; + s_t s1 = { 0, }; + struct cmp cmp = { .file[0].desc = r->file[0].desc + s1.a }; + *r = cmp; + } + ]], + [[]])], + [], + [CFLAGS="$CFLAGS -Wno-missing-field-initializers" + AC_COMPILE_IFELSE([], + [gl_cv_cc_nomfi_needed=yes])]) + CFLAGS="$gl_save_CFLAGS" + ]) + + dnl Next, check if -Werror -Wuninitialized is useful with the + dnl user's choice of $CFLAGS; some versions of gcc warn that it + dnl has no effect if -O is not also used + AC_CACHE_CHECK([whether -Wuninitialized is supported], + [gl_cv_cc_uninitialized_supported], + [gl_save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -Werror -Wuninitialized" + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[]], [[]])], + [gl_cv_cc_uninitialized_supported=yes], + [gl_cv_cc_uninitialized_supported=no]) + CFLAGS="$gl_save_CFLAGS" + ]) + ]) + + # List all gcc warning categories. + # To compare this list to your installed GCC's, run this Bash command: + # + # comm -3 \ + # <((sed -n 's/^ *\(-[^ 0-9][^ ]*\).*/\1/p' manywarnings.m4; \ + # awk '/^[^#]/ {print $1}' ../build-aux/gcc-warning.spec) | sort) \ + # <(LC_ALL=C gcc --help=warnings | sed -n 's/^ \(-[^ ]*\) .*/\1/p' | sort) + + $1= + for gl_manywarn_item in -fanalyzer -fstrict-flex-arrays \ + -Wall \ + -Warith-conversion \ + -Wbad-function-cast \ + -Wcast-align=strict \ + -Wdate-time \ + -Wdisabled-optimization \ + -Wdouble-promotion \ + -Wduplicated-branches \ + -Wduplicated-cond \ + -Wextra \ + -Wformat-signedness \ + -Winit-self \ + -Winline \ + -Winvalid-pch \ + -Wlogical-op \ + -Wmissing-declarations \ + -Wmissing-include-dirs \ + -Wmissing-prototypes \ + -Wnested-externs \ + -Wnull-dereference \ + -Wold-style-definition \ + -Wopenmp-simd \ + -Woverlength-strings \ + -Wpacked \ + -Wpointer-arith \ + -Wshadow \ + -Wstack-protector \ + -Wstrict-flex-arrays \ + -Wstrict-overflow \ + -Wstrict-prototypes \ + -Wsuggest-attribute=cold \ + -Wsuggest-attribute=const \ + -Wsuggest-attribute=format \ + -Wsuggest-attribute=malloc \ + -Wsuggest-attribute=noreturn \ + -Wsuggest-attribute=pure \ + -Wsuggest-final-methods \ + -Wsuggest-final-types \ + -Wsync-nand \ + -Wsystem-headers \ + -Wtrampolines \ + -Wuninitialized \ + -Wunknown-pragmas \ + -Wunsafe-loop-optimizations \ + -Wunused-macros \ + -Wvariadic-macros \ + -Wvector-operation-performance \ + -Wvla \ + -Wwrite-strings \ + \ + ; do + AS_VAR_APPEND([$1], [" $gl_manywarn_item"]) + done + + # gcc --help=warnings outputs an unusual form for these options; list + # them here so that the above 'comm' command doesn't report a false match. + AS_VAR_APPEND([$1], [' -Warray-bounds=2']) + AS_VAR_APPEND([$1], [' -Wattribute-alias=2']) + AS_VAR_APPEND([$1], [' -Wbidi-chars=any,ucn']) + AS_VAR_APPEND([$1], [' -Wformat-overflow=2']) + AS_VAR_APPEND([$1], [' -Wformat=2']) + AS_VAR_APPEND([$1], [' -Wformat-truncation=2']) + AS_VAR_APPEND([$1], [' -Wimplicit-fallthrough=5']) + AS_VAR_APPEND([$1], [' -Wshift-overflow=2']) + AS_VAR_APPEND([$1], [' -Wuse-after-free=3']) + AS_VAR_APPEND([$1], [' -Wunused-const-variable=2']) + AS_VAR_APPEND([$1], [' -Wvla-larger-than=4031']) + + # These are needed for older GCC versions. + if test -n "$GCC" && gl_gcc_version=`($CC --version) 2>/dev/null`; then + case $gl_gcc_version in + 'gcc (GCC) '[[0-3]].* | \ + 'gcc (GCC) '4.[[0-7]].*) + AS_VAR_APPEND([$1], [' -fdiagnostics-show-option']) + AS_VAR_APPEND([$1], [' -funit-at-a-time']) + ;; + esac + case $gl_gcc_version in + 'gcc (GCC) '[[0-9]].*) + AS_VAR_APPEND([$1], [' -fno-common']) + ;; + esac + fi + + # Disable specific options as needed. + if test "$gl_cv_cc_nomfi_needed" = yes; then + AS_VAR_APPEND([$1], [' -Wno-missing-field-initializers']) + fi + + if test "$gl_cv_cc_uninitialized_supported" = no; then + AS_VAR_APPEND([$1], [' -Wno-uninitialized']) + fi + + # This warning have too many false alarms in GCC 11.2.1. + # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101713 + AS_VAR_APPEND([$1], [' -Wno-analyzer-malloc-leak']) + + AC_LANG_POP([C]) +]) + +# Specialization for _AC_LANG = C++. +AC_DEFUN([gl_MANYWARN_ALL_GCC(C++)], +[ + gl_MANYWARN_ALL_GCC_CXX_IMPL([$1]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/math_h.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/math_h.m4 new file mode 100644 index 00000000..7ba3c048 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/math_h.m4 @@ -0,0 +1,402 @@ +# math_h.m4 serial 126 +dnl Copyright (C) 2007-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN_ONCE([gl_MATH_H], +[ + AC_REQUIRE([gl_MATH_H_DEFAULTS]) + gl_CHECK_NEXT_HEADERS([math.h]) + + AC_CACHE_CHECK([whether NAN macro works], [gl_cv_header_math_nan_works], + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], + [[/* Solaris 10 has a broken definition of NAN. Other platforms + fail to provide NAN, or provide it only in C99 mode; this + test only needs to fail when NAN is provided but wrong. */ + float f = 1.0f; +#ifdef NAN + f = NAN; +#endif + return f == 0;]])], + [gl_cv_header_math_nan_works=yes], + [gl_cv_header_math_nan_works=no])]) + if test $gl_cv_header_math_nan_works = no; then + REPLACE_NAN=1 + fi + AC_CACHE_CHECK([whether HUGE_VAL works], [gl_cv_header_math_huge_val_works], + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], + [[/* Solaris 10 has a broken definition of HUGE_VAL. */ + double d = HUGE_VAL; + return d == 0;]])], + [gl_cv_header_math_huge_val_works=yes], + [gl_cv_header_math_huge_val_works=no])]) + if test $gl_cv_header_math_huge_val_works = no; then + REPLACE_HUGE_VAL=1 + fi + + dnl Check for declarations of anything we want to poison if the + dnl corresponding gnulib module is not in use. + gl_WARN_ON_USE_PREPARE([[#include ]], + [acosf acosl asinf asinl atanf atanl + cbrt cbrtf cbrtl ceilf ceill copysign copysignf copysignl cosf cosl coshf + expf expl exp2 exp2f exp2l expm1 expm1f expm1l + fabsf fabsl floorf floorl fma fmaf fmal + fmod fmodf fmodl frexpf frexpl hypotf hypotl + ilogb ilogbf ilogbl + ldexpf ldexpl + log logf logl log10 log10f log10l log1p log1pf log1pl log2 log2f log2l + logb logbf logbl + modf modff modfl powf + remainder remainderf remainderl + rint rintf rintl round roundf roundl sinf sinl sinhf sqrtf sqrtl + tanf tanl tanhf totalorder totalorderf totalorderl trunc truncf truncl]) +]) + +# gl_MATH_MODULE_INDICATOR([modulename]) +# sets the shell variable that indicates the presence of the given module +# to a C preprocessor expression that will evaluate to 1. +# This macro invocation must not occur in macros that are AC_REQUIREd. +AC_DEFUN([gl_MATH_MODULE_INDICATOR], +[ + dnl Ensure to expand the default settings once only. + gl_MATH_H_REQUIRE_DEFAULTS + gl_MODULE_INDICATOR_SET_VARIABLE([$1]) + dnl Define it also as a C macro, for the benefit of the unit tests. + gl_MODULE_INDICATOR_FOR_TESTS([$1]) +]) + +# Initializes the default values for AC_SUBSTed shell variables. +# This macro must not be AC_REQUIREd. It must only be invoked, and only +# outside of macros or in macros that are not AC_REQUIREd. +AC_DEFUN([gl_MATH_H_REQUIRE_DEFAULTS], +[ + m4_defun(GL_MODULE_INDICATOR_PREFIX[_MATH_H_MODULE_INDICATOR_DEFAULTS], [ + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ACOSF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ACOSL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ASINF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ASINL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ATANF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ATANL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ATAN2F]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CBRT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CBRTF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CBRTL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CEIL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CEILF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CEILL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_COPYSIGN]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_COPYSIGNF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_COPYSIGNL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_COSF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_COSL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_COSHF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXPF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXPL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXP2]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXP2F]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXP2L]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXPM1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXPM1F]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXPM1L]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FABSF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FABSL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FLOOR]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FLOORF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FLOORL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FMA]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FMAF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FMAL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FMOD]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FMODF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FMODL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FREXPF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FREXP]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FREXPL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_HYPOT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_HYPOTF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_HYPOTL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ILOGB]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ILOGBF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ILOGBL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISFINITE]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISINF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISNAN]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISNANF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISNAND]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISNANL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LDEXP]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LDEXPF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LDEXPL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOG]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOGF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOGL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOG10]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOG10F]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOG10L]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOG1P]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOG1PF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOG1PL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOG2]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOG2F]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOG2L]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOGB]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOGBF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOGBL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MODF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MODFF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MODFL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_POWF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REMAINDER]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REMAINDERF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REMAINDERL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RINT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RINTF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RINTL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ROUND]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ROUNDF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ROUNDL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SIGNBIT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SINF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SINL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SINHF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SQRTF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SQRTL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TANF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TANL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TANHF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TOTALORDER]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TOTALORDERF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TOTALORDERL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TRUNC]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TRUNCF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TRUNCL]) + dnl Support Microsoft deprecated alias function names by default. + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_J0], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_J1], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_JN], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_Y0], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_Y1], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_YN], [1]) + ]) + m4_require(GL_MODULE_INDICATOR_PREFIX[_MATH_H_MODULE_INDICATOR_DEFAULTS]) + AC_REQUIRE([gl_MATH_H_DEFAULTS]) +]) + +AC_DEFUN([gl_MATH_H_DEFAULTS], +[ + dnl Assume proper GNU behavior unless another module says otherwise. + HAVE_ACOSF=1; AC_SUBST([HAVE_ACOSF]) + HAVE_ACOSL=1; AC_SUBST([HAVE_ACOSL]) + HAVE_ASINF=1; AC_SUBST([HAVE_ASINF]) + HAVE_ASINL=1; AC_SUBST([HAVE_ASINL]) + HAVE_ATANF=1; AC_SUBST([HAVE_ATANF]) + HAVE_ATANL=1; AC_SUBST([HAVE_ATANL]) + HAVE_ATAN2F=1; AC_SUBST([HAVE_ATAN2F]) + HAVE_CBRT=1; AC_SUBST([HAVE_CBRT]) + HAVE_CBRTF=1; AC_SUBST([HAVE_CBRTF]) + HAVE_CBRTL=1; AC_SUBST([HAVE_CBRTL]) + HAVE_COPYSIGN=1; AC_SUBST([HAVE_COPYSIGN]) + HAVE_COPYSIGNL=1; AC_SUBST([HAVE_COPYSIGNL]) + HAVE_COSF=1; AC_SUBST([HAVE_COSF]) + HAVE_COSL=1; AC_SUBST([HAVE_COSL]) + HAVE_COSHF=1; AC_SUBST([HAVE_COSHF]) + HAVE_EXPF=1; AC_SUBST([HAVE_EXPF]) + HAVE_EXPL=1; AC_SUBST([HAVE_EXPL]) + HAVE_EXPM1=1; AC_SUBST([HAVE_EXPM1]) + HAVE_EXPM1F=1; AC_SUBST([HAVE_EXPM1F]) + HAVE_FABSF=1; AC_SUBST([HAVE_FABSF]) + HAVE_FABSL=1; AC_SUBST([HAVE_FABSL]) + HAVE_FMA=1; AC_SUBST([HAVE_FMA]) + HAVE_FMAF=1; AC_SUBST([HAVE_FMAF]) + HAVE_FMAL=1; AC_SUBST([HAVE_FMAL]) + HAVE_FMODF=1; AC_SUBST([HAVE_FMODF]) + HAVE_FMODL=1; AC_SUBST([HAVE_FMODL]) + HAVE_FREXPF=1; AC_SUBST([HAVE_FREXPF]) + HAVE_HYPOTF=1; AC_SUBST([HAVE_HYPOTF]) + HAVE_HYPOTL=1; AC_SUBST([HAVE_HYPOTL]) + HAVE_ILOGB=1; AC_SUBST([HAVE_ILOGB]) + HAVE_ILOGBF=1; AC_SUBST([HAVE_ILOGBF]) + HAVE_ILOGBL=1; AC_SUBST([HAVE_ILOGBL]) + HAVE_ISNANF=1; AC_SUBST([HAVE_ISNANF]) + HAVE_ISNAND=1; AC_SUBST([HAVE_ISNAND]) + HAVE_ISNANL=1; AC_SUBST([HAVE_ISNANL]) + HAVE_LDEXPF=1; AC_SUBST([HAVE_LDEXPF]) + HAVE_LOGF=1; AC_SUBST([HAVE_LOGF]) + HAVE_LOGL=1; AC_SUBST([HAVE_LOGL]) + HAVE_LOG10F=1; AC_SUBST([HAVE_LOG10F]) + HAVE_LOG10L=1; AC_SUBST([HAVE_LOG10L]) + HAVE_LOG1P=1; AC_SUBST([HAVE_LOG1P]) + HAVE_LOG1PF=1; AC_SUBST([HAVE_LOG1PF]) + HAVE_LOG1PL=1; AC_SUBST([HAVE_LOG1PL]) + HAVE_LOGBF=1; AC_SUBST([HAVE_LOGBF]) + HAVE_LOGBL=1; AC_SUBST([HAVE_LOGBL]) + HAVE_MODFF=1; AC_SUBST([HAVE_MODFF]) + HAVE_MODFL=1; AC_SUBST([HAVE_MODFL]) + HAVE_POWF=1; AC_SUBST([HAVE_POWF]) + HAVE_REMAINDER=1; AC_SUBST([HAVE_REMAINDER]) + HAVE_REMAINDERF=1; AC_SUBST([HAVE_REMAINDERF]) + HAVE_RINT=1; AC_SUBST([HAVE_RINT]) + HAVE_RINTL=1; AC_SUBST([HAVE_RINTL]) + HAVE_SINF=1; AC_SUBST([HAVE_SINF]) + HAVE_SINL=1; AC_SUBST([HAVE_SINL]) + HAVE_SINHF=1; AC_SUBST([HAVE_SINHF]) + HAVE_SQRTF=1; AC_SUBST([HAVE_SQRTF]) + HAVE_SQRTL=1; AC_SUBST([HAVE_SQRTL]) + HAVE_TANF=1; AC_SUBST([HAVE_TANF]) + HAVE_TANL=1; AC_SUBST([HAVE_TANL]) + HAVE_TANHF=1; AC_SUBST([HAVE_TANHF]) + HAVE_TOTALORDER=1; AC_SUBST([HAVE_TOTALORDER]) + HAVE_TOTALORDERF=1; AC_SUBST([HAVE_TOTALORDERF]) + HAVE_TOTALORDERL=1; AC_SUBST([HAVE_TOTALORDERL]) + HAVE_DECL_ACOSL=1; AC_SUBST([HAVE_DECL_ACOSL]) + HAVE_DECL_ASINL=1; AC_SUBST([HAVE_DECL_ASINL]) + HAVE_DECL_ATANL=1; AC_SUBST([HAVE_DECL_ATANL]) + HAVE_DECL_CBRTF=1; AC_SUBST([HAVE_DECL_CBRTF]) + HAVE_DECL_CBRTL=1; AC_SUBST([HAVE_DECL_CBRTL]) + HAVE_DECL_CEILF=1; AC_SUBST([HAVE_DECL_CEILF]) + HAVE_DECL_CEILL=1; AC_SUBST([HAVE_DECL_CEILL]) + HAVE_DECL_COPYSIGNF=1; AC_SUBST([HAVE_DECL_COPYSIGNF]) + HAVE_DECL_COSL=1; AC_SUBST([HAVE_DECL_COSL]) + HAVE_DECL_EXPL=1; AC_SUBST([HAVE_DECL_EXPL]) + HAVE_DECL_EXP2=1; AC_SUBST([HAVE_DECL_EXP2]) + HAVE_DECL_EXP2F=1; AC_SUBST([HAVE_DECL_EXP2F]) + HAVE_DECL_EXP2L=1; AC_SUBST([HAVE_DECL_EXP2L]) + HAVE_DECL_EXPM1L=1; AC_SUBST([HAVE_DECL_EXPM1L]) + HAVE_DECL_FLOORF=1; AC_SUBST([HAVE_DECL_FLOORF]) + HAVE_DECL_FLOORL=1; AC_SUBST([HAVE_DECL_FLOORL]) + HAVE_DECL_FREXPL=1; AC_SUBST([HAVE_DECL_FREXPL]) + HAVE_DECL_LDEXPL=1; AC_SUBST([HAVE_DECL_LDEXPL]) + HAVE_DECL_LOGL=1; AC_SUBST([HAVE_DECL_LOGL]) + HAVE_DECL_LOG10L=1; AC_SUBST([HAVE_DECL_LOG10L]) + HAVE_DECL_LOG2=1; AC_SUBST([HAVE_DECL_LOG2]) + HAVE_DECL_LOG2F=1; AC_SUBST([HAVE_DECL_LOG2F]) + HAVE_DECL_LOG2L=1; AC_SUBST([HAVE_DECL_LOG2L]) + HAVE_DECL_LOGB=1; AC_SUBST([HAVE_DECL_LOGB]) + HAVE_DECL_REMAINDER=1; AC_SUBST([HAVE_DECL_REMAINDER]) + HAVE_DECL_REMAINDERL=1; AC_SUBST([HAVE_DECL_REMAINDERL]) + HAVE_DECL_RINTF=1; AC_SUBST([HAVE_DECL_RINTF]) + HAVE_DECL_ROUND=1; AC_SUBST([HAVE_DECL_ROUND]) + HAVE_DECL_ROUNDF=1; AC_SUBST([HAVE_DECL_ROUNDF]) + HAVE_DECL_ROUNDL=1; AC_SUBST([HAVE_DECL_ROUNDL]) + HAVE_DECL_SINL=1; AC_SUBST([HAVE_DECL_SINL]) + HAVE_DECL_SQRTL=1; AC_SUBST([HAVE_DECL_SQRTL]) + HAVE_DECL_TANL=1; AC_SUBST([HAVE_DECL_TANL]) + HAVE_DECL_TRUNC=1; AC_SUBST([HAVE_DECL_TRUNC]) + HAVE_DECL_TRUNCF=1; AC_SUBST([HAVE_DECL_TRUNCF]) + HAVE_DECL_TRUNCL=1; AC_SUBST([HAVE_DECL_TRUNCL]) + REPLACE_ACOSF=0; AC_SUBST([REPLACE_ACOSF]) + REPLACE_ASINF=0; AC_SUBST([REPLACE_ASINF]) + REPLACE_ATANF=0; AC_SUBST([REPLACE_ATANF]) + REPLACE_ATAN2F=0; AC_SUBST([REPLACE_ATAN2F]) + REPLACE_CBRTF=0; AC_SUBST([REPLACE_CBRTF]) + REPLACE_CBRTL=0; AC_SUBST([REPLACE_CBRTL]) + REPLACE_CEIL=0; AC_SUBST([REPLACE_CEIL]) + REPLACE_CEILF=0; AC_SUBST([REPLACE_CEILF]) + REPLACE_CEILL=0; AC_SUBST([REPLACE_CEILL]) + REPLACE_COSF=0; AC_SUBST([REPLACE_COSF]) + REPLACE_COSHF=0; AC_SUBST([REPLACE_COSHF]) + REPLACE_EXPF=0; AC_SUBST([REPLACE_EXPF]) + REPLACE_EXPL=0; AC_SUBST([REPLACE_EXPL]) + REPLACE_EXPM1=0; AC_SUBST([REPLACE_EXPM1]) + REPLACE_EXPM1F=0; AC_SUBST([REPLACE_EXPM1F]) + REPLACE_EXPM1L=0; AC_SUBST([REPLACE_EXPM1L]) + REPLACE_EXP2=0; AC_SUBST([REPLACE_EXP2]) + REPLACE_EXP2L=0; AC_SUBST([REPLACE_EXP2L]) + REPLACE_FABSL=0; AC_SUBST([REPLACE_FABSL]) + REPLACE_FLOOR=0; AC_SUBST([REPLACE_FLOOR]) + REPLACE_FLOORF=0; AC_SUBST([REPLACE_FLOORF]) + REPLACE_FLOORL=0; AC_SUBST([REPLACE_FLOORL]) + REPLACE_FMA=0; AC_SUBST([REPLACE_FMA]) + REPLACE_FMAF=0; AC_SUBST([REPLACE_FMAF]) + REPLACE_FMAL=0; AC_SUBST([REPLACE_FMAL]) + REPLACE_FMOD=0; AC_SUBST([REPLACE_FMOD]) + REPLACE_FMODF=0; AC_SUBST([REPLACE_FMODF]) + REPLACE_FMODL=0; AC_SUBST([REPLACE_FMODL]) + REPLACE_FREXPF=0; AC_SUBST([REPLACE_FREXPF]) + REPLACE_FREXP=0; AC_SUBST([REPLACE_FREXP]) + REPLACE_FREXPL=0; AC_SUBST([REPLACE_FREXPL]) + REPLACE_HUGE_VAL=0; AC_SUBST([REPLACE_HUGE_VAL]) + REPLACE_HYPOT=0; AC_SUBST([REPLACE_HYPOT]) + REPLACE_HYPOTF=0; AC_SUBST([REPLACE_HYPOTF]) + REPLACE_HYPOTL=0; AC_SUBST([REPLACE_HYPOTL]) + REPLACE_ILOGB=0; AC_SUBST([REPLACE_ILOGB]) + REPLACE_ILOGBF=0; AC_SUBST([REPLACE_ILOGBF]) + REPLACE_ILOGBL=0; AC_SUBST([REPLACE_ILOGBL]) + REPLACE_ISFINITE=0; AC_SUBST([REPLACE_ISFINITE]) + REPLACE_ISINF=0; AC_SUBST([REPLACE_ISINF]) + REPLACE_ISNAN=0; AC_SUBST([REPLACE_ISNAN]) + REPLACE_LDEXP=0; AC_SUBST([REPLACE_LDEXP]) + REPLACE_LDEXPL=0; AC_SUBST([REPLACE_LDEXPL]) + REPLACE_LOG=0; AC_SUBST([REPLACE_LOG]) + REPLACE_LOGF=0; AC_SUBST([REPLACE_LOGF]) + REPLACE_LOGL=0; AC_SUBST([REPLACE_LOGL]) + REPLACE_LOG10=0; AC_SUBST([REPLACE_LOG10]) + REPLACE_LOG10F=0; AC_SUBST([REPLACE_LOG10F]) + REPLACE_LOG10L=0; AC_SUBST([REPLACE_LOG10L]) + REPLACE_LOG1P=0; AC_SUBST([REPLACE_LOG1P]) + REPLACE_LOG1PF=0; AC_SUBST([REPLACE_LOG1PF]) + REPLACE_LOG1PL=0; AC_SUBST([REPLACE_LOG1PL]) + REPLACE_LOG2=0; AC_SUBST([REPLACE_LOG2]) + REPLACE_LOG2F=0; AC_SUBST([REPLACE_LOG2F]) + REPLACE_LOG2L=0; AC_SUBST([REPLACE_LOG2L]) + REPLACE_LOGB=0; AC_SUBST([REPLACE_LOGB]) + REPLACE_LOGBF=0; AC_SUBST([REPLACE_LOGBF]) + REPLACE_LOGBL=0; AC_SUBST([REPLACE_LOGBL]) + REPLACE_MODF=0; AC_SUBST([REPLACE_MODF]) + REPLACE_MODFF=0; AC_SUBST([REPLACE_MODFF]) + REPLACE_MODFL=0; AC_SUBST([REPLACE_MODFL]) + REPLACE_NAN=0; AC_SUBST([REPLACE_NAN]) + REPLACE_REMAINDER=0; AC_SUBST([REPLACE_REMAINDER]) + REPLACE_REMAINDERF=0; AC_SUBST([REPLACE_REMAINDERF]) + REPLACE_REMAINDERL=0; AC_SUBST([REPLACE_REMAINDERL]) + REPLACE_RINTL=0; AC_SUBST([REPLACE_RINTL]) + REPLACE_ROUND=0; AC_SUBST([REPLACE_ROUND]) + REPLACE_ROUNDF=0; AC_SUBST([REPLACE_ROUNDF]) + REPLACE_ROUNDL=0; AC_SUBST([REPLACE_ROUNDL]) + REPLACE_SIGNBIT=0; AC_SUBST([REPLACE_SIGNBIT]) + REPLACE_SIGNBIT_USING_BUILTINS=0; AC_SUBST([REPLACE_SIGNBIT_USING_BUILTINS]) + REPLACE_SINF=0; AC_SUBST([REPLACE_SINF]) + REPLACE_SINHF=0; AC_SUBST([REPLACE_SINHF]) + REPLACE_SQRTF=0; AC_SUBST([REPLACE_SQRTF]) + REPLACE_SQRTL=0; AC_SUBST([REPLACE_SQRTL]) + REPLACE_TANF=0; AC_SUBST([REPLACE_TANF]) + REPLACE_TANHF=0; AC_SUBST([REPLACE_TANHF]) + REPLACE_TOTALORDER=0; AC_SUBST([REPLACE_TOTALORDER]) + REPLACE_TOTALORDERF=0; AC_SUBST([REPLACE_TOTALORDERF]) + REPLACE_TOTALORDERL=0; AC_SUBST([REPLACE_TOTALORDERL]) + REPLACE_TRUNC=0; AC_SUBST([REPLACE_TRUNC]) + REPLACE_TRUNCF=0; AC_SUBST([REPLACE_TRUNCF]) + REPLACE_TRUNCL=0; AC_SUBST([REPLACE_TRUNCL]) +]) + +# gl_LONG_DOUBLE_VS_DOUBLE +# determines whether 'long double' and 'double' have the same representation. +# Sets variable HAVE_SAME_LONG_DOUBLE_AS_DOUBLE to 0 or 1, and defines +# HAVE_SAME_LONG_DOUBLE_AS_DOUBLE accordingly. +# The currently known platforms where this is the case are: +# Linux/HPPA, NetBSD/sparc32, Minix 3.1.8, AIX 5, AIX 6 and 7 with xlc, MSVC 9. +AC_DEFUN([gl_LONG_DOUBLE_VS_DOUBLE], +[ + AC_CACHE_CHECK([whether long double and double are the same], + [gl_cv_long_double_equals_double], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#include ]], + [[typedef int check[sizeof (long double) == sizeof (double) + && LDBL_MANT_DIG == DBL_MANT_DIG + && LDBL_MAX_EXP == DBL_MAX_EXP + && LDBL_MIN_EXP == DBL_MIN_EXP + ? 1 : -1]; + ]])], + [gl_cv_long_double_equals_double=yes], + [gl_cv_long_double_equals_double=no]) + ]) + if test $gl_cv_long_double_equals_double = yes; then + AC_DEFINE([HAVE_SAME_LONG_DOUBLE_AS_DOUBLE], [1], + [Define to 1 if 'long double' and 'double' have the same representation.]) + HAVE_SAME_LONG_DOUBLE_AS_DOUBLE=1 + else + HAVE_SAME_LONG_DOUBLE_AS_DOUBLE=0 + fi + AC_SUBST([HAVE_SAME_LONG_DOUBLE_AS_DOUBLE]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/mbchar.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/mbchar.m4 new file mode 100644 index 00000000..471e8c45 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/mbchar.m4 @@ -0,0 +1,13 @@ +# mbchar.m4 serial 9 +dnl Copyright (C) 2005-2007, 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl autoconf tests required for use of mbchar.m4 +dnl From Bruno Haible. + +AC_DEFUN([gl_MBCHAR], +[ + AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/mbiter.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/mbiter.m4 new file mode 100644 index 00000000..2f7e7885 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/mbiter.m4 @@ -0,0 +1,14 @@ +# mbiter.m4 serial 7 +dnl Copyright (C) 2005, 2008-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl autoconf tests required for use of mbiter.h +dnl From Bruno Haible. + +AC_DEFUN([gl_MBITER], +[ + AC_REQUIRE([AC_TYPE_MBSTATE_T]) + : +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/mbrtoc32.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/mbrtoc32.m4 new file mode 100644 index 00000000..c1eb126a --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/mbrtoc32.m4 @@ -0,0 +1,266 @@ +# mbrtoc32.m4 serial 18 +dnl Copyright (C) 2014-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_MBRTOC32], +[ + AC_REQUIRE([gl_UCHAR_H_DEFAULTS]) + + AC_REQUIRE([AC_TYPE_MBSTATE_T]) + dnl Determine REPLACE_MBSTATE_T, from which GNULIB_defined_mbstate_t is + dnl determined. It describes how our overridden mbrtowc is implemented. + dnl We then implement mbrtoc32 accordingly. + AC_REQUIRE([gl_MBSTATE_T_BROKEN]) + + AC_REQUIRE([gl_TYPE_CHAR32_T]) + AC_REQUIRE([gl_MBRTOC32_SANITYCHECK]) + + AC_REQUIRE([gl_CHECK_FUNC_MBRTOC32]) + if test $gl_cv_func_mbrtoc32 = no; then + HAVE_MBRTOC32=0 + else + if test $GNULIBHEADERS_OVERRIDE_CHAR32_T = 1 || test $REPLACE_MBSTATE_T = 1; then + REPLACE_MBRTOC32=1 + else + gl_MBRTOC32_EMPTY_INPUT + gl_MBRTOC32_C_LOCALE + case "$gl_cv_func_mbrtoc32_empty_input" in + *yes) ;; + *) AC_DEFINE([MBRTOC32_EMPTY_INPUT_BUG], [1], + [Define if the mbrtoc32 function does not return (size_t) -2 for empty input.]) + REPLACE_MBRTOC32=1 + ;; + esac + case "$gl_cv_func_mbrtoc32_C_locale_sans_EILSEQ" in + *yes) ;; + *) AC_DEFINE([MBRTOC32_IN_C_LOCALE_MAYBE_EILSEQ], [1], + [Define if the mbrtoc32 function may signal encoding errors in the C locale.]) + REPLACE_MBRTOC32=1 + ;; + esac + fi + if test $HAVE_WORKING_MBRTOC32 = 0; then + REPLACE_MBRTOC32=1 + fi + fi +]) + +AC_DEFUN([gl_CHECK_FUNC_MBRTOC32], +[ + dnl Cf. gl_CHECK_FUNCS_ANDROID + AC_CHECK_DECL([mbrtoc32], , , + [[#ifdef __HAIKU__ + #include + #endif + #include + ]]) + if test $ac_cv_have_decl_mbrtoc32 = yes; then + dnl We can't use AC_CHECK_FUNC here, because mbrtoc32() is defined as a + dnl static inline function on Haiku 2020. + AC_CACHE_CHECK([for mbrtoc32], [gl_cv_func_mbrtoc32], + [AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include + #ifdef __HAIKU__ + #include + #endif + #include + ]], + [[char32_t c; + return mbrtoc32 (&c, "", 1, NULL) == 0; + ]]) + ], + [gl_cv_func_mbrtoc32=yes], + [gl_cv_func_mbrtoc32=no]) + ]) + else + gl_cv_func_mbrtoc32=no + fi +]) + +dnl Test whether mbrtoc32 returns the correct value on empty input. + +AC_DEFUN([gl_MBRTOC32_EMPTY_INPUT], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether mbrtoc32 works on empty input], + [gl_cv_func_mbrtoc32_empty_input], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ + #ifdef __HAIKU__ + #include + #endif + #include + static char32_t wc; + static mbstate_t mbs; + int + main (void) + { + return mbrtoc32 (&wc, "", 0, &mbs) != (size_t) -2; + }]])], + [gl_cv_func_mbrtoc32_empty_input=yes], + [gl_cv_func_mbrtoc32_empty_input=no], + [case "$host_os" in + # Guess no on glibc systems. + *-gnu* | gnu*) gl_cv_func_mbrtoc32_empty_input="guessing no" ;; + # Guess no on Android. + linux*-android*) gl_cv_func_mbrtoc32_empty_input="guessing no" ;; + # Guess no on native Windows. + mingw* | windows*) gl_cv_func_mbrtoc32_empty_input="guessing no" ;; + *) gl_cv_func_mbrtoc32_empty_input="guessing yes" ;; + esac + ]) + ]) +]) + +dnl +dnl POSIX:2018 says regarding mbrtowc: "In the POSIX locale an [EILSEQ] error +dnl cannot occur since all byte values are valid characters." It is reasonable +dnl to expect mbrtoc32 to behave in the same way. + +AC_DEFUN([gl_MBRTOC32_C_LOCALE], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether the C locale is free of encoding errors], + [gl_cv_func_mbrtoc32_C_locale_sans_EILSEQ], + [AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [[#include + #include + #ifdef __HAIKU__ + #include + #endif + #include + ]], [[ + int i; + char *locale = setlocale (LC_ALL, "C"); + if (! locale) + return 2; + for (i = CHAR_MIN; i <= CHAR_MAX; i++) + { + char c = i; + char32_t wc; + mbstate_t mbs = { 0, }; + size_t ss = mbrtoc32 (&wc, &c, 1, &mbs); + if (1 < ss) + return 3; + } + return 0; + ]])], + [gl_cv_func_mbrtoc32_C_locale_sans_EILSEQ=yes], + [gl_cv_func_mbrtoc32_C_locale_sans_EILSEQ=no], + [case "$host_os" in + # Guess yes on native Windows. + mingw* | windows*) gl_cv_func_mbrtoc32_C_locale_sans_EILSEQ="guessing yes" ;; + *) gl_cv_func_mbrtoc32_C_locale_sans_EILSEQ="$gl_cross_guess_normal" ;; + esac + ]) + ]) +]) + +dnl Test whether mbrtoc32 works not worse than mbrtowc. +dnl Result is HAVE_WORKING_MBRTOC32. + +AC_DEFUN([gl_MBRTOC32_SANITYCHECK], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([gl_TYPE_CHAR32_T]) + AC_REQUIRE([gl_CHECK_FUNC_MBRTOC32]) + AC_REQUIRE([gt_LOCALE_FR]) + AC_REQUIRE([gt_LOCALE_ZH_CN]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + if test $GNULIBHEADERS_OVERRIDE_CHAR32_T = 1 || test $gl_cv_func_mbrtoc32 = no; then + HAVE_WORKING_MBRTOC32=0 + else + AC_CACHE_CHECK([whether mbrtoc32 works as well as mbrtowc], + [gl_cv_func_mbrtoc32_sanitycheck], + [ + dnl Initial guess, used when cross-compiling or when no suitable locale + dnl is present. +changequote(,)dnl + case "$host_os" in + # Guess no on FreeBSD, Solaris, native Windows. + freebsd* | midnightbsd* | solaris* | mingw* | windows*) + gl_cv_func_mbrtoc32_sanitycheck="guessing no" + ;; + # Guess yes otherwise. + *) + gl_cv_func_mbrtoc32_sanitycheck="guessing yes" + ;; + esac +changequote([,])dnl + if test $LOCALE_FR != none || test $LOCALE_ZH_CN != none; then + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +#include +#include +#ifdef __HAIKU__ + #include +#endif +#include +int main () +{ + int result = 0; + /* This fails on native Windows: + mbrtoc32 returns (size_t)-1. + mbrtowc returns 1 (correct). */ + if (strcmp ("$LOCALE_FR", "none") != 0 + && setlocale (LC_ALL, "$LOCALE_FR") != NULL) + { + mbstate_t state; + wchar_t wc = (wchar_t) 0xBADFACE; + memset (&state, '\0', sizeof (mbstate_t)); + if (mbrtowc (&wc, "\374", 1, &state) == 1) + { + char32_t c32 = (wchar_t) 0xBADFACE; + memset (&state, '\0', sizeof (mbstate_t)); + if (mbrtoc32 (&c32, "\374", 1, &state) != 1) + result |= 1; + } + } + /* This fails on FreeBSD 13.0 and Solaris 11.4: + mbrtoc32 returns (size_t)-2 or (size_t)-1. + mbrtowc returns 4 (correct). */ + if (strcmp ("$LOCALE_ZH_CN", "none") != 0 + && setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL) + { + mbstate_t state; + wchar_t wc = (wchar_t) 0xBADFACE; + memset (&state, '\0', sizeof (mbstate_t)); + if (mbrtowc (&wc, "\224\071\375\067", 4, &state) == 4) + { + char32_t c32 = (wchar_t) 0xBADFACE; + memset (&state, '\0', sizeof (mbstate_t)); + if (mbrtoc32 (&c32, "\224\071\375\067", 4, &state) != 4) + result |= 2; + } + } + return result; +}]])], + [gl_cv_func_mbrtoc32_sanitycheck=yes], + [gl_cv_func_mbrtoc32_sanitycheck=no], + [:]) + fi + ]) + case "$gl_cv_func_mbrtoc32_sanitycheck" in + *yes) + HAVE_WORKING_MBRTOC32=1 + AC_DEFINE([HAVE_WORKING_MBRTOC32], [1], + [Define if the mbrtoc32 function basically works.]) + ;; + *) HAVE_WORKING_MBRTOC32=0 ;; + esac + fi + AC_SUBST([HAVE_WORKING_MBRTOC32]) +]) + +# Prerequisites of lib/mbrtoc32.c and lib/lc-charset-dispatch.c. +AC_DEFUN([gl_PREREQ_MBRTOC32], [ + : +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/mbrtowc.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/mbrtowc.m4 new file mode 100644 index 00000000..6ff51824 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/mbrtowc.m4 @@ -0,0 +1,796 @@ +# mbrtowc.m4 serial 44 -*- coding: utf-8 -*- +dnl Copyright (C) 2001-2002, 2004-2005, 2008-2024 Free Software Foundation, +dnl Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_MBRTOWC], +[ + AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) + AC_REQUIRE([gl_PTHREADLIB]) + AC_CHECK_HEADERS_ONCE([threads.h]) + + AC_REQUIRE([AC_TYPE_MBSTATE_T]) + gl_MBSTATE_T_BROKEN + + AC_CHECK_FUNCS_ONCE([mbrtowc]) + if test $ac_cv_func_mbrtowc = no; then + HAVE_MBRTOWC=0 + AC_CHECK_DECLS([mbrtowc],,, [[ + #include + ]]) + if test $ac_cv_have_decl_mbrtowc = yes; then + dnl On Minix 3.1.8, the system's declares mbrtowc() although + dnl it does not have the function. Avoid a collision with gnulib's + dnl replacement. + REPLACE_MBRTOWC=1 + fi + else + if test $REPLACE_MBSTATE_T = 1; then + REPLACE_MBRTOWC=1 + else + gl_MBRTOWC_NULL_ARG1 + gl_MBRTOWC_NULL_ARG2 + gl_MBRTOWC_RETVAL + gl_MBRTOWC_NUL_RETVAL + gl_MBRTOWC_STORES_INCOMPLETE + gl_MBRTOWC_EMPTY_INPUT + gl_MBRTOWC_C_LOCALE + case "$gl_cv_func_mbrtowc_null_arg1" in + *yes) ;; + *) AC_DEFINE([MBRTOWC_NULL_ARG1_BUG], [1], + [Define if the mbrtowc function has the NULL pwc argument bug.]) + REPLACE_MBRTOWC=1 + ;; + esac + case "$gl_cv_func_mbrtowc_null_arg2" in + *yes) ;; + *) AC_DEFINE([MBRTOWC_NULL_ARG2_BUG], [1], + [Define if the mbrtowc function has the NULL string argument bug.]) + REPLACE_MBRTOWC=1 + ;; + esac + case "$gl_cv_func_mbrtowc_retval" in + *yes) ;; + *) AC_DEFINE([MBRTOWC_RETVAL_BUG], [1], + [Define if the mbrtowc function returns a wrong return value.]) + REPLACE_MBRTOWC=1 + ;; + esac + case "$gl_cv_func_mbrtowc_nul_retval" in + *yes) ;; + *) AC_DEFINE([MBRTOWC_NUL_RETVAL_BUG], [1], + [Define if the mbrtowc function does not return 0 for a NUL character.]) + REPLACE_MBRTOWC=1 + ;; + esac + case "$gl_cv_func_mbrtowc_stores_incomplete" in + *no) ;; + *) AC_DEFINE([MBRTOWC_STORES_INCOMPLETE_BUG], [1], + [Define if the mbrtowc function stores a wide character when reporting incomplete input.]) + REPLACE_MBRTOWC=1 + ;; + esac + case "$gl_cv_func_mbrtowc_empty_input" in + *yes) ;; + *) AC_DEFINE([MBRTOWC_EMPTY_INPUT_BUG], [1], + [Define if the mbrtowc function does not return (size_t) -2 + for empty input.]) + REPLACE_MBRTOWC=1 + ;; + esac + case "$gl_cv_func_mbrtowc_C_locale_sans_EILSEQ" in + *yes) ;; + *) AC_DEFINE([MBRTOWC_IN_C_LOCALE_MAYBE_EILSEQ], [1], + [Define if the mbrtowc function may signal encoding errors in the C locale.]) + REPLACE_MBRTOWC=1 + ;; + esac + fi + fi + if test $REPLACE_MBSTATE_T = 1; then + case "$host_os" in + mingw* | windows*) + MBRTOWC_LIB= + ;; + *) + gl_WEAK_SYMBOLS + case "$gl_cv_have_weak" in + *yes) MBRTOWC_LIB= ;; + *) MBRTOWC_LIB="$LIBPTHREAD" ;; + esac + ;; + esac + else + MBRTOWC_LIB= + fi + dnl MBRTOWC_LIB is expected to be '-pthread' or '-lpthread' on AIX + dnl with gcc or xlc, and empty otherwise. + AC_SUBST([MBRTOWC_LIB]) + dnl For backward compatibility. + LIB_MBRTOWC="$MBRTOWC_LIB" + AC_SUBST([LIB_MBRTOWC]) +]) + +dnl Test whether mbsinit() and mbrtowc() need to be overridden in a way that +dnl redefines the semantics of the given mbstate_t type. +dnl Result is REPLACE_MBSTATE_T. +dnl When this is set to 1, we replace both mbsinit() and mbrtowc(), in order to +dnl avoid inconsistencies. + +AC_DEFUN_ONCE([gl_MBSTATE_T_BROKEN], +[ + AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) + AC_REQUIRE([AC_CANONICAL_HOST]) + + AC_REQUIRE([AC_TYPE_MBSTATE_T]) + AC_CHECK_FUNCS_ONCE([mbsinit]) + AC_CHECK_FUNCS_ONCE([mbrtowc]) + dnl On native Windows, we know exactly how mbsinit() behaves and don't need + dnl to override it, even if - like on MSVC - mbsinit() is only defined as + dnl an inline function, not as a global function. + if case "$host_os" in + mingw* | windows*) true ;; + *) test $ac_cv_func_mbsinit = yes ;; + esac \ + && test $ac_cv_func_mbrtowc = yes; then + gl_MBRTOWC_INCOMPLETE_STATE + gl_MBRTOWC_SANITYCHECK + REPLACE_MBSTATE_T=0 + case "$gl_cv_func_mbrtowc_incomplete_state" in + *yes) ;; + *) REPLACE_MBSTATE_T=1 ;; + esac + case "$gl_cv_func_mbrtowc_sanitycheck" in + *yes) ;; + *) REPLACE_MBSTATE_T=1 ;; + esac + else + REPLACE_MBSTATE_T=1 + fi +]) + +dnl Test whether mbrtowc puts the state into non-initial state when parsing an +dnl incomplete multibyte character. +dnl Result is gl_cv_func_mbrtowc_incomplete_state. + +AC_DEFUN([gl_MBRTOWC_INCOMPLETE_STATE], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([gt_LOCALE_JA]) + AC_REQUIRE([gt_LOCALE_FR_UTF8]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether mbrtowc handles incomplete characters], + [gl_cv_func_mbrtowc_incomplete_state], + [ + dnl Initial guess, used when cross-compiling or when no suitable locale + dnl is present. +changequote(,)dnl + case "$host_os" in + # Guess no on AIX and OSF/1. + aix* | osf*) gl_cv_func_mbrtowc_incomplete_state="guessing no" ;; + # Guess yes otherwise. + *) gl_cv_func_mbrtowc_incomplete_state="guessing yes" ;; + esac +changequote([,])dnl + if test $LOCALE_JA != none; then + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +#include +int main () +{ + if (setlocale (LC_ALL, "$LOCALE_JA") != NULL) + { + const char input[] = "B\217\253\344\217\251\316er"; /* "Büßer" */ + mbstate_t state; + wchar_t wc; + + memset (&state, '\0', sizeof (mbstate_t)); + if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2)) + if (mbsinit (&state)) + return 2; + } + return 0; +}]])], + [gl_cv_func_mbrtowc_incomplete_state=yes], + [gl_cv_func_mbrtowc_incomplete_state=no], + [:]) + else + if test $LOCALE_FR_UTF8 != none; then + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +#include +int main () +{ + if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL) + { + const char input[] = "B\303\274\303\237er"; /* "Büßer" */ + mbstate_t state; + wchar_t wc; + + memset (&state, '\0', sizeof (mbstate_t)); + if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2)) + if (mbsinit (&state)) + return 2; + } + return 0; +}]])], + [gl_cv_func_mbrtowc_incomplete_state=yes], + [gl_cv_func_mbrtowc_incomplete_state=no], + [:]) + fi + fi + ]) +]) + +dnl Test whether mbrtowc works not worse than mbtowc. +dnl Result is gl_cv_func_mbrtowc_sanitycheck. + +AC_DEFUN([gl_MBRTOWC_SANITYCHECK], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([gt_LOCALE_ZH_CN]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether mbrtowc works as well as mbtowc], + [gl_cv_func_mbrtowc_sanitycheck], + [ + dnl Initial guess, used when cross-compiling or when no suitable locale + dnl is present. +changequote(,)dnl + case "$host_os" in + # Guess no on Solaris 8. + solaris2.8) gl_cv_func_mbrtowc_sanitycheck="guessing no" ;; + # Guess yes otherwise. + *) gl_cv_func_mbrtowc_sanitycheck="guessing yes" ;; + esac +changequote([,])dnl + if test $LOCALE_ZH_CN != none; then + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +#include +#include +int main () +{ + /* This fails on Solaris 8: + mbrtowc returns 2, and sets wc to 0x00F0. + mbtowc returns 4 (correct) and sets wc to 0x5EDC. */ + if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL) + { + char input[] = "B\250\271\201\060\211\070er"; /* "Büßer" */ + mbstate_t state; + wchar_t wc; + + memset (&state, '\0', sizeof (mbstate_t)); + if (mbrtowc (&wc, input + 3, 6, &state) != 4 + && mbtowc (&wc, input + 3, 6) == 4) + return 2; + } + return 0; +}]])], + [gl_cv_func_mbrtowc_sanitycheck=yes], + [gl_cv_func_mbrtowc_sanitycheck=no], + [:]) + fi + ]) +]) + +dnl Test whether mbrtowc supports a NULL pwc argument correctly. +dnl Result is gl_cv_func_mbrtowc_null_arg1. + +AC_DEFUN([gl_MBRTOWC_NULL_ARG1], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([gt_LOCALE_FR_UTF8]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether mbrtowc handles a NULL pwc argument], + [gl_cv_func_mbrtowc_null_arg1], + [ + dnl Initial guess, used when cross-compiling or when no suitable locale + dnl is present. +changequote(,)dnl + case "$host_os" in + # Guess no on Solaris. + solaris*) gl_cv_func_mbrtowc_null_arg1="guessing no" ;; + # Guess yes otherwise. + *) gl_cv_func_mbrtowc_null_arg1="guessing yes" ;; + esac +changequote([,])dnl + if test $LOCALE_FR_UTF8 != none; then + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +#include +#include +int main () +{ + int result = 0; + + if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL) + { + char input[] = "\303\237er"; + mbstate_t state; + wchar_t wc; + size_t ret; + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, input, 5, &state); + if (ret != 2) + result |= 1; + if (!mbsinit (&state)) + result |= 2; + + memset (&state, '\0', sizeof (mbstate_t)); + ret = mbrtowc (NULL, input, 5, &state); + if (ret != 2) /* Solaris 7 fails here: ret is -1. */ + result |= 4; + if (!mbsinit (&state)) + result |= 8; + } + return result; +}]])], + [gl_cv_func_mbrtowc_null_arg1=yes], + [gl_cv_func_mbrtowc_null_arg1=no], + [:]) + fi + ]) +]) + +dnl Test whether mbrtowc supports a NULL string argument correctly. +dnl Result is gl_cv_func_mbrtowc_null_arg2. + +AC_DEFUN([gl_MBRTOWC_NULL_ARG2], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([gt_LOCALE_FR_UTF8]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether mbrtowc handles a NULL string argument], + [gl_cv_func_mbrtowc_null_arg2], + [ + dnl Initial guess, used when cross-compiling or when no suitable locale + dnl is present. +changequote(,)dnl + case "$host_os" in + # Guess no on OSF/1. + osf*) gl_cv_func_mbrtowc_null_arg2="guessing no" ;; + # Guess yes otherwise. + *) gl_cv_func_mbrtowc_null_arg2="guessing yes" ;; + esac +changequote([,])dnl + if test $LOCALE_FR_UTF8 != none; then + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +#include +int main () +{ + if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL) + { + mbstate_t state; + wchar_t wc; + int ret; + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + mbrtowc (&wc, NULL, 5, &state); + /* Check that wc was not modified. */ + if (wc != (wchar_t) 0xBADFACE) + return 2; + } + return 0; +}]])], + [gl_cv_func_mbrtowc_null_arg2=yes], + [gl_cv_func_mbrtowc_null_arg2=no], + [:]) + fi + ]) +]) + +dnl Test whether mbrtowc, when parsing the end of a multibyte character, +dnl correctly returns the number of bytes that were needed to complete the +dnl character (not the total number of bytes of the multibyte character). +dnl Result is gl_cv_func_mbrtowc_retval. + +AC_DEFUN([gl_MBRTOWC_RETVAL], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([gt_LOCALE_FR_UTF8]) + AC_REQUIRE([gt_LOCALE_JA]) + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_CACHE_CHECK([whether mbrtowc has a correct return value], + [gl_cv_func_mbrtowc_retval], + [ + dnl Initial guess, used when cross-compiling or when no suitable locale + dnl is present. +changequote(,)dnl + case "$host_os" in + # Guess no on HP-UX, Solaris, native Windows. + hpux* | solaris* | mingw* | windows*) + gl_cv_func_mbrtowc_retval="guessing no" ;; + # Guess yes otherwise. + *) + gl_cv_func_mbrtowc_retval="guessing yes" ;; + esac +changequote([,])dnl + if test $LOCALE_FR_UTF8 != none || test $LOCALE_JA != none \ + || { case "$host_os" in mingw* | windows*) true;; *) false;; esac; }; then + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +#include +int main () +{ + int result = 0; + int found_some_locale = 0; + /* This fails on Solaris. */ + if (strcmp ("$LOCALE_FR_UTF8", "none") != 0 + && setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL) + { + char input[] = "B\303\274\303\237er"; /* "Büßer" */ + mbstate_t state; + wchar_t wc; + + memset (&state, '\0', sizeof (mbstate_t)); + if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2)) + { + input[1] = '\0'; + if (mbrtowc (&wc, input + 2, 5, &state) != 1) + result |= 1; + } + found_some_locale = 1; + } + /* This fails on HP-UX 11.11. */ + if (strcmp ("$LOCALE_JA", "none") != 0 + && setlocale (LC_ALL, "$LOCALE_JA") != NULL) + { + char input[] = "B\217\253\344\217\251\316er"; /* "Büßer" */ + mbstate_t state; + wchar_t wc; + + memset (&state, '\0', sizeof (mbstate_t)); + if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2)) + { + input[1] = '\0'; + if (mbrtowc (&wc, input + 2, 5, &state) != 2) + result |= 2; + } + found_some_locale = 1; + } + /* This fails on native Windows. */ + if (setlocale (LC_ALL, "Japanese_Japan.932") != NULL) + { + char input[] = "<\223\372\226\173\214\352>"; /* "<日本語>" */ + mbstate_t state; + wchar_t wc; + + memset (&state, '\0', sizeof (mbstate_t)); + if (mbrtowc (&wc, input + 3, 1, &state) == (size_t)(-2)) + { + input[3] = '\0'; + if (mbrtowc (&wc, input + 4, 4, &state) != 1) + result |= 4; + } + found_some_locale = 1; + } + if (setlocale (LC_ALL, "Chinese_Taiwan.950") != NULL) + { + char input[] = "<\244\351\245\273\273\171>"; /* "<日本語>" */ + mbstate_t state; + wchar_t wc; + + memset (&state, '\0', sizeof (mbstate_t)); + if (mbrtowc (&wc, input + 3, 1, &state) == (size_t)(-2)) + { + input[3] = '\0'; + if (mbrtowc (&wc, input + 4, 4, &state) != 1) + result |= 8; + } + found_some_locale = 1; + } + if (setlocale (LC_ALL, "Chinese_China.936") != NULL) + { + char input[] = "<\310\325\261\276\325\132>"; /* "<日本語>" */ + mbstate_t state; + wchar_t wc; + + memset (&state, '\0', sizeof (mbstate_t)); + if (mbrtowc (&wc, input + 3, 1, &state) == (size_t)(-2)) + { + input[3] = '\0'; + if (mbrtowc (&wc, input + 4, 4, &state) != 1) + result |= 16; + } + found_some_locale = 1; + } + return (found_some_locale ? result : 77); +}]])], + [gl_cv_func_mbrtowc_retval=yes], + [if test $? != 77; then + gl_cv_func_mbrtowc_retval=no + fi + ], + [:]) + fi + ]) +]) + +dnl Test whether mbrtowc, when parsing a NUL character, correctly returns 0. +dnl Result is gl_cv_func_mbrtowc_nul_retval. + +AC_DEFUN([gl_MBRTOWC_NUL_RETVAL], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([gt_LOCALE_ZH_CN]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether mbrtowc returns 0 when parsing a NUL character], + [gl_cv_func_mbrtowc_nul_retval], + [ + dnl Initial guess, used when cross-compiling or when no suitable locale + dnl is present. +changequote(,)dnl + case "$host_os" in + # Guess no on Solaris 8 and 9. + solaris2.[89]) gl_cv_func_mbrtowc_nul_retval="guessing no" ;; + # Guess yes otherwise. + *) gl_cv_func_mbrtowc_nul_retval="guessing yes" ;; + esac +changequote([,])dnl + if test $LOCALE_ZH_CN != none; then + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +#include +int main () +{ + /* This fails on Solaris 8 and 9. */ + if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL) + { + mbstate_t state; + wchar_t wc; + + memset (&state, '\0', sizeof (mbstate_t)); + if (mbrtowc (&wc, "", 1, &state) != 0) + return 2; + } + return 0; +}]])], + [gl_cv_func_mbrtowc_nul_retval=yes], + [gl_cv_func_mbrtowc_nul_retval=no], + [:]) + fi + ]) +]) + +dnl Test whether mbrtowc stores a wide character when reporting incomplete +dnl input. + +AC_DEFUN([gl_MBRTOWC_STORES_INCOMPLETE], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether mbrtowc stores incomplete characters], + [gl_cv_func_mbrtowc_stores_incomplete], + [ + dnl Initial guess, used when cross-compiling or when no suitable locale + dnl is present. +changequote(,)dnl + case "$host_os" in + # Guess yes on native Windows. + mingw* | windows*) gl_cv_func_mbrtowc_stores_incomplete="guessing yes" ;; + *) gl_cv_func_mbrtowc_stores_incomplete="guessing no" ;; + esac +changequote([,])dnl + case "$host_os" in + mingw* | windows*) + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +#include +int main () +{ + int result = 0; + if (setlocale (LC_ALL, "French_France.65001") != NULL) + { + wchar_t wc = (wchar_t) 0xBADFACE; + mbstate_t state; + + memset (&state, '\0', sizeof (mbstate_t)); + if (mbrtowc (&wc, "\303", 1, &state) == (size_t)(-2) + && wc != (wchar_t) 0xBADFACE) + result |= 1; + } + if (setlocale (LC_ALL, "Japanese_Japan.932") != NULL) + { + wchar_t wc = (wchar_t) 0xBADFACE; + mbstate_t state; + + memset (&state, '\0', sizeof (mbstate_t)); + if (mbrtowc (&wc, "\226", 1, &state) == (size_t)(-2) + && wc != (wchar_t) 0xBADFACE) + result |= 2; + } + if (setlocale (LC_ALL, "Chinese_Taiwan.950") != NULL) + { + wchar_t wc = (wchar_t) 0xBADFACE; + mbstate_t state; + + memset (&state, '\0', sizeof (mbstate_t)); + if (mbrtowc (&wc, "\245", 1, &state) == (size_t)(-2) + && wc != (wchar_t) 0xBADFACE) + result |= 4; + } + if (setlocale (LC_ALL, "Chinese_China.936") != NULL) + { + wchar_t wc = (wchar_t) 0xBADFACE; + mbstate_t state; + + memset (&state, '\0', sizeof (mbstate_t)); + if (mbrtowc (&wc, "\261", 1, &state) == (size_t)(-2) + && wc != (wchar_t) 0xBADFACE) + result |= 8; + } + return result; +}]])], + [gl_cv_func_mbrtowc_stores_incomplete=no], + [gl_cv_func_mbrtowc_stores_incomplete=yes], + [:]) + ;; + *) + AC_REQUIRE([gt_LOCALE_FR_UTF8]) + if test $LOCALE_FR_UTF8 != none; then + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +#include +int main () +{ + if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL) + { + wchar_t wc = (wchar_t) 0xBADFACE; + mbstate_t state; + + memset (&state, '\0', sizeof (mbstate_t)); + if (mbrtowc (&wc, "\303", 1, &state) == (size_t)(-2) + && wc != (wchar_t) 0xBADFACE) + return 1; + } + return 0; +}]])], + [gl_cv_func_mbrtowc_stores_incomplete=no], + [gl_cv_func_mbrtowc_stores_incomplete=yes], + [:]) + fi + ;; + esac + ]) +]) + +dnl Test whether mbrtowc returns the correct value on empty input. + +AC_DEFUN([gl_MBRTOWC_EMPTY_INPUT], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether mbrtowc works on empty input], + [gl_cv_func_mbrtowc_empty_input], + [AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ + #include + static wchar_t wc; + static mbstate_t mbs; + int + main (void) + { + return mbrtowc (&wc, "", 0, &mbs) != (size_t) -2; + }]])], + [gl_cv_func_mbrtowc_empty_input=yes], + [gl_cv_func_mbrtowc_empty_input=no], + [case "$host_os" in + # Guess no on AIX and glibc systems. + aix* | *-gnu* | gnu*) gl_cv_func_mbrtowc_empty_input="guessing no" ;; + # Guess no on Android. + linux*-android*) gl_cv_func_mbrtowc_empty_input="guessing no" ;; + # Guess no on native Windows. + mingw* | windows*) gl_cv_func_mbrtowc_empty_input="guessing no" ;; + *) gl_cv_func_mbrtowc_empty_input="guessing yes" ;; + esac + ]) + ]) +]) + +dnl Test whether mbrtowc reports encoding errors in the C locale. +dnl Although POSIX was never intended to allow this, the GNU C Library +dnl and other implementations do it. See: +dnl https://sourceware.org/bugzilla/show_bug.cgi?id=19932 +dnl POSIX has now clarified it: +dnl +dnl says: "In the POSIX locale an [EILSEQ] error cannot occur since all byte +dnl values are valid characters." + +AC_DEFUN([gl_MBRTOWC_C_LOCALE], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether the C locale is free of encoding errors], + [gl_cv_func_mbrtowc_C_locale_sans_EILSEQ], + [AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [[#include + #include + #include + ]], [[ + int i; + char *locale = setlocale (LC_ALL, "C"); + if (! locale) + return 2; + for (i = CHAR_MIN; i <= CHAR_MAX; i++) + { + char c = i; + wchar_t wc; + mbstate_t mbs = { 0, }; + size_t ss = mbrtowc (&wc, &c, 1, &mbs); + if (1 < ss) + return 3; + } + return 0; + ]])], + [gl_cv_func_mbrtowc_C_locale_sans_EILSEQ=yes], + [gl_cv_func_mbrtowc_C_locale_sans_EILSEQ=no], + [case "$host_os" in + # Guess yes on native Windows. + mingw* | windows*) gl_cv_func_mbrtowc_C_locale_sans_EILSEQ="guessing yes" ;; + *) gl_cv_func_mbrtowc_C_locale_sans_EILSEQ="$gl_cross_guess_normal" ;; + esac + ]) + ]) +]) + +# Prerequisites of lib/mbrtowc.c and lib/lc-charset-dispatch.c. +AC_DEFUN([gl_PREREQ_MBRTOWC], [ + AC_REQUIRE([AC_C_INLINE]) + : +]) + +# Prerequisites of lib/mbtowc-lock.c. +AC_DEFUN([gl_PREREQ_MBTOWC_LOCK], +[ + gl_VISIBILITY +]) + + +dnl From Paul Eggert + +dnl This is an override of an autoconf macro. + +AC_DEFUN([AC_FUNC_MBRTOWC], +[ + dnl Same as AC_FUNC_MBRTOWC in autoconf-2.60. + AC_CACHE_CHECK([whether mbrtowc and mbstate_t are properly declared], + [gl_cv_func_mbrtowc], + [AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include ]], + [[wchar_t wc; + char const s[] = ""; + size_t n = 1; + mbstate_t state; + return ! (sizeof state && (mbrtowc) (&wc, s, n, &state));]])], + [gl_cv_func_mbrtowc=yes], + [gl_cv_func_mbrtowc=no])]) + if test $gl_cv_func_mbrtowc = yes; then + AC_DEFINE([HAVE_MBRTOWC], [1], + [Define to 1 if mbrtowc and mbstate_t are properly declared.]) + fi +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/mbsinit.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/mbsinit.m4 new file mode 100644 index 00000000..10a5b619 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/mbsinit.m4 @@ -0,0 +1,44 @@ +# mbsinit.m4 serial 10 +dnl Copyright (C) 2008, 2010-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_MBSINIT], +[ + AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) + AC_REQUIRE([AC_CANONICAL_HOST]) + + AC_REQUIRE([AC_TYPE_MBSTATE_T]) + gl_MBSTATE_T_BROKEN + + AC_CHECK_FUNCS_ONCE([mbsinit]) + if test $ac_cv_func_mbsinit = no; then + HAVE_MBSINIT=0 + AC_CHECK_DECLS([mbsinit],,, [[ + #include + ]]) + if test $ac_cv_have_decl_mbsinit = yes; then + dnl On Minix 3.1.8, the system's declares mbsinit() although + dnl it does not have the function. Avoid a collision with gnulib's + dnl replacement. + REPLACE_MBSINIT=1 + fi + else + if test $REPLACE_MBSTATE_T = 1; then + REPLACE_MBSINIT=1 + else + dnl On mingw, mbsinit() always returns 1, which is inappropriate for + dnl states produced by mbrtowc() for an incomplete multibyte character + dnl in multibyte locales. + case "$host_os" in + mingw* | windows*) REPLACE_MBSINIT=1 ;; + esac + fi + fi +]) + +# Prerequisites of lib/mbsinit.c. +AC_DEFUN([gl_PREREQ_MBSINIT], [ + : +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/mbsrtowcs.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/mbsrtowcs.m4 new file mode 100644 index 00000000..84ac0b70 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/mbsrtowcs.m4 @@ -0,0 +1,154 @@ +# mbsrtowcs.m4 serial 17 +dnl Copyright (C) 2008-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_MBSRTOWCS], +[ + AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) + + AC_REQUIRE([AC_TYPE_MBSTATE_T]) + gl_MBSTATE_T_BROKEN + + AC_CHECK_FUNCS_ONCE([mbsrtowcs]) + if test $ac_cv_func_mbsrtowcs = no; then + HAVE_MBSRTOWCS=0 + AC_CHECK_DECLS([mbsrtowcs],,, [[ + #include + ]]) + if test $ac_cv_have_decl_mbsrtowcs = yes; then + dnl On Minix 3.1.8, the system's declares mbsrtowcs() although + dnl it does not have the function. Avoid a collision with gnulib's + dnl replacement. + REPLACE_MBSRTOWCS=1 + fi + else + if test $REPLACE_MBSTATE_T = 1; then + REPLACE_MBSRTOWCS=1 + else + gl_MBSRTOWCS_WORKS + case "$gl_cv_func_mbsrtowcs_works" in + *yes) ;; + *) REPLACE_MBSRTOWCS=1 ;; + esac + if test $REPLACE_MBSRTOWCS = 0; then + gl_MBRTOWC_C_LOCALE + case "$gl_cv_func_mbrtowc_C_locale_sans_EILSEQ" in + *yes) ;; + *) REPLACE_MBSRTOWCS=1 ;; + esac + fi + fi + fi +]) + +dnl Test whether mbsrtowcs works. +dnl Result is gl_cv_func_mbsrtowcs_works. + +AC_DEFUN([gl_MBSRTOWCS_WORKS], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([gt_LOCALE_FR]) + AC_REQUIRE([gt_LOCALE_FR_UTF8]) + AC_REQUIRE([gt_LOCALE_JA]) + AC_REQUIRE([gt_LOCALE_ZH_CN]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether mbsrtowcs works], + [gl_cv_func_mbsrtowcs_works], + [ + dnl Initial guess, used when cross-compiling or when no suitable locale + dnl is present. +changequote(,)dnl + case "$host_os" in + # Guess no on HP-UX, Solaris, mingw. + hpux* | solaris* | mingw* | windows*) + gl_cv_func_mbsrtowcs_works="guessing no" ;; + # Guess yes otherwise. + *) + gl_cv_func_mbsrtowcs_works="guessing yes" ;; + esac +changequote([,])dnl + if test $LOCALE_FR != none || test $LOCALE_FR_UTF8 != none || test $LOCALE_JA != none || test $LOCALE_ZH_CN != none; then + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +#include +int main () +{ + int result = 0; + /* Test whether the function supports a NULL destination argument. + This fails on native Windows. */ + if (strcmp ("$LOCALE_FR", "none") != 0 + && setlocale (LC_ALL, "$LOCALE_FR") != NULL) + { + const char input[] = "\337er"; + const char *src = input; + mbstate_t state; + + memset (&state, '\0', sizeof (mbstate_t)); + if (mbsrtowcs (NULL, &src, 1, &state) != 3 + || src != input) + result |= 1; + } + /* Test whether the function works when started with a conversion state + in non-initial state. This fails on HP-UX 11.11 and Solaris 10. */ + if (strcmp ("$LOCALE_FR_UTF8", "none") != 0 + && setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL) + { + const char input[] = "B\303\274\303\237er"; + mbstate_t state; + + memset (&state, '\0', sizeof (mbstate_t)); + if (mbrtowc (NULL, input + 1, 1, &state) == (size_t)(-2)) + if (!mbsinit (&state)) + { + const char *src = input + 2; + if (mbsrtowcs (NULL, &src, 10, &state) != 4) + result |= 2; + } + } + if (strcmp ("$LOCALE_JA", "none") != 0 + && setlocale (LC_ALL, "$LOCALE_JA") != NULL) + { + const char input[] = "<\306\374\313\334\270\354>"; + mbstate_t state; + + memset (&state, '\0', sizeof (mbstate_t)); + if (mbrtowc (NULL, input + 3, 1, &state) == (size_t)(-2)) + if (!mbsinit (&state)) + { + const char *src = input + 4; + if (mbsrtowcs (NULL, &src, 10, &state) != 3) + result |= 4; + } + } + if (strcmp ("$LOCALE_ZH_CN", "none") != 0 + && setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL) + { + const char input[] = "B\250\271\201\060\211\070er"; + mbstate_t state; + + memset (&state, '\0', sizeof (mbstate_t)); + if (mbrtowc (NULL, input + 1, 1, &state) == (size_t)(-2)) + if (!mbsinit (&state)) + { + const char *src = input + 2; + if (mbsrtowcs (NULL, &src, 10, &state) != 4) + result |= 8; + } + } + return result; +}]])], + [gl_cv_func_mbsrtowcs_works=yes], + [gl_cv_func_mbsrtowcs_works=no], + [:]) + fi + ]) +]) + +# Prerequisites of lib/mbsrtowcs.c. +AC_DEFUN([gl_PREREQ_MBSRTOWCS], [ + : +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/mbstate_t.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/mbstate_t.m4 new file mode 100644 index 00000000..b2bcba45 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/mbstate_t.m4 @@ -0,0 +1,34 @@ +# mbstate_t.m4 serial 14 +dnl Copyright (C) 2000-2002, 2008-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +# From Paul Eggert. + +# BeOS 5 has but does not define mbstate_t, +# so you can't declare an object of that type. +# Check for this incompatibility with Standard C. + +# AC_TYPE_MBSTATE_T +# ----------------- +AC_DEFUN([AC_TYPE_MBSTATE_T], +[ + AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) dnl for HP-UX 11.11 + + AC_CACHE_CHECK([for mbstate_t], [ac_cv_type_mbstate_t], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [AC_INCLUDES_DEFAULT[ + #include ]], + [[mbstate_t x; return sizeof x;]])], + [ac_cv_type_mbstate_t=yes], + [ac_cv_type_mbstate_t=no])]) + if test $ac_cv_type_mbstate_t = yes; then + AC_DEFINE([HAVE_MBSTATE_T], [1], + [Define to 1 if declares mbstate_t.]) + else + AC_DEFINE([mbstate_t], [int], + [Define to a type if does not define.]) + fi +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/mbtowc.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/mbtowc.m4 new file mode 100644 index 00000000..2bdc879c --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/mbtowc.m4 @@ -0,0 +1,27 @@ +# mbtowc.m4 serial 5 +dnl Copyright (C) 2011-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_MBTOWC], +[ + AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) + + gl_CHECK_FUNCS_ANDROID([mbtowc], [[#include ]]) + if test $ac_cv_func_mbtowc = no; then + HAVE_MBTOWC=0 + case "$gl_cv_onwards_func_mbtowc" in + future*) REPLACE_MBTOWC=1 ;; + esac + else + if false; then + REPLACE_MBTOWC=1 + fi + fi +]) + +# Prerequisites of lib/mbtowc.c. +AC_DEFUN([gl_PREREQ_MBTOWC], [ + : +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/memchr.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/memchr.m4 new file mode 100644 index 00000000..6184ddc8 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/memchr.m4 @@ -0,0 +1,106 @@ +# memchr.m4 serial 19 +dnl Copyright (C) 2002-2004, 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN_ONCE([gl_FUNC_MEMCHR], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + + dnl Check for prerequisites for memory fence checks. + gl_FUNC_MMAP_ANON + AC_CHECK_HEADERS_ONCE([sys/mman.h]) + AC_CHECK_FUNCS_ONCE([mprotect]) + + AC_REQUIRE([gl_STRING_H_DEFAULTS]) + # Detect platform-specific bugs in some versions of glibc: + # memchr should not dereference anything with length 0 + # https://bugzilla.redhat.com/show_bug.cgi?id=499689 + # memchr should not dereference overestimated length after a match + # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=521737 + # https://sourceware.org/bugzilla/show_bug.cgi?id=10162 + # memchr should cast the second argument to 'unsigned char'. + # This bug exists in Android 4.3. + # Assume that memchr works on platforms that lack mprotect. + AC_CACHE_CHECK([whether memchr works], [gl_cv_func_memchr_works], + [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ +#include +#if HAVE_SYS_MMAN_H +# include +# include +# include +# include +# ifndef MAP_FILE +# define MAP_FILE 0 +# endif +#endif +]], [[ + int result = 0; + char *fence = NULL; +#if HAVE_SYS_MMAN_H && HAVE_MPROTECT +# if HAVE_MAP_ANONYMOUS + const int flags = MAP_ANONYMOUS | MAP_PRIVATE; + const int fd = -1; +# else /* !HAVE_MAP_ANONYMOUS */ + const int flags = MAP_FILE | MAP_PRIVATE; + int fd = open ("/dev/zero", O_RDONLY, 0666); + if (fd >= 0) +# endif + { + int pagesize = getpagesize (); + char *two_pages = + (char *) mmap (NULL, 2 * pagesize, PROT_READ | PROT_WRITE, + flags, fd, 0); + if (two_pages != (char *)(-1) + && mprotect (two_pages + pagesize, pagesize, PROT_NONE) == 0) + fence = two_pages + pagesize; + } +#endif + if (fence) + { + /* Test against bugs on glibc systems. */ + if (memchr (fence, 0, 0)) + result |= 1; + strcpy (fence - 9, "12345678"); + if (memchr (fence - 9, 0, 79) != fence - 1) + result |= 2; + if (memchr (fence - 1, 0, 3) != fence - 1) + result |= 4; + /* Test against bug on AIX 7.2. */ + if (memchr (fence - 4, '6', 16) != fence - 4) + result |= 8; + } + /* Test against bug on Android 4.3. */ + { + char input[3]; + input[0] = 'a'; + input[1] = 'b'; + input[2] = 'c'; + if (memchr (input, 0x789abc00 | 'b', 3) != input + 1) + result |= 16; + } + return result; +]])], + [gl_cv_func_memchr_works=yes], + [gl_cv_func_memchr_works=no], + [case "$host_os" in + # Guess no on Android. + linux*-android*) gl_cv_func_memchr_works="guessing no" ;; + # Guess yes on native Windows. + mingw* | windows*) gl_cv_func_memchr_works="guessing yes" ;; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_memchr_works="$gl_cross_guess_normal" ;; + esac + ]) + ]) + case "$gl_cv_func_memchr_works" in + *yes) ;; + *) REPLACE_MEMCHR=1 ;; + esac +]) + +# Prerequisites of lib/memchr.c. +AC_DEFUN([gl_PREREQ_MEMCHR], [ + AC_CHECK_HEADERS([bp-sym.h]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/mempcpy.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/mempcpy.m4 new file mode 100644 index 00000000..94ce05d1 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/mempcpy.m4 @@ -0,0 +1,29 @@ +# mempcpy.m4 serial 14 +dnl Copyright (C) 2003-2004, 2006-2007, 2009-2024 Free Software Foundation, +dnl Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_MEMPCPY], +[ + dnl Persuade glibc to declare mempcpy(). + AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) + + dnl The mempcpy() declaration in lib/string.in.h uses 'restrict'. + AC_REQUIRE([AC_C_RESTRICT]) + + AC_REQUIRE([gl_STRING_H_DEFAULTS]) + gl_CHECK_FUNCS_ANDROID([mempcpy], [[#include ]]) + if test $ac_cv_func_mempcpy = no; then + HAVE_MEMPCPY=0 + case "$gl_cv_onwards_func_mempcpy" in + future*) REPLACE_MEMPCPY=1 ;; + esac + fi +]) + +# Prerequisites of lib/mempcpy.c. +AC_DEFUN([gl_PREREQ_MEMPCPY], [ + : +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/memrchr.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/memrchr.m4 new file mode 100644 index 00000000..b4ccdfa3 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/memrchr.m4 @@ -0,0 +1,23 @@ +# memrchr.m4 serial 11 +dnl Copyright (C) 2002-2003, 2005-2007, 2009-2024 Free Software Foundation, +dnl Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_MEMRCHR], +[ + dnl Persuade glibc to declare memrchr(). + AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) + + AC_REQUIRE([gl_STRING_H_DEFAULTS]) + AC_CHECK_DECLS_ONCE([memrchr]) + if test $ac_cv_have_decl_memrchr = no; then + HAVE_DECL_MEMRCHR=0 + fi + + AC_CHECK_FUNCS([memrchr]) +]) + +# Prerequisites of lib/memrchr.c. +AC_DEFUN([gl_PREREQ_MEMRCHR], [:]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/minmax.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/minmax.m4 new file mode 100644 index 00000000..5c0a927d --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/minmax.m4 @@ -0,0 +1,44 @@ +# minmax.m4 serial 4 +dnl Copyright (C) 2005, 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_PREREQ([2.53]) + +AC_DEFUN([gl_MINMAX], +[ + AC_REQUIRE([gl_PREREQ_MINMAX]) +]) + +# Prerequisites of lib/minmax.h. +AC_DEFUN([gl_PREREQ_MINMAX], +[ + gl_MINMAX_IN_HEADER([limits.h]) + gl_MINMAX_IN_HEADER([sys/param.h]) +]) + +dnl gl_MINMAX_IN_HEADER(HEADER) +dnl The parameter has to be a literal header name; it cannot be macro, +dnl nor a shell variable. (Because autoheader collects only AC_DEFINE +dnl invocations with a literal macro name.) +AC_DEFUN([gl_MINMAX_IN_HEADER], +[ + m4_pushdef([header], AS_TR_SH([$1])) + m4_pushdef([HEADER], AS_TR_CPP([$1])) + AC_CACHE_CHECK([whether <$1> defines MIN and MAX], + [gl_cv_minmax_in_]header, + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include <$1> + int x = MIN (42, 17);]], + [[]])], + [gl_cv_minmax_in_]header[=yes], + [gl_cv_minmax_in_]header[=no])]) + if test $gl_cv_minmax_in_[]header = yes; then + AC_DEFINE([HAVE_MINMAX_IN_]HEADER, 1, + [Define to 1 if <$1> defines the MIN and MAX macros.]) + fi + m4_popdef([HEADER]) + m4_popdef([header]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/mkdir.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/mkdir.m4 new file mode 100644 index 00000000..48297f90 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/mkdir.m4 @@ -0,0 +1,92 @@ +# serial 20 + +# Copyright (C) 2001, 2003-2004, 2006, 2008-2024 Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# On some systems, mkdir ("foo/", 0700) fails because of the trailing slash. +# On others, mkdir ("foo/./", 0700) mistakenly succeeds. +# On such systems, arrange to use a wrapper function. +AC_DEFUN([gl_FUNC_MKDIR], +[dnl + AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CHECK_HEADERS_ONCE([unistd.h]) + AC_CACHE_CHECK([whether mkdir handles trailing slash], + [gl_cv_func_mkdir_trailing_slash_works], + [rm -rf conftest.dir + AC_RUN_IFELSE( + [AC_LANG_PROGRAM([[ + #include + #include + ]GL_MDA_DEFINES], + [[return mkdir ("conftest.dir/", 0700);]])], + [gl_cv_func_mkdir_trailing_slash_works=yes], + [gl_cv_func_mkdir_trailing_slash_works=no], + [case "$host_os" in + # Guess yes on Linux systems. + linux-* | linux) gl_cv_func_mkdir_trailing_slash_works="guessing yes" ;; + # Guess yes on systems that emulate the Linux system calls. + midipix*) gl_cv_func_mkdir_trailing_slash_works="guessing yes" ;; + # Guess yes on glibc systems. + *-gnu* | gnu*) gl_cv_func_mkdir_trailing_slash_works="guessing yes" ;; + # Guess yes on MSVC, no on mingw. + windows*-msvc*) gl_cv_func_mkdir_trailing_slash_works="guessing yes" ;; + mingw* | windows*) AC_EGREP_CPP([Known], [ +#ifdef _MSC_VER + Known +#endif + ], + [gl_cv_func_mkdir_trailing_slash_works="guessing yes"], + [gl_cv_func_mkdir_trailing_slash_works="guessing no"]) + ;; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_mkdir_trailing_slash_works="$gl_cross_guess_normal" ;; + esac + ]) + rm -rf conftest.dir + ]) + case "$gl_cv_func_mkdir_trailing_slash_works" in + *yes) ;; + *) + REPLACE_MKDIR=1 + ;; + esac + + AC_CACHE_CHECK([whether mkdir handles trailing dot], + [gl_cv_func_mkdir_trailing_dot_works], + [rm -rf conftest.dir + AC_RUN_IFELSE( + [AC_LANG_PROGRAM([[ + #include + #include + ]GL_MDA_DEFINES], + [[return !mkdir ("conftest.dir/./", 0700);]])], + [gl_cv_func_mkdir_trailing_dot_works=yes], + [gl_cv_func_mkdir_trailing_dot_works=no], + [case "$host_os" in + # Guess yes on glibc systems. + *-gnu* | gnu*) gl_cv_func_mkdir_trailing_dot_works="guessing yes" ;; + # Guess yes on musl systems. + *-musl*) gl_cv_func_mkdir_trailing_dot_works="guessing yes" ;; + # Guess yes on systems that emulate the Linux system calls. + midipix*) gl_cv_func_mkdir_trailing_dot_works="guessing yes" ;; + # Guess no on native Windows. + mingw* | windows*) gl_cv_func_mkdir_trailing_dot_works="guessing no" ;; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_mkdir_trailing_dot_works="$gl_cross_guess_normal" ;; + esac + ]) + rm -rf conftest.dir + ] + ) + case "$gl_cv_func_mkdir_trailing_dot_works" in + *yes) ;; + *) + REPLACE_MKDIR=1 + AC_DEFINE([FUNC_MKDIR_DOT_BUG], [1], [Define to 1 if mkdir mistakenly + creates a directory given with a trailing dot component.]) + ;; + esac +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/mkstemp.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/mkstemp.m4 new file mode 100644 index 00000000..106a6b8e --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/mkstemp.m4 @@ -0,0 +1,87 @@ +#serial 30 + +# Copyright (C) 2001, 2003-2007, 2009-2024 Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# On some hosts (e.g., HP-UX 10.20, SunOS 4.1.4, Solaris 2.5.1), mkstemp has a +# silly limit that it can create no more than 26 files from a given template. +# Other systems lack mkstemp altogether. +# On OSF1/Tru64 V4.0F, the system-provided mkstemp function can create +# only 32 files per process. +# On some hosts, mkstemp creates files with mode 0666, which is a security +# problem and a violation of POSIX 2008. +# On systems like the above, arrange to use the replacement function. +AC_DEFUN([gl_FUNC_MKSTEMP], +[ + AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + + AC_CHECK_FUNCS_ONCE([mkstemp]) + if test $ac_cv_func_mkstemp = yes; then + AC_CACHE_CHECK([for working mkstemp], + [gl_cv_func_working_mkstemp], + [ + mkdir conftest.mkstemp + AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [AC_INCLUDES_DEFAULT + GL_MDA_DEFINES], + [[int result = 0; + int i; + off_t large = (off_t) 4294967295u; + if (large < 0) + large = 2147483647; + umask (0); + for (i = 0; i < 70; i++) + { + char templ[] = "conftest.mkstemp/coXXXXXX"; + int (*mkstemp_function) (char *) = mkstemp; + int fd = mkstemp_function (templ); + if (fd < 0) + result |= 1; + else + { + struct stat st; + if (lseek (fd, large, SEEK_SET) != large) + result |= 2; + if (fstat (fd, &st) < 0) + result |= 4; + else if (st.st_mode & 0077) + result |= 8; + if (close (fd)) + result |= 16; + } + } + return result;]])], + [gl_cv_func_working_mkstemp=yes], + [gl_cv_func_working_mkstemp=no], + [case "$host_os" in + # Guess yes on glibc systems. + *-gnu* | gnu*) gl_cv_func_working_mkstemp="guessing yes" ;; + # Guess yes on musl systems. + *-musl* | midipix*) gl_cv_func_working_mkstemp="guessing yes" ;; + # Guess no on native Windows. + mingw* | windows*) gl_cv_func_working_mkstemp="guessing no" ;; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_working_mkstemp="$gl_cross_guess_normal" ;; + esac + ]) + rm -rf conftest.mkstemp + ]) + case "$gl_cv_func_working_mkstemp" in + *yes) ;; + *) + REPLACE_MKSTEMP=1 + ;; + esac + else + HAVE_MKSTEMP=0 + fi +]) + +# Prerequisites of lib/mkstemp.c. +AC_DEFUN([gl_PREREQ_MKSTEMP], +[ +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/mktime.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/mktime.m4 new file mode 100644 index 00000000..0565e5e6 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/mktime.m4 @@ -0,0 +1,318 @@ +# serial 39 +dnl Copyright (C) 2002-2003, 2005-2007, 2009-2024 Free Software Foundation, +dnl Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Jim Meyering. + +AC_DEFUN([gl_TIME_T_IS_SIGNED], +[ + AC_CACHE_CHECK([whether time_t is signed], + [gl_cv_time_t_is_signed], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#include + char time_t_signed[(time_t) -1 < 0 ? 1 : -1];]])], + [gl_cv_time_t_is_signed=yes], + [gl_cv_time_t_is_signed=no])]) + if test $gl_cv_time_t_is_signed = yes; then + AC_DEFINE([TIME_T_IS_SIGNED], [1], [Define to 1 if time_t is signed.]) + fi +]) + +dnl Test whether mktime works. Set gl_cv_func_working_mktime. +AC_DEFUN([gl_FUNC_MKTIME_WORKS], +[ + AC_REQUIRE([gl_TIME_T_IS_SIGNED]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + + dnl We don't use AC_FUNC_MKTIME any more, because it is no longer maintained + dnl in Autoconf and because it invokes AC_LIBOBJ. + AC_CHECK_HEADERS_ONCE([unistd.h]) + AC_CHECK_DECLS_ONCE([alarm]) + AC_REQUIRE([gl_MULTIARCH]) + AC_CACHE_CHECK([for working mktime], [gl_cv_func_working_mktime], + [if test $APPLE_UNIVERSAL_BUILD = 1; then + # A universal build on Apple Mac OS X platforms. + # The test result would be 'yes' in 32-bit mode and 'no' in 64-bit mode. + # But we need a configuration result that is valid in both modes. + gl_cv_func_working_mktime="guessing no" + else + AC_RUN_IFELSE( + [AC_LANG_SOURCE( +[[/* Test program from Paul Eggert and Tony Leneis. */ +#include +#include +#include + +#ifdef HAVE_UNISTD_H +# include +#endif + +#if HAVE_DECL_ALARM +# include +#endif + +]GL_MDA_DEFINES[ + +#ifndef TIME_T_IS_SIGNED +# define TIME_T_IS_SIGNED 0 +#endif + +static time_t time_t_max; +static time_t time_t_min; + +/* Values we'll use to set the TZ environment variable. */ +static char *tz_strings[] = { + (char *) 0, "TZ=GMT0", "TZ=JST-9", + "TZ=EST+3EDT+2,M10.1.0/00:00:00,M2.3.0/00:00:00" +}; +#define N_STRINGS (sizeof (tz_strings) / sizeof (tz_strings[0])) + +/* Return 0 if mktime fails to convert a date in the spring-forward gap. + Based on a problem report from Andreas Jaeger. */ +static int +spring_forward_gap () +{ + /* glibc (up to about 1998-10-07) failed this test. */ + struct tm tm; + + /* Use the portable POSIX.1 specification "TZ=PST8PDT,M4.1.0,M10.5.0" + instead of "TZ=America/Vancouver" in order to detect the bug even + on systems that don't support the Olson extension, or don't have the + full zoneinfo tables installed. */ + if (putenv ("TZ=PST8PDT,M4.1.0,M10.5.0") != 0) + return -1; + + tm.tm_year = 98; + tm.tm_mon = 3; + tm.tm_mday = 5; + tm.tm_hour = 2; + tm.tm_min = 0; + tm.tm_sec = 0; + tm.tm_isdst = -1; + return mktime (&tm) != (time_t) -1; +} + +static int +mktime_test1 (time_t now) +{ + struct tm *lt; + return ! (lt = localtime (&now)) || mktime (lt) == now; +} + +static int +mktime_test (time_t now) +{ + return (mktime_test1 (now) + && mktime_test1 ((time_t) (time_t_max - now)) + && mktime_test1 ((time_t) (time_t_min + now))); +} + +static int +irix_6_4_bug () +{ + /* Based on code from Ariel Faigon. */ + struct tm tm; + tm.tm_year = 96; + tm.tm_mon = 3; + tm.tm_mday = 0; + tm.tm_hour = 0; + tm.tm_min = 0; + tm.tm_sec = 0; + tm.tm_isdst = -1; + mktime (&tm); + return tm.tm_mon == 2 && tm.tm_mday == 31; +} + +static int +bigtime_test (int j) +{ + struct tm tm; + time_t now; + tm.tm_year = tm.tm_mon = tm.tm_mday = tm.tm_hour = tm.tm_min = tm.tm_sec = j; + now = mktime (&tm); + if (now != (time_t) -1) + { + struct tm *lt = localtime (&now); + if (! (lt + && lt->tm_year == tm.tm_year + && lt->tm_mon == tm.tm_mon + && lt->tm_mday == tm.tm_mday + && lt->tm_hour == tm.tm_hour + && lt->tm_min == tm.tm_min + && lt->tm_sec == tm.tm_sec + && lt->tm_yday == tm.tm_yday + && lt->tm_wday == tm.tm_wday + && ((lt->tm_isdst < 0 ? -1 : 0 < lt->tm_isdst) + == (tm.tm_isdst < 0 ? -1 : 0 < tm.tm_isdst)))) + return 0; + } + return 1; +} + +static int +year_2050_test () +{ + /* The correct answer for 2050-02-01 00:00:00 in Pacific time, + ignoring leap seconds. */ + unsigned long int answer = 2527315200UL; + + struct tm tm; + time_t t; + tm.tm_year = 2050 - 1900; + tm.tm_mon = 2 - 1; + tm.tm_mday = 1; + tm.tm_hour = tm.tm_min = tm.tm_sec = 0; + tm.tm_isdst = -1; + + /* Use the portable POSIX.1 specification "TZ=PST8PDT,M4.1.0,M10.5.0" + instead of "TZ=America/Vancouver" in order to detect the bug even + on systems that don't support the Olson extension, or don't have the + full zoneinfo tables installed. */ + if (putenv ("TZ=PST8PDT,M4.1.0,M10.5.0") != 0) + return -1; + + t = mktime (&tm); + + /* Check that the result is either a failure, or close enough + to the correct answer that we can assume the discrepancy is + due to leap seconds. */ + return (t == (time_t) -1 + || (0 < t && answer - 120 <= t && t <= answer + 120)); +} + +static int +indiana_test () +{ + if (putenv ("TZ=America/Indiana/Indianapolis") != 0) + return -1; + struct tm tm; + tm.tm_year = 1986 - 1900; tm.tm_mon = 4 - 1; tm.tm_mday = 28; + tm.tm_hour = 16; tm.tm_min = 24; tm.tm_sec = 50; tm.tm_isdst = 0; + time_t std = mktime (&tm); + if (! (std == 515107490 || std == 515107503)) + return 1; + + /* This platform supports TZDB, either without or with leap seconds. + Return true if GNU Bug#48085 is absent. */ + tm.tm_isdst = 1; + time_t dst = mktime (&tm); + return std - dst == 60 * 60; +} + +int +main () +{ + int result = 0; + time_t t, delta; + int i, j; + int time_t_signed_magnitude = (time_t) ~ (time_t) 0 < (time_t) -1; + +#if HAVE_DECL_ALARM + /* This test makes some buggy mktime implementations loop. + Give up after 60 seconds; a mktime slower than that + isn't worth using anyway. */ + signal (SIGALRM, SIG_DFL); + alarm (60); +#endif + + time_t_max = (! TIME_T_IS_SIGNED + ? (time_t) -1 + : ((((time_t) 1 << (sizeof (time_t) * CHAR_BIT - 2)) - 1) + * 2 + 1)); + time_t_min = (! TIME_T_IS_SIGNED + ? (time_t) 0 + : time_t_signed_magnitude + ? ~ (time_t) 0 + : ~ time_t_max); + + delta = time_t_max / 997; /* a suitable prime number */ + for (i = 0; i < N_STRINGS; i++) + { + if (tz_strings[i]) + putenv (tz_strings[i]); + + for (t = 0; t <= time_t_max - delta && (result & 1) == 0; t += delta) + if (! mktime_test (t)) + result |= 1; + if ((result & 2) == 0 + && ! (mktime_test ((time_t) 1) + && mktime_test ((time_t) (60 * 60)) + && mktime_test ((time_t) (60 * 60 * 24)))) + result |= 2; + + for (j = 1; (result & 4) == 0; j <<= 1) + { + if (! bigtime_test (j)) + result |= 4; + if (INT_MAX / 2 < j) + break; + } + if ((result & 8) == 0 && ! bigtime_test (INT_MAX)) + result |= 8; + } + if (! irix_6_4_bug ()) + result |= 16; + if (! spring_forward_gap ()) + result |= 32; + if (! year_2050_test () || ! indiana_test ()) + result |= 64; + return result; +}]])], + [gl_cv_func_working_mktime=yes], + [gl_cv_func_working_mktime=no], + [case "$host_os" in + # Guess no on native Windows. + mingw* | windows*) gl_cv_func_working_mktime="guessing no" ;; + *) gl_cv_func_working_mktime="$gl_cross_guess_normal" ;; + esac + ]) + fi + ]) +]) + +dnl Main macro of module 'mktime'. +AC_DEFUN([gl_FUNC_MKTIME], +[ + AC_REQUIRE([gl_TIME_H_DEFAULTS]) + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_REQUIRE([gl_FUNC_MKTIME_WORKS]) + + if test "$gl_cv_func_working_mktime" != yes; then + REPLACE_MKTIME=1 + AC_DEFINE([NEED_MKTIME_WORKING], [1], + [Define if the compilation of mktime.c should define 'mktime' + with the algorithmic workarounds.]) + fi + case "$host_os" in + mingw* | windows*) + REPLACE_MKTIME=1 + AC_DEFINE([NEED_MKTIME_WINDOWS], [1], + [Define if the compilation of mktime.c should define 'mktime' + with the native Windows TZ workaround.]) + ;; + esac +]) + +dnl Main macro of module 'mktime-internal'. +AC_DEFUN([gl_FUNC_MKTIME_INTERNAL], [ + AC_REQUIRE([gl_FUNC_MKTIME_WORKS]) + + WANT_MKTIME_INTERNAL=0 + dnl BeOS has __mktime_internal in libc, but other platforms don't. + AC_CHECK_FUNC([__mktime_internal], + [AC_DEFINE([mktime_internal], [__mktime_internal], + [Define to the real name of the mktime_internal function.]) + ], + [dnl mktime works but it doesn't export __mktime_internal, + dnl so we need to substitute our own mktime implementation. + WANT_MKTIME_INTERNAL=1 + AC_DEFINE([NEED_MKTIME_INTERNAL], [1], + [Define if the compilation of mktime.c should define 'mktime_internal'.]) + ]) +]) + +# Prerequisites of lib/mktime.c. +AC_DEFUN([gl_PREREQ_MKTIME], [:]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/mmap-anon.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/mmap-anon.m4 new file mode 100644 index 00000000..642f07db --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/mmap-anon.m4 @@ -0,0 +1,55 @@ +# mmap-anon.m4 serial 12 +dnl Copyright (C) 2005, 2007, 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +# Detect how mmap can be used to create anonymous (not file-backed) memory +# mappings. +# - On Linux, AIX, OSF/1, Solaris, Cygwin, Interix, Haiku, both MAP_ANONYMOUS +# and MAP_ANON exist and have the same value. +# - On HP-UX, only MAP_ANONYMOUS exists. +# - On Mac OS X, FreeBSD, NetBSD, OpenBSD, Minix, only MAP_ANON exists. +# - On IRIX, neither exists, and a file descriptor opened to /dev/zero must be +# used. + +AC_DEFUN_ONCE([gl_FUNC_MMAP_ANON], +[ + dnl Persuade glibc to define MAP_ANONYMOUS. + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + + # Check for mmap(). Don't use AC_FUNC_MMAP, because it checks too much: it + # fails on HP-UX 11, because MAP_FIXED mappings do not work. But this is + # irrelevant for anonymous mappings. + AC_CHECK_FUNC([mmap], [gl_have_mmap=yes], [gl_have_mmap=no]) + + # Try to allow MAP_ANONYMOUS. + gl_have_mmap_anonymous=no + if test $gl_have_mmap = yes; then + AC_MSG_CHECKING([for MAP_ANONYMOUS]) + AC_EGREP_CPP([I cannot identify this map], [ +#include +#ifdef MAP_ANONYMOUS + I cannot identify this map +#endif +], + [gl_have_mmap_anonymous=yes]) + if test $gl_have_mmap_anonymous != yes; then + AC_EGREP_CPP([I cannot identify this map], [ +#include +#ifdef MAP_ANON + I cannot identify this map +#endif +], + [AC_DEFINE([MAP_ANONYMOUS], [MAP_ANON], + [Define to a substitute value for mmap()'s MAP_ANONYMOUS flag.]) + gl_have_mmap_anonymous=yes]) + fi + AC_MSG_RESULT([$gl_have_mmap_anonymous]) + if test $gl_have_mmap_anonymous = yes; then + AC_DEFINE([HAVE_MAP_ANONYMOUS], [1], + [Define to 1 if mmap()'s MAP_ANONYMOUS flag is available after including + config.h and .]) + fi + fi +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/mode_t.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/mode_t.m4 new file mode 100644 index 00000000..af88da51 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/mode_t.m4 @@ -0,0 +1,26 @@ +# mode_t.m4 serial 2 +dnl Copyright (C) 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +# For using mode_t, it's sufficient to use AC_TYPE_MODE_T and +# include . + +# Define PROMOTED_MODE_T to the type that is the result of "default argument +# promotion" (ISO C 6.5.2.2.(6)) of the type mode_t. +AC_DEFUN([gl_PROMOTED_TYPE_MODE_T], +[ + AC_REQUIRE([AC_TYPE_MODE_T]) + AC_CACHE_CHECK([for promoted mode_t type], [gl_cv_promoted_mode_t], [ + dnl Assume mode_t promotes to 'int' if and only if it is smaller than 'int', + dnl and to itself otherwise. This assumption is not guaranteed by the ISO C + dnl standard, but we don't know of any real-world counterexamples. + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], + [[typedef int array[2 * (sizeof (mode_t) < sizeof (int)) - 1];]])], + [gl_cv_promoted_mode_t='int'], + [gl_cv_promoted_mode_t='mode_t']) + ]) + AC_DEFINE_UNQUOTED([PROMOTED_MODE_T], [$gl_cv_promoted_mode_t], + [Define to the type that is the result of default argument promotions of type mode_t.]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/msvc-inval.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/msvc-inval.m4 new file mode 100644 index 00000000..b8ba598e --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/msvc-inval.m4 @@ -0,0 +1,19 @@ +# msvc-inval.m4 serial 1 +dnl Copyright (C) 2011-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_MSVC_INVAL], +[ + AC_CHECK_FUNCS_ONCE([_set_invalid_parameter_handler]) + if test $ac_cv_func__set_invalid_parameter_handler = yes; then + HAVE_MSVC_INVALID_PARAMETER_HANDLER=1 + AC_DEFINE([HAVE_MSVC_INVALID_PARAMETER_HANDLER], [1], + [Define to 1 on MSVC platforms that have the "invalid parameter handler" + concept.]) + else + HAVE_MSVC_INVALID_PARAMETER_HANDLER=0 + fi + AC_SUBST([HAVE_MSVC_INVALID_PARAMETER_HANDLER]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/msvc-nothrow.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/msvc-nothrow.m4 new file mode 100644 index 00000000..3e332a09 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/msvc-nothrow.m4 @@ -0,0 +1,10 @@ +# msvc-nothrow.m4 serial 1 +dnl Copyright (C) 2011-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_MSVC_NOTHROW], +[ + AC_REQUIRE([gl_MSVC_INVAL]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/multiarch.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/multiarch.m4 new file mode 100644 index 00000000..5f8339f5 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/multiarch.m4 @@ -0,0 +1,65 @@ +# multiarch.m4 serial 9 +dnl Copyright (C) 2008-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +# Determine whether the compiler is or may be producing universal binaries. +# +# On Mac OS X 10.5 and later systems, the user can create libraries and +# executables that work on multiple system types--known as "fat" or +# "universal" binaries--by specifying multiple '-arch' options to the +# compiler but only a single '-arch' option to the preprocessor. Like +# this: +# +# ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ +# CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ +# CPP="gcc -E" CXXCPP="g++ -E" +# +# Detect this situation and set APPLE_UNIVERSAL_BUILD accordingly. + +AC_DEFUN_ONCE([gl_MULTIARCH], +[ + dnl Code similar to autoconf-2.63 AC_C_BIGENDIAN. + AC_CACHE_CHECK([whether the compiler produces multi-arch binaries], + [gl_cv_c_multiarch], + [gl_cv_c_multiarch=no + AC_COMPILE_IFELSE( + [AC_LANG_SOURCE( + [[#ifndef __APPLE_CC__ + not a universal capable compiler + #endif + typedef int dummy; + ]])], + [ + dnl Check for potential -arch flags. It is not universal unless + dnl there are at least two -arch flags with different values. + arch= + prev= + for word in ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}; do + if test -n "$prev"; then + case $word in + i?86 | x86_64 | ppc | ppc64 | arm | arm64) + if test -z "$arch" || test "$arch" = "$word"; then + arch="$word" + else + gl_cv_c_multiarch=yes + fi + ;; + esac + prev= + else + if test "x$word" = "x-arch"; then + prev=arch + fi + fi + done + ]) + ]) + if test $gl_cv_c_multiarch = yes; then + APPLE_UNIVERSAL_BUILD=1 + else + APPLE_UNIVERSAL_BUILD=0 + fi + AC_SUBST([APPLE_UNIVERSAL_BUILD]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/musl.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/musl.m4 new file mode 100644 index 00000000..34d2c1ff --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/musl.m4 @@ -0,0 +1,20 @@ +# musl.m4 serial 4 +dnl Copyright (C) 2019-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +# Test for musl libc, despite the musl libc authors don't like it +# +# . +# From Bruno Haible. + +AC_DEFUN_ONCE([gl_MUSL_LIBC], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) + case "$host_os" in + *-musl* | midipix*) + AC_DEFINE([MUSL_LIBC], [1], [Define to 1 on musl libc.]) + ;; + esac +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/nan-mips.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/nan-mips.m4 new file mode 100644 index 00000000..d5650e19 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/nan-mips.m4 @@ -0,0 +1,89 @@ +# nan-mips.m4 serial 1 +dnl Copyright (C) 2023-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +# Extra meta-info mentioned by lib/snan.h. +AC_DEFUN_ONCE([gl_NAN_MIPS], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) + case "$host_cpu" in + mips*) + AC_CACHE_CHECK([whether the NaN float encoding is IEEE 754-2008 compliant], + [gl_cv_nan2008_f], + [AC_RUN_IFELSE( + [AC_LANG_PROGRAM([[ + float volatile zero; + /* Assume 'float' has 32 bits, i.e. IEEE single-float. */ + union { float value; unsigned int word; } qnan; + ]], + [[qnan.value = zero / zero; + return !((qnan.word >> 22) & 1); + ]]) + ], + [gl_cv_nan2008_f=yes], + [gl_cv_nan2008_f=no], + [gl_cv_nan2008_f="guessing no"]) + ]) + case "$gl_cv_nan2008_f" in + *yes) gl_mips_nan2008_f=1 ;; + *) gl_mips_nan2008_f=0 ;; + esac + AC_DEFINE_UNQUOTED([MIPS_NAN2008_FLOAT], [$gl_mips_nan2008_f], + [Define to 1 if the encoding of NaN 'float's is as in IEEE 754-2008 § 6.2.1.]) + + AC_CACHE_CHECK([whether the NaN double encoding is IEEE 754-2008 compliant], + [gl_cv_nan2008_d], + [AC_RUN_IFELSE( + [AC_LANG_PROGRAM([[ + double volatile zero; + /* Assume 'double' has 64 bits, i.e. IEEE double-float. */ + union { double value; unsigned long long word; } qnan; + ]], + [[qnan.value = zero / zero; + return !((qnan.word >> 51) & 1); + ]]) + ], + [gl_cv_nan2008_d=yes], + [gl_cv_nan2008_d=no], + [gl_cv_nan2008_d="guessing no"]) + ]) + case "$gl_cv_nan2008_d" in + *yes) gl_mips_nan2008_d=1 ;; + *) gl_mips_nan2008_d=0 ;; + esac + AC_DEFINE_UNQUOTED([MIPS_NAN2008_DOUBLE], [$gl_mips_nan2008_d], + [Define to 1 if the encoding of NaN 'double's is as in IEEE 754-2008 § 6.2.1.]) + + AC_CACHE_CHECK([whether the NaN long double encoding is IEEE 754-2008 compliant], + [gl_cv_nan2008_l], + [AC_RUN_IFELSE( + [AC_LANG_PROGRAM([[ + #include + long double volatile zero; + #define NWORDS \ + ((sizeof (long double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) + union { long double value; unsigned int word[NWORDS]; } qnan; + ]], + [[qnan.value = zero / zero; + #if defined _MIPSEB /* equivalent: __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ */ + return !((qnan.word[0] >> ((LDBL_MANT_DIG - 2) % 32)) & 1); + #else + return !((qnan.word[NWORDS - 1] >> ((LDBL_MANT_DIG - 2) % 32)) & 1); + #endif + ]]) + ], + [gl_cv_nan2008_l=yes], + [gl_cv_nan2008_l=no], + [gl_cv_nan2008_l="guessing no"]) + ]) + case "$gl_cv_nan2008_l" in + *yes) gl_mips_nan2008_l=1 ;; + *) gl_mips_nan2008_l=0 ;; + esac + AC_DEFINE_UNQUOTED([MIPS_NAN2008_LONG_DOUBLE], [$gl_mips_nan2008_l], + [Define to 1 if the encoding of NaN 'long double's is as in IEEE 754-2008 § 6.2.1.]) + ;; + esac +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/nanosleep.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/nanosleep.m4 new file mode 100644 index 00000000..2302d2d9 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/nanosleep.m4 @@ -0,0 +1,151 @@ +# serial 45 + +dnl From Jim Meyering. +dnl Check for the nanosleep function. +dnl If not found, use the supplied replacement. +dnl + +# Copyright (C) 1999-2001, 2003-2024 Free Software Foundation, Inc. + +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_NANOSLEEP], +[ + AC_REQUIRE([gl_TIME_H_DEFAULTS]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + + dnl Persuade glibc and Solaris to declare nanosleep. + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + + AC_CHECK_DECLS_ONCE([alarm]) + + nanosleep_save_libs=$LIBS + + # Solaris 2.5.1 needs -lposix4 to get the nanosleep function. + # Solaris 7 prefers the library name -lrt to the obsolescent name -lposix4. + NANOSLEEP_LIB= + AC_SUBST([NANOSLEEP_LIB]) + AC_SEARCH_LIBS([nanosleep], [rt posix4], + [test "$ac_cv_search_nanosleep" = "none required" || + NANOSLEEP_LIB=$ac_cv_search_nanosleep]) + if test "x$ac_cv_search_nanosleep" != xno; then + dnl The system has a nanosleep function. + + AC_REQUIRE([gl_MULTIARCH]) + if test $APPLE_UNIVERSAL_BUILD = 1; then + # A universal build on Apple Mac OS X platforms. + # The test result would be 'no (mishandles large arguments)' in 64-bit + # mode but 'yes' in 32-bit mode. But we need a configuration result that + # is valid in both modes. + gl_cv_func_nanosleep='no (mishandles large arguments)' + fi + + AC_CACHE_CHECK([for working nanosleep], + [gl_cv_func_nanosleep], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ + #include + #include + #include + #include + #include + #define TYPE_SIGNED(t) (! ((t) 0 < (t) -1)) + #define TYPE_MAXIMUM(t) \ + ((t) (! TYPE_SIGNED (t) \ + ? (t) -1 \ + : ((((t) 1 << (sizeof (t) * CHAR_BIT - 2)) - 1) * 2 + 1))) + + #if HAVE_DECL_ALARM + static void + check_for_SIGALRM (int sig) + { + if (sig != SIGALRM) + _exit (1); + } + #endif + + int + main () + { + static struct timespec ts_sleep; + static struct timespec ts_remaining; + /* Test for major problems first. */ + if (! nanosleep) + return 2; + ts_sleep.tv_sec = 0; + ts_sleep.tv_nsec = 1; + #if HAVE_DECL_ALARM + { + static struct sigaction act; + act.sa_handler = check_for_SIGALRM; + sigemptyset (&act.sa_mask); + sigaction (SIGALRM, &act, NULL); + alarm (1); + if (nanosleep (&ts_sleep, NULL) != 0) + return 3; + /* Test for a minor problem: the handling of large arguments. */ + ts_sleep.tv_sec = TYPE_MAXIMUM (time_t); + ts_sleep.tv_nsec = 999999999; + alarm (1); + if (nanosleep (&ts_sleep, &ts_remaining) != -1) + return 4; + if (errno != EINTR) + return 5; + if (ts_remaining.tv_sec <= TYPE_MAXIMUM (time_t) - 10) + return 6; + } + #else /* A simpler test for native Windows. */ + if (nanosleep (&ts_sleep, &ts_remaining) < 0) + return 3; + /* Test for 32-bit mingw bug: negative nanosecond values do not + cause failure. */ + ts_sleep.tv_sec = 1; + ts_sleep.tv_nsec = -1; + if (nanosleep (&ts_sleep, &ts_remaining) != -1) + return 7; + #endif + return 0; + }]])], + [gl_cv_func_nanosleep=yes], + [case $? in + 4|5|6) gl_cv_func_nanosleep='no (mishandles large arguments)' ;; + 7) gl_cv_func_nanosleep='no (mishandles negative tv_nsec)' ;; + *) gl_cv_func_nanosleep=no ;; + esac], + [case "$host_os" in + # Guess it halfway works when the kernel is Linux. + linux*) + gl_cv_func_nanosleep='guessing no (mishandles large arguments)' ;; + # Guess no on native Windows. + mingw* | windows*) + gl_cv_func_nanosleep='guessing no' ;; + # If we don't know, obey --enable-cross-guesses. + *) + gl_cv_func_nanosleep="$gl_cross_guess_normal" ;; + esac + ]) + ]) + case "$gl_cv_func_nanosleep" in + *yes) ;; + *) + REPLACE_NANOSLEEP=1 + case "$gl_cv_func_nanosleep" in + *"mishandles large arguments"*) + AC_DEFINE([HAVE_BUG_BIG_NANOSLEEP], [1], + [Define to 1 if nanosleep mishandles large arguments.]) + ;; + esac + ;; + esac + else + HAVE_NANOSLEEP=0 + fi + LIBS=$nanosleep_save_libs + + # For backward compatibility. + LIB_NANOSLEEP="$NANOSLEEP_LIB" + AC_SUBST([LIB_NANOSLEEP]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/netinet_in_h.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/netinet_in_h.m4 new file mode 100644 index 00000000..9618c0cc --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/netinet_in_h.m4 @@ -0,0 +1,29 @@ +# netinet_in_h.m4 serial 6 +dnl Copyright (C) 2006-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_HEADER_NETINET_IN], +[ + AC_CACHE_CHECK([whether is self-contained], + [gl_cv_header_netinet_in_h_selfcontained], + [ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[]])], + [gl_cv_header_netinet_in_h_selfcontained=yes], + [gl_cv_header_netinet_in_h_selfcontained=no]) + ]) + if test $gl_cv_header_netinet_in_h_selfcontained = yes; then + GL_GENERATE_NETINET_IN_H=false + else + GL_GENERATE_NETINET_IN_H=true + AC_CHECK_HEADERS([netinet/in.h]) + gl_CHECK_NEXT_HEADERS([netinet/in.h]) + if test $ac_cv_header_netinet_in_h = yes; then + HAVE_NETINET_IN_H=1 + else + HAVE_NETINET_IN_H=0 + fi + AC_SUBST([HAVE_NETINET_IN_H]) + fi +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/nl_langinfo.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/nl_langinfo.m4 new file mode 100644 index 00000000..3ffefe3c --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/nl_langinfo.m4 @@ -0,0 +1,80 @@ +# nl_langinfo.m4 serial 11 +dnl Copyright (C) 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_NL_LANGINFO], +[ + AC_REQUIRE([gl_LANGINFO_H_DEFAULTS]) + AC_REQUIRE([gl_LANGINFO_H]) + gl_CHECK_FUNCS_ANDROID([nl_langinfo], [[#include ]]) + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_REQUIRE([gl_FUNC_SETLOCALE_NULL]) + AC_REQUIRE([gl_PTHREADLIB]) + AC_CHECK_HEADERS_ONCE([threads.h]) + if test $ac_cv_func_nl_langinfo = yes; then + # On Irix 6.5, YESEXPR is defined, but nl_langinfo(YESEXPR) is broken. + AC_CACHE_CHECK([whether YESEXPR works], + [gl_cv_func_nl_langinfo_yesexpr_works], + [AC_RUN_IFELSE( + [AC_LANG_PROGRAM([[#include +]], [[return !*nl_langinfo(YESEXPR); +]])], + [gl_cv_func_nl_langinfo_yesexpr_works=yes], + [gl_cv_func_nl_langinfo_yesexpr_works=no], + [ + case "$host_os" in + # Guess no on irix systems. + irix*) gl_cv_func_nl_langinfo_yesexpr_works="guessing no";; + # Guess yes elsewhere. + *) gl_cv_func_nl_langinfo_yesexpr_works="guessing yes";; + esac + ]) + ]) + case $gl_cv_func_nl_langinfo_yesexpr_works in + *yes) FUNC_NL_LANGINFO_YESEXPR_WORKS=1 ;; + *) FUNC_NL_LANGINFO_YESEXPR_WORKS=0 ;; + esac + AC_DEFINE_UNQUOTED([FUNC_NL_LANGINFO_YESEXPR_WORKS], + [$FUNC_NL_LANGINFO_YESEXPR_WORKS], + [Define to 1 if nl_langinfo (YESEXPR) returns a non-empty string.]) + # On Solaris 10 and Solaris 11.3, nl_langinfo is not multithread-safe. + case "$host_os" in + solaris*) NL_LANGINFO_MTSAFE=0 ;; + *) NL_LANGINFO_MTSAFE=1 ;; + esac + AC_DEFINE_UNQUOTED([NL_LANGINFO_MTSAFE], [$NL_LANGINFO_MTSAFE], + [Define to 1 if nl_langinfo is multithread-safe.]) + if test $HAVE_LANGINFO_CODESET = 1 \ + && test $HAVE_LANGINFO_T_FMT_AMPM = 1 \ + && test $HAVE_LANGINFO_ALTMON = 1 \ + && test $HAVE_LANGINFO_ERA = 1 \ + && test $FUNC_NL_LANGINFO_YESEXPR_WORKS = 1 \ + && test $NL_LANGINFO_MTSAFE = 1; then + : + else + REPLACE_NL_LANGINFO=1 + AC_DEFINE([REPLACE_NL_LANGINFO], [1], + [Define if nl_langinfo exists but is overridden by gnulib.]) + fi + else + HAVE_NL_LANGINFO=0 + case "$gl_cv_onwards_func_nl_langinfo" in + future*) REPLACE_NL_LANGINFO=1 ;; + esac + fi + if test $HAVE_NL_LANGINFO = 0 || test $HAVE_LANGINFO_CODESET = 0; then + LIB_NL_LANGINFO="$SETLOCALE_NULL_LIB" + else + LIB_NL_LANGINFO= + fi + dnl LIB_NL_LANGINFO is expected to be empty everywhere. + AC_SUBST([LIB_NL_LANGINFO]) +]) + +# Prerequisites of lib/nl_langinfo-lock.c. +AC_DEFUN([gl_PREREQ_NL_LANGINFO_LOCK], +[ + gl_VISIBILITY +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/nocrash.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/nocrash.m4 new file mode 100644 index 00000000..9730fc09 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/nocrash.m4 @@ -0,0 +1,131 @@ +# nocrash.m4 serial 5 +dnl Copyright (C) 2005, 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl Based on libsigsegv, from Bruno Haible and Paolo Bonzini. + +AC_PREREQ([2.13]) + +dnl Expands to some code for use in .c programs that will cause the configure +dnl test to exit instead of crashing. This is useful to avoid triggering +dnl action from a background debugger and to avoid core dumps. +dnl Usage: ... +dnl ]GL_NOCRASH[ +dnl ... +dnl int main() { nocrash_init(); ... } +AC_DEFUN([GL_NOCRASH],[[ +#include +#if defined __MACH__ && defined __APPLE__ +/* Avoid a crash on Mac OS X. */ +#include +#include +#include +#include +#include +#include +/* The exception port on which our thread listens. */ +static mach_port_t our_exception_port; +/* The main function of the thread listening for exceptions of type + EXC_BAD_ACCESS. */ +static void * +mach_exception_thread (void *arg) +{ + /* Buffer for a message to be received. */ + struct { + mach_msg_header_t head; + mach_msg_body_t msgh_body; + char data[1024]; + } msg; + mach_msg_return_t retval; + /* Wait for a message on the exception port. */ + retval = mach_msg (&msg.head, MACH_RCV_MSG | MACH_RCV_LARGE, 0, sizeof (msg), + our_exception_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (retval != MACH_MSG_SUCCESS) + abort (); + exit (1); +} +static void +nocrash_init (void) +{ + mach_port_t self = mach_task_self (); + /* Allocate a port on which the thread shall listen for exceptions. */ + if (mach_port_allocate (self, MACH_PORT_RIGHT_RECEIVE, &our_exception_port) + == KERN_SUCCESS) { + /* See https://web.mit.edu/darwin/src/modules/xnu/osfmk/man/mach_port_insert_right.html. */ + if (mach_port_insert_right (self, our_exception_port, our_exception_port, + MACH_MSG_TYPE_MAKE_SEND) + == KERN_SUCCESS) { + /* The exceptions we want to catch. Only EXC_BAD_ACCESS is interesting + for us. */ + exception_mask_t mask = EXC_MASK_BAD_ACCESS; + /* Create the thread listening on the exception port. */ + pthread_attr_t attr; + pthread_t thread; + if (pthread_attr_init (&attr) == 0 + && pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED) == 0 + && pthread_create (&thread, &attr, mach_exception_thread, NULL) == 0) { + pthread_attr_destroy (&attr); + /* Replace the exception port info for these exceptions with our own. + Note that we replace the exception port for the entire task, not only + for a particular thread. This has the effect that when our exception + port gets the message, the thread specific exception port has already + been asked, and we don't need to bother about it. + See https://web.mit.edu/darwin/src/modules/xnu/osfmk/man/task_set_exception_ports.html. */ + task_set_exception_ports (self, mask, our_exception_port, + EXCEPTION_DEFAULT, MACHINE_THREAD_STATE); + } + } + } +} +#elif defined _WIN32 && ! defined __CYGWIN__ +/* Avoid a crash on native Windows. */ +#define WIN32_LEAN_AND_MEAN +#include +#include +static LONG WINAPI +exception_filter (EXCEPTION_POINTERS *ExceptionInfo) +{ + switch (ExceptionInfo->ExceptionRecord->ExceptionCode) + { + case EXCEPTION_ACCESS_VIOLATION: + case EXCEPTION_IN_PAGE_ERROR: + case EXCEPTION_STACK_OVERFLOW: + case EXCEPTION_GUARD_PAGE: + case EXCEPTION_PRIV_INSTRUCTION: + case EXCEPTION_ILLEGAL_INSTRUCTION: + case EXCEPTION_DATATYPE_MISALIGNMENT: + case EXCEPTION_ARRAY_BOUNDS_EXCEEDED: + case EXCEPTION_NONCONTINUABLE_EXCEPTION: + exit (1); + } + return EXCEPTION_CONTINUE_SEARCH; +} +static void +nocrash_init (void) +{ + SetUnhandledExceptionFilter ((LPTOP_LEVEL_EXCEPTION_FILTER) exception_filter); +} +#else +/* Avoid a crash on POSIX systems. */ +#include +#include +/* A POSIX signal handler. */ +static void +exception_handler (int sig) +{ + _exit (1); +} +static void +nocrash_init (void) +{ +#ifdef SIGSEGV + signal (SIGSEGV, exception_handler); +#endif +#ifdef SIGBUS + signal (SIGBUS, exception_handler); +#endif +} +#endif +]]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/nstrftime.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/nstrftime.m4 new file mode 100644 index 00000000..67250dc9 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/nstrftime.m4 @@ -0,0 +1,22 @@ +# serial 37 + +# Copyright (C) 1996-1997, 1999-2007, 2009-2024 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# Written by Jim Meyering and Paul Eggert. + +AC_DEFUN([gl_FUNC_GNU_STRFTIME], +[ + AC_REQUIRE([AC_C_RESTRICT]) + + # This defines (or not) HAVE_TZNAME and HAVE_STRUCT_TM_TM_ZONE. + AC_REQUIRE([AC_STRUCT_TIMEZONE]) + + AC_REQUIRE([gl_TM_GMTOFF]) + + AC_DEFINE([my_strftime], [nstrftime], + [Define to the name of the strftime replacement function.]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/nullptr.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/nullptr.m4 new file mode 100644 index 00000000..f5721e5c --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/nullptr.m4 @@ -0,0 +1,62 @@ +# Check for nullptr that conforms to C23 and C++11. + +dnl Copyright 2023-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_NULLPTR], +[ + m4_provide_if([AC_PROG_CC], + [AC_LANG_PUSH([C]) + AC_CACHE_CHECK([for C nullptr], [gl_cv_c_nullptr], + [AC_COMPILE_IFELSE( + [AC_LANG_SOURCE([[int *p = nullptr;]])], + [gl_cv_c_nullptr=yes], + [gl_cv_c_nullptr=no])]) + gl_c_nullptr=$gl_cv_c_nullptr + AC_LANG_POP([C])], + [gl_c_nullptr=no]) + if test "$gl_c_nullptr" = yes; then + AC_DEFINE([HAVE_C_NULLPTR], [1], + [Define to 1 if C nullptr is known to work.]) + fi + + m4_provide_if([AC_PROG_CXX], + [AC_LANG_PUSH([C++]) + AC_CACHE_CHECK([for C++ nullptr], [gl_cv_cxx_nullptr], + [AC_COMPILE_IFELSE( + [AC_LANG_SOURCE([[int *p = nullptr;]])], + [gl_cv_cxx_nullptr=yes], + [AC_COMPILE_IFELSE( + [AC_LANG_SOURCE([[#include + int *p = nullptr;]])], + [gl_cv_cxx_nullptr="yes, but it is a macro"], + [gl_cv_cxx_nullptr=no])])]) + AS_CASE([$gl_cv_cxx_nullptr], + [yes], [gl_have_cxx_nullptr=1], + [yes*], [gl_have_cxx_nullptr="(-1)"], + [gl_have_cxx_nullptr=0]) + AC_DEFINE_UNQUOTED([HAVE_CXX_NULLPTR], [$gl_have_cxx_nullptr], + [Define to 1 if C++ nullptr works, 0 if not, + (-1) if it is a macro.]) + AC_LANG_POP([C++])]) +]) + + AH_VERBATIM([zznullptr], +[#if defined __cplusplus && HAVE_CXX_NULLPTR < 0 +# include +# undef/**/nullptr +#endif +#ifndef nullptr +# if !defined __cplusplus && !defined HAVE_C_NULLPTR +# define nullptr ((void *) 0) +# elif defined __cplusplus && HAVE_CXX_NULLPTR <= 0 +# if 3 <= __GNUG__ +# define nullptr __null +# else +# define nullptr 0L +# endif +# endif +#endif]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/off_t.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/off_t.m4 new file mode 100644 index 00000000..f3259f9c --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/off_t.m4 @@ -0,0 +1,18 @@ +# off_t.m4 serial 1 +dnl Copyright (C) 2012-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl Check whether to override the 'off_t' type. +dnl Set WINDOWS_64_BIT_OFF_T. + +AC_DEFUN([gl_TYPE_OFF_T], +[ + m4_ifdef([gl_LARGEFILE], [ + AC_REQUIRE([gl_LARGEFILE]) + ], [ + WINDOWS_64_BIT_OFF_T=0 + ]) + AC_SUBST([WINDOWS_64_BIT_OFF_T]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/open-cloexec.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/open-cloexec.m4 new file mode 100644 index 00000000..a2d50329 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/open-cloexec.m4 @@ -0,0 +1,21 @@ +# Test whether O_CLOEXEC is defined. + +dnl Copyright 2017-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_PREPROC_O_CLOEXEC], +[ + AC_CACHE_CHECK([for O_CLOEXEC], + [gl_cv_macro_O_CLOEXEC], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#include + #ifndef O_CLOEXEC + choke me; + #endif + ]], + [[return O_CLOEXEC;]])], + [gl_cv_macro_O_CLOEXEC=yes], + [gl_cv_macro_O_CLOEXEC=no])]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/open-slash.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/open-slash.m4 new file mode 100644 index 00000000..45310c0c --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/open-slash.m4 @@ -0,0 +1,60 @@ +# open-slash.m4 serial 2 +dnl Copyright (C) 2007-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl Tests whether open() and creat() recognize a trailing slash. +dnl Sets gl_cv_func_open_slash. +AC_DEFUN([gl_OPEN_TRAILING_SLASH_BUG], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + dnl open("foo/") should not create a file when the file name has a + dnl trailing slash. FreeBSD only has the problem on symlinks. + AC_CHECK_FUNCS_ONCE([lstat]) + AC_CACHE_CHECK([whether open recognizes a trailing slash], + [gl_cv_func_open_slash], + [# Assume that if we have lstat, we can also check symlinks. + if test $ac_cv_func_lstat = yes; then + touch conftest.tmp + ln -s conftest.tmp conftest.lnk + fi + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#if HAVE_UNISTD_H +# include +#endif +]GL_MDA_DEFINES[ +int main () +{ + int result = 0; +#if HAVE_LSTAT + if (open ("conftest.lnk/", O_RDONLY) != -1) + result |= 1; +#endif + if (open ("conftest.sl/", O_CREAT, 0600) >= 0) + result |= 2; + return result; +}]])], + [gl_cv_func_open_slash=yes], + [gl_cv_func_open_slash=no], + [ +changequote(,)dnl + case "$host_os" in + freebsd* | aix* | hpux* | solaris2.[0-9] | solaris2.[0-9].*) + gl_cv_func_open_slash="guessing no" ;; + *) + gl_cv_func_open_slash="guessing yes" ;; + esac +changequote([,])dnl + ]) + rm -f conftest.sl conftest.tmp conftest.lnk + ]) + case "$gl_cv_func_open_slash" in + *no) + AC_DEFINE([OPEN_TRAILING_SLASH_BUG], [1], + [Define to 1 if open() fails to recognize a trailing slash.]) + ;; + esac +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/open.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/open.m4 new file mode 100644 index 00000000..91e5c31b --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/open.m4 @@ -0,0 +1,56 @@ +# open.m4 serial 16 +dnl Copyright (C) 2007-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_OPEN], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_REQUIRE([gl_PREPROC_O_CLOEXEC]) + case "$host_os" in + mingw* | windows* | pw*) + REPLACE_OPEN=1 + ;; + *) + dnl open("foo/") should not create a file when the file name has a + dnl trailing slash. FreeBSD only has the problem on symlinks. + AC_CHECK_FUNCS_ONCE([lstat]) + if test "$gl_cv_macro_O_CLOEXEC" != yes; then + REPLACE_OPEN=1 + fi + gl_OPEN_TRAILING_SLASH_BUG + case "$gl_cv_func_open_slash" in + *no) + REPLACE_OPEN=1 + ;; + esac + ;; + esac + dnl Replace open() for supporting the gnulib-defined fchdir() function, + dnl to keep fchdir's bookkeeping up-to-date. + m4_ifdef([gl_FUNC_FCHDIR], [ + if test $REPLACE_OPEN = 0; then + gl_TEST_FCHDIR + if test $HAVE_FCHDIR = 0; then + REPLACE_OPEN=1 + fi + fi + ]) + dnl Replace open() for supporting the gnulib-defined O_NONBLOCK flag. + m4_ifdef([gl_NONBLOCKING_IO], [ + if test $REPLACE_OPEN = 0; then + gl_NONBLOCKING_IO + if test $gl_cv_have_open_O_NONBLOCK != yes; then + REPLACE_OPEN=1 + fi + fi + ]) +]) + +# Prerequisites of lib/open.c. +AC_DEFUN([gl_PREREQ_OPEN], +[ + AC_REQUIRE([gl_PROMOTED_TYPE_MODE_T]) + : +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/openat.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/openat.m4 new file mode 100644 index 00000000..47cd93c8 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/openat.m4 @@ -0,0 +1,38 @@ +# serial 46 +# See if we need to use our replacement for Solaris' openat et al functions. + +dnl Copyright (C) 2004-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +# Written by Jim Meyering. + +AC_DEFUN([gl_FUNC_OPENAT], +[ + AC_REQUIRE([gl_FCNTL_H_DEFAULTS]) + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + AC_CHECK_FUNCS_ONCE([openat]) + AC_REQUIRE([gl_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK]) + AC_REQUIRE([gl_PREPROC_O_CLOEXEC]) + case $ac_cv_func_openat+$gl_cv_func_lstat_dereferences_slashed_symlink+$gl_cv_macro_O_CLOEXEC in + yes+*yes+yes) + ;; + yes+*) + # Solaris 10 lacks O_CLOEXEC. + # Solaris 9 has *at functions, but uniformly mishandles trailing + # slash in all of them. + REPLACE_OPENAT=1 + ;; + *) + HAVE_OPENAT=0 + ;; + esac +]) + +# Prerequisites of lib/openat.c. +AC_DEFUN([gl_PREREQ_OPENAT], +[ + AC_REQUIRE([gl_PROMOTED_TYPE_MODE_T]) + : +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/opendir.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/opendir.m4 new file mode 100644 index 00000000..7cc86325 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/opendir.m4 @@ -0,0 +1,31 @@ +# opendir.m4 serial 7 +dnl Copyright (C) 2011-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_OPENDIR], +[ + AC_REQUIRE([gl_DIRENT_H_DEFAULTS]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + + AC_CHECK_FUNCS([opendir]) + if test $ac_cv_func_opendir = no; then + HAVE_OPENDIR=0 + else + dnl Replace opendir() on native Windows and OS/2 kLIBC, + dnl to support fdopendir(). + AC_REQUIRE([gl_DIRENT_DIR]) + if test $DIR_HAS_FD_MEMBER = 0; then + REPLACE_OPENDIR=1 + fi + dnl Replace opendir() for supporting the gnulib-defined fchdir() function, + dnl to keep fchdir's bookkeeping up-to-date. + m4_ifdef([gl_FUNC_FCHDIR], [ + gl_TEST_FCHDIR + if test $HAVE_FCHDIR = 0; then + REPLACE_OPENDIR=1 + fi + ]) + fi +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/pathmax.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/pathmax.m4 new file mode 100644 index 00000000..a0fc296c --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/pathmax.m4 @@ -0,0 +1,42 @@ +# pathmax.m4 serial 11 +dnl Copyright (C) 2002-2003, 2005-2006, 2009-2024 Free Software Foundation, +dnl Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_PATHMAX], +[ + dnl Prerequisites of lib/pathmax.h. + AC_CHECK_HEADERS_ONCE([sys/param.h]) +]) + +# Expands to a piece of C program that defines PATH_MAX in the same way as +# "pathmax.h" will do. +AC_DEFUN([gl_PATHMAX_SNIPPET], [[ +/* Arrange to define PATH_MAX, like "pathmax.h" does. */ +#if HAVE_UNISTD_H +# include +#endif +#include +#if defined HAVE_SYS_PARAM_H && !defined PATH_MAX && !defined MAXPATHLEN +# include +#endif +#if !defined PATH_MAX && defined MAXPATHLEN +# define PATH_MAX MAXPATHLEN +#endif +#ifdef __hpux +# undef PATH_MAX +# define PATH_MAX 1024 +#endif +#if defined _WIN32 && ! defined __CYGWIN__ +# undef PATH_MAX +# define PATH_MAX 260 +#endif +]]) + +# Prerequisites of gl_PATHMAX_SNIPPET. +AC_DEFUN([gl_PATHMAX_SNIPPET_PREREQ], +[ + AC_CHECK_HEADERS_ONCE([unistd.h sys/param.h]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/pclose.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/pclose.m4 new file mode 100644 index 00000000..ed4ccc63 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/pclose.m4 @@ -0,0 +1,20 @@ +# pclose.m4 serial 1 +dnl Copyright (C) 2011-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_PCLOSE], +[ + AC_REQUIRE([gl_STDIO_H_DEFAULTS]) + AC_CHECK_FUNCS_ONCE([pclose]) + if test $ac_cv_func_pclose = no; then + HAVE_PCLOSE=0 + fi +]) + +# Prerequisites of lib/pclose.c. +AC_DEFUN([gl_PREREQ_PCLOSE], +[ + : +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/perl.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/perl.m4 new file mode 100644 index 00000000..51a3c215 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/perl.m4 @@ -0,0 +1,53 @@ +# serial 11 + +dnl From Jim Meyering. +dnl Find a new-enough version of Perl. + +# Copyright (C) 1998-2001, 2003-2004, 2007, 2009-2024 Free Software Foundation, +# Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_PERL], +[ + dnl FIXME: don't hard-code 5.005 +AC_CACHE_CHECK([for Perl 5.005 or newer], + [gl_cv_prog_perl], + [ + if test "${PERL+set}" = set; then + # 'PERL' is set in the user's environment. + candidate_perl_names="$PERL" + perl_specified=yes + else + candidate_perl_names='perl perl5' + perl_specified=no + fi + + gl_cv_prog_perl=no + for perl in $candidate_perl_names; do + # Run test in a subshell; some versions of sh will print an error if + # an executable is not found, even if stderr is redirected. + if ( $perl -e 'require 5.005; use File::Compare; use warnings;' ) > /dev/null 2>&1; then + gl_cv_prog_perl=$perl + break + fi + done + ]) + +if test "$gl_cv_prog_perl" != no; then + PERL=$gl_cv_prog_perl +else + PERL="$am_missing_run perl" + AC_MSG_WARN([ +WARNING: You don't seem to have perl5.005 or newer installed, or you lack + a usable version of the Perl File::Compare module. As a result, + you may be unable to run a few tests or to regenerate certain + files if you modify the sources from which they are derived. +] ) +fi + +AC_SUBST([PERL]) + +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/perror.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/perror.m4 new file mode 100644 index 00000000..6538c252 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/perror.m4 @@ -0,0 +1,76 @@ +# perror.m4 serial 13 +dnl Copyright (C) 2008-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_PERROR], +[ + AC_REQUIRE([gl_STDIO_H_DEFAULTS]) + AC_REQUIRE([gl_HEADER_ERRNO_H]) + AC_REQUIRE([gl_FUNC_STRERROR_R]) + AC_REQUIRE([gl_FUNC_STRERROR_0]) + AC_REQUIRE([AC_CANONICAL_HOST]) + dnl We intentionally do not check for the broader REPLACE_STRERROR_R, + dnl since on glibc systems, strerror_r is replaced only for signature + dnl issues, and perror is just fine. Rather, we only want to + dnl replace perror if strerror_r was replaced for a content fix. + if test "$GL_GENERATE_ERRNO_H:$REPLACE_STRERROR_0" != false:0; then + dnl The system's perror() cannot know about the new errno values we add + dnl to , or any fix for strerror(0). Replace it. + REPLACE_PERROR=1 + fi + case ${gl_cv_func_strerror_r_works-unset} in + unset|*yes) + AC_CACHE_CHECK([whether perror matches strerror], + [gl_cv_func_perror_works], + [AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [[#include + #include + #include + #include + ]], + [[char *str = strerror (-1); + if (!getenv("CONFTEST_OUTPUT")) return 0; + if (!str) str = ""; + puts (str); + errno = -1; + perror (""); + return 0; + ]])], + [if CONFTEST_OUTPUT=1 ./conftest$EXEEXT >conftest.txt1 2>conftest.txt2 \ + && cmp conftest.txt1 conftest.txt2 >/dev/null; then + gl_cv_func_perror_works=yes + else + gl_cv_func_perror_works=no + fi + rm -rf conftest.txt1 conftest.txt2], + [gl_cv_func_perror_works=no], + [case "$host_os" in + # Guess yes on musl systems. + *-musl* | midipix*) gl_cv_func_perror_works="guessing yes" ;; + # Guess yes on native Windows. + mingw* | windows*) gl_cv_func_perror_works="guessing yes" ;; + # Otherwise obey --enable-cross-guesses. + *) gl_cv_func_perror_works="$gl_cross_guess_normal" ;; + esac + ]) + ]) + case "$gl_cv_func_perror_works" in + *yes) ;; + *) REPLACE_PERROR=1 ;; + esac + ;; + *) + dnl The system's perror() probably inherits the bugs in the + dnl system's strerror_r(). Replace it. + REPLACE_PERROR=1 + ;; + esac + dnl Does perror clobber the strerror buffer? + case "$host_os" in + # Yes on Android 11. + linux*-android*) REPLACE_PERROR=1 ;; + esac +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/pid_t.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/pid_t.m4 new file mode 100644 index 00000000..8f8d39d8 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/pid_t.m4 @@ -0,0 +1,38 @@ +# pid_t.m4 serial 4 +dnl Copyright (C) 2020-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +# The following implementation works around a problem in autoconf <= 2.69. +m4_version_prereq([2.70], [], [ + +dnl Define pid_t if the headers don't define it. +AC_DEFUN([AC_TYPE_PID_T], +[ + AC_CHECK_TYPE([pid_t], + [], + [dnl On 64-bit native Windows, define it to the equivalent of 'intptr_t' + dnl (= 'long long' = '__int64'), because that is the return type + dnl of the _spawnv* functions + dnl + dnl and the argument type of the _cwait function + dnl . + dnl Otherwise (on 32-bit Windows and on old Unix platforms), define it + dnl to 'int'. + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[ + #if defined _WIN64 && !defined __CYGWIN__ + LLP64 + #endif + ]]) + ], + [gl_pid_type='int'], + [gl_pid_type='__int64']) + AC_DEFINE_UNQUOTED([pid_t], [$gl_pid_type], + [Define as a signed integer type capable of holding a process identifier.]) + ], + [AC_INCLUDES_DEFAULT]) +]) + +])# m4_version_prereq 2.70 diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/pipe.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/pipe.m4 new file mode 100644 index 00000000..1d3742eb --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/pipe.m4 @@ -0,0 +1,15 @@ +# pipe.m4 serial 2 +dnl Copyright (C) 2010-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_PIPE], +[ + AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) + + AC_CHECK_FUNCS_ONCE([pipe]) + if test $ac_cv_func_pipe != yes; then + HAVE_PIPE=0 + fi +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/popen.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/popen.m4 new file mode 100644 index 00000000..0dca5da7 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/popen.m4 @@ -0,0 +1,54 @@ +# popen.m4 serial 7 +dnl Copyright (C) 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_POPEN], +[ + AC_REQUIRE([gl_STDIO_H_DEFAULTS]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CHECK_FUNCS_ONCE([popen]) + if test $ac_cv_func_popen = no; then + HAVE_POPEN=0 + else + AC_CACHE_CHECK([whether popen works with closed stdin], + [gl_cv_func_popen_works], + [ + AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [[#include ]], + [[int result = 0; + FILE *child; + fclose (stdin); + fclose (stdout); + child = popen ("echo a", "r"); + if (fgetc (child) != 'a') + result |= 1; + if (pclose (child) != 0) + result |= 2; + return result; + ]])], + [gl_cv_func_popen_works=yes], + [gl_cv_func_popen_works=no], + [case "$host_os" in + # For now, only cygwin 1.5 or older is known to be broken. + cygwin*) gl_cv_func_popen_works="guessing no" ;; + # Guess yes on native Windows. + mingw* | windows*) gl_cv_func_popen_works="guessing yes" ;; + *) gl_cv_func_popen_works="guessing yes" ;; + esac + ]) + ]) + case "$gl_cv_func_popen_works" in + *yes) ;; + *) REPLACE_POPEN=1 ;; + esac + fi +]) + +# Prerequisites of lib/popen.c. +AC_DEFUN([gl_PREREQ_POPEN], +[ + : +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/printf.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/printf.m4 new file mode 100644 index 00000000..bb67d594 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/printf.m4 @@ -0,0 +1,2214 @@ +# printf.m4 serial 89 +dnl Copyright (C) 2003, 2007-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl Test whether the *printf family of functions supports the 'j', 'z', 't', +dnl 'L' size specifiers. (ISO C99, POSIX:2001) +dnl Result is gl_cv_func_printf_sizes_c99. + +AC_DEFUN([gl_PRINTF_SIZES_C99], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([gl_AC_HEADER_STDINT_H]) + AC_REQUIRE([gl_AC_HEADER_INTTYPES_H]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether printf supports size specifiers as in C99], + [gl_cv_func_printf_sizes_c99], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +#include +#include +#if HAVE_STDINT_H_WITH_UINTMAX +# include +#endif +#if HAVE_INTTYPES_H_WITH_UINTMAX +# include +#endif +static char buf[100]; +int main () +{ + int result = 0; +#if HAVE_STDINT_H_WITH_UINTMAX || HAVE_INTTYPES_H_WITH_UINTMAX + buf[0] = '\0'; + if (sprintf (buf, "%ju %d", (uintmax_t) 12345671, 33, 44, 55) < 0 + || strcmp (buf, "12345671 33") != 0) + result |= 1; +#else + result |= 1; +#endif + buf[0] = '\0'; + if (sprintf (buf, "%zu %d", (size_t) 12345672, 33, 44, 55) < 0 + || strcmp (buf, "12345672 33") != 0) + result |= 2; + buf[0] = '\0'; + if (sprintf (buf, "%tu %d", (ptrdiff_t) 12345673, 33, 44, 55) < 0 + || strcmp (buf, "12345673 33") != 0) + result |= 4; + buf[0] = '\0'; + if (sprintf (buf, "%Lg %d", (long double) 1.5, 33, 44, 55) < 0 + || strcmp (buf, "1.5 33") != 0) + result |= 8; + return result; +}]])], + [gl_cv_func_printf_sizes_c99=yes], + [gl_cv_func_printf_sizes_c99=no], + [ + case "$host_os" in +changequote(,)dnl + # Guess yes on glibc systems. + *-gnu* | gnu*) gl_cv_func_printf_sizes_c99="guessing yes";; + # Guess yes on musl systems. + *-musl* | midipix*) gl_cv_func_printf_sizes_c99="guessing yes";; + # Guess yes on FreeBSD >= 5. + freebsd[1-4].*) gl_cv_func_printf_sizes_c99="guessing no";; + freebsd* | kfreebsd*) gl_cv_func_printf_sizes_c99="guessing yes";; + midnightbsd*) gl_cv_func_printf_sizes_c99="guessing yes";; + # Guess yes on Mac OS X >= 10.3. + darwin[1-6].*) gl_cv_func_printf_sizes_c99="guessing no";; + darwin*) gl_cv_func_printf_sizes_c99="guessing yes";; + # Guess yes on OpenBSD >= 3.9. + openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*) + gl_cv_func_printf_sizes_c99="guessing no";; + openbsd*) gl_cv_func_printf_sizes_c99="guessing yes";; + # Guess yes on Solaris >= 2.10. + solaris2.[1-9][0-9]*) gl_cv_func_printf_sizes_c99="guessing yes";; + solaris*) gl_cv_func_printf_sizes_c99="guessing no";; + # Guess yes on NetBSD >= 3. + netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) + gl_cv_func_printf_sizes_c99="guessing no";; + netbsd*) gl_cv_func_printf_sizes_c99="guessing yes";; + # Guess yes on Android. + linux*-android*) gl_cv_func_printf_sizes_c99="guessing yes";; +changequote([,])dnl + # Guess yes on MSVC, no on mingw. + windows*-msvc*) gl_cv_func_printf_sizes_c99="guessing yes" ;; + mingw* | windows*) AC_EGREP_CPP([Known], [ +#ifdef _MSC_VER + Known +#endif + ], + [gl_cv_func_printf_sizes_c99="guessing yes"], + [gl_cv_func_printf_sizes_c99="guessing no"]) + ;; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_printf_sizes_c99="$gl_cross_guess_normal";; + esac + ]) + ]) +]) + +dnl Test whether the *printf family of functions supports the 'w8', 'w16', +dnl 'w32', 'w64', 'wf8', 'wf16', 'wf32', 'wf64' size specifiers. (ISO C23) +dnl Result is gl_cv_func_printf_sizes_c23. + +AC_DEFUN([gl_PRINTF_SIZES_C23], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([gl_AC_HEADER_STDINT_H]) + AC_REQUIRE([gl_AC_HEADER_INTTYPES_H]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether printf supports size specifiers as in C23], + [gl_cv_func_printf_sizes_c23], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +#include +#include +#if HAVE_STDINT_H_WITH_UINTMAX +# include +#endif +#if HAVE_INTTYPES_H_WITH_UINTMAX +# include +#endif +static char buf[100]; +int main () +{ + int result = 0; + buf[0] = '\0'; + if (sprintf (buf, "%w8u %d", (uint8_t) 123, 33, 44, 55) < 0 + || strcmp (buf, "123 33") != 0) + result |= 1; + buf[0] = '\0'; + if (sprintf (buf, "%wf8u %d", (uint_fast8_t) 123, 33, 44, 55) < 0 + || strcmp (buf, "123 33") != 0) + result |= 1; + buf[0] = '\0'; + if (sprintf (buf, "%w16u %d", (uint16_t) 12345, 33, 44, 55) < 0 + || strcmp (buf, "12345 33") != 0) + result |= 2; + buf[0] = '\0'; + if (sprintf (buf, "%wf16u %d", (uint_fast16_t) 12345, 33, 44, 55) < 0 + || strcmp (buf, "12345 33") != 0) + result |= 2; + buf[0] = '\0'; + if (sprintf (buf, "%w32u %d", (uint32_t) 12345671, 33, 44, 55) < 0 + || strcmp (buf, "12345671 33") != 0) + result |= 4; + buf[0] = '\0'; + if (sprintf (buf, "%wf32u %d", (uint_fast32_t) 12345671, 33, 44, 55) < 0 + || strcmp (buf, "12345671 33") != 0) + result |= 4; +#if HAVE_STDINT_H_WITH_UINTMAX || HAVE_INTTYPES_H_WITH_UINTMAX + buf[0] = '\0'; + if (sprintf (buf, "%w64u %d", (uint64_t) 12345671, 33, 44, 55) < 0 + || strcmp (buf, "12345671 33") != 0) + result |= 8; + buf[0] = '\0'; + if (sprintf (buf, "%wf64u %d", (uint_fast64_t) 12345671, 33, 44, 55) < 0 + || strcmp (buf, "12345671 33") != 0) + result |= 8; +#else + result |= 8; +#endif + return result; +}]])], + [gl_cv_func_printf_sizes_c23=yes], + [gl_cv_func_printf_sizes_c23=no], + [ + case "$host_os" in + # Guess no on glibc systems. + *-gnu* | gnu*) gl_cv_func_printf_sizes_c23="guessing no";; + # Guess no on musl systems. + *-musl* | midipix*) gl_cv_func_printf_sizes_c23="guessing no";; + # Guess no on Android. + linux*-android*) gl_cv_func_printf_sizes_c23="guessing no";; + # Guess no on native Windows. + mingw* | windows*) gl_cv_func_printf_sizes_c23="guessing no";; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_printf_sizes_c23="$gl_cross_guess_normal";; + esac + ]) + ]) +]) + +dnl Test whether the *printf family of functions supports 'long double' +dnl arguments together with the 'L' size specifier. (ISO C99, POSIX:2001) +dnl Result is gl_cv_func_printf_long_double. + +AC_DEFUN([gl_PRINTF_LONG_DOUBLE], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether printf supports 'long double' arguments], + [gl_cv_func_printf_long_double], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +static char buf[10000]; +int main () +{ + int result = 0; + buf[0] = '\0'; + if (sprintf (buf, "%Lf %d", 1.75L, 33, 44, 55) < 0 + || strcmp (buf, "1.750000 33") != 0) + result |= 1; + buf[0] = '\0'; + if (sprintf (buf, "%Le %d", 1.75L, 33, 44, 55) < 0 + || strcmp (buf, "1.750000e+00 33") != 0) + result |= 2; + buf[0] = '\0'; + if (sprintf (buf, "%Lg %d", 1.75L, 33, 44, 55) < 0 + || strcmp (buf, "1.75 33") != 0) + result |= 4; + return result; +}]])], + [gl_cv_func_printf_long_double=yes], + [gl_cv_func_printf_long_double=no], + [case "$host_os" in + # Guess no on BeOS. + beos*) gl_cv_func_printf_long_double="guessing no";; + # Guess yes on Android. + linux*-android*) gl_cv_func_printf_long_double="guessing yes";; + # Guess yes on MSVC, no on mingw. + windows*-msvc*) gl_cv_func_printf_long_double="guessing yes" ;; + mingw* | windows*) AC_EGREP_CPP([Known], [ +#ifdef _MSC_VER + Known +#endif + ], + [gl_cv_func_printf_long_double="guessing yes"], + [gl_cv_func_printf_long_double="guessing no"]) + ;; + *) gl_cv_func_printf_long_double="guessing yes";; + esac + ]) + ]) +]) + +dnl Test whether the *printf family of functions supports infinite and NaN +dnl 'double' arguments and negative zero arguments in the %f, %e, %g +dnl directives. (ISO C99, POSIX:2001) +dnl Result is gl_cv_func_printf_infinite. + +AC_DEFUN([gl_PRINTF_INFINITE], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether printf supports infinite 'double' arguments], + [gl_cv_func_printf_infinite], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +static int +strisnan (const char *string, size_t start_index, size_t end_index) +{ + if (start_index < end_index) + { + if (string[start_index] == '-') + start_index++; + if (start_index + 3 <= end_index + && memcmp (string + start_index, "nan", 3) == 0) + { + start_index += 3; + if (start_index == end_index + || (string[start_index] == '(' && string[end_index - 1] == ')')) + return 1; + } + } + return 0; +} +static int +have_minus_zero () +{ + static double plus_zero = 0.0; + double minus_zero = - plus_zero; + return memcmp (&plus_zero, &minus_zero, sizeof (double)) != 0; +} +static char buf[10000]; +static double zero = 0.0; +int main () +{ + int result = 0; + if (sprintf (buf, "%f", 1.0 / zero) < 0 + || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0)) + result |= 1; + if (sprintf (buf, "%f", -1.0 / zero) < 0 + || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0)) + result |= 1; + if (sprintf (buf, "%f", zero / zero) < 0 + || !strisnan (buf, 0, strlen (buf))) + result |= 2; + if (sprintf (buf, "%e", 1.0 / zero) < 0 + || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0)) + result |= 4; + if (sprintf (buf, "%e", -1.0 / zero) < 0 + || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0)) + result |= 4; + if (sprintf (buf, "%e", zero / zero) < 0 + || !strisnan (buf, 0, strlen (buf))) + result |= 8; + if (sprintf (buf, "%g", 1.0 / zero) < 0 + || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0)) + result |= 16; + if (sprintf (buf, "%g", -1.0 / zero) < 0 + || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0)) + result |= 16; + if (sprintf (buf, "%g", zero / zero) < 0 + || !strisnan (buf, 0, strlen (buf))) + result |= 32; + /* This test fails on HP-UX 10.20. */ + if (have_minus_zero ()) + if (sprintf (buf, "%g", - zero) < 0 + || strcmp (buf, "-0") != 0) + result |= 64; + return result; +}]])], + [gl_cv_func_printf_infinite=yes], + [gl_cv_func_printf_infinite=no], + [ + case "$host_os" in +changequote(,)dnl + # Guess yes on glibc systems. + *-gnu* | gnu*) gl_cv_func_printf_infinite="guessing yes";; + # Guess yes on musl systems. + *-musl* | midipix*) gl_cv_func_printf_infinite="guessing yes";; + # Guess yes on FreeBSD >= 6. + freebsd[1-5].*) gl_cv_func_printf_infinite="guessing no";; + freebsd* | kfreebsd*) gl_cv_func_printf_infinite="guessing yes";; + midnightbsd*) gl_cv_func_printf_infinite="guessing yes";; + # Guess yes on Mac OS X >= 10.3. + darwin[1-6].*) gl_cv_func_printf_infinite="guessing no";; + darwin*) gl_cv_func_printf_infinite="guessing yes";; + # Guess yes on HP-UX >= 11. + hpux[7-9]* | hpux10*) gl_cv_func_printf_infinite="guessing no";; + hpux*) gl_cv_func_printf_infinite="guessing yes";; + # Guess yes on NetBSD >= 3. + netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) + gl_cv_func_printf_infinite="guessing no";; + netbsd*) gl_cv_func_printf_infinite="guessing yes";; + # Guess yes on OpenBSD >= 6.0. + openbsd[1-5].*) gl_cv_func_printf_infinite="guessing no";; + openbsd*) gl_cv_func_printf_infinite="guessing yes";; + # Guess yes on BeOS. + beos*) gl_cv_func_printf_infinite="guessing yes";; + # Guess no on Android. + linux*-android*) gl_cv_func_printf_infinite="guessing no";; +changequote([,])dnl + # Guess yes on MSVC, no on mingw. + windows*-msvc*) gl_cv_func_printf_infinite="guessing yes" ;; + mingw* | windows*) AC_EGREP_CPP([Known], [ +#ifdef _MSC_VER + Known +#endif + ], + [gl_cv_func_printf_infinite="guessing yes"], + [gl_cv_func_printf_infinite="guessing no"]) + ;; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_printf_infinite="$gl_cross_guess_normal";; + esac + ]) + ]) +]) + +dnl Test whether the *printf family of functions supports infinite and NaN +dnl 'long double' arguments in the %f, %e, %g directives. (ISO C99, POSIX:2001) +dnl Result is gl_cv_func_printf_infinite_long_double. + +AC_DEFUN([gl_PRINTF_INFINITE_LONG_DOUBLE], +[ + AC_REQUIRE([gl_PRINTF_LONG_DOUBLE]) + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([gl_BIGENDIAN]) + AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + dnl The user can set or unset the variable gl_printf_safe to indicate + dnl that he wishes a safe handling of non-IEEE-754 'long double' values. + if test -n "$gl_printf_safe"; then + AC_DEFINE([CHECK_PRINTF_SAFE], [1], + [Define if you wish *printf() functions that have a safe handling of + non-IEEE-754 'long double' values.]) + fi + case "$gl_cv_func_printf_long_double" in + *yes) + AC_CACHE_CHECK([whether printf supports infinite 'long double' arguments], + [gl_cv_func_printf_infinite_long_double], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +]GL_NOCRASH[ +#include +#include +#include +static int +strisnan (const char *string, size_t start_index, size_t end_index) +{ + if (start_index < end_index) + { + if (string[start_index] == '-') + start_index++; + if (start_index + 3 <= end_index + && memcmp (string + start_index, "nan", 3) == 0) + { + start_index += 3; + if (start_index == end_index + || (string[start_index] == '(' && string[end_index - 1] == ')')) + return 1; + } + } + return 0; +} +static char buf[10000]; +static long double zeroL = 0.0L; +int main () +{ + int result = 0; + nocrash_init(); + if (sprintf (buf, "%Lf", 1.0L / zeroL) < 0 + || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0)) + result |= 1; + if (sprintf (buf, "%Lf", -1.0L / zeroL) < 0 + || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0)) + result |= 1; + if (sprintf (buf, "%Lf", zeroL / zeroL) < 0 + || !strisnan (buf, 0, strlen (buf))) + result |= 1; + if (sprintf (buf, "%Le", 1.0L / zeroL) < 0 + || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0)) + result |= 1; + if (sprintf (buf, "%Le", -1.0L / zeroL) < 0 + || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0)) + result |= 1; + if (sprintf (buf, "%Le", zeroL / zeroL) < 0 + || !strisnan (buf, 0, strlen (buf))) + result |= 1; + if (sprintf (buf, "%Lg", 1.0L / zeroL) < 0 + || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0)) + result |= 1; + if (sprintf (buf, "%Lg", -1.0L / zeroL) < 0 + || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0)) + result |= 1; + if (sprintf (buf, "%Lg", zeroL / zeroL) < 0 + || !strisnan (buf, 0, strlen (buf))) + result |= 1; +#if CHECK_PRINTF_SAFE && ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_)) && !HAVE_SAME_LONG_DOUBLE_AS_DOUBLE +/* Representation of an 80-bit 'long double' as an initializer for a sequence + of 'unsigned int' words. */ +# ifdef WORDS_BIGENDIAN +# define LDBL80_WORDS(exponent,manthi,mantlo) \ + { ((unsigned int) (exponent) << 16) | ((unsigned int) (manthi) >> 16), \ + ((unsigned int) (manthi) << 16) | ((unsigned int) (mantlo) >> 16), \ + (unsigned int) (mantlo) << 16 \ + } +# else +# define LDBL80_WORDS(exponent,manthi,mantlo) \ + { mantlo, manthi, exponent } +# endif + { /* Quiet NaN. */ + static union { unsigned int word[4]; long double value; } x = + { LDBL80_WORDS (0xFFFF, 0xC3333333, 0x00000000) }; + if (sprintf (buf, "%Lf", x.value) < 0 + || !strisnan (buf, 0, strlen (buf))) + result |= 2; + if (sprintf (buf, "%Le", x.value) < 0 + || !strisnan (buf, 0, strlen (buf))) + result |= 2; + if (sprintf (buf, "%Lg", x.value) < 0 + || !strisnan (buf, 0, strlen (buf))) + result |= 2; + } + { + /* Signalling NaN. */ + static union { unsigned int word[4]; long double value; } x = + { LDBL80_WORDS (0xFFFF, 0x83333333, 0x00000000) }; + if (sprintf (buf, "%Lf", x.value) < 0 + || !strisnan (buf, 0, strlen (buf))) + result |= 2; + if (sprintf (buf, "%Le", x.value) < 0 + || !strisnan (buf, 0, strlen (buf))) + result |= 2; + if (sprintf (buf, "%Lg", x.value) < 0 + || !strisnan (buf, 0, strlen (buf))) + result |= 2; + } + { /* Pseudo-NaN. */ + static union { unsigned int word[4]; long double value; } x = + { LDBL80_WORDS (0xFFFF, 0x40000001, 0x00000000) }; + if (sprintf (buf, "%Lf", x.value) <= 0) + result |= 4; + if (sprintf (buf, "%Le", x.value) <= 0) + result |= 4; + if (sprintf (buf, "%Lg", x.value) <= 0) + result |= 4; + } + { /* Pseudo-Infinity. */ + static union { unsigned int word[4]; long double value; } x = + { LDBL80_WORDS (0xFFFF, 0x00000000, 0x00000000) }; + if (sprintf (buf, "%Lf", x.value) <= 0) + result |= 8; + if (sprintf (buf, "%Le", x.value) <= 0) + result |= 8; + if (sprintf (buf, "%Lg", x.value) <= 0) + result |= 8; + } + { /* Pseudo-Zero. */ + static union { unsigned int word[4]; long double value; } x = + { LDBL80_WORDS (0x4004, 0x00000000, 0x00000000) }; + if (sprintf (buf, "%Lf", x.value) <= 0) + result |= 16; + if (sprintf (buf, "%Le", x.value) <= 0) + result |= 16; + if (sprintf (buf, "%Lg", x.value) <= 0) + result |= 16; + } + { /* Unnormalized number. */ + static union { unsigned int word[4]; long double value; } x = + { LDBL80_WORDS (0x4000, 0x63333333, 0x00000000) }; + if (sprintf (buf, "%Lf", x.value) <= 0) + result |= 32; + if (sprintf (buf, "%Le", x.value) <= 0) + result |= 32; + if (sprintf (buf, "%Lg", x.value) <= 0) + result |= 32; + } + { /* Pseudo-Denormal. */ + static union { unsigned int word[4]; long double value; } x = + { LDBL80_WORDS (0x0000, 0x83333333, 0x00000000) }; + if (sprintf (buf, "%Lf", x.value) <= 0) + result |= 64; + if (sprintf (buf, "%Le", x.value) <= 0) + result |= 64; + if (sprintf (buf, "%Lg", x.value) <= 0) + result |= 64; + } +#endif + return result; +}]])], + [gl_cv_func_printf_infinite_long_double=yes], + [gl_cv_func_printf_infinite_long_double=no], + [case "$host_cpu" in + # Guess no on ia64, x86_64, i386. + ia64 | x86_64 | i*86) gl_cv_func_printf_infinite_long_double="guessing no";; + *) + case "$host_os" in +changequote(,)dnl + # Guess yes on glibc systems. + *-gnu* | gnu*) gl_cv_func_printf_infinite_long_double="guessing yes";; + # Guess yes on musl systems. + *-musl* | midipix*) gl_cv_func_printf_infinite_long_double="guessing yes";; + # Guess yes on FreeBSD >= 6. + freebsd[1-5].*) gl_cv_func_printf_infinite_long_double="guessing no";; + freebsd* | kfreebsd*) gl_cv_func_printf_infinite_long_double="guessing yes";; + midnightbsd*) gl_cv_func_printf_infinite_long_double="guessing yes";; + # Guess yes on HP-UX >= 11. + hpux[7-9]* | hpux10*) gl_cv_func_printf_infinite_long_double="guessing no";; + hpux*) gl_cv_func_printf_infinite_long_double="guessing yes";; + # Guess yes on OpenBSD >= 6.0. + openbsd[1-5].*) gl_cv_func_printf_infinite_long_double="guessing no";; + openbsd*) gl_cv_func_printf_infinite_long_double="guessing yes";; + # Guess no on Android. + linux*-android*) gl_cv_func_printf_infinite_long_double="guessing no";; +changequote([,])dnl + # Guess yes on MSVC, no on mingw. + windows*-msvc*) gl_cv_func_printf_infinite_long_double="guessing yes" ;; + mingw* | windows*) AC_EGREP_CPP([Known], [ +#ifdef _MSC_VER + Known +#endif + ], + [gl_cv_func_printf_infinite_long_double="guessing yes"], + [gl_cv_func_printf_infinite_long_double="guessing no"]) + ;; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_printf_infinite_long_double="$gl_cross_guess_normal";; + esac + ;; + esac + ]) + ]) + ;; + *) + gl_cv_func_printf_infinite_long_double="irrelevant" + ;; + esac +]) + +dnl Test whether the *printf family of functions supports the 'a' and 'A' +dnl conversion specifier for hexadecimal output of floating-point numbers. +dnl (ISO C99, POSIX:2001) +dnl Result is gl_cv_func_printf_directive_a. + +AC_DEFUN([gl_PRINTF_DIRECTIVE_A], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether printf supports the 'a' and 'A' directives], + [gl_cv_func_printf_directive_a], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +static char buf[100]; +static double zero = 0.0; +int main () +{ + int result = 0; + if (sprintf (buf, "%a %d", 3.1416015625, 33, 44, 55) < 0 + || (strcmp (buf, "0x1.922p+1 33") != 0 + && strcmp (buf, "0x3.244p+0 33") != 0 + && strcmp (buf, "0x6.488p-1 33") != 0 + && strcmp (buf, "0xc.91p-2 33") != 0)) + result |= 1; + if (sprintf (buf, "%A %d", -3.1416015625, 33, 44, 55) < 0 + || (strcmp (buf, "-0X1.922P+1 33") != 0 + && strcmp (buf, "-0X3.244P+0 33") != 0 + && strcmp (buf, "-0X6.488P-1 33") != 0 + && strcmp (buf, "-0XC.91P-2 33") != 0)) + result |= 2; + /* This catches a FreeBSD 13.0 bug: it doesn't round. */ + if (sprintf (buf, "%.2a %d", 1.51, 33, 44, 55) < 0 + || (strcmp (buf, "0x1.83p+0 33") != 0 + && strcmp (buf, "0x3.05p-1 33") != 0 + && strcmp (buf, "0x6.0ap-2 33") != 0 + && strcmp (buf, "0xc.14p-3 33") != 0)) + result |= 4; + /* This catches a Mac OS X 10.12.4 (Darwin 16.5) bug: it doesn't round. */ + if (sprintf (buf, "%.0a %d", 1.51, 33, 44, 55) < 0 + || (strcmp (buf, "0x2p+0 33") != 0 + && strcmp (buf, "0x3p-1 33") != 0 + && strcmp (buf, "0x6p-2 33") != 0 + && strcmp (buf, "0xcp-3 33") != 0)) + result |= 4; + /* This catches a FreeBSD 6.1 bug. See + */ + if (sprintf (buf, "%010a %d", 1.0 / zero, 33, 44, 55) < 0 + || buf[0] == '0') + result |= 8; + /* This catches a Mac OS X 10.3.9 (Darwin 7.9) bug. */ + if (sprintf (buf, "%.1a", 1.999) < 0 + || (strcmp (buf, "0x1.0p+1") != 0 + && strcmp (buf, "0x2.0p+0") != 0 + && strcmp (buf, "0x4.0p-1") != 0 + && strcmp (buf, "0x8.0p-2") != 0)) + result |= 16; + /* This catches the same Mac OS X 10.3.9 (Darwin 7.9) bug and also a + glibc 2.4 bug . */ + if (sprintf (buf, "%.1La", 1.999L) < 0 + || (strcmp (buf, "0x1.0p+1") != 0 + && strcmp (buf, "0x2.0p+0") != 0 + && strcmp (buf, "0x4.0p-1") != 0 + && strcmp (buf, "0x8.0p-2") != 0)) + result |= 32; + return result; +}]])], + [gl_cv_func_printf_directive_a=yes], + [gl_cv_func_printf_directive_a=no], + [ + case "$host_os" in + # Guess yes on glibc >= 2.5 systems. + *-gnu* | gnu*) + AC_EGREP_CPP([BZ2908], [ + #include + #ifdef __GNU_LIBRARY__ + #if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 5) || (__GLIBC__ > 2)) && !defined __UCLIBC__ + BZ2908 + #endif + #endif + ], + [gl_cv_func_printf_directive_a="guessing yes"], + [gl_cv_func_printf_directive_a="guessing no"]) + ;; + # Guess yes on musl systems. + *-musl* | midipix*) gl_cv_func_printf_directive_a="guessing yes";; + # Guess no on Android. + linux*-android*) gl_cv_func_printf_directive_a="guessing no";; + # Guess no on native Windows. + mingw* | windows*) gl_cv_func_printf_directive_a="guessing no";; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_printf_directive_a="$gl_cross_guess_normal";; + esac + ]) + ]) +]) + +dnl Test whether the *printf family of functions supports the 'b' conversion +dnl specifier for binary output of integers. +dnl (ISO C23) +dnl Result is gl_cv_func_printf_directive_b. + +AC_DEFUN([gl_PRINTF_DIRECTIVE_B], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether printf supports the 'b' directive], + [gl_cv_func_printf_directive_b], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +static char buf[100]; +int main () +{ + int result = 0; + if (sprintf (buf, "%b %d", 12345, 33, 44, 55) < 0 + || strcmp (buf, "11000000111001 33") != 0) + result |= 1; + return result; +}]])], + [gl_cv_func_printf_directive_b=yes], + [gl_cv_func_printf_directive_b=no], + [ + case "$host_os" in + # Guess yes on glibc >= 2.35 systems. + *-gnu* | gnu*) + AC_EGREP_CPP([Lucky], [ + #include + #ifdef __GNU_LIBRARY__ + #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 35) || (__GLIBC__ > 2) + Lucky user + #endif + #endif + ], + [gl_cv_func_printf_directive_uppercase_b="guessing yes"], + [gl_cv_func_printf_directive_uppercase_b="guessing no"]) + ;; + # Guess no on musl systems. + *-musl* | midipix*) gl_cv_func_printf_directive_b="guessing no";; + # Guess no on Android. + linux*-android*) gl_cv_func_printf_directive_b="guessing no";; + # Guess no on native Windows. + mingw* | windows*) gl_cv_func_printf_directive_b="guessing no";; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_printf_directive_b="$gl_cross_guess_normal";; + esac + ]) + ]) +]) + +dnl Test whether the *printf family of functions supports the 'B' conversion +dnl specifier for binary output of integers. +dnl (GNU, encouraged by ISO C23 § 7.23.6.1) +dnl Result is gl_cv_func_printf_directive_uppercase_b. + +AC_DEFUN([gl_PRINTF_DIRECTIVE_UPPERCASE_B], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether printf supports the 'B' directive], + [gl_cv_func_printf_directive_uppercase_b], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +static char buf[100]; +int main () +{ + int result = 0; + if (sprintf (buf, "%#B %d", 12345, 33, 44, 55) < 0 + || strcmp (buf, "0B11000000111001 33") != 0) + result |= 1; + return result; +}]])], + [gl_cv_func_printf_directive_uppercase_b=yes], + [gl_cv_func_printf_directive_uppercase_b=no], + [ + case "$host_os" in + # Guess yes on glibc >= 2.35 systems. + *-gnu* | gnu*) + AC_EGREP_CPP([Lucky], [ + #include + #ifdef __GNU_LIBRARY__ + #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 35) || (__GLIBC__ > 2) + Lucky user + #endif + #endif + ], + [gl_cv_func_printf_directive_uppercase_b="guessing yes"], + [gl_cv_func_printf_directive_uppercase_b="guessing no"]) + ;; + # Guess no on musl systems. + *-musl* | midipix*) gl_cv_func_printf_directive_uppercase_b="guessing no";; + # Guess no on Android. + linux*-android*) gl_cv_func_printf_directive_uppercase_b="guessing no";; + # Guess no on native Windows. + mingw* | windows*) gl_cv_func_printf_directive_uppercase_b="guessing no";; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_printf_directive_uppercase_b="$gl_cross_guess_normal";; + esac + ]) + ]) +]) + +dnl Test whether the *printf family of functions supports the %F format +dnl directive. (ISO C99, POSIX:2001) +dnl Result is gl_cv_func_printf_directive_f. + +AC_DEFUN([gl_PRINTF_DIRECTIVE_F], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether printf supports the 'F' directive], + [gl_cv_func_printf_directive_f], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +static char buf[100]; +static double zero = 0.0; +int main () +{ + int result = 0; + if (sprintf (buf, "%F %d", 1234567.0, 33, 44, 55) < 0 + || strcmp (buf, "1234567.000000 33") != 0) + result |= 1; + if (sprintf (buf, "%F", 1.0 / zero) < 0 + || (strcmp (buf, "INF") != 0 && strcmp (buf, "INFINITY") != 0)) + result |= 2; + /* This catches a Cygwin 1.5.x bug. */ + if (sprintf (buf, "%.F", 1234.0) < 0 + || strcmp (buf, "1234") != 0) + result |= 4; + return result; +}]])], + [gl_cv_func_printf_directive_f=yes], + [gl_cv_func_printf_directive_f=no], + [ + case "$host_os" in +changequote(,)dnl + # Guess yes on glibc systems. + *-gnu* | gnu*) gl_cv_func_printf_directive_f="guessing yes";; + # Guess yes on musl systems. + *-musl* | midipix*) gl_cv_func_printf_directive_f="guessing yes";; + # Guess yes on FreeBSD >= 6. + freebsd[1-5].*) gl_cv_func_printf_directive_f="guessing no";; + freebsd* | kfreebsd*) gl_cv_func_printf_directive_f="guessing yes";; + midnightbsd*) gl_cv_func_printf_directive_f="guessing yes";; + # Guess yes on Mac OS X >= 10.3. + darwin[1-6].*) gl_cv_func_printf_directive_f="guessing no";; + darwin*) gl_cv_func_printf_directive_f="guessing yes";; + # Guess yes on OpenBSD >= 6.0. + openbsd[1-5].*) gl_cv_func_printf_directive_f="guessing no";; + openbsd*) gl_cv_func_printf_directive_f="guessing yes";; + # Guess yes on Solaris >= 2.10. + solaris2.[1-9][0-9]*) gl_cv_func_printf_directive_f="guessing yes";; + solaris*) gl_cv_func_printf_directive_f="guessing no";; + # Guess no on Android. + linux*-android*) gl_cv_func_printf_directive_f="guessing no";; +changequote([,])dnl + # Guess yes on MSVC, no on mingw. + windows*-msvc*) gl_cv_func_printf_directive_f="guessing yes" ;; + mingw* | windows*) AC_EGREP_CPP([Known], [ +#ifdef _MSC_VER + Known +#endif + ], + [gl_cv_func_printf_directive_f="guessing yes"], + [gl_cv_func_printf_directive_f="guessing no"]) + ;; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_printf_directive_f="$gl_cross_guess_normal";; + esac + ]) + ]) +]) + +dnl Test whether the *printf family of functions supports the %n format +dnl directive. (ISO C99, POSIX:2001) +dnl Result is gl_cv_func_printf_directive_n. + +AC_DEFUN([gl_PRINTF_DIRECTIVE_N], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether printf supports the 'n' directive], + [gl_cv_func_printf_directive_n], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +#include +#ifdef _MSC_VER +#include +/* See page about "Parameter Validation" on msdn.microsoft.com. + + */ +static void cdecl +invalid_parameter_handler (const wchar_t *expression, + const wchar_t *function, + const wchar_t *file, unsigned int line, + uintptr_t dummy) +{ + exit (1); +} +#endif +static char fmtstring[10]; +static char buf[100]; +int main () +{ + int count = -1; +#ifdef _MSC_VER + _set_invalid_parameter_handler (invalid_parameter_handler); +#endif + /* Copy the format string. Some systems (glibc with _FORTIFY_SOURCE=2) + support %n in format strings in read-only memory but not in writable + memory. */ + strcpy (fmtstring, "%d %n"); + if (sprintf (buf, fmtstring, 123, &count, 33, 44, 55) < 0 + || strcmp (buf, "123 ") != 0 + || count != 4) + return 1; + return 0; +}]])], + [gl_cv_func_printf_directive_n=yes], + [gl_cv_func_printf_directive_n=no], + [case "$host_os" in + # Guess no on glibc when _FORTIFY_SOURCE >= 2. + *-gnu* | gnu*) AC_COMPILE_IFELSE( + [AC_LANG_SOURCE( + [[#if _FORTIFY_SOURCE >= 2 + error fail + #endif + ]])], + [gl_cv_func_printf_directive_n="guessing yes"], + [gl_cv_func_printf_directive_n="guessing no"]) + ;; + # Guess no on Android. + linux*-android*) gl_cv_func_printf_directive_n="guessing no";; + # Guess no on native Windows. + mingw* | windows*) gl_cv_func_printf_directive_n="guessing no";; + *) gl_cv_func_printf_directive_n="guessing yes";; + esac + ]) + ]) +]) + +dnl Test whether the *printf family of functions supports the %ls format +dnl directive and in particular, when a precision is specified, whether +dnl the functions stop converting the wide string argument when the number +dnl of bytes that have been produced by this conversion equals or exceeds +dnl the precision. +dnl Result is gl_cv_func_printf_directive_ls. + +AC_DEFUN([gl_PRINTF_DIRECTIVE_LS], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether printf supports the 'ls' directive], + [gl_cv_func_printf_directive_ls], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +#include +int main () +{ + int result = 0; + char buf[100]; + /* Test whether %ls works at all. + This test fails on OpenBSD 4.0, IRIX 6.5, Solaris 2.6, Haiku, but not on + Cygwin 1.5. */ + { + static const wchar_t wstring[] = { 'a', 'b', 'c', 0 }; + buf[0] = '\0'; + if (sprintf (buf, "%ls", wstring) < 0 + || strcmp (buf, "abc") != 0) + result |= 1; + } + /* This test fails on IRIX 6.5, Solaris 2.6, Cygwin 1.5, Haiku (with an + assertion failure inside libc), but not on OpenBSD 4.0. */ + { + static const wchar_t wstring[] = { 'a', 0 }; + buf[0] = '\0'; + if (sprintf (buf, "%ls", wstring) < 0 + || strcmp (buf, "a") != 0) + result |= 2; + } + /* Test whether precisions in %ls are supported as specified in ISO C 99 + section 7.19.6.1: + "If a precision is specified, no more than that many bytes are written + (including shift sequences, if any), and the array shall contain a + null wide character if, to equal the multibyte character sequence + length given by the precision, the function would need to access a + wide character one past the end of the array." + This test fails on Solaris 10. */ + { + static const wchar_t wstring[] = { 'a', 'b', (wchar_t) 0xfdfdfdfd, 0 }; + buf[0] = '\0'; + if (sprintf (buf, "%.2ls", wstring) < 0 + || strcmp (buf, "ab") != 0) + result |= 8; + } + return result; +}]])], + [gl_cv_func_printf_directive_ls=yes], + [gl_cv_func_printf_directive_ls=no], + [ +changequote(,)dnl + case "$host_os" in + # Guess yes on OpenBSD >= 6.0. + openbsd[1-5].*) gl_cv_func_printf_directive_ls="guessing no";; + openbsd*) gl_cv_func_printf_directive_ls="guessing yes";; + irix*) gl_cv_func_printf_directive_ls="guessing no";; + solaris*) gl_cv_func_printf_directive_ls="guessing no";; + cygwin*) gl_cv_func_printf_directive_ls="guessing no";; + beos* | haiku*) gl_cv_func_printf_directive_ls="guessing no";; + # Guess no on Android. + linux*-android*) gl_cv_func_printf_directive_ls="guessing no";; + # Guess yes on native Windows. + mingw* | windows*) gl_cv_func_printf_directive_ls="guessing yes";; + *) gl_cv_func_printf_directive_ls="guessing yes";; + esac +changequote([,])dnl + ]) + ]) +]) + +dnl Test whether the *printf family of functions supports the %lc format +dnl directive and in particular, when the argument is a null wide character, +dnl whether the functions produce a NUL byte, as specified in ISO C 23 +dnl after the issue GB-141 was fixed. +dnl Result is gl_cv_func_printf_directive_lc. + +AC_DEFUN([gl_PRINTF_DIRECTIVE_LC], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether printf supports the 'lc' directive correctly], + [gl_cv_func_printf_directive_lc], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +#include +int main () +{ + int result = 0; + char buf[100]; + /* This test fails on musl libc 1.2.4. */ + { + buf[0] = '\0'; + if (sprintf (buf, "%lc%lc%lc", (wint_t) 'a', (wint_t) 0, (wint_t) 'z') < 0 + || memcmp (buf, "a\0z", 4) != 0) + result |= 1; + } + return result; +}]])], + [gl_cv_func_printf_directive_lc=yes], + [gl_cv_func_printf_directive_lc=no], + [ +changequote(,)dnl + case "$host_os" in + # Guess no on musl libc. + *-musl* | midipix*) gl_cv_func_printf_directive_lc="guessing no";; + # Guess yes otherwise. + *) gl_cv_func_printf_directive_lc="guessing yes";; + esac +changequote([,])dnl + ]) + ]) +]) + +dnl Test whether the *printf family of functions supports POSIX/XSI format +dnl strings with positions. (POSIX:2001) +dnl Result is gl_cv_func_printf_positions. + +AC_DEFUN_ONCE([gl_PRINTF_POSITIONS], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether printf supports POSIX/XSI format strings with positions], + [gl_cv_func_printf_positions], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +/* The string "%2$d %1$d", with dollar characters protected from the shell's + dollar expansion (possibly an autoconf bug). */ +static char format[] = { '%', '2', '$', 'd', ' ', '%', '1', '$', 'd', '\0' }; +static char buf[100]; +int main () +{ + sprintf (buf, format, 33, 55); + return (strcmp (buf, "55 33") != 0); +}]])], + [gl_cv_func_printf_positions=yes], + [gl_cv_func_printf_positions=no], + [ +changequote(,)dnl + case "$host_os" in + netbsd[1-3]* | netbsdelf[1-3]* | netbsdaout[1-3]* | netbsdcoff[1-3]*) + gl_cv_func_printf_positions="guessing no";; + beos*) + gl_cv_func_printf_positions="guessing no";; + # Guess yes on Android. + linux*-android*) + gl_cv_func_printf_positions="guessing yes";; + # Guess no on native Windows. + mingw* | windows* | pw*) + gl_cv_func_printf_positions="guessing no";; + *) + gl_cv_func_printf_positions="guessing yes";; + esac +changequote([,])dnl + ]) + ]) +]) + +dnl Test whether the *printf family of functions supports POSIX/XSI format +dnl strings with the ' flag for grouping of decimal digits. (POSIX:2001) +dnl Result is gl_cv_func_printf_flag_grouping. + +AC_DEFUN([gl_PRINTF_FLAG_GROUPING], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether printf supports the grouping flag], + [gl_cv_func_printf_flag_grouping], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +static char buf[100]; +int main () +{ + if (sprintf (buf, "%'d %d", 1234567, 99) < 0 + || buf[strlen (buf) - 1] != '9') + return 1; + return 0; +}]])], + [gl_cv_func_printf_flag_grouping=yes], + [gl_cv_func_printf_flag_grouping=no], + [ +changequote(,)dnl + case "$host_os" in + cygwin*) gl_cv_func_printf_flag_grouping="guessing no";; + netbsd*) gl_cv_func_printf_flag_grouping="guessing no";; + # Guess no on Android. + linux*-android*) gl_cv_func_printf_flag_grouping="guessing no";; + # Guess no on native Windows. + mingw* | windows* | pw*) gl_cv_func_printf_flag_grouping="guessing no";; + *) gl_cv_func_printf_flag_grouping="guessing yes";; + esac +changequote([,])dnl + ]) + ]) +]) + +dnl Test whether the *printf family of functions supports the - flag correctly. +dnl (ISO C99.) See +dnl +dnl Result is gl_cv_func_printf_flag_leftadjust. + +AC_DEFUN([gl_PRINTF_FLAG_LEFTADJUST], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether printf supports the left-adjust flag correctly], + [gl_cv_func_printf_flag_leftadjust], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +static char buf[100]; +int main () +{ + /* Check that a '-' flag is not annihilated by a negative width. */ + if (sprintf (buf, "a%-*sc", -3, "b") < 0 + || strcmp (buf, "ab c") != 0) + return 1; + return 0; +}]])], + [gl_cv_func_printf_flag_leftadjust=yes], + [gl_cv_func_printf_flag_leftadjust=no], + [ +changequote(,)dnl + case "$host_os" in + # Guess yes on HP-UX 11. + hpux11*) gl_cv_func_printf_flag_leftadjust="guessing yes";; + # Guess no on HP-UX 10 and older. + hpux*) gl_cv_func_printf_flag_leftadjust="guessing no";; + # Guess yes on Android. + linux*-android*) gl_cv_func_printf_flag_leftadjust="guessing yes";; + # Guess yes on native Windows. + mingw* | windows*) gl_cv_func_printf_flag_leftadjust="guessing yes";; + # Guess yes otherwise. + *) gl_cv_func_printf_flag_leftadjust="guessing yes";; + esac +changequote([,])dnl + ]) + ]) +]) + +dnl Test whether the *printf family of functions supports padding of non-finite +dnl values with the 0 flag correctly. (ISO C99 + TC1 + TC2.) See +dnl +dnl Result is gl_cv_func_printf_flag_zero. + +AC_DEFUN([gl_PRINTF_FLAG_ZERO], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether printf supports the zero flag correctly], + [gl_cv_func_printf_flag_zero], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +static char buf[100]; +static double zero = 0.0; +int main () +{ + if (sprintf (buf, "%010f", 1.0 / zero, 33, 44, 55) < 0 + || (strcmp (buf, " inf") != 0 + && strcmp (buf, " infinity") != 0)) + return 1; + return 0; +}]])], + [gl_cv_func_printf_flag_zero=yes], + [gl_cv_func_printf_flag_zero=no], + [ +changequote(,)dnl + case "$host_os" in + # Guess yes on glibc systems. + *-gnu* | gnu*) gl_cv_func_printf_flag_zero="guessing yes";; + # Guess yes on musl systems. + *-musl* | midipix*) gl_cv_func_printf_flag_zero="guessing yes";; + # Guess yes on BeOS. + beos*) gl_cv_func_printf_flag_zero="guessing yes";; + # Guess no on Android. + linux*-android*) gl_cv_func_printf_flag_zero="guessing no";; + # Guess no on native Windows. + mingw* | windows*) gl_cv_func_printf_flag_zero="guessing no";; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_printf_flag_zero="$gl_cross_guess_normal";; + esac +changequote([,])dnl + ]) + ]) +]) + +dnl Test whether the *printf family of functions supports the # flag with a +dnl zero precision and a zero value in the 'x' and 'X' directives correctly. +dnl ISO C and POSIX specify that for the 'd', 'i', 'b', 'o', 'u', 'x', 'X' +dnl directives: "The result of converting a zero value with a precision of +dnl zero is no characters." But on Mac OS X 10.5, for the 'x', 'X' directives, +dnl when a # flag is present, the output is "0" instead of "". +dnl Result is gl_cv_func_printf_flag_alt_precision_zero. + +AC_DEFUN([gl_PRINTF_FLAG_ALT_PRECISION_ZERO], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether printf supports the alternative flag with a zero precision], + [gl_cv_func_printf_flag_alt_precision_zero], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +static char buf[10]; +int main () +{ + int result = 0; + if (sprintf (buf, "%#.0x %d", 0, 33, 44) > 0 + 3) + result |= 1; + return result; +}]])], + [gl_cv_func_printf_flag_alt_precision_zero=yes], + [gl_cv_func_printf_flag_alt_precision_zero=no], + [ +changequote(,)dnl + case "$host_os" in + # Guess no only on macOS 10..12 systems. + darwin[0-9] | darwin[0-9].* | \ + darwin1[0-9] | darwin1[0-9].* | \ + darwin2[0-1] | darwin2[0-1].*) + gl_cv_func_printf_flag_alt_precision_zero="guessing no" ;; + darwin*) gl_cv_func_printf_flag_alt_precision_zero="guessing yes" ;; + *) gl_cv_func_printf_flag_alt_precision_zero="guessing yes" ;; + esac +changequote([,])dnl + ]) + ]) +]) + +dnl Test whether the *printf family of functions supports large precisions. +dnl On mingw, precisions larger than 512 are treated like 512, in integer, +dnl floating-point or pointer output. On Solaris 10/x86, precisions larger +dnl than 510 in floating-point output crash the program. On Solaris 10/SPARC, +dnl precisions larger than 510 in floating-point output yield wrong results. +dnl On AIX 7.1, precisions larger than 998 in floating-point output yield +dnl wrong results. On BeOS, precisions larger than 1044 crash the program. +dnl Result is gl_cv_func_printf_precision. + +AC_DEFUN([gl_PRINTF_PRECISION], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether printf supports large precisions], + [gl_cv_func_printf_precision], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +static char buf[5000]; +int main () +{ + int result = 0; +#ifdef __BEOS__ + /* On BeOS, this would crash and show a dialog box. Avoid the crash. */ + return 1; +#endif + if (sprintf (buf, "%.4000d %d", 1, 33, 44) < 4000 + 3) + result |= 1; + if (sprintf (buf, "%.4000f %d", 1.0, 33, 44) < 4000 + 5) + result |= 2; + if (sprintf (buf, "%.511f %d", 1.0, 33, 44) < 511 + 5 + || buf[0] != '1') + result |= 4; + if (sprintf (buf, "%.999f %d", 1.0, 33, 44) < 999 + 5 + || buf[0] != '1') + result |= 4; + return result; +}]])], + [gl_cv_func_printf_precision=yes], + [gl_cv_func_printf_precision=no], + [ +changequote(,)dnl + case "$host_os" in + # Guess no only on Solaris, native Windows, and BeOS systems. + solaris*) gl_cv_func_printf_precision="guessing no" ;; + mingw* | windows* | pw*) gl_cv_func_printf_precision="guessing no" ;; + beos*) gl_cv_func_printf_precision="guessing no" ;; + # Guess yes on Android. + linux*-android*) gl_cv_func_printf_precision="guessing yes" ;; + *) gl_cv_func_printf_precision="guessing yes" ;; + esac +changequote([,])dnl + ]) + ]) +]) + +dnl Test whether the *printf family of functions recovers gracefully in case +dnl of an out-of-memory condition, or whether it crashes the entire program. +dnl Result is gl_cv_func_printf_enomem. + +AC_DEFUN([gl_PRINTF_ENOMEM], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([gl_MULTIARCH]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether printf survives out-of-memory conditions], + [gl_cv_func_printf_enomem], + [ + gl_cv_func_printf_enomem="guessing no" + if test "$cross_compiling" = no; then + if test $APPLE_UNIVERSAL_BUILD = 0; then + AC_LANG_CONFTEST([AC_LANG_SOURCE([[ +]GL_NOCRASH[ +#include +#include +#include +#include +#include +int main() +{ + struct rlimit limit; + int ret; + nocrash_init (); + /* Some printf implementations allocate temporary space with malloc. */ + /* On BSD systems, malloc() is limited by RLIMIT_DATA. */ +#ifdef RLIMIT_DATA + if (getrlimit (RLIMIT_DATA, &limit) < 0) + return 77; + if (limit.rlim_max == RLIM_INFINITY || limit.rlim_max > 5000000) + limit.rlim_max = 5000000; + limit.rlim_cur = limit.rlim_max; + if (setrlimit (RLIMIT_DATA, &limit) < 0) + return 77; +#endif + /* On Linux systems, malloc() is limited by RLIMIT_AS. */ +#ifdef RLIMIT_AS + if (getrlimit (RLIMIT_AS, &limit) < 0) + return 77; + if (limit.rlim_max == RLIM_INFINITY || limit.rlim_max > 5000000) + limit.rlim_max = 5000000; + limit.rlim_cur = limit.rlim_max; + if (setrlimit (RLIMIT_AS, &limit) < 0) + return 77; +#endif + /* Some printf implementations allocate temporary space on the stack. */ +#ifdef RLIMIT_STACK + if (getrlimit (RLIMIT_STACK, &limit) < 0) + return 77; + if (limit.rlim_max == RLIM_INFINITY || limit.rlim_max > 5000000) + limit.rlim_max = 5000000; + limit.rlim_cur = limit.rlim_max; + if (setrlimit (RLIMIT_STACK, &limit) < 0) + return 77; +#endif + ret = printf ("%.5000000f", 1.0); + return !(ret == 5000002 || (ret < 0 && errno == ENOMEM)); +} + ]])]) + if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then + (./conftest 2>&AS_MESSAGE_LOG_FD + result=$? + _AS_ECHO_LOG([\$? = $result]) + if test $result != 0 && test $result != 77; then result=1; fi + exit $result + ) >/dev/null 2>/dev/null + case $? in + 0) gl_cv_func_printf_enomem="yes" ;; + 77) gl_cv_func_printf_enomem="guessing no" ;; + *) gl_cv_func_printf_enomem="no" ;; + esac + else + gl_cv_func_printf_enomem="guessing no" + fi + rm -fr conftest* + else + dnl A universal build on Apple Mac OS X platforms. + dnl The result would be 'no' in 32-bit mode and 'yes' in 64-bit mode. + dnl But we need a configuration result that is valid in both modes. + gl_cv_func_printf_enomem="guessing no" + fi + fi + if test "$gl_cv_func_printf_enomem" = "guessing no"; then +changequote(,)dnl + case "$host_os" in + # Guess yes on glibc systems. + *-gnu* | gnu*) gl_cv_func_printf_enomem="guessing yes";; + # Guess yes on Solaris. + solaris*) gl_cv_func_printf_enomem="guessing yes";; + # Guess yes on AIX. + aix*) gl_cv_func_printf_enomem="guessing yes";; + # Guess yes on HP-UX/hppa. + hpux*) case "$host_cpu" in + hppa*) gl_cv_func_printf_enomem="guessing yes";; + *) gl_cv_func_printf_enomem="guessing no";; + esac + ;; + # Guess yes on IRIX. + irix*) gl_cv_func_printf_enomem="guessing yes";; + # Guess yes on OSF/1. + osf*) gl_cv_func_printf_enomem="guessing yes";; + # Guess yes on BeOS. + beos*) gl_cv_func_printf_enomem="guessing yes";; + # Guess yes on Haiku. + haiku*) gl_cv_func_printf_enomem="guessing yes";; + # Guess no on Android. + linux*-android*) gl_cv_func_printf_enomem="guessing no";; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_printf_enomem="$gl_cross_guess_normal";; + esac +changequote([,])dnl + fi + ]) +]) + +dnl Test whether the snprintf function exists. (ISO C99, POSIX:2001) +dnl Result is ac_cv_func_snprintf. + +AC_DEFUN([gl_SNPRINTF_PRESENCE], +[ + AC_CHECK_FUNCS_ONCE([snprintf]) +]) + +dnl Test whether the string produced by the snprintf function is always NUL +dnl terminated. (ISO C99, POSIX:2001) +dnl Result is gl_cv_func_snprintf_truncation_c99. + +AC_DEFUN_ONCE([gl_SNPRINTF_TRUNCATION_C99], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_REQUIRE([gl_SNPRINTF_PRESENCE]) + AC_CACHE_CHECK([whether snprintf truncates the result as in C99], + [gl_cv_func_snprintf_truncation_c99], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +#if HAVE_SNPRINTF +# define my_snprintf snprintf +#else +# include +static int my_snprintf (char *buf, int size, const char *format, ...) +{ + va_list args; + int ret; + va_start (args, format); + ret = vsnprintf (buf, size, format, args); + va_end (args); + return ret; +} +#endif +static char buf[100]; +int main () +{ + strcpy (buf, "ABCDEF"); + my_snprintf (buf, 3, "%d %d", 4567, 89); + if (memcmp (buf, "45\0DEF", 6) != 0) + return 1; + return 0; +}]])], + [gl_cv_func_snprintf_truncation_c99=yes], + [gl_cv_func_snprintf_truncation_c99=no], + [ +changequote(,)dnl + case "$host_os" in + # Guess yes on glibc systems. + *-gnu* | gnu*) gl_cv_func_snprintf_truncation_c99="guessing yes";; + # Guess yes on musl systems. + *-musl* | midipix*) gl_cv_func_snprintf_truncation_c99="guessing yes";; + # Guess yes on FreeBSD >= 5. + freebsd[1-4].*) gl_cv_func_snprintf_truncation_c99="guessing no";; + freebsd* | kfreebsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";; + midnightbsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";; + # Guess yes on Mac OS X >= 10.3. + darwin[1-6].*) gl_cv_func_snprintf_truncation_c99="guessing no";; + darwin*) gl_cv_func_snprintf_truncation_c99="guessing yes";; + # Guess yes on OpenBSD >= 3.9. + openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*) + gl_cv_func_snprintf_truncation_c99="guessing no";; + openbsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";; + # Guess yes on Solaris >= 2.6. + solaris2.[0-5] | solaris2.[0-5].*) + gl_cv_func_snprintf_truncation_c99="guessing no";; + solaris*) gl_cv_func_snprintf_truncation_c99="guessing yes";; + # Guess yes on AIX >= 4. + aix[1-3]*) gl_cv_func_snprintf_truncation_c99="guessing no";; + aix*) gl_cv_func_snprintf_truncation_c99="guessing yes";; + # Guess yes on HP-UX >= 11. + hpux[7-9]* | hpux10*) gl_cv_func_snprintf_truncation_c99="guessing no";; + hpux*) gl_cv_func_snprintf_truncation_c99="guessing yes";; + # Guess yes on IRIX >= 6.5. + irix6.5) gl_cv_func_snprintf_truncation_c99="guessing yes";; + # Guess yes on OSF/1 >= 5. + osf[3-4]*) gl_cv_func_snprintf_truncation_c99="guessing no";; + osf*) gl_cv_func_snprintf_truncation_c99="guessing yes";; + # Guess yes on NetBSD >= 3. + netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) + gl_cv_func_snprintf_truncation_c99="guessing no";; + netbsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";; + # Guess yes on BeOS. + beos*) gl_cv_func_snprintf_truncation_c99="guessing yes";; + # Guess yes on Android. + linux*-android*) gl_cv_func_snprintf_truncation_c99="guessing yes";; + # Guess no on native Windows. + mingw* | windows*) gl_cv_func_snprintf_truncation_c99="guessing no";; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_snprintf_truncation_c99="$gl_cross_guess_normal";; + esac +changequote([,])dnl + ]) + ]) +]) + +dnl Test whether the return value of the snprintf function is the number +dnl of bytes (excluding the terminating NUL) that would have been produced +dnl if the buffer had been large enough. (ISO C99, POSIX:2001) +dnl For example, this test program fails on IRIX 6.5: +dnl --------------------------------------------------------------------- +dnl #include +dnl int main() +dnl { +dnl static char buf[8]; +dnl int retval = snprintf (buf, 3, "%d", 12345); +dnl return retval >= 0 && retval < 3; +dnl } +dnl --------------------------------------------------------------------- +dnl Result is gl_cv_func_snprintf_retval_c99. + +AC_DEFUN_ONCE([gl_SNPRINTF_RETVAL_C99], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_REQUIRE([gl_SNPRINTF_PRESENCE]) + AC_CACHE_CHECK([whether snprintf returns a byte count as in C99], + [gl_cv_func_snprintf_retval_c99], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +#if HAVE_SNPRINTF +# define my_snprintf snprintf +#else +# include +static int my_snprintf (char *buf, int size, const char *format, ...) +{ + va_list args; + int ret; + va_start (args, format); + ret = vsnprintf (buf, size, format, args); + va_end (args); + return ret; +} +#endif +static char buf[100]; +int main () +{ + strcpy (buf, "ABCDEF"); + if (my_snprintf (buf, 3, "%d %d", 4567, 89) != 7) + return 1; + if (my_snprintf (buf, 0, "%d %d", 4567, 89) != 7) + return 2; + if (my_snprintf (NULL, 0, "%d %d", 4567, 89) != 7) + return 3; + return 0; +}]])], + [gl_cv_func_snprintf_retval_c99=yes], + [gl_cv_func_snprintf_retval_c99=no], + [case "$host_os" in +changequote(,)dnl + # Guess yes on glibc systems. + *-gnu* | gnu*) gl_cv_func_snprintf_retval_c99="guessing yes";; + # Guess yes on musl systems. + *-musl* | midipix*) gl_cv_func_snprintf_retval_c99="guessing yes";; + # Guess yes on FreeBSD >= 5. + freebsd[1-4].*) gl_cv_func_snprintf_retval_c99="guessing no";; + freebsd* | kfreebsd*) gl_cv_func_snprintf_retval_c99="guessing yes";; + midnightbsd*) gl_cv_func_snprintf_retval_c99="guessing yes";; + # Guess yes on Mac OS X >= 10.3. + darwin[1-6].*) gl_cv_func_snprintf_retval_c99="guessing no";; + darwin*) gl_cv_func_snprintf_retval_c99="guessing yes";; + # Guess yes on OpenBSD >= 3.9. + openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*) + gl_cv_func_snprintf_retval_c99="guessing no";; + openbsd*) gl_cv_func_snprintf_retval_c99="guessing yes";; + # Guess yes on Solaris >= 2.10. + solaris2.[1-9][0-9]*) gl_cv_func_printf_sizes_c99="guessing yes";; + solaris*) gl_cv_func_printf_sizes_c99="guessing no";; + # Guess yes on AIX >= 4. + aix[1-3]*) gl_cv_func_snprintf_retval_c99="guessing no";; + aix*) gl_cv_func_snprintf_retval_c99="guessing yes";; + # Guess yes on NetBSD >= 3. + netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) + gl_cv_func_snprintf_retval_c99="guessing no";; + netbsd*) gl_cv_func_snprintf_retval_c99="guessing yes";; + # Guess yes on BeOS. + beos*) gl_cv_func_snprintf_retval_c99="guessing yes";; + # Guess yes on Android. + linux*-android*) gl_cv_func_snprintf_retval_c99="guessing yes";; +changequote([,])dnl + # Guess yes on MSVC, no on mingw. + windows*-msvc*) gl_cv_func_snprintf_retval_c99="guessing yes" ;; + mingw* | windows*) AC_EGREP_CPP([Known], [ +#ifdef _MSC_VER + Known +#endif + ], + [gl_cv_func_snprintf_retval_c99="guessing yes"], + [gl_cv_func_snprintf_retval_c99="guessing no"]) + ;; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_snprintf_retval_c99="$gl_cross_guess_normal";; + esac + ]) + ]) +]) + +dnl Test whether the snprintf function supports the %n format directive +dnl also in truncated portions of the format string. (ISO C99, POSIX:2001) +dnl Result is gl_cv_func_snprintf_directive_n. + +AC_DEFUN([gl_SNPRINTF_DIRECTIVE_N], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_REQUIRE([gl_SNPRINTF_PRESENCE]) + AC_CACHE_CHECK([whether snprintf fully supports the 'n' directive], + [gl_cv_func_snprintf_directive_n], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +#if HAVE_SNPRINTF +# define my_snprintf snprintf +#else +# include +static int my_snprintf (char *buf, int size, const char *format, ...) +{ + va_list args; + int ret; + va_start (args, format); + ret = vsnprintf (buf, size, format, args); + va_end (args); + return ret; +} +#endif +static char fmtstring[10]; +static char buf[100]; +int main () +{ + int count = -1; + /* Copy the format string. Some systems (glibc with _FORTIFY_SOURCE=2) + support %n in format strings in read-only memory but not in writable + memory. */ + strcpy (fmtstring, "%d %n"); + my_snprintf (buf, 4, fmtstring, 12345, &count, 33, 44, 55); + if (count != 6) + return 1; + return 0; +}]])], + [gl_cv_func_snprintf_directive_n=yes], + [gl_cv_func_snprintf_directive_n=no], + [ + case "$host_os" in + # Guess no on glibc when _FORTIFY_SOURCE >= 2. + *-gnu* | gnu*) AC_COMPILE_IFELSE( + [AC_LANG_SOURCE( + [[#if _FORTIFY_SOURCE >= 2 + error fail + #endif + ]])], + [gl_cv_func_snprintf_directive_n="guessing yes"], + [gl_cv_func_snprintf_directive_n="guessing no"]) + ;; +changequote(,)dnl + # Guess yes on musl systems. + *-musl* | midipix*) gl_cv_func_snprintf_directive_n="guessing yes";; + # Guess yes on FreeBSD >= 5. + freebsd[1-4].*) gl_cv_func_snprintf_directive_n="guessing no";; + freebsd* | kfreebsd*) gl_cv_func_snprintf_directive_n="guessing yes";; + midnightbsd*) gl_cv_func_snprintf_directive_n="guessing yes";; + # Guess yes on Mac OS X >= 10.3. + darwin[1-6].*) gl_cv_func_snprintf_directive_n="guessing no";; + darwin*) gl_cv_func_snprintf_directive_n="guessing yes";; + # Guess yes on Solaris >= 2.6. + solaris2.[0-5] | solaris2.[0-5].*) + gl_cv_func_snprintf_directive_n="guessing no";; + solaris*) gl_cv_func_snprintf_directive_n="guessing yes";; + # Guess yes on AIX >= 4. + aix[1-3]*) gl_cv_func_snprintf_directive_n="guessing no";; + aix*) gl_cv_func_snprintf_directive_n="guessing yes";; + # Guess yes on IRIX >= 6.5. + irix6.5) gl_cv_func_snprintf_directive_n="guessing yes";; + # Guess yes on OSF/1 >= 5. + osf[3-4]*) gl_cv_func_snprintf_directive_n="guessing no";; + osf*) gl_cv_func_snprintf_directive_n="guessing yes";; + # Guess yes on NetBSD >= 3. + netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) + gl_cv_func_snprintf_directive_n="guessing no";; + netbsd*) gl_cv_func_snprintf_directive_n="guessing yes";; + # Guess yes on BeOS. + beos*) gl_cv_func_snprintf_directive_n="guessing yes";; + # Guess no on Android. + linux*-android*) gl_cv_func_snprintf_directive_n="guessing no";; + # Guess no on native Windows. + mingw* | windows*) gl_cv_func_snprintf_directive_n="guessing no";; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_snprintf_directive_n="$gl_cross_guess_normal";; +changequote([,])dnl + esac + ]) + ]) +]) + +dnl Test whether the snprintf function, when passed a size = 1, writes any +dnl output without bounds in this case, behaving like sprintf. This is the +dnl case on Linux libc5. +dnl Result is gl_cv_func_snprintf_size1. + +AC_DEFUN([gl_SNPRINTF_SIZE1], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_REQUIRE([gl_SNPRINTF_PRESENCE]) + AC_CACHE_CHECK([whether snprintf respects a size of 1], + [gl_cv_func_snprintf_size1], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#if HAVE_SNPRINTF +# define my_snprintf snprintf +#else +# include +static int my_snprintf (char *buf, int size, const char *format, ...) +{ + va_list args; + int ret; + va_start (args, format); + ret = vsnprintf (buf, size, format, args); + va_end (args); + return ret; +} +#endif +int main() +{ + static char buf[8] = { 'D', 'E', 'A', 'D', 'B', 'E', 'E', 'F' }; + my_snprintf (buf, 1, "%d", 12345); + return buf[1] != 'E'; +}]])], + [gl_cv_func_snprintf_size1=yes], + [gl_cv_func_snprintf_size1=no], + [case "$host_os" in + # Guess yes on Android. + linux*-android*) gl_cv_func_snprintf_size1="guessing yes" ;; + # Guess yes on native Windows. + mingw* | windows*) gl_cv_func_snprintf_size1="guessing yes" ;; + *) gl_cv_func_snprintf_size1="guessing yes" ;; + esac + ]) + ]) +]) + +dnl Test whether the vsnprintf function, when passed a zero size, produces no +dnl output. (ISO C99, POSIX:2001) +dnl For example, snprintf nevertheless writes a NUL byte in this case +dnl on OSF/1 5.1: +dnl --------------------------------------------------------------------- +dnl #include +dnl int main() +dnl { +dnl static char buf[8] = { 'D', 'E', 'A', 'D', 'B', 'E', 'E', 'F' }; +dnl snprintf (buf, 0, "%d", 12345); +dnl return buf[0] != 'D'; +dnl } +dnl --------------------------------------------------------------------- +dnl And vsnprintf writes any output without bounds in this case, behaving like +dnl vsprintf, on HP-UX 11 and OSF/1 5.1: +dnl --------------------------------------------------------------------- +dnl #include +dnl #include +dnl static int my_snprintf (char *buf, int size, const char *format, ...) +dnl { +dnl va_list args; +dnl int ret; +dnl va_start (args, format); +dnl ret = vsnprintf (buf, size, format, args); +dnl va_end (args); +dnl return ret; +dnl } +dnl int main() +dnl { +dnl static char buf[8] = { 'D', 'E', 'A', 'D', 'B', 'E', 'E', 'F' }; +dnl my_snprintf (buf, 0, "%d", 12345); +dnl return buf[0] != 'D'; +dnl } +dnl --------------------------------------------------------------------- +dnl Result is gl_cv_func_vsnprintf_zerosize_c99. + +AC_DEFUN([gl_VSNPRINTF_ZEROSIZE_C99], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether vsnprintf respects a zero size as in C99], + [gl_cv_func_vsnprintf_zerosize_c99], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +static int my_snprintf (char *buf, int size, const char *format, ...) +{ + va_list args; + int ret; + va_start (args, format); + ret = vsnprintf (buf, size, format, args); + va_end (args); + return ret; +} +int main() +{ + static char buf[8] = { 'D', 'E', 'A', 'D', 'B', 'E', 'E', 'F' }; + my_snprintf (buf, 0, "%d", 12345); + return buf[0] != 'D'; +}]])], + [gl_cv_func_vsnprintf_zerosize_c99=yes], + [gl_cv_func_vsnprintf_zerosize_c99=no], + [ +changequote(,)dnl + case "$host_os" in + # Guess yes on glibc systems. + *-gnu* | gnu*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + # Guess yes on musl systems. + *-musl* | midipix*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + # Guess yes on FreeBSD >= 5. + freebsd[1-4].*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; + freebsd* | kfreebsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + midnightbsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + # Guess yes on Mac OS X >= 10.3. + darwin[1-6].*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; + darwin*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + # Guess yes on Cygwin. + cygwin*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + # Guess yes on Solaris >= 2.6. + solaris2.[0-5] | solaris2.[0-5].*) + gl_cv_func_vsnprintf_zerosize_c99="guessing no";; + solaris*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + # Guess yes on AIX >= 4. + aix[1-3]*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; + aix*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + # Guess yes on IRIX >= 6.5. + irix6.5) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + # Guess yes on NetBSD >= 3. + netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) + gl_cv_func_vsnprintf_zerosize_c99="guessing no";; + netbsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + # Guess yes on BeOS. + beos*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + # Guess yes on Android. + linux*-android*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + # Guess yes on native Windows. + mingw* | windows* | pw*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_vsnprintf_zerosize_c99="$gl_cross_guess_normal";; + esac +changequote([,])dnl + ]) + ]) +]) + +dnl Test whether the swprintf function works correctly when it produces output +dnl that contains null wide characters. +dnl Result is gl_cv_func_swprintf_works. + +AC_DEFUN([gl_SWPRINTF_WORKS], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CHECK_FUNCS_ONCE([swprintf]) + AC_CACHE_CHECK([whether swprintf works], + [gl_cv_func_swprintf_works], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#ifndef __USE_MINGW_ANSI_STDIO +# define __USE_MINGW_ANSI_STDIO 1 +#endif +#include +#include +int main() +{ + int result = 0; + { /* This test fails on musl libc 1.2.3, FreeBSD, NetBSD, OpenBSD, macOS, AIX. */ + wchar_t buf[5] = { 0xBEEF, 0xBEEF, 0xBEEF, 0xBEEF, 0xBEEF }; + int ret = swprintf (buf, 4, L"%cz", '\0'); + /* Expected result: + ret = 2, buf[0] = 0x0, buf[1] = 0x7a, buf[2] = 0x0, buf[3] = 0xbeef + musl libc 1.2.3: + ret = 2, buf[0] = 0x0, buf[1] = 0x0, buf[2] = 0x0, buf[3] = 0x0 + Reported at . + FreeBSD 13.1, NetBSD 9.0, OpenBSD 7.2, macOS 12.5, AIX 7.2: + ret = 2, buf[0] = 0x0, buf[1] = 0xbeef, buf[2] = 0xbeef, buf[3] = 0xbeef + */ + if (ret < 0 || buf[1] != 'z') + result |= 1; + } + { /* This test fails on mingw. */ + wchar_t buf[2]; + int ret = swprintf (buf, 2, L"%lc", (wint_t)0); + /* Expected: ret = 1 + mingw: ret = 0 + */ + if (ret != 1) + result |= 2; + } + return result; +}]])], + [gl_cv_func_swprintf_works=yes], + [gl_cv_func_swprintf_works=no], + [case "$host_os" in + # Guess yes on glibc systems. + *-gnu* | gnu*) gl_cv_func_swprintf_works="guessing yes";; + # Guess no on musl systems. + *-musl* | midipix*) gl_cv_func_swprintf_works="guessing no";; + # Guess no on FreeBSD, NetBSD, OpenBSD, macOS, AIX. + freebsd* | midnightbsd* | netbsd* | openbsd* | darwin* | aix*) + gl_cv_func_swprintf_works="guessing no";; + # Guess no on native Windows. + mingw* | windows* | pw*) gl_cv_func_swprintf_works="guessing no";; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_swprintf_works="$gl_cross_guess_normal";; + esac + ]) + ]) +]) + +dnl Test whether the *wprintf family of functions supports the 'a' and 'A' +dnl conversion specifier for hexadecimal output of 'long double' numbers. +dnl (ISO C99, POSIX:2001) +dnl Result is gl_cv_func_swprintf_directive_la. + +AC_DEFUN([gl_SWPRINTF_DIRECTIVE_LA], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether swprintf supports the 'La' and 'LA' directives], + [gl_cv_func_swprintf_directive_la], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +static wchar_t buf[100]; +int main () +{ + int result = 0; + /* This catches a glibc 2.15 and Haiku 2022 bug. */ + if (swprintf (buf, sizeof (buf) / sizeof (wchar_t), + L"%La %d", 3.1416015625L, 33, 44, 55) < 0 + || (wcscmp (buf, L"0x1.922p+1 33") != 0 + && wcscmp (buf, L"0x3.244p+0 33") != 0 + && wcscmp (buf, L"0x6.488p-1 33") != 0 + && wcscmp (buf, L"0xc.91p-2 33") != 0)) + result |= 1; + return result; +}]])], + [gl_cv_func_swprintf_directive_la=yes], + [gl_cv_func_swprintf_directive_la=no], + [case "$host_os" in + # Guess yes on glibc >= 2.17 systems. + *-gnu* | gnu*) + AC_EGREP_CPP([Unlucky], [ + #include + #ifdef __GNU_LIBRARY__ + #if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 16) || (__GLIBC__ > 2)) && !defined __UCLIBC__ + Unlucky + #endif + #endif + ], + [gl_cv_func_swprintf_directive_la="guessing yes"], + [gl_cv_func_swprintf_directive_la="guessing no"]) + ;; + # Guess yes on musl systems. + *-musl* | midipix*) gl_cv_func_swprintf_directive_la="guessing yes";; + # Guess yes on Android. + linux*-android*) gl_cv_func_swprintf_directive_la="guessing yes";; + # Guess no on native Windows. + mingw* | windows*) gl_cv_func_swprintf_directive_la="guessing no";; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_swprintf_directive_la="$gl_cross_guess_normal";; + esac + ]) + ]) +]) + +dnl Test whether the *wprintf family of functions supports the 'lc' conversion +dnl specifier for all wide characters. +dnl (ISO C11, POSIX:2001) +dnl Result is gl_cv_func_swprintf_directive_lc. + +AC_DEFUN([gl_SWPRINTF_DIRECTIVE_LC], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether swprintf supports the 'lc' directive], + [gl_cv_func_swprintf_directive_lc], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +static wchar_t buf[100]; +static wint_t L_invalid = (wchar_t) 0x76543210; +int main () +{ + int result = 0; + /* This catches a musl libc 1.2.4, Android bug. + Reported at . */ + if (swprintf (buf, sizeof (buf) / sizeof (wchar_t), + L"%lc %d", L_invalid, 33, 44, 55) < 0) + result |= 1; + return result; +}]])], + [gl_cv_func_swprintf_directive_lc=yes], + [gl_cv_func_swprintf_directive_lc=no], + [case "$host_os" in + # Guess yes on glibc systems. + *-gnu* | gnu*) gl_cv_func_swprintf_directive_lc="guessing yes";; + # Guess no on musl systems. + *-musl* | midipix*) gl_cv_func_swprintf_directive_lc="guessing no";; + # Guess no on Android. + linux*-android*) gl_cv_func_swprintf_directive_lc="guessing no";; + # Guess yes on native Windows. + mingw* | windows*) gl_cv_func_swprintf_directive_lc="guessing yes";; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_swprintf_directive_lc="$gl_cross_guess_normal";; + esac + ]) + ]) +]) + +dnl The results of these tests on various platforms are: +dnl +dnl 1 = gl_PRINTF_SIZES_C99 +dnl 2 = gl_PRINTF_SIZES_C23 +dnl 3 = gl_PRINTF_LONG_DOUBLE +dnl 4 = gl_PRINTF_INFINITE +dnl 5 = gl_PRINTF_INFINITE_LONG_DOUBLE +dnl 6 = gl_PRINTF_DIRECTIVE_A +dnl 7 = gl_PRINTF_DIRECTIVE_B +dnl 8 = gl_PRINTF_DIRECTIVE_UPPERCASE_B +dnl 9 = gl_PRINTF_DIRECTIVE_F +dnl 10 = gl_PRINTF_DIRECTIVE_N +dnl 11 = gl_PRINTF_DIRECTIVE_LS +dnl 12 = gl_PRINTF_DIRECTIVE_LC +dnl 13 = gl_PRINTF_POSITIONS +dnl 14 = gl_PRINTF_FLAG_GROUPING +dnl 15 = gl_PRINTF_FLAG_LEFTADJUST +dnl 16 = gl_PRINTF_FLAG_ZERO +dnl 17 = gl_PRINTF_FLAG_ALT_PRECISION_ZERO +dnl 18 = gl_PRINTF_PRECISION +dnl 19 = gl_PRINTF_ENOMEM +dnl 20 = gl_SNPRINTF_PRESENCE +dnl 21 = gl_SNPRINTF_TRUNCATION_C99 +dnl 22 = gl_SNPRINTF_RETVAL_C99 +dnl 23 = gl_SNPRINTF_DIRECTIVE_N +dnl 24 = gl_SNPRINTF_SIZE1 +dnl 25 = gl_VSNPRINTF_ZEROSIZE_C99 +dnl 26 = gl_SWPRINTF_WORKS +dnl 27 = gl_SWPRINTF_DIRECTIVE_LA +dnl 28 = gl_SWPRINTF_DIRECTIVE_LC +dnl +dnl 1 = checking whether printf supports size specifiers as in C99... +dnl 2 = checking whether printf supports size specifiers as in C23... +dnl 3 = checking whether printf supports 'long double' arguments... +dnl 4 = checking whether printf supports infinite 'double' arguments... +dnl 5 = checking whether printf supports infinite 'long double' arguments... +dnl 6 = checking whether printf supports the 'a' and 'A' directives... +dnl 7 = checking whether printf supports the 'b' directive... +dnl 8 = checking whether printf supports the 'B' directive... +dnl 9 = checking whether printf supports the 'F' directive... +dnl 10 = checking whether printf supports the 'n' directive... +dnl 11 = checking whether printf supports the 'ls' directive... +dnl 12 = checking whether printf supports the 'lc' directive correctly... +dnl 13 = checking whether printf supports POSIX/XSI format strings with positions... +dnl 14 = checking whether printf supports the grouping flag... +dnl 15 = checking whether printf supports the left-adjust flag correctly... +dnl 16 = checking whether printf supports the zero flag correctly... +dnl 17 = checking whether printf supports the alternative flag with a zero precision... +dnl 18 = checking whether printf supports large precisions... +dnl 19 = checking whether printf survives out-of-memory conditions... +dnl 20 = checking for snprintf... +dnl 21 = checking whether snprintf truncates the result as in C99... +dnl 22 = checking whether snprintf returns a byte count as in C99... +dnl 23 = checking whether snprintf fully supports the 'n' directive... +dnl 24 = checking whether snprintf respects a size of 1... +dnl 25 = checking whether vsnprintf respects a zero size as in C99... +dnl 26 = checking whether swprintf works... +dnl 27 = checking whether swprintf supports the 'La' and 'LA' directives... +dnl 28 = checking whether swprintf supports the 'lc' directive... +dnl +dnl . = yes, # = no. +dnl +dnl 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 +dnl musl libc 1.2.3 . # . . . . # # . . . # . . . . ? . . . . . . . . # . # +dnl glibc 2.35 . # . . . . . . . . . . . . . . . . . . . . . . . . . . +dnl glibc 2.5 . # . . . . # # . . . . . . . . . . . . . . . . . . # . +dnl glibc 2.3.6 . # . . . # # # . . . . . . . . . . . . . . . . . . # . +dnl FreeBSD 14.0 . . . . . # . . . . . . . . . . . . # . . . . . . # . # +dnl FreeBSD 13.0 . # . . . # # # . . . . . . . . . . # . . . . . . # . # +dnl FreeBSD 5.4, 6.1 . # . . . # # # . . . . . . . # ? . # . . . . . . # ? ? +dnl Mac OS X 10.13.5 . # . . # # # # . # . . . . . . . . . . . . # . . # ? ? +dnl Mac OS X 10.5.8 . # . . # # # # . . . . . . . # # . . . . . . . . # ? ? +dnl Mac OS X 10.3.9 . # . . . # # # . . . . . . . # # . # . . . . . . # ? ? +dnl OpenBSD 6.0, 6.7 . # . . . # # # . . . . . . . . . . # . . . . . . # . # +dnl OpenBSD 3.9, 4.0 . # . # # # # # # . # . . # . # ? . # . . . . . . # ? ? +dnl Cygwin 1.7.0 (2009) . # . . # . # # . . ? ? . . . . ? . ? . . . . . . ? ? ? +dnl Cygwin 1.5.25 (2008) . # . . # # # # . . # ? . . . . ? . # . . . . . . ? ? ? +dnl Cygwin 1.5.19 (2006) # # . . # # # # # . # ? . # . # ? # # . . . . . . ? ? ? +dnl Solaris 11.4 . # . # # # # # . . # . . . . # . . . . . . . . . . # . +dnl Solaris 11.3 . # . . . # # # . . # . . . . . . . . . . . . . . . # . +dnl Solaris 11.0 . # . # # # # # . . # . . . . # . . . . . . . . . ? ? ? +dnl Solaris 10 . # . # # # # # . . # . . . . # . # . . . . . . . . # . +dnl Solaris 2.6 ... 9 # # . # # # # # # . # . . . . # ? # . . . # . . . ? ? ? +dnl Solaris 2.5.1 # # . # # # # # # . # . . . . # ? . . # # # # # # ? ? ? +dnl AIX 7.1 . # . # # # # # . . . . . . . # . # . . . . . . . # . . +dnl AIX 5.2 . # . # # # # # . . . . . . . # ? . . . . . . . . # ? ? +dnl AIX 4.3.2, 5.1 # # . # # # # # # . . . . . . # ? . . . . # . . . # ? ? +dnl HP-UX 11.31 . # . . . # # # . . . ? . . . # ? . . . . # # . . ? ? ? +dnl HP-UX 11.{00,11,23} # # . . . # # # # . . ? . . . # ? . . . . # # . # ? ? ? +dnl HP-UX 10.20 # # . # . # # # # . ? ? . . # # ? . . . . # # ? # ? ? ? +dnl IRIX 6.5 # # . # # # # # # . # . . . . # ? . . . . # . . . # ? ? +dnl OSF/1 5.1 # # . # # # # # # . . ? . . . # ? . . . . # . . # ? ? ? +dnl OSF/1 4.0d # # . # # # # # # . . ? . . . # ? . . # # # # # # ? ? ? +dnl NetBSD 9.0 . # . . . # # # . . . . . . . . . . . . . . . . . # . # +dnl NetBSD 5.0 . # . . # # # # . . . . . . . # ? . # . . . . . . # ? ? +dnl NetBSD 4.0 . # ? ? ? ? # # ? . ? . . ? ? ? ? ? ? . . . ? ? ? # ? ? +dnl NetBSD 3.0 . # . . . # # # # . ? . # # ? # ? . # . . . . . . # ? ? +dnl Haiku . # . . # # # # # . # ? . . . . ? . ? . . ? . . . . # . +dnl BeOS # # # . # # # # # . ? ? # . ? . ? # ? . . ? . . . ? ? ? +dnl Android 4.3 . # . # # # # # # # # ? . # . # ? . # . . . # . . ? ? ? +dnl old mingw / msvcrt # # # # # # # # # . . ? # # . # ? # ? . # # # . . # ? ? +dnl MSVC 9 # # # # # # # # # # . ? # # . # ? # ? # # # # . . # ? ? +dnl mingw 2009-2011 . # # . # . # # . . . ? # # . . ? . ? . . . . . . # ? ? +dnl mingw-w64 2011 # # # # # # # # # . . ? # # . # ? # ? . # # # . . # ? ? diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/priv-set.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/priv-set.m4 new file mode 100644 index 00000000..bbdce660 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/priv-set.m4 @@ -0,0 +1,15 @@ +# serial 8 + +# Copyright (C) 2009-2024 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# Written by David Bartley. + +AC_DEFUN([gl_PRIV_SET], +[ + AC_CHECK_FUNCS([getppriv]) + AC_CHECK_HEADERS_ONCE([priv.h]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/pselect.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/pselect.m4 new file mode 100644 index 00000000..005b722b --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/pselect.m4 @@ -0,0 +1,75 @@ +# pselect.m4 serial 11 +dnl Copyright (C) 2011-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_PSELECT], +[ + AC_REQUIRE([gl_SYS_SELECT_H]) + AC_REQUIRE([AC_C_RESTRICT]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CHECK_FUNCS_ONCE([pselect]) + + if test $ac_cv_func_pselect = yes; then + AC_CACHE_CHECK([whether signature of pselect conforms to POSIX], + [gl_cv_sig_pselect], + [AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include + ]], + [[int (*p) (int, fd_set *, fd_set *, fd_set *restrict, + struct timespec const *restrict, + sigset_t const *restrict) = pselect; + return !p;]])], + [gl_cv_sig_pselect=yes], + [gl_cv_sig_pselect=no])]) + + dnl On FreeBSD 8.2, pselect() doesn't always reject bad fds. + AC_CACHE_CHECK([whether pselect detects invalid fds], + [gl_cv_func_pselect_detects_ebadf], + [ + AC_RUN_IFELSE([AC_LANG_PROGRAM([[ +#include +#include +#if HAVE_SYS_SELECT_H +# include +#endif +#include +#include +]GL_MDA_DEFINES], +[[ + fd_set set; + dup2(0, 16); + FD_ZERO(&set); + FD_SET(16, &set); + close(16); + struct timespec timeout; + timeout.tv_sec = 0; + timeout.tv_nsec = 5000; + return pselect (17, &set, NULL, NULL, &timeout, NULL) != -1 || errno != EBADF; +]])], [gl_cv_func_pselect_detects_ebadf=yes], + [gl_cv_func_pselect_detects_ebadf=no], + [ + case "$host_os" in + # Guess yes on Linux systems. + linux-* | linux) gl_cv_func_pselect_detects_ebadf="guessing yes" ;; + # Guess yes on systems that emulate the Linux system calls. + midipix*) gl_cv_func_pselect_detects_ebadf="guessing yes" ;; + # Guess yes on glibc systems. + *-gnu* | gnu*) gl_cv_func_pselect_detects_ebadf="guessing yes" ;; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_pselect_detects_ebadf="$gl_cross_guess_normal" ;; + esac + ]) + ]) + case $gl_cv_func_pselect_detects_ebadf in + *yes) ;; + *) REPLACE_PSELECT=1 ;; + esac + fi + + if test $ac_cv_func_pselect = no || test $gl_cv_sig_pselect = no; then + REPLACE_PSELECT=1 + fi +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/pthread-thread.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/pthread-thread.m4 new file mode 100644 index 00000000..37855587 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/pthread-thread.m4 @@ -0,0 +1,69 @@ +# pthread-thread.m4 serial 3 +dnl Copyright (C) 2019-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_PTHREAD_THREAD], +[ + AC_REQUIRE([gl_PTHREAD_H]) + AC_REQUIRE([AC_CANONICAL_HOST]) + + if { case "$host_os" in mingw* | windows*) true;; *) false;; esac; } \ + && test $gl_threads_api = windows; then + dnl Choose function names that don't conflict with the mingw-w64 winpthreads + dnl library. + REPLACE_PTHREAD_CREATE=1 + REPLACE_PTHREAD_ATTR_INIT=1 + REPLACE_PTHREAD_ATTR_GETDETACHSTATE=1 + REPLACE_PTHREAD_ATTR_SETDETACHSTATE=1 + REPLACE_PTHREAD_ATTR_DESTROY=1 + REPLACE_PTHREAD_SELF=1 + REPLACE_PTHREAD_EQUAL=1 + REPLACE_PTHREAD_DETACH=1 + REPLACE_PTHREAD_JOIN=1 + REPLACE_PTHREAD_EXIT=1 + else + if test $HAVE_PTHREAD_H = 0; then + HAVE_PTHREAD_CREATE=0 + HAVE_PTHREAD_ATTR_INIT=0 + HAVE_PTHREAD_ATTR_GETDETACHSTATE=0 + HAVE_PTHREAD_ATTR_SETDETACHSTATE=0 + HAVE_PTHREAD_ATTR_DESTROY=0 + HAVE_PTHREAD_SELF=0 + HAVE_PTHREAD_EQUAL=0 + HAVE_PTHREAD_DETACH=0 + HAVE_PTHREAD_JOIN=0 + HAVE_PTHREAD_EXIT=0 + else + dnl On HP-UX 11.11, pthread_create() and pthread_attr_init() are only + dnl defined as inline functions. + AC_CACHE_CHECK([whether pthread_create exists as a global function], + [gl_cv_func_pthread_create], + [saved_LIBS="$LIBS" + LIBS="$LIBS $LIBPMULTITHREAD" + AC_LINK_IFELSE( + [AC_LANG_SOURCE( + [[extern + #ifdef __cplusplus + "C" + #endif + int pthread_create (void); + int main () + { + return pthread_create (); + } + ]])], + [gl_cv_func_pthread_create=yes], + [gl_cv_func_pthread_create=no]) + LIBS="$saved_LIBS" + ]) + if test $gl_cv_func_pthread_create = no; then + REPLACE_PTHREAD_CREATE=1 + REPLACE_PTHREAD_ATTR_INIT=1 + AC_DEFINE([PTHREAD_CREATE_IS_INLINE], [1], + [Define if pthread_create is an inline function.]) + fi + fi + fi +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/pthread_h.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/pthread_h.m4 new file mode 100644 index 00000000..c33afa0c --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/pthread_h.m4 @@ -0,0 +1,283 @@ +# pthread_h.m4 serial 9 +dnl Copyright (C) 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN_ONCE([gl_PTHREAD_H], +[ + dnl Ensure to expand the default settings once only, before all statements + dnl that occur in other macros. + AC_REQUIRE([gl_PTHREAD_H_DEFAULTS]) + + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_REQUIRE([gl_PTHREADLIB]) + + gl_CHECK_NEXT_HEADERS([pthread.h]) + if test $ac_cv_header_pthread_h = yes; then + HAVE_PTHREAD_H=1 + dnl On mingw, if --enable-threads=windows or gl_AVOID_WINPTHREAD is used, + dnl ignore the from the mingw-w64 winpthreads library. + m4_ifdef([gl_][THREADLIB], [ + AC_REQUIRE([gl_][THREADLIB]) + if { case "$host_os" in mingw* | windows*) true;; *) false;; esac; } \ + && test $gl_threads_api = windows; then + HAVE_PTHREAD_H=0 + fi + ]) + else + HAVE_PTHREAD_H=0 + fi + AC_SUBST([HAVE_PTHREAD_H]) + + AC_CHECK_TYPES([pthread_t, pthread_spinlock_t], [], [], + [AC_INCLUDES_DEFAULT[ + #if HAVE_PTHREAD_H + #include + #endif]]) + if test $ac_cv_type_pthread_t != yes; then + HAVE_PTHREAD_T=0 + fi + if test $ac_cv_type_pthread_spinlock_t != yes; then + HAVE_PTHREAD_SPINLOCK_T=0 + fi + + dnl Constants may be defined as C preprocessor macros or as enum items. + + AC_CACHE_CHECK([for PTHREAD_CREATE_DETACHED], + [gl_cv_const_PTHREAD_CREATE_DETACHED], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include + int x = PTHREAD_CREATE_DETACHED; + ]], + [[]])], + [gl_cv_const_PTHREAD_CREATE_DETACHED=yes], + [gl_cv_const_PTHREAD_CREATE_DETACHED=no]) + ]) + if test $gl_cv_const_PTHREAD_CREATE_DETACHED != yes; then + HAVE_PTHREAD_CREATE_DETACHED=0 + fi + + AC_CACHE_CHECK([for PTHREAD_MUTEX_RECURSIVE], + [gl_cv_const_PTHREAD_MUTEX_RECURSIVE], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include + int x = PTHREAD_MUTEX_RECURSIVE; + ]], + [[]])], + [gl_cv_const_PTHREAD_MUTEX_RECURSIVE=yes], + [gl_cv_const_PTHREAD_MUTEX_RECURSIVE=no]) + ]) + if test $gl_cv_const_PTHREAD_MUTEX_RECURSIVE != yes; then + HAVE_PTHREAD_MUTEX_RECURSIVE=0 + fi + + AC_CACHE_CHECK([for PTHREAD_MUTEX_ROBUST], + [gl_cv_const_PTHREAD_MUTEX_ROBUST], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include + int x = PTHREAD_MUTEX_ROBUST; + ]], + [[]])], + [gl_cv_const_PTHREAD_MUTEX_ROBUST=yes], + [gl_cv_const_PTHREAD_MUTEX_ROBUST=no]) + ]) + if test $gl_cv_const_PTHREAD_MUTEX_ROBUST != yes; then + HAVE_PTHREAD_MUTEX_ROBUST=0 + fi + + AC_CACHE_CHECK([for PTHREAD_PROCESS_SHARED], + [gl_cv_const_PTHREAD_PROCESS_SHARED], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include + int x = PTHREAD_PROCESS_SHARED; + ]], + [[]])], + [gl_cv_const_PTHREAD_PROCESS_SHARED=yes], + [gl_cv_const_PTHREAD_PROCESS_SHARED=no]) + ]) + if test $gl_cv_const_PTHREAD_PROCESS_SHARED != yes; then + HAVE_PTHREAD_PROCESS_SHARED=0 + fi + + dnl Check for declarations of anything we want to poison if the + dnl corresponding gnulib module is not in use, if it is not common + dnl enough to be declared everywhere. + gl_WARN_ON_USE_PREPARE([[#include + ]], [ + pthread_create pthread_attr_init pthread_attr_getdetachstate + pthread_attr_setdetachstate pthread_attr_destroy pthread_self pthread_equal + pthread_detach pthread_join pthread_exit + pthread_once + pthread_mutex_init pthread_mutexattr_init pthread_mutexattr_gettype + pthread_mutexattr_settype pthread_mutexattr_getrobust + pthread_mutexattr_setrobust pthread_mutexattr_destroy pthread_mutex_lock + pthread_mutex_trylock pthread_mutex_timedlock pthread_mutex_unlock + pthread_mutex_destroy + pthread_rwlock_init pthread_rwlockattr_init pthread_rwlockattr_destroy + pthread_rwlock_rdlock pthread_rwlock_wrlock pthread_rwlock_tryrdlock + pthread_rwlock_trywrlock pthread_rwlock_timedrdlock + pthread_rwlock_timedwrlock pthread_rwlock_unlock pthread_rwlock_destroy + pthread_cond_init pthread_condattr_init pthread_condattr_destroy + pthread_cond_wait pthread_cond_timedwait pthread_cond_signal + pthread_cond_broadcast pthread_cond_destroy + pthread_key_create pthread_setspecific pthread_getspecific + pthread_key_delete + pthread_spin_init pthread_spin_lock pthread_spin_trylock pthread_spin_unlock + pthread_spin_destroy]) + + AC_REQUIRE([AC_C_RESTRICT]) + + dnl For backward compatibility with gnulib versions <= 2019-07. + LIB_PTHREAD="$LIBPMULTITHREAD" + AC_SUBST([LIB_PTHREAD]) +]) + +# gl_PTHREAD_MODULE_INDICATOR([modulename]) +# sets the shell variable that indicates the presence of the given module +# to a C preprocessor expression that will evaluate to 1. +# This macro invocation must not occur in macros that are AC_REQUIREd. +AC_DEFUN([gl_PTHREAD_MODULE_INDICATOR], +[ + dnl Ensure to expand the default settings once only. + gl_PTHREAD_H_REQUIRE_DEFAULTS + gl_MODULE_INDICATOR_SET_VARIABLE([$1]) + dnl Define it also as a C macro, for the benefit of the unit tests. + gl_MODULE_INDICATOR_FOR_TESTS([$1]) +]) + +# Initializes the default values for AC_SUBSTed shell variables. +# This macro must not be AC_REQUIREd. It must only be invoked, and only +# outside of macros or in macros that are not AC_REQUIREd. +AC_DEFUN([gl_PTHREAD_H_REQUIRE_DEFAULTS], +[ + m4_defun(GL_MODULE_INDICATOR_PREFIX[_PTHREAD_H_MODULE_INDICATOR_DEFAULTS], [ + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PTHREAD_THREAD]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PTHREAD_ONCE]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PTHREAD_MUTEX]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PTHREAD_RWLOCK]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PTHREAD_COND]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PTHREAD_TSS]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PTHREAD_SPIN]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PTHREAD_MUTEX_TIMEDLOCK]) + ]) + m4_require(GL_MODULE_INDICATOR_PREFIX[_PTHREAD_H_MODULE_INDICATOR_DEFAULTS]) + AC_REQUIRE([gl_PTHREAD_H_DEFAULTS]) +]) + +AC_DEFUN([gl_PTHREAD_H_DEFAULTS], +[ + dnl Assume proper GNU behavior unless another module says otherwise. + HAVE_PTHREAD_T=1; AC_SUBST([HAVE_PTHREAD_T]) + HAVE_PTHREAD_SPINLOCK_T=1; AC_SUBST([HAVE_PTHREAD_SPINLOCK_T]) + HAVE_PTHREAD_CREATE_DETACHED=1; AC_SUBST([HAVE_PTHREAD_CREATE_DETACHED]) + HAVE_PTHREAD_MUTEX_RECURSIVE=1; AC_SUBST([HAVE_PTHREAD_MUTEX_RECURSIVE]) + HAVE_PTHREAD_MUTEX_ROBUST=1; AC_SUBST([HAVE_PTHREAD_MUTEX_ROBUST]) + HAVE_PTHREAD_PROCESS_SHARED=1; AC_SUBST([HAVE_PTHREAD_PROCESS_SHARED]) + HAVE_PTHREAD_CREATE=1; AC_SUBST([HAVE_PTHREAD_CREATE]) + HAVE_PTHREAD_ATTR_INIT=1; AC_SUBST([HAVE_PTHREAD_ATTR_INIT]) + HAVE_PTHREAD_ATTR_GETDETACHSTATE=1; AC_SUBST([HAVE_PTHREAD_ATTR_GETDETACHSTATE]) + HAVE_PTHREAD_ATTR_SETDETACHSTATE=1; AC_SUBST([HAVE_PTHREAD_ATTR_SETDETACHSTATE]) + HAVE_PTHREAD_ATTR_DESTROY=1; AC_SUBST([HAVE_PTHREAD_ATTR_DESTROY]) + HAVE_PTHREAD_SELF=1; AC_SUBST([HAVE_PTHREAD_SELF]) + HAVE_PTHREAD_EQUAL=1; AC_SUBST([HAVE_PTHREAD_EQUAL]) + HAVE_PTHREAD_DETACH=1; AC_SUBST([HAVE_PTHREAD_DETACH]) + HAVE_PTHREAD_JOIN=1; AC_SUBST([HAVE_PTHREAD_JOIN]) + HAVE_PTHREAD_EXIT=1; AC_SUBST([HAVE_PTHREAD_EXIT]) + HAVE_PTHREAD_ONCE=1; AC_SUBST([HAVE_PTHREAD_ONCE]) + HAVE_PTHREAD_MUTEX_INIT=1; AC_SUBST([HAVE_PTHREAD_MUTEX_INIT]) + HAVE_PTHREAD_MUTEXATTR_INIT=1; AC_SUBST([HAVE_PTHREAD_MUTEXATTR_INIT]) + HAVE_PTHREAD_MUTEXATTR_GETTYPE=1; AC_SUBST([HAVE_PTHREAD_MUTEXATTR_GETTYPE]) + HAVE_PTHREAD_MUTEXATTR_SETTYPE=1; AC_SUBST([HAVE_PTHREAD_MUTEXATTR_SETTYPE]) + HAVE_PTHREAD_MUTEXATTR_GETROBUST=1; AC_SUBST([HAVE_PTHREAD_MUTEXATTR_GETROBUST]) + HAVE_PTHREAD_MUTEXATTR_SETROBUST=1; AC_SUBST([HAVE_PTHREAD_MUTEXATTR_SETROBUST]) + HAVE_PTHREAD_MUTEXATTR_DESTROY=1; AC_SUBST([HAVE_PTHREAD_MUTEXATTR_DESTROY]) + HAVE_PTHREAD_MUTEX_LOCK=1; AC_SUBST([HAVE_PTHREAD_MUTEX_LOCK]) + HAVE_PTHREAD_MUTEX_TRYLOCK=1; AC_SUBST([HAVE_PTHREAD_MUTEX_TRYLOCK]) + HAVE_PTHREAD_MUTEX_TIMEDLOCK=1; AC_SUBST([HAVE_PTHREAD_MUTEX_TIMEDLOCK]) + HAVE_PTHREAD_MUTEX_UNLOCK=1; AC_SUBST([HAVE_PTHREAD_MUTEX_UNLOCK]) + HAVE_PTHREAD_MUTEX_DESTROY=1; AC_SUBST([HAVE_PTHREAD_MUTEX_DESTROY]) + HAVE_PTHREAD_RWLOCK_INIT=1; AC_SUBST([HAVE_PTHREAD_RWLOCK_INIT]) + HAVE_PTHREAD_RWLOCKATTR_INIT=1; AC_SUBST([HAVE_PTHREAD_RWLOCKATTR_INIT]) + HAVE_PTHREAD_RWLOCKATTR_DESTROY=1; AC_SUBST([HAVE_PTHREAD_RWLOCKATTR_DESTROY]) + HAVE_PTHREAD_RWLOCK_RDLOCK=1; AC_SUBST([HAVE_PTHREAD_RWLOCK_RDLOCK]) + HAVE_PTHREAD_RWLOCK_WRLOCK=1; AC_SUBST([HAVE_PTHREAD_RWLOCK_WRLOCK]) + HAVE_PTHREAD_RWLOCK_TRYRDLOCK=1; AC_SUBST([HAVE_PTHREAD_RWLOCK_TRYRDLOCK]) + HAVE_PTHREAD_RWLOCK_TRYWRLOCK=1; AC_SUBST([HAVE_PTHREAD_RWLOCK_TRYWRLOCK]) + HAVE_PTHREAD_RWLOCK_TIMEDRDLOCK=1; AC_SUBST([HAVE_PTHREAD_RWLOCK_TIMEDRDLOCK]) + HAVE_PTHREAD_RWLOCK_TIMEDWRLOCK=1; AC_SUBST([HAVE_PTHREAD_RWLOCK_TIMEDWRLOCK]) + HAVE_PTHREAD_RWLOCK_UNLOCK=1; AC_SUBST([HAVE_PTHREAD_RWLOCK_UNLOCK]) + HAVE_PTHREAD_RWLOCK_DESTROY=1; AC_SUBST([HAVE_PTHREAD_RWLOCK_DESTROY]) + HAVE_PTHREAD_COND_INIT=1; AC_SUBST([HAVE_PTHREAD_COND_INIT]) + HAVE_PTHREAD_CONDATTR_INIT=1; AC_SUBST([HAVE_PTHREAD_CONDATTR_INIT]) + HAVE_PTHREAD_CONDATTR_DESTROY=1; AC_SUBST([HAVE_PTHREAD_CONDATTR_DESTROY]) + HAVE_PTHREAD_COND_WAIT=1; AC_SUBST([HAVE_PTHREAD_COND_WAIT]) + HAVE_PTHREAD_COND_TIMEDWAIT=1; AC_SUBST([HAVE_PTHREAD_COND_TIMEDWAIT]) + HAVE_PTHREAD_COND_SIGNAL=1; AC_SUBST([HAVE_PTHREAD_COND_SIGNAL]) + HAVE_PTHREAD_COND_BROADCAST=1; AC_SUBST([HAVE_PTHREAD_COND_BROADCAST]) + HAVE_PTHREAD_COND_DESTROY=1; AC_SUBST([HAVE_PTHREAD_COND_DESTROY]) + HAVE_PTHREAD_KEY_CREATE=1; AC_SUBST([HAVE_PTHREAD_KEY_CREATE]) + HAVE_PTHREAD_SETSPECIFIC=1; AC_SUBST([HAVE_PTHREAD_SETSPECIFIC]) + HAVE_PTHREAD_GETSPECIFIC=1; AC_SUBST([HAVE_PTHREAD_GETSPECIFIC]) + HAVE_PTHREAD_KEY_DELETE=1; AC_SUBST([HAVE_PTHREAD_KEY_DELETE]) + HAVE_PTHREAD_SPIN_INIT=1; AC_SUBST([HAVE_PTHREAD_SPIN_INIT]) + HAVE_PTHREAD_SPIN_LOCK=1; AC_SUBST([HAVE_PTHREAD_SPIN_LOCK]) + HAVE_PTHREAD_SPIN_TRYLOCK=1; AC_SUBST([HAVE_PTHREAD_SPIN_TRYLOCK]) + HAVE_PTHREAD_SPIN_UNLOCK=1; AC_SUBST([HAVE_PTHREAD_SPIN_UNLOCK]) + HAVE_PTHREAD_SPIN_DESTROY=1; AC_SUBST([HAVE_PTHREAD_SPIN_DESTROY]) + REPLACE_PTHREAD_CREATE=0; AC_SUBST([REPLACE_PTHREAD_CREATE]) + REPLACE_PTHREAD_ATTR_INIT=0; AC_SUBST([REPLACE_PTHREAD_ATTR_INIT]) + REPLACE_PTHREAD_ATTR_GETDETACHSTATE=0; AC_SUBST([REPLACE_PTHREAD_ATTR_GETDETACHSTATE]) + REPLACE_PTHREAD_ATTR_SETDETACHSTATE=0; AC_SUBST([REPLACE_PTHREAD_ATTR_SETDETACHSTATE]) + REPLACE_PTHREAD_ATTR_DESTROY=0; AC_SUBST([REPLACE_PTHREAD_ATTR_DESTROY]) + REPLACE_PTHREAD_SELF=0; AC_SUBST([REPLACE_PTHREAD_SELF]) + REPLACE_PTHREAD_EQUAL=0; AC_SUBST([REPLACE_PTHREAD_EQUAL]) + REPLACE_PTHREAD_DETACH=0; AC_SUBST([REPLACE_PTHREAD_DETACH]) + REPLACE_PTHREAD_JOIN=0; AC_SUBST([REPLACE_PTHREAD_JOIN]) + REPLACE_PTHREAD_EXIT=0; AC_SUBST([REPLACE_PTHREAD_EXIT]) + REPLACE_PTHREAD_ONCE=0; AC_SUBST([REPLACE_PTHREAD_ONCE]) + REPLACE_PTHREAD_MUTEX_INIT=0; AC_SUBST([REPLACE_PTHREAD_MUTEX_INIT]) + REPLACE_PTHREAD_MUTEXATTR_INIT=0; AC_SUBST([REPLACE_PTHREAD_MUTEXATTR_INIT]) + REPLACE_PTHREAD_MUTEXATTR_GETTYPE=0; AC_SUBST([REPLACE_PTHREAD_MUTEXATTR_GETTYPE]) + REPLACE_PTHREAD_MUTEXATTR_SETTYPE=0; AC_SUBST([REPLACE_PTHREAD_MUTEXATTR_SETTYPE]) + REPLACE_PTHREAD_MUTEXATTR_GETROBUST=0; AC_SUBST([REPLACE_PTHREAD_MUTEXATTR_GETROBUST]) + REPLACE_PTHREAD_MUTEXATTR_SETROBUST=0; AC_SUBST([REPLACE_PTHREAD_MUTEXATTR_SETROBUST]) + REPLACE_PTHREAD_MUTEXATTR_DESTROY=0; AC_SUBST([REPLACE_PTHREAD_MUTEXATTR_DESTROY]) + REPLACE_PTHREAD_MUTEX_LOCK=0; AC_SUBST([REPLACE_PTHREAD_MUTEX_LOCK]) + REPLACE_PTHREAD_MUTEX_TRYLOCK=0; AC_SUBST([REPLACE_PTHREAD_MUTEX_TRYLOCK]) + REPLACE_PTHREAD_MUTEX_TIMEDLOCK=0; AC_SUBST([REPLACE_PTHREAD_MUTEX_TIMEDLOCK]) + REPLACE_PTHREAD_MUTEX_UNLOCK=0; AC_SUBST([REPLACE_PTHREAD_MUTEX_UNLOCK]) + REPLACE_PTHREAD_MUTEX_DESTROY=0; AC_SUBST([REPLACE_PTHREAD_MUTEX_DESTROY]) + REPLACE_PTHREAD_RWLOCK_INIT=0; AC_SUBST([REPLACE_PTHREAD_RWLOCK_INIT]) + REPLACE_PTHREAD_RWLOCKATTR_INIT=0; AC_SUBST([REPLACE_PTHREAD_RWLOCKATTR_INIT]) + REPLACE_PTHREAD_RWLOCKATTR_DESTROY=0; AC_SUBST([REPLACE_PTHREAD_RWLOCKATTR_DESTROY]) + REPLACE_PTHREAD_RWLOCK_RDLOCK=0; AC_SUBST([REPLACE_PTHREAD_RWLOCK_RDLOCK]) + REPLACE_PTHREAD_RWLOCK_WRLOCK=0; AC_SUBST([REPLACE_PTHREAD_RWLOCK_WRLOCK]) + REPLACE_PTHREAD_RWLOCK_TRYRDLOCK=0; AC_SUBST([REPLACE_PTHREAD_RWLOCK_TRYRDLOCK]) + REPLACE_PTHREAD_RWLOCK_TRYWRLOCK=0; AC_SUBST([REPLACE_PTHREAD_RWLOCK_TRYWRLOCK]) + REPLACE_PTHREAD_RWLOCK_TIMEDRDLOCK=0; AC_SUBST([REPLACE_PTHREAD_RWLOCK_TIMEDRDLOCK]) + REPLACE_PTHREAD_RWLOCK_TIMEDWRLOCK=0; AC_SUBST([REPLACE_PTHREAD_RWLOCK_TIMEDWRLOCK]) + REPLACE_PTHREAD_RWLOCK_UNLOCK=0; AC_SUBST([REPLACE_PTHREAD_RWLOCK_UNLOCK]) + REPLACE_PTHREAD_RWLOCK_DESTROY=0; AC_SUBST([REPLACE_PTHREAD_RWLOCK_DESTROY]) + REPLACE_PTHREAD_COND_INIT=0; AC_SUBST([REPLACE_PTHREAD_COND_INIT]) + REPLACE_PTHREAD_CONDATTR_INIT=0; AC_SUBST([REPLACE_PTHREAD_CONDATTR_INIT]) + REPLACE_PTHREAD_CONDATTR_DESTROY=0; AC_SUBST([REPLACE_PTHREAD_CONDATTR_DESTROY]) + REPLACE_PTHREAD_COND_WAIT=0; AC_SUBST([REPLACE_PTHREAD_COND_WAIT]) + REPLACE_PTHREAD_COND_TIMEDWAIT=0; AC_SUBST([REPLACE_PTHREAD_COND_TIMEDWAIT]) + REPLACE_PTHREAD_COND_SIGNAL=0; AC_SUBST([REPLACE_PTHREAD_COND_SIGNAL]) + REPLACE_PTHREAD_COND_BROADCAST=0; AC_SUBST([REPLACE_PTHREAD_COND_BROADCAST]) + REPLACE_PTHREAD_COND_DESTROY=0; AC_SUBST([REPLACE_PTHREAD_COND_DESTROY]) + REPLACE_PTHREAD_KEY_CREATE=0; AC_SUBST([REPLACE_PTHREAD_KEY_CREATE]) + REPLACE_PTHREAD_SETSPECIFIC=0; AC_SUBST([REPLACE_PTHREAD_SETSPECIFIC]) + REPLACE_PTHREAD_GETSPECIFIC=0; AC_SUBST([REPLACE_PTHREAD_GETSPECIFIC]) + REPLACE_PTHREAD_KEY_DELETE=0; AC_SUBST([REPLACE_PTHREAD_KEY_DELETE]) + REPLACE_PTHREAD_SPIN_INIT=0; AC_SUBST([REPLACE_PTHREAD_SPIN_INIT]) + REPLACE_PTHREAD_SPIN_LOCK=0; AC_SUBST([REPLACE_PTHREAD_SPIN_LOCK]) + REPLACE_PTHREAD_SPIN_TRYLOCK=0; AC_SUBST([REPLACE_PTHREAD_SPIN_TRYLOCK]) + REPLACE_PTHREAD_SPIN_UNLOCK=0; AC_SUBST([REPLACE_PTHREAD_SPIN_UNLOCK]) + REPLACE_PTHREAD_SPIN_DESTROY=0; AC_SUBST([REPLACE_PTHREAD_SPIN_DESTROY]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/pthread_rwlock_rdlock.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/pthread_rwlock_rdlock.m4 new file mode 100644 index 00000000..98e5f0e3 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/pthread_rwlock_rdlock.m4 @@ -0,0 +1,185 @@ +# pthread_rwlock_rdlock.m4 serial 7 +dnl Copyright (C) 2017-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. +dnl Inspired by +dnl https://github.com/linux-test-project/ltp/blob/master/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/2-2.c +dnl by Intel Corporation. + +dnl Test whether in a situation where +dnl - an rwlock is taken by a reader and has a writer waiting, +dnl - an additional reader requests the lock, +dnl - the waiting writer and the requesting reader threads have the same +dnl priority, +dnl the requesting reader thread gets blocked, so that at some point the +dnl waiting writer can acquire the lock. +dnl Without such a guarantee, when there a N readers and each of the readers +dnl spends more than 1/Nth of the time with the lock held, there is a high +dnl probability that the waiting writer will not get the lock in a given finite +dnl time, a phenomenon called "writer starvation". +dnl Without such a guarantee, applications have a hard time avoiding writer +dnl starvation. +dnl +dnl POSIX:2017 makes this requirement only for implementations that support TPS +dnl (Thread Priority Scheduling) and only for the scheduling policies SCHED_FIFO +dnl and SCHED_RR, see +dnl https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_rwlock_rdlock.html +dnl but this test verifies the guarantee regardless of TPS and regardless of +dnl scheduling policy. +dnl Glibc does not provide this guarantee (and never will on Linux), see +dnl https://sourceware.org/bugzilla/show_bug.cgi?id=13701 +dnl https://bugzilla.redhat.com/show_bug.cgi?id=1410052 +AC_DEFUN([gl_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER], +[ + AC_REQUIRE([gl_THREADLIB]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether pthread_rwlock_rdlock prefers a writer to a reader], + [gl_cv_pthread_rwlock_rdlock_prefer_writer], + [save_LIBS="$LIBS" + LIBS="$LIBS $LIBMULTITHREAD" + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +#include +#include + +#define SUCCEED() exit (0) +#define FAILURE() exit (1) +#define UNEXPECTED(n) (exit (10 + (n))) + +/* The main thread creates the waiting writer and the requesting reader threads + in the default way; this guarantees that they have the same priority. + We can reuse the main thread as first reader thread. */ + +static pthread_rwlock_t lock; +static pthread_t reader1; +static pthread_t writer; +static pthread_t reader2; +static pthread_t timer; +/* Used to pass control from writer to reader2 and from reader2 to timer, + as in a relay race. + Passing control from one running thread to another running thread + is most likely faster than to create the second thread. */ +static pthread_mutex_t baton; + +static void * +timer_func (void *ignored) +{ + /* Step 13 (can be before or after step 12): + The timer thread takes the baton, then waits a moment to make sure + it can tell whether the second reader thread is blocked at step 12. */ + if (pthread_mutex_lock (&baton)) + UNEXPECTED (13); + usleep (100000); + /* By the time we get here, it's clear that the second reader thread is + blocked at step 12. This is the desired behaviour. */ + SUCCEED (); +} + +static void * +reader2_func (void *ignored) +{ + int err; + + /* Step 8 (can be before or after step 7): + The second reader thread takes the baton, then waits a moment to make sure + the writer thread has reached step 7. */ + if (pthread_mutex_lock (&baton)) + UNEXPECTED (8); + usleep (100000); + /* Step 9: The second reader thread requests the lock. */ + err = pthread_rwlock_tryrdlock (&lock); + if (err == 0) + FAILURE (); + else if (err != EBUSY) + UNEXPECTED (9); + /* Step 10: Launch a timer, to test whether the next call blocks. */ + if (pthread_create (&timer, NULL, timer_func, NULL)) + UNEXPECTED (10); + /* Step 11: Release the baton. */ + if (pthread_mutex_unlock (&baton)) + UNEXPECTED (11); + /* Step 12: The second reader thread requests the lock. */ + err = pthread_rwlock_rdlock (&lock); + if (err == 0) + FAILURE (); + else + UNEXPECTED (12); +} + +static void * +writer_func (void *ignored) +{ + /* Step 4: Take the baton, so that the second reader thread does not go ahead + too early. */ + if (pthread_mutex_lock (&baton)) + UNEXPECTED (4); + /* Step 5: Create the second reader thread. */ + if (pthread_create (&reader2, NULL, reader2_func, NULL)) + UNEXPECTED (5); + /* Step 6: Release the baton. */ + if (pthread_mutex_unlock (&baton)) + UNEXPECTED (6); + /* Step 7: The writer thread requests the lock. */ + if (pthread_rwlock_wrlock (&lock)) + UNEXPECTED (7); + return NULL; +} + +int +main () +{ + reader1 = pthread_self (); + + /* Step 1: The main thread initializes the lock and the baton. */ + if (pthread_rwlock_init (&lock, NULL)) + UNEXPECTED (1); + if (pthread_mutex_init (&baton, NULL)) + UNEXPECTED (1); + /* Step 2: The main thread acquires the lock as a reader. */ + if (pthread_rwlock_rdlock (&lock)) + UNEXPECTED (2); + /* Step 3: Create the writer thread. */ + if (pthread_create (&writer, NULL, writer_func, NULL)) + UNEXPECTED (3); + /* Job done. Go to sleep. */ + for (;;) + { + sleep (1); + } +} +]])], + [gl_cv_pthread_rwlock_rdlock_prefer_writer=yes], + [gl_cv_pthread_rwlock_rdlock_prefer_writer=no], + [case "$host_os" in + # Guess no on glibc systems. + *-gnu* | gnu*) gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing no" ;; + # Guess no on musl systems. + *-musl* | midipix*) gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing no" ;; + # Guess no on bionic systems. + *-android*) gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing no" ;; + # Guess yes on native Windows with the mingw-w64 winpthreads library. + # Guess no on native Windows with the gnulib windows-rwlock module. + mingw* | windows*) if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then + gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing yes" + else + gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing no" + fi + ;; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_pthread_rwlock_rdlock_prefer_writer="$gl_cross_guess_normal" ;; + esac + ]) + LIBS="$save_LIBS" + ]) + case "$gl_cv_pthread_rwlock_rdlock_prefer_writer" in + *yes) + AC_DEFINE([HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER], [1], + [Define if the 'pthread_rwlock_rdlock' function prefers a writer to a reader.]) + ;; + esac +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/pthread_sigmask.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/pthread_sigmask.m4 new file mode 100644 index 00000000..81be9611 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/pthread_sigmask.m4 @@ -0,0 +1,280 @@ +# pthread_sigmask.m4 serial 22 +dnl Copyright (C) 2011-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_PTHREAD_SIGMASK], +[ + AC_REQUIRE([gl_SIGNAL_H_DEFAULTS]) + + AC_CHECK_FUNCS_ONCE([pthread_sigmask]) + + dnl On MinGW pthread_sigmask is just a macro which always returns 0. + dnl It does not exist as a real function, which is required by POSIX. + AC_CACHE_CHECK([whether pthread_sigmask is a macro], + [gl_cv_func_pthread_sigmask_macro], + [AC_EGREP_CPP([headers_define_pthread_sigmask], [ +#include +#include +#ifdef pthread_sigmask + headers_define_pthread_sigmask +#endif], + [gl_cv_func_pthread_sigmask_macro=yes], + [gl_cv_func_pthread_sigmask_macro=no]) + ]) + + PTHREAD_SIGMASK_LIB= + + if test $gl_cv_func_pthread_sigmask_macro = yes; then + dnl pthread_sigmask is a dummy macro. + HAVE_PTHREAD_SIGMASK=0 + dnl Make sure to '#undef pthread_sigmask' before defining it. + REPLACE_PTHREAD_SIGMASK=1 + else + dnl Test whether the gnulib module 'threadlib' is in use. + dnl Some packages like Emacs use --avoid=threadlib. + dnl Write the symbol in such a way that it does not cause 'aclocal' to pick + dnl the threadlib.m4 file that is installed in $PREFIX/share/aclocal/. + m4_ifdef([gl_][THREADLIB], [ + AC_REQUIRE([gl_][THREADLIB]) + + if test "$gl_threads_api" = posix; then + if test $ac_cv_func_pthread_sigmask = yes; then + dnl pthread_sigmask is available without -lpthread. + : + else + if test -n "$LIBMULTITHREAD"; then + AC_CACHE_CHECK([for pthread_sigmask in $LIBMULTITHREAD], + [gl_cv_func_pthread_sigmask_in_LIBMULTITHREAD], + [gl_save_LIBS="$LIBS" + LIBS="$LIBS $LIBMULTITHREAD" + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include + #include + ]], + [[return pthread_sigmask (0, (sigset_t *) 0, (sigset_t *) 0);]]) + ], + [gl_cv_func_pthread_sigmask_in_LIBMULTITHREAD=yes], + [gl_cv_func_pthread_sigmask_in_LIBMULTITHREAD=no]) + LIBS="$gl_save_LIBS" + ]) + if test $gl_cv_func_pthread_sigmask_in_LIBMULTITHREAD = yes; then + dnl pthread_sigmask is available with -pthread or -lpthread. + PTHREAD_SIGMASK_LIB="$LIBMULTITHREAD" + else + dnl pthread_sigmask is not available at all. + HAVE_PTHREAD_SIGMASK=0 + fi + else + dnl pthread_sigmask is not available at all. + HAVE_PTHREAD_SIGMASK=0 + fi + fi + else + dnl pthread_sigmask may exist but does not interoperate with the chosen + dnl multithreading facility. + if test $ac_cv_func_pthread_sigmask = yes; then + REPLACE_PTHREAD_SIGMASK=1 + else + HAVE_PTHREAD_SIGMASK=0 + fi + fi + ], [ + dnl The module 'threadlib' is not in use, due to --avoid=threadlib being + dnl specified. + dnl The package either has prepared CPPFLAGS and LIBS for use of + dnl POSIX:2008 threads, or wants to build single-threaded programs. + if test $ac_cv_func_pthread_sigmask = yes; then + dnl pthread_sigmask exists and does not require extra libraries. + dnl Assume that it is declared. + : + else + dnl pthread_sigmask either does not exist or needs extra libraries. + HAVE_PTHREAD_SIGMASK=0 + dnl Define the symbol rpl_pthread_sigmask, not pthread_sigmask, + dnl so as to not accidentally override the system's pthread_sigmask + dnl symbol from libpthread. This is necessary on IRIX 6.5. + REPLACE_PTHREAD_SIGMASK=1 + fi + ]) + fi + + AC_SUBST([PTHREAD_SIGMASK_LIB]) + dnl For backward compatibility. + LIB_PTHREAD_SIGMASK="$PTHREAD_SIGMASK_LIB" + AC_SUBST([LIB_PTHREAD_SIGMASK]) + dnl We don't need a variable LTLIB_PTHREAD_SIGMASK, because when + dnl "$gl_threads_api" = posix, $LTLIBMULTITHREAD and $LIBMULTITHREAD are the + dnl same. + + dnl Now test for some bugs in the system function. + if test $HAVE_PTHREAD_SIGMASK = 1; then + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + + dnl On FreeBSD 13.0, MidnightBSD 1.1, HP-UX 11.31, Solaris 9, in programs + dnl that are not linked with -lpthread, the pthread_sigmask() function + dnl always returns 0 and has no effect. + if test -z "$PTHREAD_SIGMASK_LIB"; then + case " $LIBS " in + *' -pthread '*) ;; + *' -lpthread '*) ;; + *) + AC_CACHE_CHECK([whether pthread_sigmask works without -lpthread], + [gl_cv_func_pthread_sigmask_in_libc_works], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ + #include + #include + #include + int main () + { + sigset_t set; + sigemptyset (&set); + return pthread_sigmask (1729, &set, NULL) != 0; + }]])], + [gl_cv_func_pthread_sigmask_in_libc_works=no], + [gl_cv_func_pthread_sigmask_in_libc_works=yes], + [ + changequote(,)dnl + case "$host_os" in + freebsd* | midnightbsd* | hpux* | solaris | solaris2.[2-9]*) + gl_cv_func_pthread_sigmask_in_libc_works="guessing no";; + *) + gl_cv_func_pthread_sigmask_in_libc_works="guessing yes";; + esac + changequote([,])dnl + ]) + ]) + case "$gl_cv_func_pthread_sigmask_in_libc_works" in + *no) + REPLACE_PTHREAD_SIGMASK=1 + AC_DEFINE([PTHREAD_SIGMASK_INEFFECTIVE], [1], + [Define to 1 if pthread_sigmask may return 0 and have no effect.]) + ;; + esac;; + esac + fi + + dnl On Cygwin 1.7.5, the pthread_sigmask() has a wrong return value + dnl convention: Upon failure, it returns -1 and sets errno. + AC_CACHE_CHECK([whether pthread_sigmask returns error numbers], + [gl_cv_func_pthread_sigmask_return_works], + [ + gl_save_LIBS="$LIBS" + LIBS="$LIBS $PTHREAD_SIGMASK_LIB" + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +#include +int main () +{ + sigset_t set; + sigemptyset (&set); + if (pthread_sigmask (1729, &set, NULL) == -1) + return 1; + return 0; +}]])], + [gl_cv_func_pthread_sigmask_return_works=yes], + [gl_cv_func_pthread_sigmask_return_works=no], + [case "$host_os" in + cygwin*) + gl_cv_func_pthread_sigmask_return_works="guessing no";; + *) + gl_cv_func_pthread_sigmask_return_works="guessing yes";; + esac + ]) + LIBS="$gl_save_LIBS" + ]) + case "$gl_cv_func_pthread_sigmask_return_works" in + *no) + REPLACE_PTHREAD_SIGMASK=1 + AC_DEFINE([PTHREAD_SIGMASK_FAILS_WITH_ERRNO], [1], + [Define to 1 if pthread_sigmask(), when it fails, returns -1 and sets errno.]) + ;; + esac + + dnl On IRIX 6.5, in a single-threaded program, pending signals are not + dnl immediately delivered when they are unblocked through pthread_sigmask, + dnl only a little while later. + AC_CACHE_CHECK([whether pthread_sigmask unblocks signals correctly], + [gl_cv_func_pthread_sigmask_unblock_works], + [ + case "$host_os" in + irix*) + gl_cv_func_pthread_sigmask_unblock_works="guessing no";; + *) + gl_cv_func_pthread_sigmask_unblock_works="guessing yes";; + esac + m4_ifdef([gl_][THREADLIB], + [dnl Link against $LIBMULTITHREAD, not only $PTHREAD_SIGMASK_LIB. + dnl Otherwise we get a false positive on those platforms where + dnl $gl_cv_func_pthread_sigmask_in_libc_works is "no". + gl_save_LIBS=$LIBS + LIBS="$LIBS $LIBMULTITHREAD"]) + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +#include +#include +#include +#include +]GL_MDA_DEFINES[ +static volatile int sigint_occurred; +static void +sigint_handler (int sig) +{ + sigint_occurred++; +} +int main () +{ + sigset_t set; + pid_t pid = getpid (); + char command[80]; + if (LONG_MAX < pid) + return 6; + signal (SIGINT, sigint_handler); + sigemptyset (&set); + sigaddset (&set, SIGINT); + if (!(pthread_sigmask (SIG_BLOCK, &set, NULL) == 0)) + return 1; + sprintf (command, "sh -c 'sleep 1; kill -INT %ld' &", (long) pid); + if (!(system (command) == 0)) + return 2; + sleep (2); + if (!(sigint_occurred == 0)) + return 3; + if (!(pthread_sigmask (SIG_UNBLOCK, &set, NULL) == 0)) + return 4; + if (!(sigint_occurred == 1)) /* This fails on IRIX. */ + return 5; + return 0; +}]])], + [:], + [gl_cv_func_pthread_sigmask_unblock_works=no], + [:]) + m4_ifdef([gl_][THREADLIB], [LIBS=$gl_save_LIBS]) + ]) + case "$gl_cv_func_pthread_sigmask_unblock_works" in + *no) + REPLACE_PTHREAD_SIGMASK=1 + AC_DEFINE([PTHREAD_SIGMASK_UNBLOCK_BUG], [1], + [Define to 1 if pthread_sigmask() unblocks signals incorrectly.]) + ;; + esac + fi +]) + +# Prerequisite of lib/pthread_sigmask.c. +AC_DEFUN([gl_PREREQ_PTHREAD_SIGMASK], +[ + if test $HAVE_PTHREAD_SIGMASK = 1; then + AC_DEFINE([HAVE_PTHREAD_SIGMASK], [1], + [Define to 1 if the pthread_sigmask function can be used (despite bugs).]) + fi +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/putenv.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/putenv.m4 new file mode 100644 index 00000000..da6abec2 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/putenv.m4 @@ -0,0 +1,64 @@ +# putenv.m4 serial 27 +dnl Copyright (C) 2002-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Jim Meyering. +dnl +dnl Check whether putenv ("FOO") removes FOO from the environment. +dnl The putenv in libc on at least SunOS 4.1.4 does *not* do that. + +AC_DEFUN([gl_FUNC_PUTENV], +[ + AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([for putenv compatible with GNU and SVID], + [gl_cv_func_svid_putenv], + [AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [AC_INCLUDES_DEFAULT + GL_MDA_DEFINES], + [[ + /* Put it in env. */ + if (putenv ("CONFTEST_putenv=val")) + return 1; + + /* Try to remove it. */ + if (putenv ("CONFTEST_putenv")) + return 2; + + /* Make sure it was deleted. */ + if (getenv ("CONFTEST_putenv") != 0) + return 3; + + return 0; + ]])], + [gl_cv_func_svid_putenv=yes], + [gl_cv_func_svid_putenv=no], + [dnl When crosscompiling, assume putenv is broken. + case "$host_os" in + # Guess yes on glibc systems. + *-gnu* | gnu*) gl_cv_func_svid_putenv="guessing yes" ;; + # Guess yes on musl systems. + *-musl* | midipix*) gl_cv_func_svid_putenv="guessing yes" ;; + # Guess no on native Windows. + mingw* | windows*) gl_cv_func_svid_putenv="guessing no" ;; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_svid_putenv="$gl_cross_guess_normal" ;; + esac + ]) + ]) + case "$gl_cv_func_svid_putenv" in + *yes) ;; + *) + REPLACE_PUTENV=1 + ;; + esac +]) + +# Prerequisites of lib/putenv.c. +AC_DEFUN([gl_PREREQ_PUTENV], +[ + AC_CHECK_DECLS([_putenv]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/quote.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/quote.m4 new file mode 100644 index 00000000..e44c674e --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/quote.m4 @@ -0,0 +1,13 @@ +# quote.m4 serial 6 +dnl Copyright (C) 2002-2003, 2005-2006, 2009-2024 Free Software Foundation, +dnl Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_QUOTE], +[ + dnl Prerequisites of lib/quote.c. + dnl (none) + : +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/quotearg.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/quotearg.m4 new file mode 100644 index 00000000..3ea7eb51 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/quotearg.m4 @@ -0,0 +1,11 @@ +# quotearg.m4 serial 10 +dnl Copyright (C) 2002, 2004-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_QUOTEARG], +[ + AC_REQUIRE([AC_C_RESTRICT]) + : +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/raise.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/raise.m4 new file mode 100644 index 00000000..08b9545b --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/raise.m4 @@ -0,0 +1,36 @@ +# raise.m4 serial 4 +dnl Copyright (C) 2011-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_RAISE], +[ + AC_REQUIRE([gl_SIGNAL_H_DEFAULTS]) + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_CHECK_FUNCS([raise]) + if test $ac_cv_func_raise = no; then + HAVE_RAISE=0 + else + m4_ifdef([gl_MSVC_INVAL], [ + AC_REQUIRE([gl_MSVC_INVAL]) + if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then + REPLACE_RAISE=1 + fi + ]) + m4_ifdef([gl_SIGNALBLOCKING], [ + gl_SIGNALBLOCKING + if test $HAVE_POSIX_SIGNALBLOCKING = 0; then + m4_ifdef([gl_SIGNAL_SIGPIPE], [ + gl_SIGNAL_SIGPIPE + if test $gl_cv_header_signal_h_SIGPIPE != yes; then + REPLACE_RAISE=1 + fi + ], [:]) + fi + ]) + fi +]) + +# Prerequisites of lib/raise.c. +AC_DEFUN([gl_PREREQ_RAISE], [:]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/rawmemchr.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/rawmemchr.m4 new file mode 100644 index 00000000..57d1c291 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/rawmemchr.m4 @@ -0,0 +1,20 @@ +# rawmemchr.m4 serial 3 +dnl Copyright (C) 2003, 2007-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_RAWMEMCHR], +[ + dnl Persuade glibc to declare rawmemchr(). + AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) + + AC_REQUIRE([gl_STRING_H_DEFAULTS]) + AC_CHECK_FUNCS([rawmemchr]) + if test $ac_cv_func_rawmemchr = no; then + HAVE_RAWMEMCHR=0 + fi +]) + +# Prerequisites of lib/strchrnul.c. +AC_DEFUN([gl_PREREQ_RAWMEMCHR], [:]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/readdir.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/readdir.m4 new file mode 100644 index 00000000..2205f132 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/readdir.m4 @@ -0,0 +1,22 @@ +# readdir.m4 serial 3 +dnl Copyright (C) 2011-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_READDIR], +[ + AC_REQUIRE([gl_DIRENT_H_DEFAULTS]) + + AC_CHECK_FUNCS([readdir]) + if test $ac_cv_func_readdir = no; then + HAVE_READDIR=0 + else + dnl Replace readdir() on native Windows and OS/2 kLIBC, + dnl to support fdopendir(). + AC_REQUIRE([gl_DIRENT_DIR]) + if test $DIR_HAS_FD_MEMBER = 0; then + REPLACE_READDIR=1 + fi + fi +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/readlink.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/readlink.m4 new file mode 100644 index 00000000..6d78ec84 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/readlink.m4 @@ -0,0 +1,120 @@ +# readlink.m4 serial 17 +dnl Copyright (C) 2003, 2007, 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_READLINK], +[ + AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CHECK_FUNCS_ONCE([readlink]) + if test $ac_cv_func_readlink = no; then + HAVE_READLINK=0 + else + AC_CACHE_CHECK([whether readlink signature is correct], + [gl_cv_decl_readlink_works], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include + /* Cause compilation failure if original declaration has wrong type. */ + ssize_t readlink (const char *, char *, size_t);]])], + [gl_cv_decl_readlink_works=yes], [gl_cv_decl_readlink_works=no])]) + dnl Solaris 9 ignores trailing slash. + dnl FreeBSD 7.2 dereferences only one level of links with trailing slash. + AC_CACHE_CHECK([whether readlink handles trailing slash correctly], + [gl_cv_func_readlink_trailing_slash], + [# We have readlink, so assume ln -s works. + ln -s conftest.no-such conftest.link + ln -s conftest.link conftest.lnk2 + AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [[#include +]], [[char buf[20]; + return readlink ("conftest.lnk2/", buf, sizeof buf) != -1;]])], + [gl_cv_func_readlink_trailing_slash=yes], + [gl_cv_func_readlink_trailing_slash=no], + [case "$host_os" in + # Guess yes on Linux or glibc systems. + linux-* | linux | *-gnu* | gnu*) + gl_cv_func_readlink_trailing_slash="guessing yes" ;; + # Guess yes on systems that emulate the Linux system calls. + midipix*) + gl_cv_func_readlink_trailing_slash="guessing yes" ;; + # Guess no on AIX or HP-UX. + aix* | hpux*) + gl_cv_func_readlink_trailing_slash="guessing no" ;; + # If we don't know, obey --enable-cross-guesses. + *) + gl_cv_func_readlink_trailing_slash="$gl_cross_guess_normal" ;; + esac + ]) + rm -f conftest.link conftest.lnk2]) + case "$gl_cv_func_readlink_trailing_slash" in + *yes) + if test "$gl_cv_decl_readlink_works" != yes; then + REPLACE_READLINK=1 + fi + ;; + *) + AC_DEFINE([READLINK_TRAILING_SLASH_BUG], [1], [Define to 1 if readlink + fails to recognize a trailing slash.]) + REPLACE_READLINK=1 + ;; + esac + + AC_CACHE_CHECK([whether readlink truncates results correctly], + [gl_cv_func_readlink_truncate], + [# We have readlink, so assume ln -s works. + ln -s ab conftest.link + AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [[#include +]], [[char c; + return readlink ("conftest.link", &c, 1) != 1;]])], + [gl_cv_func_readlink_truncate=yes], + [gl_cv_func_readlink_truncate=no], + [case "$host_os" in + # Guess yes on Linux or glibc systems. + linux-* | linux | *-gnu* | gnu*) + gl_cv_func_readlink_truncate="guessing yes" ;; + # Guess yes on systems that emulate the Linux system calls. + midipix*) + gl_cv_func_readlink_truncate="guessing yes" ;; + # Guess no on AIX or HP-UX. + aix* | hpux*) + gl_cv_func_readlink_truncate="guessing no" ;; + # If we don't know, obey --enable-cross-guesses. + *) + gl_cv_func_readlink_truncate="$gl_cross_guess_normal" ;; + esac + ]) + rm -f conftest.link conftest.lnk2]) + case $gl_cv_func_readlink_truncate in + *yes) + if test "$gl_cv_decl_readlink_works" != yes; then + REPLACE_READLINK=1 + fi + ;; + *) + AC_DEFINE([READLINK_TRUNCATE_BUG], [1], [Define to 1 if readlink + sets errno instead of truncating a too-long link.]) + REPLACE_READLINK=1 + ;; + esac + fi +]) + +# Like gl_FUNC_READLINK, except prepare for separate compilation +# (no REPLACE_READLINK, no AC_LIBOBJ). +AC_DEFUN([gl_FUNC_READLINK_SEPARATE], +[ + AC_CHECK_FUNCS_ONCE([readlink]) + gl_PREREQ_READLINK +]) + +# Prerequisites of lib/readlink.c. +AC_DEFUN([gl_PREREQ_READLINK], +[ + : +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/readlinkat.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/readlinkat.m4 new file mode 100644 index 00000000..99822102 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/readlinkat.m4 @@ -0,0 +1,42 @@ +# serial 8 +# See if we need to provide readlinkat replacement. + +dnl Copyright (C) 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +# Written by Eric Blake. + +AC_DEFUN([gl_FUNC_READLINKAT], +[ + AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + gl_CHECK_FUNCS_ANDROID([readlinkat], [[#include ]]) + AC_REQUIRE([gl_FUNC_READLINK]) + if test $ac_cv_func_readlinkat = no; then + HAVE_READLINKAT=0 + case "$gl_cv_onwards_func_readlinkat" in + future*) REPLACE_READLINKAT=1 ;; + esac + else + AC_CACHE_CHECK([whether readlinkat signature is correct], + [gl_cv_decl_readlinkat_works], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include + /* Check whether original declaration has correct type. */ + ssize_t readlinkat (int, char const *, char *, size_t);]])], + [gl_cv_decl_readlinkat_works=yes], + [gl_cv_decl_readlinkat_works=no])]) + # Assume readlinkat has the same bugs as readlink, + # as is the case on OS X 10.10 with trailing slashes. + case $gl_cv_decl_readlinkat_works,$gl_cv_func_readlink_trailing_slash,$gl_cv_func_readlink_truncate in + *yes,*yes,*yes) + ;; + *) + REPLACE_READLINKAT=1 + ;; + esac + fi +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/realloc.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/realloc.m4 new file mode 100644 index 00000000..a59af280 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/realloc.m4 @@ -0,0 +1,64 @@ +# realloc.m4 serial 29 +dnl Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +# This is adapted with modifications from upstream Autoconf here: +# https://git.savannah.gnu.org/cgit/autoconf.git/tree/lib/autoconf/functions.m4?id=v2.70#n1455 +AC_DEFUN([_AC_FUNC_REALLOC_IF], +[ + AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles + AC_CACHE_CHECK([whether realloc (0, 0) returns nonnull], + [ac_cv_func_realloc_0_nonnull], + [AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [[#include + ]], + [[void *p = realloc (0, 0); + void * volatile vp = p; + int result = !vp; + free (p); + return result;]]) + ], + [ac_cv_func_realloc_0_nonnull=yes], + [ac_cv_func_realloc_0_nonnull=no], + [case "$host_os" in + # Guess yes on platforms where we know the result. + *-gnu* | freebsd* | netbsd* | openbsd* | bitrig* \ + | gnu* | *-musl* | midipix* | midnightbsd* \ + | hpux* | solaris* | cygwin* | mingw* | windows* | msys* ) + ac_cv_func_realloc_0_nonnull="guessing yes" ;; + # If we don't know, obey --enable-cross-guesses. + *) ac_cv_func_realloc_0_nonnull="$gl_cross_guess_normal" ;; + esac + ]) + ]) + AS_CASE([$ac_cv_func_realloc_0_nonnull], [*yes], [$1], [$2]) +])# AC_FUNC_REALLOC + +# gl_FUNC_REALLOC_GNU +# ------------------- +# Replace realloc if it is not compatible with GNU libc. +AC_DEFUN([gl_FUNC_REALLOC_GNU], +[ + AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) + AC_REQUIRE([gl_FUNC_REALLOC_POSIX]) + if test $REPLACE_REALLOC_FOR_REALLOC_GNU = 0; then + _AC_FUNC_REALLOC_IF([], [REPLACE_REALLOC_FOR_REALLOC_GNU=1]) + fi +])# gl_FUNC_REALLOC_GNU + +# gl_FUNC_REALLOC_POSIX +# --------------------- +# Test whether 'realloc' is POSIX compliant (sets errno to ENOMEM when it +# fails, and doesn't mess up with ptrdiff_t overflow), +# and replace realloc if it is not. +AC_DEFUN([gl_FUNC_REALLOC_POSIX], +[ + AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) + AC_REQUIRE([gl_FUNC_MALLOC_POSIX]) + if test $REPLACE_MALLOC_FOR_MALLOC_POSIX = 1; then + REPLACE_REALLOC_FOR_REALLOC_POSIX=1 + fi +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/reallocarray.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/reallocarray.m4 new file mode 100644 index 00000000..20c4601e --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/reallocarray.m4 @@ -0,0 +1,26 @@ +# reallocarray.m4 serial 5 +dnl Copyright (C) 2017-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_REALLOCARRAY], +[ + dnl Persuade glibc to declare reallocarray. + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + + AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) + AC_REQUIRE([gl_CHECK_MALLOC_PTRDIFF]) + gl_CHECK_FUNCS_ANDROID([reallocarray], [[#include ]]) + if test "$ac_cv_func_reallocarray" = no; then + HAVE_REALLOCARRAY=0 + case "$gl_cv_onwards_func_reallocarray" in + future*) REPLACE_REALLOCARRAY=1 ;; + esac + elif test "$gl_cv_malloc_ptrdiff" = no; then + REPLACE_REALLOCARRAY=1 + fi +]) + +# Prerequisites of lib/reallocarray.c. +AC_DEFUN([gl_PREREQ_REALLOCARRAY], [:]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/regex.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/regex.m4 new file mode 100644 index 00000000..3dfeabea --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/regex.m4 @@ -0,0 +1,396 @@ +# serial 75 + +# Copyright (C) 1996-2001, 2003-2024 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +dnl Initially derived from code in GNU grep. +dnl Mostly written by Jim Meyering. + +AC_PREREQ([2.50]) + +AC_DEFUN([gl_REGEX], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_ARG_WITH([included-regex], + [AS_HELP_STRING([[--without-included-regex]], + [don't compile regex; this is the default on systems + with recent-enough versions of the GNU C Library + (use with caution on other systems).])]) + + case $with_included_regex in #( + yes|no) ac_use_included_regex=$with_included_regex + ;; + '') + # If the system regex support is good enough that it passes the + # following run test, then default to *not* using the included regex.c. + # If cross compiling, assume the test would fail and use the included + # regex.c. + AC_CHECK_DECLS_ONCE([alarm]) + AC_CHECK_HEADERS_ONCE([malloc.h]) + AC_CACHE_CHECK([for working re_compile_pattern], + [gl_cv_func_re_compile_pattern_working], + [AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [[#include + + #include + #include + #include + + #if defined M_CHECK_ACTION || HAVE_DECL_ALARM + # include + # include + #endif + + #if HAVE_MALLOC_H + # include + #endif + + #ifdef M_CHECK_ACTION + /* Exit with distinguishable exit code. */ + static void sigabrt_no_core (int sig) { raise (SIGTERM); } + #endif + ]], + [[int result = 0; + static struct re_pattern_buffer regex; + unsigned char folded_chars[UCHAR_MAX + 1]; + int i; + const char *s; + struct re_registers regs; + + /* Some builds of glibc go into an infinite loop on this + test. Use alarm to force death, and mallopt to avoid + malloc recursion in diagnosing the corrupted heap. */ +#if HAVE_DECL_ALARM + signal (SIGALRM, SIG_DFL); + alarm (2); +#endif +#ifdef M_CHECK_ACTION + signal (SIGABRT, sigabrt_no_core); + mallopt (M_CHECK_ACTION, 2); +#endif + + if (setlocale (LC_ALL, "en_US.UTF-8")) + { + { + /* https://sourceware.org/ml/libc-hacker/2006-09/msg00008.html + This test needs valgrind to catch the bug on Debian + GNU/Linux 3.1 x86, but it might catch the bug better + on other platforms and it shouldn't hurt to try the + test here. */ + static char const pat[] = "insert into"; + static char const data[] = + "\xFF\0\x12\xA2\xAA\xC4\xB1,K\x12\xC4\xB1*\xACK"; + re_set_syntax (RE_SYNTAX_GREP | RE_HAT_LISTS_NOT_NEWLINE + | RE_ICASE); + memset (®ex, 0, sizeof regex); + s = re_compile_pattern (pat, sizeof pat - 1, ®ex); + if (s) + result |= 1; + else + { + if (re_search (®ex, data, sizeof data - 1, + 0, sizeof data - 1, ®s) + != -1) + result |= 1; + regfree (®ex); + } + } + + { + /* This test is from glibc bug 15078. + The test case is from Andreas Schwab in + . + */ + static char const pat[] = "[^x]x"; + static char const data[] = + /* */ + "\xe1\x80\x80" + "\xe1\x80\xbb" + "\xe1\x80\xbd" + "\xe1\x80\x94" + "\xe1\x80\xba" + "\xe1\x80\xaf" + "\xe1\x80\x95" + "\xe1\x80\xba" + "x"; + re_set_syntax (0); + memset (®ex, 0, sizeof regex); + s = re_compile_pattern (pat, sizeof pat - 1, ®ex); + if (s) + result |= 1; + else + { + i = re_search (®ex, data, sizeof data - 1, + 0, sizeof data - 1, 0); + if (i != 0 && i != 21) + result |= 1; + regfree (®ex); + } + } + + if (! setlocale (LC_ALL, "C")) + return 1; + } + + /* This test is from glibc bug 3957, reported by Andrew Mackey. */ + re_set_syntax (RE_SYNTAX_EGREP | RE_HAT_LISTS_NOT_NEWLINE); + memset (®ex, 0, sizeof regex); + s = re_compile_pattern ("a[^x]b", 6, ®ex); + if (s) + result |= 2; + else + { + /* This should fail, but succeeds for glibc-2.5. */ + if (re_search (®ex, "a\nb", 3, 0, 3, ®s) != -1) + result |= 2; + regfree (®ex); + } + + /* This regular expression is from Spencer ere test number 75 + in grep-2.3. */ + re_set_syntax (RE_SYNTAX_POSIX_EGREP); + memset (®ex, 0, sizeof regex); + for (i = 0; i <= UCHAR_MAX; i++) + folded_chars[i] = i; + regex.translate = folded_chars; + s = re_compile_pattern ("a[[:@:>@:]]b\n", 11, ®ex); + /* This should fail with _Invalid character class name_ error. */ + if (!s) + { + result |= 4; + regfree (®ex); + } + + /* Ensure that [b-a] is diagnosed as invalid, when + using RE_NO_EMPTY_RANGES. */ + re_set_syntax (RE_SYNTAX_POSIX_EGREP | RE_NO_EMPTY_RANGES); + memset (®ex, 0, sizeof regex); + s = re_compile_pattern ("a[b-a]", 6, ®ex); + if (s == 0) + { + result |= 8; + regfree (®ex); + } + + /* This should succeed, but does not for glibc-2.1.3. */ + memset (®ex, 0, sizeof regex); + s = re_compile_pattern ("{1", 2, ®ex); + if (s) + result |= 8; + else + regfree (®ex); + + /* The following example is derived from a problem report + against gawk from Jorge Stolfi . */ + memset (®ex, 0, sizeof regex); + s = re_compile_pattern ("[an\371]*n", 7, ®ex); + if (s) + result |= 8; + else + { + /* This should match, but does not for glibc-2.2.1. */ + if (re_match (®ex, "an", 2, 0, ®s) != 2) + result |= 8; + else + { + free (regs.start); + free (regs.end); + } + regfree (®ex); + } + + memset (®ex, 0, sizeof regex); + s = re_compile_pattern ("x", 1, ®ex); + if (s) + result |= 8; + else + { + /* glibc-2.2.93 does not work with a negative RANGE argument. */ + if (re_search (®ex, "wxy", 3, 2, -2, ®s) != 1) + result |= 8; + else + { + free (regs.start); + free (regs.end); + } + regfree (®ex); + } + + /* The version of regex.c in older versions of gnulib + ignored RE_ICASE. Detect that problem too. */ + re_set_syntax (RE_SYNTAX_EMACS | RE_ICASE); + memset (®ex, 0, sizeof regex); + s = re_compile_pattern ("x", 1, ®ex); + if (s) + result |= 16; + else + { + if (re_search (®ex, "WXY", 3, 0, 3, ®s) < 0) + result |= 16; + else + { + free (regs.start); + free (regs.end); + } + regfree (®ex); + } + + /* Catch a bug reported by Vin Shelton in + https://lists.gnu.org/r/bug-coreutils/2007-06/msg00089.html + */ + re_set_syntax (RE_SYNTAX_POSIX_BASIC + & ~RE_CONTEXT_INVALID_DUP + & ~RE_NO_EMPTY_RANGES); + memset (®ex, 0, sizeof regex); + s = re_compile_pattern ("[[:alnum:]_-]\\\\+\$", 16, ®ex); + if (s) + result |= 32; + else + regfree (®ex); + + /* REG_STARTEND was added to glibc on 2004-01-15. + Reject older versions. */ + if (! REG_STARTEND) + result |= 64; + + /* Matching with the compiled form of this regexp would provoke + an assertion failure prior to glibc-2.28: + regexec.c:1375: pop_fail_stack: Assertion 'num >= 0' failed + With glibc-2.28, compilation fails and reports the invalid + back reference. */ + re_set_syntax (RE_SYNTAX_POSIX_EGREP); + memset (®ex, 0, sizeof regex); + s = re_compile_pattern ("0|()0|\\\\1|0", 10, ®ex); + if (!s) + { + memset (®s, 0, sizeof regs); + i = re_search (®ex, "x", 1, 0, 1, ®s); + if (i != -1) + result |= 64; + if (0 <= i) + { + free (regs.start); + free (regs.end); + } + regfree (®ex); + } + else + { + if (strcmp (s, "Invalid back reference")) + result |= 64; + } + + /* glibc bug 11053. */ + re_set_syntax (RE_SYNTAX_POSIX_BASIC); + memset (®ex, 0, sizeof regex); + static char const pat_sub2[] = "\\\\(a*\\\\)*a*\\\\1"; + s = re_compile_pattern (pat_sub2, sizeof pat_sub2 - 1, ®ex); + if (s) + result |= 64; + else + { + memset (®s, 0, sizeof regs); + static char const data[] = "a"; + int datalen = sizeof data - 1; + i = re_search (®ex, data, datalen, 0, datalen, ®s); + if (i != 0) + result |= 64; + else if (regs.num_regs < 2) + result |= 64; + else if (! (regs.start[0] == 0 && regs.end[0] == 1)) + result |= 64; + else if (! (regs.start[1] == 0 && regs.end[1] == 0)) + result |= 64; + regfree (®ex); + free (regs.start); + free (regs.end); + } + +#if 0 + /* It would be nice to reject hosts whose regoff_t values are too + narrow (including glibc on hosts with 64-bit ptrdiff_t and + 32-bit int), but we should wait until glibc implements this + feature. Otherwise, support for equivalence classes and + multibyte collation symbols would always be broken except + when compiling --without-included-regex. */ + if (sizeof (regoff_t) < sizeof (ptrdiff_t) + || sizeof (regoff_t) < sizeof (ssize_t)) + result |= 64; +#endif + + return result; + ]])], + [gl_cv_func_re_compile_pattern_working=yes], + [gl_cv_func_re_compile_pattern_working=no], + [case "$host_os" in + # Guess no on native Windows. + mingw* | windows*) gl_cv_func_re_compile_pattern_working="guessing no" ;; + # Otherwise obey --enable-cross-guesses. + *) gl_cv_func_re_compile_pattern_working="$gl_cross_guess_normal" ;; + esac + ]) + ]) + case "$gl_cv_func_re_compile_pattern_working" in #( + *yes) ac_use_included_regex=no;; #( + *no) ac_use_included_regex=yes;; + esac + ;; + *) AC_MSG_ERROR([Invalid value for --with-included-regex: $with_included_regex]) + ;; + esac + + if test $ac_use_included_regex = yes; then + AC_DEFINE([_REGEX_INCLUDE_LIMITS_H], [1], + [Define if you want to include , so that it + consistently overrides 's RE_DUP_MAX.]) + AC_DEFINE([_REGEX_LARGE_OFFSETS], [1], + [Define if you want regoff_t to be at least as wide POSIX requires.]) + AC_DEFINE([re_syntax_options], [rpl_re_syntax_options], + [Define to rpl_re_syntax_options if the replacement should be used.]) + AC_DEFINE([re_set_syntax], [rpl_re_set_syntax], + [Define to rpl_re_set_syntax if the replacement should be used.]) + AC_DEFINE([re_compile_pattern], [rpl_re_compile_pattern], + [Define to rpl_re_compile_pattern if the replacement should be used.]) + AC_DEFINE([re_compile_fastmap], [rpl_re_compile_fastmap], + [Define to rpl_re_compile_fastmap if the replacement should be used.]) + AC_DEFINE([re_search], [rpl_re_search], + [Define to rpl_re_search if the replacement should be used.]) + AC_DEFINE([re_search_2], [rpl_re_search_2], + [Define to rpl_re_search_2 if the replacement should be used.]) + AC_DEFINE([re_match], [rpl_re_match], + [Define to rpl_re_match if the replacement should be used.]) + AC_DEFINE([re_match_2], [rpl_re_match_2], + [Define to rpl_re_match_2 if the replacement should be used.]) + AC_DEFINE([re_set_registers], [rpl_re_set_registers], + [Define to rpl_re_set_registers if the replacement should be used.]) + AC_DEFINE([re_comp], [rpl_re_comp], + [Define to rpl_re_comp if the replacement should be used.]) + AC_DEFINE([re_exec], [rpl_re_exec], + [Define to rpl_re_exec if the replacement should be used.]) + AC_DEFINE([regcomp], [rpl_regcomp], + [Define to rpl_regcomp if the replacement should be used.]) + AC_DEFINE([regexec], [rpl_regexec], + [Define to rpl_regexec if the replacement should be used.]) + AC_DEFINE([regerror], [rpl_regerror], + [Define to rpl_regerror if the replacement should be used.]) + AC_DEFINE([regfree], [rpl_regfree], + [Define to rpl_regfree if the replacement should be used.]) + fi +]) + +# Prerequisites of lib/regex.c and lib/regex_internal.c. +AC_DEFUN([gl_PREREQ_REGEX], +[ + AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) + AC_REQUIRE([AC_C_INLINE]) + AC_REQUIRE([AC_C_RESTRICT]) + AC_REQUIRE([AC_TYPE_MBSTATE_T]) + AC_REQUIRE([gl_EEMALLOC]) + AC_CHECK_HEADERS([libintl.h]) + AC_CHECK_FUNCS_ONCE([isblank iswctype]) + AC_CHECK_DECLS([isblank], [], [], [[#include ]]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/rmdir.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/rmdir.m4 new file mode 100644 index 00000000..50156e0d --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/rmdir.m4 @@ -0,0 +1,56 @@ +# rmdir.m4 serial 19 +dnl Copyright (C) 2002, 2005, 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_RMDIR], +[ + AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + dnl Detect cygwin 1.5.x bug. + AC_CHECK_HEADERS_ONCE([unistd.h]) + AC_CACHE_CHECK([whether rmdir works], [gl_cv_func_rmdir_works], + [mkdir conftest.dir + touch conftest.file + AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [[#include + #include + #if HAVE_UNISTD_H + # include + #else /* on Windows with MSVC */ + # include + #endif + ]GL_MDA_DEFINES], + [[int result = 0; + if (!rmdir ("conftest.file/")) + result |= 1; + else if (errno != ENOTDIR) + result |= 2; + if (!rmdir ("conftest.dir/./")) + result |= 4; + return result; + ]])], + [gl_cv_func_rmdir_works=yes], [gl_cv_func_rmdir_works=no], + [case "$host_os" in + # Guess yes on Linux systems. + linux-* | linux) gl_cv_func_rmdir_works="guessing yes" ;; + # Guess yes on systems that emulate the Linux system calls. + midipix*) gl_cv_func_rmdir_works="guessing yes" ;; + # Guess yes on glibc systems. + *-gnu* | gnu*) gl_cv_func_rmdir_works="guessing yes" ;; + # Guess no on native Windows. + mingw* | windows*) gl_cv_func_rmdir_works="guessing no" ;; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_rmdir_works="$gl_cross_guess_normal" ;; + esac + ]) + rm -rf conftest.dir conftest.file]) + case "$gl_cv_func_rmdir_works" in + *yes) ;; + *) + REPLACE_RMDIR=1 + ;; + esac +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/save-cwd.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/save-cwd.m4 new file mode 100644 index 00000000..f1ac3456 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/save-cwd.m4 @@ -0,0 +1,11 @@ +# serial 10 +dnl Copyright (C) 2002-2006, 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl Prerequisites for lib/save-cwd.c. +AC_DEFUN([gl_SAVE_CWD], +[ + AC_CHECK_FUNCS_ONCE([fchdir]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sched_h.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sched_h.m4 new file mode 100644 index 00000000..2ff821e4 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sched_h.m4 @@ -0,0 +1,106 @@ +# sched_h.m4 serial 15 +dnl Copyright (C) 2008-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl Written by Bruno Haible. + +AC_DEFUN_ONCE([gl_SCHED_H], +[ + dnl Ensure to expand the default settings once only, before all statements + dnl that occur in other macros. + AC_REQUIRE([gl_SCHED_H_DEFAULTS]) + + AC_REQUIRE([AC_CANONICAL_HOST]) + + AC_CHECK_HEADERS_ONCE([sys/cdefs.h]) + AC_CHECK_HEADERS([sched.h], [], [], + [[#if HAVE_SYS_CDEFS_H + #include + #endif + ]]) + gl_NEXT_HEADERS([sched.h]) + + if test "$ac_cv_header_sched_h" = yes; then + HAVE_SCHED_H=1 + else + HAVE_SCHED_H=0 + fi + AC_SUBST([HAVE_SCHED_H]) + + if test "$HAVE_SCHED_H" = 1; then + AC_CHECK_TYPE([struct sched_param], + [HAVE_STRUCT_SCHED_PARAM=1], [HAVE_STRUCT_SCHED_PARAM=0], + [[#if HAVE_SYS_CDEFS_H + #include + #endif + #include + ]]) + else + HAVE_STRUCT_SCHED_PARAM=0 + case "$host_os" in + os2*) + dnl On OS/2 kLIBC, struct sched_param is in spawn.h. + AC_CHECK_TYPE([struct sched_param], + [HAVE_STRUCT_SCHED_PARAM=1], [], + [#include ]) + ;; + vms) + dnl On OpenVMS 7.2 or newer, struct sched_param is in pthread.h. + AC_CHECK_TYPE([struct sched_param], + [HAVE_STRUCT_SCHED_PARAM=1], [], + [#include ]) + ;; + esac + fi + AC_SUBST([HAVE_STRUCT_SCHED_PARAM]) + + if test "$ac_cv_header_sys_cdefs_h" = yes; then + HAVE_SYS_CDEFS_H=1 + else + HAVE_SYS_CDEFS_H=0 + fi + AC_SUBST([HAVE_SYS_CDEFS_H]) + + dnl Ensure the type pid_t gets defined. + AC_REQUIRE([AC_TYPE_PID_T]) + + dnl Check for declarations of anything we want to poison if the + dnl corresponding gnulib module is not in use, if it is not common + dnl enough to be declared everywhere. + gl_WARN_ON_USE_PREPARE([[#include + ]], [sched_yield]) +]) + +# gl_SCHED_MODULE_INDICATOR([modulename]) +# sets the shell variable that indicates the presence of the given module +# to a C preprocessor expression that will evaluate to 1. +# This macro invocation must not occur in macros that are AC_REQUIREd. +AC_DEFUN([gl_SCHED_MODULE_INDICATOR], +[ + dnl Ensure to expand the default settings once only. + gl_SCHED_H_REQUIRE_DEFAULTS + gl_MODULE_INDICATOR_SET_VARIABLE([$1]) + dnl Define it also as a C macro, for the benefit of the unit tests. + gl_MODULE_INDICATOR_FOR_TESTS([$1]) +]) + +# Initializes the default values for AC_SUBSTed shell variables. +# This macro must not be AC_REQUIREd. It must only be invoked, and only +# outside of macros or in macros that are not AC_REQUIREd. +AC_DEFUN([gl_SCHED_H_REQUIRE_DEFAULTS], +[ + m4_defun(GL_MODULE_INDICATOR_PREFIX[_SCHED_H_MODULE_INDICATOR_DEFAULTS], [ + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SCHED_YIELD]) + ]) + m4_require(GL_MODULE_INDICATOR_PREFIX[_SCHED_H_MODULE_INDICATOR_DEFAULTS]) + AC_REQUIRE([gl_SCHED_H_DEFAULTS]) +]) + +AC_DEFUN([gl_SCHED_H_DEFAULTS], +[ + dnl Assume proper GNU behavior unless another module says otherwise. + HAVE_SCHED_YIELD=1; AC_SUBST([HAVE_SCHED_YIELD]) + REPLACE_SCHED_YIELD=0; AC_SUBST([REPLACE_SCHED_YIELD]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/select.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/select.m4 new file mode 100644 index 00000000..f3f9dcc0 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/select.m4 @@ -0,0 +1,122 @@ +# select.m4 serial 16 +dnl Copyright (C) 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_SELECT], +[ + AC_REQUIRE([gl_SYS_SELECT_H]) + AC_REQUIRE([AC_C_RESTRICT]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_REQUIRE([gl_SOCKETS]) + if test "$ac_cv_header_winsock2_h" = yes; then + REPLACE_SELECT=1 + else + dnl On Interix 3.5, select(0, NULL, NULL, NULL, timeout) fails with error + dnl EFAULT. + AC_CHECK_HEADERS_ONCE([sys/select.h]) + AC_CACHE_CHECK([whether select supports a 0 argument], + [gl_cv_func_select_supports0], + [ + AC_RUN_IFELSE([AC_LANG_SOURCE([[ +#include +#include +#if HAVE_SYS_SELECT_H +#include +#endif +int main () +{ + struct timeval timeout; + timeout.tv_sec = 0; + timeout.tv_usec = 5; + return select (0, (fd_set *)0, (fd_set *)0, (fd_set *)0, &timeout) < 0; +}]])], [gl_cv_func_select_supports0=yes], [gl_cv_func_select_supports0=no], + [ +changequote(,)dnl + case "$host_os" in + # Guess no on Interix. + interix*) gl_cv_func_select_supports0="guessing no";; + # Guess yes otherwise. + *) gl_cv_func_select_supports0="guessing yes";; + esac +changequote([,])dnl + ]) + ]) + case "$gl_cv_func_select_supports0" in + *yes) ;; + *) REPLACE_SELECT=1 ;; + esac + + dnl On FreeBSD 8.2, select() doesn't always reject bad fds. + AC_CACHE_CHECK([whether select detects invalid fds], + [gl_cv_func_select_detects_ebadf], + [ + AC_RUN_IFELSE([AC_LANG_PROGRAM([[ +#include +#include +#if HAVE_SYS_SELECT_H +# include +#endif +#include +#include +]GL_MDA_DEFINES], +[[ + fd_set set; + dup2(0, 16); + FD_ZERO(&set); + FD_SET(16, &set); + close(16); + struct timeval timeout; + timeout.tv_sec = 0; + timeout.tv_usec = 5; + return select (17, &set, NULL, NULL, &timeout) != -1 || errno != EBADF; +]])], [gl_cv_func_select_detects_ebadf=yes], + [gl_cv_func_select_detects_ebadf=no], + [ + case "$host_os" in + # Guess yes on Linux systems. + linux-* | linux) gl_cv_func_select_detects_ebadf="guessing yes" ;; + # Guess yes on systems that emulate the Linux system calls. + midipix*) gl_cv_func_select_detects_ebadf="guessing yes" ;; + # Guess yes on glibc systems. + *-gnu* | gnu*) gl_cv_func_select_detects_ebadf="guessing yes" ;; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_select_detects_ebadf="$gl_cross_guess_normal" ;; + esac + ]) + ]) + case $gl_cv_func_select_detects_ebadf in + *yes) ;; + *) REPLACE_SELECT=1 ;; + esac + fi + + dnl Determine the needed libraries. + SELECT_LIB="$LIBSOCKET" + if test $REPLACE_SELECT = 1; then + case "$host_os" in + mingw* | windows*) + dnl On the MSVC platform, the function MsgWaitForMultipleObjects + dnl (used in lib/select.c) requires linking with -luser32. On mingw, + dnl it is implicit. + AC_LINK_IFELSE( + [AC_LANG_SOURCE([[ +#define WIN32_LEAN_AND_MEAN +#include +int +main () +{ + MsgWaitForMultipleObjects (0, NULL, 0, 0, 0); + return 0; +}]])], + [], + [SELECT_LIB="$SELECT_LIB -luser32"]) + ;; + esac + fi + AC_SUBST([SELECT_LIB]) + dnl For backward compatibility. + LIB_SELECT="$LIB_SELECT" + AC_SUBST([LIB_SELECT]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/setenv.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/setenv.m4 new file mode 100644 index 00000000..21253e65 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/setenv.m4 @@ -0,0 +1,165 @@ +# setenv.m4 serial 33 +dnl Copyright (C) 2001-2004, 2006-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_SETENV], +[ + AC_REQUIRE([gl_FUNC_SETENV_SEPARATE]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + if test $ac_cv_func_setenv = no; then + HAVE_SETENV=0 + else + AC_CACHE_CHECK([whether setenv validates arguments], + [gl_cv_func_setenv_works], + [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ + #include + #include + #include + ]], [[ + int result = 0; + { + if (setenv ("", "", 0) != -1) + result |= 1; + else if (errno != EINVAL) + result |= 2; + } + { + if (setenv ("a", "=", 1) != 0) + result |= 4; + else if (strcmp (getenv ("a"), "=") != 0) + result |= 8; + } + return result; + ]])], + [gl_cv_func_setenv_works=yes], [gl_cv_func_setenv_works=no], + [case "$host_os" in + # Guess yes on glibc systems. + *-gnu* | gnu*) gl_cv_func_setenv_works="guessing yes" ;; + # Guess yes on musl systems. + *-musl* | midipix*) gl_cv_func_setenv_works="guessing yes" ;; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_setenv_works="$gl_cross_guess_normal" ;; + esac + ])]) + case "$gl_cv_func_setenv_works" in + *yes) ;; + *) + REPLACE_SETENV=1 + ;; + esac + fi +]) + +# Like gl_FUNC_SETENV, except prepare for separate compilation +# (no REPLACE_SETENV, no AC_LIBOBJ). +AC_DEFUN([gl_FUNC_SETENV_SEPARATE], +[ + AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) + AC_CHECK_DECLS_ONCE([setenv]) + if test $ac_cv_have_decl_setenv = no; then + HAVE_DECL_SETENV=0 + fi + AC_CHECK_FUNCS_ONCE([setenv]) + gl_PREREQ_SETENV +]) + +AC_DEFUN([gl_FUNC_UNSETENV], +[ + AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CHECK_DECLS_ONCE([unsetenv]) + if test $ac_cv_have_decl_unsetenv = no; then + HAVE_DECL_UNSETENV=0 + fi + AC_CHECK_FUNCS([unsetenv]) + if test $ac_cv_func_unsetenv = no; then + HAVE_UNSETENV=0 + else + HAVE_UNSETENV=1 + dnl Some BSDs return void, failing to do error checking. + AC_CACHE_CHECK([for unsetenv() return type], [gt_cv_func_unsetenv_ret], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[ +#undef _BSD +#define _BSD 1 /* unhide unsetenv declaration in OSF/1 5.1 */ +#include +extern +#ifdef __cplusplus +"C" +#endif +int unsetenv (const char *name); + ]], + [[]])], + [gt_cv_func_unsetenv_ret='int'], + [gt_cv_func_unsetenv_ret='void'])]) + if test $gt_cv_func_unsetenv_ret = 'void'; then + AC_DEFINE([VOID_UNSETENV], [1], [Define to 1 if unsetenv returns void + instead of int.]) + REPLACE_UNSETENV=1 + fi + + dnl Solaris 10 unsetenv does not remove all copies of a name. + dnl Haiku alpha 2 unsetenv gets confused by assignment to environ. + dnl OpenBSD 4.7 unsetenv("") does not fail. + AC_CACHE_CHECK([whether unsetenv obeys POSIX], + [gl_cv_func_unsetenv_works], + [AC_RUN_IFELSE( + [AC_LANG_PROGRAM([[ + #include + #include + extern char **environ; + ]GL_MDA_DEFINES], + [[ + char entry1[] = "a=1"; + char entry2[] = "b=2"; + char *env[] = { entry1, entry2, NULL }; + if (putenv ((char *) "a=1")) return 1; + if (putenv (entry2)) return 2; + entry2[0] = 'a'; + unsetenv ("a"); + if (getenv ("a")) return 3; + if (!unsetenv ("") || errno != EINVAL) return 4; + entry2[0] = 'b'; + environ = env; + if (!getenv ("a")) return 5; + entry2[0] = 'a'; + unsetenv ("a"); + if (getenv ("a")) return 6; + ]])], + [gl_cv_func_unsetenv_works=yes], + [gl_cv_func_unsetenv_works=no], + [case "$host_os" in + # Guess yes on glibc systems. + *-gnu*) gl_cv_func_unsetenv_works="guessing yes" ;; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_unsetenv_works="$gl_cross_guess_normal" ;; + esac + ]) + ]) + case "$gl_cv_func_unsetenv_works" in + *yes) ;; + *) + REPLACE_UNSETENV=1 + ;; + esac + fi +]) + +# Prerequisites of lib/setenv.c. +AC_DEFUN([gl_PREREQ_SETENV], +[ + AC_REQUIRE([gl_ENVIRON]) + AC_CHECK_HEADERS_ONCE([unistd.h]) + AC_CHECK_HEADERS([search.h]) + gl_CHECK_FUNCS_ANDROID([tsearch], [[#include ]]) +]) + +# Prerequisites of lib/unsetenv.c. +AC_DEFUN([gl_PREREQ_UNSETENV], +[ + AC_REQUIRE([gl_ENVIRON]) + AC_CHECK_HEADERS_ONCE([unistd.h]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/setlocale_null.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/setlocale_null.m4 new file mode 100644 index 00000000..54d3d46d --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/setlocale_null.m4 @@ -0,0 +1,117 @@ +# setlocale_null.m4 serial 9 +dnl Copyright (C) 2019-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_SETLOCALE_NULL], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_REQUIRE([gl_PTHREADLIB]) + AC_CHECK_HEADERS_ONCE([threads.h]) + + AC_CACHE_CHECK([whether setlocale (LC_ALL, NULL) is multithread-safe], + [gl_cv_func_setlocale_null_all_mtsafe], + [case "$host_os" in + # Guess no on musl libc, macOS, FreeBSD, NetBSD, OpenBSD, AIX, Haiku. + *-musl* | midipix* | darwin* | freebsd* | midnightbsd* | netbsd* | openbsd* | aix* | haiku*) + gl_cv_func_setlocale_null_all_mtsafe=no ;; + # Guess no on Cygwin < 3.4.6. + cygwin*) + AC_EGREP_CPP([Lucky user], + [ +#if defined __CYGWIN__ + #include + #if CYGWIN_VERSION_DLL_COMBINED >= CYGWIN_VERSION_DLL_MAKE_COMBINED (3004, 6) + Lucky user + #endif +#endif + ], + [gl_cv_func_setlocale_null_all_mtsafe=yes], + [gl_cv_func_setlocale_null_all_mtsafe=no]) + ;; + # Guess yes on glibc, HP-UX, IRIX, Solaris, native Windows. + *-gnu* | gnu* | hpux* | irix* | solaris* | mingw* | windows*) + gl_cv_func_setlocale_null_all_mtsafe=yes ;; + # If we don't know, obey --enable-cross-guesses. + *) + gl_cv_func_setlocale_null_all_mtsafe="$gl_cross_guess_normal" ;; + esac + ]) + dnl On platforms without multithreading, there is no issue. + case "$host_os" in + mingw* | windows*) ;; + *) + if test $gl_pthread_api = no && test $ac_cv_header_threads_h = no; then + gl_cv_func_setlocale_null_all_mtsafe="trivially yes" + fi + ;; + esac + case "$gl_cv_func_setlocale_null_all_mtsafe" in + *yes) SETLOCALE_NULL_ALL_MTSAFE=1 ;; + *) SETLOCALE_NULL_ALL_MTSAFE=0 ;; + esac + AC_DEFINE_UNQUOTED([SETLOCALE_NULL_ALL_MTSAFE], [$SETLOCALE_NULL_ALL_MTSAFE], + [Define to 1 if setlocale (LC_ALL, NULL) is multithread-safe.]) + + dnl This is about a single category (not LC_ALL). + AC_CACHE_CHECK([whether setlocale (category, NULL) is multithread-safe], + [gl_cv_func_setlocale_null_one_mtsafe], + [case "$host_os" in + # Guess no on OpenBSD, AIX. + openbsd* | aix*) + gl_cv_func_setlocale_null_one_mtsafe=no ;; + # Guess yes on glibc, musl libc, macOS, FreeBSD, NetBSD, HP-UX, IRIX, Solaris, Haiku, Cygwin, native Windows. + *-gnu* | gnu* | *-musl* | midipix* | darwin* | freebsd* | midnightbsd* | netbsd* | hpux* | irix* | solaris* | haiku* | cygwin* | mingw* | windows*) + gl_cv_func_setlocale_null_one_mtsafe=yes ;; + # If we don't know, obey --enable-cross-guesses. + *) + gl_cv_func_setlocale_null_one_mtsafe="$gl_cross_guess_normal" ;; + esac + ]) + dnl On platforms without multithreading, there is no issue. + case "$host_os" in + mingw* | windows*) ;; + *) + if test $gl_pthread_api = no && test $ac_cv_header_threads_h = no; then + gl_cv_func_setlocale_null_one_mtsafe="trivially yes" + fi + ;; + esac + case "$gl_cv_func_setlocale_null_one_mtsafe" in + *yes) SETLOCALE_NULL_ONE_MTSAFE=1 ;; + *) SETLOCALE_NULL_ONE_MTSAFE=0 ;; + esac + AC_DEFINE_UNQUOTED([SETLOCALE_NULL_ONE_MTSAFE], [$SETLOCALE_NULL_ONE_MTSAFE], + [Define to 1 if setlocale (category, NULL) is multithread-safe.]) + + dnl Determine link dependencies of lib/setlocale_null.c and lib/setlocale-lock.c. + if test $SETLOCALE_NULL_ALL_MTSAFE = 0 || test $SETLOCALE_NULL_ONE_MTSAFE = 0; then + case "$host_os" in + mingw* | windows*) + SETLOCALE_NULL_LIB= + ;; + *) + gl_WEAK_SYMBOLS + case "$gl_cv_have_weak" in + *yes) SETLOCALE_NULL_LIB= ;; + *) SETLOCALE_NULL_LIB="$LIBPTHREAD" ;; + esac + ;; + esac + else + SETLOCALE_NULL_LIB= + fi + dnl SETLOCALE_NULL_LIB is expected to be '-pthread' or '-lpthread' on AIX + dnl with gcc or xlc, and empty otherwise. + AC_SUBST([SETLOCALE_NULL_LIB]) + dnl For backward compatibility. + LIB_SETLOCALE_NULL="$SETLOCALE_NULL_LIB" + AC_SUBST([LIB_SETLOCALE_NULL]) +]) + +# Prerequisites of lib/setlocale-lock.c. +AC_DEFUN([gl_PREREQ_SETLOCALE_LOCK], +[ + gl_VISIBILITY +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sigaction.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sigaction.m4 new file mode 100644 index 00000000..926bb9c7 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sigaction.m4 @@ -0,0 +1,40 @@ +# sigaction.m4 serial 7 +dnl Copyright (C) 2008-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +# Determine if sigaction interface is present. +AC_DEFUN([gl_SIGACTION], +[ + AC_REQUIRE([gl_SIGNAL_H_DEFAULTS]) + AC_CHECK_FUNCS_ONCE([sigaction]) + if test $ac_cv_func_sigaction = yes; then + AC_CHECK_MEMBERS([struct sigaction.sa_sigaction], , , + [[#include ]]) + if test $ac_cv_member_struct_sigaction_sa_sigaction = no; then + HAVE_STRUCT_SIGACTION_SA_SIGACTION=0 + fi + else + HAVE_SIGACTION=0 + fi +]) + +# Prerequisites of the part of lib/signal.in.h and of lib/sigaction.c. +AC_DEFUN([gl_PREREQ_SIGACTION], +[ + AC_REQUIRE([gl_SIGNAL_H_DEFAULTS]) + AC_REQUIRE([AC_C_RESTRICT]) + AC_REQUIRE([AC_TYPE_UID_T]) + AC_REQUIRE([gl_PREREQ_SIG_HANDLER_H]) + AC_CHECK_FUNCS_ONCE([sigaltstack siginterrupt]) + AC_CHECK_TYPES([siginfo_t], [], [], [[ +#include + ]]) + if test $ac_cv_type_siginfo_t = no; then + HAVE_SIGINFO_T=0 + fi +]) + +# Prerequisites of lib/sig-handler.h. +AC_DEFUN([gl_PREREQ_SIG_HANDLER_H], [:]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sigaltstack.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sigaltstack.m4 new file mode 100644 index 00000000..7684c860 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sigaltstack.m4 @@ -0,0 +1,197 @@ +# sigaltstack.m4 serial 15 +dnl Copyright (C) 2002-2024 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl Written by Bruno Haible and Eric Blake. + +AC_DEFUN([SV_SIGALTSTACK], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) + + AC_CHECK_FUNCS_ONCE([sigaltstack setrlimit]) + + if test "$ac_cv_func_sigaltstack" = yes; then + AC_CHECK_TYPE([stack_t], , + [AC_DEFINE(stack_t, [struct sigaltstack], + [Define to 'struct sigaltstack' if that's the type of the argument to sigaltstack]) + ], + [ +#include +#if HAVE_SYS_SIGNAL_H +# include +#endif + ]) + fi + + AC_CACHE_CHECK([for working sigaltstack], [sv_cv_sigaltstack], [ + if test "$ac_cv_func_sigaltstack" = yes; then + case "$host_os" in + macos* | darwin[[6-9]]* | darwin[[1-9]][[0-9]]*) + # On MacOS X 10.2 or newer, just assume that if it compiles, it will + # work. If we were to perform the real test, 1 Crash Report dialog + # window would pop up. + AC_LINK_IFELSE([ + AC_LANG_PROGRAM([[#include ]], + [[int x = SA_ONSTACK; stack_t ss; sigaltstack ((stack_t*)0, &ss);]])], + [sv_cv_sigaltstack="guessing yes"], + [sv_cv_sigaltstack=no]) + ;; + *) + AC_RUN_IFELSE([ + AC_LANG_SOURCE([[ +#include +#include +#if HAVE_SYS_SIGNAL_H +# include +#endif +#if HAVE_SETRLIMIT +# include +# include +# include +#endif +void stackoverflow_handler (int sig) +{ + /* If we get here, the stack overflow was caught. */ + exit (0); +} +volatile int * recurse_1 (volatile int n, volatile int *p) +{ + if (n >= 0) + *recurse_1 (n + 1, p) += n; + return p; +} +int recurse (volatile int n) +{ + int sum = 0; + return *recurse_1 (n, &sum); +} +char mystack[2 * (1 << 24)]; +int main () +{ + stack_t altstack; + struct sigaction action; +#if defined HAVE_SETRLIMIT && defined RLIMIT_STACK + /* Before starting the endless recursion, try to be friendly to the user's + machine. On some Linux 2.2.x systems, there is no stack limit for user + processes at all. We don't want to kill such systems. */ + struct rlimit rl; + rl.rlim_cur = rl.rlim_max = 0x100000; /* 1 MB */ + setrlimit (RLIMIT_STACK, &rl); +#endif + /* Install the alternate stack. Use the midpoint of mystack, to guard + against a buggy interpretation of ss_sp on IRIX. */ +#ifdef SIGSTKSZ + if (sizeof mystack / 2 < SIGSTKSZ) + exit (3); +#endif + altstack.ss_sp = mystack + sizeof mystack / 2; + altstack.ss_size = sizeof mystack / 2; + altstack.ss_flags = 0; /* no SS_DISABLE */ + if (sigaltstack (&altstack, NULL) < 0) + exit (1); + /* Install the SIGSEGV handler. */ + sigemptyset (&action.sa_mask); + action.sa_handler = &stackoverflow_handler; + action.sa_flags = SA_ONSTACK; + sigaction (SIGSEGV, &action, (struct sigaction *) NULL); + sigaction (SIGBUS, &action, (struct sigaction *) NULL); + /* Provoke a stack overflow. */ + recurse (0); + exit (2); +}]])], + [sv_cv_sigaltstack=yes], + [sv_cv_sigaltstack=no], + [ + dnl FIXME: Put in some more known values here. + case "$host_os" in + *) + AC_LINK_IFELSE([ + AC_LANG_PROGRAM([[#include ]], + [[int x = SA_ONSTACK; stack_t ss; sigaltstack ((stack_t*)0, &ss);]])], + [sv_cv_sigaltstack="guessing yes"], + [sv_cv_sigaltstack=no]) + ;; + esac + ]) + ;; + esac + else + sv_cv_sigaltstack=no + fi + ]) + if test "$sv_cv_sigaltstack" != no; then + AC_DEFINE([HAVE_WORKING_SIGALTSTACK], [1], + [Define if you have the sigaltstack() function and it works.]) + + dnl The ss_sp field of a stack_t is, according to POSIX, the lowest address + dnl of the memory block designated as an alternate stack. But IRIX 5.3 + dnl interprets it as the highest address! + AC_CACHE_CHECK([for correct stack_t interpretation], + [sv_cv_sigaltstack_low_base], [ + AC_RUN_IFELSE([ + AC_LANG_SOURCE([[ +#include +#include +#if HAVE_SYS_SIGNAL_H +# include +#endif +volatile char *stack_lower_bound; +volatile char *stack_upper_bound; +static void check_stack_location (volatile char *addr) +{ + if (addr >= stack_lower_bound && addr <= stack_upper_bound) + exit (0); + else + exit (1); +} +static void stackoverflow_handler (int sig) +{ + char dummy; + check_stack_location (&dummy); +} +char mystack[2 * (1 << 24)]; +int main () +{ + stack_t altstack; + struct sigaction action; + /* Install the alternate stack. */ + altstack.ss_sp = mystack + sizeof mystack / 2; + altstack.ss_size = sizeof mystack / 2; + stack_lower_bound = (char *) altstack.ss_sp; + stack_upper_bound = (char *) altstack.ss_sp + altstack.ss_size - 1; + altstack.ss_flags = 0; /* no SS_DISABLE */ + if (sigaltstack (&altstack, NULL) < 0) + exit (2); + /* Install the SIGSEGV handler. */ + sigemptyset (&action.sa_mask); + action.sa_handler = &stackoverflow_handler; + action.sa_flags = SA_ONSTACK; + if (sigaction (SIGSEGV, &action, (struct sigaction *) NULL) < 0) + exit(3); + /* Provoke a SIGSEGV. */ + raise (SIGSEGV); + exit (3); +}]])], + [sv_cv_sigaltstack_low_base=yes], + [sv_cv_sigaltstack_low_base=no], + [ + dnl FIXME: Put in some more known values here. + case "$host_os" in + irix5*) sv_cv_sigaltstack_low_base="no" ;; + *) sv_cv_sigaltstack_low_base="guessing yes" ;; + esac + ]) + ]) + if test "$sv_cv_sigaltstack_low_base" = no; then + AC_DEFINE([SIGALTSTACK_SS_REVERSED], [1], + [Define if sigaltstack() interprets the stack_t.ss_sp field incorrectly, + as the highest address of the alternate stack range rather than as the + lowest address.]) + fi + fi +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/signal_h.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/signal_h.m4 new file mode 100644 index 00000000..6f7dcc73 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/signal_h.m4 @@ -0,0 +1,100 @@ +# signal_h.m4 serial 22 +dnl Copyright (C) 2007-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN_ONCE([gl_SIGNAL_H], +[ + AC_REQUIRE([gl_SIGNAL_H_DEFAULTS]) + AC_REQUIRE([gl_CHECK_TYPE_SIGSET_T]) + gl_NEXT_HEADERS([signal.h]) + +# AIX declares sig_atomic_t to already include volatile, and C89 compilers +# then choke on 'volatile sig_atomic_t'. C99 requires that it compile. + AC_CHECK_TYPE([volatile sig_atomic_t], [], + [HAVE_TYPE_VOLATILE_SIG_ATOMIC_T=0], [[ +#include + ]]) + + dnl Ensure the type pid_t gets defined. + AC_REQUIRE([AC_TYPE_PID_T]) + + AC_REQUIRE([AC_TYPE_UID_T]) + + dnl Persuade glibc to define sighandler_t. + AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) + AC_CHECK_TYPE([sighandler_t], [], [HAVE_SIGHANDLER_T=0], [[ +#include + ]]) + + dnl Check for declarations of anything we want to poison if the + dnl corresponding gnulib module is not in use. + gl_WARN_ON_USE_PREPARE([[#include + ]], [pthread_sigmask sigaction + sigaddset sigdelset sigemptyset sigfillset sigismember + sigpending sigprocmask]) + + AC_REQUIRE([AC_C_RESTRICT]) +]) + +AC_DEFUN([gl_CHECK_TYPE_SIGSET_T], +[ + AC_CHECK_TYPES([sigset_t], + [gl_cv_type_sigset_t=yes], [gl_cv_type_sigset_t=no], + [[ + #include + /* Mingw defines sigset_t not in , but in . */ + #include + ]]) + if test $gl_cv_type_sigset_t != yes; then + HAVE_SIGSET_T=0 + fi +]) + +# gl_SIGNAL_MODULE_INDICATOR([modulename]) +# sets the shell variable that indicates the presence of the given module +# to a C preprocessor expression that will evaluate to 1. +# This macro invocation must not occur in macros that are AC_REQUIREd. +AC_DEFUN([gl_SIGNAL_MODULE_INDICATOR], +[ + dnl Ensure to expand the default settings once only. + gl_SIGNAL_H_REQUIRE_DEFAULTS + gl_MODULE_INDICATOR_SET_VARIABLE([$1]) + dnl Define it also as a C macro, for the benefit of the unit tests. + gl_MODULE_INDICATOR_FOR_TESTS([$1]) +]) + +# Initializes the default values for AC_SUBSTed shell variables. +# This macro must not be AC_REQUIREd. It must only be invoked, and only +# outside of macros or in macros that are not AC_REQUIREd. +AC_DEFUN([gl_SIGNAL_H_REQUIRE_DEFAULTS], +[ + m4_defun(GL_MODULE_INDICATOR_PREFIX[_SIGNAL_H_MODULE_INDICATOR_DEFAULTS], [ + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PTHREAD_SIGMASK]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RAISE]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SIGNAL_H_SIGPIPE]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SIGPROCMASK]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SIGACTION]) + ]) + m4_require(GL_MODULE_INDICATOR_PREFIX[_SIGNAL_H_MODULE_INDICATOR_DEFAULTS]) + AC_REQUIRE([gl_SIGNAL_H_DEFAULTS]) +]) + +AC_DEFUN([gl_SIGNAL_H_DEFAULTS], +[ + dnl Assume proper GNU behavior unless another module says otherwise. + HAVE_POSIX_SIGNALBLOCKING=1; AC_SUBST([HAVE_POSIX_SIGNALBLOCKING]) + HAVE_PTHREAD_SIGMASK=1; AC_SUBST([HAVE_PTHREAD_SIGMASK]) + HAVE_RAISE=1; AC_SUBST([HAVE_RAISE]) + HAVE_SIGSET_T=1; AC_SUBST([HAVE_SIGSET_T]) + HAVE_SIGINFO_T=1; AC_SUBST([HAVE_SIGINFO_T]) + HAVE_SIGACTION=1; AC_SUBST([HAVE_SIGACTION]) + HAVE_STRUCT_SIGACTION_SA_SIGACTION=1; + AC_SUBST([HAVE_STRUCT_SIGACTION_SA_SIGACTION]) + HAVE_TYPE_VOLATILE_SIG_ATOMIC_T=1; + AC_SUBST([HAVE_TYPE_VOLATILE_SIG_ATOMIC_T]) + HAVE_SIGHANDLER_T=1; AC_SUBST([HAVE_SIGHANDLER_T]) + REPLACE_PTHREAD_SIGMASK=0; AC_SUBST([REPLACE_PTHREAD_SIGMASK]) + REPLACE_RAISE=0; AC_SUBST([REPLACE_RAISE]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/signalblocking.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/signalblocking.m4 new file mode 100644 index 00000000..f818d5da --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/signalblocking.m4 @@ -0,0 +1,23 @@ +# signalblocking.m4 serial 17 +dnl Copyright (C) 2001-2002, 2006-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +# Determine available signal blocking primitives. Three different APIs exist: +# 1) POSIX: sigemptyset, sigaddset, sigprocmask +# 2) SYSV: sighold, sigrelse +# 3) BSD: sigblock, sigsetmask +# For simplicity, here we check only for the POSIX signal blocking. +AC_DEFUN([gl_SIGNALBLOCKING], +[ + AC_REQUIRE([gl_SIGNAL_H_DEFAULTS]) + AC_REQUIRE([gl_CHECK_TYPE_SIGSET_T]) + HAVE_POSIX_SIGNALBLOCKING=0 + if test "$gl_cv_type_sigset_t" = yes; then + AC_CHECK_FUNC([sigprocmask], [HAVE_POSIX_SIGNALBLOCKING=1]) + fi +]) + +# Prerequisites of lib/sigprocmask.c. +AC_DEFUN([gl_PREREQ_SIGPROCMASK], [:]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/signbit.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/signbit.m4 new file mode 100644 index 00000000..4acb0e98 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/signbit.m4 @@ -0,0 +1,393 @@ +# signbit.m4 serial 22 +dnl Copyright (C) 2007-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_SIGNBIT], +[ + AC_REQUIRE([gl_MATH_H_DEFAULTS]) + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_CACHE_CHECK([for signbit macro], [gl_cv_func_signbit], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +/* If signbit is defined as a function, don't use it, since calling it for + 'float' or 'long double' arguments would involve conversions. + If signbit is not declared at all but exists as a library function, don't + use it, since the prototype may not match. + If signbit is not declared at all but exists as a compiler built-in, don't + use it, since it's preferable to use __builtin_signbit* (no warnings, + no conversions). */ +#ifndef signbit +# error "signbit should be a macro" +#endif +#include +]gl_SIGNBIT_TEST_PROGRAM +])], + [gl_cv_func_signbit=yes], + [gl_cv_func_signbit=no], + [case "$host_os" in + # Guess yes on glibc systems. + *-gnu* | gnu*) gl_cv_func_signbit="guessing yes" ;; + # Guess yes on musl systems. + *-musl* | midipix*) gl_cv_func_signbit="guessing yes" ;; + # Guess yes on native Windows. + mingw* | windows*) gl_cv_func_signbit="guessing yes" ;; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_signbit="$gl_cross_guess_normal" ;; + esac + ]) + ]) + dnl GCC >= 4.0 and clang provide three built-ins for signbit. + dnl They can be used without warnings, also in C++, regardless of . + dnl But they may expand to calls to functions, which may or may not be in + dnl libc. + AC_CACHE_CHECK([for signbit compiler built-ins], + [gl_cv_func_signbit_builtins], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#if (__GNUC__ >= 4) || (__clang_major__ >= 4) +# define signbit(x) \ + (sizeof (x) == sizeof (long double) ? __builtin_signbitl (x) : \ + sizeof (x) == sizeof (double) ? __builtin_signbit (x) : \ + __builtin_signbitf (x)) +#else +# error "signbit should be three compiler built-ins" +#endif +#include +]gl_SIGNBIT_TEST_PROGRAM +])], + [gl_cv_func_signbit_builtins=yes], + [gl_cv_func_signbit_builtins=no], + [case "$host_os" in + # Guess yes on glibc systems. + *-gnu* | gnu*) gl_cv_func_signbit_builtins="guessing yes" ;; + # Guess yes on musl systems. + *-musl* | midipix*) gl_cv_func_signbit_builtins="guessing yes" ;; + # Guess yes on mingw, no on MSVC. + mingw* | windows*) if test -n "$GCC"; then + gl_cv_func_signbit_builtins="guessing yes" + else + gl_cv_func_signbit_builtins="guessing no" + fi + ;; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_signbit_builtins="$gl_cross_guess_normal" ;; + esac + ]) + ]) + dnl Use the compiler built-ins whenever possible, because they are more + dnl efficient than the system library functions (if they exist). + case "$gl_cv_func_signbit_builtins" in + *yes) + REPLACE_SIGNBIT_USING_BUILTINS=1 + ;; + *) + case "$gl_cv_func_signbit" in + *yes) ;; + *) + dnl REPLACE_SIGNBIT=1 makes sure the signbit[fdl] functions get built. + REPLACE_SIGNBIT=1 + ;; + esac + ;; + esac + dnl On Solaris 10, with CC in C++ mode, signbit is not available although + dnl is with cc in C mode. This cannot be worked around by defining + dnl _XOPEN_SOURCE=600, because the latter does not work in C++ mode on + dnl Solaris 11.0. Therefore use the replacement functions on Solaris. + case "$host_os" in + solaris*) + REPLACE_SIGNBIT=1 + ;; + esac + if test $REPLACE_SIGNBIT = 1; then + gl_FLOAT_SIGN_LOCATION + gl_DOUBLE_SIGN_LOCATION + gl_LONG_DOUBLE_SIGN_LOCATION + if test "$gl_cv_cc_float_signbit" = unknown; then + dnl Test whether copysignf() is declared. + AC_CHECK_DECLS([copysignf], , , [[#include ]]) + if test "$ac_cv_have_decl_copysignf" = yes; then + dnl Test whether copysignf() can be used without libm. + AC_CACHE_CHECK([whether copysignf can be used without linking with libm], + [gl_cv_func_copysignf_no_libm], + [ + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include + float x, y;]], + [[return copysignf (x, y) < 0;]])], + [gl_cv_func_copysignf_no_libm=yes], + [gl_cv_func_copysignf_no_libm=no]) + ]) + if test $gl_cv_func_copysignf_no_libm = yes; then + AC_DEFINE([HAVE_COPYSIGNF_IN_LIBC], [1], + [Define if the copysignf function is declared in and available in libc.]) + fi + fi + fi + if test "$gl_cv_cc_double_signbit" = unknown; then + dnl Test whether copysign() is declared. + AC_CHECK_DECLS([copysign], , , [[#include ]]) + if test "$ac_cv_have_decl_copysign" = yes; then + dnl Test whether copysign() can be used without libm. + AC_CACHE_CHECK([whether copysign can be used without linking with libm], + [gl_cv_func_copysign_no_libm], + [ + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include + double x, y;]], + [[return copysign (x, y) < 0;]])], + [gl_cv_func_copysign_no_libm=yes], + [gl_cv_func_copysign_no_libm=no]) + ]) + if test $gl_cv_func_copysign_no_libm = yes; then + AC_DEFINE([HAVE_COPYSIGN_IN_LIBC], [1], + [Define if the copysign function is declared in and available in libc.]) + fi + fi + fi + if test "$gl_cv_cc_long_double_signbit" = unknown; then + dnl Test whether copysignl() is declared. + AC_CHECK_DECLS([copysignl], , , [[#include ]]) + if test "$ac_cv_have_decl_copysignl" = yes; then + dnl Test whether copysignl() can be used without libm. + AC_CACHE_CHECK([whether copysignl can be used without linking with libm], + [gl_cv_func_copysignl_no_libm], + [ + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include + long double x, y;]], + [[return copysignl (x, y) < 0;]])], + [gl_cv_func_copysignl_no_libm=yes], + [gl_cv_func_copysignl_no_libm=no]) + ]) + if test $gl_cv_func_copysignl_no_libm = yes; then + AC_DEFINE([HAVE_COPYSIGNL_IN_LIBC], [1], + [Define if the copysignl function is declared in and available in libc.]) + fi + fi + fi + fi +]) + +AC_DEFUN([gl_SIGNBIT_TEST_PROGRAM], [[ +/* Global variables. + Needed because GCC 4 constant-folds __builtin_signbitl (literal) + but cannot constant-fold __builtin_signbitl (variable). */ +float vf; +double vd; +long double vl; +int main () +{ +/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0. + So we use -p0f and -p0d instead. */ +float p0f = 0.0f; +float m0f = -p0f; +double p0d = 0.0; +double m0d = -p0d; +/* On HP-UX 10.20, negating 0.0L does not yield -0.0L. + So we use another constant expression instead. + But that expression does not work on other platforms, such as when + cross-compiling to PowerPC on Mac OS X 10.5. */ +long double p0l = 0.0L; +#if defined __hpux || defined __sgi +long double m0l = -LDBL_MIN * LDBL_MIN; +#else +long double m0l = -p0l; +#endif + int result = 0; + if (signbit (vf)) /* link check */ + vf++; + { + float plus_inf = 1.0f / p0f; + float minus_inf = -1.0f / p0f; + if (!(!signbit (255.0f) + && signbit (-255.0f) + && !signbit (p0f) + && (memcmp (&m0f, &p0f, sizeof (float)) == 0 || signbit (m0f)) + && !signbit (plus_inf) + && signbit (minus_inf))) + result |= 1; + } + if (signbit (vd)) /* link check */ + vd++; + { + double plus_inf = 1.0 / p0d; + double minus_inf = -1.0 / p0d; + if (!(!signbit (255.0) + && signbit (-255.0) + && !signbit (p0d) + && (memcmp (&m0d, &p0d, sizeof (double)) == 0 || signbit (m0d)) + && !signbit (plus_inf) + && signbit (minus_inf))) + result |= 2; + } + if (signbit (vl)) /* link check */ + vl++; + { + long double plus_inf = 1.0L / p0l; + long double minus_inf = -1.0L / p0l; + if (signbit (255.0L)) + result |= 4; + if (!signbit (-255.0L)) + result |= 4; + if (signbit (p0l)) + result |= 8; + if (!(memcmp (&m0l, &p0l, sizeof (long double)) == 0 || signbit (m0l))) + result |= 16; + if (signbit (plus_inf)) + result |= 32; + if (!signbit (minus_inf)) + result |= 64; + } + return result; +} +]]) + +AC_DEFUN([gl_FLOAT_SIGN_LOCATION], +[ + gl_FLOATTYPE_SIGN_LOCATION([float], [gl_cv_cc_float_signbit], [f], [FLT]) +]) + +AC_DEFUN([gl_DOUBLE_SIGN_LOCATION], +[ + gl_FLOATTYPE_SIGN_LOCATION([double], [gl_cv_cc_double_signbit], [], [DBL]) +]) + +AC_DEFUN([gl_LONG_DOUBLE_SIGN_LOCATION], +[ + gl_FLOATTYPE_SIGN_LOCATION([long double], [gl_cv_cc_long_double_signbit], [L], [LDBL]) +]) + +AC_DEFUN([gl_FLOATTYPE_SIGN_LOCATION], +[ + AC_CACHE_CHECK([where to find the sign bit in a '$1'], + [$2], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +#define NWORDS \ + ((sizeof ($1) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) +typedef union { $1 value; unsigned int word[NWORDS]; } + memory_float; +static memory_float plus = { 1.0$3 }; +static memory_float minus = { -1.0$3 }; +int main () +{ + size_t j, k, i; + unsigned int m; + FILE *fp = fopen ("conftest.out", "w"); + if (fp == NULL) + return 1; + /* Find the different bit. */ + k = 0; m = 0; + for (j = 0; j < NWORDS; j++) + { + unsigned int x = plus.word[j] ^ minus.word[j]; + if ((x & (x - 1)) || (x && m)) + { + /* More than one bit difference. */ + fprintf (fp, "unknown"); + fclose (fp); + return 2; + } + if (x) + { + k = j; + m = x; + } + } + if (m == 0) + { + /* No difference. */ + fprintf (fp, "unknown"); + fclose (fp); + return 3; + } + /* Now m = plus.word[k] ^ ~minus.word[k]. */ + if (plus.word[k] & ~minus.word[k]) + { + /* Oh? The sign bit is set in the positive and cleared in the negative + numbers? */ + fprintf (fp, "unknown"); + fclose (fp); + return 4; + } + for (i = 0; ; i++) + if ((m >> i) & 1) + break; + fprintf (fp, "word %d bit %d", (int) k, (int) i); + if (fclose (fp) != 0) + return 5; + return 0; +} + ]])], + [$2=`cat conftest.out`], + [$2="unknown"], + [ + dnl When cross-compiling, we don't know. It depends on the + dnl ABI and compiler version. There are too many cases. + $2="unknown" + ]) + rm -f conftest.out + ]) + case "$]$2[" in + word*bit*) + word=`echo "$]$2[" | sed -e 's/word //' -e 's/ bit.*//'` + bit=`echo "$]$2[" | sed -e 's/word.*bit //'` + AC_DEFINE_UNQUOTED([$4][_SIGNBIT_WORD], [$word], + [Define as the word index where to find the sign of '$1'.]) + AC_DEFINE_UNQUOTED([$4][_SIGNBIT_BIT], [$bit], + [Define as the bit index in the word where to find the sign of '$1'.]) + ;; + esac +]) + +# Expands to code that defines a function signbitf(float). +# It extracts the sign bit of a non-NaN value. +AC_DEFUN([gl_FLOAT_SIGNBIT_CODE], +[ + gl_FLOATTYPE_SIGNBIT_CODE([float], [f], [f]) +]) + +# Expands to code that defines a function signbitd(double). +# It extracts the sign bit of a non-NaN value. +AC_DEFUN([gl_DOUBLE_SIGNBIT_CODE], +[ + gl_FLOATTYPE_SIGNBIT_CODE([double], [d], []) +]) + +# Expands to code that defines a function signbitl(long double). +# It extracts the sign bit of a non-NaN value. +AC_DEFUN([gl_LONG_DOUBLE_SIGNBIT_CODE], +[ + gl_FLOATTYPE_SIGNBIT_CODE([long double], [l], [L]) +]) + +AC_DEFUN([gl_FLOATTYPE_SIGNBIT_CODE], +[[ +static int +signbit$2 ($1 value) +{ + typedef union { $1 f; unsigned char b[sizeof ($1)]; } float_union; + static float_union plus_one = { 1.0$3 }; /* unused bits are zero here */ + static float_union minus_one = { -1.0$3 }; /* unused bits are zero here */ + /* Compute the sign bit mask as the XOR of plus_one and minus_one. */ + float_union u; + unsigned int i; + u.f = value; + for (i = 0; i < sizeof ($1); i++) + if (u.b[i] & (plus_one.b[i] ^ minus_one.b[i])) + return 1; + return 0; +} +]]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sigsegv.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sigsegv.m4 new file mode 100644 index 00000000..6ac87474 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sigsegv.m4 @@ -0,0 +1,20 @@ +# sigsegv.m4 serial 2 +dnl Copyright (C) 2021-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. + +AC_DEFUN_ONCE([gl_SIGSEGV], +[ + AC_ARG_WITH([libsigsegv], + [AS_HELP_STRING([[--with-libsigsegv]], + [use the GNU libsigsegv library, when present, instead of the gnulib module 'sigsegv'])]) + if test "$with_libsigsegv" = yes; then + gl_LIBSIGSEGV + gl_sigsegv_uses_libsigsegv="$gl_cv_lib_sigsegv" + else + gl_sigsegv_uses_libsigsegv=no + fi +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/size_max.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/size_max.m4 new file mode 100644 index 00000000..b3f7624f --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/size_max.m4 @@ -0,0 +1,75 @@ +# size_max.m4 serial 12 +dnl Copyright (C) 2003, 2005-2006, 2008-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. + +AC_PREREQ([2.61]) + +AC_DEFUN([gl_SIZE_MAX], +[ + AC_CHECK_HEADERS([stdint.h]) + dnl First test whether the system already has SIZE_MAX. + AC_CACHE_CHECK([for SIZE_MAX], [gl_cv_size_max], [ + gl_cv_size_max=no + AC_EGREP_CPP([Found it], [ +#include +#if HAVE_STDINT_H +#include +#endif +#ifdef SIZE_MAX +Found it +#endif +], [gl_cv_size_max=yes]) + if test $gl_cv_size_max != yes; then + dnl Define it ourselves. Here we assume that the type 'size_t' is not wider + dnl than the type 'unsigned long'. Try hard to find a definition that can + dnl be used in a preprocessor #if, i.e. doesn't contain a cast. + AC_COMPUTE_INT([size_t_bits_minus_1], [sizeof (size_t) * CHAR_BIT - 1], + [#include +#include ], [size_t_bits_minus_1=]) + AC_COMPUTE_INT([fits_in_uint], [sizeof (size_t) <= sizeof (unsigned int)], + [#include ], [fits_in_uint=]) + if test -n "$size_t_bits_minus_1" && test -n "$fits_in_uint"; then + if test $fits_in_uint = 1; then + dnl Even though SIZE_MAX fits in an unsigned int, it must be of type + dnl 'unsigned long' if the type 'size_t' is the same as 'unsigned long'. + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include + extern size_t foo; + extern unsigned long foo; + ]], + [[]])], + [fits_in_uint=0]) + fi + dnl We cannot use 'expr' to simplify this expression, because 'expr' + dnl works only with 'long' integers in the host environment, while we + dnl might be cross-compiling from a 32-bit platform to a 64-bit platform. + if test $fits_in_uint = 1; then + gl_cv_size_max="(((1U << $size_t_bits_minus_1) - 1) * 2 + 1)" + else + gl_cv_size_max="(((1UL << $size_t_bits_minus_1) - 1) * 2 + 1)" + fi + else + dnl Shouldn't happen, but who knows... + gl_cv_size_max='((size_t)~(size_t)0)' + fi + fi + ]) + if test "$gl_cv_size_max" != yes; then + AC_DEFINE_UNQUOTED([SIZE_MAX], [$gl_cv_size_max], + [Define as the maximum value of type 'size_t', if the system doesn't define it.]) + fi + dnl Don't redefine SIZE_MAX in config.h if config.h is re-included after + dnl . Remember that the #undef in AH_VERBATIM gets replaced with + dnl #define by AC_DEFINE_UNQUOTED. + AH_VERBATIM([SIZE_MAX], +[/* Define as the maximum value of type 'size_t', if the system doesn't define + it. */ +#ifndef SIZE_MAX +# undef SIZE_MAX +#endif]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sleep.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sleep.m4 new file mode 100644 index 00000000..2003698c --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sleep.m4 @@ -0,0 +1,68 @@ +# sleep.m4 serial 13 +dnl Copyright (C) 2007-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_SLEEP], +[ + AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + dnl We expect to see the declaration of sleep() in a header file. + dnl Older versions of mingw have a sleep() function that is an alias to + dnl _sleep() in MSVCRT. It has a different signature than POSIX sleep(): + dnl it takes the number of milliseconds as argument and returns void. + dnl mingw does not declare this function. + AC_CHECK_DECLS([sleep], , , [[#include ]]) + AC_CHECK_FUNCS_ONCE([sleep]) + if test $ac_cv_have_decl_sleep != yes; then + HAVE_SLEEP=0 + else + dnl Cygwin 1.5.x has a bug where sleep can't exceed 49.7 days. + AC_CACHE_CHECK([for working sleep], [gl_cv_func_sleep_works], + [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ +#include +#include +#include +static void +handle_alarm (int sig) +{ + if (sig != SIGALRM) + _exit (2); +} +]], [[ + /* Failure to compile this test due to missing alarm is okay, + since all such platforms (mingw) also lack sleep. */ + unsigned int pentecost = 50 * 24 * 60 * 60; /* 50 days. */ + unsigned int remaining; + signal (SIGALRM, handle_alarm); + alarm (1); + remaining = sleep (pentecost); + if (remaining > pentecost) + return 3; + if (remaining <= pentecost - 10) + return 4; + return 0; + ]])], + [gl_cv_func_sleep_works=yes], [gl_cv_func_sleep_works=no], + [case "$host_os" in + # Guess yes on glibc systems. + *-gnu* | gnu*) gl_cv_func_sleep_works="guessing yes" ;; + # Guess yes on musl systems. + *-musl*) gl_cv_func_sleep_works="guessing yes" ;; + # Guess yes on systems that emulate the Linux system calls. + midipix*) gl_cv_func_sleep_works="guessing yes" ;; + # Guess no on native Windows. + mingw* | windows*) gl_cv_func_sleep_works="guessing no" ;; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_sleep_works="$gl_cross_guess_normal" ;; + esac + ])]) + case "$gl_cv_func_sleep_works" in + *yes) ;; + *) + REPLACE_SLEEP=1 + ;; + esac + fi +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/snan.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/snan.m4 new file mode 100644 index 00000000..6a0a7453 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/snan.m4 @@ -0,0 +1,14 @@ +# snan.m4 serial 3 +dnl Copyright (C) 2023-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +# Prerequisites for lib/snan.h. +AC_DEFUN_ONCE([gl_SNAN], +[ + gl_FLOAT_EXPONENT_LOCATION + gl_DOUBLE_EXPONENT_LOCATION + gl_LONG_DOUBLE_EXPONENT_LOCATION + AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/snprintf.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/snprintf.m4 new file mode 100644 index 00000000..96f9c4e4 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/snprintf.m4 @@ -0,0 +1,62 @@ +# snprintf.m4 serial 7 +dnl Copyright (C) 2002-2004, 2007-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl Libintl 0.17 will replace snprintf only if it does not support %1$s, +dnl but defers to any gnulib snprintf replacements. Therefore, gnulib +dnl must guarantee that the decision for replacing snprintf is a superset +dnl of the reasons checked by libintl. +AC_DEFUN([gl_FUNC_SNPRINTF], +[ + AC_REQUIRE([gl_STDIO_H_DEFAULTS]) + gl_cv_func_snprintf_usable=no + AC_CHECK_FUNCS([snprintf]) + if test $ac_cv_func_snprintf = yes; then + gl_SNPRINTF_SIZE1 + case "$gl_cv_func_snprintf_size1" in + *yes) + gl_SNPRINTF_RETVAL_C99 + case "$gl_cv_func_snprintf_retval_c99" in + *yes) + gl_PRINTF_POSITIONS + case "$gl_cv_func_printf_positions" in + *yes) + gl_cv_func_snprintf_usable=yes + ;; + esac + ;; + esac + ;; + esac + fi + if test $gl_cv_func_snprintf_usable = no; then + gl_REPLACE_SNPRINTF + fi + AC_CHECK_DECLS_ONCE([snprintf]) + if test $ac_cv_have_decl_snprintf = no; then + HAVE_DECL_SNPRINTF=0 + fi +]) + +AC_DEFUN([gl_REPLACE_SNPRINTF], +[ + AC_REQUIRE([gl_STDIO_H_DEFAULTS]) + AC_LIBOBJ([snprintf]) + if test $ac_cv_func_snprintf = yes; then + REPLACE_SNPRINTF=1 + else + AC_CHECK_DECLS_ONCE([snprintf]) + if test $ac_cv_have_decl_snprintf = yes; then + dnl If the function is declared but does not appear to exist, it may be + dnl defined as an inline function. In order to avoid a conflict, we have + dnl to define rpl_snprintf, not snprintf. + REPLACE_SNPRINTF=1 + fi + fi + gl_PREREQ_SNPRINTF +]) + +# Prerequisites of lib/snprintf.c. +AC_DEFUN([gl_PREREQ_SNPRINTF], [:]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/socketlib.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/socketlib.m4 new file mode 100644 index 00000000..5ecb34d3 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/socketlib.m4 @@ -0,0 +1,96 @@ +# socketlib.m4 serial 3 +dnl Copyright (C) 2008-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl gl_SOCKETLIB +dnl Determines the library to use for socket functions. +dnl Sets and AC_SUBSTs LIBSOCKET. + +AC_DEFUN([gl_SOCKETLIB], +[ + gl_PREREQ_SYS_H_WINSOCK2 dnl for HAVE_WINSOCK2_H + LIBSOCKET= + if test $HAVE_WINSOCK2_H = 1; then + dnl Native Windows API (not Cygwin). + dnl If the function WSAStartup exists (declared in and + dnl defined through -lws2_32), we need to call it. + AC_CACHE_CHECK([for WSAStartup], + [gl_cv_func_wsastartup], [ + gl_save_LIBS="$LIBS" + LIBS="$LIBS -lws2_32" + AC_LINK_IFELSE( + [AC_LANG_PROGRAM([[ +#ifdef HAVE_WINSOCK2_H +# include +#endif]], [[ + WORD wVersionRequested = MAKEWORD(1, 1); + WSADATA wsaData; + int err = WSAStartup(wVersionRequested, &wsaData); + WSACleanup (); + ]]) + ], + [gl_cv_func_wsastartup=yes], + [gl_cv_func_wsastartup=no]) + LIBS="$gl_save_LIBS" + ]) + if test "$gl_cv_func_wsastartup" = "yes"; then + AC_DEFINE([WINDOWS_SOCKETS], [1], [Define if WSAStartup is needed.]) + LIBSOCKET='-lws2_32' + fi + else + dnl Unix API. + dnl Solaris has most socket functions in libsocket. + dnl Haiku has most socket functions in libnetwork. + dnl BeOS has most socket functions in libnet. + dnl On HP-UX, do NOT link with libxnet, because in 64-bit mode this would + dnl break code (e.g. in libraries) that invokes accept(), getpeername(), + dnl getsockname(), getsockopt(), or recvfrom() with a 32-bit addrlen. See + dnl "man xopen_networking" for details. + AC_CACHE_CHECK([for library containing setsockopt], [gl_cv_lib_socket], [ + gl_cv_lib_socket= + AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern +#ifdef __cplusplus +"C" +#endif +char setsockopt();]], [[setsockopt();]])], + [], + [gl_save_LIBS="$LIBS" + LIBS="$gl_save_LIBS -lsocket" + AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern +#ifdef __cplusplus +"C" +#endif +char setsockopt();]], [[setsockopt();]])], + [gl_cv_lib_socket="-lsocket"]) + if test -z "$gl_cv_lib_socket"; then + LIBS="$gl_save_LIBS -lnetwork" + AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern +#ifdef __cplusplus +"C" +#endif +char setsockopt();]], [[setsockopt();]])], + [gl_cv_lib_socket="-lnetwork"]) + if test -z "$gl_cv_lib_socket"; then + LIBS="$gl_save_LIBS -lnet" + AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern +#ifdef __cplusplus +"C" +#endif +char setsockopt();]], [[setsockopt();]])], + [gl_cv_lib_socket="-lnet"]) + fi + fi + LIBS="$gl_save_LIBS" + ]) + if test -z "$gl_cv_lib_socket"; then + gl_cv_lib_socket="none needed" + fi + ]) + if test "$gl_cv_lib_socket" != "none needed"; then + LIBSOCKET="$gl_cv_lib_socket" + fi + fi + AC_SUBST([LIBSOCKET]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sockets.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sockets.m4 new file mode 100644 index 00000000..7be4dc96 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sockets.m4 @@ -0,0 +1,17 @@ +# sockets.m4 serial 7 +dnl Copyright (C) 2008-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_SOCKETS], +[ + AC_REQUIRE([AC_C_INLINE]) + AC_REQUIRE([gl_SOCKETLIB]) + gl_PREREQ_SOCKETS +]) + +# Prerequisites of lib/sockets.c. +AC_DEFUN([gl_PREREQ_SOCKETS], [ + : +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/socklen.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/socklen.m4 new file mode 100644 index 00000000..9c46db18 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/socklen.m4 @@ -0,0 +1,76 @@ +# socklen.m4 serial 11 +dnl Copyright (C) 2005-2007, 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Albert Chin, Windows fixes from Simon Josefsson. + +dnl Check for socklen_t: historically on BSD it is an int, and in +dnl POSIX 1g it is a type of its own, but some platforms use different +dnl types for the argument to getsockopt, getpeername, etc.: +dnl HP-UX 10.20, IRIX 6.5, OSF/1 4.0, Interix 3.5, BeOS. +dnl So we have to test to find something that will work. + +AC_DEFUN([gl_TYPE_SOCKLEN_T], + [AC_REQUIRE([gl_CHECK_SOCKET_HEADERS])dnl + AC_CHECK_TYPE([socklen_t], , + [AC_CACHE_CHECK([for socklen_t equivalent], + [gl_cv_socklen_t_equiv], + [# Systems have either "struct sockaddr *" or + # "void *" as the second argument to getpeername + gl_cv_socklen_t_equiv= + for arg2 in "struct sockaddr" void; do + for t in int size_t "unsigned int" "long int" "unsigned long int"; do + AC_COMPILE_IFELSE([AC_LANG_PROGRAM( + [[#include + #include + + int getpeername (int, $arg2 *, $t *);]], + [[$t len; + getpeername (0, 0, &len);]])], + [gl_cv_socklen_t_equiv="$t"]) + test "$gl_cv_socklen_t_equiv" != "" && break + done + test "$gl_cv_socklen_t_equiv" != "" && break + done + if test "$gl_cv_socklen_t_equiv" = ""; then + AC_MSG_ERROR([Cannot find a type to use in place of socklen_t]) + fi + ]) + AC_DEFINE_UNQUOTED([socklen_t], [$gl_cv_socklen_t_equiv], + [type to use in place of socklen_t if not defined])], + [gl_SOCKET_HEADERS])]) + +dnl On mingw32, socklen_t is in ws2tcpip.h ('int'), so we try to find +dnl it there too. But on Cygwin, wc2tcpip.h must not be included. Users +dnl of this module should use the same include pattern as gl_SOCKET_HEADERS. +dnl When you change this macro, keep also in sync: +dnl - gl_CHECK_SOCKET_HEADERS, +dnl - the Include section of modules/socklen. +AC_DEFUN([gl_SOCKET_HEADERS], +[ +/* is not needed according to POSIX, but the + in i386-unknown-freebsd4.10 and + powerpc-apple-darwin5.5 required it. */ +#include +#if HAVE_SYS_SOCKET_H +# include +#elif HAVE_WS2TCPIP_H +# include +#endif +]) + +dnl Tests for the existence of the header for socket facilities. +dnl Defines the C macros HAVE_SYS_SOCKET_H, HAVE_WS2TCPIP_H. +dnl This macro must match gl_SOCKET_HEADERS. +AC_DEFUN([gl_CHECK_SOCKET_HEADERS], + [AC_CHECK_HEADERS_ONCE([sys/socket.h]) + if test $ac_cv_header_sys_socket_h = no; then + dnl We cannot use AC_CHECK_HEADERS_ONCE here, because that would make + dnl the check for those headers unconditional; yet cygwin reports + dnl that the headers are present but cannot be compiled (since on + dnl cygwin, all socket information should come from sys/socket.h). + AC_CHECK_HEADERS([ws2tcpip.h]) + fi + ]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sockpfaf.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sockpfaf.m4 new file mode 100644 index 00000000..390abfe2 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sockpfaf.m4 @@ -0,0 +1,84 @@ +# sockpfaf.m4 serial 10 +dnl Copyright (C) 2004, 2006, 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl Test for some common socket protocol families (PF_INET, PF_INET6, ...) +dnl and some common address families (AF_INET, AF_INET6, ...). +dnl This test assumes that a system supports an address family if and only if +dnl it supports the corresponding protocol family. + +dnl From Bruno Haible. + +AC_DEFUN([gl_SOCKET_FAMILIES], +[ + AC_REQUIRE([gl_SYS_SOCKET_H]) + AC_CHECK_HEADERS_ONCE([netinet/in.h]) + + AC_CACHE_CHECK([for IPv4 sockets], + [gl_cv_socket_ipv4], + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +#ifdef HAVE_NETINET_IN_H +#include +#endif +#ifdef HAVE_WINSOCK2_H +#include +#endif]], +[[int x = AF_INET; struct in_addr y; struct sockaddr_in z; + if (&x && &y && &z) return 0;]])], + gl_cv_socket_ipv4=yes, gl_cv_socket_ipv4=no)]) + if test $gl_cv_socket_ipv4 = yes; then + AC_DEFINE([HAVE_IPV4], [1], [Define to 1 if defines AF_INET.]) + fi + + AC_CACHE_CHECK([for IPv6 sockets], + [gl_cv_socket_ipv6], + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +#ifdef HAVE_NETINET_IN_H +#include +#endif +#ifdef HAVE_WINSOCK2_H +#include +#endif +#ifdef HAVE_WS2TCPIP_H +#include +#endif]], +[[int x = AF_INET6; struct in6_addr y; struct sockaddr_in6 z; + if (&x && &y && &z) return 0;]])], + gl_cv_socket_ipv6=yes, gl_cv_socket_ipv6=no)]) + if test $gl_cv_socket_ipv6 = yes; then + AC_DEFINE([HAVE_IPV6], [1], [Define to 1 if defines AF_INET6.]) + fi +]) + +AC_DEFUN([gl_SOCKET_FAMILY_UNIX], +[ + AC_REQUIRE([gl_SYS_SOCKET_H]) + AC_CHECK_HEADERS_ONCE([sys/un.h]) + + AC_CACHE_CHECK([for UNIX domain sockets], + [gl_cv_socket_unix], + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +#ifdef HAVE_SYS_UN_H +#include +#endif +#ifdef HAVE_WINSOCK2_H +#include +#endif]], +[[int x = AF_UNIX; struct sockaddr_un y; + if (&x && &y) return 0;]])], + gl_cv_socket_unix=yes, gl_cv_socket_unix=no)]) + if test $gl_cv_socket_unix = yes; then + AC_DEFINE([HAVE_UNIXSOCKET], [1], [Define to 1 if defines AF_UNIX.]) + fi +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/ssize_t.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/ssize_t.m4 new file mode 100644 index 00000000..25b28d77 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/ssize_t.m4 @@ -0,0 +1,37 @@ +# ssize_t.m4 serial 6 +dnl Copyright (C) 2001-2003, 2006, 2010-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. +dnl Define ssize_t if it does not already exist. + +AC_DEFUN([gt_TYPE_SSIZE_T], +[ + AC_CACHE_CHECK([for ssize_t], [gl_cv_ssize_t], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include ]], + [[int x = sizeof (ssize_t *) + sizeof (ssize_t); + return !x;]])], + [gl_cv_ssize_t=yes], [gl_cv_ssize_t=no])]) + if test $gl_cv_ssize_t = no; then + dnl On 64-bit native Windows, ssize_t needs to be defined as 'long long', + dnl for consistency with the 64-bit size_t. + AC_CACHE_CHECK([whether size_t is wider than 'long'], [gl_cv_size_t_large], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include + typedef int array [2 * (sizeof (size_t) > sizeof (long)) - 1]; + ]])], + [gl_cv_size_t_large=yes], [gl_cv_size_t_large=no])]) + if test $gl_cv_size_t_large = yes; then + gl_def_ssize_t='long long' + else + gl_def_ssize_t='long' + fi + AC_DEFINE_UNQUOTED([ssize_t], [$gl_def_ssize_t], + [Define as a signed type of the same size as size_t.]) + fi +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/stack-direction.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/stack-direction.m4 new file mode 100644 index 00000000..69bafe15 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/stack-direction.m4 @@ -0,0 +1,125 @@ +# stack-direction.m4 serial 11 +dnl Copyright (C) 2002-2024 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl Written by Bruno Haible. + +# Determine the stack direction. Define the C macro STACK_DIRECTION. +AC_DEFUN([SV_STACK_DIRECTION], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_CACHE_CHECK([for stack direction], [sv_cv_stack_direction_msg], [ + case "$host_cpu" in + dnl See the #define STACK_GROWS_DOWNWARD in gcc-3.1/gcc/config/*/*.h. + a29k | \ + aarch64* | \ + alpha* | \ + arc | arceb | arc32 | arc64 | \ + arm* | strongarm* | xscale* | \ + avr | avr32 | \ + bfin | \ + c1 | c2 | c32 | c34 | c38 | \ + clipper | \ + cr16 | \ + cris | \ + csky | \ + d30v | \ + epiphany | \ + elxsi | \ + fr30 | \ + frv | \ + ft32 | \ + h8300 | \ + i?86 | x86_64 | \ + i860 | \ + ia64 | \ + iq2000 | \ + lm32 | \ + loongarch* | \ + m32c | \ + m32r | \ + m68* | \ + m88k | \ + mcore | \ + microblaze* | \ + mips* | \ + mmix | \ + mn10200 | \ + mn10300 | \ + moxie | \ + msp430 | \ + nds32* | \ + nios2 | nios2eb | nios2el | \ + ns32k | \ + nvptx | \ + or1k | \ + pdp11 | \ + pj* | \ + powerpc* | rs6000 | \ + pru | \ + riscv* | \ + rl78 | \ + romp | \ + rx | \ + s390* | \ + sh* | \ + sparc* | \ + tic6x | \ + tilegx | \ + tilepro | \ + v850 | \ + vax | \ + visium | \ + xtensa) + sv_cv_stack_direction=-1 ;; + c4x | \ + dsp16xx | \ + i960 | \ + hppa* | parisc* | \ + stormy16 | \ + we32k) + sv_cv_stack_direction=1 ;; + *) + if test $cross_compiling = no; then + cat > conftest.c < +int +find_stack_direction (int *addr, int depth) +{ + int dir, dummy = 0; + if (! addr) + addr = &dummy; + *addr = addr < &dummy ? 1 : addr == &dummy ? 0 : -1; + dir = depth ? find_stack_direction (addr, depth - 1) : 0; + return dir + dummy; +} +int +main (int argc, char *argv[[]]) +{ + printf ("%d\n", find_stack_direction (NULL, argc + 20)); + return 0; +} +EOF + AC_TRY_EVAL([ac_link]) + sv_cv_stack_direction=`./conftest` + else + sv_cv_stack_direction=0 + fi + ;; + esac + case $sv_cv_stack_direction in + 1) sv_cv_stack_direction_msg="grows up";; + -1) sv_cv_stack_direction_msg="grows down";; + *) sv_cv_stack_direction_msg="unknown";; + esac + ]) + AC_DEFINE_UNQUOTED([STACK_DIRECTION], [$sv_cv_stack_direction], + [Define as the direction of stack growth for your system. + STACK_DIRECTION > 0 => grows toward higher addresses + STACK_DIRECTION < 0 => grows toward lower addresses + STACK_DIRECTION = 0 => spaghetti stack.]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/stat-time.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/stat-time.m4 new file mode 100644 index 00000000..8bec2f5f --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/stat-time.m4 @@ -0,0 +1,83 @@ +# Checks for stat-related time functions. + +# Copyright (C) 1998-1999, 2001, 2003, 2005-2007, 2009-2024 Free Software +# Foundation, Inc. + +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +dnl From Paul Eggert. + +# st_atim.tv_nsec - Linux, Solaris, Cygwin +# st_atimespec.tv_nsec - FreeBSD, NetBSD, if ! defined _POSIX_SOURCE +# st_atimensec - FreeBSD, NetBSD, if defined _POSIX_SOURCE +# st_atim.st__tim.tv_nsec - UnixWare (at least 2.1.2 through 7.1) + +# st_birthtimespec - FreeBSD, NetBSD (hidden on OpenBSD 3.9, anyway) +# st_birthtim - Cygwin 1.7.0+ + +AC_DEFUN([gl_STAT_TIME], +[ + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + AC_CHECK_HEADERS_ONCE([sys/time.h]) + + AC_CHECK_MEMBERS([struct stat.st_atim.tv_nsec], + [AC_CACHE_CHECK([whether struct stat.st_atim is of type struct timespec], + [ac_cv_typeof_struct_stat_st_atim_is_struct_timespec], + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM( + [[ + #include + #include + #if HAVE_SYS_TIME_H + # include + #endif + #include + struct timespec ts; + struct stat st; + ]], + [[ + st.st_atim = ts; + ]])], + [ac_cv_typeof_struct_stat_st_atim_is_struct_timespec=yes], + [ac_cv_typeof_struct_stat_st_atim_is_struct_timespec=no])]) + if test $ac_cv_typeof_struct_stat_st_atim_is_struct_timespec = yes; then + AC_DEFINE([TYPEOF_STRUCT_STAT_ST_ATIM_IS_STRUCT_TIMESPEC], [1], + [Define to 1 if the type of the st_atim member of a struct stat is + struct timespec.]) + fi], + [AC_CHECK_MEMBERS([struct stat.st_atimespec.tv_nsec], [], + [AC_CHECK_MEMBERS([struct stat.st_atimensec], [], + [AC_CHECK_MEMBERS([struct stat.st_atim.st__tim.tv_nsec], [], [], + [#include + #include ])], + [#include + #include ])], + [#include + #include ])], + [#include + #include ]) +]) + +# Check for st_birthtime, a feature from UFS2 (FreeBSD, NetBSD, OpenBSD, etc.) +# and NTFS (Cygwin). +# There was a time when this field was named st_createtime (21 June +# 2002 to 16 July 2002) But that window is very small and applied only +# to development code, so systems still using that configuration are +# not supported. See revisions 1.10 and 1.11 of FreeBSD's +# src/sys/ufs/ufs/dinode.h. +# +AC_DEFUN([gl_STAT_BIRTHTIME], +[ + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + AC_CHECK_HEADERS_ONCE([sys/time.h]) + AC_CHECK_MEMBERS([struct stat.st_birthtimespec.tv_nsec], [], + [AC_CHECK_MEMBERS([struct stat.st_birthtimensec], [], + [AC_CHECK_MEMBERS([struct stat.st_birthtim.tv_nsec], [], [], + [#include + #include ])], + [#include + #include ])], + [#include + #include ]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/stat.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/stat.m4 new file mode 100644 index 00000000..1d2a9e2c --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/stat.m4 @@ -0,0 +1,87 @@ +# serial 21 + +# Copyright (C) 2009-2024 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_STAT], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS]) + AC_CHECK_FUNCS_ONCE([lstat]) + case "$host_os" in + mingw* | windows*) + dnl On this platform, the original stat() returns st_atime, st_mtime, + dnl st_ctime values that are affected by the time zone. + REPLACE_STAT=1 + ;; + *) + dnl AIX 7.1, Solaris 9, mingw64 mistakenly succeed on stat("file/"). + dnl (For mingw, this is due to a broken stat() override in libmingwex.a.) + dnl FreeBSD 7.2 mistakenly succeeds on stat("link-to-file/"). + AC_CACHE_CHECK([whether stat handles trailing slashes on files], + [gl_cv_func_stat_file_slash], + [touch conftest.tmp + # Assume that if we have lstat, we can also check symlinks. + if test $ac_cv_func_lstat = yes; then + ln -s conftest.tmp conftest.lnk + fi + AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [[#include +]], [[int result = 0; + struct stat st; + if (!stat ("conftest.tmp/", &st)) + result |= 1; +#if HAVE_LSTAT + if (!stat ("conftest.lnk/", &st)) + result |= 2; +#endif + return result; + ]])], + [gl_cv_func_stat_file_slash=yes], [gl_cv_func_stat_file_slash=no], + [case "$host_os" in + # Guess yes on Linux systems. + linux-* | linux) gl_cv_func_stat_file_slash="guessing yes" ;; + # Guess yes on systems that emulate the Linux system calls. + midipix*) gl_cv_func_stat_file_slash="guessing yes" ;; + # Guess yes on glibc systems. + *-gnu* | gnu*) gl_cv_func_stat_file_slash="guessing yes" ;; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_stat_file_slash="$gl_cross_guess_normal" ;; + esac + ]) + rm -f conftest.tmp conftest.lnk]) + case $gl_cv_func_stat_file_slash in + *no) + REPLACE_STAT=1 + AC_DEFINE([REPLACE_FUNC_STAT_FILE], [1], [Define to 1 if stat needs + help when passed a file name with a trailing slash]);; + esac + case $host_os in + dnl macOS and Solaris stat can return a negative tv_nsec. + darwin* | solaris*) + REPLACE_FSTAT=1 ;; + esac + ;; + esac +]) + +# Prerequisites of lib/stat.c and lib/stat-w32.c. +AC_DEFUN([gl_PREREQ_STAT], [ + AC_REQUIRE([gl_SYS_STAT_H]) + AC_REQUIRE([gl_PREREQ_STAT_W32]) + : +]) + +# Prerequisites of lib/stat-w32.c. +AC_DEFUN([gl_PREREQ_STAT_W32], [ + AC_REQUIRE([AC_CANONICAL_HOST]) + case "$host_os" in + mingw* | windows*) + AC_CHECK_HEADERS([sdkddkver.h]) + ;; + esac +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/std-gnu11.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/std-gnu11.m4 new file mode 100644 index 00000000..59998c17 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/std-gnu11.m4 @@ -0,0 +1,829 @@ +# Prefer GNU C11 and C++11 to earlier versions. -*- coding: utf-8 -*- + +# This implementation is taken from GNU Autoconf lib/autoconf/c.m4 +# commit 017d5ddd82854911f0119691d91ea8a1438824d6 +# dated Sun Apr 3 13:57:17 2016 -0700 +# This implementation will be obsolete once we can assume Autoconf 2.70 +# or later is installed everywhere a Gnulib program might be developed. + +m4_version_prereq([2.70], [], [ + + +# Copyright (C) 2001-2024 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 . + +# Written by David MacKenzie, with help from +# Akim Demaille, Paul Eggert, +# François Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor, +# Roland McGrath, Noah Friedman, david d zuhn, and many others. + + +# AC_PROG_CC([COMPILER ...]) +# -------------------------- +# COMPILER ... is a space separated list of C compilers to search for. +# This just gives the user an opportunity to specify an alternative +# search list for the C compiler. +AC_DEFUN_ONCE([AC_PROG_CC], +[AC_LANG_PUSH(C)dnl +AC_ARG_VAR([CC], [C compiler command])dnl +AC_ARG_VAR([CFLAGS], [C compiler flags])dnl +_AC_ARG_VAR_LDFLAGS()dnl +_AC_ARG_VAR_LIBS()dnl +_AC_ARG_VAR_CPPFLAGS()dnl +m4_ifval([$1], + [AC_CHECK_TOOLS(CC, [$1])], +[AC_CHECK_TOOL(CC, gcc) +if test -z "$CC"; then + dnl Here we want: + dnl AC_CHECK_TOOL(CC, cc) + dnl but without the check for a tool without the prefix. + dnl Until the check is removed from there, copy the code: + if test -n "$ac_tool_prefix"; then + AC_CHECK_PROG(CC, [${ac_tool_prefix}cc], [${ac_tool_prefix}cc]) + fi +fi +if test -z "$CC"; then + AC_CHECK_PROG(CC, cc, cc, , , /usr/ucb/cc) +fi +if test -z "$CC"; then + AC_CHECK_TOOLS(CC, cl.exe) +fi +if test -z "$CC"; then + AC_CHECK_TOOL(CC, clang) +fi +]) + +test -z "$CC" && AC_MSG_FAILURE([no acceptable C compiler found in \$PATH]) + +# Provide some information about the compiler. +_AS_ECHO_LOG([checking for _AC_LANG compiler version]) +set X $ac_compile +ac_compiler=$[2] +for ac_option in --version -v -V -qversion -version; do + _AC_DO_LIMIT([$ac_compiler $ac_option >&AS_MESSAGE_LOG_FD]) +done + +m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl +m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl +_AC_LANG_COMPILER_GNU +if test $ac_compiler_gnu = yes; then + GCC=yes +else + GCC= +fi +_AC_PROG_CC_G +dnl +dnl Set ac_prog_cc_stdc to the supported C version. +dnl Also set the documented variable ac_cv_prog_cc_stdc; +dnl its name was chosen when it was cached, but it is no longer cached. +_AC_PROG_CC_C11([ac_prog_cc_stdc=c11 + ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c11], + [_AC_PROG_CC_C99([ac_prog_cc_stdc=c99 + ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c99], + [_AC_PROG_CC_C89([ac_prog_cc_stdc=c89 + ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c89], + [ac_prog_cc_stdc=no + ac_cv_prog_cc_stdc=no])])]) +dnl +AC_LANG_POP(C)dnl +])# AC_PROG_CC + + + +# AC_PROG_CXX([LIST-OF-COMPILERS]) +# -------------------------------- +# LIST-OF-COMPILERS is a space separated list of C++ compilers to search +# for (if not specified, a default list is used). This just gives the +# user an opportunity to specify an alternative search list for the C++ +# compiler. +# aCC HP-UX C++ compiler much better than `CC', so test before. +# FCC Fujitsu C++ compiler +# KCC KAI C++ compiler +# RCC Rational C++ +# xlC_r AIX C Set++ (with support for reentrant code) +# xlC AIX C Set++ +AC_DEFUN([AC_PROG_CXX], +[AC_LANG_PUSH(C++)dnl +AC_ARG_VAR([CXX], [C++ compiler command])dnl +AC_ARG_VAR([CXXFLAGS], [C++ compiler flags])dnl +_AC_ARG_VAR_LDFLAGS()dnl +_AC_ARG_VAR_LIBS()dnl +_AC_ARG_VAR_CPPFLAGS()dnl +_AC_ARG_VAR_PRECIOUS([CCC])dnl +if test -z "$CXX"; then + if test -n "$CCC"; then + CXX=$CCC + else + AC_CHECK_TOOLS(CXX, + [m4_default([$1], + [g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC clang++])], + g++) + fi +fi +# Provide some information about the compiler. +_AS_ECHO_LOG([checking for _AC_LANG compiler version]) +set X $ac_compile +ac_compiler=$[2] +for ac_option in --version -v -V -qversion; do + _AC_DO_LIMIT([$ac_compiler $ac_option >&AS_MESSAGE_LOG_FD]) +done + +m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl +m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl +_AC_LANG_COMPILER_GNU +if test $ac_compiler_gnu = yes; then + GXX=yes +else + GXX= +fi +_AC_PROG_CXX_G +_AC_PROG_CXX_CXX11([ac_prog_cxx_stdcxx=cxx11 + ac_cv_prog_cxx_stdcxx=$ac_cv_prog_cxx_cxx11 + ac_cv_prog_cxx_cxx98=$ac_cv_prog_cxx_cxx11], + [_AC_PROG_CXX_CXX98([ac_prog_cxx_stdcxx=cxx98 + ac_cv_prog_cxx_stdcxx=$ac_cv_prog_cxx_cxx98], + [ac_prog_cxx_stdcxx=no + ac_cv_prog_cxx_stdcxx=no])]) +AC_LANG_POP(C++)dnl +])# AC_PROG_CXX + + +# _AC_C_STD_TRY(STANDARD, TEST-PROLOGUE, TEST-BODY, OPTION-LIST, +# ACTION-IF-AVAILABLE, ACTION-IF-UNAVAILABLE) +# -------------------------------------------------------------- +# Check whether the C compiler accepts features of STANDARD (e.g `c89', `c99') +# by trying to compile a program of TEST-PROLOGUE and TEST-BODY. If this fails, +# try again with each compiler option in the space-separated OPTION-LIST; if one +# helps, append it to CC. If eventually successful, run ACTION-IF-AVAILABLE, +# else ACTION-IF-UNAVAILABLE. +AC_DEFUN([_AC_C_STD_TRY], +[AC_MSG_CHECKING([for $CC option to enable ]m4_translit($1, [c], [C])[ features]) +AC_CACHE_VAL(ac_cv_prog_cc_$1, +[ac_cv_prog_cc_$1=no +ac_save_CC=$CC +AC_LANG_CONFTEST([AC_LANG_PROGRAM([$2], [$3])]) +for ac_arg in '' $4 +do + CC="$ac_save_CC $ac_arg" + _AC_COMPILE_IFELSE([], [ac_cv_prog_cc_$1=$ac_arg]) + test "x$ac_cv_prog_cc_$1" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC +])# AC_CACHE_VAL +ac_prog_cc_stdc_options= +case "x$ac_cv_prog_cc_$1" in + x) + AC_MSG_RESULT([none needed]) ;; + xno) + AC_MSG_RESULT([unsupported]) ;; + *) + ac_prog_cc_stdc_options=" $ac_cv_prog_cc_$1" + CC=$CC$ac_prog_cc_stdc_options + AC_MSG_RESULT([$ac_cv_prog_cc_$1]) ;; +esac +AS_IF([test "x$ac_cv_prog_cc_$1" != xno], [$5], [$6]) +])# _AC_C_STD_TRY + +# _AC_C_C99_TEST_HEADER +# --------------------- +# A C header suitable for testing for C99. +AC_DEFUN([_AC_C_C99_TEST_HEADER], +[[#include +#include +#include +#include +#include +#include + +// Check varargs macros. These examples are taken from C99 6.10.3.5. +#define debug(...) fprintf (stderr, __VA_ARGS__) +#define showlist(...) puts (#__VA_ARGS__) +#define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__)) +static void +test_varargs_macros (void) +{ + int x = 1234; + int y = 5678; + debug ("Flag"); + debug ("X = %d\n", x); + showlist (The first, second, and third items.); + report (x>y, "x is %d but y is %d", x, y); +} + +// Check long long types. +#define BIG64 18446744073709551615ull +#define BIG32 4294967295ul +#define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0) +#if !BIG_OK + your preprocessor is broken; +#endif +#if BIG_OK +#else + your preprocessor is broken; +#endif +static long long int bignum = -9223372036854775807LL; +static unsigned long long int ubignum = BIG64; + +struct incomplete_array +{ + int datasize; + double data[]; +}; + +struct named_init { + int number; + const wchar_t *name; + double average; +}; + +typedef const char *ccp; + +static inline int +test_restrict (ccp restrict text) +{ + // See if C++-style comments work. + // Iterate through items via the restricted pointer. + // Also check for declarations in for loops. + for (unsigned int i = 0; *(text+i) != '\0'; ++i) + continue; + return 0; +} + +// Check varargs and va_copy. +static bool +test_varargs (const char *format, ...) +{ + va_list args; + va_start (args, format); + va_list args_copy; + va_copy (args_copy, args); + + const char *str = ""; + int number = 0; + float fnumber = 0; + + while (*format) + { + switch (*format++) + { + case 's': // string + str = va_arg (args_copy, const char *); + break; + case 'd': // int + number = va_arg (args_copy, int); + break; + case 'f': // float + fnumber = va_arg (args_copy, double); + break; + default: + break; + } + } + va_end (args_copy); + va_end (args); + + return *str && number && fnumber; +}]])# _AC_C_C99_TEST_HEADER + +# _AC_C_C99_TEST_BODY +# ------------------- +# A C body suitable for testing for C99, assuming the corresponding header. +AC_DEFUN([_AC_C_C99_TEST_BODY], +[[ + // Check bool. + _Bool success = false; + + // Check restrict. + if (test_restrict ("String literal") == 0) + success = true; + char *restrict newvar = "Another string"; + + // Check varargs. + success &= test_varargs ("s, d' f .", "string", 65, 34.234); + test_varargs_macros (); + + // Check flexible array members. + struct incomplete_array *ia = + malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10)); + ia->datasize = 10; + for (int i = 0; i < ia->datasize; ++i) + ia->data[i] = i * 1.234; + + // Check named initializers. + struct named_init ni = { + .number = 34, + .name = L"Test wide string", + .average = 543.34343, + }; + + ni.number = 58; + + int dynamic_array[ni.number]; + dynamic_array[ni.number - 1] = 543; + + // work around unused variable warnings + return (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == 'x' + || dynamic_array[ni.number - 1] != 543); +]]) + +# _AC_PROG_CC_C99 ([ACTION-IF-AVAILABLE], [ACTION-IF-UNAVAILABLE]) +# ---------------------------------------------------------------- +# If the C compiler is not in ISO C99 mode by default, try to add an +# option to output variable CC to make it so. This macro tries +# various options that select ISO C99 on some system or another. It +# considers the compiler to be in ISO C99 mode if it handles _Bool, +# // comments, flexible array members, inline, long long int, mixed +# code and declarations, named initialization of structs, restrict, +# va_copy, varargs macros, variable declarations in for loops and +# variable length arrays. +AC_DEFUN([_AC_PROG_CC_C99], +[_AC_C_STD_TRY([c99], +[_AC_C_C99_TEST_HEADER], +[_AC_C_C99_TEST_BODY], +dnl Try +dnl GCC -std=gnu99 (unused restrictive modes: -std=c99 -std=iso9899:1999) +dnl IBM XL C -qlanglvl=extc1x (V12.1; does not pass C11 test) +dnl IBM XL C -qlanglvl=extc99 +dnl (pre-V12.1; unused restrictive mode: -qlanglvl=stdc99) +dnl HP cc -AC99 +dnl Intel ICC -std=c99, -c99 (deprecated) +dnl IRIX -c99 +dnl Solaris -D_STDC_C99= +dnl cc's -xc99 option uses linker magic to define the external +dnl symbol __xpg4 as if by "int __xpg4 = 1;", which enables C99 +dnl behavior for C library functions. This is not wanted here, +dnl because it means that a single module compiled with -xc99 +dnl alters C runtime behavior for the entire program, not for +dnl just the module. Instead, define the (private) symbol +dnl _STDC_C99, which suppresses a bogus failure in . +dnl The resulting compiler passes the test case here, and that's +dnl good enough. For more, please see the thread starting at: +dnl https://lists.gnu.org/r/autoconf/2010-12/msg00059.html +dnl Tru64 -c99 +dnl with extended modes being tried first. +[[-std=gnu99 -std=c99 -c99 -AC99 -D_STDC_C99= -qlanglvl=extc1x -qlanglvl=extc99]], [$1], [$2])[]dnl +])# _AC_PROG_CC_C99 + + +# _AC_PROG_CC_C11 ([ACTION-IF-AVAILABLE], [ACTION-IF-UNAVAILABLE]) +# ---------------------------------------------------------------- +# If the C compiler is not in ISO C11 mode by default, try to add an +# option to output variable CC to make it so. This macro tries +# various options that select ISO C11 on some system or another. It +# considers the compiler to be in ISO C11 mode if it handles _Alignas, +# _Alignof, _Noreturn, _Static_assert, UTF-8 string literals, +# duplicate typedefs, and anonymous structures and unions. +AC_DEFUN([_AC_PROG_CC_C11], +[_AC_C_STD_TRY([c11], +[_AC_C_C99_TEST_HEADER[ +// Check _Alignas. +char _Alignas (double) aligned_as_double; +char _Alignas (0) no_special_alignment; +extern char aligned_as_int; +char _Alignas (0) _Alignas (int) aligned_as_int; + +// Check _Alignof. +enum +{ + int_alignment = _Alignof (int), + int_array_alignment = _Alignof (int[100]), + char_alignment = _Alignof (char) +}; +_Static_assert (0 < -_Alignof (int), "_Alignof is signed"); + +// Check _Noreturn. +int _Noreturn does_not_return (void) { for (;;) continue; } + +// Check _Static_assert. +struct test_static_assert +{ + int x; + _Static_assert (sizeof (int) <= sizeof (long int), + "_Static_assert does not work in struct"); + long int y; +}; + +// Check UTF-8 literals. +#define u8 syntax error! +char const utf8_literal[] = u8"happens to be ASCII" "another string"; + +// Check duplicate typedefs. +typedef long *long_ptr; +typedef long int *long_ptr; +typedef long_ptr long_ptr; + +// Anonymous structures and unions -- taken from C11 6.7.2.1 Example 1. +struct anonymous +{ + union { + struct { int i; int j; }; + struct { int k; long int l; } w; + }; + int m; +} v1; +]], +[_AC_C_C99_TEST_BODY[ + v1.i = 2; + v1.w.k = 5; + _Static_assert ((offsetof (struct anonymous, i) + == offsetof (struct anonymous, w.k)), + "Anonymous union alignment botch"); +]], +dnl Try +dnl GCC -std=gnu11 (unused restrictive mode: -std=c11) +dnl with extended modes being tried first. +dnl +dnl Do not try -qlanglvl=extc1x, because IBM XL C V12.1 (the latest version as +dnl of September 2012) does not pass the C11 test. For now, try extc1x when +dnl compiling the C99 test instead, since it enables _Static_assert and +dnl _Noreturn, which is a win. If -qlanglvl=extc11 or -qlanglvl=extc1x passes +dnl the C11 test in some future version of IBM XL C, we'll add it here, +dnl preferably extc11. +[[-std=gnu11]], [$1], [$2])[]dnl +])# _AC_PROG_CC_C11 + + +# AC_PROG_CC_C89 +# -------------- +# Do not use AU_ALIAS here and in AC_PROG_CC_C99 and AC_PROG_CC_STDC, +# as that'd be incompatible with how Automake redefines AC_PROG_CC. See +# . +AU_DEFUN([AC_PROG_CC_C89], + [AC_REQUIRE([AC_PROG_CC])], + [$0 is obsolete; use AC_PROG_CC] +) + +# AC_PROG_CC_C99 +# -------------- +AU_DEFUN([AC_PROG_CC_C99], + [AC_REQUIRE([AC_PROG_CC])], + [$0 is obsolete; use AC_PROG_CC] +) + +# AC_PROG_CC_STDC +# --------------- +AU_DEFUN([AC_PROG_CC_STDC], + [AC_REQUIRE([AC_PROG_CC])], + [$0 is obsolete; use AC_PROG_CC] +) + + +# AC_C_PROTOTYPES +# --------------- +# Check if the C compiler supports prototypes, included if it needs +# options. +AC_DEFUN([AC_C_PROTOTYPES], +[AC_REQUIRE([AC_PROG_CC])dnl +if test "$ac_prog_cc_stdc" != no; then + AC_DEFINE(PROTOTYPES, 1, + [Define to 1 if the C compiler supports function prototypes.]) + AC_DEFINE(__PROTOTYPES, 1, + [Define like PROTOTYPES; this can be used by system headers.]) +fi +])# AC_C_PROTOTYPES + + +# _AC_CXX_STD_TRY(STANDARD, TEST-PROLOGUE, TEST-BODY, OPTION-LIST, +# ACTION-IF-AVAILABLE, ACTION-IF-UNAVAILABLE) +# ---------------------------------------------------------------- +# Check whether the C++ compiler accepts features of STANDARD (e.g +# `cxx98', `cxx11') by trying to compile a program of TEST-PROLOGUE +# and TEST-BODY. If this fails, try again with each compiler option +# in the space-separated OPTION-LIST; if one helps, append it to CXX. +# If eventually successful, run ACTION-IF-AVAILABLE, else +# ACTION-IF-UNAVAILABLE. +AC_DEFUN([_AC_CXX_STD_TRY], +[AC_MSG_CHECKING([for $CXX option to enable ]m4_translit(m4_translit($1, [x], [+]), [a-z], [A-Z])[ features]) +AC_LANG_PUSH(C++)dnl +AC_CACHE_VAL(ac_cv_prog_cxx_$1, +[ac_cv_prog_cxx_$1=no +ac_save_CXX=$CXX +AC_LANG_CONFTEST([AC_LANG_PROGRAM([$2], [$3])]) +for ac_arg in '' $4 +do + CXX="$ac_save_CXX $ac_arg" + _AC_COMPILE_IFELSE([], [ac_cv_prog_cxx_$1=$ac_arg]) + test "x$ac_cv_prog_cxx_$1" != "xno" && break +done +rm -f conftest.$ac_ext +CXX=$ac_save_CXX +])# AC_CACHE_VAL +ac_prog_cxx_stdcxx_options= +case "x$ac_cv_prog_cxx_$1" in + x) + AC_MSG_RESULT([none needed]) ;; + xno) + AC_MSG_RESULT([unsupported]) ;; + *) + ac_prog_cxx_stdcxx_options=" $ac_cv_prog_cxx_$1" + CXX=$CXX$ac_prog_cxx_stdcxx_options + AC_MSG_RESULT([$ac_cv_prog_cxx_$1]) ;; +esac +AC_LANG_POP(C++)dnl +AS_IF([test "x$ac_cv_prog_cxx_$1" != xno], [$5], [$6]) +])# _AC_CXX_STD_TRY + +# _AC_CXX_CXX98_TEST_HEADER +# ------------------------- +# A C++ header suitable for testing for CXX98. +AC_DEFUN([_AC_CXX_CXX98_TEST_HEADER], +[[ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace test { + typedef std::vector string_vec; + typedef std::pair map_value; + typedef std::map map_type; + typedef std::set set_type; + + template + class printer { + public: + printer(std::ostringstream& os): os(os) {} + void operator() (T elem) { os << elem << std::endl; } + private: + std::ostringstream& os; + }; +} +]])# _AC_CXX_CXX98_TEST_HEADER + +# _AC_CXX_CXX98_TEST_BODY +# ----------------------- +# A C++ body suitable for testing for CXX98, assuming the corresponding header. +AC_DEFUN([_AC_CXX_CXX98_TEST_BODY], +[[ + +try { + // Basic string. + std::string teststr("ASCII text"); + teststr += " string"; + + // Simple vector. + test::string_vec testvec; + testvec.push_back(teststr); + testvec.push_back("foo"); + testvec.push_back("bar"); + if (testvec.size() != 3) { + throw std::runtime_error("vector size is not 1"); + } + + // Dump vector into stringstream and obtain string. + std::ostringstream os; + for (test::string_vec::const_iterator i = testvec.begin(); + i != testvec.end(); ++i) { + if (i + 1 != testvec.end()) { + os << teststr << '\n'; + } + } + // Check algorithms work. + std::for_each(testvec.begin(), testvec.end(), test::printer(os)); + std::string os_out = os.str(); + + // Test pair and map. + test::map_type testmap; + testmap.insert(std::make_pair(std::string("key"), + std::make_pair(53,false))); + + // Test set. + int values[] = {9, 7, 13, 15, 4, 18, 12, 10, 5, 3, 14, 19, 17, 8, 6, 20, 16, 2, 11, 1}; + test::set_type testset(values, values + sizeof(values)/sizeof(values[0])); + std::list testlist(testset.begin(), testset.end()); + std::copy(testset.begin(), testset.end(), std::back_inserter(testlist)); +} catch (const std::exception& e) { + std::cerr << "Caught exception: " << e.what() << std::endl; + + // Test fstream + std::ofstream of("test.txt"); + of << "Test ASCII text\n" << std::flush; + of << "N= " << std::hex << std::setw(8) << std::left << 534 << std::endl; + of.close(); +} +std::exit(0); +]]) + +# _AC_CXX_CXX11_TEST_HEADER +# ------------------------- +# A C++ header suitable for testing for CXX11. +AC_DEFUN([_AC_CXX_CXX11_TEST_HEADER], +[[ +#include +#include +#include +#include +#include +#include +#include + +namespace cxx11test +{ + typedef std::shared_ptr sptr; + typedef std::weak_ptr wptr; + + typedef std::tuple tp; + typedef std::array int_array; + + constexpr int get_val() { return 20; } + + struct testinit + { + int i; + double d; + }; + + class delegate { + public: + delegate(int n) : n(n) {} + delegate(): delegate(2354) {} + + virtual int getval() { return this->n; }; + protected: + int n; + }; + + class overridden : public delegate { + public: + overridden(int n): delegate(n) {} + virtual int getval() override final { return this->n * 2; } + }; + + class nocopy { + public: + nocopy(int i): i(i) {} + nocopy() = default; + nocopy(const nocopy&) = delete; + nocopy & operator=(const nocopy&) = delete; + private: + int i; + }; +} +]])# _AC_CXX_CXX11_TEST_HEADER + +# _AC_CXX_CXX11_TEST_BODY +# ----------------------- +# A C++ body suitable for testing for CXX11, assuming the corresponding header. +AC_DEFUN([_AC_CXX_CXX11_TEST_BODY], +[[ +{ + // Test auto and decltype + std::deque d; + d.push_front(43); + d.push_front(484); + d.push_front(3); + d.push_front(844); + int total = 0; + for (auto i = d.begin(); i != d.end(); ++i) { total += *i; } + + auto a1 = 6538; + auto a2 = 48573953.4; + auto a3 = "String literal"; + + decltype(a2) a4 = 34895.034; +} +{ + // Test constexpr + short sa[cxx11test::get_val()] = { 0 }; +} +{ + // Test initializer lists + cxx11test::testinit il = { 4323, 435234.23544 }; +} +{ + // Test range-based for and lambda + cxx11test::int_array array = {9, 7, 13, 15, 4, 18, 12, 10, 5, 3, 14, 19, 17, 8, 6, 20, 16, 2, 11, 1}; + for (int &x : array) { x += 23; } + std::for_each(array.begin(), array.end(), [](int v1){ std::cout << v1; }); +} +{ + using cxx11test::sptr; + using cxx11test::wptr; + + sptr sp(new std::string("ASCII string")); + wptr wp(sp); + sptr sp2(wp); +} +{ + cxx11test::tp tuple("test", 54, 45.53434); + double d = std::get<2>(tuple); + std::string s; + int i; + std::tie(s,i,d) = tuple; +} +{ + static std::regex filename_regex("^_?([a-z0-9_.]+-)+[a-z0-9]+$"); + std::string testmatch("Test if this string matches"); + bool match = std::regex_search(testmatch, filename_regex); +} +{ + cxx11test::int_array array = {9, 7, 13, 15, 4, 18, 12, 10, 5, 3, 14, 19, 17, 8, 6, 20, 16, 2, 11, 1}; + cxx11test::int_array::size_type size = array.size(); +} +{ + // Test constructor delegation + cxx11test::delegate d1; + cxx11test::delegate d2(); + cxx11test::delegate d3(45); +} +{ + // Test override and final + cxx11test::overridden o1(55464); +} +{ + // Test nullptr + char *c = nullptr; +} +{ + // Test template brackets + std::vector> v1; +} +{ + // Unicode literals + char const *utf8 = u8"UTF-8 string \u2500"; + char16_t const *utf16 = u"UTF-8 string \u2500"; + char32_t const *utf32 = U"UTF-32 string \u2500"; +} +]]) + +# _AC_PROG_CXX_CXX98 ([ACTION-IF-AVAILABLE], [ACTION-IF-UNAVAILABLE]) +# ------------------------------------------------------------------- + +# If the C++ compiler is not in ISO C++98 mode by default, try to add +# an option to output variable CXX to make it so. This macro tries +# various options that select ISO C++98 on some system or another. It +# considers the compiler to be in ISO C++98 mode if it handles basic +# features of the std namespace including: string, containers (list, +# map, set, vector), streams (fstreams, iostreams, stringstreams, +# iomanip), pair, exceptions and algorithms. + + +AC_DEFUN([_AC_PROG_CXX_CXX98], +[_AC_CXX_STD_TRY([cxx98], +[_AC_CXX_CXX98_TEST_HEADER], +[_AC_CXX_CXX98_TEST_BODY], +dnl Try +dnl GCC -std=gnu++98 (unused restrictive mode: -std=c++98) +dnl IBM XL C -qlanglvl=extended +dnl HP aC++ -AA +dnl Intel ICC -std=gnu++98 +dnl Solaris N/A (default) +dnl Tru64 N/A (default, but -std gnu could be used) +dnl with extended modes being tried first. +[[-std=gnu++98 -std=c++98 -qlanglvl=extended -AA]], [$1], [$2])[]dnl +])# _AC_PROG_CXX_CXX98 + +# _AC_PROG_CXX_CXX11 ([ACTION-IF-AVAILABLE], [ACTION-IF-UNAVAILABLE]) +# ------------------------------------------------------------------- +# If the C++ compiler is not in ISO CXX11 mode by default, try to add +# an option to output variable CXX to make it so. This macro tries +# various options that select ISO C++11 on some system or another. It +# considers the compiler to be in ISO C++11 mode if it handles all the +# tests from the C++98 checks, plus the following: Language features +# (auto, constexpr, decltype, default/deleted constructors, delegate +# constructors, final, initializer lists, lambda functions, nullptr, +# override, range-based for loops, template brackets without spaces, +# unicode literals) and library features (array, memory (shared_ptr, +# weak_ptr), regex and tuple types). +AC_DEFUN([_AC_PROG_CXX_CXX11], +[_AC_CXX_STD_TRY([cxx11], +[_AC_CXX_CXX11_TEST_HEADER +_AC_CXX_CXX98_TEST_HEADER], +[_AC_CXX_CXX11_TEST_BODY +_AC_CXX_CXX98_TEST_BODY], +dnl Try +dnl GCC -std=gnu++11 (unused restrictive mode: -std=c++11) [and 0x variants] +dnl IBM XL C -qlanglvl=extended0x +dnl (pre-V12.1; unused restrictive mode: -qlanglvl=stdcxx11) +dnl HP aC++ -AA +dnl Intel ICC -std=c++11 -std=c++0x +dnl Solaris N/A (no support) +dnl Tru64 N/A (no support) +dnl with extended modes being tried first. +[[-std=gnu++11 -std=c++11 -std=gnu++0x -std=c++0x -qlanglvl=extended0x -AA]], [$1], [$2])[]dnl +])# _AC_PROG_CXX_CXX11 + + +])# m4_version_prereq diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/stdalign.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/stdalign.m4 new file mode 100644 index 00000000..2efd5f96 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/stdalign.m4 @@ -0,0 +1,206 @@ +# Check for alignas and alignof that conform to C23. + +dnl Copyright 2011-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl Written by Paul Eggert and Bruno Haible. + +# Prepare for substituting if it is not supported. + +AC_DEFUN([gl_ALIGNASOF], +[ + AC_CACHE_CHECK([for alignas and alignof], + [gl_cv_header_working_stdalign_h], + [gl_save_CFLAGS=$CFLAGS + for gl_working in "yes, keywords" "yes, macros"; do + AS_CASE([$gl_working], + [*stdalign.h*], [CFLAGS="$gl_save_CFLAGS -DINCLUDE_STDALIGN_H"]) + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include + #ifdef INCLUDE_STDALIGN_H + #include + #endif + #include + + /* Test that alignof yields a result consistent with offsetof. + This catches GCC bug 52023 + . */ + #ifdef __cplusplus + template struct alignof_helper { char a; t b; }; + # define ao(type) offsetof (alignof_helper, b) + #else + # define ao(type) offsetof (struct { char a; type b; }, b) + #endif + char test_double[ao (double) % _Alignof (double) == 0 ? 1 : -1]; + char test_long[ao (long int) % _Alignof (long int) == 0 ? 1 : -1]; + char test_alignof[alignof (double) == _Alignof (double) ? 1 : -1]; + + /* Test alignas only on platforms where gnulib can help. */ + #if \ + ((defined __cplusplus && 201103 <= __cplusplus) \ + || (__TINYC__ && defined __attribute__) \ + || (defined __APPLE__ && defined __MACH__ \ + ? 4 < __GNUC__ + (1 <= __GNUC_MINOR__) \ + : __GNUC__) \ + || (__ia64 && (61200 <= __HP_cc || 61200 <= __HP_aCC)) \ + || __ICC || 0x590 <= __SUNPRO_C || 0x0600 <= __xlC__ \ + || 1300 <= _MSC_VER) + struct alignas_test { char c; char alignas (8) alignas_8; }; + char test_alignas[offsetof (struct alignas_test, alignas_8) == 8 + ? 1 : -1]; + #endif + ]])], + [gl_cv_header_working_stdalign_h=$gl_working], + [gl_cv_header_working_stdalign_h=no]) + + CFLAGS=$gl_save_CFLAGS + test "$gl_cv_header_working_stdalign_h" != no && break + done]) + + AS_CASE([$gl_cv_header_working_stdalign_h], + [yes*keyword*], + [AC_DEFINE([HAVE_C_ALIGNASOF], [1], + [Define to 1 if the alignas and alignof keywords work.])]) + + dnl The "zz" puts this toward config.h's end, to avoid potential + dnl collisions with other definitions. + AH_VERBATIM([zzalignas], +[#if !defined HAVE_C_ALIGNASOF \ + && !(defined __cplusplus && 201103 <= __cplusplus) \ + && !defined alignof +# if defined HAVE_STDALIGN_H +# include +# endif + +/* ISO C23 alignas and alignof for platforms that lack it. + + References: + ISO C23 (latest free draft + ) + sections 6.5.3.4, 6.7.5, 7.15. + C++11 (latest free draft + ) + section 18.10. */ + +/* alignof (TYPE), also known as _Alignof (TYPE), yields the alignment + requirement of a structure member (i.e., slot or field) that is of + type TYPE, as an integer constant expression. + + This differs from GCC's and clang's __alignof__ operator, which can + yield a better-performing alignment for an object of that type. For + example, on x86 with GCC and on Linux/x86 with clang, + __alignof__ (double) and __alignof__ (long long) are 8, whereas + alignof (double) and alignof (long long) are 4 unless the option + '-malign-double' is used. + + The result cannot be used as a value for an 'enum' constant, if you + want to be portable to HP-UX 10.20 cc and AIX 3.2.5 xlc. */ + +/* GCC releases before GCC 4.9 had a bug in _Alignof. See GCC bug 52023 + . + clang versions < 8.0.0 have the same bug. */ +# if (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 \ + || (defined __GNUC__ && __GNUC__ < 4 + (__GNUC_MINOR__ < 9) \ + && !defined __clang__) \ + || (defined __clang__ && __clang_major__ < 8)) +# undef/**/_Alignof +# ifdef __cplusplus +# if (201103 <= __cplusplus || defined _MSC_VER) +# define _Alignof(type) alignof (type) +# else + template struct __alignof_helper { char __a; __t __b; }; +# if (defined __GNUC__ && 4 <= __GNUC__) || defined __clang__ +# define _Alignof(type) __builtin_offsetof (__alignof_helper, __b) +# else +# define _Alignof(type) offsetof (__alignof_helper, __b) +# endif +# define _GL_STDALIGN_NEEDS_STDDEF 1 +# endif +# else +# if (defined __GNUC__ && 4 <= __GNUC__) || defined __clang__ +# define _Alignof(type) __builtin_offsetof (struct { char __a; type __b; }, __b) +# else +# define _Alignof(type) offsetof (struct { char __a; type __b; }, __b) +# define _GL_STDALIGN_NEEDS_STDDEF 1 +# endif +# endif +# endif +# if ! (defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER)) +# undef/**/alignof +# define alignof _Alignof +# endif + +/* alignas (A), also known as _Alignas (A), aligns a variable or type + to the alignment A, where A is an integer constant expression. For + example: + + int alignas (8) foo; + struct s { int a; int alignas (8) bar; }; + + aligns the address of FOO and the offset of BAR to be multiples of 8. + + A should be a power of two that is at least the type's alignment + and at most the implementation's alignment limit. This limit is + 2**28 on typical GNUish hosts, and 2**13 on MSVC. To be portable + to MSVC through at least version 10.0, A should be an integer + constant, as MSVC does not support expressions such as 1 << 3. + To be portable to Sun C 5.11, do not align auto variables to + anything stricter than their default alignment. + + The following C23 requirements are not supported here: + + - If A is zero, alignas has no effect. + - alignas can be used multiple times; the strictest one wins. + - alignas (TYPE) is equivalent to alignas (alignof (TYPE)). + + */ +# if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 +# if defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER) +# define _Alignas(a) alignas (a) +# elif (!defined __attribute__ \ + && ((defined __APPLE__ && defined __MACH__ \ + ? 4 < __GNUC__ + (1 <= __GNUC_MINOR__) \ + : __GNUC__ && !defined __ibmxl__) \ + || (4 <= __clang_major__) \ + || (__ia64 && (61200 <= __HP_cc || 61200 <= __HP_aCC)) \ + || __ICC || 0x590 <= __SUNPRO_C || 0x0600 <= __xlC__)) +# define _Alignas(a) __attribute__ ((__aligned__ (a))) +# elif 1300 <= _MSC_VER +# define _Alignas(a) __declspec (align (a)) +# endif +# endif +# if !defined HAVE_STDALIGN_H +# if ((defined _Alignas \ + && !(defined __cplusplus \ + && (201103 <= __cplusplus || defined _MSC_VER))) \ + || (defined __STDC_VERSION__ && 201112 <= __STDC_VERSION__)) +# define alignas _Alignas +# endif +# endif + +# if defined _GL_STDALIGN_NEEDS_STDDEF +# include +# endif +#endif]) +]) + +AC_DEFUN([gl_STDALIGN_H], +[ + AC_REQUIRE([gl_ALIGNASOF]) + if test "$gl_cv_header_working_stdalign_h" = no; then + GL_GENERATE_STDALIGN_H=true + else + GL_GENERATE_STDALIGN_H=false + fi + + gl_CHECK_NEXT_HEADERS([stdalign.h]) + if test $ac_cv_header_stdalign_h = yes; then + HAVE_STDALIGN_H=1 + else + HAVE_STDALIGN_H=0 + fi + AC_SUBST([HAVE_STDALIGN_H]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/stdarg.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/stdarg.m4 new file mode 100644 index 00000000..989383c1 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/stdarg.m4 @@ -0,0 +1,76 @@ +# stdarg.m4 serial 8 +dnl Copyright (C) 2006, 2008-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. +dnl Provide a working va_copy in combination with . + +AC_DEFUN([gl_STDARG_H], +[ + GL_GENERATE_STDARG_H=false + NEXT_STDARG_H='' + AC_CACHE_CHECK([for va_copy], + [gl_cv_func_va_copy], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include ]], + [[ +#ifndef va_copy +void (*func) (va_list, va_list) = va_copy; +#endif + ]])], + [gl_cv_func_va_copy=yes], + [gl_cv_func_va_copy=no]) + ]) + if test $gl_cv_func_va_copy = no; then + dnl Provide a substitute. + dnl Usually a simple definition in is enough. Not so on AIX 5 + dnl with some versions of the /usr/vac/bin/cc compiler. It has an + dnl which does '#undef va_copy', leading to a missing va_copy symbol. For + dnl this platform, we use an substitute. But we cannot use this + dnl approach on other platforms, because often defines only + dnl preprocessor macros and gl_ABSOLUTE_HEADER, gl_CHECK_NEXT_HEADERS do + dnl not work in this situation. + AC_EGREP_CPP([vaccine], + [#if defined _AIX && !defined __GNUC__ + AIX vaccine + #endif + ], [gl_aixcc=yes], [gl_aixcc=no]) + if test $gl_aixcc = yes; then + dnl Provide a substitute file. + GL_GENERATE_STDARG_H=true + gl_NEXT_HEADERS([stdarg.h]) + dnl Fallback for the case when contains only macro definitions. + if test "$gl_cv_next_stdarg_h" = '""'; then + gl_cv_next_stdarg_h='"///usr/include/stdarg.h"' + NEXT_STDARG_H="$gl_cv_next_stdarg_h" + fi + else + dnl Provide a substitute in , either __va_copy or as a simple + dnl assignment. + gl_CACHE_VAL_SILENT([gl_cv_func___va_copy], [ + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include ]], + [[ +#ifndef __va_copy +error, bail out +#endif + ]])], + [gl_cv_func___va_copy=yes], + [gl_cv_func___va_copy=no])]) + if test $gl_cv_func___va_copy = yes; then + AC_DEFINE([va_copy], [__va_copy], + [Define as a macro for copying va_list variables.]) + else + AH_VERBATIM([gl_VA_COPY], [/* A replacement for va_copy, if needed. */ +#define gl_va_copy(a,b) ((a) = (b))]) + AC_DEFINE([va_copy], [gl_va_copy], + [Define as a macro for copying va_list variables.]) + fi + fi + fi + AC_SUBST([NEXT_STDARG_H]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/stddef_h.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/stddef_h.m4 new file mode 100644 index 00000000..1bf9eb39 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/stddef_h.m4 @@ -0,0 +1,119 @@ +# stddef_h.m4 serial 14 +dnl Copyright (C) 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl A placeholder for , for platforms that have issues. + +AC_DEFUN_ONCE([gl_STDDEF_H], +[ + AC_REQUIRE([gl_STDDEF_H_DEFAULTS]) + AC_REQUIRE([gt_TYPE_WCHAR_T]) + + dnl Persuade OpenBSD to declare max_align_t. + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + + GL_GENERATE_STDDEF_H=false + + dnl Test whether the type max_align_t exists and whether its alignment + dnl "is as great as is supported by the implementation in all contexts". + AC_CACHE_CHECK([for good max_align_t], + [gl_cv_type_max_align_t], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[/* On FreeBSD 12.0/x86, max_align_t defined by has + the correct alignment with the default (wrong) definition of + _Alignof, but a wrong alignment as soon as we activate an + ISO C compliant _Alignof definition. */ + #if ((defined __GNUC__ && 4 <= __GNUC__) || defined __clang__) && !defined __cplusplus + #define _Alignof(type) __builtin_offsetof (struct { char __a; type __b; }, __b) + #endif + #include + unsigned int s = sizeof (max_align_t); + #if defined __GNUC__ || defined __clang__ || defined __IBM__ALIGNOF__ + int check1[2 * (__alignof__ (double) <= __alignof__ (max_align_t)) - 1]; + int check2[2 * (__alignof__ (long double) <= __alignof__ (max_align_t)) - 1]; + #endif + typedef struct { char a; max_align_t b; } max_helper; + typedef struct { char a; long b; } long_helper; + typedef struct { char a; double b; } double_helper; + typedef struct { char a; long double b; } long_double_helper; + int check3[2 * (offsetof (long_helper, b) <= offsetof (max_helper, b)) - 1]; + int check4[2 * (offsetof (double_helper, b) <= offsetof (max_helper, b)) - 1]; + int check5[2 * (offsetof (long_double_helper, b) <= offsetof (max_helper, b)) - 1]; + ]])], + [gl_cv_type_max_align_t=yes], + [gl_cv_type_max_align_t=no]) + ]) + if test $gl_cv_type_max_align_t = no; then + HAVE_MAX_ALIGN_T=0 + GL_GENERATE_STDDEF_H=true + fi + + if test $gt_cv_c_wchar_t = no; then + HAVE_WCHAR_T=0 + GL_GENERATE_STDDEF_H=true + fi + + AC_CACHE_CHECK([whether NULL can be used in arbitrary expressions], + [gl_cv_decl_null_works], + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include + int test[2 * (sizeof NULL == sizeof (void *)) -1]; +]])], + [gl_cv_decl_null_works=yes], + [gl_cv_decl_null_works=no])]) + if test $gl_cv_decl_null_works = no; then + REPLACE_NULL=1 + GL_GENERATE_STDDEF_H=true + fi + + AC_CACHE_CHECK([for unreachable], + [gl_cv_func_unreachable], + [AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include + ]], + [[unreachable (); + ]])], + [gl_cv_func_unreachable=yes], + [gl_cv_func_unreachable=no]) + ]) + if test $gl_cv_func_unreachable = no; then + GL_GENERATE_STDDEF_H=true + fi + + if $GL_GENERATE_STDDEF_H; then + gl_NEXT_HEADERS([stddef.h]) + fi +]) + +# gl_STDDEF_MODULE_INDICATOR([modulename]) +# sets the shell variable that indicates the presence of the given module +# to a C preprocessor expression that will evaluate to 1. +# This macro invocation must not occur in macros that are AC_REQUIREd. +AC_DEFUN([gl_STDDEF_MODULE_INDICATOR], +[ + dnl Ensure to expand the default settings once only. + gl_STDDEF_H_REQUIRE_DEFAULTS + gl_MODULE_INDICATOR_SET_VARIABLE([$1]) +]) + +# Initializes the default values for AC_SUBSTed shell variables. +# This macro must not be AC_REQUIREd. It must only be invoked, and only +# outside of macros or in macros that are not AC_REQUIREd. +AC_DEFUN([gl_STDDEF_H_REQUIRE_DEFAULTS], +[ + m4_defun(GL_MODULE_INDICATOR_PREFIX[_STDDEF_H_MODULE_INDICATOR_DEFAULTS], [ + ]) + m4_require(GL_MODULE_INDICATOR_PREFIX[_STDDEF_H_MODULE_INDICATOR_DEFAULTS]) + AC_REQUIRE([gl_STDDEF_H_DEFAULTS]) +]) + +AC_DEFUN([gl_STDDEF_H_DEFAULTS], +[ + dnl Assume proper GNU behavior unless another module says otherwise. + REPLACE_NULL=0; AC_SUBST([REPLACE_NULL]) + HAVE_MAX_ALIGN_T=1; AC_SUBST([HAVE_MAX_ALIGN_T]) + HAVE_WCHAR_T=1; AC_SUBST([HAVE_WCHAR_T]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/stdint.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/stdint.m4 new file mode 100644 index 00000000..4aa25082 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/stdint.m4 @@ -0,0 +1,534 @@ +# stdint.m4 serial 63 +dnl Copyright (C) 2001-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Paul Eggert and Bruno Haible. +dnl Test whether is supported or must be substituted. + +AC_PREREQ([2.61]) + +AC_DEFUN_ONCE([gl_STDINT_H], +[ + AC_PREREQ([2.59])dnl + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + + AC_REQUIRE([gl_LIMITS_H]) + AC_REQUIRE([gt_TYPE_WINT_T]) + + dnl For backward compatibility. Some packages may still be testing these + dnl macros. + AC_DEFINE([HAVE_LONG_LONG_INT], [1], + [Define to 1 if the system has the type 'long long int'.]) + AC_DEFINE([HAVE_UNSIGNED_LONG_LONG_INT], [1], + [Define to 1 if the system has the type 'unsigned long long int'.]) + + dnl Check for , in the same way as gl_WCHAR_H does. + AC_CHECK_HEADERS_ONCE([wchar.h]) + if test $ac_cv_header_wchar_h = yes; then + HAVE_WCHAR_H=1 + else + HAVE_WCHAR_H=0 + fi + AC_SUBST([HAVE_WCHAR_H]) + + dnl Check for . + AC_CHECK_HEADERS_ONCE([inttypes.h]) + if test $ac_cv_header_inttypes_h = yes; then + HAVE_INTTYPES_H=1 + else + HAVE_INTTYPES_H=0 + fi + AC_SUBST([HAVE_INTTYPES_H]) + + dnl Check for . + AC_CHECK_HEADERS_ONCE([sys/types.h]) + if test $ac_cv_header_sys_types_h = yes; then + HAVE_SYS_TYPES_H=1 + else + HAVE_SYS_TYPES_H=0 + fi + AC_SUBST([HAVE_SYS_TYPES_H]) + + gl_CHECK_NEXT_HEADERS([stdint.h]) + if test $ac_cv_header_stdint_h = yes; then + HAVE_STDINT_H=1 + else + HAVE_STDINT_H=0 + fi + AC_SUBST([HAVE_STDINT_H]) + + dnl Now see whether we need a substitute . + if test $ac_cv_header_stdint_h = yes; then + AC_CACHE_CHECK([whether stdint.h conforms to C99], + [gl_cv_header_working_stdint_h], + [gl_cv_header_working_stdint_h=no + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ +#define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */ +#define __STDC_CONSTANT_MACROS 1 +#define __STDC_LIMIT_MACROS 1 +#include +/* Dragonfly defines WCHAR_MIN, WCHAR_MAX only in . */ +#if !(defined WCHAR_MIN && defined WCHAR_MAX) +#error "WCHAR_MIN, WCHAR_MAX not defined in " +#endif +] +gl_STDINT_INCLUDES +[ +#ifdef INT8_MAX +int8_t a1 = INT8_MAX; +int8_t a1min = INT8_MIN; +#endif +#ifdef INT16_MAX +int16_t a2 = INT16_MAX; +int16_t a2min = INT16_MIN; +#endif +#ifdef INT32_MAX +int32_t a3 = INT32_MAX; +int32_t a3min = INT32_MIN; +#endif +#ifdef INT64_MAX +int64_t a4 = INT64_MAX; +int64_t a4min = INT64_MIN; +#endif +#ifdef UINT8_MAX +uint8_t b1 = UINT8_MAX; +#else +typedef int b1[(unsigned char) -1 != 255 ? 1 : -1]; +#endif +#ifdef UINT16_MAX +uint16_t b2 = UINT16_MAX; +#endif +#ifdef UINT32_MAX +uint32_t b3 = UINT32_MAX; +#endif +#ifdef UINT64_MAX +uint64_t b4 = UINT64_MAX; +#endif +int_least8_t c1 = INT8_C (0x7f); +int_least8_t c1max = INT_LEAST8_MAX; +int_least8_t c1min = INT_LEAST8_MIN; +int_least16_t c2 = INT16_C (0x7fff); +int_least16_t c2max = INT_LEAST16_MAX; +int_least16_t c2min = INT_LEAST16_MIN; +int_least32_t c3 = INT32_C (0x7fffffff); +int_least32_t c3max = INT_LEAST32_MAX; +int_least32_t c3min = INT_LEAST32_MIN; +int_least64_t c4 = INT64_C (0x7fffffffffffffff); +int_least64_t c4max = INT_LEAST64_MAX; +int_least64_t c4min = INT_LEAST64_MIN; +uint_least8_t d1 = UINT8_C (0xff); +uint_least8_t d1max = UINT_LEAST8_MAX; +uint_least16_t d2 = UINT16_C (0xffff); +uint_least16_t d2max = UINT_LEAST16_MAX; +uint_least32_t d3 = UINT32_C (0xffffffff); +uint_least32_t d3max = UINT_LEAST32_MAX; +uint_least64_t d4 = UINT64_C (0xffffffffffffffff); +uint_least64_t d4max = UINT_LEAST64_MAX; +int_fast8_t e1 = INT_FAST8_MAX; +int_fast8_t e1min = INT_FAST8_MIN; +int_fast16_t e2 = INT_FAST16_MAX; +int_fast16_t e2min = INT_FAST16_MIN; +int_fast32_t e3 = INT_FAST32_MAX; +int_fast32_t e3min = INT_FAST32_MIN; +int_fast64_t e4 = INT_FAST64_MAX; +int_fast64_t e4min = INT_FAST64_MIN; +uint_fast8_t f1 = UINT_FAST8_MAX; +uint_fast16_t f2 = UINT_FAST16_MAX; +uint_fast32_t f3 = UINT_FAST32_MAX; +uint_fast64_t f4 = UINT_FAST64_MAX; +#ifdef INTPTR_MAX +intptr_t g = INTPTR_MAX; +intptr_t gmin = INTPTR_MIN; +#endif +#ifdef UINTPTR_MAX +uintptr_t h = UINTPTR_MAX; +#endif +intmax_t i = INTMAX_MAX; +uintmax_t j = UINTMAX_MAX; + +/* Check that SIZE_MAX has the correct type, if possible. */ +/* ISO C 11 mandates _Generic, but GCC versions < 4.9 lack it. */ +#if 201112 <= __STDC_VERSION__ \ + && (!defined __GNUC__ || 4 < __GNUC__ + (9 <= __GNUC_MINOR__) \ + || defined __clang__) +int k = _Generic (SIZE_MAX, size_t: 0); +#elif (2 <= __GNUC__ || 4 <= __clang_major__ || defined __IBM__TYPEOF__ \ + || (0x5110 <= __SUNPRO_C && !__STDC__)) +extern size_t k; +extern __typeof__ (SIZE_MAX) k; +#endif + +#include /* for CHAR_BIT */ +#define TYPE_MINIMUM(t) \ + ((t) ((t) 0 < (t) -1 ? (t) 0 : ~ TYPE_MAXIMUM (t))) +#define TYPE_MAXIMUM(t) \ + ((t) ((t) 0 < (t) -1 \ + ? (t) -1 \ + : ((((t) 1 << (sizeof (t) * CHAR_BIT - 2)) - 1) * 2 + 1))) +struct s { + int check_PTRDIFF: + PTRDIFF_MIN == TYPE_MINIMUM (ptrdiff_t) + && PTRDIFF_MAX == TYPE_MAXIMUM (ptrdiff_t) + ? 1 : -1; + /* Detect bug in FreeBSD 6.0/ia64 and FreeBSD 13.0/arm64. */ + int check_SIG_ATOMIC: + SIG_ATOMIC_MIN == TYPE_MINIMUM (sig_atomic_t) + && SIG_ATOMIC_MAX == TYPE_MAXIMUM (sig_atomic_t) + ? 1 : -1; + int check_SIZE: SIZE_MAX == TYPE_MAXIMUM (size_t) ? 1 : -1; + int check_WCHAR: + WCHAR_MIN == TYPE_MINIMUM (wchar_t) + && WCHAR_MAX == TYPE_MAXIMUM (wchar_t) + ? 1 : -1; + /* Detect bug in mingw. */ + int check_WINT: + WINT_MIN == TYPE_MINIMUM (wint_t) + && WINT_MAX == TYPE_MAXIMUM (wint_t) + ? 1 : -1; + + /* Detect bugs in glibc 2.4 and Solaris 10 stdint.h, among others. */ + int check_UINT8_C: + (-1 < UINT8_C (0)) == (-1 < (uint_least8_t) 0) ? 1 : -1; + int check_UINT16_C: + (-1 < UINT16_C (0)) == (-1 < (uint_least16_t) 0) ? 1 : -1; + + /* Detect bugs in OpenBSD 3.9 stdint.h. */ +#ifdef UINT8_MAX + int check_uint8: (uint8_t) -1 == UINT8_MAX ? 1 : -1; +#endif +#ifdef UINT16_MAX + int check_uint16: (uint16_t) -1 == UINT16_MAX ? 1 : -1; +#endif +#ifdef UINT32_MAX + int check_uint32: (uint32_t) -1 == UINT32_MAX ? 1 : -1; +#endif +#ifdef UINT64_MAX + int check_uint64: (uint64_t) -1 == UINT64_MAX ? 1 : -1; +#endif + int check_uint_least8: (uint_least8_t) -1 == UINT_LEAST8_MAX ? 1 : -1; + int check_uint_least16: (uint_least16_t) -1 == UINT_LEAST16_MAX ? 1 : -1; + int check_uint_least32: (uint_least32_t) -1 == UINT_LEAST32_MAX ? 1 : -1; + int check_uint_least64: (uint_least64_t) -1 == UINT_LEAST64_MAX ? 1 : -1; + int check_uint_fast8: (uint_fast8_t) -1 == UINT_FAST8_MAX ? 1 : -1; + int check_uint_fast16: (uint_fast16_t) -1 == UINT_FAST16_MAX ? 1 : -1; + int check_uint_fast32: (uint_fast32_t) -1 == UINT_FAST32_MAX ? 1 : -1; + int check_uint_fast64: (uint_fast64_t) -1 == UINT_FAST64_MAX ? 1 : -1; + int check_uintptr: (uintptr_t) -1 == UINTPTR_MAX ? 1 : -1; + int check_uintmax: (uintmax_t) -1 == UINTMAX_MAX ? 1 : -1; + int check_size: (size_t) -1 == SIZE_MAX ? 1 : -1; +}; + ]])], + [dnl Determine whether the various *_MIN, *_MAX macros are usable + dnl in preprocessor expression. We could do it by compiling a test + dnl program for each of these macros. It is faster to run a program + dnl that inspects the macro expansion. + dnl This detects a bug on HP-UX 11.23/ia64. + AC_RUN_IFELSE([ + AC_LANG_PROGRAM([[ +#define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */ +#define __STDC_CONSTANT_MACROS 1 +#define __STDC_LIMIT_MACROS 1 +#include +] +gl_STDINT_INCLUDES +[ +#include +#include +#define MVAL(macro) MVAL1(macro) +#define MVAL1(expression) #expression +static const char *macro_values[] = + { +#ifdef INT8_MAX + MVAL (INT8_MAX), +#endif +#ifdef INT16_MAX + MVAL (INT16_MAX), +#endif +#ifdef INT32_MAX + MVAL (INT32_MAX), +#endif +#ifdef INT64_MAX + MVAL (INT64_MAX), +#endif +#ifdef UINT8_MAX + MVAL (UINT8_MAX), +#endif +#ifdef UINT16_MAX + MVAL (UINT16_MAX), +#endif +#ifdef UINT32_MAX + MVAL (UINT32_MAX), +#endif +#ifdef UINT64_MAX + MVAL (UINT64_MAX), +#endif + NULL + }; +]], [[ + const char **mv; + for (mv = macro_values; *mv != NULL; mv++) + { + const char *value = *mv; + /* Test whether it looks like a cast expression. */ + if (strncmp (value, "((unsigned int)"/*)*/, 15) == 0 + || strncmp (value, "((unsigned short)"/*)*/, 17) == 0 + || strncmp (value, "((unsigned char)"/*)*/, 16) == 0 + || strncmp (value, "((int)"/*)*/, 6) == 0 + || strncmp (value, "((signed short)"/*)*/, 15) == 0 + || strncmp (value, "((signed char)"/*)*/, 14) == 0) + return mv - macro_values + 1; + } + return 0; +]])], + [gl_cv_header_working_stdint_h=yes], + [], + [case "$host_os" in + # Guess yes on native Windows. + mingw* | windows*) gl_cv_header_working_stdint_h="guessing yes" ;; + # In general, assume it works. + *) gl_cv_header_working_stdint_h="guessing yes" ;; + esac + ]) + ]) + ]) + fi + + HAVE_C99_STDINT_H=0 + HAVE_SYS_BITYPES_H=0 + HAVE_SYS_INTTYPES_H=0 + GL_GENERATE_STDINT_H=true + case "$gl_cv_header_working_stdint_h" in + *yes) + HAVE_C99_STDINT_H=1 + dnl Now see whether the system works without + dnl __STDC_CONSTANT_MACROS/__STDC_LIMIT_MACROS defined. + dnl If not, there would be problems when stdint.h is included from C++. + AC_CACHE_CHECK([whether stdint.h works without ISO C predefines], + [gl_cv_header_stdint_without_STDC_macros], + [gl_cv_header_stdint_without_STDC_macros=no + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ +#define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */ +#include +] +gl_STDINT_INCLUDES +[ +intmax_t im = INTMAX_MAX; +int32_t i32 = INT32_C (0x7fffffff); + ]])], + [gl_cv_header_stdint_without_STDC_macros=yes]) + ]) + + if test $gl_cv_header_stdint_without_STDC_macros = no; then + AC_DEFINE([__STDC_CONSTANT_MACROS], [1], + [Define to 1 if the system predates C++11.]) + AC_DEFINE([__STDC_LIMIT_MACROS], [1], + [Define to 1 if the system predates C++11.]) + fi + AC_CACHE_CHECK([whether stdint.h has UINTMAX_WIDTH etc.], + [gl_cv_header_stdint_width], + [gl_cv_header_stdint_width=no + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[ + /* Work if build is not clean. */ + #define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 + #ifndef __STDC_WANT_IEC_60559_BFP_EXT__ + #define __STDC_WANT_IEC_60559_BFP_EXT__ 1 + #endif + #include + ]gl_STDINT_INCLUDES[ + int iw = UINTMAX_WIDTH; + ]])], + [gl_cv_header_stdint_width=yes])]) + if test "$gl_cv_header_stdint_width" = yes; then + GL_GENERATE_STDINT_H=false + fi + ;; + *) + dnl Check for , and for + dnl (used in Linux libc4 >= 4.6.7 and libc5). + AC_CHECK_HEADERS([sys/inttypes.h sys/bitypes.h]) + if test $ac_cv_header_sys_inttypes_h = yes; then + HAVE_SYS_INTTYPES_H=1 + fi + if test $ac_cv_header_sys_bitypes_h = yes; then + HAVE_SYS_BITYPES_H=1 + fi + gl_STDINT_TYPE_PROPERTIES + ;; + esac + + dnl The substitute stdint.h needs the substitute limit.h's _GL_INTEGER_WIDTH. + gl_REPLACE_LIMITS_H + + AC_SUBST([HAVE_C99_STDINT_H]) + AC_SUBST([HAVE_SYS_BITYPES_H]) + AC_SUBST([HAVE_SYS_INTTYPES_H]) +]) + +dnl gl_STDINT_BITSIZEOF(TYPES, INCLUDES) +dnl Determine the size of each of the given types in bits. +AC_DEFUN([gl_STDINT_BITSIZEOF], +[ + dnl Use a shell loop, to avoid bloating configure, and + dnl - extra AH_TEMPLATE calls, so that autoheader knows what to put into + dnl config.h.in, + dnl - extra AC_SUBST calls, so that the right substitutions are made. + m4_foreach_w([gltype], [$1], + [AH_TEMPLATE([BITSIZEOF_]m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]), + [Define to the number of bits in type ']gltype['.])]) + for gltype in $1 ; do + AC_CACHE_CHECK([for bit size of $gltype], [gl_cv_bitsizeof_${gltype}], + [AC_COMPUTE_INT([result], [sizeof ($gltype) * CHAR_BIT], + [$2 +#include ], [result=unknown]) + eval gl_cv_bitsizeof_${gltype}=\$result + ]) + eval result=\$gl_cv_bitsizeof_${gltype} + if test $result = unknown; then + dnl Use a nonempty default, because some compilers, such as IRIX 5 cc, + dnl do a syntax check even on unused #if conditions and give an error + dnl on valid C code like this: + dnl #if 0 + dnl # if > 32 + dnl # endif + dnl #endif + result=0 + fi + GLTYPE=`echo "$gltype" | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'` + AC_DEFINE_UNQUOTED([BITSIZEOF_${GLTYPE}], [$result]) + eval BITSIZEOF_${GLTYPE}=\$result + done + m4_foreach_w([gltype], [$1], + [AC_SUBST([BITSIZEOF_]m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]))]) +]) + +dnl gl_CHECK_TYPES_SIGNED(TYPES, INCLUDES) +dnl Determine the signedness of each of the given types. +dnl Define HAVE_SIGNED_TYPE if type is signed. +AC_DEFUN([gl_CHECK_TYPES_SIGNED], +[ + dnl Use a shell loop, to avoid bloating configure, and + dnl - extra AH_TEMPLATE calls, so that autoheader knows what to put into + dnl config.h.in, + dnl - extra AC_SUBST calls, so that the right substitutions are made. + m4_foreach_w([gltype], [$1], + [AH_TEMPLATE([HAVE_SIGNED_]m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]), + [Define to 1 if ']gltype[' is a signed integer type.])]) + for gltype in $1 ; do + AC_CACHE_CHECK([whether $gltype is signed], [gl_cv_type_${gltype}_signed], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([$2[ + int verify[2 * (($gltype) -1 < ($gltype) 0) - 1];]])], + result=yes, result=no) + eval gl_cv_type_${gltype}_signed=\$result + ]) + eval result=\$gl_cv_type_${gltype}_signed + GLTYPE=`echo $gltype | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'` + if test "$result" = yes; then + AC_DEFINE_UNQUOTED([HAVE_SIGNED_${GLTYPE}], [1]) + eval HAVE_SIGNED_${GLTYPE}=1 + else + eval HAVE_SIGNED_${GLTYPE}=0 + fi + done + m4_foreach_w([gltype], [$1], + [AC_SUBST([HAVE_SIGNED_]m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]))]) +]) + +dnl gl_INTEGER_TYPE_SUFFIX(TYPES, INCLUDES) +dnl Determine the suffix to use for integer constants of the given types. +dnl Define t_SUFFIX for each such type. +AC_DEFUN([gl_INTEGER_TYPE_SUFFIX], +[ + dnl Use a shell loop, to avoid bloating configure, and + dnl - extra AH_TEMPLATE calls, so that autoheader knows what to put into + dnl config.h.in, + dnl - extra AC_SUBST calls, so that the right substitutions are made. + m4_foreach_w([gltype], [$1], + [AH_TEMPLATE(m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_])[_SUFFIX], + [Define to l, ll, u, ul, ull, etc., as suitable for + constants of type ']gltype['.])]) + for gltype in $1 ; do + AC_CACHE_CHECK([for $gltype integer literal suffix], + [gl_cv_type_${gltype}_suffix], + [eval gl_cv_type_${gltype}_suffix=no + eval result=\$gl_cv_type_${gltype}_signed + if test "$result" = yes; then + glsufu= + else + glsufu=u + fi + for glsuf in "$glsufu" ${glsufu}l ${glsufu}ll ${glsufu}i64; do + case $glsuf in + '') gltype1='int';; + l) gltype1='long int';; + ll) gltype1='long long int';; + i64) gltype1='__int64';; + u) gltype1='unsigned int';; + ul) gltype1='unsigned long int';; + ull) gltype1='unsigned long long int';; + ui64)gltype1='unsigned __int64';; + esac + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([$2[ + extern $gltype foo; + extern $gltype1 foo;]])], + [eval gl_cv_type_${gltype}_suffix=\$glsuf]) + eval result=\$gl_cv_type_${gltype}_suffix + test "$result" != no && break + done]) + GLTYPE=`echo $gltype | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'` + eval result=\$gl_cv_type_${gltype}_suffix + test "$result" = no && result= + eval ${GLTYPE}_SUFFIX=\$result + AC_DEFINE_UNQUOTED([${GLTYPE}_SUFFIX], [$result]) + done + m4_foreach_w([gltype], [$1], + [AC_SUBST(m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_])[_SUFFIX])]) +]) + +dnl gl_STDINT_INCLUDES +AC_DEFUN([gl_STDINT_INCLUDES], +[[ + #include + #include + #if HAVE_WCHAR_H + # include + #endif +]]) + +dnl gl_STDINT_TYPE_PROPERTIES +dnl Compute HAVE_SIGNED_t, BITSIZEOF_t and t_SUFFIX, for all the types t +dnl of interest to stdint.in.h. +AC_DEFUN([gl_STDINT_TYPE_PROPERTIES], +[ + AC_REQUIRE([gl_MULTIARCH]) + if test $APPLE_UNIVERSAL_BUILD = 0; then + gl_STDINT_BITSIZEOF([ptrdiff_t size_t], + [gl_STDINT_INCLUDES]) + fi + gl_STDINT_BITSIZEOF([sig_atomic_t wchar_t wint_t], + [gl_STDINT_INCLUDES]) + gl_CHECK_TYPES_SIGNED([sig_atomic_t wchar_t wint_t], + [gl_STDINT_INCLUDES]) + gl_cv_type_ptrdiff_t_signed=yes + gl_cv_type_size_t_signed=no + if test $APPLE_UNIVERSAL_BUILD = 0; then + gl_INTEGER_TYPE_SUFFIX([ptrdiff_t size_t], + [gl_STDINT_INCLUDES]) + fi + gl_INTEGER_TYPE_SUFFIX([sig_atomic_t wchar_t wint_t], + [gl_STDINT_INCLUDES]) + + dnl If wint_t is smaller than 'int', it cannot satisfy the ISO C 99 + dnl requirement that wint_t is "unchanged by default argument promotions". + dnl In this case gnulib's and override wint_t. + dnl Set the variable BITSIZEOF_WINT_T accordingly. + if test $GNULIBHEADERS_OVERRIDE_WINT_T = 1; then + BITSIZEOF_WINT_T=32 + fi +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/stdint_h.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/stdint_h.m4 new file mode 100644 index 00000000..ee9773a8 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/stdint_h.m4 @@ -0,0 +1,27 @@ +# stdint_h.m4 serial 9 +dnl Copyright (C) 1997-2004, 2006, 2008-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Paul Eggert. + +# Define HAVE_STDINT_H_WITH_UINTMAX if exists, +# doesn't clash with , and declares uintmax_t. + +AC_DEFUN([gl_AC_HEADER_STDINT_H], +[ + AC_CACHE_CHECK([for stdint.h], [gl_cv_header_stdint_h], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include + #include ]], + [[uintmax_t i = (uintmax_t) -1; return !i;]])], + [gl_cv_header_stdint_h=yes], + [gl_cv_header_stdint_h=no])]) + if test $gl_cv_header_stdint_h = yes; then + AC_DEFINE_UNQUOTED([HAVE_STDINT_H_WITH_UINTMAX], [1], + [Define if exists, doesn't clash with , + and declares uintmax_t. ]) + fi +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/stdio_h.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/stdio_h.m4 new file mode 100644 index 00000000..c19feefe --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/stdio_h.m4 @@ -0,0 +1,255 @@ +# stdio_h.m4 serial 63 +dnl Copyright (C) 2007-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_STDIO_H_EARLY], +[ + dnl Defining __USE_MINGW_ANSI_STDIO to 1 must be done early, because + dnl the results of several configure tests depend on it: The tests + dnl - checking whether snprintf returns a byte count as in C99... + dnl - checking whether snprintf truncates the result as in C99... + dnl - checking whether printf supports the 'F' directive... + dnl - checking whether printf supports the grouping flag... + dnl - checking whether printf supports the zero flag correctly... + dnl - checking whether printf supports infinite 'double' arguments... + dnl - checking whether printf supports large precisions... + dnl report 'yes' if __USE_MINGW_ANSI_STDIO is 1 but 'no' if + dnl __USE_MINGW_ANSI_STDIO is not set. + AH_VERBATIM([MINGW_ANSI_STDIO], +[/* Use GNU style printf and scanf. */ +#ifndef __USE_MINGW_ANSI_STDIO +# undef __USE_MINGW_ANSI_STDIO +#endif +]) + AC_DEFINE([__USE_MINGW_ANSI_STDIO]) +]) + +AC_DEFUN_ONCE([gl_STDIO_H], +[ + AC_REQUIRE([gl_STDIO_H_DEFAULTS]) + gl_NEXT_HEADERS([stdio.h]) + + dnl Determine whether __USE_MINGW_ANSI_STDIO makes printf and + dnl inttypes.h behave like gnu instead of system; we must give our + dnl printf wrapper the right attribute to match. + AC_CACHE_CHECK([which flavor of printf attribute matches inttypes macros], + [gl_cv_func_printf_attribute_flavor], + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #define __STDC_FORMAT_MACROS 1 + #include + #include + /* For non-mingw systems, compilation will trivially succeed. + For mingw, compilation will succeed for older mingw (system + printf, "I64d") and fail for newer mingw (gnu printf, "lld"). */ + #if (defined _WIN32 && ! defined __CYGWIN__) && \ + (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) + extern char PRIdMAX_probe[sizeof PRIdMAX == sizeof "I64d" ? 1 : -1]; + #endif + ]])], [gl_cv_func_printf_attribute_flavor=system], + [gl_cv_func_printf_attribute_flavor=gnu])]) + if test "$gl_cv_func_printf_attribute_flavor" = gnu; then + AC_DEFINE([GNULIB_PRINTF_ATTRIBUTE_FLAVOR_GNU], [1], + [Define to 1 if printf and friends should be labeled with + attribute "__gnu_printf__" instead of "__printf__"]) + fi + + dnl For defining _PRINTF_NAN_LEN_MAX. + gl_MUSL_LIBC + + dnl This ifdef is an optimization, to avoid performing a configure check whose + dnl result is not used. But it does not make the test of + dnl GNULIB_STDIO_H_NONBLOCKING or GNULIB_NONBLOCKING redundant. + m4_ifdef([gl_NONBLOCKING_IO], [ + gl_NONBLOCKING_IO + if test $gl_cv_have_nonblocking != yes; then + REPLACE_STDIO_READ_FUNCS=1 + fi + ]) + + dnl This ifdef is an optimization, to avoid performing a configure check whose + dnl result is not used. But it does not make the test of + dnl GNULIB_STDIO_H_SIGPIPE or GNULIB_SIGPIPE redundant. + m4_ifdef([gl_SIGNAL_SIGPIPE], [ + gl_SIGNAL_SIGPIPE + if test $gl_cv_header_signal_h_SIGPIPE != yes; then + REPLACE_STDIO_WRITE_FUNCS=1 + fi + ]) + dnl This ifdef is an optimization, to avoid performing a configure check whose + dnl result is not used. But it does not make the test of + dnl GNULIB_STDIO_H_NONBLOCKING or GNULIB_NONBLOCKING redundant. + m4_ifdef([gl_NONBLOCKING_IO], [ + gl_NONBLOCKING_IO + if test $gl_cv_have_nonblocking != yes; then + REPLACE_STDIO_WRITE_FUNCS=1 + fi + ]) + + dnl Check for declarations of anything we want to poison if the + dnl corresponding gnulib module is not in use, and which is not + dnl guaranteed by both C89 and C11. + gl_WARN_ON_USE_PREPARE([[#include + ]], [dprintf fpurge fseeko ftello getdelim getline gets pclose popen + renameat snprintf tmpfile vdprintf vsnprintf]) + + AC_REQUIRE([AC_C_RESTRICT]) + + AC_CHECK_DECLS_ONCE([fcloseall]) + if test $ac_cv_have_decl_fcloseall = no; then + HAVE_DECL_FCLOSEALL=0 + fi + + AC_CHECK_DECLS_ONCE([getw]) + if test $ac_cv_have_decl_getw = no; then + HAVE_DECL_GETW=0 + fi + + AC_CHECK_DECLS_ONCE([putw]) + if test $ac_cv_have_decl_putw = no; then + HAVE_DECL_PUTW=0 + fi +]) + +# gl_STDIO_MODULE_INDICATOR([modulename]) +# sets the shell variable that indicates the presence of the given module +# to a C preprocessor expression that will evaluate to 1. +# This macro invocation must not occur in macros that are AC_REQUIREd. +AC_DEFUN([gl_STDIO_MODULE_INDICATOR], +[ + dnl Ensure to expand the default settings once only. + gl_STDIO_H_REQUIRE_DEFAULTS + gl_MODULE_INDICATOR_SET_VARIABLE([$1]) + dnl Define it also as a C macro, for the benefit of the unit tests. + gl_MODULE_INDICATOR_FOR_TESTS([$1]) +]) + +# Initializes the default values for AC_SUBSTed shell variables. +# This macro must not be AC_REQUIREd. It must only be invoked, and only +# outside of macros or in macros that are not AC_REQUIREd. +AC_DEFUN([gl_STDIO_H_REQUIRE_DEFAULTS], +[ + m4_defun(GL_MODULE_INDICATOR_PREFIX[_STDIO_H_MODULE_INDICATOR_DEFAULTS], [ + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_DPRINTF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FCLOSE]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FDOPEN]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FFLUSH]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FGETC]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FGETS]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FOPEN]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FOPEN_GNU]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FPRINTF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FPRINTF_POSIX]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FPURGE]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FPUTC]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FPUTS]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FREAD]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FREOPEN]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FSCANF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FSEEK]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FSEEKO]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FTELL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FTELLO]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FWRITE]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETC]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETCHAR]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETDELIM]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETLINE]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_OBSTACK_PRINTF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_OBSTACK_PRINTF_POSIX]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PCLOSE]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PERROR]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_POPEN]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PRINTF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PRINTF_POSIX]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PUTC]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PUTCHAR]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PUTS]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REMOVE]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RENAME]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RENAMEAT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SCANF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SNPRINTF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SPRINTF_POSIX]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STDIO_H_NONBLOCKING]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STDIO_H_SIGPIPE]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TMPFILE]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VASPRINTF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VFSCANF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VSCANF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VDPRINTF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VFPRINTF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VFPRINTF_POSIX]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VPRINTF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VPRINTF_POSIX]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VSNPRINTF]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VSPRINTF_POSIX]) + dnl Support Microsoft deprecated alias function names by default. + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_FCLOSEALL], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_FDOPEN], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_FILENO], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_GETW], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_PUTW], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_TEMPNAM], [1]) + ]) + m4_require(GL_MODULE_INDICATOR_PREFIX[_STDIO_H_MODULE_INDICATOR_DEFAULTS]) + AC_REQUIRE([gl_STDIO_H_DEFAULTS]) +]) + +AC_DEFUN([gl_STDIO_H_DEFAULTS], +[ + dnl Assume proper GNU behavior unless another module says otherwise. + HAVE_DECL_FCLOSEALL=1; AC_SUBST([HAVE_DECL_FCLOSEALL]) + HAVE_DECL_FPURGE=1; AC_SUBST([HAVE_DECL_FPURGE]) + HAVE_DECL_FSEEKO=1; AC_SUBST([HAVE_DECL_FSEEKO]) + HAVE_DECL_FTELLO=1; AC_SUBST([HAVE_DECL_FTELLO]) + HAVE_DECL_GETDELIM=1; AC_SUBST([HAVE_DECL_GETDELIM]) + HAVE_DECL_GETLINE=1; AC_SUBST([HAVE_DECL_GETLINE]) + HAVE_DECL_GETW=1; AC_SUBST([HAVE_DECL_GETW]) + HAVE_DECL_OBSTACK_PRINTF=1; AC_SUBST([HAVE_DECL_OBSTACK_PRINTF]) + HAVE_DECL_PUTW=1; AC_SUBST([HAVE_DECL_PUTW]) + HAVE_DECL_SNPRINTF=1; AC_SUBST([HAVE_DECL_SNPRINTF]) + HAVE_DECL_VSNPRINTF=1; AC_SUBST([HAVE_DECL_VSNPRINTF]) + HAVE_DPRINTF=1; AC_SUBST([HAVE_DPRINTF]) + HAVE_FSEEKO=1; AC_SUBST([HAVE_FSEEKO]) + HAVE_FTELLO=1; AC_SUBST([HAVE_FTELLO]) + HAVE_PCLOSE=1; AC_SUBST([HAVE_PCLOSE]) + HAVE_POPEN=1; AC_SUBST([HAVE_POPEN]) + HAVE_RENAMEAT=1; AC_SUBST([HAVE_RENAMEAT]) + HAVE_VASPRINTF=1; AC_SUBST([HAVE_VASPRINTF]) + HAVE_VDPRINTF=1; AC_SUBST([HAVE_VDPRINTF]) + REPLACE_DPRINTF=0; AC_SUBST([REPLACE_DPRINTF]) + REPLACE_FCLOSE=0; AC_SUBST([REPLACE_FCLOSE]) + REPLACE_FDOPEN=0; AC_SUBST([REPLACE_FDOPEN]) + REPLACE_FFLUSH=0; AC_SUBST([REPLACE_FFLUSH]) + REPLACE_FOPEN=0; AC_SUBST([REPLACE_FOPEN]) + REPLACE_FOPEN_FOR_FOPEN_GNU=0; AC_SUBST([REPLACE_FOPEN_FOR_FOPEN_GNU]) + REPLACE_FPRINTF=0; AC_SUBST([REPLACE_FPRINTF]) + REPLACE_FPURGE=0; AC_SUBST([REPLACE_FPURGE]) + REPLACE_FREOPEN=0; AC_SUBST([REPLACE_FREOPEN]) + REPLACE_FSEEK=0; AC_SUBST([REPLACE_FSEEK]) + REPLACE_FSEEKO=0; AC_SUBST([REPLACE_FSEEKO]) + REPLACE_FTELL=0; AC_SUBST([REPLACE_FTELL]) + REPLACE_FTELLO=0; AC_SUBST([REPLACE_FTELLO]) + REPLACE_GETDELIM=0; AC_SUBST([REPLACE_GETDELIM]) + REPLACE_GETLINE=0; AC_SUBST([REPLACE_GETLINE]) + REPLACE_OBSTACK_PRINTF=0; AC_SUBST([REPLACE_OBSTACK_PRINTF]) + REPLACE_PERROR=0; AC_SUBST([REPLACE_PERROR]) + REPLACE_POPEN=0; AC_SUBST([REPLACE_POPEN]) + REPLACE_PRINTF=0; AC_SUBST([REPLACE_PRINTF]) + REPLACE_REMOVE=0; AC_SUBST([REPLACE_REMOVE]) + REPLACE_RENAME=0; AC_SUBST([REPLACE_RENAME]) + REPLACE_RENAMEAT=0; AC_SUBST([REPLACE_RENAMEAT]) + REPLACE_SNPRINTF=0; AC_SUBST([REPLACE_SNPRINTF]) + REPLACE_SPRINTF=0; AC_SUBST([REPLACE_SPRINTF]) + REPLACE_STDIO_READ_FUNCS=0; AC_SUBST([REPLACE_STDIO_READ_FUNCS]) + REPLACE_STDIO_WRITE_FUNCS=0; AC_SUBST([REPLACE_STDIO_WRITE_FUNCS]) + REPLACE_TMPFILE=0; AC_SUBST([REPLACE_TMPFILE]) + REPLACE_VASPRINTF=0; AC_SUBST([REPLACE_VASPRINTF]) + REPLACE_VDPRINTF=0; AC_SUBST([REPLACE_VDPRINTF]) + REPLACE_VFPRINTF=0; AC_SUBST([REPLACE_VFPRINTF]) + REPLACE_VPRINTF=0; AC_SUBST([REPLACE_VPRINTF]) + REPLACE_VSNPRINTF=0; AC_SUBST([REPLACE_VSNPRINTF]) + REPLACE_VSPRINTF=0; AC_SUBST([REPLACE_VSPRINTF]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/stdlib_h.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/stdlib_h.m4 new file mode 100644 index 00000000..92e67a74 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/stdlib_h.m4 @@ -0,0 +1,258 @@ +# stdlib_h.m4 serial 76 +dnl Copyright (C) 2007-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN_ONCE([gl_STDLIB_H], +[ + AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) + gl_NEXT_HEADERS([stdlib.h]) + + dnl Check for declarations of anything we want to poison if the + dnl corresponding gnulib module is not in use, and which is not + dnl guaranteed by C89. + gl_WARN_ON_USE_PREPARE([[#include +#if HAVE_SYS_LOADAVG_H +/* OpenIndiana has a bug: must be included before + . */ +# include +# include +#endif +#if HAVE_RANDOM_H +# include +#endif + ]], [_Exit aligned_alloc atoll canonicalize_file_name free + getloadavg getprogname getsubopt grantpt + initstate initstate_r mbstowcs mbtowc mkdtemp mkostemp mkostemps mkstemp + mkstemps posix_memalign posix_openpt ptsname ptsname_r qsort_r + random random_r reallocarray realpath rpmatch secure_getenv setenv + setstate setstate_r srandom srandom_r + strtod strtol strtold strtoll strtoul strtoull unlockpt unsetenv]) + + AC_REQUIRE([AC_C_RESTRICT]) + + dnl Test whether MB_CUR_MAX needs to be overridden. + dnl On Solaris 10, in UTF-8 locales, its value is 3 but needs to be 4. + dnl Fortunately, we can do this because on this platform MB_LEN_MAX is 5. + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_REQUIRE([gt_LOCALE_FR_UTF8]) + AC_CACHE_CHECK([whether MB_CUR_MAX is correct], + [gl_cv_macro_MB_CUR_MAX_good], + [ + dnl Initial guess, used when cross-compiling or when no suitable locale + dnl is present. +changequote(,)dnl + case "$host_os" in + # Guess no on Solaris. + solaris*) gl_cv_macro_MB_CUR_MAX_good="guessing no" ;; + # Guess yes otherwise. + *) gl_cv_macro_MB_CUR_MAX_good="guessing yes" ;; + esac +changequote([,])dnl + if test $LOCALE_FR_UTF8 != none; then + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +int main () +{ + int result = 0; + if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL) + { + if (MB_CUR_MAX < 4) + result |= 1; + } + return result; +}]])], + [gl_cv_macro_MB_CUR_MAX_good=yes], + [gl_cv_macro_MB_CUR_MAX_good=no], + [:]) + fi + ]) + case "$gl_cv_macro_MB_CUR_MAX_good" in + *yes) ;; + *) REPLACE_MB_CUR_MAX=1 ;; + esac + + AC_CHECK_DECLS_ONCE([ecvt]) + if test $ac_cv_have_decl_ecvt = no; then + HAVE_DECL_ECVT=0 + fi + AC_CHECK_DECLS_ONCE([fcvt]) + if test $ac_cv_have_decl_fcvt = no; then + HAVE_DECL_FCVT=0 + fi + AC_CHECK_DECLS_ONCE([gcvt]) + if test $ac_cv_have_decl_gcvt = no; then + HAVE_DECL_GCVT=0 + fi +]) + +# gl_STDLIB_MODULE_INDICATOR([modulename]) +# sets the shell variable that indicates the presence of the given module +# to a C preprocessor expression that will evaluate to 1. +# This macro invocation must not occur in macros that are AC_REQUIREd. +AC_DEFUN([gl_STDLIB_MODULE_INDICATOR], +[ + dnl Ensure to expand the default settings once only. + gl_STDLIB_H_REQUIRE_DEFAULTS + gl_MODULE_INDICATOR_SET_VARIABLE([$1]) + dnl Define it also as a C macro, for the benefit of the unit tests. + gl_MODULE_INDICATOR_FOR_TESTS([$1]) +]) + +# Initializes the default values for AC_SUBSTed shell variables. +# This macro must not be AC_REQUIREd. It must only be invoked, and only +# outside of macros or in macros that are not AC_REQUIREd. +AC_DEFUN([gl_STDLIB_H_REQUIRE_DEFAULTS], +[ + m4_defun(GL_MODULE_INDICATOR_PREFIX[_STDLIB_H_MODULE_INDICATOR_DEFAULTS], [ + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB__EXIT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ALIGNED_ALLOC]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ATOLL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CALLOC_GNU]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CALLOC_POSIX]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CANONICALIZE_FILE_NAME]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FREE_POSIX]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETLOADAVG]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETPROGNAME]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETSUBOPT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GRANTPT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MALLOC_GNU]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MALLOC_POSIX]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSTOWCS]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBTOWC]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKDTEMP]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKOSTEMP]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKOSTEMPS]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKSTEMP]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKSTEMPS]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_POSIX_MEMALIGN]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_POSIX_OPENPT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PTSNAME]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PTSNAME_R]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PUTENV]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_QSORT_R]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RAND]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RANDOM]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RANDOM_R]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REALLOCARRAY]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REALLOC_GNU]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REALLOC_POSIX]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REALPATH]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RPMATCH]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SECURE_GETENV]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SETENV]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOD]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOLD]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOLL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOUL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOULL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SYSTEM_POSIX]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNLOCKPT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNSETENV]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCTOMB]) + dnl Support Microsoft deprecated alias function names by default. + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_ECVT], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_FCVT], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_GCVT], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_MKTEMP], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_PUTENV], [1]) + ]) + m4_require(GL_MODULE_INDICATOR_PREFIX[_STDLIB_H_MODULE_INDICATOR_DEFAULTS]) + AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) +]) + +AC_DEFUN([gl_STDLIB_H_DEFAULTS], +[ + dnl Assume proper GNU behavior unless another module says otherwise. + HAVE__EXIT=1; AC_SUBST([HAVE__EXIT]) + HAVE_ALIGNED_ALLOC=1; AC_SUBST([HAVE_ALIGNED_ALLOC]) + HAVE_ATOLL=1; AC_SUBST([HAVE_ATOLL]) + HAVE_CANONICALIZE_FILE_NAME=1; AC_SUBST([HAVE_CANONICALIZE_FILE_NAME]) + HAVE_DECL_ECVT=1; AC_SUBST([HAVE_DECL_ECVT]) + HAVE_DECL_FCVT=1; AC_SUBST([HAVE_DECL_FCVT]) + HAVE_DECL_GCVT=1; AC_SUBST([HAVE_DECL_GCVT]) + HAVE_DECL_GETLOADAVG=1; AC_SUBST([HAVE_DECL_GETLOADAVG]) + HAVE_DECL_PROGRAM_INVOCATION_NAME=1; AC_SUBST([HAVE_DECL_PROGRAM_INVOCATION_NAME]) + HAVE_GETPROGNAME=1; AC_SUBST([HAVE_GETPROGNAME]) + HAVE_GETSUBOPT=1; AC_SUBST([HAVE_GETSUBOPT]) + HAVE_GRANTPT=1; AC_SUBST([HAVE_GRANTPT]) + HAVE_INITSTATE=1; AC_SUBST([HAVE_INITSTATE]) + HAVE_DECL_INITSTATE=1; AC_SUBST([HAVE_DECL_INITSTATE]) + HAVE_MBTOWC=1; AC_SUBST([HAVE_MBTOWC]) + HAVE_MKDTEMP=1; AC_SUBST([HAVE_MKDTEMP]) + HAVE_MKOSTEMP=1; AC_SUBST([HAVE_MKOSTEMP]) + HAVE_MKOSTEMPS=1; AC_SUBST([HAVE_MKOSTEMPS]) + HAVE_MKSTEMP=1; AC_SUBST([HAVE_MKSTEMP]) + HAVE_MKSTEMPS=1; AC_SUBST([HAVE_MKSTEMPS]) + HAVE_POSIX_MEMALIGN=1; AC_SUBST([HAVE_POSIX_MEMALIGN]) + HAVE_POSIX_OPENPT=1; AC_SUBST([HAVE_POSIX_OPENPT]) + HAVE_PTSNAME=1; AC_SUBST([HAVE_PTSNAME]) + HAVE_PTSNAME_R=1; AC_SUBST([HAVE_PTSNAME_R]) + HAVE_QSORT_R=1; AC_SUBST([HAVE_QSORT_R]) + HAVE_RANDOM=1; AC_SUBST([HAVE_RANDOM]) + HAVE_RANDOM_H=1; AC_SUBST([HAVE_RANDOM_H]) + HAVE_RANDOM_R=1; AC_SUBST([HAVE_RANDOM_R]) + HAVE_REALLOCARRAY=1; AC_SUBST([HAVE_REALLOCARRAY]) + HAVE_REALPATH=1; AC_SUBST([HAVE_REALPATH]) + HAVE_RPMATCH=1; AC_SUBST([HAVE_RPMATCH]) + HAVE_SECURE_GETENV=1; AC_SUBST([HAVE_SECURE_GETENV]) + HAVE_SETENV=1; AC_SUBST([HAVE_SETENV]) + HAVE_DECL_SETENV=1; AC_SUBST([HAVE_DECL_SETENV]) + HAVE_SETSTATE=1; AC_SUBST([HAVE_SETSTATE]) + HAVE_DECL_SETSTATE=1; AC_SUBST([HAVE_DECL_SETSTATE]) + HAVE_STRTOD=1; AC_SUBST([HAVE_STRTOD]) + HAVE_STRTOL=1; AC_SUBST([HAVE_STRTOL]) + HAVE_STRTOLD=1; AC_SUBST([HAVE_STRTOLD]) + HAVE_STRTOLL=1; AC_SUBST([HAVE_STRTOLL]) + HAVE_STRTOUL=1; AC_SUBST([HAVE_STRTOUL]) + HAVE_STRTOULL=1; AC_SUBST([HAVE_STRTOULL]) + HAVE_STRUCT_RANDOM_DATA=1; AC_SUBST([HAVE_STRUCT_RANDOM_DATA]) + HAVE_SYS_LOADAVG_H=0; AC_SUBST([HAVE_SYS_LOADAVG_H]) + HAVE_UNLOCKPT=1; AC_SUBST([HAVE_UNLOCKPT]) + HAVE_DECL_UNSETENV=1; AC_SUBST([HAVE_DECL_UNSETENV]) + REPLACE__EXIT=0; AC_SUBST([REPLACE__EXIT]) + REPLACE_ALIGNED_ALLOC=0; AC_SUBST([REPLACE_ALIGNED_ALLOC]) + REPLACE_CALLOC_FOR_CALLOC_GNU=0; AC_SUBST([REPLACE_CALLOC_FOR_CALLOC_GNU]) + REPLACE_CALLOC_FOR_CALLOC_POSIX=0; AC_SUBST([REPLACE_CALLOC_FOR_CALLOC_POSIX]) + REPLACE_CANONICALIZE_FILE_NAME=0; AC_SUBST([REPLACE_CANONICALIZE_FILE_NAME]) + REPLACE_FREE=0; AC_SUBST([REPLACE_FREE]) + REPLACE_GETLOADAVG=0; AC_SUBST([REPLACE_GETLOADAVG]) + REPLACE_GETPROGNAME=0; AC_SUBST([REPLACE_GETPROGNAME]) + REPLACE_GETSUBOPT=0; AC_SUBST([REPLACE_GETSUBOPT]) + REPLACE_INITSTATE=0; AC_SUBST([REPLACE_INITSTATE]) + REPLACE_MALLOC_FOR_MALLOC_GNU=0; AC_SUBST([REPLACE_MALLOC_FOR_MALLOC_GNU]) + REPLACE_MALLOC_FOR_MALLOC_POSIX=0; AC_SUBST([REPLACE_MALLOC_FOR_MALLOC_POSIX]) + REPLACE_MB_CUR_MAX=0; AC_SUBST([REPLACE_MB_CUR_MAX]) + REPLACE_MBSTOWCS=0; AC_SUBST([REPLACE_MBSTOWCS]) + REPLACE_MBTOWC=0; AC_SUBST([REPLACE_MBTOWC]) + REPLACE_MKOSTEMP=0; AC_SUBST([REPLACE_MKOSTEMP]) + REPLACE_MKOSTEMPS=0; AC_SUBST([REPLACE_MKOSTEMPS]) + REPLACE_MKSTEMP=0; AC_SUBST([REPLACE_MKSTEMP]) + REPLACE_POSIX_MEMALIGN=0; AC_SUBST([REPLACE_POSIX_MEMALIGN]) + REPLACE_POSIX_OPENPT=0; AC_SUBST([REPLACE_POSIX_OPENPT]) + REPLACE_PTSNAME=0; AC_SUBST([REPLACE_PTSNAME]) + REPLACE_PTSNAME_R=0; AC_SUBST([REPLACE_PTSNAME_R]) + REPLACE_PUTENV=0; AC_SUBST([REPLACE_PUTENV]) + REPLACE_QSORT_R=0; AC_SUBST([REPLACE_QSORT_R]) + REPLACE_RAND=0; AC_SUBST([REPLACE_RAND]) + REPLACE_RANDOM=0; AC_SUBST([REPLACE_RANDOM]) + REPLACE_RANDOM_R=0; AC_SUBST([REPLACE_RANDOM_R]) + REPLACE_REALLOC_FOR_REALLOC_GNU=0; AC_SUBST([REPLACE_REALLOC_FOR_REALLOC_GNU]) + REPLACE_REALLOC_FOR_REALLOC_POSIX=0; AC_SUBST([REPLACE_REALLOC_FOR_REALLOC_POSIX]) + REPLACE_REALLOCARRAY=0; AC_SUBST([REPLACE_REALLOCARRAY]) + REPLACE_REALPATH=0; AC_SUBST([REPLACE_REALPATH]) + REPLACE_SETENV=0; AC_SUBST([REPLACE_SETENV]) + REPLACE_SETSTATE=0; AC_SUBST([REPLACE_SETSTATE]) + REPLACE_STRTOD=0; AC_SUBST([REPLACE_STRTOD]) + REPLACE_STRTOL=0; AC_SUBST([REPLACE_STRTOL]) + REPLACE_STRTOLD=0; AC_SUBST([REPLACE_STRTOLD]) + REPLACE_STRTOLL=0; AC_SUBST([REPLACE_STRTOLL]) + REPLACE_STRTOUL=0; AC_SUBST([REPLACE_STRTOUL]) + REPLACE_STRTOULL=0; AC_SUBST([REPLACE_STRTOULL]) + REPLACE_UNSETENV=0; AC_SUBST([REPLACE_UNSETENV]) + REPLACE_WCTOMB=0; AC_SUBST([REPLACE_WCTOMB]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/stpcpy.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/stpcpy.m4 new file mode 100644 index 00000000..04c8bbe4 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/stpcpy.m4 @@ -0,0 +1,28 @@ +# stpcpy.m4 serial 11 +dnl Copyright (C) 2002, 2007, 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_STPCPY], +[ + dnl Persuade glibc to declare stpcpy(). + AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) + + dnl The stpcpy() declaration in lib/string.in.h uses 'restrict'. + AC_REQUIRE([AC_C_RESTRICT]) + + AC_REQUIRE([gl_STRING_H_DEFAULTS]) + gl_CHECK_FUNCS_ANDROID([stpcpy], [[#include ]]) + if test $ac_cv_func_stpcpy = no; then + HAVE_STPCPY=0 + case "$gl_cv_onwards_func_stpcpy" in + future*) REPLACE_STPCPY=1 ;; + esac + fi +]) + +# Prerequisites of lib/stpcpy.c. +AC_DEFUN([gl_PREREQ_STPCPY], [ + : +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/strcase.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/strcase.m4 new file mode 100644 index 00000000..3252a62c --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/strcase.m4 @@ -0,0 +1,45 @@ +# strcase.m4 serial 12 +dnl Copyright (C) 2002, 2005-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_STRCASE], +[ + gl_FUNC_STRCASECMP + gl_FUNC_STRNCASECMP +]) + +AC_DEFUN([gl_FUNC_STRCASECMP], +[ + AC_REQUIRE([gl_STRINGS_H_DEFAULTS]) + AC_CHECK_FUNCS([strcasecmp]) + if test $ac_cv_func_strcasecmp = no; then + HAVE_STRCASECMP=0 + fi +]) + +AC_DEFUN([gl_FUNC_STRNCASECMP], +[ + AC_REQUIRE([gl_STRINGS_H_DEFAULTS]) + AC_CHECK_FUNCS([strncasecmp]) + if test $ac_cv_func_strncasecmp = yes; then + HAVE_STRNCASECMP=1 + else + HAVE_STRNCASECMP=0 + fi + AC_CHECK_DECLS([strncasecmp]) + if test $ac_cv_have_decl_strncasecmp = no; then + HAVE_DECL_STRNCASECMP=0 + fi +]) + +# Prerequisites of lib/strcasecmp.c. +AC_DEFUN([gl_PREREQ_STRCASECMP], [ + : +]) + +# Prerequisites of lib/strncasecmp.c. +AC_DEFUN([gl_PREREQ_STRNCASECMP], [ + : +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/strdup.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/strdup.m4 new file mode 100644 index 00000000..491f760c --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/strdup.m4 @@ -0,0 +1,32 @@ +# strdup.m4 serial 15 + +dnl Copyright (C) 2002-2024 Free Software Foundation, Inc. + +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_STRDUP], +[ + AC_REQUIRE([gl_STRING_H_DEFAULTS]) + AC_CHECK_DECLS_ONCE([strdup]) + if test $ac_cv_have_decl_strdup = no; then + HAVE_DECL_STRDUP=0 + fi +]) + +AC_DEFUN([gl_FUNC_STRDUP_POSIX], +[ + AC_REQUIRE([gl_STRING_H_DEFAULTS]) + AC_REQUIRE([gl_CHECK_MALLOC_POSIX]) + if test $gl_cv_func_malloc_posix != yes; then + REPLACE_STRDUP=1 + fi + AC_CHECK_DECLS_ONCE([strdup]) + if test $ac_cv_have_decl_strdup = no; then + HAVE_DECL_STRDUP=0 + fi +]) + +# Prerequisites of lib/strdup.c. +AC_DEFUN([gl_PREREQ_STRDUP], [:]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/strerror.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/strerror.m4 new file mode 100644 index 00000000..a1d12612 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/strerror.m4 @@ -0,0 +1,102 @@ +# strerror.m4 serial 25 +dnl Copyright (C) 2002, 2007-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_STRERROR], +[ + AC_REQUIRE([gl_STRING_H_DEFAULTS]) + AC_REQUIRE([gl_HEADER_ERRNO_H]) + AC_REQUIRE([gl_FUNC_STRERROR_0]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + m4_ifdef([gl_FUNC_STRERROR_R_WORKS], [ + AC_REQUIRE([gl_FUNC_STRERROR_R_WORKS]) + ]) + if test "$GL_GENERATE_ERRNO_H:$REPLACE_STRERROR_0" = false:0; then + AC_CACHE_CHECK([for working strerror function], + [gl_cv_func_working_strerror], + [AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [[#include + ]], + [[if (!*strerror (-2)) return 1;]])], + [gl_cv_func_working_strerror=yes], + [gl_cv_func_working_strerror=no], + [case "$host_os" in + # Guess yes on glibc systems. + *-gnu* | gnu*) gl_cv_func_working_strerror="guessing yes" ;; + # Guess yes on musl systems. + *-musl* | midipix*) gl_cv_func_working_strerror="guessing yes" ;; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_working_strerror="$gl_cross_guess_normal" ;; + esac + ]) + ]) + case "$gl_cv_func_working_strerror" in + *yes) ;; + *) + dnl The system's strerror() fails to return a string for out-of-range + dnl integers. Replace it. + REPLACE_STRERROR=1 + ;; + esac + m4_ifdef([gl_FUNC_STRERROR_R_WORKS], [ + dnl If the system's strerror_r or __xpg_strerror_r clobbers strerror's + dnl buffer, we must replace strerror. + case "$gl_cv_func_strerror_r_works" in + *no) REPLACE_STRERROR=1 ;; + esac + ]) + else + dnl The system's strerror() cannot know about the new errno values we add + dnl to , or any fix for strerror(0). Replace it. + REPLACE_STRERROR=1 + fi +]) + +dnl Detect if strerror(0) passes (that is, does not set errno, and does not +dnl return a string that matches strerror(-1)). +AC_DEFUN([gl_FUNC_STRERROR_0], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + REPLACE_STRERROR_0=0 + AC_CACHE_CHECK([whether strerror(0) succeeds], + [gl_cv_func_strerror_0_works], + [AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [[#include + #include + ]], + [[int result = 0; + char *str; + errno = 0; + str = strerror (0); + if (!*str) result |= 1; + if (errno) result |= 2; + if (strstr (str, "nknown") || strstr (str, "ndefined")) + result |= 4; + return result;]])], + [gl_cv_func_strerror_0_works=yes], + [gl_cv_func_strerror_0_works=no], + [case "$host_os" in + # Guess yes on glibc systems. + *-gnu* | gnu*) gl_cv_func_strerror_0_works="guessing yes" ;; + # Guess yes on musl systems. + *-musl* | midipix*) gl_cv_func_strerror_0_works="guessing yes" ;; + # Guess yes on native Windows. + mingw* | windows*) gl_cv_func_strerror_0_works="guessing yes" ;; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_strerror_0_works="$gl_cross_guess_normal" ;; + esac + ]) + ]) + case "$gl_cv_func_strerror_0_works" in + *yes) ;; + *) + REPLACE_STRERROR_0=1 + AC_DEFINE([REPLACE_STRERROR_0], [1], [Define to 1 if strerror(0) + does not return a message implying success.]) + ;; + esac +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/strerror_r.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/strerror_r.m4 new file mode 100644 index 00000000..903d03c3 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/strerror_r.m4 @@ -0,0 +1,180 @@ +# strerror_r.m4 serial 26 +dnl Copyright (C) 2002, 2007-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_STRERROR_R], +[ + AC_REQUIRE([gl_STRING_H_DEFAULTS]) + AC_REQUIRE([gl_FUNC_STRERROR_R_WORKS]) + + dnl Some systems don't declare strerror_r() if _THREAD_SAFE and _REENTRANT + dnl are not defined. + AC_CHECK_DECLS_ONCE([strerror_r]) + if test $ac_cv_have_decl_strerror_r = no; then + HAVE_DECL_STRERROR_R=0 + fi + + if test $ac_cv_func_strerror_r = yes; then + if test "$GL_GENERATE_ERRNO_H:$REPLACE_STRERROR_0" = false:0; then + if test $gl_cv_func_strerror_r_posix_signature = yes; then + case "$gl_cv_func_strerror_r_works" in + dnl The system's strerror_r has bugs. Replace it. + *no) REPLACE_STRERROR_R=1 ;; + esac + else + dnl The system's strerror_r() has a wrong signature. Replace it. + REPLACE_STRERROR_R=1 + fi + else + dnl The system's strerror_r() cannot know about the new errno values we + dnl add to , or any fix for strerror(0). Replace it. + REPLACE_STRERROR_R=1 + fi + fi +]) + +# Prerequisites of lib/strerror_r.c. +AC_DEFUN([gl_PREREQ_STRERROR_R], [ + AC_REQUIRE([AC_FUNC_STRERROR_R]) + dnl glibc >= 2.3.4 and cygwin 1.7.9 have a function __xpg_strerror_r. + AC_CHECK_FUNCS_ONCE([__xpg_strerror_r]) + gl_CHECK_FUNCS_ANDROID([catgets], [[#include ]]) + AC_CHECK_FUNCS_ONCE([snprintf]) +]) + +# Detect if strerror_r works, but without affecting whether a replacement +# strerror_r will be used. +AC_DEFUN([gl_FUNC_STRERROR_R_WORKS], +[ + AC_REQUIRE([gl_HEADER_ERRNO_H]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + + dnl Persuade Android to use the GNU strerror_r API, + dnl and Solaris to declare strerror_r. + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + + AC_REQUIRE([gl_FUNC_STRERROR_0]) + + gl_CHECK_FUNCS_ANDROID([strerror_r], [[#include ]]) + if test $ac_cv_func_strerror_r = yes; then + if test "$GL_GENERATE_ERRNO_H:$REPLACE_STRERROR_0" = false:0; then + dnl The POSIX prototype is: int strerror_r (int, char *, size_t); + dnl glibc, Cygwin: char *strerror_r (int, char *, size_t); + dnl AIX 5.1, OSF/1 5.1: int strerror_r (int, char *, int); + AC_CACHE_CHECK([for strerror_r with POSIX signature], + [gl_cv_func_strerror_r_posix_signature], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include + int strerror_r (int, char *, size_t); + ]], + [])], + [gl_cv_func_strerror_r_posix_signature=yes], + [gl_cv_func_strerror_r_posix_signature=no]) + ]) + if test $gl_cv_func_strerror_r_posix_signature = yes; then + dnl AIX 6.1 strerror_r fails by returning -1, not an error number. + dnl HP-UX 11.31 strerror_r always fails when the buffer length argument + dnl is less than 80. + dnl FreeBSD 8.s strerror_r claims failure on 0 + dnl Mac OS X 10.5 strerror_r treats 0 like -1 + dnl Solaris 10 strerror_r corrupts errno on failure + AC_CACHE_CHECK([whether strerror_r works], + [gl_cv_func_strerror_r_works], + [AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [[#include + #include + ]], + [[int result = 0; + char buf[79]; + if (strerror_r (EACCES, buf, 0) < 0) + result |= 1; + errno = 0; + if (strerror_r (EACCES, buf, sizeof buf) != 0) + result |= 2; + strcpy (buf, "Unknown"); + if (strerror_r (0, buf, sizeof buf) != 0) + result |= 4; + if (errno) + result |= 8; + if (strstr (buf, "nknown") || strstr (buf, "ndefined")) + result |= 0x10; + errno = 0; + *buf = 0; + if (strerror_r (-3, buf, sizeof buf) < 0) + result |= 0x20; + if (errno) + result |= 0x40; + if (!*buf) + result |= 0x80; + return result; + ]])], + [gl_cv_func_strerror_r_works=yes], + [gl_cv_func_strerror_r_works=no], + [ +changequote(,)dnl + case "$host_os" in + # Guess no on AIX. + aix*) gl_cv_func_strerror_r_works="guessing no";; + # Guess no on HP-UX. + hpux*) gl_cv_func_strerror_r_works="guessing no";; + # Guess no on BSD variants. + *bsd*) gl_cv_func_strerror_r_works="guessing no";; + # Guess yes otherwise. + *) gl_cv_func_strerror_r_works="guessing yes";; + esac +changequote([,])dnl + ]) + ]) + else + dnl The system's strerror() has a wrong signature. + dnl glibc >= 2.3.4 and cygwin 1.7.9 have a function __xpg_strerror_r. + AC_CHECK_FUNCS_ONCE([__xpg_strerror_r]) + dnl In glibc < 2.14, __xpg_strerror_r does not populate buf on failure. + dnl In cygwin < 1.7.10, __xpg_strerror_r clobbers strerror's buffer. + if test $ac_cv_func___xpg_strerror_r = yes; then + AC_CACHE_CHECK([whether __xpg_strerror_r works], + [gl_cv_func_strerror_r_works], + [AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [[#include + #include + extern + #ifdef __cplusplus + "C" + #endif + int __xpg_strerror_r(int, char *, size_t); + ]], + [[int result = 0; + char buf[256] = "^"; + char copy[256]; + char *str = strerror (-1); + strcpy (copy, str); + if (__xpg_strerror_r (-2, buf, 1) == 0) + result |= 1; + if (*buf) + result |= 2; + __xpg_strerror_r (-2, buf, 256); + if (strcmp (str, copy)) + result |= 4; + return result; + ]])], + [gl_cv_func_strerror_r_works=yes], + [gl_cv_func_strerror_r_works=no], + [dnl Guess no on all platforms that have __xpg_strerror_r, + dnl at least until fixed glibc and cygwin are more common. + gl_cv_func_strerror_r_works="$gl_cross_guess_normal" + ]) + ]) + fi + fi + fi + else + case "$gl_cv_onwards_func_strerror_r" in + future*) REPLACE_STRERROR_R=1 ;; + esac + fi +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/string_h.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/string_h.m4 new file mode 100644 index 00000000..9ea748cc --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/string_h.m4 @@ -0,0 +1,152 @@ +# Configure a GNU-like replacement for . + +# Copyright (C) 2007-2024 Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 39 + +# Written by Paul Eggert. + +AC_DEFUN_ONCE([gl_STRING_H], +[ + dnl Ensure to expand the default settings once only, before all statements + dnl that occur in other macros. + AC_REQUIRE([gl_STRING_H_DEFAULTS]) + gl_NEXT_HEADERS([string.h]) + + dnl Check for declarations of anything we want to poison if the + dnl corresponding gnulib module is not in use, and which is not + dnl guaranteed by C89. + gl_WARN_ON_USE_PREPARE([[#include + ]], + [explicit_bzero ffsl ffsll memmem mempcpy memrchr memset_explicit + rawmemchr stpcpy stpncpy strchrnul + strdup strncat strndup strnlen strpbrk strsep strcasestr strtok_r + strerror_r strerrorname_np sigabbrev_np sigdescr_np strsignal strverscmp]) + + AC_REQUIRE([AC_C_RESTRICT]) +]) + +# gl_STRING_MODULE_INDICATOR([modulename]) +# sets the shell variable that indicates the presence of the given module +# to a C preprocessor expression that will evaluate to 1. +# This macro invocation must not occur in macros that are AC_REQUIREd. +AC_DEFUN([gl_STRING_MODULE_INDICATOR], +[ + dnl Ensure to expand the default settings once only. + gl_STRING_H_REQUIRE_DEFAULTS + gl_MODULE_INDICATOR_SET_VARIABLE([$1]) + dnl Define it also as a C macro, for the benefit of the unit tests. + gl_MODULE_INDICATOR_FOR_TESTS([$1]) +]) + +# Initializes the default values for AC_SUBSTed shell variables. +# This macro must not be AC_REQUIREd. It must only be invoked, and only +# outside of macros or in macros that are not AC_REQUIREd. +AC_DEFUN([gl_STRING_H_REQUIRE_DEFAULTS], +[ + m4_defun(GL_MODULE_INDICATOR_PREFIX[_STRING_H_MODULE_INDICATOR_DEFAULTS], [ + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXPLICIT_BZERO]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FFSL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FFSLL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MEMCHR]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MEMMEM]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MEMPCPY]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MEMRCHR]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MEMSET_EXPLICIT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RAWMEMCHR]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STPCPY]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STPNCPY]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRCHRNUL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRDUP]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRNCAT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRNDUP]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRNLEN]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRPBRK]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRSEP]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRSTR]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRCASESTR]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOK_R]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSLEN]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSNLEN]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSCHR]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSRCHR]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSSTR]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSCASECMP]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSNCASECMP]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSPCASECMP]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSCASESTR]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSCSPN]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSPBRK]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSSPN]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSSEP]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSTOK_R]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRERROR]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRERROR_R]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRERRORNAME_NP]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SIGABBREV_NP]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SIGDESCR_NP]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRSIGNAL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRVERSCMP]) + dnl Support Microsoft deprecated alias function names by default. + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_MEMCCPY], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_STRDUP], [1]) + ]) + m4_require(GL_MODULE_INDICATOR_PREFIX[_STRING_H_MODULE_INDICATOR_DEFAULTS]) + dnl Make sure the shell variable for GNULIB_FREE_POSIX is initialized. + gl_STDLIB_H_REQUIRE_DEFAULTS + AC_REQUIRE([gl_STRING_H_DEFAULTS]) +]) + +AC_DEFUN([gl_STRING_H_DEFAULTS], +[ + HAVE_MBSLEN=0; AC_SUBST([HAVE_MBSLEN]) + dnl Assume proper GNU behavior unless another module says otherwise. + HAVE_EXPLICIT_BZERO=1; AC_SUBST([HAVE_EXPLICIT_BZERO]) + HAVE_FFSL=1; AC_SUBST([HAVE_FFSL]) + HAVE_FFSLL=1; AC_SUBST([HAVE_FFSLL]) + HAVE_DECL_MEMMEM=1; AC_SUBST([HAVE_DECL_MEMMEM]) + HAVE_MEMPCPY=1; AC_SUBST([HAVE_MEMPCPY]) + HAVE_MEMSET_EXPLICIT=1; AC_SUBST([HAVE_MEMSET_EXPLICIT]) + HAVE_DECL_MEMRCHR=1; AC_SUBST([HAVE_DECL_MEMRCHR]) + HAVE_RAWMEMCHR=1; AC_SUBST([HAVE_RAWMEMCHR]) + HAVE_STPCPY=1; AC_SUBST([HAVE_STPCPY]) + HAVE_STPNCPY=1; AC_SUBST([HAVE_STPNCPY]) + HAVE_STRCHRNUL=1; AC_SUBST([HAVE_STRCHRNUL]) + HAVE_DECL_STRDUP=1; AC_SUBST([HAVE_DECL_STRDUP]) + HAVE_DECL_STRNDUP=1; AC_SUBST([HAVE_DECL_STRNDUP]) + HAVE_DECL_STRNLEN=1; AC_SUBST([HAVE_DECL_STRNLEN]) + HAVE_STRPBRK=1; AC_SUBST([HAVE_STRPBRK]) + HAVE_STRSEP=1; AC_SUBST([HAVE_STRSEP]) + HAVE_STRCASESTR=1; AC_SUBST([HAVE_STRCASESTR]) + HAVE_DECL_STRTOK_R=1; AC_SUBST([HAVE_DECL_STRTOK_R]) + HAVE_DECL_STRERROR_R=1; AC_SUBST([HAVE_DECL_STRERROR_R]) + HAVE_STRERRORNAME_NP=1; AC_SUBST([HAVE_STRERRORNAME_NP]) + HAVE_SIGABBREV_NP=1; AC_SUBST([HAVE_SIGABBREV_NP]) + HAVE_SIGDESCR_NP=1; AC_SUBST([HAVE_SIGDESCR_NP]) + HAVE_DECL_STRSIGNAL=1; AC_SUBST([HAVE_DECL_STRSIGNAL]) + HAVE_STRVERSCMP=1; AC_SUBST([HAVE_STRVERSCMP]) + REPLACE_FFSLL=0; AC_SUBST([REPLACE_FFSLL]) + REPLACE_MEMCHR=0; AC_SUBST([REPLACE_MEMCHR]) + REPLACE_MEMMEM=0; AC_SUBST([REPLACE_MEMMEM]) + REPLACE_MEMPCPY=0; AC_SUBST([REPLACE_MEMPCPY]) + REPLACE_MEMSET_EXPLICIT=0; AC_SUBST([REPLACE_MEMSET_EXPLICIT]) + REPLACE_STPCPY=0; AC_SUBST([REPLACE_STPCPY]) + REPLACE_STPNCPY=0; AC_SUBST([REPLACE_STPNCPY]) + REPLACE_STRCHRNUL=0; AC_SUBST([REPLACE_STRCHRNUL]) + REPLACE_STRDUP=0; AC_SUBST([REPLACE_STRDUP]) + REPLACE_STRNCAT=0; AC_SUBST([REPLACE_STRNCAT]) + REPLACE_STRNDUP=0; AC_SUBST([REPLACE_STRNDUP]) + REPLACE_STRNLEN=0; AC_SUBST([REPLACE_STRNLEN]) + REPLACE_STRSTR=0; AC_SUBST([REPLACE_STRSTR]) + REPLACE_STRCASESTR=0; AC_SUBST([REPLACE_STRCASESTR]) + REPLACE_STRTOK_R=0; AC_SUBST([REPLACE_STRTOK_R]) + REPLACE_STRERROR=0; AC_SUBST([REPLACE_STRERROR]) + REPLACE_STRERROR_R=0; AC_SUBST([REPLACE_STRERROR_R]) + REPLACE_STRERRORNAME_NP=0; AC_SUBST([REPLACE_STRERRORNAME_NP]) + REPLACE_STRSIGNAL=0; AC_SUBST([REPLACE_STRSIGNAL]) + REPLACE_STRVERSCMP=0; AC_SUBST([REPLACE_STRVERSCMP]) + UNDEFINE_STRTOK_R=0; AC_SUBST([UNDEFINE_STRTOK_R]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/strings_h.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/strings_h.m4 new file mode 100644 index 00000000..37b6ca9b --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/strings_h.m4 @@ -0,0 +1,62 @@ +# Configure a replacement for . +# serial 9 + +# Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +AC_DEFUN_ONCE([gl_STRINGS_H], +[ + dnl Ensure to expand the default settings once only, before all statements + dnl that occur in other macros. + AC_REQUIRE([gl_STRINGS_H_DEFAULTS]) + + gl_CHECK_NEXT_HEADERS([strings.h]) + if test $ac_cv_header_strings_h = yes; then + HAVE_STRINGS_H=1 + else + HAVE_STRINGS_H=0 + fi + AC_SUBST([HAVE_STRINGS_H]) + + dnl Check for declarations of anything we want to poison if the + dnl corresponding gnulib module is not in use. + gl_WARN_ON_USE_PREPARE([[ + /* Minix 3.1.8 has a bug: must be included before + . */ + #include + #include + ]], [ffs strcasecmp strncasecmp]) +]) + +# gl_STRINGS_MODULE_INDICATOR([modulename]) +# sets the shell variable that indicates the presence of the given module +# to a C preprocessor expression that will evaluate to 1. +# This macro invocation must not occur in macros that are AC_REQUIREd. +AC_DEFUN([gl_STRINGS_MODULE_INDICATOR], +[ + dnl Ensure to expand the default settings once only. + gl_STRINGS_H_REQUIRE_DEFAULTS + gl_MODULE_INDICATOR_SET_VARIABLE([$1]) +]) + +# Initializes the default values for AC_SUBSTed shell variables. +# This macro must not be AC_REQUIREd. It must only be invoked, and only +# outside of macros or in macros that are not AC_REQUIREd. +AC_DEFUN([gl_STRINGS_H_REQUIRE_DEFAULTS], +[ + m4_defun(GL_MODULE_INDICATOR_PREFIX[_STRINGS_H_MODULE_INDICATOR_DEFAULTS], [ + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FFS]) + ]) + m4_require(GL_MODULE_INDICATOR_PREFIX[_STRINGS_H_MODULE_INDICATOR_DEFAULTS]) + AC_REQUIRE([gl_STRINGS_H_DEFAULTS]) +]) + +AC_DEFUN([gl_STRINGS_H_DEFAULTS], +[ + dnl Assume proper GNU behavior unless another module says otherwise. + HAVE_FFS=1; AC_SUBST([HAVE_FFS]) + HAVE_STRCASECMP=1; AC_SUBST([HAVE_STRCASECMP]) + HAVE_DECL_STRNCASECMP=1; AC_SUBST([HAVE_DECL_STRNCASECMP]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/strnlen.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/strnlen.m4 new file mode 100644 index 00000000..3eac8e62 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/strnlen.m4 @@ -0,0 +1,30 @@ +# strnlen.m4 serial 14 +dnl Copyright (C) 2002-2003, 2005-2007, 2009-2024 Free Software Foundation, +dnl Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_STRNLEN], +[ + AC_REQUIRE([gl_STRING_H_DEFAULTS]) + + dnl Persuade glibc to declare strnlen(). + AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) + + AC_CHECK_DECLS_ONCE([strnlen]) + if test $ac_cv_have_decl_strnlen = no; then + HAVE_DECL_STRNLEN=0 + else + m4_pushdef([AC_LIBOBJ], [:]) + dnl Note: AC_FUNC_STRNLEN does AC_LIBOBJ([strnlen]). + AC_FUNC_STRNLEN + m4_popdef([AC_LIBOBJ]) + if test $ac_cv_func_strnlen_working = no; then + REPLACE_STRNLEN=1 + fi + fi +]) + +# Prerequisites of lib/strnlen.c. +AC_DEFUN([gl_PREREQ_STRNLEN], [:]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/strptime.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/strptime.m4 new file mode 100644 index 00000000..778c2759 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/strptime.m4 @@ -0,0 +1,22 @@ +# strptime.m4 serial 8 +dnl Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_STRPTIME], +[ + AC_REQUIRE([gl_TIME_H_DEFAULTS]) + AC_REQUIRE([AC_C_RESTRICT]) + AC_CHECK_FUNCS_ONCE([strptime]) + if test $ac_cv_func_strptime != yes; then + HAVE_STRPTIME=0 + fi +]) + +# Prerequisites of lib/strptime.c. +AC_DEFUN([gl_PREREQ_STRPTIME], +[ + AC_REQUIRE([gl_TM_GMTOFF]) + : +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/strtoimax.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/strtoimax.m4 new file mode 100644 index 00000000..b58fa48f --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/strtoimax.m4 @@ -0,0 +1,88 @@ +# strtoimax.m4 serial 17 +dnl Copyright (C) 2002-2004, 2006, 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_STRTOIMAX], +[ + AC_REQUIRE([gl_INTTYPES_H_DEFAULTS]) + + dnl On OSF/1 5.1 with cc, this function is declared but not defined. + AC_CHECK_FUNCS_ONCE([strtoimax]) + AC_CHECK_DECLS_ONCE([strtoimax]) + if test "$ac_cv_have_decl_strtoimax" != yes; then + HAVE_DECL_STRTOIMAX=0 + fi + + if test "$ac_cv_func_strtoimax" = yes; then + HAVE_STRTOIMAX=1 + dnl On AIX 5.1, strtoimax() fails for values outside the 'int' range. + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether strtoimax works], [gl_cv_func_strtoimax], + [AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +#include +int main () +{ + if (sizeof (intmax_t) > sizeof (int)) + { + const char *s = "4294967295"; + char *p; + intmax_t res; + errno = 0; + res = strtoimax (s, &p, 10); + if (p != s + strlen (s)) + return 1; + if (errno != 0) + return 2; + if (res != (intmax_t) 65535 * (intmax_t) 65537) + return 3; + } + else + { + const char *s = "2147483647"; + char *p; + intmax_t res; + errno = 0; + res = strtoimax (s, &p, 10); + if (p != s + strlen (s)) + return 1; + if (errno != 0) + return 2; + if (res != 2147483647) + return 3; + } + return 0; +} +]])], + [gl_cv_func_strtoimax=yes], + [gl_cv_func_strtoimax=no], + [case "$host_os" in + # Guess no on AIX 5. + aix5*) gl_cv_func_strtoimax="guessing no" ;; + # Guess yes on native Windows. + mingw* | windows*) gl_cv_func_strtoimax="guessing yes" ;; + # Guess yes otherwise. + *) gl_cv_func_strtoimax="guessing yes" ;; + esac + ]) + ]) + case "$gl_cv_func_strtoimax" in + *no) REPLACE_STRTOIMAX=1 ;; + esac + else + if test "$ac_cv_have_decl_strtoimax" = yes; then + # HP-UX 11.11 has "#define strtoimax(...) ..." but no function. + REPLACE_STRTOIMAX=1 + fi + HAVE_STRTOIMAX=0 + fi +]) + +# Prerequisites of lib/strtoimax.c. +AC_DEFUN([gl_PREREQ_STRTOIMAX], [ + AC_CHECK_DECLS([strtoll]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/strtoll.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/strtoll.m4 new file mode 100644 index 00000000..130b9094 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/strtoll.m4 @@ -0,0 +1,68 @@ +# strtoll.m4 serial 12 +dnl Copyright (C) 2002, 2004, 2006, 2008-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_STRTOLL], +[ + AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_CHECK_FUNCS([strtoll]) + if test $ac_cv_func_strtoll = yes; then + AC_CACHE_CHECK([whether strtoll works], + [gl_cv_func_strtoll_works], + [AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [[#include ]], + [[int result = 0; + char *term; + /* This test fails on Minix and native Windows. */ + { + static char const input[2][3] = {"0x", "0b"}; + static int const base[] = {0, 2, 10}; + int i, j; + for (i = 0; i < 2; i++) + for (j = 0; j < 3; j++) + { + (void) strtoll (input[i], &term, base[j]); + if (term != input[i] + 1) + result |= 1; + } + } + /* This test fails on pre-C23 platforms. */ + { + const char input[] = "0b1"; + (void) strtoll (input, &term, 2); + if (term != input + 3) + result |= 2; + } + return result; + ]]) + ], + [gl_cv_func_strtoll_works=yes], + [gl_cv_func_strtoll_works=no], + [case "$host_os" in + # Guess no on native Windows. + mingw* | windows*) gl_cv_func_strtoll_works="guessing no" ;; + # Guess no on glibc systems. + *-gnu* | gnu*) gl_cv_func_strtoll_works="guessing no" ;; + # Guess no on musl systems. + *-musl* | midipix*) gl_cv_func_strtoll_works="guessing no" ;; + *) gl_cv_func_strtoll_works="$gl_cross_guess_normal" ;; + esac + ]) + ]) + case "$gl_cv_func_strtoll_works" in + *yes) ;; + *) REPLACE_STRTOLL=1 ;; + esac + else + HAVE_STRTOLL=0 + fi +]) + +# Prerequisites of lib/strtoll.c. +AC_DEFUN([gl_PREREQ_STRTOLL], [ + : +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/symlink.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/symlink.m4 new file mode 100644 index 00000000..62062cf1 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/symlink.m4 @@ -0,0 +1,57 @@ +# serial 10 +# See if we need to provide symlink replacement. + +dnl Copyright (C) 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +# Written by Eric Blake. + +AC_DEFUN([gl_FUNC_SYMLINK], +[ + AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CHECK_FUNCS_ONCE([symlink]) + dnl The best we can do on mingw is provide a dummy that always fails, so + dnl that compilation can proceed with fewer ifdefs. On FreeBSD 7.2, AIX 7.1, + dnl and Solaris 9, we want to fix a bug with trailing slash handling. + if test $ac_cv_func_symlink = no; then + HAVE_SYMLINK=0 + else + AC_CACHE_CHECK([whether symlink handles trailing slash correctly], + [gl_cv_func_symlink_works], + [AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [[#include + ]], + [[int result = 0; + if (!symlink ("a", "conftest.link/")) + result |= 1; + if (symlink ("conftest.f", "conftest.lnk2")) + result |= 2; + else if (!symlink ("a", "conftest.lnk2/")) + result |= 4; + return result; + ]])], + [gl_cv_func_symlink_works=yes], [gl_cv_func_symlink_works=no], + [case "$host_os" in + # Guess yes on Linux systems. + linux-* | linux) gl_cv_func_symlink_works="guessing yes" ;; + # Guess yes on systems that emulate the Linux system calls. + midipix*) gl_cv_func_symlink_works="guessing yes" ;; + # Guess yes on glibc systems. + *-gnu* | gnu*) gl_cv_func_symlink_works="guessing yes" ;; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_symlink_works="$gl_cross_guess_normal" ;; + esac + ]) + rm -f conftest.f conftest.link conftest.lnk2]) + case "$gl_cv_func_symlink_works" in + *yes) ;; + *) + REPLACE_SYMLINK=1 + ;; + esac + fi +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/symlinkat.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/symlinkat.m4 new file mode 100644 index 00000000..afc045d4 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/symlinkat.m4 @@ -0,0 +1,61 @@ +# serial 13 +# See if we need to provide symlinkat replacement. + +dnl Copyright (C) 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +# Written by Eric Blake. + +AC_DEFUN([gl_FUNC_SYMLINKAT], +[ + AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) + AC_REQUIRE([gl_FUNC_OPENAT]) + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + gl_CHECK_FUNCS_ANDROID([symlinkat], [[#include ]]) + if test $ac_cv_func_symlinkat = no; then + HAVE_SYMLINKAT=0 + case "$gl_cv_onwards_func_symlinkat" in + future*) REPLACE_SYMLINKAT=1 ;; + esac + else + AC_CACHE_CHECK([whether symlinkat handles trailing slash correctly], + [gl_cv_func_symlinkat_works], + [AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [[#include + #include + ]], + [[int result = 0; + if (!symlinkat ("a", AT_FDCWD, "conftest.link/")) + result |= 1; + if (symlinkat ("conftest.f", AT_FDCWD, "conftest.lnk2")) + result |= 2; + else if (!symlinkat ("a", AT_FDCWD, "conftest.lnk2/")) + result |= 4; + return result; + ]])], + [gl_cv_func_symlinkat_works=yes], + [gl_cv_func_symlinkat_works=no], + [case "$host_os" in + # Guess yes on Linux systems. + linux-* | linux) gl_cv_func_symlinkat_works="guessing yes" ;; + # Guess yes on systems that emulate the Linux system calls. + midipix*) gl_cv_func_symlinkat_works="guessing yes" ;; + # Guess yes on glibc systems. + *-gnu* | gnu*) gl_cv_func_symlinkat_works="guessing yes" ;; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_symlinkat_works="$gl_cross_guess_normal" ;; + esac + ]) + rm -f conftest.f conftest.link conftest.lnk2]) + case "$gl_cv_func_symlinkat_works" in + *yes) ;; + *) + REPLACE_SYMLINKAT=1 + ;; + esac + fi +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sys_ioctl_h.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sys_ioctl_h.m4 new file mode 100644 index 00000000..3e789f3d --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sys_ioctl_h.m4 @@ -0,0 +1,79 @@ +# sys_ioctl_h.m4 serial 15 +dnl Copyright (C) 2008-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl Written by Bruno Haible. + +AC_DEFUN_ONCE([gl_SYS_IOCTL_H], +[ + dnl Ensure to expand the default settings once only, before all statements + dnl that occur in other macros. + AC_REQUIRE([gl_SYS_IOCTL_H_DEFAULTS]) + + AC_CHECK_HEADERS_ONCE([sys/ioctl.h]) + if test $ac_cv_header_sys_ioctl_h = yes; then + HAVE_SYS_IOCTL_H=1 + dnl Test whether declares ioctl(), or whether some other + dnl header file, such as or , is needed for that. + AC_CACHE_CHECK([whether declares ioctl], + [gl_cv_decl_ioctl_in_sys_ioctl_h], + [dnl We cannot use AC_CHECK_DECL because it produces its own messages. + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include ]], + [[(void) ioctl;]])], + [gl_cv_decl_ioctl_in_sys_ioctl_h=yes], + [gl_cv_decl_ioctl_in_sys_ioctl_h=no]) + ]) + else + HAVE_SYS_IOCTL_H=0 + fi + AC_SUBST([HAVE_SYS_IOCTL_H]) + dnl is always overridden, because of GNULIB_POSIXCHECK. + gl_CHECK_NEXT_HEADERS([sys/ioctl.h]) + + dnl Check for declarations of anything we want to poison if the + dnl corresponding gnulib module is not in use. + gl_WARN_ON_USE_PREPARE([[#include +/* Some platforms declare ioctl in the wrong header. */ +#if !(defined __GLIBC__ && !defined __UCLIBC__) +# include +#endif + ]], [ioctl]) +]) + +# gl_SYS_IOCTL_MODULE_INDICATOR([modulename]) +# sets the shell variable that indicates the presence of the given module +# to a C preprocessor expression that will evaluate to 1. +# This macro invocation must not occur in macros that are AC_REQUIREd. +AC_DEFUN([gl_SYS_IOCTL_MODULE_INDICATOR], +[ + dnl Ensure to expand the default settings once only. + gl_SYS_IOCTL_H_REQUIRE_DEFAULTS + gl_MODULE_INDICATOR_SET_VARIABLE([$1]) + dnl Define it also as a C macro, for the benefit of the unit tests. + gl_MODULE_INDICATOR_FOR_TESTS([$1]) +]) + +# Initializes the default values for AC_SUBSTed shell variables. +# This macro must not be AC_REQUIREd. It must only be invoked, and only +# outside of macros or in macros that are not AC_REQUIREd. +AC_DEFUN([gl_SYS_IOCTL_H_REQUIRE_DEFAULTS], +[ + m4_defun(GL_MODULE_INDICATOR_PREFIX[_SYS_IOCTL_H_MODULE_INDICATOR_DEFAULTS], [ + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_IOCTL]) + ]) + m4_require(GL_MODULE_INDICATOR_PREFIX[_SYS_IOCTL_H_MODULE_INDICATOR_DEFAULTS]) + AC_REQUIRE([gl_SYS_IOCTL_H_DEFAULTS]) +]) + +AC_DEFUN([gl_SYS_IOCTL_H_DEFAULTS], +[ + dnl Assume proper GNU behavior unless another module says otherwise. + SYS_IOCTL_H_HAVE_WINSOCK2_H=0; AC_SUBST([SYS_IOCTL_H_HAVE_WINSOCK2_H]) + SYS_IOCTL_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS=0; + AC_SUBST([SYS_IOCTL_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS]) + REPLACE_IOCTL=0; AC_SUBST([REPLACE_IOCTL]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sys_random_h.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sys_random_h.m4 new file mode 100644 index 00000000..b050d079 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sys_random_h.m4 @@ -0,0 +1,68 @@ +# sys_random_h.m4 serial 8 +dnl Copyright (C) 2020-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN_ONCE([gl_SYS_RANDOM_H], +[ + AC_REQUIRE([gl_SYS_RANDOM_H_DEFAULTS]) + dnl is always overridden, because of GNULIB_POSIXCHECK. + gl_CHECK_NEXT_HEADERS([sys/random.h]) + if test $ac_cv_header_sys_random_h = yes; then + HAVE_SYS_RANDOM_H=1 + else + HAVE_SYS_RANDOM_H=0 + fi + AC_SUBST([HAVE_SYS_RANDOM_H]) + + m4_ifdef([gl_UNISTD_H_DEFAULTS], [AC_REQUIRE([gl_UNISTD_H_DEFAULTS])]) + if test $ac_cv_header_sys_random_h = yes; then + UNISTD_H_HAVE_SYS_RANDOM_H=1 + fi + + dnl Check for declarations of anything we want to poison if the + dnl corresponding gnulib module is not in use. + gl_WARN_ON_USE_PREPARE([[ +#if HAVE_SYS_RANDOM_H +/* Additional includes are needed before on uClibc + and Mac OS X. */ +# include +# include +# include +#endif + ]], + [getrandom]) +]) + +# gl_SYS_RANDOM_MODULE_INDICATOR([modulename]) +# sets the shell variable that indicates the presence of the given module +# to a C preprocessor expression that will evaluate to 1. +# This macro invocation must not occur in macros that are AC_REQUIREd. +AC_DEFUN([gl_SYS_RANDOM_MODULE_INDICATOR], +[ + dnl Ensure to expand the default settings once only. + gl_SYS_RANDOM_H_REQUIRE_DEFAULTS + gl_MODULE_INDICATOR_SET_VARIABLE([$1]) + dnl Define it also as a C macro, for the benefit of the unit tests. + gl_MODULE_INDICATOR_FOR_TESTS([$1]) +]) + +# Initializes the default values for AC_SUBSTed shell variables. +# This macro must not be AC_REQUIREd. It must only be invoked, and only +# outside of macros or in macros that are not AC_REQUIREd. +AC_DEFUN([gl_SYS_RANDOM_H_REQUIRE_DEFAULTS], +[ + m4_defun(GL_MODULE_INDICATOR_PREFIX[_SYS_RANDOM_H_MODULE_INDICATOR_DEFAULTS], [ + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETRANDOM]) + ]) + m4_require(GL_MODULE_INDICATOR_PREFIX[_SYS_RANDOM_H_MODULE_INDICATOR_DEFAULTS]) + AC_REQUIRE([gl_SYS_RANDOM_H_DEFAULTS]) +]) + +AC_DEFUN([gl_SYS_RANDOM_H_DEFAULTS], +[ + dnl Assume proper GNU behavior unless another module says otherwise. + HAVE_GETRANDOM=1; AC_SUBST([HAVE_GETRANDOM]) + REPLACE_GETRANDOM=0; AC_SUBST([REPLACE_GETRANDOM]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sys_select_h.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sys_select_h.m4 new file mode 100644 index 00000000..9e279fba --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sys_select_h.m4 @@ -0,0 +1,110 @@ +# sys_select_h.m4 serial 23 +dnl Copyright (C) 2006-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN_ONCE([gl_SYS_SELECT_H], +[ + AC_REQUIRE([gl_SYS_SELECT_H_DEFAULTS]) + AC_REQUIRE([AC_C_RESTRICT]) + AC_CACHE_CHECK([whether is self-contained], + [gl_cv_header_sys_select_h_selfcontained], + [ + dnl Test against two bugs: + dnl 1. On many platforms, assumes prior inclusion of + dnl . + dnl 2. On OSF/1 4.0, provides only a forward declaration + dnl of 'struct timeval', and no definition of this type. + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], + [[struct timeval b;]])], + [gl_cv_header_sys_select_h_selfcontained=yes], + [gl_cv_header_sys_select_h_selfcontained=no]) + dnl Test against another bug: + dnl 3. On Solaris 10, provides an FD_ZERO implementation + dnl that relies on memset(), but without including . + if test $gl_cv_header_sys_select_h_selfcontained = yes; then + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#include ]], + [[int memset; int bzero;]]) + ], + [AC_LINK_IFELSE( + [AC_LANG_PROGRAM([[#include ]], [[ + #undef memset + #define memset nonexistent_memset + extern + #ifdef __cplusplus + "C" + #endif + void *memset (void *, int, unsigned long); + #undef bzero + #define bzero nonexistent_bzero + extern + #ifdef __cplusplus + "C" + #endif + void bzero (void *, unsigned long); + fd_set fds; + FD_ZERO (&fds); + ]]) + ], + [], + [gl_cv_header_sys_select_h_selfcontained=no]) + ]) + fi + ]) + dnl is always overridden, because of GNULIB_POSIXCHECK. + gl_CHECK_NEXT_HEADERS([sys/select.h]) + if test $ac_cv_header_sys_select_h = yes; then + HAVE_SYS_SELECT_H=1 + else + HAVE_SYS_SELECT_H=0 + fi + AC_SUBST([HAVE_SYS_SELECT_H]) + gl_PREREQ_SYS_H_WINSOCK2 + + dnl Check for declarations of anything we want to poison if the + dnl corresponding gnulib module is not in use. + gl_WARN_ON_USE_PREPARE([[ +/* Some systems require prerequisite headers. */ +#include +#if !(defined __GLIBC__ && !defined __UCLIBC__) && HAVE_SYS_TIME_H +# include +#endif +#include + ]], [pselect select]) +]) + +# gl_SYS_SELECT_MODULE_INDICATOR([modulename]) +# sets the shell variable that indicates the presence of the given module +# to a C preprocessor expression that will evaluate to 1. +# This macro invocation must not occur in macros that are AC_REQUIREd. +AC_DEFUN([gl_SYS_SELECT_MODULE_INDICATOR], +[ + dnl Ensure to expand the default settings once only. + gl_SYS_SELECT_H_REQUIRE_DEFAULTS + gl_MODULE_INDICATOR_SET_VARIABLE([$1]) + dnl Define it also as a C macro, for the benefit of the unit tests. + gl_MODULE_INDICATOR_FOR_TESTS([$1]) +]) + +# Initializes the default values for AC_SUBSTed shell variables. +# This macro must not be AC_REQUIREd. It must only be invoked, and only +# outside of macros or in macros that are not AC_REQUIREd. +AC_DEFUN([gl_SYS_SELECT_H_REQUIRE_DEFAULTS], +[ + m4_defun(GL_MODULE_INDICATOR_PREFIX[_SYS_SELECT_H_MODULE_INDICATOR_DEFAULTS], [ + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PSELECT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SELECT]) + ]) + m4_require(GL_MODULE_INDICATOR_PREFIX[_SYS_SELECT_H_MODULE_INDICATOR_DEFAULTS]) + AC_REQUIRE([gl_SYS_SELECT_H_DEFAULTS]) +]) + +AC_DEFUN([gl_SYS_SELECT_H_DEFAULTS], +[ + dnl Assume proper GNU behavior unless another module says otherwise. + HAVE_PSELECT=1; AC_SUBST([HAVE_PSELECT]) + REPLACE_PSELECT=0; AC_SUBST([REPLACE_PSELECT]) + REPLACE_SELECT=0; AC_SUBST([REPLACE_SELECT]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sys_socket_h.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sys_socket_h.m4 new file mode 100644 index 00000000..af524849 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sys_socket_h.m4 @@ -0,0 +1,206 @@ +# sys_socket_h.m4 serial 29 +dnl Copyright (C) 2005-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Simon Josefsson. + +AC_DEFUN_ONCE([gl_SYS_SOCKET_H], +[ + AC_REQUIRE([gl_SYS_SOCKET_H_DEFAULTS]) + AC_REQUIRE([AC_CANONICAL_HOST]) + + dnl On OSF/1, the functions recv(), send(), recvfrom(), sendto() have + dnl old-style declarations (with return type 'int' instead of 'ssize_t') + dnl unless _POSIX_PII_SOCKET is defined. + case "$host_os" in + osf*) + AC_DEFINE([_POSIX_PII_SOCKET], [1], + [Define to 1 in order to get the POSIX compatible declarations + of socket functions.]) + ;; + esac + + GL_GENERATE_SYS_SOCKET_H=false + AC_CACHE_CHECK([whether is self-contained], + [gl_cv_header_sys_socket_h_selfcontained], + [ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[]])], + [gl_cv_header_sys_socket_h_selfcontained=yes], + [gl_cv_header_sys_socket_h_selfcontained=no]) + ]) + if test $gl_cv_header_sys_socket_h_selfcontained = yes; then + dnl If the shutdown function exists, should define + dnl SHUT_RD, SHUT_WR, SHUT_RDWR. + AC_CHECK_FUNCS([shutdown]) + if test $ac_cv_func_shutdown = yes; then + AC_CACHE_CHECK([whether defines the SHUT_* macros], + [gl_cv_header_sys_socket_h_shut], + [ + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#include ]], + [[int a[] = { SHUT_RD, SHUT_WR, SHUT_RDWR };]])], + [gl_cv_header_sys_socket_h_shut=yes], + [gl_cv_header_sys_socket_h_shut=no]) + ]) + if test $gl_cv_header_sys_socket_h_shut = no; then + GL_GENERATE_SYS_SOCKET_H=true + fi + fi + fi + # We need to check for ws2tcpip.h now. + gl_PREREQ_SYS_H_SOCKET + AC_CHECK_TYPES([struct sockaddr_storage, sa_family_t],,,[ + /* sys/types.h is not needed according to POSIX, but the + sys/socket.h in i386-unknown-freebsd4.10 and + powerpc-apple-darwin5.5 required it. */ +#include +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +#ifdef HAVE_WS2TCPIP_H +#include +#endif +]) + if test $ac_cv_type_struct_sockaddr_storage = no; then + HAVE_STRUCT_SOCKADDR_STORAGE=0 + fi + if test $ac_cv_type_sa_family_t = no; then + HAVE_SA_FAMILY_T=0 + fi + if test $ac_cv_type_struct_sockaddr_storage != no; then + AC_CHECK_MEMBERS([struct sockaddr_storage.ss_family], + [], + [HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY=0], + [#include + #ifdef HAVE_SYS_SOCKET_H + #include + #endif + #ifdef HAVE_WS2TCPIP_H + #include + #endif + ]) + fi + if test $HAVE_STRUCT_SOCKADDR_STORAGE = 0 || test $HAVE_SA_FAMILY_T = 0 \ + || test $HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY = 0; then + GL_GENERATE_SYS_SOCKET_H=true + fi + gl_PREREQ_SYS_H_WINSOCK2 + + dnl Check for declarations of anything we want to poison if the + dnl corresponding gnulib module is not in use. + gl_WARN_ON_USE_PREPARE([[ +/* Some systems require prerequisite headers. */ +#include +#include + ]], [socket connect accept bind getpeername getsockname getsockopt + listen recv send recvfrom sendto setsockopt shutdown accept4]) + + AC_REQUIRE([AC_C_RESTRICT]) +]) + +AC_DEFUN([gl_PREREQ_SYS_H_SOCKET], +[ + dnl Check prerequisites of the replacement. + AC_REQUIRE([gl_CHECK_SOCKET_HEADERS]) + gl_CHECK_NEXT_HEADERS([sys/socket.h]) + if test $ac_cv_header_sys_socket_h = yes; then + HAVE_SYS_SOCKET_H=1 + else + HAVE_SYS_SOCKET_H=0 + fi + AC_SUBST([HAVE_SYS_SOCKET_H]) + gl_PREREQ_SYS_H_WS2TCPIP +]) + +# Common prerequisites of the replacement and of the +# replacement. +# Sets and substitutes HAVE_WINSOCK2_H. +AC_DEFUN([gl_PREREQ_SYS_H_WINSOCK2], +[ + m4_ifdef([gl_UNISTD_H_DEFAULTS], [AC_REQUIRE([gl_UNISTD_H_DEFAULTS])]) + m4_ifdef([gl_SYS_IOCTL_H_DEFAULTS], [AC_REQUIRE([gl_SYS_IOCTL_H_DEFAULTS])]) + AC_CHECK_HEADERS_ONCE([sys/socket.h]) + if test $ac_cv_header_sys_socket_h != yes; then + dnl We cannot use AC_CHECK_HEADERS_ONCE here, because that would make + dnl the check for those headers unconditional; yet cygwin reports + dnl that the headers are present but cannot be compiled (since on + dnl cygwin, all socket information should come from sys/socket.h). + AC_CHECK_HEADERS([winsock2.h]) + fi + if test "$ac_cv_header_winsock2_h" = yes; then + HAVE_WINSOCK2_H=1 + UNISTD_H_HAVE_WINSOCK2_H=1 + SYS_IOCTL_H_HAVE_WINSOCK2_H=1 + else + HAVE_WINSOCK2_H=0 + fi + AC_SUBST([HAVE_WINSOCK2_H]) +]) + +# Common prerequisites of the replacement and of the +# replacement. +# Sets and substitutes HAVE_WS2TCPIP_H. +AC_DEFUN([gl_PREREQ_SYS_H_WS2TCPIP], +[ + AC_REQUIRE([gl_CHECK_SOCKET_HEADERS]) + if test $ac_cv_header_sys_socket_h = yes; then + HAVE_WS2TCPIP_H=0 + else + if test $ac_cv_header_ws2tcpip_h = yes; then + HAVE_WS2TCPIP_H=1 + else + HAVE_WS2TCPIP_H=0 + fi + fi + AC_SUBST([HAVE_WS2TCPIP_H]) +]) + +# gl_SYS_SOCKET_MODULE_INDICATOR([modulename]) +# sets the shell variable that indicates the presence of the given module +# to a C preprocessor expression that will evaluate to 1. +# This macro invocation must not occur in macros that are AC_REQUIREd. +AC_DEFUN([gl_SYS_SOCKET_MODULE_INDICATOR], +[ + dnl Ensure to expand the default settings once only. + gl_SYS_SOCKET_H_REQUIRE_DEFAULTS + gl_MODULE_INDICATOR_SET_VARIABLE([$1]) + dnl Define it also as a C macro, for the benefit of the unit tests. + gl_MODULE_INDICATOR_FOR_TESTS([$1]) +]) + +# Initializes the default values for AC_SUBSTed shell variables. +# This macro must not be AC_REQUIREd. It must only be invoked, and only +# outside of macros or in macros that are not AC_REQUIREd. +AC_DEFUN([gl_SYS_SOCKET_H_REQUIRE_DEFAULTS], +[ + m4_defun(GL_MODULE_INDICATOR_PREFIX[_SYS_SOCKET_H_MODULE_INDICATOR_DEFAULTS], [ + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SOCKET]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CONNECT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ACCEPT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_BIND]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETPEERNAME]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETSOCKNAME]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETSOCKOPT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LISTEN]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RECV]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SEND]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RECVFROM]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SENDTO]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SETSOCKOPT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SHUTDOWN]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ACCEPT4]) + ]) + m4_require(GL_MODULE_INDICATOR_PREFIX[_SYS_SOCKET_H_MODULE_INDICATOR_DEFAULTS]) + AC_REQUIRE([gl_SYS_SOCKET_H_DEFAULTS]) +]) + +AC_DEFUN([gl_SYS_SOCKET_H_DEFAULTS], +[ + HAVE_STRUCT_SOCKADDR_STORAGE=1; AC_SUBST([HAVE_STRUCT_SOCKADDR_STORAGE]) + HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY=1; + AC_SUBST([HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY]) + HAVE_SA_FAMILY_T=1; AC_SUBST([HAVE_SA_FAMILY_T]) + HAVE_ACCEPT4=1; AC_SUBST([HAVE_ACCEPT4]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sys_stat_h.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sys_stat_h.m4 new file mode 100644 index 00000000..75018537 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sys_stat_h.m4 @@ -0,0 +1,129 @@ +# sys_stat_h.m4 serial 42 -*- Autoconf -*- +dnl Copyright (C) 2006-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Eric Blake. +dnl Provide a GNU-like . + +AC_DEFUN_ONCE([gl_SYS_STAT_H], +[ + AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS]) + + dnl Check for broken stat macros. + AC_REQUIRE([AC_HEADER_STAT]) + + gl_CHECK_NEXT_HEADERS([sys/stat.h]) + + dnl Ensure the type mode_t gets defined. + AC_REQUIRE([AC_TYPE_MODE_T]) + + dnl Whether to enable precise timestamps in 'struct stat'. + m4_ifdef([gl_WINDOWS_STAT_TIMESPEC], [ + AC_REQUIRE([gl_WINDOWS_STAT_TIMESPEC]) + ], [ + WINDOWS_STAT_TIMESPEC=0 + ]) + AC_SUBST([WINDOWS_STAT_TIMESPEC]) + + dnl Whether to ensure that struct stat.st_size is 64-bit wide. + m4_ifdef([gl_LARGEFILE], [ + AC_REQUIRE([gl_LARGEFILE]) + ], [ + WINDOWS_64_BIT_ST_SIZE=0 + ]) + AC_SUBST([WINDOWS_64_BIT_ST_SIZE]) + + dnl Define types that are supposed to be defined in or + dnl . + AC_CHECK_TYPE([nlink_t], [], + [AC_DEFINE([nlink_t], [int], + [Define to the type of st_nlink in struct stat, or a supertype.])], + [#include + #include ]) + + dnl Check for declarations of anything we want to poison if the + dnl corresponding gnulib module is not in use. + gl_WARN_ON_USE_PREPARE([[#include + ]], [chmod fchmodat fstat fstatat futimens getumask lchmod lstat + mkdirat mkfifo mkfifoat mknod mknodat stat utimensat]) + + AC_REQUIRE([AC_C_RESTRICT]) +]) + +# gl_SYS_STAT_MODULE_INDICATOR([modulename]) +# sets the shell variable that indicates the presence of the given module +# to a C preprocessor expression that will evaluate to 1. +# This macro invocation must not occur in macros that are AC_REQUIREd. +AC_DEFUN([gl_SYS_STAT_MODULE_INDICATOR], +[ + dnl Ensure to expand the default settings once only. + gl_SYS_STAT_H_REQUIRE_DEFAULTS + gl_MODULE_INDICATOR_SET_VARIABLE([$1]) + dnl Define it also as a C macro, for the benefit of the unit tests. + gl_MODULE_INDICATOR_FOR_TESTS([$1]) +]) + +# Initializes the default values for AC_SUBSTed shell variables. +# This macro must not be AC_REQUIREd. It must only be invoked, and only +# outside of macros or in macros that are not AC_REQUIREd. +AC_DEFUN([gl_SYS_STAT_H_REQUIRE_DEFAULTS], +[ + m4_defun(GL_MODULE_INDICATOR_PREFIX[_SYS_STAT_H_MODULE_INDICATOR_DEFAULTS], [ + gl_UNISTD_H_REQUIRE_DEFAULTS dnl for REPLACE_FCHDIR + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CHMOD]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FCHMODAT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FSTAT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FSTATAT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FUTIMENS]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETUMASK]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LCHMOD]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LSTAT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKDIR]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKDIRAT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKFIFO]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKFIFOAT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKNOD]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKNODAT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STAT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UTIMENSAT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_OVERRIDES_STRUCT_STAT]) + dnl Support Microsoft deprecated alias function names by default. + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_CHMOD], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_MKDIR], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_UMASK], [1]) + ]) + m4_require(GL_MODULE_INDICATOR_PREFIX[_SYS_STAT_H_MODULE_INDICATOR_DEFAULTS]) + AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS]) +]) + +AC_DEFUN([gl_SYS_STAT_H_DEFAULTS], +[ + dnl Assume proper GNU behavior unless another module says otherwise. + HAVE_FCHMODAT=1; AC_SUBST([HAVE_FCHMODAT]) + HAVE_FSTATAT=1; AC_SUBST([HAVE_FSTATAT]) + HAVE_FUTIMENS=1; AC_SUBST([HAVE_FUTIMENS]) + HAVE_GETUMASK=1; AC_SUBST([HAVE_GETUMASK]) + HAVE_LCHMOD=1; AC_SUBST([HAVE_LCHMOD]) + HAVE_LSTAT=1; AC_SUBST([HAVE_LSTAT]) + HAVE_MKDIRAT=1; AC_SUBST([HAVE_MKDIRAT]) + HAVE_MKFIFO=1; AC_SUBST([HAVE_MKFIFO]) + HAVE_MKFIFOAT=1; AC_SUBST([HAVE_MKFIFOAT]) + HAVE_MKNOD=1; AC_SUBST([HAVE_MKNOD]) + HAVE_MKNODAT=1; AC_SUBST([HAVE_MKNODAT]) + HAVE_UTIMENSAT=1; AC_SUBST([HAVE_UTIMENSAT]) + REPLACE_CHMOD=0; AC_SUBST([REPLACE_CHMOD]) + REPLACE_FCHMODAT=0; AC_SUBST([REPLACE_FCHMODAT]) + REPLACE_FSTAT=0; AC_SUBST([REPLACE_FSTAT]) + REPLACE_FSTATAT=0; AC_SUBST([REPLACE_FSTATAT]) + REPLACE_FUTIMENS=0; AC_SUBST([REPLACE_FUTIMENS]) + REPLACE_LSTAT=0; AC_SUBST([REPLACE_LSTAT]) + REPLACE_MKDIR=0; AC_SUBST([REPLACE_MKDIR]) + REPLACE_MKFIFO=0; AC_SUBST([REPLACE_MKFIFO]) + REPLACE_MKFIFOAT=0; AC_SUBST([REPLACE_MKFIFOAT]) + REPLACE_MKNOD=0; AC_SUBST([REPLACE_MKNOD]) + REPLACE_MKNODAT=0; AC_SUBST([REPLACE_MKNODAT]) + REPLACE_STAT=0; AC_SUBST([REPLACE_STAT]) + REPLACE_UTIMENSAT=0; AC_SUBST([REPLACE_UTIMENSAT]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sys_time_h.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sys_time_h.m4 new file mode 100644 index 00000000..dc5353f3 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sys_time_h.m4 @@ -0,0 +1,120 @@ +# Configure a replacement for . +# serial 12 + +# Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# Written by Paul Eggert and Martin Lambers. + +AC_DEFUN_ONCE([gl_SYS_TIME_H], +[ + dnl Use AC_REQUIRE here, so that the REPLACE_GETTIMEOFDAY=0 statement + dnl below is expanded once only, before all REPLACE_GETTIMEOFDAY=1 + dnl statements that occur in other macros. + AC_REQUIRE([gl_SYS_TIME_H_DEFAULTS]) + AC_REQUIRE([AC_C_RESTRICT]) + AC_CHECK_HEADERS_ONCE([sys/time.h]) + gl_CHECK_NEXT_HEADERS([sys/time.h]) + + if test $ac_cv_header_sys_time_h != yes; then + HAVE_SYS_TIME_H=0 + fi + + dnl On native Windows with MSVC, 'struct timeval' is defined in + dnl only. So include that header in the list. + gl_PREREQ_SYS_H_WINSOCK2 + AC_CACHE_CHECK([for struct timeval], [gl_cv_sys_struct_timeval], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#if HAVE_SYS_TIME_H + #include + #endif + #include + #if HAVE_WINSOCK2_H + # include + #endif + ]], + [[static struct timeval x; x.tv_sec = x.tv_usec;]])], + [gl_cv_sys_struct_timeval=yes], + [gl_cv_sys_struct_timeval=no]) + ]) + if test $gl_cv_sys_struct_timeval != yes; then + HAVE_STRUCT_TIMEVAL=0 + else + dnl On native Windows with a 64-bit 'time_t', 'struct timeval' is defined + dnl (in and for mingw64, in only + dnl for MSVC) with a tv_sec field of type 'long' (32-bit!), which is + dnl smaller than the 'time_t' type mandated by POSIX. + dnl On OpenBSD 5.1 amd64, tv_sec is 64 bits and time_t 32 bits, but + dnl that is good enough. + AC_CACHE_CHECK([for wide-enough struct timeval.tv_sec member], + [gl_cv_sys_struct_timeval_tv_sec], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#if HAVE_SYS_TIME_H + #include + #endif + #include + #if HAVE_WINSOCK2_H + # include + #endif + ]], + [[static struct timeval x; + typedef int verify_tv_sec_type[ + sizeof (time_t) <= sizeof x.tv_sec ? 1 : -1 + ]; + ]])], + [gl_cv_sys_struct_timeval_tv_sec=yes], + [gl_cv_sys_struct_timeval_tv_sec=no]) + ]) + if test $gl_cv_sys_struct_timeval_tv_sec != yes; then + REPLACE_STRUCT_TIMEVAL=1 + fi + fi + + dnl Check for declarations of anything we want to poison if the + dnl corresponding gnulib module is not in use. + gl_WARN_ON_USE_PREPARE([[ +#if HAVE_SYS_TIME_H +# include +#endif +#include + ]], [gettimeofday]) +]) + +# gl_SYS_TIME_MODULE_INDICATOR([modulename]) +# sets the shell variable that indicates the presence of the given module +# to a C preprocessor expression that will evaluate to 1. +# This macro invocation must not occur in macros that are AC_REQUIREd. +AC_DEFUN([gl_SYS_TIME_MODULE_INDICATOR], +[ + dnl Ensure to expand the default settings once only. + gl_SYS_TIME_H_REQUIRE_DEFAULTS + gl_MODULE_INDICATOR_SET_VARIABLE([$1]) + dnl Define it also as a C macro, for the benefit of the unit tests. + gl_MODULE_INDICATOR_FOR_TESTS([$1]) +]) + +# Initializes the default values for AC_SUBSTed shell variables. +# This macro must not be AC_REQUIREd. It must only be invoked, and only +# outside of macros or in macros that are not AC_REQUIREd. +AC_DEFUN([gl_SYS_TIME_H_REQUIRE_DEFAULTS], +[ + m4_defun(GL_MODULE_INDICATOR_PREFIX[_SYS_TIME_H_MODULE_INDICATOR_DEFAULTS], [ + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETTIMEOFDAY]) + ]) + m4_require(GL_MODULE_INDICATOR_PREFIX[_SYS_TIME_H_MODULE_INDICATOR_DEFAULTS]) + AC_REQUIRE([gl_SYS_TIME_H_DEFAULTS]) +]) + +AC_DEFUN([gl_SYS_TIME_H_DEFAULTS], +[ + dnl Assume POSIX behavior unless another module says otherwise. + HAVE_GETTIMEOFDAY=1; AC_SUBST([HAVE_GETTIMEOFDAY]) + HAVE_STRUCT_TIMEVAL=1; AC_SUBST([HAVE_STRUCT_TIMEVAL]) + HAVE_SYS_TIME_H=1; AC_SUBST([HAVE_SYS_TIME_H]) + REPLACE_GETTIMEOFDAY=0; AC_SUBST([REPLACE_GETTIMEOFDAY]) + REPLACE_STRUCT_TIMEVAL=0; AC_SUBST([REPLACE_STRUCT_TIMEVAL]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sys_types_h.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sys_types_h.m4 new file mode 100644 index 00000000..37d0ccad --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sys_types_h.m4 @@ -0,0 +1,70 @@ +# sys_types_h.m4 serial 13 +dnl Copyright (C) 2011-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN_ONCE([gl_SYS_TYPES_H], +[ + AC_REQUIRE([gl_SYS_TYPES_H_DEFAULTS]) + + dnl Use sane struct stat types in OpenVMS 8.2 and later. + AC_DEFINE([_USE_STD_STAT], 1, [For standard stat data types on VMS.]) + + gl_NEXT_HEADERS([sys/types.h]) + + dnl Ensure the type pid_t gets defined. + AC_REQUIRE([AC_TYPE_PID_T]) + + dnl Ensure the type mode_t gets defined. + AC_REQUIRE([AC_TYPE_MODE_T]) + + dnl Whether to override the 'off_t' type. + AC_REQUIRE([gl_TYPE_OFF_T]) + + dnl Whether to override the 'dev_t' and 'ino_t' types. + m4_ifdef([gl_WINDOWS_STAT_INODES], [ + AC_REQUIRE([gl_WINDOWS_STAT_INODES]) + ], [ + WINDOWS_STAT_INODES=0 + ]) + AC_SUBST([WINDOWS_STAT_INODES]) +]) + +# Initializes the default values for AC_SUBSTed shell variables. +# This macro must not be AC_REQUIREd. It must only be invoked, and only +# outside of macros or in macros that are not AC_REQUIREd. +AC_DEFUN([gl_SYS_TYPES_H_REQUIRE_DEFAULTS], +[ + m4_defun(GL_MODULE_INDICATOR_PREFIX[_SYS_TYPE_H_MODULE_INDICATOR_DEFAULTS], [ + ]) + m4_require(GL_MODULE_INDICATOR_PREFIX[_SYS_TYPE_H_MODULE_INDICATOR_DEFAULTS]) + AC_REQUIRE([gl_SYS_TYPES_H_DEFAULTS]) +]) + +AC_DEFUN([gl_SYS_TYPES_H_DEFAULTS], +[ +]) + +# This works around a buggy version in autoconf <= 2.69. +# See +# The 2.70 version isn't quoted properly, so override it too. + +m4_version_prereq([2.70.1], [], [ + +m4_undefine([AC_HEADER_MAJOR]) +AC_DEFUN([AC_HEADER_MAJOR], +[AC_CHECK_HEADERS_ONCE([sys/types.h]) +AC_CHECK_HEADER([sys/mkdev.h], + [AC_DEFINE([MAJOR_IN_MKDEV], [1], + [Define to 1 if `major', `minor', and `makedev' are + declared in .])]) +if test $ac_cv_header_sys_mkdev_h = no; then + AC_CHECK_HEADER([sys/sysmacros.h], + [AC_DEFINE([MAJOR_IN_SYSMACROS], [1], + [Define to 1 if `major', `minor', and `makedev' + are declared in .])]) +fi +])# AC_HEADER_MAJOR + +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sys_uio_h.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sys_uio_h.m4 new file mode 100644 index 00000000..ce252ed4 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sys_uio_h.m4 @@ -0,0 +1,46 @@ +# sys_uio_h.m4 serial 3 +dnl Copyright (C) 2011-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN_ONCE([gl_SYS_UIO_H], +[ + AC_REQUIRE([gl_SYS_UIO_H_DEFAULTS]) + dnl is always overridden, because of GNULIB_POSIXCHECK. + gl_CHECK_NEXT_HEADERS([sys/uio.h]) + if test $ac_cv_header_sys_uio_h = yes; then + HAVE_SYS_UIO_H=1 + else + HAVE_SYS_UIO_H=0 + fi + AC_SUBST([HAVE_SYS_UIO_H]) +]) + +# gl_SYS_UIO_MODULE_INDICATOR([modulename]) +# sets the shell variable that indicates the presence of the given module +# to a C preprocessor expression that will evaluate to 1. +# This macro invocation must not occur in macros that are AC_REQUIREd. +AC_DEFUN([gl_SYS_UIO_MODULE_INDICATOR], +[ + dnl Ensure to expand the default settings once only. + gl_SYS_UIO_H_REQUIRE_DEFAULTS + gl_MODULE_INDICATOR_SET_VARIABLE([$1]) + dnl Define it also as a C macro, for the benefit of the unit tests. + gl_MODULE_INDICATOR_FOR_TESTS([$1]) +]) + +# Initializes the default values for AC_SUBSTed shell variables. +# This macro must not be AC_REQUIREd. It must only be invoked, and only +# outside of macros or in macros that are not AC_REQUIREd. +AC_DEFUN([gl_SYS_UIO_H_REQUIRE_DEFAULTS], +[ + m4_defun(GL_MODULE_INDICATOR_PREFIX[_SYS_UIO_H_MODULE_INDICATOR_DEFAULTS], [ + ]) + m4_require(GL_MODULE_INDICATOR_PREFIX[_SYS_UIO_H_MODULE_INDICATOR_DEFAULTS]) + AC_REQUIRE([gl_SYS_UIO_H_DEFAULTS]) +]) + +AC_DEFUN([gl_SYS_UIO_H_DEFAULTS], +[ +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sys_wait_h.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sys_wait_h.m4 new file mode 100644 index 00000000..6759b084 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/sys_wait_h.m4 @@ -0,0 +1,51 @@ +# sys_wait_h.m4 serial 9 +dnl Copyright (C) 2008-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN_ONCE([gl_SYS_WAIT_H], +[ + AC_REQUIRE([gl_SYS_WAIT_H_DEFAULTS]) + + dnl is always overridden, because of GNULIB_POSIXCHECK. + gl_CHECK_NEXT_HEADERS([sys/wait.h]) + + dnl Ensure the type pid_t gets defined. + AC_REQUIRE([AC_TYPE_PID_T]) + + dnl Check for declarations of anything we want to poison if the + dnl corresponding gnulib module is not in use. + gl_WARN_ON_USE_PREPARE([[#include ]], + [waitpid]) +]) + +# gl_SYS_WAIT_MODULE_INDICATOR([modulename]) +# sets the shell variable that indicates the presence of the given module +# to a C preprocessor expression that will evaluate to 1. +# This macro invocation must not occur in macros that are AC_REQUIREd. +AC_DEFUN([gl_SYS_WAIT_MODULE_INDICATOR], +[ + dnl Ensure to expand the default settings once only. + gl_SYS_WAIT_H_REQUIRE_DEFAULTS + gl_MODULE_INDICATOR_SET_VARIABLE([$1]) + dnl Define it also as a C macro, for the benefit of the unit tests. + gl_MODULE_INDICATOR_FOR_TESTS([$1]) +]) + +# Initializes the default values for AC_SUBSTed shell variables. +# This macro must not be AC_REQUIREd. It must only be invoked, and only +# outside of macros or in macros that are not AC_REQUIREd. +AC_DEFUN([gl_SYS_WAIT_H_REQUIRE_DEFAULTS], +[ + m4_defun(GL_MODULE_INDICATOR_PREFIX[_SYS_WAIT_H_MODULE_INDICATOR_DEFAULTS], [ + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WAITPID]) + ]) + m4_require(GL_MODULE_INDICATOR_PREFIX[_SYS_WAIT_H_MODULE_INDICATOR_DEFAULTS]) + AC_REQUIRE([gl_SYS_WAIT_H_DEFAULTS]) +]) + +AC_DEFUN([gl_SYS_WAIT_H_DEFAULTS], +[ + dnl Assume proper GNU behavior unless another module says otherwise. +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/tempname.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/tempname.m4 new file mode 100644 index 00000000..31d35c83 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/tempname.m4 @@ -0,0 +1,19 @@ +#serial 5 + +# Copyright (C) 2006-2007, 2009-2024 Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# glibc provides __gen_tempname as a wrapper for mk[ds]temp. Expose +# it as a public API, and provide it on systems that are lacking. +AC_DEFUN([gl_FUNC_GEN_TEMPNAME], +[ + gl_PREREQ_TEMPNAME +]) + +# Prerequisites of lib/tempname.c. +AC_DEFUN([gl_PREREQ_TEMPNAME], +[ + : +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/thread.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/thread.m4 new file mode 100644 index 00000000..c2aead4a --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/thread.m4 @@ -0,0 +1,17 @@ +# thread.m4 serial 4 +dnl Copyright (C) 2008-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_THREAD], +[ + AC_REQUIRE([gl_THREADLIB]) + + if test $gl_threads_api = posix; then + gl_save_LIBS="$LIBS" + LIBS="$LIBS $LIBMULTITHREAD" + gl_CHECK_FUNCS_ANDROID([pthread_atfork], [[#include ]]) + LIBS="$gl_save_LIBS" + fi +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/threadlib.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/threadlib.m4 new file mode 100644 index 00000000..0be2c987 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/threadlib.m4 @@ -0,0 +1,686 @@ +# threadlib.m4 serial 41 +dnl Copyright (C) 2005-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. + +AC_PREREQ([2.60]) + +dnl The general structure of the multithreading modules in gnulib is that we +dnl have three set of modules: +dnl +dnl * POSIX API: +dnl pthread, which combines +dnl pthread-h +dnl pthread-thread +dnl pthread-once +dnl pthread-mutex +dnl pthread-rwlock +dnl pthread-cond +dnl pthread-tss +dnl pthread-spin +dnl sched_yield +dnl +dnl * ISO C API: +dnl threads, which combines +dnl threads-h +dnl thrd +dnl mtx +dnl cnd +dnl tss +dnl +dnl * Gnulib API, with an implementation that can be chosen at configure +dnl time through the option --enable-threads=... +dnl thread +dnl lock +dnl cond +dnl tls +dnl yield +dnl +dnl They are independent, except for the fact that +dnl - the implementation of the ISO C API may use the POSIX (or some other +dnl platform dependent) API, +dnl - the implementation of the Gnulib API may use the POSIX or ISO C or +dnl some other platform dependent API, depending on the --enable-threads +dnl option. +dnl +dnl This file contains macros for all of these APIs! + +dnl ============================================================================ +dnl Macros for all thread APIs + +AC_DEFUN([gl_ANYTHREADLIB_EARLY], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) + if test -z "$gl_anythreadlib_early_done"; then + case "$host_os" in + osf*) + # On OSF/1, the compiler needs the flag -D_REENTRANT so that it + # groks . cc also understands the flag -pthread, but + # we don't use it because 1. gcc-2.95 doesn't understand -pthread, + # 2. putting a flag into CPPFLAGS that has an effect on the linker + # causes the AC_LINK_IFELSE test below to succeed unexpectedly, + # leading to wrong values of LIBTHREAD and LTLIBTHREAD. + CPPFLAGS="$CPPFLAGS -D_REENTRANT" + ;; + esac + # Some systems optimize for single-threaded programs by default, and + # need special flags to disable these optimizations. For example, the + # definition of 'errno' in . + case "$host_os" in + aix* | freebsd*) CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE" ;; + solaris*) CPPFLAGS="$CPPFLAGS -D_REENTRANT" ;; + esac + gl_anythreadlib_early_done=done + fi +]) + +dnl Checks whether the compiler and linker support weak declarations of symbols. + +AC_DEFUN([gl_WEAK_SYMBOLS], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_CACHE_CHECK([whether imported symbols can be declared weak], + [gl_cv_have_weak], + [case "$host_os" in + cygwin* | mingw* | windows*) + dnl On Cygwin 3.2.0 with gcc 10.2, and likewise on mingw 10.0.0 with + dnl gcc 11.3, the test below would succeed, but programs that use + dnl pthread_in_use() with weak symbol references crash miserably at + dnl runtime. + gl_cv_have_weak="guessing no" + ;; + *) + gl_cv_have_weak=no + dnl First, test whether the compiler accepts it syntactically. + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[extern void xyzzy (); +#pragma weak xyzzy]], + [[xyzzy();]])], + [gl_cv_have_weak=maybe]) + if test $gl_cv_have_weak = maybe; then + dnl Second, test whether it actually works. On Cygwin 1.7.2, with + dnl gcc 4.3, symbols declared weak always evaluate to the address 0. + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#pragma weak fputs +int main () +{ + return (fputs == NULL); +}]])], + [gl_cv_have_weak=yes], + [gl_cv_have_weak=no], + [dnl When cross-compiling, assume that only ELF platforms support + dnl weak symbols. + AC_EGREP_CPP([Extensible Linking Format], + [#ifdef __ELF__ + Extensible Linking Format + #endif + ], + [gl_cv_have_weak="guessing yes"], + [gl_cv_have_weak="guessing no"]) + ]) + fi + ;; + esac + dnl But when linking statically, weak symbols don't work. + case " $LDFLAGS " in + *" -static "*) gl_cv_have_weak=no ;; + esac + dnl Test for a bug in FreeBSD 11: A link error occurs when using a weak + dnl symbol and linking against a shared library that has a dependency on + dnl the shared library that defines the symbol. + case "$gl_cv_have_weak" in + *yes) + case "$host_os" in + freebsd* | dragonfly* | midnightbsd*) + : > conftest1.c + $CC $CPPFLAGS $CFLAGS $LDFLAGS -fPIC -shared -o libempty.so conftest1.c -lpthread >&AS_MESSAGE_LOG_FD 2>&1 + cat < conftest2.c +#include +#pragma weak pthread_mutexattr_gettype +int main () +{ + return (pthread_mutexattr_gettype != NULL); +} +EOF + $CC $CPPFLAGS $CFLAGS $LDFLAGS -o conftest conftest2.c libempty.so >&AS_MESSAGE_LOG_FD 2>&1 \ + || gl_cv_have_weak=no + rm -f conftest1.c libempty.so conftest2.c conftest + ;; + esac + ;; + esac + ]) + case "$gl_cv_have_weak" in + *yes) + AC_DEFINE([HAVE_WEAK_SYMBOLS], [1], + [Define to 1 if the compiler and linker support weak declarations of symbols.]) + ;; + esac +]) + +dnl ============================================================================ +dnl Macros for the POSIX API + +dnl gl_PTHREADLIB +dnl ------------- +dnl Tests for the libraries needs for using the POSIX threads API. +dnl Sets the variable LIBPTHREAD to the linker options for use in a Makefile. +dnl Sets the variable LIBPMULTITHREAD, for programs that really need +dnl multithread functionality. The difference between LIBPTHREAD and +dnl LIBPMULTITHREAD is that on platforms supporting weak symbols, typically +dnl LIBPTHREAD is empty whereas LIBPMULTITHREAD is not. +dnl Sets the variable SCHED_YIELD_LIB to the linker options needed to use the +dnl sched_yield() function. +dnl Adds to CPPFLAGS the flag -D_REENTRANT or -D_THREAD_SAFE if needed for +dnl multithread-safe programs. +dnl Defines the C macro HAVE_PTHREAD_API if (at least parts of) the POSIX +dnl threads API is available. + +dnl The guts of gl_PTHREADLIB. Needs to be expanded only once. + +AC_DEFUN([gl_PTHREADLIB_BODY], +[ + AC_REQUIRE([gl_ANYTHREADLIB_EARLY]) + if test -z "$gl_pthreadlib_body_done"; then + gl_pthread_api=no + LIBPTHREAD= + LIBPMULTITHREAD= + # On OSF/1, the compiler needs the flag -pthread or -D_REENTRANT so that + # it groks . It's added above, in gl_ANYTHREADLIB_EARLY. + AC_CHECK_HEADER([pthread.h], + [gl_have_pthread_h=yes], [gl_have_pthread_h=no]) + if test "$gl_have_pthread_h" = yes; then + # Other possible tests: + # -lpthreads (FSU threads, PCthreads) + # -lgthreads + # Test whether both pthread_mutex_lock and pthread_mutexattr_init exist + # in libc. IRIX 6.5 has the first one in both libc and libpthread, but + # the second one only in libpthread, and lock.c needs it. + # + # If -pthread works, prefer it to -lpthread, since Ubuntu 14.04 + # needs -pthread for some reason. See: + # https://lists.gnu.org/r/bug-gnulib/2014-09/msg00023.html + save_LIBS=$LIBS + for gl_pthread in '' '-pthread'; do + LIBS="$LIBS $gl_pthread" + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include + pthread_mutex_t m; + pthread_mutexattr_t ma; + ]], + [[pthread_mutex_lock (&m); + pthread_mutexattr_init (&ma);]])], + [gl_pthread_api=yes + LIBPTHREAD=$gl_pthread + LIBPMULTITHREAD=$gl_pthread]) + LIBS=$save_LIBS + test $gl_pthread_api = yes && break + done + echo "$as_me:__oline__: gl_pthread_api=$gl_pthread_api" >&AS_MESSAGE_LOG_FD + echo "$as_me:__oline__: LIBPTHREAD=$LIBPTHREAD" >&AS_MESSAGE_LOG_FD + + gl_pthread_in_glibc=no + # On Linux with glibc >= 2.34, libc contains the fully functional + # pthread functions. + case "$host_os" in + linux*) + AC_EGREP_CPP([Lucky user], + [#include + #ifdef __GNU_LIBRARY__ + #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 34) || (__GLIBC__ > 2) + Lucky user + #endif + #endif + ], + [gl_pthread_in_glibc=yes], + []) + ;; + esac + echo "$as_me:__oline__: gl_pthread_in_glibc=$gl_pthread_in_glibc" >&AS_MESSAGE_LOG_FD + + # Test for libpthread by looking for pthread_kill. (Not pthread_self, + # since it is defined as a macro on OSF/1.) + if test $gl_pthread_api = yes && test -z "$LIBPTHREAD"; then + # The program links fine without libpthread. But it may actually + # need to link with libpthread in order to create multiple threads. + AC_CHECK_LIB([pthread], [pthread_kill], + [if test $gl_pthread_in_glibc = yes; then + LIBPMULTITHREAD= + else + LIBPMULTITHREAD=-lpthread + # On Solaris and HP-UX, most pthread functions exist also in libc. + # Therefore pthread_in_use() needs to actually try to create a + # thread: pthread_create from libc will fail, whereas + # pthread_create will actually create a thread. + # On Solaris 10 or newer, this test is no longer needed, because + # libc contains the fully functional pthread functions. + case "$host_os" in +changequote(,)dnl + solaris | solaris2.[1-9] | solaris2.[1-9].* | hpux*) +changequote([,])dnl + AC_DEFINE([PTHREAD_IN_USE_DETECTION_HARD], [1], + [Define if the pthread_in_use() detection is hard.]) + esac + fi + ], + [dnl This is needed on FreeBSD 5.2.1. + AC_CHECK_LIB([thr], [pthread_kill], + [if test $gl_pthread_in_glibc = yes; then + LIBPMULTITHREAD= + else + LIBPMULTITHREAD=-lthr + fi + ]) + ]) + elif test $gl_pthread_api != yes; then + # Some library is needed. Try libpthread and libc_r. + AC_CHECK_LIB([pthread], [pthread_kill], + [gl_pthread_api=yes + LIBPTHREAD=-lpthread + LIBPMULTITHREAD=-lpthread]) + if test $gl_pthread_api != yes; then + # For FreeBSD 4. + AC_CHECK_LIB([c_r], [pthread_kill], + [gl_pthread_api=yes + LIBPTHREAD=-lc_r + LIBPMULTITHREAD=-lc_r]) + fi + fi + echo "$as_me:__oline__: LIBPMULTITHREAD=$LIBPMULTITHREAD" >&AS_MESSAGE_LOG_FD + fi + AC_MSG_CHECKING([whether POSIX threads API is available]) + AC_MSG_RESULT([$gl_pthread_api]) + AC_SUBST([LIBPTHREAD]) + AC_SUBST([LIBPMULTITHREAD]) + if test $gl_pthread_api = yes; then + AC_DEFINE([HAVE_PTHREAD_API], [1], + [Define if you have the header and the POSIX threads API.]) + fi + + dnl On some systems, sched_yield is in librt, rather than in libpthread. + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include ]], + [[sched_yield ();]])], + [SCHED_YIELD_LIB= + ], + [dnl Solaris 7...10 has sched_yield in librt, not in libpthread or libc. + AC_CHECK_LIB([rt], [sched_yield], [SCHED_YIELD_LIB=-lrt], + [dnl Solaris 2.5.1, 2.6 has sched_yield in libposix4, not librt. + AC_CHECK_LIB([posix4], [sched_yield], [SCHED_YIELD_LIB=-lposix4])]) + ]) + AC_SUBST([SCHED_YIELD_LIB]) + dnl For backward compatibility. + LIB_SCHED_YIELD="$SCHED_YIELD_LIB" + AC_SUBST([LIB_SCHED_YIELD]) + + gl_pthreadlib_body_done=done + fi +]) + +AC_DEFUN([gl_PTHREADLIB], +[ + AC_REQUIRE([gl_ANYTHREADLIB_EARLY]) + gl_PTHREADLIB_BODY +]) + +dnl ============================================================================ +dnl Macros for the ISO C API + +dnl gl_STDTHREADLIB +dnl --------------- +dnl Tests for the libraries needs for using the ISO C threads API. +dnl Sets the variable LIBSTDTHREAD to the linker options for use in a Makefile. +dnl Adds to CPPFLAGS the flag -D_REENTRANT or -D_THREAD_SAFE if needed for +dnl multithread-safe programs. +dnl Defines the C macro HAVE_THREADS_H if (at least parts of) the ISO C threads +dnl API is available. + +dnl The guts of gl_STDTHREADLIB. Needs to be expanded only once. + +AC_DEFUN([gl_STDTHREADLIB_BODY], +[ + AC_REQUIRE([gl_ANYTHREADLIB_EARLY]) + AC_REQUIRE([AC_CANONICAL_HOST]) + if test -z "$gl_stdthreadlib_body_done"; then + AC_CHECK_HEADERS_ONCE([threads.h]) + + case "$host_os" in + mingw* | windows*) + LIBSTDTHREAD= + ;; + *) + gl_PTHREADLIB_BODY + if test $ac_cv_header_threads_h = yes; then + dnl glibc >= 2.29 has thrd_create in libpthread. + dnl FreeBSD >= 10 has thrd_create in libstdthreads; this library depends + dnl on libpthread (for the symbol 'pthread_mutexattr_gettype'). + dnl glibc >= 2.34, AIX >= 7.1, and Solaris >= 11.4 have thrd_create in + dnl libc. + gl_CHECK_FUNCS_ANDROID([thrd_create], [[#include ]]) + if test $ac_cv_func_thrd_create = yes; then + LIBSTDTHREAD= + else + AC_CHECK_LIB([stdthreads], [thrd_create], [ + LIBSTDTHREAD='-lstdthreads -lpthread' + ], [ + dnl Guess that thrd_create is in libpthread. + LIBSTDTHREAD="$LIBPMULTITHREAD" + ]) + fi + else + dnl Libraries needed by thrd.c, mtx.c, cnd.c, tss.c. + LIBSTDTHREAD="$LIBPMULTITHREAD $SCHED_YIELD_LIB" + fi + ;; + esac + AC_SUBST([LIBSTDTHREAD]) + + AC_MSG_CHECKING([whether ISO C threads API is available]) + AC_MSG_RESULT([$ac_cv_header_threads_h]) + gl_stdthreadlib_body_done=done + fi +]) + +AC_DEFUN([gl_STDTHREADLIB], +[ + AC_REQUIRE([gl_ANYTHREADLIB_EARLY]) + gl_STDTHREADLIB_BODY +]) + +dnl ============================================================================ +dnl Macros for the Gnulib API + +dnl gl_THREADLIB +dnl ------------ +dnl Tests for a multithreading library to be used. +dnl If the configure.ac contains a definition of the gl_THREADLIB_DEFAULT_NO +dnl (it must be placed before the invocation of gl_THREADLIB_EARLY!), then the +dnl default is 'no', otherwise it is system dependent. In both cases, the user +dnl can change the choice through the options --enable-threads=choice or +dnl --disable-threads. +dnl Defines at most one of the macros USE_ISOC_THREADS, USE_POSIX_THREADS, +dnl USE_ISOC_AND_POSIX_THREADS, USE_WINDOWS_THREADS. +dnl The choice --enable-threads=isoc+posix is available only on platforms that +dnl have both the ISO C and the POSIX threads APIs. It has the effect of using +dnl the ISO C API for most things and the POSIX API only for creating and +dnl controlling threads (because there is no equivalent to pthread_atfork in +dnl the ISO C API). +dnl Sets the variables LIBTHREAD and LTLIBTHREAD to the linker options for use +dnl in a Makefile (LIBTHREAD for use without libtool, LTLIBTHREAD for use with +dnl libtool). +dnl Sets the variables LIBMULTITHREAD and LTLIBMULTITHREAD similarly, for +dnl programs that really need multithread functionality. The difference +dnl between LIBTHREAD and LIBMULTITHREAD is that on platforms supporting weak +dnl symbols, typically LIBTHREAD is empty whereas LIBMULTITHREAD is not. +dnl Adds to CPPFLAGS the flag -D_REENTRANT or -D_THREAD_SAFE if needed for +dnl multithread-safe programs. +dnl Since support for GNU pth was removed, $LTLIBTHREAD and $LIBTHREAD have the +dnl same value, and similarly $LTLIBMULTITHREAD and $LIBMULTITHREAD have the +dnl same value. Only system libraries are needed. + +AC_DEFUN([gl_THREADLIB_EARLY], +[ + AC_REQUIRE([gl_THREADLIB_EARLY_BODY]) +]) + +dnl The guts of gl_THREADLIB_EARLY. Needs to be expanded only once. + +AC_DEFUN([gl_THREADLIB_EARLY_BODY], +[ + dnl Ordering constraints: This macro modifies CPPFLAGS in a way that + dnl influences the result of the autoconf tests that test for *_unlocked + dnl declarations, on AIX 5 at least. Therefore it must come early. + AC_BEFORE([$0], [gl_FUNC_GLIBC_UNLOCKED_IO])dnl + AC_BEFORE([$0], [gl_ARGP])dnl + + AC_REQUIRE([AC_CANONICAL_HOST]) + dnl _GNU_SOURCE is needed for pthread_rwlock_t on glibc systems. + AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) + dnl Check for multithreading. + m4_ifdef([gl_THREADLIB_DEFAULT_NO], + [m4_divert_text([DEFAULTS], [gl_use_threads_default=no])], + [m4_divert_text([DEFAULTS], [gl_use_threads_default=])]) + dnl gl_use_winpthreads_default defaults to 'no', because in mingw 10, like + dnl in mingw 5, the use of libwinpthread still makes test-pthread-tss crash. + m4_divert_text([DEFAULTS], [gl_use_winpthreads_default=no]) + AC_ARG_ENABLE([threads], +AS_HELP_STRING([[--enable-threads={isoc|posix|isoc+posix|windows}]], [specify multithreading API])m4_ifdef([gl_THREADLIB_DEFAULT_NO], [], [ +AS_HELP_STRING([[--disable-threads]], [build without multithread safety])]), + [gl_use_threads=$enableval], + [if test -n "$gl_use_threads_default"; then + gl_use_threads="$gl_use_threads_default" + else +changequote(,)dnl + case "$host_os" in + dnl Disable multithreading by default on OSF/1, because it interferes + dnl with fork()/exec(): When msgexec is linked with -lpthread, its + dnl child process gets an endless segmentation fault inside execvp(). + osf*) gl_use_threads=no ;; + dnl Disable multithreading by default on Cygwin 1.5.x, because it has + dnl bugs that lead to endless loops or crashes. See + dnl . + cygwin*) + case `uname -r` in + 1.[0-5].*) gl_use_threads=no ;; + *) gl_use_threads=yes ;; + esac + ;; + dnl Obey gl_AVOID_WINPTHREAD on mingw. + mingw* | windows*) + case "$gl_use_winpthreads_default" in + yes) gl_use_threads=posix ;; + no) gl_use_threads=windows ;; + *) gl_use_threads=yes ;; + esac + ;; + *) gl_use_threads=yes ;; + esac +changequote([,])dnl + fi + ]) + if test "$gl_use_threads" = yes \ + || test "$gl_use_threads" = isoc \ + || test "$gl_use_threads" = posix \ + || test "$gl_use_threads" = isoc+posix; then + # For using or : + gl_ANYTHREADLIB_EARLY + fi +]) + +dnl The guts of gl_THREADLIB. Needs to be expanded only once. + +AC_DEFUN([gl_THREADLIB_BODY], +[ + AC_REQUIRE([gl_THREADLIB_EARLY_BODY]) + gl_threads_api=none + LIBTHREAD= + LTLIBTHREAD= + LIBMULTITHREAD= + LTLIBMULTITHREAD= + if test "$gl_use_threads" != no; then + dnl Check whether the compiler and linker support weak declarations. + gl_WEAK_SYMBOLS + if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then + dnl If we use weak symbols to implement pthread_in_use / pth_in_use / + dnl thread_in_use, we also need to test whether the ISO C 11 thrd_create + dnl facility is in use. + AC_CHECK_HEADERS_ONCE([threads.h]) + : + fi + if test "$gl_use_threads" = isoc || test "$gl_use_threads" = isoc+posix; then + AC_CHECK_HEADERS_ONCE([threads.h]) + gl_have_isoc_threads="$ac_cv_header_threads_h" + fi + if test "$gl_use_threads" = yes \ + || test "$gl_use_threads" = posix \ + || test "$gl_use_threads" = isoc+posix; then + gl_PTHREADLIB_BODY + LIBTHREAD=$LIBPTHREAD LTLIBTHREAD=$LIBPTHREAD + LIBMULTITHREAD=$LIBPMULTITHREAD LTLIBMULTITHREAD=$LIBPMULTITHREAD + if test $gl_pthread_api = yes; then + if test "$gl_use_threads" = isoc+posix && test "$gl_have_isoc_threads" = yes; then + gl_threads_api='isoc+posix' + AC_DEFINE([USE_ISOC_AND_POSIX_THREADS], [1], + [Define if the combination of the ISO C and POSIX multithreading APIs can be used.]) + LIBTHREAD= LTLIBTHREAD= + else + gl_threads_api=posix + AC_DEFINE([USE_POSIX_THREADS], [1], + [Define if the POSIX multithreading library can be used.]) + if test -z "$LIBMULTITHREAD" && test -z "$LTLIBMULTITHREAD"; then + AC_DEFINE([USE_POSIX_THREADS_FROM_LIBC], [1], + [Define if references to the POSIX multithreading library are satisfied by libc.]) + else + if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then + AC_DEFINE([USE_POSIX_THREADS_WEAK], [1], + [Define if references to the POSIX multithreading library should be made weak.]) + LIBTHREAD= LTLIBTHREAD= + else + case "$host_os" in + freebsd* | dragonfly* | midnightbsd*) + if test "x$LIBTHREAD" != "x$LIBMULTITHREAD"; then + dnl If weak symbols can't tell whether pthread_create(), pthread_key_create() + dnl etc. will succeed, we need a runtime test. + AC_DEFINE([PTHREAD_IN_USE_DETECTION_HARD], [1], + [Define if the pthread_in_use() detection is hard.]) + fi + ;; + esac + fi + fi + fi + fi + fi + if test $gl_threads_api = none; then + if test "$gl_use_threads" = isoc && test "$gl_have_isoc_threads" = yes; then + gl_STDTHREADLIB_BODY + LIBTHREAD=$LIBSTDTHREAD LTLIBTHREAD=$LIBSTDTHREAD + LIBMULTITHREAD=$LIBSTDTHREAD LTLIBMULTITHREAD=$LIBSTDTHREAD + gl_threads_api=isoc + AC_DEFINE([USE_ISOC_THREADS], [1], + [Define if the ISO C multithreading library can be used.]) + fi + fi + if test $gl_threads_api = none; then + case "$gl_use_threads" in + yes | windows | win32) # The 'win32' is for backward compatibility. + if { case "$host_os" in + mingw* | windows*) true;; + *) false;; + esac + }; then + gl_threads_api=windows + AC_DEFINE([USE_WINDOWS_THREADS], [1], + [Define if the native Windows multithreading API can be used.]) + fi + ;; + esac + fi + else + dnl "$gl_use_threads" is "no". + AC_DEFINE([AVOID_ANY_THREADS], [1], + [Define if no multithread safety and no multithreading is desired.]) + fi + AC_MSG_CHECKING([for multithread API to use]) + AC_MSG_RESULT([$gl_threads_api]) + AC_SUBST([LIBTHREAD]) + AC_SUBST([LTLIBTHREAD]) + AC_SUBST([LIBMULTITHREAD]) + AC_SUBST([LTLIBMULTITHREAD]) +]) + +AC_DEFUN([gl_THREADLIB], +[ + AC_REQUIRE([gl_THREADLIB_EARLY]) + AC_REQUIRE([gl_THREADLIB_BODY]) +]) + + +dnl gl_DISABLE_THREADS +dnl ------------------ +dnl Sets the gl_THREADLIB default so that threads are not used by default. +dnl The user can still override it at installation time, by using the +dnl configure option '--enable-threads'. + +AC_DEFUN([gl_DISABLE_THREADS], [ + m4_divert_text([INIT_PREPARE], [gl_use_threads_default=no]) +]) + + +dnl gl_AVOID_WINPTHREAD +dnl ------------------- +dnl Sets the gl_THREADLIB default so that on mingw, a dependency to the +dnl libwinpthread DLL (mingw-w64 winpthreads library) is avoided. +dnl The user can still override it at installation time, by using the +dnl configure option '--enable-threads=posix'. +dnl As of 2023, this is now the default. + +AC_DEFUN([gl_AVOID_WINPTHREAD], [ + m4_divert_text([INIT_PREPARE], [gl_use_winpthreads_default=no]) +]) + + +dnl ============================================================================ + + +dnl Survey of platforms: +dnl +dnl Platform Available Compiler Supports test-lock +dnl flavours option weak result +dnl --------------- --------- --------- -------- --------- +dnl Linux 2.4/glibc posix -lpthread Y OK +dnl +dnl Linux/glibc 2.34 posix Y OK +dnl +dnl GNU Hurd/glibc posix -lpthread Y OK +dnl +dnl Ubuntu 14.04 posix -pthread Y OK +dnl +dnl FreeBSD 5.3 posix -lc_r Y +dnl posix -lkse ? Y +dnl posix -lpthread ? Y +dnl posix -lthr Y +dnl +dnl FreeBSD 5.2 posix -lc_r Y +dnl posix -lkse Y +dnl posix -lthr Y +dnl +dnl FreeBSD 4.0,4.10 posix -lc_r Y OK +dnl +dnl NetBSD 1.6 -- +dnl +dnl OpenBSD 3.4 posix -lpthread Y OK +dnl +dnl Mac OS X 10.[123] posix -lpthread Y OK +dnl +dnl Solaris 7,8,9 posix -lpthread Y Sol 7,8: 0.0; Sol 9: OK +dnl +dnl HP-UX 11 posix -lpthread N (cc) OK +dnl Y (gcc) +dnl +dnl IRIX 6.5 posix -lpthread Y 0.5 +dnl +dnl AIX 4.3,5.1 posix -lpthread N AIX 4: 0.5; AIX 5: OK +dnl +dnl OSF/1 4.0,5.1 posix -pthread (cc) N OK +dnl -lpthread (gcc) Y +dnl +dnl Cygwin posix -lpthread Y OK +dnl +dnl Mingw windows N OK +dnl +dnl BeOS 5 -- +dnl +dnl The test-lock result shows what happens if in test-lock.c EXPLICIT_YIELD is +dnl turned off: +dnl OK if all three tests terminate OK, +dnl 0.5 if the first test terminates OK but the second one loops endlessly, +dnl 0.0 if the first test already loops endlessly. diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/time.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/time.m4 new file mode 100644 index 00000000..6f2347b2 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/time.m4 @@ -0,0 +1,55 @@ +# time.m4 serial 5 +dnl Copyright (C) 2023-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. + +AC_DEFUN([gl_FUNC_TIME], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) + dnl glibc has the bug https://sourceware.org/bugzilla/show_bug.cgi?id=30200 . + AC_CACHE_CHECK([whether time() works], + [gl_cv_func_time_works], + [dnl Guess that it works except on + dnl - glibc >= 2.31 with Linux. And binaries produced on glibc < 2.31 + dnl need to run fine on newer glibc versions as well; therefore ignore + dnl __GLIBC_MINOR__. + dnl - FreeBSD/sparc, + dnl - AIX, + dnl - native Windows. + case "$host_os" in + linux*-gnu*) + AC_EGREP_CPP([Unlucky], [ + #include + #ifdef __GNU_LIBRARY__ + #if __GLIBC__ == 2 + Unlucky GNU user + #endif + #endif + ], + [gl_cv_func_time_works="guessing no"], + [gl_cv_func_time_works="guessing yes"]) + ;; + freebsd*) + case "$host_cpu" in + sparc*) gl_cv_func_time_works="guessing no";; + *) gl_cv_func_time_works="guessing yes";; + esac + ;; + aix*) gl_cv_func_time_works="guessing no";; + mingw* | windows*) gl_cv_func_time_works="guessing no";; + *) gl_cv_func_time_works="guessing yes";; + esac + ]) + case "$gl_cv_func_time_works" in + *no) REPLACE_TIME=1 ;; + esac +]) + +# Prerequisites of lib/time.c. +AC_DEFUN([gl_PREREQ_TIME], +[ + : +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/time_h.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/time_h.m4 new file mode 100644 index 00000000..32fade0f --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/time_h.m4 @@ -0,0 +1,180 @@ +# Configure a more-standard replacement for . + +# Copyright (C) 2000-2001, 2003-2007, 2009-2024 Free Software Foundation, Inc. + +# serial 25 + +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# Written by Paul Eggert and Jim Meyering. + +AC_DEFUN_ONCE([gl_TIME_H], +[ + dnl Ensure to expand the default settings once only, before all statements + dnl that occur in other macros. + AC_REQUIRE([gl_TIME_H_DEFAULTS]) + + gl_NEXT_HEADERS([time.h]) + AC_REQUIRE([gl_CHECK_TYPE_STRUCT_TIMESPEC]) + + dnl Check for declarations of anything we want to poison if the + dnl corresponding gnulib module is not in use. + gl_WARN_ON_USE_PREPARE([[ +#include + ]], [ + asctime asctime_r ctime ctime_r gmtime_r localtime localtime_r mktime + nanosleep strftime strptime time timegm timespec_get timespec_getres tzset + ]) + + AC_REQUIRE([AC_C_RESTRICT]) + + AC_CACHE_CHECK([for TIME_UTC in ], + [gl_cv_time_h_has_TIME_UTC], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include + ]], + [[static int x = TIME_UTC; x++;]])], + [gl_cv_time_h_has_TIME_UTC=yes], + [gl_cv_time_h_has_TIME_UTC=no])]) + if test $gl_cv_time_h_has_TIME_UTC = yes; then + TIME_H_DEFINES_TIME_UTC=1 + else + TIME_H_DEFINES_TIME_UTC=0 + fi + AC_SUBST([TIME_H_DEFINES_TIME_UTC]) +]) + +dnl Check whether 'struct timespec' is declared +dnl in time.h, sys/time.h, pthread.h, or unistd.h. + +AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC], +[ + AC_CHECK_HEADERS_ONCE([sys/time.h]) + AC_CACHE_CHECK([for struct timespec in ], + [gl_cv_sys_struct_timespec_in_time_h], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include + ]], + [[static struct timespec x; x.tv_sec = x.tv_nsec;]])], + [gl_cv_sys_struct_timespec_in_time_h=yes], + [gl_cv_sys_struct_timespec_in_time_h=no])]) + + TIME_H_DEFINES_STRUCT_TIMESPEC=0 + SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=0 + PTHREAD_H_DEFINES_STRUCT_TIMESPEC=0 + UNISTD_H_DEFINES_STRUCT_TIMESPEC=0 + if test $gl_cv_sys_struct_timespec_in_time_h = yes; then + TIME_H_DEFINES_STRUCT_TIMESPEC=1 + else + AC_CACHE_CHECK([for struct timespec in ], + [gl_cv_sys_struct_timespec_in_sys_time_h], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include + ]], + [[static struct timespec x; x.tv_sec = x.tv_nsec;]])], + [gl_cv_sys_struct_timespec_in_sys_time_h=yes], + [gl_cv_sys_struct_timespec_in_sys_time_h=no])]) + if test $gl_cv_sys_struct_timespec_in_sys_time_h = yes; then + SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=1 + else + AC_CACHE_CHECK([for struct timespec in ], + [gl_cv_sys_struct_timespec_in_pthread_h], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include + ]], + [[static struct timespec x; x.tv_sec = x.tv_nsec;]])], + [gl_cv_sys_struct_timespec_in_pthread_h=yes], + [gl_cv_sys_struct_timespec_in_pthread_h=no])]) + if test $gl_cv_sys_struct_timespec_in_pthread_h = yes; then + PTHREAD_H_DEFINES_STRUCT_TIMESPEC=1 + else + AC_CACHE_CHECK([for struct timespec in ], + [gl_cv_sys_struct_timespec_in_unistd_h], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include + ]], + [[static struct timespec x; x.tv_sec = x.tv_nsec;]])], + [gl_cv_sys_struct_timespec_in_unistd_h=yes], + [gl_cv_sys_struct_timespec_in_unistd_h=no])]) + if test $gl_cv_sys_struct_timespec_in_unistd_h = yes; then + UNISTD_H_DEFINES_STRUCT_TIMESPEC=1 + fi + fi + fi + fi + AC_SUBST([TIME_H_DEFINES_STRUCT_TIMESPEC]) + AC_SUBST([SYS_TIME_H_DEFINES_STRUCT_TIMESPEC]) + AC_SUBST([PTHREAD_H_DEFINES_STRUCT_TIMESPEC]) + AC_SUBST([UNISTD_H_DEFINES_STRUCT_TIMESPEC]) +]) + +# gl_TIME_MODULE_INDICATOR([modulename]) +# sets the shell variable that indicates the presence of the given module +# to a C preprocessor expression that will evaluate to 1. +# This macro invocation must not occur in macros that are AC_REQUIREd. +AC_DEFUN([gl_TIME_MODULE_INDICATOR], +[ + dnl Ensure to expand the default settings once only. + gl_TIME_H_REQUIRE_DEFAULTS + gl_MODULE_INDICATOR_SET_VARIABLE([$1]) + dnl Define it also as a C macro, for the benefit of the unit tests. + gl_MODULE_INDICATOR_FOR_TESTS([$1]) +]) + +# Initializes the default values for AC_SUBSTed shell variables. +# This macro must not be AC_REQUIREd. It must only be invoked, and only +# outside of macros or in macros that are not AC_REQUIREd. +AC_DEFUN([gl_TIME_H_REQUIRE_DEFAULTS], +[ + m4_defun(GL_MODULE_INDICATOR_PREFIX[_TIME_H_MODULE_INDICATOR_DEFAULTS], [ + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CTIME]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKTIME]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOCALTIME]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_NANOSLEEP]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRFTIME]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRPTIME]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIME]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIMEGM]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIMESPEC_GET]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIMESPEC_GETRES]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIME_R]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIME_RZ]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TZSET]) + dnl Support Microsoft deprecated alias function names by default. + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_TZSET], [1]) + ]) + m4_require(GL_MODULE_INDICATOR_PREFIX[_TIME_H_MODULE_INDICATOR_DEFAULTS]) + AC_REQUIRE([gl_TIME_H_DEFAULTS]) +]) + +AC_DEFUN([gl_TIME_H_DEFAULTS], +[ + dnl Assume proper GNU behavior unless another module says otherwise. + HAVE_DECL_LOCALTIME_R=1; AC_SUBST([HAVE_DECL_LOCALTIME_R]) + HAVE_NANOSLEEP=1; AC_SUBST([HAVE_NANOSLEEP]) + HAVE_STRPTIME=1; AC_SUBST([HAVE_STRPTIME]) + HAVE_TIMEGM=1; AC_SUBST([HAVE_TIMEGM]) + HAVE_TIMESPEC_GET=1; AC_SUBST([HAVE_TIMESPEC_GET]) + HAVE_TIMESPEC_GETRES=1; AC_SUBST([HAVE_TIMESPEC_GETRES]) + dnl Even GNU libc does not have timezone_t yet. + HAVE_TIMEZONE_T=0; AC_SUBST([HAVE_TIMEZONE_T]) + REPLACE_CTIME=0; AC_SUBST([REPLACE_CTIME]) + REPLACE_GMTIME=0; AC_SUBST([REPLACE_GMTIME]) + REPLACE_LOCALTIME=0; AC_SUBST([REPLACE_LOCALTIME]) + REPLACE_LOCALTIME_R=0; AC_SUBST([REPLACE_LOCALTIME_R]) + REPLACE_MKTIME=0; AC_SUBST([REPLACE_MKTIME]) + REPLACE_NANOSLEEP=0; AC_SUBST([REPLACE_NANOSLEEP]) + REPLACE_STRFTIME=0; AC_SUBST([REPLACE_STRFTIME]) + REPLACE_TIME=0; AC_SUBST([REPLACE_TIME]) + REPLACE_TIMEGM=0; AC_SUBST([REPLACE_TIMEGM]) + REPLACE_TIMESPEC_GET=0; AC_SUBST([REPLACE_TIMESPEC_GET]) + REPLACE_TIMESPEC_GETRES=0; AC_SUBST([REPLACE_TIMESPEC_GETRES]) + REPLACE_TZSET=0; AC_SUBST([REPLACE_TZSET]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/time_r.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/time_r.m4 new file mode 100644 index 00000000..4ee2175b --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/time_r.m4 @@ -0,0 +1,97 @@ +dnl Reentrant time functions: localtime_r, gmtime_r. + +dnl Copyright (C) 2003, 2006-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl Written by Paul Eggert. + +AC_DEFUN([gl_TIME_R], +[ + dnl Persuade glibc and Solaris to declare localtime_r. + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + + AC_REQUIRE([gl_TIME_H_DEFAULTS]) + AC_REQUIRE([AC_C_RESTRICT]) + + dnl Some systems don't declare localtime_r() and gmtime_r() if _REENTRANT is + dnl not defined. + AC_CHECK_DECLS([localtime_r], [], [], + [[/* mingw's provides the functions asctime_r, ctime_r, + gmtime_r, localtime_r only if or has + been included before. */ + #if defined __MINGW32__ + # include + #endif + #include + ]]) + if test $ac_cv_have_decl_localtime_r = no; then + HAVE_DECL_LOCALTIME_R=0 + fi + + AC_CHECK_FUNCS_ONCE([localtime_r]) + if test $ac_cv_func_localtime_r = yes; then + HAVE_LOCALTIME_R=1 + AC_CACHE_CHECK([whether localtime_r is compatible with its POSIX signature], + [gl_cv_time_r_posix], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[/* mingw's provides the functions asctime_r, ctime_r, + gmtime_r, localtime_r only if or has + been included before. */ + #if defined __MINGW32__ + # include + #endif + #include + ]], + [[/* We don't need to append 'restrict's to the argument types, + even though the POSIX signature has the 'restrict's, + since C99 says they can't affect type compatibility. */ + struct tm * (*ptr) (time_t const *, struct tm *) = localtime_r; + if (ptr) return 0; + /* Check the return type is a pointer. + On HP-UX 10 it is 'int'. */ + *localtime_r (0, 0);]]) + ], + [gl_cv_time_r_posix=yes], + [gl_cv_time_r_posix=no]) + ]) + if test $gl_cv_time_r_posix != yes; then + REPLACE_LOCALTIME_R=1 + fi + else + HAVE_LOCALTIME_R=0 + dnl On mingw, localtime_r() is defined as an inline function; use through a + dnl direct function call works but the use as a function pointer leads to a + dnl link error. + AC_CACHE_CHECK([whether localtime_r exists as an inline function], + [gl_cv_func_localtime_r_inline], + [AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[/* mingw's provides the functions asctime_r, ctime_r, + gmtime_r, localtime_r only if or has + been included before. */ + #if defined __MINGW32__ + # include + #endif + #include + ]], + [[time_t a; + struct tm r; + localtime_r (&a, &r); + ]]) + ], + [gl_cv_func_localtime_r_inline=yes], + [gl_cv_func_localtime_r_inline=no]) + ]) + if test $gl_cv_func_localtime_r_inline = yes; then + REPLACE_LOCALTIME_R=1 + fi + fi +]) + +# Prerequisites of lib/time_r.c. +AC_DEFUN([gl_PREREQ_TIME_R], [ + : +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/time_rz.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/time_rz.m4 new file mode 100644 index 00000000..c3b72b76 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/time_rz.m4 @@ -0,0 +1,53 @@ +dnl Time zone functions: tzalloc, localtime_rz, etc. + +dnl Copyright (C) 2015-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl Written by Paul Eggert. + +AC_DEFUN([gl_TIME_RZ], +[ + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + AC_REQUIRE([gl_TIME_H_DEFAULTS]) + AC_REQUIRE([AC_STRUCT_TIMEZONE]) + + # On Mac OS X 10.6, localtime loops forever with some time_t values. + # See Bug#27706, Bug#27736, and + # https://lists.gnu.org/r/bug-gnulib/2017-07/msg00142.html + AC_CACHE_CHECK([whether localtime works even near extrema], + [gl_cv_func_localtime_works], + [gl_cv_func_localtime_works=yes + AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [[#include + #include + #include + #include + ]], [[ + time_t t = -67768038400666600; + struct tm *tm; + char *tz = getenv ("TZ"); + if (! (tz && strcmp (tz, "QQQ0") == 0)) + return 0; + alarm (2); + tm = localtime (&t); + /* Use TM and *TM to suppress over-optimization. */ + return tm && tm->tm_isdst; + ]])], + [(TZ=QQQ0 ./conftest$EXEEXT) >/dev/null 2>&1 || + gl_cv_func_localtime_works=no], + [], + [gl_cv_func_localtime_works="guessing yes"])]) + if test "$gl_cv_func_localtime_works" = no; then + AC_DEFINE([HAVE_LOCALTIME_INFLOOP_BUG], 1, + [Define if localtime-like functions can loop forever on + extreme arguments.]) + fi + + AC_CHECK_TYPES([timezone_t], [], [], [[#include ]]) + if test "$ac_cv_type_timezone_t" = yes; then + HAVE_TIMEZONE_T=1 + fi +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/timegm.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/timegm.m4 new file mode 100644 index 00000000..84336043 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/timegm.m4 @@ -0,0 +1,28 @@ +# timegm.m4 serial 16 +dnl Copyright (C) 2003, 2007, 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_TIMEGM], +[ + AC_REQUIRE([gl_TIME_H_DEFAULTS]) + AC_REQUIRE([gl_FUNC_MKTIME_WORKS]) + gl_CHECK_FUNCS_ANDROID([timegm], [[#include ]]) + if test $ac_cv_func_timegm = yes; then + if test "$gl_cv_func_working_mktime" != yes; then + # Assume that timegm is buggy if mktime is. + REPLACE_TIMEGM=1 + fi + else + HAVE_TIMEGM=0 + case "$gl_cv_onwards_func_timegm" in + future*) REPLACE_TIMEGM=1 ;; + esac + fi +]) + +# Prerequisites of lib/timegm.c. +AC_DEFUN([gl_PREREQ_TIMEGM], [ + : +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/timespec.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/timespec.m4 new file mode 100644 index 00000000..59a0db99 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/timespec.m4 @@ -0,0 +1,11 @@ +#serial 15 + +# Copyright (C) 2000-2001, 2003-2007, 2009-2024 Free Software Foundation, Inc. + +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +dnl From Jim Meyering + +AC_DEFUN([gl_TIMESPEC], [:]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/timespec_get.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/timespec_get.m4 new file mode 100644 index 00000000..e9ca73dc --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/timespec_get.m4 @@ -0,0 +1,21 @@ +# timespec_get.m4 serial 6 +dnl Copyright (C) 2021-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_TIMESPEC_GET], +[ + AC_REQUIRE([gl_TIME_H_DEFAULTS]) + + dnl Persuade OpenBSD to declare timespec_get(). + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + + AC_REQUIRE([gl_CHECK_FUNC_TIMESPEC_GET]) + if test $gl_cv_func_timespec_get != yes; then + HAVE_TIMESPEC_GET=0 + case "$gl_cv_onwards_func_timespec_get" in + future*) REPLACE_TIMESPEC_GET=1 ;; + esac + fi +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/tm_gmtoff.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/tm_gmtoff.m4 new file mode 100644 index 00000000..f2e51597 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/tm_gmtoff.m4 @@ -0,0 +1,14 @@ +# tm_gmtoff.m4 serial 3 +dnl Copyright (C) 2002, 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_TM_GMTOFF], +[ + AC_CHECK_MEMBER([struct tm.tm_gmtoff], + [AC_DEFINE([HAVE_TM_GMTOFF], [1], + [Define if struct tm has the tm_gmtoff member.])], + , + [#include ]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/tzset.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/tzset.m4 new file mode 100644 index 00000000..d220534d --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/tzset.m4 @@ -0,0 +1,17 @@ +# serial 18 + +# Copyright (C) 2003, 2007, 2009-2024 Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# Written by Paul Eggert and Jim Meyering. + +AC_DEFUN([gl_FUNC_TZSET], +[ + AC_REQUIRE([gl_TIME_H_DEFAULTS]) + AC_REQUIRE([AC_CANONICAL_HOST]) + case "$host_os" in + mingw* | windows*) REPLACE_TZSET=1 ;; + esac +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/uchar_h.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/uchar_h.m4 new file mode 100644 index 00000000..abd4f51f --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/uchar_h.m4 @@ -0,0 +1,249 @@ +# uchar_h.m4 serial 31 +dnl Copyright (C) 2019-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. +dnl Prepare the overridden . + +AC_DEFUN_ONCE([gl_UCHAR_H], +[ + AC_REQUIRE([gl_UCHAR_H_DEFAULTS]) + + gl_CHECK_NEXT_HEADERS([uchar.h]) + if test $ac_cv_header_uchar_h = yes; then + HAVE_UCHAR_H=1 + else + HAVE_UCHAR_H=0 + fi + AC_SUBST([HAVE_UCHAR_H]) + + gl_TYPE_CHAR8_T + gl_TYPE_CHAR16_T + gl_TYPE_CHAR32_T + + dnl In C++ mode, clang defines 'char16_t' and 'char32_t' as built-in types + dnl on some platforms (e.g. OpenBSD 6.7), and as types defined by many + dnl header files (, , , , + dnl and others) on some platforms (e.g. Mac OS X 10.13). + dnl The same thing may also happen for 'char8_t'; so, be prepared for it. + m4_ifdef([gl_ANSI_CXX], [AC_REQUIRE([gl_ANSI_CXX])]) + CXX_HAS_UCHAR_TYPES=0 + if test $HAVE_UCHAR_H = 0; then + if test "$CXX" != no; then + AC_CACHE_CHECK([whether the C++ compiler predefines the types], + [gl_cv_cxx_has_uchar_types], + [dnl We can't use AC_LANG_PUSH([C++]) and AC_LANG_POP([C++]) here, due to + dnl an autoconf bug . + cat > conftest.cpp <<\EOF +#include +char16_t a; +char32_t b; +EOF + gl_command="$CXX $CXXFLAGS $CPPFLAGS -c conftest.cpp" + if AC_TRY_EVAL([gl_command]); then + gl_cv_cxx_has_uchar_types=yes + else + gl_cv_cxx_has_uchar_types=no + fi + rm -fr conftest* + ]) + if test $gl_cv_cxx_has_uchar_types = yes; then + CXX_HAS_UCHAR_TYPES=1 + fi + fi + fi + AC_SUBST([CXX_HAS_UCHAR_TYPES]) + CXX_HAS_CHAR8_TYPE=0 + if test $HAVE_UCHAR_H = 0; then + if test "$CXX" != no; then + AC_CACHE_CHECK([whether the C++ compiler predefines the char8_t types], + [gl_cv_cxx_has_char8_type], + [dnl We can't use AC_LANG_PUSH([C++]) and AC_LANG_POP([C++]) here, due to + dnl an autoconf bug . + cat > conftest.cpp <<\EOF +#include +char8_t a; +EOF + gl_command="$CXX $CXXFLAGS $CPPFLAGS -c conftest.cpp" + if AC_TRY_EVAL([gl_command]); then + gl_cv_cxx_has_char8_type=yes + else + gl_cv_cxx_has_char8_type=no + fi + rm -fr conftest* + ]) + if test $gl_cv_cxx_has_char8_type = yes; then + CXX_HAS_CHAR8_TYPE=1 + fi + fi + fi + AC_SUBST([CXX_HAS_CHAR8_TYPE]) + + dnl Test whether a 'char32_t' can hold more characters than a 'wchar_t'. + gl_STDINT_BITSIZEOF([wchar_t], [gl_STDINT_INCLUDES]) + if test $BITSIZEOF_WCHAR_T -lt 32; then + SMALL_WCHAR_T=1 + else + SMALL_WCHAR_T=0 + fi + dnl SMALL_WCHAR_T is expected to be 1 on 32-bit AIX, Cygwin, native Windows. + AC_SUBST([SMALL_WCHAR_T]) + + dnl Check for declarations of anything we want to poison if the + dnl corresponding gnulib module is not in use, and which is not + dnl guaranteed by C11. + gl_WARN_ON_USE_PREPARE([[ + #ifdef __HAIKU__ + #include + #endif + #include + ]], [c32rtomb mbrtoc16 mbrtoc32]) +]) + +AC_DEFUN_ONCE([gl_TYPE_CHAR8_T], +[ + dnl Determine whether gnulib's would, if present, override char8_t. + AC_CACHE_CHECK([whether char8_t is correctly defined], + [gl_cv_type_char8_t_works], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[ + #ifdef __HAIKU__ + #include + #endif + #include + int verify[(char8_t)(-1) >= 0 && sizeof (char8_t) == sizeof (unsigned char) ? 1 : -1]; + ]]) + ], + [gl_cv_type_char8_t_works=yes], + [gl_cv_type_char8_t_works=no]) + ]) + if test $gl_cv_type_char8_t_works = no; then + GNULIBHEADERS_OVERRIDE_CHAR8_T=1 + else + GNULIBHEADERS_OVERRIDE_CHAR8_T=0 + fi + AC_SUBST([GNULIBHEADERS_OVERRIDE_CHAR8_T]) +]) + +dnl On Haiku 2020, char16_t and char32_t are incorrectly defined. +dnl See . +AC_DEFUN_ONCE([gl_TYPE_CHAR16_T], +[ + dnl Determine whether gnulib's would, if present, override char16_t. + AC_CACHE_CHECK([whether char16_t is correctly defined], + [gl_cv_type_char16_t_works], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[ + #ifdef __HAIKU__ + #include + #endif + #include + /* For simplicity, assume that uint16_least_t is equivalent to + 'unsigned short'. */ + int verify[(char16_t)(-1) >= 0 && sizeof (char16_t) == sizeof (unsigned short) ? 1 : -1]; + ]]) + ], + [gl_cv_type_char16_t_works=yes], + [gl_cv_type_char16_t_works=no]) + ]) + if test $gl_cv_type_char16_t_works = no; then + GNULIBHEADERS_OVERRIDE_CHAR16_T=1 + else + GNULIBHEADERS_OVERRIDE_CHAR16_T=0 + fi + AC_SUBST([GNULIBHEADERS_OVERRIDE_CHAR16_T]) +]) +AC_DEFUN_ONCE([gl_TYPE_CHAR32_T], +[ + dnl Determine whether gnulib's would, if present, override char32_t. + AC_CACHE_CHECK([whether char32_t is correctly defined], + [gl_cv_type_char32_t_works], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[ + #ifdef __HAIKU__ + #include + #endif + #include + /* For simplicity, assume that uint32_least_t is equivalent to + 'unsigned int'. */ + int verify[(char32_t)(-1) >= 0 && sizeof (char32_t) == sizeof (unsigned int) ? 1 : -1]; + ]]) + ], + [gl_cv_type_char32_t_works=yes], + [gl_cv_type_char32_t_works=no]) + ]) + if test $gl_cv_type_char32_t_works = no; then + GNULIBHEADERS_OVERRIDE_CHAR32_T=1 + else + GNULIBHEADERS_OVERRIDE_CHAR32_T=0 + fi + AC_SUBST([GNULIBHEADERS_OVERRIDE_CHAR32_T]) +]) + +# gl_UCHAR_MODULE_INDICATOR([modulename]) +# sets the shell variable that indicates the presence of the given module +# to a C preprocessor expression that will evaluate to 1. +# This macro invocation must not occur in macros that are AC_REQUIREd. +AC_DEFUN([gl_UCHAR_MODULE_INDICATOR], +[ + dnl Ensure to expand the default settings once only. + gl_UCHAR_H_REQUIRE_DEFAULTS + gl_MODULE_INDICATOR_SET_VARIABLE([$1]) + dnl Define it also as a C macro, for the benefit of the unit tests. + gl_MODULE_INDICATOR_FOR_TESTS([$1]) +]) + +# Initializes the default values for AC_SUBSTed shell variables. +# This macro must not be AC_REQUIREd. It must only be invoked, and only +# outside of macros or in macros that are not AC_REQUIREd. +AC_DEFUN([gl_UCHAR_H_REQUIRE_DEFAULTS], +[ + m4_defun(GL_MODULE_INDICATOR_PREFIX[_UCHAR_H_MODULE_INDICATOR_DEFAULTS], [ + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_BTOC32]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32ISALNUM]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32ISALPHA]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32ISBLANK]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32ISCNTRL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32ISDIGIT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32ISGRAPH]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32ISLOWER]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32ISPRINT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32ISPUNCT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32ISSPACE]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32ISUPPER]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32ISXDIGIT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32TOLOWER]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32TOUPPER]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32WIDTH]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32RTOMB]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32SNRTOMBS]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32SRTOMBS]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32STOMBS]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32SWIDTH]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32TOB]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32_APPLY_MAPPING]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32_APPLY_TYPE_TEST]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32_GET_MAPPING]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32_GET_TYPE_TEST]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBRTOC16]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBRTOC32]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSNRTOC32S]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSRTOC32S]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSTOC32S]) + ]) + m4_require(GL_MODULE_INDICATOR_PREFIX[_UCHAR_H_MODULE_INDICATOR_DEFAULTS]) + AC_REQUIRE([gl_UCHAR_H_DEFAULTS]) +]) + +AC_DEFUN([gl_UCHAR_H_DEFAULTS], +[ + dnl Assume proper GNU behavior unless another module says otherwise. + HAVE_C32RTOMB=1; AC_SUBST([HAVE_C32RTOMB]) + HAVE_MBRTOC16=1; AC_SUBST([HAVE_MBRTOC16]) + HAVE_MBRTOC32=1; AC_SUBST([HAVE_MBRTOC32]) + REPLACE_C32RTOMB=0; AC_SUBST([REPLACE_C32RTOMB]) + REPLACE_MBRTOC16=0; AC_SUBST([REPLACE_MBRTOC16]) + REPLACE_MBRTOC32=0; AC_SUBST([REPLACE_MBRTOC32]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/unicase_h.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/unicase_h.m4 new file mode 100644 index 00000000..ad2f6215 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/unicase_h.m4 @@ -0,0 +1,43 @@ +# unicase_h.m4 serial 1 +dnl Copyright (C) 2023-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN_ONCE([gl_UNICASE_H], +[ + dnl Ensure to expand the default settings once only, before all statements + dnl that occur in other macros. + AC_REQUIRE([gl_UNICASE_H_DEFAULTS]) +]) + +# gl_UNICASE_MODULE_INDICATOR([modulename]) +# sets the shell variable that indicates the presence of the given module +# to a C preprocessor expression that will evaluate to 1. +# This macro invocation must not occur in macros that are AC_REQUIREd. +AC_DEFUN([gl_UNICASE_MODULE_INDICATOR], +[ + dnl Ensure to expand the default settings once only. + gl_UNICASE_H_REQUIRE_DEFAULTS + gl_MODULE_INDICATOR_SET_VARIABLE([$1]) + dnl Define it also as a C macro, for the benefit of the unit tests. + gl_MODULE_INDICATOR_FOR_TESTS([$1]) +]) + +# Initializes the default values for AC_SUBSTed shell variables. +# This macro must not be AC_REQUIREd. It must only be invoked, and only +# outside of macros or in macros that are not AC_REQUIREd. +AC_DEFUN([gl_UNICASE_H_REQUIRE_DEFAULTS], +[ + m4_defun(GL_MODULE_INDICATOR_PREFIX[_UNICASE_H_MODULE_INDICATOR_DEFAULTS], [ + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICASE_EMPTY_PREFIX_CONTEXT_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICASE_EMPTY_SUFFIX_CONTEXT_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + ]) + m4_require(GL_MODULE_INDICATOR_PREFIX[_UNICASE_H_MODULE_INDICATOR_DEFAULTS]) + AC_REQUIRE([gl_UNICASE_H_DEFAULTS]) +]) + +AC_DEFUN([gl_UNICASE_H_DEFAULTS], +[ + dnl Assume proper GNU behavior unless another module says otherwise. +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/unictype_h.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/unictype_h.m4 new file mode 100644 index 00000000..c4bc5c2c --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/unictype_h.m4 @@ -0,0 +1,172 @@ +# unictype_h.m4 serial 1 +dnl Copyright (C) 2023-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN_ONCE([gl_UNICTYPE_H], +[ + dnl Ensure to expand the default settings once only, before all statements + dnl that occur in other macros. + AC_REQUIRE([gl_UNICTYPE_H_DEFAULTS]) +]) + +# gl_UNICTYPE_MODULE_INDICATOR([modulename]) +# sets the shell variable that indicates the presence of the given module +# to a C preprocessor expression that will evaluate to 1. +# This macro invocation must not occur in macros that are AC_REQUIREd. +AC_DEFUN([gl_UNICTYPE_MODULE_INDICATOR], +[ + dnl Ensure to expand the default settings once only. + gl_UNICTYPE_H_REQUIRE_DEFAULTS + gl_MODULE_INDICATOR_SET_VARIABLE([$1]) + dnl Define it also as a C macro, for the benefit of the unit tests. + gl_MODULE_INDICATOR_FOR_TESTS([$1]) +]) + +# Initializes the default values for AC_SUBSTed shell variables. +# This macro must not be AC_REQUIREd. It must only be invoked, and only +# outside of macros or in macros that are not AC_REQUIREd. +AC_DEFUN([gl_UNICTYPE_H_REQUIRE_DEFAULTS], +[ + m4_defun(GL_MODULE_INDICATOR_PREFIX[_UNICTYPE_H_MODULE_INDICATOR_DEFAULTS], [ + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_L_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_LC_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_LU_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_LL_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_LT_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_LM_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_LO_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_M_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_MN_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_MC_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_ME_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_N_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_ND_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_NL_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_NO_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_P_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_PC_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_PD_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_PS_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_PE_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_PI_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_PF_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_PO_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_S_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_SM_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_SC_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_SK_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_SO_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_Z_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_ZS_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_ZL_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_ZP_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_C_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_CC_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_CF_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_CS_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_CO_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_CN_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_WHITE_SPACE_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_ALPHABETIC_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_OTHER_ALPHABETIC_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_NOT_A_CHARACTER_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_DEFAULT_IGNORABLE_CODE_POINT_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_OTHER_DEFAULT_IGNORABLE_CODE_POINT_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_DEPRECATED_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_LOGICAL_ORDER_EXCEPTION_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_VARIATION_SELECTOR_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_PRIVATE_USE_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_UNASSIGNED_CODE_VALUE_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_UPPERCASE_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_OTHER_UPPERCASE_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_LOWERCASE_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_OTHER_LOWERCASE_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_TITLECASE_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_CASED_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_CASE_IGNORABLE_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_CHANGES_WHEN_LOWERCASED_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_CHANGES_WHEN_UPPERCASED_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_CHANGES_WHEN_TITLECASED_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_CHANGES_WHEN_CASEFOLDED_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_CHANGES_WHEN_CASEMAPPED_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_SOFT_DOTTED_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_ID_START_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_OTHER_ID_START_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_ID_CONTINUE_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_OTHER_ID_CONTINUE_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_XID_START_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_XID_CONTINUE_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_PATTERN_WHITE_SPACE_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_PATTERN_SYNTAX_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_JOIN_CONTROL_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_GRAPHEME_BASE_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_GRAPHEME_EXTEND_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_OTHER_GRAPHEME_EXTEND_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_GRAPHEME_LINK_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_BIDI_CONTROL_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_BIDI_LEFT_TO_RIGHT_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_BIDI_HEBREW_RIGHT_TO_LEFT_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_BIDI_ARABIC_RIGHT_TO_LEFT_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_BIDI_EUROPEAN_DIGIT_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_BIDI_EUR_NUM_SEPARATOR_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_BIDI_EUR_NUM_TERMINATOR_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_BIDI_ARABIC_DIGIT_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_BIDI_COMMON_SEPARATOR_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_BIDI_BLOCK_SEPARATOR_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_BIDI_SEGMENT_SEPARATOR_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_BIDI_WHITESPACE_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_BIDI_NON_SPACING_MARK_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_BIDI_BOUNDARY_NEUTRAL_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_BIDI_PDF_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_BIDI_EMBEDDING_OR_OVERRIDE_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_BIDI_OTHER_NEUTRAL_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_HEX_DIGIT_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_ASCII_HEX_DIGIT_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_IDEOGRAPHIC_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_UNIFIED_IDEOGRAPH_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_RADICAL_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_IDS_BINARY_OPERATOR_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_IDS_TRINARY_OPERATOR_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_EMOJI_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_EMOJI_PRESENTATION_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_EMOJI_MODIFIER_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_EMOJI_MODIFIER_BASE_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_EMOJI_COMPONENT_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_EXTENDED_PICTOGRAPHIC_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_ZERO_WIDTH_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_SPACE_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_NON_BREAK_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_ISO_CONTROL_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_FORMAT_CONTROL_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_DASH_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_HYPHEN_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_PUNCTUATION_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_LINE_SEPARATOR_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_PARAGRAPH_SEPARATOR_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_QUOTATION_MARK_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_SENTENCE_TERMINAL_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_TERMINAL_PUNCTUATION_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_CURRENCY_SYMBOL_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_MATH_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_OTHER_MATH_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_PAIRED_PUNCTUATION_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_LEFT_OF_PAIR_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_COMBINING_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_COMPOSITE_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_DECIMAL_DIGIT_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_NUMERIC_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_DIACRITIC_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_EXTENDER_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_IGNORABLE_CONTROL_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_REGIONAL_INDICATOR_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + ]) + m4_require(GL_MODULE_INDICATOR_PREFIX[_UNICTYPE_H_MODULE_INDICATOR_DEFAULTS]) + AC_REQUIRE([gl_UNICTYPE_H_DEFAULTS]) +]) + +AC_DEFUN([gl_UNICTYPE_H_DEFAULTS], +[ + dnl Assume proper GNU behavior unless another module says otherwise. +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/uninorm_h.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/uninorm_h.m4 new file mode 100644 index 00000000..aadf5598 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/uninorm_h.m4 @@ -0,0 +1,45 @@ +# uninorm_h.m4 serial 1 +dnl Copyright (C) 2023-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN_ONCE([gl_UNINORM_H], +[ + dnl Ensure to expand the default settings once only, before all statements + dnl that occur in other macros. + AC_REQUIRE([gl_UNINORM_H_DEFAULTS]) +]) + +# gl_UNINORM_MODULE_INDICATOR([modulename]) +# sets the shell variable that indicates the presence of the given module +# to a C preprocessor expression that will evaluate to 1. +# This macro invocation must not occur in macros that are AC_REQUIREd. +AC_DEFUN([gl_UNINORM_MODULE_INDICATOR], +[ + dnl Ensure to expand the default settings once only. + gl_UNINORM_H_REQUIRE_DEFAULTS + gl_MODULE_INDICATOR_SET_VARIABLE([$1]) + dnl Define it also as a C macro, for the benefit of the unit tests. + gl_MODULE_INDICATOR_FOR_TESTS([$1]) +]) + +# Initializes the default values for AC_SUBSTed shell variables. +# This macro must not be AC_REQUIREd. It must only be invoked, and only +# outside of macros or in macros that are not AC_REQUIREd. +AC_DEFUN([gl_UNINORM_H_REQUIRE_DEFAULTS], +[ + m4_defun(GL_MODULE_INDICATOR_PREFIX[_UNINORM_H_MODULE_INDICATOR_DEFAULTS], [ + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNINORM_NFD_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNINORM_NFC_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNINORM_NFKD_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNINORM_NFKC_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE']) + ]) + m4_require(GL_MODULE_INDICATOR_PREFIX[_UNINORM_H_MODULE_INDICATOR_DEFAULTS]) + AC_REQUIRE([gl_UNINORM_H_DEFAULTS]) +]) + +AC_DEFUN([gl_UNINORM_H_DEFAULTS], +[ + dnl Assume proper GNU behavior unless another module says otherwise. +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/unistd-safer.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/unistd-safer.m4 new file mode 100644 index 00000000..9d509648 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/unistd-safer.m4 @@ -0,0 +1,10 @@ +#serial 9 +dnl Copyright (C) 2002, 2005-2006, 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_UNISTD_SAFER], +[ + AC_CHECK_FUNCS_ONCE([pipe]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/unistd_h.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/unistd_h.m4 new file mode 100644 index 00000000..e078bd61 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/unistd_h.m4 @@ -0,0 +1,276 @@ +# unistd_h.m4 serial 95 +dnl Copyright (C) 2006-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl Written by Simon Josefsson, Bruno Haible. + +AC_DEFUN_ONCE([gl_UNISTD_H], +[ + dnl Ensure to expand the default settings once only, before all statements + dnl that occur in other macros. + AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) + + gl_CHECK_NEXT_HEADERS([unistd.h]) + if test $ac_cv_header_unistd_h = yes; then + HAVE_UNISTD_H=1 + else + HAVE_UNISTD_H=0 + fi + AC_SUBST([HAVE_UNISTD_H]) + + dnl Ensure the type pid_t gets defined. + AC_REQUIRE([AC_TYPE_PID_T]) + + dnl Determine WINDOWS_64_BIT_OFF_T. + AC_REQUIRE([gl_TYPE_OFF_T]) + + dnl Check for declarations of anything we want to poison if the + dnl corresponding gnulib module is not in use. + gl_WARN_ON_USE_PREPARE([[ +#if HAVE_UNISTD_H +# include +#endif +/* Some systems declare various items in the wrong headers. */ +#if !(defined __GLIBC__ && !defined __UCLIBC__) +# include +# include +# include +# if defined _WIN32 && ! defined __CYGWIN__ +# include +# endif +#endif + ]], [access chdir chown copy_file_range dup dup2 dup3 environ euidaccess + execl execle execlp execv execve execvp execvpe + faccessat fchdir + fchownat fdatasync fsync ftruncate getcwd getdomainname getdtablesize + getentropy getgroups gethostname getlogin getlogin_r getpagesize getpass + getusershell setusershell endusershell + group_member isatty lchown link linkat lseek pipe pipe2 pread pwrite + readlink readlinkat rmdir sethostname sleep symlink symlinkat + truncate ttyname_r unlink unlinkat usleep]) + + AC_REQUIRE([AC_C_RESTRICT]) + + AC_CHECK_DECLS_ONCE([execvpe]) + if test $ac_cv_have_decl_execvpe = no; then + HAVE_DECL_EXECVPE=0 + fi +]) + +# gl_UNISTD_MODULE_INDICATOR([modulename]) +# sets the shell variable that indicates the presence of the given module +# to a C preprocessor expression that will evaluate to 1. +# This macro invocation must not occur in macros that are AC_REQUIREd. +AC_DEFUN([gl_UNISTD_MODULE_INDICATOR], +[ + dnl Ensure to expand the default settings once only. + gl_UNISTD_H_REQUIRE_DEFAULTS + gl_MODULE_INDICATOR_SET_VARIABLE([$1]) + dnl Define it also as a C macro, for the benefit of the unit tests. + gl_MODULE_INDICATOR_FOR_TESTS([$1]) +]) + +# Initializes the default values for AC_SUBSTed shell variables. +# This macro must not be AC_REQUIREd. It must only be invoked, and only +# outside of macros or in macros that are not AC_REQUIREd. +AC_DEFUN([gl_UNISTD_H_REQUIRE_DEFAULTS], +[ + m4_defun(GL_MODULE_INDICATOR_PREFIX[_UNISTD_H_MODULE_INDICATOR_DEFAULTS], [ + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ACCESS]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CHDIR]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CHOWN]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CLOSE]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_COPY_FILE_RANGE]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_DUP]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_DUP2]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_DUP3]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ENVIRON]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EUIDACCESS]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXECL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXECLE]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXECLP]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXECV]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXECVE]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXECVP]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXECVPE]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FACCESSAT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FCHDIR]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FCHOWNAT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FDATASYNC]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FSYNC]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FTRUNCATE]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETCWD]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETDOMAINNAME]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETDTABLESIZE]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETENTROPY]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETGROUPS]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETHOSTNAME]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETLOGIN]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETLOGIN_R]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETOPT_POSIX]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETPAGESIZE]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETPASS]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETPASS_GNU]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETUSERSHELL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GROUP_MEMBER]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISATTY]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LCHOWN]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LINK]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LINKAT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LSEEK]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PIPE]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PIPE2]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PREAD]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PWRITE]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_READ]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_READLINK]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_READLINKAT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RMDIR]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SETHOSTNAME]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SLEEP]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SYMLINK]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SYMLINKAT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TRUNCATE]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TTYNAME_R]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNISTD_H_GETOPT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNISTD_H_NONBLOCKING]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNISTD_H_SIGPIPE]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNLINK]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNLINKAT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_USLEEP]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WRITE]) + dnl Support Microsoft deprecated alias function names by default. + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_ACCESS], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_CHDIR], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_CLOSE], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_DUP], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_DUP2], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_EXECL], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_EXECLE], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_EXECLP], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_EXECV], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_EXECVE], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_EXECVP], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_EXECVPE], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_GETCWD], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_GETPID], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_ISATTY], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_LSEEK], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_READ], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_RMDIR], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_SWAB], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_UNLINK], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_WRITE], [1]) + ]) + m4_require(GL_MODULE_INDICATOR_PREFIX[_UNISTD_H_MODULE_INDICATOR_DEFAULTS]) + AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) +]) + +AC_DEFUN([gl_UNISTD_H_DEFAULTS], +[ + dnl Assume proper GNU behavior unless another module says otherwise. + HAVE_CHOWN=1; AC_SUBST([HAVE_CHOWN]) + HAVE_COPY_FILE_RANGE=1; AC_SUBST([HAVE_COPY_FILE_RANGE]) + HAVE_DUP3=1; AC_SUBST([HAVE_DUP3]) + HAVE_EUIDACCESS=1; AC_SUBST([HAVE_EUIDACCESS]) + HAVE_EXECVPE=1; AC_SUBST([HAVE_EXECVPE]) + HAVE_FACCESSAT=1; AC_SUBST([HAVE_FACCESSAT]) + HAVE_FCHDIR=1; AC_SUBST([HAVE_FCHDIR]) + HAVE_FCHOWNAT=1; AC_SUBST([HAVE_FCHOWNAT]) + HAVE_FDATASYNC=1; AC_SUBST([HAVE_FDATASYNC]) + HAVE_FSYNC=1; AC_SUBST([HAVE_FSYNC]) + HAVE_FTRUNCATE=1; AC_SUBST([HAVE_FTRUNCATE]) + HAVE_GETDTABLESIZE=1; AC_SUBST([HAVE_GETDTABLESIZE]) + HAVE_GETENTROPY=1; AC_SUBST([HAVE_GETENTROPY]) + HAVE_GETGROUPS=1; AC_SUBST([HAVE_GETGROUPS]) + HAVE_GETHOSTNAME=1; AC_SUBST([HAVE_GETHOSTNAME]) + HAVE_GETLOGIN=1; AC_SUBST([HAVE_GETLOGIN]) + HAVE_GETPAGESIZE=1; AC_SUBST([HAVE_GETPAGESIZE]) + HAVE_GETPASS=1; AC_SUBST([HAVE_GETPASS]) + HAVE_GROUP_MEMBER=1; AC_SUBST([HAVE_GROUP_MEMBER]) + HAVE_LCHOWN=1; AC_SUBST([HAVE_LCHOWN]) + HAVE_LINK=1; AC_SUBST([HAVE_LINK]) + HAVE_LINKAT=1; AC_SUBST([HAVE_LINKAT]) + HAVE_PIPE=1; AC_SUBST([HAVE_PIPE]) + HAVE_PIPE2=1; AC_SUBST([HAVE_PIPE2]) + HAVE_PREAD=1; AC_SUBST([HAVE_PREAD]) + HAVE_PWRITE=1; AC_SUBST([HAVE_PWRITE]) + HAVE_READLINK=1; AC_SUBST([HAVE_READLINK]) + HAVE_READLINKAT=1; AC_SUBST([HAVE_READLINKAT]) + HAVE_SETHOSTNAME=1; AC_SUBST([HAVE_SETHOSTNAME]) + HAVE_SLEEP=1; AC_SUBST([HAVE_SLEEP]) + HAVE_SYMLINK=1; AC_SUBST([HAVE_SYMLINK]) + HAVE_SYMLINKAT=1; AC_SUBST([HAVE_SYMLINKAT]) + HAVE_UNLINKAT=1; AC_SUBST([HAVE_UNLINKAT]) + HAVE_USLEEP=1; AC_SUBST([HAVE_USLEEP]) + HAVE_DECL_ENVIRON=1; AC_SUBST([HAVE_DECL_ENVIRON]) + HAVE_DECL_EXECVPE=1; AC_SUBST([HAVE_DECL_EXECVPE]) + HAVE_DECL_FCHDIR=1; AC_SUBST([HAVE_DECL_FCHDIR]) + HAVE_DECL_FDATASYNC=1; AC_SUBST([HAVE_DECL_FDATASYNC]) + HAVE_DECL_GETDOMAINNAME=1; AC_SUBST([HAVE_DECL_GETDOMAINNAME]) + HAVE_DECL_GETLOGIN=1; AC_SUBST([HAVE_DECL_GETLOGIN]) + HAVE_DECL_GETLOGIN_R=1; AC_SUBST([HAVE_DECL_GETLOGIN_R]) + HAVE_DECL_GETPAGESIZE=1; AC_SUBST([HAVE_DECL_GETPAGESIZE]) + HAVE_DECL_GETUSERSHELL=1; AC_SUBST([HAVE_DECL_GETUSERSHELL]) + HAVE_DECL_SETHOSTNAME=1; AC_SUBST([HAVE_DECL_SETHOSTNAME]) + HAVE_DECL_TRUNCATE=1; AC_SUBST([HAVE_DECL_TRUNCATE]) + HAVE_DECL_TTYNAME_R=1; AC_SUBST([HAVE_DECL_TTYNAME_R]) + HAVE_OS_H=0; AC_SUBST([HAVE_OS_H]) + HAVE_SYS_PARAM_H=0; AC_SUBST([HAVE_SYS_PARAM_H]) + REPLACE_ACCESS=0; AC_SUBST([REPLACE_ACCESS]) + REPLACE_CHOWN=0; AC_SUBST([REPLACE_CHOWN]) + REPLACE_CLOSE=0; AC_SUBST([REPLACE_CLOSE]) + REPLACE_COPY_FILE_RANGE=0; AC_SUBST([REPLACE_COPY_FILE_RANGE]) + REPLACE_DUP=0; AC_SUBST([REPLACE_DUP]) + REPLACE_DUP2=0; AC_SUBST([REPLACE_DUP2]) + REPLACE_DUP3=0; AC_SUBST([REPLACE_DUP3]) + REPLACE_EXECL=0; AC_SUBST([REPLACE_EXECL]) + REPLACE_EXECLE=0; AC_SUBST([REPLACE_EXECLE]) + REPLACE_EXECLP=0; AC_SUBST([REPLACE_EXECLP]) + REPLACE_EXECV=0; AC_SUBST([REPLACE_EXECV]) + REPLACE_EXECVE=0; AC_SUBST([REPLACE_EXECVE]) + REPLACE_EXECVP=0; AC_SUBST([REPLACE_EXECVP]) + REPLACE_EXECVPE=0; AC_SUBST([REPLACE_EXECVPE]) + REPLACE_FACCESSAT=0; AC_SUBST([REPLACE_FACCESSAT]) + REPLACE_FCHDIR=0; AC_SUBST([REPLACE_FCHDIR]) + REPLACE_FCHOWNAT=0; AC_SUBST([REPLACE_FCHOWNAT]) + REPLACE_FDATASYNC=0; AC_SUBST([REPLACE_FDATASYNC]) + REPLACE_FTRUNCATE=0; AC_SUBST([REPLACE_FTRUNCATE]) + REPLACE_GETCWD=0; AC_SUBST([REPLACE_GETCWD]) + REPLACE_GETDOMAINNAME=0; AC_SUBST([REPLACE_GETDOMAINNAME]) + REPLACE_GETDTABLESIZE=0; AC_SUBST([REPLACE_GETDTABLESIZE]) + REPLACE_GETENTROPY=0; AC_SUBST([REPLACE_GETENTROPY]) + REPLACE_GETLOGIN_R=0; AC_SUBST([REPLACE_GETLOGIN_R]) + REPLACE_GETGROUPS=0; AC_SUBST([REPLACE_GETGROUPS]) + REPLACE_GETPAGESIZE=0; AC_SUBST([REPLACE_GETPAGESIZE]) + REPLACE_GETPASS=0; AC_SUBST([REPLACE_GETPASS]) + REPLACE_GETPASS_FOR_GETPASS_GNU=0; AC_SUBST([REPLACE_GETPASS_FOR_GETPASS_GNU]) + REPLACE_ISATTY=0; AC_SUBST([REPLACE_ISATTY]) + REPLACE_LCHOWN=0; AC_SUBST([REPLACE_LCHOWN]) + REPLACE_LINK=0; AC_SUBST([REPLACE_LINK]) + REPLACE_LINKAT=0; AC_SUBST([REPLACE_LINKAT]) + REPLACE_LSEEK=0; AC_SUBST([REPLACE_LSEEK]) + REPLACE_PIPE2=0; AC_SUBST([REPLACE_PIPE2]) + REPLACE_PREAD=0; AC_SUBST([REPLACE_PREAD]) + REPLACE_PWRITE=0; AC_SUBST([REPLACE_PWRITE]) + REPLACE_READ=0; AC_SUBST([REPLACE_READ]) + REPLACE_READLINK=0; AC_SUBST([REPLACE_READLINK]) + REPLACE_READLINKAT=0; AC_SUBST([REPLACE_READLINKAT]) + REPLACE_RMDIR=0; AC_SUBST([REPLACE_RMDIR]) + REPLACE_SETHOSTNAME=0; AC_SUBST([REPLACE_SETHOSTNAME]) + REPLACE_SLEEP=0; AC_SUBST([REPLACE_SLEEP]) + REPLACE_SYMLINK=0; AC_SUBST([REPLACE_SYMLINK]) + REPLACE_SYMLINKAT=0; AC_SUBST([REPLACE_SYMLINKAT]) + REPLACE_TRUNCATE=0; AC_SUBST([REPLACE_TRUNCATE]) + REPLACE_TTYNAME_R=0; AC_SUBST([REPLACE_TTYNAME_R]) + REPLACE_UNLINK=0; AC_SUBST([REPLACE_UNLINK]) + REPLACE_UNLINKAT=0; AC_SUBST([REPLACE_UNLINKAT]) + REPLACE_USLEEP=0; AC_SUBST([REPLACE_USLEEP]) + REPLACE_WRITE=0; AC_SUBST([REPLACE_WRITE]) + UNISTD_H_HAVE_SYS_RANDOM_H=0; AC_SUBST([UNISTD_H_HAVE_SYS_RANDOM_H]) + UNISTD_H_HAVE_WINSOCK2_H=0; AC_SUBST([UNISTD_H_HAVE_WINSOCK2_H]) + UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS=0; + AC_SUBST([UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/unlink.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/unlink.m4 new file mode 100644 index 00000000..19982a02 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/unlink.m4 @@ -0,0 +1,137 @@ +# unlink.m4 serial 17 +dnl Copyright (C) 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_UNLINK], +[ + AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_CHECK_HEADERS_ONCE([unistd.h]) + + dnl Detect FreeBSD 7.2, AIX 7.1, Solaris 9 bug. + AC_CACHE_CHECK([whether unlink honors trailing slashes], + [gl_cv_func_unlink_honors_slashes], + [touch conftest.file + # Assume that if we have lstat, we can also check symlinks. + if test $ac_cv_func_lstat = yes; then + ln -s conftest.file conftest.lnk + fi + AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [[#if HAVE_UNISTD_H + # include + #else /* on Windows with MSVC */ + # include + #endif + #include + ]GL_MDA_DEFINES], + [[int result = 0; + if (!unlink ("conftest.file/")) + result |= 1; + else if (errno != ENOTDIR) + result |= 2; +#if HAVE_LSTAT + if (!unlink ("conftest.lnk/")) + result |= 4; + else if (errno != ENOTDIR) + result |= 8; +#endif + return result; + ]])], + [gl_cv_func_unlink_honors_slashes=yes], + [gl_cv_func_unlink_honors_slashes=no], + [case "$host_os" in + # Guess yes on Linux systems. + linux-* | linux) gl_cv_func_unlink_honors_slashes="guessing yes" ;; + # Guess yes on systems that emulate the Linux system calls. + midipix*) gl_cv_func_unlink_honors_slashes="guessing yes" ;; + # Guess yes on glibc systems. + *-gnu*) gl_cv_func_unlink_honors_slashes="guessing yes" ;; + # Guess no on native Windows. + mingw* | windows*) gl_cv_func_unlink_honors_slashes="guessing no" ;; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_unlink_honors_slashes="$gl_cross_guess_normal" ;; + esac + ]) + rm -f conftest.file conftest.lnk]) + case "$gl_cv_func_unlink_honors_slashes" in + *no) + REPLACE_UNLINK=1 + ;; + esac + + dnl Detect Mac OS X 10.5.6 bug: On read-write HFS mounts, unlink("..") or + dnl unlink("../..") succeeds without doing anything. + AC_CACHE_CHECK([whether unlink of a parent directory fails as it should], + [gl_cv_func_unlink_parent_fails], + [case "$host_os" in + darwin*) + dnl Try to unlink a subdirectory of /tmp, because /tmp is usually on a + dnl HFS mount on Mac OS X. Use a subdirectory, owned by the current + dnl user, because otherwise unlink() may fail due to permissions + dnl reasons, and because when running as root we don't want to risk + dnl destroying the entire /tmp. + if { + # Use the mktemp program if available. If not available, hide the error + # message. + tmp=`(umask 077 && mktemp -d /tmp/gtXXXXXX) 2>/dev/null` && + test -n "$tmp" && test -d "$tmp" + } || + { + # Use a simple mkdir command. It is guaranteed to fail if the directory + # already exists. $RANDOM is bash specific and expands to empty in shells + # other than bash, ksh and zsh. Its use does not increase security; + # rather, it minimizes the probability of failure in a very cluttered /tmp + # directory. + tmp=/tmp/gt$$-$RANDOM + (umask 077 && mkdir "$tmp") + }; then + mkdir "$tmp/subdir" + GL_SUBDIR_FOR_UNLINK="$tmp/subdir" + export GL_SUBDIR_FOR_UNLINK + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ + #include + #if HAVE_UNISTD_H + # include + #else /* on Windows with MSVC */ + # include + # include + #endif + ]GL_MDA_DEFINES[ + int main () + { + int result = 0; + if (chdir (getenv ("GL_SUBDIR_FOR_UNLINK")) != 0) + result |= 1; + else if (unlink ("..") == 0) + result |= 2; + return result; + } + ]])], + [gl_cv_func_unlink_parent_fails=yes], + [gl_cv_func_unlink_parent_fails=no], + [# If we don't know, obey --enable-cross-guesses. + gl_cv_func_unlink_parent_fails="$gl_cross_guess_normal" + ]) + unset GL_SUBDIR_FOR_UNLINK + rm -rf "$tmp" + else + gl_cv_func_unlink_parent_fails="guessing no" + fi + ;; + *) + gl_cv_func_unlink_parent_fails="guessing yes" + ;; + esac + ]) + case "$gl_cv_func_unlink_parent_fails" in + *no) + REPLACE_UNLINK=1 + AC_DEFINE([UNLINK_PARENT_BUG], [1], + [Define to 1 if unlink() on a parent directory may succeed]) + ;; + esac +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/unlinkat.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/unlinkat.m4 new file mode 100644 index 00000000..d5615dfc --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/unlinkat.m4 @@ -0,0 +1,34 @@ +# unlinkat.m4 serial 2 +dnl Copyright (C) 2004-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +# Written by Jim Meyering. + +AC_DEFUN([gl_FUNC_UNLINKAT], +[ + AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + AC_CHECK_FUNCS_ONCE([unlinkat]) + AC_REQUIRE([gl_FUNC_UNLINK]) + AC_REQUIRE([gl_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK]) + if test $ac_cv_func_unlinkat = no; then + HAVE_UNLINKAT=0 + else + case "$gl_cv_func_lstat_dereferences_slashed_symlink" in + *no) + # Solaris 9 has *at functions, but uniformly mishandles trailing + # slash in all of them. + REPLACE_UNLINKAT=1 + ;; + *) + # GNU/Hurd has unlinkat, but it has the same bug as unlink. + # Darwin has unlinkat, but it has the same UNLINK_PARENT_BUG. + if test $REPLACE_UNLINK = 1; then + REPLACE_UNLINKAT=1 + fi + ;; + esac + fi +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/unlinkdir.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/unlinkdir.m4 new file mode 100644 index 00000000..baa3c0fc --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/unlinkdir.m4 @@ -0,0 +1,32 @@ +# serial 8 + +# Copyright (C) 2005-2007, 2009-2024 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# Written by Paul Eggert. + +AC_DEFUN([gl_UNLINKDIR], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_CHECK_HEADERS_ONCE([priv.h]) + + # The Hurd, the Linux kernel, the FreeBSD kernel version 2.2 and later, + # Cygwin, and mingw never let anyone (even root) unlink directories. + # If anyone knows of another system for which unlink can never + # remove a directory, please report it to . + # Unfortunately this is difficult to test for, since it requires root access + # and might create garbage in the file system, + # so the code below simply relies on the kernel name and version number. + case $host_os in + gnu[[0-9]]* | \ + linux-* | linux | \ + freebsd2.2* | freebsd[[3-9]]* | freebsd[[1-9]][[0-9]]* | \ + cygwin | \ + mingw* | windows*) + AC_DEFINE([UNLINK_CANNOT_UNLINK_DIR], [1], + [Define to 1 if unlink (dir) cannot possibly succeed.]);; + esac +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/unlocked-io.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/unlocked-io.m4 new file mode 100644 index 00000000..558f57d8 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/unlocked-io.m4 @@ -0,0 +1,36 @@ +# unlocked-io.m4 serial 16 + +# Copyright (C) 1998-2006, 2009-2024 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +dnl From Jim Meyering. +dnl +dnl See if the glibc *_unlocked I/O macros or functions are available. +dnl Use only those *_unlocked macros or functions that are declared +dnl (because some of them were declared in Solaris 2.5.1 but were removed +dnl in Solaris 2.6, whereas we want binaries built on Solaris 2.5.1 to run +dnl on Solaris 2.6). + +AC_DEFUN([gl_FUNC_GLIBC_UNLOCKED_IO], +[ + dnl Persuade glibc and Solaris to declare + dnl fgets_unlocked(), fputs_unlocked() etc. + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + + AC_CHECK_DECLS_ONCE([clearerr_unlocked]) + AC_CHECK_DECLS_ONCE([feof_unlocked]) + AC_CHECK_DECLS_ONCE([ferror_unlocked]) + AC_CHECK_DECLS_ONCE([fflush_unlocked]) + AC_CHECK_DECLS_ONCE([fgets_unlocked]) + AC_CHECK_DECLS_ONCE([fputc_unlocked]) + AC_CHECK_DECLS_ONCE([fputs_unlocked]) + AC_CHECK_DECLS_ONCE([fread_unlocked]) + AC_CHECK_DECLS_ONCE([fwrite_unlocked]) + AC_CHECK_DECLS_ONCE([getc_unlocked]) + AC_CHECK_DECLS_ONCE([getchar_unlocked]) + AC_CHECK_DECLS_ONCE([putc_unlocked]) + AC_CHECK_DECLS_ONCE([putchar_unlocked]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/vararrays.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/vararrays.m4 new file mode 100644 index 00000000..164bf0c4 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/vararrays.m4 @@ -0,0 +1,72 @@ +# Check for variable-length arrays. + +# serial 6 + +# From Paul Eggert + +# Copyright (C) 2001, 2009-2024 Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +m4_version_prereq([2.70], [], [ + +# AC_C_VARARRAYS +# -------------- +# Check whether the C compiler supports variable-length arrays. +AC_DEFUN([AC_C_VARARRAYS], +[ + AC_CACHE_CHECK([for variable-length arrays], + ac_cv_c_vararrays, + [AC_EGREP_CPP([defined], + [#ifdef __STDC_NO_VLA__ + defined + #endif + ], + [ac_cv_c_vararrays='no: __STDC_NO_VLA__ is defined'], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[/* Test for VLA support. This test is partly inspired + from examples in the C standard. Use at least two VLA + functions to detect the GCC 3.4.3 bug described in: + https://lists.gnu.org/archive/html/bug-gnulib/2014-08/msg00014.html + */ + #ifdef __STDC_NO_VLA__ + syntax error; + #else + extern int n; + int B[100]; + int fvla (int m, int C[m][m]); + + int + simple (int count, int all[static count]) + { + return all[count - 1]; + } + + int + fvla (int m, int C[m][m]) + { + typedef int VLA[m][m]; + VLA x; + int D[m]; + static int (*q)[m] = &B; + int (*s)[n] = q; + return C && &x[0][0] == &D[0] && &D[0] == s[0]; + } + #endif + ]])], + [ac_cv_c_vararrays=yes], + [ac_cv_c_vararrays=no])])]) + if test "$ac_cv_c_vararrays" = yes; then + dnl This is for compatibility with Autoconf 2.61-2.69. + AC_DEFINE([HAVE_C_VARARRAYS], 1, + [Define to 1 if C supports variable-length arrays.]) + elif test "$ac_cv_c_vararrays" = no; then + AC_DEFINE([__STDC_NO_VLA__], 1, + [Define to 1 if C does not support variable-length arrays, and + if the compiler does not already define this.]) + fi +]) + +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/vasnprintf.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/vasnprintf.m4 new file mode 100644 index 00000000..21a85bb1 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/vasnprintf.m4 @@ -0,0 +1,480 @@ +# vasnprintf.m4 serial 52 +dnl Copyright (C) 2002-2004, 2006-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_VASNPRINTF], +[ + AC_CHECK_FUNCS_ONCE([vasnprintf]) + if test $ac_cv_func_vasnprintf = no; then + gl_REPLACE_VASNPRINTF + fi +]) + +AC_DEFUN([gl_REPLACE_VASNPRINTF], +[ + AC_CHECK_FUNCS_ONCE([vasnprintf]) + AC_LIBOBJ([vasnprintf]) + AC_LIBOBJ([printf-args]) + AC_LIBOBJ([printf-parse]) + AC_LIBOBJ([asnprintf]) + if test $ac_cv_func_vasnprintf = yes; then + AC_DEFINE([REPLACE_VASNPRINTF], [1], + [Define if vasnprintf exists but is overridden by gnulib.]) + fi + gl_PREREQ_PRINTF_ARGS + gl_PREREQ_PRINTF_PARSE + gl_PREREQ_VASNPRINTF + gl_PREREQ_ASNPRINTF +]) + +AC_DEFUN([gl_FUNC_VASNWPRINTF], +[ + AC_LIBOBJ([printf-args]) + gl_PREREQ_PRINTF_ARGS + gl_PREREQ_PRINTF_PARSE + gl_PREREQ_VASNWPRINTF + gl_PREREQ_ASNPRINTF +]) + +# Prerequisites of lib/printf-args.h, lib/printf-args.c. +AC_DEFUN([gl_PREREQ_PRINTF_ARGS], +[ + AC_REQUIRE([gt_TYPE_WCHAR_T]) + AC_REQUIRE([gt_TYPE_WINT_T]) +]) + +# Prerequisites of lib/printf-parse.h, lib/printf-parse.c. +# Prerequisites of lib/wprintf-parse.h, lib/wprintf-parse.c. +AC_DEFUN([gl_PREREQ_PRINTF_PARSE], +[ + AC_REQUIRE([gl_FEATURES_H]) + AC_REQUIRE([gt_TYPE_WCHAR_T]) + AC_REQUIRE([gt_TYPE_WINT_T]) + AC_REQUIRE([AC_TYPE_SIZE_T]) + AC_CHECK_TYPE([ptrdiff_t], , + [AC_DEFINE([ptrdiff_t], [long], + [Define as the type of the result of subtracting two pointers, if the system doesn't define it.]) + ]) + AC_REQUIRE([gt_AC_TYPE_INTMAX_T]) +]) + +# Prerequisites of lib/vasnprintf.c if !WIDE_CHAR_VERSION. +AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF], +[ + AC_CHECK_FUNCS([snprintf strnlen wcrtomb]) + dnl Use the _snprintf function only if it is declared (because on NetBSD it + dnl is defined as a weak alias of snprintf; we prefer to use the latter). + AC_CHECK_DECLS([_snprintf], , , [[#include ]]) + dnl We can avoid a lot of code by assuming that snprintf's return value + dnl conforms to ISO C99. So check that. + AC_REQUIRE([gl_SNPRINTF_RETVAL_C99]) + case "$gl_cv_func_snprintf_retval_c99" in + *yes) + AC_DEFINE([HAVE_SNPRINTF_RETVAL_C99], [1], + [Define if the return value of the snprintf function is the number of + of bytes (excluding the terminating NUL) that would have been produced + if the buffer had been large enough.]) + ;; + esac + dnl Additionally, the use of %n can be eliminated by assuming that snprintf + dnl always produces NUL-terminated strings (no truncation). + AC_REQUIRE([gl_SNPRINTF_TRUNCATION_C99]) + case "$gl_cv_func_snprintf_truncation_c99" in + *yes) + AC_DEFINE([HAVE_SNPRINTF_TRUNCATION_C99], [1], + [Define if the string produced by the snprintf function is always NUL + terminated.]) + ;; + esac + gl_PREREQ_VASNXPRINTF +]) + +# Prerequisites of lib/vasnwprintf.c. +AC_DEFUN_ONCE([gl_PREREQ_VASNWPRINTF], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CHECK_FUNCS_ONCE([swprintf wcsnlen mbrtowc]) + AC_CHECK_DECLS([_snwprintf], , , [[#include ]]) + AC_CHECK_DECLS([wcsnlen], , , [[#include ]]) + gl_SWPRINTF_WORKS + case "$gl_cv_func_swprintf_works" in + *yes) + AC_DEFINE([HAVE_WORKING_SWPRINTF], [1], + [Define if the swprintf function works correctly when it produces output + that contains null wide characters.]) + ;; + esac + gl_MBRTOWC_C_LOCALE + case "$gl_cv_func_mbrtowc_C_locale_sans_EILSEQ" in + *yes) + AC_CACHE_CHECK([whether swprintf in the C locale is free of encoding errors], + [gl_cv_func_swprintf_C_locale_sans_EILSEQ], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#ifndef __USE_MINGW_ANSI_STDIO +# define __USE_MINGW_ANSI_STDIO 1 +#endif +#include +#include +int main() +{ + int result = 0; + { /* This test fails on glibc 2.35, musl libc 1.2.4, FreeBSD 13.2, NetBSD 9.3, + OpenBSD 7.2, Cygwin 2.9.0. + Reported at . */ + wchar_t buf[12]; + int ret = swprintf (buf, 12, L"%c", '\377'); + if (ret < 0) + result |= 1; + } + return result; +}]])], + [gl_cv_func_swprintf_C_locale_sans_EILSEQ=yes], + [gl_cv_func_swprintf_C_locale_sans_EILSEQ=no], + [case "$host_os" in + # Guess no on glibc systems. + *-gnu* | gnu*) gl_cv_func_swprintf_C_locale_sans_EILSEQ="guessing yes";; + # Guess no on musl systems. + *-musl* | midipix*) gl_cv_func_swprintf_C_locale_sans_EILSEQ="guessing no";; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_swprintf_C_locale_sans_EILSEQ="$gl_cross_guess_normal";; + esac + ]) + ]) + ;; + esac + if case "$gl_cv_func_mbrtowc_C_locale_sans_EILSEQ" in + *yes) false ;; + *) true ;; + esac \ + || case "$gl_cv_func_swprintf_C_locale_sans_EILSEQ" in + *yes) false ;; + *) true ;; + esac; then + AC_DEFINE([NEED_WPRINTF_DIRECTIVE_C], [1], + [Define if the vasnwprintf implementation needs special code for + the 'c' directive.]) + fi + gl_SWPRINTF_DIRECTIVE_LA + case "$gl_cv_func_swprintf_directive_la" in + *yes) ;; + *) + AC_DEFINE([NEED_WPRINTF_DIRECTIVE_LA], [1], + [Define if the vasnwprintf implementation needs special code for + the 'a' directive with 'long double' arguments.]) + ;; + esac + gl_SWPRINTF_DIRECTIVE_LC + case "$gl_cv_func_swprintf_directive_lc" in + *yes) ;; + *) + AC_DEFINE([NEED_WPRINTF_DIRECTIVE_LC], [1], + [Define if the vasnwprintf implementation needs special code for + the 'lc' directive.]) + ;; + esac + gl_MUSL_LIBC + gl_PREREQ_VASNXPRINTF +]) + +# Common prerequisites of lib/vasnprintf.c and lib/vasnwprintf.c. +AC_DEFUN_ONCE([gl_PREREQ_VASNXPRINTF], +[ + AC_REQUIRE([AC_FUNC_ALLOCA]) + AC_REQUIRE([gt_TYPE_WCHAR_T]) + AC_REQUIRE([gt_TYPE_WINT_T]) + AC_CHECK_FUNCS([wcslen]) + dnl Knowing DBL_EXPBIT0_WORD and DBL_EXPBIT0_BIT enables an optimization + dnl in the code for NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_DOUBLE. + AC_REQUIRE([gl_DOUBLE_EXPONENT_LOCATION]) +]) + +# Extra prerequisites of lib/vasnprintf.c for supporting 'long double' +# arguments. +AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF_LONG_DOUBLE], +[ + AC_REQUIRE([gl_PRINTF_LONG_DOUBLE]) + case "$gl_cv_func_printf_long_double" in + *yes) + ;; + *) + AC_DEFINE([NEED_PRINTF_LONG_DOUBLE], [1], + [Define if the vasnprintf implementation needs special code for + 'long double' arguments.]) + ;; + esac +]) + +# Extra prerequisites of lib/vasnprintf.c for supporting infinite 'double' +# arguments. +AC_DEFUN([gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE], +[ + AC_REQUIRE([gl_PRINTF_INFINITE]) + case "$gl_cv_func_printf_infinite" in + *yes) + ;; + *) + AC_DEFINE([NEED_PRINTF_INFINITE_DOUBLE], [1], + [Define if the vasnprintf implementation needs special code for + infinite 'double' arguments.]) + ;; + esac +]) + +# Extra prerequisites of lib/vasnprintf.c for supporting infinite 'long double' +# arguments. +AC_DEFUN([gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE], +[ + AC_REQUIRE([gl_PRINTF_INFINITE_LONG_DOUBLE]) + dnl There is no need to set NEED_PRINTF_INFINITE_LONG_DOUBLE if + dnl NEED_PRINTF_LONG_DOUBLE is already set. + AC_REQUIRE([gl_PREREQ_VASNPRINTF_LONG_DOUBLE]) + case "$gl_cv_func_printf_long_double" in + *yes) + case "$gl_cv_func_printf_infinite_long_double" in + *yes) + ;; + *) + AC_DEFINE([NEED_PRINTF_INFINITE_LONG_DOUBLE], [1], + [Define if the vasnprintf implementation needs special code for + infinite 'long double' arguments.]) + ;; + esac + ;; + esac +]) + +# Extra prerequisites of lib/vasnprintf.c for supporting the 'a' directive. +AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_A], +[ + AC_REQUIRE([gl_PRINTF_DIRECTIVE_A]) + case "$gl_cv_func_printf_directive_a" in + *yes) + ;; + *) + AC_DEFINE([NEED_PRINTF_DIRECTIVE_A], [1], + [Define if the vasnprintf implementation needs special code for + the 'a' and 'A' directives.]) + gl_CHECK_FUNCS_ANDROID([nl_langinfo], [[#include ]]) + ;; + esac +]) + +# Extra prerequisites of lib/vasnprintf.c for supporting the 'b' directive. +AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_B], +[ + AC_REQUIRE([gl_PRINTF_DIRECTIVE_B]) + case "$gl_cv_func_printf_directive_b" in + *yes) + ;; + *) + AC_DEFINE([NEED_PRINTF_DIRECTIVE_B], [1], + [Define if the vasnprintf implementation needs special code for + the 'b' directive.]) + ;; + esac +]) + +# Extra prerequisites of lib/vasnprintf.c for supporting the 'F' directive. +AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_F], +[ + AC_REQUIRE([gl_PRINTF_DIRECTIVE_F]) + case "$gl_cv_func_printf_directive_f" in + *yes) + ;; + *) + AC_DEFINE([NEED_PRINTF_DIRECTIVE_F], [1], + [Define if the vasnprintf implementation needs special code for + the 'F' directive.]) + ;; + esac +]) + +# Extra prerequisites of lib/vasnprintf.c for supporting the 'ls' directive. +AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_LS], +[ + AC_REQUIRE([gl_PRINTF_DIRECTIVE_LS]) + case "$gl_cv_func_printf_directive_ls" in + *yes) + ;; + *) + AC_DEFINE([NEED_PRINTF_DIRECTIVE_LS], [1], + [Define if the vasnprintf implementation needs special code for + the 'ls' directive.]) + ;; + esac +]) + +# Extra prerequisites of lib/vasnprintf.c for supporting the 'lc' directive. +AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_LC], +[ + AC_REQUIRE([gl_PRINTF_DIRECTIVE_LC]) + case "$gl_cv_func_printf_directive_lc" in + *yes) + ;; + *) + AC_DEFINE([NEED_PRINTF_DIRECTIVE_LC], [1], + [Define if the vasnprintf implementation needs special code for + the 'lc' directive.]) + ;; + esac +]) + +# Extra prerequisites of lib/vasnprintf.c for supporting the ' flag. +AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_GROUPING], +[ + AC_REQUIRE([gl_PRINTF_FLAG_GROUPING]) + case "$gl_cv_func_printf_flag_grouping" in + *yes) + ;; + *) + AC_DEFINE([NEED_PRINTF_FLAG_GROUPING], [1], + [Define if the vasnprintf implementation needs special code for the + ' flag.]) + ;; + esac +]) + +# Extra prerequisites of lib/vasnprintf.c for supporting the '-' flag. +AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_LEFTADJUST], +[ + AC_REQUIRE([gl_PRINTF_FLAG_LEFTADJUST]) + case "$gl_cv_func_printf_flag_leftadjust" in + *yes) + ;; + *) + AC_DEFINE([NEED_PRINTF_FLAG_LEFTADJUST], [1], + [Define if the vasnprintf implementation needs special code for the + '-' flag.]) + ;; + esac +]) + +# Extra prerequisites of lib/vasnprintf.c for supporting the 0 flag. +AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_ZERO], +[ + AC_REQUIRE([gl_PRINTF_FLAG_ZERO]) + case "$gl_cv_func_printf_flag_zero" in + *yes) + ;; + *) + AC_DEFINE([NEED_PRINTF_FLAG_ZERO], [1], + [Define if the vasnprintf implementation needs special code for the + 0 flag.]) + ;; + esac +]) + +# Extra prerequisites of lib/vasnprintf.c for supporting the # flag with a +# zero precision and a zero value in the 'x' and 'X' directives. +AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_ALT_PRECISION_ZERO], +[ + AC_REQUIRE([gl_PRINTF_FLAG_ALT_PRECISION_ZERO]) + case "$gl_cv_func_printf_flag_alt_precision_zero" in + *yes) + ;; + *) + AC_DEFINE([NEED_PRINTF_FLAG_ALT_PRECISION_ZERO], [1], + [Define if the vasnprintf implementation needs special code for the + # flag with a zero precision and a zero value in the 'x' and 'X' directives.]) + ;; + esac +]) + +# Extra prerequisites of lib/vasnprintf.c for supporting large precisions. +AC_DEFUN([gl_PREREQ_VASNPRINTF_PRECISION], +[ + AC_REQUIRE([gl_PRINTF_PRECISION]) + case "$gl_cv_func_printf_precision" in + *yes) + ;; + *) + AC_DEFINE([NEED_PRINTF_UNBOUNDED_PRECISION], [1], + [Define if the vasnprintf implementation needs special code for + supporting large precisions without arbitrary bounds.]) + AC_DEFINE([NEED_PRINTF_DOUBLE], [1], + [Define if the vasnprintf implementation needs special code for + 'double' arguments.]) + AC_DEFINE([NEED_PRINTF_LONG_DOUBLE], [1], + [Define if the vasnprintf implementation needs special code for + 'long double' arguments.]) + ;; + esac +]) + +# Extra prerequisites of lib/vasnprintf.c for surviving out-of-memory +# conditions. +AC_DEFUN([gl_PREREQ_VASNPRINTF_ENOMEM], +[ + AC_REQUIRE([gl_PRINTF_ENOMEM]) + case "$gl_cv_func_printf_enomem" in + *yes) + ;; + *) + AC_DEFINE([NEED_PRINTF_ENOMEM], [1], + [Define if the vasnprintf implementation needs special code for + surviving out-of-memory conditions.]) + AC_DEFINE([NEED_PRINTF_DOUBLE], [1], + [Define if the vasnprintf implementation needs special code for + 'double' arguments.]) + AC_DEFINE([NEED_PRINTF_LONG_DOUBLE], [1], + [Define if the vasnprintf implementation needs special code for + 'long double' arguments.]) + ;; + esac +]) + +# Prerequisites of lib/vasnprintf.c including all extras for POSIX compliance. +AC_DEFUN([gl_PREREQ_VASNPRINTF_WITH_POSIX_EXTRAS], +[ + AC_REQUIRE([gl_PREREQ_VASNPRINTF]) + gl_PREREQ_VASNPRINTF_LONG_DOUBLE + gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE + gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE + gl_PREREQ_VASNPRINTF_DIRECTIVE_A + gl_PREREQ_VASNPRINTF_DIRECTIVE_B + gl_PREREQ_VASNPRINTF_DIRECTIVE_F + gl_PREREQ_VASNPRINTF_DIRECTIVE_LS + gl_PREREQ_VASNPRINTF_DIRECTIVE_LC + gl_PREREQ_VASNPRINTF_FLAG_GROUPING + gl_PREREQ_VASNPRINTF_FLAG_LEFTADJUST + gl_PREREQ_VASNPRINTF_FLAG_ZERO + gl_PREREQ_VASNPRINTF_FLAG_ALT_PRECISION_ZERO + gl_PREREQ_VASNPRINTF_PRECISION + gl_PREREQ_VASNPRINTF_ENOMEM +]) + +# Extra prerequisites of lib/vasnprintf.c for supporting the 'B' directive. +AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_UPPERCASE_B], +[ + AC_REQUIRE([gl_PRINTF_DIRECTIVE_UPPERCASE_B]) + case "$gl_cv_func_printf_directive_uppercase_b" in + *yes) + ;; + *) + AC_DEFINE([NEED_PRINTF_DIRECTIVE_UPPERCASE_B], [1], + [Define if the vasnprintf implementation needs special code for + the 'B' directive.]) + ;; + esac +]) + +# Prerequisites of lib/vasnprintf.c including all extras for POSIX compliance +# and GNU compatibility. +AC_DEFUN([gl_PREREQ_VASNPRINTF_WITH_GNU_EXTRAS], +[ + gl_PREREQ_VASNPRINTF_WITH_POSIX_EXTRAS + AC_DEFINE([SUPPORT_GNU_PRINTF_DIRECTIVES], [1], + [Define if the vasnprintf implementation should support GNU compatible + printf directives.]) + gl_PREREQ_VASNPRINTF_DIRECTIVE_UPPERCASE_B +]) + +# Prerequisites of lib/asnprintf.c. +# Prerequisites of lib/asnwprintf.c. +AC_DEFUN([gl_PREREQ_ASNPRINTF], +[ +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/version-etc.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/version-etc.m4 new file mode 100644 index 00000000..d992e309 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/version-etc.m4 @@ -0,0 +1,33 @@ +# version-etc.m4 serial 2 +# Copyright (C) 2009-2024 Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +dnl $1 - configure flag and define name +dnl $2 - human readable description +m4_define([gl_VERSION_ETC_FLAG], +[dnl + AC_ARG_WITH([$1], [AS_HELP_STRING([[--with-]$1], [$2])], + [dnl + case $withval in + yes|no) ;; + *) AC_DEFINE_UNQUOTED(AS_TR_CPP([PACKAGE_$1]), ["$withval"], [$2]) ;; + esac + ]) +]) + +AC_DEFUN([gl_VERSION_ETC], +[dnl + gl_VERSION_ETC_FLAG([packager], + [String identifying the packager of this software]) + gl_VERSION_ETC_FLAG([packager-version], + [Packager-specific version information]) + gl_VERSION_ETC_FLAG([packager-bug-reports], + [Packager info for bug reports (URL/e-mail/...)]) + if test "X$with_packager" = "X" && \ + test "X$with_packager_version$with_packager_bug_reports" != "X" + then + AC_MSG_ERROR([The --with-packager-{bug-reports,version} options require --with-packager]) + fi +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/visibility.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/visibility.m4 new file mode 100644 index 00000000..b9b36a86 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/visibility.m4 @@ -0,0 +1,82 @@ +# visibility.m4 serial 8 +dnl Copyright (C) 2005, 2008, 2010-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. + +dnl Tests whether the compiler supports the command-line option +dnl -fvisibility=hidden and the function and variable attributes +dnl __attribute__((__visibility__("hidden"))) and +dnl __attribute__((__visibility__("default"))). +dnl Does *not* test for __visibility__("protected") - which has tricky +dnl semantics (see the 'vismain' test in glibc) and does not exist e.g. on +dnl Mac OS X. +dnl Does *not* test for __visibility__("internal") - which has processor +dnl dependent semantics. +dnl Does *not* test for #pragma GCC visibility push(hidden) - which is +dnl "really only recommended for legacy code". +dnl Set the variable CFLAG_VISIBILITY. +dnl Defines and sets the variable HAVE_VISIBILITY. + +AC_DEFUN([gl_VISIBILITY], +[ + AC_REQUIRE([AC_PROG_CC]) + CFLAG_VISIBILITY= + HAVE_VISIBILITY=0 + if test -n "$GCC"; then + dnl First, check whether -Werror can be added to the command line, or + dnl whether it leads to an error because of some other option that the + dnl user has put into $CC $CFLAGS $CPPFLAGS. + AC_CACHE_CHECK([whether the -Werror option is usable], + [gl_cv_cc_vis_werror], + [gl_save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -Werror" + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[]], [[]])], + [gl_cv_cc_vis_werror=yes], + [gl_cv_cc_vis_werror=no]) + CFLAGS="$gl_save_CFLAGS" + ]) + dnl Now check whether visibility declarations are supported. + AC_CACHE_CHECK([for simple visibility declarations], + [gl_cv_cc_visibility], + [gl_save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -fvisibility=hidden" + dnl We use the option -Werror and a function dummyfunc, because on some + dnl platforms (Cygwin 1.7) the use of -fvisibility triggers a warning + dnl "visibility attribute not supported in this configuration; ignored" + dnl at the first function definition in every compilation unit, and we + dnl don't want to use the option in this case. + if test $gl_cv_cc_vis_werror = yes; then + CFLAGS="$CFLAGS -Werror" + fi + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[extern __attribute__((__visibility__("hidden"))) int hiddenvar; + extern __attribute__((__visibility__("default"))) int exportedvar; + extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void); + extern __attribute__((__visibility__("default"))) int exportedfunc (void); + void dummyfunc (void); + int hiddenvar; + int exportedvar; + int hiddenfunc (void) { return 51; } + int exportedfunc (void) { return 1225736919; } + void dummyfunc (void) {} + ]], + [[]])], + [gl_cv_cc_visibility=yes], + [gl_cv_cc_visibility=no]) + CFLAGS="$gl_save_CFLAGS" + ]) + if test $gl_cv_cc_visibility = yes; then + CFLAG_VISIBILITY="-fvisibility=hidden" + HAVE_VISIBILITY=1 + fi + fi + AC_SUBST([CFLAG_VISIBILITY]) + AC_SUBST([HAVE_VISIBILITY]) + AC_DEFINE_UNQUOTED([HAVE_VISIBILITY], [$HAVE_VISIBILITY], + [Define to 1 or 0, depending whether the compiler supports simple visibility declarations.]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/warn-on-use.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/warn-on-use.m4 new file mode 100644 index 00000000..6e251fb8 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/warn-on-use.m4 @@ -0,0 +1,62 @@ +# warn-on-use.m4 serial 10 +dnl Copyright (C) 2010-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +# gl_WARN_ON_USE_PREPARE(INCLUDES, NAMES) +# --------------------------------------- +# If the module 'posixcheck' is in use: +# +# For each whitespace-separated element in the list of NAMES, define +# HAVE_RAW_DECL_name if the function has a declaration among INCLUDES +# even after being undefined as a macro. +# +# See warn-on-use.h for some hints on how to poison function names, as +# well as ideas on poisoning global variables and macros. NAMES may +# include global variables, but remember that only functions work with +# _GL_WARN_ON_USE. Typically, INCLUDES only needs to list a single +# header, but if the replacement header pulls in other headers because +# some systems declare functions in the wrong header, then INCLUDES +# should do likewise. +# +# It is generally safe to assume declarations for functions declared +# in the intersection of C89 and C11 (such as printf) without +# needing gl_WARN_ON_USE_PREPARE. +AC_DEFUN([gl_WARN_ON_USE_PREPARE], +[ + m4_ifdef([gl_POSIXCHECK], + [m4_foreach_w([gl_decl], [$2], + [AH_TEMPLATE([HAVE_RAW_DECL_]AS_TR_CPP(m4_defn([gl_decl])), + [Define to 1 if ]m4_defn([gl_decl])[ is declared even after + undefining macros.])])dnl + for gl_func in m4_flatten([$2]); do + AS_VAR_PUSHDEF([gl_Symbol], [gl_cv_have_raw_decl_$gl_func])dnl + dnl As a workaround to implicit built-in function declarations in + dnl clang (e.g. strndup), reference ac_compile_for_check_decl instead + dnl of ac_compile. If, for whatever reason, the override of AC_PROG_CC + dnl in zzgnulib.m4 is inactive, use the original ac_compile. + ac_save_ac_compile="$ac_compile" + if test -n "$ac_compile_for_check_decl"; then + ac_compile="$ac_compile_for_check_decl" + fi + AC_CACHE_CHECK([whether $gl_func is declared without a macro], + [gl_Symbol], + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$1], +[[#undef $gl_func + (void) $gl_func;]])], + [AS_VAR_SET([gl_Symbol], [yes])], [AS_VAR_SET([gl_Symbol], [no])])]) + ac_compile="$ac_save_ac_compile" + AS_VAR_IF([gl_Symbol], [yes], + [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_RAW_DECL_$gl_func]), [1]) + dnl Shortcut for an AC_CHECK_DECL invocation that may come later: + dnl If the raw declaration exists with the given includes, then + dnl AC_CHECK_DECL with its many includes would see it as well. + dnl So, set a cache variable to allow skipping any later + dnl AC_CHECK_DECL invocation for $gl_func. + eval "ac_cv_have_decl_$gl_func=yes" + ]) + AS_VAR_POPDEF([gl_Symbol])dnl + done + ]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/warnings.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/warnings.m4 new file mode 100644 index 00000000..6c97ef19 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/warnings.m4 @@ -0,0 +1,176 @@ +# warnings.m4 serial 19 +dnl Copyright (C) 2008-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Simon Josefsson + +AC_PREREQ([2.64]) + +# gl_COMPILER_OPTION_IF(OPTION, [IF-SUPPORTED], [IF-NOT-SUPPORTED], +# [PROGRAM = AC_LANG_PROGRAM()]) +# ----------------------------------------------------------------- +# Check if the compiler supports OPTION when compiling PROGRAM. +# +# The effects of this macro depend on the current language (_AC_LANG). +AC_DEFUN([gl_COMPILER_OPTION_IF], +[ +AS_VAR_PUSHDEF([gl_Warn], [gl_cv_warn_[]_AC_LANG_ABBREV[]_$1])dnl +AS_VAR_PUSHDEF([gl_Flags], [_AC_LANG_PREFIX[]FLAGS])dnl +AS_LITERAL_IF([$1], + [m4_pushdef([gl_Positive], m4_bpatsubst([$1], [^-Wno-], [-W]))], + [gl_positive="$1" +case $gl_positive in + -Wno-*) gl_positive=-W`expr "X$gl_positive" : 'X-Wno-\(.*\)'` ;; +esac +m4_pushdef([gl_Positive], [$gl_positive])])dnl +AC_CACHE_CHECK([whether _AC_LANG compiler handles $1], [gl_Warn], [ + gl_save_compiler_FLAGS="$gl_Flags" + AS_VAR_APPEND(m4_defn([gl_Flags]), + [" $gl_unknown_warnings_are_errors ]m4_defn([gl_Positive])["]) + AC_LINK_IFELSE([m4_default([$4], [AC_LANG_PROGRAM([[]])])], + [AS_VAR_SET([gl_Warn], [yes])], + [AS_VAR_SET([gl_Warn], [no])]) + gl_Flags="$gl_save_compiler_FLAGS" +]) +AS_VAR_IF(gl_Warn, [yes], [$2], [$3]) +m4_popdef([gl_Positive])dnl +AS_VAR_POPDEF([gl_Flags])dnl +AS_VAR_POPDEF([gl_Warn])dnl +]) + +# gl_UNKNOWN_WARNINGS_ARE_ERRORS +# ------------------------------ +# Clang doesn't complain about unknown warning options unless one also +# specifies -Wunknown-warning-option -Werror. Detect this. +# +# The effects of this macro depend on the current language (_AC_LANG). +AC_DEFUN([gl_UNKNOWN_WARNINGS_ARE_ERRORS], +[_AC_LANG_DISPATCH([$0], _AC_LANG, $@)]) + +# Specialization for _AC_LANG = C. This macro can be AC_REQUIREd. +AC_DEFUN([gl_UNKNOWN_WARNINGS_ARE_ERRORS(C)], +[ + AC_LANG_PUSH([C]) + gl_UNKNOWN_WARNINGS_ARE_ERRORS_IMPL + AC_LANG_POP([C]) +]) + +# Specialization for _AC_LANG = C++. This macro can be AC_REQUIREd. +AC_DEFUN([gl_UNKNOWN_WARNINGS_ARE_ERRORS(C++)], +[ + AC_LANG_PUSH([C++]) + gl_UNKNOWN_WARNINGS_ARE_ERRORS_IMPL + AC_LANG_POP([C++]) +]) + +# Specialization for _AC_LANG = Objective C. This macro can be AC_REQUIREd. +AC_DEFUN([gl_UNKNOWN_WARNINGS_ARE_ERRORS(Objective C)], +[ + AC_LANG_PUSH([Objective C]) + gl_UNKNOWN_WARNINGS_ARE_ERRORS_IMPL + AC_LANG_POP([Objective C]) +]) + +AC_DEFUN([gl_UNKNOWN_WARNINGS_ARE_ERRORS_IMPL], +[gl_COMPILER_OPTION_IF([-Werror -Wunknown-warning-option], + [gl_unknown_warnings_are_errors='-Wunknown-warning-option -Werror'], + [gl_unknown_warnings_are_errors=])]) + +# gl_WARN_ADD(OPTION, [VARIABLE = WARN_CFLAGS/WARN_CXXFLAGS], +# [PROGRAM = AC_LANG_PROGRAM()]) +# ----------------------------------------------------------- +# Adds OPTION to VARIABLE (which defaults to WARN_CFLAGS or WARN_CXXFLAGS) +# if the compiler supports it when compiling PROGRAM. +# +# If VARIABLE is a variable name, AC_SUBST it. +# +# The effects of this macro depend on the current language (_AC_LANG). +# +# Example: gl_WARN_ADD([-Wparentheses]). +AC_DEFUN([gl_WARN_ADD], +[AC_REQUIRE([gl_UNKNOWN_WARNINGS_ARE_ERRORS(]_AC_LANG[)]) +gl_COMPILER_OPTION_IF([$1], + [AS_VAR_APPEND(m4_if([$2], [], [[WARN_]_AC_LANG_PREFIX[FLAGS]], [[$2]]), [" $1"])], + [], + [$3]) +m4_ifval([$2], + [AS_LITERAL_IF([$2], [AC_SUBST([$2])])], + [AC_SUBST([WARN_]_AC_LANG_PREFIX[FLAGS])])dnl +]) + + +# gl_CC_INHIBIT_WARNINGS +# sets and substitutes a variable GL_CFLAG_INHIBIT_WARNINGS, to a $(CC) option +# that reverts all preceding -W* options, if available. +# This is expected to be '-w' at least on gcc, clang, AIX xlc, xlclang, Sun cc, +# "compile cl" (MSVC), "compile clang-cl" (MSVC-compatible clang). Or it can be +# empty. +AC_DEFUN([gl_CC_INHIBIT_WARNINGS], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_CACHE_CHECK([for C compiler option to inhibit all warnings], + [gl_cv_cc_winhibit], + [rm -f conftest* + echo 'int dummy;' > conftest.c + AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -c conftest.c 2>conftest1.err]) >/dev/null + AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -w -c conftest.c 2>conftest2.err]) >/dev/null + if test $? = 0 && test `wc -l < conftest1.err` = `wc -l < conftest2.err`; then + gl_cv_cc_winhibit='-w' + else + gl_cv_cc_winhibit=none + fi + rm -f conftest* + ]) + case "$gl_cv_cc_winhibit" in + none) GL_CFLAG_INHIBIT_WARNINGS='' ;; + *) + GL_CFLAG_INHIBIT_WARNINGS="$gl_cv_cc_winhibit" + dnl If all warnings are inhibited, there's no point in having the GCC + dnl analyzer enabled. This saves RAM requirements and CPU consumption. + gl_WARN_ADD([-fno-analyzer], [GL_CFLAG_INHIBIT_WARNINGS]) + ;; + esac + AC_SUBST([GL_CFLAG_INHIBIT_WARNINGS]) +]) + +# gl_CXX_INHIBIT_WARNINGS +# sets and substitutes a variable GL_CXXFLAG_INHIBIT_WARNINGS, to a $(CC) option +# that reverts all preceding -W* options, if available. +AC_DEFUN([gl_CXX_INHIBIT_WARNINGS], +[ + dnl Requires AC_PROG_CXX or gl_PROG_ANSI_CXX. + if test -n "$CXX" && test "$CXX" != no; then + AC_CACHE_CHECK([for C++ compiler option to inhibit all warnings], + [gl_cv_cxx_winhibit], + [rm -f conftest* + echo 'int dummy;' > conftest.cc + AC_TRY_COMMAND([${CXX-c++} $CXXFLAGS $CPPFLAGS -c conftest.cc 2>conftest1.err]) >/dev/null + AC_TRY_COMMAND([${CXX-c++} $CXXFLAGS $CPPFLAGS -w -c conftest.cc 2>conftest2.err]) >/dev/null + if test $? = 0 && test `wc -l < conftest1.err` = `wc -l < conftest2.err`; then + gl_cv_cxx_winhibit='-w' + else + gl_cv_cxx_winhibit=none + fi + rm -f conftest* + ]) + case "$gl_cv_cxx_winhibit" in + none) GL_CXXFLAG_INHIBIT_WARNINGS='' ;; + *) + GL_CXXFLAG_INHIBIT_WARNINGS="$gl_cv_cxx_winhibit" + dnl If all warnings are inhibited, there's no point in having the GCC + dnl analyzer enabled. This saves RAM requirements and CPU consumption. + gl_WARN_ADD([-fno-analyzer], [GL_CXXFLAG_INHIBIT_WARNINGS]) + ;; + esac + else + GL_CXXFLAG_INHIBIT_WARNINGS='' + fi + AC_SUBST([GL_CXXFLAG_INHIBIT_WARNINGS]) +]) + + +# Local Variables: +# mode: autoconf +# End: diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/wchar_h.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/wchar_h.m4 new file mode 100644 index 00000000..3582fa77 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/wchar_h.m4 @@ -0,0 +1,264 @@ +dnl A placeholder for ISO C99 , for platforms that have issues. + +dnl Copyright (C) 2007-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl Written by Eric Blake. + +# wchar_h.m4 serial 62 + +AC_DEFUN_ONCE([gl_WCHAR_H], +[ + AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) + AC_REQUIRE([gl_WCHAR_H_INLINE_OK]) + dnl Prepare for creating substitute . + dnl Check for (missing in Linux uClibc when built without wide + dnl character support). + dnl is always overridden, because of GNULIB_POSIXCHECK. + gl_CHECK_NEXT_HEADERS([wchar.h]) + if test $ac_cv_header_wchar_h = yes; then + HAVE_WCHAR_H=1 + else + HAVE_WCHAR_H=0 + fi + AC_SUBST([HAVE_WCHAR_H]) + + AC_REQUIRE([gl_FEATURES_H]) + + AC_REQUIRE([gt_TYPE_WINT_T]) + if test $gt_cv_c_wint_t = yes; then + HAVE_WINT_T=1 + else + HAVE_WINT_T=0 + fi + AC_SUBST([HAVE_WINT_T]) + + AC_REQUIRE([gl_TYPE_WINT_T_PREREQ]) + + dnl Check for declarations of anything we want to poison if the + dnl corresponding gnulib module is not in use. + gl_WARN_ON_USE_PREPARE([[ + #include + ]], + [btowc wctob mbsinit mbrtowc mbrlen mbsrtowcs mbsnrtowcs wcrtomb + wcsrtombs wcsnrtombs wcwidth + wmemchr wmemcmp wmemcpy wmemmove wmempcpy wmemset + wcslen wcsnlen wcscpy wcpcpy wcsncpy wcpncpy wcscat wcsncat wcscmp + wcsncmp wcscasecmp wcsncasecmp wcscoll wcsxfrm wcsdup wcschr wcsrchr + wcscspn wcsspn wcspbrk wcsstr wcstok wcswidth wcsftime + ]) + + AC_REQUIRE([AC_C_RESTRICT]) + + AC_CHECK_DECLS([wcsdup], [], [], [[ + #include + ]]) + if test $ac_cv_have_decl_wcsdup = no; then + HAVE_DECL_WCSDUP=0 + fi +]) + +dnl Check whether is usable at all. +AC_DEFUN([gl_WCHAR_H_INLINE_OK], +[ + dnl Test whether suffers due to the transition from '__inline' to + dnl 'gnu_inline'. See + dnl and . In summary, + dnl glibc version 2.5 or older, together with gcc version 4.3 or newer and + dnl the option -std=c99 or -std=gnu99, leads to a broken . + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_CACHE_CHECK([whether uses 'inline' correctly], + [gl_cv_header_wchar_h_correct_inline], + [gl_cv_header_wchar_h_correct_inline=yes + case "$host_os" in + *-gnu* | gnu*) + AC_LANG_CONFTEST([ + AC_LANG_SOURCE([[ + #define wcstod renamed_wcstod + #include + extern int zero (void); + int main () { return zero(); } + ]])]) + dnl Do not rename the object file from conftest.$ac_objext to + dnl conftest1.$ac_objext, as this will cause the link to fail on + dnl z/OS when using the XPLINK object format (due to duplicate + dnl CSECT names). Instead, temporarily redefine $ac_compile so + dnl that the object file has the latter name from the start. + save_ac_compile="$ac_compile" + ac_compile=`echo "$save_ac_compile" | sed s/conftest/conftest1/` + if echo '#include "conftest.c"' >conftest1.c \ + && AC_TRY_EVAL([ac_compile]); then + AC_LANG_CONFTEST([ + AC_LANG_SOURCE([[ + #define wcstod renamed_wcstod + #include + int zero (void) { return 0; } + ]])]) + dnl See note above about renaming object files. + ac_compile=`echo "$save_ac_compile" | sed s/conftest/conftest2/` + if echo '#include "conftest.c"' >conftest2.c \ + && AC_TRY_EVAL([ac_compile]); then + if $CC -o conftest$ac_exeext $CFLAGS $LDFLAGS conftest1.$ac_objext conftest2.$ac_objext $LIBS >&AS_MESSAGE_LOG_FD 2>&1; then + : + else + gl_cv_header_wchar_h_correct_inline=no + fi + fi + fi + ac_compile="$save_ac_compile" + rm -f conftest[12].c conftest[12].$ac_objext conftest$ac_exeext + ;; + esac + ]) + if test $gl_cv_header_wchar_h_correct_inline = no; then + AC_MSG_ERROR([ cannot be used with this compiler ($CC $CFLAGS $CPPFLAGS). +This is a known interoperability problem of glibc <= 2.5 with gcc >= 4.3 in +C99 mode. You have four options: + - Add the flag -fgnu89-inline to CC and reconfigure, or + - Fix your include files, using parts of + , or + - Use a gcc version older than 4.3, or + - Don't use the flags -std=c99 or -std=gnu99. +Configuration aborted.]) + fi +]) + +# gl_WCHAR_MODULE_INDICATOR([modulename]) +# sets the shell variable that indicates the presence of the given module +# to a C preprocessor expression that will evaluate to 1. +# This macro invocation must not occur in macros that are AC_REQUIREd. +AC_DEFUN([gl_WCHAR_MODULE_INDICATOR], +[ + dnl Ensure to expand the default settings once only. + gl_WCHAR_H_REQUIRE_DEFAULTS + gl_MODULE_INDICATOR_SET_VARIABLE([$1]) + dnl Define it also as a C macro, for the benefit of the unit tests. + gl_MODULE_INDICATOR_FOR_TESTS([$1]) +]) + +# Initializes the default values for AC_SUBSTed shell variables. +# This macro must not be AC_REQUIREd. It must only be invoked, and only +# outside of macros or in macros that are not AC_REQUIREd. +AC_DEFUN([gl_WCHAR_H_REQUIRE_DEFAULTS], +[ + m4_defun(GL_MODULE_INDICATOR_PREFIX[_WCHAR_H_MODULE_INDICATOR_DEFAULTS], [ + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_BTOWC]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCTOB]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSINIT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSZERO]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBRTOWC]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBRLEN]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSRTOWCS]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSNRTOWCS]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCRTOMB]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSRTOMBS]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSNRTOMBS]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCWIDTH]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WMEMCHR]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WMEMCMP]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WMEMCPY]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WMEMMOVE]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WMEMPCPY]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WMEMSET]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSLEN]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSNLEN]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSCPY]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCPCPY]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSNCPY]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCPNCPY]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSCAT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSNCAT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSCMP]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSNCMP]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSCASECMP]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSNCASECMP]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSCOLL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSXFRM]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSDUP]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSCHR]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSRCHR]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSCSPN]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSSPN]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSPBRK]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSSTR]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSTOK]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSWIDTH]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSFTIME]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WGETCWD]) + dnl Support Microsoft deprecated alias function names by default. + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_WCSDUP], [1]) + ]) + m4_require(GL_MODULE_INDICATOR_PREFIX[_WCHAR_H_MODULE_INDICATOR_DEFAULTS]) + dnl Make sure the shell variable for GNULIB_FREE_POSIX is initialized. + gl_STDLIB_H_REQUIRE_DEFAULTS + AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) +]) + +AC_DEFUN([gl_WCHAR_H_DEFAULTS], +[ + dnl Assume proper GNU behavior unless another module says otherwise. + HAVE_BTOWC=1; AC_SUBST([HAVE_BTOWC]) + HAVE_MBSINIT=1; AC_SUBST([HAVE_MBSINIT]) + HAVE_MBRTOWC=1; AC_SUBST([HAVE_MBRTOWC]) + HAVE_MBRLEN=1; AC_SUBST([HAVE_MBRLEN]) + HAVE_MBSRTOWCS=1; AC_SUBST([HAVE_MBSRTOWCS]) + HAVE_MBSNRTOWCS=1; AC_SUBST([HAVE_MBSNRTOWCS]) + HAVE_WCRTOMB=1; AC_SUBST([HAVE_WCRTOMB]) + HAVE_WCSRTOMBS=1; AC_SUBST([HAVE_WCSRTOMBS]) + HAVE_WCSNRTOMBS=1; AC_SUBST([HAVE_WCSNRTOMBS]) + HAVE_WMEMCHR=1; AC_SUBST([HAVE_WMEMCHR]) + HAVE_WMEMCMP=1; AC_SUBST([HAVE_WMEMCMP]) + HAVE_WMEMCPY=1; AC_SUBST([HAVE_WMEMCPY]) + HAVE_WMEMMOVE=1; AC_SUBST([HAVE_WMEMMOVE]) + HAVE_WMEMPCPY=1; AC_SUBST([HAVE_WMEMPCPY]) + HAVE_WMEMSET=1; AC_SUBST([HAVE_WMEMSET]) + HAVE_WCSLEN=1; AC_SUBST([HAVE_WCSLEN]) + HAVE_WCSNLEN=1; AC_SUBST([HAVE_WCSNLEN]) + HAVE_WCSCPY=1; AC_SUBST([HAVE_WCSCPY]) + HAVE_WCPCPY=1; AC_SUBST([HAVE_WCPCPY]) + HAVE_WCSNCPY=1; AC_SUBST([HAVE_WCSNCPY]) + HAVE_WCPNCPY=1; AC_SUBST([HAVE_WCPNCPY]) + HAVE_WCSCAT=1; AC_SUBST([HAVE_WCSCAT]) + HAVE_WCSNCAT=1; AC_SUBST([HAVE_WCSNCAT]) + HAVE_WCSCMP=1; AC_SUBST([HAVE_WCSCMP]) + HAVE_WCSNCMP=1; AC_SUBST([HAVE_WCSNCMP]) + HAVE_WCSCASECMP=1; AC_SUBST([HAVE_WCSCASECMP]) + HAVE_WCSNCASECMP=1; AC_SUBST([HAVE_WCSNCASECMP]) + HAVE_WCSCOLL=1; AC_SUBST([HAVE_WCSCOLL]) + HAVE_WCSXFRM=1; AC_SUBST([HAVE_WCSXFRM]) + HAVE_WCSDUP=1; AC_SUBST([HAVE_WCSDUP]) + HAVE_WCSCHR=1; AC_SUBST([HAVE_WCSCHR]) + HAVE_WCSRCHR=1; AC_SUBST([HAVE_WCSRCHR]) + HAVE_WCSCSPN=1; AC_SUBST([HAVE_WCSCSPN]) + HAVE_WCSSPN=1; AC_SUBST([HAVE_WCSSPN]) + HAVE_WCSPBRK=1; AC_SUBST([HAVE_WCSPBRK]) + HAVE_WCSSTR=1; AC_SUBST([HAVE_WCSSTR]) + HAVE_WCSTOK=1; AC_SUBST([HAVE_WCSTOK]) + HAVE_WCSWIDTH=1; AC_SUBST([HAVE_WCSWIDTH]) + HAVE_WCSFTIME=1; AC_SUBST([HAVE_WCSFTIME]) + HAVE_DECL_WCTOB=1; AC_SUBST([HAVE_DECL_WCTOB]) + HAVE_DECL_WCSDUP=1; AC_SUBST([HAVE_DECL_WCSDUP]) + HAVE_DECL_WCWIDTH=1; AC_SUBST([HAVE_DECL_WCWIDTH]) + REPLACE_MBSTATE_T=0; AC_SUBST([REPLACE_MBSTATE_T]) + REPLACE_BTOWC=0; AC_SUBST([REPLACE_BTOWC]) + REPLACE_WCTOB=0; AC_SUBST([REPLACE_WCTOB]) + REPLACE_MBSINIT=0; AC_SUBST([REPLACE_MBSINIT]) + REPLACE_MBRTOWC=0; AC_SUBST([REPLACE_MBRTOWC]) + REPLACE_MBRLEN=0; AC_SUBST([REPLACE_MBRLEN]) + REPLACE_MBSRTOWCS=0; AC_SUBST([REPLACE_MBSRTOWCS]) + REPLACE_MBSNRTOWCS=0; AC_SUBST([REPLACE_MBSNRTOWCS]) + REPLACE_WCRTOMB=0; AC_SUBST([REPLACE_WCRTOMB]) + REPLACE_WCSRTOMBS=0; AC_SUBST([REPLACE_WCSRTOMBS]) + REPLACE_WCSNRTOMBS=0; AC_SUBST([REPLACE_WCSNRTOMBS]) + REPLACE_WCWIDTH=0; AC_SUBST([REPLACE_WCWIDTH]) + REPLACE_WCSWIDTH=0; AC_SUBST([REPLACE_WCSWIDTH]) + REPLACE_WCSFTIME=0; AC_SUBST([REPLACE_WCSFTIME]) + REPLACE_WCSCMP=0; AC_SUBST([REPLACE_WCSCMP]) + REPLACE_WCSNCMP=0; AC_SUBST([REPLACE_WCSNCMP]) + REPLACE_WCSSTR=0; AC_SUBST([REPLACE_WCSSTR]) + REPLACE_WCSTOK=0; AC_SUBST([REPLACE_WCSTOK]) + REPLACE_WMEMCMP=0; AC_SUBST([REPLACE_WMEMCMP]) + REPLACE_WMEMPCPY=0; AC_SUBST([REPLACE_WMEMPCPY]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/wchar_t.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/wchar_t.m4 new file mode 100644 index 00000000..94353571 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/wchar_t.m4 @@ -0,0 +1,24 @@ +# wchar_t.m4 serial 4 (gettext-0.18.2) +dnl Copyright (C) 2002-2003, 2008-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. +dnl Test whether has the 'wchar_t' type. +dnl Prerequisite: AC_PROG_CC + +AC_DEFUN([gt_TYPE_WCHAR_T], +[ + AC_CACHE_CHECK([for wchar_t], [gt_cv_c_wchar_t], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include + wchar_t foo = (wchar_t)'\0';]], + [[]])], + [gt_cv_c_wchar_t=yes], + [gt_cv_c_wchar_t=no])]) + if test $gt_cv_c_wchar_t = yes; then + AC_DEFINE([HAVE_WCHAR_T], [1], [Define if you have the 'wchar_t' type.]) + fi +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/wcrtomb.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/wcrtomb.m4 new file mode 100644 index 00000000..f00f6452 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/wcrtomb.m4 @@ -0,0 +1,152 @@ +# wcrtomb.m4 serial 19 +dnl Copyright (C) 2008-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_WCRTOMB], +[ + AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) + + AC_REQUIRE([AC_TYPE_MBSTATE_T]) + gl_MBSTATE_T_BROKEN + + AC_CHECK_FUNCS_ONCE([wcrtomb]) + if test $ac_cv_func_wcrtomb = no; then + HAVE_WCRTOMB=0 + AC_CHECK_DECLS([wcrtomb],,, [[ + #include + ]]) + if test $ac_cv_have_decl_wcrtomb = yes; then + dnl On Minix 3.1.8, the system's declares wcrtomb() although + dnl it does not have the function. Avoid a collision with gnulib's + dnl replacement. + REPLACE_WCRTOMB=1 + fi + else + dnl We don't actually need to override wcrtomb when redefining the semantics + dnl of the mbstate_t type. Tested on 32-bit AIX. + dnl if test $REPLACE_MBSTATE_T = 1; then + dnl REPLACE_WCRTOMB=1 + dnl fi + if test $REPLACE_WCRTOMB = 0; then + dnl On Android 4.3, wcrtomb produces wrong characters in the C locale. + dnl On AIX 4.3, OSF/1 5.1 and Solaris <= 11.3, wcrtomb (NULL, 0, NULL) + dnl sometimes returns 0 instead of 1. + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([gt_LOCALE_FR]) + AC_REQUIRE([gt_LOCALE_FR_UTF8]) + AC_REQUIRE([gt_LOCALE_JA]) + AC_REQUIRE([gt_LOCALE_ZH_CN]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether wcrtomb works in the C locale], + [gl_cv_func_wcrtomb_works], + [AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +#include +int main () +{ + mbstate_t state; + char out[64]; + int count; + memset (&state, 0, sizeof (state)); + out[0] = 'x'; + count = wcrtomb (out, L'a', &state); + return !(count == 1 && out[0] == 'a'); +}]])], + [gl_cv_func_wcrtomb_works=yes], + [gl_cv_func_wcrtomb_works=no], + [case "$host_os" in + # Guess no on Android. + linux*-android*) gl_cv_func_wcrtomb_works="guessing no";; + # Guess yes otherwise. + *) gl_cv_func_wcrtomb_works="guessing yes";; + esac + ]) + ]) + case "$gl_cv_func_wcrtomb_works" in + *yes) ;; + *) AC_DEFINE([WCRTOMB_C_LOCALE_BUG], [1], + [Define if the wcrtomb function does not work in the C locale.]) + REPLACE_WCRTOMB=1 ;; + esac + fi + if test $REPLACE_WCRTOMB = 0; then + AC_CACHE_CHECK([whether wcrtomb return value is correct], + [gl_cv_func_wcrtomb_retval], + [ + dnl Initial guess, used when cross-compiling or when no suitable locale + dnl is present. +changequote(,)dnl + case "$host_os" in + # Guess no on AIX 4, OSF/1, Solaris, native Windows. + aix4* | osf* | solaris* | mingw* | windows*) + gl_cv_func_wcrtomb_retval="guessing no" ;; + # Guess yes otherwise. + *) + gl_cv_func_wcrtomb_retval="guessing yes" ;; + esac +changequote([,])dnl + if test $LOCALE_FR != none || test $LOCALE_FR_UTF8 != none || test $LOCALE_JA != none || test $LOCALE_ZH_CN != none; then + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +#include +#include +int main () +{ + int result = 0; + if (strcmp ("$LOCALE_FR", "none") != 0 + && setlocale (LC_ALL, "$LOCALE_FR") != NULL) + { + if (wcrtomb (NULL, 0, NULL) != 1) + result |= 1; + } + if (strcmp ("$LOCALE_FR_UTF8", "none") != 0 + && setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL) + { + if (wcrtomb (NULL, 0, NULL) != 1) + result |= 2; + { + wchar_t wc = (wchar_t) 0xBADFACE; + if (mbtowc (&wc, "\303\274", 2) == 2) + if (wcrtomb (NULL, wc, NULL) != 1) + result |= 2; + } + } + if (strcmp ("$LOCALE_JA", "none") != 0 + && setlocale (LC_ALL, "$LOCALE_JA") != NULL) + { + if (wcrtomb (NULL, 0, NULL) != 1) + result |= 4; + } + if (strcmp ("$LOCALE_ZH_CN", "none") != 0 + && setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL) + { + if (wcrtomb (NULL, 0, NULL) != 1) + result |= 8; + } + return result; +}]])], + [gl_cv_func_wcrtomb_retval=yes], + [gl_cv_func_wcrtomb_retval=no], + [:]) + fi + ]) + case "$gl_cv_func_wcrtomb_retval" in + *yes) ;; + *) AC_DEFINE([WCRTOMB_RETVAL_BUG], [1], + [Define if the wcrtomb function has an incorrect return value.]) + REPLACE_WCRTOMB=1 ;; + esac + fi + fi +]) + +# Prerequisites of lib/wcrtomb.c. +AC_DEFUN([gl_PREREQ_WCRTOMB], [ + : +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/wctob.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/wctob.m4 new file mode 100644 index 00000000..323b1ede --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/wctob.m4 @@ -0,0 +1,109 @@ +# wctob.m4 serial 14 +dnl Copyright (C) 2008-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_WCTOB], +[ + AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) + + AC_CHECK_FUNCS_ONCE([wctob]) + if test $ac_cv_func_wctob = no; then + HAVE_WCTOB=0 + HAVE_DECL_WCTOB=0 + else + HAVE_WCTOB=1 + + dnl Solaris 9 has the wctob() function but it does not work. + dnl Cygwin 1.7.2 has the wctob() function but it clobbers caller-owned + dnl registers, see . + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([gt_LOCALE_FR]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether wctob works], + [gl_cv_func_wctob_works], + [ + dnl Initial guess, used when cross-compiling or when no suitable locale + dnl is present. +changequote(,)dnl + case "$host_os" in + # Guess no on Solaris <= 9 and Cygwin. + solaris2.[1-9] | solaris2.[1-9].* | cygwin*) + gl_cv_func_wctob_works="guessing no" ;; + # Guess no on native Windows. + mingw* | windows*) + gl_cv_func_wctob_works="guessing no" ;; + # Guess yes otherwise. + *) gl_cv_func_wctob_works="guessing yes" ;; + esac +changequote([,])dnl + case "$host_os" in + cygwin*) + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include + +register long global __asm__ ("%ebx"); + +int main () +{ + setlocale (LC_ALL, "en_US.UTF-8"); + + global = 0x12345678; + if (wctob (0x00FC) != -1) + return 1; + if (global != 0x12345678) + return 2; + return 0; +}]])], + [:], + [gl_cv_func_wctob_works=no], + [:]) + ;; + esac + if test "$gl_cv_func_wctob_works" != no && test $LOCALE_FR != none; then + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +#include +int main () +{ + if (setlocale (LC_ALL, "$LOCALE_FR") != NULL) + { + wchar_t wc; + + if (mbtowc (&wc, "\374", 1) == 1) + if (wctob (wc) != (unsigned char) '\374') + return 1; + } + return 0; +}]])], + [gl_cv_func_wctob_works=yes], + [gl_cv_func_wctob_works=no], + [:]) + fi + ]) + case "$gl_cv_func_wctob_works" in + *yes) ;; + *) REPLACE_WCTOB=1 ;; + esac + if test $REPLACE_WCTOB = 0; then + + dnl IRIX 6.5 has the wctob() function but does not declare it. + AC_CHECK_DECLS([wctob], [], [], [[ + #include + ]]) + if test $ac_cv_have_decl_wctob != yes; then + HAVE_DECL_WCTOB=0 + fi + fi + fi +]) + +# Prerequisites of lib/wctob.c. +AC_DEFUN([gl_PREREQ_WCTOB], [ + : +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/wctomb.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/wctomb.m4 new file mode 100644 index 00000000..d8f36527 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/wctomb.m4 @@ -0,0 +1,19 @@ +# wctomb.m4 serial 2 +dnl Copyright (C) 2011-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_WCTOMB], +[ + AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) + + if false; then + REPLACE_WCTOMB=1 + fi +]) + +# Prerequisites of lib/wctomb.c. +AC_DEFUN([gl_PREREQ_WCTOMB], [ + : +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/wctype.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/wctype.m4 new file mode 100644 index 00000000..3660d7d9 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/wctype.m4 @@ -0,0 +1,51 @@ +# wctype.m4 serial 6 +dnl Copyright (C) 2011-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN_ONCE([gl_FUNC_WCTYPE], +[ + AC_REQUIRE([gl_WCTYPE_H_DEFAULTS]) + AC_REQUIRE([gl_WCTYPE_H]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + HAVE_WCTYPE=$HAVE_WCTYPE_T + if test $HAVE_WCTYPE = 1; then + AC_CACHE_CHECK([whether wctype supports the "blank" and "punct" character classes], + [gl_cv_func_wctype_works], + [AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ + #include + #include + #include + int main () + { + /* This test fails on mingw. */ + if (wctype ("blank") == (wctype_t)0) + return 1; + /* This test fails on MSVC 14. */ + if ((! iswctype ('\t', wctype ("blank"))) != (! iswblank ('\t'))) + return 2; + /* This test fails on Android 11. */ + if ((! iswctype ('\`', wctype ("punct"))) != (! ispunct ('\`'))) + return 4; + return 0; + } + ]])], + [gl_cv_func_wctype_works=yes], [gl_cv_func_wctype_works=no], + [case "$host_os" in + # Guess no on native Windows. + mingw* | windows*) gl_cv_func_wctype_works="guessing no" ;; + # Guess no on Android. + android*) gl_cv_func_wctype_works="guessing no" ;; + # Guess yes otherwise. + *) gl_cv_func_wctype_works="guessing yes" ;; + esac + ]) + ]) + case "$gl_cv_func_wctype_works" in + *yes) ;; + *) REPLACE_WCTYPE=1 ;; + esac + fi +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/wctype_h.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/wctype_h.m4 new file mode 100644 index 00000000..c8993949 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/wctype_h.m4 @@ -0,0 +1,204 @@ +# wctype_h.m4 serial 33 + +dnl A placeholder for ISO C99 , for platforms that lack it. + +dnl Copyright (C) 2006-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl Written by Paul Eggert. + +AC_DEFUN_ONCE([gl_WCTYPE_H], +[ + AC_REQUIRE([gl_WCTYPE_H_DEFAULTS]) + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_CHECK_FUNCS_ONCE([iswcntrl]) + if test $ac_cv_func_iswcntrl = yes; then + HAVE_ISWCNTRL=1 + else + HAVE_ISWCNTRL=0 + fi + AC_SUBST([HAVE_ISWCNTRL]) + + AC_REQUIRE([gt_TYPE_WINT_T]) + if test $gt_cv_c_wint_t = yes; then + HAVE_WINT_T=1 + else + HAVE_WINT_T=0 + fi + AC_SUBST([HAVE_WINT_T]) + + AC_REQUIRE([gl_TYPE_WINT_T_PREREQ]) + + gl_CHECK_NEXT_HEADERS([wctype.h]) + if test $ac_cv_header_wctype_h = yes; then + if test $ac_cv_func_iswcntrl = yes; then + dnl Linux libc5 has an iswprint function that returns 0 for all arguments. + dnl The other functions are likely broken in the same way. + AC_CACHE_CHECK([whether iswcntrl works], [gl_cv_func_iswcntrl_works], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ + #include + #include + int main () { return iswprint ('x') == 0; } + ]])], + [gl_cv_func_iswcntrl_works=yes], [gl_cv_func_iswcntrl_works=no], + [dnl Guess no on Linux libc5, yes otherwise. + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include + #if __GNU_LIBRARY__ == 1 + Linux libc5 i18n is broken. + #endif]], [[]])], + [gl_cv_func_iswcntrl_works="guessing yes"], + [gl_cv_func_iswcntrl_works="guessing no"]) + ]) + ]) + fi + HAVE_WCTYPE_H=1 + else + HAVE_WCTYPE_H=0 + fi + AC_SUBST([HAVE_WCTYPE_H]) + + if test $GNULIBHEADERS_OVERRIDE_WINT_T = 1; then + REPLACE_ISWCNTRL=1 + else + case "$gl_cv_func_iswcntrl_works" in + *yes) REPLACE_ISWCNTRL=0 ;; + *) REPLACE_ISWCNTRL=1 ;; + esac + fi + AC_SUBST([REPLACE_ISWCNTRL]) + + if test $HAVE_ISWCNTRL = 0 || test $REPLACE_ISWCNTRL = 1; then + dnl Redefine all of iswcntrl, ..., iswxdigit in . + : + fi + + if test $REPLACE_ISWCNTRL = 1; then + REPLACE_TOWLOWER=1 + else + AC_CHECK_FUNCS([towlower]) + if test $ac_cv_func_towlower = yes; then + REPLACE_TOWLOWER=0 + else + AC_CHECK_DECLS([towlower],,, + [[#include + #if HAVE_WCTYPE_H + # include + #endif + ]]) + if test $ac_cv_have_decl_towlower = yes; then + dnl On Minix 3.1.8, the system's declares towlower() and + dnl towupper() although it does not have the functions. Avoid a + dnl collision with gnulib's replacement. + REPLACE_TOWLOWER=1 + else + REPLACE_TOWLOWER=0 + fi + fi + fi + AC_SUBST([REPLACE_TOWLOWER]) + + if test $HAVE_ISWCNTRL = 0 || test $REPLACE_TOWLOWER = 1; then + dnl Redefine towlower, towupper in . + : + fi + + dnl We assume that the wctype() and iswctype() functions exist if and only + dnl if the type wctype_t is defined in or in if that + dnl exists. + dnl HP-UX 11.00 declares all these in and lacks . + AC_CACHE_CHECK([for wctype_t], [gl_cv_type_wctype_t], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include + #if HAVE_WCTYPE_H + # include + #endif + wctype_t a; + ]], + [[]])], + [gl_cv_type_wctype_t=yes], + [gl_cv_type_wctype_t=no]) + ]) + if test $gl_cv_type_wctype_t = no; then + HAVE_WCTYPE_T=0 + fi + + dnl We assume that the wctrans() and towctrans() functions exist if and only + dnl if the type wctrans_t is defined in . + AC_CACHE_CHECK([for wctrans_t], [gl_cv_type_wctrans_t], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include + #include + wctrans_t a; + ]], + [[]])], + [gl_cv_type_wctrans_t=yes], + [gl_cv_type_wctrans_t=no]) + ]) + if test $gl_cv_type_wctrans_t = no; then + HAVE_WCTRANS_T=0 + fi + + dnl Check for declarations of anything we want to poison if the + dnl corresponding gnulib module is not in use. + gl_WARN_ON_USE_PREPARE([[ +#if !(defined __GLIBC__ && !defined __UCLIBC__) +# include +#endif +#include + ]], + [wctype iswctype wctrans towctrans + ]) +]) + +# gl_WCTYPE_MODULE_INDICATOR([modulename]) +# sets the shell variable that indicates the presence of the given module +# to a C preprocessor expression that will evaluate to 1. +# This macro invocation must not occur in macros that are AC_REQUIREd. +AC_DEFUN([gl_WCTYPE_MODULE_INDICATOR], +[ + dnl Ensure to expand the default settings once only. + gl_WCTYPE_H_REQUIRE_DEFAULTS + gl_MODULE_INDICATOR_SET_VARIABLE([$1]) + dnl Define it also as a C macro, for the benefit of the unit tests. + gl_MODULE_INDICATOR_FOR_TESTS([$1]) +]) + +# Initializes the default values for AC_SUBSTed shell variables. +# This macro must not be AC_REQUIREd. It must only be invoked, and only +# outside of macros or in macros that are not AC_REQUIREd. +AC_DEFUN([gl_WCTYPE_H_REQUIRE_DEFAULTS], +[ + m4_defun(GL_MODULE_INDICATOR_PREFIX[_WCTYPE_H_MODULE_INDICATOR_DEFAULTS], [ + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISWBLANK]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISWDIGIT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISWPUNCT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISWXDIGIT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCTYPE]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISWCTYPE]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCTRANS]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TOWCTRANS]) + ]) + m4_require(GL_MODULE_INDICATOR_PREFIX[_WCTYPE_H_MODULE_INDICATOR_DEFAULTS]) + AC_REQUIRE([gl_WCTYPE_H_DEFAULTS]) +]) + +AC_DEFUN([gl_WCTYPE_H_DEFAULTS], +[ + dnl Assume proper GNU behavior unless another module says otherwise. + HAVE_ISWBLANK=1; AC_SUBST([HAVE_ISWBLANK]) + HAVE_WCTYPE_T=1; AC_SUBST([HAVE_WCTYPE_T]) + HAVE_WCTRANS_T=1; AC_SUBST([HAVE_WCTRANS_T]) + REPLACE_ISWBLANK=0; AC_SUBST([REPLACE_ISWBLANK]) + REPLACE_ISWDIGIT=0; AC_SUBST([REPLACE_ISWDIGIT]) + REPLACE_ISWPUNCT=0; AC_SUBST([REPLACE_ISWPUNCT]) + REPLACE_ISWXDIGIT=0; AC_SUBST([REPLACE_ISWXDIGIT]) + REPLACE_WCTRANS=0; AC_SUBST([REPLACE_WCTRANS]) + REPLACE_WCTYPE=0; AC_SUBST([REPLACE_WCTYPE]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/wcwidth.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/wcwidth.m4 new file mode 100644 index 00000000..53a26c7d --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/wcwidth.m4 @@ -0,0 +1,115 @@ +# wcwidth.m4 serial 36 +dnl Copyright (C) 2006-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_WCWIDTH], +[ + AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + + dnl Persuade glibc to declare wcwidth(). + AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) + + AC_REQUIRE([gt_TYPE_WCHAR_T]) + AC_REQUIRE([gt_TYPE_WINT_T]) + + AC_CHECK_HEADERS_ONCE([wchar.h]) + AC_CHECK_FUNCS_ONCE([wcwidth]) + + AC_CHECK_DECLS([wcwidth], [], [], [[ + #include + ]]) + if test $ac_cv_have_decl_wcwidth != yes; then + HAVE_DECL_WCWIDTH=0 + fi + + if test $ac_cv_func_wcwidth != yes; then + AC_CACHE_CHECK([whether wcwidth is a macro], + [gl_cv_func_wcwidth_macro], + [AC_EGREP_CPP([wchar_header_defines_wcwidth], [ +#include +#ifdef wcwidth + wchar_header_defines_wcwidth +#endif], + [gl_cv_func_wcwidth_macro=yes], + [gl_cv_func_wcwidth_macro=no]) + ]) + fi + + if test $ac_cv_func_wcwidth = yes || test $gl_cv_func_wcwidth_macro = yes; then + HAVE_WCWIDTH=1 + dnl On Mac OS X 10.3, wcwidth(0x0301) (COMBINING ACUTE ACCENT) returns 1. + dnl On macOS 12.5, NetBSD 9.0, OpenBSD 5.0, MidnightBSD 1.1, + dnl wcwidth(0x05B0) (HEBREW POINT SHEVA) returns 1. + dnl On macOS 12.5, NetBSD 9.0, MidnightBSD 1.1, OSF/1 5.1, + dnl wcwidth(0x200B) (ZERO WIDTH SPACE) returns 1. + dnl On OpenBSD 5.8, wcwidth(0xFF1A) (FULLWIDTH COLON) returns 0. + dnl This leads to bugs in 'ls' (coreutils). + dnl On Solaris 11.4, wcwidth(0x2202) (PARTIAL DIFFERENTIAL) returns 2, + dnl even in Western locales. + AC_CACHE_CHECK([whether wcwidth works reasonably in UTF-8 locales], + [gl_cv_func_wcwidth_works], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +#if !HAVE_DECL_WCWIDTH +extern +# ifdef __cplusplus +"C" +# endif +int wcwidth (int); +#endif +int main () +{ + int result = 0; + if (setlocale (LC_ALL, "en_US.UTF-8") != NULL) + { + if (wcwidth (0x0301) > 0) + result |= 1; + if (wcwidth (0x05B0) > 0) + result |= 2; + if (wcwidth (0x200B) > 0) + result |= 4; + if (wcwidth (0xFF1A) == 0) + result |= 8; + if (wcwidth (0x2202) > 1) + result |= 16; + } + return result; +}]])], + [gl_cv_func_wcwidth_works=yes], + [gl_cv_func_wcwidth_works=no], + [ +changequote(,)dnl + case "$host_os" in + # Guess yes on glibc systems. + *-gnu* | gnu*) gl_cv_func_wcwidth_works="guessing yes";; + # Guess yes on musl systems. + *-musl* | midipix*) gl_cv_func_wcwidth_works="guessing yes";; + # Guess yes on AIX 7 systems. + aix[7-9]*) gl_cv_func_wcwidth_works="guessing yes";; + *) gl_cv_func_wcwidth_works="$gl_cross_guess_normal";; + esac +changequote([,])dnl + ]) + ]) + case "$gl_cv_func_wcwidth_works" in + *yes) ;; + *no) REPLACE_WCWIDTH=1 ;; + esac + else + HAVE_WCWIDTH=0 + fi + dnl We don't substitute HAVE_WCWIDTH. We assume that if the system does not + dnl have the wcwidth function, then it does not declare it. +]) + +# Prerequisites of lib/wcwidth.c. +AC_DEFUN([gl_PREREQ_WCWIDTH], [ + AC_REQUIRE([AC_C_INLINE]) + : +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/wint_t.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/wint_t.m4 new file mode 100644 index 00000000..21350f56 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/wint_t.m4 @@ -0,0 +1,57 @@ +# wint_t.m4 serial 11 +dnl Copyright (C) 2003, 2007-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. +dnl Test whether has the 'wint_t' type and whether gnulib's +dnl or would, if present, override 'wint_t'. +dnl Prerequisite: AC_PROG_CC + +AC_DEFUN([gt_TYPE_WINT_T], +[ + AC_CACHE_CHECK([for wint_t], [gt_cv_c_wint_t], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include + wint_t foo = (wchar_t)'\0';]], + [[]])], + [gt_cv_c_wint_t=yes], + [gt_cv_c_wint_t=no])]) + if test $gt_cv_c_wint_t = yes; then + AC_DEFINE([HAVE_WINT_T], [1], [Define if you have the 'wint_t' type.]) + + dnl Determine whether gnulib's or would, if present, + dnl override 'wint_t'. + AC_CACHE_CHECK([whether wint_t is large enough], + [gl_cv_type_wint_t_large_enough], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include + int verify[sizeof (wint_t) < sizeof (int) ? -1 : 1]; + ]])], + [gl_cv_type_wint_t_large_enough=yes], + [gl_cv_type_wint_t_large_enough=no])]) + if test $gl_cv_type_wint_t_large_enough = no; then + GNULIBHEADERS_OVERRIDE_WINT_T=1 + else + GNULIBHEADERS_OVERRIDE_WINT_T=0 + fi + else + GNULIBHEADERS_OVERRIDE_WINT_T=0 + fi + AC_SUBST([GNULIBHEADERS_OVERRIDE_WINT_T]) +]) + +dnl Prerequisites of the 'wint_t' override. +AC_DEFUN([gl_TYPE_WINT_T_PREREQ], +[ + AC_CHECK_HEADERS_ONCE([crtdefs.h]) + if test $ac_cv_header_crtdefs_h = yes; then + HAVE_CRTDEFS_H=1 + else + HAVE_CRTDEFS_H=0 + fi + AC_SUBST([HAVE_CRTDEFS_H]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/wmemchr.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/wmemchr.m4 new file mode 100644 index 00000000..54f1c83d --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/wmemchr.m4 @@ -0,0 +1,25 @@ +# wmemchr.m4 serial 5 +dnl Copyright (C) 2011-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_WMEMCHR], +[ + AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) + dnl We cannot use AC_CHECK_FUNCS here, because the MSVC 9 header files + dnl provide this function as an inline function definition. + AC_CACHE_CHECK([for wmemchr], [gl_cv_func_wmemchr], + [AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include + ]], + [[return ! wmemchr ((const wchar_t *) 0, (wchar_t) ' ', 0);]]) + ], + [gl_cv_func_wmemchr=yes], + [gl_cv_func_wmemchr=no]) + ]) + if test $gl_cv_func_wmemchr = no; then + HAVE_WMEMCHR=0 + fi +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/wmempcpy.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/wmempcpy.m4 new file mode 100644 index 00000000..6c08d55d --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/wmempcpy.m4 @@ -0,0 +1,24 @@ +# wmempcpy.m4 serial 3 +dnl Copyright (C) 2020-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_WMEMPCPY], +[ + AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) + + dnl Persuade glibc to declare wmempcpy(). + AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) + + dnl The wmempcpy() declaration in lib/wchar.in.h uses 'restrict'. + AC_REQUIRE([AC_C_RESTRICT]) + + gl_CHECK_FUNCS_ANDROID([wmempcpy], [[#include ]]) + if test $ac_cv_func_wmempcpy = no; then + HAVE_WMEMPCPY=0 + case "$gl_cv_onwards_func_wmempcpy" in + future*) REPLACE_WMEMPCPY=1 ;; + esac + fi +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/xalloc.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/xalloc.m4 new file mode 100644 index 00000000..f60ea3d5 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/xalloc.m4 @@ -0,0 +1,7 @@ +# xalloc.m4 serial 18 +dnl Copyright (C) 2002-2006, 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_XALLOC], [:]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/xsize.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/xsize.m4 new file mode 100644 index 00000000..6125f9c1 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/xsize.m4 @@ -0,0 +1,12 @@ +# xsize.m4 serial 5 +dnl Copyright (C) 2003-2004, 2008-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_XSIZE], +[ + dnl Prerequisites of lib/xsize.h. + AC_REQUIRE([gl_SIZE_MAX]) + AC_CHECK_HEADERS([stdint.h]) +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/xstrtol.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/xstrtol.m4 new file mode 100644 index 00000000..9a536189 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/xstrtol.m4 @@ -0,0 +1,10 @@ +#serial 11 +dnl Copyright (C) 2002-2007, 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_XSTRTOL], +[ + : +]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/zzgnulib.m4 b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/zzgnulib.m4 new file mode 100644 index 00000000..eed5ecbf --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/m4/zzgnulib.m4 @@ -0,0 +1,23 @@ +# zzgnulib.m4 serial 1 +dnl Copyright (C) 2020-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl This file must be named something that sorts after all other +dnl package- or gnulib-provided .m4 files - at least for those packages +dnl that redefine AC_PROG_CC. + +dnl Redefine AC_PROG_CC so that it ends with invocations of gl_COMPILER_CLANG +dnl and gl_COMPILER_PREPARE_CHECK_DECL. +m4_define([AC_PROG_CC], + m4_defn([AC_PROG_CC])[ +gl_COMPILER_CLANG +gl_COMPILER_PREPARE_CHECK_DECL +]) + +# gl_ZZGNULIB +# ----------- +# Witness macro that this file has been included. Needed to force +# Automake to include this file after all other gnulib .m4 files. +AC_DEFUN([gl_ZZGNULIB]) diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.result/maint.mk b/gnulib-tool-tests/import-tests/test-diffutils-1.result/maint.mk new file mode 100644 index 00000000..1b4a2de4 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.result/maint.mk @@ -0,0 +1,1805 @@ +# -*-Makefile-*- +# This Makefile fragment tries to be general-purpose enough to be +# used by many projects via the gnulib maintainer-makefile module. + +## Copyright (C) 2001-2024 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 . + +# This is reported not to work with make-3.79.1 +# ME := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) +ME := maint.mk + +# These variables ought to be defined through the configure.ac section +# of the module description. But some packages import this file directly, +# ignoring the module description. +AWK ?= awk +GREP ?= grep +SED ?= sed + +# Helper variables. +_empty = +_sp = $(_empty) $(_empty) + +# _equal,S1,S2 +# ------------ +# If S1 == S2, return S1, otherwise the empty string. +_equal = $(and $(findstring $(1),$(2)),$(findstring $(2),$(1))) + +# member-check,VARIABLE,VALID-VALUES +# ---------------------------------- +# Check that $(VARIABLE) is in the space-separated list of VALID-VALUES, and +# return it. Die otherwise. +member-check = \ + $(strip \ + $(if $($(1)), \ + $(if $(findstring $(_sp),$($(1))), \ + $(error invalid $(1): '$($(1))', expected $(2)), \ + $(or $(findstring $(_sp)$($(1))$(_sp),$(_sp)$(2)$(_sp)), \ + $(error invalid $(1): '$($(1))', expected $(2)))), \ + $(error $(1) undefined))) + +# Do not save the original name or timestamp in the .tar.gz file. +# Use --rsyncable if available. +gzip_rsyncable := \ + $(shell gzip --help 2>/dev/null|$(GREP) rsyncable >/dev/null \ + && printf %s --rsyncable) +GZIP_ENV = '--no-name --best $(gzip_rsyncable)' + +GIT = git +VC = $(GIT) + +VC_LIST = $(srcdir)/$(_build-aux)/vc-list-files -C $(srcdir) + +# You can override this variable in cfg.mk if your gnulib submodule lives +# in a different location. +gnulib_dir ?= $(shell if test -n "$(GNULIB_SRCDIR)" && test -f "$(GNULIB_SRCDIR)/gnulib-tool"; then \ + echo "$(GNULIB_SRCDIR)"; \ + else \ + echo $(srcdir)/gnulib; \ + fi) + +# You can override this variable in cfg.mk to set your own regexp +# matching files to ignore. +VC_LIST_ALWAYS_EXCLUDE_REGEX ?= ^$$ + +# This is to preprocess robustly the output of $(VC_LIST), so that even +# when $(srcdir) is a pathological name like "....", the leading sed command +# removes only the intended prefix. +_dot_escaped_srcdir = $(subst .,\.,$(srcdir)) + +# Post-process $(VC_LIST) output, prepending $(srcdir)/, but only +# when $(srcdir) is not ".". +ifeq ($(srcdir),.) + _prepend_srcdir_prefix = +else + _prepend_srcdir_prefix = | $(SED) 's|^|$(srcdir)/|' +endif + +# In order to be able to consistently filter "."-relative names, +# (i.e., with no $(srcdir) prefix), this definition is careful to +# remove any $(srcdir) prefix, and to restore what it removes. +_sc_excl = \ + $(or $(exclude_file_name_regexp--$@),^$$) +VC_LIST_EXCEPT = \ + $(VC_LIST) | $(SED) 's|^$(_dot_escaped_srcdir)/||' \ + | if test -f $(srcdir)/.x-$@; then $(GREP) -vEf $(srcdir)/.x-$@; \ + else $(GREP) -Ev -e "$${VC_LIST_EXCEPT_DEFAULT-ChangeLog}"; fi \ + | $(GREP) -Ev -e '($(VC_LIST_ALWAYS_EXCLUDE_REGEX)|$(_sc_excl))' \ + $(_prepend_srcdir_prefix) + +ifeq ($(origin prev_version_file), undefined) + prev_version_file = $(srcdir)/.prev-version +endif + +PREV_VERSION := $(shell cat $(prev_version_file) 2>/dev/null) +VERSION_REGEXP = $(subst .,\.,$(VERSION)) +PREV_VERSION_REGEXP = $(subst .,\.,$(PREV_VERSION)) + +ifeq ($(VC),$(GIT)) + this-vc-tag = v$(VERSION) + this-vc-tag-regexp = v$(VERSION_REGEXP) +else + tag-package = $(shell echo "$(PACKAGE)" | tr '[:lower:]' '[:upper:]') + tag-this-version = $(subst .,_,$(VERSION)) + this-vc-tag = $(tag-package)-$(tag-this-version) + this-vc-tag-regexp = $(this-vc-tag) +endif +my_distdir = $(PACKAGE)-$(VERSION) + +# Old releases are stored here. +release_archive_dir ?= ../release + +# If RELEASE_TYPE is undefined, but RELEASE is, use its second word. +# But overwrite VERSION. +ifdef RELEASE + VERSION := $(word 1, $(RELEASE)) + RELEASE_TYPE ?= $(word 2, $(RELEASE)) +endif + +# Validate and return $(RELEASE_TYPE), or die. +RELEASE_TYPES = alpha beta stable +release-type = $(call member-check,RELEASE_TYPE,$(RELEASE_TYPES)) + +# Override gnu_rel_host and url_dir_list in cfg.mk if these are not right. +# Use alpha.gnu.org for alpha and beta releases. +# Use ftp.gnu.org for stable releases. +gnu_ftp_host-alpha = alpha.gnu.org +gnu_ftp_host-beta = alpha.gnu.org +gnu_ftp_host-stable = ftp.gnu.org +gnu_rel_host ?= $(gnu_ftp_host-$(release-type)) + +url_dir_list ?= $(if $(call _equal,$(gnu_rel_host),ftp.gnu.org), \ + https://ftpmirror.gnu.org/$(PACKAGE), \ + https://$(gnu_rel_host)/gnu/$(PACKAGE)) + +# Override this in cfg.mk if you are using a different format in your +# NEWS file. +today = $(shell date +%Y-%m-%d) + +# Select which lines of NEWS are searched for $(news-check-regexp). +# This is a sed line number spec. The default says that we search +# lines 1..10 of NEWS for $(news-check-regexp). +# If you want to search only line 3 or only lines 20-22, use "3" or "20,22". +news-check-lines-spec ?= 1,10 +news-check-regexp ?= '^\*.* $(VERSION_REGEXP) \($(today)\)' + +# Prevent programs like 'sort' from considering distinct strings to be equal. +# Doing it here saves us from having to set LC_ALL elsewhere in this file. +export LC_ALL = C + +## --------------- ## +## Sanity checks. ## +## --------------- ## + +ifneq ($(_gl-Makefile),) +_cfg_mk := $(wildcard $(srcdir)/cfg.mk) + +# Collect the names of rules starting with 'sc_'. +syntax-check-rules := $(sort $(shell env LC_ALL=C $(SED) -n \ + 's/^\(sc_[a-zA-Z0-9_-]*\):.*/\1/p' $(srcdir)/$(ME) $(_cfg_mk))) +.PHONY: $(syntax-check-rules) + +ifeq ($(shell $(VC_LIST) >/dev/null 2>&1; echo $$?),0) + local-checks-available += $(syntax-check-rules) +else + local-checks-available += no-vc-detected +no-vc-detected: + @echo "No version control files detected; skipping syntax check" +endif +.PHONY: $(local-checks-available) + +# Arrange to prine the name of each syntax-checking rule just before running it. +$(syntax-check-rules): %: %.m +sc_m_rules_ = $(patsubst %, %.m, $(syntax-check-rules)) +.PHONY: $(sc_m_rules_) +$(sc_m_rules_): + @echo $(patsubst sc_%.m, %, $@) + @date +%s.%N > .sc-start-$(basename $@) + +# Compute and print the elapsed time for each syntax-check rule. +sc_z_rules_ = $(patsubst %, %.z, $(syntax-check-rules)) +.PHONY: $(sc_z_rules_) +$(sc_z_rules_): %.z: % + @end=$$(date +%s.%N); \ + start=$$(cat .sc-start-$*); \ + rm -f .sc-start-$*; \ + $(AWK) -v s=$$start -v e=$$end \ + 'END {printf "%.2f $(patsubst sc_%,%,$*)\n", e - s}' < /dev/null + +# The patsubst here is to replace each sc_% rule with its sc_%.z wrapper +# that computes and prints elapsed time. +local-check := \ + $(patsubst sc_%, sc_%.z, \ + $(filter-out $(local-checks-to-skip), $(local-checks-available))) + +syntax-check: $(local-check) +endif + +# _sc_search_regexp +# +# This macro searches for a given construct in the selected files and +# then takes some action. +# +# Parameters (shell variables): +# +# prohibit | require +# +# Regular expression (ERE) denoting either a forbidden construct +# or a required construct. Those arguments are exclusive. +# +# exclude +# +# Regular expression (ERE) denoting lines to ignore that matched +# a prohibit construct. For example, this can be used to exclude +# comments that mention why the nearby code uses an alternative +# construct instead of the simpler prohibited construct. +# +# in_vc_files | in_files +# +# grep-E-style regexp selecting the files to check. For in_vc_files, +# the regexp is used to select matching files from the list of all +# version-controlled files; for in_files, it's from the names printed +# by "find $(srcdir)". When neither is specified, use all files that +# are under version control. +# +# containing | non_containing +# +# Select the files (non) containing strings matching this regexp. +# If both arguments are specified then CONTAINING takes +# precedence. +# +# with_grep_options +# +# Extra options for grep. +# +# ignore_case +# +# Ignore case. +# +# halt +# +# Message to display before to halting execution. +# +# Finally, you may exempt files based on an ERE matching file names. +# For example, to exempt from the sc_space_tab check all files with the +# .diff suffix, set this Make variable: +# +# exclude_file_name_regexp--sc_space_tab = \.diff$ +# +# Note that while this functionality is mostly inherited via VC_LIST_EXCEPT, +# when filtering by name via in_files, we explicitly filter out matching +# names here as well. + +# Initialize each, so that envvar settings cannot interfere. +export require = +export prohibit = +export exclude = +export in_vc_files = +export in_files = +export containing = +export non_containing = +export halt = +export with_grep_options = + +# By default, _sc_search_regexp does not ignore case. +export ignore_case = +_ignore_case = $$(test -n "$$ignore_case" && printf %s -i || :) + +define _sc_say_and_exit + dummy=; : so we do not need a semicolon before each use; \ + { printf '%s\n' "$(ME): $$msg" 1>&2; exit 1; }; +endef + +define _sc_search_regexp + dummy=; : so we do not need a semicolon before each use; \ + \ + : Check arguments; \ + test -n "$$prohibit" && test -n "$$require" \ + && { msg='Cannot specify both prohibit and require' \ + $(_sc_say_and_exit) } || :; \ + test -z "$$prohibit" && test -z "$$require" \ + && { msg='Should specify either prohibit or require' \ + $(_sc_say_and_exit) } || :; \ + test -z "$$prohibit" && test -n "$$exclude" \ + && { msg='Use of exclude requires a prohibit pattern' \ + $(_sc_say_and_exit) } || :; \ + test -n "$$in_vc_files" && test -n "$$in_files" \ + && { msg='Cannot specify both in_vc_files and in_files' \ + $(_sc_say_and_exit) } || :; \ + test "x$$halt" != x \ + || { msg='halt not defined' $(_sc_say_and_exit) }; \ + \ + : Filter by file name; \ + if test -n "$$in_files"; then \ + files=$$(find $(srcdir) | $(GREP) -E "$$in_files" \ + | $(GREP) -Ev '$(_sc_excl)'); \ + else \ + files=$$($(VC_LIST_EXCEPT)); \ + if test -n "$$in_vc_files"; then \ + files=$$(echo "$$files" | $(GREP) -E "$$in_vc_files"); \ + fi; \ + fi; \ + \ + : Filter by content; \ + test -n "$$files" \ + && test -n "$$containing" \ + && { files=$$(echo "$$files" | xargs $(GREP) -l "$$containing"); } \ + || :; \ + test -n "$$files" \ + && test -n "$$non_containing" \ + && { files=$$(echo "$$files" | xargs $(GREP) -vl "$$non_containing"); } \ + || :; \ + \ + : Check for the construct; \ + if test -n "$$files"; then \ + if test -n "$$prohibit"; then \ + echo "$$files" \ + | xargs $(GREP) $$with_grep_options $(_ignore_case) -nE \ + "$$prohibit" /dev/null \ + | $(GREP) -vE "$${exclude:-^$$}" \ + && { msg="$$halt" $(_sc_say_and_exit) } \ + || :; \ + else \ + echo "$$files" \ + | xargs \ + $(GREP) $$with_grep_options $(_ignore_case) -LE "$$require" \ + | $(GREP) . \ + && { msg="$$halt" $(_sc_say_and_exit) } \ + || :; \ + fi \ + else :; \ + fi || :; +endef + +sc_avoid_if_before_free: + @$(VC_LIST_EXCEPT) \ + | $(GREP) -v useless-if-before-free \ + | xargs \ + $(srcdir)/$(_build-aux)/useless-if-before-free \ + $(useless_free_options) \ + && { printf '$(ME): found useless "if"' \ + ' before "free" above\n' 1>&2; \ + exit 1; } \ + || : + +sc_cast_of_argument_to_free: + @prohibit='\/dev/null 2>&1; then \ + (cd $(srcdir) && autoconf --trace AC_CONFIG_FILES:'$$1') | \ + tr ' ' '\n' | \ + $(SED) -ne '/Makefile/{s/\.in$$//;p;}' | \ + while read m; do \ + $(MAKE) -qp -f $$m .DUMMY-TARGET 2>/dev/null | \ + $(AWK) -v file=$$m -e '$($@_awk_)' || exit 1; \ + done; \ + fi + +# Using EXIT_SUCCESS as the first argument to error is misleading, +# since when that parameter is 0, error does not exit. Use '0' instead. +sc_error_exit_success: + @prohibit='error *\(EXIT_SUCCESS,' \ + in_vc_files='\.[chly]$$' \ + halt='found error (EXIT_SUCCESS' \ + $(_sc_search_regexp) + +# "FATAL:" should be fully upper-cased in error messages +# "WARNING:" should be fully upper-cased, or fully lower-cased +sc_error_message_warn_fatal: + @$(VC_LIST_EXCEPT) \ + | xargs $(GREP) -nEA2 '[^rp]error *\(' /dev/null \ + | $(GREP) -E '"Warning|"Fatal|"fatal' \ + && { echo '$(ME): use FATAL, WARNING or warning' 1>&2; \ + exit 1; } \ + || : + +# Error messages should not start with a capital letter +sc_error_message_uppercase: + @$(VC_LIST_EXCEPT) \ + | xargs $(GREP) -nEA2 '[^rp]error *\(' /dev/null \ + | $(GREP) -E '"[A-Z]' \ + | $(GREP) -vE '"FATAL|"WARNING|"Java|"C#|"PRI' \ + && { echo '$(ME): found capitalized error message' 1>&2; \ + exit 1; } \ + || : + +# Error messages should not end with a period +sc_error_message_period: + @$(VC_LIST_EXCEPT) \ + | xargs $(GREP) -nEA2 '[^rp]error *\(' /dev/null \ + | $(GREP) -E '[^."]\."' \ + && { echo '$(ME): found error message ending in period' 1>&2; \ + exit 1; } \ + || : + +sc_file_system: + @prohibit=file''system \ + exclude='/proc/filesystems' \ + ignore_case=1 \ + halt='found use of "file''system"; spell it "file system"' \ + $(_sc_search_regexp) + +# Don't use cpp tests of this symbol. All code assumes config.h is included. +sc_prohibit_have_config_h: + @prohibit='^# *if.*HAVE''_CONFIG_H' \ + halt='found use of HAVE''_CONFIG_H; remove' \ + $(_sc_search_regexp) + +# Nearly all .c files must include . However, we also permit this +# via inclusion of a package-specific header, if cfg.mk specified one. +# config_h_header must be suitable for grep -E. +config_h_header ?= +sc_require_config_h: + @require='^# *include $(config_h_header)' \ + in_vc_files='\.c$$' \ + halt='the above files do not include ' \ + $(_sc_search_regexp) + +# Print each file name for which the first #include does not match +# $(config_h_header). Like grep -m 1, this only looks at the first match. +perl_config_h_first_ = \ + -e 'BEGIN {$$ret = 0}' \ + -e 'if (/^\# *include\b/) {' \ + -e ' if (not m{^\# *include $(config_h_header)}) {' \ + -e ' print "$$ARGV\n";' \ + -e ' $$ret = 1;' \ + -e ' }' \ + -e ' \# Move on to next file after first include' \ + -e ' close ARGV;' \ + -e '}' \ + -e 'END {exit $$ret}' + +# You must include before including any other header file. +# This can possibly be via a package-specific header, if given by cfg.mk. +sc_require_config_h_first: + @if $(VC_LIST_EXCEPT) | $(GREP) '\.c$$' > /dev/null; then \ + files=$$($(VC_LIST_EXCEPT) | $(GREP) '\.c$$') && \ + perl -n $(perl_config_h_first_) $$files || \ + { echo '$(ME): the above files include some other header' \ + 'before ' 1>&2; exit 1; } || :; \ + else :; \ + fi + +sc_prohibit_HAVE_MBRTOWC: + @prohibit='\bHAVE_MBRTOWC\b' \ + halt="do not use $$prohibit; it is always defined" \ + $(_sc_search_regexp) + +# To use this "command" macro, you must first define two shell variables: +# h: the header name, with no enclosing <> or "" +# re: a regular expression that matches IFF something provided by $h is used. +define _sc_header_without_use + dummy=; : so we do not need a semicolon before each use; \ + h_esc=`echo '[<"]'"$$h"'[">]'|$(SED) 's/\./\\\\./g'`; \ + if $(VC_LIST_EXCEPT) | $(GREP) '\.c$$' > /dev/null; then \ + files=$$($(GREP) -l '^# *include '"$$h_esc" \ + $$($(VC_LIST_EXCEPT) | $(GREP) '\.c$$')) && \ + $(GREP) -LE "$$re" $$files | $(GREP) . && \ + { echo "$(ME): the above files include $$h but don't use it" \ + 1>&2; exit 1; } || :; \ + else :; \ + fi +endef + +# Prohibit the inclusion of assert.h without an actual use of assert. +sc_prohibit_assert_without_use: + @h='assert.h' re='\new(file => "/dev/stdin")->as_string'|sed 's/\?://g' +_xa1 = x(i(m(emdup0?|alloc)|realloc(array)?|([cz]|nm)alloc)|([pz]|c(har)?|2n?re|nm)alloc|realloc(array)?|m(alloc|emdup)|alloc_die|strdup) +_xa2 = X([CZ]|N?M)ALLOC +sc_prohibit_xalloc_without_use: + @h='xalloc.h' \ + re='\<($(_xa1)|$(_xa2)) *\('\ + $(_sc_header_without_use) + +# Extract function names: +# perl -lne '/^(?:extern )?(?:void|char|Hash_table) \*?(\w+) *\(/ and print $1' lib/hash.h +_hash_re = \ +hash_(re(set_tuning|move)|xin(itialize|sert)|in(itialize|sert)|get_(firs|nex)t|print_statistics|(delet|fre)e|lookup|clear) +_hash_fn = \<($(_hash_re)) *\( +_hash_struct = (struct )?\<[Hh]ash_(table|tuning)\> +sc_prohibit_hash_without_use: + @h='hash.h' \ + re='$(_hash_fn)|$(_hash_struct)'\ + $(_sc_header_without_use) + +sc_prohibit_cloexec_without_use: + @h='cloexec.h' re='\<(set_cloexec_flag|dup_cloexec) *\(' \ + $(_sc_header_without_use) + +sc_prohibit_posixver_without_use: + @h='posixver.h' re='\' \ + halt='do not use HAVE''_FCNTL_H or O'_NDELAY \ + $(_sc_search_regexp) + +# FIXME: warn about definitions of EXIT_FAILURE, EXIT_SUCCESS, STREQ + +# Each nonempty ChangeLog line must start with a year number, or a TAB. +sc_changelog: + @prohibit='^[^12 ]' \ + in_vc_files='^ChangeLog$$' \ + halt='found unexpected prefix in a ChangeLog' \ + $(_sc_search_regexp) + +# Ensure that each .c file containing a "main" function also +# calls bindtextdomain. +sc_bindtextdomain: + @require='bindtextdomain *\(' \ + in_vc_files='\.c$$' \ + containing='\
/dev/null \ + && : || { die=1; echo $$i; } \ + done; \ + test $$die = 1 && \ + { echo 1>&2 '$(ME): the final line in each of the above is not:'; \ + echo 1>&2 'Exit something'; \ + exit 1; } || :; \ + fi + +sc_trailing_blank: + @prohibit='[ ]$$' \ + halt='found trailing blank(s)' \ + exclude='^Binary file .* matches$$' \ + $(_sc_search_regexp) + +# Match lines like the following, but where there is only one space +# between the options and the description: +# -D, --all-repeated[=delimit-method] print all duplicate lines\n +longopt_re = --[a-z][0-9A-Za-z-]*(\[?=[0-9A-Za-z-]*]?)? +sc_two_space_separator_in_usage: + @prohibit='^ *(-[A-Za-z],)? $(longopt_re) [^ ].*\\$$' \ + halt='help2man requires at least two spaces between an option and its description'\ + $(_sc_search_regexp) + +# A regexp matching function names like "error" that may be used +# to emit translatable messages. +_gl_translatable_diag_func_re ?= error + +# Look for diagnostics that aren't marked for translation. +# This won't find any for which error's format string is on a separate line. +sc_unmarked_diagnostics: + @prohibit='\<$(_gl_translatable_diag_func_re) *\([^"]*"[^"]*[a-z]{3}' \ + exclude='(_|ngettext ?)\(' \ + halt='found unmarked diagnostic(s)' \ + $(_sc_search_regexp) + +# Avoid useless parentheses like those in this example: +# #if defined (SYMBOL) || defined (SYM2) +sc_useless_cpp_parens: + @prohibit='^# *if .*defined *\(' \ + halt='found useless parentheses in cpp directive' \ + $(_sc_search_regexp) + +# List headers for which HAVE_HEADER_H is always true, assuming you are +# using the appropriate gnulib module. CAUTION: for each "unnecessary" +# #if HAVE_HEADER_H that you remove, be sure that your project explicitly +# requires the gnulib module that guarantees the usability of that header. +gl_assured_headers_ = \ + cd $(gnulib_dir)/lib && echo *.in.h|$(SED) 's/\.in\.h//g' + +# Convert the list of names to upper case, and replace each space with "|". +az_ = abcdefghijklmnopqrstuvwxyz +AZ_ = ABCDEFGHIJKLMNOPQRSTUVWXYZ +gl_header_upper_case_or_ = \ + $$($(gl_assured_headers_) \ + | tr $(az_)/.- $(AZ_)___ \ + | tr -s ' ' '|' \ + ) +sc_prohibit_always_true_header_tests: + @or=$(gl_header_upper_case_or_); \ + re="HAVE_($$or)_H"; \ + prohibit='\<'"$$re"'\>' \ + halt=$$(printf '%s\n' \ + 'do not test the above HAVE_
_H symbol(s);' \ + ' with the corresponding gnulib module, they are always true') \ + $(_sc_search_regexp) + +sc_prohibit_defined_have_decl_tests: + @prohibit='(#[ ]*ifn?def|\[ (]+HAVE_DECL_' \ + halt='HAVE_DECL macros are always defined' \ + $(_sc_search_regexp) + +# ================================================================== +gl_other_headers_ ?= \ + intprops.h \ + openat.h \ + stat-macros.h + +# Perl -lne code to extract "significant" cpp-defined symbols from a +# gnulib header file, eliminating a few common false-positives. +# The exempted names below are defined only conditionally in gnulib, +# and hence sometimes must/may be defined in application code. +gl_extract_significant_defines_ = \ + /^\# *define ([^_ (][^ (]*)(\s*\(|\s+\w+)/\ + && $$2 !~ /(?:rpl_|_used_without_)/\ + && $$1 !~ /^(?:NSIG|ENODATA)$$/\ + && $$1 !~ /^(?:SA_RESETHAND|SA_RESTART)$$/\ + and print $$1 + +# Create a list of regular expressions matching the names +# of macros that are guaranteed to be defined by parts of gnulib. +define def_sym_regex + gen_h=$(gl_generated_headers_); \ + (cd $(gnulib_dir)/lib; \ + for f in *.in.h $(gl_other_headers_); do \ + test -f $$f \ + && perl -lne '$(gl_extract_significant_defines_)' $$f; \ + done; \ + ) | sort -u \ + | $(SED) 's/^/^ *# *(define|undef) */;s/$$/\\>/' +endef + +# Don't define macros that we already get from gnulib header files. +sc_prohibit_always-defined_macros: + @if test -d $(gnulib_dir); then \ + case $$(echo all: | $(GREP) -l -f - Makefile) in Makefile);; *) \ + echo '$(ME): skipping $@: you lack GNU grep' 1>&2; exit 0;; \ + esac; \ + regex=$$($(def_sym_regex)); export regex; \ + $(VC_LIST_EXCEPT) \ + | xargs sh -c 'echo $$regex | $(GREP) -E -f - "$$@"' \ + dummy /dev/null \ + && { printf '$(ME): define the above' \ + ' via some gnulib .h file\n' 1>&2; \ + exit 1; } \ + || :; \ + fi +# ================================================================== + +# Prohibit checked in backup files. +sc_prohibit_backup_files: + @$(VC_LIST) | $(GREP) '~$$' && \ + { echo '$(ME): found version controlled backup file' 1>&2; \ + exit 1; } || : + +# Require the latest GPL. +sc_GPL_version: + @prohibit='either ''version [^3]' \ + halt='GPL vN, N!=3' \ + $(_sc_search_regexp) + +# Require the latest GFDL. Two regexp, since some .texi files end up +# line wrapping between 'Free Documentation License,' and 'Version'. +_GFDL_regexp = (Free ''Documentation.*Version 1\.[^3]|Version 1\.[^3] or any) +sc_GFDL_version: + @prohibit='$(_GFDL_regexp)' \ + halt='GFDL vN, N!=3' \ + $(_sc_search_regexp) + +# Don't use Texinfo's @acronym{}. +# https://lists.gnu.org/r/bug-gnulib/2010-03/msg00321.html +texinfo_suffix_re_ ?= \.(txi|texi(nfo)?)$$ +sc_texinfo_acronym: + @prohibit='@acronym\{' \ + in_vc_files='$(texinfo_suffix_re_)' \ + halt='found use of Texinfo @acronym{}' \ + $(_sc_search_regexp) + +cvs_keywords = \ + Author|Date|Header|Id|Name|Locker|Log|RCSfile|Revision|Source|State + +sc_prohibit_cvs_keyword: + @prohibit='\$$($(cvs_keywords))\$$' \ + halt='do not use CVS keyword expansion' \ + $(_sc_search_regexp) + +# This Perl code is slightly obfuscated. Not only is each "$" doubled +# because it's in a Makefile, but the $$c's are comments; we cannot +# use "#" due to the way the script ends up concatenated onto one line. +# It would be much more concise, and would produce better output (including +# counts) if written as: +# perl -ln -0777 -e '/\n(\n+)$/ and print "$ARGV: ".length $1' ... +# but that would be far less efficient, reading the entire contents +# of each file, rather than just the last two bytes of each. +# In addition, while the code below detects both blank lines and a missing +# newline at EOF, the above detects only the former. +# +# This is a perl script that is expected to be the single-quoted argument +# to a command-line "-le". The remaining arguments are file names. +# Print the name of each file that does not end in exactly one newline byte. +# I.e., warn if there are blank lines (2 or more newlines), or if the +# last byte is not a newline. However, currently we don't complain +# about any file that contains exactly one byte. +# Exit nonzero if at least one such file is found, otherwise, exit 0. +# Warn about, but otherwise ignore open failure. Ignore seek/read failure. +# +# Use this if you want to remove trailing empty lines from selected files: +# perl -pi -0777 -e 's/\n\n+$/\n/' files... +# +require_exactly_one_NL_at_EOF_ = \ + foreach my $$f (@ARGV) \ + { \ + open F, "<", $$f or (warn "failed to open $$f: $$!\n"), next; \ + my $$p = sysseek (F, -2, 2); \ + my $$c = "seek failure probably means file has < 2 bytes; ignore"; \ + my $$last_two_bytes; \ + defined $$p and $$p = sysread F, $$last_two_bytes, 2; \ + close F; \ + $$c = "ignore read failure"; \ + $$p && ($$last_two_bytes eq "\n\n" \ + || substr ($$last_two_bytes,1) ne "\n") \ + and (print $$f), $$fail=1; \ + } \ + END { exit defined $$fail } +sc_prohibit_empty_lines_at_EOF: + @$(VC_LIST_EXCEPT) \ + | xargs perl -le '$(require_exactly_one_NL_at_EOF_)' \ + || { echo '$(ME): empty line(s) or no newline at EOF' 1>&2; \ + exit 1; } \ + || : + +# Make sure we don't use st_blocks. Use ST_NBLOCKS or STP_NBLOCKS instead. +# This is a bit of a kludge, since it prevents use of the string +# even in comments, but for now it does the job with no false positives. +sc_prohibit_stat_st_blocks: + @prohibit='[.>]st_blocks' \ + halt='do not use st_blocks; use ST_NBLOCKS or STP_NBLOCKS' \ + $(_sc_search_regexp) + +# Make sure we don't define any S_IS* macros in src/*.c files. +# They're already defined via gnulib's sys/stat.h replacement. +sc_prohibit_S_IS_definition: + @prohibit='^ *# *define *S_IS' \ + halt='do not define S_IS* macros; include ' \ + $(_sc_search_regexp) + +# Perl block to convert a match to FILE_NAME:LINENO:TEST, +# that is shared by two definitions below. +perl_filename_lineno_text_ = \ + -e ' {' \ + -e ' $$n = ($$` =~ tr/\n/\n/ + 1);' \ + -e ' ($$v = $$&) =~ s/\n/\\n/g;' \ + -e ' print "$$ARGV:$$n:$$v\n";' \ + -e ' }' + +prohibit_doubled_words_ = \ + the then in an on if is it but for or at and do to can +# expand the regex before running the check to avoid using expensive captures +prohibit_doubled_word_expanded_ = \ + $(join $(prohibit_doubled_words_),$(addprefix \s+,$(prohibit_doubled_words_))) +prohibit_doubled_word_RE_ ?= \ + /\b(?:$(subst $(_sp),|,$(prohibit_doubled_word_expanded_)))\b/gims +prohibit_doubled_word_ = \ + -e 'while ($(prohibit_doubled_word_RE_))' \ + $(perl_filename_lineno_text_) + +# Define this to a regular expression that matches +# any filename:dd:match lines you want to ignore. +# The default is to ignore no matches. +ignore_doubled_word_match_RE_ ?= ^$$ + +sc_prohibit_doubled_word: + @$(VC_LIST_EXCEPT) \ + | xargs perl -n -0777 $(prohibit_doubled_word_) \ + | $(GREP) -vE '$(ignore_doubled_word_match_RE_)' \ + | $(GREP) . \ + && { echo '$(ME): doubled words' 1>&2; exit 1; } \ + || : + +# A regular expression matching undesirable combinations of words like +# "can not"; this matches them even when the two words appear on different +# lines, but not when there is an intervening delimiter like "#" or "*". +# Similarly undesirable, "See @xref{...}", since an @xref should start +# a sentence. Explicitly prohibit any prefix of "see" or "also". +# Also prohibit a prefix matching "\w+ +". +# @pxref gets the same see/also treatment and should be parenthesized; +# presume it must *not* start a sentence. +# POSIX spells it "timestamp" rather than "time\s+stamp", so we do, too. +bad_xref_re_ ?= (?:[\w,:;] +|(?:see|also)\s+)\@xref\{ +bad_pxref_re_ ?= (?:[.!?]|(?:see|also))\s+\@pxref\{ +prohibit_undesirable_word_seq_RE_ ?= \ + /(?:\bcan\s+not\b|\btime\s+stamps?\b|$(bad_xref_re_)|$(bad_pxref_re_))/gims +prohibit_undesirable_word_seq_ = \ + -e 'while ($(prohibit_undesirable_word_seq_RE_))' \ + $(perl_filename_lineno_text_) +# Define this to a regular expression that matches +# any filename:dd:match lines you want to ignore. +# The default is to ignore no matches. +ignore_undesirable_word_sequence_RE_ ?= ^$$ + +sc_prohibit_undesirable_word_seq: + @$(VC_LIST_EXCEPT) \ + | xargs perl -n -0777 $(prohibit_undesirable_word_seq_) \ + | $(GREP) -vE '$(ignore_undesirable_word_sequence_RE_)' \ + | $(GREP) . \ + && { echo '$(ME): undesirable word sequence' >&2; exit 1; } \ + || : + +# Except for shell files and for loops, double semicolon is probably a mistake +sc_prohibit_double_semicolon: + @prohibit='; *;[ {} \]*(/[/*]|$$)' \ + in_vc_files='\.[chly]$$' \ + exclude='\bfor *\(.*\)' \ + halt="Double semicolon detected" \ + $(_sc_search_regexp) + +_ptm1 = use "test C1 && test C2", not "test C1 -''a C2" +_ptm2 = use "test C1 || test C2", not "test C1 -''o C2" +# Using test's -a and -o operators is not portable. +# We prefer test over [, since the latter is spelled [[ in configure.ac. +sc_prohibit_test_minus_ao: + @prohibit='(\ /dev/null \ + || { fail=1; echo 1>&2 "$(ME): $$p uses proper_name_utf8"; }; \ + done; \ + test $$fail = 1 && \ + { echo 1>&2 '$(ME): the above do not link with any ICONV library'; \ + exit 1; } || :; \ + fi + +# Warn about "c0nst struct Foo const foo[]", +# but not about "char const *const foo" or "#define const const". +sc_redundant_const: + @prohibit='\bconst\b[[:space:][:alnum:]]{2,}\bconst\b' \ + halt='redundant "const" in declarations' \ + $(_sc_search_regexp) + +sc_const_long_option: + @prohibit='^ *static.*struct option ' \ + exclude='const struct option|struct option const' \ + halt='add "const" to the above declarations' \ + $(_sc_search_regexp) + +NEWS_hash = \ + $$($(SED) -n '/^\*.* $(PREV_VERSION_REGEXP) ([0-9-]*)/,$$p' \ + $(srcdir)/NEWS \ + | perl -0777 -pe \ + 's/^Copyright.+?Free\sSoftware\sFoundation,\sInc\.\n//ms' \ + | md5sum - \ + | $(SED) 's/ .*//') + +# Ensure that we don't accidentally insert an entry into an old NEWS block. +sc_immutable_NEWS: + @if test -f $(srcdir)/NEWS; then \ + test "$(NEWS_hash)" = '$(old_NEWS_hash)' && : || \ + { echo '$(ME): you have modified old NEWS' 1>&2; exit 1; }; \ + fi + +# Update the hash stored above. Do this after each release and +# for any corrections to old entries. +update-NEWS-hash: NEWS + perl -pi -e 's/^(old_NEWS_hash[ \t]+:?=[ \t]+).*/$${1}'"$(NEWS_hash)/" \ + $(srcdir)/cfg.mk + +# Ensure that we use only the standard $(VAR) notation, +# not @...@ in Makefile.am, now that we can rely on automake +# to emit a definition for each substituted variable. +# However, there is still one case in which @VAR@ use is not just +# legitimate, but actually required: when augmenting an automake-defined +# variable with a prefix. For example, gettext uses this: +# MAKEINFO = env LANG= LC_MESSAGES= LC_ALL= LANGUAGE= @MAKEINFO@ +# otherwise, makeinfo would put German or French (current locale) +# navigation hints in the otherwise-English documentation. +# +# Allow the package to add exceptions via a hook in cfg.mk; +# for example, @PRAGMA_SYSTEM_HEADER@ can be permitted by +# setting this to ' && !/PRAGMA_SYSTEM_HEADER/'. +_makefile_at_at_check_exceptions ?= +sc_makefile_at_at_check: + @perl -ne '/\@\w+\@/' \ + -e ' && !/(\w+)\s+=.*\@\1\@$$/' \ + -e ''$(_makefile_at_at_check_exceptions) \ + -e 'and (print "$$ARGV:$$.: $$_"), $$m=1; END {exit !$$m}' \ + $$($(VC_LIST_EXCEPT) | $(GREP) -E '(^|/)(Makefile\.am|[^/]+\.mk)$$') \ + && { echo '$(ME): use $$(...), not @...@' 1>&2; exit 1; } || : + +news-check: NEWS + $(AM_V_GEN)if $(SED) -n $(news-check-lines-spec)p $< \ + | $(GREP) -E $(news-check-regexp) >/dev/null; then \ + :; \ + else \ + echo 'NEWS: $$(news-check-regexp) failed to match' 1>&2; \ + exit 1; \ + fi + +sc_makefile_TAB_only_indentation: + @prohibit='^ [ ]{8}' \ + in_vc_files='akefile|\.mk$$' \ + halt='found TAB-8-space indentation' \ + $(_sc_search_regexp) + +sc_m4_quote_check: + @prohibit='(AC_DEFINE(_UNQUOTED)?|AC_DEFUN)\([^[]' \ + in_vc_files='(^configure\.ac|\.m4)$$' \ + halt='quote the first arg to AC_DEF*' \ + $(_sc_search_regexp) + +fix_po_file_diag = \ +'you have changed the set of files with translatable diagnostics;\n\ +apply the above patch\n' + +# Generate a list of files in which to search for translatable strings. +perl_translatable_files_list_ = \ + -e 'foreach $$file (@ARGV) {' \ + -e ' \# Consider only file extensions with one or two letters' \ + -e ' $$file =~ /\...?$$/ or next;' \ + -e ' \# Ignore m4 and mk files' \ + -e ' $$file =~ /\.m[4k]$$/ and next;' \ + -e ' \# Ignore a .c or .h file with a corresponding .l or .y file' \ + -e ' $$file =~ /(.+)\.[ch]$$/ && (-e "$${1}.l" || -e "$${1}.y")' \ + -e ' and next;' \ + -e ' \# Skip unreadable files' \ + -e ' -r $$file or next;' \ + -e ' print "$$file ";' \ + -e '}' + +# Verify that all source files using _() (more specifically, files that +# match $(_gl_translatable_string_re)) are listed in po/POTFILES.in. +po_file ?= $(srcdir)/po/POTFILES.in +generated_files ?= $(srcdir)/lib/*.[ch] +_gl_translatable_string_re ?= \b(N?_|gettext *)\([^)"]*("|$$) +sc_po_check: + @if test -f $(po_file); then \ + $(GREP) -E -v '^(#|$$)' $(po_file) \ + | $(GREP) -v '^src/false\.c$$' | sort > $@-1; \ + { $(VC_LIST_EXCEPT); echo $(generated_files); } \ + | xargs perl $(perl_translatable_files_list_) \ + | xargs $(GREP) -E -l '$(_gl_translatable_string_re)' \ + | $(SED) 's|^$(_dot_escaped_srcdir)/||' \ + | sort -u > $@-2; \ + diff -u -L $(po_file) -L $(po_file) $@-1 $@-2 \ + || { printf '$(ME): '$(fix_po_file_diag) 1>&2; exit 1; }; \ + rm -f $@-1 $@-2; \ + fi + +# Sometimes it is useful to change the PATH environment variable +# in Makefiles. When doing so, it's better not to use the Unix-centric +# path separator of ':', but rather the automake-provided '$(PATH_SEPARATOR)'. +msg = 'Do not use ":" above; use $$(PATH_SEPARATOR) instead' +sc_makefile_path_separator_check: + @prohibit='PATH[=].*:' \ + in_vc_files='akefile|\.mk$$' \ + halt=$(msg) \ + $(_sc_search_regexp) + +sc_makefile_DISTCHECK_CONFIGURE_FLAGS: + @prohibit='^DISTCHECK_CONFIGURE_FLAGS' \ + in_vc_files='akefile|\.mk$$' \ + halt="use AM_DISTCHECK_CONFIGURE_FLAGS" \ + $(_sc_search_regexp) + +# Check that 'make alpha' will not fail at the end of the process, +# i.e., when pkg-M.N.tar.xz already exists (either in "." or in ../release) +# and is read-only. +writable-files: + $(AM_V_GEN)if test -d $(release_archive_dir); then \ + for file in $(DIST_ARCHIVES); do \ + for p in ./ $(release_archive_dir)/; do \ + test -e $$p$$file || continue; \ + test -w $$p$$file \ + || { echo ERROR: $$p$$file is not writable; fail=1; }; \ + done; \ + done; \ + test "$$fail" && exit 1 || : ; \ + else :; \ + fi + +v_etc_file = $(gnulib_dir)/lib/version-etc.c +sample-test = tests/sample-test +texi = doc/$(PACKAGE).texi +# Make sure that the copyright date in $(v_etc_file) is up to date. +# Do the same for the $(sample-test) and the main doc/.texi file. +sc_copyright_check: + @require='enum { COPYRIGHT_YEAR = '$$(date +%Y)' };' \ + in_files=$(v_etc_file) \ + halt='out of date copyright in $(v_etc_file); update it' \ + $(_sc_search_regexp) + @require='# Copyright \(C\) '$$(date +%Y)' Free' \ + in_vc_files=$(sample-test) \ + halt='out of date copyright in $(sample-test); update it' \ + $(_sc_search_regexp) + @require='Copyright @copyright\{} .*'$$(date +%Y) \ + in_vc_files=$(texi) \ + halt='out of date copyright in $(texi); update it' \ + $(_sc_search_regexp) + +# If tests/help-version exists and seems to be new enough, assume that its +# use of init.sh and path_prepend_ is correct, and ensure that every other +# use of init.sh is identical. +# This is useful because help-version cross-checks prog --version +# with $(VERSION), which verifies that its path_prepend_ invocation +# sets PATH correctly. This is an inexpensive way to ensure that +# the other init.sh-using tests also get it right. +_hv_file ?= $(srcdir)/tests/help-version +_hv_regex_weak ?= ^ *\. .*/init\.sh" +# Fix syntax-highlighters " +_hv_regex_strong ?= ^ *\. "\$${srcdir=\.}/init\.sh" +sc_cross_check_PATH_usage_in_tests: + @if test -f $(_hv_file); then \ + $(GREP) -l 'VERSION mismatch' $(_hv_file) >/dev/null \ + || { echo "$@: skipped: no such file: $(_hv_file)" 1>&2; \ + exit 0; }; \ + $(GREP) -lE '$(_hv_regex_strong)' $(_hv_file) >/dev/null \ + || { echo "$@: $(_hv_file) lacks conforming use of init.sh" 1>&2; \ + exit 1; }; \ + good=$$($(GREP) -E '$(_hv_regex_strong)' $(_hv_file)); \ + $(VC_LIST_EXCEPT) \ + | xargs $(GREP) -lE '$(_hv_regex_weak)' \ + | xargs $(GREP) -LFx "$$good" \ + | $(GREP) . \ + && { printf "$(ME): the above files use" \ + " path_prepend_ inconsistently\n" 1>&2; \ + exit 1; } \ + || :; \ + fi + +# BRE regex of file contents to identify a test script. +_test_script_regex ?= \ + +# In tests, use "compare expected actual", not the reverse. +sc_prohibit_reversed_compare_failure: + @prohibit='\ vc-diffs || : + $(AM_V_at)if test -s vc-diffs; then \ + cat vc-diffs; \ + echo "Some files are locally modified:" 1>&2; \ + exit 1; \ + else \ + rm vc-diffs; \ + fi + +rel-files = $(DIST_ARCHIVES) + +gnulib-version = $$(cd $(gnulib_dir) \ + && { git describe || git rev-parse --short=10 HEAD; } ) +bootstrap-tools ?= autoconf,automake,gnulib + +gpgv = $$(gpgv2 --version >/dev/null && echo gpgv2 || echo gpgv) +# If it's not already specified, derive the GPG key ID from +# the signed tag we've just applied to mark this release. +gpg_key_ID ?= \ + $$(cd $(srcdir) \ + && git cat-file tag v$(VERSION) \ + | $(gpgv) --status-fd 1 --keyring /dev/null - - 2>/dev/null \ + | $(AWK) '/^\[GNUPG:] ERRSIG / {print $$3; exit}') +gpg_key_email ?= \ + $$(gpg --list-key --with-colons $(gpg_key_ID) 2>/dev/null \ + | $(AWK) -F: '/^uid/ {print $$10; exit}' \ + | $(SED) -n 's/.*<\(.*\)>/\1/p') +gpg_keyring_url ?= https://savannah.gnu.org/project/release-gpgkeys.php?group=$(PACKAGE)&download=1 + +translation_project_ ?= coordinator@translationproject.org + +# Make info-gnu the default only for a stable release. +announcement_Cc_stable = $(translation_project_), $(PACKAGE_BUGREPORT) +announcement_mail_headers_stable = \ + To: info-gnu@gnu.org \ + Cc: $(announcement_Cc_) \ + Mail-Followup-To: $(PACKAGE_BUGREPORT) + +announcement_Cc_alpha = $(translation_project_) +announcement_mail_headers_alpha = \ + To: $(PACKAGE_BUGREPORT) \ + Cc: $(announcement_Cc_) + +announcement_mail_Cc_beta = $(announcement_mail_Cc_alpha) +announcement_mail_headers_beta = $(announcement_mail_headers_alpha) + +announcement_Cc_ ?= $(announcement_Cc_$(release-type)) +announcement_mail_headers_ ?= $(announcement_mail_headers_$(release-type)) +announcement: NEWS ChangeLog $(rel-files) +# Not $(AM_V_GEN) since the output of this command serves as +# announcement message: it would start with " GEN announcement". + $(AM_V_at)$(srcdir)/$(_build-aux)/announce-gen \ + --mail-headers='$(announcement_mail_headers_)' \ + --release-type=$(release-type) \ + --package=$(PACKAGE) \ + --prev=$(PREV_VERSION) \ + --curr=$(VERSION) \ + --gpg-key-id=$(gpg_key_ID) \ + $$(test -n "$(gpg_key_email)" && \ + echo --gpg-key-email="$(gpg_key_email)") \ + $$(test -n "$(gpg_keyring_url)" && \ + echo --gpg-keyring-url="$(gpg_keyring_url)") \ + --srcdir=$(srcdir) \ + --news=$(srcdir)/NEWS \ + --bootstrap-tools=$(bootstrap-tools) \ + $$(case ,$(bootstrap-tools), in (*,gnulib,*) \ + echo --gnulib-version=$(gnulib-version);; esac) \ + $(addprefix --url-dir=, $(url_dir_list)) + +.PHONY: release-commit +release-commit: + $(AM_V_GEN)cd $(srcdir) \ + && $(_build-aux)/do-release-commit-and-tag \ + -C $(abs_builddir) $(RELEASE) + +## ---------------- ## +## Updating files. ## +## ---------------- ## + +ftp-gnu = https://ftp.gnu.org/gnu +www-gnu = https://www.gnu.org + +upload_dest_dir_ ?= $(PACKAGE) +upload_command = \ + $(srcdir)/$(_build-aux)/gnupload $(GNUPLOADFLAGS) \ + --to $(gnu_rel_host):$(upload_dest_dir_) \ + $(rel-files) +emit_upload_commands: + @echo ===================================== + @echo ===================================== + @echo '$(upload_command)' + @echo '# send the ~/announce-$(my_distdir) e-mail' + @echo ===================================== + @echo ===================================== + +.PHONY: upload +upload: + $(AM_V_GEN)$(upload_command) + +define emit-commit-log + printf '%s\n' 'maint: post-release administrivia' '' \ + '* NEWS: Add header line for next release.' \ + '* .prev-version: Record previous version.' \ + '* cfg.mk (old_NEWS_hash): Auto-update.' +endef + +.PHONY: no-submodule-changes +no-submodule-changes: + $(AM_V_GEN)if test -d $(srcdir)/.git \ + && git --version >/dev/null 2>&1; then \ + diff=$$(cd $(srcdir) && git submodule -q foreach \ + git diff-index --name-only HEAD) \ + || exit 1; \ + case $$diff in '') ;; \ + *) echo '$(ME): submodule files are locally modified:'; \ + echo "$$diff"; exit 1;; esac; \ + else \ + : ; \ + fi + +submodule-checks ?= no-submodule-changes public-submodule-commit + +# Ensure that each sub-module commit we're using is public. +# Without this, it is too easy to tag and release code that +# cannot be built from a fresh clone. +.PHONY: public-submodule-commit +public-submodule-commit: + $(AM_V_GEN)if test -d $(srcdir)/.git \ + && git --version >/dev/null 2>&1; then \ + cd $(srcdir) && \ + git submodule --quiet foreach \ + 'test "$$(git rev-parse "$$sha1")" \ + = "$$(git merge-base origin "$$sha1")"' \ + || { echo '$(ME): found non-public submodule commit' >&2; \ + exit 1; }; \ + else \ + : ; \ + fi +# This rule has a high enough utility/cost ratio that it should be a +# dependent of "check" by default. However, some of us do occasionally +# commit a temporary change that deliberately points to a non-public +# submodule commit, and want to be able to use rules like "make check". +# In that case, run e.g., "make check gl_public_submodule_commit=" +# to disable this test. +gl_public_submodule_commit ?= public-submodule-commit +check: $(gl_public_submodule_commit) + +.PHONY: alpha beta stable release +ALL_RECURSIVE_TARGETS += alpha beta stable +alpha beta stable: $(local-check) writable-files $(submodule-checks) + $(AM_V_GEN)test $@ = stable \ + && { echo $(VERSION) | $(GREP) -E '^[0-9]+(\.[0-9]+)+$$' \ + || { echo "invalid version string: $(VERSION)" 1>&2; exit 1;};}\ + || : + $(AM_V_at)$(MAKE) vc-diff-check + $(AM_V_at)$(MAKE) news-check + $(AM_V_at)$(MAKE) distcheck + $(AM_V_at)$(MAKE) dist + $(AM_V_at)$(MAKE) $(release-prep-hook) RELEASE_TYPE=$@ + $(AM_V_at)$(MAKE) -s emit_upload_commands RELEASE_TYPE=$@ + +release: + $(AM_V_GEN)$(MAKE) _version + $(AM_V_at)$(MAKE) $(release-type) + +# Override this in cfg.mk if you follow different procedures. +release-prep-hook ?= release-prep + +gl_noteworthy_news_ = * Noteworthy changes in release ?.? (????-??-??) [?] +.PHONY: release-prep +release-prep: + $(AM_V_GEN)$(MAKE) --no-print-directory -s announcement \ + > ~/announce-$(my_distdir) + $(AM_V_at)if test -d $(release_archive_dir); then \ + ln $(rel-files) $(release_archive_dir); \ + chmod a-w $(rel-files); \ + fi + $(AM_V_at)echo $(VERSION) > $(prev_version_file) + $(AM_V_at)$(MAKE) update-NEWS-hash + $(AM_V_at)perl -pi \ + -e '$$. == 3 and print "$(gl_noteworthy_news_)\n\n\n"' \ + $(srcdir)/NEWS + $(AM_V_at)msg=$$($(emit-commit-log)) || exit 1; \ + cd $(srcdir) && $(VC) commit -m "$$msg" -a + +# Override this with e.g., -s $(srcdir)/some_other_name.texi +# if the default $(PACKAGE)-derived name doesn't apply. +gendocs_options_ ?= + +.PHONY: web-manual +web-manual: + $(AM_V_GEN)test -z "$(manual_title)" \ + && { echo define manual_title in cfg.mk 1>&2; exit 1; } || : + $(AM_V_at)cd '$(srcdir)/doc'; \ + $(SHELL) ../$(_build-aux)/gendocs.sh $(gendocs_options_) \ + -o '$(abs_builddir)/doc/manual' \ + --email $(PACKAGE_BUGREPORT) $(PACKAGE) \ + "$(PACKAGE_NAME) - $(manual_title)" + $(AM_V_at)echo " *** Upload the doc/manual directory to web-cvs." + +.PHONY: web-manual-update +web-manual-update: + $(AM_V_GEN)cd $(srcdir) \ + && $(_build-aux)/gnu-web-doc-update -C $(abs_builddir) + + +# Code Coverage + +init-coverage: + $(MAKE) $(AM_MAKEFLAGS) clean + lcov --directory . --zerocounters + +COVERAGE_CCOPTS ?= "-g --coverage" +COVERAGE_OUT ?= doc/coverage + +build-coverage: + $(MAKE) $(AM_MAKEFLAGS) CFLAGS=$(COVERAGE_CCOPTS) CXXFLAGS=$(COVERAGE_CCOPTS) + $(MAKE) $(AM_MAKEFLAGS) CFLAGS=$(COVERAGE_CCOPTS) CXXFLAGS=$(COVERAGE_CCOPTS) check + mkdir -p $(COVERAGE_OUT) + lcov --directory . --output-file $(COVERAGE_OUT)/$(PACKAGE).info \ + --capture + +gen-coverage: + genhtml --output-directory $(COVERAGE_OUT) \ + $(COVERAGE_OUT)/$(PACKAGE).info \ + --highlight --frames --legend \ + --title "$(PACKAGE_NAME)" + +coverage: + $(MAKE) init-coverage + $(MAKE) build-coverage + $(MAKE) gen-coverage + +# Some projects carry local adjustments for gnulib modules via patches in +# a gnulib patch directory whose default name is gl/ (defined in bootstrap +# via local_gl_dir=gl). Those patches become stale as the originals evolve +# in gnulib. Use this rule to refresh any stale patches. It applies each +# patch to the original in $(gnulib_dir) and uses the temporary result to +# generate a fuzz-free .diff file. If you customize the name of your local +# gnulib patch directory via bootstrap.conf, this rule detects that name. +# Run this from a non-VPATH (i.e., srcdir) build directory. +.PHONY: refresh-gnulib-patches +refresh-gnulib-patches: + gl=gl; \ + if test -f bootstrap.conf; then \ + t=$$(perl -lne '/^\s*local_gl_dir=(\S+)/ and $$d=$$1;' \ + -e 'END{defined $$d and print $$d}' bootstrap.conf); \ + test -n "$$t" && gl=$$t; \ + fi; \ + for diff in $$(cd $$gl; git ls-files | $(GREP) '\.diff$$'); do \ + b=$$(printf %s "$$diff"|$(SED) 's/\.diff$$//'); \ + VERSION_CONTROL=none \ + patch "$(gnulib_dir)/$$b" "$$gl/$$diff" || exit 1; \ + ( cd $(gnulib_dir) || exit 1; \ + git diff "$$b" > "../$$gl/$$diff"; \ + git checkout $$b ) || exit 1; \ + done + +# Update gettext files. +PACKAGE ?= $(shell basename $(PWD)) +PO_DOMAIN ?= $(PACKAGE) +POURL = https://translationproject.org/latest/$(PO_DOMAIN)/ +PODIR ?= po +refresh-po: + rm -f $(PODIR)/*.po && \ + echo "$(ME): getting translations into po (please ignore the robots.txt ERROR 404)..." && \ + wget --no-verbose --directory-prefix $(PODIR) --no-directories --recursive --level 1 --accept .po --accept .po.1 $(POURL) && \ + echo 'en@boldquot' > $(PODIR)/LINGUAS && \ + echo 'en@quot' >> $(PODIR)/LINGUAS && \ + ls $(PODIR)/*.po | $(SED) 's/\.po//;s,$(PODIR)/,,' | \ + sort >> $(PODIR)/LINGUAS + +# Indentation + +indent_args ?= -ppi 1 +C_SOURCES ?= $$($(VC_LIST_EXCEPT) | grep '\.[ch]\(.in\)\?$$') +INDENT_SOURCES ?= $(C_SOURCES) +exclude_file_name_regexp--indent ?= $(exclude_file_name_regexp--sc_indent) + +.PHONY: indent +indent: # Running indent once is not idempotent, but running it twice is. + $(AM_V_GEN)indent $(indent_args) $(INDENT_SOURCES) && \ + indent $(indent_args) $(INDENT_SOURCES) + +sc_indent: + @if ! indent --version 2> /dev/null | grep 'GNU indent' > /dev/null; then \ + echo 1>&2 '$(ME): sc_indent: GNU indent is missing'; \ + else \ + fail=0; files="$(INDENT_SOURCES)"; \ + for f in $$files; do \ + indent $(indent_args) -st $$f \ + | indent $(indent_args) -st - \ + | diff -u $$f - || fail=1; \ + done; \ + test $$fail = 1 && \ + { echo 1>&2 '$(ME): code format error, try "make indent"'; \ + exit 1; } || :; \ + fi + +# If you want to set UPDATE_COPYRIGHT_* environment variables, +# put the assignments in this variable. +update-copyright-env ?= + +# Run this rule once per year (usually early in January) +# to update all FSF copyright year lists in your project. +# If you have an additional project-specific rule, +# add it in cfg.mk along with a line 'update-copyright: prereq'. +# By default, exclude all variants of COPYING; you can also +# add exemptions (such as ChangeLog..* for rotated change logs) +# in the file .x-update-copyright. +.PHONY: update-copyright +update-copyright: + $(AM_V_GEN)$(GREP) -l -w Copyright \ + $$(export VC_LIST_EXCEPT_DEFAULT=COPYING && $(VC_LIST_EXCEPT)) \ + | $(update-copyright-env) xargs $(srcdir)/$(_build-aux)/$@ + +# This tight_scope test is skipped with a warning if $(_gl_TS_headers) is not +# overridden and $(_gl_TS_dir)/Makefile.am does not mention noinst_HEADERS. + +# NOTE: to override any _gl_TS_* default value, you must +# define the variable(s) using "export" in cfg.mk. +_gl_TS_dir ?= src + +ALL_RECURSIVE_TARGETS += sc_tight_scope +sc_tight_scope: tight-scope.mk + @fail=0; \ + if ! $(GREP) '^ *export _gl_TS_headers *=' $(srcdir)/cfg.mk \ + > /dev/null \ + && ! $(GREP) -w noinst_HEADERS $(srcdir)/$(_gl_TS_dir)/Makefile.am \ + > /dev/null 2>&1; then \ + echo '$(ME): skipping $@'; \ + else \ + $(MAKE) -s -C $(_gl_TS_dir) \ + -f Makefile \ + -f $(abs_top_srcdir)/cfg.mk \ + -f $(abs_top_builddir)/$< \ + _gl_tight_scope \ + || fail=1; \ + fi; \ + rm -f $<; \ + exit $$fail + +tight-scope.mk: $(ME) + @perl -ne '/^# TS-start/.../^# TS-end/ and print' $(srcdir)/$(ME) > $@-t + @mv $@-t $@ + +ifeq (a,b) +# TS-start + +# Most functions should have static scope. +# Any that don't must be marked with 'extern', but 'main' +# and 'usage' are exceptions: they're always extern, but +# do not need to be marked. Symbols matching '__.*' are +# reserved by the compiler, so are automatically excluded below. +_gl_TS_unmarked_extern_functions ?= main usage +_gl_TS_function_match ?= /^(?:$(_gl_TS_extern)) +.*?(\w+) *\(/ + +# If your project uses a macro like "XTERN", then put +# the following in cfg.mk to override this default: +# export _gl_TS_extern = extern|XTERN +_gl_TS_extern ?= extern + +# The second nm|grep checks for file-scope variables with 'extern' scope. +# Without gnulib's progname module, you might put program_name here. +# Symbols matching '__.*' are reserved by the compiler, +# so are automatically excluded below. +_gl_TS_unmarked_extern_vars ?= + +# NOTE: the _match variables are perl expressions -- not mere regular +# expressions -- so that you can extend them to match other patterns +# and easily extract matched variable names. +# For example, if your project declares some global variables via +# a macro like this: GLOBAL(type, var_name, initializer), then you +# can override this definition to automatically extract those names: +# export _gl_TS_var_match = \ +# /^(?:$(_gl_TS_extern)) .*?\**(\w+)(\[.*?])?;/ || /\bGLOBAL\(.*?,\s*(.*?),/ +_gl_TS_var_match ?= /^(?:$(_gl_TS_extern)) .*?(\w+)(\[.*?])?;/ + +# The names of object files in (or relative to) $(_gl_TS_dir). +_gl_TS_obj_files ?= *.$(OBJEXT) + +# Files in which to search for the one-line style extern declarations. +# $(_gl_TS_dir)-relative. +_gl_TS_headers ?= $(noinst_HEADERS) +_gl_TS_other_headers ?= *.h + +.PHONY: _gl_tight_scope +_gl_tight_scope: $(bin_PROGRAMS) + sed_wrap='s/^/^_?/;s/$$/$$/'; \ + t=exceptions-$$$$; \ + trap 's=$$?; rm -f $$t; exit $$s' 0; \ + for sig in 1 2 3 13 15; do \ + eval "trap 'v=`expr $$sig + 128`; (exit $$v); exit $$v' $$sig"; \ + done; \ + src=`for f in $(SOURCES); do \ + test -f $$f && d= || d=$(srcdir)/; echo $$d$$f; done`; \ + hdr=`for f in $(_gl_TS_headers); do \ + test -f $$f && d= || d=$(srcdir)/; echo $$d$$f; done`; \ + ( printf '%s\n' '__.*' $(_gl_TS_unmarked_extern_functions); \ + $(GREP) -h -A1 '^extern .*[^;]$$' $$src \ + | $(GREP) -vE '^(extern |--|#)' | $(SED) 's/ .*//; /^$$/d'; \ + perl -lne \ + '$(_gl_TS_function_match) and print $$1' $$hdr; \ + ) | sort -u | $(SED) "$$sed_wrap" > $$t; \ + nm -g $(_gl_TS_obj_files)|$(SED) -n 's/.* T //p'|$(GREP) -Ev -f $$t \ + && { echo the above functions should have static scope >&2; \ + exit 1; } || : ; \ + ( printf '%s\n' '__.*' main $(_gl_TS_unmarked_extern_vars); \ + perl -lne '$(_gl_TS_var_match) and print $$1' \ + $$hdr $(_gl_TS_other_headers) \ + ) | sort -u | $(SED) "$$sed_wrap" > $$t; \ + nm -g $(_gl_TS_obj_files) | $(SED) -n 's/.* [BCDGRS] //p' \ + | sort -u | $(GREP) -Ev -f $$t \ + && { echo the above variables should have static scope >&2; \ + exit 1; } || : +# TS-end +endif diff --git a/gnulib-tool-tests/import-tests/test-diffutils-1.sh b/gnulib-tool-tests/import-tests/test-diffutils-1.sh new file mode 100755 index 00000000..6147cac8 --- /dev/null +++ b/gnulib-tool-tests/import-tests/test-diffutils-1.sh @@ -0,0 +1,124 @@ +#!/bin/sh +. ../init.sh +# This tests a hairy case: A file, gnulib-tests/nan.h, that previously came +# from gnulib/tests/ and now comes from gnulib/lib/. It should not be shown +# as a removed and added file, but rather as a changed file, with no effect +# on gnulib-tests/.gitignore. +do_import_test diffutils-20230801 . "`echo ' + --import + --local-dir=gl + --lib=libdiffutils + --source-base=lib + --m4-base=m4 + --doc-base=doc + --tests-base=gnulib-tests + --aux-dir=build-aux + --with-tests + --makefile-name=gnulib.mk + --no-conditional-dependencies + --no-libtool + --macro-prefix=gl + --avoid=localename + --avoid=lock-tests + --avoid=setlocale + announce-gen + argmatch + assert-h + attribute + binary-io + builtin-expect + c-ctype + c-stack + c32isspace + c32tolower + c32width + careadlinkat + config-h + count-leading-zeros + diffseq + dirname + do-release-commit-and-tag + dup2 + error + exclude + exitfail + extensions + extern-inline + fcntl + fdopendir + file-type + filenamecat + flexmember + fnmatch-gnu + fstatat + getopt-gnu + gettext-h + git-version-gen + gitlog-to-changelog + gnu-make + gnu-web-doc-update + gnumakefile + gnupload + hard-locale + ialloc + idx + intprops + inttypes + isblank + largefile + lstat + maintainer-makefile + manywarnings + mbrtoc32 + mempcpy + minmax + mkstemp + mktime + nstrftime + nullptr + openat + pclose + perl + popen + progname + propername-lite + raise + rawmemchr + readdir + readlinkat + readme-release + regex + same-inode + sh-quote + sigaction + signal + sigprocmask + stat + stat-macros + stat-time + stdbool + stdckdint + stdint + stpcpy + strcase + strptime + strtoimax + sys_wait + system-quote + time_rz + timespec + timespec_get + unistd + unlocked-io + update-copyright + verify + version-etc + version-etc-fsf + xalloc + xfreopen + xmalloca + xstdopen + xstrtoimax + year2038 + +'`" -- 2.39.5